Spaces:
Running
on
Zero
Running
on
Zero
tori29umai
commited on
Commit
•
967d328
1
Parent(s):
65d41ac
app.py
Browse files
app.py
CHANGED
@@ -36,10 +36,9 @@ def load_model(lora_dir, cn_dir):
|
|
36 |
pipe = StableDiffusionXLControlNetImg2ImgPipeline.from_pretrained(
|
37 |
"cagliostrolab/animagine-xl-3.1", controlnet=controlnet, vae=vae, torch_dtype=torch.float16
|
38 |
)
|
|
|
39 |
pipe.load_lora_weights(lora_dir, weight_name="normalmap.safetensors")
|
40 |
-
pipe
|
41 |
-
pipe.fuse_lora()
|
42 |
-
pipe = pipe.to(device)
|
43 |
return pipe
|
44 |
|
45 |
|
@@ -48,7 +47,8 @@ def predict(input_image_path, prompt, negative_prompt, controlnet_scale):
|
|
48 |
pipe = load_model(lora_dir, cn_dir)
|
49 |
input_image = Image.open(input_image_path)
|
50 |
base_image = base_generation(input_image.size, (150, 110, 255, 255)).convert("RGB")
|
51 |
-
resize_image = resize_image_aspect_ratio(
|
|
|
52 |
generator = torch.manual_seed(0)
|
53 |
last_time = time.time()
|
54 |
prompt = "masterpiece, best quality, normal map, purple background, " + prompt
|
@@ -59,7 +59,7 @@ def predict(input_image_path, prompt, negative_prompt, controlnet_scale):
|
|
59 |
print(prompt)
|
60 |
|
61 |
output_image = pipe(
|
62 |
-
image=
|
63 |
control_image=resize_image,
|
64 |
strength=1.0,
|
65 |
prompt=prompt,
|
|
|
36 |
pipe = StableDiffusionXLControlNetImg2ImgPipeline.from_pretrained(
|
37 |
"cagliostrolab/animagine-xl-3.1", controlnet=controlnet, vae=vae, torch_dtype=torch.float16
|
38 |
)
|
39 |
+
pipe.enable_model_cpu_offload()
|
40 |
pipe.load_lora_weights(lora_dir, weight_name="normalmap.safetensors")
|
41 |
+
# pipe = pipe.to(device)
|
|
|
|
|
42 |
return pipe
|
43 |
|
44 |
|
|
|
47 |
pipe = load_model(lora_dir, cn_dir)
|
48 |
input_image = Image.open(input_image_path)
|
49 |
base_image = base_generation(input_image.size, (150, 110, 255, 255)).convert("RGB")
|
50 |
+
resize_image = resize_image_aspect_ratio(input_image)
|
51 |
+
resize_base_image = resize_image_aspect_ratio(base_image)
|
52 |
generator = torch.manual_seed(0)
|
53 |
last_time = time.time()
|
54 |
prompt = "masterpiece, best quality, normal map, purple background, " + prompt
|
|
|
59 |
print(prompt)
|
60 |
|
61 |
output_image = pipe(
|
62 |
+
image=resize_base_image,
|
63 |
control_image=resize_image,
|
64 |
strength=1.0,
|
65 |
prompt=prompt,
|