fffiloni commited on
Commit
f250ee0
·
1 Parent(s): 51c2dc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -1,4 +1,6 @@
1
  import gradio as gr
 
 
2
  from share_btn import community_icon_html, loading_icon_html, share_js
3
  import torch
4
  from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
@@ -8,12 +10,25 @@ pipe = DiffusionPipeline.from_pretrained("cerspense/zeroscope_v2_576w", torch_dt
8
  pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
9
  pipe.enable_model_cpu_offload()
10
 
 
 
 
 
 
 
 
11
  def infer(prompt):
12
  #prompt = "Darth Vader is surfing on waves"
13
  video_frames = pipe(prompt, num_inference_steps=40, height=320, width=576, num_frames=24).frames
14
  video_path = export_to_video(video_frames)
15
  print(video_path)
16
- return video_path, gr.Group.update(visible=True)
 
 
 
 
 
 
17
 
18
  css = """
19
  #col-container {max-width: 510px; margin-left: auto; margin-right: auto;}
 
1
  import gradio as gr
2
+ import numpy as np
3
+ from PIL import Image
4
  from share_btn import community_icon_html, loading_icon_html, share_js
5
  import torch
6
  from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
 
10
  pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
11
  pipe.enable_model_cpu_offload()
12
 
13
+ pipe_xl = DiffusionPipeline.from_pretrained("cerspense/zeroscope_v2_XL", torch_dtype=torch.float16, revision="refs/pr/17")
14
+ pipe_xl.vae.enable_slicing()
15
+ pipe_xl.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
16
+ pipe_xl.enable_model_cpu_offload()
17
+
18
+
19
+
20
  def infer(prompt):
21
  #prompt = "Darth Vader is surfing on waves"
22
  video_frames = pipe(prompt, num_inference_steps=40, height=320, width=576, num_frames=24).frames
23
  video_path = export_to_video(video_frames)
24
  print(video_path)
25
+
26
+ video = [Image.fromarray(frame).resize((1024, 576)) for frame in video_frames]
27
+
28
+ video_frames = pipe_xl(prompt, video=video, strength=0.6).frames
29
+ video_path = export_to_video(video_frames, output_video_path="xl_result.mp4")
30
+
31
+ return "xl_result.mp4", gr.Group.update(visible=True)
32
 
33
  css = """
34
  #col-container {max-width: 510px; margin-left: auto; margin-right: auto;}