Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -285,9 +285,24 @@ def call(
|
|
285 |
|
286 |
return StableDiffusionXLPipelineOutput(images=image)
|
287 |
|
288 |
-
|
|
|
|
|
289 |
generator = [torch.Generator(device="cuda").manual_seed(5)]
|
290 |
-
res = call(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
image1 = res.images[0]
|
292 |
image2 = ImageOps.exif_transpose(image1.rotate(180, resample=0))
|
293 |
return image1, image2
|
@@ -295,25 +310,27 @@ def simple_call(prompt1, prompt2, guidance_scale1, guidance_scale2, negative_pro
|
|
295 |
with gr.Blocks() as app:
|
296 |
gr.Markdown(
|
297 |
'''
|
298 |
-
<center
|
299 |
-
|
|
|
|
|
300 |
</center>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
'''
|
302 |
)
|
|
|
303 |
|
304 |
with gr.Row():
|
305 |
with gr.Column():
|
306 |
prompt1 = gr.Textbox(label="Prompt 1")
|
307 |
prompt2 = gr.Textbox(label="Prompt 2")
|
308 |
-
negative_prompt1 = gr.Textbox(label="Negative Prompt 1")
|
309 |
-
negative_prompt2 = gr.Textbox(label="Negative Prompt 2")
|
310 |
-
guidance_scale1 = gr.Slider(minimum=0, maximum=10, step=0.1, label="Guidance Scale 1")
|
311 |
-
guidance_scale2 = gr.Slider(minimum=0, maximum=10, step=0.1, label="Guidance Scale 2")
|
312 |
run_btn = gr.Button("Run")
|
313 |
-
|
314 |
-
with gr.Accordion(label="Advanced Options", open=False):
|
315 |
-
# You can place additional sliders or options here
|
316 |
-
pass
|
317 |
|
318 |
with gr.Column():
|
319 |
result_image1 = gr.Image(label="Output 1")
|
@@ -321,11 +338,11 @@ with gr.Blocks() as app:
|
|
321 |
|
322 |
run_btn.click(
|
323 |
simple_call,
|
324 |
-
inputs=[prompt1, prompt2
|
325 |
outputs=[result_image1, result_image2]
|
326 |
)
|
327 |
|
328 |
app.queue(max_size=20)
|
329 |
|
330 |
if __name__ == "__main__":
|
331 |
-
app.launch(debug=True)
|
|
|
285 |
|
286 |
return StableDiffusionXLPipelineOutput(images=image)
|
287 |
|
288 |
+
NEGATIVE_PROMPTS = "text, watermark, low-quality, signature, moiré pattern, downsampling, aliasing, distorted, blurry, glossy, blur, jpeg artifacts, compression artifacts, poorly drawn, low-resolution, bad, distortion, twisted, excessive, exaggerated pose, exaggerated limbs, grainy, symmetrical, duplicate, error, pattern, beginner, pixelated, fake, hyper, glitch, overexposed, high-contrast, bad-contrast"
|
289 |
+
|
290 |
+
def simple_call(prompt1, prompt2):
|
291 |
generator = [torch.Generator(device="cuda").manual_seed(5)]
|
292 |
+
res = call(
|
293 |
+
pipe,
|
294 |
+
prompt1,
|
295 |
+
prompt2,
|
296 |
+
width=768,
|
297 |
+
height=768,
|
298 |
+
num_images_per_prompt=1,
|
299 |
+
num_inference_steps=50,
|
300 |
+
guidance_scale=5.0,
|
301 |
+
guidance_scale2=8.0,
|
302 |
+
negative_prompt=NEGATIVE_PROMPTS,
|
303 |
+
negative_prompt2=NEGATIVE_PROMPTS,
|
304 |
+
generator=generator
|
305 |
+
)
|
306 |
image1 = res.images[0]
|
307 |
image2 = ImageOps.exif_transpose(image1.rotate(180, resample=0))
|
308 |
return image1, image2
|
|
|
310 |
with gr.Blocks() as app:
|
311 |
gr.Markdown(
|
312 |
'''
|
313 |
+
<center>
|
314 |
+
<h1>Upside Down Diffusion</h1>
|
315 |
+
<p>Code by Alex Carlier, please follow them on <a href="https://twitter.com/alexcarliera">Twitter</a></p>
|
316 |
+
<p>A space by <a href="https://twitter.com/angrypenguinPNG">AP</a></p>
|
317 |
</center>
|
318 |
+
<hr>
|
319 |
+
<p>
|
320 |
+
🌟 <strong>Unleash the Magic of Optical Illusions with Stable Diffusion!</strong> 🌟
|
321 |
+
</p>
|
322 |
+
<p>
|
323 |
+
Enter your first prompt to craft an image when upright. Then, inject a second prompt to reveal a mesmerizing surprise when you flip the image upside down! Prepare to be mesmerized! ✨
|
324 |
+
</p>
|
325 |
'''
|
326 |
)
|
327 |
+
|
328 |
|
329 |
with gr.Row():
|
330 |
with gr.Column():
|
331 |
prompt1 = gr.Textbox(label="Prompt 1")
|
332 |
prompt2 = gr.Textbox(label="Prompt 2")
|
|
|
|
|
|
|
|
|
333 |
run_btn = gr.Button("Run")
|
|
|
|
|
|
|
|
|
334 |
|
335 |
with gr.Column():
|
336 |
result_image1 = gr.Image(label="Output 1")
|
|
|
338 |
|
339 |
run_btn.click(
|
340 |
simple_call,
|
341 |
+
inputs=[prompt1, prompt2],
|
342 |
outputs=[result_image1, result_image2]
|
343 |
)
|
344 |
|
345 |
app.queue(max_size=20)
|
346 |
|
347 |
if __name__ == "__main__":
|
348 |
+
app.launch(debug=True)
|