JeCabrera commited on
Commit
54b5a7b
·
verified ·
1 Parent(s): deb7544

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -17
app.py CHANGED
@@ -60,30 +60,35 @@ def query(prompt, is_negative=False, steps=30, cfg_scale=7, sampler="DPM++ 2M Ka
60
  print(f"Error when trying to open the image: {e}")
61
  return None
62
 
 
 
 
63
  with gr.Blocks() as app:
64
- gr.HTML("<center><h1>Dream Generator with Flux</h1><h2>Transforma tus sueños en imágenes vibrantes con un solo clic.</h2></center>")
 
 
 
65
 
66
  with gr.Row():
67
  with gr.Column(scale=1):
 
68
  with gr.Row():
69
- text_prompt = gr.Textbox(label="Prompt", placeholder="Enter a prompt here", lines=2, elem_id="prompt-text-input")
70
- with gr.Row():
71
- with gr.Accordion("Advanced Settings", open=False):
72
- negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="What should not be in the image", value="(deformed, distorted, disfigured), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, misspellings, typos", lines=3, elem_id="negative-prompt-text-input")
73
- steps = gr.Slider(label="Sampling steps", value=35, minimum=1, maximum=100, step=1)
74
- cfg = gr.Slider(label="CFG Scale", value=7, minimum=1, maximum=20, step=1)
75
- method = gr.Radio(label="Sampling method", value="DPM++ 2M Karras", choices=["DPM++ 2M Karras", "DPM++ SDE Karras", "Euler", "Euler a", "Heun", "DDIM"])
76
- strength = gr.Slider(label="Strength", value=0.7, minimum=0, maximum=1, step=0.001)
77
- seed = gr.Slider(label="Seed", value=-1, minimum=-1, maximum=1000000000, step=1)
78
-
79
- with gr.Row():
80
- generate_button = gr.Button("Generate", elem_id="generate-button")
81
- clear_button = gr.Button("Clear", elem_id="clear-button")
82
 
83
  with gr.Column(scale=1):
84
  image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
85
-
86
- generate_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength], outputs=image_output)
87
- clear_button.click(lambda: (None, None), outputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength, image_output])
88
 
89
  app.launch(show_api=False, share=False)
 
60
  print(f"Error when trying to open the image: {e}")
61
  return None
62
 
63
+ def clear_prompt(prompt):
64
+ return ""
65
+
66
  with gr.Blocks() as app:
67
+ gr.HTML("""
68
+ <h1 align="center">Dream Generator with Flux</h1>
69
+ <h2 align="center">Transforma tus sueños en imágenes vibrantes con un solo clic.</h2>
70
+ """)
71
 
72
  with gr.Row():
73
  with gr.Column(scale=1):
74
+ text_prompt = gr.Textbox(label="Prompt", placeholder="Enter a prompt here", lines=2, elem_id="prompt-text-input")
75
  with gr.Row():
76
+ with gr.Column(scale=1):
77
+ clear_button = gr.Button("Clear", elem_id="clear-button", variant="secondary")
78
+ with gr.Column(scale=1):
79
+ generate_button = gr.Button("Generate", elem_id="generate-button", variant="primary", color="green")
80
+ with gr.Accordion("Advanced Settings", open=False):
81
+ negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="What should not be in the image", value="(deformed, distorted, disfigured), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, misspellings, typos", lines=3, elem_id="negative-prompt-text-input")
82
+ steps = gr.Slider(label="Sampling steps", value=35, minimum=1, maximum=100, step=1)
83
+ cfg = gr.Slider(label="CFG Scale", value=7, minimum=1, maximum=20, step=1)
84
+ method = gr.Radio(label="Sampling method", value="DPM++ 2M Karras", choices=["DPM++ 2M Karras", "DPM++ SDE Karras", "Euler", "Euler a", "Heun", "DDIM"])
85
+ strength = gr.Slider(label="Strength", value=0.7, minimum=0, maximum=1, step=0.001)
86
+ seed = gr.Slider(label="Seed", value=-1, minimum=-1, maximum=1000000000, step=1)
 
 
87
 
88
  with gr.Column(scale=1):
89
  image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
90
+
91
+ clear_button.click(fn=clear_prompt, inputs=text_prompt, outputs=text_prompt)
92
+ generate_button.click(fn=query, inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength], outputs=image_output)
93
 
94
  app.launch(show_api=False, share=False)