freealise commited on
Commit
55cb886
1 Parent(s): 4071c34

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -166,8 +166,9 @@ def make_video(video_path, outdir='./vis_video_depth', encoder='vits'):
166
  raw_video.release()
167
  # out.release()
168
  cv2.destroyAllWindows()
169
-
170
- return final_vid, final_zip, orig_frames, depth_frames #output_path
 
171
 
172
  def depth_edges_mask(depth):
173
  """Returns a mask of edges in the depth map.
@@ -300,11 +301,11 @@ def blur_image(image, depth, blur_data):
300
  def loadurl(url):
301
  return url
302
 
303
- def select_frame(evt: gr.SelectData):
304
  global frame_selected
305
  if evt.index != frame_selected:
306
  frame_selected = evt.index
307
- return gr.Gallery(selected_index=evt.index, preview=True), frame_selected
308
 
309
 
310
  css = """
@@ -354,6 +355,7 @@ with gr.Blocks(css=css) as demo:
354
  input_url.change(fn=loadurl, inputs=[input_url], outputs=[input_video])
355
  output_frame = gr.Gallery(label="Frame", type='numpy', preview=True, columns=8192)
356
  output_depth = gr.Gallery(label="Depth", type='numpy', preview=True, columns=8192, interactive=False)
 
357
  submit = gr.Button("Submit")
358
  with gr.Column():
359
  model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl")], type="value", value="vits", label='Model Type')
@@ -564,8 +566,8 @@ with gr.Blocks(css=css) as demo:
564
  <a id='move' href='#'>move</a> <a id='rotate' href='#'>rotate</a> <a id='scale' href='#'>scale</a>
565
  </pre>""")
566
  selected = gr.Number(elem_id="fnum", value=0, minimum=0, maximum=256, interactive=False)
567
- output_frame.select(fn=select_frame, inputs=None, outputs=[output_depth, selected], show_progress='hidden')
568
- output_depth.select(fn=select_frame, inputs=None, outputs=[output_frame, selected], show_progress='hidden')
569
  example_coords = """[
570
  {"latLng": { "lat": 50.07379596793083, "lng": 14.437146122950555 } },
571
  {"latLng": { "lat": 50.073799567020004, "lng": 14.437146774240507 } },
@@ -719,14 +721,14 @@ with gr.Blocks(css=css) as demo:
719
 
720
  return output_video_path + (locations,)
721
 
722
- submit.click(on_submit, inputs=[input_video, model_type, coords], outputs=[processed_video, processed_zip, output_frame, output_depth, coords])
723
  render.click(partial(get_mesh), inputs=[output_frame, output_depth, blur_in, load_all], outputs=[result])
724
 
725
  example_files = os.listdir('examples')
726
  example_files.sort()
727
  example_files = [os.path.join('examples', filename) for filename in example_files]
728
 
729
- examples = gr.Examples(examples=example_files, inputs=[input_video], outputs=[processed_video, processed_zip, output_frame, output_depth, coords], fn=on_submit, cache_examples=True)
730
 
731
 
732
  if __name__ == '__main__':
 
166
  raw_video.release()
167
  # out.release()
168
  cv2.destroyAllWindows()
169
+
170
+ global frame_selected
171
+ return final_vid, final_zip, orig_frames, depth_frames, depth_frames[frame_selected] #output_path
172
 
173
  def depth_edges_mask(depth):
174
  """Returns a mask of edges in the depth map.
 
301
  def loadurl(url):
302
  return url
303
 
304
+ def select_frame(v, evt: gr.SelectData):
305
  global frame_selected
306
  if evt.index != frame_selected:
307
  frame_selected = evt.index
308
+ return gr.Gallery(selected_index=evt.index, preview=True), gr.ImageEditor(background=v), frame_selected
309
 
310
 
311
  css = """
 
355
  input_url.change(fn=loadurl, inputs=[input_url], outputs=[input_video])
356
  output_frame = gr.Gallery(label="Frame", type='numpy', preview=True, columns=8192)
357
  output_depth = gr.Gallery(label="Depth", type='numpy', preview=True, columns=8192, interactive=False)
358
+ output_mask = gr.ImageEditor(transforms=None, eraser=True, brush=True, layers=True)
359
  submit = gr.Button("Submit")
360
  with gr.Column():
361
  model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl")], type="value", value="vits", label='Model Type')
 
566
  <a id='move' href='#'>move</a> <a id='rotate' href='#'>rotate</a> <a id='scale' href='#'>scale</a>
567
  </pre>""")
568
  selected = gr.Number(elem_id="fnum", value=0, minimum=0, maximum=256, interactive=False)
569
+ output_frame.select(fn=select_frame, inputs=output_depth, outputs=[output_depth, output_mask, selected], show_progress='hidden')
570
+ output_depth.select(fn=select_frame, inputs=output_depth, outputs=[output_frame, output_mask, selected], show_progress='hidden')
571
  example_coords = """[
572
  {"latLng": { "lat": 50.07379596793083, "lng": 14.437146122950555 } },
573
  {"latLng": { "lat": 50.073799567020004, "lng": 14.437146774240507 } },
 
721
 
722
  return output_video_path + (locations,)
723
 
724
+ submit.click(on_submit, inputs=[input_video, model_type, coords], outputs=[processed_video, processed_zip, output_frame, output_depth, output_mask, coords])
725
  render.click(partial(get_mesh), inputs=[output_frame, output_depth, blur_in, load_all], outputs=[result])
726
 
727
  example_files = os.listdir('examples')
728
  example_files.sort()
729
  example_files = [os.path.join('examples', filename) for filename in example_files]
730
 
731
+ examples = gr.Examples(examples=example_files, inputs=[input_video], outputs=[processed_video, processed_zip, output_frame, output_depth, output_mask, coords], fn=on_submit, cache_examples=True)
732
 
733
 
734
  if __name__ == '__main__':