3D Generation API
API reference for the 3D Generation module.
ModelGenerator
Main class for generating 3D models from 2D masks.
Constructor
Parameters:
method(str): Depth estimation method ('midas', 'silhouette')resolution(int): Mesh resolutiondevice(str): Compute device ('cuda' or 'cpu')
Example:
Methods
generate_from_mask()
Generate 3D model from 2D segmentation mask.
def generate_from_mask(
mask: np.ndarray,
depth_scale: float = 1.0,
mesh_simplification: float = 1.0
) -> Mesh3D
Parameters:
mask(np.ndarray): Binary segmentation maskdepth_scale(float): Scale factor for depth valuesmesh_simplification(float): Simplification ratio (0-1)
Returns: 3D mesh object
save_model()
Save 3D model to file.
Parameters:
model(Mesh3D): 3D mesh to saveoutput_path(str): Output file pathformat(str): File format ('obj', 'ply', 'stl', 'gltf')
batch_generate()
Generate multiple 3D models in batch.
Parameters:
masks(list): List of binary masksnum_workers(int): Number of parallel workers
Returns: List of 3D mesh objects
estimate_depth()
Estimate depth map from mask.
Parameters:
mask(np.ndarray): Binary segmentation mask
Returns: Depth map as numpy array
simplify_mesh()
Reduce mesh polygon count.
Parameters:
model(Mesh3D): Input meshtarget_faces(int): Target number of facespreserve_boundary(bool): Preserve mesh boundaries
Returns: Simplified mesh
smooth_mesh()
Apply smoothing to mesh.
Parameters:
model(Mesh3D): Input meshiterations(int): Number of smoothing iterationsmethod(str): Smoothing method ('laplacian', 'taubin')
Returns: Smoothed mesh