├── Depthtrack_workspace ├── config.yaml ├── seqtrack_b256.ini ├── seqtrack_b384.ini ├── seqtrack_l256.ini └── seqtrack_l384.ini ├── Figures ├── Framework.png ├── Frameworkv2.png └── pipeline.gif ├── LICENSE ├── MODEL_ZOO.md ├── README.md ├── RGBE_workspace └── test_rgbe_mgpus.py ├── RGBT_workspace └── test_rgbt_mgpus.py ├── VOT22RGBD_workspace ├── config.yaml ├── seqtrack_b256.ini ├── seqtrack_b384.ini ├── seqtrack_l256.ini └── seqtrack_l384.ini ├── experiments ├── seqtrack │ ├── seqtrack_b256.yaml │ ├── seqtrack_b256_got.yaml │ ├── seqtrack_b384.yaml │ ├── seqtrack_b384_got.yaml │ ├── seqtrack_l256.yaml │ ├── seqtrack_l256_got.yaml │ ├── seqtrack_l384.yaml │ └── seqtrack_l384_got.yaml └── seqtrackv2 │ ├── seqtrackv2_b256.yaml │ ├── seqtrackv2_b384.yaml │ ├── seqtrackv2_l256.yaml │ └── seqtrackv2_l384.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 │ │ │ ├── local.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 │ │ ├── seqtrack_alpha_seg_class.py │ │ ├── seqtrack_b256_ar.py │ │ ├── seqtrack_b384_ar.py │ │ ├── seqtrack_l256_ar.py │ │ ├── seqtrack_l384_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 │ │ ├── local.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 └── vot20 │ └── seqtrack │ ├── config.yaml │ ├── exp.sh │ ├── seqtrack_b256.ini │ ├── seqtrack_b256_ar.ini │ ├── seqtrack_b384.ini │ ├── seqtrack_b384_ar.ini │ ├── seqtrack_l256.ini │ ├── seqtrack_l256_ar.ini │ ├── seqtrack_l384.ini │ └── seqtrack_l384_ar.ini ├── install.sh ├── lib ├── __init__.py ├── config │ ├── __init__.py │ ├── seqtrack │ │ └── config.py │ └── seqtrackv2 │ │ └── config.py ├── models │ ├── __init__.py │ ├── seqtrack │ │ ├── __init__.py │ │ ├── decoder.py │ │ ├── encoder.py │ │ ├── seqtrack.py │ │ └── vit.py │ └── seqtrackv2 │ │ ├── __init__.py │ │ ├── decoder.py │ │ ├── encoder.py │ │ ├── language_model.py │ │ ├── seqtrackv2.py │ │ ├── utils.py │ │ ├── vit.py │ │ └── vit_mm.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 │ │ ├── lasotextensionsubsetdataset.py │ │ ├── lasotlangdataset.py │ │ ├── local.py │ │ ├── nfsdataset.py │ │ ├── nfsdataset_back.py │ │ ├── otb99langdataset.py │ │ ├── otbdataset.py │ │ ├── running.py │ │ ├── tc128cedataset.py │ │ ├── tc128dataset.py │ │ ├── tnl2kdataset.py │ │ ├── tracker.py │ │ ├── trackingnetdataset.py │ │ └── uavdataset.py │ ├── parameter │ │ ├── __init__.py │ │ ├── seqtrack.py │ │ └── seqtrackv2.py │ ├── tracker │ │ ├── __init__.py │ │ ├── basetracker.py │ │ ├── seqtrack.py │ │ ├── seqtrack_utils.py │ │ └── seqtrackv2.py │ ├── utils │ │ ├── __init__.py │ │ ├── _init_paths.py │ │ ├── load_text.py │ │ ├── params.py │ │ ├── transform_got10k.py │ │ └── transform_trackingnet.py │ ├── vot │ │ ├── seqtrack_class.py │ │ ├── seqtrackv2_b256_depthtrack.py │ │ ├── seqtrackv2_b256_votrgbd.py │ │ ├── seqtrackv2_b384_depthtrack.py │ │ ├── seqtrackv2_b384_votrgbd.py │ │ ├── seqtrackv2_l256_depthtrack.py │ │ ├── seqtrackv2_l256_votrgbd.py │ │ ├── seqtrackv2_l384_depthtrack.py │ │ ├── seqtrackv2_l384_votrgbd.py │ │ ├── vot.py │ │ └── vot22_utils.py │ └── vot20 │ │ ├── seqtrack_b256.py │ │ ├── seqtrack_b384.py │ │ ├── seqtrack_l256.py │ │ ├── seqtrack_l384.py │ │ ├── seqtrack_vot20.py │ │ ├── vot.py │ │ └── vot20_utils.py ├── train │ ├── __init__.py │ ├── _init_paths.py │ ├── actors │ │ ├── __init__.py │ │ ├── actor_utils.py │ │ ├── base_actor.py │ │ ├── seqtrack.py │ │ └── seqtrackv2.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 │ │ ├── depthtrack_train.txt │ │ ├── depthtrack_val.txt │ │ ├── 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 │ │ ├── lasher_all.txt │ │ ├── lasher_train.txt │ │ ├── lasher_val.txt │ │ ├── lasot_train_split.txt │ │ ├── otb99_test_split.txt │ │ ├── otb99_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 │ │ ├── depth_utils.py │ │ ├── depthtrack.py │ │ ├── got10k.py │ │ ├── got10k_lmdb.py │ │ ├── imagenet1k.py │ │ ├── imagenet22k.py │ │ ├── imagenet22k_dataset.py │ │ ├── imagenetvid.py │ │ ├── imagenetvid_lmdb.py │ │ ├── lasher.py │ │ ├── lasot.py │ │ ├── lasot_lmdb.py │ │ ├── otb99_lang.py │ │ ├── refcoco_seq.py │ │ ├── refer.py │ │ ├── tnl2k.py │ │ ├── tracking_net.py │ │ ├── tracking_net_lmdb.py │ │ └── visevent.py │ ├── run_training.py │ ├── train_script.py │ └── trainers │ │ ├── __init__.py │ │ ├── base_trainer.py │ │ └── ltr_trainer.py └── utils │ ├── __init__.py │ ├── box_ops.py │ ├── ema_sched.py │ ├── gen_fname_list.py │ ├── lmdb_utils.py │ ├── lr_sched.py │ ├── merge.py │ ├── misc.py │ ├── pos_embed.py │ ├── tensor.py │ └── write_to_lmdb.py └── tracking ├── _init_paths.py ├── analysis_results.py ├── create_default_local_file.py ├── profile_model.py ├── test.py └── train.py /Depthtrack_workspace/config.yaml: -------------------------------------------------------------------------------- 1 | registry: 2 | - ./seqtrack_b256.ini 3 | - ./seqtrack_b384.ini 4 | - ./seqtrack_l256.ini 5 | - ./seqtrack_l384.ini 6 | stack: votrgbd2021 7 | -------------------------------------------------------------------------------- /Depthtrack_workspace/seqtrack_b256.ini: -------------------------------------------------------------------------------- 1 | [seqtrackv2_b256] # 2 | label = seqtrackv2_b256 3 | protocol = traxpython 4 | command = seqtrackv2_b256_depthtrack 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /path/to/SeqTrackv2/lib/test/vot 7 | -------------------------------------------------------------------------------- /Depthtrack_workspace/seqtrack_b384.ini: -------------------------------------------------------------------------------- 1 | [seqtrackv2_b384] # 2 | label = seqtrackv2_b384 3 | protocol = traxpython 4 | command = seqtrackv2_b384_depthtrack 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /path/to/SeqTrackv2/lib/test/vot 7 | -------------------------------------------------------------------------------- /Depthtrack_workspace/seqtrack_l256.ini: -------------------------------------------------------------------------------- 1 | [seqtrackv2_l256] # 2 | label = seqtrackv2_l256 3 | protocol = traxpython 4 | command = seqtrackv2_l256_depthtrack 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /path/to/SeqTrackv2/lib/test/vot 7 | -------------------------------------------------------------------------------- /Depthtrack_workspace/seqtrack_l384.ini: -------------------------------------------------------------------------------- 1 | [seqtrackv2_l384] # 2 | label = seqtrackv2_l384 3 | protocol = traxpython 4 | command = seqtrackv2_l384_depthtrack 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /path/to/SeqTrackv2/lib/test/vot 7 | -------------------------------------------------------------------------------- /Figures/Framework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/Figures/Framework.png -------------------------------------------------------------------------------- /Figures/Frameworkv2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/Figures/Frameworkv2.png -------------------------------------------------------------------------------- /Figures/pipeline.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/Figures/pipeline.gif -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /VOT22RGBD_workspace/config.yaml: -------------------------------------------------------------------------------- 1 | registry: 2 | - ./seqtrack_b256.ini 3 | - ./seqtrack_b384.ini 4 | - ./seqtrack_l256.ini 5 | - ./seqtrack_l384.ini 6 | stack: vot2022/rgbd 7 | -------------------------------------------------------------------------------- /VOT22RGBD_workspace/seqtrack_b256.ini: -------------------------------------------------------------------------------- 1 | [seqtrackv2_b256] # 2 | label = seqtrackv2_b256 3 | protocol = traxpython 4 | command = seqtrackv2_b256_votrgbd 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /path/to/SeqTrackv2/lib/test/vot 7 | -------------------------------------------------------------------------------- /VOT22RGBD_workspace/seqtrack_b384.ini: -------------------------------------------------------------------------------- 1 | [seqtrackv2_b256] # 2 | label = seqtrackv2_b256 3 | protocol = traxpython 4 | command = seqtrackv2_b256_votrgbd 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /path/to/SeqTrackv2/lib/test/vot 7 | -------------------------------------------------------------------------------- /VOT22RGBD_workspace/seqtrack_l256.ini: -------------------------------------------------------------------------------- 1 | [seqtrackv2_b256] # 2 | label = seqtrackv2_b256 3 | protocol = traxpython 4 | command = seqtrackv2_b256_votrgbd 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /path/to/SeqTrackv2/lib/test/vot 7 | -------------------------------------------------------------------------------- /VOT22RGBD_workspace/seqtrack_l384.ini: -------------------------------------------------------------------------------- 1 | [seqtrackv2_b256] # 2 | label = seqtrackv2_b256 3 | protocol = traxpython 4 | command = seqtrackv2_b256_votrgbd 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /path/to/SeqTrackv2/lib/test/vot 7 | -------------------------------------------------------------------------------- /experiments/seqtrack/seqtrack_b256.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | MAX_SAMPLE_INTERVAL: 400 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: 256 12 | NUMBER: 1 13 | STD: 14 | - 0.229 15 | - 0.224 16 | - 0.225 17 | TEMPLATE: 18 | CENTER_JITTER: 0 19 | FACTOR: 4.0 20 | SCALE_JITTER: 0 21 | SIZE: 256 22 | NUMBER: 2 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 | MODEL: 36 | ENCODER: 37 | TYPE: vit_base_patch16 38 | PRETRAIN_TYPE: mae 39 | DECODER: 40 | DEC_LAYERS: 2 41 | HIDDEN_DIM: 256 42 | BINS: 4000 43 | FEATURE_TYPE: x 44 | TRAIN: 45 | ENCODER_MULTIPLIER: 0.1 46 | BATCH_SIZE: 16 47 | EPOCH: 500 48 | GRAD_CLIP_NORM: 0.1 49 | CE_WEIGHT: 1.0 50 | LR: 0.0001 51 | LR_DROP_EPOCH: 400 52 | NUM_WORKER: 8 53 | OPTIMIZER: ADAMW 54 | PRINT_INTERVAL: 50 55 | SCHEDULER: 56 | TYPE: step 57 | DECAY_RATE: 0.1 58 | WEIGHT_DECAY: 0.0001 59 | TEST: 60 | EPOCH: 500 61 | SEARCH_FACTOR: 4.0 62 | SEARCH_SIZE: 256 63 | TEMPLATE_FACTOR: 4.0 64 | TEMPLATE_SIZE: 256 65 | WINDOW: true 66 | NUM_TEMPLATES: 2 67 | UPDATE_INTERVALS: 68 | VOT20: 1 69 | VOT21: 1 70 | VOT22: 1 71 | UPDATE_THRESHOLD: 72 | VOT20: 0.55 73 | VOT21: 0.55 74 | VOT22: 0.55 75 | 76 | -------------------------------------------------------------------------------- /experiments/seqtrack/seqtrack_b256_got.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | MAX_SAMPLE_INTERVAL: 400 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: 256 12 | NUMBER: 1 13 | STD: 14 | - 0.229 15 | - 0.224 16 | - 0.225 17 | TEMPLATE: 18 | CENTER_JITTER: 0 19 | FACTOR: 4.0 20 | SCALE_JITTER: 0 21 | SIZE: 256 22 | NUMBER: 2 23 | TRAIN: 24 | DATASETS_NAME: 25 | - GOT10K_train_full 26 | DATASETS_RATIO: 27 | - 1 28 | SAMPLE_PER_EPOCH: 30000 29 | MODEL: 30 | ENCODER: 31 | TYPE: vit_base_patch16 32 | PRETRAIN_TYPE: mae 33 | DECODER: 34 | DEC_LAYERS: 2 35 | HIDDEN_DIM: 256 36 | BINS: 4000 37 | FEATURE_TYPE: x 38 | TRAIN: 39 | ENCODER_MULTIPLIER: 0.1 40 | BATCH_SIZE: 8 41 | EPOCH: 500 42 | GRAD_CLIP_NORM: 0.1 43 | CE_WEIGHT: 1.0 44 | LR: 0.0001 45 | LR_DROP_EPOCH: 400 46 | NUM_WORKER: 8 47 | OPTIMIZER: ADAMW 48 | PRINT_INTERVAL: 50 49 | SCHEDULER: 50 | TYPE: step 51 | DECAY_RATE: 0.1 52 | WEIGHT_DECAY: 0.0001 53 | TEST: 54 | EPOCH: 500 55 | SEARCH_FACTOR: 4.0 56 | SEARCH_SIZE: 256 57 | TEMPLATE_FACTOR: 4.0 58 | TEMPLATE_SIZE: 256 59 | WINDOW: true 60 | NUM_TEMPLATES: 2 61 | -------------------------------------------------------------------------------- /experiments/seqtrack/seqtrack_b384.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | MAX_SAMPLE_INTERVAL: 400 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: 384 12 | NUMBER: 1 13 | STD: 14 | - 0.229 15 | - 0.224 16 | - 0.225 17 | TEMPLATE: 18 | CENTER_JITTER: 0 19 | FACTOR: 4.0 20 | SCALE_JITTER: 0 21 | SIZE: 384 22 | NUMBER: 2 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 | MODEL: 36 | ENCODER: 37 | TYPE: vit_base_patch16 38 | PRETRAIN_TYPE: mae 39 | DECODER: 40 | DEC_LAYERS: 2 41 | HIDDEN_DIM: 256 42 | BINS: 4000 43 | FEATURE_TYPE: x 44 | TRAIN: 45 | ENCODER_MULTIPLIER: 0.1 46 | BATCH_SIZE: 8 47 | EPOCH: 500 48 | GRAD_CLIP_NORM: 0.1 49 | CE_WEIGHT: 1.0 50 | LR: 0.0001 51 | LR_DROP_EPOCH: 400 52 | NUM_WORKER: 8 53 | OPTIMIZER: ADAMW 54 | PRINT_INTERVAL: 50 55 | SCHEDULER: 56 | TYPE: step 57 | DECAY_RATE: 0.1 58 | WEIGHT_DECAY: 0.0001 59 | TEST: 60 | EPOCH: 500 61 | SEARCH_FACTOR: 4.0 62 | SEARCH_SIZE: 384 63 | TEMPLATE_FACTOR: 4.0 64 | TEMPLATE_SIZE: 384 65 | WINDOW: true 66 | NUM_TEMPLATES: 2 67 | UPDATE_INTERVALS: 68 | VOT20: 20 69 | VOT21: 20 70 | VOT22: 20 71 | UPDATE_THRESHOLD: 72 | VOT20: 0.45 73 | VOT21: 0.45 74 | VOT22: 0.45 75 | -------------------------------------------------------------------------------- /experiments/seqtrack/seqtrack_b384_got.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | MAX_SAMPLE_INTERVAL: 400 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: 384 12 | NUMBER: 1 13 | STD: 14 | - 0.229 15 | - 0.224 16 | - 0.225 17 | TEMPLATE: 18 | CENTER_JITTER: 0 19 | FACTOR: 4.0 20 | SCALE_JITTER: 0 21 | SIZE: 384 22 | NUMBER: 2 23 | TRAIN: 24 | DATASETS_NAME: 25 | - GOT10K_train_full 26 | DATASETS_RATIO: 27 | - 1 28 | SAMPLE_PER_EPOCH: 30000 29 | MODEL: 30 | ENCODER: 31 | TYPE: vit_base_patch16 32 | PRETRAIN_TYPE: mae 33 | DECODER: 34 | DEC_LAYERS: 2 35 | HIDDEN_DIM: 256 36 | BINS: 4000 37 | FEATURE_TYPE: x 38 | TRAIN: 39 | ENCODER_MULTIPLIER: 0.1 40 | BATCH_SIZE: 8 41 | EPOCH: 500 42 | GRAD_CLIP_NORM: 0.1 43 | CE_WEIGHT: 1.0 44 | LR: 0.0001 45 | LR_DROP_EPOCH: 400 46 | NUM_WORKER: 8 47 | OPTIMIZER: ADAMW 48 | PRINT_INTERVAL: 50 49 | SCHEDULER: 50 | TYPE: step 51 | DECAY_RATE: 0.1 52 | WEIGHT_DECAY: 0.0001 53 | TEST: 54 | EPOCH: 500 55 | SEARCH_FACTOR: 4.0 56 | SEARCH_SIZE: 384 57 | TEMPLATE_FACTOR: 4.0 58 | TEMPLATE_SIZE: 384 59 | WINDOW: true 60 | NUM_TEMPLATES: 2 61 | -------------------------------------------------------------------------------- /experiments/seqtrack/seqtrack_l256.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | MAX_SAMPLE_INTERVAL: 400 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: 256 12 | NUMBER: 1 13 | STD: 14 | - 0.229 15 | - 0.224 16 | - 0.225 17 | TEMPLATE: 18 | CENTER_JITTER: 0 19 | FACTOR: 4.0 20 | SCALE_JITTER: 0 21 | SIZE: 256 22 | NUMBER: 2 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 | MODEL: 36 | ENCODER: 37 | TYPE: vit_large_patch16 38 | PRETRAIN_TYPE: mae 39 | DECODER: 40 | DEC_LAYERS: 2 41 | HIDDEN_DIM: 256 42 | BINS: 4000 43 | FEATURE_TYPE: x 44 | TRAIN: 45 | ENCODER_MULTIPLIER: 0.1 46 | BATCH_SIZE: 8 47 | EPOCH: 500 48 | GRAD_CLIP_NORM: 0.1 49 | CE_WEIGHT: 1.0 50 | LR: 0.0001 51 | LR_DROP_EPOCH: 400 52 | NUM_WORKER: 8 53 | OPTIMIZER: ADAMW 54 | PRINT_INTERVAL: 50 55 | SCHEDULER: 56 | TYPE: step 57 | DECAY_RATE: 0.1 58 | WEIGHT_DECAY: 0.0001 59 | TEST: 60 | EPOCH: 500 61 | SEARCH_FACTOR: 4.0 62 | SEARCH_SIZE: 256 63 | TEMPLATE_FACTOR: 4.0 64 | TEMPLATE_SIZE: 256 65 | WINDOW: true 66 | NUM_TEMPLATES: 2 67 | -------------------------------------------------------------------------------- /experiments/seqtrack/seqtrack_l256_got.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | MAX_SAMPLE_INTERVAL: 400 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: 256 12 | NUMBER: 1 13 | STD: 14 | - 0.229 15 | - 0.224 16 | - 0.225 17 | TEMPLATE: 18 | CENTER_JITTER: 0 19 | FACTOR: 4.0 20 | SCALE_JITTER: 0 21 | SIZE: 256 22 | NUMBER: 2 23 | TRAIN: 24 | DATASETS_NAME: 25 | - GOT10K_train_full 26 | DATASETS_RATIO: 27 | - 1 28 | SAMPLE_PER_EPOCH: 30000 29 | MODEL: 30 | ENCODER: 31 | TYPE: vit_large_patch16 32 | PRETRAIN_TYPE: mae 33 | DECODER: 34 | DEC_LAYERS: 2 35 | HIDDEN_DIM: 256 36 | BINS: 4000 37 | FEATURE_TYPE: x 38 | TRAIN: 39 | ENCODER_MULTIPLIER: 0.1 40 | BATCH_SIZE: 8 41 | EPOCH: 500 42 | GRAD_CLIP_NORM: 0.1 43 | CE_WEIGHT: 1.0 44 | LR: 0.0001 45 | LR_DROP_EPOCH: 400 46 | NUM_WORKER: 8 47 | OPTIMIZER: ADAMW 48 | PRINT_INTERVAL: 50 49 | SCHEDULER: 50 | TYPE: step 51 | DECAY_RATE: 0.1 52 | WEIGHT_DECAY: 0.0001 53 | TEST: 54 | EPOCH: 500 55 | SEARCH_FACTOR: 4.0 56 | SEARCH_SIZE: 256 57 | TEMPLATE_FACTOR: 4.0 58 | TEMPLATE_SIZE: 256 59 | WINDOW: true 60 | NUM_TEMPLATES: 2 61 | -------------------------------------------------------------------------------- /experiments/seqtrack/seqtrack_l384.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | MAX_SAMPLE_INTERVAL: 400 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: 384 12 | NUMBER: 1 13 | STD: 14 | - 0.229 15 | - 0.224 16 | - 0.225 17 | TEMPLATE: 18 | CENTER_JITTER: 0 19 | FACTOR: 4.0 20 | SCALE_JITTER: 0 21 | SIZE: 384 22 | NUMBER: 2 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 | MODEL: 36 | ENCODER: 37 | TYPE: vit_large_patch16 38 | PRETRAIN_TYPE: mae 39 | DECODER: 40 | DEC_LAYERS: 2 41 | HIDDEN_DIM: 256 42 | BINS: 4000 43 | FEATURE_TYPE: x 44 | TRAIN: 45 | ENCODER_MULTIPLIER: 0.1 46 | BATCH_SIZE: 8 47 | EPOCH: 500 48 | GRAD_CLIP_NORM: 0.1 49 | CE_WEIGHT: 1.0 50 | LR: 0.0001 51 | LR_DROP_EPOCH: 400 52 | NUM_WORKER: 8 53 | OPTIMIZER: ADAMW 54 | PRINT_INTERVAL: 50 55 | SCHEDULER: 56 | TYPE: step 57 | DECAY_RATE: 0.1 58 | WEIGHT_DECAY: 0.0001 59 | TEST: 60 | EPOCH: 500 61 | SEARCH_FACTOR: 4.0 62 | SEARCH_SIZE: 384 63 | TEMPLATE_FACTOR: 4.0 64 | TEMPLATE_SIZE: 384 65 | WINDOW: true 66 | NUM_TEMPLATES: 2 67 | -------------------------------------------------------------------------------- /experiments/seqtrack/seqtrack_l384_got.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | MAX_SAMPLE_INTERVAL: 400 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: 384 12 | NUMBER: 1 13 | STD: 14 | - 0.229 15 | - 0.224 16 | - 0.225 17 | TEMPLATE: 18 | CENTER_JITTER: 0 19 | FACTOR: 4.0 20 | SCALE_JITTER: 0 21 | SIZE: 384 22 | NUMBER: 2 23 | TRAIN: 24 | DATASETS_NAME: 25 | - GOT10K_train_full 26 | DATASETS_RATIO: 27 | - 1 28 | SAMPLE_PER_EPOCH: 30000 29 | MODEL: 30 | ENCODER: 31 | TYPE: vit_large_patch16 32 | PRETRAIN_TYPE: mae 33 | DECODER: 34 | DEC_LAYERS: 2 35 | HIDDEN_DIM: 256 36 | BINS: 4000 37 | FEATURE_TYPE: x 38 | TRAIN: 39 | ENCODER_MULTIPLIER: 0.1 40 | BATCH_SIZE: 8 41 | EPOCH: 500 42 | GRAD_CLIP_NORM: 0.1 43 | CE_WEIGHT: 1.0 44 | LR: 0.0001 45 | LR_DROP_EPOCH: 400 46 | NUM_WORKER: 8 47 | OPTIMIZER: ADAMW 48 | PRINT_INTERVAL: 50 49 | SCHEDULER: 50 | TYPE: step 51 | DECAY_RATE: 0.1 52 | WEIGHT_DECAY: 0.0001 53 | TEST: 54 | EPOCH: 500 55 | SEARCH_FACTOR: 4.0 56 | SEARCH_SIZE: 384 57 | TEMPLATE_FACTOR: 4.0 58 | TEMPLATE_SIZE: 384 59 | WINDOW: true 60 | NUM_TEMPLATES: 2 61 | -------------------------------------------------------------------------------- /experiments/seqtrackv2/seqtrackv2_b256.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | MAX_SAMPLE_INTERVAL: 400 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: 256 12 | NUMBER: 1 13 | STD: 14 | - 0.229 15 | - 0.224 16 | - 0.225 17 | TEMPLATE: 18 | CENTER_JITTER: 0 19 | FACTOR: 4.0 20 | SCALE_JITTER: 0 21 | SIZE: 256 22 | NUMBER: 2 23 | TRAIN: 24 | DATASETS_NAME: 25 | - LASOT 26 | - REFCOCOG 27 | - TNL2K_train 28 | - OTB99_train 29 | - DepthTrack_train 30 | - VisEvent 31 | - LasHeR_train 32 | DATASETS_RATIO: 33 | - 1 34 | - 1 35 | - 1 36 | - 1 37 | - 4 38 | - 4 39 | - 4 40 | SAMPLE_PER_EPOCH: 60000 41 | MODEL: 42 | LANGUAGE: 43 | TYPE: 'bert-base-uncased' 44 | PATH: 'pretrained/bert/bert-base-uncased.tar.gz' 45 | VOCAB_PATH: 'pretrained/bert/bert-base-uncased-vocab.txt' 46 | BERT: 47 | ENC_NUM: 12 48 | HIDDEN_DIM: 256 49 | MAX_QUERY_LEN: 40 50 | ENCODER: 51 | TYPE: vitmm_base_patch16 52 | PRETRAIN_TYPE: mae 53 | INSTRUCT: True # task-prompt token 54 | DECODER: 55 | DEC_LAYERS: 2 56 | INSTRUCT: True # task-prompt token 57 | HIDDEN_DIM: 256 58 | BINS: 4000 59 | FEATURE_TYPE: x 60 | INTERFACE_TYPE: low-rank_add 61 | INTERFACE_DIM: 32 62 | TRAIN: 63 | BATCH_SIZE: 32 64 | EPOCH: 240 65 | GRAD_CLIP_NORM: 0.1 66 | CE_WEIGHT: 1.0 67 | LR: 0.0004 68 | LR_DROP_EPOCH: 192 69 | NUM_WORKER: 8 70 | OPTIMIZER: ADAMW 71 | PRINT_INTERVAL: 50 72 | SCHEDULER: 73 | TYPE: step 74 | DECAY_RATE: 0.1 75 | WEIGHT_DECAY: 0.0001 76 | TYPE: peft 77 | FIX_BN: True 78 | PRETRAINED_PATH: 'pretrained/seqtrack/seqtrack_b256/SEQTRACK_ep0500.pth.tar' 79 | TEST: 80 | EPOCH: 240 81 | SEARCH_FACTOR: 4.0 82 | SEARCH_SIZE: 256 83 | TEMPLATE_FACTOR: 4.0 84 | TEMPLATE_SIZE: 256 85 | WINDOW: true 86 | NUM_TEMPLATES: 2 87 | 88 | -------------------------------------------------------------------------------- /experiments/seqtrackv2/seqtrackv2_b384.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | MAX_SAMPLE_INTERVAL: 400 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: 384 12 | NUMBER: 1 13 | STD: 14 | - 0.229 15 | - 0.224 16 | - 0.225 17 | TEMPLATE: 18 | CENTER_JITTER: 0 19 | FACTOR: 4.0 20 | SCALE_JITTER: 0 21 | SIZE: 384 22 | NUMBER: 2 23 | TRAIN: 24 | DATASETS_NAME: 25 | - LASOT 26 | - REFCOCOG 27 | - TNL2K_train 28 | - OTB99_train 29 | - DepthTrack_train 30 | - VisEvent 31 | - LasHeR_train 32 | DATASETS_RATIO: 33 | - 1 34 | - 1 35 | - 1 36 | - 1 37 | - 4 38 | - 4 39 | - 4 40 | SAMPLE_PER_EPOCH: 60000 41 | MODEL: 42 | LANGUAGE: 43 | TYPE: 'bert-base-uncased' 44 | PATH: 'pretrained/bert/bert-base-uncased.tar.gz' 45 | VOCAB_PATH: 'pretrained/bert/bert-base-uncased-vocab.txt' 46 | BERT: 47 | # LR: 0.00001 48 | ENC_NUM: 12 49 | HIDDEN_DIM: 256 50 | MAX_QUERY_LEN: 40 51 | ENCODER: 52 | TYPE: vitmm_base_patch16 53 | PRETRAIN_TYPE: mae 54 | INSTRUCT: True # task-prompt token 55 | DECODER: 56 | DEC_LAYERS: 2 57 | INSTRUCT: True # task-prompt token 58 | HIDDEN_DIM: 256 59 | BINS: 4000 60 | FEATURE_TYPE: x 61 | INTERFACE_TYPE: low-rank_add 62 | INTERFACE_DIM: 32 63 | TRAIN: 64 | BATCH_SIZE: 12 65 | EPOCH: 240 66 | GRAD_CLIP_NORM: 0.1 67 | CE_WEIGHT: 1.0 68 | LR: 0.0004 69 | LR_DROP_EPOCH: 192 70 | NUM_WORKER: 8 71 | OPTIMIZER: ADAMW 72 | PRINT_INTERVAL: 50 73 | SCHEDULER: 74 | TYPE: step 75 | DECAY_RATE: 0.1 76 | WEIGHT_DECAY: 0.0001 77 | TYPE: peft 78 | FIX_BN: True 79 | PRETRAINED_PATH: 'pretrained/seqtrack/seqtrack_b384/SEQTRACK_ep0500.pth.tar' 80 | TEST: 81 | EPOCH: 240 82 | SEARCH_FACTOR: 4.0 83 | SEARCH_SIZE: 384 84 | TEMPLATE_FACTOR: 4.0 85 | TEMPLATE_SIZE: 384 86 | WINDOW: true 87 | NUM_TEMPLATES: 2 88 | 89 | -------------------------------------------------------------------------------- /experiments/seqtrackv2/seqtrackv2_l256.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | MAX_SAMPLE_INTERVAL: 400 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: 256 12 | NUMBER: 1 13 | STD: 14 | - 0.229 15 | - 0.224 16 | - 0.225 17 | TEMPLATE: 18 | CENTER_JITTER: 0 19 | FACTOR: 4.0 20 | SCALE_JITTER: 0 21 | SIZE: 256 22 | NUMBER: 2 23 | TRAIN: 24 | DATASETS_NAME: 25 | - LASOT 26 | - REFCOCOG 27 | - TNL2K_train 28 | - OTB99_train 29 | - DepthTrack_train 30 | - VisEvent 31 | - LasHeR_train 32 | DATASETS_RATIO: 33 | - 1 34 | - 1 35 | - 1 36 | - 1 37 | - 4 38 | - 4 39 | - 4 40 | SAMPLE_PER_EPOCH: 60000 41 | MODEL: 42 | LANGUAGE: 43 | TYPE: 'bert-base-uncased' 44 | PATH: 'pretrained/bert/bert-base-uncased.tar.gz' 45 | VOCAB_PATH: 'pretrained/bert/bert-base-uncased-vocab.txt' 46 | BERT: 47 | # LR: 0.00001 48 | ENC_NUM: 12 49 | HIDDEN_DIM: 256 50 | MAX_QUERY_LEN: 40 51 | ENCODER: 52 | TYPE: vitmm_large_patch16 53 | PRETRAIN_TYPE: mae 54 | INSTRUCT: True # task-prompt token 55 | DECODER: 56 | DEC_LAYERS: 2 57 | INSTRUCT: True # task-prompt token 58 | HIDDEN_DIM: 256 59 | BINS: 4000 60 | FEATURE_TYPE: x 61 | INTERFACE_TYPE: low-rank_add 62 | INTERFACE_DIM: 32 63 | TRAIN: 64 | BATCH_SIZE: 16 65 | EPOCH: 240 66 | GRAD_CLIP_NORM: 0.1 67 | CE_WEIGHT: 1.0 68 | LR: 0.0004 69 | LR_DROP_EPOCH: 192 70 | NUM_WORKER: 8 71 | OPTIMIZER: ADAMW 72 | PRINT_INTERVAL: 50 73 | SCHEDULER: 74 | TYPE: step 75 | DECAY_RATE: 0.1 76 | WEIGHT_DECAY: 0.0001 77 | TYPE: peft 78 | FIX_BN: True 79 | PRETRAINED_PATH: 'pretrained/seqtrack/seqtrack_l256/SEQTRACK_ep0500.pth.tar' 80 | TEST: 81 | EPOCH: 240 82 | SEARCH_FACTOR: 4.0 83 | SEARCH_SIZE: 256 84 | TEMPLATE_FACTOR: 4.0 85 | TEMPLATE_SIZE: 256 86 | WINDOW: true 87 | NUM_TEMPLATES: 2 88 | 89 | -------------------------------------------------------------------------------- /experiments/seqtrackv2/seqtrackv2_l384.yaml: -------------------------------------------------------------------------------- 1 | DATA: 2 | MAX_SAMPLE_INTERVAL: 400 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: 384 12 | NUMBER: 1 13 | STD: 14 | - 0.229 15 | - 0.224 16 | - 0.225 17 | TEMPLATE: 18 | CENTER_JITTER: 0 19 | FACTOR: 4.0 20 | SCALE_JITTER: 0 21 | SIZE: 384 22 | NUMBER: 2 23 | TRAIN: 24 | DATASETS_NAME: 25 | - LASOT 26 | - REFCOCOG 27 | - TNL2K_train 28 | - OTB99_train 29 | - DepthTrack_train 30 | - VisEvent 31 | - LasHeR_train 32 | DATASETS_RATIO: 33 | - 1 34 | - 1 35 | - 1 36 | - 1 37 | - 4 38 | - 4 39 | - 4 40 | SAMPLE_PER_EPOCH: 60000 41 | MODEL: 42 | LANGUAGE: 43 | TYPE: 'bert-base-uncased' 44 | PATH: 'pretrained/bert/bert-base-uncased.tar.gz' 45 | VOCAB_PATH: 'pretrained/bert/bert-base-uncased-vocab.txt' 46 | BERT: 47 | # LR: 0.00001 48 | ENC_NUM: 12 49 | HIDDEN_DIM: 256 50 | MAX_QUERY_LEN: 40 51 | ENCODER: 52 | TYPE: vitmm_large_patch16 53 | PRETRAIN_TYPE: mae 54 | INSTRUCT: True # task-prompt token 55 | DECODER: 56 | DEC_LAYERS: 2 57 | INSTRUCT: True # task-prompt token 58 | HIDDEN_DIM: 256 59 | BINS: 4000 60 | FEATURE_TYPE: x 61 | INTERFACE_TYPE: low-rank_add 62 | INTERFACE_DIM: 32 63 | TRAIN: 64 | BATCH_SIZE: 4 65 | EPOCH: 240 66 | GRAD_CLIP_NORM: 0.1 67 | CE_WEIGHT: 1.0 68 | LR: 0.0004 69 | LR_DROP_EPOCH: 192 70 | NUM_WORKER: 8 71 | OPTIMIZER: ADAMW 72 | PRINT_INTERVAL: 50 73 | SCHEDULER: 74 | TYPE: step 75 | DECAY_RATE: 0.1 76 | WEIGHT_DECAY: 0.0001 77 | TYPE: peft 78 | FIX_BN: True 79 | PRETRAINED_PATH: 'pretrained/seqtrack/seqtrack_l384/SEQTRACK_ep0500.pth.tar' 80 | TEST: 81 | EPOCH: 240 82 | SEARCH_FACTOR: 4.0 83 | SEARCH_SIZE: 384 84 | TEMPLATE_FACTOR: 4.0 85 | TEMPLATE_SIZE: 384 86 | WINDOW: true 87 | NUM_TEMPLATES: 2 88 | 89 | -------------------------------------------------------------------------------- /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 | Following STARK, we combine the SeqTrack 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 SeqTrack, 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/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/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/local.py: -------------------------------------------------------------------------------- 1 | class EnvironmentSettings: 2 | def __init__(self): 3 | self.workspace_dir = '/home/cx/cx1/MSRA/CLOUD/MyExperiments/SeqTrack/external/AR' # Base directory for saving network checkpoints. 4 | self.tensorboard_dir = self.workspace_dir + '/tensorboard/' # Directory for tensorboard files. 5 | self.lasot_dir = '' 6 | self.got10k_dir = '' 7 | self.trackingnet_dir = '' 8 | self.coco_dir = '' 9 | self.lvis_dir = '' 10 | self.sbd_dir = '' 11 | self.imagenet_dir = '' 12 | self.imagenetdet_dir = '' 13 | self.ecssd_dir = '' 14 | self.hkuis_dir = '' 15 | self.msra10k_dir = '' 16 | self.davis_dir = '' 17 | self.youtubevos_dir = '' 18 | -------------------------------------------------------------------------------- /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/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/external/AR/ltr/models/AR_seg_mask/__init__.py -------------------------------------------------------------------------------- /external/AR/ltr/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/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/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/external/AR/ltr/models/head/__init__.py -------------------------------------------------------------------------------- /external/AR/ltr/models/layers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/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/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/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/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/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/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/external/AR/ltr/train_settings/__init__.py -------------------------------------------------------------------------------- /external/AR/ltr/train_settings/bbreg/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/external/AR/ltr/train_settings/bbreg/__init__.py -------------------------------------------------------------------------------- /external/AR/ltr/train_settings/dimp/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/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/seqtrack_b256_ar.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | env_path = os.path.join(os.path.dirname(__file__), '../..') 4 | if env_path not in sys.path: 5 | sys.path.append(env_path) 6 | env_path = os.path.join(os.path.dirname(__file__), '../../../..') 7 | if env_path not in sys.path: 8 | sys.path.append(env_path) 9 | from pytracking.VOT2020_super_only_mask_384_HP.seqtrack_alpha_seg_class import run_vot_exp 10 | 11 | os.environ['CUDA_VISIBLE_DEVICES'] = '1' 12 | run_vot_exp('seqtrack', 'seqtrack_b256', 13 | 'ARcm_coco_seg_only_mask_384', 0.65, VIS=True) 14 | -------------------------------------------------------------------------------- /external/AR/pytracking/VOT2020_super_only_mask_384_HP/seqtrack_b384_ar.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | env_path = os.path.join(os.path.dirname(__file__), '../..') 4 | if env_path not in sys.path: 5 | sys.path.append(env_path) 6 | env_path = os.path.join(os.path.dirname(__file__), '../../../..') 7 | if env_path not in sys.path: 8 | sys.path.append(env_path) 9 | from pytracking.VOT2020_super_only_mask_384_HP.seqtrack_alpha_seg_class import run_vot_exp 10 | 11 | # os.environ['CUDA_VISIBLE_DEVICES'] = '1' 12 | run_vot_exp('seqtrack', 'seqtrack_b384', 13 | 'ARcm_coco_seg_only_mask_384', 0.65, VIS=False) -------------------------------------------------------------------------------- /external/AR/pytracking/VOT2020_super_only_mask_384_HP/seqtrack_l256_ar.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | env_path = os.path.join(os.path.dirname(__file__), '../..') 4 | if env_path not in sys.path: 5 | sys.path.append(env_path) 6 | env_path = os.path.join(os.path.dirname(__file__), '../../../..') 7 | if env_path not in sys.path: 8 | sys.path.append(env_path) 9 | from pytracking.VOT2020_super_only_mask_384_HP.seqtrack_alpha_seg_class import run_vot_exp 10 | 11 | # os.environ['CUDA_VISIBLE_DEVICES'] = '1' 12 | run_vot_exp('seqtrack', 'seqtrack_l256', 13 | 'ARcm_coco_seg_only_mask_384', 0.65, VIS=False) -------------------------------------------------------------------------------- /external/AR/pytracking/VOT2020_super_only_mask_384_HP/seqtrack_l384_ar.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | env_path = os.path.join(os.path.dirname(__file__), '../..') 4 | if env_path not in sys.path: 5 | sys.path.append(env_path) 6 | env_path = os.path.join(os.path.dirname(__file__), '../../../..') 7 | if env_path not in sys.path: 8 | sys.path.append(env_path) 9 | from pytracking.VOT2020_super_only_mask_384_HP.seqtrack_alpha_seg_class import run_vot_exp 10 | 11 | # os.environ['CUDA_VISIBLE_DEVICES'] = '1' 12 | run_vot_exp('seqtrack', 'seqtrack_l384', 13 | 'ARcm_coco_seg_only_mask_384', 0.65, VIS=False) -------------------------------------------------------------------------------- /external/AR/pytracking/__init__.py: -------------------------------------------------------------------------------- 1 | from pytracking.libs import TensorList, TensorDict 2 | -------------------------------------------------------------------------------- /external/AR/pytracking/analysis/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/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/local.py: -------------------------------------------------------------------------------- 1 | from pytracking.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_path = '' 10 | settings.got_packed_results_path = '' 11 | settings.got_reports_path = '' 12 | settings.lasot_path = '' 13 | settings.network_path = '/home/cx/cx1/MSRA/CLOUD/MyExperiments/SeqTrack/external/AR/pytracking/networks/' # Where tracking networks are stored. 14 | settings.nfs_path = '' 15 | settings.otb_path = '' 16 | settings.result_plot_path = '/home/cx/cx1/MSRA/CLOUD/MyExperiments/SeqTrack/external/AR/pytracking/result_plots/' 17 | settings.results_path = '/home/cx/cx1/MSRA/CLOUD/MyExperiments/SeqTrack/external/AR/pytracking/tracking_results/' # Where to store tracking results 18 | settings.segmentation_path = '/home/cx/cx1/MSRA/CLOUD/MyExperiments/SeqTrack/external/AR/pytracking/segmentation_results/' 19 | settings.tn_packed_results_path = '' 20 | settings.tpl_path = '' 21 | settings.trackingnet_path = '' 22 | settings.uav_path = '' 23 | settings.vot_path = '' 24 | settings.youtubevos_dir = '' 25 | 26 | return settings 27 | 28 | -------------------------------------------------------------------------------- /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/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/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/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/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/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/external/AR/pytracking/parameter/__init__.py -------------------------------------------------------------------------------- /external/AR/pytracking/parameter/atom/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/external/AR/pytracking/parameter/atom/__init__.py -------------------------------------------------------------------------------- /external/AR/pytracking/parameter/dimp/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/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/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/external/AR/pytracking/parameter/eco/__init__.py -------------------------------------------------------------------------------- /external/AR/pytracking/tracker/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/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/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/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/vot20/seqtrack/config.yaml: -------------------------------------------------------------------------------- 1 | registry: 2 | - ./seqtrack_b256_ar.ini 3 | - ./seqtrack_b384_ar.ini 4 | - ./seqtrack_l256_ar.ini 5 | - ./seqtrack_l384_ar.ini 6 | - ./seqtrack_b256.ini 7 | - ./seqtrack_b384.ini 8 | - ./seqtrack_l256.ini 9 | - ./seqtrack_l384.ini 10 | stack: vot2020 11 | -------------------------------------------------------------------------------- /external/vot20/seqtrack/exp.sh: -------------------------------------------------------------------------------- 1 | vot evaluate --workspace . seqtrack_l384_ar 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /external/vot20/seqtrack/seqtrack_b256.ini: -------------------------------------------------------------------------------- 1 | [seqtrack_b256] # 2 | label = seqtrack_b256 3 | protocol = traxpython 4 | command = seqtrack_b256 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /home/cx/cx1/MSRA/CLOUD/MyExperiments/SeqTrack/lib/test/vot20 7 | -------------------------------------------------------------------------------- /external/vot20/seqtrack/seqtrack_b256_ar.ini: -------------------------------------------------------------------------------- 1 | [seqtrack_b256_ar] # 2 | label = seqtrack_b256_ar 3 | protocol = traxpython 4 | command = seqtrack_b256_ar 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /home/cx/cx1/MSRA/CLOUD/MyExperiments/SeqTrack/external/AR/pytracking/VOT2020_super_only_mask_384_HP 7 | -------------------------------------------------------------------------------- /external/vot20/seqtrack/seqtrack_b384.ini: -------------------------------------------------------------------------------- 1 | [seqtrack_b384] # 2 | label = seqtrack_b384 3 | protocol = traxpython 4 | command = seqtrack_b384 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /home/cx/cx1/MSRA/CLOUD/MyExperiments/SeqTrack/lib/test/vot20 7 | -------------------------------------------------------------------------------- /external/vot20/seqtrack/seqtrack_b384_ar.ini: -------------------------------------------------------------------------------- 1 | [seqtrack_b384_ar] # 2 | label = seqtrack_b384_ar 3 | protocol = traxpython 4 | command = seqtrack_b384_ar 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /home/cx/cx1/MSRA/CLOUD/MyExperiments/SeqTrack/external/AR/pytracking/VOT2020_super_only_mask_384_HP 7 | -------------------------------------------------------------------------------- /external/vot20/seqtrack/seqtrack_l256.ini: -------------------------------------------------------------------------------- 1 | [seqtrack_l256] # 2 | label = seqtrack_l256 3 | protocol = traxpython 4 | command = seqtrack_l256 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /home/cx/cx1/MSRA/CLOUD/MyExperiments/SeqTrack/lib/test/vot20 7 | -------------------------------------------------------------------------------- /external/vot20/seqtrack/seqtrack_l256_ar.ini: -------------------------------------------------------------------------------- 1 | [seqtrack_l256_ar] # 2 | label = seqtrack_l256_ar 3 | protocol = traxpython 4 | command = seqtrack_l256_ar 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /home/cx/cx1/MSRA/CLOUD/MyExperiments/SeqTrack/external/AR/pytracking/VOT2020_super_only_mask_384_HP 7 | -------------------------------------------------------------------------------- /external/vot20/seqtrack/seqtrack_l384.ini: -------------------------------------------------------------------------------- 1 | [seqtrack_l384] # 2 | label = seqtrack_l384 3 | protocol = traxpython 4 | command = seqtrack_l384 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /home/cx/cx1/MSRA/CLOUD/MyExperiments/SeqTrack/lib/test/vot20 7 | -------------------------------------------------------------------------------- /external/vot20/seqtrack/seqtrack_l384_ar.ini: -------------------------------------------------------------------------------- 1 | [seqtrack_l384_ar] # 2 | label = seqtrack_l384_ar 3 | protocol = traxpython 4 | command = seqtrack_l384_ar 5 | # Specify a path to trax python wrapper if it is not visible (separate by ; if using multiple paths) 6 | paths = /home/cx/cx1/MSRA/CLOUD/MyExperiments/SeqTrack/external/AR/pytracking/VOT2020_super_only_mask_384_HP 7 | -------------------------------------------------------------------------------- /lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/lib/__init__.py -------------------------------------------------------------------------------- /lib/config/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/lib/config/__init__.py -------------------------------------------------------------------------------- /lib/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/lib/models/__init__.py -------------------------------------------------------------------------------- /lib/models/seqtrack/__init__.py: -------------------------------------------------------------------------------- 1 | from .seqtrack import build_seqtrack -------------------------------------------------------------------------------- /lib/models/seqtrackv2/__init__.py: -------------------------------------------------------------------------------- 1 | from .seqtrackv2 import build_seqtrackv2 -------------------------------------------------------------------------------- /lib/models/seqtrackv2/utils.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | import torch 4 | import torch.nn.functional as F 5 | 6 | def combine_tokens(template_tokens, search_tokens, mode='direct', return_res=False): 7 | # [B, HW, C] 8 | len_t = template_tokens.shape[1] 9 | len_s = search_tokens.shape[1] 10 | 11 | if mode == 'direct': 12 | merged_feature = torch.cat((template_tokens, search_tokens), dim=1) 13 | elif mode == 'template_central': 14 | central_pivot = len_s // 2 15 | first_half = search_tokens[:, :central_pivot, :] 16 | second_half = search_tokens[:, central_pivot:, :] 17 | merged_feature = torch.cat((first_half, template_tokens, second_half), dim=1) 18 | elif mode == 'partition': 19 | feat_size_s = int(math.sqrt(len_s)) 20 | feat_size_t = int(math.sqrt(len_t)) 21 | window_size = math.ceil(feat_size_t / 2.) 22 | # pad feature maps to multiples of window size 23 | B, _, C = template_tokens.shape 24 | H = W = feat_size_t 25 | template_tokens = template_tokens.view(B, H, W, C) 26 | pad_l = pad_b = pad_r = 0 27 | # pad_r = (window_size - W % window_size) % window_size 28 | pad_t = (window_size - H % window_size) % window_size 29 | template_tokens = F.pad(template_tokens, (0, 0, pad_l, pad_r, pad_t, pad_b)) 30 | _, Hp, Wp, _ = template_tokens.shape 31 | template_tokens = template_tokens.view(B, Hp // window_size, window_size, W, C) 32 | template_tokens = torch.cat([template_tokens[:, 0, ...], template_tokens[:, 1, ...]], dim=2) 33 | _, Hc, Wc, _ = template_tokens.shape 34 | template_tokens = template_tokens.view(B, -1, C) 35 | merged_feature = torch.cat([template_tokens, search_tokens], dim=1) 36 | 37 | # calculate new h and w, which may be useful for SwinT or others 38 | merged_h, merged_w = feat_size_s + Hc, feat_size_s 39 | if return_res: 40 | return merged_feature, merged_h, merged_w 41 | 42 | else: 43 | raise NotImplementedError 44 | 45 | return merged_feature 46 | 47 | ''' 48 | add token transfer to feature 49 | ''' 50 | def token2feature(tokens): 51 | B,L,D=tokens.shape 52 | H=W=int(L**0.5) 53 | x = tokens.permute(0, 2, 1).view(B, D, W, H).contiguous() 54 | return x 55 | 56 | 57 | ''' 58 | feature2token 59 | ''' 60 | def feature2token(x): 61 | B,C,W,H = x.shape 62 | L = W*H 63 | tokens = x.view(B, C, L).permute(0, 2, 1).contiguous() 64 | return tokens -------------------------------------------------------------------------------- /lib/test/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/lib/test/__init__.py -------------------------------------------------------------------------------- /lib/test/analysis/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/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 | lasot_extension_subset = DatasetInfo(module=pt % "lasotextensionsubset", class_name="LaSOTExtensionSubsetDataset", 22 | kwargs=dict()), 23 | otb99_lang=DatasetInfo(module=pt % "otb99lang", class_name="OTB99LangDataset", kwargs=dict()), 24 | tnl2k=DatasetInfo(module=pt % "tnl2k", class_name="TNL2kDataset", kwargs=dict()), 25 | lasot_lang=DatasetInfo(module=pt % "lasotlang", class_name="LaSOTLangDataset", kwargs=dict()), 26 | ) 27 | 28 | 29 | def load_dataset(name: str): 30 | """ Import and load a single dataset.""" 31 | name = name.lower() 32 | dset_info = dataset_dict.get(name) 33 | if dset_info is None: 34 | raise ValueError('Unknown dataset \'%s\'' % name) 35 | 36 | m = importlib.import_module(dset_info.module) 37 | dataset = getattr(m, dset_info.class_name)(**dset_info.kwargs) # Call the constructor 38 | return dataset.get_sequence_list() 39 | 40 | 41 | def get_dataset(*args): 42 | """ Get a single or set of datasets.""" 43 | dset = SequenceList() 44 | for name in args: 45 | dset.extend(load_dataset(name)) 46 | 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 = '/home/cx/cx1/github-repo/SeqTrackv2/data/got10k_lmdb' 10 | settings.got10k_path = '/home/cx/cx1/github-repo/SeqTrackv2/data/got10k' 11 | settings.got_packed_results_path = '' 12 | settings.got_reports_path = '' 13 | settings.lasot_extension_subset_path = '/home/cx/cx1/github-repo/SeqTrackv2/data/lasot_extension_subset' 14 | settings.lasot_lmdb_path = '/home/cx/cx1/github-repo/SeqTrackv2/data/lasot_lmdb' 15 | settings.lasot_path = '/home/cx/cx1/github-repo/SeqTrackv2/data/lasot' 16 | settings.lasotlang_path = '/home/cx/cx1/github-repo/SeqTrackv2/data/lasot' 17 | settings.network_path = '/home/cx/cx1/github-repo/SeqTrackv2/test/networks' # Where tracking networks are stored. 18 | settings.nfs_path = '/home/cx/cx1/github-repo/SeqTrackv2/data/nfs' 19 | settings.otb_path = '/home/cx/cx1/github-repo/SeqTrackv2/data/OTB2015' 20 | settings.otblang_path = '/home/cx/cx1/github-repo/SeqTrackv2/data/otb_lang' 21 | settings.prj_dir = '/home/cx/cx1/github-repo/SeqTrackv2' 22 | settings.result_plot_path = '/home/cx/cx1/github-repo/SeqTrackv2/test/result_plots' 23 | settings.results_path = '/home/cx/cx1/github-repo/SeqTrackv2/test/tracking_results' # Where to store tracking results 24 | settings.save_dir = '/home/cx/cx1/github-repo/SeqTrackv2' 25 | settings.segmentation_path = '/home/cx/cx1/github-repo/SeqTrackv2/test/segmentation_results' 26 | settings.tc128_path = '/home/cx/cx1/github-repo/SeqTrackv2/data/TC128' 27 | settings.tn_packed_results_path = '' 28 | settings.tnl2k_path = '/home/cx/cx1/github-repo/SeqTrackv2/data/tnl2k/test' 29 | settings.tpl_path = '' 30 | settings.trackingnet_path = '/home/cx/cx1/github-repo/SeqTrackv2/data/trackingnet' 31 | settings.uav_path = '/home/cx/cx1/github-repo/SeqTrackv2/data/UAV123' 32 | settings.vot_path = '/home/cx/cx1/github-repo/SeqTrackv2/data/VOT2019' 33 | settings.youtubevos_dir = '' 34 | 35 | return settings 36 | 37 | -------------------------------------------------------------------------------- /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/tnl2kdataset.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import numpy as np 4 | from lib.test.evaluation.data import Sequence, BaseDataset, SequenceList 5 | from lib.test.utils.load_text import load_text, load_str 6 | 7 | 8 | class TNL2kDataset(BaseDataset): 9 | """ 10 | TNL2k test set 11 | """ 12 | def __init__(self): 13 | super().__init__() 14 | self.base_path = self.env_settings.tnl2k_path 15 | self.sequence_list = self._get_sequence_list() 16 | 17 | def get_sequence_list(self): 18 | return SequenceList([self._construct_sequence(s) for s in self.sequence_list]) 19 | 20 | def _construct_sequence(self, sequence_name): 21 | # class_name = sequence_name.split('-')[0] 22 | anno_path = '{}/{}/groundtruth.txt'.format(self.base_path, sequence_name) 23 | 24 | ground_truth_rect = load_text(str(anno_path), delimiter=',', dtype=np.float64) 25 | 26 | text_dsp_path = '{}/{}/language.txt'.format(self.base_path, sequence_name) 27 | text_dsp = load_str(text_dsp_path) 28 | 29 | frames_path = '{}/{}/imgs'.format(self.base_path, sequence_name) 30 | frames_list = [f for f in os.listdir(frames_path)] 31 | frames_list = sorted(frames_list) 32 | frames_list = ['{}/{}'.format(frames_path, frame_i) for frame_i in frames_list] 33 | 34 | return Sequence(sequence_name, frames_list, 'tnl2k', ground_truth_rect.reshape(-1, 4), 35 | language_query=text_dsp) 36 | 37 | def __len__(self): 38 | return len(self.sequence_list) 39 | 40 | def _get_sequence_list(self): 41 | sequence_list = [] 42 | for seq in os.listdir(self.base_path): 43 | if os.path.isdir(os.path.join(self.base_path, seq)): 44 | sequence_list.append(seq) 45 | 46 | return sequence_list 47 | -------------------------------------------------------------------------------- /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/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/lib/test/parameter/__init__.py -------------------------------------------------------------------------------- /lib/test/parameter/seqtrack.py: -------------------------------------------------------------------------------- 1 | from lib.test.utils import TrackerParams 2 | import os 3 | from lib.test.evaluation.environment import env_settings 4 | from lib.config.seqtrack.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/seqtrack/%s.yaml' % yaml_name) 13 | update_config_from_file(yaml_file) 14 | params.cfg = cfg 15 | print("test config: ", cfg) 16 | 17 | params.yaml_name = yaml_name 18 | # template and search region 19 | params.template_factor = cfg.TEST.TEMPLATE_FACTOR 20 | params.template_size = cfg.TEST.TEMPLATE_SIZE 21 | params.search_factor = cfg.TEST.SEARCH_FACTOR 22 | params.search_size = cfg.TEST.SEARCH_SIZE 23 | 24 | # Network checkpoint path 25 | params.checkpoint = os.path.join(save_dir, "checkpoints/train/seqtrack/%s/SEQTRACK_ep%04d.pth.tar" % 26 | (yaml_name, cfg.TEST.EPOCH)) 27 | 28 | # whether to save boxes from all queries 29 | params.save_all_boxes = False 30 | 31 | return params 32 | -------------------------------------------------------------------------------- /lib/test/parameter/seqtrackv2.py: -------------------------------------------------------------------------------- 1 | from lib.test.utils import TrackerParams 2 | import os 3 | from lib.test.evaluation.environment import env_settings 4 | from lib.config.seqtrackv2.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/seqtrackv2/%s.yaml' % yaml_name) 13 | update_config_from_file(yaml_file) 14 | params.cfg = cfg 15 | print("test config: ", cfg) 16 | 17 | params.yaml_name = yaml_name 18 | # template and search region 19 | params.template_factor = cfg.TEST.TEMPLATE_FACTOR 20 | params.template_size = cfg.TEST.TEMPLATE_SIZE 21 | params.search_factor = cfg.TEST.SEARCH_FACTOR 22 | params.search_size = cfg.TEST.SEARCH_SIZE 23 | 24 | # Network checkpoint path 25 | params.checkpoint = os.path.join(save_dir, "checkpoints/train/seqtrackv2/%s/SEQTRACKV2_ep%04d.pth.tar" % 26 | (yaml_name, cfg.TEST.EPOCH)) 27 | 28 | # whether to save boxes from all queries 29 | params.save_all_boxes = False 30 | 31 | return params 32 | -------------------------------------------------------------------------------- /lib/test/tracker/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenxin-dlut/SeqTrackv2/36fd6490c669dace0105087de19059700f365564/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/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 | 43 | 44 | def load_str(path): 45 | with open(path, "r") as f: 46 | text_str = f.readline().strip().lower() 47 | return text_str 48 | -------------------------------------------------------------------------------- /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=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=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/vot/seqtrackv2_b256_depthtrack.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | env_path = os.path.join(os.path.dirname(__file__), '../../..') 4 | if env_path not in sys.path: 5 | sys.path.append(env_path) 6 | from lib.test.vot.seqtrack_class import run_vot_exp 7 | 8 | run_vot_exp('seqtrackv2', 'seqtrackv2_b256', vis=False, out_conf=True, channel_type='rgbd') 9 | 10 | -------------------------------------------------------------------------------- /lib/test/vot/seqtrackv2_b256_votrgbd.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | env_path = os.path.join(os.path.dirname(__file__), '../../..') 4 | if env_path not in sys.path: 5 | sys.path.append(env_path) 6 | from lib.test.vot.seqtrack_class import run_vot_exp 7 | 8 | run_vot_exp('seqtrackv2', 'seqtrackv2_b256', vis=False, out_conf=True, channel_type='rgbd') 9 | -------------------------------------------------------------------------------- /lib/test/vot/seqtrackv2_b384_depthtrack.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | env_path = os.path.join(os.path.dirname(__file__), '../../..') 4 | if env_path not in sys.path: 5 | sys.path.append(env_path) 6 | from lib.test.vot.seqtrack_class import run_vot_exp 7 | 8 | run_vot_exp('seqtrackv2', 'seqtrackv2_b384', vis=False, out_conf=True, channel_type='rgbd') 9 | 10 | -------------------------------------------------------------------------------- /lib/test/vot/seqtrackv2_b384_votrgbd.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | env_path = os.path.join(os.path.dirname(__file__), '../../..') 4 | if env_path not in sys.path: 5 | sys.path.append(env_path) 6 | from lib.test.vot.seqtrack_class import run_vot_exp 7 | 8 | run_vot_exp('seqtrackv2', 'seqtrackv2_b384', vis=False, out_conf=True, channel_type='rgbd') 9 | -------------------------------------------------------------------------------- /lib/test/vot/seqtrackv2_l256_depthtrack.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | env_path = os.path.join(os.path.dirname(__file__), '../../..') 4 | if env_path not in sys.path: 5 | sys.path.append(env_path) 6 | from lib.test.vot.seqtrack_class import run_vot_exp 7 | 8 | run_vot_exp('seqtrackv2', 'seqtrackv2_l256', vis=False, out_conf=True, channel_type='rgbd') 9 | 10 | -------------------------------------------------------------------------------- /lib/test/vot/seqtrackv2_l256_votrgbd.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | env_path = os.path.join(os.path.dirname(__file__), '../../..') 4 | if env_path not in sys.path: 5 | sys.path.append(env_path) 6 | from lib.test.vot.seqtrack_class import run_vot_exp 7 | 8 | run_vot_exp('seqtrackv2', 'seqtrackv2_l256', vis=False, out_conf=True, channel_type='rgbd') 9 | -------------------------------------------------------------------------------- /lib/test/vot/seqtrackv2_l384_depthtrack.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | env_path = os.path.join(os.path.dirname(__file__), '../../..') 4 | if env_path not in sys.path: 5 | sys.path.append(env_path) 6 | from lib.test.vot.seqtrack_class import run_vot_exp 7 | 8 | run_vot_exp('seqtrackv2', 'seqtrackv2_l384', vis=False, out_conf=True, channel_type='rgbd') 9 | 10 | -------------------------------------------------------------------------------- /lib/test/vot/seqtrackv2_l384_votrgbd.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | env_path = os.path.join(os.path.dirname(__file__), '../../..') 4 | if env_path not in sys.path: 5 | sys.path.append(env_path) 6 | from lib.test.vot.seqtrack_class import run_vot_exp 7 | 8 | run_vot_exp('seqtrackv2', 'seqtrackv2_l384', vis=False, out_conf=True, channel_type='rgbd') 9 | -------------------------------------------------------------------------------- /lib/test/vot/vot22_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/test/vot20/seqtrack_b256.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | env_path = os.path.join(os.path.dirname(__file__), '../../..') 4 | if env_path not in sys.path: 5 | sys.path.append(env_path) 6 | from lib.test.vot20.seqtrack_vot20 import run_vot_exp 7 | # os.environ['CUDA_VISIBLE_DEVICES'] = '1' 8 | run_vot_exp('seqtrack', 'seqtrack_b256', vis=True) 9 | -------------------------------------------------------------------------------- /lib/test/vot20/seqtrack_b384.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | env_path = os.path.join(os.path.dirname(__file__), '../../..') 4 | if env_path not in sys.path: 5 | sys.path.append(env_path) 6 | from lib.test.vot20.seqtrack_vot20 import run_vot_exp 7 | # os.environ['CUDA_VISIBLE_DEVICES'] = '1' 8 | run_vot_exp('seqtrack', 'seqtrack_b384', vis=False) 9 | -------------------------------------------------------------------------------- /lib/test/vot20/seqtrack_l256.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | env_path = os.path.join(os.path.dirname(__file__), '../../..') 4 | if env_path not in sys.path: 5 | sys.path.append(env_path) 6 | from lib.test.vot20.seqtrack_vot20 import run_vot_exp 7 | # os.environ['CUDA_VISIBLE_DEVICES'] = '1' 8 | run_vot_exp('seqtrack', 'seqtrack_l256', vis=False) 9 | -------------------------------------------------------------------------------- /lib/test/vot20/seqtrack_l384.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | env_path = os.path.join(os.path.dirname(__file__), '../../..') 4 | if env_path not in sys.path: 5 | sys.path.append(env_path) 6 | from lib.test.vot20.seqtrack_vot20 import run_vot_exp 7 | # os.environ['CUDA_VISIBLE_DEVICES'] = '1' 8 | run_vot_exp('seqtrack', 'seqtrack_l384', vis=False) 9 | -------------------------------------------------------------------------------- /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 .seqtrack import SeqTrackActor 3 | from .seqtrackv2 import SeqTrackV2Actor 4 | 5 | -------------------------------------------------------------------------------- /lib/train/actors/actor_utils.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | def get_jittered_box(boxes): 4 | """ Jitter the input box 5 | args: 6 | box - input bounding box 7 | returns: 8 | torch.Tensor - jittered box 9 | """ 10 | jittered_box_list = [] 11 | device = boxes.device 12 | for box in boxes: 13 | scale_jitter_factor = 0.25 14 | center_jitter_factor = 0.25 15 | jittered_size = box[2:4] * torch.exp(torch.randn(2, device=device) * scale_jitter_factor) 16 | max_offset = (jittered_size.prod().sqrt() * torch.tensor(center_jitter_factor, device=device).float()) 17 | jittered_center = box[0:2] + 0.5 * box[2:4] + max_offset * (torch.rand(2, device=device) - 0.5) 18 | jittered_box = torch.cat((jittered_center - 0.5 * jittered_size, jittered_size), dim=0).unsqueeze(0) 19 | jittered_box_list.append(jittered_box) 20 | jittered_boxes = torch.cat(jittered_box_list, dim=0) 21 | return jittered_boxes 22 | 23 | def get_jittered_box_1(box): 24 | """ Jitter the input box 25 | args: 26 | box - input bounding box 27 | returns: 28 | torch.Tensor - jittered box 29 | """ 30 | device = box.device 31 | scale_jitter_factor = 0.25 32 | center_jitter_factor = 0.5 33 | jittered_size = box[2:4] * torch.exp(torch.randn(2, device=device) * scale_jitter_factor) 34 | max_offset = (jittered_size.prod().sqrt() * torch.tensor(center_jitter_factor, device=device).float()) 35 | jittered_center = box[0:2] + 0.5 * box[2:4] + max_offset * (torch.rand(2, device=device) - 0.5) 36 | jittered_box = torch.cat((jittered_center - 0.5 * jittered_size, jittered_size), dim=0) 37 | return jittered_box -------------------------------------------------------------------------------- /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/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 = '/home/cx/cx1/github-repo/SeqTrackv2' # Base directory for saving network checkpoints. 4 | self.tensorboard_dir = '/home/cx/cx1/github-repo/SeqTrackv2/tensorboard' # Directory for tensorboard files. 5 | self.pretrained_networks = '/home/cx/cx1/github-repo/SeqTrackv2/pretrained_networks' 6 | self.lasot_dir = '/home/cx/cx1/github-repo/SeqTrackv2/data/lasot' 7 | self.got10k_dir = '/home/cx/cx1/github-repo/SeqTrackv2/data/got10k/train' 8 | self.lasot_lmdb_dir = '/home/cx/cx1/github-repo/SeqTrackv2/data/lasot_lmdb' 9 | self.got10k_lmdb_dir = '/home/cx/cx1/github-repo/SeqTrackv2/data/got10k_lmdb' 10 | self.trackingnet_dir = '/home/cx/cx1/github-repo/SeqTrackv2/data/trackingnet' 11 | self.trackingnet_lmdb_dir = '/home/cx/cx1/github-repo/SeqTrackv2/data/trackingnet_lmdb' 12 | self.coco_dir = '/home/cx/cx1/github-repo/SeqTrackv2/data/coco' 13 | self.coco_lmdb_dir = '/home/cx/cx1/github-repo/SeqTrackv2/data/coco_lmdb' 14 | self.imagenet1k_dir = '/home/cx/cx1/github-repo/SeqTrackv2/data/imagenet1k' 15 | self.imagenet22k_dir = '/home/cx/cx1/github-repo/SeqTrackv2/data/imagenet22k' 16 | self.lvis_dir = '' 17 | self.sbd_dir = '' 18 | self.imagenet_dir = '/home/cx/cx1/github-repo/SeqTrackv2/data/vid' 19 | self.imagenet_lmdb_dir = '/home/cx/cx1/github-repo/SeqTrackv2/data/vid_lmdb' 20 | self.imagenetdet_dir = '' 21 | self.ecssd_dir = '' 22 | self.hkuis_dir = '' 23 | self.msra10k_dir = '' 24 | self.davis_dir = '' 25 | self.youtubevos_dir = '' 26 | self.depthtrack_dir = '/home/cx/cx1/github-repo/SeqTrackv2/data/depthtrack/train' 27 | self.lasher_dir = '/home/cx/cx1/github-repo/SeqTrackv2/data/lasher/trainingset' 28 | self.visevent_dir = '/home/cx/cx1/github-repo/SeqTrackv2/data/visevent/train' 29 | self.refcoco_dir = '/home/cx/cx1/github-repo/SeqTrackv2/data/refcoco' 30 | self.tnl2k_dir = '/home/cx/cx1/github-repo/SeqTrackv2/data/tnl2k/train' 31 | self.otb99_dir = '/home/cx/cx1/github-repo/SeqTrackv2/data/otb_lang' 32 | -------------------------------------------------------------------------------- /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/data_specs/depthtrack_train.txt: -------------------------------------------------------------------------------- 1 | adapter02_indoor 2 | bag03_indoor 3 | bag05_indoor 4 | ball02_indoor 5 | ball03_indoor 6 | ball04_indoor 7 | ball05_indoor 8 | ball07_indoor 9 | ball08_wild 10 | ball09_wild 11 | ball12_wild 12 | ball13_indoor 13 | ball14_wild 14 | ball17_wild 15 | ball19_indoor 16 | ball21_indoor 17 | basket_indoor 18 | beautifullight01_indoor 19 | bike01_wild 20 | bike02_wild 21 | bike03_wild 22 | book01_indoor 23 | book02_indoor 24 | book04_indoor 25 | book05_indoor 26 | book06_indoor 27 | bottle01_indoor 28 | bottle02_indoor 29 | bottle05_indoor 30 | bottle06_indoor 31 | box_indoor 32 | candlecup_indoor 33 | car01_indoor 34 | car02_indoor 35 | cart_indoor 36 | cat02_indoor 37 | cat03_indoor 38 | cat04_indoor 39 | cat05_indoor 40 | chair01_indoor 41 | chair02_indoor 42 | clothes_indoor 43 | colacan01_indoor 44 | colacan02_indoor 45 | colacan04_indoor 46 | container01_indoor 47 | container02_indoor 48 | cube01_indoor 49 | cube04_indoor 50 | cube06_indoor 51 | cup03_indoor 52 | cup05_indoor 53 | cup06_indoor 54 | cup07_indoor 55 | cup08_indoor 56 | cup09_indoor 57 | cup10_indoor 58 | cup11_indoor 59 | cup13_indoor 60 | cup14_indoor 61 | duck01_wild 62 | duck02_wild 63 | duck04_wild 64 | duck05_wild 65 | duck06_wild 66 | dumbbells02_indoor 67 | earphone02_indoor 68 | egg_indoor 69 | file02_indoor 70 | flower01_indoor 71 | flower02_wild 72 | flowerbasket_indoor 73 | ghostmask_indoor 74 | glass02_indoor 75 | glass03_indoor 76 | glass04_indoor 77 | glass05_indoor 78 | guitarbag_indoor 79 | gymring_wild 80 | hand02_indoor 81 | hat01_indoor 82 | hat02_indoor_320 83 | hat03_indoor 84 | hat04_indoor 85 | human01_indoor 86 | human03_wild 87 | human04_wild 88 | human05_wild 89 | human06_indoor 90 | leaves01_wild 91 | leaves02_indoor 92 | leaves03_wild 93 | leaves04_indoor 94 | leaves05_indoor 95 | leaves06_wild 96 | lock01_wild 97 | mac_indoor 98 | milkbottle_indoor 99 | mirror_indoor 100 | mobilephone01_indoor 101 | mobilephone02_indoor 102 | mobilephone04_indoor 103 | mobilephone05_indoor 104 | mobilephone06_indoor 105 | mushroom01_indoor 106 | mushroom02_wild 107 | mushroom03_wild 108 | mushroom04_indoor 109 | mushroom05_indoor 110 | notebook02_indoor 111 | notebook03_indoor 112 | paintbottle_indoor 113 | painting_indoor_320 114 | parkingsign_wild 115 | pigeon03_wild 116 | pigeon06_wild 117 | pigeon07_wild 118 | pine01_indoor 119 | pine02_wild_320 120 | shoes01_indoor 121 | shoes03_indoor 122 | skateboard01_indoor 123 | skateboard02_indoor 124 | speaker_indoor 125 | stand_indoor 126 | suitcase_indoor 127 | swing01_wild 128 | swing02_wild 129 | teacup_indoor 130 | thermos01_indoor 131 | thermos02_indoor 132 | toiletpaper02_indoor 133 | toiletpaper03_indoor 134 | toiletpaper04_indoor 135 | toy01_indoor 136 | toy04_indoor 137 | toy05_indoor 138 | toy06_indoor 139 | toy07_indoor_320 140 | toy08_indoor 141 | toy10_indoor 142 | toydog_indoor 143 | trashbin_indoor 144 | tree_wild 145 | trophy_indoor 146 | ukulele02_indoor 147 | -------------------------------------------------------------------------------- /lib/train/data_specs/depthtrack_val.txt: -------------------------------------------------------------------------------- 1 | toy03_indoor 2 | pigeon05_wild 3 | bottle03_indoor 4 | ball16_indoor 5 | bag04_indoor 6 | flower03_indoor -------------------------------------------------------------------------------- /lib/train/data_specs/lasher_val.txt: -------------------------------------------------------------------------------- 1 | boywalkinginsnow3 2 | leftdrillmasterstanding 3 | leftgirlunderthelamp 4 | girlridesbike 5 | midboyplayingphone 6 | boywithumbrella 7 | manrun 8 | ab_pingpongball 9 | whitecarturnl 10 | girltakemoto 11 | rightgirlatbike 12 | easy_blackboy 13 | man_with_black_clothes2 14 | 7runone 15 | turnblkbike 16 | motobesidescar 17 | bikeafterwhitecar 18 | 2runsix 19 | rightboy_1227 20 | whitesuvcome 21 | AQrightofcomingmotos 22 | 7one 23 | blackman_0115 24 | rightmirrornotshining 25 | AQmanfromdarktrees 26 | bikeboy128 27 | orangegirl 28 | girlturnbike 29 | blackman2 30 | blackcarback 31 | rightof2cupsattached 32 | whitecar2west 33 | hatboy`shead 34 | whitebetweenblackandblue 35 | 2rdcarcome 36 | whitemancome 37 | nearmangotoD 38 | farmanrightwhitesmallhouse 39 | lightmotocoming 40 | boymototakesgirl 41 | leftblackboy 42 | righttallholdball 43 | blackcarcome 44 | twolinefirstone-gai 45 | lowerfoam2throw 46 | Awhitecargo 47 | car2north3 48 | rightfirstboy-ly 49 | girltakingplate 50 | left2ndgreenboy 51 | ab_bolster 52 | 9hatboy 53 | whitecarturn2 54 | midboyblue 55 | basketboywhite 56 | nightmototurn 57 | girlbike 58 | mantoground 59 | pickuptheyellowbook 60 | 8lastone 61 | AQbikeback 62 | girlsquattingbesidesleftbar 63 | blkbikefromnorth 64 | whitecar 65 | Amidredgirl 66 | blackbag 67 | AQblkgirlbike 68 | manwithyellowumbrella 69 | browncar2north 70 | carstop 71 | whiteboywithbag 72 | theleftestrunningboy 73 | girlafterglassdoor2 74 | rightmirrorlikesky 75 | redgirl1497 76 | midboy 77 | folderatlefthand 78 | bikecome 79 | leftfallenchair_inf_white 80 | Agirlrideback 81 | rightgirl 82 | belowrightwhiteboy 83 | moto2north1 84 | truckk 85 | highright2ndboy 86 | girl`sheadoncall 87 | whiteboy 88 | truckwhite 89 | AQgirlbiketurns 90 | left2ndboy 91 | whitegirl2right 92 | rightboywithwhite 93 | girlplayingphone 94 | girlumbrella 95 | truck 96 | manfarbesidespool 97 | dotat43 -------------------------------------------------------------------------------- /lib/train/data_specs/otb99_test_split.txt: -------------------------------------------------------------------------------- 1 | Biker 2 | Bird1 3 | Bird2 4 | BlurBody 5 | BlurCar1 6 | BlurCar2 7 | BlurCar3 8 | BlurCar4 9 | BlurFace 10 | BlurOwl 11 | Board 12 | Bolt2 13 | Box 14 | Car1 15 | Car2 16 | Car24 17 | Coupon 18 | Crowds 19 | Dancer 20 | Dancer2 21 | Diving 22 | Dog 23 | DragonBaby 24 | Girl2 25 | Gym 26 | Human2 27 | Human3 28 | Human4 29 | Human5 30 | Human6 31 | Human7 32 | Human8 33 | Human9 34 | Jump 35 | KiteSurf 36 | Man 37 | Panda 38 | RedTeam 39 | Rubik 40 | Skater 41 | Skater2 42 | Skating2 43 | Skating3 44 | Surfer 45 | Toy 46 | Trans 47 | Twinnings 48 | Vase -------------------------------------------------------------------------------- /lib/train/data_specs/otb99_train_split.txt: -------------------------------------------------------------------------------- 1 | Basketball 2 | Bolt 3 | Boy 4 | Car4 5 | CarDark 6 | CarScale 7 | Coke 8 | Couple 9 | Crossing 10 | David 11 | David2 12 | David3 13 | Deer 14 | Dog1 15 | Doll 16 | Dudek 17 | FaceOcc1 18 | FaceOcc2 19 | Fish 20 | FleetFace 21 | Football 22 | Football1 23 | Freeman1 24 | Freeman3 25 | Freeman4 26 | Girl 27 | Ironman 28 | Jogging 29 | Jumping 30 | Lemming 31 | Liquor 32 | Matrix 33 | Mhyang 34 | MotorRolling 35 | MountainBike 36 | Shaking 37 | Singer1 38 | Singer2 39 | Skating1 40 | Skiing 41 | Soccer 42 | Subway 43 | Suv 44 | Sylvester 45 | Tiger1 46 | Tiger2 47 | Trellis 48 | Walking 49 | Walking2 50 | Woman -------------------------------------------------------------------------------- /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 | from .imagenet1k import Imagenet1k 13 | from .imagenet22k import Imagenet22k 14 | # RGBT dataloader 15 | from .lasher import LasHeR 16 | # RGBD dataloader 17 | from .depthtrack import DepthTrack 18 | # Event dataloader 19 | from .visevent import VisEvent 20 | # Language dataloader 21 | from .otb99_lang import Otb99_lang 22 | from .tnl2k import Tnl2k 23 | from .refcoco_seq import RefCOCOSeq 24 | -------------------------------------------------------------------------------- /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/dataset/imagenet1k.py: -------------------------------------------------------------------------------- 1 | import os 2 | from lib.train.dataset.base_video_dataset import BaseVideoDataset 3 | from lib.train.data import jpeg4py_loader 4 | import torch 5 | import random 6 | import torchvision.datasets as datasets 7 | from collections import OrderedDict 8 | from lib.train.admin import env_settings 9 | 10 | 11 | class Imagenet1k(BaseVideoDataset): 12 | """ The ImageNet1k dataset. ImageNet1k is an image dataset. Thus, we treat each image as a sequence of length 1. 13 | """ 14 | 15 | def __init__(self, root=None, image_loader=jpeg4py_loader, split="train"): 16 | """ 17 | args: 18 | root - path to the coco dataset. 19 | image_loader (default_image_loader) - The function to read the images. If installed, 20 | jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. Else, 21 | opencv's imread is used. 22 | data_fraction (None) - Fraction of images to be used. The images are selected randomly. If None, all the 23 | images will be used 24 | split - 'train' or 'val'. 25 | version - version of coco dataset (2014 or 2017) 26 | """ 27 | root = env_settings().imagenet1k_dir if root is None else root 28 | super().__init__('imagenet1k', root, image_loader) 29 | 30 | self.dataset = datasets.ImageFolder(os.path.join(root, 'train'), loader=image_loader) 31 | 32 | def is_video_sequence(self): 33 | return False 34 | 35 | def get_name(self): 36 | return 'imagenet1k' 37 | 38 | def get_num_sequences(self): 39 | return len(self.dataset.samples) 40 | 41 | def get_sequence_info(self, seq_id): 42 | '''2021.1.3 To avoid too small bounding boxes. Here we change the threshold to 50 pixels''' 43 | valid = torch.tensor([True]) 44 | visible = valid.clone().byte() 45 | return {'bbox': None, 'mask': None, 'valid': valid, 'visible': visible} 46 | def _get_frames(self, seq_id): 47 | img, target = self.dataset.__getitem__(seq_id) 48 | return img 49 | 50 | def get_frames(self, seq_id=None, frame_ids=None, anno=None): 51 | # Imagenet is an image dataset. Thus we replicate the image denoted by seq_id len(frame_ids) times, and return a 52 | # list containing these replicated images. 53 | frame = self._get_frames(seq_id) 54 | 55 | frame_list = [frame.copy() for _ in frame_ids] 56 | 57 | return frame_list, None, None 58 | 59 | if __name__ == '__main__': 60 | data_root = './data/imagenet1k' 61 | dataset = Imagenet1k(data_root) -------------------------------------------------------------------------------- /lib/train/dataset/imagenet22k.py: -------------------------------------------------------------------------------- 1 | import os 2 | from lib.train.dataset.base_video_dataset import BaseVideoDataset 3 | from lib.train.data import jpeg4py_loader 4 | import torch 5 | import random 6 | from lib.train.dataset.imagenet22k_dataset import IN22KDataset 7 | from collections import OrderedDict 8 | from lib.train.admin import env_settings 9 | import numpy as np 10 | 11 | 12 | class Imagenet22k(BaseVideoDataset): 13 | """ The ImageNet22k dataset. ImageNet22k is an image dataset. Thus, we treat each image as a sequence of length 1. 14 | """ 15 | 16 | def __init__(self, root=None, image_loader=jpeg4py_loader, split="train"): 17 | """ 18 | args: 19 | root - path to the coco dataset. 20 | image_loader (default_image_loader) - The function to read the images. If installed, 21 | jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. Else, 22 | opencv's imread is used. 23 | data_fraction (None) - Fraction of images to be used. The images are selected randomly. If None, all the 24 | images will be used 25 | split - 'train' or 'val'. 26 | version - version of coco dataset (2014 or 2017) 27 | """ 28 | root = env_settings().imagenet22k_dir if root is None else root 29 | super().__init__('imagenet22k', root, image_loader) 30 | 31 | self.dataset = IN22KDataset(data_root=root, transform=None, fname_format='imagenet5k/{}.JPEG', debug=False) 32 | 33 | def is_video_sequence(self): 34 | return False 35 | 36 | def get_name(self): 37 | return 'imagenet22k' 38 | 39 | def get_num_sequences(self): 40 | return len(self.dataset) 41 | 42 | def get_sequence_info(self, seq_id): 43 | '''2021.1.3 To avoid too small bounding boxes. Here we change the threshold to 50 pixels''' 44 | valid = torch.tensor([True]) 45 | visible = valid.clone().byte() 46 | return {'bbox': None, 'mask': None, 'valid': valid, 'visible': visible} 47 | 48 | def _get_frames(self, seq_id): 49 | img, target = self.dataset.__getitem__(seq_id) 50 | return img 51 | 52 | def get_frames(self, seq_id=None, frame_ids=None, anno=None): 53 | # Imagenet is an image dataset. Thus we replicate the image denoted by seq_id len(frame_ids) times, and return a 54 | # list containing these replicated images. 55 | frame = self._get_frames(seq_id) 56 | 57 | frame_list = [frame.copy() for _ in frame_ids] 58 | 59 | return frame_list, None, None 60 | 61 | 62 | if __name__ == '__main__': 63 | data_root = './data/imagenet22k' 64 | dataset = Imagenet22k(data_root) 65 | -------------------------------------------------------------------------------- /lib/train/dataset/imagenet22k_dataset.py: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------- 2 | # ImageNet 22k Dataset 3 | # Copyright (c) 2022 Microsoft 4 | # -------------------------------------------------------- 5 | 6 | import io 7 | import os 8 | import torch 9 | from collections import defaultdict 10 | from PIL import Image 11 | import zipfile 12 | 13 | 14 | class IN22KDataset(torch.utils.data.Dataset): 15 | def __init__(self, data_root, transform, fname_format='{}.jpeg', debug=False): 16 | super().__init__() 17 | self.data_root = data_root 18 | self.transform = transform 19 | self.debug = debug 20 | self.fname_format = fname_format 21 | 22 | info_fname = os.path.join(data_root, 'in22k_image_names.txt') 23 | assert os.path.isfile( 24 | info_fname), f'IN22k-List filelist: {info_fname} does not exist' 25 | 26 | folders = defaultdict(list) 27 | with open(info_fname, 'r') as f: 28 | for iname in f: 29 | iname = iname.strip() 30 | class_name = iname[:iname.index('_')] 31 | folders[class_name].append(iname) 32 | class_names = sorted(folders.keys()) 33 | self.nb_classes = len(class_names) 34 | 35 | if debug: 36 | for name in class_names: 37 | if not name.startswith('n00288190'): 38 | folders[name] = [] 39 | 40 | self.data = [] 41 | for cls_id, cls_name in enumerate(class_names): 42 | self.data.extend([(iname, cls_id) for iname in folders[cls_name]]) 43 | 44 | def __len__(self): 45 | return len(self.data) 46 | 47 | def __getitem__(self, idx): 48 | iname, target = self.data[idx] 49 | iob = self._read_file(iname) 50 | img = Image.open(iob).convert('RGB') 51 | 52 | if self.transform is not None: 53 | img = self.transform(img) 54 | return img, target 55 | 56 | def _read_file(self, iname): 57 | # Example: 58 | # iname: 'n00007846_10001' 59 | # fname: 'n00007846_10001.jpeg' 60 | cls_name = iname[:iname.index('_')] 61 | fname = self.fname_format.format(iname) 62 | zip_fname = os.path.join(self.data_root, cls_name + '.zip') 63 | handle = zipfile.ZipFile(zip_fname, 'r') 64 | bstr = handle.read(fname) 65 | iob = io.BytesIO(bstr) 66 | return iob 67 | 68 | def get_keys(self): 69 | return [e[0] for e in self.data] 70 | 71 | 72 | if __name__ == '__main__': 73 | data_root = './data/imagenet22k' 74 | def transform(x): return x 75 | fname_format = 'imagenet5k/{}.JPEG' 76 | dataset = IN22KDataset(data_root, transform, fname_format, debug=True) 77 | for img, target in dataset: 78 | print(type(img), target) 79 | break -------------------------------------------------------------------------------- /lib/train/trainers/__init__.py: -------------------------------------------------------------------------------- 1 | from .base_trainer import BaseTrainer 2 | from .ltr_trainer import LTRTrainer 3 | -------------------------------------------------------------------------------- /lib/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .tensor import TensorDict, TensorList 2 | -------------------------------------------------------------------------------- /lib/utils/ema_sched.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # All rights reserved. 3 | 4 | # This source code is licensed under the license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | import math 8 | 9 | class CosineEMA: 10 | def __init__(self, cfg): 11 | self.cfg = cfg 12 | self.last_epoch = 0 13 | 14 | def adjust(self, epoch): 15 | """Decay the learning rate with half-cycle cosine after warmup""" 16 | self.last_epoch = epoch 17 | cfg = self.cfg 18 | 19 | ema_decay = cfg.TRAIN.EMA_SCHEDULER.MAX - \ 20 | (cfg.TRAIN.EMA_SCHEDULER.MAX - cfg.TRAIN.EMA_SCHEDULER.MIN) * 0.5 * \ 21 | (1. + math.cos(math.pi * epoch / cfg.TRAIN.EPOCH)) 22 | 23 | return ema_decay 24 | 25 | class ConstantEMA: 26 | def __init__(self, cfg): 27 | self.cfg = cfg 28 | 29 | def adjust(self, epoch): 30 | ema_decay = self.cfg.TRAIN.EMA_DECAY 31 | return ema_decay -------------------------------------------------------------------------------- /lib/utils/gen_fname_list.py: -------------------------------------------------------------------------------- 1 | import os 2 | import argparse 3 | 4 | parser = argparse.ArgumentParser(description='generate namelist') 5 | # parser.add_argument('--base_dir', type=str, required=True, help='data directory.') 6 | # parser.add_argument('--result_file', type=str, required=True, help="result file.") 7 | args = parser.parse_args() 8 | # base_dir = args.base_dir 9 | # result_file = args.result_file 10 | 11 | # base_dir = "/data/sda/v-yanbi/iccv21/LittleBoy/data/got10k/" # replace it with your own path 12 | # result_file = "/data/sda/v-yanbi/iccv21/LittleBoy/data/got10k.namelist" 13 | # base_dir = "/data/sda/v-yanbi/iccv21/LittleBoy/data/lasot/" # replace it with your own path 14 | # result_file = "/data/sda/v-yanbi/iccv21/LittleBoy/data/lasot.namelist" 15 | # base_dir = "/data/sda/v-yanbi/iccv21/LittleBoy/data/vid/" # replace it with your own path 16 | # result_file = "/data/sda/v-yanbi/iccv21/LittleBoy/data/vid.namelist" 17 | # base_dir = "/data/sda/v-yanbi/iccv21/LittleBoy/data/coco/" # replace it with your own path 18 | # result_file = "/data/sda/v-yanbi/iccv21/LittleBoy/data/coco.namelist" 19 | base_dir = "/home/cx/cx3/GOT10K/" # replace it with your own path 20 | result_file = "/home/cx/cx3/got10k.namelist" 21 | 22 | assert (base_dir.endswith('/')) 23 | fnames = [] 24 | for root, dirs, files in os.walk(base_dir): 25 | for file in files: 26 | path = os.path.join(root, file) 27 | if not os.path.exists(path): 28 | print("%s doesn't exist.") 29 | rela_path = path.replace(base_dir, "") 30 | fnames.append(rela_path) 31 | 32 | 33 | with open(result_file, 'w') as fout: 34 | for name in fnames: 35 | fout.write(name + '\n') 36 | -------------------------------------------------------------------------------- /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/lr_sched.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # All rights reserved. 3 | 4 | # This source code is licensed under the license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | import math 8 | 9 | class CosineWarmUp: 10 | 11 | def __init__(self, cfg): 12 | self.cfg = cfg 13 | self.last_epoch = 0 14 | 15 | def adjust_learning_rate(self, optimizer, epoch): 16 | """Decay the learning rate with half-cycle cosine after warmup""" 17 | self.last_epoch = epoch 18 | cfg = self.cfg 19 | if epoch < cfg.TRAIN.WARMUP_EPOCHS: 20 | lr = cfg.TRAIN.LR * epoch / cfg.TRAIN.WARMUP_EPOCHS 21 | else: 22 | lr = cfg.TRAIN.MIN_LR + (cfg.TRAIN.LR - cfg.TRAIN.MIN_LR) * 0.5 * \ 23 | (1. + math.cos(math.pi * (epoch - cfg.TRAIN.WARMUP_EPOCHS) / (cfg.TRAIN.EPOCH - cfg.TRAIN.WARMUP_EPOCHS))) 24 | for param_group in optimizer.param_groups: 25 | if "lr_scale" in param_group: 26 | param_group["lr"] = lr * param_group["lr_scale"] 27 | else: 28 | param_group["lr"] = lr 29 | return lr 30 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/utils/write_to_lmdb.py: -------------------------------------------------------------------------------- 1 | import lmdb 2 | import os 3 | from tqdm import tqdm 4 | import argparse 5 | 6 | parser = argparse.ArgumentParser(description='generate lmdb') 7 | # parser.add_argument('--base_dir', type=str, required=True, help='data directory.') 8 | # parser.add_argument('--result_file', type=str, required=True, help="result file.") 9 | args = parser.parse_args() 10 | # base_dir = args.base_dir 11 | # result_file = args.result_file 12 | 13 | # base_dir = "/data/sda/v-yanbi/iccv21/LittleBoy/data/got10k/" # replace it with your own path 14 | # result_file = "/data/sda/v-yanbi/iccv21/LittleBoy/data/got10k.namelist" 15 | # base_dir = "/data/sda/v-yanbi/iccv21/LittleBoy/data/lasot/" # replace it with your own path 16 | # result_file = "/data/sda/v-yanbi/iccv21/LittleBoy/data/lasot.namelist" 17 | # base_dir = "/data/sda/v-yanbi/iccv21/LittleBoy/data/vid/" # replace it with your own path 18 | # result_file = "/data/sda/v-yanbi/iccv21/LittleBoy/data/vid.namelist" 19 | # base_dir = "/data/sda/v-yanbi/iccv21/LittleBoy/data/coco/" # replace it with your own path 20 | # result_file = "/data/sda/v-yanbi/iccv21/LittleBoy/data/coco.namelist" 21 | base_dir = "/home/cx/cx3/GOT10K/" # replace it with your own path 22 | result_file = "/home/cx/cx3/got10k.namelist" 23 | 24 | namelist = [x.strip() for x in open(result_file).readlines()] 25 | print('number:', len(namelist)) 26 | 27 | if base_dir.endswith("/"): 28 | lmdb_fname = base_dir[:-1] + '_lmdb' 29 | else: 30 | lmdb_fname = base_dir + '_lmdb' 31 | env = lmdb.open(lmdb_fname, map_size=1024 ** 4) 32 | txn = env.begin(write=True) 33 | 34 | for i, t in enumerate(tqdm(namelist)): 35 | if i % 100000 == 0: 36 | txn.commit() 37 | txn = env.begin(write=True) 38 | with open(os.path.join(base_dir, t), 'rb') as fin: 39 | txn.put(key=t.encode(), value=fin.read()) 40 | 41 | txn.commit() 42 | env.close() 43 | -------------------------------------------------------------------------------- /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 = 'otb99_lang' # choosen from 'uav', 'nfs', 'lasot_extension_subset', 'lasot', 'otb99_lang', 'tnl2k' 10 | 11 | trackers.extend(trackerlist(name='seqtrack', parameter_name='seqtrack_b256', dataset_name=dataset_name, 12 | run_ids=None, display_name='seqtrack_b256')) 13 | 14 | dataset = get_dataset(dataset_name) 15 | 16 | print_results(trackers, dataset, dataset_name, merge_results=True, plot_types=('success', 'prec', 'norm_prec'), 17 | force_evaluation=True) 18 | 19 | -------------------------------------------------------------------------------- /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/test.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import argparse 4 | 5 | env_path = os.path.join(os.path.dirname(__file__), '../..') 6 | if env_path not in sys.path: 7 | sys.path.append(env_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 | def run_tracker(tracker_name, tracker_param, run_id=None, dataset_name='otb', sequence=None, debug=0, threads=0, 14 | num_gpus=8): 15 | """Run tracker on sequence or dataset. 16 | args: 17 | tracker_name: Name of tracking method. 18 | tracker_param: Name of parameter file. 19 | run_id: The run id. 20 | dataset_name: Name of dataset. 21 | sequence: Sequence number or name. 22 | debug: Debug level. 23 | threads: Number of threads. 24 | """ 25 | 26 | dataset = get_dataset(dataset_name) 27 | 28 | if sequence is not None: 29 | dataset = [dataset[sequence]] 30 | 31 | trackers = [Tracker(tracker_name, tracker_param, dataset_name, run_id)] 32 | 33 | run_dataset(dataset, trackers, debug, threads, num_gpus=num_gpus) 34 | 35 | 36 | def main(): 37 | parser = argparse.ArgumentParser(description='Run tracker on sequence or dataset.') 38 | parser.add_argument('tracker_name', type=str, help='Name of tracking method.') 39 | parser.add_argument('tracker_param', type=str, help='Name of config file.') 40 | parser.add_argument('--runid', type=int, default=None, help='The run id.') 41 | parser.add_argument('--dataset_name', type=str, default='lasot', help='Name of dataset (otb, nfs, uav, got10k_test, ' 42 | 'lasot, trackingnet, lasot_extension_subset, tnl2k,' 43 | 'lasot_lang, otb99_lang).') 44 | parser.add_argument('--sequence', type=str, default=None, help='Sequence number or name.') 45 | parser.add_argument('--debug', type=int, default=0, help='Debug level.') 46 | parser.add_argument('--threads', type=int, default=0, help='Number of threads.') 47 | parser.add_argument('--num_gpus', type=int, default=8) 48 | 49 | args = parser.parse_args() 50 | 51 | try: 52 | seq_name = int(args.sequence) 53 | except: 54 | seq_name = args.sequence 55 | 56 | run_tracker(args.tracker_name, args.tracker_param, args.runid, args.dataset_name, seq_name, args.debug, 57 | args.threads, num_gpus=args.num_gpus) 58 | 59 | 60 | if __name__ == '__main__': 61 | main() 62 | -------------------------------------------------------------------------------- /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 | # for knowledge distillation 19 | parser.add_argument('--distill', type=int, choices=[0, 1], default=0) # whether to use knowledge distillation 20 | parser.add_argument('--script_teacher', type=str, help='teacher script name') 21 | parser.add_argument('--config_teacher', type=str, help='teacher yaml configure file name') 22 | 23 | args = parser.parse_args() 24 | 25 | return args 26 | 27 | 28 | def main(): 29 | args = parse_args() 30 | if args.mode == "single": 31 | train_cmd = "python lib/train/run_training.py --script %s --config %s --save_dir %s --use_lmdb %d " \ 32 | % (args.script, args.config, args.save_dir, args.use_lmdb) 33 | elif args.mode == "multiple": 34 | train_cmd = "python -m torch.distributed.launch --nproc_per_node %d lib/train/run_training.py " \ 35 | "--script %s --config %s --save_dir %s --use_lmdb %d " \ 36 | % (args.nproc_per_node, args.script, args.config, args.save_dir, args.use_lmdb) 37 | else: 38 | raise ValueError("mode should be 'single' or 'multiple'.") 39 | print(train_cmd) 40 | os.system(train_cmd) 41 | 42 | 43 | if __name__ == "__main__": 44 | main() 45 | --------------------------------------------------------------------------------