anton-l HF staff commited on
Commit
1d0d7c6
·
1 Parent(s): 0f49cfb

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +10 -12
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
- 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")
@@ -38,7 +37,6 @@ image_pil.save("test.png")
38
 
39
  ## Samples
40
 
41
- 1. ![sample_1](https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/hf/ddim-lsun-bedroom/image_0.png)
42
- 2. ![sample_1](https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/hf/ddim-lsun-bedroom/image_1.png)
43
- 3. ![sample_1](https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/hf/ddim-lsun-bedroom/image_2.png)
44
- 4. ![sample_1](https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/hf/ddim-lsun-bedroom/image_3.png)
 
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. ![sample_1](https://huggingface.co/datasets/anton-l/images/resolve/main/glide1.png)
41
+ 2. ![sample_2](https://huggingface.co/datasets/anton-l/images/resolve/main/glide2.png)
42
+ 3. ![sample_3](https://huggingface.co/datasets/anton-l/images/resolve/main/glide3.png)