Spaces:
Running
on
A10G
Running
on
A10G
Commit
•
3e0fef3
1
Parent(s):
a0b90fa
Update app.py
Browse files
app.py
CHANGED
@@ -17,7 +17,7 @@ pipe_xl.scheduler = DPMSolverMultistepScheduler.from_config(pipe_xl.scheduler.co
|
|
17 |
pipe_xl.enable_model_cpu_offload()
|
18 |
pipe_xl.to("cuda")
|
19 |
|
20 |
-
def convert_mp4_to_frames(video_path
|
21 |
# Read the video file
|
22 |
video = cv2.VideoCapture(video_path)
|
23 |
|
@@ -26,7 +26,10 @@ def convert_mp4_to_frames(video_path, duration=3):
|
|
26 |
|
27 |
# Calculate the number of frames to extract
|
28 |
# Note: we cannot go beyond 3 seconds on the large A10G
|
29 |
-
num_frames = int(fps * min(duration, 3))
|
|
|
|
|
|
|
30 |
|
31 |
frames = []
|
32 |
frame_count = 0
|
@@ -64,7 +67,7 @@ def infer(prompt, video_in, denoise_strength, secret_token):
|
|
64 |
negative_prompt = "text, watermark, copyright, blurry, cropped, noisy, pixelated, nsfw"
|
65 |
|
66 |
|
67 |
-
video = convert_mp4_to_frames(video_in
|
68 |
video_resized = [Image.fromarray(frame).resize((1024, 576)) for frame in video]
|
69 |
video_frames = pipe_xl(prompt, negative_prompt=negative_prompt, video=video_resized, strength=denoise_strength).frames
|
70 |
video_path = export_to_video(video_frames, output_video_path="xl_result.mp4")
|
|
|
17 |
pipe_xl.enable_model_cpu_offload()
|
18 |
pipe_xl.to("cuda")
|
19 |
|
20 |
+
def convert_mp4_to_frames(video_path):
|
21 |
# Read the video file
|
22 |
video = cv2.VideoCapture(video_path)
|
23 |
|
|
|
26 |
|
27 |
# Calculate the number of frames to extract
|
28 |
# Note: we cannot go beyond 3 seconds on the large A10G
|
29 |
+
# num_frames = int(fps * min(duration, 3))
|
30 |
+
|
31 |
+
# let's use a fixed max for now, no need to have a duration field
|
32 |
+
num_frames = int(fps * 3)
|
33 |
|
34 |
frames = []
|
35 |
frame_count = 0
|
|
|
67 |
negative_prompt = "text, watermark, copyright, blurry, cropped, noisy, pixelated, nsfw"
|
68 |
|
69 |
|
70 |
+
video = convert_mp4_to_frames(video_in)
|
71 |
video_resized = [Image.fromarray(frame).resize((1024, 576)) for frame in video]
|
72 |
video_frames = pipe_xl(prompt, negative_prompt=negative_prompt, video=video_resized, strength=denoise_strength).frames
|
73 |
video_path = export_to_video(video_frames, output_video_path="xl_result.mp4")
|