cris2312 commited on
Commit
227b955
·
1 Parent(s): 359700a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -3
app.py CHANGED
@@ -1,4 +1,18 @@
1
- import streamlit as st
 
 
2
 
3
- x = st.slider('Select a value')
4
- st.write(x, 'squared is', x * x)
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
3
+ from diffusers.utils import export_to_video
4
 
5
+ # load pipeline
6
+ pipe = DiffusionPipeline.from_pretrained("damo-vilab/text-to-video-ms-1.7b", torch_dtype=torch.float16, variant="fp16")
7
+ pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
8
+
9
+ # optimize for GPU memory
10
+ pipe.enable_model_cpu_offload()
11
+ pipe.enable_vae_slicing()
12
+
13
+ # generate
14
+ prompt = "Spiderman is surfing. Darth Vader is also surfing and following Spiderman"
15
+ video_frames = pipe(prompt, num_inference_steps=25, num_frames=200).frames
16
+
17
+ # convent to video
18
+ video_path = export_to_video(video_frames)