### Start Backend Service for Basic Workflow Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Initiates the backend service required for the basic workflow example. Specify the model directory, host, and port. ```bash # 🔧 Start backend service da3 backend --model-dir depth-anything/DA3NESTED-GIANT-LARGE --host 0.0.0.0 --port 8008 ``` -------------------------------- ### Start Gallery Server with Custom Host and Port Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Starts the Depth Anything 3 Gallery server with a custom host address and port number. ```bash da3 gallery \ --gallery-dir ./workspace \ --host 0.0.0.0 \ --port 8007 ``` -------------------------------- ### Install HuggingFace CLI Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/BENCHMARK.md Install the HuggingFace CLI tool, which is required for downloading benchmark datasets. ```bash pip install -U huggingface_hub[cli] ``` -------------------------------- ### Install Depth Anything 3 and Dependencies Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/README.md Installs the core library, PyTorch, xformers, and optional dependencies for Gradio UI or full features. Ensure PyTorch version is compatible. ```bash pip install xformers torch>=2 torchvision pip install -e . # Basic pip install --no-build-isolation git+https://github.com/nerfstudio-project/gsplat.git@0b4dddf04cb687367602c01196913cde6a743d70 # for gaussian head pip install -e "[app]" # Gradio, python>=3.10 pip install -e "[all]" # ALL ``` -------------------------------- ### Start Basic Gallery Server Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Launches a standalone Depth Anything 3 Gallery server, specifying the gallery directory. ```bash da3 gallery --gallery-dir ./workspace ``` -------------------------------- ### Start Backend Service Using CPU Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Launches a backend service for Depth Anything 3, explicitly setting the device to CPU. ```bash da3 backend --model-dir depth-anything/DA3NESTED-GIANT-LARGE --device cpu ``` -------------------------------- ### Install Depth Anything 3 Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/notebooks/da3.ipynb Installs the required depth-anything-3 package. Run this command in your environment before proceeding. ```python # Install required packages # !pip install depth-anything-3 ``` -------------------------------- ### Start Backend Service Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Start the backend service for efficient processing of multiple tasks. Specify the model directory, device, host, port, and gallery directory. ```bash # 🔧 Start backend da3 backend \ --model-dir depth-anything/DA3NESTED-GIANT-LARGE \ --device cuda \ --host 0.0.0.0 \ --port 8008 \ --gallery-dir ./workspace ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/da3_streaming/README.md Install the necessary Python dependencies for Depth Anything 3 by running pip with the requirements file. ```bash pip install -r requirements.txt ``` -------------------------------- ### Setup: Download Weights for DA3-Streaming Source: https://context7.com/bytedance-seed/depth-anything-3/llms.txt Before running DA3-Streaming, navigate to the 'da3_streaming' directory and execute the provided script to download necessary weights. ```bash cd da3_streaming bash ./scripts/download_weights.sh ``` -------------------------------- ### Start Gallery Server and Auto-Open Browser Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Launches the Depth Anything 3 Gallery server and automatically opens the default web browser. ```bash da3 gallery --gallery-dir ./workspace --open-browser ``` -------------------------------- ### Custom Model Configuration Example Source: https://context7.com/bytedance-seed/depth-anything-3/llms.txt Define custom model architectures using YAML configuration files. This example shows a basic structure for specifying backbone and head configurations. ```yaml backbone: name: resnet50 pretrained: true head: name: depth_head loss: l1 optimizer: lr: 0.0001 weight_decay: 0.0001 ``` -------------------------------- ### Full Evaluation Example Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/BENCHMARK.md Run a full evaluation using the specified model path. This command performs a comprehensive benchmark. ```bash MODEL=depth-anything/DA3-GIANT # Full evaluation python -m depth_anything_3.bench.evaluator model.path=$MODEL ``` -------------------------------- ### Start Depth Anything V3 Backend Service Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Start the backend service for model inference. This service keeps the model in GPU memory and provides a REST API. Optionally, configure host, port, and a gallery directory. ```bash da3 backend [OPTIONS] ``` -------------------------------- ### Start Depth Anything 3 Backend Service Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Starts the backend service, which keeps the model loaded in GPU memory for faster subsequent requests. Specify the model directory using `--model-dir`. ```bash da3 backend --model-dir depth-anything/DA3NESTED-GIANT-LARGE ``` -------------------------------- ### Install libGL for OpenCV Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/da3_streaming/README.md Install the libGL system dependency if encountering errors related to libGL.so.1, often from opencv-python. ```bash sudo apt-get install -y libgl1-mesa-glx ``` -------------------------------- ### Start Gradio Web Application Source: https://context7.com/bytedance-seed/depth-anything-3/llms.txt Launch an interactive Gradio web application for depth estimation. Configure the model directory, workspace, gallery, host, and port. ```bash da3 gradio \ --model-dir depth-anything/DA3NESTED-GIANT-LARGE \ --workspace-dir ./workspace \ --gallery-dir ./gallery \ --host 0.0.0.0 \ --port 7860 ``` -------------------------------- ### Start Backend Service with Model Caching Source: https://context7.com/bytedance-seed/depth-anything-3/llms.txt Launch a backend service to keep models in GPU memory for faster inference. Configure the model directory, device, host, port, and optionally a gallery directory. ```bash da3 backend \ --model-dir depth-anything/DA3NESTED-GIANT-LARGE \ --device cuda \ --host 0.0.0.0 \ --port 8008 \ --gallery-dir ./workspace ``` -------------------------------- ### Launch Basic Gradio Application Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Starts the Depth Anything 3 Gradio interactive web application with required model, workspace, and gallery directories. ```bash da3 gradio \ --model-dir depth-anything/DA3NESTED-GIANT-LARGE \ --workspace-dir ./workspace \ --gallery-dir ./gallery ``` -------------------------------- ### Pre-cache Example Scenes for Gradio App Source: https://context7.com/bytedance-seed/depth-anything-3/llms.txt Configure the Gradio application to pre-cache example scenes for faster loading. Specify the model directory, workspace, gallery, and cache options. ```bash da3 gradio \ --model-dir depth-anything/DA3NESTED-GIANT-LARGE \ --workspace-dir ./workspace \ --gallery-dir ./gallery \ --cache-examples \ --cache-gs-tag "dl3dv" ``` -------------------------------- ### Model Configuration Example (YAML) Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/README.md Define a custom model architecture by creating a new YAML configuration file. This specifies the network components and their parameters. ```yaml __object__: path: depth_anything_3.model.da3 name: DepthAnything3Net args: as_params net: __object__: path: depth_anything_3.model.dinov2.dinov2 name: DinoV2 args: as_params name: vitb out_layers: [5, 7, 9, 11] alt_start: 4 qknorm_start: 4 rope_start: 4 cat_token: True head: __object__: path: depth_anything_3.model.dualdpt name: DualDPT args: as_params dim_in: &head_dim_in 1536 output_dim: 2 features: &head_features 128 out_channels: &head_out_channels [96, 192, 384, 768] ``` -------------------------------- ### Depth Anything V3 Inference Usage Example Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/API.md Example of how to use the inference method of the Depth Anything V3 model and access its outputs. Ensure the model is loaded and images are provided as a list. ```python prediction = model.inference(image=["img1.jpg", "img2.jpg"]) # Access depth maps depth_maps = prediction.depth # shape: (2, H, W) # Access confidence if hasattr(prediction, 'conf'): confidence = prediction.conf ``` -------------------------------- ### Basic Depth Estimation Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/API.md Quick example to initialize the DepthAnything3 model and perform basic depth estimation on a list of images. ```APIDOC ## Basic Depth Estimation ```python from depth_anything_3.api import DepthAnything3 # Initialize and run inference model = DepthAnything3.from_pretrained("depth-anything/DA3NESTED-GIANT-LARGE").to("cuda") prediction = model.inference(["image1.jpg", "image2.jpg"]) ``` ``` -------------------------------- ### Export Results Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/API.md Example showing how to export depth data and 3D visualization results to a specified directory and format. ```APIDOC ## Export Results ```python # Export depth data and 3D visualization prediction = model.inference( image=image_paths, export_dir="./output", export_format="mini_npz-glb" ) ``` ``` -------------------------------- ### Reference View Selection Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/API.md Examples for selecting the reference view strategy, including 'saddle_balanced' for multi-view inputs and 'middle' for video sequences. ```APIDOC ## Reference View Selection ```python # For multi-view inputs, automatically select the best reference view prediction = model.inference( image=image_paths, ref_view_strategy="saddle_balanced", # Default: balanced selection ) # For video sequences, use middle frame as reference prediction = model.inference( image=video_frames, ref_view_strategy="middle", # Good for temporally ordered inputs ) ``` ``` -------------------------------- ### Multi-GPU Inference Setup Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/BENCHMARK.md Configure the number of GPUs for inference using the CUDA_VISIBLE_DEVICES environment variable. Defaults to all available GPUs if not specified. ```bash # Use 4 GPUs CUDA_VISIBLE_DEVICES=0,1,2,3 python -m depth_anything_3.bench.evaluator model.path=$MODEL ``` ```bash # Use all available GPUs (default) python -m depth_anything_3.bench.evaluator model.path=$MODEL ``` ```bash # Single GPU CUDA_VISIBLE_DEVICES=0 python -m depth_anything_3.bench.evaluator model.path=$MODEL ``` -------------------------------- ### Using Ray-Based Pose Estimation Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/API.md Example demonstrating the use of ray-based pose estimation as an alternative to the camera decoder. ```APIDOC ## Using Ray-Based Pose Estimation ```python # Use ray-based pose estimation instead of camera decoder prediction = model.inference( image=image_paths, export_dir="./output", export_format="glb", use_ray_pose=True, # Enable ray-based pose estimation ) ``` ``` -------------------------------- ### Depth Anything 3 Quick Start: Reuse Backend Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Processes a video file using auto mode and reuses the running backend service for inference. This is efficient for multiple jobs as the model remains in GPU memory. Specify the backend URL with `--backend-url`. ```bash da3 auto path/to/video.mp4 \ --export-dir ./workspace/scene002 \ --use-backend \ --backend-url http://localhost:8008 ``` -------------------------------- ### Start Gradio App with Public Sharing and Debug Mode Source: https://context7.com/bytedance-seed/depth-anything-3/llms.txt Launch the Gradio application with options for public sharing and enabling debug mode. Ensure model and workspace directories are set. ```bash da3 gradio \ --model-dir depth-anything/DA3NESTED-GIANT-LARGE \ --workspace-dir ./workspace \ --gallery-dir ./gallery \ --share \ --debug ``` -------------------------------- ### Depth Anything 3 CLI - Backend Service Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md The 'backend' command starts a service that keeps the model resident in GPU memory, allowing subsequent commands to reuse cached weights for faster inference. ```APIDOC ## POST /api/users ### Description Start the backend service to keep the model resident in GPU memory. ### Method POST ### Endpoint /api/users ### Parameters #### Path Parameters None #### Query Parameters - **--model-dir** (str) - Required - Path to the model directory (e.g., `depth-anything/DA3NESTED-GIANT-LARGE`) - **--port** (int) - Optional - Port for the backend service (Default: `8008`) - **--device** (str) - Optional - Device to use for the model (Default: `cuda`) #### Request Body None ### Request Example ```bash # 🔧 Start backend service (optional, keeps model resident in GPU memory) da3 backend --model-dir depth-anything/DA3NESTED-GIANT-LARGE ``` ### Response #### Success Response (200) - **message** (str) - Confirmation message that the backend service has started. #### Response Example ```json { "message": "Backend service started on port 8008" } ``` ``` -------------------------------- ### Advanced Export with Feature Visualization Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/API.md Example showcasing export with intermediate feature visualization, including specifying feature layers and frames per second for visualization. ```APIDOC ## Advanced Export with Feature Visualization ```python # Export with intermediate feature visualization prediction = model.inference( image=image_paths, export_dir="./output", export_format="mini_npz-glb-depth_vis-feat_vis", export_feat_layers=[0, 5, 10, 15, 20], feat_vis_fps=30, ) ``` ``` -------------------------------- ### Extract Frames from Video for DA3-Streaming Source: https://context7.com/bytedance-seed/depth-anything-3/llms.txt If your input is a video, use FFmpeg to extract frames into a specified directory. This example sets FPS to 5 and scales width to 640px while maintaining aspect ratio. ```bash mkdir ./extract_images ffmpeg -i your_video.mp4 -vf "fps=5,scale=640:-1" ./extract_images/frame_%06d.png ``` -------------------------------- ### Depth Anything 3 Quick Start: Auto Mode Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Processes an input file or directory using the auto mode, which detects the input type and applies the appropriate handler. The output is exported to the specified directory. ```bash da3 auto path/to/input --export-dir ./workspace/scene001 ``` -------------------------------- ### Load Model and Set Up Device Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/notebooks/da3.ipynb Loads the Depth Anything 3 model and moves it to the appropriate device (CUDA if available, otherwise CPU). Ensure the model is in evaluation mode. ```python import os import numpy as np import matplotlib.pyplot as plt from PIL import Image import torch from depth_anything_3.api import DepthAnything3 from depth_anything_3.utils.visualize import visualize_depth device = torch.device("cuda" if torch.cuda.is_available() else "cpu") model = DepthAnything3.from_pretrained("depth-anything/DA3NESTED-GIANT-LARGE") model = model.to(device) model.eval() print(f"Model loaded on {device}") ``` -------------------------------- ### View Main Help Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Display the main help message for the da3 CLI. ```bash # 📖 View main help da3 --help ``` -------------------------------- ### Launch Gallery to View Results Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Launch the gallery to view processed results. Specify the gallery directory and optionally open the browser. ```bash # 🖞ïļ Launch gallery to view results da3 gallery --gallery-dir ./workspace --open-browser ``` -------------------------------- ### Command Line Interface for Depth Anything 3 Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/funcs/ref_view_strategy.md Shows how to perform depth estimation using the Depth Anything 3 CLI with various reference view strategies. The default strategy is 'saddle_balanced'. Options include specifying strategies for auto, video, and multi-view image processing. ```bash # Default (saddle_balanced) da3 auto input/ --export-dir output/ # Explicitly specify strategy da3 auto input/ --ref-view-strategy saddle_balanced # For video processing da3 video input.mp4 --ref-view-strategy middle # For wide-baseline multi-view da3 images captures/ --ref-view-strategy saddle_sim_range ``` -------------------------------- ### Gallery Server Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Launches a standalone Depth Anything 3 Gallery server for viewing processed scenes. ```APIDOC ## POST /api/gallery ### Description Launches a standalone Depth Anything 3 Gallery server. ### Method POST ### Endpoint /api/gallery ### Parameters #### Query Parameters - **`--gallery-dir`** (str) - Required - Gallery root directory. Defaults to a default gallery directory. - **`--host`** (str) - Optional - Host address to bind to. Defaults to `127.0.0.1`. - **`--port`** (int) - Optional - Port number to bind to. Defaults to `8007`. - **`--open-browser`** (bool) - Optional - Open browser after launch. Defaults to `False`. ### Request Example ```json { "gallery_dir": "./workspace", "host": "0.0.0.0", "port": 8007, "open_browser": true } ``` ### Response #### Success Response (200) - **message** (str) - Confirmation message that the gallery server has started. #### Response Example ```json { "message": "Gallery server started successfully on http://127.0.0.1:8007." } ``` ``` -------------------------------- ### Download Benchmark Datasets Source: https://context7.com/bytedance-seed/depth-anything-3/llms.txt Download benchmark datasets for evaluation from HuggingFace using the 'hf download' command. Ensure the target directory is created. ```bash mkdir -p workspace/benchmark_dataset hf download depth-anything/DA3-BENCH \ --local-dir workspace/benchmark_dataset \ --repo-type dataset ``` -------------------------------- ### DepthAnything3 Class Initialization and Basic Inference Source: https://context7.com/bytedance-seed/depth-anything-3/llms.txt This snippet demonstrates how to initialize the DepthAnything3 model from HuggingFace Hub and perform basic inference on a directory of images. It also shows how to access the prediction outputs such as depth maps, confidence scores, and camera parameters, and how to export results. ```APIDOC ## DepthAnything3 Class Initialization and Basic Inference ### Description Initialize the DepthAnything3 model from HuggingFace Hub and perform basic inference on a directory of images. Access prediction outputs and export results. ### Method `DepthAnything3.from_pretrained(model_name)` `model.inference(images, ...)` ### Parameters #### Request Body (for `inference` method) - **images** (list[str] or list[np.ndarray]) - Required - List of image paths or image data. - **export_dir** (str) - Optional - Directory to save exported results. - **export_format** (str) - Optional - Format for export (e.g., "mini_npz-glb"). - **conf_thresh_percentile** (float) - Optional - Confidence threshold for point selection. - **num_max_points** (int) - Optional - Maximum number of points to export. - **show_cameras** (bool) - Optional - Whether to show camera positions in exported visualization. ### Request Example ```python import glob import os import torch import numpy as np from depth_anything_3.api import DepthAnything3 device = torch.device("cuda") model = DepthAnything3.from_pretrained("depth-anything/DA3NESTED-GIANT-LARGE") model = model.to(device=device) example_path = "assets/examples/SOH" images = sorted(glob.glob(os.path.join(example_path, "*.png"))) prediction = model.inference(images) print(prediction.processed_images.shape) print(prediction.depth.shape) print(prediction.conf.shape) print(prediction.extrinsics.shape) print(prediction.intrinsics.shape) prediction = model.inference( images, export_dir="./output", export_format="mini_npz-glb", conf_thresh_percentile=40.0, num_max_points=1_000_000, show_cameras=True ) ``` ### Response #### Success Response (200) - **processed_images** (np.ndarray) - Preprocessed images [N, H, W, 3] uint8. - **depth** (np.ndarray) - Depth maps [N, H, W] float32. - **conf** (np.ndarray) - Confidence maps [N, H, W] float32. - **extrinsics** (np.ndarray) - Camera extrinsics (world-to-camera) [N, 3, 4] float32. - **intrinsics** (np.ndarray) - Camera intrinsics [N, 3, 3] float32. #### Response Example ```json { "depth": "[N, H, W] float32 array", "conf": "[N, H, W] float32 array", "extrinsics": "[N, 3, 4] float32 array", "intrinsics": "[N, 3, 3] float32 array" } ``` ``` -------------------------------- ### Initialize and Run Basic Depth Estimation Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/API.md Initializes the DepthAnything3 model and performs basic depth estimation on a list of images. Ensure the model is moved to the appropriate device (e.g., 'cuda'). ```python from depth_anything_3.api import DepthAnything3 # Initialize and run inference model = DepthAnything3.from_pretrained("depth-anything/DA3NESTED-GIANT-LARGE").to("cuda") prediction = model.inference(["image1.jpg", "image2.jpg"]) ``` -------------------------------- ### Advanced Export with Gaussian Splatting Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/API.md Example for advanced export options including Gaussian Splatting (GS) formats, requiring specific models like 'da3-giant'. ```APIDOC ## Advanced Export with Gaussian Splatting ```python # Export multiple formats including Gaussian Splatting # Note: infer_gs=True requires da3-giant or da3nested-giant-large model model = DepthAnything3(model_name="da3-giant").to("cuda") prediction = model.inference( image=image_paths, extrinsics=extrinsics_array, intrinsics=intrinsics_array, export_dir="./output", export_format="npz-glb-gs_ply-gs_video", align_to_input_ext_scale=True, infer_gs=True, # Required for gs_ply and gs_video exports ) ``` ``` -------------------------------- ### Extract Benchmark Datasets Source: https://context7.com/bytedance-seed/depth-anything-3/llms.txt After downloading, navigate to the benchmark dataset directory and extract the zip files to prepare them for evaluation. ```bash cd workspace/benchmark_dataset for f in *.zip; do unzip -q "$f"; done cd ../.. ``` -------------------------------- ### Download Pre-trained Weights Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/da3_streaming/README.md Execute the provided bash script to download all required pre-trained model weights. ```bash bash ./scripts/download_weights.sh ``` -------------------------------- ### Initialize and Run Basic Inference with DepthAnything3 Source: https://context7.com/bytedance-seed/depth-anything-3/llms.txt Initializes the DepthAnything3 model from HuggingFace Hub and performs basic inference on a directory of images. It shows how to access the processed images, depth maps, confidence scores, and camera parameters. Results can be exported to various formats. ```python import glob import os import torch import numpy as np from depth_anything_3.api import DepthAnything3 # Initialize model from HuggingFace Hub device = torch.device("cuda") model = DepthAnything3.from_pretrained("depth-anything/DA3NESTED-GIANT-LARGE") model = model.to(device=device) # Basic inference on image directory example_path = "assets/examples/SOH" images = sorted(glob.glob(os.path.join(example_path, "*.png"))) prediction = model.inference(images) # Access prediction outputs print(prediction.processed_images.shape) # [N, H, W, 3] uint8 - preprocessed images print(prediction.depth.shape) # [N, H, W] float32 - depth maps print(prediction.conf.shape) # [N, H, W] float32 - confidence maps print(prediction.extrinsics.shape) # [N, 3, 4] float32 - camera extrinsics (w2c) print(prediction.intrinsics.shape) # [N, 3, 3] float32 - camera intrinsics # Export results to GLB format prediction = model.inference( images, export_dir="./output", export_format="mini_npz-glb", conf_thresh_percentile=40.0, num_max_points=1_000_000, show_cameras=True ) ``` -------------------------------- ### View Specific Command Help Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Display detailed help for specific da3 commands like 'auto', 'image', or 'backend'. ```bash # 🔍 View specific command help da3 auto --help da3 image --help da3 backend --help ``` -------------------------------- ### Export 3D Gaussian Splats and Rendered Videos Source: https://context7.com/bytedance-seed/depth-anything-3/llms.txt Enable the Gaussian branch for 3DGS point cloud and video exports. Requires DA3-GIANT or DA3NESTED-GIANT-LARGE models with gsplat installed. Set `infer_gs=True` for 3DGS exports. ```python from depth_anything_3.api import DepthAnything3 # Load model with Gaussian support model = DepthAnything3.from_pretrained("depth-anything/DA3NESTED-GIANT-LARGE").to("cuda") # Enable Gaussian branch and export prediction = model.inference( image=image_paths, infer_gs=True, # Required for 3DGS exports export_dir="./output", export_format="glb-gs_ply-gs_video", export_kwargs={ "gs_ply": { "gs_views_interval": 1 # Export every N views }, "gs_video": { "trj_mode": "interpolate_smooth", "chunk_size": 8, "vis_depth": "hcat", # Horizontal concat RGB+depth "video_quality": "high" } } ) # Access Gaussian data gaussians = prediction.aux.get("gaussians") ``` -------------------------------- ### Depth Anything 3 Auto Mode: Use Backend Service Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Processes an input using the 'auto' command while leveraging a running backend service for inference. This example also specifies multiple export formats and the backend URL. ```bash da3 auto path/to/input \ --export-format mini_npz-glb \ --use-backend \ --backend-url http://localhost:8008 \ --export-dir ./output ``` -------------------------------- ### Python: Create Model from Config Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/README.md Instantiate the model using a custom configuration file. This requires the `create_object` and `load_config` functions from the `depth_anything_3.cfg` module. ```python from depth_anything_3.cfg import create_object, load_config Model = create_object(load_config("path/to/new/config")) ``` -------------------------------- ### CLI: Auto Mode with Backend Reuse Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/README.md Use the CLI in auto mode, reusing the backend for caching models to the GPU. Ensure the model directory is set. ```bash export GALLERY_DIR=workspace/gallery mkdir -p $GALLERY_DIR da3 backend --model-dir ${MODEL_DIR} --gallery-dir ${GALLERY_DIR} # Cache model to gpu da3 auto assets/examples/SOH \ --export-format glb \ --export-dir ${GALLERY_DIR}/TEST_BACKEND/SOH \ --use-backend ``` -------------------------------- ### Download Specific Benchmark Dataset Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/BENCHMARK.md Download a specific dataset, such as 'hiroom.zip', from the HuggingFace repository. This is useful if you only need a subset of the benchmark data. ```bash # Download only HiRoom hf download depth-anything/DA3-BENCH hiroom.zip \ --local-dir workspace/benchmark_dataset \ --repo-type dataset ``` -------------------------------- ### Use Backend Service from Other Commands Source: https://context7.com/bytedance-seed/depth-anything-3/llms.txt Enable other DA3 commands to utilize a running backend service by specifying the '--use-backend' flag and the backend URL. ```bash da3 auto ./input \ --use-backend \ --backend-url http://localhost:8008 \ --export-dir ./output ``` -------------------------------- ### Export Multiple Formats in Depth Anything V3 Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/API.md Demonstrates how to export multiple formats simultaneously by separating them with a hyphen. This is useful for generating various outputs from a single inference pass. ```python # Export both mini_npz and glb formats export_format = "mini_npz-glb" ``` ```python # Export multiple formats export_format = "npz-glb-gs_ply" ``` -------------------------------- ### Quick Test on HiRoom Dataset Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/BENCHMARK.md Perform a quick test focusing only on the HiRoom dataset and pose estimation mode. This is useful for rapid checks. ```bash MODEL=depth-anything/DA3-GIANT # Quick test on HiRoom only python -m depth_anything_3.bench.evaluator \ model.path=$MODEL \ eval.datasets=[hiroom] \ eval.modes=[pose] ``` -------------------------------- ### Launch Gradio Application Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Launch the Gradio web application for interactive use. Specify the model directory, workspace, gallery directory, host, port, and whether to share the application. ```bash # ðŸŽĻ Launch Gradio application da3 gradio \ --model-dir depth-anything/DA3NESTED-GIANT-LARGE \ --workspace-dir workspace/gradio \ --gallery-dir ./gallery \ --host 0.0.0.0 \ --port 7860 \ --share ``` -------------------------------- ### Process Video in Basic Workflow Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Processes a video file using the Depth Anything 3 CLI, setting a specific frame rate for extraction, exporting results, and using a backend service. ```bash # 🎎 Process video da3 video video.mp4 --fps 2.0 --export-dir ./output2 --use-backend ``` -------------------------------- ### Backend Service Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/CLI.md Launches the backend service for Depth Anything 3. This service can be used to process images and videos, and can be accessed by other applications using the `--use-backend` flag. ```APIDOC ## POST /api/backend ### Description Starts the Depth Anything 3 backend service. ### Method POST ### Endpoint /api/backend ### Parameters #### Query Parameters - **`--model-dir`** (str) - Required - Model directory path. - **`--device`** (str) - Optional - Device to use (e.g., `cuda`, `cpu`). Defaults to `cuda` if available. - **`--host`** (str) - Optional - Host address to bind to. Defaults to `0.0.0.0`. - **`--port`** (int) - Optional - Port number to bind to. Defaults to `8008`. - **`--gallery-dir`** (str) - Optional - Directory for the gallery. If provided, a gallery server will also be launched. ### Request Example ```json { "model_dir": "depth-anything/DA3NESTED-GIANT-LARGE", "device": "cuda", "port": 8008, "gallery_dir": "./workspace" } ``` ### Response #### Success Response (200) - **message** (str) - Confirmation message that the backend service has started. #### Response Example ```json { "message": "Backend service started successfully on port 8008." } ``` ``` -------------------------------- ### Download and Extract Benchmark Data Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/BENCHMARK.md Download all benchmark datasets from HuggingFace and extract them. This includes setting an alternative endpoint if the default download is slow. ```bash cd da3_release mkdir -p workspace/benchmark_dataset hf download depth-anything/DA3-BENCH \ --local-dir workspace/benchmark_dataset \ --repo-type dataset cd workspace/benchmark_dataset for f in *.zip; do unzip -q "$f"; done ``` -------------------------------- ### Python API for Inference with Reference View Strategies Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/funcs/ref_view_strategy.md Demonstrates how to use the DepthAnything3 model's inference method with different reference view selection strategies. The default strategy is 'saddle_balanced'. For video sequences, 'middle' is recommended, and for wide-baseline multi-view scenarios, 'saddle_sim_range' can be effective. ```python from depth_anything_3 import DepthAnything3 model = DepthAnything3.from_pretrained("depth-anything/DA3NESTED-GIANT-LARGE") # Use default (saddle_balanced) prediction = model.inference( images, ref_view_strategy="saddle_balanced" ) # For video sequences, consider using middle prediction = model.inference( video_frames, ref_view_strategy="middle" # Good for temporal sequences ) # For complex scenes with wide baselines prediction = model.inference( images, ref_view_strategy="saddle_sim_range" ) ``` -------------------------------- ### DepthAnything3 Class Initialization Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/API.md Initializes the DepthAnything3 model with a specified model name and moves it to the GPU. ```APIDOC ## DepthAnything3 Class The main API class that provides depth estimation capabilities with optional pose conditioning. ### Initialization ```python from depth_anything_3 import DepthAnything3 # Initialize the model with a model name model = DepthAnything3(model_name="da3-large") model = model.to("cuda") # Move to GPU ``` **Parameters:** - `model_name` (str, default: "da3-large"): The name of the model preset to use. - **Available models:** - ðŸĶū `"da3-giant"` - 1.15B params, any-view model with GS support - ⭐ `"da3-large"` - 0.35B params, any-view model (recommended for most use cases) - ðŸ“Ķ `"da3-base"` - 0.12B params, any-view model - ðŸŠķ `"da3-small"` - 0.08B params, any-view model - 👁ïļ `"da3mono-large"` - 0.35B params, monocular depth only - 📏 `"da3metric-large"` - 0.35B params, metric depth with sky segmentation - ðŸŽŊ `"da3nested-giant-large"` - 1.40B params, nested model with all features ``` -------------------------------- ### Run DA3-Streaming on Images Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/da3_streaming/README.md Execute the DA3-Streaming pipeline on a directory of images. Optionally specify a configuration file and output directory. ```python python da3_streaming.py --image_dir ./path_of_images ``` ```python python da3_streaming.py --image_dir ./path_of_images --config ./configs/base_config.yaml --output_dir ${OUTPUT_DIR} ``` -------------------------------- ### Prepare Input Images for Inference Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/API.md The `image` parameter accepts a list of inputs, which can be file paths, numpy arrays, or PIL Images. Ensure your images are loaded correctly before passing them to the inference method. ```python # From file paths image = ["image1.jpg", "image2.jpg", "image3.jpg"] ``` ```python # From numpy arrays image = [np.array(img1), np.array(img2)] ``` ```python # From PIL Images image = [Image.open("image1.jpg"), Image.open("image2.jpg")] ``` -------------------------------- ### Run DA3-Streaming with Custom Config and Output Source: https://context7.com/bytedance-seed/depth-anything-3/llms.txt Process long videos using DA3-Streaming with a custom configuration file and specify a dedicated output directory for results. ```python python da3_streaming.py \ --image_dir ./extract_images \ --config ./configs/base_config.yaml \ --output_dir ./output ``` -------------------------------- ### CLI: Video Processing with Feature Visualization Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/README.md Process video files using the CLI, enabling feature visualization. Specify export formats, directories, and processing methods. ```bash da3 video assets/examples/robot_unitree.mp4 \ --fps 15 \ --use-backend \ --export-dir ${GALLERY_DIR}/TEST_BACKEND/robo \ --export-format glb-feat_vis \ --feat-vis-fps 15 \ --process-res-method lower_bound_resize \ --export-feat "11,21,31" ``` -------------------------------- ### Initialize DepthAnything3 Model Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/API.md Initializes the DepthAnything3 model with a specified model name. The model is then moved to the GPU for processing. Available models include 'da3-giant', 'da3-large', 'da3-base', 'da3-small', 'da3mono-large', 'da3metric-large', and 'da3nested-giant-large'. ```python from depth_anything_3 import DepthAnything3 # Initialize the model with a model name model = DepthAnything3(model_name="da3-large") model = model.to("cuda") # Move to GPU ``` -------------------------------- ### Reference View Selection Strategies in DepthAnything3 Source: https://context7.com/bytedance-seed/depth-anything-3/llms.txt Demonstrates how to specify different reference view selection strategies for multi-view depth estimation (3+ images). The default 'saddle_balanced' is robust, while 'middle' is suitable for video sequences and 'saddle_sim_range' for wide-baseline captures. ```python from depth_anything_3.api import DepthAnything3 model = DepthAnything3.from_pretrained("depth-anything/DA3NESTED-GIANT-LARGE").to("cuda") # Default: saddle_balanced - robust for diverse scenarios prediction = model.inference( images, ref_view_strategy="saddle_balanced" # Balanced selection across metrics ) # For video sequences with temporal ordering prediction = model.inference( video_frames, ref_view_strategy="middle" # Use middle frame as reference ) # For wide-baseline multi-view captures prediction = model.inference( images, ref_view_strategy="saddle_sim_range" # Maximize information coverage ) # Available strategies: # - "saddle_balanced" (default): Balanced across similarity, norm, variance # - "saddle_sim_range": View with largest similarity range to others # - "middle": Middle view (best for video sequences) # - "first": First view (only if manually pre-sorted) ``` -------------------------------- ### Run Full Benchmark Evaluation Source: https://context7.com/bytedance-seed/depth-anything-3/llms.txt Execute the full benchmark evaluation using the specified model path. This command runs inference and evaluation on all configured datasets. ```python MODEL=depth-anything/DA3-GIANT python -m depth_anything_3.bench.evaluator model.path=$MODEL ``` -------------------------------- ### Clone DA3-Streaming Project Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/da3_streaming/README.md Clone the repository including submodules. Use the --recursive flag for initial cloning. ```bash git clone --recursive https://github.com/ByteDance-Seed/Depth-Anything-3.git ``` ```bash cd /Depth-Anything-3/ git submodule update --init --recursive . ``` -------------------------------- ### Export Parameters Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/API.md Configure output directory, format, and specific parameters for different export types. ```APIDOC ## Export Parameters ### `export_dir` (optional) - **Type**: `Optional[str]` - **Description**: Directory path where exported files will be saved. If not provided, no files will be exported. ### `export_format` (default: "mini_npz") - **Type**: `str` - **Description**: Format for exporting results. Supports multiple formats separated by `-`. - **Example**: `"mini_npz-glb"` exports both mini_npz and glb formats. ### GLB Export Parameters These parameters are passed directly to the `inference()` method and only apply when `export_format` includes `"glb"`. ##### `conf_thresh_percentile` (default: 40.0) - **Type**: `float` - **Description**: Lower percentile for adaptive confidence threshold. Points below this confidence percentile will be filtered out from the point cloud. ##### `num_max_points` (default: 1,000,000) - **Type**: `int` - **Description**: Maximum number of points in the exported point cloud. If the point cloud exceeds this limit, it will be downsampled. ##### `show_cameras` (default: True) - **Type**: `bool` - **Description**: Whether to include camera wireframes in the exported GLB file for visualization. ### Feature Visualization Parameters These parameters are passed directly to the `inference()` method and only apply when `export_format` includes `"feat_vis"`. ##### `feat_vis_fps` (default: 15) - **Type**: `int` - **Description**: Frame rate for the output video when visualizing features across multiple images. ### 3DGS and 3DGS Video Parameters These parameters are passed directly to the `inference()` method and only apply when `export_format` includes `"gs_ply"` or `"gs_video"`. ##### `export_kwargs` (default: `{}`) - Type: `dict[str, dict[str, Any]]` - Description: Per-format extra arguments passed to export functions, mainly for `"gs_ply"` and `"gs_video"`. - Access pattern: `export_kwargs[export_format][key] = value` - Example: ```python { "gs_ply": { "gs_views_interval": 1, }, "gs_video": { "trj_mode": "interpolate_smooth", "chunk_size": 1, "vis_depth": None, }, } ``` ``` -------------------------------- ### Evaluation Command Reference Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/BENCHMARK.md This section provides a comprehensive reference for the command-line interface used to run evaluations on various datasets. It includes configuration options, overrides, and special flags. ```APIDOC ## Command Reference ```bash python -m depth_anything_3.bench.evaluator [OPTIONS] [KEY=VALUE ...] ``` ### Configuration: `--config PATH` Config YAML file (default: bench/configs/eval_bench.yaml) ### Config Overrides (using dotlist notation): `model.path=VALUE` Model path or HuggingFace ID `workspace.work_dir=VALUE` Working directory for outputs `eval.datasets=[dataset1,dataset2]` Datasets to evaluate (eth3d,7scenes,scannetpp,hiroom,dtu,dtu64) `eval.modes=[mode1,mode2]` Evaluation modes (pose,recon_unposed,recon_posed) `eval.scenes=[scene1,scene2]` Specific scenes to evaluate (null=all) `eval.max_frames=VALUE` Max frames per scene (-1=no limit, default: 100) `eval.ref_view_strategy=VALUE` Reference view strategy (default: first) `eval.eval_only=VALUE` Only run evaluation (skip inference) (true/false) `eval.print_only=VALUE` Only print saved metrics (true/false) `inference.num_fusion_workers=VALUE` Number of parallel workers (default: 4) `inference.debug=VALUE` Enable debug mode (true/false) ### Special Flags: `--help`, `-h` Show this help message ### Multi-GPU: Use CUDA_VISIBLE_DEVICES to specify GPUs (auto-detected and distributed) ### Examples: ```bash MODEL=depth-anything/DA3-GIANT # Full evaluation python -m depth_anything_3.bench.evaluator model.path=$MODEL # Quick test on HiRoom only python -m depth_anything_3.bench.evaluator \ model.path=$MODEL \ eval.datasets=[hiroom] \ eval.modes=[pose] # Pose-only evaluation (all 5 pose datasets) python -m depth_anything_3.bench.evaluator \ model.path=$MODEL \ eval.datasets=[eth3d,7scenes,scannetpp,hiroom,dtu64] \ eval.modes=[pose] # Recon-only evaluation (all 5 recon datasets) python -m depth_anything_3.bench.evaluator \ model.path=$MODEL \ eval.datasets=[eth3d,7scenes,scannetpp,hiroom,dtu] \ eval.modes=[recon_unposed,recon_posed] # Debug specific scenes python -m depth_anything_3.bench.evaluator \ model.path=$MODEL \ eval.datasets=[eth3d] \ eval.scenes=[courtyard] \ inference.debug=true # Re-evaluate without re-running inference python -m depth_anything_3.bench.evaluator eval.eval_only=true # Just view results python -m depth_anything_3.bench.evaluator eval.print_only=true ``` ``` -------------------------------- ### Troubleshooting Data Path Issues Source: https://github.com/bytedance-seed/depth-anything-3/blob/main/docs/BENCHMARK.md Guidance on resolving issues related to dataset paths by ensuring the paths in `src/depth_anything_3/utils/constants.py` are correctly configured. ```APIDOC ### Data Path Issues Ensure dataset paths in `src/depth_anything_3/utils/constants.py` are correct: ```python # Default paths (relative to project root) ETH3D_EVAL_DATA_ROOT = "workspace/benchmark_dataset/eth3d" SEVENSCENES_EVAL_DATA_ROOT = "workspace/benchmark_dataset/7scenes" SCANNETPP_EVAL_DATA_ROOT = "workspace/benchmark_dataset/scannetpp" HIROOM_EVAL_DATA_ROOT = "workspace/benchmark_dataset/hiroom/data" DTU_EVAL_DATA_ROOT = "workspace/benchmark_dataset/dtu" DTU64_EVAL_DATA_ROOT = "workspace/benchmark_dataset/dtu64" ``` ```