Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,19 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
-
#import gradio.helpers
|
3 |
import torch
|
4 |
import os
|
5 |
from glob import glob
|
6 |
from pathlib import Path
|
7 |
from typing import Optional
|
8 |
-
|
9 |
from diffusers import StableVideoDiffusionPipeline
|
10 |
from diffusers.utils import load_image, export_to_video
|
11 |
from PIL import Image
|
12 |
-
|
13 |
import uuid
|
14 |
import random
|
15 |
from huggingface_hub import hf_hub_download
|
16 |
|
17 |
-
#gradio.helpers.CACHED_FOLDER = '/data/cache'
|
18 |
-
|
19 |
pipe = StableVideoDiffusionPipeline.from_pretrained(
|
20 |
-
"stabilityai/stable-video-diffusion-img2vid-xt", torch_dtype=torch.float16, variant="fp16"
|
21 |
)
|
22 |
pipe.to("cuda")
|
23 |
pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
|
@@ -25,6 +21,7 @@ pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
|
|
25 |
|
26 |
max_64_bit_int = 2**63 - 1
|
27 |
|
|
|
28 |
def sample(
|
29 |
image: Image,
|
30 |
seed: Optional[int] = 42,
|
@@ -48,7 +45,7 @@ def sample(
|
|
48 |
base_count = len(glob(os.path.join(output_folder, "*.mp4")))
|
49 |
video_path = os.path.join(output_folder, f"{base_count:06d}.mp4")
|
50 |
|
51 |
-
frames = pipe(image, decode_chunk_size=decoding_t, generator=generator, motion_bucket_id=motion_bucket_id, noise_aug_strength=0.1, num_frames=
|
52 |
export_to_video(frames, video_path, fps=fps_id)
|
53 |
torch.manual_seed(seed)
|
54 |
|
|
|
1 |
+
import spaces
|
2 |
import gradio as gr
|
|
|
3 |
import torch
|
4 |
import os
|
5 |
from glob import glob
|
6 |
from pathlib import Path
|
7 |
from typing import Optional
|
|
|
8 |
from diffusers import StableVideoDiffusionPipeline
|
9 |
from diffusers.utils import load_image, export_to_video
|
10 |
from PIL import Image
|
|
|
11 |
import uuid
|
12 |
import random
|
13 |
from huggingface_hub import hf_hub_download
|
14 |
|
|
|
|
|
15 |
pipe = StableVideoDiffusionPipeline.from_pretrained(
|
16 |
+
"stabilityai/stable-video-diffusion-img2vid-xt-1-1", torch_dtype=torch.float16, variant="fp16"
|
17 |
)
|
18 |
pipe.to("cuda")
|
19 |
pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
|
|
|
21 |
|
22 |
max_64_bit_int = 2**63 - 1
|
23 |
|
24 |
+
@spaces.GPU
|
25 |
def sample(
|
26 |
image: Image,
|
27 |
seed: Optional[int] = 42,
|
|
|
45 |
base_count = len(glob(os.path.join(output_folder, "*.mp4")))
|
46 |
video_path = os.path.join(output_folder, f"{base_count:06d}.mp4")
|
47 |
|
48 |
+
frames = pipe(image, decode_chunk_size=decoding_t, generator=generator, motion_bucket_id=motion_bucket_id, noise_aug_strength=0.1, num_frames=14).frames[0]
|
49 |
export_to_video(frames, video_path, fps=fps_id)
|
50 |
torch.manual_seed(seed)
|
51 |
|