Update README.md
Browse files
README.md
CHANGED
|
@@ -14,23 +14,22 @@ license: apache-2.0
|
|
| 14 |
|
| 15 |
```python
|
| 16 |
# !pip install diffusers
|
|
|
|
| 17 |
from diffusers import DiffusionPipeline
|
| 18 |
import PIL.Image
|
| 19 |
-
import numpy as np
|
| 20 |
|
| 21 |
model_id = "fusing/glide-base"
|
| 22 |
|
| 23 |
# load model and scheduler
|
| 24 |
-
|
| 25 |
|
| 26 |
-
# run
|
| 27 |
-
|
| 28 |
|
| 29 |
# process image to PIL
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
image_pil = PIL.Image.fromarray(image_processed[0])
|
| 34 |
|
| 35 |
# save image
|
| 36 |
image_pil.save("test.png")
|
|
@@ -38,7 +37,6 @@ image_pil.save("test.png")
|
|
| 38 |
|
| 39 |
## Samples
|
| 40 |
|
| 41 |
-
1. 
|
|
|
|
| 14 |
|
| 15 |
```python
|
| 16 |
# !pip install diffusers
|
| 17 |
+
import torch
|
| 18 |
from diffusers import DiffusionPipeline
|
| 19 |
import PIL.Image
|
|
|
|
| 20 |
|
| 21 |
model_id = "fusing/glide-base"
|
| 22 |
|
| 23 |
# load model and scheduler
|
| 24 |
+
pipeline = DiffusionPipeline.from_pretrained(model_id)
|
| 25 |
|
| 26 |
+
# run inference (text-conditioned denoising + upscaling)
|
| 27 |
+
img = pipeline("a corgi wearing a red bowtie and a purple party hat")
|
| 28 |
|
| 29 |
# process image to PIL
|
| 30 |
+
img = img.squeeze(0)
|
| 31 |
+
img = ((img + 1)*127.5).round().clamp(0, 255).to(torch.uint8).cpu().numpy()
|
| 32 |
+
image_pil = PIL.Image.fromarray(img)
|
|
|
|
| 33 |
|
| 34 |
# save image
|
| 35 |
image_pil.save("test.png")
|
|
|
|
| 37 |
|
| 38 |
## Samples
|
| 39 |
|
| 40 |
+
1. 
|
| 41 |
+
2. 
|
| 42 |
+
3. 
|
|
|