aiqtech commited on
Commit
0ac1314
·
verified ·
1 Parent(s): 5aa4162

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -11
app.py CHANGED
@@ -1009,7 +1009,8 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
1009
  with gr.Group(elem_classes="input-panel"):
1010
  with gr.Tabs():
1011
  # 첫 번째 탭: 이미지 업로드 및 인페인팅
1012
- with gr.Tab("Image Upload & Inpainting"):
 
1013
  input_image = gr.Image(
1014
  type="pil",
1015
  label="Upload Image",
@@ -1030,7 +1031,8 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
1030
  inpaint_btn = gr.Button("Apply Inpainting", variant="primary")
1031
 
1032
  # 두 번째 탭: 배경 제거 및 생성
1033
- with gr.Tab("Background Removal"):
 
1034
  text_prompt = gr.Textbox(
1035
  label="Object to Extract",
1036
  placeholder="Enter what you want to extract...",
@@ -1057,17 +1059,17 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
1057
  with gr.Group(elem_classes="controls-panel", visible=False) as object_controls:
1058
  with gr.Column(scale=1):
1059
  with gr.Row():
1060
- btn_top_left = gr.Button("↖", elem_classes="position-btn")
1061
- btn_top_center = gr.Button("↑", elem_classes="position-btn")
1062
- btn_top_right = gr.Button("↗", elem_classes="position-btn")
1063
  with gr.Row():
1064
- btn_middle_left = gr.Button("←", elem_classes="position-btn")
1065
- btn_middle_center = gr.Button("•", elem_classes="position-btn")
1066
- btn_middle_right = gr.Button("→", elem_classes="position-btn")
1067
  with gr.Row():
1068
- btn_bottom_left = gr.Button("↙", elem_classes="position-btn")
1069
- btn_bottom_center = gr.Button("↓", elem_classes="position-btn", value="selected")
1070
- btn_bottom_right = gr.Button("↘", elem_classes="position-btn")
1071
  with gr.Column(scale=1):
1072
  scale_slider = gr.Slider(
1073
  minimum=10,
@@ -1203,6 +1205,22 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
1203
  visible=True
1204
  )
1205
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1206
  # 이벤트 바인딩
1207
  for btn, pos in position_mapping.items():
1208
  btn.click(
@@ -1211,6 +1229,8 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
1211
  api_name=f"update_position_{pos}"
1212
  )
1213
 
 
 
1214
  inpaint_btn.click(
1215
  fn=process_inpainting_with_feedback,
1216
  inputs=[input_image, mask_input, inpaint_prompt],
 
1009
  with gr.Group(elem_classes="input-panel"):
1010
  with gr.Tabs():
1011
  # 첫 번째 탭: 이미지 업로드 및 인페인팅
1012
+ with gr.Tab("Image Upload & Inpainting", elem_classes="tab"):
1013
+
1014
  input_image = gr.Image(
1015
  type="pil",
1016
  label="Upload Image",
 
1031
  inpaint_btn = gr.Button("Apply Inpainting", variant="primary")
1032
 
1033
  # 두 번째 탭: 배경 제거 및 생성
1034
+ with gr.Tab("Background Removal", elem_classes="tab"):
1035
+
1036
  text_prompt = gr.Textbox(
1037
  label="Object to Extract",
1038
  placeholder="Enter what you want to extract...",
 
1059
  with gr.Group(elem_classes="controls-panel", visible=False) as object_controls:
1060
  with gr.Column(scale=1):
1061
  with gr.Row():
1062
+ btn_top_left = gr.Button("↖", elem_classes=["position-btn", "interactive-element"])
1063
+ btn_top_center = gr.Button("↑", elem_classes=["position-btn", "interactive-element"])
1064
+ btn_top_right = gr.Button("↗", elem_classes=["position-btn", "interactive-element"])
1065
  with gr.Row():
1066
+ btn_middle_left = gr.Button("←", elem_classes=["position-btn", "interactive-element"])
1067
+ btn_middle_center = gr.Button("•", elem_classes=["position-btn", "interactive-element"])
1068
+ btn_middle_right = gr.Button("→", elem_classes=["position-btn", "interactive-element"])
1069
  with gr.Row():
1070
+ btn_bottom_left = gr.Button("↙", elem_classes=["position-btn", "interactive-element"])
1071
+ btn_bottom_center = gr.Button("↓", elem_classes=["position-btn", value="selected")
1072
+ btn_bottom_right = gr.Button("↘", elem_classes=["position-btn", "interactive-element"])
1073
  with gr.Column(scale=1):
1074
  scale_slider = gr.Slider(
1075
  minimum=10,
 
1205
  visible=True
1206
  )
1207
 
1208
+
1209
+ def handle_button_click(btn_pos):
1210
+ """버튼 클릭 이벤트 핸들러"""
1211
+ print(f"Button clicked: {btn_pos}") # 디버깅용
1212
+ return update_position_and_ui(btn_pos)
1213
+
1214
+ # 버튼 이벤트 바인딩
1215
+ for btn, pos in position_mapping.items():
1216
+ btn.click(
1217
+ fn=handle_button_click,
1218
+ inputs=[gr.State(pos)],
1219
+ outputs=[position] + list(position_mapping.keys()),
1220
+ api_name=f"btn_click_{pos}"
1221
+ )
1222
+
1223
+
1224
  # 이벤트 바인딩
1225
  for btn, pos in position_mapping.items():
1226
  btn.click(
 
1229
  api_name=f"update_position_{pos}"
1230
  )
1231
 
1232
+
1233
+
1234
  inpaint_btn.click(
1235
  fn=process_inpainting_with_feedback,
1236
  inputs=[input_image, mask_input, inpaint_prompt],