Spaces:
Runtime error
Runtime error
Fix: Absolute rollback to stable Gradio 4.44.1 environment
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import sys
|
| 2 |
import os
|
| 3 |
|
| 4 |
-
# ---
|
| 5 |
try:
|
| 6 |
import huggingface_hub
|
| 7 |
class MockHfFolder:
|
|
@@ -13,7 +13,6 @@ try:
|
|
| 13 |
def delete_token(): pass
|
| 14 |
huggingface_hub.HfFolder = MockHfFolder
|
| 15 |
sys.modules["huggingface_hub.HfFolder"] = MockHfFolder
|
| 16 |
-
setattr(huggingface_hub, "HfFolder", MockHfFolder)
|
| 17 |
except: pass
|
| 18 |
|
| 19 |
try:
|
|
@@ -22,7 +21,7 @@ try:
|
|
| 22 |
except:
|
| 23 |
from unittest.mock import MagicMock
|
| 24 |
sys.modules["audioop"] = MagicMock()
|
| 25 |
-
# -------------------------------------------------------
|
| 26 |
|
| 27 |
import spaces
|
| 28 |
import gradio as gr
|
|
@@ -64,8 +63,6 @@ def generate_t2i(prompt, neg, lora_id, lora_scale, w, h, init_img):
|
|
| 64 |
except: pass
|
| 65 |
kwargs = {"prompt": prompt, "negative_prompt": neg, "num_inference_steps": 30, "guidance_scale": 7.0}
|
| 66 |
if is_img2img:
|
| 67 |
-
if isinstance(init_img, dict):
|
| 68 |
-
init_img = init_img["composite"] if "composite" in init_img else init_img["background"]
|
| 69 |
kwargs["image"] = Image.fromarray(init_img).convert("RGB").resize((int(w), int(h)))
|
| 70 |
kwargs["strength"] = 0.6
|
| 71 |
else:
|
|
@@ -78,8 +75,6 @@ def generate_video(prompt, init_image, lora_scale):
|
|
| 78 |
pipe = load_video().to("cuda")
|
| 79 |
kwargs = {"prompt": prompt, "negative_prompt": NEG_DEFAULT, "num_frames": 49, "num_inference_steps": 30}
|
| 80 |
if init_image is not None:
|
| 81 |
-
if isinstance(init_image, dict):
|
| 82 |
-
init_image = init_image["composite"] if "composite" in init_image else init_image["background"]
|
| 83 |
kwargs["image"] = Image.fromarray(init_image).convert("RGB").resize((768, 512))
|
| 84 |
if lora_scale > 0:
|
| 85 |
kwargs["cross_attention_kwargs"] = {"scale": lora_scale}
|
|
@@ -95,7 +90,7 @@ with gr.Blocks(title="Image Utility v2.1") as demo:
|
|
| 95 |
with gr.Row():
|
| 96 |
with gr.Column():
|
| 97 |
t2i_p = gr.Textbox(label="Input Data String", lines=3)
|
| 98 |
-
t2i_img = gr.Image(label="Base Reference (Optional)", type="numpy"
|
| 99 |
t2i_n = gr.Textbox(label="Excluded Data", value=NEG_DEFAULT)
|
| 100 |
t2i_lora = gr.Textbox(label="Extension ID")
|
| 101 |
t2i_ls = gr.Slider(0, 1.5, 0.8, label="Extension Weight")
|
|
@@ -109,10 +104,10 @@ with gr.Blocks(title="Image Utility v2.1") as demo:
|
|
| 109 |
with gr.Row():
|
| 110 |
with gr.Column():
|
| 111 |
v_p = gr.Textbox(label="Motion Vector String", lines=3)
|
| 112 |
-
v_img = gr.Image(label="Source Buffer", type="numpy"
|
| 113 |
v_ls = gr.Slider(0, 1.5, 0.8, label="Motion Weight")
|
| 114 |
v_btn = gr.Button("Process Sequence", variant="primary")
|
| 115 |
v_out = gr.Video(label="Sequence Output")
|
| 116 |
v_btn.click(generate_video, [v_p, v_img, v_ls], v_out)
|
| 117 |
|
| 118 |
-
demo.queue().launch(show_api=
|
|
|
|
| 1 |
import sys
|
| 2 |
import os
|
| 3 |
|
| 4 |
+
# --- PARCHES DE COMPATIBILIDAD (Gradio 4 + Python 3.13) ---
|
| 5 |
try:
|
| 6 |
import huggingface_hub
|
| 7 |
class MockHfFolder:
|
|
|
|
| 13 |
def delete_token(): pass
|
| 14 |
huggingface_hub.HfFolder = MockHfFolder
|
| 15 |
sys.modules["huggingface_hub.HfFolder"] = MockHfFolder
|
|
|
|
| 16 |
except: pass
|
| 17 |
|
| 18 |
try:
|
|
|
|
| 21 |
except:
|
| 22 |
from unittest.mock import MagicMock
|
| 23 |
sys.modules["audioop"] = MagicMock()
|
| 24 |
+
# --------------------------------------------------------
|
| 25 |
|
| 26 |
import spaces
|
| 27 |
import gradio as gr
|
|
|
|
| 63 |
except: pass
|
| 64 |
kwargs = {"prompt": prompt, "negative_prompt": neg, "num_inference_steps": 30, "guidance_scale": 7.0}
|
| 65 |
if is_img2img:
|
|
|
|
|
|
|
| 66 |
kwargs["image"] = Image.fromarray(init_img).convert("RGB").resize((int(w), int(h)))
|
| 67 |
kwargs["strength"] = 0.6
|
| 68 |
else:
|
|
|
|
| 75 |
pipe = load_video().to("cuda")
|
| 76 |
kwargs = {"prompt": prompt, "negative_prompt": NEG_DEFAULT, "num_frames": 49, "num_inference_steps": 30}
|
| 77 |
if init_image is not None:
|
|
|
|
|
|
|
| 78 |
kwargs["image"] = Image.fromarray(init_image).convert("RGB").resize((768, 512))
|
| 79 |
if lora_scale > 0:
|
| 80 |
kwargs["cross_attention_kwargs"] = {"scale": lora_scale}
|
|
|
|
| 90 |
with gr.Row():
|
| 91 |
with gr.Column():
|
| 92 |
t2i_p = gr.Textbox(label="Input Data String", lines=3)
|
| 93 |
+
t2i_img = gr.Image(label="Base Reference (Optional)", type="numpy")
|
| 94 |
t2i_n = gr.Textbox(label="Excluded Data", value=NEG_DEFAULT)
|
| 95 |
t2i_lora = gr.Textbox(label="Extension ID")
|
| 96 |
t2i_ls = gr.Slider(0, 1.5, 0.8, label="Extension Weight")
|
|
|
|
| 104 |
with gr.Row():
|
| 105 |
with gr.Column():
|
| 106 |
v_p = gr.Textbox(label="Motion Vector String", lines=3)
|
| 107 |
+
v_img = gr.Image(label="Source Buffer", type="numpy")
|
| 108 |
v_ls = gr.Slider(0, 1.5, 0.8, label="Motion Weight")
|
| 109 |
v_btn = gr.Button("Process Sequence", variant="primary")
|
| 110 |
v_out = gr.Video(label="Sequence Output")
|
| 111 |
v_btn.click(generate_video, [v_p, v_img, v_ls], v_out)
|
| 112 |
|
| 113 |
+
demo.queue().launch(show_api=False)
|