"projects/TR3D/tr3d/axis_aligned_iou_loss.py" did not exist on "53435c629d507633aa9a380674c863ba2316e690"
run_glide.py 546 Bytes
Newer Older
anton-l's avatar
anton-l committed
1
import torch
anton-l's avatar
anton-l committed
2
3
from diffusers import DiffusionPipeline
import PIL.Image
anton-l's avatar
Style  
anton-l committed
4

anton-l's avatar
anton-l committed
5
6
7
generator = torch.Generator()
generator = generator.manual_seed(0)

anton-l's avatar
anton-l committed
8
9
10
11
12
13
14
model_id = "fusing/glide-base"

# load model and scheduler
pipeline = DiffusionPipeline.from_pretrained(model_id)

# run inference (text-conditioned denoising + upscaling)
img = pipeline("a clip art of a hugging face", generator)
anton-l's avatar
anton-l committed
15

anton-l's avatar
anton-l committed
16
# process image to PIL
anton-l's avatar
anton-l committed
17
img = ((img + 1)*127.5).round().clamp(0, 255).to(torch.uint8).cpu().numpy()
anton-l's avatar
anton-l committed
18
image_pil = PIL.Image.fromarray(img)
anton-l's avatar
anton-l committed
19

anton-l's avatar
anton-l committed
20
21
# save image
image_pil.save("test.png")