jbilcke-hf HF Staff commited on
Commit
0623a6a
·
1 Parent(s): 8e303a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -24,7 +24,8 @@ def convert_mp4_to_frames(video_path, duration=3):
24
  fps = video.get(cv2.CAP_PROP_FPS)
25
 
26
  # Calculate the number of frames to extract
27
- num_frames = int(fps * duration)
 
28
 
29
  frames = []
30
  frame_count = 0
@@ -61,8 +62,8 @@ def infer(prompt, video_in, denoise_strength, duration, secret_token: str = '')
61
 
62
  negative_prompt = "text, watermark, copyright, blurry, cropped, noisy, pixelated, nsfw"
63
 
64
- # we cannot go beyond 3 seconds on the large A10G
65
- video = convert_mp4_to_frames(video_in, min(duration, 3))
66
  video_resized = [Image.fromarray(frame).resize((1024, 576)) for frame in video]
67
  video_frames = pipe_xl(prompt, negative_prompt=negative_prompt, video=video_resized, strength=denoise_strength).frames
68
  video_path = export_to_video(video_frames, output_video_path="xl_result.mp4")
@@ -84,7 +85,7 @@ with gr.Blocks() as demo:
84
  video_result = gr.Video(label="Video Output", elem_id="video-output")
85
 
86
  submit_btn.click(fn=infer,
87
- inputs=[prompt_in, video_in, denoise_strength, secret_token],
88
  outputs=[video_result],
89
  api_name="zero_xl"
90
  )
 
24
  fps = video.get(cv2.CAP_PROP_FPS)
25
 
26
  # Calculate the number of frames to extract
27
+ # Note: we cannot go beyond 3 seconds on the large A10G
28
+ num_frames = int(fps * min(duration, 3))
29
 
30
  frames = []
31
  frame_count = 0
 
62
 
63
  negative_prompt = "text, watermark, copyright, blurry, cropped, noisy, pixelated, nsfw"
64
 
65
+
66
+ video = convert_mp4_to_frames(video_in, duration)
67
  video_resized = [Image.fromarray(frame).resize((1024, 576)) for frame in video]
68
  video_frames = pipe_xl(prompt, negative_prompt=negative_prompt, video=video_resized, strength=denoise_strength).frames
69
  video_path = export_to_video(video_frames, output_video_path="xl_result.mp4")
 
85
  video_result = gr.Video(label="Video Output", elem_id="video-output")
86
 
87
  submit_btn.click(fn=infer,
88
+ inputs=[prompt_in, video_in, denoise_strength, duration, secret_token],
89
  outputs=[video_result],
90
  api_name="zero_xl"
91
  )