SwinTrack: A Simple and Strong Baseline for Transformer Tracking

Overview

SwinTrack

This is the official repo for SwinTrack.

banner

A Simple and Strong Baseline

performance

Prerequisites

Environment

conda (recommended)

conda create -y -n SwinTrack
conda activate SwinTrack
conda install -y anaconda
conda install -y pytorch torchvision cudatoolkit -c pytorch
conda install -y -c fvcore -c iopath -c conda-forge fvcore
pip install wandb
pip install timm

pip

pip install -r requirements.txt

Dataset

Download

Unzip

The paths should be organized as following:

lasot
├── airplane
├── basketball
...
├── training_set.txt
└── testing_set.txt

lasot_extension
├── atv
├── badminton
...
└── wingsuit

got-10k
├── train
│   ├── GOT-10k_Train_000001
│   ...
├── val
│   ├── GOT-10k_Val_000001
│   ...
└── test
    ├── GOT-10k_Test_000001
    ...
    
trackingnet
├── TEST
├── TRAIN_0
...
└── TRAIN_11

coco2017
├── annotations
│   ├── instances_train2017.json
│   └── instances_val2017.json
└── images
    ├── train2017
    │   ├── 000000000009.jpg
    │   ├── 000000000025.jpg
    │   ...
    └── val2017
        ├── 000000000139.jpg
        ├── 000000000285.jpg
        ...

Prepare path.yaml

Copy path.template.yaml as path.yaml and fill in the paths.

LaSOT_PATH: '/path/to/lasot'
LaSOT_Extension_PATH: '/path/to/lasot_ext'
GOT10k_PATH: '/path/to/got10k'
TrackingNet_PATH: '/path/to/trackingnet'
COCO_2017_PATH: '/path/to/coco2017'

Prepare dataset metadata cache (optional)

Download the metadata cache from google drive, and unzip it in datasets/cache/

datasets
└── cache
    ├── SingleObjectTrackingDataset_MemoryMapped
    │   └── filtered
    │       ├── got-10k-got10k_vot_train_split-train-3c1ffeb0c530522f0345d088b2f72168.np
    │       ...
    └── DetectionDataset_MemoryMapped
        └── filtered
            └── coco2017-nocrowd-train-bcd5bf68d4b87619ab451fe293098401.np

Login to wandb

Register an account at wandb, then login with command:

wandb login

Training & Evaluation

Train and evaluate on a single GPU

# Tiny
python main.py SwinTrack Tiny --output_dir /path/to/output -W $num_dataloader_workers

# Base
python main.py SwinTrack Base --output_dir /path/to/output -W $num_dataloader_workers

# Base-384
python main.py SwinTrack Base-384 --output_dir /path/to/output -W $num_dataloader_workers

--output_dir is optional, -W defaults to 4.

note: our code performs evaluation automatically when training is done, output is saved in /path/to/output/test_metrics.

Train and evaluate on multiple GPUs using DDP

# Tiny
python main.py SwinTrack Tiny --distributed_nproc_per_node $num_gpus --distributed_do_spawn_workers --output_dir /path/to/output -W $num_dataloader_workers

Train and evaluate on multiple nodes with multiple GPUs using DDP

# Tiny
python main.py SwinTrack Tiny --master_address $master_address --distributed_node_rank $node_rank distributed_nnodes $num_nodes --distributed_nproc_per_node $num_gpus --distributed_do_spawn_workers --output_dir /path/to/output -W $num_dataloader_workers 

Train and evaluate with run.sh helper script

# Train and evaluate on all GPUs
./run.sh SwinTrack Tiny --output_dir /path/to/output -W $num_dataloader_workers
# Train and evaluate on multiple nodes
NODE_RANK=$NODE_INDEX NUM_NODES=$NUM_NODES MASTER_ADDRESS=$MASTER_ADDRESS DATE_WITH_TIME=$DATE_WITH_TIME ./run.sh SwinTrack Tiny --output_dir /path/to/output -W $num_dataloader_workers 

Ablation study

The ablation study can be done by applying a small patch to the main config file.

Take the ResNet 50 backbone as the example, the rest parameters are the same as the above.

# Train and evaluate with resnet50 backbone
python main.py SwinTrack Tiny --mixin_config resnet.yaml
# or with run.sh
./run.sh SwinTrack Tiny --mixin resnet.yaml

