PyTorch3D

PyTorch3D

  • Docs
  • Tutorials
  • API
  • GitHub
Support Ukraine 🇺🇦 Help Provide Humanitarian Aid to Ukraine.
Project Logo

A library for deep learning with 3D data

Docs
Tutorials
Get Started

Heterogeneous Batching

Supports batching of 3D inputs of different sizes such as meshes

Fast 3D Operators

Supports optimized implementations of several common functions for 3D data

Differentiable Rendering

Modular differentiable rendering API with parallel implementations in PyTorch, C++ and CUDA

Get Started

  1. Install PyTorch3D (following the instructions here)
  2. Try a few 3D operators e.g. compute the chamfer loss between two meshes:
    from pytorch3d.utils import ico_sphere
    from pytorch3d.io import load_obj
    from pytorch3d.structures import Meshes
    from pytorch3d.ops import sample_points_from_meshes
    from pytorch3d.loss import chamfer_distance
    
    # Use an ico_sphere mesh and load a mesh from an .obj e.g. model.obj
    sphere_mesh = ico_sphere(level=3)
    verts, faces, _ = load_obj("model.obj")
    test_mesh = Meshes(verts=[verts], faces=[faces.verts_idx])
    
    # Differentiably sample 5k points from the surface of each mesh and then compute the loss.
    sample_sphere = sample_points_from_meshes(sphere_mesh, 5000)
    sample_test = sample_points_from_meshes(test_mesh, 5000)
    loss_chamfer, _ = chamfer_distance(sample_sphere, sample_test)
    
pytorch3d
Facebook Open Source
Copyright © 2024 Meta Platforms, Inc
Legal:PrivacyTerms