VGGT (Visual Geometry Grounded Transformer)

repository·main·Indexed 12 days ago

https://github.com/facebookresearch/vggt

A feed-forward neural network designed to infer 3D scene attributes—including camera parameters, depth maps, point maps, and 3D point tracks—from one or more image views in seconds. It supports zero-shot single-view reconstruction and can export results to COLMAP format for integration with tools like gsplat.

Tokens
4.2K
Snippets
17
Records
21
Agent score
85%

What's inside VGGT

  1. Perform zero-shot single-view reconstruction

    main
    VGGT can perform single-view 3D reconstruction without explicit training for the task. The model infers 3D structure directly from the tokens of a single view image, meaning you do not need to duplicate the single-view image into a pair. It has shown competitive or better results compared to state-of-the-art monocular depth estimation methods like DepthAnything v2 or MoGe.
  2. Commercial usage and model checkpoints

    main

    Standard model checkpoints may have different licensing terms. Only the specific checkpoint hosted on Hugging Face allows for commercial usage. This commercial checkpoint (VGGT-1B-Commercial) achieves performance levels comparable to or slightly better than the original (e.g., AUC@30: 90.37 vs 89.98 on the Co3D dataset).

    https://huggingface.co/facebook/VGGT-1B-Commercial
  3. Install VGGT

    main

    To install VGGT, clone the repository and install the required dependencies using pip.

    Required dependencies include torch, torchvision, numpy, Pillow, and huggingface_hub.

    git clone git@github.com:facebookresearch/vggt.git 
    cd vggt
    pip install -r requirements.txt
  4. Integrate with Gaussian Splatting (gsplat)

    main

    The COLMAP files exported by VGGT can be used directly for training with gsplat.

    Workflow:

    1. Export COLMAP files using demo_colmap.py.
    2. Install gsplat (version 1.3.0 is recommended).
    3. Run the trainer pointing to your scene directory.
    cd gsplat
    python examples/simple_trainer.py  default --data_factor 1 --data_dir /YOUR/SCENE_DIR/ --result_dir /YOUR/RESULT_DIR/
  5. Install PyTorch and torchvision prerequisites

    main

    Before installing VGGT, you must manually install torch and torchvision to prevent CUDA version mismatches. It is recommended to install PyTorch 2.3.1 with CUDA 12.1.

    # install pytorch 2.3.1 with cuda 12.1
    pip install torch==2.3.1 torchvision==0.18.1 --index-url https://download.pytorch.org/whl/cu121
  6. Quick Start: Run VGGT inference

    main

    You can run VGGT inference with a few lines of code. The model automatically downloads pretrained weights from Hugging Face on the first run.

    Note on Precision: bfloat16 is supported on Ampere GPUs (Compute Capability 8.0+). For older GPUs, use float16.

    import torch
    from vggt.models.vggt import VGGT
    from vggt.utils.load_fn import load_and_preprocess_images
    
    device = "cuda" if torch.cuda.is_available() else "cpu"
    # bfloat16 is supported on Ampere GPUs (Compute Capability 8.0+)
    dtype = torch.bfloat16 if torch.cuda.get_device_capability()[0] >= 8 else torch.float16
    
    # Initialize the model and load the pretrained weights.
    model = VGGT.from_pretrained("facebook/VGGT-1B").to(device)
    
    # Load and preprocess example images (replace with your own image paths)
    image_names = ["path/to/imageA.png", "path/to/imageB.png", "path/to/imageC.png"]  
    images = load_and_preprocess_images(image_names).to(device)
    
    with torch.no_grad():
        with torch.cuda.amp.autocast(dtype=dtype):
            # Predict attributes including cameras, depth maps, and point maps.
            predictions = model(images)
  7. Visualize reconstructions with Gradio or Viser

    main

    To use the interactive visualization tools, first install the demo dependencies:

    pip install -r requirements_demo.txt

    Gradio Web Interface

    Launch a local web interface to upload images/videos and interactively explore the 3D scene:

    python demo_gradio.py

    Viser 3D Viewer

    Run reconstruction and visualize point clouds in viser. This script requires a folder containing only image files:

    python demo_viser.py --image_folder path/to/your/images/folder

    Use the --use_point_map flag to use the point cloud from the point map branch instead of the depth-based reconstruction.

    pip install -r requirements_demo.txt
    
    # Gradio
    python demo_gradio.py
    
    # Viser
    python demo_viser.py --image_folder path/to/your/images/folder