├── LICENSE ├── MODEL_ZOO.md ├── README.md ├── experiments ├── simtrack │ ├── baseline.yaml │ └── baseline_got10k_only.yaml ├── stark_lightning_X_trt │ └── baseline_rephead_4_lite_search5.yaml ├── stark_s │ ├── baseline.yaml │ └── baseline_got10k_only.yaml ├── stark_st1 │ ├── baseline.yaml │ ├── baseline_R101.yaml │ ├── baseline_R101_got10k_only.yaml │ └── baseline_got10k_only.yaml └── stark_st2 │ ├── baseline.yaml │ ├── baseline_R101.yaml │ ├── baseline_R101_got10k_only.yaml │ └── baseline_got10k_only.yaml ├── external ├── AR │ ├── README.md │ ├── ltr │ │ ├── README.md │ │ ├── __init__.py │ │ ├── actors │ │ │ ├── __init__.py │ │ │ ├── base_actor.py │ │ │ ├── bbreg.py │ │ │ └── tracking.py │ │ ├── admin │ │ │ ├── __init__.py │ │ │ ├── environment.py │ │ │ ├── loading.py │ │ │ ├── model_constructor.py │ │ │ ├── multigpu.py │ │ │ ├── settings.py │ │ │ ├── stats.py │ │ │ └── tensorboard.py │ │ ├── data │ │ │ ├── __init__.py │ │ │ ├── bounding_box_utils.py │ │ │ ├── image_loader.py │ │ │ ├── loader.py │ │ │ ├── processing.py │ │ │ ├── processing_utils.py │ │ │ ├── processing_utils_SE.py │ │ │ ├── sampler.py │ │ │ └── transforms.py │ │ ├── dataset │ │ │ ├── __init__.py │ │ │ ├── base_image_dataset.py │ │ │ ├── base_video_dataset.py │ │ │ ├── coco.py │ │ │ ├── coco_seq.py │ │ │ ├── davis.py │ │ │ ├── ecssd.py │ │ │ ├── got10k.py │ │ │ ├── hku_is.py │ │ │ ├── imagenetvid.py │ │ │ ├── lasot.py │ │ │ ├── lvis.py │ │ │ ├── msra10k.py │ │ │ ├── sbd.py │ │ │ ├── synthetic_video.py │ │ │ ├── synthetic_video_blend.py │ │ │ ├── tracking_net.py │ │ │ ├── vos_base.py │ │ │ └── youtubevos.py │ │ ├── models │ │ │ ├── AR_seg_mask │ │ │ │ ├── AR_seg_mask.py │ │ │ │ └── __init__.py │ │ │ ├── __init__.py │ │ │ ├── backbone │ │ │ │ ├── __init__.py │ │ │ │ ├── base.py │ │ │ │ ├── resnet.py │ │ │ │ ├── resnet18_vggm.py │ │ │ │ └── resnet_seg.py │ │ │ ├── bbreg │ │ │ │ ├── __init__.py │ │ │ │ ├── atom.py │ │ │ │ └── atom_iou_net.py │ │ │ ├── head │ │ │ │ ├── __init__.py │ │ │ │ ├── seg_network.py │ │ │ │ └── utils.py │ │ │ ├── layers │ │ │ │ ├── __init__.py │ │ │ │ ├── activation.py │ │ │ │ ├── blocks.py │ │ │ │ ├── distance.py │ │ │ │ ├── filter.py │ │ │ │ ├── normalization.py │ │ │ │ └── transform.py │ │ │ ├── loss │ │ │ │ ├── __init__.py │ │ │ │ ├── kl_regression.py │ │ │ │ └── target_classification.py │ │ │ ├── meta │ │ │ │ ├── __init__.py │ │ │ │ └── steepestdescent.py │ │ │ ├── neck │ │ │ │ ├── CorrNL.py │ │ │ │ └── neck_utils.py │ │ │ ├── target_classifier │ │ │ │ ├── __init__.py │ │ │ │ ├── features.py │ │ │ │ ├── initializer.py │ │ │ │ ├── linear_filter.py │ │ │ │ ├── optimizer.py │ │ │ │ └── residual_modules.py │ │ │ └── tracking │ │ │ │ ├── __init__.py │ │ │ │ └── dimpnet.py │ │ ├── run_training.py │ │ ├── train_settings │ │ │ ├── __init__.py │ │ │ ├── bbreg │ │ │ │ ├── __init__.py │ │ │ │ ├── atom.py │ │ │ │ ├── atom_gmm_sampl.py │ │ │ │ ├── atom_paper.py │ │ │ │ └── atom_prob_ml.py │ │ │ └── dimp │ │ │ │ ├── __init__.py │ │ │ │ ├── dimp18.py │ │ │ │ ├── dimp50.py │ │ │ │ ├── prdimp18.py │ │ │ │ ├── prdimp50.py │ │ │ │ └── super_dimp.py │ │ └── trainers │ │ │ ├── __init__.py │ │ │ ├── base_trainer.py │ │ │ └── ltr_trainer.py │ └── pytracking │ │ ├── ARcm_seg.py │ │ ├── VOT │ │ ├── tracker_DiMP.m │ │ ├── trackers.ini │ │ └── vot.py │ │ ├── VOT2020_super_only_mask_384_HP │ │ ├── dimp_alpha_065.py │ │ ├── dimp_alpha_seg_class.py │ │ ├── stark_alpha_seg_class.py │ │ ├── stark_s50_ar.py │ │ ├── stark_st101_ar.py │ │ ├── stark_st50_ar.py │ │ └── vot.py │ │ ├── __init__.py │ │ ├── analysis │ │ ├── __init__.py │ │ ├── evaluate_vos.py │ │ ├── extract_results.py │ │ ├── playback_results.py │ │ ├── plot_results.py │ │ └── vos_utils.py │ │ ├── evaluation │ │ ├── __init__.py │ │ ├── data.py │ │ ├── datasets.py │ │ ├── environment.py │ │ ├── got10kdataset.py │ │ ├── lasotdataset.py │ │ ├── mobifacedataset.py │ │ ├── multi_object_wrapper.py │ │ ├── nfsdataset.py │ │ ├── otbdataset.py │ │ ├── running.py │ │ ├── tpldataset.py │ │ ├── tracker.py │ │ ├── trackingnetdataset.py │ │ ├── uavdataset.py │ │ ├── vot.py │ │ ├── vot2020.py │ │ └── votdataset.py │ │ ├── experiments │ │ ├── __init__.py │ │ └── myexperiments.py │ │ ├── features │ │ ├── __init__.py │ │ ├── augmentation.py │ │ ├── color.py │ │ ├── deep.py │ │ ├── extractor.py │ │ ├── featurebase.py │ │ ├── net_wrappers.py │ │ ├── preprocessing.py │ │ └── util.py │ │ ├── libs │ │ ├── __init__.py │ │ ├── complex.py │ │ ├── dcf.py │ │ ├── fourier.py │ │ ├── operation.py │ │ ├── optimization.py │ │ ├── tensordict.py │ │ └── tensorlist.py │ │ ├── parameter │ │ ├── __init__.py │ │ ├── atom │ │ │ ├── __init__.py │ │ │ ├── atom_gmm_sampl.py │ │ │ ├── atom_prob_ml.py │ │ │ ├── default.py │ │ │ ├── default_vot.py │ │ │ └── multiscale_no_iounet.py │ │ ├── dimp │ │ │ ├── __init__.py │ │ │ ├── dimp18.py │ │ │ ├── dimp18_vot.py │ │ │ ├── dimp50.py │ │ │ ├── dimp50_vot.py │ │ │ ├── dimp50_vot19.py │ │ │ ├── prdimp18.py │ │ │ ├── prdimp50.py │ │ │ └── super_dimp.py │ │ └── eco │ │ │ ├── __init__.py │ │ │ └── default.py │ │ ├── tracker │ │ ├── __init__.py │ │ ├── atom │ │ │ ├── __init__.py │ │ │ ├── atom.py │ │ │ └── optim.py │ │ ├── base │ │ │ ├── __init__.py │ │ │ └── basetracker.py │ │ ├── dimp │ │ │ ├── __init__.py │ │ │ └── dimp.py │ │ └── eco │ │ │ ├── __init__.py │ │ │ ├── eco.py │ │ │ └── optim.py │ │ ├── util_scripts │ │ ├── __init__.py │ │ ├── download_results.py │ │ ├── pack_got10k_results.py │ │ └── pack_trackingnet_results.py │ │ ├── utils │ │ ├── __init__.py │ │ ├── convert_vot_anno_to_rect.py │ │ ├── load_text.py │ │ ├── loading.py │ │ ├── params.py │ │ ├── plotting.py │ │ └── visdom.py │ │ └── vot20_utils.py ├── STARK-ExtreMart.pdf ├── vot20 │ ├── stark_s50 │ │ ├── config.yaml │ │ ├── exp.sh │ │ └── trackers.ini │ ├── stark_s50_ar │ │ ├── config.yaml │ │ ├── exp.sh │ │ └── trackers.ini │ ├── stark_st101 │ │ ├── config.yaml │ │ ├── exp.sh │ │ └── trackers.ini │ ├── stark_st101_ar │ │ ├── config.yaml │ │ ├── exp.sh │ │ └── trackers.ini │ ├── stark_st50 │ │ ├── config.yaml │ │ ├── exp.sh │ │ └── trackers.ini │ └── stark_st50_ar │ │ ├── config.yaml │ │ ├── exp.sh │ │ └── trackers.ini └── vot20_lt │ ├── stark_st101_lt │ ├── config.yaml │ ├── exp.sh │ └── trackers.ini │ └── stark_st50_lt │ ├── config.yaml │ ├── exp.sh │ └── trackers.ini ├── install.sh ├── install_pytorch17.sh ├── lib ├── __init__.py ├── config │ ├── __init__.py │ ├── simtrack │ │ └── config.py │ ├── stark_lightning_X_trt │ │ └── config.py │ ├── stark_s │ │ └── config.py │ ├── stark_st1 │ │ └── config.py │ └── stark_st2 │ │ └── config.py ├── models │ ├── __init__.py │ └── stark │ │ ├── __init__.py │ │ ├── backbone.py │ │ ├── backbone_X.py │ │ ├── clipvit16.py │ │ ├── head.py │ │ ├── lite_encoder.py │ │ ├── position_encoding.py │ │ ├── repvgg.py │ │ ├── resnet.py │ │ ├── simtrack.py │ │ ├── stark_lightning_x_trt.py │ │ ├── stark_s.py │ │ ├── stark_st.py │ │ ├── swin_base_patch4_window12_384_S16.yaml │ │ ├── swin_config.py │ │ ├── swin_transformer.py │ │ ├── transformer.py │ │ └── transformer_enc.py ├── test │ ├── __init__.py │ ├── analysis │ │ ├── __init__.py │ │ ├── extract_results.py │ │ └── plot_results.py │ ├── evaluation │ │ ├── __init__.py │ │ ├── data.py │ │ ├── datasets.py │ │ ├── environment.py │ │ ├── got10kdataset.py │ │ ├── lasot_lmdbdataset.py │ │ ├── lasotdataset.py │ │ ├── local.py │ │ ├── nfsdataset.py │ │ ├── otbdataset.py │ │ ├── running.py │ │ ├── tc128cedataset.py │ │ ├── tc128dataset.py │ │ ├── tracker.py │ │ ├── trackingnetdataset.py │ │ └── uavdataset.py │ ├── parameter │ │ ├── __init__.py │ │ ├── simtrack.py │ │ ├── stark_lightning_X_trt.py │ │ ├── stark_s.py │ │ └── stark_st.py │ ├── tracker │ │ ├── __init__.py │ │ ├── basetracker.py │ │ ├── simtrack.py │ │ ├── stark_lightning_X_trt.py │ │ ├── stark_s.py │ │ ├── stark_st.py │ │ └── stark_utils.py │ ├── utils │ │ ├── __init__.py │ │ ├── _init_paths.py │ │ ├── load_text.py │ │ ├── params.py │ │ ├── transform_got10k.py │ │ └── transform_trackingnet.py │ └── vot20 │ │ ├── stark_s50.py │ │ ├── stark_st101.py │ │ ├── stark_st101_lt.py │ │ ├── stark_st50.py │ │ ├── stark_st50_lt.py │ │ ├── stark_vot20.py │ │ ├── stark_vot20lt.py │ │ ├── vot.py │ │ └── vot20_utils.py ├── train │ ├── __init__.py │ ├── _init_paths.py │ ├── actors │ │ ├── __init__.py │ │ ├── base_actor.py │ │ ├── simtrack.py │ │ ├── stark_lightningXtrt.py │ │ ├── stark_lightningXtrt_distill.py │ │ ├── stark_s.py │ │ └── stark_st.py │ ├── admin │ │ ├── __init__.py │ │ ├── environment.py │ │ ├── local.py │ │ ├── multigpu.py │ │ ├── settings.py │ │ ├── stats.py │ │ └── tensorboard.py │ ├── base_functions.py │ ├── data │ │ ├── __init__.py │ │ ├── bounding_box_utils.py │ │ ├── image_loader.py │ │ ├── loader.py │ │ ├── processing.py │ │ ├── processing_utils.py │ │ ├── sampler.py │ │ └── transforms.py │ ├── data_specs │ │ ├── README.md │ │ ├── got10k_train_full_split.txt │ │ ├── got10k_train_split.txt │ │ ├── got10k_val_split.txt │ │ ├── got10k_vot_exclude.txt │ │ ├── got10k_vot_train_split.txt │ │ ├── got10k_vot_val_split.txt │ │ ├── lasot_train_split.txt │ │ └── trackingnet_classmap.txt │ ├── dataset │ │ ├── COCO_tool.py │ │ ├── __init__.py │ │ ├── base_image_dataset.py │ │ ├── base_video_dataset.py │ │ ├── coco.py │ │ ├── coco_seq.py │ │ ├── coco_seq_lmdb.py │ │ ├── got10k.py │ │ ├── got10k_lmdb.py │ │ ├── imagenetvid.py │ │ ├── imagenetvid_lmdb.py │ │ ├── lasot.py │ │ ├── lasot_lmdb.py │ │ ├── tracking_net.py │ │ └── tracking_net_lmdb.py │ ├── run_training.py │ ├── train_script.py │ ├── train_script_distill.py │ └── trainers │ │ ├── __init__.py │ │ ├── base_trainer.py │ │ └── ltr_trainer.py ├── tutorials │ ├── STARK_Lightning_Ch.md │ └── STARK_Lightning_En.md └── utils │ ├── __init__.py │ ├── box_ops.py │ ├── lmdb_utils.py │ ├── merge.py │ ├── misc.py │ └── tensor.py ├── test.sh ├── tracking ├── Framework.png ├── ORT_lightning_X_trt_backbone_bottleneck_pe.py ├── ORT_lightning_X_trt_complete.py ├── _init_paths.py ├── analysis_results.py ├── analysis_results_ITP.py ├── convert_transt.py ├── create_default_local_file.py ├── download_pytracking_results.py ├── pre_read_datasets.py ├── profile_model.py ├── profile_model_lightning_X_trt.py ├── test.py ├── train.py └── video_demo.py └── train.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Multimedia Research 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SimTrack 2 | ========================================= 3 | Official Code for [Backbone is All Your Need: A Simplified Architecture for Visual Object Tracking](https://arxiv.org/abs/2107.02960) accepted by ECCV 2022. 4 | 5 | 6 | ## Requirements 7 | - python==3.8.15 8 | - torch==1.8.1 9 | - torchvision==0.9.0 10 | - timm==0.5.4 11 | 12 | 13 | ## Results (AUC) 14 | |method| FLOPs | LaSOT | TNL2K | TrackingNet | GOT-10k_Test | UAV123 | model-clip| model-mae| 15 | |:------:|:-----:|:-----:|:-----:|:------:|:------:|:------:|:------:|:------:| 16 | |SimTrack| 25.0G | 69.3 | 54.8 | 82.3 | 70.6 | 69.8| [Sim-B/16](https://drive.google.com/file/d/19iSJi14yfJsi_XN5bfKdkBPUHgFzagg9/view?usp=sharing)| [MAE-B/16](https://drive.google.com/file/d/1TPir2JSrWuV7ZEA92oV1vvjjXn0KCRrx/view?usp=share_link)| 17 | |Raw Results| - | [LaSOT](https://drive.google.com/file/d/1bVohxZGlpdTmEwIm0IRB9vbM6hIZOKpy/view?usp=sharing) | [TNL2K](https://drive.google.com/file/d/1B9Y3QDBWL16ku5BpavharMdfqVQvofhF/view?usp=sharing) | [TrackingNet](https://drive.google.com/file/d/1nnQqXN4BkUd6CORieHmGuTKSvo0rAZAZ/view?usp=sharing) | [GOT-10k_Test](https://drive.google.com/file/d/1G5HgEUUkx8EWglvTFpZrJ5plKDqHCF9X/view?usp=sharing) | [UAV123](https://drive.google.com/file/d/1U6SnBZLMqgPqFv-Gg0TvP6dtserjo5RA/view?usp=sharing) | - | -| 18 | 19 | It should be noted that the above pretrained model is trained under [PYSOT codebase](https://github.com/STVIR/pysot). If you want to load the model in current pipeline, you may need to change the parameter name. Or you can train a new model with the current pipeline. 20 | 21 | 22 | ## Evaluation 23 | Download the model [Sim-B/16](https://drive.google.com/file/d/19iSJi14yfJsi_XN5bfKdkBPUHgFzagg9/view?usp=sharing). Add the model path to https://github.com/LPXTT/SimTrack/blob/a238932fd0cba9aa4a6fcdb590470d5882e5b0b4/lib/test/tracker/simtrack.py#L19 24 | ``` 25 | python tracking/test.py simtrack baseline --dataset got10k_test --threads 32 26 | ``` 27 | 28 | Before evaluation, please make sure the data path in [***local.py***](./lib/test/evaluation/local.py) is correct. 29 | 30 | ## Training 31 | ``` 32 | python tracking/train.py --script simtrack --config baseline_got10k_only --save_dir . --mode multiple --nproc_per_node 8 33 | ``` 34 | 35 | Before training, please make sure the data path in [***local.py***](./lib/train/admin/local.py) is correct. 36 | Also, please make sure there is "ViT-B/16": "https://openaipublic.azureedge.net/clip/models/5806e77cd80f8b59890b7e101eabd078d9fb84e6937f9e85e4ecb61988df416f/ViT-B-16.pt" in '**/anaconda3/envs/stark/lib/python3.8/site-packages/clip/clip.py'. If not, please add it manually. 37 | 38 | ## Thanks 39 | This implementation is based on [STARK](https://github.com/researchmm/Stark). Please ref to their reposity for more details. 40 | 41 | ## Citation 42 | If you find that this project helps your research, please consider citing our paper: 43 | ``` 44 | @article{chen2022backbone, 45 | title={Backbone is All Your Need: A Simplified Architecture for Visual Object Tracking}, 46 | author={Chen, Boyu and Li, Peixia and Bai, Lei and Qiao, Lei and Shen, Qiuhong and Li, Bo and Gan, Weihao and Wu, Wei and Ouyang, Wanli}, 47 | journal={arXiv preprint arXiv:2203.05328}, 48 | year={2022} 49 | } 50 | -------------------------------------------------------------------------------- /experiments/simtrack/baseline.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | MAX_SAMPLE_INTERVAL: 200 3 | MEAN: 4 | - 0.485 5 | - 0.456 6 | - 0.406 7 | SEARCH: 8 | CENTER_JITTER: 3.5 9 | FACTOR: 4.0 10 | SCALE_JITTER: 0.5 11 | SIZE: 224 12 | STD: 13 | - 0.229 14 | - 0.224 15 | - 0.225 16 | TEMPLATE: 17 | CENTER_JITTER: 0 18 | FACTOR: 2.0 19 | SCALE_JITTER: 0 20 | SIZE: 112 21 | TRAIN: 22 | DATASETS_NAME: 23 | - LASOT 24 | - GOT10K_vottrain 25 | - COCO17 26 | - TRACKINGNET 27 | DATASETS_RATIO: 28 | - 1 29 | - 1 30 | - 1 31 | - 1 32 | SAMPLE_PER_EPOCH: 60000 33 | VAL: 34 | DATASETS_NAME: 35 | - GOT10K_votval 36 | DATASETS_RATIO: 37 | - 1 38 | SAMPLE_PER_EPOCH: 10000 39 | MODEL: 40 | BACKBONE: 41 | NUM_FEA: 768 42 | TEMPLATE_SZ: 112 43 | SEARCH_SZ: 224 44 | WINDOW_SZ: 16 45 | FOVEAL_SZ: 64 46 | TYPE: 'ViT-B/16' 47 | HEAD_TYPE: CORNER 48 | HIDDEN_DIM: 256 49 | 50 | 51 | TRAIN: 52 | BACKBONE_MULTIPLIER: 0.1 53 | BATCH_SIZE: 64 54 | DEEP_SUPERVISION: false 55 | EPOCH: 50 56 | FREEZE_BACKBONE_BN: false 57 | # FREEZE_LAYERS: 58 | # - conv1 59 | # - layer1 60 | GIOU_WEIGHT: 2.0 61 | GRAD_CLIP_NORM: 0.1 62 | L1_WEIGHT: 5.0 63 | LR: 0.0001 64 | LR_DROP_EPOCH: 40 65 | NUM_WORKER: 8 66 | OPTIMIZER: ADAMW 67 | PRINT_INTERVAL: 40 68 | SCHEDULER: 69 | TYPE: step 70 | DECAY_RATE: 0.1 71 | VAL_EPOCH_INTERVAL: 20 72 | WEIGHT_DECAY: 0.0001 73 | TEST: 74 | EPOCH: 50 75 | SEARCH_FACTOR: 4.0 76 | SEARCH_SIZE: 224 77 | TEMPLATE_FACTOR: 2.0 78 | TEMPLATE_SIZE: 112 -------------------------------------------------------------------------------- /experiments/simtrack/baseline_got10k_only.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | MAX_SAMPLE_INTERVAL: 200 3 | MEAN: 4 | - 0.485 5 | - 0.456 6 | - 0.406 7 | SEARCH: 8 | CENTER_JITTER: 3.5 9 | FACTOR: 4.0 10 | SCALE_JITTER: 0.5 11 | SIZE: 224 12 | STD: 13 | - 0.229 14 | - 0.224 15 | - 0.225 16 | TEMPLATE: 17 | CENTER_JITTER: 0 18 | FACTOR: 2.0 19 | SCALE_JITTER: 0 20 | SIZE: 112 21 | TRAIN: 22 | DATASETS_NAME: 23 | - GOT10K_train_full 24 | DATASETS_RATIO: 25 | - 1 26 | SAMPLE_PER_EPOCH: 60000 27 | VAL: 28 | DATASETS_NAME: 29 | - GOT10K_votval 30 | DATASETS_RATIO: 31 | - 1 32 | SAMPLE_PER_EPOCH: 10000 33 | MODEL: 34 | BACKBONE: 35 | NUM_FEA: 768 36 | TEMPLATE_SZ: 112 37 | SEARCH_SZ: 224 38 | WINDOW_SZ: 16 39 | FOVEAL_SZ: 64 40 | TYPE: 'ViT-B/16' 41 | HEAD_TYPE: CORNER 42 | HIDDEN_DIM: 256 43 | 44 | 45 | TRAIN: 46 | BACKBONE_MULTIPLIER: 0.1 47 | BATCH_SIZE: 64 48 | DEEP_SUPERVISION: false 49 | EPOCH: 50 50 | FREEZE_BACKBONE_BN: false 51 | # FREEZE_LAYERS: 52 | # - conv1 53 | # - layer1 54 | GIOU_WEIGHT: 2.0 55 | GRAD_CLIP_NORM: 0.1 56 | L1_WEIGHT: 5.0 57 | LR: 0.0001 58 | LR_DROP_EPOCH: 40 59 | NUM_WORKER: 8 60 | OPTIMIZER: ADAMW 61 | PRINT_INTERVAL: 40 62 | SCHEDULER: 63 | TYPE: step 64 | DECAY_RATE: 0.1 65 | VAL_EPOCH_INTERVAL: 20 66 | WEIGHT_DECAY: 0.0001 67 | TEST: 68 | EPOCH: 50 69 | SEARCH_FACTOR: 4.0 70 | SEARCH_SIZE: 224 71 | TEMPLATE_FACTOR: 2.0 72 | TEMPLATE_SIZE: 112 -------------------------------------------------------------------------------- /experiments/stark_lightning_X_trt/baseline_rephead_4_lite_search5.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | MAX_SAMPLE_INTERVAL: 200 3 | MEAN: 4 | - 0.485 5 | - 0.456 6 | - 0.406 7 | SEARCH: 8 | CENTER_JITTER: 4.5 # ori 4.5 9 | FACTOR: 5.0 # ori 5.0 10 | SCALE_JITTER: 0.5 # ori 0.5 11 | SIZE: 320 # ori 320 12 | FEAT_SIZE: 20 13 | STD: 14 | - 0.229 15 | - 0.224 16 | - 0.225 17 | TEMPLATE: 18 | CENTER_JITTER: 0 19 | FACTOR: 2.0 20 | SCALE_JITTER: 0 21 | SIZE: 128 22 | FEAT_SIZE: 8 23 | TRAIN: 24 | DATASETS_NAME: 25 | - LASOT 26 | - GOT10K_vottrain 27 | - COCO17 28 | - TRACKINGNET 29 | DATASETS_RATIO: 30 | - 1 31 | - 1 32 | - 1 33 | - 1 34 | SAMPLE_PER_EPOCH: 60000 35 | VAL: 36 | DATASETS_NAME: 37 | - GOT10K_votval 38 | DATASETS_RATIO: 39 | - 1 40 | SAMPLE_PER_EPOCH: 10000 41 | MODEL: 42 | BACKBONE: 43 | LAST_STAGE_BLOCK: 4 44 | DILATION: false 45 | OUTPUT_LAYERS: 46 | - stage3 # ori layer3 47 | TYPE: RepVGG-A0 # ori resnet50 48 | HEAD_TYPE: CORNER_LITE_REP_v2 # ori CORNER 49 | HIDDEN_DIM: 128 50 | HEAD_DIM: 128 # ori 256 51 | TRANSFORMER: 52 | DIM_FEEDFORWARD: 1024 53 | DROPOUT: 0.1 54 | NHEADS: 8 55 | TRAIN: 56 | AMP: False 57 | BACKBONE_MULTIPLIER: 0.1 58 | BATCH_SIZE: 16 59 | DEEP_SUPERVISION: false 60 | EPOCH: 500 61 | FREEZE_BACKBONE_BN: true 62 | BACKBONE_TRAINED_LAYERS: 63 | - stage1 64 | - stage2 65 | - stage3 66 | GIOU_WEIGHT: 2.0 67 | GRAD_CLIP_NORM: 0.1 68 | L1_WEIGHT: 5.0 69 | LR: 0.0001 70 | LR_DROP_EPOCH: 400 71 | NUM_WORKER: 8 72 | OPTIMIZER: ADAMW 73 | PRINT_INTERVAL: 50 74 | SCHEDULER: 75 | TYPE: step 76 | DECAY_RATE: 0.1 77 | VAL_EPOCH_INTERVAL: 20 78 | WEIGHT_DECAY: 0.0001 79 | TEST: 80 | EPOCH: 500 81 | SEARCH_FACTOR: 5.0 # ori 5.0 82 | SEARCH_SIZE: 320 # ori 320 83 | TEMPLATE_FACTOR: 2.0 84 | TEMPLATE_SIZE: 128 -------------------------------------------------------------------------------- /experiments/stark_s/baseline.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | MAX_SAMPLE_INTERVAL: 200 3 | MEAN: 4 | - 0.485 5 | - 0.456 6 | - 0.406 7 | SEARCH: 8 | CENTER_JITTER: 4.5 9 | FACTOR: 5.0 10 | SCALE_JITTER: 0.5 11 | SIZE: 320 12 | STD: 13 | - 0.229 14 | - 0.224 15 | - 0.225 16 | TEMPLATE: 17 | CENTER_JITTER: 0 18 | FACTOR: 2.0 19 | SCALE_JITTER: 0 20 | SIZE: 128 21 | TRAIN: 22 | DATASETS_NAME: 23 | - LASOT 24 | - GOT10K_vottrain 25 | - COCO17 26 | - TRACKINGNET 27 | DATASETS_RATIO: 28 | - 1 29 | - 1 30 | - 1 31 | - 1 32 | SAMPLE_PER_EPOCH: 60000 33 | VAL: 34 | DATASETS_NAME: 35 | - GOT10K_votval 36 | DATASETS_RATIO: 37 | - 1 38 | SAMPLE_PER_EPOCH: 10000 39 | MODEL: 40 | BACKBONE: 41 | DILATION: false 42 | OUTPUT_LAYERS: 43 | - layer3 44 | TYPE: resnet50 45 | HEAD_TYPE: CORNER 46 | HIDDEN_DIM: 256 47 | NUM_OBJECT_QUERIES: 1 48 | POSITION_EMBEDDING: sine 49 | PREDICT_MASK: false 50 | TRANSFORMER: 51 | DEC_LAYERS: 6 52 | DIM_FEEDFORWARD: 2048 53 | DIVIDE_NORM: false 54 | DROPOUT: 0.1 55 | ENC_LAYERS: 6 56 | NHEADS: 8 57 | PRE_NORM: false 58 | TRAIN: 59 | BACKBONE_MULTIPLIER: 0.1 60 | BATCH_SIZE: 16 61 | DEEP_SUPERVISION: false 62 | EPOCH: 500 63 | FREEZE_BACKBONE_BN: true 64 | FREEZE_LAYERS: 65 | - conv1 66 | - layer1 67 | GIOU_WEIGHT: 2.0 68 | GRAD_CLIP_NORM: 0.1 69 | L1_WEIGHT: 5.0 70 | LR: 0.0001 71 | LR_DROP_EPOCH: 400 72 | NUM_WORKER: 8 73 | OPTIMIZER: ADAMW 74 | PRINT_INTERVAL: 50 75 | SCHEDULER: 76 | TYPE: step 77 | DECAY_RATE: 0.1 78 | VAL_EPOCH_INTERVAL: 20 79 | WEIGHT_DECAY: 0.0001 80 | TEST: 81 | EPOCH: 500 82 | SEARCH_FACTOR: 5.0 83 | SEARCH_SIZE: 320 84 | TEMPLATE_FACTOR: 2.0 85 | TEMPLATE_SIZE: 128 -------------------------------------------------------------------------------- /experiments/stark_s/baseline_got10k_only.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | MAX_SAMPLE_INTERVAL: 200 3 | MEAN: 4 | - 0.485 5 | - 0.456 6 | - 0.406 7 | SEARCH: 8 | CENTER_JITTER: 4.5 9 | FACTOR: 5.0 10 | SCALE_JITTER: 0.5 11 | SIZE: 320 12 | STD: 13 | - 0.229 14 | - 0.224 15 | - 0.225 16 | TEMPLATE: 17 | CENTER_JITTER: 0 18 | FACTOR: 2.0 19 | SCALE_JITTER: 0 20 | SIZE: 128 21 | TRAIN: 22 | DATASETS_NAME: 23 | - GOT10K_train_full 24 | DATASETS_RATIO: 25 | - 1 26 | SAMPLE_PER_EPOCH: 60000 27 | VAL: 28 | DATASETS_NAME: 29 | - GOT10K_votval 30 | DATASETS_RATIO: 31 | - 1 32 | SAMPLE_PER_EPOCH: 10000 33 | MODEL: 34 | BACKBONE: 35 | DILATION: false 36 | OUTPUT_LAYERS: 37 | - layer3 38 | TYPE: resnet50 39 | HEAD_TYPE: CORNER 40 | HIDDEN_DIM: 256 41 | NUM_OBJECT_QUERIES: 1 42 | POSITION_EMBEDDING: sine 43 | PREDICT_MASK: false 44 | TRANSFORMER: 45 | DEC_LAYERS: 6 46 | DIM_FEEDFORWARD: 2048 47 | DIVIDE_NORM: false 48 | DROPOUT: 0.1 49 | ENC_LAYERS: 6 50 | NHEADS: 8 51 | PRE_NORM: false 52 | TRAIN: 53 | BACKBONE_MULTIPLIER: 0.1 54 | BATCH_SIZE: 16 55 | DEEP_SUPERVISION: false 56 | EPOCH: 500 57 | FREEZE_BACKBONE_BN: true 58 | FREEZE_LAYERS: 59 | - conv1 60 | - layer1 61 | GIOU_WEIGHT: 2.0 62 | GRAD_CLIP_NORM: 0.1 63 | L1_WEIGHT: 5.0 64 | LR: 0.0001 65 | LR_DROP_EPOCH: 400 66 | NUM_WORKER: 8 67 | OPTIMIZER: ADAMW 68 | PRINT_INTERVAL: 50 69 | SCHEDULER: 70 | TYPE: step 71 | DECAY_RATE: 0.1 72 | VAL_EPOCH_INTERVAL: 20 73 | WEIGHT_DECAY: 0.0001 74 | TEST: 75 | EPOCH: 500 76 | SEARCH_FACTOR: 5.0 77 | SEARCH_SIZE: 320 78 | TEMPLATE_FACTOR: 2.0 79 | TEMPLATE_SIZE: 128 -------------------------------------------------------------------------------- /experiments/stark_st1/baseline.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | SAMPLER_MODE: trident_pro 3 | MAX_SAMPLE_INTERVAL: 4 | - 200 5 | MEAN: 6 | - 0.485 7 | - 0.456 8 | - 0.406 9 | SEARCH: 10 | CENTER_JITTER: 4.5 11 | FACTOR: 5.0 12 | SCALE_JITTER: 0.5 13 | SIZE: 320 14 | NUMBER: 1 15 | STD: 16 | - 0.229 17 | - 0.224 18 | - 0.225 19 | TEMPLATE: 20 | CENTER_JITTER: 0 21 | FACTOR: 2.0 22 | SCALE_JITTER: 0 23 | SIZE: 128 24 | NUMBER: 2 25 | TRAIN: 26 | DATASETS_NAME: 27 | - LASOT 28 | - GOT10K_vottrain 29 | - COCO17 30 | - TRACKINGNET 31 | DATASETS_RATIO: 32 | - 1 33 | - 1 34 | - 1 35 | - 1 36 | SAMPLE_PER_EPOCH: 60000 37 | VAL: 38 | DATASETS_NAME: 39 | - GOT10K_votval 40 | DATASETS_RATIO: 41 | - 1 42 | SAMPLE_PER_EPOCH: 10000 43 | MODEL: 44 | HEAD_TYPE: CORNER 45 | BACKBONE: 46 | DILATION: false 47 | OUTPUT_LAYERS: 48 | - layer3 49 | STRIDE: 16 50 | TYPE: resnet50 51 | HIDDEN_DIM: 256 52 | NUM_OBJECT_QUERIES: 1 53 | POSITION_EMBEDDING: sine 54 | PREDICT_MASK: false 55 | TRANSFORMER: 56 | DEC_LAYERS: 6 57 | DIM_FEEDFORWARD: 2048 58 | DIVIDE_NORM: false 59 | DROPOUT: 0.1 60 | ENC_LAYERS: 6 61 | NHEADS: 8 62 | PRE_NORM: false 63 | TRAIN: 64 | BACKBONE_MULTIPLIER: 0.1 65 | BATCH_SIZE: 16 66 | DEEP_SUPERVISION: false 67 | EPOCH: 500 68 | FREEZE_BACKBONE_BN: true 69 | FREEZE_LAYERS: 70 | - conv1 71 | - layer1 72 | GIOU_WEIGHT: 2.0 73 | GRAD_CLIP_NORM: 0.1 74 | L1_WEIGHT: 5.0 75 | LR: 0.0001 76 | LR_DROP_EPOCH: 400 77 | NUM_WORKER: 8 78 | OPTIMIZER: ADAMW 79 | PRINT_INTERVAL: 50 80 | VAL_EPOCH_INTERVAL: 20 81 | WEIGHT_DECAY: 0.0001 82 | -------------------------------------------------------------------------------- /experiments/stark_st1/baseline_R101.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | SAMPLER_MODE: trident_pro 3 | MAX_SAMPLE_INTERVAL: 4 | - 200 5 | MEAN: 6 | - 0.485 7 | - 0.456 8 | - 0.406 9 | SEARCH: 10 | CENTER_JITTER: 4.5 11 | FACTOR: 5.0 12 | SCALE_JITTER: 0.5 13 | SIZE: 320 14 | NUMBER: 1 15 | STD: 16 | - 0.229 17 | - 0.224 18 | - 0.225 19 | TEMPLATE: 20 | CENTER_JITTER: 0 21 | FACTOR: 2.0 22 | SCALE_JITTER: 0 23 | SIZE: 128 24 | NUMBER: 2 25 | TRAIN: 26 | DATASETS_NAME: 27 | - LASOT 28 | - GOT10K_vottrain 29 | - COCO17 30 | - TRACKINGNET 31 | DATASETS_RATIO: 32 | - 1 33 | - 1 34 | - 1 35 | - 1 36 | SAMPLE_PER_EPOCH: 60000 37 | VAL: 38 | DATASETS_NAME: 39 | - GOT10K_votval 40 | DATASETS_RATIO: 41 | - 1 42 | SAMPLE_PER_EPOCH: 10000 43 | MODEL: 44 | HEAD_TYPE: CORNER 45 | BACKBONE: 46 | DILATION: false 47 | OUTPUT_LAYERS: 48 | - layer3 49 | STRIDE: 16 50 | TYPE: resnet101 51 | HIDDEN_DIM: 256 52 | NUM_OBJECT_QUERIES: 1 53 | POSITION_EMBEDDING: sine 54 | PREDICT_MASK: false 55 | TRANSFORMER: 56 | DEC_LAYERS: 6 57 | DIM_FEEDFORWARD: 2048 58 | DIVIDE_NORM: false 59 | DROPOUT: 0.1 60 | ENC_LAYERS: 6 61 | NHEADS: 8 62 | PRE_NORM: false 63 | TRAIN: 64 | BACKBONE_MULTIPLIER: 0.1 65 | BATCH_SIZE: 16 66 | DEEP_SUPERVISION: false 67 | EPOCH: 500 68 | FREEZE_BACKBONE_BN: true 69 | FREEZE_LAYERS: 70 | - conv1 71 | - layer1 72 | GIOU_WEIGHT: 2.0 73 | GRAD_CLIP_NORM: 0.1 74 | L1_WEIGHT: 5.0 75 | LR: 0.0001 76 | LR_DROP_EPOCH: 400 77 | NUM_WORKER: 8 78 | OPTIMIZER: ADAMW 79 | PRINT_INTERVAL: 50 80 | VAL_EPOCH_INTERVAL: 20 81 | WEIGHT_DECAY: 0.0001 82 | -------------------------------------------------------------------------------- /experiments/stark_st1/baseline_R101_got10k_only.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | SAMPLER_MODE: trident_pro 3 | MAX_SAMPLE_INTERVAL: 4 | - 200 5 | MEAN: 6 | - 0.485 7 | - 0.456 8 | - 0.406 9 | SEARCH: 10 | CENTER_JITTER: 4.5 11 | FACTOR: 5.0 12 | SCALE_JITTER: 0.5 13 | SIZE: 320 14 | NUMBER: 1 15 | STD: 16 | - 0.229 17 | - 0.224 18 | - 0.225 19 | TEMPLATE: 20 | CENTER_JITTER: 0 21 | FACTOR: 2.0 22 | SCALE_JITTER: 0 23 | SIZE: 128 24 | NUMBER: 2 25 | TRAIN: 26 | DATASETS_NAME: 27 | - GOT10K_train_full 28 | DATASETS_RATIO: 29 | - 1 30 | SAMPLE_PER_EPOCH: 60000 31 | VAL: 32 | DATASETS_NAME: 33 | - GOT10K_votval 34 | DATASETS_RATIO: 35 | - 1 36 | SAMPLE_PER_EPOCH: 10000 37 | MODEL: 38 | HEAD_TYPE: CORNER 39 | BACKBONE: 40 | DILATION: false 41 | OUTPUT_LAYERS: 42 | - layer3 43 | STRIDE: 16 44 | TYPE: resnet101 45 | HIDDEN_DIM: 256 46 | NUM_OBJECT_QUERIES: 1 47 | POSITION_EMBEDDING: sine 48 | PREDICT_MASK: false 49 | TRANSFORMER: 50 | DEC_LAYERS: 6 51 | DIM_FEEDFORWARD: 2048 52 | DIVIDE_NORM: false 53 | DROPOUT: 0.1 54 | ENC_LAYERS: 6 55 | NHEADS: 8 56 | PRE_NORM: false 57 | TRAIN: 58 | BACKBONE_MULTIPLIER: 0.1 59 | BATCH_SIZE: 16 60 | DEEP_SUPERVISION: false 61 | EPOCH: 500 62 | FREEZE_BACKBONE_BN: true 63 | FREEZE_LAYERS: 64 | - conv1 65 | - layer1 66 | GIOU_WEIGHT: 2.0 67 | GRAD_CLIP_NORM: 0.1 68 | L1_WEIGHT: 5.0 69 | LR: 0.0001 70 | LR_DROP_EPOCH: 400 71 | NUM_WORKER: 8 72 | OPTIMIZER: ADAMW 73 | PRINT_INTERVAL: 50 74 | VAL_EPOCH_INTERVAL: 20 75 | WEIGHT_DECAY: 0.0001 76 | -------------------------------------------------------------------------------- /experiments/stark_st1/baseline_got10k_only.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | SAMPLER_MODE: trident_pro 3 | MAX_SAMPLE_INTERVAL: 4 | - 200 5 | MEAN: 6 | - 0.485 7 | - 0.456 8 | - 0.406 9 | SEARCH: 10 | CENTER_JITTER: 4.5 11 | FACTOR: 5.0 12 | SCALE_JITTER: 0.5 13 | SIZE: 320 14 | NUMBER: 1 15 | STD: 16 | - 0.229 17 | - 0.224 18 | - 0.225 19 | TEMPLATE: 20 | CENTER_JITTER: 0 21 | FACTOR: 2.0 22 | SCALE_JITTER: 0 23 | SIZE: 128 24 | NUMBER: 2 25 | TRAIN: 26 | DATASETS_NAME: 27 | - GOT10K_train_full 28 | DATASETS_RATIO: 29 | - 1 30 | SAMPLE_PER_EPOCH: 60000 31 | VAL: 32 | DATASETS_NAME: 33 | - GOT10K_votval 34 | DATASETS_RATIO: 35 | - 1 36 | SAMPLE_PER_EPOCH: 10000 37 | MODEL: 38 | HEAD_TYPE: CORNER 39 | BACKBONE: 40 | DILATION: false 41 | OUTPUT_LAYERS: 42 | - layer3 43 | STRIDE: 16 44 | TYPE: resnet50 45 | HIDDEN_DIM: 256 46 | NUM_OBJECT_QUERIES: 1 47 | POSITION_EMBEDDING: sine 48 | PREDICT_MASK: false 49 | TRANSFORMER: 50 | DEC_LAYERS: 6 51 | DIM_FEEDFORWARD: 2048 52 | DIVIDE_NORM: false 53 | DROPOUT: 0.1 54 | ENC_LAYERS: 6 55 | NHEADS: 8 56 | PRE_NORM: false 57 | TRAIN: 58 | BACKBONE_MULTIPLIER: 0.1 59 | BATCH_SIZE: 16 60 | DEEP_SUPERVISION: false 61 | EPOCH: 500 62 | FREEZE_BACKBONE_BN: true 63 | FREEZE_LAYERS: 64 | - conv1 65 | - layer1 66 | GIOU_WEIGHT: 2.0 67 | GRAD_CLIP_NORM: 0.1 68 | L1_WEIGHT: 5.0 69 | LR: 0.0001 70 | LR_DROP_EPOCH: 400 71 | NUM_WORKER: 8 72 | OPTIMIZER: ADAMW 73 | PRINT_INTERVAL: 50 74 | VAL_EPOCH_INTERVAL: 20 75 | WEIGHT_DECAY: 0.0001 76 | -------------------------------------------------------------------------------- /experiments/stark_st2/baseline.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | SAMPLER_MODE: trident_pro 3 | MAX_SAMPLE_INTERVAL: 4 | - 200 5 | MEAN: 6 | - 0.485 7 | - 0.456 8 | - 0.406 9 | SEARCH: 10 | CENTER_JITTER: 4.5 11 | FACTOR: 5.0 12 | SCALE_JITTER: 0.5 13 | SIZE: 320 14 | NUMBER: 1 15 | STD: 16 | - 0.229 17 | - 0.224 18 | - 0.225 19 | TEMPLATE: 20 | CENTER_JITTER: 0 21 | FACTOR: 2.0 22 | SCALE_JITTER: 0 23 | SIZE: 128 24 | NUMBER: 2 25 | TRAIN: 26 | DATASETS_NAME: 27 | - LASOT 28 | - GOT10K_vottrain 29 | - COCO17 30 | - TRACKINGNET 31 | DATASETS_RATIO: 32 | - 1 33 | - 1 34 | - 1 35 | - 1 36 | SAMPLE_PER_EPOCH: 60000 37 | VAL: 38 | DATASETS_NAME: 39 | - GOT10K_votval 40 | DATASETS_RATIO: 41 | - 1 42 | SAMPLE_PER_EPOCH: 10000 43 | MODEL: 44 | HEAD_TYPE: CORNER 45 | NLAYER_HEAD: 3 46 | BACKBONE: 47 | DILATION: false 48 | OUTPUT_LAYERS: 49 | - layer3 50 | STRIDE: 16 51 | TYPE: resnet50 52 | HIDDEN_DIM: 256 53 | NUM_OBJECT_QUERIES: 1 54 | POSITION_EMBEDDING: sine 55 | PREDICT_MASK: false 56 | TRANSFORMER: 57 | DEC_LAYERS: 6 58 | DIM_FEEDFORWARD: 2048 59 | DIVIDE_NORM: false 60 | DROPOUT: 0.1 61 | ENC_LAYERS: 6 62 | NHEADS: 8 63 | PRE_NORM: false 64 | TRAIN: 65 | BACKBONE_MULTIPLIER: 0.1 66 | BATCH_SIZE: 16 67 | DEEP_SUPERVISION: false 68 | EPOCH: 50 69 | FREEZE_BACKBONE_BN: true 70 | FREEZE_LAYERS: 71 | - conv1 72 | - layer1 73 | GRAD_CLIP_NORM: 0.1 74 | LR: 0.0001 75 | LR_DROP_EPOCH: 40 76 | NUM_WORKER: 8 77 | OPTIMIZER: ADAMW 78 | PRINT_INTERVAL: 50 79 | VAL_EPOCH_INTERVAL: 10 80 | WEIGHT_DECAY: 0.0001 81 | TEST: 82 | EPOCH: 50 83 | SEARCH_FACTOR: 5.0 84 | SEARCH_SIZE: 320 85 | TEMPLATE_FACTOR: 2.0 86 | TEMPLATE_SIZE: 128 87 | UPDATE_INTERVALS: 88 | LASOT: [200] 89 | GOT10K_TEST: [200] 90 | TRACKINGNET: [25] 91 | VOT20: [10] 92 | VOT20LT: [200] -------------------------------------------------------------------------------- /experiments/stark_st2/baseline_R101.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | SAMPLER_MODE: trident_pro 3 | MAX_SAMPLE_INTERVAL: 4 | - 200 5 | MEAN: 6 | - 0.485 7 | - 0.456 8 | - 0.406 9 | SEARCH: 10 | CENTER_JITTER: 4.5 11 | FACTOR: 5.0 12 | SCALE_JITTER: 0.5 13 | SIZE: 320 14 | NUMBER: 1 15 | STD: 16 | - 0.229 17 | - 0.224 18 | - 0.225 19 | TEMPLATE: 20 | CENTER_JITTER: 0 21 | FACTOR: 2.0 22 | SCALE_JITTER: 0 23 | SIZE: 128 24 | NUMBER: 2 25 | TRAIN: 26 | DATASETS_NAME: 27 | - LASOT 28 | - GOT10K_vottrain 29 | - COCO17 30 | - TRACKINGNET 31 | DATASETS_RATIO: 32 | - 1 33 | - 1 34 | - 1 35 | - 1 36 | SAMPLE_PER_EPOCH: 60000 37 | VAL: 38 | DATASETS_NAME: 39 | - GOT10K_votval 40 | DATASETS_RATIO: 41 | - 1 42 | SAMPLE_PER_EPOCH: 10000 43 | MODEL: 44 | HEAD_TYPE: CORNER 45 | NLAYER_HEAD: 3 46 | BACKBONE: 47 | DILATION: false 48 | OUTPUT_LAYERS: 49 | - layer3 50 | STRIDE: 16 51 | TYPE: resnet101 52 | HIDDEN_DIM: 256 53 | NUM_OBJECT_QUERIES: 1 54 | POSITION_EMBEDDING: sine 55 | PREDICT_MASK: false 56 | TRANSFORMER: 57 | DEC_LAYERS: 6 58 | DIM_FEEDFORWARD: 2048 59 | DIVIDE_NORM: false 60 | DROPOUT: 0.1 61 | ENC_LAYERS: 6 62 | NHEADS: 8 63 | PRE_NORM: false 64 | TRAIN: 65 | BACKBONE_MULTIPLIER: 0.1 66 | BATCH_SIZE: 16 67 | DEEP_SUPERVISION: false 68 | EPOCH: 50 69 | FREEZE_BACKBONE_BN: true 70 | FREEZE_LAYERS: 71 | - conv1 72 | - layer1 73 | GRAD_CLIP_NORM: 0.1 74 | LR: 0.0001 75 | LR_DROP_EPOCH: 40 76 | NUM_WORKER: 8 77 | OPTIMIZER: ADAMW 78 | PRINT_INTERVAL: 50 79 | VAL_EPOCH_INTERVAL: 10 80 | WEIGHT_DECAY: 0.0001 81 | TEST: 82 | EPOCH: 50 83 | SEARCH_FACTOR: 5.0 84 | SEARCH_SIZE: 320 85 | TEMPLATE_FACTOR: 2.0 86 | TEMPLATE_SIZE: 128 87 | UPDATE_INTERVALS: 88 | LASOT: [200] 89 | GOT10K_TEST: [200] 90 | TRACKINGNET: [25] 91 | VOT20: [10] 92 | VOT20LT: [100] -------------------------------------------------------------------------------- /experiments/stark_st2/baseline_R101_got10k_only.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | SAMPLER_MODE: trident_pro 3 | MAX_SAMPLE_INTERVAL: 4 | - 200 5 | MEAN: 6 | - 0.485 7 | - 0.456 8 | - 0.406 9 | SEARCH: 10 | CENTER_JITTER: 4.5 11 | FACTOR: 5.0 12 | SCALE_JITTER: 0.5 13 | SIZE: 320 14 | NUMBER: 1 15 | STD: 16 | - 0.229 17 | - 0.224 18 | - 0.225 19 | TEMPLATE: 20 | CENTER_JITTER: 0 21 | FACTOR: 2.0 22 | SCALE_JITTER: 0 23 | SIZE: 128 24 | NUMBER: 2 25 | TRAIN: 26 | DATASETS_NAME: 27 | - GOT10K_train_full 28 | DATASETS_RATIO: 29 | - 1 30 | SAMPLE_PER_EPOCH: 60000 31 | VAL: 32 | DATASETS_NAME: 33 | - GOT10K_votval 34 | DATASETS_RATIO: 35 | - 1 36 | SAMPLE_PER_EPOCH: 10000 37 | MODEL: 38 | HEAD_TYPE: CORNER 39 | NLAYER_HEAD: 3 40 | BACKBONE: 41 | DILATION: false 42 | OUTPUT_LAYERS: 43 | - layer3 44 | STRIDE: 16 45 | TYPE: resnet101 46 | HIDDEN_DIM: 256 47 | NUM_OBJECT_QUERIES: 1 48 | POSITION_EMBEDDING: sine 49 | PREDICT_MASK: false 50 | TRANSFORMER: 51 | DEC_LAYERS: 6 52 | DIM_FEEDFORWARD: 2048 53 | DIVIDE_NORM: false 54 | DROPOUT: 0.1 55 | ENC_LAYERS: 6 56 | NHEADS: 8 57 | PRE_NORM: false 58 | TRAIN: 59 | BACKBONE_MULTIPLIER: 0.1 60 | BATCH_SIZE: 16 61 | DEEP_SUPERVISION: false 62 | EPOCH: 50 63 | FREEZE_BACKBONE_BN: true 64 | FREEZE_LAYERS: 65 | - conv1 66 | - layer1 67 | GRAD_CLIP_NORM: 0.1 68 | LR: 0.0001 69 | LR_DROP_EPOCH: 40 70 | NUM_WORKER: 8 71 | OPTIMIZER: ADAMW 72 | PRINT_INTERVAL: 50 73 | VAL_EPOCH_INTERVAL: 10 74 | WEIGHT_DECAY: 0.0001 75 | TEST: 76 | EPOCH: 50 77 | SEARCH_FACTOR: 5.0 78 | SEARCH_SIZE: 320 79 | TEMPLATE_FACTOR: 2.0 80 | TEMPLATE_SIZE: 128 -------------------------------------------------------------------------------- /experiments/stark_st2/baseline_got10k_only.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | SAMPLER_MODE: trident_pro 3 | MAX_SAMPLE_INTERVAL: 4 | - 200 5 | MEAN: 6 | - 0.485 7 | - 0.456 8 | - 0.406 9 | SEARCH: 10 | CENTER_JITTER: 4.5 11 | FACTOR: 5.0 12 | SCALE_JITTER: 0.5 13 | SIZE: 320 14 | NUMBER: 1 15 | STD: 16 | - 0.229 17 | - 0.224 18 | - 0.225 19 | TEMPLATE: 20 | CENTER_JITTER: 0 21 | FACTOR: 2.0 22 | SCALE_JITTER: 0 23 | SIZE: 128 24 | NUMBER: 2 25 | TRAIN: 26 | DATASETS_NAME: 27 | - GOT10K_train_full 28 | DATASETS_RATIO: 29 | - 1 30 | SAMPLE_PER_EPOCH: 60000 31 | VAL: 32 | DATASETS_NAME: 33 | - GOT10K_votval 34 | DATASETS_RATIO: 35 | - 1 36 | SAMPLE_PER_EPOCH: 10000 37 | MODEL: 38 | HEAD_TYPE: CORNER 39 | NLAYER_HEAD: 3 40 | BACKBONE: 41 | DILATION: false 42 | OUTPUT_LAYERS: 43 | - layer3 44 | STRIDE: 16 45 | TYPE: resnet50 46 | HIDDEN_DIM: 256 47 | NUM_OBJECT_QUERIES: 1 48 | POSITION_EMBEDDING: sine 49 | PREDICT_MASK: false 50 | TRANSFORMER: 51 | DEC_LAYERS: 6 52 | DIM_FEEDFORWARD: 2048 53 | DIVIDE_NORM: false 54 | DROPOUT: 0.1 55 | ENC_LAYERS: 6 56 | NHEADS: 8 57 | PRE_NORM: false 58 | TRAIN: 59 | BACKBONE_MULTIPLIER: 0.1 60 | BATCH_SIZE: 16 61 | DEEP_SUPERVISION: false 62 | EPOCH: 50 63 | FREEZE_BACKBONE_BN: true 64 | FREEZE_LAYERS: 65 | - conv1 66 | - layer1 67 | GRAD_CLIP_NORM: 0.1 68 | LR: 0.0001 69 | LR_DROP_EPOCH: 40 70 | NUM_WORKER: 8 71 | OPTIMIZER: ADAMW 72 | PRINT_INTERVAL: 50 73 | VAL_EPOCH_INTERVAL: 10 74 | WEIGHT_DECAY: 0.0001 75 | TEST: 76 | EPOCH: 50 77 | SEARCH_FACTOR: 5.0 78 | SEARCH_SIZE: 320 79 | TEMPLATE_FACTOR: 2.0 80 | TEMPLATE_SIZE: 128 -------------------------------------------------------------------------------- /external/AR/README.md: -------------------------------------------------------------------------------- 1 | # Alpha-Refine 2 | ## Introduction 3 | Alpha-Refine is the winner of the VOT Real-Time Challenge 2020, which has great ability to predict high-quality masks. 4 | In this work, we combine the STARK tracker with Alpha-Refine to test on the VOT2020 benchamark. 5 | 6 | ## Installation 7 | After the environment has been installed according to the README.md of STARK, you only need to install a few more packages as shown below. 8 | 9 | * Install ninja-build for Precise ROI pooling 10 | ```bash 11 | sudo apt-get install ninja-build 12 | ``` 13 | In case of issues, we refer to https://github.com/vacancy/PreciseRoIPooling. 14 | 15 | * Install the Precise ROI pooling 16 | ``` 17 | cd ltr/external 18 | git clone https://github.com/vacancy/PreciseRoIPooling.git 19 | cd ../.. 20 | ``` 21 | * Add the project path to environment variables 22 | ``` 23 | export PYTHONPATH=:$PYTHONPATH 24 | ``` 25 | 26 | * Setup the environment 27 | 28 | Create the default environment setting files. 29 | ```bash 30 | # Environment settings for pytracking. Saved at pytracking/evaluation/local.py 31 | python -c "from pytracking.evaluation.environment import create_default_local_file; create_default_local_file()" 32 | 33 | # Environment settings for ltr. Saved at ltr/admin/local.py 34 | python -c "from ltr.admin.environment import create_default_local_file; create_default_local_file()" 35 | ``` 36 | 37 | You can modify these files to set the paths to datasets, results paths etc. 38 | 39 | * Download the pre-trained Alpha-Refine network 40 | Download the network for [Alpha-Refine](https://drive.google.com/open?id=1qOQRfaRMbQ2nmgX1NFjoQHfXOAn609QM) 41 | and put it under the ltr/checkpoints/ltr/ARcm_seg/ARcm_coco_seg_only_mask_384 dir. 42 | 43 | -------------------------------------------------------------------------------- /external/AR/ltr/__init__.py: -------------------------------------------------------------------------------- 1 | from .admin.loading import load_network 2 | from .admin.model_constructor import model_constructor 3 | from .admin.multigpu import MultiGPU -------------------------------------------------------------------------------- /external/AR/ltr/actors/__init__.py: -------------------------------------------------------------------------------- 1 | from .base_actor import BaseActor 2 | from .bbreg import AtomActor 3 | from .tracking import DiMPActor -------------------------------------------------------------------------------- /external/AR/ltr/actors/base_actor.py: -------------------------------------------------------------------------------- 1 | from pytracking import TensorDict 2 | 3 | 4 | class BaseActor: 5 | """ Base class for actor. The actor class handles the passing of the data through the network 6 | and calculation the loss""" 7 | def __init__(self, net, objective): 8 | """ 9 | args: 10 | net - The network to train 11 | objective - The loss function 12 | """ 13 | self.net = net 14 | self.objective = objective 15 | 16 | def __call__(self, data: TensorDict): 17 | """ Called in each training iteration. Should pass in input data through the network, calculate the loss, and 18 | return the training stats for the input data 19 | args: 20 | data - A TensorDict containing all the necessary data blocks. 21 | 22 | returns: 23 | loss - loss for the input data 24 | stats - a dict containing detailed losses 25 | """ 26 | raise NotImplementedError 27 | 28 | def to(self, device): 29 | """ Move the network to device 30 | args: 31 | device - device to use. 'cpu' or 'cuda' 32 | """ 33 | self.net.to(device) 34 | 35 | def train(self, mode=True): 36 | """ Set whether the network is in train mode. 37 | args: 38 | mode (True) - Bool specifying whether in training mode. 39 | """ 40 | self.net.train(mode) 41 | 42 | def eval(self): 43 | """ Set network to eval mode""" 44 | self.train(False) -------------------------------------------------------------------------------- /external/AR/ltr/actors/bbreg.py: -------------------------------------------------------------------------------- 1 | from . import BaseActor 2 | 3 | 4 | class AtomActor(BaseActor): 5 | """ Actor for training the IoU-Net in ATOM""" 6 | def __call__(self, data): 7 | """ 8 | args: 9 | data - The input data, should contain the fields 'train_images', 'test_images', 'train_anno', 10 | 'test_proposals' and 'proposal_iou'. 11 | 12 | returns: 13 | loss - the training loss 14 | states - dict containing detailed losses 15 | """ 16 | # Run network to obtain IoU prediction for each proposal in 'test_proposals' 17 | iou_pred = self.net(data['train_images'], data['test_images'], data['train_anno'], data['test_proposals']) 18 | 19 | iou_pred = iou_pred.view(-1, iou_pred.shape[2]) 20 | iou_gt = data['proposal_iou'].view(-1, data['proposal_iou'].shape[2]) 21 | 22 | # Compute loss 23 | loss = self.objective(iou_pred, iou_gt) 24 | 25 | # Return training stats 26 | stats = {'Loss/total': loss.item(), 27 | 'Loss/iou': loss.item()} 28 | 29 | return loss, stats 30 | 31 | 32 | class AtomBBKLActor(BaseActor): 33 | """ Actor for training the IoU-Net in ATOM with BBKL""" 34 | def __call__(self, data): 35 | """ 36 | args: 37 | data - The input data, should contain the fields 'train_images', 'test_images', 'train_anno', 38 | 'test_proposals', 'proposal_density', and 'gt_density'. 39 | 40 | returns: 41 | loss - the training loss 42 | states - dict containing detailed losses 43 | """ 44 | # Run network to obtain IoU prediction for each proposal in 'test_proposals' 45 | bb_scores = self.net(data['train_images'], data['test_images'], data['train_anno'], data['test_proposals']) 46 | 47 | bb_scores = bb_scores.view(-1, bb_scores.shape[2]) 48 | proposal_density = data['proposal_density'].view(-1, data['proposal_density'].shape[2]) 49 | gt_density = data['gt_density'].view(-1, data['gt_density'].shape[2]) 50 | 51 | # Compute loss 52 | loss = self.objective(bb_scores, sample_density=proposal_density, gt_density=gt_density, mc_dim=1) 53 | 54 | # Return training stats 55 | stats = {'Loss/total': loss.item(), 56 | 'Loss/bb_ce': loss.item()} 57 | 58 | return loss, stats 59 | -------------------------------------------------------------------------------- /external/AR/ltr/admin/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/ltr/admin/__init__.py -------------------------------------------------------------------------------- /external/AR/ltr/admin/environment.py: -------------------------------------------------------------------------------- 1 | import importlib 2 | import os 3 | from collections import OrderedDict 4 | 5 | 6 | def create_default_local_file(): 7 | path = os.path.join(os.path.dirname(__file__), 'local.py') 8 | 9 | empty_str = '\'\'' 10 | default_settings = OrderedDict({ 11 | 'workspace_dir': empty_str, 12 | 'tensorboard_dir': 'self.workspace_dir + \'/tensorboard/\'', 13 | 'lasot_dir': empty_str, 14 | 'got10k_dir': empty_str, 15 | 'trackingnet_dir': empty_str, 16 | 'coco_dir': empty_str, 17 | 'lvis_dir': empty_str, 18 | 'sbd_dir': empty_str, 19 | 'imagenet_dir': empty_str, 20 | 'imagenetdet_dir': empty_str, 21 | 'ecssd_dir': empty_str, 22 | 'hkuis_dir': empty_str, 23 | 'msra10k_dir': empty_str, 24 | 'davis_dir': empty_str, 25 | 'youtubevos_dir': empty_str}) 26 | 27 | comment = {'workspace_dir': 'Base directory for saving network checkpoints.', 28 | 'tensorboard_dir': 'Directory for tensorboard files.'} 29 | 30 | with open(path, 'w') as f: 31 | f.write('class EnvironmentSettings:\n') 32 | f.write(' def __init__(self):\n') 33 | 34 | for attr, attr_val in default_settings.items(): 35 | comment_str = None 36 | if attr in comment: 37 | comment_str = comment[attr] 38 | if comment_str is None: 39 | f.write(' self.{} = {}\n'.format(attr, attr_val)) 40 | else: 41 | f.write(' self.{} = {} # {}\n'.format(attr, attr_val, comment_str)) 42 | 43 | 44 | def env_settings(): 45 | env_module_name = 'ltr.admin.local' 46 | try: 47 | env_module = importlib.import_module(env_module_name) 48 | return env_module.EnvironmentSettings() 49 | except: 50 | env_file = os.path.join(os.path.dirname(__file__), 'local.py') 51 | 52 | create_default_local_file() 53 | raise RuntimeError('YOU HAVE NOT SETUP YOUR local.py!!!\n Go to "{}" and set all the paths you need. Then try to run again.'.format(env_file)) 54 | -------------------------------------------------------------------------------- /external/AR/ltr/admin/model_constructor.py: -------------------------------------------------------------------------------- 1 | from functools import wraps 2 | import importlib 3 | 4 | 5 | def model_constructor(f): 6 | """ Wraps the function 'f' which returns the network. An extra field 'constructor' is added to the network returned 7 | by 'f'. This field contains an instance of the 'NetConstructor' class, which contains the information needed to 8 | re-construct the network, such as the name of the function 'f', the function arguments etc. Thus, the network can 9 | be easily constructed from a saved checkpoint by calling NetConstructor.get() function. 10 | """ 11 | @wraps(f) 12 | def f_wrapper(*args, **kwds): 13 | net_constr = NetConstructor(f.__name__, f.__module__, args, kwds) 14 | output = f(*args, **kwds) 15 | if isinstance(output, (tuple, list)): 16 | # Assume first argument is the network 17 | output[0].constructor = net_constr 18 | else: 19 | output.constructor = net_constr 20 | return output 21 | return f_wrapper 22 | 23 | 24 | class NetConstructor: 25 | """ Class to construct networks. Takes as input the function name (e.g. atom_resnet18), the name of the module 26 | which contains the network function (e.g. ltr.models.bbreg.atom) and the arguments for the network 27 | function. The class object can then be stored along with the network weights to re-construct the network.""" 28 | def __init__(self, fun_name, fun_module, args, kwds): 29 | """ 30 | args: 31 | fun_name - The function which returns the network 32 | fun_module - the module which contains the network function 33 | args - arguments which are passed to the network function 34 | kwds - arguments which are passed to the network function 35 | """ 36 | self.fun_name = fun_name 37 | self.fun_module = fun_module 38 | self.args = args 39 | self.kwds = kwds 40 | 41 | def get(self): 42 | """ Rebuild the network by calling the network function with the correct arguments. """ 43 | net_module = importlib.import_module(self.fun_module) 44 | net_fun = getattr(net_module, self.fun_name) 45 | return net_fun(*self.args, **self.kwds) 46 | -------------------------------------------------------------------------------- /external/AR/ltr/admin/multigpu.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | 3 | 4 | def is_multi_gpu(net): 5 | return isinstance(net, (MultiGPU, nn.DataParallel)) 6 | 7 | 8 | class MultiGPU(nn.DataParallel): 9 | """Wraps a network to allow simple multi-GPU training.""" 10 | def __getattr__(self, item): 11 | try: 12 | return super().__getattr__(item) 13 | except: 14 | pass 15 | return getattr(self.module, item) -------------------------------------------------------------------------------- /external/AR/ltr/admin/settings.py: -------------------------------------------------------------------------------- 1 | from ltr.admin.environment import env_settings 2 | 3 | 4 | class Settings: 5 | """ Training settings, e.g. the paths to datasets and networks.""" 6 | def __init__(self): 7 | self.set_default() 8 | 9 | def set_default(self): 10 | self.env = env_settings() 11 | self.use_gpu = True 12 | 13 | 14 | -------------------------------------------------------------------------------- /external/AR/ltr/admin/stats.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class StatValue: 4 | def __init__(self): 5 | self.clear() 6 | 7 | def reset(self): 8 | self.val = 0 9 | 10 | def clear(self): 11 | self.reset() 12 | self.history = [] 13 | 14 | def update(self, val): 15 | self.val = val 16 | self.history.append(self.val) 17 | 18 | 19 | class AverageMeter(object): 20 | """Computes and stores the average and current value""" 21 | def __init__(self): 22 | self.clear() 23 | self.has_new_data = False 24 | 25 | def reset(self): 26 | self.avg = 0 27 | self.val = 0 28 | self.sum = 0 29 | self.count = 0 30 | 31 | def clear(self): 32 | self.reset() 33 | self.history = [] 34 | 35 | def update(self, val, n=1): 36 | self.val = val 37 | self.sum += val * n 38 | self.count += n 39 | self.avg = self.sum / self.count 40 | 41 | def new_epoch(self): 42 | if self.count > 0: 43 | self.history.append(self.avg) 44 | self.reset() 45 | self.has_new_data = True 46 | else: 47 | self.has_new_data = False 48 | 49 | 50 | def topk_accuracy(output, target, topk=(1,)): 51 | """Computes the precision@k for the specified values of k""" 52 | single_input = not isinstance(topk, (tuple, list)) 53 | if single_input: 54 | topk = (topk,) 55 | 56 | maxk = max(topk) 57 | batch_size = target.size(0) 58 | 59 | _, pred = output.topk(maxk, 1, True, True) 60 | pred = pred.t() 61 | correct = pred.eq(target.view(1, -1).expand_as(pred)) 62 | 63 | res = [] 64 | for k in topk: 65 | correct_k = correct[:k].view(-1).float().sum(0, keepdim=True)[0] 66 | res.append(correct_k * 100.0 / batch_size) 67 | 68 | if single_input: 69 | return res[0] 70 | 71 | return res 72 | -------------------------------------------------------------------------------- /external/AR/ltr/admin/tensorboard.py: -------------------------------------------------------------------------------- 1 | import os 2 | from collections import OrderedDict 3 | try: 4 | from torch.utils.tensorboard import SummaryWriter 5 | except: 6 | print('WARNING: You are using tensorboardX instead sis you have a too old pytorch version.') 7 | from tensorboardX import SummaryWriter 8 | 9 | 10 | class TensorboardWriter: 11 | def __init__(self, directory, loader_names): 12 | self.directory = directory 13 | self.writer = OrderedDict({name: SummaryWriter(os.path.join(self.directory, name)) for name in loader_names}) 14 | 15 | def write_info(self, module_name, script_name, description): 16 | tb_info_writer = SummaryWriter(os.path.join(self.directory, 'info')) 17 | tb_info_writer.add_text('Modulet_name', module_name) 18 | tb_info_writer.add_text('Script_name', script_name) 19 | tb_info_writer.add_text('Description', description) 20 | tb_info_writer.close() 21 | 22 | def write_epoch(self, stats: OrderedDict, epoch: int, ind=-1): 23 | for loader_name, loader_stats in stats.items(): 24 | if loader_stats is None: 25 | continue 26 | for var_name, val in loader_stats.items(): 27 | if hasattr(val, 'history') and getattr(val, 'has_new_data', True): 28 | self.writer[loader_name].add_scalar(var_name, val.history[ind], epoch) -------------------------------------------------------------------------------- /external/AR/ltr/data/__init__.py: -------------------------------------------------------------------------------- 1 | from .loader import LTRLoader -------------------------------------------------------------------------------- /external/AR/ltr/dataset/__init__.py: -------------------------------------------------------------------------------- 1 | from .lasot import Lasot 2 | from .got10k import Got10k 3 | from .tracking_net import TrackingNet 4 | from .imagenetvid import ImagenetVID 5 | from .coco import MSCOCO 6 | from .coco_seq import MSCOCOSeq 7 | from .youtubevos import YouTubeVOS 8 | from .davis import Davis 9 | from .lvis import LVIS 10 | from .ecssd import ECSSD 11 | from .msra10k import MSRA10k 12 | from .hku_is import HKUIS 13 | from .sbd import SBD 14 | from .synthetic_video import SyntheticVideo 15 | from .synthetic_video_blend import SyntheticVideoBlend 16 | -------------------------------------------------------------------------------- /external/AR/ltr/dataset/base_image_dataset.py: -------------------------------------------------------------------------------- 1 | import torch.utils.data 2 | from ltr.data.image_loader import jpeg4py_loader 3 | 4 | 5 | class BaseImageDataset(torch.utils.data.Dataset): 6 | """ Base class for image datasets """ 7 | 8 | def __init__(self, name, root, image_loader=jpeg4py_loader): 9 | """ 10 | args: 11 | root - The root path to the dataset 12 | image_loader (jpeg4py_loader) - The function to read the images. jpeg4py (https://github.com/ajkxyz/jpeg4py) 13 | is used by default. 14 | """ 15 | self.name = name 16 | self.root = root 17 | self.image_loader = image_loader 18 | 19 | self.image_list = [] # Contains the list of sequences. 20 | self.class_list = [] 21 | 22 | def __len__(self): 23 | """ Returns size of the dataset 24 | returns: 25 | int - number of samples in the dataset 26 | """ 27 | return self.get_num_images() 28 | 29 | def __getitem__(self, index): 30 | """ Not to be used! Check get_frames() instead. 31 | """ 32 | return None 33 | 34 | def get_name(self): 35 | """ Name of the dataset 36 | 37 | returns: 38 | string - Name of the dataset 39 | """ 40 | raise NotImplementedError 41 | 42 | def get_num_images(self): 43 | """ Number of sequences in a dataset 44 | 45 | returns: 46 | int - number of sequences in the dataset.""" 47 | return len(self.image_list) 48 | 49 | def has_class_info(self): 50 | return False 51 | 52 | def get_class_name(self, image_id): 53 | return None 54 | 55 | def get_num_classes(self): 56 | return len(self.class_list) 57 | 58 | def get_class_list(self): 59 | return self.class_list 60 | 61 | def get_images_in_class(self, class_name): 62 | raise NotImplementedError 63 | 64 | def has_segmentation_info(self): 65 | return False 66 | 67 | def get_image_info(self, seq_id): 68 | """ Returns information about a particular image, 69 | 70 | args: 71 | seq_id - index of the image 72 | 73 | returns: 74 | Dict 75 | """ 76 | raise NotImplementedError 77 | 78 | def get_image(self, image_id, anno=None): 79 | """ Get a image 80 | 81 | args: 82 | image_id - index of image 83 | anno(None) - The annotation for the sequence (see get_sequence_info). If None, they will be loaded. 84 | 85 | returns: 86 | image - 87 | anno - 88 | dict - A dict containing meta information about the sequence, e.g. class of the target object. 89 | 90 | """ 91 | raise NotImplementedError 92 | 93 | -------------------------------------------------------------------------------- /external/AR/ltr/models/AR_seg_mask/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/ltr/models/AR_seg_mask/__init__.py -------------------------------------------------------------------------------- /external/AR/ltr/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/ltr/models/__init__.py -------------------------------------------------------------------------------- /external/AR/ltr/models/backbone/__init__.py: -------------------------------------------------------------------------------- 1 | from .resnet import resnet18, resnet50, resnet_baby 2 | from .resnet18_vggm import resnet18_vggmconv1 3 | -------------------------------------------------------------------------------- /external/AR/ltr/models/backbone/base.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | 4 | 5 | class Backbone(nn.Module): 6 | """Base class for backbone networks. Handles freezing layers etc. 7 | args: 8 | frozen_layers - Name of layers to freeze. Either list of strings, 'none' or 'all'. Default: 'none'. 9 | """ 10 | def __init__(self, frozen_layers=()): 11 | super().__init__() 12 | 13 | if isinstance(frozen_layers, str): 14 | if frozen_layers.lower() == 'none': 15 | frozen_layers = () 16 | elif frozen_layers.lower() != 'all': 17 | raise ValueError('Unknown option for frozen layers: \"{}\". Should be \"all\", \"none\" or list of layer names.'.format(frozen_layers)) 18 | 19 | self.frozen_layers = frozen_layers 20 | self._is_frozen_nograd = False 21 | 22 | 23 | def train(self, mode=True): 24 | super().train(mode) 25 | if mode == True: 26 | self._set_frozen_to_eval() 27 | if not self._is_frozen_nograd: 28 | self._set_frozen_to_nograd() 29 | self._is_frozen_nograd = True 30 | 31 | 32 | def _set_frozen_to_eval(self): 33 | if isinstance(self.frozen_layers, str) and self.frozen_layers.lower() == 'all': 34 | self.eval() 35 | else: 36 | for layer in self.frozen_layers: 37 | getattr(self, layer).eval() 38 | 39 | 40 | def _set_frozen_to_nograd(self): 41 | if isinstance(self.frozen_layers, str) and self.frozen_layers.lower() == 'all': 42 | for p in self.parameters(): 43 | p.requires_grad_(False) 44 | else: 45 | for layer in self.frozen_layers: 46 | for p in getattr(self, layer).parameters(): 47 | p.requires_grad_(False) -------------------------------------------------------------------------------- /external/AR/ltr/models/bbreg/__init__.py: -------------------------------------------------------------------------------- 1 | from .atom_iou_net import AtomIoUNet 2 | -------------------------------------------------------------------------------- /external/AR/ltr/models/head/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/ltr/models/head/__init__.py -------------------------------------------------------------------------------- /external/AR/ltr/models/layers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/ltr/models/layers/__init__.py -------------------------------------------------------------------------------- /external/AR/ltr/models/layers/activation.py: -------------------------------------------------------------------------------- 1 | import math 2 | import torch 3 | import torch.nn as nn 4 | import torch.nn.functional as F 5 | 6 | 7 | def softmax_reg(x: torch.Tensor, dim, reg=None): 8 | """Softmax with optinal denominator regularization.""" 9 | if reg is None: 10 | return torch.softmax(x, dim=dim) 11 | dim %= x.dim() 12 | if isinstance(reg, (float, int)): 13 | reg = x.new_tensor([reg]) 14 | reg = reg.expand([1 if d==dim else x.shape[d] for d in range(x.dim())]) 15 | x = torch.cat((x, reg), dim=dim) 16 | return torch.softmax(x, dim=dim)[[slice(-1) if d==dim else slice(None) for d in range(x.dim())]] 17 | 18 | 19 | 20 | class MLU(nn.Module): 21 | r"""MLU activation 22 | """ 23 | def __init__(self, min_val, inplace=False): 24 | super().__init__() 25 | self.min_val = min_val 26 | self.inplace = inplace 27 | 28 | def forward(self, input): 29 | return F.elu(F.leaky_relu(input, 1/self.min_val, inplace=self.inplace), self.min_val, inplace=self.inplace) 30 | 31 | 32 | class LeakyReluPar(nn.Module): 33 | r"""LeakyRelu parametric activation 34 | """ 35 | 36 | def forward(self, x, a): 37 | return (1.0 - a)/2.0 * torch.abs(x) + (1.0 + a)/2.0 * x 38 | 39 | class LeakyReluParDeriv(nn.Module): 40 | r"""Derivative of the LeakyRelu parametric activation, wrt x. 41 | """ 42 | 43 | def forward(self, x, a): 44 | return (1.0 - a)/2.0 * torch.sign(x.detach()) + (1.0 + a)/2.0 45 | 46 | 47 | class BentIdentPar(nn.Module): 48 | r"""BentIdent parametric activation 49 | """ 50 | def __init__(self, b=1.0): 51 | super().__init__() 52 | self.b = b 53 | 54 | def forward(self, x, a): 55 | return (1.0 - a)/2.0 * (torch.sqrt(x*x + 4.0*self.b*self.b) - 2.0*self.b) + (1.0 + a)/2.0 * x 56 | 57 | 58 | class BentIdentParDeriv(nn.Module): 59 | r"""BentIdent parametric activation deriv 60 | """ 61 | def __init__(self, b=1.0): 62 | super().__init__() 63 | self.b = b 64 | 65 | def forward(self, x, a): 66 | return (1.0 - a)/2.0 * (x / torch.sqrt(x*x + 4.0*self.b*self.b)) + (1.0 + a)/2.0 67 | 68 | -------------------------------------------------------------------------------- /external/AR/ltr/models/layers/blocks.py: -------------------------------------------------------------------------------- 1 | from torch import nn 2 | 3 | 4 | def conv_block(in_planes, out_planes, kernel_size=3, stride=1, padding=1, dilation=1, bias=True, 5 | batch_norm=True, relu=True, padding_mode='zeros'): 6 | layers = [] 7 | assert padding_mode == 'zeros' or padding_mode == 'replicate' 8 | 9 | if padding_mode == 'replicate' and padding > 0: 10 | assert isinstance(padding, int) 11 | layers.append(nn.ReflectionPad2d(padding)) 12 | padding = 0 13 | 14 | layers.append(nn.Conv2d(in_planes, out_planes, kernel_size=kernel_size, stride=stride, 15 | padding=padding, dilation=dilation, bias=bias)) 16 | if batch_norm: 17 | layers.append(nn.BatchNorm2d(out_planes)) 18 | if relu: 19 | layers.append(nn.ReLU(inplace=True)) 20 | return nn.Sequential(*layers) 21 | 22 | 23 | class LinearBlock(nn.Module): 24 | def __init__(self, in_planes, out_planes, input_sz, bias=True, batch_norm=True, relu=True): 25 | super().__init__() 26 | self.linear = nn.Linear(in_planes*input_sz*input_sz, out_planes, bias=bias) 27 | self.bn = nn.BatchNorm2d(out_planes) if batch_norm else None 28 | self.relu = nn.ReLU(inplace=True) if relu else None 29 | 30 | def forward(self, x): 31 | x = self.linear(x.reshape(x.shape[0], -1)) 32 | if self.bn is not None: 33 | x = self.bn(x.reshape(x.shape[0], x.shape[1], 1, 1)) 34 | if self.relu is not None: 35 | x = self.relu(x) 36 | return x.reshape(x.shape[0], -1) -------------------------------------------------------------------------------- /external/AR/ltr/models/layers/distance.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | import torch.nn.functional as F 4 | 5 | 6 | class DistanceMap(nn.Module): 7 | """Generate a distance map from a origin center location. 8 | args: 9 | num_bins: Number of bins in the map. 10 | bin_displacement: Displacement of the bins. 11 | """ 12 | def __init__(self, num_bins, bin_displacement=1.0): 13 | super().__init__() 14 | self.num_bins = num_bins 15 | self.bin_displacement = bin_displacement 16 | 17 | def forward(self, center, output_sz): 18 | """Create the distance map. 19 | args: 20 | center: Torch tensor with (y,x) center position. Dims (batch, 2) 21 | output_sz: Size of output distance map. 2-dimensional tuple.""" 22 | 23 | center = center.view(-1,2) 24 | 25 | bin_centers = torch.arange(self.num_bins, dtype=torch.float32, device=center.device).view(1, -1, 1, 1) 26 | 27 | k0 = torch.arange(output_sz[0], dtype=torch.float32, device=center.device).view(1,1,-1,1) 28 | k1 = torch.arange(output_sz[1], dtype=torch.float32, device=center.device).view(1,1,1,-1) 29 | 30 | d0 = k0 - center[:,0].view(-1,1,1,1) 31 | d1 = k1 - center[:,1].view(-1,1,1,1) 32 | 33 | dist = torch.sqrt(d0*d0 + d1*d1) 34 | bin_diff = dist / self.bin_displacement - bin_centers 35 | 36 | bin_val = torch.cat((F.relu(1.0 - torch.abs(bin_diff[:,:-1,:,:]), inplace=True), 37 | (1.0 + bin_diff[:,-1:,:,:]).clamp(0, 1)), dim=1) 38 | 39 | return bin_val 40 | 41 | 42 | -------------------------------------------------------------------------------- /external/AR/ltr/models/layers/normalization.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | import torch.nn.functional as F 4 | 5 | 6 | class InstanceL2Norm(nn.Module): 7 | """Instance L2 normalization. 8 | """ 9 | def __init__(self, size_average=True, eps=1e-5, scale=1.0): 10 | super().__init__() 11 | self.size_average = size_average 12 | self.eps = eps 13 | self.scale = scale 14 | 15 | def forward(self, input): 16 | if self.size_average: 17 | return input * (self.scale * ((input.shape[1] * input.shape[2] * input.shape[3]) / ( 18 | torch.sum((input * input).view(input.shape[0], 1, 1, -1), dim=3, keepdim=True) + self.eps)).sqrt()) 19 | else: 20 | return input * (self.scale / (torch.sum((input * input).view(input.shape[0], 1, 1, -1), dim=3, keepdim=True) + self.eps).sqrt()) 21 | 22 | -------------------------------------------------------------------------------- /external/AR/ltr/models/layers/transform.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | import torch.nn.functional as F 4 | from collections import OrderedDict 5 | 6 | 7 | def interpolate(x, sz): 8 | """Interpolate 4D tensor x to size sz.""" 9 | sz = sz.tolist() if torch.is_tensor(sz) else sz 10 | return F.interpolate(x, sz, mode='bilinear', align_corners=False) if x.shape[-2:] != sz else x 11 | 12 | 13 | class InterpCat(nn.Module): 14 | """Interpolate and concatenate features of different resolutions.""" 15 | 16 | def forward(self, input): 17 | if isinstance(input, (dict, OrderedDict)): 18 | input = list(input.values()) 19 | 20 | output_shape = None 21 | for x in input: 22 | if output_shape is None or output_shape[0] > x.shape[-2]: 23 | output_shape = x.shape[-2:] 24 | 25 | return torch.cat([interpolate(x, output_shape) for x in input], dim=-3) 26 | -------------------------------------------------------------------------------- /external/AR/ltr/models/loss/__init__.py: -------------------------------------------------------------------------------- 1 | from .target_classification import LBHinge 2 | -------------------------------------------------------------------------------- /external/AR/ltr/models/loss/kl_regression.py: -------------------------------------------------------------------------------- 1 | import math 2 | import torch 3 | import torch.nn as nn 4 | from torch.nn import functional as F 5 | 6 | 7 | class KLRegression(nn.Module): 8 | """KL-divergence loss for probabilistic regression. 9 | It is computed using Monte Carlo (MC) samples from an arbitrary distribution.""" 10 | 11 | def __init__(self, eps=0.0): 12 | super().__init__() 13 | self.eps = eps 14 | 15 | def forward(self, scores, sample_density, gt_density, mc_dim=-1): 16 | """Args: 17 | scores: predicted score values 18 | sample_density: probability density of the sample distribution 19 | gt_density: probability density of the ground truth distribution 20 | mc_dim: dimension of the MC samples""" 21 | 22 | exp_val = scores - torch.log(sample_density + self.eps) 23 | 24 | L = torch.logsumexp(exp_val, dim=mc_dim) - math.log(scores.shape[mc_dim]) - \ 25 | torch.mean(scores * (gt_density / (sample_density + self.eps)), dim=mc_dim) 26 | 27 | return L.mean() 28 | 29 | 30 | class MLRegression(nn.Module): 31 | """Maximum likelihood loss for probabilistic regression. 32 | It is computed using Monte Carlo (MC) samples from an arbitrary distribution.""" 33 | 34 | def __init__(self, eps=0.0): 35 | super().__init__() 36 | self.eps = eps 37 | 38 | def forward(self, scores, sample_density, gt_density=None, mc_dim=-1): 39 | """Args: 40 | scores: predicted score values. First sample must be ground-truth 41 | sample_density: probability density of the sample distribution 42 | gt_density: not used 43 | mc_dim: dimension of the MC samples. Only mc_dim=1 supported""" 44 | 45 | assert mc_dim == 1 46 | assert (sample_density[:,0,...] == -1).all() 47 | 48 | exp_val = scores[:, 1:, ...] - torch.log(sample_density[:, 1:, ...] + self.eps) 49 | 50 | L = torch.logsumexp(exp_val, dim=mc_dim) - math.log(scores.shape[mc_dim] - 1) - scores[:, 0, ...] 51 | loss = L.mean() 52 | return loss 53 | 54 | 55 | class KLRegressionGrid(nn.Module): 56 | """KL-divergence loss for probabilistic regression. 57 | It is computed using the grid integration strategy.""" 58 | 59 | def forward(self, scores, gt_density, grid_dim=-1, grid_scale=1.0): 60 | """Args: 61 | scores: predicted score values 62 | gt_density: probability density of the ground truth distribution 63 | grid_dim: dimension(s) of the grid 64 | grid_scale: area of one grid cell""" 65 | 66 | score_corr = grid_scale * torch.sum(scores * gt_density, dim=grid_dim) 67 | 68 | L = torch.logsumexp(scores, dim=grid_dim) + math.log(grid_scale) - score_corr 69 | 70 | return L.mean() 71 | -------------------------------------------------------------------------------- /external/AR/ltr/models/loss/target_classification.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | import torch 3 | from torch.nn import functional as F 4 | 5 | 6 | class LBHinge(nn.Module): 7 | """Loss that uses a 'hinge' on the lower bound. 8 | This means that for samples with a label value smaller than the threshold, the loss is zero if the prediction is 9 | also smaller than that threshold. 10 | args: 11 | error_matric: What base loss to use (MSE by default). 12 | threshold: Threshold to use for the hinge. 13 | clip: Clip the loss if it is above this value. 14 | """ 15 | def __init__(self, error_metric=nn.MSELoss(), threshold=None, clip=None): 16 | super().__init__() 17 | self.error_metric = error_metric 18 | self.threshold = threshold if threshold is not None else -100 19 | self.clip = clip 20 | 21 | def forward(self, prediction, label, target_bb=None): 22 | negative_mask = (label < self.threshold).float() 23 | positive_mask = (1.0 - negative_mask) 24 | 25 | prediction = negative_mask * F.relu(prediction) + positive_mask * prediction 26 | 27 | loss = self.error_metric(prediction, positive_mask * label) 28 | 29 | if self.clip is not None: 30 | loss = torch.min(loss, torch.tensor([self.clip], device=loss.device)) 31 | return loss 32 | -------------------------------------------------------------------------------- /external/AR/ltr/models/meta/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/ltr/models/meta/__init__.py -------------------------------------------------------------------------------- /external/AR/ltr/models/target_classifier/__init__.py: -------------------------------------------------------------------------------- 1 | from .linear_filter import LinearFilter 2 | -------------------------------------------------------------------------------- /external/AR/ltr/models/tracking/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/ltr/models/tracking/__init__.py -------------------------------------------------------------------------------- /external/AR/ltr/run_training.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import argparse 4 | import importlib 5 | import multiprocessing 6 | import cv2 as cv 7 | import torch.backends.cudnn 8 | 9 | env_path = os.path.join(os.path.dirname(__file__), '..') 10 | if env_path not in sys.path: 11 | sys.path.append(env_path) 12 | 13 | import ltr.admin.settings as ws_settings 14 | 15 | 16 | def run_training(train_module, train_name, cudnn_benchmark=True): 17 | """Run a train scripts in train_settings. 18 | args: 19 | train_module: Name of module in the "train_settings/" folder. 20 | train_name: Name of the train settings file. 21 | cudnn_benchmark: Use cudnn benchmark or not (default is True). 22 | """ 23 | 24 | # This is needed to avoid strange crashes related to opencv 25 | cv.setNumThreads(0) 26 | 27 | torch.backends.cudnn.benchmark = cudnn_benchmark 28 | 29 | print('Training: {} {}'.format(train_module, train_name)) 30 | 31 | settings = ws_settings.Settings() 32 | settings.module_name = train_module 33 | settings.script_name = train_name 34 | settings.project_path = 'ltr/{}/{}'.format(train_module, train_name) 35 | 36 | expr_module = importlib.import_module('ltr.train_settings.{}.{}'.format(train_module, train_name)) 37 | expr_func = getattr(expr_module, 'run') 38 | 39 | expr_func(settings) 40 | 41 | 42 | def main(): 43 | parser = argparse.ArgumentParser(description='Run a train scripts in train_settings.') 44 | parser.add_argument('train_module', type=str, help='Name of module in the "train_settings/" folder.') 45 | parser.add_argument('train_name', type=str, help='Name of the train settings file.') 46 | parser.add_argument('--cudnn_benchmark', type=bool, default=True, help='Set cudnn benchmark on (1) or off (0) (default is on).') 47 | 48 | args = parser.parse_args() 49 | 50 | run_training(args.train_module, args.train_name, args.cudnn_benchmark) 51 | 52 | 53 | if __name__ == '__main__': 54 | multiprocessing.set_start_method('spawn', force=True) 55 | main() 56 | -------------------------------------------------------------------------------- /external/AR/ltr/train_settings/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/ltr/train_settings/__init__.py -------------------------------------------------------------------------------- /external/AR/ltr/train_settings/bbreg/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/ltr/train_settings/bbreg/__init__.py -------------------------------------------------------------------------------- /external/AR/ltr/train_settings/dimp/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/ltr/train_settings/dimp/__init__.py -------------------------------------------------------------------------------- /external/AR/ltr/trainers/__init__.py: -------------------------------------------------------------------------------- 1 | from .base_trainer import BaseTrainer 2 | from .ltr_trainer import LTRTrainer -------------------------------------------------------------------------------- /external/AR/pytracking/VOT/tracker_DiMP.m: -------------------------------------------------------------------------------- 1 | % Set path to the python in the pytracking conda environment 2 | python_path = 'PATH_TO_CONDA_INSTALLATION/envs/pytracking/bin/python'; 3 | 4 | % Set path to pytracking 5 | pytracking_path = 'PATH_TO_VISIONML/pytracking'; 6 | 7 | % Set path to trax installation. Check 8 | % https://trax.readthedocs.io/en/latest/tutorial_compiling.html for 9 | % compilation information 10 | trax_path = 'PATH_TO_VOT_TOOLKIT/native/trax'; 11 | 12 | tracker_name = 'dimp'; % Name of the tracker to evaluate 13 | runfile_name = 'dimp18_vot'; % Name of the parameter file to use 14 | debug = 0; 15 | 16 | %% 17 | tracker_label = [tracker_name, '_', runfile_name]; 18 | 19 | % Generate python command 20 | tracker_command = sprintf(['%s -c "import sys; sys.path.append(''%s'');', ... 21 | 'sys.path.append(''%s/support/python'');', ... 22 | 'import run_vot;', ... 23 | 'run_vot.run_vot(''%s'', ''%s'', debug=%d)"'],... 24 | python_path, pytracking_path, trax_path, ... 25 | tracker_name, runfile_name, debug); 26 | 27 | 28 | tracker_interpreter = python_path; 29 | 30 | tracker_linkpath = {[trax_path, '/build'],... 31 | [trax_path, '/build/support/client'],... 32 | [trax_path, '/build/support/opencv']}; 33 | -------------------------------------------------------------------------------- /external/AR/pytracking/VOT/trackers.ini: -------------------------------------------------------------------------------- 1 | [DiMP] # 2 | label = DiMP 3 | protocol = traxpython 4 | 5 | command = run_vot; run_vot.run_vot2020('dimp', 'dimp50') # Set the tracker name and the parameter name 6 | 7 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 8 | paths = PATH_TO_PYTRACKING 9 | 10 | # Additional environment paths 11 | #env_PATH = ;${PATH} 12 | 13 | -------------------------------------------------------------------------------- /external/AR/pytracking/VOT2020_super_only_mask_384_HP/dimp_alpha_065.py: -------------------------------------------------------------------------------- 1 | from pytracking.VOT2020_super_only_mask_384_HP.dimp_alpha_seg_class import run_vot_exp 2 | import os 3 | os.environ['CUDA_VISIBLE_DEVICES'] = '1' 4 | # run_vot_exp('dimp','dimp50_vot19','SEbcm',0.60,VIS=False) 5 | run_vot_exp('dimp','super_dimp','ARcm_coco_seg_only_mask_384',0.65,VIS=False) 6 | # run_vot_exp('dimp','super_dimp','ARcm_coco_seg_only_mask_384',0.65,VIS=True) -------------------------------------------------------------------------------- /external/AR/pytracking/VOT2020_super_only_mask_384_HP/stark_s50_ar.py: -------------------------------------------------------------------------------- 1 | from pytracking.VOT2020_super_only_mask_384_HP.stark_alpha_seg_class import run_vot_exp 2 | import os 3 | os.environ['CUDA_VISIBLE_DEVICES'] = '3' 4 | run_vot_exp('stark_s', 'baseline', 5 | 'ARcm_coco_seg_only_mask_384', 0.65, VIS=False) 6 | -------------------------------------------------------------------------------- /external/AR/pytracking/VOT2020_super_only_mask_384_HP/stark_st101_ar.py: -------------------------------------------------------------------------------- 1 | from pytracking.VOT2020_super_only_mask_384_HP.stark_alpha_seg_class import run_vot_exp 2 | import os 3 | os.environ['CUDA_VISIBLE_DEVICES'] = '2' 4 | run_vot_exp('stark_st', 'baseline_R101', 5 | 'ARcm_coco_seg_only_mask_384', 0.65, VIS=False) 6 | -------------------------------------------------------------------------------- /external/AR/pytracking/VOT2020_super_only_mask_384_HP/stark_st50_ar.py: -------------------------------------------------------------------------------- 1 | from pytracking.VOT2020_super_only_mask_384_HP.stark_alpha_seg_class import run_vot_exp 2 | import os 3 | os.environ['CUDA_VISIBLE_DEVICES'] = '1' 4 | run_vot_exp('stark_st', 'baseline', 5 | 'ARcm_coco_seg_only_mask_384', 0.65, VIS=False) 6 | -------------------------------------------------------------------------------- /external/AR/pytracking/__init__.py: -------------------------------------------------------------------------------- 1 | from pytracking.libs import TensorList, TensorDict 2 | -------------------------------------------------------------------------------- /external/AR/pytracking/analysis/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/pytracking/analysis/__init__.py -------------------------------------------------------------------------------- /external/AR/pytracking/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | from .data import Sequence 2 | from .tracker import Tracker, trackerlist 3 | from .datasets import get_dataset -------------------------------------------------------------------------------- /external/AR/pytracking/evaluation/environment.py: -------------------------------------------------------------------------------- 1 | import importlib 2 | import os 3 | 4 | 5 | class EnvSettings: 6 | def __init__(self): 7 | pytracking_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) 8 | 9 | self.results_path = '{}/tracking_results/'.format(pytracking_path) 10 | self.segmentation_path = '{}/segmentation_results/'.format(pytracking_path) 11 | self.network_path = '{}/networks/'.format(pytracking_path) 12 | self.result_plot_path = '{}/result_plots/'.format(pytracking_path) 13 | self.otb_path = '' 14 | self.nfs_path = '' 15 | self.uav_path = '' 16 | self.tpl_path = '' 17 | self.vot_path = '' 18 | self.got10k_path = '' 19 | self.lasot_path = '' 20 | self.trackingnet_path = '' 21 | self.davis_dir = '' 22 | self.youtubevos_dir = '' 23 | 24 | self.got_packed_results_path = '' 25 | self.got_reports_path = '' 26 | self.tn_packed_results_path = '' 27 | 28 | 29 | def create_default_local_file(): 30 | comment = {'results_path': 'Where to store tracking results', 31 | 'network_path': 'Where tracking networks are stored.'} 32 | 33 | path = os.path.join(os.path.dirname(__file__), 'local.py') 34 | with open(path, 'w') as f: 35 | settings = EnvSettings() 36 | 37 | f.write('from pytracking.evaluation.environment import EnvSettings\n\n') 38 | f.write('def local_env_settings():\n') 39 | f.write(' settings = EnvSettings()\n\n') 40 | f.write(' # Set your local paths here.\n\n') 41 | 42 | for attr in dir(settings): 43 | comment_str = None 44 | if attr in comment: 45 | comment_str = comment[attr] 46 | attr_val = getattr(settings, attr) 47 | if not attr.startswith('__') and not callable(attr_val): 48 | if comment_str is None: 49 | f.write(' settings.{} = \'{}\'\n'.format(attr, attr_val)) 50 | else: 51 | f.write(' settings.{} = \'{}\' # {}\n'.format(attr, attr_val, comment_str)) 52 | f.write('\n return settings\n\n') 53 | 54 | 55 | def env_settings(): 56 | env_module_name = 'pytracking.evaluation.local' 57 | try: 58 | env_module = importlib.import_module(env_module_name) 59 | return env_module.local_env_settings() 60 | except: 61 | env_file = os.path.join(os.path.dirname(__file__), 'local.py') 62 | 63 | # Create a default file 64 | create_default_local_file() 65 | raise RuntimeError('YOU HAVE NOT SETUP YOUR local.py!!!\n Go to "{}" and set all the paths you need. ' 66 | 'Then try to run again.'.format(env_file)) -------------------------------------------------------------------------------- /external/AR/pytracking/evaluation/got10kdataset.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pytracking.evaluation.data import Sequence, BaseDataset, SequenceList 3 | from pytracking.utils.load_text import load_text 4 | import os 5 | 6 | 7 | class GOT10KDataset(BaseDataset): 8 | """ GOT-10k dataset. 9 | 10 | Publication: 11 | GOT-10k: A Large High-Diversity Benchmark for Generic Object Tracking in the Wild 12 | Lianghua Huang, Xin Zhao, and Kaiqi Huang 13 | arXiv:1810.11981, 2018 14 | https://arxiv.org/pdf/1810.11981.pdf 15 | 16 | Download dataset from http://got-10k.aitestunion.com/downloads 17 | """ 18 | def __init__(self, split): 19 | super().__init__() 20 | # Split can be test, val, or ltrval (a validation split consisting of videos from the official train set) 21 | if split == 'test' or split == 'val': 22 | self.base_path = os.path.join(self.env_settings.got10k_path, split) 23 | else: 24 | self.base_path = os.path.join(self.env_settings.got10k_path, 'train') 25 | 26 | self.sequence_list = self._get_sequence_list(split) 27 | self.split = split 28 | 29 | def get_sequence_list(self): 30 | return SequenceList([self._construct_sequence(s) for s in self.sequence_list]) 31 | 32 | def _construct_sequence(self, sequence_name): 33 | anno_path = '{}/{}/groundtruth.txt'.format(self.base_path, sequence_name) 34 | 35 | ground_truth_rect = load_text(str(anno_path), delimiter=',', dtype=np.float64) 36 | 37 | frames_path = '{}/{}'.format(self.base_path, sequence_name) 38 | frame_list = [frame for frame in os.listdir(frames_path) if frame.endswith(".jpg")] 39 | frame_list.sort(key=lambda f: int(f[:-4])) 40 | frames_list = [os.path.join(frames_path, frame) for frame in frame_list] 41 | 42 | return Sequence(sequence_name, frames_list, 'got10k', ground_truth_rect.reshape(-1, 4)) 43 | 44 | def __len__(self): 45 | return len(self.sequence_list) 46 | 47 | def _get_sequence_list(self, split): 48 | with open('{}/list.txt'.format(self.base_path)) as f: 49 | sequence_list = f.read().splitlines() 50 | 51 | if split == 'ltrval': 52 | with open('{}/got10k_val_split.txt'.format(self.env_settings.dataspec_path)) as f: 53 | seq_ids = f.read().splitlines() 54 | 55 | sequence_list = [sequence_list[int(x)] for x in seq_ids] 56 | return sequence_list 57 | -------------------------------------------------------------------------------- /external/AR/pytracking/evaluation/mobifacedataset.py: -------------------------------------------------------------------------------- 1 | from pytracking.evaluation.data import Sequence, BaseDataset, SequenceList 2 | import glob 3 | import numpy as np 4 | import os.path as osp 5 | from collections import OrderedDict 6 | import pandas as pd 7 | 8 | 9 | class MobifaceDataset(BaseDataset): 10 | """ Mobiface dataset. 11 | Publication: 12 | MobiFace: A Novel Dataset for Mobile Face Tracking in the Wild 13 | Yiming Lin, Shiyang Cheng, Jie Shen, Maja Pantic 14 | arXiv:1805.09749, 2018 15 | https://arxiv.org/pdf/1805.09749v2 16 | 17 | Download dataset from https://mobiface.github.io/ 18 | """ 19 | def __init__(self, split): 20 | """ 21 | args: 22 | split - Split to use. Can be i) 'train': official training set, ii) 'test': official test set, iii) 'all': whole dataset. 23 | """ 24 | super().__init__() 25 | self.base_path = self.env_settings.mobiface_path 26 | self.sequence_list = self._get_sequence_list(split) 27 | self.split = split 28 | 29 | def get_sequence_list(self): 30 | return SequenceList([self._construct_sequence(s) for s in self.sequence_list]) 31 | 32 | def _get_sequence_list(self, split): 33 | 34 | self.train_meta_fn = osp.join(self.base_path, 'train.meta.csv') 35 | self.test_meta_fn = osp.join(self.base_path, 'test.meta.csv') 36 | self.train_meta = pd.read_csv(self.train_meta_fn,index_col=0).transpose().to_dict() 37 | self.test_meta = pd.read_csv(self.test_meta_fn,index_col=0).transpose().to_dict() 38 | if split == 'train': 39 | self.meta = self.train_meta 40 | elif split == 'test': 41 | self.meta = self.test_meta 42 | else: 43 | self.meta = {**self.train_meta, **self.test_meta} # In Python 3.5 or greater 44 | self.meta = OrderedDict(sorted(self.meta.items(), key=lambda t: t[0])) 45 | self.anno_files = [] 46 | for k,v in self.meta.items(): 47 | if k in self.train_meta.keys(): 48 | self.anno_files.append(osp.abspath(osp.join(self.base_path,'train', k+'.annot.csv'))) 49 | else: 50 | self.anno_files.append(osp.abspath(osp.join(self.base_path,'test', k+'.annot.csv'))) 51 | self.seq_names = sorted(list(self.meta.keys())) 52 | self.seq_dirs = [fn[:-len('.annot.csv')] for fn in self.anno_files] 53 | return self.seq_names 54 | 55 | def _construct_sequence(self, sequence_name): 56 | index = self.seq_names.index(sequence_name) 57 | img_files = sorted(glob.glob(self.seq_dirs[index]+'/*.jpg')) 58 | if len(img_files) == 0: 59 | img_files = sorted(glob.glob(self.seq_dirs[index]+'.png')) 60 | with open(self.anno_files[index], 'r') as f: 61 | anno = np.loadtxt(f, delimiter=',', skiprows=1, dtype=int) 62 | anno = anno[:,1:] 63 | assert anno.shape[1] == 4 64 | 65 | return Sequence(sequence_name, img_files, anno.reshape(-1, 4)) 66 | 67 | def __len__(self): 68 | return len(self.sequence_list) 69 | -------------------------------------------------------------------------------- /external/AR/pytracking/evaluation/trackingnetdataset.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pytracking.evaluation.data import Sequence, BaseDataset, SequenceList 3 | import os 4 | from pytracking.utils.load_text import load_text 5 | 6 | 7 | class TrackingNetDataset(BaseDataset): 8 | """ TrackingNet test set. 9 | 10 | Publication: 11 | TrackingNet: A Large-Scale Dataset and Benchmark for Object Tracking in the Wild. 12 | Matthias Mueller,Adel Bibi, Silvio Giancola, Salman Al-Subaihi and Bernard Ghanem 13 | ECCV, 2018 14 | https://ivul.kaust.edu.sa/Documents/Publications/2018/TrackingNet%20A%20Large%20Scale%20Dataset%20and%20Benchmark%20for%20Object%20Tracking%20in%20the%20Wild.pdf 15 | 16 | Download the dataset using the toolkit https://github.com/SilvioGiancola/TrackingNet-devkit. 17 | """ 18 | def __init__(self): 19 | super().__init__() 20 | self.base_path = self.env_settings.trackingnet_path 21 | 22 | sets = 'TEST' 23 | if not isinstance(sets, (list, tuple)): 24 | if sets == 'TEST': 25 | sets = ['TEST'] 26 | elif sets == 'TRAIN': 27 | sets = ['TRAIN_{}'.format(i) for i in range(5)] 28 | 29 | self.sequence_list = self._list_sequences(self.base_path, sets) 30 | 31 | def get_sequence_list(self): 32 | return SequenceList([self._construct_sequence(set, seq_name) for set, seq_name in self.sequence_list]) 33 | 34 | def _construct_sequence(self, set, sequence_name): 35 | anno_path = '{}/{}/anno/{}.txt'.format(self.base_path, set, sequence_name) 36 | 37 | ground_truth_rect = load_text(str(anno_path), delimiter=',', dtype=np.float64, backend='numpy') 38 | 39 | frames_path = '{}/{}/frames/{}'.format(self.base_path, set, sequence_name) 40 | frame_list = [frame for frame in os.listdir(frames_path) if frame.endswith(".jpg")] 41 | frame_list.sort(key=lambda f: int(f[:-4])) 42 | frames_list = [os.path.join(frames_path, frame) for frame in frame_list] 43 | 44 | return Sequence(sequence_name, frames_list, 'trackingnet', ground_truth_rect.reshape(-1, 4)) 45 | 46 | def __len__(self): 47 | return len(self.sequence_list) 48 | 49 | def _list_sequences(self, root, set_ids): 50 | sequence_list = [] 51 | 52 | for s in set_ids: 53 | anno_dir = os.path.join(root, s, "anno") 54 | sequences_cur_set = [(s, os.path.splitext(f)[0]) for f in os.listdir(anno_dir) if f.endswith('.txt')] 55 | 56 | sequence_list += sequences_cur_set 57 | 58 | return sequence_list 59 | -------------------------------------------------------------------------------- /external/AR/pytracking/experiments/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/pytracking/experiments/__init__.py -------------------------------------------------------------------------------- /external/AR/pytracking/experiments/myexperiments.py: -------------------------------------------------------------------------------- 1 | from pytracking.evaluation import Tracker, get_dataset, trackerlist 2 | 3 | 4 | def atom_nfs_uav(): 5 | # Run three runs of ATOM on NFS and UAV datasets 6 | trackers = trackerlist('atom', 'default', range(3)) 7 | 8 | dataset = get_dataset('nfs', 'uav') 9 | return trackers, dataset 10 | 11 | 12 | def uav_test(): 13 | # Run DiMP18, ATOM and ECO on the UAV dataset 14 | trackers = trackerlist('dimp', 'dimp18', range(1)) + \ 15 | trackerlist('atom', 'default', range(1)) + \ 16 | trackerlist('eco', 'default', range(1)) 17 | 18 | dataset = get_dataset('uav') 19 | return trackers, dataset 20 | -------------------------------------------------------------------------------- /external/AR/pytracking/features/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/pytracking/features/__init__.py -------------------------------------------------------------------------------- /external/AR/pytracking/features/color.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from pytracking.features.featurebase import FeatureBase 3 | 4 | 5 | class RGB(FeatureBase): 6 | """RGB feature normalized to [-0.5, 0.5].""" 7 | def dim(self): 8 | return 3 9 | 10 | def stride(self): 11 | return self.pool_stride 12 | 13 | def extract(self, im: torch.Tensor): 14 | return im/255 - 0.5 15 | 16 | 17 | class Grayscale(FeatureBase): 18 | """Grayscale feature normalized to [-0.5, 0.5].""" 19 | def dim(self): 20 | return 1 21 | 22 | def stride(self): 23 | return self.pool_stride 24 | 25 | def extract(self, im: torch.Tensor): 26 | return torch.mean(im/255 - 0.5, 1, keepdim=True) 27 | -------------------------------------------------------------------------------- /external/AR/pytracking/features/net_wrappers.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from pytracking.utils.loading import load_network 3 | 4 | 5 | class NetWrapper: 6 | """Used for wrapping networks in pytracking. 7 | Network modules and functions can be accessed directly as if they were members of this class.""" 8 | _rec_iter=0 9 | def __init__(self, net_path, use_gpu=True, initialize=False, **kwargs): 10 | self.net_path = net_path 11 | self.use_gpu = use_gpu 12 | self.net = None 13 | self.net_kwargs = kwargs 14 | if initialize: 15 | self.initialize() 16 | 17 | def __getattr__(self, name): 18 | if self._rec_iter > 0: 19 | self._rec_iter = 0 20 | return None 21 | self._rec_iter += 1 22 | try: 23 | ret_val = getattr(self.net, name) 24 | except Exception as e: 25 | self._rec_iter = 0 26 | raise e 27 | self._rec_iter = 0 28 | return ret_val 29 | 30 | def load_network(self): 31 | self.net = load_network(self.net_path, **self.net_kwargs) 32 | if self.use_gpu: 33 | self.cuda() 34 | self.eval() 35 | 36 | def initialize(self): 37 | self.load_network() 38 | 39 | 40 | class NetWithBackbone(NetWrapper): 41 | """Wraps a network with a common backbone. 42 | Assumes the network have a 'extract_backbone_features(image)' function.""" 43 | 44 | def __init__(self, net_path, use_gpu=True, initialize=False, image_format='rgb', 45 | mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225), **kwargs): 46 | super().__init__(net_path, use_gpu, initialize, **kwargs) 47 | 48 | self.image_format = image_format 49 | self._mean = torch.Tensor(mean).view(1, -1, 1, 1) 50 | self._std = torch.Tensor(std).view(1, -1, 1, 1) 51 | 52 | def initialize(self, image_format='rgb', mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)): 53 | super().initialize() 54 | 55 | def preprocess_image(self, im: torch.Tensor): 56 | """Normalize the image with the mean and standard deviation used by the network.""" 57 | 58 | if self.image_format in ['rgb', 'bgr']: 59 | im = im/255 60 | 61 | if self.image_format in ['bgr', 'bgr255']: 62 | im = im[:, [2, 1, 0], :, :] 63 | im -= self._mean 64 | im /= self._std 65 | 66 | if self.use_gpu: 67 | im = im.cuda() 68 | 69 | return im 70 | 71 | def extract_backbone(self, im: torch.Tensor): 72 | """Extract backbone features from the network. 73 | Expects a float tensor image with pixel range [0, 255].""" 74 | im = self.preprocess_image(im) 75 | return self.net.extract_backbone_features(im) 76 | -------------------------------------------------------------------------------- /external/AR/pytracking/features/util.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from pytracking.features.featurebase import FeatureBase 3 | 4 | 5 | class Concatenate(FeatureBase): 6 | """A feature that concatenates other features. 7 | args: 8 | features: List of features to concatenate. 9 | """ 10 | def __init__(self, features, pool_stride = None, normalize_power = None, use_for_color = True, use_for_gray = True): 11 | super(Concatenate, self).__init__(pool_stride, normalize_power, use_for_color, use_for_gray) 12 | self.features = features 13 | 14 | self.input_stride = self.features[0].stride() 15 | 16 | for feat in self.features: 17 | if self.input_stride != feat.stride(): 18 | raise ValueError('Strides for the features must be the same for a bultiresolution feature.') 19 | 20 | def dim(self): 21 | return sum([f.dim() for f in self.features]) 22 | 23 | def stride(self): 24 | return self.pool_stride * self.input_stride 25 | 26 | def extract(self, im: torch.Tensor): 27 | return torch.cat([f.get_feature(im) for f in self.features], 1) -------------------------------------------------------------------------------- /external/AR/pytracking/libs/__init__.py: -------------------------------------------------------------------------------- 1 | from .tensorlist import TensorList 2 | from .tensordict import TensorDict -------------------------------------------------------------------------------- /external/AR/pytracking/libs/operation.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn.functional as F 3 | from pytracking.libs.tensorlist import tensor_operation, TensorList 4 | 5 | 6 | @tensor_operation 7 | def conv2d(input: torch.Tensor, weight: torch.Tensor, bias: torch.Tensor = None, stride=1, padding=0, dilation=1, groups=1, mode=None): 8 | """Standard conv2d. Returns the input if weight=None.""" 9 | 10 | if weight is None: 11 | return input 12 | 13 | ind = None 14 | if mode is not None: 15 | if padding != 0: 16 | raise ValueError('Cannot input both padding and mode.') 17 | if mode == 'same': 18 | padding = (weight.shape[2]//2, weight.shape[3]//2) 19 | if weight.shape[2] % 2 == 0 or weight.shape[3] % 2 == 0: 20 | ind = (slice(-1) if weight.shape[2] % 2 == 0 else slice(None), 21 | slice(-1) if weight.shape[3] % 2 == 0 else slice(None)) 22 | elif mode == 'valid': 23 | padding = (0, 0) 24 | elif mode == 'full': 25 | padding = (weight.shape[2]-1, weight.shape[3]-1) 26 | else: 27 | raise ValueError('Unknown mode for padding.') 28 | 29 | out = F.conv2d(input, weight, bias=bias, stride=stride, padding=padding, dilation=dilation, groups=groups) 30 | if ind is None: 31 | return out 32 | return out[:,:,ind[0],ind[1]] 33 | 34 | 35 | @tensor_operation 36 | def conv1x1(input: torch.Tensor, weight: torch.Tensor): 37 | """Do a convolution with a 1x1 kernel weights. Implemented with matmul, which can be faster than using conv.""" 38 | 39 | if weight is None: 40 | return input 41 | 42 | return torch.conv2d(input, weight) 43 | -------------------------------------------------------------------------------- /external/AR/pytracking/libs/tensordict.py: -------------------------------------------------------------------------------- 1 | from collections import OrderedDict 2 | import torch 3 | import copy 4 | 5 | 6 | class TensorDict(OrderedDict): 7 | """Container mainly used for dicts of torch tensors. Extends OrderedDict with pytorch functionality.""" 8 | 9 | def concat(self, other): 10 | """Concatenates two dicts without copying internal data.""" 11 | return TensorDict(self, **other) 12 | 13 | def copy(self): 14 | return TensorDict(super(TensorDict, self).copy()) 15 | 16 | def __deepcopy__(self, memodict={}): 17 | return TensorDict(copy.deepcopy(list(self), memodict)) 18 | 19 | def __getattr__(self, name): 20 | if not hasattr(torch.Tensor, name): 21 | raise AttributeError('\'TensorDict\' object has not attribute \'{}\''.format(name)) 22 | 23 | def apply_attr(*args, **kwargs): 24 | return TensorDict({n: getattr(e, name)(*args, **kwargs) if hasattr(e, name) else e for n, e in self.items()}) 25 | return apply_attr 26 | 27 | def attribute(self, attr: str, *args): 28 | return TensorDict({n: getattr(e, attr, *args) for n, e in self.items()}) 29 | 30 | def apply(self, fn, *args, **kwargs): 31 | return TensorDict({n: fn(e, *args, **kwargs) for n, e in self.items()}) 32 | 33 | @staticmethod 34 | def _iterable(a): 35 | return isinstance(a, (TensorDict, list)) 36 | 37 | -------------------------------------------------------------------------------- /external/AR/pytracking/parameter/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/pytracking/parameter/__init__.py -------------------------------------------------------------------------------- /external/AR/pytracking/parameter/atom/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/pytracking/parameter/atom/__init__.py -------------------------------------------------------------------------------- /external/AR/pytracking/parameter/dimp/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/pytracking/parameter/dimp/__init__.py -------------------------------------------------------------------------------- /external/AR/pytracking/parameter/dimp/dimp18.py: -------------------------------------------------------------------------------- 1 | from pytracking.utils import TrackerParams 2 | from pytracking.features.net_wrappers import NetWithBackbone 3 | 4 | def parameters(): 5 | params = TrackerParams() 6 | 7 | params.debug = 0 8 | params.visualization = False 9 | 10 | params.use_gpu = True 11 | 12 | params.image_sample_size = 18*16 13 | params.search_area_scale = 5 14 | 15 | # Learning parameters 16 | params.sample_memory_size = 50 17 | params.learning_rate = 0.01 18 | params.init_samples_minimum_weight = 0.25 19 | params.train_skipping = 20 20 | 21 | # Net optimization params 22 | params.update_classifier = True 23 | params.net_opt_iter = 10 24 | params.net_opt_update_iter = 2 25 | params.net_opt_hn_iter = 1 26 | 27 | # Detection parameters 28 | params.window_output = False 29 | 30 | # Init augmentation parameters 31 | params.use_augmentation = True 32 | params.augmentation = {'fliplr': True, 33 | 'rotate': [10, -10, 45, -45], 34 | 'blur': [(3,1), (1, 3), (2, 2)], 35 | 'relativeshift': [(0.6, 0.6), (-0.6, 0.6), (0.6, -0.6), (-0.6,-0.6)], 36 | 'dropout': (2, 0.2)} 37 | 38 | params.augmentation_expansion_factor = 2 39 | params.random_shift_factor = 1/3 40 | 41 | # Advanced localization parameters 42 | params.advanced_localization = True 43 | params.target_not_found_threshold = 0.25 44 | params.distractor_threshold = 0.8 45 | params.hard_negative_threshold = 0.5 46 | params.target_neighborhood_scale = 2.2 47 | params.dispalcement_scale = 0.8 48 | params.hard_negative_learning_rate = 0.02 49 | params.update_scale_when_uncertain = True 50 | 51 | # IoUnet parameters 52 | params.iounet_augmentation = False 53 | params.iounet_use_log_scale = True 54 | params.iounet_k = 3 55 | params.num_init_random_boxes = 9 56 | params.box_jitter_pos = 0.1 57 | params.box_jitter_sz = 0.5 58 | params.maximal_aspect_ratio = 6 59 | params.box_refinement_iter = 5 60 | params.box_refinement_step_length = 1 61 | params.box_refinement_step_decay = 1 62 | 63 | params.net = NetWithBackbone(net_path='dimp18.pth', 64 | use_gpu=params.use_gpu) 65 | 66 | params.vot_anno_conversion_type = 'preserve_area' 67 | 68 | return params 69 | -------------------------------------------------------------------------------- /external/AR/pytracking/parameter/dimp/dimp18_vot.py: -------------------------------------------------------------------------------- 1 | from pytracking.utils import TrackerParams 2 | from pytracking.features.net_wrappers import NetWithBackbone 3 | 4 | def parameters(): 5 | params = TrackerParams() 6 | 7 | params.debug = 0 8 | params.visualization = False 9 | 10 | params.use_gpu = True 11 | 12 | params.image_sample_size = 14 * 16 13 | params.search_area_scale = 4 14 | params.feature_size_odd = False 15 | 16 | # Learning parameters 17 | params.sample_memory_size = 250 18 | params.learning_rate = 0.0075 19 | params.init_samples_minimum_weight = 0.0 20 | params.train_skipping = 10 21 | 22 | # Net optimization params 23 | params.update_classifier = True 24 | params.net_opt_iter = 25 25 | params.net_opt_update_iter = 3 26 | params.net_opt_hn_iter = 3 27 | 28 | # Detection parameters 29 | params.window_output = True 30 | 31 | # Init augmentation parameters 32 | params.use_augmentation = True 33 | params.augmentation = {'fliplr': True, 34 | 'rotate': [5, -5, 10, -10, 20, -20, 30, -30, 45, -45, -60, 60], 35 | 'blur': [(2, 0.2), (0.2, 2), (3, 1), (1, 3), (2, 2)], 36 | 'relativeshift': [(0.6, 0.6), (-0.6, 0.6), (0.6, -0.6), (-0.6, -0.6)], 37 | 'dropout': (7, 0.2)} 38 | 39 | params.augmentation_expansion_factor = 2 40 | params.random_shift_factor = 1/3 41 | 42 | # Advanced localization parameters 43 | params.advanced_localization = True 44 | params.target_not_found_threshold = 0.0 45 | params.distractor_threshold = 100 46 | params.hard_negative_threshold = 0.45 47 | params.target_neighborhood_scale = 2.2 48 | params.dispalcement_scale = 0.7 49 | 50 | params.perform_hn_without_windowing = True 51 | 52 | params.hard_negative_learning_rate = 0.02 53 | params.update_scale_when_uncertain = True 54 | 55 | # IoUnet parameters 56 | params.iounet_augmentation = False 57 | params.iounet_use_log_scale = True 58 | params.iounet_k = 3 59 | params.num_init_random_boxes = 9 60 | params.box_jitter_pos = 0.1 61 | params.box_jitter_sz = 0.5 62 | params.maximal_aspect_ratio = 6 63 | params.box_refinement_iter = 5 64 | params.box_refinement_step_length = 1 65 | params.box_refinement_step_decay = 1 66 | 67 | params.net = NetWithBackbone(net_path='dimp18.pth', 68 | use_gpu=params.use_gpu) 69 | 70 | params.vot_anno_conversion_type = 'preserve_area' 71 | 72 | return params 73 | -------------------------------------------------------------------------------- /external/AR/pytracking/parameter/dimp/dimp50.py: -------------------------------------------------------------------------------- 1 | from pytracking.utils import TrackerParams 2 | from pytracking.features.net_wrappers import NetWithBackbone 3 | 4 | def parameters(): 5 | params = TrackerParams() 6 | 7 | params.debug = 0 8 | params.visualization = False 9 | 10 | params.use_gpu = True 11 | 12 | params.image_sample_size = 18*16 13 | params.search_area_scale = 5 14 | 15 | # Learning parameters 16 | params.sample_memory_size = 50 17 | params.learning_rate = 0.01 18 | params.init_samples_minimum_weight = 0.25 19 | params.train_skipping = 20 20 | 21 | # Net optimization params 22 | params.update_classifier = True 23 | params.net_opt_iter = 10 24 | params.net_opt_update_iter = 2 25 | params.net_opt_hn_iter = 1 26 | 27 | # Detection parameters 28 | params.window_output = False 29 | 30 | # Init augmentation parameters 31 | params.use_augmentation = True 32 | params.augmentation = {'fliplr': True, 33 | 'rotate': [10, -10, 45, -45], 34 | 'blur': [(3,1), (1, 3), (2, 2)], 35 | 'relativeshift': [(0.6, 0.6), (-0.6, 0.6), (0.6, -0.6), (-0.6,-0.6)], 36 | 'dropout': (2, 0.2)} 37 | 38 | params.augmentation_expansion_factor = 2 39 | params.random_shift_factor = 1/3 40 | 41 | # Advanced localization parameters 42 | params.advanced_localization = True 43 | params.target_not_found_threshold = 0.25 44 | params.distractor_threshold = 0.8 45 | params.hard_negative_threshold = 0.5 46 | params.target_neighborhood_scale = 2.2 47 | params.dispalcement_scale = 0.8 48 | params.hard_negative_learning_rate = 0.02 49 | params.update_scale_when_uncertain = True 50 | 51 | # IoUnet parameters 52 | params.iounet_augmentation = False 53 | params.iounet_use_log_scale = True 54 | params.iounet_k = 3 55 | params.num_init_random_boxes = 9 56 | params.box_jitter_pos = 0.1 57 | params.box_jitter_sz = 0.5 58 | params.maximal_aspect_ratio = 6 59 | params.box_refinement_iter = 5 60 | params.box_refinement_step_length = 1 61 | params.box_refinement_step_decay = 1 62 | 63 | params.net = NetWithBackbone(net_path='dimp50.pth', 64 | use_gpu=params.use_gpu) 65 | 66 | params.vot_anno_conversion_type = 'preserve_area' 67 | 68 | return params 69 | -------------------------------------------------------------------------------- /external/AR/pytracking/parameter/dimp/dimp50_vot.py: -------------------------------------------------------------------------------- 1 | from pytracking.utils import TrackerParams 2 | from pytracking.features.net_wrappers import NetWithBackbone 3 | 4 | def parameters(): 5 | params = TrackerParams() 6 | 7 | params.debug = 0 8 | params.visualization = False 9 | 10 | params.use_gpu = True 11 | 12 | params.image_sample_size = 14 * 16 13 | params.search_area_scale = 4 14 | 15 | # Learning parameters 16 | params.sample_memory_size = 250 17 | params.learning_rate = 0.0075 18 | params.init_samples_minimum_weight = 0.0 19 | params.train_skipping = 10 20 | 21 | # Net optimization params 22 | params.update_classifier = True 23 | params.net_opt_iter = 25 24 | params.net_opt_update_iter = 3 25 | params.net_opt_hn_iter = 3 26 | 27 | # Detection parameters 28 | params.window_output = True 29 | 30 | # Init augmentation parameters 31 | params.use_augmentation = True 32 | params.augmentation = {'fliplr': True, 33 | 'rotate': [5, -5, 10, -10, 20, -20, 30, -30, 45, -45, -60, 60], 34 | 'blur': [(2, 0.2), (0.2, 2), (3, 1), (1, 3), (2, 2)], 35 | 'relativeshift': [(0.6, 0.6), (-0.6, 0.6), (0.6, -0.6), (-0.6, -0.6)], 36 | 'dropout': (7, 0.2)} 37 | 38 | params.augmentation_expansion_factor = 2 39 | params.random_shift_factor = 1/3 40 | 41 | # Advanced localization parameters 42 | params.advanced_localization = True 43 | params.target_not_found_threshold = 0.0 44 | params.distractor_threshold = 100 45 | params.hard_negative_threshold = 0.45 46 | params.target_neighborhood_scale = 2.2 47 | params.dispalcement_scale = 0.7 48 | 49 | params.perform_hn_without_windowing = True 50 | 51 | params.hard_negative_learning_rate = 0.02 52 | params.update_scale_when_uncertain = True 53 | 54 | # IoUnet parameters 55 | params.iounet_augmentation = False 56 | params.iounet_use_log_scale = True 57 | params.iounet_k = 3 58 | params.num_init_random_boxes = 9 59 | params.box_jitter_pos = 0.1 60 | params.box_jitter_sz = 0.5 61 | params.maximal_aspect_ratio = 6 62 | params.box_refinement_iter = 5 63 | params.box_refinement_step_length = 1 64 | params.box_refinement_step_decay = 1 65 | 66 | params.net = NetWithBackbone(net_path='dimp50.pth', 67 | use_gpu=params.use_gpu) 68 | 69 | params.vot_anno_conversion_type = 'preserve_area' 70 | 71 | return params 72 | -------------------------------------------------------------------------------- /external/AR/pytracking/parameter/dimp/dimp50_vot19.py: -------------------------------------------------------------------------------- 1 | from pytracking.utils import TrackerParams 2 | from pytracking.features.net_wrappers import NetWithBackbone 3 | 4 | def parameters(): 5 | params = TrackerParams() 6 | 7 | params.debug = 0 8 | params.visualization = False 9 | 10 | params.use_gpu = True 11 | 12 | params.image_sample_size = 16 * 16 13 | params.search_area_scale = 4.5 14 | 15 | # Learning parameters 16 | params.sample_memory_size = 100 17 | params.learning_rate = 0.0075 18 | params.init_samples_minimum_weight = 0.0 19 | params.train_skipping = 10 20 | 21 | # Net optimization params 22 | params.update_classifier = True 23 | params.net_opt_iter = 15 24 | params.net_opt_update_iter = 2 25 | params.net_opt_hn_iter = 2 26 | 27 | # Detection parameters 28 | params.window_output = True 29 | 30 | # Init augmentation parameters 31 | params.use_augmentation = True 32 | params.augmentation = {'fliplr': True, 33 | 'rotate': [-5, 10, -30, 60], 34 | 'blur': [(2, 0.2), (1, 3)], 35 | 'relativeshift': [(0.6, 0.6), (-0.6, -0.6)], 36 | 'dropout': (3, 0.2)} 37 | 38 | params.augmentation_expansion_factor = 1.4 39 | params.random_shift_factor = 1/3 40 | 41 | # Advanced localization parameters 42 | params.advanced_localization = True 43 | params.target_not_found_threshold = 0.0 44 | params.distractor_threshold = 100 45 | params.hard_negative_threshold = 0.45 46 | params.target_neighborhood_scale = 2.2 47 | params.dispalcement_scale = 0.7 48 | 49 | params.perform_hn_without_windowing = True 50 | 51 | params.hard_negative_learning_rate = 0.02 52 | params.update_scale_when_uncertain = True 53 | 54 | # IoUnet parameters 55 | params.iounet_augmentation = False 56 | params.iounet_use_log_scale = True 57 | params.iounet_k = 3 58 | params.num_init_random_boxes = 9 59 | params.box_jitter_pos = 0.1 60 | params.box_jitter_sz = 0.5 61 | params.maximal_aspect_ratio = 6 62 | params.box_refinement_iter = 3 63 | params.box_refinement_step_length = 1 64 | params.box_refinement_step_decay = 1 65 | 66 | params.net = NetWithBackbone(net_path='dimp50.pth', 67 | use_gpu=params.use_gpu) 68 | 69 | params.vot_anno_conversion_type = 'preserve_area' 70 | 71 | return params 72 | -------------------------------------------------------------------------------- /external/AR/pytracking/parameter/dimp/prdimp18.py: -------------------------------------------------------------------------------- 1 | from pytracking.utils import TrackerParams 2 | from pytracking.features.net_wrappers import NetWithBackbone 3 | 4 | def parameters(): 5 | params = TrackerParams() 6 | 7 | params.debug = 0 8 | params.visualization = False 9 | 10 | params.use_gpu = True 11 | 12 | params.image_sample_size = 18*16 13 | params.search_area_scale = 5 14 | 15 | # Learning parameters 16 | params.sample_memory_size = 50 17 | params.learning_rate = 0.01 18 | params.init_samples_minimum_weight = 0.25 19 | params.train_skipping = 20 20 | 21 | # Net optimization params 22 | params.update_classifier = True 23 | params.net_opt_iter = 10 24 | params.net_opt_update_iter = 2 25 | params.net_opt_hn_iter = 1 26 | 27 | # Detection parameters 28 | params.window_output = False 29 | 30 | # Init augmentation parameters 31 | params.use_augmentation = True 32 | params.augmentation = {'fliplr': True, 33 | 'rotate': [10, -10, 45, -45], 34 | 'blur': [(3,1), (1, 3), (2, 2)], 35 | 'relativeshift': [(0.6, 0.6), (-0.6, 0.6), (0.6, -0.6), (-0.6,-0.6)], 36 | 'dropout': (2, 0.2)} 37 | 38 | params.augmentation_expansion_factor = 2 39 | params.random_shift_factor = 1/3 40 | 41 | # Advanced localization parameters 42 | params.advanced_localization = True 43 | params.score_preprocess = 'softmax' 44 | params.target_not_found_threshold = 0.04 45 | params.distractor_threshold = 0.8 46 | params.hard_negative_threshold = 0.5 47 | params.target_neighborhood_scale = 2.2 48 | params.dispalcement_scale = 0.8 49 | params.hard_negative_learning_rate = 0.02 50 | params.update_scale_when_uncertain = True 51 | 52 | # IoUnet parameters 53 | params.box_refinement_space = 'relative' 54 | params.iounet_augmentation = False # Use the augmented samples to compute the modulation vector 55 | params.iounet_k = 3 # Top-k average to estimate final box 56 | params.num_init_random_boxes = 9 # Num extra random boxes in addition to the classifier prediction 57 | params.box_jitter_pos = 0.1 # How much to jitter the translation for random boxes 58 | params.box_jitter_sz = 0.5 # How much to jitter the scale for random boxes 59 | params.maximal_aspect_ratio = 6 # Limit on the aspect ratio 60 | params.box_refinement_iter = 10 # Number of iterations for refining the boxes 61 | params.box_refinement_step_length = 2.5e-3 # 1 # Gradient step length in the bounding box refinement 62 | params.box_refinement_step_decay = 1 # Multiplicative step length decay (1 means no decay) 63 | 64 | params.net = NetWithBackbone(net_path='prdimp18.pth.tar', 65 | use_gpu=params.use_gpu) 66 | 67 | params.vot_anno_conversion_type = 'preserve_area' 68 | 69 | return params 70 | -------------------------------------------------------------------------------- /external/AR/pytracking/parameter/dimp/prdimp50.py: -------------------------------------------------------------------------------- 1 | from pytracking.utils import TrackerParams 2 | from pytracking.features.net_wrappers import NetWithBackbone 3 | 4 | def parameters(): 5 | params = TrackerParams() 6 | 7 | params.debug = 0 8 | params.visualization = False 9 | 10 | params.use_gpu = True 11 | 12 | params.image_sample_size = 22*16 13 | params.search_area_scale = 6 14 | params.border_mode = 'inside_major' 15 | params.patch_max_scale_change = 1.5 16 | 17 | # Learning parameters 18 | params.sample_memory_size = 50 19 | params.learning_rate = 0.01 20 | params.init_samples_minimum_weight = 0.25 21 | params.train_skipping = 20 22 | 23 | # Net optimization params 24 | params.update_classifier = True 25 | params.net_opt_iter = 10 26 | params.net_opt_update_iter = 2 27 | params.net_opt_hn_iter = 1 28 | 29 | # Detection parameters 30 | params.window_output = False 31 | 32 | # Init augmentation parameters 33 | params.use_augmentation = True 34 | params.augmentation = {'fliplr': True, 35 | 'rotate': [10, -10, 45, -45], 36 | 'blur': [(3,1), (1, 3), (2, 2)], 37 | 'relativeshift': [(0.6, 0.6), (-0.6, 0.6), (0.6, -0.6), (-0.6,-0.6)], 38 | 'dropout': (2, 0.2)} 39 | 40 | params.augmentation_expansion_factor = 2 41 | params.random_shift_factor = 1/3 42 | 43 | # Advanced localization parameters 44 | params.advanced_localization = True 45 | params.score_preprocess = 'softmax' 46 | params.target_not_found_threshold = 0.04 47 | params.distractor_threshold = 0.8 48 | params.hard_negative_threshold = 0.5 49 | params.target_neighborhood_scale = 2.2 50 | params.dispalcement_scale = 0.8 51 | params.hard_negative_learning_rate = 0.02 52 | params.update_scale_when_uncertain = True 53 | 54 | # IoUnet parameters 55 | params.box_refinement_space = 'relative' 56 | params.iounet_augmentation = False # Use the augmented samples to compute the modulation vector 57 | params.iounet_k = 3 # Top-k average to estimate final box 58 | params.num_init_random_boxes = 9 # Num extra random boxes in addition to the classifier prediction 59 | params.box_jitter_pos = 0.1 # How much to jitter the translation for random boxes 60 | params.box_jitter_sz = 0.5 # How much to jitter the scale for random boxes 61 | params.maximal_aspect_ratio = 6 # Limit on the aspect ratio 62 | params.box_refinement_iter = 10 # Number of iterations for refining the boxes 63 | params.box_refinement_step_length = 2.5e-3 # 1 # Gradient step length in the bounding box refinement 64 | params.box_refinement_step_decay = 1 # Multiplicative step length decay (1 means no decay) 65 | 66 | params.net = NetWithBackbone(net_path='prdimp50.pth.tar', 67 | use_gpu=params.use_gpu) 68 | 69 | params.vot_anno_conversion_type = 'preserve_area' 70 | 71 | return params 72 | -------------------------------------------------------------------------------- /external/AR/pytracking/parameter/dimp/super_dimp.py: -------------------------------------------------------------------------------- 1 | from pytracking.utils import TrackerParams 2 | from pytracking.features.net_wrappers import NetWithBackbone 3 | 4 | def parameters(): 5 | params = TrackerParams() 6 | 7 | params.debug = 0 8 | params.visualization = False 9 | 10 | params.use_gpu = True 11 | 12 | params.image_sample_size = 22*16 13 | params.search_area_scale = 6 14 | params.border_mode = 'inside_major' 15 | params.patch_max_scale_change = 1.5 16 | 17 | # Learning parameters 18 | params.sample_memory_size = 50 19 | params.learning_rate = 0.01 20 | params.init_samples_minimum_weight = 0.25 21 | params.train_skipping = 20 22 | 23 | # Net optimization params 24 | params.update_classifier = True 25 | params.net_opt_iter = 10 26 | params.net_opt_update_iter = 2 27 | params.net_opt_hn_iter = 1 28 | 29 | # Detection parameters 30 | params.window_output = False 31 | 32 | # Init augmentation parameters 33 | params.use_augmentation = True 34 | params.augmentation = {'fliplr': True, 35 | 'rotate': [10, -10, 45, -45], 36 | 'blur': [(3,1), (1, 3), (2, 2)], 37 | 'relativeshift': [(0.6, 0.6), (-0.6, 0.6), (0.6, -0.6), (-0.6,-0.6)], 38 | 'dropout': (2, 0.2)} 39 | 40 | params.augmentation_expansion_factor = 2 41 | params.random_shift_factor = 1/3 42 | 43 | # Advanced localization parameters 44 | params.advanced_localization = True 45 | params.target_not_found_threshold = 0.25 46 | params.distractor_threshold = 0.8 47 | params.hard_negative_threshold = 0.5 48 | params.target_neighborhood_scale = 2.2 49 | params.dispalcement_scale = 0.8 50 | params.hard_negative_learning_rate = 0.02 51 | params.update_scale_when_uncertain = True 52 | 53 | # IoUnet parameters 54 | params.box_refinement_space = 'relative' 55 | params.iounet_augmentation = False # Use the augmented samples to compute the modulation vector 56 | params.iounet_k = 3 # Top-k average to estimate final box 57 | params.num_init_random_boxes = 9 # Num extra random boxes in addition to the classifier prediction 58 | params.box_jitter_pos = 0.1 # How much to jitter the translation for random boxes 59 | params.box_jitter_sz = 0.5 # How much to jitter the scale for random boxes 60 | params.maximal_aspect_ratio = 6 # Limit on the aspect ratio 61 | params.box_refinement_iter = 10 # Number of iterations for refining the boxes 62 | params.box_refinement_step_length = 2.5e-3 # 1 # Gradient step length in the bounding box refinement 63 | params.box_refinement_step_decay = 1 # Multiplicative step length decay (1 means no decay) 64 | 65 | params.net = NetWithBackbone(net_path='super_dimp.pth.tar', 66 | use_gpu=params.use_gpu) 67 | 68 | params.vot_anno_conversion_type = 'preserve_area' 69 | 70 | return params 71 | -------------------------------------------------------------------------------- /external/AR/pytracking/parameter/eco/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/pytracking/parameter/eco/__init__.py -------------------------------------------------------------------------------- /external/AR/pytracking/tracker/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/pytracking/tracker/__init__.py -------------------------------------------------------------------------------- /external/AR/pytracking/tracker/atom/__init__.py: -------------------------------------------------------------------------------- 1 | from .atom import ATOM 2 | 3 | def get_tracker_class(): 4 | return ATOM -------------------------------------------------------------------------------- /external/AR/pytracking/tracker/base/__init__.py: -------------------------------------------------------------------------------- 1 | from .basetracker import BaseTracker -------------------------------------------------------------------------------- /external/AR/pytracking/tracker/base/basetracker.py: -------------------------------------------------------------------------------- 1 | from _collections import OrderedDict 2 | 3 | class BaseTracker: 4 | """Base class for all trackers.""" 5 | 6 | def __init__(self, params): 7 | self.params = params 8 | self.visdom = None 9 | 10 | 11 | def initialize(self, image, info: dict) -> dict: 12 | """Overload this function in your tracker. This should initialize the model.""" 13 | raise NotImplementedError 14 | 15 | 16 | def track(self, image, info: dict = None) -> dict: 17 | """Overload this function in your tracker. This should track in the frame and update the model.""" 18 | raise NotImplementedError 19 | 20 | 21 | def visdom_draw_tracking(self, image, box, segmentation=None): 22 | if isinstance(box, OrderedDict): 23 | box = [v for k, v in box.items()] 24 | else: 25 | box = (box,) 26 | if segmentation is None: 27 | self.visdom.register((image, *box), 'Tracking', 1, 'Tracking') 28 | else: 29 | self.visdom.register((image, *box, segmentation), 'Tracking', 1, 'Tracking') -------------------------------------------------------------------------------- /external/AR/pytracking/tracker/dimp/__init__.py: -------------------------------------------------------------------------------- 1 | from .dimp import DiMP 2 | 3 | def get_tracker_class(): 4 | return DiMP -------------------------------------------------------------------------------- /external/AR/pytracking/tracker/eco/__init__.py: -------------------------------------------------------------------------------- 1 | from .eco import ECO 2 | 3 | def get_tracker_class(): 4 | return ECO -------------------------------------------------------------------------------- /external/AR/pytracking/util_scripts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/AR/pytracking/util_scripts/__init__.py -------------------------------------------------------------------------------- /external/AR/pytracking/util_scripts/pack_got10k_results.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import os 3 | import shutil 4 | from pytracking.evaluation.environment import env_settings 5 | 6 | 7 | def pack_got10k_results(tracker_name, param_name, output_name): 8 | """ Packs got10k results into a zip folder which can be directly uploaded to the evaluation server. The packed 9 | file is saved in the folder env_settings().got_packed_results_path 10 | 11 | args: 12 | tracker_name - name of the tracker 13 | param_name - name of the parameter file 14 | output_name - name of the packed zip file 15 | """ 16 | output_path = os.path.join(env_settings().got_packed_results_path, output_name) 17 | 18 | if not os.path.exists(output_path): 19 | os.makedirs(output_path) 20 | 21 | results_path = env_settings().results_path 22 | for i in range(1,181): 23 | seq_name = 'GOT-10k_Test_{:06d}'.format(i) 24 | 25 | seq_output_path = '{}/{}'.format(output_path, seq_name) 26 | if not os.path.exists(seq_output_path): 27 | os.makedirs(seq_output_path) 28 | 29 | for run_id in range(3): 30 | res = np.loadtxt('{}/{}/{}_{:03d}/{}.txt'.format(results_path, tracker_name, param_name, run_id, seq_name), dtype=np.float64) 31 | times = np.loadtxt( 32 | '{}/{}/{}_{:03d}/{}_time.txt'.format(results_path, tracker_name, param_name, run_id, seq_name), 33 | dtype=np.float64) 34 | 35 | np.savetxt('{}/{}_{:03d}.txt'.format(seq_output_path, seq_name, run_id+1), res, delimiter=',', fmt='%f') 36 | np.savetxt('{}/{}_time.txt'.format(seq_output_path, seq_name), times, fmt='%f') 37 | 38 | # Generate ZIP file 39 | shutil.make_archive(output_path, 'zip', output_path) 40 | 41 | # Remove raw text files 42 | shutil.rmtree(output_path) 43 | -------------------------------------------------------------------------------- /external/AR/pytracking/util_scripts/pack_trackingnet_results.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import os 3 | import shutil 4 | from pytracking.evaluation.environment import env_settings 5 | from pytracking.evaluation.datasets import get_dataset 6 | 7 | 8 | def pack_trackingnet_results(tracker_name, param_name, run_id=None, output_name=None): 9 | """ Packs trackingnet results into a zip folder which can be directly uploaded to the evaluation server. The packed 10 | file is saved in the folder env_settings().tn_packed_results_path 11 | 12 | args: 13 | tracker_name - name of the tracker 14 | param_name - name of the parameter file 15 | run_id - run id for the tracker 16 | output_name - name of the packed zip file 17 | """ 18 | 19 | if output_name is None: 20 | if run_id is None: 21 | output_name = '{}_{}'.format(tracker_name, param_name) 22 | else: 23 | output_name = '{}_{}_{:03d}'.format(tracker_name, param_name, run_id) 24 | 25 | output_path = os.path.join(env_settings().tn_packed_results_path, output_name) 26 | 27 | if not os.path.exists(output_path): 28 | os.makedirs(output_path) 29 | 30 | results_path = env_settings().results_path 31 | 32 | tn_dataset = get_dataset('trackingnet') 33 | 34 | for seq in tn_dataset: 35 | seq_name = seq.name 36 | 37 | if run_id is None: 38 | seq_results_path = '{}/{}/{}/{}.txt'.format(results_path, tracker_name, param_name, seq_name) 39 | else: 40 | seq_results_path = '{}/{}/{}_{:03d}/{}.txt'.format(results_path, tracker_name, param_name, run_id, seq_name) 41 | 42 | results = np.loadtxt(seq_results_path, dtype=np.float64) 43 | 44 | np.savetxt('{}/{}.txt'.format(output_path, seq_name), results, delimiter=',', fmt='%.2f') 45 | 46 | # Generate ZIP file 47 | shutil.make_archive(output_path, 'zip', output_path) 48 | 49 | # Remove raw text files 50 | shutil.rmtree(output_path) 51 | -------------------------------------------------------------------------------- /external/AR/pytracking/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .params import TrackerParams, FeatureParams, Choice -------------------------------------------------------------------------------- /external/AR/pytracking/utils/convert_vot_anno_to_rect.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | def convert_vot_anno_to_rect(vot_anno, type): 5 | if len(vot_anno) == 4: 6 | return vot_anno 7 | 8 | if type == 'union': 9 | x1 = min(vot_anno[0::2]) 10 | x2 = max(vot_anno[0::2]) 11 | y1 = min(vot_anno[1::2]) 12 | y2 = max(vot_anno[1::2]) 13 | return [x1, y1, x2 - x1, y2 - y1] 14 | elif type == 'preserve_area': 15 | if len(vot_anno) != 8: 16 | raise ValueError 17 | 18 | vot_anno = np.array(vot_anno) 19 | cx = np.mean(vot_anno[0::2]) 20 | cy = np.mean(vot_anno[1::2]) 21 | 22 | x1 = min(vot_anno[0::2]) 23 | x2 = max(vot_anno[0::2]) 24 | y1 = min(vot_anno[1::2]) 25 | y2 = max(vot_anno[1::2]) 26 | 27 | A1 = np.linalg.norm(vot_anno[0:2] - vot_anno[2: 4]) * np.linalg.norm(vot_anno[2: 4] - vot_anno[4:6]) 28 | A2 = (x2 - x1) * (y2 - y1) 29 | s = np.sqrt(A1 / A2) 30 | w = s * (x2 - x1) + 1 31 | h = s * (y2 - y1) + 1 32 | 33 | x = cx - 0.5*w 34 | y = cy - 0.5*h 35 | return [x, y, w, h] 36 | else: 37 | raise ValueError 38 | -------------------------------------------------------------------------------- /external/AR/pytracking/utils/load_text.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pandas as pd 3 | 4 | 5 | def load_text_numpy(path, delimiter, dtype): 6 | if isinstance(delimiter, (tuple, list)): 7 | for d in delimiter: 8 | try: 9 | ground_truth_rect = np.loadtxt(path, delimiter=d, dtype=dtype) 10 | return ground_truth_rect 11 | except: 12 | pass 13 | 14 | raise Exception('Could not read file {}'.format(path)) 15 | else: 16 | ground_truth_rect = np.loadtxt(path, delimiter=delimiter, dtype=dtype) 17 | return ground_truth_rect 18 | 19 | 20 | def load_text_pandas(path, delimiter, dtype): 21 | if isinstance(delimiter, (tuple, list)): 22 | for d in delimiter: 23 | try: 24 | ground_truth_rect = pd.read_csv(path, delimiter=d, header=None, dtype=dtype, na_filter=False, 25 | low_memory=False).values 26 | return ground_truth_rect 27 | except Exception as e: 28 | pass 29 | 30 | raise Exception('Could not read file {}'.format(path)) 31 | else: 32 | ground_truth_rect = pd.read_csv(path, delimiter=delimiter, header=None, dtype=dtype, na_filter=False, 33 | low_memory=False).values 34 | return ground_truth_rect 35 | 36 | 37 | def load_text(path, delimiter=' ', dtype=np.float32, backend='numpy'): 38 | if backend == 'numpy': 39 | return load_text_numpy(path, delimiter, dtype) 40 | elif backend == 'pandas': 41 | return load_text_pandas(path, delimiter, dtype) 42 | -------------------------------------------------------------------------------- /external/AR/pytracking/utils/loading.py: -------------------------------------------------------------------------------- 1 | import os 2 | import ltr.admin.loading as ltr_loading 3 | from pytracking.evaluation.environment import env_settings 4 | 5 | 6 | def load_network(net_path, **kwargs): 7 | """Load network for tracking. 8 | args: 9 | net_path - Path to network. If it is not an absolute path, it is relative to the network_path in the local.py. 10 | See ltr.admin.loading.load_network for further details. 11 | **kwargs - Additional key-word arguments that are sent to ltr.admin.loading.load_network. 12 | """ 13 | kwargs['backbone_pretrained'] = False 14 | if os.path.isabs(net_path): 15 | path_full = net_path 16 | net, _ = ltr_loading.load_network(path_full, **kwargs) 17 | elif isinstance(env_settings().network_path, (list, tuple)): 18 | net = None 19 | for p in env_settings().network_path: 20 | path_full = os.path.join(p, net_path) 21 | try: 22 | net, _ = ltr_loading.load_network(path_full, **kwargs) 23 | break 24 | except Exception as e: 25 | # print(e) 26 | pass 27 | 28 | assert net is not None, 'Failed to load network' 29 | else: 30 | path_full = os.path.join(env_settings().network_path, net_path) 31 | net, _ = ltr_loading.load_network(path_full, **kwargs) 32 | 33 | return net 34 | -------------------------------------------------------------------------------- /external/AR/pytracking/utils/params.py: -------------------------------------------------------------------------------- 1 | from pytracking import TensorList 2 | import random 3 | 4 | 5 | class TrackerParams: 6 | """Class for tracker parameters.""" 7 | def set_default_values(self, default_vals: dict): 8 | for name, val in default_vals.items(): 9 | if not hasattr(self, name): 10 | setattr(self, name, val) 11 | 12 | def get(self, name: str, *default): 13 | """Get a parameter value with the given name. If it does not exists, it return the default value given as a 14 | second argument or returns an error if no default value is given.""" 15 | if len(default) > 1: 16 | raise ValueError('Can only give one default value.') 17 | 18 | if not default: 19 | return getattr(self, name) 20 | 21 | return getattr(self, name, default[0]) 22 | 23 | def has(self, name: str): 24 | """Check if there exist a parameter with the given name.""" 25 | return hasattr(self, name) 26 | 27 | 28 | class FeatureParams: 29 | """Class for feature specific parameters""" 30 | def __init__(self, *args, **kwargs): 31 | if len(args) > 0: 32 | raise ValueError 33 | 34 | for name, val in kwargs.items(): 35 | if isinstance(val, list): 36 | setattr(self, name, TensorList(val)) 37 | else: 38 | setattr(self, name, val) 39 | 40 | 41 | def Choice(*args): 42 | """Can be used to sample random parameter values.""" 43 | return random.choice(args) 44 | -------------------------------------------------------------------------------- /external/AR/pytracking/vot20_utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | def make_full_size(x, output_sz): 5 | ''' 6 | zero-pad input x (right and down) to match output_sz 7 | x: numpy array e.g., binary mask 8 | output_sz: size of the output [width, height] 9 | ''' 10 | if x.shape[0] == output_sz[1] and x.shape[1] == output_sz[0]: 11 | return x 12 | pad_x = output_sz[0] - x.shape[1] 13 | if pad_x < 0: 14 | x = x[:, :x.shape[1] + pad_x] 15 | # padding has to be set to zero, otherwise pad function fails 16 | pad_x = 0 17 | pad_y = output_sz[1] - x.shape[0] 18 | if pad_y < 0: 19 | x = x[:x.shape[0] + pad_y, :] 20 | # padding has to be set to zero, otherwise pad function fails 21 | pad_y = 0 22 | return np.pad(x, ((0, pad_y), (0, pad_x)), 'constant', constant_values=0) 23 | 24 | 25 | def rect_from_mask(mask): 26 | ''' 27 | create an axis-aligned rectangle from a given binary mask 28 | mask in created as a minimal rectangle containing all non-zero pixels 29 | ''' 30 | x_ = np.sum(mask, axis=0) 31 | y_ = np.sum(mask, axis=1) 32 | x0 = np.min(np.nonzero(x_)) 33 | x1 = np.max(np.nonzero(x_)) 34 | y0 = np.min(np.nonzero(y_)) 35 | y1 = np.max(np.nonzero(y_)) 36 | return [x0, y0, x1 - x0 + 1, y1 - y0 + 1] 37 | 38 | 39 | def mask_from_rect(rect, output_sz): 40 | ''' 41 | create a binary mask from a given rectangle 42 | rect: axis-aligned rectangle [x0, y0, width, height] 43 | output_sz: size of the output [width, height] 44 | ''' 45 | mask = np.zeros((output_sz[1], output_sz[0]), dtype=np.uint8) 46 | x0 = max(int(round(rect[0])), 0) 47 | y0 = max(int(round(rect[1])), 0) 48 | x1 = min(int(round(rect[0] + rect[2])), output_sz[0]) 49 | y1 = min(int(round(rect[1] + rect[3])), output_sz[1]) 50 | mask[y0:y1, x0:x1] = 1 51 | return mask 52 | 53 | 54 | def bbox_clip(x1, y1, x2, y2, boundary, min_sz=10): 55 | '''boundary (H,W)''' 56 | x1_new = max(0, min(x1, boundary[1] - min_sz)) 57 | y1_new = max(0, min(y1, boundary[0] - min_sz)) 58 | x2_new = max(min_sz, min(x2, boundary[1])) 59 | y2_new = max(min_sz, min(y2, boundary[0])) 60 | return x1_new, y1_new, x2_new, y2_new -------------------------------------------------------------------------------- /external/STARK-ExtreMart.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/external/STARK-ExtreMart.pdf -------------------------------------------------------------------------------- /external/vot20/stark_s50/config.yaml: -------------------------------------------------------------------------------- 1 | registry: 2 | - ./trackers.ini 3 | stack: vot2020 4 | -------------------------------------------------------------------------------- /external/vot20/stark_s50/exp.sh: -------------------------------------------------------------------------------- 1 | vot evaluate --workspace . stark_s50 2 | vot analysis --workspace . stark_s50 --format html 3 | 4 | 5 | -------------------------------------------------------------------------------- /external/vot20/stark_s50/trackers.ini: -------------------------------------------------------------------------------- 1 | [stark_s50] # 2 | label = stark_s50 3 | protocol = traxpython 4 | command = stark_s50 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /lib/test/vot20 7 | -------------------------------------------------------------------------------- /external/vot20/stark_s50_ar/config.yaml: -------------------------------------------------------------------------------- 1 | registry: 2 | - ./trackers.ini 3 | stack: vot2020 4 | -------------------------------------------------------------------------------- /external/vot20/stark_s50_ar/exp.sh: -------------------------------------------------------------------------------- 1 | vot evaluate --workspace . stark_s50_ar 2 | vot analysis --workspace . stark_s50_ar --format html 3 | 4 | 5 | -------------------------------------------------------------------------------- /external/vot20/stark_s50_ar/trackers.ini: -------------------------------------------------------------------------------- 1 | [stark_s50_ar] # 2 | label = stark_s50_ar 3 | protocol = traxpython 4 | command = stark_s50_ar 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /external/AR/pytracking/VOT2020_super_only_mask_384_HP 7 | -------------------------------------------------------------------------------- /external/vot20/stark_st101/config.yaml: -------------------------------------------------------------------------------- 1 | registry: 2 | - ./trackers.ini 3 | stack: vot2020 4 | -------------------------------------------------------------------------------- /external/vot20/stark_st101/exp.sh: -------------------------------------------------------------------------------- 1 | vot evaluate --workspace . stark_st101 2 | vot analysis --workspace . stark_st101 --format html -------------------------------------------------------------------------------- /external/vot20/stark_st101/trackers.ini: -------------------------------------------------------------------------------- 1 | [stark_st101] # 2 | label = stark_st101 3 | protocol = traxpython 4 | command = stark_st101 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /lib/test/vot20 7 | -------------------------------------------------------------------------------- /external/vot20/stark_st101_ar/config.yaml: -------------------------------------------------------------------------------- 1 | registry: 2 | - ./trackers.ini 3 | stack: vot2020 4 | -------------------------------------------------------------------------------- /external/vot20/stark_st101_ar/exp.sh: -------------------------------------------------------------------------------- 1 | vot evaluate --workspace . stark_st101_ar 2 | vot analysis --workspace . stark_st101_ar --format html 3 | 4 | 5 | -------------------------------------------------------------------------------- /external/vot20/stark_st101_ar/trackers.ini: -------------------------------------------------------------------------------- 1 | [stark_st101_ar] # 2 | label = stark_st101_ar 3 | protocol = traxpython 4 | command = stark_st101_ar 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /external/AR/pytracking/VOT2020_super_only_mask_384_HP 7 | -------------------------------------------------------------------------------- /external/vot20/stark_st50/config.yaml: -------------------------------------------------------------------------------- 1 | registry: 2 | - ./trackers.ini 3 | stack: vot2020 4 | -------------------------------------------------------------------------------- /external/vot20/stark_st50/exp.sh: -------------------------------------------------------------------------------- 1 | vot evaluate --workspace . stark_st50 2 | vot analysis --workspace . stark_st50 --format html 3 | 4 | 5 | -------------------------------------------------------------------------------- /external/vot20/stark_st50/trackers.ini: -------------------------------------------------------------------------------- 1 | [stark_st50] # 2 | label = stark_st50 3 | protocol = traxpython 4 | command = stark_st50 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /lib/test/vot20 7 | -------------------------------------------------------------------------------- /external/vot20/stark_st50_ar/config.yaml: -------------------------------------------------------------------------------- 1 | registry: 2 | - ./trackers.ini 3 | stack: vot2020 4 | -------------------------------------------------------------------------------- /external/vot20/stark_st50_ar/exp.sh: -------------------------------------------------------------------------------- 1 | vot evaluate --workspace . stark_st50_ar 2 | vot analysis --workspace . stark_st50_ar --format html 3 | 4 | 5 | -------------------------------------------------------------------------------- /external/vot20/stark_st50_ar/trackers.ini: -------------------------------------------------------------------------------- 1 | [stark_st50_ar] # 2 | label = stark_st50_ar 3 | protocol = traxpython 4 | command = stark_st50_ar 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /external/AR/pytracking/VOT2020_super_only_mask_384_HP 7 | -------------------------------------------------------------------------------- /external/vot20_lt/stark_st101_lt/config.yaml: -------------------------------------------------------------------------------- 1 | registry: 2 | - ./trackers.ini 3 | stack: votlt2020 4 | -------------------------------------------------------------------------------- /external/vot20_lt/stark_st101_lt/exp.sh: -------------------------------------------------------------------------------- 1 | vot evaluate --workspace . stark_st101_lt 2 | vot analysis --workspace . stark_st101_lt --format html 3 | 4 | 5 | -------------------------------------------------------------------------------- /external/vot20_lt/stark_st101_lt/trackers.ini: -------------------------------------------------------------------------------- 1 | [stark_st101_lt] # 2 | label = stark_st101_lt 3 | protocol = traxpython 4 | command = stark_st101_lt 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /lib/test/vot20 7 | -------------------------------------------------------------------------------- /external/vot20_lt/stark_st50_lt/config.yaml: -------------------------------------------------------------------------------- 1 | registry: 2 | - ./trackers.ini 3 | stack: votlt2020 4 | -------------------------------------------------------------------------------- /external/vot20_lt/stark_st50_lt/exp.sh: -------------------------------------------------------------------------------- 1 | vot evaluate --workspace . stark_st50_lt 2 | vot analysis --workspace . stark_st50_lt --format html 3 | 4 | 5 | -------------------------------------------------------------------------------- /external/vot20_lt/stark_st50_lt/trackers.ini: -------------------------------------------------------------------------------- 1 | [stark_st50_lt] # 2 | label = stark_st50_lt 3 | protocol = traxpython 4 | command = stark_st50_lt 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /lib/test/vot20 7 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | echo "****************** Installing pytorch ******************" 2 | conda install -y pytorch==1.5.1 torchvision==0.6.1 cudatoolkit=10.2 -c pytorch 3 | 4 | echo "" 5 | echo "" 6 | echo "****************** Installing yaml ******************" 7 | pip install PyYAML 8 | 9 | echo "" 10 | echo "" 11 | echo "****************** Installing easydict ******************" 12 | pip install easydict 13 | 14 | echo "" 15 | echo "" 16 | echo "****************** Installing cython ******************" 17 | pip install cython 18 | 19 | echo "" 20 | echo "" 21 | echo "****************** Installing opencv-python ******************" 22 | pip install opencv-python 23 | 24 | echo "" 25 | echo "" 26 | echo "****************** Installing pandas ******************" 27 | pip install pandas 28 | 29 | echo "" 30 | echo "" 31 | echo "****************** Installing tqdm ******************" 32 | conda install -y tqdm 33 | 34 | echo "" 35 | echo "" 36 | echo "****************** Installing coco toolkit ******************" 37 | pip install pycocotools 38 | 39 | echo "" 40 | echo "" 41 | echo "****************** Installing jpeg4py python wrapper ******************" 42 | apt-get install libturbojpeg 43 | pip install jpeg4py 44 | 45 | echo "" 46 | echo "" 47 | echo "****************** Installing tensorboard ******************" 48 | pip install tb-nightly 49 | 50 | echo "" 51 | echo "" 52 | echo "****************** Installing tikzplotlib ******************" 53 | pip install tikzplotlib 54 | 55 | echo "" 56 | echo "" 57 | echo "****************** Installing thop tool for FLOPs and Params computing ******************" 58 | pip install --upgrade git+https://github.com/Lyken17/pytorch-OpCounter.git 59 | 60 | echo "" 61 | echo "" 62 | echo "****************** Installing colorama ******************" 63 | pip install colorama 64 | 65 | echo "" 66 | echo "" 67 | echo "****************** Installing lmdb ******************" 68 | pip install lmdb 69 | 70 | echo "" 71 | echo "" 72 | echo "****************** Installing scipy ******************" 73 | pip install scipy 74 | 75 | echo "" 76 | echo "" 77 | echo "****************** Installing visdom ******************" 78 | pip install visdom 79 | 80 | echo "" 81 | echo "" 82 | echo "****************** Installing vot-toolkit python ******************" 83 | pip install git+https://github.com/votchallenge/vot-toolkit-python 84 | 85 | echo "" 86 | echo "" 87 | echo "****************** Installation complete! ******************" 88 | -------------------------------------------------------------------------------- /install_pytorch17.sh: -------------------------------------------------------------------------------- 1 | echo "****************** Installing pytorch ******************" 2 | conda install -y pytorch==1.7.0 torchvision==0.8.1 cudatoolkit=10.2 -c pytorch 3 | 4 | echo "" 5 | echo "" 6 | echo "****************** Installing yaml ******************" 7 | pip install PyYAML 8 | 9 | echo "" 10 | echo "" 11 | echo "****************** Installing easydict ******************" 12 | pip install easydict 13 | 14 | echo "" 15 | echo "" 16 | echo "****************** Installing cython ******************" 17 | pip install cython 18 | 19 | echo "" 20 | echo "" 21 | echo "****************** Installing opencv-python ******************" 22 | pip install opencv-python 23 | 24 | echo "" 25 | echo "" 26 | echo "****************** Installing pandas ******************" 27 | pip install pandas 28 | 29 | echo "" 30 | echo "" 31 | echo "****************** Installing tqdm ******************" 32 | conda install -y tqdm 33 | 34 | echo "" 35 | echo "" 36 | echo "****************** Installing coco toolkit ******************" 37 | pip install pycocotools 38 | 39 | echo "" 40 | echo "" 41 | echo "****************** Installing jpeg4py python wrapper ******************" 42 | apt-get install libturbojpeg 43 | pip install jpeg4py 44 | 45 | echo "" 46 | echo "" 47 | echo "****************** Installing tensorboard ******************" 48 | pip install tb-nightly 49 | 50 | echo "" 51 | echo "" 52 | echo "****************** Installing tikzplotlib ******************" 53 | pip install tikzplotlib 54 | 55 | echo "" 56 | echo "" 57 | echo "****************** Installing thop tool for FLOPs and Params computing ******************" 58 | pip install --upgrade git+https://github.com/Lyken17/pytorch-OpCounter.git 59 | 60 | echo "" 61 | echo "" 62 | echo "****************** Installing colorama ******************" 63 | pip install colorama 64 | 65 | echo "" 66 | echo "" 67 | echo "****************** Installing lmdb ******************" 68 | pip install lmdb 69 | 70 | echo "" 71 | echo "" 72 | echo "****************** Installing scipy ******************" 73 | pip install scipy 74 | 75 | echo "" 76 | echo "" 77 | echo "****************** Installing visdom ******************" 78 | pip install visdom 79 | 80 | echo "" 81 | echo "" 82 | echo "****************** Installing vot-toolkit python ******************" 83 | pip install git+https://github.com/votchallenge/vot-toolkit-python 84 | 85 | echo "" 86 | echo "" 87 | echo "****************** Installing onnx and onnxruntime-gpu ******************" 88 | pip install onnx onnxruntime-gpu==1.6.0 89 | 90 | echo "" 91 | echo "" 92 | echo "****************** Installing timm ******************" 93 | pip install timm==0.3.2 94 | 95 | echo "" 96 | echo "" 97 | echo "****************** Installing timm ******************" 98 | pip install timm==0.3.2 99 | 100 | echo "" 101 | echo "" 102 | echo "****************** Installing clip ******************" 103 | pip install clip-by-openai 104 | 105 | echo "" 106 | echo "" 107 | echo "****************** Installing yacs ******************" 108 | pip install yacs 109 | 110 | echo "" 111 | echo "" 112 | 113 | echo "****************** Installation complete! ******************" 114 | -------------------------------------------------------------------------------- /lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/lib/__init__.py -------------------------------------------------------------------------------- /lib/config/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/lib/config/__init__.py -------------------------------------------------------------------------------- /lib/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/lib/models/__init__.py -------------------------------------------------------------------------------- /lib/models/stark/__init__.py: -------------------------------------------------------------------------------- 1 | from .stark_s import build_starks 2 | from .stark_st import build_starkst 3 | from .stark_lightning_x_trt import build_stark_lightning_x_trt, build_stark_lightning_x_trt_new 4 | from .simtrack import build_simtrack 5 | -------------------------------------------------------------------------------- /lib/models/stark/swin_base_patch4_window12_384_S16.yaml: -------------------------------------------------------------------------------- 1 | # only for evaluation 2 | DATA: 3 | IMG_SIZE: 384 4 | MODEL: 5 | TYPE: swin 6 | NAME: swin_base_patch4_window12_384_S16 7 | SWIN: 8 | EMBED_DIM: 128 9 | DEPTHS: [ 2, 2, 18] 10 | NUM_HEADS: [ 4, 8, 16] 11 | WINDOW_SIZE: 12 12 | TEST: 13 | CROP: False -------------------------------------------------------------------------------- /lib/test/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/lib/test/__init__.py -------------------------------------------------------------------------------- /lib/test/analysis/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/lib/test/analysis/__init__.py -------------------------------------------------------------------------------- /lib/test/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | from .data import Sequence 2 | from .tracker import Tracker, trackerlist 3 | from .datasets import get_dataset 4 | from .environment import create_default_local_file_ITP_test -------------------------------------------------------------------------------- /lib/test/evaluation/datasets.py: -------------------------------------------------------------------------------- 1 | from collections import namedtuple 2 | import importlib 3 | from lib.test.evaluation.data import SequenceList 4 | 5 | DatasetInfo = namedtuple('DatasetInfo', ['module', 'class_name', 'kwargs']) 6 | 7 | pt = "lib.test.evaluation.%sdataset" # Useful abbreviations to reduce the clutter 8 | 9 | dataset_dict = dict( 10 | otb=DatasetInfo(module=pt % "otb", class_name="OTBDataset", kwargs=dict()), 11 | nfs=DatasetInfo(module=pt % "nfs", class_name="NFSDataset", kwargs=dict()), 12 | uav=DatasetInfo(module=pt % "uav", class_name="UAVDataset", kwargs=dict()), 13 | tc128=DatasetInfo(module=pt % "tc128", class_name="TC128Dataset", kwargs=dict()), 14 | tc128ce=DatasetInfo(module=pt % "tc128ce", class_name="TC128CEDataset", kwargs=dict()), 15 | trackingnet=DatasetInfo(module=pt % "trackingnet", class_name="TrackingNetDataset", kwargs=dict()), 16 | got10k_test=DatasetInfo(module=pt % "got10k", class_name="GOT10KDataset", kwargs=dict(split='test')), 17 | got10k_val=DatasetInfo(module=pt % "got10k", class_name="GOT10KDataset", kwargs=dict(split='val')), 18 | got10k_ltrval=DatasetInfo(module=pt % "got10k", class_name="GOT10KDataset", kwargs=dict(split='ltrval')), 19 | lasot=DatasetInfo(module=pt % "lasot", class_name="LaSOTDataset", kwargs=dict()), 20 | lasot_lmdb=DatasetInfo(module=pt % "lasot_lmdb", class_name="LaSOTlmdbDataset", kwargs=dict()) 21 | ) 22 | 23 | 24 | def load_dataset(name: str): 25 | """ Import and load a single dataset.""" 26 | name = name.lower() 27 | dset_info = dataset_dict.get(name) 28 | if dset_info is None: 29 | raise ValueError('Unknown dataset \'%s\'' % name) 30 | 31 | m = importlib.import_module(dset_info.module) 32 | dataset = getattr(m, dset_info.class_name)(**dset_info.kwargs) # Call the constructor 33 | return dataset.get_sequence_list() 34 | 35 | 36 | def get_dataset(*args): 37 | """ Get a single or set of datasets.""" 38 | dset = SequenceList() 39 | for name in args: 40 | dset.extend(load_dataset(name)) 41 | return dset -------------------------------------------------------------------------------- /lib/test/evaluation/got10kdataset.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from lib.test.evaluation.data import Sequence, BaseDataset, SequenceList 3 | from lib.test.utils.load_text import load_text 4 | import os 5 | 6 | 7 | class GOT10KDataset(BaseDataset): 8 | """ GOT-10k dataset. 9 | 10 | Publication: 11 | GOT-10k: A Large High-Diversity Benchmark for Generic Object Tracking in the Wild 12 | Lianghua Huang, Xin Zhao, and Kaiqi Huang 13 | arXiv:1810.11981, 2018 14 | https://arxiv.org/pdf/1810.11981.pdf 15 | 16 | Download dataset from http://got-10k.aitestunion.com/downloads 17 | """ 18 | def __init__(self, split): 19 | super().__init__() 20 | # Split can be test, val, or ltrval (a validation split consisting of videos from the official train set) 21 | if split == 'test' or split == 'val': 22 | self.base_path = os.path.join(self.env_settings.got10k_path, split) 23 | else: 24 | self.base_path = os.path.join(self.env_settings.got10k_path, 'train') 25 | 26 | self.sequence_list = self._get_sequence_list(split) 27 | self.split = split 28 | 29 | def get_sequence_list(self): 30 | return SequenceList([self._construct_sequence(s) for s in self.sequence_list]) 31 | 32 | def _construct_sequence(self, sequence_name): 33 | anno_path = '{}/{}/groundtruth.txt'.format(self.base_path, sequence_name) 34 | 35 | ground_truth_rect = load_text(str(anno_path), delimiter=',', dtype=np.float64) 36 | 37 | frames_path = '{}/{}'.format(self.base_path, sequence_name) 38 | frame_list = [frame for frame in os.listdir(frames_path) if frame.endswith(".jpg")] 39 | frame_list.sort(key=lambda f: int(f[:-4])) 40 | frames_list = [os.path.join(frames_path, frame) for frame in frame_list] 41 | 42 | return Sequence(sequence_name, frames_list, 'got10k', ground_truth_rect.reshape(-1, 4)) 43 | 44 | def __len__(self): 45 | return len(self.sequence_list) 46 | 47 | def _get_sequence_list(self, split): 48 | with open('{}/list.txt'.format(self.base_path)) as f: 49 | sequence_list = f.read().splitlines() 50 | 51 | if split == 'ltrval': 52 | with open('{}/got10k_val_split.txt'.format(self.env_settings.dataspec_path)) as f: 53 | seq_ids = f.read().splitlines() 54 | 55 | sequence_list = [sequence_list[int(x)] for x in seq_ids] 56 | return sequence_list 57 | -------------------------------------------------------------------------------- /lib/test/evaluation/local.py: -------------------------------------------------------------------------------- 1 | from lib.test.evaluation.environment import EnvSettings 2 | 3 | def local_env_settings(): 4 | settings = EnvSettings() 5 | 6 | # Set your local paths here. 7 | 8 | settings.davis_dir = '' 9 | settings.got10k_lmdb_path = '' 10 | settings.got10k_path = '' 11 | settings.got_packed_results_path = '' 12 | settings.got_reports_path = '' 13 | settings.lasot_lmdb_path = '' 14 | settings.lasot_path = '' 15 | settings.network_path = '' # Where tracking networks are stored. 16 | settings.nfs_path = '' 17 | settings.otb_path = '' 18 | settings.prj_dir = '' 19 | settings.result_plot_path = '' 20 | settings.results_path = '' # Where to store tracking results 21 | settings.save_dir = '' 22 | settings.segmentation_path = '' 23 | settings.tc128_path = '' 24 | settings.tn_packed_results_path = '' 25 | settings.tpl_path = '' 26 | settings.trackingnet_path = '' 27 | settings.uav_path = '' 28 | settings.vot_path = '' 29 | settings.youtubevos_dir = '' 30 | 31 | return settings 32 | 33 | -------------------------------------------------------------------------------- /lib/test/evaluation/tc128cedataset.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from lib.test.evaluation.data import Sequence, BaseDataset, SequenceList 3 | import os 4 | import glob 5 | import six 6 | 7 | 8 | class TC128CEDataset(BaseDataset): 9 | """ 10 | TC-128 Dataset (78 newly added sequences) 11 | modified from the implementation in got10k-toolkit (https://github.com/got-10k/toolkit) 12 | """ 13 | def __init__(self): 14 | super().__init__() 15 | self.base_path = self.env_settings.tc128_path 16 | self.anno_files = sorted(glob.glob( 17 | os.path.join(self.base_path, '*/*_gt.txt'))) 18 | """filter the newly added sequences (_ce)""" 19 | self.anno_files = [s for s in self.anno_files if "_ce" in s] 20 | self.seq_dirs = [os.path.dirname(f) for f in self.anno_files] 21 | self.seq_names = [os.path.basename(d) for d in self.seq_dirs] 22 | # valid frame range for each sequence 23 | self.range_files = [glob.glob(os.path.join(d, '*_frames.txt'))[0] for d in self.seq_dirs] 24 | 25 | def get_sequence_list(self): 26 | return SequenceList([self._construct_sequence(s) for s in self.seq_names]) 27 | 28 | def _construct_sequence(self, sequence_name): 29 | if isinstance(sequence_name, six.string_types): 30 | if not sequence_name in self.seq_names: 31 | raise Exception('Sequence {} not found.'.format(sequence_name)) 32 | index = self.seq_names.index(sequence_name) 33 | # load valid frame range 34 | frames = np.loadtxt(self.range_files[index], dtype=int, delimiter=',') 35 | img_files = [os.path.join(self.seq_dirs[index], 'img/%04d.jpg' % f) for f in range(frames[0], frames[1] + 1)] 36 | 37 | # load annotations 38 | anno = np.loadtxt(self.anno_files[index], delimiter=',') 39 | assert len(img_files) == len(anno) 40 | assert anno.shape[1] == 4 41 | 42 | # return img_files, anno 43 | return Sequence(sequence_name, img_files, 'tc128', anno.reshape(-1, 4)) 44 | 45 | def __len__(self): 46 | return len(self.seq_names) 47 | -------------------------------------------------------------------------------- /lib/test/evaluation/tc128dataset.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from lib.test.evaluation.data import Sequence, BaseDataset, SequenceList 3 | import os 4 | import glob 5 | import six 6 | 7 | 8 | class TC128Dataset(BaseDataset): 9 | """ 10 | TC-128 Dataset 11 | modified from the implementation in got10k-toolkit (https://github.com/got-10k/toolkit) 12 | """ 13 | def __init__(self): 14 | super().__init__() 15 | self.base_path = self.env_settings.tc128_path 16 | self.anno_files = sorted(glob.glob( 17 | os.path.join(self.base_path, '*/*_gt.txt'))) 18 | self.seq_dirs = [os.path.dirname(f) for f in self.anno_files] 19 | self.seq_names = [os.path.basename(d) for d in self.seq_dirs] 20 | # valid frame range for each sequence 21 | self.range_files = [glob.glob(os.path.join(d, '*_frames.txt'))[0] for d in self.seq_dirs] 22 | 23 | def get_sequence_list(self): 24 | return SequenceList([self._construct_sequence(s) for s in self.seq_names]) 25 | 26 | def _construct_sequence(self, sequence_name): 27 | if isinstance(sequence_name, six.string_types): 28 | if not sequence_name in self.seq_names: 29 | raise Exception('Sequence {} not found.'.format(sequence_name)) 30 | index = self.seq_names.index(sequence_name) 31 | # load valid frame range 32 | frames = np.loadtxt(self.range_files[index], dtype=int, delimiter=',') 33 | img_files = [os.path.join(self.seq_dirs[index], 'img/%04d.jpg' % f) for f in range(frames[0], frames[1] + 1)] 34 | 35 | # load annotations 36 | anno = np.loadtxt(self.anno_files[index], delimiter=',') 37 | assert len(img_files) == len(anno) 38 | assert anno.shape[1] == 4 39 | 40 | # return img_files, anno 41 | return Sequence(sequence_name, img_files, 'tc128', anno.reshape(-1, 4)) 42 | 43 | def __len__(self): 44 | return len(self.seq_names) 45 | -------------------------------------------------------------------------------- /lib/test/evaluation/trackingnetdataset.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from lib.test.evaluation.data import Sequence, BaseDataset, SequenceList 3 | import os 4 | from lib.test.utils.load_text import load_text 5 | 6 | 7 | class TrackingNetDataset(BaseDataset): 8 | """ TrackingNet test set. 9 | 10 | Publication: 11 | TrackingNet: A Large-Scale Dataset and Benchmark for Object Tracking in the Wild. 12 | Matthias Mueller,Adel Bibi, Silvio Giancola, Salman Al-Subaihi and Bernard Ghanem 13 | ECCV, 2018 14 | https://ivul.kaust.edu.sa/Documents/Publications/2018/TrackingNet%20A%20Large%20Scale%20Dataset%20and%20Benchmark%20for%20Object%20Tracking%20in%20the%20Wild.pdf 15 | 16 | Download the dataset using the toolkit https://github.com/SilvioGiancola/TrackingNet-devkit. 17 | """ 18 | def __init__(self): 19 | super().__init__() 20 | self.base_path = self.env_settings.trackingnet_path 21 | 22 | sets = 'TEST' 23 | if not isinstance(sets, (list, tuple)): 24 | if sets == 'TEST': 25 | sets = ['TEST'] 26 | elif sets == 'TRAIN': 27 | sets = ['TRAIN_{}'.format(i) for i in range(5)] 28 | 29 | self.sequence_list = self._list_sequences(self.base_path, sets) 30 | 31 | def get_sequence_list(self): 32 | return SequenceList([self._construct_sequence(set, seq_name) for set, seq_name in self.sequence_list]) 33 | 34 | def _construct_sequence(self, set, sequence_name): 35 | anno_path = '{}/{}/anno/{}.txt'.format(self.base_path, set, sequence_name) 36 | 37 | ground_truth_rect = load_text(str(anno_path), delimiter=',', dtype=np.float64, backend='numpy') 38 | 39 | frames_path = '{}/{}/frames/{}'.format(self.base_path, set, sequence_name) 40 | frame_list = [frame for frame in os.listdir(frames_path) if frame.endswith(".jpg")] 41 | frame_list.sort(key=lambda f: int(f[:-4])) 42 | frames_list = [os.path.join(frames_path, frame) for frame in frame_list] 43 | 44 | return Sequence(sequence_name, frames_list, 'trackingnet', ground_truth_rect.reshape(-1, 4)) 45 | 46 | def __len__(self): 47 | return len(self.sequence_list) 48 | 49 | def _list_sequences(self, root, set_ids): 50 | sequence_list = [] 51 | 52 | for s in set_ids: 53 | anno_dir = os.path.join(root, s, "anno") 54 | sequences_cur_set = [(s, os.path.splitext(f)[0]) for f in os.listdir(anno_dir) if f.endswith('.txt')] 55 | 56 | sequence_list += sequences_cur_set 57 | 58 | return sequence_list 59 | -------------------------------------------------------------------------------- /lib/test/parameter/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/lib/test/parameter/__init__.py -------------------------------------------------------------------------------- /lib/test/parameter/simtrack.py: -------------------------------------------------------------------------------- 1 | from lib.test.utils import TrackerParams 2 | import os 3 | from lib.test.evaluation.environment import env_settings 4 | from lib.config.simtrack.config import cfg, update_config_from_file 5 | 6 | 7 | def parameters(yaml_name: str): 8 | params = TrackerParams() 9 | prj_dir = env_settings().prj_dir 10 | save_dir = env_settings().save_dir 11 | # update default config from yaml file 12 | yaml_file = os.path.join(prj_dir, 'experiments/simtrack/%s.yaml' % yaml_name) 13 | update_config_from_file(yaml_file) 14 | params.cfg = cfg 15 | print("test config: ", cfg) 16 | 17 | # template and search region 18 | params.template_factor = cfg.TEST.TEMPLATE_FACTOR 19 | params.template_size = cfg.TEST.TEMPLATE_SIZE 20 | params.search_factor = cfg.TEST.SEARCH_FACTOR 21 | params.search_size = cfg.TEST.SEARCH_SIZE 22 | 23 | # Network checkpoint path 24 | params.checkpoint = os.path.join(save_dir, "checkpoints/train/simtrack/%s/SimTrack_ep%04d.pth.tar" % 25 | (yaml_name, cfg.TEST.EPOCH)) 26 | 27 | # whether to save boxes from all queries 28 | params.save_all_boxes = False 29 | 30 | return params 31 | -------------------------------------------------------------------------------- /lib/test/parameter/stark_lightning_X_trt.py: -------------------------------------------------------------------------------- 1 | from lib.test.utils import TrackerParams 2 | import os 3 | from lib.test.evaluation.environment import env_settings 4 | from lib.config.stark_lightning_X_trt.config import cfg, update_config_from_file 5 | 6 | 7 | def parameters(yaml_name: str): 8 | params = TrackerParams() 9 | prj_dir = env_settings().prj_dir 10 | save_dir = env_settings().save_dir 11 | # update default config from yaml file 12 | yaml_file = os.path.join(prj_dir, 'experiments/stark_lightning_X_trt/%s.yaml' % yaml_name) 13 | update_config_from_file(yaml_file) 14 | params.cfg = cfg 15 | print("test config: ", cfg) 16 | 17 | # template and search region 18 | params.template_factor = cfg.TEST.TEMPLATE_FACTOR 19 | params.template_size = cfg.TEST.TEMPLATE_SIZE 20 | params.search_factor = cfg.TEST.SEARCH_FACTOR 21 | params.search_size = cfg.TEST.SEARCH_SIZE 22 | 23 | # Network checkpoint path 24 | params.checkpoint = os.path.join(save_dir, 25 | "checkpoints/train/stark_lightning_X_trt/%s/STARKLightningXtrt_ep%04d.pth.tar" % 26 | (yaml_name, cfg.TEST.EPOCH)) 27 | # whether to save boxes from all queries 28 | params.save_all_boxes = False 29 | return params 30 | -------------------------------------------------------------------------------- /lib/test/parameter/stark_s.py: -------------------------------------------------------------------------------- 1 | from lib.test.utils import TrackerParams 2 | import os 3 | from lib.test.evaluation.environment import env_settings 4 | from lib.config.stark_s.config import cfg, update_config_from_file 5 | 6 | 7 | def parameters(yaml_name: str): 8 | params = TrackerParams() 9 | prj_dir = env_settings().prj_dir 10 | save_dir = env_settings().save_dir 11 | # update default config from yaml file 12 | yaml_file = os.path.join(prj_dir, 'experiments/stark_s/%s.yaml' % yaml_name) 13 | update_config_from_file(yaml_file) 14 | params.cfg = cfg 15 | print("test config: ", cfg) 16 | 17 | # template and search region 18 | params.template_factor = cfg.TEST.TEMPLATE_FACTOR 19 | params.template_size = cfg.TEST.TEMPLATE_SIZE 20 | params.search_factor = cfg.TEST.SEARCH_FACTOR 21 | params.search_size = cfg.TEST.SEARCH_SIZE 22 | 23 | # Network checkpoint path 24 | params.checkpoint = os.path.join(save_dir, "checkpoints/train/stark_s/%s/STARKS_ep%04d.pth.tar" % 25 | (yaml_name, cfg.TEST.EPOCH)) 26 | 27 | # whether to save boxes from all queries 28 | params.save_all_boxes = False 29 | 30 | return params 31 | -------------------------------------------------------------------------------- /lib/test/parameter/stark_st.py: -------------------------------------------------------------------------------- 1 | from lib.test.utils import TrackerParams 2 | import os 3 | from lib.test.evaluation.environment import env_settings 4 | from lib.config.stark_st2.config import cfg, update_config_from_file 5 | 6 | 7 | def parameters(yaml_name: str): 8 | params = TrackerParams() 9 | prj_dir = env_settings().prj_dir 10 | save_dir = env_settings().save_dir 11 | # update default config from yaml file 12 | yaml_file = os.path.join(prj_dir, 'experiments/stark_st2/%s.yaml' % yaml_name) 13 | update_config_from_file(yaml_file) 14 | params.cfg = cfg 15 | print("test config: ", cfg) 16 | 17 | # template and search region 18 | params.template_factor = cfg.TEST.TEMPLATE_FACTOR 19 | params.template_size = cfg.TEST.TEMPLATE_SIZE 20 | params.search_factor = cfg.TEST.SEARCH_FACTOR 21 | params.search_size = cfg.TEST.SEARCH_SIZE 22 | 23 | # Network checkpoint path 24 | params.checkpoint = os.path.join(save_dir, "checkpoints/train/stark_st2/%s/STARKST_ep%04d.pth.tar" % 25 | (yaml_name, cfg.TEST.EPOCH)) 26 | 27 | # whether to save boxes from all queries 28 | params.save_all_boxes = False 29 | 30 | return params 31 | -------------------------------------------------------------------------------- /lib/test/tracker/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/lib/test/tracker/__init__.py -------------------------------------------------------------------------------- /lib/test/tracker/basetracker.py: -------------------------------------------------------------------------------- 1 | from _collections import OrderedDict 2 | 3 | 4 | class BaseTracker: 5 | """Base class for all trackers.""" 6 | 7 | def __init__(self, params): 8 | self.params = params 9 | self.visdom = None 10 | 11 | def predicts_segmentation_mask(self): 12 | return False 13 | 14 | def initialize(self, image, info: dict) -> dict: 15 | """Overload this function in your tracker. This should initialize the model.""" 16 | raise NotImplementedError 17 | 18 | def track(self, image, info: dict = None) -> dict: 19 | """Overload this function in your tracker. This should track in the frame and update the model.""" 20 | raise NotImplementedError 21 | 22 | def visdom_draw_tracking(self, image, box, segmentation=None): 23 | if isinstance(box, OrderedDict): 24 | box = [v for k, v in box.items()] 25 | else: 26 | box = (box,) 27 | if segmentation is None: 28 | self.visdom.register((image, *box), 'Tracking', 1, 'Tracking') 29 | else: 30 | self.visdom.register((image, *box, segmentation), 'Tracking', 1, 'Tracking') -------------------------------------------------------------------------------- /lib/test/tracker/stark_utils.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | from lib.utils.misc import NestedTensor 4 | 5 | 6 | class Preprocessor(object): 7 | def __init__(self): 8 | self.mean = torch.tensor([0.485, 0.456, 0.406]).view((1, 3, 1, 1)).cuda() 9 | self.std = torch.tensor([0.229, 0.224, 0.225]).view((1, 3, 1, 1)).cuda() 10 | 11 | def process(self, img_arr: np.ndarray, amask_arr: np.ndarray): 12 | # Deal with the image patch 13 | img_tensor = torch.tensor(img_arr).cuda().float().permute((2,0,1)).unsqueeze(dim=0) 14 | img_tensor_norm = ((img_tensor / 255.0) - self.mean) / self.std # (1,3,H,W) 15 | # Deal with the attention mask 16 | amask_tensor = torch.from_numpy(amask_arr).to(torch.bool).cuda().unsqueeze(dim=0) # (1,H,W) 17 | return img_tensor_norm #NestedTensor(img_tensor_norm, amask_tensor) 18 | 19 | 20 | class PreprocessorX(object): 21 | def __init__(self): 22 | self.mean = torch.tensor([0.485, 0.456, 0.406]).view((1, 3, 1, 1)).cuda() 23 | self.std = torch.tensor([0.229, 0.224, 0.225]).view((1, 3, 1, 1)).cuda() 24 | 25 | def process(self, img_arr: np.ndarray, amask_arr: np.ndarray): 26 | # Deal with the image patch 27 | img_tensor = torch.tensor(img_arr).cuda().float().permute((2,0,1)).unsqueeze(dim=0) 28 | img_tensor_norm = ((img_tensor / 255.0) - self.mean) / self.std # (1,3,H,W) 29 | # Deal with the attention mask 30 | amask_tensor = torch.from_numpy(amask_arr).to(torch.bool).cuda().unsqueeze(dim=0) # (1,H,W) 31 | return img_tensor_norm, amask_tensor 32 | 33 | 34 | class PreprocessorX_onnx(object): 35 | def __init__(self): 36 | self.mean = np.array([0.485, 0.456, 0.406]).reshape((1, 3, 1, 1)) 37 | self.std = np.array([0.229, 0.224, 0.225]).reshape((1, 3, 1, 1)) 38 | 39 | def process(self, img_arr: np.ndarray, amask_arr: np.ndarray): 40 | """img_arr: (H,W,3), amask_arr: (H,W)""" 41 | # Deal with the image patch 42 | img_arr_4d = img_arr[np.newaxis, :, :, :].transpose(0, 3, 1, 2) 43 | img_arr_4d = (img_arr_4d / 255.0 - self.mean) / self.std # (1, 3, H, W) 44 | # Deal with the attention mask 45 | amask_arr_3d = amask_arr[np.newaxis, :, :] # (1,H,W) 46 | return img_arr_4d.astype(np.float32), amask_arr_3d.astype(np.bool) 47 | -------------------------------------------------------------------------------- /lib/test/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .params import TrackerParams, FeatureParams, Choice -------------------------------------------------------------------------------- /lib/test/utils/_init_paths.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import division 3 | from __future__ import print_function 4 | 5 | import os.path as osp 6 | import sys 7 | 8 | 9 | def add_path(path): 10 | if path not in sys.path: 11 | sys.path.insert(0, path) 12 | 13 | 14 | this_dir = osp.dirname(__file__) 15 | 16 | prj_path = osp.join(this_dir, '..', '..', '..') 17 | add_path(prj_path) 18 | -------------------------------------------------------------------------------- /lib/test/utils/load_text.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pandas as pd 3 | 4 | 5 | def load_text_numpy(path, delimiter, dtype): 6 | if isinstance(delimiter, (tuple, list)): 7 | for d in delimiter: 8 | try: 9 | ground_truth_rect = np.loadtxt(path, delimiter=d, dtype=dtype) 10 | return ground_truth_rect 11 | except: 12 | pass 13 | 14 | raise Exception('Could not read file {}'.format(path)) 15 | else: 16 | ground_truth_rect = np.loadtxt(path, delimiter=delimiter, dtype=dtype) 17 | return ground_truth_rect 18 | 19 | 20 | def load_text_pandas(path, delimiter, dtype): 21 | if isinstance(delimiter, (tuple, list)): 22 | for d in delimiter: 23 | try: 24 | ground_truth_rect = pd.read_csv(path, delimiter=d, header=None, dtype=dtype, na_filter=False, 25 | low_memory=False).values 26 | return ground_truth_rect 27 | except Exception as e: 28 | pass 29 | 30 | raise Exception('Could not read file {}'.format(path)) 31 | else: 32 | ground_truth_rect = pd.read_csv(path, delimiter=delimiter, header=None, dtype=dtype, na_filter=False, 33 | low_memory=False).values 34 | return ground_truth_rect 35 | 36 | 37 | def load_text(path, delimiter=' ', dtype=np.float32, backend='numpy'): 38 | if backend == 'numpy': 39 | return load_text_numpy(path, delimiter, dtype) 40 | elif backend == 'pandas': 41 | return load_text_pandas(path, delimiter, dtype) 42 | -------------------------------------------------------------------------------- /lib/test/utils/params.py: -------------------------------------------------------------------------------- 1 | from lib.utils import TensorList 2 | import random 3 | 4 | 5 | class TrackerParams: 6 | """Class for tracker parameters.""" 7 | def set_default_values(self, default_vals: dict): 8 | for name, val in default_vals.items(): 9 | if not hasattr(self, name): 10 | setattr(self, name, val) 11 | 12 | def get(self, name: str, *default): 13 | """Get a parameter value with the given name. If it does not exists, it return the default value given as a 14 | second argument or returns an error if no default value is given.""" 15 | if len(default) > 1: 16 | raise ValueError('Can only give one default value.') 17 | 18 | if not default: 19 | return getattr(self, name) 20 | 21 | return getattr(self, name, default[0]) 22 | 23 | def has(self, name: str): 24 | """Check if there exist a parameter with the given name.""" 25 | return hasattr(self, name) 26 | 27 | 28 | class FeatureParams: 29 | """Class for feature specific parameters""" 30 | def __init__(self, *args, **kwargs): 31 | if len(args) > 0: 32 | raise ValueError 33 | 34 | for name, val in kwargs.items(): 35 | if isinstance(val, list): 36 | setattr(self, name, TensorList(val)) 37 | else: 38 | setattr(self, name, val) 39 | 40 | 41 | def Choice(*args): 42 | """Can be used to sample random parameter values.""" 43 | return random.choice(args) 44 | -------------------------------------------------------------------------------- /lib/test/utils/transform_got10k.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import os 3 | import shutil 4 | import argparse 5 | import _init_paths 6 | from lib.test.evaluation.environment import env_settings 7 | 8 | 9 | def transform_got10k(tracker_name, cfg_name): 10 | env = env_settings() 11 | result_dir = env.results_path 12 | src_dir = os.path.join(result_dir, "%s/%s/got10k/" % (tracker_name, cfg_name)) 13 | dest_dir = os.path.join(result_dir, "%s/%s/got10k_submit/" % (tracker_name, cfg_name)) 14 | if not os.path.exists(dest_dir): 15 | os.makedirs(dest_dir) 16 | items = os.listdir(src_dir) 17 | for item in items: 18 | if "all" in item: 19 | continue 20 | src_path = os.path.join(src_dir, item) 21 | if "time" not in item: 22 | seq_name = item.replace(".txt", '') 23 | seq_dir = os.path.join(dest_dir, seq_name) 24 | if not os.path.exists(seq_dir): 25 | os.makedirs(seq_dir) 26 | new_item = item.replace(".txt", '_001.txt') 27 | dest_path = os.path.join(seq_dir, new_item) 28 | bbox_arr = np.loadtxt(src_path, dtype=np.int, delimiter='\t') 29 | np.savetxt(dest_path, bbox_arr, fmt='%d', delimiter=',') 30 | else: 31 | seq_name = item.replace("_time.txt", '') 32 | seq_dir = os.path.join(dest_dir, seq_name) 33 | if not os.path.exists(seq_dir): 34 | os.makedirs(seq_dir) 35 | dest_path = os.path.join(seq_dir, item) 36 | os.system("cp %s %s" % (src_path, dest_path)) 37 | # make zip archive 38 | shutil.make_archive(src_dir, "zip", src_dir) 39 | shutil.make_archive(dest_dir, "zip", dest_dir) 40 | # Remove the original files 41 | shutil.rmtree(src_dir) 42 | shutil.rmtree(dest_dir) 43 | 44 | 45 | if __name__ == "__main__": 46 | parser = argparse.ArgumentParser(description='transform got10k results.') 47 | parser.add_argument('--tracker_name', type=str, help='Name of tracking method.') 48 | parser.add_argument('--cfg_name', type=str, help='Name of config file.') 49 | 50 | args = parser.parse_args() 51 | transform_got10k(args.tracker_name, args.cfg_name) 52 | 53 | -------------------------------------------------------------------------------- /lib/test/utils/transform_trackingnet.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import os 3 | import shutil 4 | import argparse 5 | import _init_paths 6 | from lib.test.evaluation.environment import env_settings 7 | 8 | 9 | def transform_trackingnet(tracker_name, cfg_name): 10 | env = env_settings() 11 | result_dir = env.results_path 12 | src_dir = os.path.join(result_dir, "%s/%s/trackingnet/" % (tracker_name, cfg_name)) 13 | dest_dir = os.path.join(result_dir, "%s/%s/trackingnet_submit/" % (tracker_name, cfg_name)) 14 | if not os.path.exists(dest_dir): 15 | os.makedirs(dest_dir) 16 | items = os.listdir(src_dir) 17 | for item in items: 18 | if "all" in item: 19 | continue 20 | if "time" not in item: 21 | src_path = os.path.join(src_dir, item) 22 | dest_path = os.path.join(dest_dir, item) 23 | bbox_arr = np.loadtxt(src_path, dtype=np.int, delimiter='\t') 24 | np.savetxt(dest_path, bbox_arr, fmt='%d', delimiter=',') 25 | # make zip archive 26 | shutil.make_archive(src_dir, "zip", src_dir) 27 | shutil.make_archive(dest_dir, "zip", dest_dir) 28 | # Remove the original files 29 | shutil.rmtree(src_dir) 30 | shutil.rmtree(dest_dir) 31 | 32 | 33 | if __name__ == "__main__": 34 | parser = argparse.ArgumentParser(description='transform trackingnet results.') 35 | parser.add_argument('--tracker_name', type=str, help='Name of tracking method.') 36 | parser.add_argument('--cfg_name', type=str, help='Name of config file.') 37 | 38 | args = parser.parse_args() 39 | transform_trackingnet(args.tracker_name, args.cfg_name) 40 | -------------------------------------------------------------------------------- /lib/test/vot20/stark_s50.py: -------------------------------------------------------------------------------- 1 | from lib.test.vot20.stark_vot20 import run_vot_exp 2 | import os 3 | os.environ['CUDA_VISIBLE_DEVICES'] = '0' 4 | run_vot_exp('stark_s', 'baseline', vis=False) 5 | -------------------------------------------------------------------------------- /lib/test/vot20/stark_st101.py: -------------------------------------------------------------------------------- 1 | from lib.test.vot20.stark_vot20 import run_vot_exp 2 | import os 3 | os.environ['CUDA_VISIBLE_DEVICES'] = '5' 4 | run_vot_exp('stark_st', 'baseline_R101', vis=False) 5 | -------------------------------------------------------------------------------- /lib/test/vot20/stark_st101_lt.py: -------------------------------------------------------------------------------- 1 | from lib.test.vot20.stark_vot20lt import run_vot_exp 2 | import os 3 | os.environ['CUDA_VISIBLE_DEVICES'] = '7' 4 | run_vot_exp('stark_st', 'baseline_R101', vis=False) 5 | -------------------------------------------------------------------------------- /lib/test/vot20/stark_st50.py: -------------------------------------------------------------------------------- 1 | from lib.test.vot20.stark_vot20 import run_vot_exp 2 | import os 3 | os.environ['CUDA_VISIBLE_DEVICES'] = '4' 4 | run_vot_exp('stark_st', 'baseline', vis=False) 5 | -------------------------------------------------------------------------------- /lib/test/vot20/stark_st50_lt.py: -------------------------------------------------------------------------------- 1 | from lib.test.vot20.stark_vot20lt import run_vot_exp 2 | import os 3 | os.environ['CUDA_VISIBLE_DEVICES'] = '6' 4 | run_vot_exp('stark_st', 'baseline', vis=False) 5 | -------------------------------------------------------------------------------- /lib/test/vot20/vot20_utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | def make_full_size(x, output_sz): 5 | """ 6 | zero-pad input x (right and down) to match output_sz 7 | x: numpy array e.g., binary mask 8 | output_sz: size of the output [width, height] 9 | """ 10 | if x.shape[0] == output_sz[1] and x.shape[1] == output_sz[0]: 11 | return x 12 | pad_x = output_sz[0] - x.shape[1] 13 | if pad_x < 0: 14 | x = x[:, :x.shape[1] + pad_x] 15 | # padding has to be set to zero, otherwise pad function fails 16 | pad_x = 0 17 | pad_y = output_sz[1] - x.shape[0] 18 | if pad_y < 0: 19 | x = x[:x.shape[0] + pad_y, :] 20 | # padding has to be set to zero, otherwise pad function fails 21 | pad_y = 0 22 | return np.pad(x, ((0, pad_y), (0, pad_x)), 'constant', constant_values=0) 23 | 24 | 25 | def rect_from_mask(mask): 26 | """ 27 | create an axis-aligned rectangle from a given binary mask 28 | mask in created as a minimal rectangle containing all non-zero pixels 29 | """ 30 | x_ = np.sum(mask, axis=0) 31 | y_ = np.sum(mask, axis=1) 32 | x0 = np.min(np.nonzero(x_)) 33 | x1 = np.max(np.nonzero(x_)) 34 | y0 = np.min(np.nonzero(y_)) 35 | y1 = np.max(np.nonzero(y_)) 36 | return [x0, y0, x1 - x0 + 1, y1 - y0 + 1] 37 | 38 | 39 | def mask_from_rect(rect, output_sz): 40 | """ 41 | create a binary mask from a given rectangle 42 | rect: axis-aligned rectangle [x0, y0, width, height] 43 | output_sz: size of the output [width, height] 44 | """ 45 | mask = np.zeros((output_sz[1], output_sz[0]), dtype=np.uint8) 46 | x0 = max(int(round(rect[0])), 0) 47 | y0 = max(int(round(rect[1])), 0) 48 | x1 = min(int(round(rect[0] + rect[2])), output_sz[0]) 49 | y1 = min(int(round(rect[1] + rect[3])), output_sz[1]) 50 | mask[y0:y1, x0:x1] = 1 51 | return mask 52 | 53 | 54 | def bbox_clip(x1, y1, x2, y2, boundary, min_sz=10): 55 | """boundary (H,W)""" 56 | x1_new = max(0, min(x1, boundary[1] - min_sz)) 57 | y1_new = max(0, min(y1, boundary[0] - min_sz)) 58 | x2_new = max(min_sz, min(x2, boundary[1])) 59 | y2_new = max(min_sz, min(y2, boundary[0])) 60 | return x1_new, y1_new, x2_new, y2_new -------------------------------------------------------------------------------- /lib/train/__init__.py: -------------------------------------------------------------------------------- 1 | from .admin.multigpu import MultiGPU 2 | -------------------------------------------------------------------------------- /lib/train/_init_paths.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import division 3 | from __future__ import print_function 4 | 5 | import os.path as osp 6 | import sys 7 | 8 | 9 | def add_path(path): 10 | if path not in sys.path: 11 | sys.path.insert(0, path) 12 | 13 | 14 | this_dir = osp.dirname(__file__) 15 | 16 | prj_path = osp.join(this_dir, '../..') 17 | add_path(prj_path) 18 | -------------------------------------------------------------------------------- /lib/train/actors/__init__.py: -------------------------------------------------------------------------------- 1 | from .base_actor import BaseActor 2 | from .stark_s import STARKSActor 3 | from .stark_st import STARKSTActor 4 | from .stark_lightningXtrt import STARKLightningXtrtActor 5 | from .stark_lightningXtrt_distill import STARKLightningXtrtdistillActor 6 | from .simtrack import SimTrackActor 7 | -------------------------------------------------------------------------------- /lib/train/actors/base_actor.py: -------------------------------------------------------------------------------- 1 | from lib.utils import TensorDict 2 | 3 | 4 | class BaseActor: 5 | """ Base class for actor. The actor class handles the passing of the data through the network 6 | and calculation the loss""" 7 | def __init__(self, net, objective): 8 | """ 9 | args: 10 | net - The network to train 11 | objective - The loss function 12 | """ 13 | self.net = net 14 | self.objective = objective 15 | 16 | def __call__(self, data: TensorDict): 17 | """ Called in each training iteration. Should pass in input data through the network, calculate the loss, and 18 | return the training stats for the input data 19 | args: 20 | data - A TensorDict containing all the necessary data blocks. 21 | 22 | returns: 23 | loss - loss for the input data 24 | stats - a dict containing detailed losses 25 | """ 26 | raise NotImplementedError 27 | 28 | def to(self, device): 29 | """ Move the network to device 30 | args: 31 | device - device to use. 'cpu' or 'cuda' 32 | """ 33 | self.net.to(device) 34 | 35 | def train(self, mode=True): 36 | """ Set whether the network is in train mode. 37 | args: 38 | mode (True) - Bool specifying whether in training mode. 39 | """ 40 | self.net.train(mode) 41 | 42 | def eval(self): 43 | """ Set network to eval mode""" 44 | self.train(False) -------------------------------------------------------------------------------- /lib/train/actors/stark_st.py: -------------------------------------------------------------------------------- 1 | from . import STARKSActor 2 | 3 | 4 | class STARKSTActor(STARKSActor): 5 | """ Actor for training the STARK-ST(Stage2)""" 6 | def __init__(self, net, objective, loss_weight, settings): 7 | super().__init__(net, objective, loss_weight, settings) 8 | self.loss_weight = loss_weight 9 | self.settings = settings 10 | self.bs = self.settings.batchsize # batch size 11 | 12 | def __call__(self, data): 13 | """ 14 | args: 15 | data - The input data, should contain the fields 'template', 'search', 'gt_bbox'. 16 | template_images: (N_t, batch, 3, H, W) 17 | search_images: (N_s, batch, 3, H, W) 18 | returns: 19 | loss - the training loss 20 | status - dict containing detailed losses 21 | """ 22 | # forward pass 23 | out_dict = self.forward_pass(data, run_box_head=False, run_cls_head=True) 24 | 25 | # process the groundtruth label 26 | labels = data['label'].view(-1) # (batch, ) 0 or 1 27 | 28 | loss, status = self.compute_losses(out_dict, labels) 29 | 30 | return loss, status 31 | 32 | def compute_losses(self, pred_dict, labels, return_status=True): 33 | loss = self.loss_weight["cls"] * self.objective['cls'](pred_dict["pred_logits"].view(-1), labels) 34 | if return_status: 35 | # status for log 36 | status = { 37 | "cls_loss": loss.item()} 38 | return loss, status 39 | else: 40 | return loss 41 | -------------------------------------------------------------------------------- /lib/train/admin/__init__.py: -------------------------------------------------------------------------------- 1 | from .environment import env_settings, create_default_local_file_ITP_train 2 | from .stats import AverageMeter, StatValue 3 | from .tensorboard import TensorboardWriter 4 | -------------------------------------------------------------------------------- /lib/train/admin/local.py: -------------------------------------------------------------------------------- 1 | class EnvironmentSettings: 2 | def __init__(self): 3 | self.workspace_dir = '' # Base directory for saving network checkpoints. 4 | self.tensorboard_dir = '' # Directory for tensorboard files. 5 | self.pretrained_networks = '' 6 | self.lasot_dir = '' 7 | self.got10k_dir = '' 8 | self.lasot_lmdb_dir = '' 9 | self.got10k_lmdb_dir = '' 10 | self.trackingnet_dir = '' 11 | self.trackingnet_lmdb_dir = '' 12 | self.coco_dir = '' 13 | self.coco_lmdb_dir = '' 14 | self.lvis_dir = '' 15 | self.sbd_dir = '' 16 | self.imagenet_dir = '' 17 | self.imagenet_lmdb_dir = '' 18 | self.imagenetdet_dir = '' 19 | self.ecssd_dir = '' 20 | self.hkuis_dir = '' 21 | self.msra10k_dir = '' 22 | self.davis_dir = '' 23 | self.youtubevos_dir = '' 24 | -------------------------------------------------------------------------------- /lib/train/admin/multigpu.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | # Here we use DistributedDataParallel(DDP) rather than DataParallel(DP) for multiple GPUs training 3 | 4 | 5 | def is_multi_gpu(net): 6 | return isinstance(net, (MultiGPU, nn.parallel.distributed.DistributedDataParallel)) 7 | 8 | 9 | class MultiGPU(nn.parallel.distributed.DistributedDataParallel): 10 | def __getattr__(self, item): 11 | try: 12 | return super().__getattr__(item) 13 | except: 14 | pass 15 | return getattr(self.module, item) 16 | -------------------------------------------------------------------------------- /lib/train/admin/settings.py: -------------------------------------------------------------------------------- 1 | from lib.train.admin.environment import env_settings 2 | 3 | 4 | class Settings: 5 | """ Training settings, e.g. the paths to datasets and networks.""" 6 | def __init__(self): 7 | self.set_default() 8 | 9 | def set_default(self): 10 | self.env = env_settings() 11 | self.use_gpu = True 12 | 13 | 14 | -------------------------------------------------------------------------------- /lib/train/admin/stats.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class StatValue: 4 | def __init__(self): 5 | self.clear() 6 | 7 | def reset(self): 8 | self.val = 0 9 | 10 | def clear(self): 11 | self.reset() 12 | self.history = [] 13 | 14 | def update(self, val): 15 | self.val = val 16 | self.history.append(self.val) 17 | 18 | 19 | class AverageMeter(object): 20 | """Computes and stores the average and current value""" 21 | def __init__(self): 22 | self.clear() 23 | self.has_new_data = False 24 | 25 | def reset(self): 26 | self.avg = 0 27 | self.val = 0 28 | self.sum = 0 29 | self.count = 0 30 | 31 | def clear(self): 32 | self.reset() 33 | self.history = [] 34 | 35 | def update(self, val, n=1): 36 | self.val = val 37 | self.sum += val * n 38 | self.count += n 39 | self.avg = self.sum / self.count 40 | 41 | def new_epoch(self): 42 | if self.count > 0: 43 | self.history.append(self.avg) 44 | self.reset() 45 | self.has_new_data = True 46 | else: 47 | self.has_new_data = False 48 | 49 | 50 | def topk_accuracy(output, target, topk=(1,)): 51 | """Computes the precision@k for the specified values of k""" 52 | single_input = not isinstance(topk, (tuple, list)) 53 | if single_input: 54 | topk = (topk,) 55 | 56 | maxk = max(topk) 57 | batch_size = target.size(0) 58 | 59 | _, pred = output.topk(maxk, 1, True, True) 60 | pred = pred.t() 61 | correct = pred.eq(target.view(1, -1).expand_as(pred)) 62 | 63 | res = [] 64 | for k in topk: 65 | correct_k = correct[:k].view(-1).float().sum(0, keepdim=True)[0] 66 | res.append(correct_k * 100.0 / batch_size) 67 | 68 | if single_input: 69 | return res[0] 70 | 71 | return res 72 | -------------------------------------------------------------------------------- /lib/train/admin/tensorboard.py: -------------------------------------------------------------------------------- 1 | import os 2 | from collections import OrderedDict 3 | try: 4 | from torch.utils.tensorboard import SummaryWriter 5 | except: 6 | print('WARNING: You are using tensorboardX instead sis you have a too old pytorch version.') 7 | from tensorboardX import SummaryWriter 8 | 9 | 10 | class TensorboardWriter: 11 | def __init__(self, directory, loader_names): 12 | self.directory = directory 13 | self.writer = OrderedDict({name: SummaryWriter(os.path.join(self.directory, name)) for name in loader_names}) 14 | 15 | def write_info(self, script_name, description): 16 | tb_info_writer = SummaryWriter(os.path.join(self.directory, 'info')) 17 | tb_info_writer.add_text('Script_name', script_name) 18 | tb_info_writer.add_text('Description', description) 19 | tb_info_writer.close() 20 | 21 | def write_epoch(self, stats: OrderedDict, epoch: int, ind=-1): 22 | for loader_name, loader_stats in stats.items(): 23 | if loader_stats is None: 24 | continue 25 | for var_name, val in loader_stats.items(): 26 | if hasattr(val, 'history') and getattr(val, 'has_new_data', True): 27 | self.writer[loader_name].add_scalar(var_name, val.history[ind], epoch) -------------------------------------------------------------------------------- /lib/train/data/__init__.py: -------------------------------------------------------------------------------- 1 | from .loader import LTRLoader 2 | from .image_loader import jpeg4py_loader, opencv_loader, jpeg4py_loader_w_failsafe, default_image_loader 3 | -------------------------------------------------------------------------------- /lib/train/data_specs/README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | ## Description for different text files 4 | GOT10K 5 | - got10k_train_full_split.txt: the complete GOT-10K training set. (9335 videos) 6 | - got10k_train_split.txt: part of videos from the GOT-10K training set 7 | - got10k_val_split.txt: another part of videos from the GOT-10K training set 8 | - got10k_vot_exclude.txt: 1k videos that are forbidden from "using to train models then testing on VOT" (as required by [VOT Challenge](https://www.votchallenge.net/vot2020/participation.html)) 9 | - got10k_vot_train_split.txt: part of videos from the "VOT-permitted" GOT-10K training set 10 | - got10k_vot_val_split.txt: another part of videos from the "VOT-permitted" GOT-10K training set 11 | 12 | LaSOT 13 | - lasot_train_split.txt: the complete LaSOT training set 14 | 15 | TrackingNnet 16 | - trackingnet_classmap.txt: The map from the sequence name to the target class for the TrackingNet -------------------------------------------------------------------------------- /lib/train/dataset/__init__.py: -------------------------------------------------------------------------------- 1 | from .lasot import Lasot 2 | from .got10k import Got10k 3 | from .tracking_net import TrackingNet 4 | from .imagenetvid import ImagenetVID 5 | from .coco import MSCOCO 6 | from .coco_seq import MSCOCOSeq 7 | from .got10k_lmdb import Got10k_lmdb 8 | from .lasot_lmdb import Lasot_lmdb 9 | from .imagenetvid_lmdb import ImagenetVID_lmdb 10 | from .coco_seq_lmdb import MSCOCOSeq_lmdb 11 | from .tracking_net_lmdb import TrackingNet_lmdb 12 | -------------------------------------------------------------------------------- /lib/train/dataset/base_image_dataset.py: -------------------------------------------------------------------------------- 1 | import torch.utils.data 2 | from lib.train.data.image_loader import jpeg4py_loader 3 | 4 | 5 | class BaseImageDataset(torch.utils.data.Dataset): 6 | """ Base class for image datasets """ 7 | 8 | def __init__(self, name, root, image_loader=jpeg4py_loader): 9 | """ 10 | args: 11 | root - The root path to the dataset 12 | image_loader (jpeg4py_loader) - The function to read the images. jpeg4py (https://github.com/ajkxyz/jpeg4py) 13 | is used by default. 14 | """ 15 | self.name = name 16 | self.root = root 17 | self.image_loader = image_loader 18 | 19 | self.image_list = [] # Contains the list of sequences. 20 | self.class_list = [] 21 | 22 | def __len__(self): 23 | """ Returns size of the dataset 24 | returns: 25 | int - number of samples in the dataset 26 | """ 27 | return self.get_num_images() 28 | 29 | def __getitem__(self, index): 30 | """ Not to be used! Check get_frames() instead. 31 | """ 32 | return None 33 | 34 | def get_name(self): 35 | """ Name of the dataset 36 | 37 | returns: 38 | string - Name of the dataset 39 | """ 40 | raise NotImplementedError 41 | 42 | def get_num_images(self): 43 | """ Number of sequences in a dataset 44 | 45 | returns: 46 | int - number of sequences in the dataset.""" 47 | return len(self.image_list) 48 | 49 | def has_class_info(self): 50 | return False 51 | 52 | def get_class_name(self, image_id): 53 | return None 54 | 55 | def get_num_classes(self): 56 | return len(self.class_list) 57 | 58 | def get_class_list(self): 59 | return self.class_list 60 | 61 | def get_images_in_class(self, class_name): 62 | raise NotImplementedError 63 | 64 | def has_segmentation_info(self): 65 | return False 66 | 67 | def get_image_info(self, seq_id): 68 | """ Returns information about a particular image, 69 | 70 | args: 71 | seq_id - index of the image 72 | 73 | returns: 74 | Dict 75 | """ 76 | raise NotImplementedError 77 | 78 | def get_image(self, image_id, anno=None): 79 | """ Get a image 80 | 81 | args: 82 | image_id - index of image 83 | anno(None) - The annotation for the sequence (see get_sequence_info). If None, they will be loaded. 84 | 85 | returns: 86 | image - 87 | anno - 88 | dict - A dict containing meta information about the sequence, e.g. class of the target object. 89 | 90 | """ 91 | raise NotImplementedError 92 | 93 | -------------------------------------------------------------------------------- /lib/train/trainers/__init__.py: -------------------------------------------------------------------------------- 1 | from .base_trainer import BaseTrainer 2 | from .ltr_trainer import LTRTrainer 3 | -------------------------------------------------------------------------------- /lib/tutorials/STARK_Lightning_Ch.md: -------------------------------------------------------------------------------- 1 | # STARK-Lightning 中文教程 2 | **前言**: [ONNXRUNTIME](https://github.com/microsoft/onnxruntime) 是微软开源的一个用于网络推理加速的库,在该教程中我们将教给大家如何将训练好的模型导出成ONNX格式, 3 | 并使用ONNXRUNTIME来进一步加速推理,加速后的STARK-Lightning在RTX TITAN上的运行速度可达200+ FPS!让我们开始吧 4 | ## STARK-Lightning v.s 其他跟踪器 5 | | Tracker | LaSOT (AUC)| Speed (FPS) | Params (MB)| 6 | |---|---|---|---| 7 | |**STARK-Lightning**|**58.2**|**~200**|**8.2**| 8 | |DiMP50|56.8|~50|165| 9 | |DaSiamRPN|41.5|~200|362| 10 | |SiamFC|33.6|~100|8.9| 11 | 12 | STARK-Lightning取得了比DiMP50更强的性能,运行速度和DaSiamRPN一样快 :zap: ,而模型大小比SiamFC还要更小一些! 13 | ## (非必须) 训练 STARK-Lightning 14 | 运行下面的指令,可8卡并行训练 15 | ``` 16 | python tracking/train.py --script stark_lightning_X_trt --config baseline_rephead_4_lite_search5 --save_dir . --mode multiple --nproc_per_node 8 17 | ``` 18 | 由于STARK-Lightning的训练很快,并且只需要极少的显存,因此也可以考虑用2卡或者4卡训练,只需对应修改 ```nproc_per_node```即可. 19 | ## 安装onnx和onnxruntime 20 | 如果想在GPU上使用onnxruntime完成推理 21 | ``` 22 | pip install onnx onnxruntime-gpu==1.6.0 23 | ``` 24 | - 这里onnxruntime-gpu的版本需要和机器上的CUDA版本还有CUDNN版本适配,版本对应关系请参考https://www.onnxruntime.ai/docs/reference/execution-providers/CUDA-ExecutionProvider.html 25 | 。在我的电脑上,CUDA版本10.2,CUDNN版本8.0.3,故安装的是onnxruntime-gpu==1.6.0 26 | 27 | 如果只需要在CPU上使用 28 | ``` 29 | pip install onnx onnxruntime 30 | ``` 31 | ## ONNX模型转换与推理测试 32 | 下载训练好的PyTorch模型权重文件 [STARK_Lightning](https://drive.google.com/file/d/1dVme6p-_j0fFcxYQ-rrF07pRuf57uPA-/view?usp=sharing) 33 | 34 | 将训练好的PyTorch模型转换成onnx格式,并测试onnxruntime 35 | ``` 36 | python tracking/ORT_lightning_X_trt_backbone_bottleneck_pe.py # for the template branch 37 | python tracking/ORT_lightning_X_trt_complete.py # for the search region branch 38 | ``` 39 | - 模型转换在终端里可以跑通,但是在pycharm里面会报找不到libcudnn8.so的错误,后面就在终端运行吧 40 | 41 | 在LaSOT上测试转换后的模型(支持多卡推理) 42 | - 首先在lib/test/tracker/stark_lightning_X_trt.py中设置 use_onnx = True, 之后运行 43 | ``` 44 | python tracking/test.py stark_lightning_X_trt baseline_rephead_4_lite_search5 --threads 8 --num_gpus 2 45 | ``` 46 | 其中num_gpus是想使用的GPU数量,threads是进程数量,我们通常将其设置成GPU数量的4倍。 47 | 如果想一个一个视频来跑,可以运行以下指令 48 | ``` 49 | python tracking/test.py stark_lightning_X_trt baseline_rephead_4_lite_search5 --threads 0 --num_gpus 1 50 | ``` 51 | - 评估跟踪指标 52 | ``` 53 | python tracking/analysis_results_ITP.py --script stark_lightning_X_trt --config baseline_rephead_4_lite_search5 54 | ``` 55 | -------------------------------------------------------------------------------- /lib/tutorials/STARK_Lightning_En.md: -------------------------------------------------------------------------------- 1 | # STARK-Lightning Tutorial 2 | **Introduction**:[ONNXRUNTIME](https://github.com/microsoft/onnxruntime) is an open-source library by Microsoft for network inference acceleration. In this tutorial, we will show how to export the trained model to ONNX format 3 | and use ONNXRUNTIME to further accelerate the inference. The accelerated STARK-Lightning can run at 200+ FPS on a RTX TITAN GPU! let's get started. 4 | ## STARK-Lightning v.s Other Trackers 5 | | Tracker | LaSOT (AUC)| Speed (FPS) | Params (MB)| 6 | |---|---|---|---| 7 | |**STARK-Lightning**|**58.2**|**~200**|**8.2**| 8 | |DiMP50|56.8|~50|165| 9 | |DaSiamRPN|41.5|~200|362| 10 | |SiamFC|33.6|~100|8.9| 11 | 12 | STARK-Lightning achieves better performance than DiMP50, runs at a competitive speed as DaSiamRPN :zap: , and has a smaller model size than SiamFC! 13 | ## (Optionally) Train STARK-Lightning 14 | Train STARK-Lightning with 8 GPUs with the following command 15 | ``` 16 | python tracking/train.py --script stark_lightning_X_trt --config baseline_rephead_4_lite_search5 --save_dir . --mode multiple --nproc_per_node 8 17 | ``` 18 | Since the training of STARK-Lightning is fast and memory-friendly, you can also train it with less GPUs (such as 2 or 4) by set ```nproc_per_node``` accordingly. 19 | ## Install onnx and onnxruntime 20 | for inference on GPU 21 | ``` 22 | pip install onnx onnxruntime-gpu==1.6.0 23 | ``` 24 | - Here the version of onnxruntime-gpu needs to be compatible to the CUDA version and CUDNN version on the machine. For more details, please refer to https://www.onnxruntime.ai/docs/reference/execution-providers/CUDA-ExecutionProvider.html 25 | . For example, on my computer, CUDA version is 10.2, CUDNN version is 8.0.3, so I choose onnxruntime-gpu==1.6.0 26 | 27 | for inference only on CPU 28 | ``` 29 | pip install onnx onnxruntime 30 | ``` 31 | ## ONNX Conversion and Inference 32 | Download trained PyTorch checkpoints [STARK_Lightning](https://drive.google.com/file/d/1dVme6p-_j0fFcxYQ-rrF07pRuf57uPA-/view?usp=sharing) 33 | 34 | Export the trained PyTorch model to onnx format, then test it with onnxruntime 35 | ``` 36 | python tracking/ORT_lightning_X_trt_backbone_bottleneck_pe.py # for the template branch 37 | python tracking/ORT_lightning_X_trt_complete.py # for the search region branch 38 | ``` 39 | - The conversion can run successfully in the terminal. However, it leads to an error of "libcudnn8.so is not found" when running in Pycharm. 40 | So please run these two commands in the terminal. 41 | 42 | Evaluate the converted onnx model on LaSOT (Support multiple-GPU inference). 43 | - Set ```use_onnx=True``` in lib/test/tracker/stark_lightning_X_trt.py, then run 44 | ``` 45 | python tracking/test.py stark_lightning_X_trt baseline_rephead_4_lite_search5 --threads 8 --num_gpus 2 46 | ``` 47 | ```num_gpus``` is the the number of GPUs to use,```threads``` is the number of processes. we usually set ```threads``` to be four times ```num_gpus```. 48 | If the user want to run the sequences one by one, you can run the following command 49 | ``` 50 | python tracking/test.py stark_lightning_X_trt baseline_rephead_4_lite_search5 --threads 0 --num_gpus 1 51 | ``` 52 | - Evaluate the tracking results 53 | ``` 54 | python tracking/analysis_results_ITP.py --script stark_lightning_X_trt --config baseline_rephead_4_lite_search5 55 | ``` 56 | -------------------------------------------------------------------------------- /lib/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .tensor import TensorDict, TensorList 2 | -------------------------------------------------------------------------------- /lib/utils/box_ops.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torchvision.ops.boxes import box_area 3 | import numpy as np 4 | 5 | 6 | def box_cxcywh_to_xyxy(x): 7 | x_c, y_c, w, h = x.unbind(-1) 8 | b = [(x_c - 0.5 * w), (y_c - 0.5 * h), 9 | (x_c + 0.5 * w), (y_c + 0.5 * h)] 10 | return torch.stack(b, dim=-1) 11 | 12 | 13 | def box_xywh_to_xyxy(x): 14 | x1, y1, w, h = x.unbind(-1) 15 | b = [x1, y1, x1 + w, y1 + h] 16 | return torch.stack(b, dim=-1) 17 | 18 | 19 | def box_xyxy_to_xywh(x): 20 | x1, y1, x2, y2 = x.unbind(-1) 21 | b = [x1, y1, x2 - x1, y2 - y1] 22 | return torch.stack(b, dim=-1) 23 | 24 | 25 | def box_xyxy_to_cxcywh(x): 26 | x0, y0, x1, y1 = x.unbind(-1) 27 | b = [(x0 + x1) / 2, (y0 + y1) / 2, 28 | (x1 - x0), (y1 - y0)] 29 | return torch.stack(b, dim=-1) 30 | 31 | 32 | # modified from torchvision to also return the union 33 | '''Note that this function only supports shape (N,4)''' 34 | 35 | 36 | def box_iou(boxes1, boxes2): 37 | """ 38 | 39 | :param boxes1: (N, 4) (x1,y1,x2,y2) 40 | :param boxes2: (N, 4) (x1,y1,x2,y2) 41 | :return: 42 | """ 43 | area1 = box_area(boxes1) # (N,) 44 | area2 = box_area(boxes2) # (N,) 45 | 46 | lt = torch.max(boxes1[:, :2], boxes2[:, :2]) # (N,2) 47 | rb = torch.min(boxes1[:, 2:], boxes2[:, 2:]) # (N,2) 48 | 49 | wh = (rb - lt).clamp(min=0) # (N,2) 50 | inter = wh[:, 0] * wh[:, 1] # (N,) 51 | 52 | union = area1 + area2 - inter 53 | 54 | iou = inter / union 55 | return iou, union 56 | 57 | 58 | '''Note that this implementation is different from DETR's''' 59 | 60 | 61 | def generalized_box_iou(boxes1, boxes2): 62 | """ 63 | Generalized IoU from https://giou.stanford.edu/ 64 | 65 | The boxes should be in [x0, y0, x1, y1] format 66 | 67 | boxes1: (N, 4) 68 | boxes2: (N, 4) 69 | """ 70 | # degenerate boxes gives inf / nan results 71 | # so do an early check 72 | # try: 73 | assert (boxes1[:, 2:] >= boxes1[:, :2]).all() 74 | assert (boxes2[:, 2:] >= boxes2[:, :2]).all() 75 | iou, union = box_iou(boxes1, boxes2) # (N,) 76 | 77 | lt = torch.min(boxes1[:, :2], boxes2[:, :2]) 78 | rb = torch.max(boxes1[:, 2:], boxes2[:, 2:]) 79 | 80 | wh = (rb - lt).clamp(min=0) # (N,2) 81 | area = wh[:, 0] * wh[:, 1] # (N,) 82 | 83 | return iou - (area - union) / area, iou 84 | 85 | 86 | def giou_loss(boxes1, boxes2): 87 | """ 88 | 89 | :param boxes1: (N, 4) (x1,y1,x2,y2) 90 | :param boxes2: (N, 4) (x1,y1,x2,y2) 91 | :return: 92 | """ 93 | giou, iou = generalized_box_iou(boxes1, boxes2) 94 | return (1 - giou).mean(), iou 95 | 96 | 97 | def clip_box(box: list, H, W, margin=0): 98 | x1, y1, w, h = box 99 | x2, y2 = x1 + w, y1 + h 100 | x1 = min(max(0, x1), W-margin) 101 | x2 = min(max(margin, x2), W) 102 | y1 = min(max(0, y1), H-margin) 103 | y2 = min(max(margin, y2), H) 104 | w = max(margin, x2-x1) 105 | h = max(margin, y2-y1) 106 | return [x1, y1, w, h] 107 | -------------------------------------------------------------------------------- /lib/utils/lmdb_utils.py: -------------------------------------------------------------------------------- 1 | import lmdb 2 | import numpy as np 3 | import cv2 4 | import json 5 | 6 | LMDB_ENVS = dict() 7 | LMDB_HANDLES = dict() 8 | LMDB_FILELISTS = dict() 9 | 10 | 11 | def get_lmdb_handle(name): 12 | global LMDB_HANDLES, LMDB_FILELISTS 13 | item = LMDB_HANDLES.get(name, None) 14 | if item is None: 15 | env = lmdb.open(name, readonly=True, lock=False, readahead=False, meminit=False) 16 | LMDB_ENVS[name] = env 17 | item = env.begin(write=False) 18 | LMDB_HANDLES[name] = item 19 | 20 | return item 21 | 22 | 23 | def decode_img(lmdb_fname, key_name): 24 | handle = get_lmdb_handle(lmdb_fname) 25 | binfile = handle.get(key_name.encode()) 26 | if binfile is None: 27 | print("Illegal data detected. %s %s" % (lmdb_fname, key_name)) 28 | s = np.frombuffer(binfile, np.uint8) 29 | x = cv2.cvtColor(cv2.imdecode(s, cv2.IMREAD_COLOR), cv2.COLOR_BGR2RGB) 30 | return x 31 | 32 | 33 | def decode_str(lmdb_fname, key_name): 34 | handle = get_lmdb_handle(lmdb_fname) 35 | binfile = handle.get(key_name.encode()) 36 | string = binfile.decode() 37 | return string 38 | 39 | 40 | def decode_json(lmdb_fname, key_name): 41 | return json.loads(decode_str(lmdb_fname, key_name)) 42 | 43 | 44 | if __name__ == "__main__": 45 | lmdb_fname = "/data/sda/v-yanbi/iccv21/LittleBoy_clean/data/got10k_lmdb" 46 | '''Decode image''' 47 | # key_name = "test/GOT-10k_Test_000001/00000001.jpg" 48 | # img = decode_img(lmdb_fname, key_name) 49 | # cv2.imwrite("001.jpg", img) 50 | '''Decode str''' 51 | # key_name = "test/list.txt" 52 | # key_name = "train/GOT-10k_Train_000001/groundtruth.txt" 53 | key_name = "train/GOT-10k_Train_000001/absence.label" 54 | str_ = decode_str(lmdb_fname, key_name) 55 | print(str_) 56 | -------------------------------------------------------------------------------- /lib/utils/merge.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | def merge_template_search(inp_list, return_search=False, return_template=False): 5 | """NOTICE: search region related features must be in the last place""" 6 | seq_dict = {"feat": torch.cat([x["feat"] for x in inp_list], dim=0), 7 | "mask": torch.cat([x["mask"] for x in inp_list], dim=1), 8 | "pos": torch.cat([x["pos"] for x in inp_list], dim=0)} 9 | if return_search: 10 | x = inp_list[-1] 11 | seq_dict.update({"feat_x": x["feat"], "mask_x": x["mask"], "pos_x": x["pos"]}) 12 | if return_template: 13 | z = inp_list[0] 14 | seq_dict.update({"feat_z": z["feat"], "mask_z": z["mask"], "pos_z": z["pos"]}) 15 | return seq_dict 16 | 17 | 18 | def get_qkv(inp_list): 19 | """The 1st element of the inp_list is about the template, 20 | the 2nd (the last) element is about the search region""" 21 | dict_x = inp_list[-1] 22 | dict_c = {"feat": torch.cat([x["feat"] for x in inp_list], dim=0), 23 | "mask": torch.cat([x["mask"] for x in inp_list], dim=1), 24 | "pos": torch.cat([x["pos"] for x in inp_list], dim=0)} # concatenated dict 25 | q = dict_x["feat"] + dict_x["pos"] 26 | k = dict_c["feat"] + dict_c["pos"] 27 | v = dict_c["feat"] 28 | key_padding_mask = dict_c["mask"] 29 | return q, k, v, key_padding_mask 30 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | #NNODES=${NNODES:-1} 2 | #NODE_RANK=${NODE_RANK:-0} 3 | #PORT=${PORT:-29525} 4 | #MASTER_ADDR=${MASTER_ADDR:-"127.0.0.1"} 5 | PYTHONPATH="$(dirname $0)":$PYTHONPATH 6 | 7 | #srun -p ai4science -n1 --gres=gpu:8 --ntasks-per-node=1 --cpus-per-task=5 --quotatype spot \ 8 | python tracking/test.py simtrack baseline --dataset lasot --threads 32 9 | -------------------------------------------------------------------------------- /tracking/Framework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LPXTT/SimTrack/a89a268aa7b70186fad4af70d994b489e8b5b942/tracking/Framework.png -------------------------------------------------------------------------------- /tracking/_init_paths.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import division 3 | from __future__ import print_function 4 | 5 | import os.path as osp 6 | import sys 7 | 8 | 9 | def add_path(path): 10 | if path not in sys.path: 11 | sys.path.insert(0, path) 12 | 13 | 14 | this_dir = osp.dirname(__file__) 15 | 16 | prj_path = osp.join(this_dir, '..') 17 | add_path(prj_path) 18 | -------------------------------------------------------------------------------- /tracking/analysis_results.py: -------------------------------------------------------------------------------- 1 | import _init_paths 2 | import matplotlib.pyplot as plt 3 | plt.rcParams['figure.figsize'] = [8, 8] 4 | 5 | from lib.test.analysis.plot_results import plot_results, print_results, print_per_sequence_results 6 | from lib.test.evaluation import get_dataset, trackerlist 7 | 8 | trackers = [] 9 | dataset_name = 'tc128' 10 | """stark""" 11 | trackers.extend(trackerlist(name='stark_s', parameter_name='baseline', dataset_name=dataset_name, 12 | run_ids=None, display_name='STARK-S50')) 13 | trackers.extend(trackerlist(name='stark_st', parameter_name='baseline', dataset_name=dataset_name, 14 | run_ids=None, display_name='STARK-ST50')) 15 | trackers.extend(trackerlist(name='stark_st', parameter_name='baseline_R101', dataset_name=dataset_name, 16 | run_ids=None, display_name='STARK-ST101')) 17 | """TransT""" 18 | # trackers.extend(trackerlist(name='TransT_N2', parameter_name=None, dataset_name=None, 19 | # run_ids=None, display_name='TransT_N2', result_only=True)) 20 | # trackers.extend(trackerlist(name='TransT_N4', parameter_name=None, dataset_name=None, 21 | # run_ids=None, display_name='TransT_N4', result_only=True)) 22 | """pytracking""" 23 | # trackers.extend(trackerlist('atom', 'default', None, range(0,5), 'ATOM')) 24 | # trackers.extend(trackerlist('dimp', 'dimp18', None, range(0,5), 'DiMP18')) 25 | # trackers.extend(trackerlist('dimp', 'dimp50', None, range(0,5), 'DiMP50')) 26 | # trackers.extend(trackerlist('dimp', 'prdimp18', None, range(0,5), 'PrDiMP18')) 27 | # trackers.extend(trackerlist('dimp', 'prdimp50', None, range(0,5), 'PrDiMP50')) 28 | 29 | # dataset = get_dataset(dataset_name) 30 | dataset = get_dataset('otb', 'nfs', 'uav', 'tc128ce') 31 | # plot_results(trackers, dataset, 'OTB2015', merge_results=True, plot_types=('success', 'norm_prec'), 32 | # skip_missing_seq=False, force_evaluation=True, plot_bin_gap=0.05) 33 | print_results(trackers, dataset, dataset_name, merge_results=True, plot_types=('success', 'prec')) 34 | # print_results(trackers, dataset, 'UNO', merge_results=True, plot_types=('success', 'prec')) 35 | -------------------------------------------------------------------------------- /tracking/analysis_results_ITP.py: -------------------------------------------------------------------------------- 1 | import _init_paths 2 | import argparse 3 | from lib.test.analysis.plot_results import print_results 4 | from lib.test.evaluation import get_dataset, trackerlist 5 | 6 | 7 | def parse_args(): 8 | """ 9 | args for evaluation. 10 | """ 11 | parser = argparse.ArgumentParser(description='Parse args for training') 12 | # for train 13 | parser.add_argument('--script', type=str, help='training script name') 14 | parser.add_argument('--config', type=str, default='baseline', help='yaml configure file name') 15 | 16 | args = parser.parse_args() 17 | 18 | return args 19 | 20 | 21 | if __name__ == "__main__": 22 | args = parse_args() 23 | trackers = [] 24 | trackers.extend(trackerlist(args.script, args.config, "None", None, args.config)) 25 | 26 | dataset = get_dataset('lasot') 27 | 28 | print_results(trackers, dataset, 'LaSOT', merge_results=True, plot_types=('success', 'prec', 'norm_prec')) -------------------------------------------------------------------------------- /tracking/convert_transt.py: -------------------------------------------------------------------------------- 1 | import _init_paths 2 | import os 3 | from lib.test.evaluation import get_dataset 4 | import shutil 5 | 6 | trackers = [] 7 | # dataset_name = 'uav' 8 | dataset_name = 'nfs' 9 | 10 | 11 | root_dir = "/data/sda/v-yanbi/iccv21/STARK_Latest/Stark" 12 | base_dir = os.path.join(root_dir, "test/tracking_results/TransT_N2") 13 | dataset = get_dataset(dataset_name) 14 | for x in dataset: 15 | seq_name = x.name 16 | file_name = "%s.txt" % (seq_name.replace("nfs_", "")) 17 | file_path = os.path.join(base_dir, file_name) 18 | file_path_new = os.path.join(base_dir, "%s.txt" % seq_name) 19 | if os.path.exists(file_path): 20 | shutil.move(file_path, file_path_new) 21 | 22 | -------------------------------------------------------------------------------- /tracking/create_default_local_file.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import os 3 | import _init_paths 4 | from lib.train.admin import create_default_local_file_ITP_train 5 | from lib.test.evaluation import create_default_local_file_ITP_test 6 | 7 | 8 | def parse_args(): 9 | parser = argparse.ArgumentParser(description='Create default local file on ITP or PAI') 10 | parser.add_argument("--workspace_dir", type=str, required=True) # workspace dir 11 | parser.add_argument("--data_dir", type=str, required=True) 12 | parser.add_argument("--save_dir", type=str, required=True) 13 | args = parser.parse_args() 14 | return args 15 | 16 | 17 | if __name__ == "__main__": 18 | args = parse_args() 19 | workspace_dir = os.path.realpath(args.workspace_dir) 20 | data_dir = os.path.realpath(args.data_dir) 21 | save_dir = os.path.realpath(args.save_dir) 22 | create_default_local_file_ITP_train(workspace_dir, data_dir) 23 | create_default_local_file_ITP_test(workspace_dir, data_dir, save_dir) 24 | -------------------------------------------------------------------------------- /tracking/pre_read_datasets.py: -------------------------------------------------------------------------------- 1 | import _init_paths 2 | import multiprocessing as mp 3 | import argparse 4 | import os 5 | from lib.utils.lmdb_utils import decode_str 6 | import time 7 | import json 8 | 9 | 10 | def parse_args(): 11 | """ 12 | args for training. 13 | """ 14 | parser = argparse.ArgumentParser(description='Parse args for training') 15 | parser.add_argument('--data_dir', type=str, help='directory where lmdb data is located') 16 | parser.add_argument('--dataset_str', type=str, help="which datasets to use") 17 | args = parser.parse_args() 18 | 19 | return args 20 | 21 | 22 | def get_trknet_dict(trknet_dir): 23 | with open(os.path.join(trknet_dir, "seq_list.json"), "r") as f: 24 | seq_list = json.loads(f.read()) 25 | res_dict = {} 26 | set_idx_pre = -1 27 | for set_idx, seq_name in seq_list: 28 | if set_idx != set_idx_pre: 29 | res_dict[set_idx] = "anno/%s.txt" % seq_name 30 | set_idx_pre = set_idx 31 | return res_dict 32 | 33 | 34 | def target(lmdb_dir, key_name): 35 | _ = decode_str(lmdb_dir, key_name) 36 | 37 | 38 | if __name__ == "__main__": 39 | args = parse_args() 40 | data_dir = args.data_dir 41 | dataset_str = args.dataset_str 42 | key_dict = {"got10k_lmdb": "train/list.txt", 43 | "lasot_lmdb": "LaSOTBenchmark.json", 44 | "coco_lmdb": "annotations/instances_train2017.json", 45 | "vid_lmdb": "cache.json"} 46 | print("Ready to pre load datasets") 47 | start = time.time() 48 | ps = [] 49 | datasets = [] 50 | if 'g' in dataset_str: 51 | datasets.append("got10k_lmdb") 52 | if 'l' in dataset_str: 53 | datasets.append("lasot_lmdb") 54 | if 'c' in dataset_str: 55 | datasets.append("coco_lmdb") 56 | if 'v' in dataset_str: 57 | datasets.append("vid_lmdb") 58 | for dataset in datasets: 59 | lmdb_dir = os.path.join(data_dir, dataset) 60 | p = mp.Process(target=target, args=(lmdb_dir, key_dict[dataset])) 61 | print("add %s %s to job queue" % (lmdb_dir, key_dict[dataset])) 62 | ps.append(p) 63 | # deal with trackingnet 64 | if 't' in dataset_str: 65 | trknet_dict = get_trknet_dict(os.path.join(data_dir, "trackingnet_lmdb")) 66 | for set_idx, seq_path in trknet_dict.items(): 67 | lmdb_dir = os.path.join(data_dir, "trackingnet_lmdb", "TRAIN_%d_lmdb" % set_idx) 68 | p = mp.Process(target=target, args=(lmdb_dir, seq_path)) 69 | print("add %s %s to job queue" % (lmdb_dir, seq_path)) 70 | ps.append(p) 71 | for p in ps: 72 | p.start() 73 | for p in ps: 74 | p.join() 75 | 76 | print("Pre read over") 77 | end = time.time() 78 | hour = (end - start) / 3600 79 | print("it takes %.2f hours to pre-read data" % hour) 80 | -------------------------------------------------------------------------------- /tracking/test.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import argparse 4 | 5 | prj_path = os.path.join(os.path.dirname(__file__), '..') 6 | if prj_path not in sys.path: 7 | sys.path.append(prj_path) 8 | 9 | from lib.test.evaluation import get_dataset 10 | from lib.test.evaluation.running import run_dataset 11 | from lib.test.evaluation.tracker import Tracker 12 | 13 | from pdb import set_trace 14 | def run_tracker(tracker_name, tracker_param, run_id=None, dataset_name='otb', sequence=None, debug=0, threads=0, 15 | num_gpus=4): 16 | """Run tracker on sequence or dataset. 17 | args: 18 | tracker_name: Name of tracking method. 19 | tracker_param: Name of parameter file. 20 | run_id: The run id. 21 | dataset_name: Name of dataset (otb, nfs, uav, tpl, vot, tn, gott, gotv, lasot). 22 | sequence: Sequence number or name. 23 | debug: Debug level. 24 | threads: Number of threads. 25 | """ 26 | 27 | dataset = get_dataset(dataset_name) 28 | 29 | if sequence is not None: 30 | dataset = [dataset[sequence]] 31 | 32 | trackers = [Tracker(tracker_name, tracker_param, dataset_name, run_id)] 33 | # set_trace() 34 | run_dataset(dataset, trackers, debug, threads, num_gpus=num_gpus) 35 | 36 | 37 | def main(): 38 | parser = argparse.ArgumentParser(description='Run tracker on sequence or dataset.') 39 | parser.add_argument('tracker_name', type=str, help='Name of tracking method.') 40 | parser.add_argument('tracker_param', type=str, help='Name of config file.') 41 | parser.add_argument('--runid', type=int, default=None, help='The run id.') 42 | parser.add_argument('--dataset_name', type=str, default='otb', help='Name of dataset (otb, nfs, uav, tpl, vot, tn, gott, gotv, lasot).') 43 | parser.add_argument('--sequence', type=str, default=None, help='Sequence number or name.') 44 | parser.add_argument('--debug', type=int, default=0, help='Debug level.') 45 | parser.add_argument('--threads', type=int, default=0, help='Number of threads.') 46 | parser.add_argument('--num_gpus', type=int, default=8) 47 | 48 | args = parser.parse_args() 49 | 50 | try: 51 | seq_name = int(args.sequence) 52 | except: 53 | seq_name = args.sequence 54 | 55 | run_tracker(args.tracker_name, args.tracker_param, args.runid, args.dataset_name, seq_name, args.debug, 56 | args.threads, num_gpus=args.num_gpus) 57 | 58 | 59 | if __name__ == '__main__': 60 | main() 61 | -------------------------------------------------------------------------------- /tracking/train.py: -------------------------------------------------------------------------------- 1 | import os 2 | import argparse 3 | 4 | 5 | def parse_args(): 6 | """ 7 | args for training. 8 | """ 9 | parser = argparse.ArgumentParser(description='Parse args for training') 10 | # for train 11 | parser.add_argument('--script', type=str, help='training script name') 12 | parser.add_argument('--config', type=str, default='baseline', help='yaml configure file name') 13 | parser.add_argument('--save_dir', type=str, help='root directory to save checkpoints, logs, and tensorboard') 14 | parser.add_argument('--mode', type=str, choices=["single", "multiple"], default="multiple", 15 | help="train on single gpu or multiple gpus") 16 | parser.add_argument('--nproc_per_node', type=int, help="number of GPUs per node") # specify when mode is multiple 17 | parser.add_argument('--use_lmdb', type=int, choices=[0, 1], default=0) # whether datasets are in lmdb format 18 | parser.add_argument('--script_prv', type=str, help='training script name') 19 | parser.add_argument('--config_prv', type=str, default='baseline', help='yaml configure file name') 20 | # for knowledge distillation 21 | parser.add_argument('--distill', type=int, choices=[0, 1], default=0) # whether to use knowledge distillation 22 | parser.add_argument('--script_teacher', type=str, help='teacher script name') 23 | parser.add_argument('--config_teacher', type=str, help='teacher yaml configure file name') 24 | 25 | args = parser.parse_args() 26 | 27 | return args 28 | 29 | 30 | def main(): 31 | args = parse_args() 32 | if args.mode == "single": 33 | train_cmd = "python lib/train/run_training.py --script %s --config %s --save_dir %s --use_lmdb %d " \ 34 | "--script_prv %s --config_prv %s --distill %d --script_teacher %s --config_teacher %s" \ 35 | % (args.script, args.config, args.save_dir, args.use_lmdb, args.script_prv, args.config_prv, 36 | args.distill, args.script_teacher, args.config_teacher) 37 | elif args.mode == "multiple": 38 | train_cmd = "python -m torch.distributed.launch --nproc_per_node %d lib/train/run_training.py " \ 39 | "--script %s --config %s --save_dir %s --use_lmdb %d --script_prv %s --config_prv %s " \ 40 | "--distill %d --script_teacher %s --config_teacher %s" \ 41 | % (args.nproc_per_node, args.script, args.config, args.save_dir, args.use_lmdb, args.script_prv, 42 | args.config_prv, args.distill, args.script_teacher, args.config_teacher) 43 | else: 44 | raise ValueError("mode should be 'single' or 'multiple'.") 45 | os.system(train_cmd) 46 | 47 | 48 | if __name__ == "__main__": 49 | main() 50 | -------------------------------------------------------------------------------- /tracking/video_demo.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import argparse 4 | 5 | prj_path = os.path.join(os.path.dirname(__file__), '..') 6 | if prj_path not in sys.path: 7 | sys.path.append(prj_path) 8 | 9 | from lib.test.evaluation import Tracker 10 | 11 | 12 | def run_video(tracker_name, tracker_param, videofile, optional_box=None, debug=None, save_results=False): 13 | """Run the tracker on your webcam. 14 | args: 15 | tracker_name: Name of tracking method. 16 | tracker_param: Name of parameter file. 17 | debug: Debug level. 18 | """ 19 | tracker = Tracker(tracker_name, tracker_param, "video") 20 | tracker.run_video(videofilepath=videofile, optional_box=optional_box, debug=debug, save_results=save_results) 21 | 22 | 23 | def main(): 24 | parser = argparse.ArgumentParser(description='Run the tracker on your webcam.') 25 | parser.add_argument('tracker_name', type=str, help='Name of tracking method.') 26 | parser.add_argument('tracker_param', type=str, help='Name of parameter file.') 27 | parser.add_argument('videofile', type=str, help='path to a video file.') 28 | parser.add_argument('--optional_box', type=float, default=None, nargs="+", help='optional_box with format x y w h.') 29 | parser.add_argument('--debug', type=int, default=0, help='Debug level.') 30 | parser.add_argument('--save_results', dest='save_results', action='store_true', help='Save bounding boxes') 31 | parser.set_defaults(save_results=False) 32 | 33 | args = parser.parse_args() 34 | 35 | run_video(args.tracker_name, args.tracker_param, args.videofile, args.optional_box, args.debug, args.save_results) 36 | 37 | 38 | if __name__ == '__main__': 39 | main() 40 | -------------------------------------------------------------------------------- /train.sh: -------------------------------------------------------------------------------- 1 | PYTHONPATH="$(dirname $0)":$PYTHONPATH 2 | 3 | #srun -p ai4science -n1 --gres=gpu:8 --ntasks-per-node=1 --cpus-per-task=5 --quotatype spot \ 4 | python tracking/train.py --script simtrack --config baseline_got10k_only --save_dir . --mode multiple --nproc_per_node 8 5 | --------------------------------------------------------------------------------