Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -170,7 +170,7 @@ def make_video(video_path, outdir='./vis_video_depth', encoder='vits'):
|
|
170 |
|
171 |
cv2.imwrite(f"f{count}_dmap.png", depth_color)
|
172 |
depth_frames.append(f"f{count}_dmap.png")
|
173 |
-
masks.append(
|
174 |
count += 1
|
175 |
|
176 |
final_vid = create_video(depth_frames, frame_rate, "depth")
|
@@ -388,9 +388,8 @@ def reset_mask():
|
|
388 |
global masks
|
389 |
global depths
|
390 |
|
391 |
-
masks[frame_selected]
|
392 |
-
|
393 |
-
return masks[frame_selected], f"f{frame_selected}_dmap.png"
|
394 |
|
395 |
def apply_mask(d, b):
|
396 |
global frame_selected
|
@@ -402,13 +401,14 @@ def apply_mask(d, b):
|
|
402 |
mask = cv2.dilate(mask, dilation)
|
403 |
d["background"][mask==255] = (255,255,255,255)
|
404 |
|
405 |
-
for k,
|
406 |
if k != frame_selected:
|
407 |
-
masks[k]
|
|
|
|
|
408 |
|
409 |
-
masks[frame_selected]
|
410 |
-
|
411 |
-
return masks[frame_selected], f"f{frame_selected}_dmap.png"
|
412 |
|
413 |
def draw_mask(l, t, v, d, evt: gr.EventData):
|
414 |
global params
|
|
|
170 |
|
171 |
cv2.imwrite(f"f{count}_dmap.png", depth_color)
|
172 |
depth_frames.append(f"f{count}_dmap.png")
|
173 |
+
masks.append(f"f{count}_dmap.png")
|
174 |
count += 1
|
175 |
|
176 |
final_vid = create_video(depth_frames, frame_rate, "depth")
|
|
|
388 |
global masks
|
389 |
global depths
|
390 |
|
391 |
+
cv2.imwrite(masks[frame_selected], cv2.imread(depths[frame_selected]))
|
392 |
+
return masks[frame_selected], masks[frame_selected]
|
|
|
393 |
|
394 |
def apply_mask(d, b):
|
395 |
global frame_selected
|
|
|
401 |
mask = cv2.dilate(mask, dilation)
|
402 |
d["background"][mask==255] = (255,255,255,255)
|
403 |
|
404 |
+
for k, mk in enumerate(masks):
|
405 |
if k != frame_selected:
|
406 |
+
m = cv2.imread(masks[k])
|
407 |
+
m[mask!=255] = (255,255,255)
|
408 |
+
cv2.imwrite(masks[k], m)
|
409 |
|
410 |
+
cv2.imwrite(masks[frame_selected], d["background"])
|
411 |
+
return masks[frame_selected], masks[frame_selected]
|
|
|
412 |
|
413 |
def draw_mask(l, t, v, d, evt: gr.EventData):
|
414 |
global params
|