Update app.py
Browse files
app.py
CHANGED
@@ -116,6 +116,20 @@ def infer(url_in,interpolation,fps_output,resize_n,winsize,o_flow):
|
|
116 |
for idx, frame in enumerate(frames_list[0:int(n_frame)]):
|
117 |
if idx < len(frames_list) - 1:
|
118 |
next_frame = frames_list[idx+1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
interpolated_frames = do_interpolation(frame, next_frame, interpolation) # should return a list of 3 interpolated frames
|
120 |
break_interpolated_video = get_frames(interpolated_frames, "interpol", f"{idx}_", 0)
|
121 |
print(break_interpolated_video[0])
|
@@ -166,14 +180,9 @@ def infer(url_in,interpolation,fps_output,resize_n,winsize,o_flow):
|
|
166 |
alpha = 1.0/len(result_frames)
|
167 |
beta = (1.0 - alpha)
|
168 |
res = cv2.addWeighted(rgb, alpha, res, beta, 0.0, res)
|
169 |
-
|
170 |
-
|
171 |
-
lo = np.array([0,0,0,0])
|
172 |
-
hi = np.array([0,0,0,255])
|
173 |
-
mask = cv2.inRange(rgb, lo, hi)
|
174 |
-
rgb[mask>0] = (0,0,0,0)
|
175 |
|
176 |
-
cv2.imwrite(f"opticalfb{i}.png",
|
177 |
depth_frames.append(f"opticalfb{i}.png")
|
178 |
i+=1
|
179 |
prvs = nxt
|
@@ -247,7 +256,7 @@ with gr.Blocks() as demo:
|
|
247 |
depth_output = gr.Video()
|
248 |
|
249 |
gr.Examples(
|
250 |
-
examples=[["./examples/
|
251 |
fn=infer,
|
252 |
inputs=[url_input,interpolation_slider,fps_output_slider,resize_num,winsize_num,of_check],
|
253 |
outputs=[video_output,file_output,depth_output],
|
|
|
116 |
for idx, frame in enumerate(frames_list[0:int(n_frame)]):
|
117 |
if idx < len(frames_list) - 1:
|
118 |
next_frame = frames_list[idx+1]
|
119 |
+
|
120 |
+
rgb = cv2.imread(frame).astype(np.uint8)
|
121 |
+
rgb_next = cv2.imread(next_frame).astype(np.uint8)
|
122 |
+
|
123 |
+
diff = np.abs(rgb_next - rgb)
|
124 |
+
lo = np.array([0,0,0])
|
125 |
+
hi = np.array([16,16,16])
|
126 |
+
mask = cv2.inRange(diff, lo, hi)
|
127 |
+
rgb[mask>0] = (255,255,255)
|
128 |
+
rgb_next[mask>0] = (255,255,255)
|
129 |
+
|
130 |
+
cv2.imwrite(frame, rgb)
|
131 |
+
cv2.imwrite(next_frame, rgb_next)
|
132 |
+
|
133 |
interpolated_frames = do_interpolation(frame, next_frame, interpolation) # should return a list of 3 interpolated frames
|
134 |
break_interpolated_video = get_frames(interpolated_frames, "interpol", f"{idx}_", 0)
|
135 |
print(break_interpolated_video[0])
|
|
|
180 |
alpha = 1.0/len(result_frames)
|
181 |
beta = (1.0 - alpha)
|
182 |
res = cv2.addWeighted(rgb, alpha, res, beta, 0.0, res)
|
183 |
+
rgba = cv2.cvtColor(rgb, cv2.COLOR_GRAY2RGBA)
|
|
|
|
|
|
|
|
|
|
|
184 |
|
185 |
+
cv2.imwrite(f"opticalfb{i}.png", rgba)
|
186 |
depth_frames.append(f"opticalfb{i}.png")
|
187 |
i+=1
|
188 |
prvs = nxt
|
|
|
256 |
depth_output = gr.Video()
|
257 |
|
258 |
gr.Examples(
|
259 |
+
examples=[["./examples/man-in-museum.mp4", 1, 0, 256, 15, True]],
|
260 |
fn=infer,
|
261 |
inputs=[url_input,interpolation_slider,fps_output_slider,resize_num,winsize_num,of_check],
|
262 |
outputs=[video_output,file_output,depth_output],
|