Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
f27c835
1
Parent(s):
0cb9d4a
init
Browse files- __lib__/app.py +9 -7
- __lib__/i18n/ar.pyc +0 -0
- __lib__/i18n/da.pyc +0 -0
- __lib__/i18n/de.pyc +0 -0
- __lib__/i18n/en.pyc +0 -0
- __lib__/i18n/es.pyc +0 -0
- __lib__/i18n/fi.pyc +0 -0
- __lib__/i18n/fr.pyc +0 -0
- __lib__/i18n/he.pyc +0 -0
- __lib__/i18n/hi.pyc +0 -0
- __lib__/i18n/id.pyc +0 -0
- __lib__/i18n/it.pyc +0 -0
- __lib__/i18n/ja.pyc +0 -0
- __lib__/i18n/nl.pyc +0 -0
- __lib__/i18n/no.pyc +0 -0
- __lib__/i18n/pt.pyc +0 -0
- __lib__/i18n/ru.pyc +0 -0
- __lib__/i18n/sv.pyc +0 -0
- __lib__/i18n/tr.pyc +0 -0
- __lib__/i18n/uk.pyc +0 -0
- __lib__/i18n/vi.pyc +0 -0
- __lib__/i18n/zh.pyc +0 -0
__lib__/app.py
CHANGED
|
@@ -507,6 +507,8 @@ def edit_image_interface(input_image, prompt, lang, request: gr.Request, progres
|
|
| 507 |
"""
|
| 508 |
Interface function for processing image editing with phase-based limitations
|
| 509 |
"""
|
|
|
|
|
|
|
| 510 |
try:
|
| 511 |
# Extract user IP
|
| 512 |
client_ip = request.client.host
|
|
@@ -518,17 +520,17 @@ def edit_image_interface(input_image, prompt, lang, request: gr.Request, progres
|
|
| 518 |
IP_Dict[client_ip] += 1
|
| 519 |
|
| 520 |
if input_image is None:
|
| 521 |
-
return None, t("error_upload_first", lang), gr.update(visible=False)
|
| 522 |
|
| 523 |
if not prompt or prompt.strip() == "":
|
| 524 |
-
return None, t("error_enter_prompt", lang), gr.update(visible=False)
|
| 525 |
|
| 526 |
# Check if prompt length is greater than 3 characters
|
| 527 |
if len(prompt.strip()) <= 3:
|
| 528 |
-
return None, t("error_prompt_too_short", lang), gr.update(visible=False)
|
| 529 |
except Exception as e:
|
| 530 |
print(f"⚠️ Unexpected error: {e}", flush=True)
|
| 531 |
-
return None, t("error_processing_failed", lang), gr.update(visible=False)
|
| 532 |
|
| 533 |
# Concurrency guard: block if there is an active task within last 3 minutes
|
| 534 |
try:
|
|
@@ -537,7 +539,7 @@ def edit_image_interface(input_image, prompt, lang, request: gr.Request, progres
|
|
| 537 |
if active_info:
|
| 538 |
start_ts = active_info.get("start", 0)
|
| 539 |
if now_ts - start_ts <= 180:
|
| 540 |
-
return None, "You already have a task in progress. Please wait for it to finish before submitting a new one.", gr.update(visible=False, value=None)
|
| 541 |
else:
|
| 542 |
# Cleanup stale record
|
| 543 |
Active_Tasks.pop(client_ip, None)
|
|
@@ -589,7 +591,7 @@ def edit_image_interface(input_image, prompt, lang, request: gr.Request, progres
|
|
| 589 |
# Use same message for all users to avoid discrimination perception
|
| 590 |
blocked_message = t("error_free_limit_reached", lang)
|
| 591 |
|
| 592 |
-
return None, blocked_message, gr.update(value=blocked_button_html, visible=True)
|
| 593 |
|
| 594 |
# Check rate limit (applies to rate_limit phases)
|
| 595 |
if current_phase in ['rate_limit_1', 'rate_limit_2', 'rate_limit_3']:
|
|
@@ -1105,7 +1107,7 @@ def create_app():
|
|
| 1105 |
edit_button.click(
|
| 1106 |
fn=edit_image_interface,
|
| 1107 |
inputs=[input_image, prompt_input, lang_state],
|
| 1108 |
-
outputs=[output_image, status_output, action_buttons],
|
| 1109 |
show_progress=True,
|
| 1110 |
concurrency_limit=20
|
| 1111 |
)
|
|
|
|
| 507 |
"""
|
| 508 |
Interface function for processing image editing with phase-based limitations
|
| 509 |
"""
|
| 510 |
+
# 默认禁用“Use as Input”按钮,待成功生成后再开启
|
| 511 |
+
use_as_input_state = gr.update(interactive=False)
|
| 512 |
try:
|
| 513 |
# Extract user IP
|
| 514 |
client_ip = request.client.host
|
|
|
|
| 520 |
IP_Dict[client_ip] += 1
|
| 521 |
|
| 522 |
if input_image is None:
|
| 523 |
+
return None, t("error_upload_first", lang), gr.update(visible=False), use_as_input_state
|
| 524 |
|
| 525 |
if not prompt or prompt.strip() == "":
|
| 526 |
+
return None, t("error_enter_prompt", lang), gr.update(visible=False), use_as_input_state
|
| 527 |
|
| 528 |
# Check if prompt length is greater than 3 characters
|
| 529 |
if len(prompt.strip()) <= 3:
|
| 530 |
+
return None, t("error_prompt_too_short", lang), gr.update(visible=False), use_as_input_state
|
| 531 |
except Exception as e:
|
| 532 |
print(f"⚠️ Unexpected error: {e}", flush=True)
|
| 533 |
+
return None, t("error_processing_failed", lang), gr.update(visible=False), use_as_input_state
|
| 534 |
|
| 535 |
# Concurrency guard: block if there is an active task within last 3 minutes
|
| 536 |
try:
|
|
|
|
| 539 |
if active_info:
|
| 540 |
start_ts = active_info.get("start", 0)
|
| 541 |
if now_ts - start_ts <= 180:
|
| 542 |
+
return None, "You already have a task in progress. Please wait for it to finish before submitting a new one.", gr.update(visible=False, value=None), use_as_input_state
|
| 543 |
else:
|
| 544 |
# Cleanup stale record
|
| 545 |
Active_Tasks.pop(client_ip, None)
|
|
|
|
| 591 |
# Use same message for all users to avoid discrimination perception
|
| 592 |
blocked_message = t("error_free_limit_reached", lang)
|
| 593 |
|
| 594 |
+
return None, blocked_message, gr.update(value=blocked_button_html, visible=True), use_as_input_state
|
| 595 |
|
| 596 |
# Check rate limit (applies to rate_limit phases)
|
| 597 |
if current_phase in ['rate_limit_1', 'rate_limit_2', 'rate_limit_3']:
|
|
|
|
| 1107 |
edit_button.click(
|
| 1108 |
fn=edit_image_interface,
|
| 1109 |
inputs=[input_image, prompt_input, lang_state],
|
| 1110 |
+
outputs=[output_image, status_output, action_buttons, use_as_input_btn],
|
| 1111 |
show_progress=True,
|
| 1112 |
concurrency_limit=20
|
| 1113 |
)
|
__lib__/i18n/ar.pyc
CHANGED
|
Binary files a/__lib__/i18n/ar.pyc and b/__lib__/i18n/ar.pyc differ
|
|
|
__lib__/i18n/da.pyc
CHANGED
|
Binary files a/__lib__/i18n/da.pyc and b/__lib__/i18n/da.pyc differ
|
|
|
__lib__/i18n/de.pyc
CHANGED
|
Binary files a/__lib__/i18n/de.pyc and b/__lib__/i18n/de.pyc differ
|
|
|
__lib__/i18n/en.pyc
CHANGED
|
Binary files a/__lib__/i18n/en.pyc and b/__lib__/i18n/en.pyc differ
|
|
|
__lib__/i18n/es.pyc
CHANGED
|
Binary files a/__lib__/i18n/es.pyc and b/__lib__/i18n/es.pyc differ
|
|
|
__lib__/i18n/fi.pyc
CHANGED
|
Binary files a/__lib__/i18n/fi.pyc and b/__lib__/i18n/fi.pyc differ
|
|
|
__lib__/i18n/fr.pyc
CHANGED
|
Binary files a/__lib__/i18n/fr.pyc and b/__lib__/i18n/fr.pyc differ
|
|
|
__lib__/i18n/he.pyc
CHANGED
|
Binary files a/__lib__/i18n/he.pyc and b/__lib__/i18n/he.pyc differ
|
|
|
__lib__/i18n/hi.pyc
CHANGED
|
Binary files a/__lib__/i18n/hi.pyc and b/__lib__/i18n/hi.pyc differ
|
|
|
__lib__/i18n/id.pyc
CHANGED
|
Binary files a/__lib__/i18n/id.pyc and b/__lib__/i18n/id.pyc differ
|
|
|
__lib__/i18n/it.pyc
CHANGED
|
Binary files a/__lib__/i18n/it.pyc and b/__lib__/i18n/it.pyc differ
|
|
|
__lib__/i18n/ja.pyc
CHANGED
|
Binary files a/__lib__/i18n/ja.pyc and b/__lib__/i18n/ja.pyc differ
|
|
|
__lib__/i18n/nl.pyc
CHANGED
|
Binary files a/__lib__/i18n/nl.pyc and b/__lib__/i18n/nl.pyc differ
|
|
|
__lib__/i18n/no.pyc
CHANGED
|
Binary files a/__lib__/i18n/no.pyc and b/__lib__/i18n/no.pyc differ
|
|
|
__lib__/i18n/pt.pyc
CHANGED
|
Binary files a/__lib__/i18n/pt.pyc and b/__lib__/i18n/pt.pyc differ
|
|
|
__lib__/i18n/ru.pyc
CHANGED
|
Binary files a/__lib__/i18n/ru.pyc and b/__lib__/i18n/ru.pyc differ
|
|
|
__lib__/i18n/sv.pyc
CHANGED
|
Binary files a/__lib__/i18n/sv.pyc and b/__lib__/i18n/sv.pyc differ
|
|
|
__lib__/i18n/tr.pyc
CHANGED
|
Binary files a/__lib__/i18n/tr.pyc and b/__lib__/i18n/tr.pyc differ
|
|
|
__lib__/i18n/uk.pyc
CHANGED
|
Binary files a/__lib__/i18n/uk.pyc and b/__lib__/i18n/uk.pyc differ
|
|
|
__lib__/i18n/vi.pyc
CHANGED
|
Binary files a/__lib__/i18n/vi.pyc and b/__lib__/i18n/vi.pyc differ
|
|
|
__lib__/i18n/zh.pyc
CHANGED
|
Binary files a/__lib__/i18n/zh.pyc and b/__lib__/i18n/zh.pyc differ
|
|
|