Spaces:
Runtime error
Runtime error
Fix: Absolute pinning of huggingface-hub and dual-layer HfFolder injection
Browse files
app.py
CHANGED
|
@@ -1,12 +1,43 @@
|
|
| 1 |
import sys
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
try:
|
| 4 |
import audioop_lts
|
| 5 |
sys.modules["audioop"] = audioop_lts
|
| 6 |
-
|
|
|
|
| 7 |
from unittest.mock import MagicMock
|
| 8 |
sys.modules["audioop"] = MagicMock()
|
| 9 |
-
# ------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
import spaces
|
| 12 |
import gradio as gr
|
|
@@ -56,7 +87,6 @@ def generate_video(prompt, init_image, lora_scale):
|
|
| 56 |
kwargs = {"prompt": prompt, "negative_prompt": NEG_DEFAULT, "num_frames": 49,
|
| 57 |
"num_inference_steps": 30, "generator": torch.Generator("cuda").manual_seed(42)}
|
| 58 |
if init_image is not None:
|
| 59 |
-
# Conversi贸n segura de imagen para Gradio 5
|
| 60 |
if isinstance(init_image, dict):
|
| 61 |
init_image = init_image["composite"] if "composite" in init_image else init_image["background"]
|
| 62 |
kwargs["image"] = Image.fromarray(init_image).convert("RGB").resize((768, 512))
|
|
@@ -67,7 +97,6 @@ def generate_video(prompt, init_image, lora_scale):
|
|
| 67 |
export_to_video(output.frames[0], tmp.name, fps=24)
|
| 68 |
return tmp.name
|
| 69 |
|
| 70 |
-
# INTERFAZ
|
| 71 |
with gr.Blocks(title="Image Utility v2.1") as demo:
|
| 72 |
gr.HTML("<h1 style='text-align:center;'>馃洜 Image Processing Utility v2.1.4</h1>")
|
| 73 |
with gr.Tabs():
|
|
@@ -89,12 +118,10 @@ with gr.Blocks(title="Image Utility v2.1") as demo:
|
|
| 89 |
with gr.Row():
|
| 90 |
with gr.Column():
|
| 91 |
v_p = gr.Textbox(label="Motion Vector String", lines=3)
|
| 92 |
-
# Mejora en el componente de imagen para permitir carga directa
|
| 93 |
v_img = gr.Image(label="Source Buffer", type="numpy", sources=["upload", "clipboard"])
|
| 94 |
v_ls = gr.Slider(0, 1.5, 0.8, label="Motion Weight")
|
| 95 |
v_btn = gr.Button("Process Sequence", variant="primary")
|
| 96 |
v_out = gr.Video(label="Sequence Output")
|
| 97 |
v_btn.click(generate_video, [v_p, v_img, v_ls], v_out)
|
| 98 |
|
| 99 |
-
|
| 100 |
-
demo.queue(api_open=True).launch(show_api=True)
|
|
|
|
| 1 |
import sys
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
# --- L脥NEA 1: PARCHE DE EMERGENCIA TOTAL (HfFolder + audioop) ---
|
| 5 |
+
try:
|
| 6 |
+
import huggingface_hub
|
| 7 |
+
# Si la pieza falta en la librer铆a del servidor, la inyectamos manualmente
|
| 8 |
+
if not hasattr(huggingface_hub, "HfFolder"):
|
| 9 |
+
class MockHfFolder:
|
| 10 |
+
@staticmethod
|
| 11 |
+
def get_token(): return os.getenv("HF_TOKEN")
|
| 12 |
+
@staticmethod
|
| 13 |
+
def save_token(token): pass
|
| 14 |
+
@staticmethod
|
| 15 |
+
def delete_token(): pass
|
| 16 |
+
huggingface_hub.HfFolder = MockHfFolder
|
| 17 |
+
sys.modules["huggingface_hub.HfFolder"] = MockHfFolder
|
| 18 |
+
print("HfFolder Patch Applied")
|
| 19 |
+
except: pass
|
| 20 |
+
|
| 21 |
try:
|
| 22 |
import audioop_lts
|
| 23 |
sys.modules["audioop"] = audioop_lts
|
| 24 |
+
print("Audioop Patch Applied")
|
| 25 |
+
except:
|
| 26 |
from unittest.mock import MagicMock
|
| 27 |
sys.modules["audioop"] = MagicMock()
|
| 28 |
+
# --------------------------------------------------------------
|
| 29 |
+
|
| 30 |
+
# --- PARCHE PARA EL BUG DE 'BOOL' EN GRADIO_CLIENT ---
|
| 31 |
+
try:
|
| 32 |
+
import gradio_client.utils as client_utils
|
| 33 |
+
if hasattr(client_utils, "get_type"):
|
| 34 |
+
old_get_type = client_utils.get_type
|
| 35 |
+
def new_get_type(schema):
|
| 36 |
+
if isinstance(schema, bool): return "Any"
|
| 37 |
+
return old_get_type(schema)
|
| 38 |
+
client_utils.get_type = new_get_type
|
| 39 |
+
except: pass
|
| 40 |
+
# -----------------------------------------------------
|
| 41 |
|
| 42 |
import spaces
|
| 43 |
import gradio as gr
|
|
|
|
| 87 |
kwargs = {"prompt": prompt, "negative_prompt": NEG_DEFAULT, "num_frames": 49,
|
| 88 |
"num_inference_steps": 30, "generator": torch.Generator("cuda").manual_seed(42)}
|
| 89 |
if init_image is not None:
|
|
|
|
| 90 |
if isinstance(init_image, dict):
|
| 91 |
init_image = init_image["composite"] if "composite" in init_image else init_image["background"]
|
| 92 |
kwargs["image"] = Image.fromarray(init_image).convert("RGB").resize((768, 512))
|
|
|
|
| 97 |
export_to_video(output.frames[0], tmp.name, fps=24)
|
| 98 |
return tmp.name
|
| 99 |
|
|
|
|
| 100 |
with gr.Blocks(title="Image Utility v2.1") as demo:
|
| 101 |
gr.HTML("<h1 style='text-align:center;'>馃洜 Image Processing Utility v2.1.4</h1>")
|
| 102 |
with gr.Tabs():
|
|
|
|
| 118 |
with gr.Row():
|
| 119 |
with gr.Column():
|
| 120 |
v_p = gr.Textbox(label="Motion Vector String", lines=3)
|
|
|
|
| 121 |
v_img = gr.Image(label="Source Buffer", type="numpy", sources=["upload", "clipboard"])
|
| 122 |
v_ls = gr.Slider(0, 1.5, 0.8, label="Motion Weight")
|
| 123 |
v_btn = gr.Button("Process Sequence", variant="primary")
|
| 124 |
v_out = gr.Video(label="Sequence Output")
|
| 125 |
v_btn.click(generate_video, [v_p, v_img, v_ls], v_out)
|
| 126 |
|
| 127 |
+
demo.queue().launch(show_api=True)
|
|
|