Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

samurai

> 编程语言
Open source

Official repository of "SAMURAI: Adapting Segment Anything Model for Zero-Shot Visual Tracking with Motion-Aware Memory"

7.1K stars0 likes2 views
WebsiteGitHub

About

Official repository of "SAMURAI: Adapting Segment Anything Model for Zero-Shot Visual Tracking with Motion-Aware Memory"

[Arxiv] [Project Page] [Raw Results]

This repository is the official implementation of SAMURAI: Adapting Segment Anything Model for Zero-Shot Visual Tracking with Motion-Aware Memory

https://github.com/user-attachments/assets/9d368ca7-2e9b-4fed-9da0-d2efbf620d88

All rights are reserved to the copyright owners (TM & © Universal (2019)). This clip is not intended for commercial use and is solely for academic demonstration in a research paper. Original source can be found here.

News

  • Incoming: Support vot-challenge toolkit intergration.
  • Incoming: Release demo script to support inference on video (with mask prompt).
  • 2025/02/18: Release multi-GPU inference script.
  • 2025/01/27: Release inference script on VOS task (SA-V)!
  • 2024/11/21: Release demo script to support inference on video (bounding box prompt).
  • 2024/11/20 Release inference script on VOT task (LaSOT, LaSOT-ext, GOT-10k, UAV123, TrackingNet, OTB100)!
  • 2024/11/19: Release paper, code, and raw results!

Getting Started

SAMURAI Installation

SAM 2 needs to be installed first before use. The code requires python>=3.10, as well as torch>=2.3.1 and torchvision>=0.18.1. Please follow the instructions here to install both PyTorch and TorchVision dependencies. You can install the SAMURAI version of SAM 2 on a GPU machine using:

bash
cd sam2
pip install -e .
pip install -e ".[notebooks]"

Please see INSTALL.md from the original SAM 2 repository for FAQs on potential issues and solutions.

Install other requirements:

bash
pip install matplotlib==3.7 tikzplotlib jpeg4py opencv-python lmdb pandas scipy loguru

SAM 2.1 Checkpoint Download

bash
cd checkpoints && \
./download_ckpts.sh && \
cd ..

Data Preparation

Please prepare the data in the following format:

data/LaSOT
├── airplane/
│   ├── airplane-1/
│   │   ├── full_occlusion.txt
│   │   ├── groundtruth.txt
│   │   ├── img
│   │   ├── nlp.txt
│   │   └── out_of_view.txt
│   ├── airplane-2/
│   ├── airplane-3/
│   ├── ...
├── basketball
├── bear
├── bicycle
...
├── training_set.txt
└── testing_set.txt

Main Inference

bash
python scripts/main_inference.py 

Demo on Custom Video

To run the demo with your custom video or frame directory, use the following examples:

Note: The .txt file contains a single line with the bounding box of the first frame in x,y,w,h format while the SAM 2 takes x1,y1,x2,y2 format as bbox input.

Input is Video File

bash
python scripts/demo.py --video_path <your_video.mp4> --txt_path <path_to_first_frame_bbox.txt>

Input is Frame Folder

bash
# Only JPG images are supported
python scripts/demo.py --video_path <your_frame_directory> --txt_path <path_to_first_frame_bbox.txt>

FAQs

Question 1: Does SAMURAI need training? issue 34

Answer 1: Unlike real-life samurai, the proposed samurai do not require additional training. It is a zero-shot method, we directly use the weights from SAM 2.1 to conduct VOT experiments. The Kalman filter is used to estimate the current and future state (bounding box location and scale in our case) of a moving object based on measurements over time, it is a common approach that had been adopted in the field of tracking for a long time, which does not require any training. Please refer to code for more detail.

Question 2: Does SAMURAI support streaming input (e.g. webcam)?

Answer 2: Not yet. The existing code doesn't support live/streaming video as we inherit most of the codebase from the amazing SAM 2. Some discussion that you might be interested in: facebookresearch/sam2#90, facebookresearch/sam2#388 (comment).

Question 3: How to use SAMURAI in longer video?

Answer 3: See the discussion from sam2 https://github.com/facebookresearch/sam2/issues/264.

Question 4: How do you run the evaluation on the VOT benchmarks?

Answer 4: For LaSOT, LaSOT-ext, OTB, NFS please refer to the issue 74 for more details. For GOT-10k-test and TrackingNet, please refer to the official portal for submission.

Acknowledgment

SAMURAI is built on top of SAM 2 by Meta FAIR.

The VOT evaluation code is modifed from VOT Toolkit by Luka Čehovin Zajc.

Citation

Please consider citing our paper and the wonderful SAM 2 if you found our work interesting and useful.

…

Issues· 12 open

View all issuesOpen on GitHub
  • #129

    Verify evals on Papers with Code

    Updated Sep 14, 2026
  • #124

    Samurai on segmentation (not-SAM2) video

    Updated Oct 17, 2025
  • #122

    Can point prompts (including negative points) be used instead of a bounding box?

    Updated Aug 1, 2025
  • #110

    Multi-object trackin

    Updated Jul 4, 2025
  • #114

    Dynamic addition of objects for tracking

    Updated Apr 30, 2025

> Tags

Python

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 22, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言