patrickvonplaten commited on
Commit
daaf23e
1 Parent(s): b795ca9
Files changed (2) hide show
  1. fantasy_landscape.png +2 -2
  2. run.py +6 -4
fantasy_landscape.png CHANGED

Git LFS Details

  • SHA256: aeb3ba81e1cce0d705f0e88de9552f2c1c81ff83e93bd2736783a99e220a63af
  • Pointer size: 131 Bytes
  • Size of remote file: 856 kB

Git LFS Details

  • SHA256: 2a71399a219086f294f19e1a6547b272ba055b48309fe03566e28952c5b26855
  • Pointer size: 131 Bytes
  • Size of remote file: 797 kB
run.py CHANGED
@@ -2,12 +2,13 @@ import requests
2
  import torch
3
  from PIL import Image
4
  from io import BytesIO
 
5
 
6
- from diffusers import StableUnCLIPImg2ImgPipeline
7
 
8
- pipe = StableUnCLIPImg2ImgPipeline.from_pretrained("/home/patrick_huggingface_co/stable-diffusion-2-1-unclip", torch_dtype=torch.float16
9
- ) # TODO update model path
10
- pipe = pipe.to("cuda")
11
 
12
  url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"
13
 
@@ -18,4 +19,5 @@ init_image = init_image.resize((768, 512))
18
  prompt = "A fantasy landscape, trending on artstation"
19
 
20
  images = pipe(prompt, init_image).images
 
21
  images[0].save("fantasy_landscape.png")
 
2
  import torch
3
  from PIL import Image
4
  from io import BytesIO
5
+ import time
6
 
7
+ from diffusers import DiffusionPipeline
8
 
9
+ start_time = time.time()
10
+ pipe = DiffusionPipeline.from_pretrained("/home/patrick_huggingface_co/stable-diffusion-2-1-unclip", torch_dtype=torch.float16, variant="fp16")
11
+ pipe.enable_model_cpu_offload()
12
 
13
  url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"
14
 
 
19
  prompt = "A fantasy landscape, trending on artstation"
20
 
21
  images = pipe(prompt, init_image).images
22
+ print(time.time() - start_time)
23
  images[0].save("fantasy_landscape.png")