Update app.py
Browse files
app.py
CHANGED
@@ -149,13 +149,13 @@ def infer(url_in,interpolation,fps_output,resize_n,winsize,o_flow):
|
|
149 |
if ret == False:
|
150 |
if o_flow == False:
|
151 |
rgb = prvs
|
152 |
-
alpha = 1.0/
|
153 |
beta = (1.0 - alpha)
|
154 |
res = cv2.addWeighted(rgb, alpha, res, beta, 0.0, res)
|
155 |
break
|
156 |
nxt = cv2.cvtColor(fr2, cv2.COLOR_RGBA2GRAY)
|
157 |
if o_flow == True:
|
158 |
-
fl = cv2.calcOpticalFlowFarneback(prvs, nxt, flow, 0.5,
|
159 |
mag, ang = cv2.cartToPolar(fl[..., 0], fl[..., 1])
|
160 |
hsv[..., 0] = ang*180/np.pi/2
|
161 |
hsv[..., 2] = cv2.normalize(mag, None, 0, 255, cv2.NORM_MINMAX)
|
@@ -164,7 +164,7 @@ def infer(url_in,interpolation,fps_output,resize_n,winsize,o_flow):
|
|
164 |
else:
|
165 |
rgb = prvs
|
166 |
|
167 |
-
alpha = 1.0/
|
168 |
beta = (1.0 - alpha)
|
169 |
res = cv2.addWeighted(rgb, alpha, res, beta, 0.0, res)
|
170 |
rgb = cv2.cvtColor(rgb, cv2.COLOR_GRAY2RGB)
|
@@ -188,7 +188,7 @@ def infer(url_in,interpolation,fps_output,resize_n,winsize,o_flow):
|
|
188 |
depth_map.release()
|
189 |
cv2.destroyAllWindows()
|
190 |
|
191 |
-
return final_vid, files, depth_vid
|
192 |
|
193 |
|
194 |
def logscale(linear):
|
@@ -249,15 +249,16 @@ with gr.Blocks() as demo:
|
|
249 |
video_output = gr.Video()
|
250 |
file_output = gr.File()
|
251 |
depth_output = gr.Video()
|
|
|
252 |
|
253 |
gr.Examples(
|
254 |
-
examples=[["./examples/man-in-museum.mp4", 2, 0, 256, 15, True]],
|
255 |
fn=infer,
|
256 |
-
inputs=[url_input,interpolation_slider,fps_output_slider,resize_num,winsize_num,of_check],
|
257 |
-
outputs=[video_output,file_output,depth_output],
|
258 |
cache_examples=True
|
259 |
)
|
260 |
|
261 |
-
submit_btn.click(fn=infer, inputs=[url_input,interpolation_slider,fps_output_slider,resize_num,winsize_num,of_check], outputs=[video_output, file_output, depth_output])
|
262 |
|
263 |
demo.launch()
|
|
|
149 |
if ret == False:
|
150 |
if o_flow == False:
|
151 |
rgb = prvs
|
152 |
+
alpha = 1.0/(i+1)
|
153 |
beta = (1.0 - alpha)
|
154 |
res = cv2.addWeighted(rgb, alpha, res, beta, 0.0, res)
|
155 |
break
|
156 |
nxt = cv2.cvtColor(fr2, cv2.COLOR_RGBA2GRAY)
|
157 |
if o_flow == True:
|
158 |
+
fl = cv2.calcOpticalFlowFarneback(prvs, nxt, flow, 0.5, 7, winsize, 7, 7, 1.5, 0)
|
159 |
mag, ang = cv2.cartToPolar(fl[..., 0], fl[..., 1])
|
160 |
hsv[..., 0] = ang*180/np.pi/2
|
161 |
hsv[..., 2] = cv2.normalize(mag, None, 0, 255, cv2.NORM_MINMAX)
|
|
|
164 |
else:
|
165 |
rgb = prvs
|
166 |
|
167 |
+
alpha = 1.0/(i+1)
|
168 |
beta = (1.0 - alpha)
|
169 |
res = cv2.addWeighted(rgb, alpha, res, beta, 0.0, res)
|
170 |
rgb = cv2.cvtColor(rgb, cv2.COLOR_GRAY2RGB)
|
|
|
188 |
depth_map.release()
|
189 |
cv2.destroyAllWindows()
|
190 |
|
191 |
+
return final_vid, files, depth_vid, 'opticalfb.png'
|
192 |
|
193 |
|
194 |
def logscale(linear):
|
|
|
249 |
video_output = gr.Video()
|
250 |
file_output = gr.File()
|
251 |
depth_output = gr.Video()
|
252 |
+
depth_avg = gr.Image()
|
253 |
|
254 |
gr.Examples(
|
255 |
+
examples=[["./examples/man-in-museum-reverse-cut.mp4", 2, 0, 256, 15, True]],
|
256 |
fn=infer,
|
257 |
+
inputs=[url_input, interpolation_slider, fps_output_slider, resize_num, winsize_num, of_check],
|
258 |
+
outputs=[video_output, file_output, depth_output, depth_avg],
|
259 |
cache_examples=True
|
260 |
)
|
261 |
|
262 |
+
submit_btn.click(fn=infer, inputs=[url_input, interpolation_slider, fps_output_slider, resize_num, winsize_num, of_check], outputs=[video_output, file_output, depth_output, depth_avg])
|
263 |
|
264 |
demo.launch()
|