Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,44 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
---
|
| 4 |
+
|
| 5 |
+
GLIDE: Towards Photorealistic Image Generation and Editing with Text-Guided Diffusion Models
|
| 6 |
+
|
| 7 |
+
**Paper**: [GLIDE: Towards Photorealistic Image Generation and Editing with Text-Guided Diffusion Models](https://arxiv.org/abs/2112.10741)
|
| 8 |
+
|
| 9 |
+
**Abstract**:
|
| 10 |
+
|
| 11 |
+
*Diffusion models have recently been shown to generate high-quality synthetic images, especially when paired with a guidance technique to trade off diversity for fidelity. We explore diffusion models for the problem of text-conditional image synthesis and compare two different guidance strategies: CLIP guidance and classifier-free guidance. We find that the latter is preferred by human evaluators for both photorealism and caption similarity, and often produces photorealistic samples. Samples from a 3.5 billion parameter text-conditional diffusion model using classifier-free guidance are favored by human evaluators to those from DALL-E, even when the latter uses expensive CLIP reranking. Additionally, we find that our models can be fine-tuned to perform image inpainting, enabling powerful text-driven image editing.*
|
| 12 |
+
|
| 13 |
+
## Usage
|
| 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 |
+
ddpm = DiffusionPipeline.from_pretrained(model_id)
|
| 25 |
+
|
| 26 |
+
# run pipeline in inference (sample random noise and denoise)
|
| 27 |
+
image = ddpm(eta=0.0, num_inference_steps=50)
|
| 28 |
+
|
| 29 |
+
# process image to PIL
|
| 30 |
+
image_processed = image.cpu().permute(0, 2, 3, 1)
|
| 31 |
+
image_processed = (image_processed + 1.0) * 127.5
|
| 32 |
+
image_processed = image_processed.numpy().astype(np.uint8)
|
| 33 |
+
image_pil = PIL.Image.fromarray(image_processed[0])
|
| 34 |
+
|
| 35 |
+
# save image
|
| 36 |
+
image_pil.save("test.png")
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
## Samples
|
| 40 |
+
|
| 41 |
+
1. 
|
| 42 |
+
2. 
|
| 43 |
+
3. 
|
| 44 |
+
4. 
|