Omnibus commited on
Commit
b7d5755
·
1 Parent(s): 793e084

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -4,30 +4,30 @@ from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
4
  from diffusers.utils import export_to_video
5
 
6
  device = "cuda" if torch.cuda.is_available() else "cpu"
7
-
8
  # load pipeline
9
- pipe = DiffusionPipeline.from_pretrained("cerspense/zeroscope_v2_576w").to(device)
10
- pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
11
- if device == "cuda":
12
  # optimize for GPU memory
13
- pipe.enable_model_cpu_offload()
14
- else:
15
- pass
16
- pipe.enable_vae_slicing()
17
 
18
  def ttv():
19
 
20
  # generate
21
  prompt = "Spiderman is surfing. Darth Vader is also surfing and following Spiderman"
22
- video_frames = pipe(prompt, num_inference_steps=25, num_frames=200).frames
23
 
24
  # convent to video
25
- video_path = export_to_video(video_frames)
26
- return video_path
27
 
28
  with gr.Blocks() as app:
29
  inp = gr.Textbox()
30
  btn = gr.Button()
31
- outp = gr.Video()
32
  btn.click(ttv,None,outp)
33
  app.launch()
 
4
  from diffusers.utils import export_to_video
5
 
6
  device = "cuda" if torch.cuda.is_available() else "cpu"
7
+ model = gr.Interface("models/cerspense/zeroscope_v2_576w")
8
  # load pipeline
9
+ #pipe = DiffusionPipeline.from_pretrained("cerspense/zeroscope_v2_576w").to(device)
10
+ #pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
11
+ #if device == "cuda":
12
  # optimize for GPU memory
13
+ # pipe.enable_model_cpu_offload()
14
+ #else:
15
+ # pass
16
+ #pipe.enable_vae_slicing()
17
 
18
  def ttv():
19
 
20
  # generate
21
  prompt = "Spiderman is surfing. Darth Vader is also surfing and following Spiderman"
22
+ video_frames = model(prompt, num_inference_steps=25, num_frames=20)
23
 
24
  # convent to video
25
+ #video_path = export_to_video(video_frames)
26
+ return video_frames
27
 
28
  with gr.Blocks() as app:
29
  inp = gr.Textbox()
30
  btn = gr.Button()
31
+ outp = gr.Gallery()
32
  btn.click(ttv,None,outp)
33
  app.launch()