freealise commited on
Commit
3a60572
1 Parent(s): 434296c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -93,7 +93,7 @@ def create_video(frames, fps, type):
93
  return type + "_result.mp4"
94
 
95
 
96
- def infer(url_in,interpolation,fps_output,resize_n):
97
 
98
  fps_output = logscale(fps_output)
99
  # 1. break video into frames and get FPS
@@ -144,7 +144,7 @@ def infer(url_in,interpolation,fps_output,resize_n):
144
  if ret == False:
145
  break
146
  nxt = cv2.cvtColor(fr2, cv2.COLOR_RGBA2GRAY)
147
- fl = cv2.calcOpticalFlowFarneback(prvs, nxt, flow, 0.5, 3, 15, 3, 5, 1.2, 0)
148
  mag, ang = cv2.cartToPolar(fl[..., 0], fl[..., 1])
149
  hsv[..., 0] = ang*180/np.pi/2
150
  hsv[..., 2] = cv2.normalize(mag, None, 0, 255, cv2.NORM_MINMAX)
@@ -196,6 +196,7 @@ with gr.Blocks() as demo:
196
  with gr.Column():
197
  url_input = gr.Textbox(value="./examples/streetview.mp4", label="URL")
198
  resize_num = gr.Slider(minimum=1, maximum=4096, step=1, value=256, label="Resize to width: ")
 
199
  with gr.Row():
200
  interpolation_slider = gr.Slider(minimum=1, maximum=5, step=1, value=1, label="Interpolation Steps: ")
201
  interpolation = gr.Label(value=2, show_label=False)
@@ -212,13 +213,13 @@ with gr.Blocks() as demo:
212
  depth_output = gr.Image(image_mode="L")
213
 
214
  gr.Examples(
215
- examples=[["./examples/streetview.mp4", 1, 1, 256]],
216
  fn=infer,
217
- inputs=[url_input,interpolation_slider,fps_output_slider,resize_num],
218
  outputs=[video_output,file_output,depth_output],
219
  cache_examples=True
220
  )
221
 
222
- submit_btn.click(fn=infer, inputs=[url_input,interpolation_slider,fps_output_slider,resize_num], outputs=[video_output, file_output, depth_output])
223
 
224
  demo.launch()
 
93
  return type + "_result.mp4"
94
 
95
 
96
+ def infer(url_in,interpolation,fps_output,resize_n,winsize):
97
 
98
  fps_output = logscale(fps_output)
99
  # 1. break video into frames and get FPS
 
144
  if ret == False:
145
  break
146
  nxt = cv2.cvtColor(fr2, cv2.COLOR_RGBA2GRAY)
147
+ fl = cv2.calcOpticalFlowFarneback(prvs, nxt, flow, 0.5, 4, winsize, 4, 7, 1.5, 0)
148
  mag, ang = cv2.cartToPolar(fl[..., 0], fl[..., 1])
149
  hsv[..., 0] = ang*180/np.pi/2
150
  hsv[..., 2] = cv2.normalize(mag, None, 0, 255, cv2.NORM_MINMAX)
 
196
  with gr.Column():
197
  url_input = gr.Textbox(value="./examples/streetview.mp4", label="URL")
198
  resize_num = gr.Slider(minimum=1, maximum=4096, step=1, value=256, label="Resize to width: ")
199
+ winsize_num = gr.Slider(minimum=1, maximum=256, step=1, value=9, label="Motion detection window size: ")
200
  with gr.Row():
201
  interpolation_slider = gr.Slider(minimum=1, maximum=5, step=1, value=1, label="Interpolation Steps: ")
202
  interpolation = gr.Label(value=2, show_label=False)
 
213
  depth_output = gr.Image(image_mode="L")
214
 
215
  gr.Examples(
216
+ examples=[["./examples/streetview.mp4", 1, 1, 256, 9]],
217
  fn=infer,
218
+ inputs=[url_input,interpolation_slider,fps_output_slider,resize_num,winsize_num],
219
  outputs=[video_output,file_output,depth_output],
220
  cache_examples=True
221
  )
222
 
223
+ submit_btn.click(fn=infer, inputs=[url_input,interpolation_slider,fps_output_slider,resize_num,winsize_num], outputs=[video_output, file_output, depth_output])
224
 
225
  demo.launch()