Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -21,6 +21,8 @@ from depth_anything.util.transform import Resize, NormalizeImage, PrepareForNet
|
|
21 |
from moviepy.editor import *
|
22 |
|
23 |
frame_selected = 0
|
|
|
|
|
24 |
masks = []
|
25 |
locations = []
|
26 |
mesh = []
|
@@ -170,8 +172,12 @@ def make_video(video_path, outdir='./vis_video_depth', encoder='vits'):
|
|
170 |
|
171 |
global frame_selected
|
172 |
global masks
|
|
|
|
|
|
|
|
|
173 |
masks = orig_frames
|
174 |
-
return final_vid, final_zip,
|
175 |
|
176 |
def depth_edges_mask(depth):
|
177 |
"""Returns a mask of edges in the depth map.
|
@@ -319,9 +325,13 @@ def select_frame(v, evt: gr.SelectData):
|
|
319 |
#print(v)
|
320 |
return v, frame_selected
|
321 |
|
322 |
-
def
|
323 |
-
global
|
324 |
-
|
|
|
|
|
|
|
|
|
325 |
|
326 |
|
327 |
css = """
|
@@ -370,6 +380,8 @@ with gr.Blocks(css=css) as demo:
|
|
370 |
input_video = gr.Video(label="Input Video", format="mp4")
|
371 |
input_url.change(fn=loadurl, inputs=[input_url], outputs=[input_video])
|
372 |
output_frame = gr.Gallery(label="Frames", type='numpy', preview=True, columns=6)
|
|
|
|
|
373 |
output_frame.change(fn=align_rows, inputs=None, outputs=[output_frame])
|
374 |
output_mask = gr.ImageEditor(interactive=True, transforms=(None,), eraser=gr.Eraser(), brush=gr.Brush(colors=['black', 'darkgray', 'gray', 'lightgray', 'white']), layers=True)
|
375 |
submit = gr.Button("Submit")
|
|
|
21 |
from moviepy.editor import *
|
22 |
|
23 |
frame_selected = 0
|
24 |
+
frames = []
|
25 |
+
depths = []
|
26 |
masks = []
|
27 |
locations = []
|
28 |
mesh = []
|
|
|
172 |
|
173 |
global frame_selected
|
174 |
global masks
|
175 |
+
global depths
|
176 |
+
global frames
|
177 |
+
frames = orig_frames
|
178 |
+
depths = depth_frames
|
179 |
masks = orig_frames
|
180 |
+
return final_vid, final_zip, orig_frames, masks[frame_selected] #output_path
|
181 |
|
182 |
def depth_edges_mask(depth):
|
183 |
"""Returns a mask of edges in the depth map.
|
|
|
325 |
#print(v)
|
326 |
return v, frame_selected
|
327 |
|
328 |
+
def switch_rows(v):
|
329 |
+
global frames
|
330 |
+
global depths
|
331 |
+
if v == True:
|
332 |
+
return depths
|
333 |
+
else:
|
334 |
+
return frames
|
335 |
|
336 |
|
337 |
css = """
|
|
|
380 |
input_video = gr.Video(label="Input Video", format="mp4")
|
381 |
input_url.change(fn=loadurl, inputs=[input_url], outputs=[input_video])
|
382 |
output_frame = gr.Gallery(label="Frames", type='numpy', preview=True, columns=6)
|
383 |
+
output_switch = gr.Checkbox(label="Show depths")
|
384 |
+
output_switch.change(fn=switch_rows, inputs=[output_switch], outputs=[output_frame])
|
385 |
output_frame.change(fn=align_rows, inputs=None, outputs=[output_frame])
|
386 |
output_mask = gr.ImageEditor(interactive=True, transforms=(None,), eraser=gr.Eraser(), brush=gr.Brush(colors=['black', 'darkgray', 'gray', 'lightgray', 'white']), layers=True)
|
387 |
submit = gr.Button("Submit")
|