Tokymin commited on
Commit
ba21e8d
1 Parent(s): 51bcf06

修正了一点小错误

Browse files
Files changed (2) hide show
  1. .gitignore +1 -0
  2. generate.py +19 -0
.gitignore CHANGED
@@ -1,3 +1,4 @@
1
  *.bin
2
  *.safetensors
3
  /.idea
 
 
1
  *.bin
2
  *.safetensors
3
  /.idea
4
+ /output_videos
generate.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import torch
3
+ from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
4
+ from diffusers.utils import export_to_video
5
+ from datetime import datetime
6
+
7
+ pipe = DiffusionPipeline.from_pretrained(r"J:\Projects\Video-Projects\text-to-video-ms-1.7b", torch_dtype=torch.float16, variant="fp16")
8
+ pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
9
+ pipe.enable_model_cpu_offload()
10
+ timestamp_str = datetime.now().strftime("%Y-%m-%d-%H%M%S")
11
+
12
+ output_video_path=f"J:/Projects/Video-Projects/text-to-video-ms-1.7b/output_videos/{timestamp_str}.mp4"
13
+ prompt = "Spiderman is surfing"
14
+
15
+ video_frames = pipe(prompt, num_inference_steps=25).frames
16
+ video_frames_np = [np.array(frame) for frame in video_frames]
17
+ video_frames_np = np.concatenate(video_frames_np, axis=0)
18
+
19
+ video_path = export_to_video(video_frames_np,output_video_path)