Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
51535d8
1
Parent(s):
959bfbe
init
Browse files- __lib__/app.py +40 -2
- __lib__/i18n/en.pyc +0 -0
- __lib__/nfsw.pyc +0 -0
- __lib__/util.pyc +0 -0
__lib__/app.py
CHANGED
|
@@ -73,13 +73,13 @@ def set_active_task(client_ip, active=True):
|
|
| 73 |
"""
|
| 74 |
if active:
|
| 75 |
util.IP_Active_Tasks[client_ip] = time.time()
|
| 76 |
-
print(f"🔒 Task locked for IP: {client_ip}")
|
| 77 |
else:
|
| 78 |
if client_ip in util.IP_Active_Tasks:
|
| 79 |
del util.IP_Active_Tasks[client_ip]
|
| 80 |
# 记录任务完成时间
|
| 81 |
util.IP_Last_Task_Time[client_ip] = time.time()
|
| 82 |
-
print(f"🔓 Task unlocked for IP: {client_ip}")
|
| 83 |
|
| 84 |
|
| 85 |
|
|
@@ -691,6 +691,9 @@ def edit_image_interface(input_image, prompt, lang, request: gr.Request, progres
|
|
| 691 |
|
| 692 |
task_priority = 1 if current_count < rate_limit_config.HIGH_PRIORITY_COUNT else 0
|
| 693 |
record_generation_attempt(client_ip, current_phase)
|
|
|
|
|
|
|
|
|
|
| 694 |
|
| 695 |
input_image_url, result_url, message, task_uuid = process_image_edit(input_image, prompt.strip(), None, progress_callback, priority=task_priority, client_ip=client_ip)
|
| 696 |
|
|
@@ -715,13 +718,16 @@ def edit_image_interface(input_image, prompt, lang, request: gr.Request, progres
|
|
| 715 |
result_html = create_result_image_html(result_url)
|
| 716 |
action_html = create_action_buttons_html(task_uuid, input_image_url, result_url, prompt, lang, show_like_tip)
|
| 717 |
set_active_task(client_ip, False) # 解锁任务
|
|
|
|
| 718 |
return result_html, result_url, t("status_completed_message", lang).format(message=message), gr.update(value=action_html, visible=True)
|
| 719 |
else:
|
| 720 |
set_active_task(client_ip, False) # 解锁任务
|
|
|
|
| 721 |
return "", None, t("error_processing_failed", lang).format(message=message), gr.update(visible=False)
|
| 722 |
|
| 723 |
except Exception as e:
|
| 724 |
set_active_task(client_ip, False) # 解锁任务
|
|
|
|
| 725 |
return "", None, t("error_processing_exception", lang).format(error=str(e)), gr.update(visible=False)
|
| 726 |
|
| 727 |
|
|
@@ -808,6 +814,9 @@ def multi_image_edit_interface(input_image1, input_image2, input_image3, prompt,
|
|
| 808 |
set_active_task(client_ip, True)
|
| 809 |
|
| 810 |
record_generation_attempt(client_ip, current_phase)
|
|
|
|
|
|
|
|
|
|
| 811 |
|
| 812 |
input_url, result_url, message, task_uuid = process_multi_image_edit(images, prompt.strip(), progress_callback, priority=task_priority, client_ip=client_ip, is_sr=is_sr)
|
| 813 |
|
|
@@ -839,13 +848,16 @@ def multi_image_edit_interface(input_image1, input_image2, input_image3, prompt,
|
|
| 839 |
status_message = f"{mode_tip}\n{t('status_completed_message', lang).format(message=message)}"
|
| 840 |
|
| 841 |
set_active_task(client_ip, False) # 解锁任务
|
|
|
|
| 842 |
return result_html, status_message, gr.update(value=action_html, visible=True)
|
| 843 |
else:
|
| 844 |
set_active_task(client_ip, False) # 解锁任务
|
|
|
|
| 845 |
return "", t("error_processing_failed", lang).format(message=message), gr.update(visible=False)
|
| 846 |
|
| 847 |
except Exception as e:
|
| 848 |
set_active_task(client_ip, False) # 解锁任务
|
|
|
|
| 849 |
return "", t("error_processing_exception", lang).format(error=str(e)), gr.update(visible=False)
|
| 850 |
|
| 851 |
|
|
@@ -921,6 +933,9 @@ def text_to_image_interface(prompt, aspect_ratio, lang, request: gr.Request, pro
|
|
| 921 |
set_active_task(client_ip, True)
|
| 922 |
|
| 923 |
record_generation_attempt(client_ip, current_phase)
|
|
|
|
|
|
|
|
|
|
| 924 |
|
| 925 |
result_url, message, task_uuid = process_text_to_image(prompt.strip(), aspect_ratio, progress_callback, priority=task_priority, client_ip=client_ip, is_sr=is_sr, target_area=target_area)
|
| 926 |
|
|
@@ -986,13 +1001,16 @@ def text_to_image_interface(prompt, aspect_ratio, lang, request: gr.Request, pro
|
|
| 986 |
status_message = f"{mode_tip}\n{t('status_completed_message', lang).format(message=message)}"
|
| 987 |
|
| 988 |
set_active_task(client_ip, False) # 解锁任务
|
|
|
|
| 989 |
return result_html, status_message, gr.update(value=action_html, visible=True)
|
| 990 |
else:
|
| 991 |
set_active_task(client_ip, False) # 解锁任务
|
|
|
|
| 992 |
return "", t("error_processing_failed", lang).format(message=message), gr.update(visible=False)
|
| 993 |
|
| 994 |
except Exception as e:
|
| 995 |
set_active_task(client_ip, False) # 解锁任务
|
|
|
|
| 996 |
return "", t("error_processing_exception", lang).format(error=str(e)), gr.update(visible=False)
|
| 997 |
|
| 998 |
|
|
@@ -1051,6 +1069,9 @@ def image_upscale_interface(input_image, lang, request: gr.Request, progress=gr.
|
|
| 1051 |
|
| 1052 |
task_priority = 1 if current_count < rate_limit_config.HIGH_PRIORITY_COUNT else 0
|
| 1053 |
record_generation_attempt(client_ip, current_phase)
|
|
|
|
|
|
|
|
|
|
| 1054 |
|
| 1055 |
input_url, result_url, message, task_uuid = process_image_upscale(input_image, progress_callback, priority=task_priority, client_ip=client_ip)
|
| 1056 |
|
|
@@ -1099,13 +1120,16 @@ def image_upscale_interface(input_image, lang, request: gr.Request, progress=gr.
|
|
| 1099 |
if show_like_tip or lang in ["zh", "hi", "ru"]:
|
| 1100 |
action_html += create_like_tip_html()
|
| 1101 |
set_active_task(client_ip, False) # 解锁任务
|
|
|
|
| 1102 |
return result_html, t("status_completed_message", lang).format(message=message), gr.update(value=action_html, visible=bool(action_html))
|
| 1103 |
else:
|
| 1104 |
set_active_task(client_ip, False) # 解锁任务
|
|
|
|
| 1105 |
return "", t("error_processing_failed", lang).format(message=message), gr.update(visible=False)
|
| 1106 |
|
| 1107 |
except Exception as e:
|
| 1108 |
set_active_task(client_ip, False) # 解锁任务
|
|
|
|
| 1109 |
return "", t("error_processing_exception", lang).format(error=str(e)), gr.update(visible=False)
|
| 1110 |
|
| 1111 |
|
|
@@ -1186,6 +1210,10 @@ def face_swap_interface(target_editor, source_face_image, lang, request: gr.Requ
|
|
| 1186 |
set_active_task(client_ip, True)
|
| 1187 |
task_priority = 1 if current_count < rate_limit_config.HIGH_PRIORITY_COUNT else 0
|
| 1188 |
record_generation_attempt(client_ip, current_phase)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1189 |
|
| 1190 |
input_url, result_url, message, task_uuid = process_face_swap(target_image, source_face_image, mask_image, progress_callback, priority=task_priority, client_ip=client_ip)
|
| 1191 |
|
|
@@ -1234,13 +1262,16 @@ def face_swap_interface(target_editor, source_face_image, lang, request: gr.Requ
|
|
| 1234 |
if show_like_tip or lang in ["zh", "hi", "ru"]:
|
| 1235 |
action_html += create_like_tip_html()
|
| 1236 |
set_active_task(client_ip, False)
|
|
|
|
| 1237 |
return result_html, t("status_completed_message", lang).format(message=message), gr.update(value=action_html, visible=bool(action_html))
|
| 1238 |
else:
|
| 1239 |
set_active_task(client_ip, False)
|
|
|
|
| 1240 |
return "", t("error_processing_failed", lang).format(message=message), gr.update(visible=False)
|
| 1241 |
|
| 1242 |
except Exception as e:
|
| 1243 |
set_active_task(client_ip, False)
|
|
|
|
| 1244 |
return "", t("error_processing_exception", lang).format(error=str(e)), gr.update(visible=False)
|
| 1245 |
|
| 1246 |
|
|
@@ -1297,6 +1328,10 @@ def watermark_removal_interface(input_image, force_removal, lang, request: gr.Re
|
|
| 1297 |
set_active_task(client_ip, True)
|
| 1298 |
task_priority = 1 if current_count < rate_limit_config.HIGH_PRIORITY_COUNT else 0
|
| 1299 |
record_generation_attempt(client_ip, current_phase)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1300 |
|
| 1301 |
input_url, result_url, message, task_uuid = process_watermark_removal(input_image, progress_callback, priority=task_priority, client_ip=client_ip, force_removal=force_removal)
|
| 1302 |
|
|
@@ -1340,13 +1375,16 @@ def watermark_removal_interface(input_image, force_removal, lang, request: gr.Re
|
|
| 1340 |
if show_like_tip or lang in ["zh", "hi", "ru"]:
|
| 1341 |
action_html += create_like_tip_html()
|
| 1342 |
set_active_task(client_ip, False)
|
|
|
|
| 1343 |
return result_html, t("status_completed_message", lang).format(message=message), gr.update(value=action_html, visible=bool(action_html))
|
| 1344 |
else:
|
| 1345 |
set_active_task(client_ip, False)
|
|
|
|
| 1346 |
return "", t("error_processing_failed", lang).format(message=message), gr.update(visible=False)
|
| 1347 |
|
| 1348 |
except Exception as e:
|
| 1349 |
set_active_task(client_ip, False)
|
|
|
|
| 1350 |
return "", t("error_processing_exception", lang).format(error=str(e)), gr.update(visible=False)
|
| 1351 |
|
| 1352 |
|
|
|
|
| 73 |
"""
|
| 74 |
if active:
|
| 75 |
util.IP_Active_Tasks[client_ip] = time.time()
|
| 76 |
+
# print(f"🔒 Task locked for IP: {client_ip}")
|
| 77 |
else:
|
| 78 |
if client_ip in util.IP_Active_Tasks:
|
| 79 |
del util.IP_Active_Tasks[client_ip]
|
| 80 |
# 记录任务完成时间
|
| 81 |
util.IP_Last_Task_Time[client_ip] = time.time()
|
| 82 |
+
# print(f"🔓 Task unlocked for IP: {client_ip}")
|
| 83 |
|
| 84 |
|
| 85 |
|
|
|
|
| 691 |
|
| 692 |
task_priority = 1 if current_count < rate_limit_config.HIGH_PRIORITY_COUNT else 0
|
| 693 |
record_generation_attempt(client_ip, current_phase)
|
| 694 |
+
updated_count = get_ip_generation_count(client_ip)
|
| 695 |
+
|
| 696 |
+
print(f"✅ [Single Edit] Processing started - IP: {client_ip}, Country: {country}, Phase: {current_phase}, Count: {updated_count}, Priority: {task_priority}, Prompt: {prompt.strip()[:50]}...", flush=True)
|
| 697 |
|
| 698 |
input_image_url, result_url, message, task_uuid = process_image_edit(input_image, prompt.strip(), None, progress_callback, priority=task_priority, client_ip=client_ip)
|
| 699 |
|
|
|
|
| 718 |
result_html = create_result_image_html(result_url)
|
| 719 |
action_html = create_action_buttons_html(task_uuid, input_image_url, result_url, prompt, lang, show_like_tip)
|
| 720 |
set_active_task(client_ip, False) # 解锁任务
|
| 721 |
+
print(f"✅ [Single Edit] Completed - IP: {client_ip}, TaskUUID: {task_uuid}, Result: {result_url[:80]}...", flush=True)
|
| 722 |
return result_html, result_url, t("status_completed_message", lang).format(message=message), gr.update(value=action_html, visible=True)
|
| 723 |
else:
|
| 724 |
set_active_task(client_ip, False) # 解锁任务
|
| 725 |
+
print(f"❌ [Single Edit] Failed - IP: {client_ip}, Error: {message}", flush=True)
|
| 726 |
return "", None, t("error_processing_failed", lang).format(message=message), gr.update(visible=False)
|
| 727 |
|
| 728 |
except Exception as e:
|
| 729 |
set_active_task(client_ip, False) # 解锁任务
|
| 730 |
+
print(f"❌ [Single Edit] Exception - IP: {client_ip}, Error: {str(e)}", flush=True)
|
| 731 |
return "", None, t("error_processing_exception", lang).format(error=str(e)), gr.update(visible=False)
|
| 732 |
|
| 733 |
|
|
|
|
| 814 |
set_active_task(client_ip, True)
|
| 815 |
|
| 816 |
record_generation_attempt(client_ip, current_phase)
|
| 817 |
+
updated_count = get_ip_generation_count(client_ip)
|
| 818 |
+
|
| 819 |
+
print(f"✅ [Multi Edit] Processing started - IP: {client_ip}, Country: {country}, Phase: {current_phase}, Count: {updated_count}, Priority: {task_priority}, Images: {len(images)}, Prompt: {prompt.strip()[:50]}...", flush=True)
|
| 820 |
|
| 821 |
input_url, result_url, message, task_uuid = process_multi_image_edit(images, prompt.strip(), progress_callback, priority=task_priority, client_ip=client_ip, is_sr=is_sr)
|
| 822 |
|
|
|
|
| 848 |
status_message = f"{mode_tip}\n{t('status_completed_message', lang).format(message=message)}"
|
| 849 |
|
| 850 |
set_active_task(client_ip, False) # 解锁任务
|
| 851 |
+
print(f"✅ [Multi Edit] Completed - IP: {client_ip}, TaskUUID: {task_uuid}, Result: {result_url[:80]}...", flush=True)
|
| 852 |
return result_html, status_message, gr.update(value=action_html, visible=True)
|
| 853 |
else:
|
| 854 |
set_active_task(client_ip, False) # 解锁任务
|
| 855 |
+
print(f"❌ [Multi Edit] Failed - IP: {client_ip}, Error: {message}", flush=True)
|
| 856 |
return "", t("error_processing_failed", lang).format(message=message), gr.update(visible=False)
|
| 857 |
|
| 858 |
except Exception as e:
|
| 859 |
set_active_task(client_ip, False) # 解锁任务
|
| 860 |
+
print(f"❌ [Multi Edit] Exception - IP: {client_ip}, Error: {str(e)}", flush=True)
|
| 861 |
return "", t("error_processing_exception", lang).format(error=str(e)), gr.update(visible=False)
|
| 862 |
|
| 863 |
|
|
|
|
| 933 |
set_active_task(client_ip, True)
|
| 934 |
|
| 935 |
record_generation_attempt(client_ip, current_phase)
|
| 936 |
+
updated_count = get_ip_generation_count(client_ip)
|
| 937 |
+
|
| 938 |
+
print(f"✅ [Text2Image] Processing started - IP: {client_ip}, Country: {country}, Phase: {current_phase}, Count: {updated_count}, Priority: {task_priority}, Ratio: {aspect_ratio}, Prompt: {prompt.strip()[:50]}...", flush=True)
|
| 939 |
|
| 940 |
result_url, message, task_uuid = process_text_to_image(prompt.strip(), aspect_ratio, progress_callback, priority=task_priority, client_ip=client_ip, is_sr=is_sr, target_area=target_area)
|
| 941 |
|
|
|
|
| 1001 |
status_message = f"{mode_tip}\n{t('status_completed_message', lang).format(message=message)}"
|
| 1002 |
|
| 1003 |
set_active_task(client_ip, False) # 解锁任务
|
| 1004 |
+
print(f"✅ [Text2Image] Completed - IP: {client_ip}, TaskUUID: {task_uuid}, Result: {result_url[:80]}...", flush=True)
|
| 1005 |
return result_html, status_message, gr.update(value=action_html, visible=True)
|
| 1006 |
else:
|
| 1007 |
set_active_task(client_ip, False) # 解锁任务
|
| 1008 |
+
print(f"❌ [Text2Image] Failed - IP: {client_ip}, Error: {message}", flush=True)
|
| 1009 |
return "", t("error_processing_failed", lang).format(message=message), gr.update(visible=False)
|
| 1010 |
|
| 1011 |
except Exception as e:
|
| 1012 |
set_active_task(client_ip, False) # 解锁任务
|
| 1013 |
+
print(f"❌ [Text2Image] Exception - IP: {client_ip}, Error: {str(e)}", flush=True)
|
| 1014 |
return "", t("error_processing_exception", lang).format(error=str(e)), gr.update(visible=False)
|
| 1015 |
|
| 1016 |
|
|
|
|
| 1069 |
|
| 1070 |
task_priority = 1 if current_count < rate_limit_config.HIGH_PRIORITY_COUNT else 0
|
| 1071 |
record_generation_attempt(client_ip, current_phase)
|
| 1072 |
+
updated_count = get_ip_generation_count(client_ip)
|
| 1073 |
+
|
| 1074 |
+
print(f"✅ [Upscale] Processing started - IP: {client_ip}, Country: {country}, Phase: {current_phase}, Count: {updated_count}, Priority: {task_priority}", flush=True)
|
| 1075 |
|
| 1076 |
input_url, result_url, message, task_uuid = process_image_upscale(input_image, progress_callback, priority=task_priority, client_ip=client_ip)
|
| 1077 |
|
|
|
|
| 1120 |
if show_like_tip or lang in ["zh", "hi", "ru"]:
|
| 1121 |
action_html += create_like_tip_html()
|
| 1122 |
set_active_task(client_ip, False) # 解锁任务
|
| 1123 |
+
print(f"✅ [Upscale] Completed - IP: {client_ip}, TaskUUID: {task_uuid}, Result: {result_url[:80]}...", flush=True)
|
| 1124 |
return result_html, t("status_completed_message", lang).format(message=message), gr.update(value=action_html, visible=bool(action_html))
|
| 1125 |
else:
|
| 1126 |
set_active_task(client_ip, False) # 解锁任务
|
| 1127 |
+
print(f"❌ [Upscale] Failed - IP: {client_ip}, Error: {message}", flush=True)
|
| 1128 |
return "", t("error_processing_failed", lang).format(message=message), gr.update(visible=False)
|
| 1129 |
|
| 1130 |
except Exception as e:
|
| 1131 |
set_active_task(client_ip, False) # 解锁任务
|
| 1132 |
+
print(f"❌ [Upscale] Exception - IP: {client_ip}, Error: {str(e)}", flush=True)
|
| 1133 |
return "", t("error_processing_exception", lang).format(error=str(e)), gr.update(visible=False)
|
| 1134 |
|
| 1135 |
|
|
|
|
| 1210 |
set_active_task(client_ip, True)
|
| 1211 |
task_priority = 1 if current_count < rate_limit_config.HIGH_PRIORITY_COUNT else 0
|
| 1212 |
record_generation_attempt(client_ip, current_phase)
|
| 1213 |
+
updated_count = get_ip_generation_count(client_ip)
|
| 1214 |
+
|
| 1215 |
+
has_mask = "Yes" if mask_image is not None else "No"
|
| 1216 |
+
print(f"✅ [FaceSwap] Processing started - IP: {client_ip}, Country: {country}, Phase: {current_phase}, Count: {updated_count}, Priority: {task_priority}, HasMask: {has_mask}", flush=True)
|
| 1217 |
|
| 1218 |
input_url, result_url, message, task_uuid = process_face_swap(target_image, source_face_image, mask_image, progress_callback, priority=task_priority, client_ip=client_ip)
|
| 1219 |
|
|
|
|
| 1262 |
if show_like_tip or lang in ["zh", "hi", "ru"]:
|
| 1263 |
action_html += create_like_tip_html()
|
| 1264 |
set_active_task(client_ip, False)
|
| 1265 |
+
print(f"✅ [FaceSwap] Completed - IP: {client_ip}, TaskUUID: {task_uuid}, Result: {result_url[:80]}...", flush=True)
|
| 1266 |
return result_html, t("status_completed_message", lang).format(message=message), gr.update(value=action_html, visible=bool(action_html))
|
| 1267 |
else:
|
| 1268 |
set_active_task(client_ip, False)
|
| 1269 |
+
print(f"❌ [FaceSwap] Failed - IP: {client_ip}, Error: {message}", flush=True)
|
| 1270 |
return "", t("error_processing_failed", lang).format(message=message), gr.update(visible=False)
|
| 1271 |
|
| 1272 |
except Exception as e:
|
| 1273 |
set_active_task(client_ip, False)
|
| 1274 |
+
print(f"❌ [FaceSwap] Exception - IP: {client_ip}, Error: {str(e)}", flush=True)
|
| 1275 |
return "", t("error_processing_exception", lang).format(error=str(e)), gr.update(visible=False)
|
| 1276 |
|
| 1277 |
|
|
|
|
| 1328 |
set_active_task(client_ip, True)
|
| 1329 |
task_priority = 1 if current_count < rate_limit_config.HIGH_PRIORITY_COUNT else 0
|
| 1330 |
record_generation_attempt(client_ip, current_phase)
|
| 1331 |
+
updated_count = get_ip_generation_count(client_ip)
|
| 1332 |
+
|
| 1333 |
+
force_mode = "Yes" if force_removal else "No"
|
| 1334 |
+
print(f"✅ [Watermark] Processing started - IP: {client_ip}, Country: {country}, Phase: {current_phase}, Count: {updated_count}, Priority: {task_priority}, ForceMode: {force_mode}", flush=True)
|
| 1335 |
|
| 1336 |
input_url, result_url, message, task_uuid = process_watermark_removal(input_image, progress_callback, priority=task_priority, client_ip=client_ip, force_removal=force_removal)
|
| 1337 |
|
|
|
|
| 1375 |
if show_like_tip or lang in ["zh", "hi", "ru"]:
|
| 1376 |
action_html += create_like_tip_html()
|
| 1377 |
set_active_task(client_ip, False)
|
| 1378 |
+
print(f"✅ [Watermark] Completed - IP: {client_ip}, TaskUUID: {task_uuid}, Result: {result_url[:80]}...", flush=True)
|
| 1379 |
return result_html, t("status_completed_message", lang).format(message=message), gr.update(value=action_html, visible=bool(action_html))
|
| 1380 |
else:
|
| 1381 |
set_active_task(client_ip, False)
|
| 1382 |
+
print(f"❌ [Watermark] Failed - IP: {client_ip}, Error: {message}", flush=True)
|
| 1383 |
return "", t("error_processing_failed", lang).format(message=message), gr.update(visible=False)
|
| 1384 |
|
| 1385 |
except Exception as e:
|
| 1386 |
set_active_task(client_ip, False)
|
| 1387 |
+
print(f"❌ [Watermark] Exception - IP: {client_ip}, Error: {str(e)}", flush=True)
|
| 1388 |
return "", t("error_processing_exception", lang).format(error=str(e)), gr.update(visible=False)
|
| 1389 |
|
| 1390 |
|
__lib__/i18n/en.pyc
CHANGED
|
Binary files a/__lib__/i18n/en.pyc and b/__lib__/i18n/en.pyc differ
|
|
|
__lib__/nfsw.pyc
CHANGED
|
Binary files a/__lib__/nfsw.pyc and b/__lib__/nfsw.pyc differ
|
|
|
__lib__/util.pyc
CHANGED
|
Binary files a/__lib__/util.pyc and b/__lib__/util.pyc differ
|
|
|