File size: 952 Bytes
9a87834
 
 
 
 
 
 
 
 
 
 
 
 
4dc9e2b
9a87834
 
 
4dc9e2b
9a87834
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""https://pypi.org/project/diffusers/.

!pip install git+https://github.com/patil-suraj/transformers@ldm-bert
!git clone https://github.com/huggingface/diffusers
!cd diffusers && pip install -e .
!pip install git+file:///content/diffusers
!pip install torch

https://github.com/CompVis/latent-diffusion/blob/main/scripts/txt2img.py

https://medium.com/tag/diffusion-models

 !pip install einops

"""
from diffusers import DiffusionPipeline

ldm = DiffusionPipeline.from_pretrained("fu sing/latent-diffusion-text2im-large")

generator = torch.manual_seed(42)

prompt = "A painting of a squirrel eating a burger"
image = ldm([prompt], generator=generator, eta=0.3, guidance_scale=6.0, num_inference_steps=50)

image_processed = image.cpu().permute(0, 2, 3, 1)
image_processed = image_processed  * 255.
image_processed = image_processed.numpy().astype(np.uint8)
image_pil = PIL.Image.fromarray(image_processed[0])

# save image
image_pil.save("test.png")