Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -20,7 +20,6 @@ from depth_anything.util.transform import Resize, NormalizeImage, PrepareForNet
|
|
20 |
from moviepy.editor import *
|
21 |
|
22 |
frame_selected = 0
|
23 |
-
depth_selected = 0
|
24 |
|
25 |
def zip_files(files_in, files_out):
|
26 |
with ZipFile("depth_result.zip", "w") as zipObj:
|
@@ -229,7 +228,7 @@ def rgb2gray(rgb):
|
|
229 |
return np.dot(rgb[...,:3], [0.333, 0.333, 0.333])
|
230 |
|
231 |
def get_mesh(image, depth):
|
232 |
-
fnum =
|
233 |
gdepth = rgb2gray(depth[fnum][0])
|
234 |
print('depth to gray - ok')
|
235 |
points = pano_depth_to_world_points(gdepth, 1)
|
@@ -271,20 +270,13 @@ def loadurl(url):
|
|
271 |
return url
|
272 |
|
273 |
def select_frame(evt: gr.SelectData):
|
274 |
-
global depth_selected
|
275 |
global frame_selected
|
276 |
if evt.index != frame_selected:
|
277 |
-
print(f'index: {evt.index},
|
278 |
-
depth_selected = evt.index
|
279 |
-
return gr.Gallery(selected_index=evt.index, preview=True)
|
280 |
-
|
281 |
-
def select_depth(evt: gr.SelectData):
|
282 |
-
global frame_selected
|
283 |
-
global depth_selected
|
284 |
-
if evt.index != depth_selected:
|
285 |
-
print(f'index: {evt.index}, f_s: {frame_selected}, d_s: {depth_selected}')
|
286 |
frame_selected = evt.index
|
287 |
return gr.Gallery(selected_index=evt.index, preview=True)
|
|
|
|
|
288 |
|
289 |
|
290 |
css = """
|
@@ -336,7 +328,7 @@ with gr.Blocks(css=css) as demo:
|
|
336 |
output_frame = gr.Gallery(label="Frame", type='numpy', preview=True, columns=8192)
|
337 |
output_depth = gr.Gallery(label="Depth", type='numpy', preview=True, columns=8192)
|
338 |
output_frame.select(fn=select_frame, inputs=None, outputs=[output_depth])
|
339 |
-
output_depth.select(fn=
|
340 |
submit = gr.Button("Submit")
|
341 |
with gr.Column():
|
342 |
model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl")], type="value", value="vits", label='Model Type')
|
|
|
20 |
from moviepy.editor import *
|
21 |
|
22 |
frame_selected = 0
|
|
|
23 |
|
24 |
def zip_files(files_in, files_out):
|
25 |
with ZipFile("depth_result.zip", "w") as zipObj:
|
|
|
228 |
return np.dot(rgb[...,:3], [0.333, 0.333, 0.333])
|
229 |
|
230 |
def get_mesh(image, depth):
|
231 |
+
fnum = frame_selected
|
232 |
gdepth = rgb2gray(depth[fnum][0])
|
233 |
print('depth to gray - ok')
|
234 |
points = pano_depth_to_world_points(gdepth, 1)
|
|
|
270 |
return url
|
271 |
|
272 |
def select_frame(evt: gr.SelectData):
|
|
|
273 |
global frame_selected
|
274 |
if evt.index != frame_selected:
|
275 |
+
print(f'index: {evt.index}, f_s: {frame_selected}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
frame_selected = evt.index
|
277 |
return gr.Gallery(selected_index=evt.index, preview=True)
|
278 |
+
else:
|
279 |
+
return
|
280 |
|
281 |
|
282 |
css = """
|
|
|
328 |
output_frame = gr.Gallery(label="Frame", type='numpy', preview=True, columns=8192)
|
329 |
output_depth = gr.Gallery(label="Depth", type='numpy', preview=True, columns=8192)
|
330 |
output_frame.select(fn=select_frame, inputs=None, outputs=[output_depth])
|
331 |
+
output_depth.select(fn=select_frame, inputs=None, outputs=[output_frame])
|
332 |
submit = gr.Button("Submit")
|
333 |
with gr.Column():
|
334 |
model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl")], type="value", value="vits", label='Model Type')
|