github-actions[bot] commited on
Commit
0b47132
·
1 Parent(s): eb40d0c

Deploy from GitHub - 2026-01-19 21:14:44

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -1603,7 +1603,7 @@ def refresh_styles_list():
1603
 
1604
  # Update dropdown choices
1605
  choices = style_list
1606
- return gr.Dropdown(choices=choices, value=choices[0] if choices else 'candy')
1607
 
1608
 
1609
  def get_style_description(style: str) -> str:
@@ -2717,12 +2717,18 @@ with gr.Blocks(
2717
  )
2718
 
2719
  # Style blending handlers
 
 
 
 
 
2720
  blend_btn.click(
2721
  fn=create_style_blend_output,
2722
  inputs=[blend_image, blend_style1, blend_style2, blend_ratio, blend_backend],
2723
  outputs=[blend_output]
2724
  ).then(
2725
- lambda: gr.Markdown(f"Blended {STYLES[blend_style1.value]} × {blend_ratio.value}% + {STYLES[blend_style2.value]} × {100-blend_ratio.value}%"),
 
2726
  outputs=[blend_info]
2727
  )
2728
 
@@ -2753,13 +2759,13 @@ with gr.Blocks(
2753
  )
2754
 
2755
  refresh_styles_btn.click(
2756
- fn=lambda: gr.Dropdown(choices=list(STYLES.keys()) + get_custom_styles(), value=list(STYLES.keys())[0]),
2757
  outputs=[quick_style]
2758
  ).then(
2759
- lambda: gr.Dropdown(choices=list(STYLES.keys()) + get_custom_styles(), value=list(STYLES.keys())[0]),
2760
  outputs=[blend_style1]
2761
  ).then(
2762
- lambda: gr.Dropdown(choices=list(STYLES.keys()) + get_custom_styles(), value=list(STYLES.keys())[0]),
2763
  outputs=[blend_style2]
2764
  )
2765
 
@@ -2794,8 +2800,8 @@ with gr.Blocks(
2794
 
2795
  if __name__ == "__main__":
2796
  demo.launch(
 
 
2797
  # Explicitly enable API for Gradio 5.x compatibility
2798
- show_api=True,
2799
- # Prevent server-side rendering issues on HuggingFace Spaces
2800
- ssr_mode=False
2801
  )
 
1603
 
1604
  # Update dropdown choices
1605
  choices = style_list
1606
+ return gr.update(choices=choices, value=choices[0] if choices else 'candy')
1607
 
1608
 
1609
  def get_style_description(style: str) -> str:
 
2717
  )
2718
 
2719
  # Style blending handlers
2720
+ def update_blend_info(style1: str, style2: str, ratio: float) -> str:
2721
+ s1_name = STYLES.get(style1, style1)
2722
+ s2_name = STYLES.get(style2, style2)
2723
+ return f"Blended {s1_name} × {ratio:.0f}% + {s2_name} × {100-ratio:.0f}%"
2724
+
2725
  blend_btn.click(
2726
  fn=create_style_blend_output,
2727
  inputs=[blend_image, blend_style1, blend_style2, blend_ratio, blend_backend],
2728
  outputs=[blend_output]
2729
  ).then(
2730
+ fn=update_blend_info,
2731
+ inputs=[blend_style1, blend_style2, blend_ratio],
2732
  outputs=[blend_info]
2733
  )
2734
 
 
2759
  )
2760
 
2761
  refresh_styles_btn.click(
2762
+ fn=lambda: gr.update(choices=list(STYLES.keys()) + get_custom_styles(), value=list(STYLES.keys())[0] if STYLES.keys() else None),
2763
  outputs=[quick_style]
2764
  ).then(
2765
+ fn=lambda: gr.update(choices=list(STYLES.keys()) + get_custom_styles(), value=list(STYLES.keys())[0] if STYLES.keys() else None),
2766
  outputs=[blend_style1]
2767
  ).then(
2768
+ fn=lambda: gr.update(choices=list(STYLES.keys()) + get_custom_styles(), value=list(STYLES.keys())[0] if STYLES.keys() else None),
2769
  outputs=[blend_style2]
2770
  )
2771
 
 
2800
 
2801
  if __name__ == "__main__":
2802
  demo.launch(
2803
+ # Required for HuggingFace Spaces deployment
2804
+ share=True,
2805
  # Explicitly enable API for Gradio 5.x compatibility
2806
+ show_api=True
 
 
2807
  )