3D Dataloader: ZIP Loader#
We give here a few pointers on how to easily sample raw, stylized meshes and pointclouds from our zipped 3D models.
Note that the ZIP loader enables to sample up to a 1000
average compositions (styles) per model, by texturing meshes βon-the-flyβ following our generated style metadata.
from demo_utils_3D import *
import utils3D.plot as plt_utils
METADATA_DIR = "./metadata/"
ZIP_PATH = "./3D_data/3DCoMPaT_ZIP.zip"
Working with raw meshes#
To load unstylized 3D shapes, we provide the ShapeLoader
class. The n_points parameter enables sampling of pointclouds when loading the shapes.
It can be instantiated with the load_mesh parameter toggled to interactively visualize the shapes with a placeholder style.
Meshes fetched by the loader are trimesh.Trimesh instances that contain all relevant geometry information.
"""Unsylized 3D shape loader.
Args:
zip_path: 3DCoMPaT models zip directory.
meta_dir: Metadata directory.
split: One of {train, valid}.
semantic_level: Semantic level to use for segmentations. One of {fine, medium, coarse}
n_points: Number of sampled points.
load_mesh: Only load meshes.
shape_only: Ignore part segments while sampling pointclouds.
get_normals: Also return normal vectors for each sampled point.
shuffle: Shuffle the dataset.
seed: Initial random seed.
"""
from compat3D import ShapeLoader
train_dataset = ShapeLoader(zip_path=ZIP_PATH,
meta_dir=METADATA_DIR,
split="train",
load_mesh=True,
shuffle=True,
seed=42)
# Iterating over the loader
for shape_id, shape_label, mesh in train_dataset:
break
mesh.show()