Spaces:
Running
on
L40S
Running
on
L40S
Upload folder using huggingface_hub
Browse files- svrm/ldm/models/svrm.py +23 -7
svrm/ldm/models/svrm.py
CHANGED
@@ -40,6 +40,29 @@ try:
|
|
40 |
import open3d as o3d
|
41 |
except:
|
42 |
raise "failed to import 3d libraries "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
from ..modules.rendering_neus.mesh import Mesh
|
45 |
from ..modules.rendering_neus.rasterize import NVDiffRasterizerContext
|
@@ -58,13 +81,6 @@ def unwrap_uv(v_pos, t_pos_idx):
|
|
58 |
indices = indices.astype(np.int64, casting="same_kind")
|
59 |
return uvs, indices
|
60 |
|
61 |
-
def uv_padding(image, hole_mask, uv_padding_size = 2):
|
62 |
-
return cv2.inpaint(
|
63 |
-
(image.detach().cpu().numpy() * 255).astype(np.uint8),
|
64 |
-
(hole_mask.detach().cpu().numpy() * 255).astype(np.uint8),
|
65 |
-
uv_padding_size,
|
66 |
-
cv2.INPAINT_TELEA
|
67 |
-
)
|
68 |
|
69 |
def refine_mesh(vtx_refine, faces_refine):
|
70 |
mesh = o3d.geometry.TriangleMesh(
|
|
|
40 |
import open3d as o3d
|
41 |
except:
|
42 |
raise "failed to import 3d libraries "
|
43 |
+
|
44 |
+
try:
|
45 |
+
import cvcuda
|
46 |
+
def uv_padding(image, hole_mask, uv_padding_size = 2):
|
47 |
+
|
48 |
+
inpaint_image = (
|
49 |
+
torch.as_tensor(
|
50 |
+
cvcuda.inpaint(
|
51 |
+
src=cvcuda.as_tensor((image * 255).to(torch.uint8), 'HWC'),
|
52 |
+
masks=cvcuda.as_tensor((hole_mask * 255).view(1024, 1024, 1).to(torch.uint8), 'HWC'),
|
53 |
+
inpaintRadius=uv_padding_size,
|
54 |
+
).cuda()
|
55 |
+
)
|
56 |
+
)
|
57 |
+
return inpaint_image.cpu().numpy()
|
58 |
+
except Exception as err:
|
59 |
+
def uv_padding(image, hole_mask, uv_padding_size = 2):
|
60 |
+
return cv2.inpaint(
|
61 |
+
(image.detach().cpu().numpy() * 255).astype(np.uint8),
|
62 |
+
(hole_mask.detach().cpu().numpy() * 255).astype(np.uint8),
|
63 |
+
uv_padding_size,
|
64 |
+
cv2.INPAINT_TELEA
|
65 |
+
)
|
66 |
|
67 |
from ..modules.rendering_neus.mesh import Mesh
|
68 |
from ..modules.rendering_neus.rasterize import NVDiffRasterizerContext
|
|
|
81 |
indices = indices.astype(np.int64, casting="same_kind")
|
82 |
return uvs, indices
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
def refine_mesh(vtx_refine, faces_refine):
|
86 |
mesh = o3d.geometry.TriangleMesh(
|