Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -13,6 +13,7 @@ def get_frames(video_in):
|
|
13 |
clip = mp.VideoFileClip(video_in)
|
14 |
clip_resized = clip.resize(height=512)
|
15 |
clip_resized.write_videofile("video_resized.mp4")
|
|
|
16 |
|
17 |
# Opens the Video file with CV2
|
18 |
cap= cv2.VideoCapture("video_resized.mp4")
|
@@ -29,11 +30,11 @@ def get_frames(video_in):
|
|
29 |
|
30 |
cap.release()
|
31 |
cv2.destroyAllWindows()
|
32 |
-
|
33 |
return frames, fps
|
34 |
|
35 |
def create_video(frames, fps):
|
36 |
-
|
37 |
clip = ImageSequenceClip(frames, fps=fps)
|
38 |
clip.write_videofile("movie.mp4", fps=fps)
|
39 |
|
@@ -41,14 +42,14 @@ def create_video(frames, fps):
|
|
41 |
|
42 |
|
43 |
def infer(prompt,video_in, seed_in, trim_value):
|
44 |
-
|
45 |
break_vid = get_frames(video_in)
|
46 |
|
47 |
frames_list= break_vid[0]
|
48 |
fps = break_vid[1]
|
49 |
n_frame = int(trim_value*fps)
|
50 |
result_frames = []
|
51 |
-
|
52 |
for i in frames_list[0:n_frame]:
|
53 |
pix2pix_img = pix2pix(prompt,5.5,1.5,i,15,"",512,512,seed_in,fn_index=0)
|
54 |
images = [os.path.join(pix2pix_img[0], img) for img in os.listdir(pix2pix_img[0])]
|
@@ -56,7 +57,7 @@ def infer(prompt,video_in, seed_in, trim_value):
|
|
56 |
print("frame " + i + ": done;")
|
57 |
|
58 |
final_vid = create_video(result_frames, fps)
|
59 |
-
|
60 |
return final_vid
|
61 |
|
62 |
title = """
|
|
|
13 |
clip = mp.VideoFileClip(video_in)
|
14 |
clip_resized = clip.resize(height=512)
|
15 |
clip_resized.write_videofile("video_resized.mp4")
|
16 |
+
print("video resized to 512 height")
|
17 |
|
18 |
# Opens the Video file with CV2
|
19 |
cap= cv2.VideoCapture("video_resized.mp4")
|
|
|
30 |
|
31 |
cap.release()
|
32 |
cv2.destroyAllWindows()
|
33 |
+
print("broke the video into frames")
|
34 |
return frames, fps
|
35 |
|
36 |
def create_video(frames, fps):
|
37 |
+
print("building video result")
|
38 |
clip = ImageSequenceClip(frames, fps=fps)
|
39 |
clip.write_videofile("movie.mp4", fps=fps)
|
40 |
|
|
|
42 |
|
43 |
|
44 |
def infer(prompt,video_in, seed_in, trim_value):
|
45 |
+
print(prompt)
|
46 |
break_vid = get_frames(video_in)
|
47 |
|
48 |
frames_list= break_vid[0]
|
49 |
fps = break_vid[1]
|
50 |
n_frame = int(trim_value*fps)
|
51 |
result_frames = []
|
52 |
+
print("set stop frames to: " + n_frame)
|
53 |
for i in frames_list[0:n_frame]:
|
54 |
pix2pix_img = pix2pix(prompt,5.5,1.5,i,15,"",512,512,seed_in,fn_index=0)
|
55 |
images = [os.path.join(pix2pix_img[0], img) for img in os.listdir(pix2pix_img[0])]
|
|
|
57 |
print("frame " + i + ": done;")
|
58 |
|
59 |
final_vid = create_video(result_frames, fps)
|
60 |
+
print("finished !")
|
61 |
return final_vid
|
62 |
|
63 |
title = """
|