Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ import torch
|
|
8 |
import torch.nn.functional as F
|
9 |
from torchvision import transforms
|
10 |
from torchvision.transforms import Compose
|
11 |
-
import open3d as o3d
|
12 |
import tempfile
|
13 |
from functools import partial
|
14 |
import spaces
|
@@ -274,6 +274,7 @@ def rgb2gray(rgb):
|
|
274 |
return np.dot(rgb[...,:3], [0.333, 0.333, 0.333])
|
275 |
|
276 |
def get_mesh(image, depth, blur_data, loadall):
|
|
|
277 |
global pcolors
|
278 |
global frame_selected
|
279 |
global mesh
|
@@ -287,7 +288,7 @@ def get_mesh(image, depth, blur_data, loadall):
|
|
287 |
#print(image[fnum][0])
|
288 |
#print(depth["composite"])
|
289 |
|
290 |
-
depthc = cv2.
|
291 |
blur_img = blur_image(cv2.imread(image[fnum][0], cv2.IMREAD_UNCHANGED).astype(np.uint8), depthc, blur_data)
|
292 |
gdepth = cv2.cvtColor(depthc, cv2.COLOR_RGB2GRAY) #rgb2gray(depthc)
|
293 |
|
@@ -488,9 +489,9 @@ def apply_mask(d, b):
|
|
488 |
|
489 |
for k, mk in enumerate(masks):
|
490 |
if k != frame_selected and k < len(depths):
|
491 |
-
masks[k] = cv2.imread(depths[k]).astype(np.uint8)
|
492 |
-
masks[k][dmask<255] = (0,0,0)
|
493 |
-
cv2.imwrite(depths[k], masks[k])
|
494 |
frame = cv2.imread(frames[k], cv2.IMREAD_UNCHANGED).astype(np.uint8)
|
495 |
frame[:, :, 3] = dmask_b
|
496 |
cv2.imwrite(frames[k], frame)
|
@@ -499,8 +500,8 @@ def apply_mask(d, b):
|
|
499 |
frame[:, :, 3] = 255 - mask_b
|
500 |
cv2.imwrite(frames[frame_selected], frame)
|
501 |
|
502 |
-
masks[frame_selected] = d["background"]
|
503 |
-
cv2.imwrite(depths[frame_selected], masks[frame_selected])
|
504 |
return masks[frame_selected], depths, frames
|
505 |
|
506 |
def draw_mask(l, t, v, d, evt: gr.EventData):
|
|
|
8 |
import torch.nn.functional as F
|
9 |
from torchvision import transforms
|
10 |
from torchvision.transforms import Compose
|
11 |
+
#import open3d as o3d
|
12 |
import tempfile
|
13 |
from functools import partial
|
14 |
import spaces
|
|
|
274 |
return np.dot(rgb[...,:3], [0.333, 0.333, 0.333])
|
275 |
|
276 |
def get_mesh(image, depth, blur_data, loadall):
|
277 |
+
global depths
|
278 |
global pcolors
|
279 |
global frame_selected
|
280 |
global mesh
|
|
|
288 |
#print(image[fnum][0])
|
289 |
#print(depth["composite"])
|
290 |
|
291 |
+
depthc = cv2.imread(depths[frame_selected], cv2.IMREAD_UNCHANGED).astype(np.uint8)
|
292 |
blur_img = blur_image(cv2.imread(image[fnum][0], cv2.IMREAD_UNCHANGED).astype(np.uint8), depthc, blur_data)
|
293 |
gdepth = cv2.cvtColor(depthc, cv2.COLOR_RGB2GRAY) #rgb2gray(depthc)
|
294 |
|
|
|
489 |
|
490 |
for k, mk in enumerate(masks):
|
491 |
if k != frame_selected and k < len(depths):
|
492 |
+
#masks[k] = cv2.imread(depths[k]).astype(np.uint8)
|
493 |
+
#masks[k][dmask<255] = (0,0,0)
|
494 |
+
#cv2.imwrite(depths[k], masks[k])
|
495 |
frame = cv2.imread(frames[k], cv2.IMREAD_UNCHANGED).astype(np.uint8)
|
496 |
frame[:, :, 3] = dmask_b
|
497 |
cv2.imwrite(frames[k], frame)
|
|
|
500 |
frame[:, :, 3] = 255 - mask_b
|
501 |
cv2.imwrite(frames[frame_selected], frame)
|
502 |
|
503 |
+
masks[frame_selected] = mask #d["background"]
|
504 |
+
#cv2.imwrite(depths[frame_selected], masks[frame_selected])
|
505 |
return masks[frame_selected], depths, frames
|
506 |
|
507 |
def draw_mask(l, t, v, d, evt: gr.EventData):
|