Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -178,24 +178,26 @@ def infer(image, width, height, overlap_percentage, num_inference_steps, resize_
|
|
178 |
cnet_image = background.copy()
|
179 |
cnet_image.paste(0, (0, 0), mask)
|
180 |
|
181 |
-
final_prompt = f"{prompt_input} , high quality, 4k"
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
|
|
|
|
199 |
|
200 |
image = image.convert("RGBA")
|
201 |
cnet_image.paste(image, (0, 0), mask)
|
@@ -249,7 +251,17 @@ css = """
|
|
249 |
}
|
250 |
"""
|
251 |
|
252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
|
254 |
with gr.Blocks(css=css) as demo:
|
255 |
with gr.Column():
|
|
|
178 |
cnet_image = background.copy()
|
179 |
cnet_image.paste(0, (0, 0), mask)
|
180 |
|
181 |
+
final_prompt = f"{prompt_input} , high quality, 4k" if prompt_input else "high quality, 4k"
|
182 |
+
|
183 |
+
# Use with torch.autocast to ensure consistent dtype
|
184 |
+
with torch.autocast(device_type="cuda", dtype=torch.float16):
|
185 |
+
(
|
186 |
+
prompt_embeds,
|
187 |
+
negative_prompt_embeds,
|
188 |
+
pooled_prompt_embeds,
|
189 |
+
negative_pooled_prompt_embeds,
|
190 |
+
) = pipe.encode_prompt(final_prompt, "cuda", True)
|
191 |
+
|
192 |
+
for image in pipe(
|
193 |
+
prompt_embeds=prompt_embeds,
|
194 |
+
negative_prompt_embeds=negative_prompt_embeds,
|
195 |
+
pooled_prompt_embeds=pooled_prompt_embeds,
|
196 |
+
negative_pooled_prompt_embeds=negative_pooled_prompt_embeds,
|
197 |
+
image=cnet_image,
|
198 |
+
num_inference_steps=num_inference_steps
|
199 |
+
):
|
200 |
+
yield cnet_image, image
|
201 |
|
202 |
image = image.convert("RGBA")
|
203 |
cnet_image.paste(image, (0, 0), mask)
|
|
|
251 |
}
|
252 |
"""
|
253 |
|
254 |
+
# Define the title HTML string
|
255 |
+
title = """<h1 align="center">Diffusers Image Outpaint</h1>
|
256 |
+
<div align="center">Drop an image you would like to extend, pick your expected ratio and hit Generate.</div>
|
257 |
+
<div style="display: flex; justify-content: center; align-items: center; text-align: center;">
|
258 |
+
<p style="display: flex;gap: 6px;">
|
259 |
+
<a href="https://github.com/huggingface/diffusers">
|
260 |
+
Built with Diffusers
|
261 |
+
</a>
|
262 |
+
</p>
|
263 |
+
</div>
|
264 |
+
"""
|
265 |
|
266 |
with gr.Blocks(css=css) as demo:
|
267 |
with gr.Column():
|