Spaces:
Running on Zero
Running on Zero
Install full PartField and Blender runtime dependencies
Browse files- packages.txt +5 -0
- partfield/partfield/dataloader.py +4 -30
- requirements.txt +10 -1
- scripts/render_upright_previews_blender.py +0 -19
packages.txt
CHANGED
|
@@ -1,4 +1,9 @@
|
|
| 1 |
libgl1-mesa-glx
|
| 2 |
libglib2.0-0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
blender
|
| 4 |
python3-numpy
|
|
|
|
| 1 |
libgl1-mesa-glx
|
| 2 |
libglib2.0-0
|
| 3 |
+
libgomp1
|
| 4 |
+
libxrender1
|
| 5 |
+
libxext6
|
| 6 |
+
libsm6
|
| 7 |
+
libice6
|
| 8 |
blender
|
| 9 |
python3-numpy
|
partfield/partfield/dataloader.py
CHANGED
|
@@ -15,38 +15,17 @@ import gc
|
|
| 15 |
from plyfile import PlyData
|
| 16 |
|
| 17 |
## For remeshing
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
mesh2sdf = None
|
| 22 |
-
try:
|
| 23 |
-
import tetgen
|
| 24 |
-
except ImportError:
|
| 25 |
-
tetgen = None
|
| 26 |
-
try:
|
| 27 |
-
import vtk
|
| 28 |
-
except ImportError:
|
| 29 |
-
vtk = None
|
| 30 |
import math
|
| 31 |
import tempfile
|
| 32 |
|
| 33 |
### For mesh processing
|
| 34 |
-
|
| 35 |
-
import pymeshlab
|
| 36 |
-
except ImportError:
|
| 37 |
-
pymeshlab = None
|
| 38 |
|
| 39 |
from partfield.utils import *
|
| 40 |
|
| 41 |
-
|
| 42 |
-
def require_optional_dependency(module, name):
|
| 43 |
-
if module is None:
|
| 44 |
-
raise ImportError(
|
| 45 |
-
f"Optional PartField dependency '{name}' is required for this dataset "
|
| 46 |
-
"operation, but it is not installed."
|
| 47 |
-
)
|
| 48 |
-
return module
|
| 49 |
-
|
| 50 |
#########################
|
| 51 |
## To handle quad inputs
|
| 52 |
#########################
|
|
@@ -167,7 +146,6 @@ class Demo_Dataset(torch.utils.data.Dataset):
|
|
| 167 |
|
| 168 |
### Pre-process mesh
|
| 169 |
if self.preprocess_mesh:
|
| 170 |
-
require_optional_dependency(pymeshlab, "pymeshlab")
|
| 171 |
# Create a PyMeshLab mesh directly from vertices and faces
|
| 172 |
ml_mesh = pymeshlab.Mesh(vertex_matrix=mesh.vertices, face_matrix=mesh.faces)
|
| 173 |
|
|
@@ -266,7 +244,6 @@ class Demo_Remesh_Dataset(torch.utils.data.Dataset):
|
|
| 266 |
|
| 267 |
### Pre-process mesh
|
| 268 |
if self.preprocess_mesh:
|
| 269 |
-
require_optional_dependency(pymeshlab, "pymeshlab")
|
| 270 |
# Create a PyMeshLab mesh directly from vertices and faces
|
| 271 |
ml_mesh = pymeshlab.Mesh(vertex_matrix=mesh.vertices, face_matrix=mesh.faces)
|
| 272 |
|
|
@@ -298,9 +275,6 @@ class Demo_Remesh_Dataset(torch.utils.data.Dataset):
|
|
| 298 |
mesh.export(f'{save_dir}/input_{uid}_{view_id}.ply')
|
| 299 |
|
| 300 |
try:
|
| 301 |
-
require_optional_dependency(mesh2sdf, "mesh2sdf")
|
| 302 |
-
require_optional_dependency(tetgen, "tetgen")
|
| 303 |
-
require_optional_dependency(vtk, "vtk")
|
| 304 |
###### Remesh ######
|
| 305 |
size= 256
|
| 306 |
level = 2 / size
|
|
|
|
| 15 |
from plyfile import PlyData
|
| 16 |
|
| 17 |
## For remeshing
|
| 18 |
+
import mesh2sdf
|
| 19 |
+
import tetgen
|
| 20 |
+
import vtk
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
import math
|
| 22 |
import tempfile
|
| 23 |
|
| 24 |
### For mesh processing
|
| 25 |
+
import pymeshlab
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
from partfield.utils import *
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
#########################
|
| 30 |
## To handle quad inputs
|
| 31 |
#########################
|
|
|
|
| 146 |
|
| 147 |
### Pre-process mesh
|
| 148 |
if self.preprocess_mesh:
|
|
|
|
| 149 |
# Create a PyMeshLab mesh directly from vertices and faces
|
| 150 |
ml_mesh = pymeshlab.Mesh(vertex_matrix=mesh.vertices, face_matrix=mesh.faces)
|
| 151 |
|
|
|
|
| 244 |
|
| 245 |
### Pre-process mesh
|
| 246 |
if self.preprocess_mesh:
|
|
|
|
| 247 |
# Create a PyMeshLab mesh directly from vertices and faces
|
| 248 |
ml_mesh = pymeshlab.Mesh(vertex_matrix=mesh.vertices, face_matrix=mesh.faces)
|
| 249 |
|
|
|
|
| 275 |
mesh.export(f'{save_dir}/input_{uid}_{view_id}.ply')
|
| 276 |
|
| 277 |
try:
|
|
|
|
|
|
|
|
|
|
| 278 |
###### Remesh ######
|
| 279 |
size= 256
|
| 280 |
level = 2 / size
|
requirements.txt
CHANGED
|
@@ -17,7 +17,7 @@ yacs
|
|
| 17 |
omegaconf
|
| 18 |
trimesh
|
| 19 |
pygltflib
|
| 20 |
-
numpy
|
| 21 |
scipy
|
| 22 |
numba
|
| 23 |
matplotlib
|
|
@@ -31,3 +31,12 @@ loguru
|
|
| 31 |
psutil
|
| 32 |
boto3
|
| 33 |
pytz
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
omegaconf
|
| 18 |
trimesh
|
| 19 |
pygltflib
|
| 20 |
+
numpy==1.23.5
|
| 21 |
scipy
|
| 22 |
numba
|
| 23 |
matplotlib
|
|
|
|
| 31 |
psutil
|
| 32 |
boto3
|
| 33 |
pytz
|
| 34 |
+
mesh2sdf==1.1.0
|
| 35 |
+
tetgen
|
| 36 |
+
vtk
|
| 37 |
+
pymeshlab
|
| 38 |
+
libigl
|
| 39 |
+
polyscope
|
| 40 |
+
potpourri3d
|
| 41 |
+
simple_parsing
|
| 42 |
+
arrgh
|
scripts/render_upright_previews_blender.py
CHANGED
|
@@ -17,26 +17,7 @@ except ImportError: # pragma: no cover - Blender-only runtime dependency
|
|
| 17 |
Vector = None
|
| 18 |
|
| 19 |
|
| 20 |
-
def patch_numpy_compatibility() -> None:
|
| 21 |
-
try:
|
| 22 |
-
import numpy as np
|
| 23 |
-
except ImportError:
|
| 24 |
-
return
|
| 25 |
-
|
| 26 |
-
deprecated_aliases = {
|
| 27 |
-
"bool": bool,
|
| 28 |
-
"int": int,
|
| 29 |
-
"float": float,
|
| 30 |
-
"complex": complex,
|
| 31 |
-
"object": object,
|
| 32 |
-
}
|
| 33 |
-
for name, value in deprecated_aliases.items():
|
| 34 |
-
if name not in np.__dict__:
|
| 35 |
-
setattr(np, name, value)
|
| 36 |
-
|
| 37 |
-
|
| 38 |
if bpy is not None:
|
| 39 |
-
patch_numpy_compatibility()
|
| 40 |
IMPORT_FUNCTIONS = {
|
| 41 |
"obj": bpy.ops.wm.obj_import,
|
| 42 |
"glb": bpy.ops.import_scene.gltf,
|
|
|
|
| 17 |
Vector = None
|
| 18 |
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
if bpy is not None:
|
|
|
|
| 21 |
IMPORT_FUNCTIONS = {
|
| 22 |
"obj": bpy.ops.wm.obj_import,
|
| 23 |
"glb": bpy.ops.import_scene.gltf,
|