All available config patches are listed in config/SwinTrack/Tiny/mixin.

Train and evaluate with GOT-10k dataset

python main.py SwinTrack Tiny --mixin_config got10k.yaml

Submit $output_dir/test_metrics/got10k/submit/*.zip to the GOT-10k evaluation server to get the result of GOT-10k test split.

Evaluate Existing Model

Download the pretrained model from google drive, then type:

python main.py SwinTrack Tiny --weight_path /path/to/weigth_file.pth --mixin_config evaluation.yaml --output_dir /path/to/output

Our code can evaluate the model on multiple GPUs in parallel, so all parameters above are also available.

Tracking results

Touch here google drive

Citation

@misc{lin2021swintrack,
      title={SwinTrack: A Simple and Strong Baseline for Transformer Tracking}, 
      author={Liting Lin and Heng Fan and Yong Xu and Haibin Ling},
      year={2021},
      eprint={2112.00995},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}
Comments
  • i find this problem

    i find this problem

    when i use ~/SwinTrack$ python main.py SwinTrack Tiny --output_dir /home/zhangruilin/SwinTrack/output --mixin_config got10k.yaml

    it returns me Traceback (most recent call last): File "main.py", line 6, in <module> main(os.path.dirname(__file__)) File "/home/zhangruilin/SwinTrack/core/entry/main.py", line 110, in main entry(args) File "/home/zhangruilin/SwinTrack/core/entry/entry.py", line 73, in entry build_and_run(runtime_vars, config, wandb_instance) File "/home/zhangruilin/SwinTrack/core/entry/build_and_run.py", line 21, in build_and_run run = build(runtime_vars, network_config, global_synchronized_rng, local_rng, wandb_instance) File "/home/zhangruilin/SwinTrack/core/run/builder.py", line 312, in build model, pseudo_data_generator, running_tasks, global_event_dispatcher, default_logger, num_epochs = build_running_tasks(runtime_vars, config, global_rng, local_rng, wandb_instance) File "/home/zhangruilin/SwinTrack/core/run/builder.py", line 262, in build_running_tasks _build_data_loaders(runtime_vars, branch_config, data_config, config, global_rng, local_rng, building_context) File "/home/zhangruilin/SwinTrack/core/run/builder.py", line 182, in _build_data_loaders data_context.event_register, data_context.context, is_training) File "/home/zhangruilin/SwinTrack/data/tracking/builder.py", line 8, in build_data_source data_pipelines = build_siamfc_data_source(data_config, runtime_vars, config, global_synchronized_rng, local_rng, event_register, context) File "/home/zhangruilin/SwinTrack/data/tracking/methods/SiamFC/builders/source.py", line 18, in build_siamfc_data_source runtime_vars.rank) File "/home/zhangruilin/SwinTrack/data/tracking/methods/SiamFC/builders/components/dataset.py", line 16, in build_siamfc_dataset datasets, dataset_parameters = build_datasets(dataset_config) File "/home/zhangruilin/SwinTrack/data/tracking/methods/_common/builders/build_datasets.py", line 23, in build_datasets datasets, dataset_parameters = build_dataset_from_config_distributed_awareness(dataset_config, _customized_dataset_parameter_handler) File "/home/zhangruilin/SwinTrack/data/utils/dataset.py", line 8, in build_dataset_from_config_distributed_awareness return build_datasets_from_config(config, user_defined_parameters_handler) File "/home/zhangruilin/SwinTrack/datasets/easy_builder/builder.py", line 148, in build_datasets_from_config return build_datasets(config, unknown_parameter_handler) File "/home/zhangruilin/SwinTrack/datasets/easy_builder/builder.py", line 120, in build_datasets seed = seed_class(root_path=path) File "/home/zhangruilin/SwinTrack/datasets/SOT/seed/LaSOT.py", line 9, in __init__ super(LaSOT_Seed, self).__init__('LaSOT', root_path, data_split, 2) File "/home/zhangruilin/SwinTrack/datasets/base/factory_seed.py", line 11, in __init__ assert root_path is not None and len(root_path) > 0 AssertionError i am glade to receive any advices

    opened by little-siskin 11
  • KeyError: 'metrics'

    KeyError: 'metrics'

    when I run main.py in order to test got10k(test) only, KeyError: 'metrics' is found. what should I do? the fully log as follow:

    ssh://[email protected]:22/home/rzh/anaconda3/bin/python3 -u /home/rzh/win-pycharm/SwinTrack/main.py SwinTrack Tiny --mixin_config got10k.yaml Not using distributed mode Traceback (most recent call last): File "/home/rzh/win-pycharm/SwinTrack/main.py", line 6, in main(os.path.dirname(file)) File "/home/rzh/win-pycharm/SwinTrack/core/entry/main.py", line 104, in main entry(args) File "/home/rzh/win-pycharm/SwinTrack/core/entry/entry.py", line 25, in entry load_static_mixin_config_and_apply_rules(runtime_vars, config) File "/home/rzh/win-pycharm/SwinTrack/core/entry/mixin_utils.py", line 87, in load_static_mixin_config_and_apply_rules apply_mixin_rules(mixin_config['mixin'], config, None) File "/home/rzh/win-pycharm/SwinTrack/core/entry/mixin_utils.py", line 64, in apply_mixin_rules _apply_mixin_rule(fixed_modification_rule, config, None) File "/home/rzh/win-pycharm/SwinTrack/core/entry/mixin_utils.py", line 24, in _apply_mixin_rule mod_config(config, query_path, value) File "/home/rzh/win-pycharm/SwinTrack/core/entry/dict_flatten_accessor.py", line 24, in mod_config config = config[sub_path] if not sub_path.isdigit() else config[int(sub_path)] KeyError: 'metrics'

    opened by chainfitness 6
  • Input resolution

    Input resolution

    Dear authors: I noticed that the pretrain_img_size of swin-transformer-tiny is only 224 and input resolution of your SwinTrack Project is also 224. I have a question "Could I increase the input resolution to 640 and keep swin-transformer-tiny as the backbone network?" Thanks and look forward to your reply!

    opened by LeungWaiHo 5
  • how to apply Swingtrack to execute a video demo like TransT or pysot .etc?

    how to apply Swingtrack to execute a video demo like TransT or pysot .etc?

    I want to test this awesome job to compare with pysot and TransT employed to the actual project. Could you mind telling me how to utilize this job to execute a video demo?

    opened by chainfitness 4
  • can not run !!!

    can not run !!!

    python main.py SwinTrack Tiny --output_dir /home/lfm/swintrack/out --num_workers 4

    Traceback (most recent call last): File "main.py", line 6, in main(os.path.dirname(file)) File "/home/lfm/swintrack/core/entry/main.py", line 104, in main entry(args) File "/home/lfm/swintrack/core/entry/entry.py", line 68, in entry build_and_run(runtime_vars, config, wandb_instance) File "/home/lfm/swintrack/core/entry/build_and_run.py", line 21, in build_and_run run = build(runtime_vars, network_config, global_synchronized_rng, local_rng, wandb_instance) File "/home/lfm/swintrack/core/run/builder.py", line 312, in build model, pseudo_data_generator, running_tasks, global_event_dispatcher, default_logger, num_epochs = build_running_tasks(runtime_vars, config, global_rng, local_rng, wandb_instance) File "/home/lfm/swintrack/core/run/builder.py", line 262, in build_running_tasks _build_data_loaders(runtime_vars, branch_config, data_config, config, global_rng, local_rng, building_context) File "/home/lfm/swintrack/core/run/builder.py", line 180, in _build_data_loaders data_loader, host_data_pipelines = build_data_source( # host_data_pipelines = [ { type: instance } ] File "/home/lfm/swintrack/data/tracking/builder.py", line 8, in build_data_source data_pipelines = build_siamfc_data_source(data_config, runtime_vars, config, global_synchronized_rng, local_rng, event_register, context) File "/home/lfm/swintrack/data/tracking/methods/SiamFC/builders/source.py", line 16, in build_siamfc_data_source dataset, worker_init_fn = build_siamfc_dataset(sampling_config, dataset_config, data_processor, File "/home/lfm/swintrack/data/tracking/methods/SiamFC/builders/components/dataset.py", line 16, in build_siamfc_dataset datasets, dataset_parameters = build_datasets(dataset_config) File "/home/lfm/swintrack/data/tracking/methods/_common/builders/build_datasets.py", line 23, in build_datasets datasets, dataset_parameters = build_dataset_from_config_distributed_awareness(dataset_config, _customized_dataset_parameter_handler) File "/home/lfm/swintrack/data/utils/dataset.py", line 8, in build_dataset_from_config_distributed_awareness return build_datasets_from_config(config, user_defined_parameters_handler) File "/home/lfm/swintrack/datasets/easy_builder/builder.py", line 148, in build_datasets_from_config return build_datasets(config, unknown_parameter_handler) File "/home/lfm/swintrack/datasets/easy_builder/builder.py", line 120, in build_datasets seed = seed_class(root_path=path) File "/home/lfm/swintrack/datasets/SOT/seed/LaSOT.py", line 9, in init super(LaSOT_Seed, self).init('LaSOT', root_path, data_split, 2) File "/home/lfm/swintrack/datasets/base/factory_seed.py", line 11, in init assert root_path is not None and len(root_path) > 0 AssertionError

    opened by longcoolman 3
  • How to change the image size of the template branch and search branch in Swin_backbone

    How to change the image size of the template branch and search branch in Swin_backbone

    Hi, thanks for your great work. At what stage of Swin did you scale the size of the images. I noticed that the original Swin has undergone a size scaling at each stage. I don’t know if you have also adopted this approach.

    opened by hongsheng-Z 3
  • issues about the Weak aug(Positional Augmentations) in swintrack

    issues about the Weak aug(Positional Augmentations) in swintrack

    hello,Congradulations,nice work.I have some questions about your positional augmentations in paper.What the weak aug means in swintrack?Does it means you did not apply any pre-process deducing random scale and random translation during the search image generation in the training phase?If so, what did you do during the preprocessing stage? At last,,,,this work makes me feel frustrated,cause I have been tried this method for about 5 months,but I did not make the trackers outperform yours hhh.

    opened by JackjackFan 2
  • RuntimeError: CUDA out of memory

    RuntimeError: CUDA out of memory

    can it run on 4GB video memory GPU? can i modify some parameters to make sure it will not out of cuda memory? is there a config file to modify? just like set epoch from 32 to 4 ,so can reduce the video memory usage? thank you so much!!! looking forward to your reply!!!

    opened by PilotPhil 1
  • Hello!About the track speed evaluation

    Hello!About the track speed evaluation

    Hello!During the test, I set time stamps before and after tracking a single frame by referring to the time module, but it is not as fast as described in the paper. Isn't the evaluation of tracking time calculated in this way?

    opened by davidyang180 1
  • Train and evaluate with GOT-10k dataset

    Train and evaluate with GOT-10k dataset

    I want to test this awesome job in got10k but I confront a situation: can't find train_got10k.yaml.could you mind telling me where should I download this file so I can compare TransT and Swintrack via official implementation by got10k official website?

    opened by chainfitness 1
  • issue about link of dataset metadata cache

    issue about link of dataset metadata cache

    The google drive link of metadata cache isn't availible for china. Could you provide a Baidu cloud one plz? I'm sorry about any inconvenience that I bring to you sincerely.

    opened by chainfitness 1
  • visualize the tracking result

    visualize the tracking result

    How can I visualize the tracking result on test datasets, such as LaSOT_TEST, TrackingNet, and so on. Is there any interface offered or where should I change the original code source? Thanks advance!

    opened by blxie 1
  • Reproduce the pre-trained model.

    Reproduce the pre-trained model.

    Is it correct that in order to reproduce the pre-trained model you have to train the model on these 4 datasets?

    We train SwinTrack using training splits of LaSOT [15], TrackingNet [33], GOT-10k [20] (1,000 videos are removed for fair comparisons with other trackers [22,44]) and COCO 2017

    opened by Xrenya 0
Owner
LitingLin
LitingLin
[ICCV 2021] A Simple Baseline for Semi-supervised Semantic Segmentation with Strong Data Augmentation

[ICCV 2021] A Simple Baseline for Semi-supervised Semantic Segmentation with Strong Data Augmentation

CodingMan 45 Dec 12, 2022
This repo is developed for Strong Baseline For Vehicle Re-Identification in Track 2 Ai-City-2021 Challenges

A STRONG BASELINE FOR VEHICLE RE-IDENTIFICATION This paper is accepted to the IEEE Conference on Computer Vision and Pattern Recognition Workshop(CVPR

Cybercore Co. Ltd 78 Dec 29, 2022
A Strong Baseline for Image Semantic Segmentation

A Strong Baseline for Image Semantic Segmentation Introduction This project is an open source semantic segmentation toolbox based on PyTorch. It is ba

Clark He 49 Sep 20, 2022
A tiny, friendly, strong baseline code for Person-reID (based on pytorch).

Pytorch ReID Strong, Small, Friendly A tiny, friendly, strong baseline code for Person-reID (based on pytorch). Strong. It is consistent with the new

Zhedong Zheng 3.5k Jan 8, 2023
Image-retrieval-baseline - MUGE Multimodal Retrieval Baseline

MUGE Multimodal Retrieval Baseline This repo is implemented based on the open_cl

null 47 Dec 16, 2022
Image-generation-baseline - MUGE Text To Image Generation Baseline

MUGE Text To Image Generation Baseline Requirements and Installation More detail

null 23 Oct 17, 2022
Jingju baseline - A baseline model of our project of Beijing opera script generation

Jingju Baseline It is a baseline of our project about Beijing opera script gener

midon 1 Jan 14, 2022
FairMOT - A simple baseline for one-shot multi-object tracking

FairMOT - A simple baseline for one-shot multi-object tracking

Yifu Zhang 3.6k Jan 8, 2023
Joint detection and tracking model named DEFT, or ``Detection Embeddings for Tracking.

DEFT: Detection Embeddings for Tracking DEFT: Detection Embeddings for Tracking, Mohamed Chaabane, Peter Zhang, J. Ross Beveridge, Stephen O'Hara

Mohamed Chaabane 253 Dec 18, 2022
Tracking code for the winner of track 1 in the MMP-Tracking Challenge at ICCV 2021 Workshop.

Tracking Code for the winner of track1 in MMP-Trakcing challenge This repository contains our tracking code for the Multi-camera Multiple People Track

DamoCV 29 Nov 13, 2022
Tracking Pipeline helps you to solve the tracking problem more easily

Tracking_Pipeline Tracking_Pipeline helps you to solve the tracking problem more easily I integrate detection algorithms like: Yolov5, Yolov4, YoloX,

VNOpenAI 32 Dec 21, 2022
Quadruped-command-tracking-controller - Quadruped command tracking controller (flat terrain)

Quadruped command tracking controller (flat terrain) Prepare Install RAISIM link

Yunho Kim 4 Oct 20, 2022
Python package for multiple object tracking research with focus on laboratory animals tracking.

motutils is a Python package for multiple object tracking research with focus on laboratory animals tracking. Features loads: MOTChallenge CSV, sleap

Matěj Šmíd 2 Sep 5, 2022
VSR-Transformer - This paper proposes a new Transformer for video super-resolution (called VSR-Transformer).

VSR-Transformer By Jiezhang Cao, Yawei Li, Kai Zhang, Luc Van Gool This paper proposes a new Transformer for video super-resolution (called VSR-Transf

Jiezhang Cao 225 Nov 13, 2022
A general and strong 3D object detection codebase that supports more methods, datasets and tools (debugging, recording and analysis).

ALLINONE-Det ALLINONE-Det is a general and strong 3D object detection codebase built on OpenPCDet, which supports more methods, datasets and tools (de

Michael.CV 5 Nov 3, 2022
Code for the paper "VisualBERT: A Simple and Performant Baseline for Vision and Language"

This repository contains code for the following two papers: VisualBERT: A Simple and Performant Baseline for Vision and Language (arxiv) with a short

Natural Language Processing @UCLA 463 Dec 9, 2022
Official Code for ICML 2021 paper "Revisiting Point Cloud Shape Classification with a Simple and Effective Baseline"

Revisiting Point Cloud Shape Classification with a Simple and Effective Baseline Ankit Goyal, Hei Law, Bowei Liu, Alejandro Newell, Jia Deng Internati

Princeton Vision & Learning Lab 115 Jan 4, 2023
This is an official implementation for "DeciWatch: A Simple Baseline for 10x Efficient 2D and 3D Pose Estimation"

DeciWatch: A Simple Baseline for 10× Efficient 2D and 3D Pose Estimation This repo is the official implementation of "DeciWatch: A Simple Baseline for

null 117 Dec 24, 2022