TripoSR

class grid.model.generation.mesh.triposr.TripoSR(*args, **kwargs)

TriPoSR: Image to 3D Mesh Reconstruction

This class implements a wrapper for the TriPoSR model, which reconstructs 3D meshes from 2D images. It utilizes the TSR library for model operations and the rembg library for background removal.

generate_mesh(image (np.ndarray)) Tuple[np.ndarray, str]

Generates a 3D mesh from the input image.

Parameters:

image (ndarray)

Return type:

Tuple[ndarray, str]

clear_weights()

Clears the model weights to free up memory.

Example

>>> from PIL import Image
>>> import numpy as np
>>> from grid.model.generation.mesh.triposr import TripoSR
>>> img = np.asarray(Image.open("path/to/image.jpg").convert("RGB"))
>>> triposr = TripoSR()
>>> preprocessed_image, mesh_name = triposr.generate_mesh(img)
Credits:

TriPoSR: https://huggingface.co/stabilityai/TripoSR

__init__()

Initializes the TripoSR model.

Return type:

None

generate_mesh(image)

Generate a mesh from the given image.

Parameters:

image (np.ndarray) -- The input image as a NumPy array.

Returns:

A tuple containing the preprocessed image as a NumPy array and the name of the generated mesh file.

Return type:

Tuple[np.ndarray, str]

Example

`python from PIL import Image import numpy as np from grid.model.generation.mesh.triposr import TripoSR img = np.asarray(Image.open("path/to/image.jpg").convert("RGB")) triposr = TripoSR() preprocessed_image, mesh_name = triposr.generate_mesh(img) `