TraceAnything

ByteDance-SeedApache-2.0长期未更新

用轨迹场把任意视频表示为 4D 结构,从普通视频中重建出带时间维度的三维场景,适合做动态场景的 4D 重建研究。

[ICLR 2026] Trace Anything: Representing Any Video in 4D via Trajectory Fields

暂无版本590star25fork同步于 2026-11-07 07:30 UTC

怎么上手

由 README 提炼,执行前请确认
git clone https://github.com/ByteDance-Seed/TraceAnything.git
cd TraceAnything
conda create -n trace_anything python=3.10
conda activate trace_anything
pip install einops omegaconf pillow opencv-python viser imageio matplotlib torchvision
python scripts/infer.py
硬件要求按 README 说明

示例在单张 ≥48 GB 显存的 GPU 上测试通过,CUDA 12.8 下验证;README 未说明支持的具体 GPU 型号,也未说明能否纯 CPU 运行。

8G 显存可跑支持 Apple Silicon需要 CUDA
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

把任意视频表示为 4D 轨迹场,单次前向即可估计像素级 3D 运动轨迹

用轨迹场把任意视频表示为 4D 结构,从普通视频中重建出带时间维度的三维场景,适合做动态场景的 4D 重建研究。

核心能力

  • 用轨迹场把每帧像素映射为连续参数化 3D 轨迹
  • 单次前向推理支持视频、图像对与图像集
  • 输出 3D 控制点、置信度图与前景掩码
  • 内置 Viser 交互式 3D 查看器浏览轨迹
  • 可选接入 SAM2 做用户引导的前景掩码

容易踩的坑

需自行从 Hugging Face 下载 trace_anything.pt 并放到 checkpoints/trace_anything.pt,否则默认路径找不到权重;输入图像要求 W ≥ H,长边会被缩放到 512,视图数超过 40 会自动降采样;SAM2 用户掩码需另装 SAM2 并下载其 checkpoint,查看器默认端口为 8020,远程访问需做 SSH 端口转发。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Trace Anything: Representing Any Video in 4D via Trajectory Fields

    Overview

    We propose a 4D video representation, trajectory field, which maps each pixel across frames to a continuous, parametric 3D trajectory. With a single forward pass, the Trace Anything model efficiently estimates such trajectory fields for any video, image pair, or unstructured image set. This repository provides the official PyTorch implementation for running inference with the Trace Anything model and exploring trajectory fields in an interactive 3D viewer.

    Teaser

    Setup

    Create and activate environment

    # Clone the repository
    git clone https://github.com/ByteDance-Seed/TraceAnything.git
    cd TraceAnything
    
    # Create and activate environment
    conda create -n trace_anything python=3.10
    conda activate trace_anything
    

    Requirements

    • Python ≥ 3.10

    • PyTorch (install according to your CUDA/CPU setup)

    • Dependencies:

      pip install einops omegaconf pillow opencv-python viser imageio matplotlib torchvision
      

    Notes

    • CUDA: Tested with CUDA 12.8.
    • GPU Memory: The provided examples are tested to run on a single GPU with ≥ 48 GB VRAM.

    Model weights

    Download the pretrained model and place it at:

    checkpoints/trace_anything.pt
    

    Inference

    We provide example input videos and image pairs under examples/input. Each subdirectory corresponds to a scene:

    examples/
      input/
        scene_name_1/
          ...
        scene_name_2/
          ...
    

    The inference script loads images from these scene folders and produces outputs.


    Notes

    • Images must satisfy W ≥ H. (Portrait images are automatically transposed.)
    • Images are resized so that the long side = 512, then cropped to the nearest multiple of 16 (a model requirement).
    • If the number of views exceeds 40, the script automatically downsamples.
    • (Advanced) The script assumes input images are ordered in time (e.g., video frames or paired images). Support for unstructured, unordered inputs will be released in the future.

    Running inference

    Run the model over all scenes:

    python scripts/infer.py
    
    Default arguments

    You can override these paths with flags:

    • --config configs/eval.yaml
    • --ckpt checkpoints/trace_anything.pt
    • --input_dir examples/input
    • --output_dir examples/output
    Example
    python scripts/infer.py \
      --input_dir examples/input \
      --output_dir examples/output \
      --ckpt checkpoints/trace_anything.pt
    

    Results are saved to:

    <output_dir>/<scene>/output.pt
    

    What’s inside output.pt?

    • preds[i]['ctrl_pts3d'] — 3D control points, shape [K, H, W, 3]

    • preds[i]['ctrl_conf'] — confidence maps, shape [K, H, W]

    • preds[i]['fg_mask'] — binary mask [H, W], computed via Otsu thresholding on control-point variance. (Mask images are also saved under <output_dir>/<scene>/masks.)

    • preds[i]['time'] — predicted scalar time ∈ [0, 1).

      Even though the true timestamp is implicit from known sequence order, the network’s timestamp head still estimates it.

    • views[i]['img'] — normalized input image tensor ∈ [-1, 1]

    Optional: User-Guided Masks with SAM2

    If you prefer user-guided SAM2 masks instead of the automatic masks computed from Trace Anything outputs (for visualization), we provide a helper script scripts/user_mask.py. This script lets you interactively select points on the first frame of a scene to produce per-frame foreground masks.

    Install SAM2 and download its checkpoint. Then run with:

    python scripts/user_mask.py --scene <output_scene_dir> \
      --sam2_cfg configs/sam2.1/sam2.1_hiera_l.yaml \
      --sam2_ckpt <path_to_sam2_ckpt>
    

    This will saves masks to:

    <scene>/masks/{i:03d}_user.png
    

    It also updates <scene>/output.pt with:

    preds[i]["fg_mask_user"]
    

    When visualizing, fg_mask_user will automatically be preferred over fg_mask if available.

    Interactive Visualization 🚀

    Our visualizer lets you explore the trajectory field interactively:

    Interactive trajectory field demo

    Fire up the interactive 3D viewer and dive your trajectory fields:

    python scripts/view.py --output examples/output/<scene>/output.pt
    

    Useful flags

    • --port 8020 — set viewer port
    • --t_step 0.025 — timeline step (smaller = more fine-grained curve evaluation)
    • --ds 2 — downsample all data by ::2 for extra speed

    Remote use (SSH port-forwarding)

    ssh -N -L 8020:localhost:8020 <user>@<server>
    # Then open http://localhost:8020 locally
    

    Trajectory panel

    Input a frame number, or simply type "mid" / "last". Then hit Build / Refresh to construct trajectories, and toggle Show trajectories to view them.

    Trajectories Panel

    Play around! 🎉

    • Pump up or shrink point size
    • Filter out noisy background / foreground points by confidence
    • Drag to swivel the viewpoint
    • Slide through time and watch the trajectories evolve

    Acknowledgements

    We sincerely thank the authors of the open-source repositories DUSt3R, Fast3R, VGGT, MonST3R, Easi3R, St4RTrack, POMATO, SpaTrackerV2 and Viser for their inspiring and high-quality work that greatly contributed to this project.

    License

    Citation

    If you find our repository useful, please consider giving it a star ⭐ and citing our paper in your work:

    @misc{liu2025traceanythingrepresentingvideo,
          title={Trace Anything: Representing Any Video in 4D via Trajectory Fields}, 
          author={Xinhang Liu and Yuxi Xiao and Donny Y. Chen and Jiashi Feng and Yu-Wing Tai and Chi-Keung Tang and Bingyi Kang},
          year={2025},
          eprint={2510.13802},
          archivePrefix={arXiv},
          primaryClass={cs.CV},
          url={https://arxiv.org/abs/2510.13802}, 
    }