aiqtech commited on
Commit
433318a
ยท
verified ยท
1 Parent(s): 71036e1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -15
app.py CHANGED
@@ -784,8 +784,23 @@ input[type="text"]:focus, textarea:focus {
784
  .fade-in {
785
  animation: fadeIn 0.3s ease-out;
786
  }
787
- """
788
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
789
 
790
  def add_text_with_stroke(draw, text, x, y, font, text_color, stroke_width):
791
  """Helper function to draw text with stroke"""
@@ -949,12 +964,11 @@ def update_position_and_ui(pos):
949
  return [pos] + [updates[btn] for btn in position_mapping.keys()]
950
 
951
  def process_inpainting_with_feedback(image, mask, prompt):
952
- """์ธํŽ˜์ธํŒ… ์ฒ˜๋ฆฌ ๋ฐ ํ”ผ๋“œ๋ฐฑ"""
953
  try:
954
  result = process_inpainting(image, mask, prompt)
955
- return result, update_ui_state("inpainting", "Inpainting completed successfully!")
956
  except Exception as e:
957
- return None, update_ui_state("inpainting", f"Error: {str(e)}", is_error=True)
958
 
959
  def update_controls(bg_prompt):
960
  """๋ฐฐ๊ฒฝ ํ”„๋กฌํ”„ํŠธ ์ž…๋ ฅ ์—ฌ๋ถ€์— ๋”ฐ๋ผ ์ปจํŠธ๋กค ํ‘œ์‹œ ์—…๋ฐ์ดํŠธ"""
@@ -1175,11 +1189,20 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
1175
  visible=True
1176
  )
1177
 
1178
- # ์œ„์น˜ ๋ฒ„ํŠผ ์ด๋ฒคํŠธ ๋ฐ”์ธ๋”ฉ
 
 
 
 
 
 
 
1179
  for btn, pos in position_mapping.items():
1180
  btn.click(
1181
  fn=lambda p=pos: update_position_and_ui(p),
1182
- outputs=[position] + list(position_mapping.keys())
 
 
1183
  )
1184
 
1185
  # ์ธํŽ˜์ธํŒ… ๋ฒ„ํŠผ ์ด๋ฒคํŠธ
@@ -1189,7 +1212,6 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
1189
  outputs=[input_image, status_message]
1190
  )
1191
 
1192
- # ํ”„๋กœ์„ธ์Šค ๋ฒ„ํŠผ ์ด๋ฒคํŠธ
1193
  process_btn.click(
1194
  fn=process_prompt,
1195
  inputs=[
@@ -1200,17 +1222,12 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
1200
  position,
1201
  scale_slider
1202
  ],
1203
- outputs=[combined_image, extracted_image]
 
 
1204
  )
1205
 
1206
 
1207
-
1208
- for btn, pos in position_mapping.items():
1209
- btn.click(
1210
- fn=lambda pos=pos: update_position(pos),
1211
- outputs=position
1212
- )
1213
-
1214
 
1215
  bg_prompt.change(
1216
  fn=update_controls,
 
784
  .fade-in {
785
  animation: fadeIn 0.3s ease-out;
786
  }
 
787
 
788
+ /* ์ƒํƒœ ๋ฉ”์‹œ์ง€ ์• ๋‹ˆ๋ฉ”์ด์…˜ */
789
+ .status-message {
790
+ animation: slideIn 0.3s ease-out;
791
+ }
792
+
793
+ @keyframes slideIn {
794
+ from {
795
+ transform: translateY(-10px);
796
+ opacity: 0;
797
+ }
798
+ to {
799
+ transform: translateY(0);
800
+ opacity: 1;
801
+ }
802
+ }
803
+ """
804
 
805
  def add_text_with_stroke(draw, text, x, y, font, text_color, stroke_width):
806
  """Helper function to draw text with stroke"""
 
964
  return [pos] + [updates[btn] for btn in position_mapping.keys()]
965
 
966
  def process_inpainting_with_feedback(image, mask, prompt):
 
967
  try:
968
  result = process_inpainting(image, mask, prompt)
969
+ return result, update_status_message("Inpainting completed successfully!")
970
  except Exception as e:
971
+ return None, update_status_message(f"Error: {str(e)}", is_error=True)
972
 
973
  def update_controls(bg_prompt):
974
  """๋ฐฐ๊ฒฝ ํ”„๋กฌํ”„ํŠธ ์ž…๋ ฅ ์—ฌ๋ถ€์— ๋”ฐ๋ผ ์ปจํŠธ๋กค ํ‘œ์‹œ ์—…๋ฐ์ดํŠธ"""
 
1189
  visible=True
1190
  )
1191
 
1192
+ def update_status_message(message: str, is_error: bool = False) -> dict:
1193
+ """์ƒํƒœ ๋ฉ”์‹œ์ง€ ์—…๋ฐ์ดํŠธ ํ•จ์ˆ˜"""
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
+ # ์ˆ˜์ •๋œ ๋ฒ„์ „
1200
  for btn, pos in position_mapping.items():
1201
  btn.click(
1202
  fn=lambda p=pos: update_position_and_ui(p),
1203
+ outputs=[position] + [btn for btn in position_mapping.keys()]
1204
+ ).then(
1205
+ fn=lambda: update_ui_state("position", "Position updated successfully!")
1206
  )
1207
 
1208
  # ์ธํŽ˜์ธํŒ… ๋ฒ„ํŠผ ์ด๋ฒคํŠธ
 
1212
  outputs=[input_image, status_message]
1213
  )
1214
 
 
1215
  process_btn.click(
1216
  fn=process_prompt,
1217
  inputs=[
 
1222
  position,
1223
  scale_slider
1224
  ],
1225
+ outputs=[combined_image, extracted_image, status_message]
1226
+ ).then(
1227
+ fn=lambda: update_status_message("Processing completed!")
1228
  )
1229
 
1230
 
 
 
 
 
 
 
 
1231
 
1232
  bg_prompt.change(
1233
  fn=update_controls,