freealise commited on
Commit
942487d
1 Parent(s): 468ae67

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -133,6 +133,7 @@ def infer(url_in,interpolation,fps_output,resize_n,winsize,o_flow):
133
  depth_map = cv2.VideoCapture(final_vid)
134
  print("interpolated frames: " + str(len(frames_list)) + " -> " + str(len(result_frames)))
135
 
 
136
  ret, fr1 = depth_map.read()
137
  prvs = cv2.cvtColor(fr1, cv2.COLOR_RGBA2GRAY)
138
  hsv = np.zeros_like(fr1)
@@ -159,18 +160,20 @@ def infer(url_in,interpolation,fps_output,resize_n,winsize,o_flow):
159
  rgb = cv2.cvtColor(rgb, cv2.COLOR_RGBA2GRAY)
160
  else:
161
  rgb = prvs
162
-
 
163
  alpha = 1.0/len(result_frames)
164
  beta = (1.0 - alpha)
165
  res = cv2.addWeighted(rgb, alpha, res, beta, 0.0, res)
166
  prvs = nxt
167
 
168
  print("averaged frames: " + str(len(result_frames)))
 
169
  cv2.imwrite('opticalfb.png', res)
170
  depth_map.release()
171
  cv2.destroyAllWindows()
172
 
173
- return final_vid, files, 'opticalfb.png'
174
 
175
 
176
  def logscale(linear):
@@ -222,7 +225,7 @@ with gr.Blocks() as demo:
222
  with gr.Column():
223
  video_output = gr.Video()
224
  file_output = gr.File()
225
- depth_output = gr.ImageEditor(image_mode="L", interactive=True, label="Depth map")
226
 
227
  gr.Examples(
228
  examples=[["./examples/streetview.mp4", 1, 0, 256, 15, False]],
 
133
  depth_map = cv2.VideoCapture(final_vid)
134
  print("interpolated frames: " + str(len(frames_list)) + " -> " + str(len(result_frames)))
135
 
136
+ depth_frames = []
137
  ret, fr1 = depth_map.read()
138
  prvs = cv2.cvtColor(fr1, cv2.COLOR_RGBA2GRAY)
139
  hsv = np.zeros_like(fr1)
 
160
  rgb = cv2.cvtColor(rgb, cv2.COLOR_RGBA2GRAY)
161
  else:
162
  rgb = prvs
163
+
164
+ depth_frames.append(rgb)
165
  alpha = 1.0/len(result_frames)
166
  beta = (1.0 - alpha)
167
  res = cv2.addWeighted(rgb, alpha, res, beta, 0.0, res)
168
  prvs = nxt
169
 
170
  print("averaged frames: " + str(len(result_frames)))
171
+ depth_vid = create_video(depth_frames, fps_output, "depth map")
172
  cv2.imwrite('opticalfb.png', res)
173
  depth_map.release()
174
  cv2.destroyAllWindows()
175
 
176
+ return final_vid, files, depth_vid
177
 
178
 
179
  def logscale(linear):
 
225
  with gr.Column():
226
  video_output = gr.Video()
227
  file_output = gr.File()
228
+ depth_output = gr.Video()
229
 
230
  gr.Examples(
231
  examples=[["./examples/streetview.mp4", 1, 0, 256, 15, False]],