zhoudewei.666 commited on
Commit
1e0e825
·
1 Parent(s): 2fed0ac

ui: move key controls out of advanced settings and add seed dice

Browse files

Improve usability by exposing paste-back mode and crop margin in the main panel, adding clearer refine guidance notes, and providing a one-click random seed generator.

Made-with: Cursor

Files changed (1) hide show
  1. app.py +25 -3
app.py CHANGED
@@ -770,10 +770,26 @@ leave it as-is to reference the whole image, or **brush on it** to specify exact
770
  可选上传第二张参考图来引导风格/内容——不涂抹则参考整张图,**涂抹则精确指定参考区域**。\
771
  """
772
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
773
  with gr.Blocks(title="RefineAnything", theme=gr.themes.Soft()) as demo:
774
  gr.Markdown("# RefineAnything")
775
  gr.Markdown(_DESCRIPTION_EN)
776
  gr.Markdown(_DESCRIPTION_CN)
 
 
777
 
778
  with gr.Row():
779
  with gr.Column():
@@ -792,11 +808,19 @@ leave it as-is to reference the whole image, or **brush on it** to specify exact
792
  with gr.Row():
793
  mode = gr.Radio(["Run inference", "Preview only"], value="Run inference", label="Mode", scale=2)
794
  seed = gr.Number(label="Seed", value=0, precision=0, scale=1)
 
795
  steps = gr.Number(label="Steps", value=8, precision=0, scale=1)
796
 
797
  with gr.Row():
798
  spatial_source = gr.Radio(["mask", "bbox"], value="mask", label="Spatial prompt source", scale=2)
799
  load_lightning_lora = gr.Checkbox(label="Lightning LoRA (faster)", value=True, scale=1)
 
 
 
 
 
 
 
800
 
801
  with gr.Accordion("Advanced settings", open=False):
802
  with gr.Row():
@@ -804,10 +828,7 @@ leave it as-is to reference the whole image, or **brush on it** to specify exact
804
  guidance_scale = gr.Number(label="Guidance scale", value=1.0)
805
  with gr.Row():
806
  paste_back_bbox = gr.Checkbox(label="Composite paste-back", value=True)
807
- paste_back_mode = gr.Radio(["bbox", "mask"], value="bbox", label="Paste-back mode")
808
- with gr.Row():
809
  focus_crop_for_bbox = gr.Checkbox(label="Focus-crop edit region", value=True)
810
- focus_crop_margin = gr.Number(label="Crop margin (px)", value=64, precision=0)
811
  with gr.Row():
812
  paste_mask_grow = gr.Number(label="Mask grow", value=3, precision=0)
813
  paste_blend_kernel = gr.Number(label="Blend kernel", value=5, precision=0)
@@ -833,6 +854,7 @@ leave it as-is to reference the whole image, or **brush on it** to specify exact
833
  ],
834
  outputs=[out_image, replaced_prompt, image1_vis, status],
835
  )
 
836
 
837
  return demo
838
 
 
770
  可选上传第二张参考图来引导风格/内容——不涂抹则参考整张图,**涂抹则精确指定参考区域**。\
771
  """
772
 
773
+ _NOTE_EN = (
774
+ "For refinement tasks, prompts starting with **refine** usually work better. "
775
+ "The model also shows some grounding edit ability (for example **add**, **remove**, **modify**) "
776
+ "even without dedicated grounding training."
777
+ )
778
+ _NOTE_CN = (
779
+ "做 refine 任务时,prompt 以 **refine** 开头通常效果更好。"
780
+ "此外模型也具备一定 grounding edit 能力(如 **add**、**remove**、**modify**),"
781
+ "虽然我们没有使用专门的 grounding 数据训练。"
782
+ )
783
+
784
+ def _randomize_seed():
785
+ return random.randint(0, 2**31 - 1)
786
+
787
  with gr.Blocks(title="RefineAnything", theme=gr.themes.Soft()) as demo:
788
  gr.Markdown("# RefineAnything")
789
  gr.Markdown(_DESCRIPTION_EN)
790
  gr.Markdown(_DESCRIPTION_CN)
791
+ gr.Markdown(_NOTE_EN)
792
+ gr.Markdown(_NOTE_CN)
793
 
794
  with gr.Row():
795
  with gr.Column():
 
808
  with gr.Row():
809
  mode = gr.Radio(["Run inference", "Preview only"], value="Run inference", label="Mode", scale=2)
810
  seed = gr.Number(label="Seed", value=0, precision=0, scale=1)
811
+ seed_dice = gr.Button("🎲 Random", scale=0, min_width=110)
812
  steps = gr.Number(label="Steps", value=8, precision=0, scale=1)
813
 
814
  with gr.Row():
815
  spatial_source = gr.Radio(["mask", "bbox"], value="mask", label="Spatial prompt source", scale=2)
816
  load_lightning_lora = gr.Checkbox(label="Lightning LoRA (faster)", value=True, scale=1)
817
+ with gr.Row():
818
+ paste_back_mode = gr.Radio(["bbox", "mask"], value="bbox", label="Paste-back mode", scale=1)
819
+ with gr.Column(scale=1):
820
+ focus_crop_margin = gr.Number(label="Crop margin (px)", value=64, precision=0)
821
+ gr.Markdown(
822
+ "Note: Increasing this value usually improves harmony between the refined region and surrounding areas; decreasing it usually improves fine-detail recovery."
823
+ )
824
 
825
  with gr.Accordion("Advanced settings", open=False):
826
  with gr.Row():
 
828
  guidance_scale = gr.Number(label="Guidance scale", value=1.0)
829
  with gr.Row():
830
  paste_back_bbox = gr.Checkbox(label="Composite paste-back", value=True)
 
 
831
  focus_crop_for_bbox = gr.Checkbox(label="Focus-crop edit region", value=True)
 
832
  with gr.Row():
833
  paste_mask_grow = gr.Number(label="Mask grow", value=3, precision=0)
834
  paste_blend_kernel = gr.Number(label="Blend kernel", value=5, precision=0)
 
854
  ],
855
  outputs=[out_image, replaced_prompt, image1_vis, status],
856
  )
857
+ seed_dice.click(fn=_randomize_seed, inputs=None, outputs=seed)
858
 
859
  return demo
860