Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
import tempfile
|
4 |
-
import spaces
|
5 |
from diffusers import StableVideoDiffusionPipeline
|
6 |
from diffusers.utils import export_to_video
|
7 |
|
@@ -13,7 +19,6 @@ pipe = StableVideoDiffusionPipeline.from_pretrained(
|
|
13 |
MODEL, torch_dtype=torch.float16
|
14 |
).to("cuda")
|
15 |
|
16 |
-
@spaces.GPU(duration=300)
|
17 |
def infer(first_image, last_image, prompt, guidance=7.5, frames=25):
|
18 |
# Generate the in-between frames
|
19 |
video = pipe(
|
@@ -23,10 +28,10 @@ def infer(first_image, last_image, prompt, guidance=7.5, frames=25):
|
|
23 |
guidance_scale=guidance,
|
24 |
num_frames=frames
|
25 |
).frames
|
26 |
-
# Export
|
27 |
mp4_path = tempfile.NamedTemporaryFile(suffix=".mp4", delete=False).name
|
28 |
export_to_video(video, mp4_path, fps=15)
|
29 |
-
return mp4_path # Gradio will auto-encode
|
30 |
|
31 |
# Build a minimal Gradio interface
|
32 |
demo = gr.Interface(
|
@@ -43,4 +48,4 @@ demo = gr.Interface(
|
|
43 |
)
|
44 |
|
45 |
# Enable the REST API
|
46 |
-
demo.queue(concurrency_count=1).launch(show_api=True
|
|
|
1 |
+
import huggingface_hub as hf_hub
|
2 |
+
# Shim missing APIs removed in huggingface_hub >= 0.26.0
|
3 |
+
if not hasattr(hf_hub, "cached_download"):
|
4 |
+
hf_hub.cached_download = hf_hub.hf_hub_download
|
5 |
+
if not hasattr(hf_hub, "model_info"):
|
6 |
+
hf_hub.model_info = hf_hub.get_model_info
|
7 |
+
|
8 |
import gradio as gr
|
9 |
import torch
|
10 |
import tempfile
|
|
|
11 |
from diffusers import StableVideoDiffusionPipeline
|
12 |
from diffusers.utils import export_to_video
|
13 |
|
|
|
19 |
MODEL, torch_dtype=torch.float16
|
20 |
).to("cuda")
|
21 |
|
|
|
22 |
def infer(first_image, last_image, prompt, guidance=7.5, frames=25):
|
23 |
# Generate the in-between frames
|
24 |
video = pipe(
|
|
|
28 |
guidance_scale=guidance,
|
29 |
num_frames=frames
|
30 |
).frames
|
31 |
+
# Export to a temporary MP4 file
|
32 |
mp4_path = tempfile.NamedTemporaryFile(suffix=".mp4", delete=False).name
|
33 |
export_to_video(video, mp4_path, fps=15)
|
34 |
+
return mp4_path # Gradio will auto-encode to base64 for the API
|
35 |
|
36 |
# Build a minimal Gradio interface
|
37 |
demo = gr.Interface(
|
|
|
48 |
)
|
49 |
|
50 |
# Enable the REST API
|
51 |
+
demo.queue(concurrency_count=1).launch(show_api=True)
|