ideprado commited on
Commit
febc658
·
1 Parent(s): a94e2a0

Fix disable enhance

Browse files
Files changed (1) hide show
  1. app.py +13 -12
app.py CHANGED
@@ -233,7 +233,7 @@ with gr.Blocks(css=css, theme="ParityError/Interstellar") as demo:
233
  visible=False,
234
  interactive=False,
235
  )
236
-
237
  with gr.Accordion("Advanced Settings", open=False):
238
  negative_prompt = gr.Text(
239
  label="Negative prompt",
@@ -242,8 +242,6 @@ with gr.Blocks(css=css, theme="ParityError/Interstellar") as demo:
242
  visible=True,
243
  )
244
 
245
- # Removed checkbox and enriched prompt display from here
246
-
247
  with gr.Tabs() as resolution_tabs:
248
  with gr.TabItem("Preset Resolutions"):
249
  resolution_dropdown = gr.Dropdown(
@@ -300,7 +298,18 @@ with gr.Blocks(css=css, theme="ParityError/Interstellar") as demo:
300
 
301
  # Examples should explicitly target only the prompt input
302
  max_length = 180
303
- examples_component = gr.Examples(examples=examples, inputs=prompt, example_labels=[ex[:max_length] + "..." if len(ex) > max_length else ex for ex in examples])
 
 
 
 
 
 
 
 
 
 
 
304
 
305
  # Update width and height when resolution dropdown changes
306
  resolution_dropdown.change(
@@ -309,13 +318,6 @@ with gr.Blocks(css=css, theme="ParityError/Interstellar") as demo:
309
  outputs=[width, height]
310
  )
311
 
312
- # Disable enrichment when an example is clicked
313
- examples_component.click(
314
- fn=lambda: False,
315
- inputs=[],
316
- outputs=[use_prompt_enrichment]
317
- )
318
-
319
  gr.on(
320
  triggers=[run_button.click, prompt.submit],
321
  fn=infer,
@@ -330,7 +332,6 @@ with gr.Blocks(css=css, theme="ParityError/Interstellar") as demo:
330
  num_inference_steps,
331
  use_prompt_enrichment,
332
  ],
333
- # Outputs now include updates for the enriched prompt display components
334
  outputs=[result, seed, enriched_prompt_display, enriched_prompt_text, enrichment_error],
335
  )
336
 
 
233
  visible=False,
234
  interactive=False,
235
  )
236
+
237
  with gr.Accordion("Advanced Settings", open=False):
238
  negative_prompt = gr.Text(
239
  label="Negative prompt",
 
242
  visible=True,
243
  )
244
 
 
 
245
  with gr.Tabs() as resolution_tabs:
246
  with gr.TabItem("Preset Resolutions"):
247
  resolution_dropdown = gr.Dropdown(
 
298
 
299
  # Examples should explicitly target only the prompt input
300
  max_length = 180
301
+
302
+ # Function to handle example clicks - sets prompt and disables enrichment
303
+ def set_example(example):
304
+ return example, False
305
+
306
+ gr.Examples(
307
+ examples=examples,
308
+ inputs=prompt,
309
+ outputs=[prompt, use_prompt_enrichment],
310
+ fn=set_example,
311
+ example_labels=[ex[:max_length] + "..." if len(ex) > max_length else ex for ex in examples]
312
+ )
313
 
314
  # Update width and height when resolution dropdown changes
315
  resolution_dropdown.change(
 
318
  outputs=[width, height]
319
  )
320
 
 
 
 
 
 
 
 
321
  gr.on(
322
  triggers=[run_button.click, prompt.submit],
323
  fn=infer,
 
332
  num_inference_steps,
333
  use_prompt_enrichment,
334
  ],
 
335
  outputs=[result, seed, enriched_prompt_display, enriched_prompt_text, enrichment_error],
336
  )
337