--- license: apache-2.0 --- GLIDE: Towards Photorealistic Image Generation and Editing with Text-Guided Diffusion Models **Paper**: [GLIDE: Towards Photorealistic Image Generation and Editing with Text-Guided Diffusion Models](https://arxiv.org/abs/2112.10741) **Abstract**: *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.* ## Usage ```python # !pip install diffusers from diffusers import DiffusionPipeline import PIL.Image import numpy as np model_id = "fusing/glide-base" # load model and scheduler ddpm = DiffusionPipeline.from_pretrained(model_id) # run pipeline in inference (sample random noise and denoise) image = ddpm(eta=0.0, num_inference_steps=50) # process image to PIL image_processed = image.cpu().permute(0, 2, 3, 1) image_processed = (image_processed + 1.0) * 127.5 image_processed = image_processed.numpy().astype(np.uint8) image_pil = PIL.Image.fromarray(image_processed[0]) # save image image_pil.save("test.png") ``` ## Samples 1. ![sample_1](https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/hf/ddim-lsun-bedroom/image_0.png) 2. ![sample_1](https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/hf/ddim-lsun-bedroom/image_1.png) 3. ![sample_1](https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/hf/ddim-lsun-bedroom/image_2.png) 4. ![sample_1](https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/hf/ddim-lsun-bedroom/image_3.png)