### Typecheck Setup Source: https://github.com/lucidrains/meshgpt-pytorch/blob/main/README.md Copy the sample environment file to `.env` at the project root to set up environment variables for typechecking. ```bash $ cp .env.sample .env ``` -------------------------------- ### Install MeshGPT-PyTorch Source: https://github.com/lucidrains/meshgpt-pytorch/blob/main/README.md Install the MeshGPT-PyTorch library using pip. This is the first step to using the library. ```bash $ pip install meshgpt-pytorch ``` -------------------------------- ### MeshTransformerTrainer Setup Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Sets up and initializes the MeshTransformerTrainer for training, supporting text-conditioned generation. Requires a dataset that includes text descriptions. ```python import torch from torch.utils.data import Dataset from meshgpt_pytorch import MeshAutoencoder, MeshTransformer from meshgpt_pytorch.trainer import MeshTransformerTrainer # Dataset with text descriptions for text-conditioned training class TextMeshDataset(Dataset): def __init__(self, num_samples=1000): self.num_samples = num_samples self.descriptions = ['a chair', 'a table', 'a lamp', 'a sofa'] def __len__(self): return self.num_samples def __getitem__(self, idx): vertices = torch.randn(121, 3) faces = torch.randint(0, 121, (64, 3)) text = self.descriptions[idx % len(self.descriptions)] return dict(vertices=vertices, faces=faces, texts=text) # Create autoencoder and transformer autoencoder = MeshAutoencoder(num_discrete_coors=128) transformer = MeshTransformer( autoencoder, dim=512, max_seq_len=768, condition_on_text=True ) train_dataset = TextMeshDataset(num_samples=10000) val_dataset = TextMeshDataset(num_samples=500) # Initialize MeshTransformerTrainer (configuration details would follow) ``` -------------------------------- ### MeshAutoencoderTrainer Setup Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Sets up and initializes the MeshAutoencoderTrainer for training. Requires a custom dataset and configuration for training parameters, validation, and checkpointing. ```python import torch from torch.utils.data import Dataset from meshgpt_pytorch import MeshAutoencoder from meshgpt_pytorch.trainer import MeshAutoencoderTrainer # Custom dataset for mesh data class MeshDataset(Dataset): def __init__(self, num_samples=1000): self.num_samples = num_samples def __len__(self): return self.num_samples def __getitem__(self, idx): # Return dict or tuple of (vertices, faces, face_edges) vertices = torch.randn(121, 3) faces = torch.randint(0, 121, (64, 3)) return dict(vertices=vertices, faces=faces) # Create model and datasets autoencoder = MeshAutoencoder( num_discrete_coors=128, num_quantizers=2 ) train_dataset = MeshDataset(num_samples=10000) val_dataset = MeshDataset(num_samples=500) # Initialize trainer trainer = MeshAutoencoderTrainer( model=autoencoder, dataset=train_dataset, val_dataset=val_dataset, num_train_steps=100000, batch_size=16, grad_accum_every=4, # Gradient accumulation steps learning_rate=1e-4, weight_decay=0.0, max_grad_norm=1.0, # Gradient clipping val_every=100, # Validate every N steps val_num_batches=5, # Batches per validation checkpoint_every=1000, # Save checkpoint every N steps checkpoint_folder='./checkpoints', warmup_steps=1000, use_wandb_tracking=False, # Enable Weights & Biases logging data_kwargs=['vertices', 'faces'] ) # Start training trainer() # Calls forward() which runs the training loop # Save and load checkpoints trainer.save('./checkpoints/autoencoder.pt') trainer.load('./checkpoints/autoencoder.pt') # Use EMA model for tokenization (recommended for inference) codes = trainer.tokenize(vertices=vertices, faces=faces) ``` -------------------------------- ### Initialize MeshTransformer for Unconditional Generation Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Initializes a MeshTransformer model for unconditional 3D mesh generation. This setup is a prerequisite for using the `.generate` method. ```python import torch from meshgpt_pytorch import MeshAutoencoder, MeshTransformer from x_transformers.autoregressive_wrapper import top_k, top_p autoencoder = MeshAutoencoder(num_discrete_coors=128) # Unconditional generation transformer = MeshTransformer( autoencoder, dim=512, max_seq_len=768 ) ``` -------------------------------- ### Initialize and Run MeshTransformerTrainer Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Configures the trainer for mesh transformer models and executes the training loop. ```python # Initialize trainer trainer = MeshTransformerTrainer( model=transformer, dataset=train_dataset, val_dataset=val_dataset, num_train_steps=100000, batch_size=8, grad_accum_every=8, learning_rate=2e-4, weight_decay=0.0, max_grad_norm=0.5, val_every=100, val_num_batches=5, checkpoint_every=1000, checkpoint_folder='./checkpoints', warmup_steps=1000, use_wandb_tracking=False, data_kwargs=['vertices', 'faces', 'texts'] # Include 'texts' for text conditioning ) # Start training trainer() # Save checkpoint trainer.save('./checkpoints/transformer.pt') ``` -------------------------------- ### Initialize Text-Conditioned MeshTransformer Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Initializes a MeshTransformer for text-conditioned mesh generation. Set `condition_on_text=True` and configure text-related parameters. Classifier-free guidance is enabled by default. ```python import torch from meshgpt_pytorch import MeshAutoencoder, MeshTransformer autoencoder = MeshAutoencoder(num_discrete_coors=128) # Enable text conditioning transformer = MeshTransformer( autoencoder, dim=512, max_seq_len=768, condition_on_text=True, # Enable text conditioning text_condition_model_types=('t5',), # Text encoder type text_condition_cond_drop_prob=0.25, # Dropout for classifier-free guidance text_cond_with_film=False, # Use FiLM conditioning fine_cross_attend_text=True, # Cross-attend text in fine decoder coarse_adaptive_rmsnorm=False # Adaptive normalization with text ) # Training with text descriptions vertices = torch.randn((2, 121, 3)) faces = torch.randint(0, 121, (2, 64, 3)) loss = transformer( vertices=vertices, faces=faces, texts=['a high chair', 'a small teapot'] # Text descriptions ) loss.backward() # Pre-compute text embeddings for efficiency text_embeds = transformer.embed_texts(['a wooden table', 'a ceramic vase']) print(f"Text embedding shape: {text_embeds.shape}") # Training with pre-computed embeddings loss = transformer( vertices=vertices, faces=faces, text_embeds=text_embeds ) ``` -------------------------------- ### Initialize and Train MeshTransformer Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Initializes a MeshTransformer model with an autoencoder and demonstrates its training process. Ensure the autoencoder is created and trained before initializing the transformer. ```python import torch from meshgpt_pytorch import MeshAutoencoder, MeshTransformer # First create and train an autoencoder autoencoder = MeshAutoencoder( num_discrete_coors=128, num_quantizers=2 ) # Initialize transformer with the autoencoder transformer = MeshTransformer( autoencoder, dim=512, # Model dimension (or tuple for coarse/fine) max_seq_len=768, # Maximum sequence length attn_depth=12, # Number of coarse attention layers attn_heads=16, # Number of attention heads attn_dim_head=64, # Dimension per attention head flash_attn=True, # Use Flash Attention dropout=0., # Dropout rate coarse_pre_gateloop_depth=2, # GateLoop layers before coarse attention fine_pre_gateloop_depth=2, # GateLoop layers before fine attention fine_attn_depth=2, # Fine attention depth pad_id=-1 # Padding ID ) # Training: forward pass returns cross-entropy loss vertices = torch.randn((2, 121, 3)) faces = torch.randint(0, 121, (2, 64, 3)) loss = transformer( vertices=vertices, faces=faces ) loss.backward() print(f"Training loss: {loss.item():.4f}") # Can also pass pre-computed codes directly codes = autoencoder.tokenize(vertices=vertices, faces=faces) loss = transformer( vertices=vertices, faces=faces, codes=codes # Skip tokenization if codes already available ) ``` -------------------------------- ### Load Pretrained Models Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Loads models from the Hugging Face Hub or a local file path. ```python from meshgpt_pytorch import MeshAutoencoder, MeshTransformer # Load pretrained autoencoder from Hugging Face autoencoder = MeshAutoencoder._from_pretrained( model_id="MarcusLoren/MeshGPT-preview", # HF repo ID map_location="cuda", # Device to load to strict=False # Allow partial loading ) # Or load from local path autoencoder = MeshAutoencoder.init_and_load( './checkpoints/mesh-autoencoder.bin', strict=False ) ``` -------------------------------- ### Initialize and Train MeshAutoencoder Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Configures the autoencoder with custom dimensions and quantization settings, then performs a forward pass to compute reconstruction and commitment losses. ```python import torch from meshgpt_pytorch import MeshAutoencoder # Initialize autoencoder with custom configuration autoencoder = MeshAutoencoder( num_discrete_coors=128, # Number of discrete coordinate bins coor_continuous_range=(-1., 1.), # Range for coordinate values dim_coor_embed=64, # Dimension of coordinate embeddings encoder_dims_through_depth=(64, 128, 256, 256, 576), # Encoder layer dimensions decoder_dims_through_depth=(128, 128, 128, 128, 192, 192, 192, 192, 256, 256, 256, 256, 256, 256, 384, 384, 384), dim_codebook=192, # Codebook dimension num_quantizers=2, # Number of RVQ layers (D in paper) codebook_size=16384, # Codebook size per quantizer use_residual_lfq=True, # Use lookup-free quantization attn_encoder_depth=0, # Attention layers in encoder attn_decoder_depth=0, # Attention layers in decoder local_attn_window_size=64, # Local attention window pad_id=-1, # Padding ID for variable-length meshes quads=False # Set True for quad meshes instead of triangles ) # Prepare mesh data (batch of 2 meshes) # vertices: (batch, num_vertices, 3) - xyz coordinates # faces: (batch, num_faces, 3) - vertex indices per face vertices = torch.randn((2, 121, 3)) faces = torch.randint(0, 121, (2, 64, 3)) # Pad faces with -1 for variable-length meshes # faces[0, 50:] = -1 # Example: first mesh has only 50 faces # Forward pass returns reconstruction + commitment loss loss = autoencoder( vertices=vertices, faces=faces ) loss.backward() # Get detailed loss breakdown total_loss, (recon_loss, commit_loss) = autoencoder( vertices=vertices, faces=faces, return_loss_breakdown=True ) print(f"Reconstruction loss: {recon_loss.item():.4f}") print(f"Commitment loss: {commit_loss.sum().item():.4f}") # Get reconstructed faces directly recon_faces = autoencoder( vertices=vertices, faces=faces, only_return_recon_faces=True ) # recon_faces shape: (batch, num_faces, 3, 3) - 3 vertices with xyz coords per face ``` -------------------------------- ### Implement Custom Dataset with DatasetFromTransforms Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Loads mesh files from a directory using custom transform functions for specific file formats. ```python from pathlib import Path from meshgpt_pytorch.data import DatasetFromTransforms # Define transform functions for different mesh formats def load_obj(path: Path): """Load vertices and faces from OBJ file.""" import torch vertices, faces = [], [] with open(path) as f: for line in f: if line.startswith('v '): vertices.append([float(x) for x in line.split()[1:4]]) elif line.startswith('f '): # OBJ faces are 1-indexed face = [int(x.split('/')[0]) - 1 for x in line.split()[1:4]] faces.append(face) return torch.tensor(vertices), torch.tensor(faces) def load_ply(path: Path): """Load vertices and faces from PLY file.""" # Implement PLY loading logic import torch # ... parsing logic ... vertices = torch.randn(100, 3) # Placeholder faces = torch.randint(0, 100, (50, 3)) return vertices, faces # Create dataset with multiple format support dataset = DatasetFromTransforms( folder='./mesh_data', transforms={ 'obj': load_obj, 'ply': load_ply }, data_kwargs=['vertices', 'faces'], augment_fn=lambda x: x # Optional augmentation function ) print(f"Found {len(dataset)} meshes") # Access mesh data vertices, faces = dataset[0] ``` -------------------------------- ### Generate Meshes with Pretrained Model Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Generates 3D mesh coordinates and masks using a pretrained MeshTransformer model. Parameters like 'batch_size', 'temperature', and 'cache_kv' control the generation process. ```python face_coords, face_mask = transformer.generate( batch_size=1, temperature=0.8, cache_kv=True ) ``` -------------------------------- ### Initialize and Train Mesh Autoencoder Source: https://github.com/lucidrains/meshgpt-pytorch/blob/main/README.md Initialize the MeshAutoencoder and train it by passing vertex and face data. The autoencoder learns a latent representation of the meshes. ```python import torch from meshgpt_pytorch import ( MeshAutoencoder, MeshTransformer ) # autoencoder autoencoder = MeshAutoencoder( num_discrete_coors = 128 ) # mock inputs vertices = torch.randn((2, 121, 3)) # (batch, num vertices, coor (3)) faces = torch.randint(0, 121, (2, 64, 3)) # (batch, num faces, vertices (3)) # make sure faces are padded with `-1` for variable lengthed meshes # forward in the faces loss = autoencoder( vertices = vertices, faces = faces ) loss.backward() ``` -------------------------------- ### Text-Conditioned Mesh Generation Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Generates meshes based on text descriptions using a MeshTransformer. Utilizes classifier-free guidance for improved conditioning. Can return raw codes instead of face coordinates. ```python # Text-conditioned generation with classifier-free guidance transformer_text = MeshTransformer( autoencoder, dim=512, max_seq_len=768, condition_on_text=True ) # Generate from text descriptions face_coordinates, face_mask = transformer_text.generate( texts=['a long dining table', 'a round coffee table'], cond_scale=8.0, # Classifier-free guidance scale (3-10) temperature=0.9, cache_kv=True ) ``` ```python # Return raw codes instead of face coordinates codes = transformer_text.generate( texts=['a modern chair'], return_codes=True, cond_scale=5.0 ) print(f"Generated codes shape: {codes.shape}") ``` -------------------------------- ### Deterministic Mesh Generation Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Generates meshes deterministically using greedy decoding (argmax) by setting temperature to 0.0. This ensures the same output for the same input conditions. ```python # Deterministic generation (greedy decoding) face_coordinates, face_mask = transformer.generate( batch_size=1, temperature=0.0, # Temperature 0 = argmax cache_kv=True ) ``` -------------------------------- ### Initialize and Train Mesh Transformer Source: https://github.com/lucidrains/meshgpt-pytorch/blob/main/README.md Initialize the MeshTransformer using the trained autoencoder. Train the transformer by passing vertex and face data. The transformer models the sequence of face vertices. ```python # after much training... # you can pass in the raw face data above to train a transformer to model this sequence of face vertices transformer = MeshTransformer( autoencoder, dim = 512, max_seq_len = 768 ) loss = transformer( vertices = vertices, faces = faces ) loss.backward() ``` -------------------------------- ### Generate Meshes with MeshGPT Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Generates meshes using the MeshGPT transformer. Supports various sampling strategies and KV caching for efficiency. The output includes face coordinates and a mask for valid faces. ```python face_coordinates, face_mask = transformer.generate( batch_size=4, # Number of meshes to generate temperature=1.0, # Sampling temperature filter_logits_fn=top_k, # Sampling strategy (top_k or top_p) filter_kwargs=dict(k=50), # top-k with k=50 cache_kv=True, # Enable KV caching for speed max_seq_len=768 # Maximum sequence length ) # face_coordinates: (batch, num_faces, 3, 3) - generated face vertices # face_mask: (batch, num_faces) - valid face mask print(f"Generated {face_mask.sum(dim=1)} faces per mesh") ``` -------------------------------- ### Tokenize Meshes for Multimodal Transformers Source: https://github.com/lucidrains/meshgpt-pytorch/blob/main/README.md Tokenize meshes using the autoencoder's `.tokenize` method. This is useful for integrating meshes into multimodal transformer models. ```python # if you want to tokenize meshes, for use in your multimodal transformer, simply invoke `.tokenize` on your autoencoder (or same method on autoencoder trainer instance for the exponentially smoothed model) mesh_token_ids = autoencoder.tokenize( vertices = vertices, faces = faces ) # (batch, num face vertices, residual quantized layer) ``` -------------------------------- ### Load Pretrained Transformer Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Loads a pretrained MeshTransformer model from a specified model ID. Ensure the model ID is valid and accessible. The 'map_location' argument specifies the device to load the model onto. ```python transformer = MeshTransformer._from_pretrained( model_id="MarcusLoren/MeshGPT-preview", map_location="cuda", strict=False ) ``` -------------------------------- ### Decode Tokens to Faces Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Reconstructs mesh face coordinates from quantized token codes. ```python import torch from meshgpt_pytorch import MeshAutoencoder autoencoder = MeshAutoencoder( num_discrete_coors=128, num_quantizers=2 ) # Assume we have codes from tokenization or generation ``` -------------------------------- ### Tokenize Mesh Geometry Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Converts mesh vertices and faces into discrete token sequences. The output shape depends on the number of faces and vertices. ```python import torch from meshgpt_pytorch import MeshAutoencoder autoencoder = MeshAutoencoder( num_discrete_coors=128, num_quantizers=2, codebook_size=16384 ) # Input mesh data vertices = torch.randn((2, 121, 3)) faces = torch.randint(0, 121, (2, 64, 3)) # Tokenize mesh into discrete codes # Returns codes of shape (batch, num_face_vertices, num_quantizers) # For triangles: num_face_vertices = num_faces * 3 mesh_token_ids = autoencoder.tokenize( vertices=vertices, faces=faces ) print(f"Token shape: {mesh_token_ids.shape}") # Output: Token shape: torch.Size([2, 192, 2]) # 64 faces * 3 vertices = 192 # Single mesh (without batch dimension) single_vertices = torch.randn((121, 3)) single_faces = torch.randint(0, 121, (64, 3)) single_tokens = autoencoder.tokenize( vertices=single_vertices, faces=single_faces ) print(f"Single mesh tokens: {single_tokens.shape}") # Output: Single mesh tokens: torch.Size([192, 2]) ``` -------------------------------- ### Generate Novel 3D Assets Source: https://github.com/lucidrains/meshgpt-pytorch/blob/main/README.md After training the transformer, generate novel 3D assets. The output includes face coordinates and a face mask. ```python # after much training of transformer, you can now sample novel 3d assets faces_coordinates, face_mask = transformer.generate() # (batch, num faces, vertices (3), coordinates (3)), (batch, num faces) # now post process for the generated 3d asset ``` -------------------------------- ### MeshAutoencoder.tokenize Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Converts raw mesh geometry into discrete token sequences suitable for transformer training. ```APIDOC ## MeshAutoencoder.tokenize ### Description Encodes mesh vertices and faces into discrete token IDs using residual vector quantization. ### Parameters #### Request Body - **vertices** (torch.Tensor) - Required - Mesh vertices with shape (batch, num_vertices, 3) or (num_vertices, 3). - **faces** (torch.Tensor) - Required - Mesh faces with shape (batch, num_faces, 3) or (num_faces, 3). ### Response #### Success Response (200) - **mesh_token_ids** (torch.Tensor) - Quantized codes with shape (batch, num_face_vertices, num_quantizers). ``` -------------------------------- ### Cache Dataset Features with Decorators Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Uses decorators to cache text embeddings and face edges to disk, reducing redundant computation during training. ```python from torch.utils.data import Dataset from meshgpt_pytorch.data import ( cache_text_embeds_for_dataset, cache_face_edges_for_dataset ) from meshgpt_pytorch import MeshTransformer, MeshAutoencoder # Setup for text embedding caching autoencoder = MeshAutoencoder(num_discrete_coors=128) transformer = MeshTransformer( autoencoder, dim=512, max_seq_len=768, condition_on_text=True ) # Apply both decorators to cache text embeds and face edges @cache_face_edges_for_dataset( max_edges_len=10000, cache_path='./cache/face_edges', pad_id=-1 ) @cache_text_embeds_for_dataset( embed_texts_fn=transformer.embed_texts, max_text_len=256, cache_path='./cache/text_embeds' ) class CachedMeshDataset(Dataset): def __init__(self, mesh_paths, descriptions): self.mesh_paths = mesh_paths self.descriptions = descriptions # data_kwargs will be auto-modified by decorators: # 'texts' -> 'text_embeds', and 'face_edges' is appended self.data_kwargs = ['vertices', 'faces', 'texts'] def __len__(self): return len(self.mesh_paths) def __getitem__(self, idx): # Load mesh from file vertices, faces = self.load_mesh(self.mesh_paths[idx]) text = self.descriptions[idx] return dict( vertices=vertices, faces=faces, texts=text # Will be converted to text_embeds by decorator ) def load_mesh(self, path): import torch return torch.randn(100, 3), torch.randint(0, 100, (50, 3)) # Usage - first epoch caches, subsequent epochs load from cache dataset = CachedMeshDataset( mesh_paths=['mesh1.obj', 'mesh2.obj'], descriptions=['a wooden chair', 'a metal table'], cache_memmap_file_mode='w+' # 'w+' for first run, 'r+' for subsequent ) # data_kwargs is now ['vertices', 'faces', 'text_embeds', 'face_edges'] print(f"Data kwargs: {dataset.data_kwargs}") ``` -------------------------------- ### Save Trained Models Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Saves the trained autoencoder and transformer models to local files. Specify the desired file paths for saving. ```python autoencoder.save('./my_autoencoder.pt') transformer.save('./my_transformer.pt') ``` -------------------------------- ### Tokenize and Decode Vertices and Faces Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Tokenizes vertices and faces using an autoencoder and decodes them back to face coordinates. Useful for preparing mesh data for the transformer. ```python vertices = torch.randn((2, 121, 3)) faces = torch.randint(0, 121, (2, 64, 3)) # First tokenize to get codes codes = autoencoder.tokenize(vertices=vertices, faces=faces) # Decode codes back to face coordinates face_coords, face_mask = autoencoder.decode_from_codes_to_faces(codes) # face_coords shape: (batch, num_faces, 3, 3) - 3 vertices with xyz per face # face_mask shape: (batch, num_faces) - boolean mask for valid faces print(f"Decoded face coordinates shape: {face_coords.shape}") print(f"Valid faces: {face_mask.sum(dim=1)}") # Get discrete codes along with continuous coordinates face_coords, discrete_codes, face_mask = autoencoder.decode_from_codes_to_faces( codes, return_discrete_codes=True ) ``` -------------------------------- ### MeshAutoencoder Forward Pass Source: https://context7.com/lucidrains/meshgpt-pytorch/llms.txt Initializes the MeshAutoencoder and performs a forward pass to compute reconstruction and commitment losses for training. ```APIDOC ## MeshAutoencoder Forward Pass ### Description Initializes the MeshAutoencoder and computes the loss for a batch of 3D meshes. ### Parameters #### Request Body - **vertices** (torch.Tensor) - Required - Batch of mesh vertices with shape (batch, num_vertices, 3). - **faces** (torch.Tensor) - Required - Batch of mesh faces with shape (batch, num_faces, 3). - **return_loss_breakdown** (bool) - Optional - If True, returns individual reconstruction and commitment losses. - **only_return_recon_faces** (bool) - Optional - If True, returns only the reconstructed face coordinates. ### Response #### Success Response (200) - **loss** (torch.Tensor) - The total loss value for the forward pass. ``` -------------------------------- ### Text-Conditioned 3D Shape Synthesis Source: https://github.com/lucidrains/meshgpt-pytorch/blob/main/README.md Enable text conditioning by setting `condition_on_text = True` on `MeshTransformer`. Pass descriptions as the `texts` keyword argument during training and generation. ```python transformer = MeshTransformer( autoencoder, dim = 512, max_seq_len = 768, condition_on_text = True ) loss = transformer( vertices = vertices, faces = faces, texts = ['a high chair', 'a small teapot'], ) loss.backward() # after much training of transformer, you can now sample novel 3d assets conditioned on text faces_coordinates, face_mask = transformer.generate( texts = ['a long table'], cond_scale = 8., # a cond_scale > 1. will enable classifier free guidance - can be placed anywhere from 3. - 10. remove_parallel_component = True # from https://arxiv.org/abs/2410.02416 ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.