Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1189,35 +1189,33 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
| 1189 |
btn_bottom_right: "bottom-right"
|
| 1190 |
}
|
| 1191 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1192 |
def update_ui_state(component_id, value, is_error=False):
|
| 1193 |
-
"""UI ์ํ ์
๋ฐ์ดํธ ์ ํธ๋ฆฌํฐ"""
|
| 1194 |
class_name = "status-error" if is_error else "status-success"
|
| 1195 |
return gr.update(
|
| 1196 |
value=f'<div class="status-message {class_name}">{value}</div>',
|
| 1197 |
visible=True
|
| 1198 |
)
|
| 1199 |
|
| 1200 |
-
|
| 1201 |
-
"""์ํ ๋ฉ์์ง ์
๋ฐ์ดํธ ํจ์"""
|
| 1202 |
-
return {
|
| 1203 |
-
"visible": True,
|
| 1204 |
-
"value": f'<div class="status-message {"status-error" if is_error else "status-success"}">{message}</div>'
|
| 1205 |
-
}
|
| 1206 |
-
|
| 1207 |
-
# ์์ ๋ ๋ฒ์
|
| 1208 |
for btn, pos in position_mapping.items():
|
| 1209 |
btn.click(
|
| 1210 |
fn=lambda p=pos: update_position_and_ui(p),
|
| 1211 |
-
outputs=[position] +
|
| 1212 |
-
|
| 1213 |
-
fn=lambda: update_ui_state("position", "Position updated successfully!")
|
| 1214 |
)
|
| 1215 |
|
| 1216 |
-
# ์ธํ์ธํ
๋ฒํผ ์ด๋ฒคํธ
|
| 1217 |
inpaint_btn.click(
|
| 1218 |
fn=process_inpainting_with_feedback,
|
| 1219 |
inputs=[input_image, mask_input, inpaint_prompt],
|
| 1220 |
-
outputs=[input_image, status_message]
|
|
|
|
| 1221 |
)
|
| 1222 |
|
| 1223 |
process_btn.click(
|
|
@@ -1230,32 +1228,32 @@ def update_status_message(message: str, is_error: bool = False) -> dict:
|
|
| 1230 |
position,
|
| 1231 |
scale_slider
|
| 1232 |
],
|
| 1233 |
-
outputs=[combined_image, extracted_image, status_message]
|
| 1234 |
-
|
| 1235 |
-
fn=lambda: update_status_message("Processing completed!")
|
| 1236 |
)
|
| 1237 |
|
| 1238 |
-
|
| 1239 |
-
|
| 1240 |
bg_prompt.change(
|
| 1241 |
fn=update_controls,
|
| 1242 |
inputs=bg_prompt,
|
| 1243 |
outputs=[aspect_ratio, object_controls],
|
| 1244 |
-
queue=False
|
|
|
|
| 1245 |
)
|
| 1246 |
-
|
| 1247 |
input_image.change(
|
| 1248 |
fn=update_process_button,
|
| 1249 |
inputs=[input_image, text_prompt],
|
| 1250 |
outputs=process_btn,
|
| 1251 |
-
queue=False
|
|
|
|
| 1252 |
)
|
| 1253 |
-
|
| 1254 |
text_prompt.change(
|
| 1255 |
fn=update_process_button,
|
| 1256 |
inputs=[input_image, text_prompt],
|
| 1257 |
outputs=process_btn,
|
| 1258 |
-
queue=False
|
|
|
|
| 1259 |
)
|
| 1260 |
|
| 1261 |
add_text_btn.click(
|
|
@@ -1272,9 +1270,8 @@ def update_status_message(message: str, is_error: bool = False) -> dict:
|
|
| 1272 |
text_position_type,
|
| 1273 |
font_choice
|
| 1274 |
],
|
| 1275 |
-
outputs=[combined_image, status_message]
|
| 1276 |
-
|
| 1277 |
-
fn=lambda: update_status_message("Text added successfully!")
|
| 1278 |
)
|
| 1279 |
|
| 1280 |
|
|
|
|
| 1189 |
btn_bottom_right: "bottom-right"
|
| 1190 |
}
|
| 1191 |
|
| 1192 |
+
|
| 1193 |
+
def update_status_message(message: str, is_error: bool = False) -> dict:
|
| 1194 |
+
return {
|
| 1195 |
+
"visible": True,
|
| 1196 |
+
"value": f'<div class="status-message {"status-error" if is_error else "status-success"}">{message}</div>'
|
| 1197 |
+
}
|
| 1198 |
+
|
| 1199 |
def update_ui_state(component_id, value, is_error=False):
|
|
|
|
| 1200 |
class_name = "status-error" if is_error else "status-success"
|
| 1201 |
return gr.update(
|
| 1202 |
value=f'<div class="status-message {class_name}">{value}</div>',
|
| 1203 |
visible=True
|
| 1204 |
)
|
| 1205 |
|
| 1206 |
+
# ์ด๋ฒคํธ ๋ฐ์ธ๋ฉ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1207 |
for btn, pos in position_mapping.items():
|
| 1208 |
btn.click(
|
| 1209 |
fn=lambda p=pos: update_position_and_ui(p),
|
| 1210 |
+
outputs=[position] + list(position_mapping.keys()),
|
| 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],
|
| 1217 |
+
outputs=[input_image, status_message],
|
| 1218 |
+
api_name="inpaint"
|
| 1219 |
)
|
| 1220 |
|
| 1221 |
process_btn.click(
|
|
|
|
| 1228 |
position,
|
| 1229 |
scale_slider
|
| 1230 |
],
|
| 1231 |
+
outputs=[combined_image, extracted_image, status_message],
|
| 1232 |
+
api_name="process"
|
|
|
|
| 1233 |
)
|
| 1234 |
|
|
|
|
|
|
|
| 1235 |
bg_prompt.change(
|
| 1236 |
fn=update_controls,
|
| 1237 |
inputs=bg_prompt,
|
| 1238 |
outputs=[aspect_ratio, object_controls],
|
| 1239 |
+
queue=False,
|
| 1240 |
+
api_name="update_controls"
|
| 1241 |
)
|
| 1242 |
+
|
| 1243 |
input_image.change(
|
| 1244 |
fn=update_process_button,
|
| 1245 |
inputs=[input_image, text_prompt],
|
| 1246 |
outputs=process_btn,
|
| 1247 |
+
queue=False,
|
| 1248 |
+
api_name="update_process_button"
|
| 1249 |
)
|
| 1250 |
+
|
| 1251 |
text_prompt.change(
|
| 1252 |
fn=update_process_button,
|
| 1253 |
inputs=[input_image, text_prompt],
|
| 1254 |
outputs=process_btn,
|
| 1255 |
+
queue=False,
|
| 1256 |
+
api_name="update_text_prompt"
|
| 1257 |
)
|
| 1258 |
|
| 1259 |
add_text_btn.click(
|
|
|
|
| 1270 |
text_position_type,
|
| 1271 |
font_choice
|
| 1272 |
],
|
| 1273 |
+
outputs=[combined_image, status_message],
|
| 1274 |
+
api_name="add_text"
|
|
|
|
| 1275 |
)
|
| 1276 |
|
| 1277 |
|