mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-29 04:20:10 +08:00
Merge 96be9b22b8 into 50e0e3c70c
This commit is contained in:
3 files changed
+27
-3
No files matched your search
@@ -23,7 +23,6 @@ from dataclasses import dataclass
|
|||||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pymeshlab
|
|
||||||
import torch
|
import torch
|
||||||
from jaxtyping import Float
|
from jaxtyping import Float
|
||||||
from rich.progress import BarColumn, Progress, TaskProgressColumn, TextColumn, TimeRemainingColumn
|
from rich.progress import BarColumn, Progress, TaskProgressColumn, TextColumn, TimeRemainingColumn
|
||||||
@@ -41,6 +40,7 @@ if TYPE_CHECKING:
|
|||||||
# Importing open3d can take ~1 second, so only do it below if we actually
|
# Importing open3d can take ~1 second, so only do it below if we actually
|
||||||
# need it.
|
# need it.
|
||||||
import open3d as o3d
|
import open3d as o3d
|
||||||
|
import pymeshlab
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@@ -71,6 +71,8 @@ def get_mesh_from_pymeshlab_mesh(mesh: pymeshlab.Mesh) -> Mesh: # type: ignore
|
|||||||
|
|
||||||
def get_mesh_from_filename(filename: str, target_num_faces: Optional[int] = None) -> Mesh:
|
def get_mesh_from_filename(filename: str, target_num_faces: Optional[int] = None) -> Mesh:
|
||||||
"""Get a Mesh from a filename."""
|
"""Get a Mesh from a filename."""
|
||||||
|
import pymeshlab
|
||||||
|
|
||||||
ms = pymeshlab.MeshSet() # type: ignore
|
ms = pymeshlab.MeshSet() # type: ignore
|
||||||
ms.load_new_mesh(filename)
|
ms.load_new_mesh(filename)
|
||||||
if target_num_faces is not None:
|
if target_num_faces is not None:
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ from pathlib import Path
|
|||||||
from typing import List, Optional, Tuple, Union
|
from typing import List, Optional, Tuple, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pymeshlab
|
|
||||||
import torch
|
import torch
|
||||||
import torch.nn.functional as F
|
import torch.nn.functional as F
|
||||||
from jaxtyping import Bool, Float
|
from jaxtyping import Bool, Float
|
||||||
@@ -50,7 +49,7 @@ class TSDF:
|
|||||||
weights: Float[Tensor, "xdim ydim zdim"]
|
weights: Float[Tensor, "xdim ydim zdim"]
|
||||||
"""TSDF weights for each voxel."""
|
"""TSDF weights for each voxel."""
|
||||||
colors: Float[Tensor, "xdim ydim zdim 3"]
|
colors: Float[Tensor, "xdim ydim zdim 3"]
|
||||||
"""TSDF colors for each voxel."""
|
"""TSDF colors of each voxel."""
|
||||||
voxel_size: Float[Tensor, "3"]
|
voxel_size: Float[Tensor, "3"]
|
||||||
"""Size of each voxel in the TSDF. [x, y, z] size."""
|
"""Size of each voxel in the TSDF. [x, y, z] size."""
|
||||||
origin: Float[Tensor, "3"]
|
origin: Float[Tensor, "3"]
|
||||||
@@ -147,6 +146,8 @@ class TSDF:
|
|||||||
mesh: The mesh to export.
|
mesh: The mesh to export.
|
||||||
filename: The filename to export the mesh to.
|
filename: The filename to export the mesh to.
|
||||||
"""
|
"""
|
||||||
|
import pymeshlab
|
||||||
|
|
||||||
assert mesh.colors is not None
|
assert mesh.colors is not None
|
||||||
vertex_matrix = mesh.vertices.cpu().numpy().astype("float64")
|
vertex_matrix = mesh.vertices.cpu().numpy().astype("float64")
|
||||||
face_matrix = mesh.faces.cpu().numpy().astype("int32")
|
face_matrix = mesh.faces.cpu().numpy().astype("int32")
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
"""Tests for exporter dependency imports."""
|
||||||
|
|
||||||
|
import importlib
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def test_exporter_modules_do_not_eagerly_import_pymeshlab(monkeypatch):
|
||||||
|
"""Exporter modules should import without initializing pymeshlab."""
|
||||||
|
monkeypatch.setitem(sys.modules, "pymeshlab", None)
|
||||||
|
|
||||||
|
modules = [
|
||||||
|
"nerfstudio.exporter.exporter_utils",
|
||||||
|
"nerfstudio.exporter.tsdf_utils",
|
||||||
|
]
|
||||||
|
for module in modules:
|
||||||
|
sys.modules.pop(module, None)
|
||||||
|
|
||||||
|
for module in modules:
|
||||||
|
importlib.import_module(module)
|
||||||
|
|
||||||
|
assert sys.modules["pymeshlab"] is None
|
||||||
Reference in new issue
Block a user