selfit-camera commited on
Commit
9a3fb3f
Β·
1 Parent(s): bdeba65
Files changed (1) hide show
  1. app.py +89 -89
app.py CHANGED
@@ -853,107 +853,107 @@ def create_app():
853
  outputs=[input_image]
854
  )
855
 
856
- # Local editing tab
857
- with gr.Tab("πŸ–ŒοΈ Local Editing"):
858
- with gr.Row():
859
- with gr.Column(scale=1):
860
- gr.Markdown("### πŸ“Έ Upload Image and Draw Edit Area")
861
- local_input_image = gr.ImageEditor(
862
- label="Upload image and draw mask",
863
- type="pil",
864
- height=512,
865
- brush=gr.Brush(colors=["#ff0000"], default_size=180),
866
- elem_classes=["upload-area"]
867
- )
868
 
869
- gr.Markdown("### ✍️ Editing Instructions")
870
- local_prompt_input = gr.Textbox(
871
- label="Enter local editing prompt",
872
- placeholder="For example: change selected area hair to golden, add patterns to selected object, change selected area color, etc...",
873
- lines=3,
874
- max_lines=5
875
- )
876
 
877
- local_edit_button = gr.Button(
878
- "🎯 Start Local Editing",
879
- variant="primary",
880
- size="lg"
881
- )
882
 
883
- with gr.Column(scale=1):
884
- gr.Markdown("### 🎯 Editing Result")
885
- local_output_image = gr.Image(
886
- label="Local edited image",
887
- height=320,
888
- elem_classes=["result-area"]
889
- )
890
 
891
- # Add "Use as Input" button
892
- local_use_as_input_btn = gr.Button(
893
- "πŸ”„ Use as Input",
894
- variant="secondary",
895
- size="sm",
896
- elem_classes=["use-as-input-btn"]
897
- )
898
 
899
- local_status_output = gr.Textbox(
900
- label="Processing status",
901
- lines=2,
902
- max_lines=3,
903
- interactive=False
904
- )
905
 
906
  # Action buttons that will show after task completion
907
- local_action_buttons = gr.HTML(visible=False)
908
 
909
- # Local editing examples
910
- gr.Markdown("### πŸ’‘ Local Editing Prompt Examples")
911
- with gr.Row():
912
- local_example_prompts = [
913
- "Change selected area hair to golden",
914
- "Add pattern designs to selected clothing",
915
- "Change selected area to different material",
916
- "Add decorations to selected object",
917
- "Change selected area color and style"
918
- ]
919
 
920
- for prompt in local_example_prompts:
921
- gr.Button(
922
- prompt,
923
- size="sm"
924
- ).click(
925
- lambda p=prompt: p,
926
- outputs=local_prompt_input
927
- )
928
 
929
- # Bind local edit button click events - simplified, remove state management
930
- local_edit_button.click(
931
- fn=local_edit_interface,
932
- inputs=[local_input_image, local_prompt_input],
933
- outputs=[local_output_image, local_status_output, local_action_buttons],
934
- show_progress=True,
935
- # Increase concurrency settings
936
- concurrency_limit=8, # Local editing is more complex, allow fewer concurrent requests
937
- api_name="local_edit"
938
- )
939
 
940
- # Simplify local edit "Use as Input" button
941
- def simple_local_use_as_input(output_img):
942
- if output_img is not None:
943
- # Create simple ImageEditor format
944
- editor_data = {
945
- "background": output_img,
946
- "layers": [],
947
- "composite": output_img
948
- }
949
- return editor_data
950
- return None
951
 
952
- local_use_as_input_btn.click(
953
- fn=simple_local_use_as_input,
954
- inputs=[local_output_image],
955
- outputs=[local_input_image]
956
- )
957
 
958
  # SEO Content Section
