Update app.py
Browse files
app.py
CHANGED
|
@@ -33,7 +33,7 @@ backend_status = {
|
|
| 33 |
def check_backend_connection():
|
| 34 |
"""Ping the HF Space and cache the client object."""
|
| 35 |
try:
|
| 36 |
-
test_client = Client("
|
| 37 |
backend_status.update({
|
| 38 |
"client": test_client,
|
| 39 |
"connected": True,
|
|
@@ -78,6 +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 |
"""Singleβshot call (no more than `max_retries` times)."""
|
| 82 |
|
| 83 |
if input_image is None:
|
|
@@ -123,7 +124,7 @@ def call_backend_with_retry(input_image: Image.Image, category: str, gender: str
|
|
| 123 |
if attempt == max_retries - 1:
|
| 124 |
return None, None, f"β {e}"
|
| 125 |
time.sleep(1)
|
| 126 |
-
|
| 127 |
return None, None, "β Unknown error"
|
| 128 |
|
| 129 |
# βββββββββ CSS βββββββββ
|
|
|
|
| 33 |
def check_backend_connection():
|
| 34 |
"""Ping the HF Space and cache the client object."""
|
| 35 |
try:
|
| 36 |
+
test_client = Client("milliyin/backend", hf_token=HF_TOKEN)
|
| 37 |
backend_status.update({
|
| 38 |
"client": test_client,
|
| 39 |
"connected": True,
|
|
|
|
| 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 |
+
run_btn.update(interactive=False)
|
| 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 |
+
run_btn.update(interactive=True)
|
| 128 |
return None, None, "β Unknown error"
|
| 129 |
|
| 130 |
# βββββββββ CSS βββββββββ
|