Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -85,12 +85,9 @@ def generate(
|
|
85 |
init_image = Image.open(BytesIO(response.content)).convert("RGB")
|
86 |
init_image = init_image.resize((width, height))
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
response = requests.get(mask_url)
|
92 |
-
mask_image = Image.open(BytesIO(response.content)).convert("RGB")
|
93 |
-
|
94 |
if use_lora:
|
95 |
pipe.load_lora_weights(lora)
|
96 |
pipe.fuse_lora(lora_scale)
|
@@ -127,6 +124,35 @@ def generate(
|
|
127 |
generator=generator,
|
128 |
).images[0]
|
129 |
return image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
with gr.Blocks(theme=gr.themes.Soft(), css="style.css") as demo:
|
132 |
gr.HTML(
|
|
|
85 |
init_image = Image.open(BytesIO(response.content)).convert("RGB")
|
86 |
init_image = init_image.resize((width, height))
|
87 |
|
88 |
+
image_init = load_image(img_url)
|
89 |
+
mask_image = load_image(mask_url)
|
90 |
+
|
|
|
|
|
|
|
91 |
if use_lora:
|
92 |
pipe.load_lora_weights(lora)
|
93 |
pipe.fuse_lora(lora_scale)
|
|
|
124 |
generator=generator,
|
125 |
).images[0]
|
126 |
return image
|
127 |
+
elif use_img2img:
|
128 |
+
images = pipe(
|
129 |
+
prompt=prompt,
|
130 |
+
image=init_image,
|
131 |
+
strength=strength_img2img,
|
132 |
+
negative_prompt=negative_prompt,
|
133 |
+
prompt_2=prompt_2,
|
134 |
+
negative_prompt_2=negative_prompt_2,
|
135 |
+
width=width,
|
136 |
+
height=height,
|
137 |
+
guidance_scale=guidance_scale_base,
|
138 |
+
num_inference_steps=num_inference_steps_base,
|
139 |
+
generator=generator,
|
140 |
+
output_type="pil",
|
141 |
+
).images[0]
|
142 |
+
return images
|
143 |
+
else:
|
144 |
+
return pipe(
|
145 |
+
prompt=prompt,
|
146 |
+
negative_prompt=negative_prompt,
|
147 |
+
prompt_2=prompt_2,
|
148 |
+
negative_prompt_2=negative_prompt_2,
|
149 |
+
width=width,
|
150 |
+
height=height,
|
151 |
+
guidance_scale=guidance_scale_base,
|
152 |
+
num_inference_steps=num_inference_steps_base,
|
153 |
+
generator=generator,
|
154 |
+
output_type="pil",
|
155 |
+
).images[0]
|
156 |
|
157 |
with gr.Blocks(theme=gr.themes.Soft(), css="style.css") as demo:
|
158 |
gr.HTML(
|