959
  gr.HTML("""
 
853
  outputs=[input_image]
854
  )
855
 
856
+ # # Local editing tab
857
+ # with gr.Tab("πŸ–ŒοΈ Local Editing"):
858
+ # with gr.Row():
859
+ # with gr.Column(scale=1):
860
+ # gr.Markdown("### πŸ“Έ Upload Image and Draw Edit Area")
861
+ # local_input_image = gr.ImageEditor(
862
+ # label="Upload image and draw mask",
863
+ # type="pil",
864
+ # height=512,
865
+ # brush=gr.Brush(colors=["#ff0000"], default_size=180),
866
+ # elem_classes=["upload-area"]
867
+ # )
868
 
869
+ # gr.Markdown("### ✍️ Editing Instructions")
870
+ # local_prompt_input = gr.Textbox(
871
+ # label="Enter local editing prompt",
872
+ # placeholder="For example: change selected area hair to golden, add patterns to selected object, change selected area color, etc...",
873
+ # lines=3,
874
+ # max_lines=5
875
+ # )
876
 
877
+ # local_edit_button = gr.Button(
878
+ # "🎯 Start Local Editing",
879
+ # variant="primary",
880
+ # size="lg"
881
+ # )
882
 
883
+ # with gr.Column(scale=1):
884
+ # gr.Markdown("### 🎯 Editing Result")
885
+ # local_output_image = gr.Image(
886
+ # label="Local edited image",
887
+ # height=320,
888
+ # elem_classes=["result-area"]
889
+ # )
890
 
891
+ # # Add "Use as Input" button
892
+ # local_use_as_input_btn = gr.Button(
893
+ # "πŸ”„ Use as Input",
894
+ # variant="secondary",
895
+ # size="sm",
896
+ # elem_classes=["use-as-input-btn"]
897
+ # )
898
 
899
+ # local_status_output = gr.Textbox(
900
+ # label="Processing status",
901
+ # lines=2,
902
+ # max_lines=3,
903
+ # interactive=False
904
+ # )
905
 
906
  # Action buttons that will show after task completion
907
+ # local_action_buttons = gr.HTML(visible=False)
908
 
909
+ # # Local editing examples
910
+ # gr.Markdown("### πŸ’‘ Local Editing Prompt Examples")
911
+ # with gr.Row():
912
+ # local_example_prompts = [
913
+ # "Change selected area hair to golden",
914
+ # "Add pattern designs to selected clothing",
915
+ # "Change selected area to different material",
916
+ # "Add decorations to selected object",
917
+ # "Change selected area color and style"
918
+ # ]
919
 
920
+ # for prompt in local_example_prompts:
921
+ # gr.Button(
922
+ # prompt,
923
+ # size="sm"
924
+ # ).click(
925
+ # lambda p=prompt: p,
926
+ # outputs=local_prompt_input
927
+ # )
928
 
929
+ # # Bind local edit button click events - simplified, remove state management
930
+ # local_edit_button.click(
931
+ # fn=local_edit_interface,
932
+ # inputs=[local_input_image, local_prompt_input],
933
+ # outputs=[local_output_image, local_status_output, local_action_buttons],
934
+ # show_progress=True,
935
+ # # Increase concurrency settings
936
+ # concurrency_limit=8, # Local editing is more complex, allow fewer concurrent requests
937
+ # api_name="local_edit"
938
+ # )
939
 
940
+ # # Simplify local edit "Use as Input" button
941
+ # def simple_local_use_as_input(output_img):
942
+ # if output_img is not None:
943
+ # # Create simple ImageEditor format
944
+ # editor_data = {
945
+ # "background": output_img,
946
+ # "layers": [],
947
+ # "composite": output_img
948
+ # }
949
+ # return editor_data
950
+ # return None
951
 
952
+ # local_use_as_input_btn.click(
953
+ # fn=simple_local_use_as_input,
954
+ # inputs=[local_output_image],
955
+ # outputs=[local_input_image]
956
+ # )
957
 
958
  # SEO Content Section
959
  gr.HTML("""