Update app.py
Browse files
app.py
CHANGED
|
@@ -78,7 +78,7 @@ def base64_to_image(b64: str) -> Image.Image | None:
|
|
| 78 |
|
| 79 |
# βββββββββ UI β Backend bridge βββββββββ
|
| 80 |
def call_backend_with_retry(input_image: Image.Image, category: str, gender: str, *, max_retries: int = MAX_RETRIES):
|
| 81 |
-
|
| 82 |
"""Singleβshot call (no more than `max_retries` times)."""
|
| 83 |
|
| 84 |
if input_image is None:
|
|
@@ -124,8 +124,8 @@ def call_backend_with_retry(input_image: Image.Image, category: str, gender: str
|
|
| 124 |
if attempt == max_retries - 1:
|
| 125 |
return None, None, f"β {e}"
|
| 126 |
time.sleep(1)
|
| 127 |
-
|
| 128 |
-
return None, None, "β Unknown error"
|
| 129 |
|
| 130 |
# βββββββββ CSS βββββββββ
|
| 131 |
custom_css = """
|
|
@@ -351,7 +351,7 @@ with gr.Blocks(css=custom_css, title="Jewellery Photography Preview") as demo:
|
|
| 351 |
run_btn.click(
|
| 352 |
fn=call_backend_with_retry,
|
| 353 |
inputs=[input_img, category, gender],
|
| 354 |
-
outputs=[out_overlay, out_bg, out_status],
|
| 355 |
concurrency_limit=1,
|
| 356 |
show_progress=True,
|
| 357 |
)
|
|
|
|
| 78 |
|
| 79 |
# βββββββββ UI β Backend bridge βββββββββ
|
| 80 |
def call_backend_with_retry(input_image: Image.Image, category: str, gender: str, *, max_retries: int = MAX_RETRIES):
|
| 81 |
+
|
| 82 |
"""Singleβshot call (no more than `max_retries` times)."""
|
| 83 |
|
| 84 |
if input_image is None:
|
|
|
|
| 124 |
if attempt == max_retries - 1:
|
| 125 |
return None, None, f"β {e}"
|
| 126 |
time.sleep(1)
|
| 127 |
+
|
| 128 |
+
return run_btn.update(interactive=False), None, None, "β Unknown error", run_btn.update(interactive=True)
|
| 129 |
|
| 130 |
# βββββββββ CSS βββββββββ
|
| 131 |
custom_css = """
|
|
|
|
| 351 |
run_btn.click(
|
| 352 |
fn=call_backend_with_retry,
|
| 353 |
inputs=[input_img, category, gender],
|
| 354 |
+
outputs=[run_btn,out_overlay, out_bg, out_status,run_btn],
|
| 355 |
concurrency_limit=1,
|
| 356 |
show_progress=True,
|
| 357 |
)
|