Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -325,39 +325,16 @@ def generate_upscale_via_hf(image_path):
|
|
| 325 |
|
| 326 |
def master_upscale(input_base64):
|
| 327 |
"""
|
| 328 |
-
超分调度器 (
|
|
|
|
| 329 |
"""
|
| 330 |
-
|
|
|
|
|
|
|
| 331 |
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
try:
|
| 336 |
-
# 1. 解码 Base64 -> Bytes -> Temp File
|
| 337 |
-
image_data = base64.b64decode(input_base64)
|
| 338 |
-
|
| 339 |
-
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as tmp_file:
|
| 340 |
-
tmp_file.write(image_data)
|
| 341 |
-
tmp_path = tmp_file.name
|
| 342 |
-
|
| 343 |
-
print(f"Saved temp file: {tmp_path}", flush=True)
|
| 344 |
-
|
| 345 |
-
# 2. 调用 Segmind
|
| 346 |
-
img = generate_upscale_via_segmind(tmp_path)
|
| 347 |
-
if img: return img
|
| 348 |
-
|
| 349 |
-
# 3. 调用 HF Space (Primary + Backup)
|
| 350 |
-
img = generate_upscale_via_hf(tmp_path)
|
| 351 |
-
if img: return img
|
| 352 |
-
|
| 353 |
-
except Exception as e:
|
| 354 |
-
print(f"Upscale logic error: {e}", flush=True)
|
| 355 |
-
finally:
|
| 356 |
-
if tmp_path and os.path.exists(tmp_path):
|
| 357 |
-
os.remove(tmp_path)
|
| 358 |
-
print("Cleaned up temp file", flush=True)
|
| 359 |
-
|
| 360 |
-
raise gr.Error("Upscaling failed on all routes.")
|
| 361 |
|
| 362 |
# --- 5. 核心调度 ---
|
| 363 |
|
|
|
|
| 325 |
|
| 326 |
def master_upscale(input_base64):
|
| 327 |
"""
|
| 328 |
+
超分调度器 (暂时停用)
|
| 329 |
+
由于目前缺乏稳定的免费算力,暂时直接返回提示。
|
| 330 |
"""
|
| 331 |
+
# 接收到请求后,仅仅打印日志
|
| 332 |
+
if input_base64:
|
| 333 |
+
print(f"--- [UPSCALE] Request received (Len: {len(input_base64)}), but feature is disabled. ---", flush=True)
|
| 334 |
|
| 335 |
+
# 直接抛出 Gradio 错误
|
| 336 |
+
# 这会在前端界面弹出一个红色的 Toast 提示框,显示下面的文字
|
| 337 |
+
raise gr.Error("抱歉,当前暂无稳定的免费高清放大资源可用 (No Resources Available)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
|
| 339 |
# --- 5. 核心调度 ---
|
| 340 |
|