johnowhitaker
commited on
Commit
•
d61aae5
1
Parent(s):
9e38d8f
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: creativeml-openrail-m
|
3 |
+
tags:
|
4 |
+
- stable-diffusion
|
5 |
+
- stable-diffusion-diffusers
|
6 |
+
- text-to-image
|
7 |
+
- multires_noise
|
8 |
+
inference: true
|
9 |
+
---
|
10 |
+
|
11 |
+
|
12 |
+
A model trained with Pyramid Noise - see https://wandb.ai/johnowhitaker/multires_noise/reports/Multi-Resolution-Noise-for-Diffusion-Model-Training--VmlldzozNjYyOTU2 for details
|
13 |
+
|
14 |
+
```python
|
15 |
+
from torch import nn
|
16 |
+
import random
|
17 |
+
|
18 |
+
def pyramid_noise_like(x, discount=0.8):
|
19 |
+
b, c, w, h = x.shape
|
20 |
+
u = nn.Upsample(size=(w, h), mode='bilinear')
|
21 |
+
noise = torch.randn_like(x)
|
22 |
+
for i in range(6):
|
23 |
+
r = random.random()*2+2 # Rather than always going 2x,
|
24 |
+
w, h = max(1, int(w/(r**i))), max(1, int(h/(r**i)))
|
25 |
+
noise += u(torch.randn(b, c, w, h).to(x)) * discount**i
|
26 |
+
if w==1 or h==1: break
|
27 |
+
return noise / noise.std() # Scale back to unit variance
|
28 |
+
```
|
29 |
+
|
30 |
+
To use the mode for inference, just load it like a normal stable diffusion pipeline:
|
31 |
+
|
32 |
+
```python
|
33 |
+
from diffusers import StableDiffusionPipeline
|
34 |
+
|
35 |
+
model_path = "johnowhitaker/pyramid_noise_test_600steps_08discount"
|
36 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_path, torch_dtype=torch.float16)
|
37 |
+
pipe.to("cuda")
|
38 |
+
|
39 |
+
image = pipe(prompt="A black image").images[0]
|
40 |
+
image
|
41 |
+
```
|