mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-10 18:17:31 +08:00
Merge 96be9b22b8 into 50e0e3c70c
This commit is contained in:
commit
2cda2807bd
@ -23,7 +23,6 @@ from dataclasses import dataclass
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple
|
||||
|
||||
import numpy as np
|
||||
import pymeshlab
|
||||
import torch
|
||||
from jaxtyping import Float
|
||||
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
|
||||
# need it.
|
||||
import open3d as o3d
|
||||
import pymeshlab
|
||||
|
||||
|
||||
@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:
|
||||
"""Get a Mesh from a filename."""
|
||||
import pymeshlab
|
||||
|
||||
ms = pymeshlab.MeshSet() # type: ignore
|
||||
ms.load_new_mesh(filename)
|
||||
if target_num_faces is not None:
|
||||
|
||||
@ -23,7 +23,6 @@ from pathlib import Path
|
||||
from typing import List, Optional, Tuple, Union
|
||||
|
||||
import numpy as np
|
||||
import pymeshlab
|
||||
import torch
|
||||
import torch.nn.functional as F
|
||||
from jaxtyping import Bool, Float
|
||||
@ -50,7 +49,7 @@ class TSDF:
|
||||
weights: Float[Tensor, "xdim ydim zdim"]
|
||||
"""TSDF weights for each voxel."""
|
||||
colors: Float[Tensor, "xdim ydim zdim 3"]
|
||||
"""TSDF colors for each voxel."""
|
||||
"""TSDF colors of each voxel."""
|
||||
voxel_size: Float[Tensor, "3"]
|
||||
"""Size of each voxel in the TSDF. [x, y, z] size."""
|
||||
origin: Float[Tensor, "3"]
|
||||
@ -147,6 +146,8 @@ class TSDF:
|
||||
mesh: The mesh to export.
|
||||
filename: The filename to export the mesh to.
|
||||
"""
|
||||
import pymeshlab
|
||||
|
||||
assert mesh.colors is not None
|
||||
vertex_matrix = mesh.vertices.cpu().numpy().astype("float64")
|
||||
face_matrix = mesh.faces.cpu().numpy().astype("int32")
|
||||
|
||||
21
tests/test_exporter_imports.py
Normal file
21
tests/test_exporter_imports.py
Normal file
@ -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
|
||||
Loading…
Reference in New Issue
Block a user