Spaces:
Running
Running
Commit
·
8b6a74d
1
Parent(s):
9d668ad
options/Video_model/Model.py
CHANGED
@@ -3,6 +3,8 @@ import torch,os,imageio
|
|
3 |
from diffusers import StableVideoDiffusionPipeline
|
4 |
from diffusers.utils import load_image, export_to_video
|
5 |
from PIL import Image
|
|
|
|
|
6 |
import numpy as np
|
7 |
|
8 |
# Check if CUDA (GPU) is available, otherwise use CPU
|
@@ -37,13 +39,11 @@ def Video(image):
|
|
37 |
# Set random seed for reproducibility
|
38 |
generator = torch.manual_seed(42)
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
# Generate the video frames
|
44 |
frames = pipeline(image, decode_chunk_size=8, generator=generator).frames[0]
|
45 |
-
path="generated.mp4"
|
46 |
# Export the frames to a video file
|
47 |
-
|
48 |
-
|
49 |
-
return path
|
|
|
3 |
from diffusers import StableVideoDiffusionPipeline
|
4 |
from diffusers.utils import load_image, export_to_video
|
5 |
from PIL import Image
|
6 |
+
from glob import glob
|
7 |
+
from pathlib import Path
|
8 |
import numpy as np
|
9 |
|
10 |
# Check if CUDA (GPU) is available, otherwise use CPU
|
|
|
39 |
# Set random seed for reproducibility
|
40 |
generator = torch.manual_seed(42)
|
41 |
|
42 |
+
os.makedirs(output_folder, exist_ok=True)
|
43 |
+
base_count = len(glob(os.path.join(output_folder, "*.mp4")))
|
44 |
+
video_path = os.path.join(output_folder, f"{base_count:06d}.mp4")
|
45 |
# Generate the video frames
|
46 |
frames = pipeline(image, decode_chunk_size=8, generator=generator).frames[0]
|
|
|
47 |
# Export the frames to a video file
|
48 |
+
export_to_video(frames, video_path, fps=fps_id)
|
49 |
+
return video_path
|
|
options/Video_model/__pycache__/Model.cpython-310.pyc
CHANGED
Binary files a/options/Video_model/__pycache__/Model.cpython-310.pyc and b/options/Video_model/__pycache__/Model.cpython-310.pyc differ
|
|