up
Browse files
README.md
CHANGED
@@ -1,16 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Dummy diffusion model following architecture of https://github.com/lucidrains/denoising-diffusion-pytorch
|
2 |
|
3 |
Run the model as follows:
|
4 |
|
5 |
```python
|
6 |
-
from diffusers import UNetModel
|
7 |
import torch
|
8 |
|
9 |
-
|
|
|
10 |
|
|
|
11 |
batch_size, num_channels, height, width = 1, 3, 32, 32
|
12 |
dummy_noise = torch.ones((batch_size, num_channels, height, width))
|
13 |
time_step = torch.tensor([10])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
-
image
|
16 |
```
|
|
|
1 |
+
---
|
2 |
+
tags:
|
3 |
+
- hf_diffuse
|
4 |
+
---
|
5 |
+
|
6 |
# Dummy diffusion model following architecture of https://github.com/lucidrains/denoising-diffusion-pytorch
|
7 |
|
8 |
Run the model as follows:
|
9 |
|
10 |
```python
|
11 |
+
from diffusers import UNetModel, GaussianDiffusion
|
12 |
import torch
|
13 |
|
14 |
+
# 1. Load model
|
15 |
+
unet = UNetModel.from_pretrained("fusing/ddpm_dummy")
|
16 |
|
17 |
+
# 2. Do one denoising step with model
|
18 |
batch_size, num_channels, height, width = 1, 3, 32, 32
|
19 |
dummy_noise = torch.ones((batch_size, num_channels, height, width))
|
20 |
time_step = torch.tensor([10])
|
21 |
+
image = unet(dummy_noise, time_step)
|
22 |
+
|
23 |
+
# 3. Load sampler
|
24 |
+
sampler = GaussianDiffusion.from_config("fusing/ddpm_dummy")
|
25 |
+
|
26 |
+
# 4. Sample image from sampler passing the model
|
27 |
+
image = sampler.sample(model, batch_size=1)
|
28 |
|
29 |
+
print(image)
|
30 |
```
|