Commit
•
df3b621
1
Parent(s):
819a296
up
Browse files- run_local_img2img_xl.py +8 -9
run_local_img2img_xl.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
#!/usr/bin/env python3
|
2 |
from diffusers import DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionPipeline, KDPM2DiscreteScheduler, StableDiffusionImg2ImgPipeline, HeunDiscreteScheduler, KDPM2AncestralDiscreteScheduler, DDIMScheduler, StableDiffusionXLImg2ImgPipeline
|
3 |
import time
|
|
|
4 |
import os
|
5 |
from huggingface_hub import HfApi
|
6 |
# from compel import Compel
|
@@ -15,7 +16,7 @@ path = sys.argv[1]
|
|
15 |
|
16 |
api = HfApi()
|
17 |
start_time = time.time()
|
18 |
-
pipe = StableDiffusionXLImg2ImgPipeline.from_pretrained(path
|
19 |
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config)
|
20 |
# pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config)
|
21 |
# pipe = StableDiffusionImg2ImgXLPipeline.from_pretrained(path, torch_dtype=torch.float16, safety_checker=None
|
@@ -23,20 +24,18 @@ pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config)
|
|
23 |
# compel = Compel(tokenizer=pipe.tokenizer, text_encoder=pipe.text_encoder)
|
24 |
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
prompt = "A red castle on a beautiful landscape with a nice sunset"
|
29 |
|
30 |
|
31 |
# pipe.unet.to(memory_format=torch.channels_last)
|
32 |
# pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
|
33 |
# pipe(prompt=prompt, num_inference_steps=2).images[0]
|
34 |
-
url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"
|
35 |
-
|
36 |
-
response = requests.get(url)
|
37 |
-
init_image =
|
38 |
|
39 |
-
image = pipe(prompt=prompt, image=init_image
|
40 |
|
41 |
file_name = f"aaa"
|
42 |
path = os.path.join(Path.home(), "images", f"{file_name}.png")
|
|
|
1 |
#!/usr/bin/env python3
|
2 |
from diffusers import DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionPipeline, KDPM2DiscreteScheduler, StableDiffusionImg2ImgPipeline, HeunDiscreteScheduler, KDPM2AncestralDiscreteScheduler, DDIMScheduler, StableDiffusionXLImg2ImgPipeline
|
3 |
import time
|
4 |
+
import numpy as np
|
5 |
import os
|
6 |
from huggingface_hub import HfApi
|
7 |
# from compel import Compel
|
|
|
16 |
|
17 |
api = HfApi()
|
18 |
start_time = time.time()
|
19 |
+
pipe = StableDiffusionXLImg2ImgPipeline.from_pretrained(path)
|
20 |
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config)
|
21 |
# pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config)
|
22 |
# pipe = StableDiffusionImg2ImgXLPipeline.from_pretrained(path, torch_dtype=torch.float16, safety_checker=None
|
|
|
24 |
# compel = Compel(tokenizer=pipe.tokenizer, text_encoder=pipe.text_encoder)
|
25 |
|
26 |
|
27 |
+
prompt = "An astronaut riding a green horse on Mars"
|
|
|
|
|
28 |
|
29 |
|
30 |
# pipe.unet.to(memory_format=torch.channels_last)
|
31 |
# pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
|
32 |
# pipe(prompt=prompt, num_inference_steps=2).images[0]
|
33 |
+
# url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"
|
34 |
+
#
|
35 |
+
# response = requests.get(url)
|
36 |
+
init_image = torch.from_numpy(np.load("/home/patrick/images/xl_latents.npy"))
|
37 |
|
38 |
+
image = pipe(prompt=prompt, image=init_image).images[0]
|
39 |
|
40 |
file_name = f"aaa"
|
41 |
path = os.path.join(Path.home(), "images", f"{file_name}.png")
|