Spaces:
Runtime error
Runtime error
corrected frame index order
Browse files
app.py
CHANGED
@@ -105,6 +105,7 @@ def get_frames(video_in, img_type):
|
|
105 |
clip = VideoFileClip(video_in)
|
106 |
|
107 |
#check fps
|
|
|
108 |
if clip.fps > 30:
|
109 |
print("vide rate is over 30, resetting to 30")
|
110 |
clip_resized = clip.resize(height=512)
|
@@ -114,6 +115,7 @@ def get_frames(video_in, img_type):
|
|
114 |
clip_resized = clip.resize(height=512)
|
115 |
clip_resized.write_videofile(f"{img_type}_video_resized.mp4", fps=clip.fps)
|
116 |
|
|
|
117 |
print("video resized to 512 height")
|
118 |
|
119 |
# Opens the Video file with CV2
|
@@ -127,11 +129,13 @@ def get_frames(video_in, img_type):
|
|
127 |
if ret == False:
|
128 |
break
|
129 |
if img_type == "source":
|
130 |
-
|
131 |
-
|
|
|
132 |
elif img_type == "mask":
|
133 |
-
|
134 |
-
|
|
|
135 |
i+=1
|
136 |
|
137 |
cap.release()
|
@@ -161,12 +165,10 @@ def infer_auto(project_name, video_in, subject_to_remove):
|
|
161 |
|
162 |
video_frames = get_frames(video_in, "source")
|
163 |
print(video_frames[0])
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
masks_frames = get_frames(matte_video, "mask")
|
168 |
print(masks_frames[0])
|
169 |
-
|
170 |
|
171 |
# Create the directory if it doesn't exist
|
172 |
my_video_directory = f"{project_name}"
|
|
|
105 |
clip = VideoFileClip(video_in)
|
106 |
|
107 |
#check fps
|
108 |
+
|
109 |
if clip.fps > 30:
|
110 |
print("vide rate is over 30, resetting to 30")
|
111 |
clip_resized = clip.resize(height=512)
|
|
|
115 |
clip_resized = clip.resize(height=512)
|
116 |
clip_resized.write_videofile(f"{img_type}_video_resized.mp4", fps=clip.fps)
|
117 |
|
118 |
+
|
119 |
print("video resized to 512 height")
|
120 |
|
121 |
# Opens the Video file with CV2
|
|
|
129 |
if ret == False:
|
130 |
break
|
131 |
if img_type == "source":
|
132 |
+
filename = f'{i:05d}.jpg'
|
133 |
+
cv2.imwrite(filename, frame)
|
134 |
+
frames.append(filename)
|
135 |
elif img_type == "mask":
|
136 |
+
filename = f'{i:05d}.png'
|
137 |
+
cv2.imwrite(filename, frame)
|
138 |
+
frames.append(filename)
|
139 |
i+=1
|
140 |
|
141 |
cap.release()
|
|
|
165 |
|
166 |
video_frames = get_frames(video_in, "source")
|
167 |
print(video_frames[0])
|
168 |
+
|
|
|
|
|
169 |
masks_frames = get_frames(matte_video, "mask")
|
170 |
print(masks_frames[0])
|
171 |
+
|
172 |
|
173 |
# Create the directory if it doesn't exist
|
174 |
my_video_directory = f"{project_name}"
|