LPX55 commited on
Commit
180e522
·
verified ·
1 Parent(s): 9f7abb0

Update app_local.py

Browse files
Files changed (1) hide show
  1. app_local.py +33 -11
app_local.py CHANGED
@@ -258,6 +258,28 @@ def update_prompt_preview(preset_type, base_prompt):
258
  return preview_text
259
  else:
260
  return "Select a preset above to see how your base prompt will be modified for batch generation."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
 
262
 
263
  @spaces.GPU()
@@ -464,10 +486,10 @@ with gr.Blocks(title="Qwen Image Edit - Fast Lightning Mode w/ Batch") as demo:
464
  preset_editor = gr.Group(visible=False)
465
  with preset_editor:
466
  gr.Markdown("### 🎨 Edit Preset Prompts")
467
- preset_prompt_1 = gr.Textbox(label="Prompt 1", lines=1)
468
- preset_prompt_2 = gr.Textbox(label="Prompt 2", lines=1)
469
- preset_prompt_3 = gr.Textbox(label="Prompt 3", lines=1)
470
- preset_prompt_4 = gr.Textbox(label="Prompt 4", lines=1)
471
  update_preset_button = gr.Button("Update Preset", variant="secondary")
472
 
473
  rewrite_toggle = gr.Checkbox(
@@ -517,14 +539,14 @@ with gr.Blocks(title="Qwen Image Edit - Fast Lightning Mode w/ Batch") as demo:
517
  step=1,
518
  value=4
519
  )
520
- ### CHANGED ### - Added interactive parameter
521
  num_images_per_prompt = gr.Slider(
522
  label="Output Count (Manual)",
523
  minimum=1,
524
  maximum=4,
525
  step=1,
526
- value=1,
527
- interactive=True ### NEW ### - Default to interactive
528
  )
529
 
530
  # Output Column
@@ -602,14 +624,15 @@ with gr.Blocks(title="Qwen Image Edit - Fast Lightning Mode w/ Batch") as demo:
602
  return update_prompt_preview(preset_type, "your subject") # Use placeholder for preview
603
  return "Select a preset first to edit its prompts."
604
 
605
-
 
606
  preset_dropdown.change(
607
- fn=toggle_output_count, ### CHANGED ### - Using new function
608
  inputs=preset_dropdown,
609
  outputs=[preset_editor, num_images_per_prompt, preset_prompt_1, preset_prompt_2, preset_prompt_3, preset_prompt_4]
610
  )
611
 
612
- # Set up prompt preview update
613
  preset_dropdown.change(
614
  fn=update_prompt_preview,
615
  inputs=[preset_dropdown, prompt],
@@ -654,5 +677,4 @@ with gr.Blocks(title="Qwen Image Edit - Fast Lightning Mode w/ Batch") as demo:
654
  outputs=outputs
655
  )
656
 
657
-
658
  demo.queue(max_size=5).launch()
 
258
  return preview_text
259
  else:
260
  return "Select a preset above to see how your base prompt will be modified for batch generation."
261
+
262
+ def toggle_output_count(preset_type):
263
+ """Control output count slider interactivity and show/hide preset editor"""
264
+ if preset_type and preset_type in PRESETS:
265
+ # When preset is selected, disable manual output count and show editor
266
+ preset = PRESETS[preset_type]
267
+ prompts = preset["prompts"]
268
+ # Pad prompts to 4 items if needed
269
+ while len(prompts) < 4:
270
+ prompts.append("")
271
+ return (
272
+ gr.Group(visible=True),
273
+ gr.Slider(interactive=False, value=preset["count"]), # Disable slider
274
+ prompts[0], prompts[1], prompts[2], prompts[3] # Populate preset prompts
275
+ )
276
+ else:
277
+ # When no preset is selected, enable manual output count and hide editor
278
+ return (
279
+ gr.Group(visible=False),
280
+ gr.Slider(interactive=True), # Enable slider
281
+ "", "", "", "" # Clear preset prompts
282
+ )
283
 
284
 
285
  @spaces.GPU()
 
486
  preset_editor = gr.Group(visible=False)
487
  with preset_editor:
488
  gr.Markdown("### 🎨 Edit Preset Prompts")
489
+ preset_prompt_1 = gr.Textbox(label="Prompt 1", lines=1, value="")
490
+ preset_prompt_2 = gr.Textbox(label="Prompt 2", lines=1, value="")
491
+ preset_prompt_3 = gr.Textbox(label="Prompt 3", lines=1, value="")
492
+ preset_prompt_4 = gr.Textbox(label="Prompt 4", lines=1, value="")
493
  update_preset_button = gr.Button("Update Preset", variant="secondary")
494
 
495
  rewrite_toggle = gr.Checkbox(
 
539
  step=1,
540
  value=4
541
  )
542
+
543
  num_images_per_prompt = gr.Slider(
544
  label="Output Count (Manual)",
545
  minimum=1,
546
  maximum=4,
547
  step=1,
548
+ value=2,
549
+ interactive=True
550
  )
551
 
552
  # Output Column
 
624
  return update_prompt_preview(preset_type, "your subject") # Use placeholder for preview
625
  return "Select a preset first to edit its prompts."
626
 
627
+
628
+ # Set up preset dropdown change handler - now controls output count slider
629
  preset_dropdown.change(
630
+ fn=toggle_output_count,
631
  inputs=preset_dropdown,
632
  outputs=[preset_editor, num_images_per_prompt, preset_prompt_1, preset_prompt_2, preset_prompt_3, preset_prompt_4]
633
  )
634
 
635
+ # Set up prompt preview updates
636
  preset_dropdown.change(
637
  fn=update_prompt_preview,
638
  inputs=[preset_dropdown, prompt],
 
677
  outputs=outputs
678
  )
679
 
 
680
  demo.queue(max_size=5).launch()