├── arena ├── __init__.py ├── LaSOT │ ├── __init__.py │ ├── legacy │ │ └── __init__.py │ ├── timer.py │ ├── common_path_siamrpn.py │ └── common_path.py ├── VOT2020 │ ├── __init__.py │ ├── vot │ │ ├── __init__.py │ │ ├── dataset │ │ │ ├── cow.png │ │ │ └── proxy.py │ │ ├── stack │ │ │ ├── votrgbd2019.yaml │ │ │ ├── votrgbd2020.yaml │ │ │ ├── votrgbtir2020.yaml │ │ │ ├── vot2015.yaml │ │ │ ├── vottir2016.yaml │ │ │ ├── vottir2015.yaml │ │ │ ├── vot2013.yaml │ │ │ ├── vot2014.yaml │ │ │ ├── votlt2019.yaml │ │ │ ├── votlt2020.yaml │ │ │ ├── vot2016.yaml │ │ │ ├── vot2017.yaml │ │ │ ├── testing.yaml │ │ │ ├── vot2018.yaml │ │ │ ├── vot2019.yaml │ │ │ └── vot2020.yaml │ │ ├── requirements.txt │ │ ├── analysis │ │ │ └── document.py │ │ ├── __main__.py │ │ └── region │ │ │ └── io.py │ ├── utils │ │ ├── __init__.py │ │ └── utils.py │ ├── common_path.py │ ├── run_siamrpn.py │ ├── run_rtmdnet.py │ ├── run_rtmdnet_alphaseg.py │ ├── run_siamrpn_alphaseg.py │ ├── run_pytracking.py │ └── run_pytracking_alphaseg.py ├── analysis │ └── .gitignore ├── GOT10k │ ├── toolkit │ │ ├── got10k │ │ │ ├── __init__.py │ │ │ ├── utils │ │ │ │ ├── __init__.py │ │ │ │ └── ioutils.py │ │ │ ├── datasets │ │ │ │ └── __init__.py │ │ │ ├── experiments │ │ │ │ ├── __init__.py │ │ │ │ ├── dtb70.py │ │ │ │ ├── nfs.py │ │ │ │ ├── tcolor128.py │ │ │ │ ├── uav123.py │ │ │ │ └── trackingnet.py │ │ │ └── trackers │ │ │ │ ├── identity_tracker.py │ │ │ │ └── __init__.py │ │ ├── setup.cfg │ │ ├── MANIFEST.in │ │ ├── resources │ │ │ └── sample_batch_run.jpg │ │ ├── .gitignore │ │ ├── requirements.txt │ │ ├── setup.py │ │ ├── tests │ │ │ ├── test_trackers.py │ │ │ └── test_utils.py │ │ └── LICENSE │ ├── cluster_test.sh │ ├── __init__.py │ ├── common_path.py │ ├── common_path_siamrpn.py │ ├── collect_reports.py │ ├── rtmdnet_RF.py │ └── eval_got10k.py ├── ar_legacy │ └── VOT2018 │ │ ├── common_path_siamrpn.py │ │ └── common_path.py └── TrackingNet │ ├── common_path_siamrpn.py │ └── common_path.py ├── external ├── __init__.py ├── RT_MDNet │ ├── __init__.py │ ├── modules │ │ ├── __init__.py │ │ ├── roi_align │ │ │ ├── functions │ │ │ │ └── __init__.py │ │ │ ├── modules │ │ │ │ └── __init__.py │ │ │ ├── __init__.py │ │ │ ├── setup.py │ │ │ └── gradcheck.py │ │ ├── pretrain_options.py │ │ └── bbreg.py │ ├── others │ │ └── __init__.py │ ├── test.sh │ ├── .gitignore │ ├── MDNet_utils.py │ └── options.py └── pysot │ ├── pysot │ ├── __init__.py │ ├── core │ │ ├── __init__.py │ │ └── xcorr.py │ ├── utils │ │ ├── __init__.py │ │ └── misc.py │ ├── datasets │ │ └── __init__.py │ ├── models │ │ ├── __init__.py │ │ ├── init_weight.py │ │ ├── neck │ │ │ ├── __init__.py │ │ │ └── neck.py │ │ ├── backbone │ │ │ └── __init__.py │ │ ├── head │ │ │ └── __init__.py │ │ └── loss.py │ └── tracker │ │ ├── __init__.py │ │ ├── tracker_builder_new.py │ │ └── tracker_builder.py │ ├── toolkit │ ├── __init__.py │ ├── utils │ │ ├── __init__.py │ │ ├── misc.py │ │ └── c_region.pxd │ ├── visualization │ │ ├── __init__.py │ │ ├── draw_utils.py │ │ ├── draw_mask.py │ │ ├── draw_eao.py │ │ └── draw_f1.py │ ├── evaluation │ │ └── __init__.py │ └── datasets │ │ ├── dataset.py │ │ ├── __init__.py │ │ └── uav.py │ ├── requirements.txt │ ├── common_path.py │ ├── setup.py │ ├── INSTALL.md │ ├── common_path_siamrpn.py │ ├── install.sh │ ├── common_path_siammask.py │ ├── .gitignore │ └── README.md ├── ltr ├── admin │ ├── __init__.py │ ├── settings.py │ ├── multigpu.py │ ├── local.py.example │ ├── tensorboard.py │ ├── stats.py │ ├── environment.py │ └── model_constructor.py ├── models │ ├── __init__.py │ ├── head │ │ ├── __init__.py │ │ └── bbox.py │ ├── kys │ │ ├── __init__.py │ │ └── conv_gru.py │ ├── lwl │ │ ├── __init__.py │ │ ├── utils.py │ │ ├── initializer.py │ │ └── loss_residual_modules.py │ ├── meta │ │ └── __init__.py │ ├── layers │ │ ├── __init__.py │ │ ├── normalization.py │ │ ├── transform.py │ │ ├── blocks.py │ │ ├── distance.py │ │ └── activation.py │ ├── tracking │ │ └── __init__.py │ ├── bbreg │ │ └── __init__.py │ ├── target_classifier │ │ └── __init__.py │ ├── loss │ │ └── __init__.py │ └── backbone │ │ ├── efficientnet │ │ ├── __init__.py │ │ └── test_efb0.py │ │ ├── __init__.py │ │ └── base.py ├── train_settings │ ├── __init__.py │ ├── bbreg │ │ └── __init__.py │ ├── dimp │ │ └── __init__.py │ ├── kys │ │ └── __init__.py │ └── lwl │ │ └── __init__.py ├── data │ ├── __init__.py │ └── ardata │ │ └── __init__.py ├── external │ └── PreciseRoIPooling │ │ ├── pytorch │ │ ├── prroi_pool │ │ │ ├── .gitignore │ │ │ ├── __init__.py │ │ │ ├── src │ │ │ │ ├── prroi_pooling_gpu.h │ │ │ │ └── prroi_pooling_gpu_impl.cuh │ │ │ └── prroi_pool.py │ │ └── tests │ │ │ └── test_prroi_pooling2d.py │ │ ├── _assets │ │ └── prroi_visualization.png │ │ ├── LICENSE │ │ ├── .gitignore │ │ └── src │ │ └── prroi_pooling_gpu_impl.cuh ├── trainers │ └── __init__.py ├── __init__.py ├── dataset │ ├── ardataset │ │ ├── check_youtubevos.py │ │ ├── get_lasot_test_txt.py │ │ └── __init__.py │ └── __init__.py ├── actors │ ├── __init__.py │ ├── base_actor.py │ ├── ar_actors │ │ └── SEc.py │ └── bbreg.py └── run_training.py ├── pytracking ├── analysis │ └── __init__.py ├── features │ ├── __init__.py │ ├── color.py │ └── util.py ├── parameter │ ├── __init__.py │ ├── atom │ │ └── __init__.py │ ├── dimp │ │ ├── __init__.py │ │ ├── dimp18.py │ │ ├── dimp50.py │ │ └── dimp50_vot19.py │ ├── eco │ │ └── __init__.py │ ├── kys │ │ └── __init__.py │ └── lwl │ │ ├── __init__.py │ │ ├── lwl_ytvos.py │ │ └── lwl_boxinit.py ├── tracker │ ├── __init__.py │ ├── base │ │ ├── __init__.py │ │ └── basetracker.py │ ├── eco │ │ └── __init__.py │ ├── atom │ │ └── __init__.py │ ├── dimp │ │ └── __init__.py │ ├── kys │ │ └── __init__.py │ └── lwl │ │ └── __init__.py ├── experiments │ ├── __init__.py │ └── myexperiments.py ├── refine_modules │ ├── __init__.py │ └── utils.py ├── util_scripts │ ├── __init__.py │ ├── pack_got10k_results.py │ └── pack_trackingnet_results.py ├── utils │ ├── __init__.py │ ├── convert_vot_anno_to_rect.py │ ├── loading.py │ ├── params.py │ └── load_text.py ├── libs │ ├── __init__.py │ ├── tensordict.py │ └── operation.py ├── .figs │ ├── NFS.png │ ├── LaSOT.png │ ├── OTB-100.png │ ├── UAV123.png │ ├── visdom.png │ ├── kys_overview.png │ ├── atom_overview.png │ ├── dimp_overview.png │ └── lwtl_overview.png ├── evaluation │ ├── __init__.py │ ├── local.py.example │ └── got10kdataset.py ├── RF_utils.py ├── __init__.py ├── VOT │ ├── trackers.ini │ └── tracker_DiMP.m ├── run_vot.py ├── run_experiment.py ├── run_video.py └── run_webcam.py ├── doc ├── asset │ └── AR-Architecture.png ├── TRAIN.md ├── arena │ └── TrackingNet.md └── Reproduce.md ├── setup.py └── .gitignore /arena/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /arena/LaSOT/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ltr/admin/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ltr/models/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /arena/VOT2020/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ltr/models/head/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ltr/models/kys/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ltr/models/lwl/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ltr/models/meta/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /arena/LaSOT/legacy/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /arena/analysis/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /external/RT_MDNet/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/pysot/pysot/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ltr/models/layers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ltr/models/tracking/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ltr/train_settings/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pytracking/analysis/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pytracking/features/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pytracking/parameter/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pytracking/tracker/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/RT_MDNet/modules/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/RT_MDNet/others/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/pysot/pysot/core/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/pysot/pysot/utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/pysot/toolkit/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ltr/train_settings/bbreg/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ltr/train_settings/dimp/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ltr/train_settings/kys/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ltr/train_settings/lwl/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pytracking/experiments/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pytracking/parameter/atom/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pytracking/parameter/dimp/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pytracking/parameter/eco/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pytracking/parameter/kys/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pytracking/parameter/lwl/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pytracking/refine_modules/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pytracking/util_scripts/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/got10k/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/pysot/pysot/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/pysot/pysot/models/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/pysot/pysot/tracker/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/got10k/utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ltr/data/__init__.py: -------------------------------------------------------------------------------- 1 | from .loader import LTRLoader -------------------------------------------------------------------------------- /external/RT_MDNet/modules/roi_align/functions/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /external/RT_MDNet/modules/roi_align/modules/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ltr/data/ardata/__init__.py: -------------------------------------------------------------------------------- 1 | from .loader import LTRLoader -------------------------------------------------------------------------------- /arena/VOT2020/vot/__init__.py: -------------------------------------------------------------------------------- 1 | class VOTException(Exception): 2 | pass -------------------------------------------------------------------------------- /ltr/models/bbreg/__init__.py: -------------------------------------------------------------------------------- 1 | from .atom_iou_net import AtomIoUNet 2 | -------------------------------------------------------------------------------- /pytracking/tracker/base/__init__.py: -------------------------------------------------------------------------------- 1 | from .basetracker import BaseTracker -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description-file = README.md 3 | -------------------------------------------------------------------------------- /ltr/external/PreciseRoIPooling/pytorch/prroi_pool/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | /_prroi_pooling 3 | -------------------------------------------------------------------------------- /ltr/models/target_classifier/__init__.py: -------------------------------------------------------------------------------- 1 | from .linear_filter import LinearFilter 2 | -------------------------------------------------------------------------------- /pytracking/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .params import TrackerParams, FeatureParams, Choice -------------------------------------------------------------------------------- /external/pysot/toolkit/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from . import region 2 | from .statistics import * 3 | -------------------------------------------------------------------------------- /ltr/trainers/__init__.py: -------------------------------------------------------------------------------- 1 | from .base_trainer import BaseTrainer 2 | from .ltr_trainer import LTRTrainer -------------------------------------------------------------------------------- /pytracking/libs/__init__.py: -------------------------------------------------------------------------------- 1 | from .tensorlist import TensorList 2 | from .tensordict import TensorDict -------------------------------------------------------------------------------- /pytracking/tracker/eco/__init__.py: -------------------------------------------------------------------------------- 1 | from .eco import ECO 2 | 3 | def get_tracker_class(): 4 | return ECO -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include got10k/datasets/uav123.json 2 | include got10k/datasets/lasot.json 3 | -------------------------------------------------------------------------------- /pytracking/.figs/NFS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasterBin-IIAU/AlphaRefine/HEAD/pytracking/.figs/NFS.png -------------------------------------------------------------------------------- /pytracking/tracker/atom/__init__.py: -------------------------------------------------------------------------------- 1 | from .atom import ATOM 2 | 3 | def get_tracker_class(): 4 | return ATOM -------------------------------------------------------------------------------- /pytracking/tracker/dimp/__init__.py: -------------------------------------------------------------------------------- 1 | from .dimp import DiMP 2 | 3 | def get_tracker_class(): 4 | return DiMP -------------------------------------------------------------------------------- /pytracking/tracker/kys/__init__.py: -------------------------------------------------------------------------------- 1 | from .kys import KYS 2 | 3 | 4 | def get_tracker_class(): 5 | return KYS -------------------------------------------------------------------------------- /pytracking/tracker/lwl/__init__.py: -------------------------------------------------------------------------------- 1 | from .lwl import LWL 2 | 3 | 4 | def get_tracker_class(): 5 | return LWL -------------------------------------------------------------------------------- /pytracking/.figs/LaSOT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasterBin-IIAU/AlphaRefine/HEAD/pytracking/.figs/LaSOT.png -------------------------------------------------------------------------------- /pytracking/.figs/OTB-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasterBin-IIAU/AlphaRefine/HEAD/pytracking/.figs/OTB-100.png -------------------------------------------------------------------------------- /pytracking/.figs/UAV123.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasterBin-IIAU/AlphaRefine/HEAD/pytracking/.figs/UAV123.png -------------------------------------------------------------------------------- /pytracking/.figs/visdom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasterBin-IIAU/AlphaRefine/HEAD/pytracking/.figs/visdom.png -------------------------------------------------------------------------------- /doc/asset/AR-Architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasterBin-IIAU/AlphaRefine/HEAD/doc/asset/AR-Architecture.png -------------------------------------------------------------------------------- /arena/VOT2020/vot/dataset/cow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasterBin-IIAU/AlphaRefine/HEAD/arena/VOT2020/vot/dataset/cow.png -------------------------------------------------------------------------------- /external/RT_MDNet/test.sh: -------------------------------------------------------------------------------- 1 | # bash 2 | python run_RTMDNet_RF.py --dataset LaSOT 3 | python run_RTMDNet_RF.py --dataset OTB100 4 | -------------------------------------------------------------------------------- /pytracking/.figs/kys_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasterBin-IIAU/AlphaRefine/HEAD/pytracking/.figs/kys_overview.png -------------------------------------------------------------------------------- /arena/GOT10k/cluster_test.sh: -------------------------------------------------------------------------------- 1 | for code in a b c d e; 2 | do 3 | python eval_got10k.py --tracker ATOM_RF --rf_code $code & 4 | done -------------------------------------------------------------------------------- /pytracking/.figs/atom_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasterBin-IIAU/AlphaRefine/HEAD/pytracking/.figs/atom_overview.png -------------------------------------------------------------------------------- /pytracking/.figs/dimp_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasterBin-IIAU/AlphaRefine/HEAD/pytracking/.figs/dimp_overview.png -------------------------------------------------------------------------------- /pytracking/.figs/lwtl_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasterBin-IIAU/AlphaRefine/HEAD/pytracking/.figs/lwtl_overview.png -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | 4 | setup( 5 | name='ar', 6 | packages=find_packages(), 7 | ) -------------------------------------------------------------------------------- /arena/VOT2020/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .utils import make_full_size, bbox_clip, rect_from_mask, mask_from_rect 2 | from .vot_utils import VOT -------------------------------------------------------------------------------- /external/RT_MDNet/.gitignore: -------------------------------------------------------------------------------- 1 | models/ 2 | *.pth 3 | *.npy 4 | *.tar 5 | *.pkl 6 | __pycache__/ 7 | build/ 8 | *.so 9 | .idea/ 10 | -------------------------------------------------------------------------------- /external/pysot/requirements.txt: -------------------------------------------------------------------------------- 1 | opencv-python 2 | yacs 3 | tqdm 4 | pyyaml 5 | matplotlib 6 | colorama 7 | cython 8 | tensorboardX 9 | -------------------------------------------------------------------------------- /ltr/models/loss/__init__.py: -------------------------------------------------------------------------------- 1 | from .target_classification import LBHinge, LBHingev2, IsTargetCellLoss, TrackingClassificationAccuracy 2 | -------------------------------------------------------------------------------- /pytracking/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | from .data import Sequence 2 | from .tracker import Tracker, trackerlist 3 | from .datasets import get_dataset -------------------------------------------------------------------------------- /ltr/__init__.py: -------------------------------------------------------------------------------- 1 | from .admin.loading import load_network 2 | from .admin.model_constructor import model_constructor 3 | from .admin.multigpu import MultiGPU -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/resources/sample_batch_run.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasterBin-IIAU/AlphaRefine/HEAD/arena/GOT10k/toolkit/resources/sample_batch_run.jpg -------------------------------------------------------------------------------- /arena/GOT10k/__init__.py: -------------------------------------------------------------------------------- 1 | from .pytracking_RF import DiMPsuper_RF, DiMP50_RF, ATOM_RF, ECO_RF 2 | from .siamrpn_RF import SiamRPNpp_RF 3 | from .rtmdnet_RF import RTMDNet_RF -------------------------------------------------------------------------------- /external/pysot/toolkit/visualization/__init__.py: -------------------------------------------------------------------------------- 1 | from .draw_f1 import draw_f1 2 | from .draw_success_precision import draw_success_precision 3 | from .draw_eao import draw_eao 4 | -------------------------------------------------------------------------------- /ltr/external/PreciseRoIPooling/_assets/prroi_visualization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasterBin-IIAU/AlphaRefine/HEAD/ltr/external/PreciseRoIPooling/_assets/prroi_visualization.png -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/.gitignore: -------------------------------------------------------------------------------- 1 | .* 2 | *.pyc 3 | __pycache__/ 4 | data 5 | data/ 6 | cache/ 7 | results/ 8 | reports/ 9 | profiles/ 10 | venv/ 11 | build/ 12 | dist/ 13 | *.egg-info 14 | !.gitignore 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | __pycache__/ 3 | *.pth 4 | *.pth.tar 5 | local.py 6 | log*.txt 7 | pytracking/pytracking.egg-info/ 8 | pytracking/pytracking 9 | pytracking/networks 10 | *.egg* 11 | *.pyc 12 | tensorboard/ 13 | -------------------------------------------------------------------------------- /external/pysot/toolkit/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | from .ar_benchmark import AccuracyRobustnessBenchmark 2 | from .eao_benchmark import EAOBenchmark 3 | from .ope_benchmark import OPEBenchmark 4 | from .f1_benchmark import F1Benchmark 5 | -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/requirements.txt: -------------------------------------------------------------------------------- 1 | cycler==0.10.0 2 | kiwisolver==1.0.1 3 | matplotlib==3.0.2 4 | numpy==1.15.4 5 | Pillow==6.2.0 6 | pyparsing==2.3.0 7 | python-dateutil==2.7.5 8 | Shapely==1.6.4.post2 9 | six==1.11.0 10 | -------------------------------------------------------------------------------- /ltr/dataset/ardataset/check_youtubevos.py: -------------------------------------------------------------------------------- 1 | from ltr.dataset import Youtube_VOS 2 | import random 3 | dataset = Youtube_VOS() 4 | num_inst = dataset.get_num_sequences() 5 | idx = random.randint(0,num_inst) 6 | dataset.get_sequence_info(idx) -------------------------------------------------------------------------------- /arena/LaSOT/timer.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | 4 | class Timer(): 5 | def __enter__(self): 6 | self.tic = time.time() 7 | 8 | def __exit__(self, exc_type, exc_val, exc_tb): 9 | self.toc = time.time() 10 | print(self.toc-self.tic) 11 | -------------------------------------------------------------------------------- /ltr/actors/__init__.py: -------------------------------------------------------------------------------- 1 | from .base_actor import BaseActor 2 | from .bbreg import AtomActor 3 | from .tracking import DiMPActor, KYSActor 4 | from ltr.actors.ar_actors.SEcm import SEcm_Actor 5 | from ltr.actors.ar_actors.SEc import SEc_Actor 6 | from ltr.actors.ar_actors.SEm import SEm_Actor 7 | -------------------------------------------------------------------------------- /ltr/models/backbone/efficientnet/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "0.7.0" 2 | from .model import EfficientNet, VALID_MODELS 3 | from .utils import ( 4 | GlobalParams, 5 | BlockArgs, 6 | BlockDecoder, 7 | efficientnet, 8 | get_model_params, 9 | ) 10 | from .model4ar import efficientnet 11 | -------------------------------------------------------------------------------- /ltr/dataset/ardataset/get_lasot_test_txt.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | lasot_test_path = '/media/masterbin-iiau/EAGET-USB/LaSOT_Test' 4 | result_path = 'lasot_test.txt' 5 | f = open(result_path, 'w') 6 | sequence_list = os.listdir(lasot_test_path) 7 | for idx, seq in enumerate(sequence_list): 8 | f.write(seq+'\n') 9 | f.close() -------------------------------------------------------------------------------- /external/RT_MDNet/modules/roi_align/__init__.py: -------------------------------------------------------------------------------- 1 | from .functions.roi_align import roi_align, roi_align_ada 2 | from .modules.roi_align import RoIAlign, RoIAlignAda, RoIAlignAvg, RoIAlignMax, RoIAlignAdaMax 3 | 4 | __all__ = ['roi_align', 'RoIAlign', 'roi_align_ada', 'RoIAlignAda', 'RoIAlignAvg', 'RoIAlignMax', 'RoIAlignAdaMax'] 5 | -------------------------------------------------------------------------------- /arena/VOT2020/vot/stack/votrgbd2019.yaml: -------------------------------------------------------------------------------- 1 | title: VOT-RGBD2019 challenge 2 | dataset: vot:vot-rgbd2019 3 | url: http://www.votchallenge.net/vot2019/ 4 | experiments: 5 | rgbd-unsupervised: 6 | type: vot.experiment.UnsupervisedExperiment 7 | repetitions: 1 8 | measures: 9 | - type: vot.analysis.measures.PrecisionRecall -------------------------------------------------------------------------------- /arena/VOT2020/vot/stack/votrgbd2020.yaml: -------------------------------------------------------------------------------- 1 | title: VOT-RGBD2020 challenge 2 | dataset: vot:vot-rgbd2019 3 | url: http://www.votchallenge.net/vot2020/ 4 | experiments: 5 | rgbd-unsupervised: 6 | type: vot.experiment.UnsupervisedExperiment 7 | repetitions: 1 8 | measures: 9 | - type: vot.analysis.measures.PrecisionRecall -------------------------------------------------------------------------------- /arena/VOT2020/vot/requirements.txt: -------------------------------------------------------------------------------- 1 | vot-trax>=3.0.2 2 | tqdm>=4.37 3 | numpy>=1.16 4 | opencv-python>=4.0 5 | six 6 | pylatex>=1.3 7 | jsonschema>=3.2 8 | pyYAML>=5.3 9 | matplotlib>=3.0 10 | Pillow>=7.0 11 | numba>=0.47 12 | requests>=2.22 13 | colorama>=0.4.3 14 | packaging>=20 15 | dominate>=2.5 16 | cachetools>=4.1 17 | bidict>=0.19 -------------------------------------------------------------------------------- /arena/VOT2020/vot/stack/votrgbtir2020.yaml: -------------------------------------------------------------------------------- 1 | title: VOT-RGBTIR2020 challenge 2 | dataset: vot:vot-rgbt2020 3 | url: http://www.votchallenge.net/vot2020/ 4 | experiments: 5 | baseline: 6 | type: vot.experiment.MultiStartExperiment 7 | measures: 8 | - type: vot.analysis.measures.AccuracyRobustnessMultiStart 9 | - type: EAOMultiStart -------------------------------------------------------------------------------- /ltr/models/backbone/__init__.py: -------------------------------------------------------------------------------- 1 | from .resnet import resnet18, resnet50, resnet34, resnet_baby 2 | from .resnet18_vggm import resnet18_vggmconv1 3 | from .resnet import * 4 | from .resnet18_vggm import * 5 | from .mobilenetv2 import mobilenet_v2 6 | from .alexnet import alexnet 7 | from .googlenet import googlenet 8 | from .efficientnet import efficientnet -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /pytracking/RF_utils.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | def bbox_clip(x1, y1, x2, y2, boundary, min_sz=10): 4 | '''boundary (H,W)''' 5 | x1_new = max(0, min(x1, boundary[1] - min_sz)) 6 | y1_new = max(0, min(y1, boundary[0] - min_sz)) 7 | x2_new = max(min_sz, min(x2, boundary[1])) 8 | y2_new = max(min_sz, min(y2, boundary[0])) 9 | return x1_new, y1_new, x2_new, y2_new -------------------------------------------------------------------------------- /arena/VOT2020/vot/analysis/document.py: -------------------------------------------------------------------------------- 1 | 2 | from typing import List 3 | 4 | from pylatex import Document, Section, Subsection, Command 5 | from pylatex.utils import italic, NoEscape 6 | 7 | from vot.workspace import Workspace 8 | from vot.tracker import Tracker 9 | 10 | 11 | def generate_latex_document(wokrspace: Workspace, trackers: List[Tracker]): 12 | pass 13 | -------------------------------------------------------------------------------- /arena/VOT2020/vot/stack/vot2015.yaml: -------------------------------------------------------------------------------- 1 | title: VOT2015 challenge 2 | dataset: vot:vot2015 3 | url: http://www.votchallenge.net/vot2015/ 4 | experiments: 5 | baseline: 6 | type: vot.experiment.SupervisedExperiment 7 | repetitions: 15 8 | skip_initialize: 5 9 | measures: 10 | - type: vot.analysis.measures.AccuracyRobustness 11 | sensitivity: 30 -------------------------------------------------------------------------------- /ltr/dataset/ardataset/__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_seq import MSCOCOSeq 6 | from .imagenetdet import ImagenetDET 7 | from .youtube_vos import Youtube_VOS 8 | from .saliency import Saliency 9 | from .coco_seq_17 import MSCOCOSeq17 10 | -------------------------------------------------------------------------------- /arena/VOT2020/vot/stack/vottir2016.yaml: -------------------------------------------------------------------------------- 1 | title: VOT-TIR2016 challenge 2 | dataset: vot:vot-tir2016 3 | url: http://www.votchallenge.net/vot2016/ 4 | experiments: 5 | baseline: 6 | type: vot.experiment.SupervisedExperiment 7 | repetitions: 15 8 | skip_initialize: 5 9 | measures: 10 | - type: vot.analysis.measures.AccuracyRobustness 11 | sensitivity: 30 12 | -------------------------------------------------------------------------------- /arena/VOT2020/vot/stack/vottir2015.yaml: -------------------------------------------------------------------------------- 1 | title: VOT-TIR2015 challenge 2 | dataset: vot:vot-tir2015 3 | url: http://www.votchallenge.net/vot2015/ 4 | experiments: 5 | baseline: 6 | type: vot.experiment.multirun.SupervisedExperiment 7 | repetitions: 15 8 | skip_initialize: 5 9 | measures: 10 | - type: vot.analysis.measures.AccuracyRobustness 11 | sensitivity: 30 12 | -------------------------------------------------------------------------------- /pytracking/__init__.py: -------------------------------------------------------------------------------- 1 | from pytracking.libs import TensorList, TensorDict 2 | import pytracking.libs.complex as complex 3 | import pytracking.libs.operation as operation 4 | import pytracking.libs.fourier as fourier 5 | import pytracking.libs.dcf as dcf 6 | import pytracking.libs.optimization as optimization 7 | from pytracking.run_tracker import run_tracker 8 | from pytracking.run_webcam import run_webcam 9 | -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/got10k/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from .got10k import GOT10k 4 | from .otb import OTB 5 | from .vot import VOT 6 | from .dtb70 import DTB70 7 | from .tcolor128 import TColor128 8 | from .uav123 import UAV123 9 | from .nfs import NfS 10 | from .lasot import LaSOT 11 | from .trackingnet import TrackingNet 12 | from .vid import ImageNetVID 13 | -------------------------------------------------------------------------------- /external/RT_MDNet/modules/roi_align/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | from torch.utils.cpp_extension import BuildExtension, CUDAExtension 3 | 4 | setup( 5 | name='roi_align_cuda', 6 | ext_modules=[ 7 | CUDAExtension('roi_align_cuda', [ 8 | 'src/roi_align_cuda.cpp', 9 | 'src/roi_align_kernel_c.cu', 10 | ]), 11 | ], 12 | cmdclass={'build_ext': BuildExtension}) 13 | -------------------------------------------------------------------------------- /arena/VOT2020/vot/__main__.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) 4 | os.environ['CUDA_VISIBLE_DEVICES'] = '1' 5 | 6 | from vot.cli import main 7 | 8 | if __name__ == '__main__': 9 | main() 10 | 11 | # evaluate --workspace /home/zxy/Desktop/AlphaRefine/analysis/VOT2020 AlphaRef 12 | # analysis --workspace /home/zxy/Desktop/AlphaRefine/analysis/VOT2020 AlphaRef --output json 13 | -------------------------------------------------------------------------------- /arena/VOT2020/vot/stack/vot2013.yaml: -------------------------------------------------------------------------------- 1 | title: VOT2013 challenge 2 | url: http://www.votchallenge.net/vot2013/ 3 | dataset: vot:vot2013 4 | deprecated: True 5 | experiments: 6 | baseline: 7 | type: vot.experiment.multirun.SupervisedExperiment 8 | repetitions: 15 9 | skip_initialize: 5 10 | measures: 11 | - type: vot.analysis.measures.AccuracyRobustness 12 | sensitivity: 30 13 | 14 | # TODO: missing experiments 15 | 16 | -------------------------------------------------------------------------------- /ltr/external/PreciseRoIPooling/pytorch/prroi_pool/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao, Tete Xiao 5 | # Email : maojiayuan@gmail.com, jasonhsiao97@gmail.com 6 | # Date : 07/13/2018 7 | # 8 | # This file is part of PreciseRoIPooling. 9 | # Distributed under terms of the MIT license. 10 | # Copyright (c) 2017 Megvii Technology Limited. 11 | 12 | from .prroi_pool import * 13 | 14 | -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/got10k/experiments/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from .got10k import ExperimentGOT10k 4 | from .otb import ExperimentOTB 5 | from .vot import ExperimentVOT 6 | from .dtb70 import ExperimentDTB70 7 | from .uav123 import ExperimentUAV123 8 | from .nfs import ExperimentNfS 9 | from .tcolor128 import ExperimentTColor128 10 | 11 | from .lasot import ExperimentLaSOT 12 | from .trackingnet import ExperimentTrackingNet 13 | -------------------------------------------------------------------------------- /pytracking/VOT/trackers.ini: -------------------------------------------------------------------------------- 1 | [DiMP] # 2 | label = DiMP 3 | protocol = traxpython 4 | 5 | command = import pytracking.run_vot as 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 | -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/got10k/trackers/identity_tracker.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from . import Tracker 4 | 5 | 6 | class IdentityTracker(Tracker): 7 | 8 | def __init__(self): 9 | super(IdentityTracker, self).__init__( 10 | name='IdentityTracker', 11 | is_deterministic=True) 12 | 13 | def init(self, image, box): 14 | self.box = box 15 | 16 | def update(self, image): 17 | return self.box 18 | -------------------------------------------------------------------------------- /external/pysot/pysot/models/init_weight.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | 3 | 4 | def init_weights(model): 5 | for m in model.modules(): 6 | if isinstance(m, nn.Conv2d): 7 | nn.init.kaiming_normal_(m.weight.data, 8 | mode='fan_out', 9 | nonlinearity='relu') 10 | elif isinstance(m, nn.BatchNorm2d): 11 | m.weight.data.fill_(1) 12 | m.bias.data.zero_() 13 | -------------------------------------------------------------------------------- /arena/VOT2020/vot/stack/vot2014.yaml: -------------------------------------------------------------------------------- 1 | title: VOT2014 challenge 2 | dataset: vot:vot2014 3 | url: http://www.votchallenge.net/vot2014/ 4 | deprecated: True 5 | experiments: 6 | baseline: 7 | type: vot.experiment.multirun.SupervisedExperiment 8 | repetitions: 15 9 | skip_initialize: 5 10 | measures: 11 | - type: vot.analysis.measures.AccuracyRobustness 12 | sensitivity: 30 13 | - type: vot.analysis.measures.FailureCount 14 | # TODO: region noise -------------------------------------------------------------------------------- /arena/ar_legacy/VOT2018/common_path_siamrpn.py: -------------------------------------------------------------------------------- 1 | from .common_path import * 2 | '''Things that we can change''' 3 | ################################################### 4 | siam_model_ = 'siamrpn_r50_l234_dwxcorr' 5 | # siam_model_ = 'siamrpn_r50_l234_dwxcorr_otb' 6 | # siam_model_ = 'siammask_r50_l3' 7 | ######################################################################################### 8 | import os 9 | project_path_ = os.path.join(os.path.dirname(__file__), '../../pysot') 10 | -------------------------------------------------------------------------------- /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, nn.parallel.DistributedDataParallel)) 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) 16 | -------------------------------------------------------------------------------- /external/pysot/common_path.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | project_path_ = '/home/zxy/Desktop/AlphaRefine/pysot' 4 | dataset_root_ = '/media/zxy/Samsung_T5/Data/DataSets/LaSOT/LaSOT_Test' 5 | 6 | save_dir = '/home/zxy/Desktop/AlphaRefine/analysis' 7 | '''Refinement Module''' 8 | project_path = '/home/zxy/Desktop/AlphaRefine/AlphaRefine_CVPR21' 9 | refine_root = os.path.join(project_path, 'ltr/checkpoints/ltr/SEbcm/') 10 | selector_root = os.path.join(project_path, 'ltr/checkpoints/ltr/selector') 11 | 12 | -------------------------------------------------------------------------------- /arena/VOT2020/vot/stack/votlt2019.yaml: -------------------------------------------------------------------------------- 1 | title: VOT-LT2019 challenge 2 | dataset: vot:vot-lt2019 3 | url: http://www.votchallenge.net/vot2019/ 4 | experiments: 5 | longterm: 6 | type: vot.experiment.UnsupervisedExperiment 7 | repetitions: 1 8 | measures: 9 | - type: vot.analysis.measures.PrecisionRecall 10 | redetection: 11 | type: UnsupervisedExperiment 12 | transformers: 13 | - type: Redetection 14 | length: 200 15 | initialization: 5 16 | padding: 2 17 | scaling: 3 18 | -------------------------------------------------------------------------------- /arena/VOT2020/vot/stack/votlt2020.yaml: -------------------------------------------------------------------------------- 1 | title: VOT-LT2020 challenge 2 | dataset: vot:vot-lt2019 3 | url: http://www.votchallenge.net/vot2020/ 4 | experiments: 5 | longterm: 6 | type: vot.experiment.UnsupervisedExperiment 7 | repetitions: 1 8 | measures: 9 | - type: vot.analysis.measures.PrecisionRecall 10 | redetection: 11 | type: UnsupervisedExperiment 12 | transformers: 13 | - type: Redetection 14 | length: 200 15 | initialization: 5 16 | padding: 2 17 | scaling: 3 18 | -------------------------------------------------------------------------------- /arena/VOT2020/vot/stack/vot2016.yaml: -------------------------------------------------------------------------------- 1 | title: VOT2016 challenge 2 | dataset: vot:vot2016 3 | url: http://www.votchallenge.net/vot2016/ 4 | experiments: 5 | baseline: 6 | type: vot.experiment.SupervisedExperiment 7 | repetitions: 15 8 | skip_initialize: 5 9 | measures: 10 | - type: vot.analysis.measures.AccuracyRobustness 11 | sensitivity: 30 12 | unsupervised: 13 | type: vot.experiment.UnsupervisedExperiment 14 | repetitions: 1 15 | measures: 16 | - type: vot.analysis.measures.AverageAccuracy 17 | -------------------------------------------------------------------------------- /external/pysot/pysot/models/neck/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) SenseTime. All Rights Reserved. 2 | 3 | from __future__ import absolute_import 4 | from __future__ import division 5 | from __future__ import print_function 6 | from __future__ import unicode_literals 7 | 8 | from external.pysot.pysot.models.neck.neck import AdjustLayer, AdjustAllLayer 9 | 10 | NECKS = { 11 | 'AdjustLayer': AdjustLayer, 12 | 'AdjustAllLayer': AdjustAllLayer 13 | } 14 | 15 | def get_neck(name, **kwargs): 16 | return NECKS[name](**kwargs) 17 | -------------------------------------------------------------------------------- /ltr/models/lwl/utils.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn.functional as F 3 | 4 | 5 | def adaptive_cat(seq, dim=0, ref_tensor=0, mode='bilinear'): 6 | sz = seq[ref_tensor].shape[-2:] 7 | t = torch.cat([interpolate(t, sz, mode=mode) for t in seq], dim=dim) 8 | return t 9 | 10 | 11 | def interpolate(t, sz, mode='bilinear'): 12 | sz = sz.tolist() if torch.is_tensor(sz) else sz 13 | align = {} if mode == 'nearest' else dict(align_corners=False) 14 | return F.interpolate(t, sz, mode=mode, **align) if t.shape[-2:] != sz else t 15 | 16 | -------------------------------------------------------------------------------- /external/pysot/setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup 2 | from distutils.extension import Extension 3 | from Cython.Build import cythonize 4 | 5 | ext_modules = [ 6 | Extension( 7 | name='toolkit.utils.region', 8 | sources=[ 9 | 'toolkit/utils/region.pyx', 10 | 'toolkit/utils/src/region.c', 11 | ], 12 | include_dirs=[ 13 | 'toolkit/utils/src' 14 | ] 15 | ) 16 | ] 17 | 18 | setup( 19 | name='toolkit', 20 | packages=['toolkit'], 21 | ext_modules=cythonize(ext_modules) 22 | ) 23 | -------------------------------------------------------------------------------- /external/RT_MDNet/MDNet_utils.py: -------------------------------------------------------------------------------- 1 | 2 | import numpy as np 3 | def bbox_clip(bbox, boundary, min_sz=10.0): 4 | x1, y1, width, height = bbox 5 | x2 = x1 + width 6 | y2 = y1 + height 7 | x1_new = max(0.0, min(x1, boundary[1] - min_sz)) 8 | y1_new = max(0.0, min(y1, boundary[0] - min_sz)) 9 | x2_new = max(min_sz, min(x2, boundary[1])) 10 | y2_new = max(min_sz, min(y2, boundary[0])) 11 | w_new = x2_new - x1_new 12 | h_new = y2_new - y1_new 13 | '''get new bbox''' 14 | bbox_new = np.array([x1_new, y1_new, w_new, h_new]) 15 | return bbox_new -------------------------------------------------------------------------------- /arena/VOT2020/vot/stack/vot2017.yaml: -------------------------------------------------------------------------------- 1 | title: VOT2017 challenge 2 | dataset: vot:vot2017 3 | url: http://www.votchallenge.net/vot2017/ 4 | experiments: 5 | baseline: 6 | type: vot.experiment.SupervisedExperiment 7 | repetitions: 15 8 | skip_initialize: 5 9 | measures: 10 | - type: vot.analysis.measures.AccuracyRobustness 11 | sensitivity: 30 12 | unsupervised: 13 | type: vot.experiment.UnsupervisedExperiment 14 | repetitions: 1 15 | measures: 16 | - type: vot.analysis.measures.AverageAccuracy 17 | realtime: 18 | type: vot.experiment.RealtimeSupervisedExperiment 19 | grace: 3 20 | -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | 4 | setup(name='got10k', 5 | version='0.1.3', 6 | description='GOT-10k benchmark official API', 7 | author='Lianghua Huang', 8 | author_email='lianghua.huang.cs@gmail.com', 9 | url='https://github.com/got-10k/toolkit', 10 | license='MIT', 11 | install_requires=[ 12 | 'numpy', 'matplotlib', 'Pillow', 'Shapely', 'fire', 'wget'], 13 | packages=find_packages(), 14 | include_package_data=True, 15 | keywords=[ 16 | 'GOT-10k', 17 | 'Generic Object Tracking', 18 | 'Benchmark',]) 19 | -------------------------------------------------------------------------------- /external/pysot/toolkit/visualization/draw_utils.py: -------------------------------------------------------------------------------- 1 | 2 | COLOR = ((1, 0, 0), 3 | (0, 1, 0), 4 | (0, 0, 1), 5 | (1, 1, 0), 6 | (0 , 162/255, 232/255), 7 | (0.5, 0.5, 0.5), 8 | (1, 0, 1), 9 | (0, 1, 1), 10 | (136/255, 0 , 21/255), 11 | (255/255, 127/255, 39/255), 12 | (173/255,28/255,138/255), 13 | (48/255,94/255,184/255), 14 | (213/255,92/255,187/255), 15 | (0, 0, 0)) 16 | 17 | LINE_STYLE = ['-', '-', '-', ':', '--', ':', '--', '--', ':', ':','--',':','--',':'] 18 | 19 | MARKER_STYLE = ['o', 'v', '<', '*', 'D', 'x', '.', 'x', '<', '.','o', 'v', '<', '*'] 20 | -------------------------------------------------------------------------------- /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 | 17 | from .imagenetdet import ImagenetDET 18 | from .youtube_vos import Youtube_VOS 19 | from .saliency import Saliency 20 | -------------------------------------------------------------------------------- /arena/VOT2020/vot/stack/testing.yaml: -------------------------------------------------------------------------------- 1 | title: VOT testing 2 | url: http://www.votchallenge.net/ 3 | dataset: vot:segmentation 4 | experiments: 5 | baseline: 6 | type: MultiStartExperiment 7 | measures: 8 | - type: AccuracyRobustnessMultiStart 9 | - type: EAOMultiStart 10 | realtime: 11 | type: MultiStartExperiment 12 | realtime: 13 | grace: 3 14 | measures: 15 | - type: AccuracyRobustnessMultiStart 16 | - type: EAOMultiStart 17 | redetection: 18 | type: UnsupervisedExperiment 19 | transformers: 20 | - type: Redetection 21 | length: 200 22 | initialization: 5 23 | padding: 2 24 | scaling: 3 -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /arena/VOT2020/common_path.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | save_root = os.path.join('/home/alphabin/Desktop/AlphaRefine_submit/vot20_debug') 4 | 5 | # ========================= Refine Module ========================= 6 | model_dir = '/home/zxy/Desktop/AlphaRefine/pytracking/ltr/checkpoints/ltr/' 7 | model_code = 'a' 8 | refine_path = os.path.join(model_dir, "SEx_beta/SEcm_r34/SEcmnet_ep0040-{}.pth.tar".format(model_code)) 9 | RF_type = 'AR_CrsM_R34SR20_pixCorr_woPr_woNL_corner_{}'.format(model_code) 10 | sr = 2.0; input_sz = int(128 * sr) # 2.0 by default 11 | 12 | # ========================= Base Tracker========================= 13 | _tracker_name = 'atom' 14 | _tracker_param = 'default' 15 | _mask_thres = 0.65 -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /arena/VOT2020/vot/stack/vot2018.yaml: -------------------------------------------------------------------------------- 1 | title: VOT-ST2018 challenge 2 | dataset: vot:vot-st2018 3 | url: http://www.votchallenge.net/vot2018/ 4 | experiments: 5 | baseline: 6 | type: SupervisedExperiment 7 | repetitions: 15 8 | skip_initialize: 5 9 | measures: 10 | - type: AccuracyRobustness 11 | sensitivity: 30 12 | - type: EAO 13 | unsupervised: 14 | type: UnsupervisedExperiment 15 | repetitions: 1 16 | measures: 17 | - type: AverageAccuracy 18 | realtime: 19 | type: SupervisedExperiment 20 | realtime: 21 | grace: 3 22 | repetitions: 1 23 | skip_initialize: 5 24 | measures: 25 | - type: AccuracyRobustness 26 | sensitivity: 30 27 | - type: EAO -------------------------------------------------------------------------------- /arena/VOT2020/vot/stack/vot2019.yaml: -------------------------------------------------------------------------------- 1 | title: VOT-ST2019 challenge 2 | dataset: vot:vot-st2019 3 | url: http://www.votchallenge.net/vot2019/ 4 | experiments: 5 | baseline: 6 | type: SupervisedExperiment 7 | repetitions: 15 8 | skip_initialize: 5 9 | measures: 10 | - type: AccuracyRobustness 11 | sensitivity: 30 12 | - type: EAO 13 | unsupervised: 14 | type: UnsupervisedExperiment 15 | repetitions: 1 16 | measures: 17 | - type: AverageAccuracy 18 | realtime: 19 | type: SupervisedExperiment 20 | realtime: 21 | grace: 3 22 | repetitions: 1 23 | skip_initialize: 5 24 | measures: 25 | - type: AccuracyRobustness 26 | sensitivity: 30 27 | - type: EAO -------------------------------------------------------------------------------- /arena/GOT10k/common_path.py: -------------------------------------------------------------------------------- 1 | import os 2 | ###################################################################### 3 | _dataset_name = 'GOT-10k' 4 | _video_name = '' # 'airplane-9' 5 | 6 | ###################################################################### 7 | _dataset_root = '/home/zxy/Downloads/Datasets' 8 | save_dir = '/home/zxy/Desktop/AlphaRefine/analysis' 9 | 10 | ######################### Refine Module ################################ 11 | model_dir = '/home/zxy/Desktop/AlphaRefine/pytracking/ltr/checkpoints/ltr/' 12 | refine_path = os.path.join(model_dir, "SEx_beta/SEcm_r34/SEcmnet_ep0040-{}.pth.tar") 13 | RF_type = 'AR_CrsM_R34SR20_pixCorr_woPr_woNL_corner_{}' 14 | selector_path = 0 15 | sr = 2.0; input_sz = int(128 * sr) # 2.0 by default 16 | -------------------------------------------------------------------------------- /arena/VOT2020/vot/stack/vot2020.yaml: -------------------------------------------------------------------------------- 1 | title: VOT-ST2020 challenge 2 | dataset: vot:vot-st2020 3 | url: http://www.votchallenge.net/vot2020/ 4 | experiments: 5 | baseline: 6 | type: vot.experiment.MultiStartExperiment 7 | measures: 8 | - type: vot.analysis.measures.AccuracyRobustnessMultiStart 9 | - type: EAOMultiStart 10 | unsupervised: 11 | type: vot.experiment.UnsupervisedExperiment 12 | repetitions: 1 13 | measures: 14 | - type: vot.analysis.measures.AverageAccuracy 15 | burnin: 1 16 | realtime: 17 | type: vot.experiment.MultiStartExperiment 18 | realtime: 19 | grace: 3 20 | measures: 21 | - type: vot.analysis.measures.AccuracyRobustnessMultiStart 22 | - type: EAOMultiStart -------------------------------------------------------------------------------- /ltr/models/backbone/efficientnet/test_efb0.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import tqdm 3 | from ltr.models.backbone.efficientnet.model4ar import efficientnet 4 | from ltr.models.backbone.resnet import resnet50, resnet34 5 | 6 | # torch.backends.cudnn.benchmark = True 7 | 8 | net = efficientnet('efficientnet-b0').cuda() 9 | # net = resnet50(['conv1', 'layer1', 'layer2', 'layer3']).cuda() 10 | # net = resnet34(['conv1', 'layer1', 'layer2', 'layer3']).cuda() 11 | batch_size = 1 12 | with torch.no_grad(): 13 | for i in tqdm.tqdm(range(5000)): 14 | fake_data = torch.rand(batch_size, 3, 224, 224).cuda() 15 | out = net(fake_data) 16 | if isinstance(out, dict): 17 | out = [o for k, o in out.items()] 18 | # print(out[-1].shape) 19 | -------------------------------------------------------------------------------- /arena/GOT10k/common_path_siamrpn.py: -------------------------------------------------------------------------------- 1 | from .common_path import * 2 | '''Things that we can change''' 3 | ################################################### 4 | siam_model_ = 'siamrpn_r50_l234_dwxcorr' 5 | # siam_model_ = 'siamrpn_r50_l234_dwxcorr_otb' 6 | # siam_model_ = 'siammask_r50_l3' 7 | ################################################### 8 | # dataset_name_ = 'GOT10K' 9 | # dataset_name_ = 'VOT2018' 10 | # dataset_name_ = 'VOT2018-LT' 11 | dataset_name_ = 'LaSOT' 12 | ################################################### 13 | video_name_ = '' 14 | # video_name_ = 'airplane-9' 15 | ######################################################################################### 16 | import os 17 | project_path_ = os.path.join(os.path.dirname(__file__), '../../pysot') 18 | -------------------------------------------------------------------------------- /arena/TrackingNet/common_path_siamrpn.py: -------------------------------------------------------------------------------- 1 | from .common_path import * 2 | '''Things that we can change''' 3 | ################################################### 4 | siam_model_ = 'siamrpn_r50_l234_dwxcorr' 5 | # siam_model_ = 'siamrpn_r50_l234_dwxcorr_otb' 6 | # siam_model_ = 'siammask_r50_l3' 7 | ################################################### 8 | # dataset_name_ = 'GOT10K' 9 | # dataset_name_ = 'VOT2018' 10 | # dataset_name_ = 'VOT2018-LT' 11 | dataset_name_ = 'LaSOT' 12 | ################################################### 13 | video_name_ = '' 14 | # video_name_ = 'airplane-9' 15 | ######################################################################################### 16 | import os 17 | project_path_ = os.path.join(os.path.dirname(__file__), '../../external/pysot') -------------------------------------------------------------------------------- /arena/ar_legacy/VOT2018/common_path.py: -------------------------------------------------------------------------------- 1 | import os 2 | ###################################################################### 3 | dataset_name_ = 'VOT2018' 4 | video_name_ = '' # 'airplane-9' 5 | 6 | ###################################################################### 7 | dataset_root_ = '/home/zxy/Downloads/Datasets/VOT2018' 8 | save_dir = '/home/zxy/Desktop/AlphaRefine/analysis' 9 | 10 | ######################### Refine Module ################################ 11 | model_dir = '/home/zxy/Desktop/AlphaRefine/pytracking/ltr/checkpoints/ltr/' 12 | refine_path = os.path.join(model_dir, "SEx_beta/SEcm_r34/SEcmnet_ep0040-{}.pth.tar") 13 | RF_type = 'AR_CrsM_R34SR20_pixCorr_woPr_woNL_corner_{}' 14 | selector_path = 0 15 | sr = 2.0; input_sz = int(128 * sr) # 2.0 by default 16 | -------------------------------------------------------------------------------- /ltr/models/lwl/initializer.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | 3 | 4 | class FilterInitializerZero(nn.Module): 5 | """Initializes a target model with zeros. 6 | args: 7 | filter_size: Size of the filter. 8 | feature_dim: Input feature dimentionality.""" 9 | 10 | def __init__(self, filter_size=1, num_filters=1, feature_dim=256, filter_groups=1): 11 | super().__init__() 12 | 13 | self.filter_size = (num_filters, feature_dim//filter_groups, filter_size, filter_size) 14 | 15 | def forward(self, feat, mask=None): 16 | assert feat.dim() == 5 17 | # num_sequences = feat.shape[1] if feat.dim() == 5 else 1 18 | num_sequences = feat.shape[1] 19 | 20 | return feat.new_zeros(num_sequences, *self.filter_size) 21 | -------------------------------------------------------------------------------- /arena/LaSOT/common_path_siamrpn.py: -------------------------------------------------------------------------------- 1 | from .common_path import * 2 | '''Things that we can change''' 3 | ################################################### 4 | siam_model_ = 'siamrpn_r50_l234_dwxcorr' 5 | # siam_model_ = 'siamrpn_r50_l234_dwxcorr_otb' 6 | # siam_model_ = 'siammask_r50_l3' 7 | ################################################### 8 | # dataset_name_ = 'GOT10K' 9 | # dataset_name_ = 'VOT2018' 10 | # dataset_name_ = 'VOT2018-LT' 11 | dataset_name_ = 'LaSOT' 12 | ################################################### 13 | video_name_ = '' 14 | # video_name_ = 'airplane-9' 15 | ######################################################################################### 16 | import os 17 | project_path_ = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../external/pysot')) 18 | -------------------------------------------------------------------------------- /external/pysot/INSTALL.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | This document contains detailed instructions for installing dependencies for PySOT. We recommand using the [install.sh](install.sh). The code is tested on an Ubuntu 16.04 system with Nvidia GPU (We recommand 1080TI / TITAN XP). 4 | 5 | ### Requirments 6 | * Conda with Python 3.7. 7 | * Nvidia GPU. 8 | * PyTorch 0.4.1 9 | * yacs 10 | * pyyaml 11 | * matplotlib 12 | * tqdm 13 | * OpenCV 14 | 15 | ## Step-by-step instructions 16 | 17 | #### activate the environment of AlphaRefine 18 | ```bash 19 | conda activate alpha 20 | ``` 21 | 22 | #### Install other requirements 23 | ``` 24 | pip install pyyaml yacs tqdm colorama matplotlib cython tensorboardX 25 | ``` 26 | 27 | #### Build extensions 28 | ``` 29 | python setup.py build_ext --inplace 30 | ``` 31 | -------------------------------------------------------------------------------- /external/pysot/pysot/tracker/tracker_builder_new.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) SenseTime. All Rights Reserved. 2 | 3 | from __future__ import absolute_import 4 | from __future__ import division 5 | from __future__ import print_function 6 | from __future__ import unicode_literals 7 | 8 | from external.pysot.pysot.core import cfg_new as cfg 9 | from external.pysot.pysot.tracker.siamrpn_tracker import SiamRPNTracker 10 | from external.pysot.pysot.tracker.siammask_tracker import SiamMaskTracker 11 | from external.pysot.pysot import SiamRPNLTTracker 12 | 13 | TRACKS = { 14 | 'SiamRPNTracker': SiamRPNTracker, 15 | 'SiamMaskTracker': SiamMaskTracker, 16 | 'SiamRPNLTTracker': SiamRPNLTTracker 17 | } 18 | 19 | 20 | def build_tracker(model): 21 | return TRACKS[cfg.TRACK.TYPE](model) 22 | -------------------------------------------------------------------------------- /external/pysot/pysot/tracker/tracker_builder.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) SenseTime. All Rights Reserved. 2 | 3 | from __future__ import absolute_import 4 | from __future__ import division 5 | from __future__ import print_function 6 | from __future__ import unicode_literals 7 | 8 | from external.pysot.pysot.core.config import cfg 9 | from external.pysot.pysot.tracker.siamrpn_tracker import SiamRPNTracker 10 | from external.pysot.pysot.tracker.siammask_tracker import SiamMaskTracker 11 | from external.pysot.pysot.tracker.siamrpnlt_tracker import SiamRPNLTTracker 12 | 13 | TRACKS = { 14 | 'SiamRPNTracker': SiamRPNTracker, 15 | 'SiamMaskTracker': SiamMaskTracker, 16 | 'SiamRPNLTTracker': SiamRPNLTTracker 17 | } 18 | 19 | 20 | def build_tracker(model): 21 | return TRACKS[cfg.TRACK.TYPE](model) 22 | -------------------------------------------------------------------------------- /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/pysot/common_path_siamrpn.py: -------------------------------------------------------------------------------- 1 | from common_path import * 2 | '''Things that we can change''' 3 | ################################################### 4 | siam_model_ = 'siamrpn_r50_l234_dwxcorr' 5 | # siam_model_ = 'siamrpn_r50_l234_dwxcorr_otb' 6 | # siam_model_ = 'siammask_r50_l3' 7 | ################################################### 8 | # dataset_name_ = 'OTB100' 9 | # dataset_name_ = 'GOT10K' 10 | # dataset_name_ = 'VOT2018' 11 | # dataset_name_ = 'VOT2018-LT' 12 | dataset_name_ = 'LaSOT' 13 | ################################################### 14 | video_name_ = '' 15 | # video_name_ = 'airplane-9' 16 | # video_name_ = 'rabbit-19' 17 | # video_name_ = 'cattle-12' 18 | # video_name_ = 'guitar-10' 19 | # video_name_ = 'airplane-1' 20 | # video_name_ = 'drone-2' 21 | # video_name_ = 'monkey-3' 22 | ######################################################################################### 23 | -------------------------------------------------------------------------------- /external/pysot/pysot/models/backbone/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) SenseTime. All Rights Reserved. 2 | 3 | from __future__ import absolute_import 4 | from __future__ import division 5 | from __future__ import print_function 6 | from __future__ import unicode_literals 7 | 8 | from external.pysot.pysot.models.backbone.alexnet import alexnetlegacy, alexnet 9 | from external.pysot.pysot.models.backbone.mobile_v2 import mobilenetv2 10 | from external.pysot.pysot.models.backbone.resnet_atrous import resnet18, resnet34, resnet50 11 | 12 | BACKBONES = { 13 | 'alexnetlegacy': alexnetlegacy, 14 | 'mobilenetv2': mobilenetv2, 15 | 'resnet18': resnet18, 16 | 'resnet34': resnet34, 17 | 'resnet50': resnet50, 18 | 'alexnet': alexnet, 19 | } 20 | 21 | 22 | def get_backbone(name, **kwargs): 23 | return BACKBONES[name](**kwargs) 24 | -------------------------------------------------------------------------------- /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/pysot/pysot/models/head/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) SenseTime. All Rights Reserved. 2 | 3 | from __future__ import absolute_import 4 | from __future__ import division 5 | from __future__ import print_function 6 | from __future__ import unicode_literals 7 | 8 | from external.pysot.pysot.models.head.mask import MaskCorr, Refine 9 | from external.pysot.pysot.models.head.rpn import UPChannelRPN, DepthwiseRPN, MultiRPN 10 | 11 | RPNS = { 12 | 'UPChannelRPN': UPChannelRPN, 13 | 'DepthwiseRPN': DepthwiseRPN, 14 | 'MultiRPN': MultiRPN 15 | } 16 | 17 | MASKS = { 18 | 'MaskCorr': MaskCorr, 19 | } 20 | 21 | REFINE = { 22 | 'Refine': Refine, 23 | } 24 | 25 | 26 | def get_rpn_head(name, **kwargs): 27 | return RPNS[name](**kwargs) 28 | 29 | 30 | def get_mask_head(name, **kwargs): 31 | return MASKS[name](**kwargs) 32 | 33 | 34 | def get_refine_head(name): 35 | return REFINE[name]() 36 | -------------------------------------------------------------------------------- /external/pysot/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -lt 2 ]; then 4 | echo "ARGS ERROR!" 5 | echo " bash install.sh /path/to/your/conda env_name" 6 | exit 1 7 | fi 8 | 9 | set -e 10 | 11 | conda_path=$1 12 | env_name=$2 13 | 14 | source $conda_path/etc/profile.d/conda.sh 15 | 16 | echo "****** create environment " $env_name "*****" 17 | # create environment 18 | conda create -y --name $env_name python=3.7 19 | conda activate $env_name 20 | 21 | echo "***** install numpy pytorch opencv *****" 22 | # numpy 23 | conda install -y numpy 24 | # pytorch 25 | # pytorch with cuda80/cuda90 is tested 26 | conda install -y pytorch=0.4.1 torchvision cuda90 -c pytorch 27 | # opencv 28 | pip install opencv-python 29 | # tensorboardX 30 | 31 | echo "***** install other libs *****" 32 | pip install tensorboardX 33 | # libs 34 | pip install pyyaml yacs tqdm colorama matplotlib cython 35 | 36 | 37 | echo "***** build extensions *****" 38 | python setup.py build_ext --inplace 39 | -------------------------------------------------------------------------------- /arena/TrackingNet/common_path.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | ###################################################################### 4 | dataset_name_ = 'LaSOT' 5 | video_name_ = '' # 'airplane-9' 6 | 7 | ###################################################################### 8 | dataset_root_ = '/home/zxy/Downloads/AR_Data/TrackingNet/TEST' 9 | save_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../analysis')) 10 | 11 | ######################### Refine Module ################################ 12 | # model_code = 'd' 13 | # refine_path = "/home/zxy/Desktop/AlphaRefine/pytracking/ltr/checkpoints/ltr/SEx_beta/SEcm_r34/SEcmnet_ep0040-{}.pth.tar".format(model_code) 14 | # RF_type = 'RF_CrsM_woPr_R34SR20_{}'.format(model_code) 15 | 16 | refine_path = '/home/zxy/Desktop/AR_Maintaince/AlphaRefine/ltr/checkpoints/ltr/SEx_beta/SEcmnet_ep0040-c.pth.tar' 17 | RF_type = 'AR_CrsM_R34SR20_pixCorr_woPr_woNL_corner' 18 | selector_path = 0 19 | sr = 2.0; input_sz = int(128 * sr) # 2.0 by default 20 | -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/tests/test_trackers.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import unittest 4 | import os 5 | import random 6 | 7 | from got10k.trackers import IdentityTracker 8 | from got10k.datasets import GOT10k 9 | 10 | 11 | class TestTrackers(unittest.TestCase): 12 | 13 | def setUp(self): 14 | self.data_dir = 'data' 15 | self.tracker = IdentityTracker() 16 | 17 | def tearDown(self): 18 | pass 19 | 20 | def test_identity_tracker(self): 21 | # setup dataset 22 | root_dir = os.path.join(self.data_dir, 'GOT-10k') 23 | dataset = GOT10k(root_dir, subset='val') 24 | # run experiment 25 | img_files, anno = random.choice(dataset) 26 | boxes, times = self.tracker.track( 27 | img_files, anno[0], visualize=True) 28 | self.assertEqual(boxes.shape, anno.shape) 29 | self.assertEqual(len(times), len(anno)) 30 | 31 | 32 | if __name__ == '__main__': 33 | unittest.main() 34 | -------------------------------------------------------------------------------- /ltr/external/PreciseRoIPooling/pytorch/prroi_pool/src/prroi_pooling_gpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : prroi_pooling_gpu.h 3 | * Author : Jiayuan Mao, Tete Xiao 4 | * Email : maojiayuan@gmail.com, jasonhsiao97@gmail.com 5 | * Date : 07/13/2018 6 | * 7 | * Distributed under terms of the MIT license. 8 | * Copyright (c) 2017 Megvii Technology Limited. 9 | */ 10 | 11 | int prroi_pooling_forward_cuda(THCudaTensor *features, THCudaTensor *rois, THCudaTensor *output, int pooled_height, int pooled_width, float spatial_scale); 12 | 13 | int prroi_pooling_backward_cuda( 14 | THCudaTensor *features, THCudaTensor *rois, THCudaTensor *output, THCudaTensor *output_diff, THCudaTensor *features_diff, 15 | int pooled_height, int pooled_width, float spatial_scale 16 | ); 17 | 18 | int prroi_pooling_coor_backward_cuda( 19 | THCudaTensor *features, THCudaTensor *rois, THCudaTensor *output, THCudaTensor *output_diff, THCudaTensor *features_diff, 20 | int pooled_height, int pooled_width, float spatial_scal 21 | ); 22 | 23 | -------------------------------------------------------------------------------- /arena/LaSOT/common_path.py: -------------------------------------------------------------------------------- 1 | import os 2 | ###################################################################### 3 | dataset_name_ = 'LaSOT' 4 | video_name_ = '' # 'airplane-9' 5 | 6 | ###################################################################### 7 | dataset_root_ = '/home/zxy/Downloads/AR_Data/LaSOT_Test' 8 | save_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../analysis')) 9 | 10 | ######################### Refine Module ################################ 11 | # model_dir = '/home/zxy/Desktop/AlphaRefine/pytracking/ltr/checkpoints/ltr/' 12 | # model_code = 'a' 13 | # refine_path = os.path.join(model_dir, "SEx_beta/SEcm_r34/SEcmnet_ep0040-{}.pth.tar".format(model_code)) 14 | # RF_type = 'AR_CrsM_R34SR20_pixCorr_woPr_woNL_corner_{}'.format(model_code) 15 | 16 | refine_path = '/home/zxy/Desktop/AR_Maintaince/AlphaRefine/ltr/checkpoints/ltr/SEx_beta/SEcmnet_ep0040-c.pth.tar' 17 | RF_type = 'AR_CrsM_R34SR20_pixCorr_woPr_woNL_corner' 18 | selector_path = 0 19 | sr = 2.0; input_sz = int(128 * sr) # 2.0 by default 20 | -------------------------------------------------------------------------------- /external/pysot/toolkit/utils/misc.py: -------------------------------------------------------------------------------- 1 | """ 2 | @author fangyi.zhang@vipl.ict.ac.cn 3 | """ 4 | import numpy as np 5 | 6 | def determine_thresholds(confidence, resolution=100): 7 | """choose threshold according to confidence 8 | 9 | Args: 10 | confidence: list or numpy array or numpy array 11 | reolution: number of threshold to choose 12 | 13 | Restures: 14 | threshold: numpy array 15 | """ 16 | if isinstance(confidence, list): 17 | confidence = np.array(confidence) 18 | confidence = confidence.flatten() 19 | confidence = confidence[~np.isnan(confidence)] 20 | confidence.sort() 21 | 22 | assert len(confidence) > resolution and resolution > 2 23 | 24 | thresholds = np.ones((resolution)) 25 | thresholds[0] = - np.inf 26 | thresholds[-1] = np.inf 27 | delta = np.floor(len(confidence) / (resolution - 2)) 28 | idxs = np.linspace(delta, len(confidence)-delta, resolution-2, dtype=np.int32) 29 | thresholds[1:-1] = confidence[idxs] 30 | return thresholds 31 | -------------------------------------------------------------------------------- /pytracking/run_vot.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 pytracking.evaluation import Tracker 10 | 11 | 12 | def run_vot2020(tracker_name, tracker_param, run_id=None, debug=0, visdom_info=None): 13 | tracker = Tracker(tracker_name, tracker_param, run_id) 14 | tracker.run_vot2020(debug, visdom_info) 15 | 16 | 17 | def run_vot(tracker_name, tracker_param, run_id=None): 18 | tracker = Tracker(tracker_name, tracker_param, run_id) 19 | tracker.run_vot() 20 | 21 | 22 | def main(): 23 | parser = argparse.ArgumentParser(description='Run VOT.') 24 | parser.add_argument('tracker_name', type=str) 25 | parser.add_argument('tracker_param', type=str) 26 | parser.add_argument('--run_id', type=int, default=None) 27 | 28 | args = parser.parse_args() 29 | 30 | run_vot(args.tracker_name, args.tracker_param, args.run_id) 31 | 32 | 33 | if __name__ == '__main__': 34 | main() 35 | -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/got10k/experiments/dtb70.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import os 4 | 5 | from .otb import ExperimentOTB 6 | from ..datasets import DTB70 7 | 8 | 9 | class ExperimentDTB70(ExperimentOTB): 10 | r"""Experiment pipeline and evaluation toolkit for DTB70 dataset. 11 | 12 | Args: 13 | root_dir (string): Root directory of DTB70 dataset. 14 | result_dir (string, optional): Directory for storing tracking 15 | results. Default is ``./results``. 16 | report_dir (string, optional): Directory for storing performance 17 | evaluation results. Default is ``./reports``. 18 | """ 19 | def __init__(self, root_dir, 20 | result_dir='results', report_dir='reports'): 21 | self.dataset = DTB70(root_dir) 22 | self.result_dir = os.path.join(result_dir, 'DTB70') 23 | self.report_dir = os.path.join(report_dir, 'DTB70') 24 | # as nbins_iou increases, the success score 25 | # converges to the average overlap (AO) 26 | self.nbins_iou = 21 27 | self.nbins_ce = 51 28 | -------------------------------------------------------------------------------- /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) -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/got10k/experiments/nfs.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import os 4 | 5 | from .otb import ExperimentOTB 6 | from ..datasets import NfS 7 | 8 | 9 | class ExperimentNfS(ExperimentOTB): 10 | r"""Experiment pipeline and evaluation toolkit for NfS dataset. 11 | 12 | Args: 13 | root_dir (string): Root directory of NfS dataset. 14 | result_dir (string, optional): Directory for storing tracking 15 | results. Default is ``./results``. 16 | report_dir (string, optional): Directory for storing performance 17 | evaluation results. Default is ``./reports``. 18 | """ 19 | def __init__(self, root_dir, fps=240, 20 | result_dir='results', report_dir='reports'): 21 | self.dataset = NfS(root_dir, fps) 22 | self.result_dir = os.path.join(result_dir, 'NfS/%d' % fps) 23 | self.report_dir = os.path.join(report_dir, 'NfS/%d' % fps) 24 | # as nbins_iou increases, the success score 25 | # converges to the average overlap (AO) 26 | self.nbins_iou = 21 27 | self.nbins_ce = 51 28 | -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/got10k/experiments/tcolor128.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import os 4 | 5 | from .otb import ExperimentOTB 6 | from ..datasets import TColor128 7 | 8 | 9 | class ExperimentTColor128(ExperimentOTB): 10 | r"""Experiment pipeline and evaluation toolkit for TColor128 dataset. 11 | 12 | Args: 13 | root_dir (string): Root directory of TColor128 dataset. 14 | result_dir (string, optional): Directory for storing tracking 15 | results. Default is ``./results``. 16 | report_dir (string, optional): Directory for storing performance 17 | evaluation results. Default is ``./reports``. 18 | """ 19 | def __init__(self, root_dir, 20 | result_dir='results', report_dir='reports'): 21 | self.dataset = TColor128(root_dir) 22 | self.result_dir = os.path.join(result_dir, 'TColor128') 23 | self.report_dir = os.path.join(report_dir, 'TColor128') 24 | # as nbins_iou increases, the success score 25 | # converges to the average overlap (AO) 26 | self.nbins_iou = 21 27 | self.nbins_ce = 51 28 | -------------------------------------------------------------------------------- /external/RT_MDNet/modules/pretrain_options.py: -------------------------------------------------------------------------------- 1 | from collections import OrderedDict 2 | 3 | pretrain_opts = OrderedDict() 4 | pretrain_opts['use_gpu'] = True 5 | 6 | pretrain_opts['init_model_path'] = './models/imagenet-vgg-m.mat' 7 | pretrain_opts['model_path'] = './models/rt_mdnet.pth' 8 | 9 | pretrain_opts['batch_frames'] = 8 10 | pretrain_opts['batch_pos'] = 64 11 | pretrain_opts['batch_neg'] = 196 12 | 13 | pretrain_opts['overlap_pos'] = [0.7, 1] 14 | pretrain_opts['overlap_neg'] = [0, 0.5] 15 | 16 | pretrain_opts['img_size'] = 107 17 | 18 | 19 | pretrain_opts['lr'] = 0.0001 20 | pretrain_opts['w_decay'] = 0.0005 21 | pretrain_opts['momentum'] = 0.9 22 | pretrain_opts['grad_clip'] = 10 23 | pretrain_opts['ft_layers'] = ['conv','fc'] 24 | pretrain_opts['lr_mult'] = {'fc':1} 25 | pretrain_opts['n_cycles'] = 1000 26 | 27 | 28 | ##################################### from RCNN ############################################# 29 | pretrain_opts['padding'] = 1.2 30 | pretrain_opts['padding_ratio']=5. 31 | pretrain_opts['padded_img_size'] = pretrain_opts['img_size']*int(pretrain_opts['padding_ratio']) 32 | pretrain_opts['frame_interval'] = 2 33 | -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 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 | -------------------------------------------------------------------------------- /ltr/external/PreciseRoIPooling/pytorch/prroi_pool/prroi_pool.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : prroi_pool.py 4 | # Author : Jiayuan Mao, Tete Xiao 5 | # Email : maojiayuan@gmail.com, jasonhsiao97@gmail.com 6 | # Date : 07/13/2018 7 | # 8 | # This file is part of PreciseRoIPooling. 9 | # Distributed under terms of the MIT license. 10 | # Copyright (c) 2017 Megvii Technology Limited. 11 | 12 | import torch.nn as nn 13 | 14 | from .functional import prroi_pool2d 15 | 16 | __all__ = ['PrRoIPool2D'] 17 | 18 | 19 | class PrRoIPool2D(nn.Module): 20 | def __init__(self, pooled_height, pooled_width, spatial_scale): 21 | super().__init__() 22 | 23 | self.pooled_height = int(pooled_height) 24 | self.pooled_width = int(pooled_width) 25 | self.spatial_scale = float(spatial_scale) 26 | 27 | def forward(self, features, rois): 28 | return prroi_pool2d(features, rois, self.pooled_height, self.pooled_width, self.spatial_scale) 29 | 30 | def extra_repr(self): 31 | return 'kernel_size=({pooled_height}, {pooled_width}), spatial_scale={spatial_scale}'.format(**self.__dict__) 32 | 33 | -------------------------------------------------------------------------------- /external/pysot/toolkit/datasets/dataset.py: -------------------------------------------------------------------------------- 1 | from tqdm import tqdm 2 | 3 | class Dataset(object): 4 | def __init__(self, name, dataset_root): 5 | self.name = name 6 | self.dataset_root = dataset_root 7 | self.videos = None 8 | 9 | def __getitem__(self, idx): 10 | if isinstance(idx, str): 11 | return self.videos[idx] 12 | elif isinstance(idx, int): 13 | return self.videos[sorted(list(self.videos.keys()))[idx]] 14 | 15 | def __len__(self): 16 | return len(self.videos) 17 | 18 | def __iter__(self): 19 | keys = sorted(list(self.videos.keys())) 20 | for key in keys: 21 | yield self.videos[key] 22 | 23 | def set_tracker(self, path, tracker_names): 24 | """ 25 | Args: 26 | path: path to tracker results, 27 | tracker_names: list of tracker name 28 | """ 29 | self.tracker_path = path 30 | self.tracker_names = tracker_names 31 | # for video in tqdm(self.videos.values(), 32 | # desc='loading tacker result', ncols=100): 33 | # video.load_tracker(path, tracker_names) 34 | -------------------------------------------------------------------------------- /ltr/admin/local.py.example: -------------------------------------------------------------------------------- 1 | import os 2 | workspace_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')) 3 | data_root = '/media/zxy/Extreme_SSD/Datasets' 4 | 5 | 6 | class EnvironmentSettings: 7 | def __init__(self): 8 | self.workspace_dir = workspace_dir # Base directory for saving network checkpoints. 9 | self.tensorboard_dir = self.workspace_dir + '/tensorboard/' # Directory for tensorboard files. 10 | self.pretrained_networks = self.workspace_dir + '/pretrained_networks/' 11 | self.lasot_dir = f'{data_root}/LaSOTBenchmark' 12 | self.got10k_dir = f'{data_root}/GOT-10K/train' 13 | self.trackingnet_dir = '' 14 | self.coco_dir = f'{data_root}/COCO' 15 | self.lvis_dir = '' 16 | self.sbd_dir = '' 17 | self.imagenet_dir = f'{data_root}/ILSVRC2015' 18 | self.imagenetdet_dir = f'{data_root}/Imagenet_DET/ILSVRC' 19 | self.ecssd_dir = '' 20 | self.hkuis_dir = '' 21 | self.msra10k_dir = '' 22 | self.davis_dir = '' 23 | self.youtubevos_dir = f'{data_root}/Youtube-VOS' 24 | self.saliency_dir = f'{data_root}/saliency/MERGED' -------------------------------------------------------------------------------- /ltr/external/PreciseRoIPooling/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Jiayuan Mao 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 | -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/tests/test_utils.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import unittest 4 | import numpy as np 5 | 6 | from got10k.utils.metrics import rect_iou, poly_iou 7 | 8 | 9 | class TestUtils(unittest.TestCase): 10 | 11 | def setUp(self): 12 | pass 13 | 14 | def tearDown(self): 15 | pass 16 | 17 | def test_iou(self): 18 | rects1 = np.random.rand(1000, 4) * 100 19 | rects2 = np.random.rand(1000, 4) * 100 20 | bound = (50, 100) 21 | ious1 = rect_iou(rects1, rects2, bound=bound) 22 | ious2 = poly_iou(rects1, rects2, bound=bound) 23 | self.assertTrue((ious1 - ious2).max() < 1e-14) 24 | 25 | polys1 = self._rect2corner(rects1) 26 | polys2 = self._rect2corner(rects2) 27 | ious3 = poly_iou(polys1, polys2, bound=bound) 28 | self.assertTrue((ious1 - ious3).max() < 1e-14) 29 | 30 | def _rect2corner(self, rects): 31 | x1, y1, w, h = rects.T 32 | x2, y2 = x1 + w, y1 + h 33 | corners = np.array([x1, y1, x1, y2, x2, y2, x2, y1]).T 34 | 35 | return corners 36 | 37 | 38 | if __name__ == '__main__': 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /pytracking/evaluation/local.py.example: -------------------------------------------------------------------------------- 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/zxy/Desktop/AlphaRefine_CVPR21/pytracking/networks/' # Where tracking networks are stored. 14 | settings.nfs_path = '' 15 | settings.otb_path = '' 16 | settings.result_plot_path = '/home/zxy/Desktop/AlphaRefine_CVPR21/pytracking/result_plots/' 17 | settings.results_path = '/home/zxy/Desktop/AlphaRefine_CVPR21/pytracking/tracking_results/' # Where to store tracking results 18 | settings.segmentation_path = '/home/zxy/Desktop/AlphaRefine_CVPR21/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 | -------------------------------------------------------------------------------- /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 predicts_segmentation_mask(self): 12 | return False 13 | 14 | 15 | def initialize(self, image, info: dict) -> dict: 16 | """Overload this function in your tracker. This should initialize the model.""" 17 | raise NotImplementedError 18 | 19 | 20 | def track(self, image, info: dict = None) -> dict: 21 | """Overload this function in your tracker. This should track in the frame and update the model.""" 22 | raise NotImplementedError 23 | 24 | 25 | def visdom_draw_tracking(self, image, box, segmentation=None): 26 | if isinstance(box, OrderedDict): 27 | box = [v for k, v in box.items()] 28 | else: 29 | box = (box,) 30 | if segmentation is None: 31 | self.visdom.register((image, *box), 'Tracking', 1, 'Tracking') 32 | else: 33 | self.visdom.register((image, *box, segmentation), 'Tracking', 1, 'Tracking') -------------------------------------------------------------------------------- /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/RT_MDNet/modules/roi_align/gradcheck.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import torch 3 | from torch.autograd import gradcheck 4 | 5 | import os.path as osp 6 | import sys 7 | sys.path.append(osp.abspath(osp.join(__file__, '../../'))) 8 | from roi_align import RoIAlign, RoIAlignAda # noqa: E402 9 | 10 | feat_size = 15 11 | spatial_scale = 1.0 / 8 12 | img_size = feat_size / spatial_scale 13 | num_imgs = 2 14 | num_rois = 20 15 | 16 | batch_ind = np.random.randint(num_imgs, size=(num_rois, 1)) 17 | rois = np.random.rand(num_rois, 4) * img_size * 0.5 18 | rois[:, 2:] += img_size * 0.5 19 | rois = np.hstack((batch_ind, rois)) 20 | 21 | feat = torch.randn( 22 | num_imgs, 16, feat_size, feat_size, requires_grad=True, device='cuda:0') 23 | rois = torch.from_numpy(rois).float().cuda() 24 | inputs = (feat, rois) 25 | print('Gradcheck for roi align...') 26 | test = gradcheck(RoIAlign(3, spatial_scale), inputs, atol=1e-3, eps=1e-3) 27 | print(test) 28 | test = gradcheck(RoIAlign(3, spatial_scale, 2), inputs, atol=1e-3, eps=1e-3) 29 | print(test) 30 | test2 = gradcheck(RoIAlignAda(3, spatial_scale), inputs, atol=1e-3, eps=1e-3) 31 | print(test2) 32 | test2 = gradcheck(RoIAlignAda(3, spatial_scale, 2), inputs, atol=1e-3, eps=1e-3) 33 | print(test2) -------------------------------------------------------------------------------- /arena/GOT10k/collect_reports.py: -------------------------------------------------------------------------------- 1 | import os 2 | import json 3 | from arena.GOT10k.common_path import save_dir 4 | 5 | 6 | def parse_args(): 7 | import argparse 8 | parser = argparse.ArgumentParser() 9 | parser.add_argument('--report_dir', default=save_dir, help='path to the report directory') 10 | parser.add_argument('--dataset', default='', help='the dataset to be evaluated') 11 | parser.add_argument('--prefix', default='', help='the dataset to be evaluated') 12 | return parser.parse_args() 13 | 14 | 15 | if __name__ == '__main__': 16 | args = parse_args() 17 | 18 | report_dir = os.path.join(args.report_dir, args.dataset, 'reports') 19 | report_dir = os.path.join(report_dir, os.listdir(report_dir)[0]) 20 | items = sorted([os.path.join(report_dir, it) for it in os.listdir(report_dir)]) 21 | for item in items: 22 | exp_name = os.path.basename(item); print(exp_name) 23 | json_file = os.path.join(item, 'performance.json') 24 | with open(json_file) as fid: 25 | report = json.load(fid) 26 | report_content = list(report.items())[0][1] 27 | overall_performance = report_content['overall'] 28 | print("AUC:{} \nPrecision:{}\n\n".format(overall_performance['success_score'], overall_performance['precision_score'])) 29 | -------------------------------------------------------------------------------- /external/pysot/pysot/models/loss.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) SenseTime. All Rights Reserved. 2 | 3 | from __future__ import absolute_import 4 | from __future__ import division 5 | from __future__ import print_function 6 | from __future__ import unicode_literals 7 | 8 | import torch 9 | import torch.nn.functional as F 10 | 11 | 12 | def get_cls_loss(pred, label, select): 13 | if len(select.size()) == 0 or \ 14 | select.size() == torch.Size([0]): 15 | return 0 16 | pred = torch.index_select(pred, 0, select) 17 | label = torch.index_select(label, 0, select) 18 | return F.nll_loss(pred, label) 19 | 20 | 21 | def select_cross_entropy_loss(pred, label): 22 | pred = pred.view(-1, 2) 23 | label = label.view(-1) 24 | pos = label.data.eq(1).nonzero().squeeze().cuda() 25 | neg = label.data.eq(0).nonzero().squeeze().cuda() 26 | loss_pos = get_cls_loss(pred, label, pos) 27 | loss_neg = get_cls_loss(pred, label, neg) 28 | return loss_pos * 0.5 + loss_neg * 0.5 29 | 30 | 31 | def weight_l1_loss(pred_loc, label_loc, loss_weight): 32 | b, _, sh, sw = pred_loc.size() 33 | pred_loc = pred_loc.view(b, 4, -1, sh, sw) 34 | diff = (pred_loc - label_loc).abs() 35 | diff = diff.sum(dim=1).view(b, -1, sh, sw) 36 | loss = diff * loss_weight 37 | return loss.sum().div(b) 38 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /pytracking/parameter/lwl/lwl_ytvos.py: -------------------------------------------------------------------------------- 1 | from pytracking.utils import TrackerParams 2 | from pytracking.features.net_wrappers import NetWithBackbone 3 | 4 | 5 | def parameters(): 6 | params = TrackerParams() 7 | 8 | params.debug = 0 9 | params.visualization = False 10 | 11 | params.seg_to_bb_mode = 'var' 12 | params.max_scale_change = (0.95, 1.1) 13 | params.min_mask_area = 100 14 | 15 | params.use_gpu = True 16 | 17 | params.image_sample_size = (30 * 16, 52 * 16) 18 | params.search_area_scale = 5.0 19 | params.border_mode = 'inside_major' 20 | params.patch_max_scale_change = None 21 | 22 | # Learning parameters 23 | params.sample_memory_size = 32 24 | params.learning_rate = 0.1 25 | params.init_samples_minimum_weight = 0.25 26 | params.train_skipping = 1 27 | 28 | # Net optimization params 29 | params.update_target_model = True 30 | params.net_opt_iter = 20 31 | params.net_opt_update_iter = 3 32 | 33 | params.net = NetWithBackbone(net_path='lwl_stage2.pth', 34 | use_gpu=params.use_gpu, 35 | image_format='bgr255', 36 | mean=[102.9801, 115.9465, 122.7717], 37 | std=[1.0, 1.0, 1.0] 38 | ) 39 | 40 | return params 41 | -------------------------------------------------------------------------------- /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) -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/got10k/trackers/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import numpy as np 4 | import time 5 | from PIL import Image 6 | 7 | from ..utils.viz import show_frame 8 | 9 | 10 | class Tracker(object): 11 | 12 | def __init__(self, name, is_deterministic=False): 13 | self.name = name 14 | self.is_deterministic = is_deterministic 15 | 16 | def init(self, image, box): 17 | raise NotImplementedError() 18 | 19 | def update(self, image): 20 | raise NotImplementedError() 21 | 22 | def track(self, img_files, box, visualize=False): 23 | frame_num = len(img_files) 24 | boxes = np.zeros((frame_num, 4)) 25 | boxes[0] = box 26 | times = np.zeros(frame_num) 27 | 28 | for f, img_file in enumerate(img_files): 29 | image = Image.open(img_file) 30 | if not image.mode == 'RGB': 31 | image = image.convert('RGB') 32 | 33 | start_time = time.time() 34 | if f == 0: 35 | self.init(image, box) 36 | else: 37 | boxes[f, :] = self.update(image) 38 | times[f] = time.time() - start_time 39 | 40 | if visualize: 41 | show_frame(image, boxes[f, :]) 42 | 43 | return boxes, times 44 | 45 | 46 | from .identity_tracker import IdentityTracker 47 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/got10k/utils/ioutils.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division 2 | 3 | import wget 4 | import os 5 | import shutil 6 | import zipfile 7 | import sys 8 | 9 | 10 | def download(url, filename): 11 | r"""Download file from the internet. 12 | 13 | Args: 14 | url (string): URL of the internet file. 15 | filename (string): Path to store the downloaded file. 16 | """ 17 | return wget.download(url, out=filename) 18 | 19 | 20 | def extract(filename, extract_dir): 21 | r"""Extract zip file. 22 | 23 | Args: 24 | filename (string): Path of the zip file. 25 | extract_dir (string): Directory to store the extracted results. 26 | """ 27 | if os.path.splitext(filename)[1] == '.zip': 28 | if not os.path.isdir(extract_dir): 29 | os.makedirs(extract_dir) 30 | with zipfile.ZipFile(filename) as z: 31 | z.extractall(extract_dir) 32 | else: 33 | raise Exception('Unsupport extension {} of the compressed file {}.'.format( 34 | os.path.splitext(filename)[1]), filename) 35 | 36 | 37 | def compress(dirname, save_file): 38 | """Compress a folder to a zip file. 39 | 40 | Arguments: 41 | dirname {string} -- Directory of all files to be compressed. 42 | save_file {string} -- Path to store the zip file. 43 | """ 44 | shutil.make_archive(save_file, 'zip', dirname) 45 | -------------------------------------------------------------------------------- /external/pysot/toolkit/utils/c_region.pxd: -------------------------------------------------------------------------------- 1 | cdef extern from "src/region.h": 2 | ctypedef enum region_type "RegionType": 3 | EMTPY 4 | SPECIAL 5 | RECTANGEL 6 | POLYGON 7 | MASK 8 | 9 | ctypedef struct region_bounds: 10 | float top 11 | float bottom 12 | float left 13 | float right 14 | 15 | ctypedef struct region_rectangle: 16 | float x 17 | float y 18 | float width 19 | float height 20 | 21 | # ctypedef struct region_mask: 22 | # int x 23 | # int y 24 | # int width 25 | # int height 26 | # char *data 27 | 28 | ctypedef struct region_polygon: 29 | int count 30 | float *x 31 | float *y 32 | 33 | ctypedef union region_container_data: 34 | region_rectangle rectangle 35 | region_polygon polygon 36 | # region_mask mask 37 | int special 38 | 39 | ctypedef struct region_container: 40 | region_type type 41 | region_container_data data 42 | 43 | # ctypedef struct region_overlap: 44 | # float overlap 45 | # float only1 46 | # float only2 47 | 48 | # region_overlap region_compute_overlap(const region_container* ra, const region_container* rb, region_bounds bounds) 49 | 50 | float compute_polygon_overlap(const region_polygon* p1, const region_polygon* p2, float *only1, float *only2, region_bounds bounds) 51 | -------------------------------------------------------------------------------- /pytracking/parameter/lwl/lwl_boxinit.py: -------------------------------------------------------------------------------- 1 | from pytracking.utils import TrackerParams 2 | from pytracking.features.net_wrappers import NetWithBackbone 3 | 4 | 5 | def parameters(): 6 | params = TrackerParams() 7 | 8 | params.debug = 0 9 | params.visualization = False 10 | 11 | params.seg_to_bb_mode = 'var' 12 | params.max_scale_change = (0.95, 1.1) 13 | params.min_mask_area = 100 14 | 15 | params.use_gpu = True 16 | 17 | params.image_sample_size = (30 * 16, 52 * 16) 18 | params.search_area_scale = 5.0 19 | params.border_mode = 'inside_major' 20 | params.patch_max_scale_change = None 21 | 22 | # Learning parameters 23 | params.sample_memory_size = 32 24 | params.learning_rate = 0.2 25 | params.init_samples_minimum_weight = 0 26 | params.train_skipping = 5 27 | 28 | # Net optimization params 29 | params.update_target_model = True 30 | params.net_opt_iter = 20 31 | params.net_opt_update_iter = 5 32 | 33 | params.init_with_box = True 34 | params.lower_init_weight = True 35 | 36 | params.net = NetWithBackbone(net_path='lwl_boxinit.pth', 37 | use_gpu=params.use_gpu, 38 | image_format='bgr255', 39 | mean=[102.9801, 115.9465, 122.7717], 40 | std=[1.0, 1.0, 1.0]) 41 | 42 | params.vot_anno_conversion_type = 'preserve_area' 43 | 44 | return params 45 | -------------------------------------------------------------------------------- /arena/VOT2020/run_siamrpn.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import cv2 3 | 4 | import torch 5 | from arena.VOT2020.utils import make_full_size, VOT 6 | from arena.VOT2020.trackers.siamrpn_ar import BaseTracker 7 | 8 | 9 | def build_tracker(threshold): 10 | tracker = BaseTracker(threshold=threshold) 11 | return tracker 12 | 13 | 14 | def run_vot_exp(threshold): 15 | tracker = build_tracker(threshold) 16 | 17 | handle = VOT("mask") 18 | selection = handle.region() 19 | imagefile = handle.frame() 20 | 21 | image = cv2.cvtColor(cv2.imread(imagefile), cv2.COLOR_BGR2RGB) # Right 22 | # mask given by the toolkit ends with the target (zero-padding to the right and down is needed) 23 | mask = make_full_size(selection, (image.shape[1], image.shape[0])) 24 | tracker.initialize(image, mask) 25 | 26 | while True: 27 | imagefile = handle.frame() 28 | if not imagefile: 29 | break 30 | image = cv2.cvtColor(cv2.imread(imagefile), cv2.COLOR_BGR2RGB) # Right 31 | b1, m = tracker.track(image) 32 | handle.report(m) 33 | 34 | 35 | def parse_args(): 36 | from arena.VOT2020.common_path import _mask_thres 37 | parser = argparse.ArgumentParser() 38 | parser.add_argument("--mask_thres", type=float, default=_mask_thres, 39 | help="mask binarization threshold") 40 | args = parser.parse_args() 41 | return args 42 | 43 | 44 | args = parse_args() 45 | torch.set_num_threads(1) 46 | print(args) 47 | run_vot_exp(args.mask_thres) 48 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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) 45 | -------------------------------------------------------------------------------- /external/RT_MDNet/options.py: -------------------------------------------------------------------------------- 1 | import os 2 | from collections import OrderedDict 3 | 4 | opts = OrderedDict() 5 | opts['use_gpu'] = True 6 | 7 | opts['img_size'] = 107 8 | opts['padding'] = 1.2 9 | opts['jitter'] = True 10 | opts['result_path']='./result.npy' 11 | opts['adaptive_align']=True 12 | opts['batch_pos'] = 32 13 | opts['batch_neg'] = 96 14 | opts['batch_neg_cand'] = 1024 15 | opts['batch_test'] = 256 16 | 17 | opts['n_samples'] = 256 18 | opts['trans_f'] = 0.6 19 | opts['scale_f'] = 1.05 20 | opts['trans_f_expand'] = 1.4 21 | 22 | opts['n_bbreg'] = 1000 23 | opts['overlap_bbreg'] = [0.6, 1] 24 | opts['scale_bbreg'] = [1, 2] 25 | 26 | opts['lr_init'] = 0.0001 # original = 0.0001 27 | opts['maxiter_init'] = 50 # original = 30 28 | opts['n_pos_init'] = 500 29 | opts['n_neg_init'] = 5000 30 | opts['overlap_pos_init'] = [0.7, 1] 31 | opts['overlap_neg_init'] = [0, 0.5] 32 | 33 | opts['lr_update'] = 0.0003 # original = 0.0002 34 | opts['maxiter_update'] = 15 # original = 15 35 | opts['n_pos_update'] = 50 36 | opts['n_neg_update'] = 200 37 | opts['overlap_pos_update'] = [0.7, 1] 38 | opts['overlap_neg_update'] = [0, 0.3] 39 | 40 | opts['success_thr'] = 0. # original = 0 41 | opts['n_frames_short'] = 20 42 | opts['n_frames_long'] = 100 43 | opts['long_interval'] = 10 44 | 45 | opts['w_decay'] = 0.0005 # original = 0.0005 46 | opts['momentum'] = 0.9 47 | opts['grad_clip'] = 10 # original = 10 48 | opts['lr_mult'] = {'fc6':10} 49 | opts['ft_layers'] = ['fc'] 50 | 51 | opts['model_path'] = os.path.join(os.path.dirname(__file__), 'rt-mdnet.pth') -------------------------------------------------------------------------------- /arena/VOT2020/run_rtmdnet.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import cv2 3 | 4 | import torch 5 | from arena.VOT2020.utils import make_full_size, VOT 6 | from arena.VOT2020.trackers.rtmdnet_ar import BaseTracker 7 | 8 | 9 | def build_tracker(threshold): 10 | tracker = BaseTracker(threshold=threshold) 11 | return tracker 12 | 13 | 14 | def run_vot_exp(threshold): 15 | tracker = build_tracker(threshold) 16 | 17 | handle = VOT("mask") 18 | selection = handle.region() 19 | imagefile = handle.frame() 20 | 21 | image = cv2.cvtColor(cv2.imread(imagefile), cv2.COLOR_BGR2RGB) # Right 22 | # mask given by the toolkit ends with the target (zero-padding to the right and down is needed) 23 | mask = make_full_size(selection, (image.shape[1], image.shape[0])) 24 | tracker.initialize(image, mask) 25 | 26 | while True: 27 | imagefile = handle.frame() 28 | if not imagefile: 29 | break 30 | image = cv2.cvtColor(cv2.imread(imagefile), cv2.COLOR_BGR2RGB) # Right 31 | b1, m = tracker.track(image) 32 | handle.report(m) 33 | 34 | 35 | def parse_args(): 36 | from arena.VOT2020.common_path import _mask_thres 37 | parser = argparse.ArgumentParser() 38 | parser.add_argument("--mask_thres", type=float, default=_mask_thres, 39 | help="tracker_param options: super_dimp;dimp50|default|default") 40 | args = parser.parse_args() 41 | return args 42 | 43 | 44 | args = parse_args() 45 | torch.set_num_threads(1) 46 | print(args) 47 | run_vot_exp(args.mask_thres) 48 | -------------------------------------------------------------------------------- /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) -------------------------------------------------------------------------------- /arena/VOT2020/run_rtmdnet_alphaseg.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import cv2 3 | 4 | import torch 5 | from arena.VOT2020.utils import make_full_size, VOT 6 | from arena.VOT2020.trackers.rtmdnet_ar import TrackerAR 7 | 8 | 9 | def build_tracker(threshold): 10 | tracker = TrackerAR(threshold=threshold) 11 | return tracker 12 | 13 | 14 | def run_vot_exp(threshold): 15 | tracker = build_tracker(threshold) 16 | 17 | handle = VOT("mask") 18 | selection = handle.region() 19 | imagefile = handle.frame() 20 | 21 | image = cv2.cvtColor(cv2.imread(imagefile), cv2.COLOR_BGR2RGB) # Right 22 | # mask given by the toolkit ends with the target (zero-padding to the right and down is needed) 23 | mask = make_full_size(selection, (image.shape[1], image.shape[0])) 24 | tracker.initialize(image, mask) 25 | 26 | while True: 27 | imagefile = handle.frame() 28 | if not imagefile: 29 | break 30 | image = cv2.cvtColor(cv2.imread(imagefile), cv2.COLOR_BGR2RGB) # Right 31 | b1, m = tracker.track(image) 32 | handle.report(m) 33 | 34 | 35 | def parse_args(): 36 | from arena.VOT2020.common_path import _mask_thres 37 | parser = argparse.ArgumentParser() 38 | parser.add_argument("--mask_thres", type=float, default=_mask_thres, 39 | help="tracker_param options: super_dimp;dimp50|default|default") 40 | args = parser.parse_args() 41 | return args 42 | 43 | 44 | args = parse_args() 45 | torch.set_num_threads(1) 46 | print(args) 47 | run_vot_exp(args.mask_thres) 48 | -------------------------------------------------------------------------------- /arena/VOT2020/run_siamrpn_alphaseg.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import cv2 3 | 4 | import torch 5 | from arena.VOT2020.utils import make_full_size, VOT 6 | from arena.VOT2020.trackers.siamrpn_ar import TrackerAR 7 | 8 | 9 | def build_tracker(threshold): 10 | tracker = TrackerAR(threshold=threshold) 11 | return tracker 12 | 13 | 14 | def run_vot_exp(threshold): 15 | tracker = build_tracker(threshold) 16 | 17 | handle = VOT("mask") 18 | selection = handle.region() 19 | imagefile = handle.frame() 20 | 21 | image = cv2.cvtColor(cv2.imread(imagefile), cv2.COLOR_BGR2RGB) # Right 22 | # mask given by the toolkit ends with the target (zero-padding to the right and down is needed) 23 | mask = make_full_size(selection, (image.shape[1], image.shape[0])) 24 | tracker.initialize(image, mask) 25 | 26 | while True: 27 | imagefile = handle.frame() 28 | if not imagefile: 29 | break 30 | image = cv2.cvtColor(cv2.imread(imagefile), cv2.COLOR_BGR2RGB) # Right 31 | b1, m = tracker.track(image) 32 | handle.report(m) 33 | 34 | 35 | def parse_args(): 36 | from arena.VOT2020.common_path import _mask_thres 37 | parser = argparse.ArgumentParser() 38 | parser.add_argument("--mask_thres", type=float, default=_mask_thres, 39 | help="tracker_param options: super_dimp;dimp50|default|default") 40 | args = parser.parse_args() 41 | return args 42 | 43 | 44 | args = parse_args() 45 | torch.set_num_threads(1) 46 | print(args) 47 | run_vot_exp(args.mask_thres) 48 | -------------------------------------------------------------------------------- /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/pysot/toolkit/visualization/draw_mask.py: -------------------------------------------------------------------------------- 1 | import os 2 | import numpy as np 3 | import cv2 4 | 5 | 6 | def mask_superpose(frame, mask_pred, color=(0, 255, 0)): 7 | im4show = frame 8 | mask_pred = np.uint8(mask_pred > 0.3)[:, :, None] 9 | contours, _ = cv2.findContours(mask_pred.squeeze(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE) 10 | im4show = im4show * (1 - mask_pred) + np.uint8(im4show * mask_pred / 2) + mask_pred * np.uint8(color) * 128 11 | 12 | cv2.drawContours(im4show, contours, -1, color, 2) 13 | main_contour = contours[np.array([c.shape[0] for c in contours]).argmax()] 14 | boundrect = cv2.boxPoints(cv2.minAreaRect(main_contour)).astype(np.int64) 15 | cv2.drawContours(im4show, [boundrect], 0, (0, 0, 255), 3) 16 | return im4show 17 | 18 | 19 | def draw_frame_idx(frame, idx): 20 | H, W, _ = frame.shape 21 | legend_x, legend_y = W - W//6, H//15 22 | cv2.putText(frame, '#{}'.format(idx), (legend_x, legend_y+24), 23 | cv2.FONT_HERSHEY_SIMPLEX, 1.5, color=(0, 255, 255), thickness=3) 24 | cv2.putText(frame, 'DiMPsuper+AR', (W//15, legend_y + 24), 25 | cv2.FONT_HERSHEY_SIMPLEX, 1, color=(0, 255, 255), thickness=3) 26 | return frame 27 | 28 | 29 | def draw_mask(frame, mask, color=(0, 255, 0), idx=0, show=False, save_dir=None): 30 | out_image = mask_superpose(frame, mask, color) 31 | out_image = draw_frame_idx(out_image, idx) 32 | if show: 33 | cv2.imshow('', out_image) 34 | cv2.waitKey(0) 35 | 36 | if not save_dir is None: 37 | cv2.imwrite(os.path.join(save_dir, '{}.jpg'.format(idx)), out_image) 38 | -------------------------------------------------------------------------------- /external/pysot/pysot/core/xcorr.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) SenseTime. All Rights Reserved. 2 | 3 | from __future__ import absolute_import 4 | from __future__ import division 5 | from __future__ import print_function 6 | from __future__ import unicode_literals 7 | 8 | import torch 9 | import torch.nn.functional as F 10 | 11 | 12 | def xcorr_slow(x, kernel): 13 | """for loop to calculate cross correlation, slow version 14 | """ 15 | batch = x.size()[0] 16 | out = [] 17 | for i in range(batch): 18 | px = x[i] 19 | pk = kernel[i] 20 | px = px.view(1, -1, px.size()[1], px.size()[2]) 21 | pk = pk.view(1, -1, pk.size()[1], pk.size()[2]) 22 | po = F.conv2d(px, pk) 23 | out.append(po) 24 | out = torch.cat(out, 0) 25 | return out 26 | 27 | 28 | def xcorr_fast(x, kernel): 29 | """group conv2d to calculate cross correlation, fast version 30 | """ 31 | batch = kernel.size()[0] 32 | pk = kernel.view(-1, x.size()[1], kernel.size()[2], kernel.size()[3]) 33 | px = x.view(1, -1, x.size()[2], x.size()[3]) 34 | po = F.conv2d(px, pk, groups=batch) 35 | po = po.view(batch, -1, po.size()[2], po.size()[3]) 36 | return po 37 | 38 | 39 | def xcorr_depthwise(x, kernel): 40 | """depthwise cross correlation 41 | """ 42 | batch = kernel.size(0) 43 | channel = kernel.size(1) 44 | x = x.view(1, batch*channel, x.size(2), x.size(3)) 45 | kernel = kernel.view(batch*channel, 1, kernel.size(2), kernel.size(3)) 46 | out = F.conv2d(x, kernel, groups=batch*channel) 47 | out = out.view(batch, channel, out.size(2), out.size(3)) 48 | return out 49 | -------------------------------------------------------------------------------- /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/pysot/toolkit/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | from .vot import VOTDataset, VOTLTDataset 2 | from .otb import OTBDataset 3 | from .uav import UAVDataset 4 | from .lasot import LaSOTDataset 5 | from .nfs import NFSDataset 6 | from .trackingnet import TrackingNetDataset 7 | from .got10k import GOT10kDataset 8 | 9 | class DatasetFactory(object): 10 | @staticmethod 11 | def create_dataset(**kwargs): 12 | """ 13 | Args: 14 | name: dataset name 'OTB2015', 'LaSOT', 'UAV123', 'NFS240', 'NFS30', 15 | 'VOT2018', 'VOT2016', 'VOT2018-LT' 16 | dataset_root: dataset root 17 | load_img: wether to load image 18 | Return: 19 | dataset 20 | """ 21 | assert 'name' in kwargs, "should provide dataset name" 22 | name = kwargs['name'] 23 | if 'OTB' in name: 24 | dataset = OTBDataset(**kwargs) 25 | elif 'LaSOT' in name: 26 | dataset = LaSOTDataset(**kwargs) 27 | elif 'UAV' in name: 28 | dataset = UAVDataset(**kwargs) 29 | elif 'NFS' in name: 30 | dataset = NFSDataset(**kwargs) 31 | elif 'VOT2018' == name or 'VOT2016' == name or 'VOT2019' == name: 32 | dataset = VOTDataset(**kwargs) 33 | elif 'VOT2018-LT' == name: 34 | dataset = VOTLTDataset(**kwargs) 35 | elif 'TrackingNet' == name: 36 | dataset = TrackingNetDataset(**kwargs) 37 | elif 'GOT-10k' == name: 38 | dataset = GOT10kDataset(**kwargs) 39 | else: 40 | raise Exception("unknow dataset {}".format(kwargs['name'])) 41 | return dataset 42 | 43 | -------------------------------------------------------------------------------- /pytracking/run_experiment.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import argparse 4 | import importlib 5 | 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 | 10 | from pytracking.evaluation.running import run_dataset 11 | 12 | 13 | def run_experiment(experiment_module: str, experiment_name: str, debug=0, threads=0): 14 | """Run experiment. 15 | args: 16 | experiment_module: Name of experiment module in the experiments/ folder. 17 | experiment_name: Name of the experiment function. 18 | debug: Debug level. 19 | threads: Number of threads. 20 | """ 21 | expr_module = importlib.import_module('pytracking.experiments.{}'.format(experiment_module)) 22 | expr_func = getattr(expr_module, experiment_name) 23 | trackers, dataset = expr_func() 24 | print('Running: {} {}'.format(experiment_module, experiment_name)) 25 | run_dataset(dataset, trackers, debug, threads) 26 | 27 | 28 | def main(): 29 | parser = argparse.ArgumentParser(description='Run tracker.') 30 | parser.add_argument('experiment_module', type=str, help='Name of experiment module in the experiments/ folder.') 31 | parser.add_argument('experiment_name', type=str, help='Name of the experiment function.') 32 | parser.add_argument('--debug', type=int, default=0, help='Debug level.') 33 | parser.add_argument('--threads', type=int, default=0, help='Number of threads.') 34 | 35 | args = parser.parse_args() 36 | 37 | run_experiment(args.experiment_module, args.experiment_name, args.debug, args.threads) 38 | 39 | 40 | if __name__ == '__main__': 41 | main() 42 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /pytracking/run_video.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 pytracking.evaluation import Tracker 10 | 11 | 12 | def run_video(tracker_name, tracker_param, videofile, optional_box=None, debug=None, save_results=False): 13 | """Run the tracker on your webcam. 14 | args: 15 | tracker_name: Name of tracking method. 16 | tracker_param: Name of parameter file. 17 | debug: Debug level. 18 | """ 19 | tracker = Tracker(tracker_name, tracker_param) 20 | tracker.run_video(videofilepath=videofile, optional_box=optional_box, debug=debug, save_results=save_results) 21 | 22 | def main(): 23 | parser = argparse.ArgumentParser(description='Run the tracker on your webcam.') 24 | parser.add_argument('tracker_name', type=str, help='Name of tracking method.') 25 | parser.add_argument('tracker_param', type=str, help='Name of parameter file.') 26 | parser.add_argument('videofile', type=str, help='path to a video file.') 27 | parser.add_argument('--optional_box', type=float, default=None, nargs="+", help='optional_box with format x y w h.') 28 | parser.add_argument('--debug', type=int, default=0, help='Debug level.') 29 | parser.add_argument('--save_results', dest='save_results', action='store_true', help='Save bounding boxes') 30 | parser.set_defaults(save_results=False) 31 | 32 | args = parser.parse_args() 33 | 34 | run_video(args.tracker_name, args.tracker_param,args.videofile, args.optional_box, args.debug, args.save_results) 35 | 36 | 37 | if __name__ == '__main__': 38 | main() 39 | -------------------------------------------------------------------------------- /doc/TRAIN.md: -------------------------------------------------------------------------------- 1 | ## Train 2 | The training code is based on [Pytracking](https://github.com/visionml/pytracking.git), thus the training operation is similar. 3 | 4 | ### Dataset 5 | 6 | * Download the Dataset 7 | [GOT-10K](http://got-10k.aitestunion.com/downloads) | 8 | [LaSOT](http://vision.cs.stonybrook.edu/~lasot/download.html) | 9 | [MS-COCO](http://cocodataset.org/#home) | 10 | [ILSVRC-VID](http://image-net.org/challenges/LSVRC/2017/) | 11 | [ImageNet-DET](http://image-net.org/challenges/LSVRC/2017/) | 12 | [YouTube-VOS](https://youtube-vos.org) | 13 | [Saliency](https://drive.google.com/file/d/1XykS4zJl249PuyKu7aHshB5d6Y-F2k0p/view) 14 | 15 | For more details, you can refer to [ltr/README.md](https://github.com/visionml/pytracking/tree/master/ltr#overview) 16 | 17 | 18 | * The path to the training sets should be specified in `ltr/admin/local.py` 19 | 20 | If the `ltr/admin/local.py` is not exist, please run 21 | ``` bash 22 | python -c "from ltr.admin.environment import create_default_local_file; create_default_local_file()" 23 | ``` 24 | An example `ltr/admin/local.py.example` is also provided. 25 | 26 | 27 | ### Run Training Scripts 28 | 29 | The training recipes are placed in `ltr/train_settings` (e.g. `ltr/train_settings/SEx_beta/SEcm_r34.py`), you can 30 | configure the *training parameters* and *Dataloaders*. 31 | 32 | For a recipe named `ltr/train_settings/$sub1/$sub2.py`, run the following command to launch the training procedure. 33 | ``` 34 | python -m torch.distributed.launch --nproc_per_node=8 \ 35 | run_training_multigpu.py $sub1 $sub2 36 | ``` 37 | The checkpoints will be saved in `AlphaRefine/checkpoints/ltr/$sub1/$sub2/SEcmnet_ep00*.pth.tar`. 38 | -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/got10k/experiments/uav123.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import os 4 | import numpy as np 5 | 6 | from .otb import ExperimentOTB 7 | from ..datasets import UAV123 8 | from ..utils.metrics import rect_iou, center_error 9 | 10 | 11 | class ExperimentUAV123(ExperimentOTB): 12 | r"""Experiment pipeline and evaluation toolkit for UAV123 dataset. 13 | 14 | Args: 15 | root_dir (string): Root directory of UAV123 dataset. 16 | result_dir (string, optional): Directory for storing tracking 17 | results. Default is ``./results``. 18 | report_dir (string, optional): Directory for storing performance 19 | evaluation results. Default is ``./reports``. 20 | """ 21 | def __init__(self, root_dir, version='UAV123', 22 | result_dir='results', report_dir='reports'): 23 | assert version.upper() in ['UAV123', 'UAV20L'] 24 | self.dataset = UAV123(root_dir, version) 25 | self.result_dir = os.path.join(result_dir, version.upper()) 26 | self.report_dir = os.path.join(report_dir, version.upper()) 27 | # as nbins_iou increases, the success score 28 | # converges to the average overlap (AO) 29 | self.nbins_iou = 21 30 | self.nbins_ce = 51 31 | 32 | def _calc_metrics(self, boxes, anno): 33 | valid = ~np.any(np.isnan(anno), axis=1) 34 | if len(valid) == 0: 35 | print('Warning: no valid annotations') 36 | return None, None 37 | else: 38 | ious = rect_iou(boxes[valid, :], anno[valid, :]) 39 | center_errors = center_error( 40 | boxes[valid, :], anno[valid, :]) 41 | return ious, center_errors 42 | -------------------------------------------------------------------------------- /doc/arena/TrackingNet.md: -------------------------------------------------------------------------------- 1 | #### Download AlphaRefine Models 2 | We provide the models of *AlphaRefine* here. The **AUC** and **Latency** are tested with SiamRPN++ as the base tracker 3 | on *LaSOT* dataset, using a RTX 2080Ti GPU. 4 | 5 | We recommend download the model into `ltr/checkpoints/ltr/SEx_beta`. 6 | 7 | | Tracker | Backbone | Latency | AUC(%) | Model | 8 | |:--------------:|:----------------:|:-----------:|:-----------:|:----------------:| 9 | | AR34c+m | ResNet34 | 5.1ms | 55.9 | [model](https://drive.google.com/file/d/1drLqNq4r9g4ZqGtOGuuLCmHJDh20Fu1m/view?usp=sharing)| 10 | | AR18c+m | ResNet18 | 4.2ms | 55.0 | [model](https://drive.google.com/file/d/1ANf0KCvlFBbGQPpvT-3WNiy414ANkgLZ/view?usp=sharing)| 11 | 12 | 13 | ##### Download AlphaRefine 14 | We recommend download the model into `ltr/checkpoints/ltr/SEx_beta` 15 | 16 | #### Run Experiment Scripts 17 | We take [arena/TrackingNet/run_trackingnet_pytracking_RF.py](arena/TrackingNet/run_trackingnet_pytracking_RF.py) as an example: 18 | 19 | ##### path setting up 20 | 1. Edit [arena/TrackingNet/common_path.py](arena/TrackingNet/common_path.py), specify 'refine_path' as 21 | `ltr/checkpoints/ltr/SEx_beta/SEcm_r34/SEcmnet_ep0040-c.pth.tar` 22 | 23 | 2. Check if you have specified the 'dataset_root_' as the `path/to/the/TrackingNet/TEST`. 24 | 25 | ##### run the inference script 26 | ``` 27 | cd arena/TrackingNet 28 | python run_trackingnet_pytracking_RF.py 29 | ``` 30 | The result files will be saved in `arena/trackingnet/analysis` 31 | 32 | ##### evaluate the result files 33 | upload the zipped result to TrackingNet submitting website 34 | [EvalAI](http://eval.tracking-net.org/web/challenges/challenge-page/39/submission) 35 | -------------------------------------------------------------------------------- /ltr/external/PreciseRoIPooling/pytorch/tests/test_prroi_pooling2d.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # File : test_prroi_pooling2d.py 3 | # Author : Jiayuan Mao 4 | # Email : maojiayuan@gmail.com 5 | # Date : 18/02/2018 6 | # 7 | # This file is part of Jacinle. 8 | 9 | import unittest 10 | 11 | import torch 12 | import torch.nn as nn 13 | import torch.nn.functional as F 14 | 15 | from jactorch.utils.unittest import TorchTestCase 16 | 17 | from prroi_pool import PrRoIPool2D 18 | 19 | 20 | class TestPrRoIPool2D(TorchTestCase): 21 | def test_forward(self): 22 | pool = PrRoIPool2D(7, 7, spatial_scale=0.5) 23 | features = torch.rand((4, 16, 24, 32)).cuda() 24 | rois = torch.tensor([ 25 | [0, 0, 0, 14, 14], 26 | [1, 14, 14, 28, 28], 27 | ]).float().cuda() 28 | 29 | out = pool(features, rois) 30 | out_gold = F.avg_pool2d(features, kernel_size=2, stride=1) 31 | 32 | self.assertTensorClose(out, torch.stack(( 33 | out_gold[0, :, :7, :7], 34 | out_gold[1, :, 7:14, 7:14], 35 | ), dim=0)) 36 | 37 | def test_backward_shapeonly(self): 38 | pool = PrRoIPool2D(2, 2, spatial_scale=0.5) 39 | 40 | features = torch.rand((4, 2, 24, 32)).cuda() 41 | rois = torch.tensor([ 42 | [0, 0, 0, 4, 4], 43 | [1, 14, 14, 18, 18], 44 | ]).float().cuda() 45 | features.requires_grad = rois.requires_grad = True 46 | out = pool(features, rois) 47 | 48 | loss = out.sum() 49 | loss.backward() 50 | 51 | self.assertTupleEqual(features.size(), features.grad.size()) 52 | self.assertTupleEqual(rois.size(), rois.grad.size()) 53 | 54 | 55 | if __name__ == '__main__': 56 | unittest.main() 57 | -------------------------------------------------------------------------------- /pytracking/run_webcam.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 pytracking.evaluation import Tracker 10 | 11 | 12 | def run_webcam(tracker_name, tracker_param, debug=None, visdom_info=None): 13 | """Run the tracker on your webcam. 14 | args: 15 | tracker_name: Name of tracking method. 16 | tracker_param: Name of parameter file. 17 | debug: Debug level. 18 | visdom_info: Dict optionally containing 'use_visdom', 'server' and 'port' for Visdom visualization. 19 | """ 20 | visdom_info = {} if visdom_info is None else visdom_info 21 | tracker = Tracker(tracker_name, tracker_param) 22 | tracker.run_webcam(debug, visdom_info) 23 | 24 | 25 | def main(): 26 | parser = argparse.ArgumentParser(description='Run the tracker on your webcam.') 27 | parser.add_argument('tracker_name', type=str, help='Name of tracking method.') 28 | parser.add_argument('tracker_param', type=str, help='Name of parameter file.') 29 | parser.add_argument('--debug', type=int, default=0, help='Debug level.') 30 | parser.add_argument('--use_visdom', type=bool, default=True, help='Flag to enable visdom') 31 | parser.add_argument('--visdom_server', type=str, default='127.0.0.1', help='Server for visdom') 32 | parser.add_argument('--visdom_port', type=int, default=8097, help='Port for visdom') 33 | 34 | args = parser.parse_args() 35 | 36 | visdom_info = {'use_visdom': args.use_visdom, 'server': args.visdom_server, 'port': args.visdom_port} 37 | run_webcam(args.tracker_name, args.tracker_param, args.debug, visdom_info) 38 | 39 | 40 | if __name__ == '__main__': 41 | main() -------------------------------------------------------------------------------- /external/pysot/common_path_siammask.py: -------------------------------------------------------------------------------- 1 | import os 2 | # from pytracking.Refine_module_bcm import Refine_module_bcm 3 | '''Things that we can change''' 4 | ################################################### 5 | siam_model_ = 'siammask_r50_l3' 6 | ################################################### 7 | # dataset_name_ = 'OTB100' 8 | # dataset_name_ = 'GOT10K' 9 | dataset_name_ = 'VOT2018' 10 | # dataset_name_ = 'VOT2018-LT' 11 | # dataset_name_ = 'LaSOT' 12 | ################################################### 13 | video_name_ = '' 14 | # video_name_ = 'airplane-13' 15 | # video_name_ = 'rabbit-19' 16 | # video_name_ = 'cattle-12' 17 | # video_name_ = 'guitar-10' 18 | # video_name_ = 'airplane-1' 19 | # video_name_ = 'drone-2' 20 | # video_name_ = 'monkey-3' 21 | ######################################################################################### 22 | project_path_ = '/home/masterbin-iiau/Object_tracking/pysot' 23 | dataset_root_ = '/home/masterbin-iiau/Desktop/tracking_datasets' 24 | '''Pysot''' 25 | snapshot_path_ = os.path.join(project_path_,'experiments/%s/model.pth'%siam_model_) 26 | config_path_ = os.path.join(project_path_,'experiments/%s/config.yaml'%siam_model_) 27 | '''Refinement Module''' 28 | project_path = '/home/masterbin-iiau/Desktop/scale-estimator' 29 | refine_root = os.path.join(project_path, 'ltr/checkpoints/ltr/SEbcm/') 30 | refine_model_name = 'SEbcm' 31 | refine_path = os.path.join(refine_root, refine_model_name) 32 | selector_root = os.path.join(project_path, 'ltr/checkpoints/ltr/selector') 33 | selector_model_name = 'selector_bcm' 34 | selector_path = os.path.join(selector_root, selector_model_name) 35 | 36 | '''Dataset''' 37 | if dataset_name_ == 'GOT10K': 38 | dataset_dir_ = os.path.join(dataset_root_, dataset_name_,'train') 39 | else: 40 | dataset_dir_ = os.path.join(dataset_root_,dataset_name_) -------------------------------------------------------------------------------- /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) -------------------------------------------------------------------------------- /ltr/models/head/bbox.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | 3 | def conv(in_planes, out_planes, kernel_size=3, stride=1, padding=1, dilation=1): 4 | return nn.Sequential( 5 | nn.Conv2d(in_planes, out_planes, kernel_size=kernel_size, stride=stride, 6 | padding=padding, dilation=dilation, bias=True), 7 | nn.BatchNorm2d(out_planes), 8 | nn.ReLU(inplace=True)) 9 | 10 | class BBox_Predictor(nn.Module): 11 | """ BBox Predictor module""" 12 | def __init__(self, inplanes=64): 13 | super(BBox_Predictor, self).__init__() 14 | self.conv1 = conv(inplanes,inplanes,kernel_size=1,padding=0) 15 | self.conv2 = conv(inplanes,inplanes,kernel_size=1,padding=0) 16 | self.avgpool = nn.AdaptiveAvgPool2d((1, 1)) 17 | self.fc = nn.Sequential(nn.Linear(inplanes, 4),nn.ReLU()) 18 | 19 | def forward(self, x): 20 | """ Forward pass with input x. """ 21 | x = self.conv1(x) 22 | x = self.conv2(x) 23 | x = self.avgpool(x) 24 | x = x.view(x.size(0),-1) 25 | x = self.fc(x) 26 | return x 27 | class BBox_Predictor_anchor(nn.Module): 28 | """ BBox Predictor module""" 29 | def __init__(self, inplanes=64): 30 | super(BBox_Predictor_anchor, self).__init__() 31 | self.conv1 = conv(inplanes,inplanes,kernel_size=1,padding=0) 32 | self.conv2 = conv(inplanes,inplanes,kernel_size=1,padding=0) 33 | self.avgpool = nn.AdaptiveAvgPool2d((1, 1)) 34 | '''NO relu activation''' 35 | self.fc = nn.Linear(inplanes, 4) 36 | 37 | def forward(self, x): 38 | """ Forward pass with input x. """ 39 | x = self.conv1(x) 40 | x = self.conv2(x) 41 | x = self.avgpool(x) 42 | x = x.view(x.size(0),-1) 43 | x = self.fc(x) 44 | return x -------------------------------------------------------------------------------- /ltr/models/lwl/loss_residual_modules.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | import math 4 | import ltr.models.layers.filter as filter_layer 5 | from pytracking import TensorList 6 | 7 | 8 | class LWTLResidual(nn.Module): 9 | """ Computes the residuals W(y_t)*(T_tau(x_t) - E(y_t) and lambda*tau in the few-shot learner loss (3) in the 10 | paper """ 11 | def __init__(self, init_filter_reg=1e-2, filter_dilation_factors=None): 12 | super().__init__() 13 | self.filter_reg = nn.Parameter(init_filter_reg * torch.ones(1)) 14 | self.filter_dilation_factors = filter_dilation_factors 15 | 16 | def forward(self, meta_parameter: TensorList, feat, label, sample_weight=None): 17 | # Assumes multiple filters, i.e. (sequences, filters, feat_dim, fH, fW) 18 | filter = meta_parameter[0] 19 | 20 | num_images = feat.shape[0] 21 | num_sequences = feat.shape[1] if feat.dim() == 5 else 1 22 | 23 | # Compute scores 24 | scores = filter_layer.apply_filter(feat, filter, dilation_factors=self.filter_dilation_factors) 25 | 26 | if sample_weight is None: 27 | sample_weight = math.sqrt(1.0 / num_images) 28 | elif isinstance(sample_weight, torch.Tensor): 29 | if sample_weight.numel() == scores.numel(): 30 | sample_weight = sample_weight.view(scores.shape) 31 | elif sample_weight.dim() == 1: 32 | sample_weight = sample_weight.view(-1, 1, 1, 1, 1) 33 | 34 | label = label.view(scores.shape) 35 | 36 | data_residual = sample_weight * (scores - label) 37 | 38 | # Compute regularization residual. Put batch in second dimension 39 | reg_residual = self.filter_reg*filter.view(1, num_sequences, -1) 40 | 41 | return TensorList([data_residual, reg_residual]) 42 | -------------------------------------------------------------------------------- /ltr/external/PreciseRoIPooling/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | .vim-template* 7 | 8 | # C extensions 9 | *.so 10 | 11 | # Distribution / packaging 12 | .Python 13 | build/ 14 | develop-eggs/ 15 | dist/ 16 | downloads/ 17 | eggs/ 18 | .eggs/ 19 | lib/ 20 | lib64/ 21 | parts/ 22 | sdist/ 23 | var/ 24 | wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | .hypothesis/ 50 | .pytest_cache/ 51 | 52 | # Translations 53 | *.mo 54 | *.pot 55 | 56 | # Django stuff: 57 | *.log 58 | local_settings.py 59 | db.sqlite3 60 | 61 | # Flask stuff: 62 | instance/ 63 | .webassets-cache 64 | 65 | # Scrapy stuff: 66 | .scrapy 67 | 68 | # Sphinx documentation 69 | docs/_build/ 70 | 71 | # PyBuilder 72 | target/ 73 | 74 | # Jupyter Notebook 75 | .ipynb_checkpoints 76 | 77 | # pyenv 78 | .python-version 79 | 80 | # celery beat schedule file 81 | celerybeat-schedule 82 | 83 | # SageMath parsed files 84 | *.sage.py 85 | 86 | # Environments 87 | .env 88 | .venv 89 | env/ 90 | venv/ 91 | ENV/ 92 | env.bak/ 93 | venv.bak/ 94 | 95 | # Spyder project settings 96 | .spyderproject 97 | .spyproject 98 | 99 | # Rope project settings 100 | .ropeproject 101 | 102 | # mkdocs documentation 103 | /site 104 | 105 | # mypy 106 | .mypy_cache/ 107 | -------------------------------------------------------------------------------- /external/pysot/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | 106 | testing_dataset/* 107 | experiments 108 | 109 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /ltr/external/PreciseRoIPooling/src/prroi_pooling_gpu_impl.cuh: -------------------------------------------------------------------------------- 1 | /* 2 | * File : prroi_pooling_gpu_impl.cuh 3 | * Author : Tete Xiao, Jiayuan Mao 4 | * Email : jasonhsiao97@gmail.com 5 | * 6 | * Distributed under terms of the MIT license. 7 | * Copyright (c) 2017 Megvii Technology Limited. 8 | */ 9 | 10 | #ifndef PRROI_POOLING_GPU_IMPL_CUH 11 | #define PRROI_POOLING_GPU_IMPL_CUH 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | #define F_DEVPTR_IN const float * 18 | #define F_DEVPTR_OUT float * 19 | 20 | void PrRoIPoolingForwardGpu( 21 | cudaStream_t stream, 22 | F_DEVPTR_IN bottom_data, 23 | F_DEVPTR_IN bottom_rois, 24 | F_DEVPTR_OUT top_data, 25 | const int channels_, const int height_, const int width_, 26 | const int pooled_height_, const int pooled_width_, 27 | const float spatial_scale_, 28 | const int top_count); 29 | 30 | void PrRoIPoolingBackwardGpu( 31 | cudaStream_t stream, 32 | F_DEVPTR_IN bottom_data, 33 | F_DEVPTR_IN bottom_rois, 34 | F_DEVPTR_IN top_data, 35 | F_DEVPTR_IN top_diff, 36 | F_DEVPTR_OUT bottom_diff, 37 | const int channels_, const int height_, const int width_, 38 | const int pooled_height_, const int pooled_width_, 39 | const float spatial_scale_, 40 | const int top_count, const int bottom_count); 41 | 42 | void PrRoIPoolingCoorBackwardGpu( 43 | cudaStream_t stream, 44 | F_DEVPTR_IN bottom_data, 45 | F_DEVPTR_IN bottom_rois, 46 | F_DEVPTR_IN top_data, 47 | F_DEVPTR_IN top_diff, 48 | F_DEVPTR_OUT bottom_diff, 49 | const int channels_, const int height_, const int width_, 50 | const int pooled_height_, const int pooled_width_, 51 | const float spatial_scale_, 52 | const int top_count, const int bottom_count); 53 | 54 | #ifdef __cplusplus 55 | } /* !extern "C" */ 56 | #endif 57 | 58 | #endif /* !PRROI_POOLING_GPU_IMPL_CUH */ 59 | 60 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /ltr/external/PreciseRoIPooling/pytorch/prroi_pool/src/prroi_pooling_gpu_impl.cuh: -------------------------------------------------------------------------------- 1 | /* 2 | * File : prroi_pooling_gpu_impl.cuh 3 | * Author : Tete Xiao, Jiayuan Mao 4 | * Email : jasonhsiao97@gmail.com 5 | * 6 | * Distributed under terms of the MIT license. 7 | * Copyright (c) 2017 Megvii Technology Limited. 8 | */ 9 | 10 | #ifndef PRROI_POOLING_GPU_IMPL_CUH 11 | #define PRROI_POOLING_GPU_IMPL_CUH 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | #define F_DEVPTR_IN const float * 18 | #define F_DEVPTR_OUT float * 19 | 20 | void PrRoIPoolingForwardGpu( 21 | cudaStream_t stream, 22 | F_DEVPTR_IN bottom_data, 23 | F_DEVPTR_IN bottom_rois, 24 | F_DEVPTR_OUT top_data, 25 | const int channels_, const int height_, const int width_, 26 | const int pooled_height_, const int pooled_width_, 27 | const float spatial_scale_, 28 | const int top_count); 29 | 30 | void PrRoIPoolingBackwardGpu( 31 | cudaStream_t stream, 32 | F_DEVPTR_IN bottom_data, 33 | F_DEVPTR_IN bottom_rois, 34 | F_DEVPTR_IN top_data, 35 | F_DEVPTR_IN top_diff, 36 | F_DEVPTR_OUT bottom_diff, 37 | const int channels_, const int height_, const int width_, 38 | const int pooled_height_, const int pooled_width_, 39 | const float spatial_scale_, 40 | const int top_count, const int bottom_count); 41 | 42 | void PrRoIPoolingCoorBackwardGpu( 43 | cudaStream_t stream, 44 | F_DEVPTR_IN bottom_data, 45 | F_DEVPTR_IN bottom_rois, 46 | F_DEVPTR_IN top_data, 47 | F_DEVPTR_IN top_diff, 48 | F_DEVPTR_OUT bottom_diff, 49 | const int channels_, const int height_, const int width_, 50 | const int pooled_height_, const int pooled_width_, 51 | const float spatial_scale_, 52 | const int top_count, const int bottom_count); 53 | 54 | #ifdef __cplusplus 55 | } /* !extern "C" */ 56 | #endif 57 | 58 | #endif /* !PRROI_POOLING_GPU_IMPL_CUH */ 59 | 60 | -------------------------------------------------------------------------------- /external/pysot/toolkit/visualization/draw_eao.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import numpy as np 3 | import pickle 4 | 5 | from matplotlib import rc 6 | from .draw_utils import COLOR, MARKER_STYLE 7 | 8 | rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']}) 9 | rc('text', usetex=True) 10 | 11 | def draw_eao(result): 12 | fig = plt.figure() 13 | ax = fig.add_subplot(111, projection='polar') 14 | angles = np.linspace(0, 2*np.pi, 8, endpoint=True) 15 | 16 | attr2value = [] 17 | for i, (tracker_name, ret) in enumerate(result.items()): 18 | value = list(ret.values()) 19 | attr2value.append(value) 20 | value.append(value[0]) 21 | attr2value = np.array(attr2value) 22 | max_value = np.max(attr2value, axis=0) 23 | min_value = np.min(attr2value, axis=0) 24 | for i, (tracker_name, ret) in enumerate(result.items()): 25 | value = list(ret.values()) 26 | value.append(value[0]) 27 | value = np.array(value) 28 | value *= (1 / max_value) 29 | plt.plot(angles, value, linestyle='-', color=COLOR[i], marker=MARKER_STYLE[i], 30 | label=tracker_name, linewidth=1.5, markersize=6) 31 | 32 | attrs = ["Overall", "Camera motion", 33 | "Illumination change","Motion Change", 34 | "Size change","Occlusion", 35 | "Unassigned"] 36 | attr_value = [] 37 | for attr, maxv, minv in zip(attrs, max_value, min_value): 38 | attr_value.append(attr + "\n({:.3f},{:.3f})".format(minv, maxv)) 39 | ax.set_thetagrids(angles[:-1] * 180/np.pi, attr_value) 40 | ax.spines['polar'].set_visible(False) 41 | ax.legend(loc='upper center', bbox_to_anchor=(0.5,-0.07), frameon=False, ncol=5) 42 | ax.grid(b=False) 43 | ax.set_ylim(0, 1.18) 44 | ax.set_yticks([]) 45 | plt.show() 46 | 47 | if __name__ == '__main__': 48 | result = pickle.load(open("../../result.pkl", 'rb')) 49 | draw_eao(result) 50 | -------------------------------------------------------------------------------- /pytracking/refine_modules/utils.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | import cv2 4 | 5 | 6 | def add_frame_mask(frame, mask, threshold=0.5): 7 | mask_new = (mask > threshold) * 255 # (H,W) 8 | frame_new = frame.copy().astype(np.float) 9 | frame_new[..., 1] += 0.3 * mask_new 10 | frame_new = frame_new.clip(0, 255).astype(np.uint8) 11 | return frame_new 12 | 13 | 14 | def add_frame_bbox(frame, refined_box, color): 15 | x1, y1, w, h = refined_box.tolist() 16 | cv2.rectangle(frame, (int(x1), int(y1)), (int(x1 + w), int(y1 + h)), color, 2) 17 | return frame 18 | 19 | 20 | def mask2bbox(mask, ori_bbox, MASK_THRESHOLD=0.5): 21 | target_mask = (mask > MASK_THRESHOLD) 22 | target_mask = target_mask.astype(np.uint8) 23 | if cv2.__version__[-5] == '4': 24 | contours, _ = cv2.findContours(target_mask, 25 | cv2.RETR_EXTERNAL, 26 | cv2.CHAIN_APPROX_NONE) 27 | else: 28 | _, contours, _ = cv2.findContours(target_mask, 29 | cv2.RETR_EXTERNAL, 30 | cv2.CHAIN_APPROX_NONE) 31 | cnt_area = [cv2.contourArea(cnt) for cnt in contours] 32 | if len(contours) != 0 and np.max(cnt_area) > 100: 33 | contour = contours[np.argmax(cnt_area)] 34 | polygon = contour.reshape(-1, 2) 35 | prbox = cv2.boundingRect(polygon) 36 | else: # empty mask 37 | prbox = ori_bbox 38 | return np.array(prbox).astype(np.float) 39 | 40 | 41 | def delta2bbox(delta): 42 | bbox_cxcywh = delta.clone() 43 | '''based on (128,128) center region''' 44 | bbox_cxcywh[:, :2] = 128.0 + delta[:, :2] * 128.0 # center offset 45 | bbox_cxcywh[:, 2:] = 128.0 * torch.exp(delta[:, 2:]) # wh revise 46 | bbox_xywh = bbox_cxcywh.clone() 47 | bbox_xywh[:, :2] = bbox_cxcywh[:, :2] - 0.5 * bbox_cxcywh[:, 2:] 48 | return bbox_xywh 49 | -------------------------------------------------------------------------------- /external/pysot/README.md: -------------------------------------------------------------------------------- 1 | # PySOT 2 | 3 | We bring the pysot code into our project for using SiamRPN++ as a base tracker. 4 | The codes are mostly not modified. 5 | 6 | ## Installation 7 | 8 | Please find installation instructions for PyTorch and PySOT in [`INSTALL.md`](INSTALL.md). 9 | 10 | ## References 11 | 12 | - [Fast Online Object Tracking and Segmentation: A Unifying Approach](https://arxiv.org/abs/1812.05050). 13 | Qiang Wang, Li Zhang, Luca Bertinetto, Weiming Hu, Philip H.S. Torr. 14 | IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2019. 15 | 16 | - [SiamRPN++: Evolution of Siamese Visual Tracking with Very Deep Networks](https://arxiv.org/abs/1812.11703). 17 | Bo Li, Wei Wu, Qiang Wang, Fangyi Zhang, Junliang Xing, Junjie Yan. 18 | IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2019. 19 | 20 | - [Distractor-aware Siamese Networks for Visual Object Tracking](https://arxiv.org/abs/1808.06048). 21 | Zheng Zhu, Qiang Wang, Bo Li, Wu Wei, Junjie Yan, Weiming Hu. 22 | The European Conference on Computer Vision (ECCV), 2018. 23 | 24 | - [High Performance Visual Tracking with Siamese Region Proposal Network](http://openaccess.thecvf.com/content_cvpr_2018/html/Li_High_Performance_Visual_CVPR_2018_paper.html). 25 | Bo Li, Wei Wu, Zheng Zhu, Junjie Yan, Xiaolin Hu. 26 | IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2018. 27 | 28 | - [Fully-Convolutional Siamese Networks for Object Tracking](https://arxiv.org/abs/1606.09549). 29 | Luca Bertinetto, Jack Valmadre, João F. Henriques, Andrea Vedaldi, Philip H. S. Torr. 30 | The European Conference on Computer Vision (ECCV) Workshops, 2016. 31 | 32 | ## Contributors 33 | 34 | - [Fangyi Zhang](https://github.com/StrangerZhang) 35 | - [Qiang Wang](http://www.robots.ox.ac.uk/~qwang/) 36 | - [Bo Li](http://bo-li.info/) 37 | 38 | ## License 39 | 40 | PySOT is released under the [Apache 2.0 license](https://github.com/STVIR/pysot/blob/master/LICENSE). 41 | -------------------------------------------------------------------------------- /external/pysot/pysot/utils/misc.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) SenseTime. All Rights Reserved. 2 | 3 | from __future__ import absolute_import 4 | from __future__ import division 5 | from __future__ import print_function 6 | from __future__ import unicode_literals 7 | 8 | import os 9 | 10 | from colorama import Fore, Style 11 | 12 | 13 | __all__ = ['commit', 'describe'] 14 | 15 | 16 | def _exec(cmd): 17 | f = os.popen(cmd, 'r', 1) 18 | return f.read().strip() 19 | 20 | 21 | def _bold(s): 22 | return "\033[1m%s\033[0m" % s 23 | 24 | 25 | def _color(s): 26 | return f'{Fore.RED}{s}{Style.RESET_ALL}' 27 | 28 | 29 | def _describe(model, lines=None, spaces=0): 30 | head = " " * spaces 31 | for name, p in model.named_parameters(): 32 | if '.' in name: 33 | continue 34 | if p.requires_grad: 35 | name = _color(name) 36 | line = "{head}- {name}".format(head=head, name=name) 37 | lines.append(line) 38 | 39 | for name, m in model.named_children(): 40 | space_num = len(name) + spaces + 1 41 | if m.training: 42 | name = _color(name) 43 | line = "{head}.{name} ({type})".format( 44 | head=head, 45 | name=name, 46 | type=m.__class__.__name__) 47 | lines.append(line) 48 | _describe(m, lines, space_num) 49 | 50 | 51 | def commit(): 52 | root = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../')) 53 | cmd = "cd {}; git log | head -n1 | awk '{{print $2}}'".format(root) 54 | commit = _exec(cmd) 55 | cmd = "cd {}; git log --oneline | head -n1".format(root) 56 | commit_log = _exec(cmd) 57 | return "commit : {}\n log : {}".format(commit, commit_log) 58 | 59 | 60 | def describe(net, name=None): 61 | num = 0 62 | lines = [] 63 | if name is not None: 64 | lines.append(name) 65 | num = len(name) 66 | _describe(net, lines, num) 67 | return "\n".join(lines) 68 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /arena/VOT2020/run_pytracking.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import cv2 3 | 4 | import torch 5 | from arena.VOT2020.utils import make_full_size, VOT 6 | from arena.VOT2020.trackers.pytracking_ar import BaseTracker 7 | 8 | 9 | def build_tracker(tracker_name, para_name, threshold): 10 | tracker = BaseTracker(tracker_name=tracker_name, para_name=para_name, threshold=threshold) 11 | return tracker 12 | 13 | 14 | def run_vot_exp(tracker_name, para_name, threshold): 15 | tracker = build_tracker(tracker_name, para_name, threshold) 16 | 17 | handle = VOT("mask") 18 | selection = handle.region() 19 | imagefile = handle.frame() 20 | 21 | image = cv2.cvtColor(cv2.imread(imagefile), cv2.COLOR_BGR2RGB) # Right 22 | # mask given by the toolkit ends with the target (zero-padding to the right and down is needed) 23 | mask = make_full_size(selection, (image.shape[1], image.shape[0])) 24 | tracker.initialize(image, mask) 25 | 26 | while True: 27 | imagefile = handle.frame() 28 | if not imagefile: 29 | break 30 | image = cv2.cvtColor(cv2.imread(imagefile), cv2.COLOR_BGR2RGB) # Right 31 | b1, m = tracker.track(image) 32 | handle.report(m) 33 | 34 | 35 | def parse_args(): 36 | from arena.VOT2020.common_path import _tracker_name, _tracker_param, _mask_thres 37 | parser = argparse.ArgumentParser() 38 | parser.add_argument("--tracker_name", default=_tracker_name, help="tracker_name options: dimp|atom|eco") 39 | parser.add_argument("--tracker_param", default=_tracker_param, 40 | help="tracker_param options: super_dimp;dimp50|default|default") 41 | parser.add_argument("--mask_thres", type=float, default=_mask_thres, 42 | help="tracker_param options: super_dimp;dimp50|default|default") 43 | args = parser.parse_args() 44 | return args 45 | 46 | 47 | args = parse_args() 48 | torch.set_num_threads(1) 49 | print(args) 50 | run_vot_exp(args.tracker_name, args.tracker_param, args.mask_thres) 51 | -------------------------------------------------------------------------------- /arena/VOT2020/run_pytracking_alphaseg.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import cv2 3 | 4 | import torch 5 | from arena.VOT2020.utils import make_full_size, VOT 6 | from arena.VOT2020.trackers.pytracking_ar import TrackerAR 7 | 8 | 9 | def build_tracker(tracker_name, para_name, threshold): 10 | tracker = TrackerAR(tracker_name=tracker_name, para_name=para_name, threshold=threshold) 11 | return tracker 12 | 13 | 14 | def run_vot_exp(tracker_name, para_name, threshold): 15 | tracker = build_tracker(tracker_name, para_name, threshold) 16 | 17 | handle = VOT("mask") 18 | selection = handle.region() 19 | imagefile = handle.frame() 20 | 21 | image = cv2.cvtColor(cv2.imread(imagefile), cv2.COLOR_BGR2RGB) # Right 22 | # mask given by the toolkit ends with the target (zero-padding to the right and down is needed) 23 | mask = make_full_size(selection, (image.shape[1], image.shape[0])) 24 | tracker.initialize(image, mask) 25 | 26 | while True: 27 | imagefile = handle.frame() 28 | if not imagefile: 29 | break 30 | image = cv2.cvtColor(cv2.imread(imagefile), cv2.COLOR_BGR2RGB) # Right 31 | b1, m = tracker.track(image) 32 | handle.report(m) 33 | 34 | 35 | def parse_args(): 36 | from arena.VOT2020.common_path import _tracker_name, _tracker_param, _mask_thres 37 | parser = argparse.ArgumentParser() 38 | parser.add_argument("--tracker_name", default=_tracker_name, help="tracker_name options: dimp|atom|eco") 39 | parser.add_argument("--tracker_param", default=_tracker_param, 40 | help="tracker_param options: super_dimp;dimp50|default|default") 41 | parser.add_argument("--mask_thres", type=float, default=_mask_thres, 42 | help="tracker_param options: super_dimp;dimp50|default|default") 43 | args = parser.parse_args() 44 | return args 45 | 46 | 47 | args = parse_args() 48 | torch.set_num_threads(1) 49 | print(args) 50 | run_vot_exp(args.tracker_name, args.tracker_param, args.mask_thres) 51 | -------------------------------------------------------------------------------- /external/pysot/pysot/models/neck/neck.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) SenseTime. All Rights Reserved. 2 | 3 | from __future__ import absolute_import 4 | from __future__ import division 5 | from __future__ import print_function 6 | from __future__ import unicode_literals 7 | 8 | import torch.nn as nn 9 | 10 | 11 | class AdjustLayer(nn.Module): 12 | def __init__(self, in_channels, out_channels, center_size=7): 13 | super(AdjustLayer, self).__init__() 14 | self.downsample = nn.Sequential( 15 | nn.Conv2d(in_channels, out_channels, kernel_size=1, bias=False), 16 | nn.BatchNorm2d(out_channels), 17 | ) 18 | self.center_size = center_size 19 | 20 | def forward(self, x): 21 | x = self.downsample(x) 22 | if x.size(3) < 20: 23 | l = (x.size(3) - self.center_size) // 2 24 | r = l + self.center_size 25 | x = x[:, :, l:r, l:r] 26 | return x 27 | 28 | 29 | class AdjustAllLayer(nn.Module): 30 | def __init__(self, in_channels, out_channels, center_size=7): 31 | super(AdjustAllLayer, self).__init__() 32 | self.num = len(out_channels) 33 | if self.num == 1: 34 | self.downsample = AdjustLayer(in_channels[0], 35 | out_channels[0], 36 | center_size) 37 | else: 38 | for i in range(self.num): 39 | self.add_module('downsample'+str(i+2), 40 | AdjustLayer(in_channels[i], 41 | out_channels[i], 42 | center_size)) 43 | 44 | def forward(self, features): 45 | if self.num == 1: 46 | return self.downsample(features) 47 | else: 48 | out = [] 49 | for i in range(self.num): 50 | adj_layer = getattr(self, 'downsample'+str(i+2)) 51 | out.append(adj_layer(features[i])) 52 | return out 53 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /ltr/actors/ar_actors/SEc.py: -------------------------------------------------------------------------------- 1 | from ltr.actors import BaseActor 2 | import torch 3 | 4 | 5 | class SEc_Actor(BaseActor): 6 | """ Actor for training the our scale estimation module""" 7 | 8 | def delta2xyxy(self, delta): 9 | '''delta的size是(batch,4)''' 10 | bbox_cxcywh = delta.clone() 11 | '''以位于中心的大小为(128,128)的框为基准''' 12 | bbox_cxcywh[:, :2] = 128.0 + delta[:, :2] * 128.0 # 中心偏移 13 | bbox_cxcywh[:, 2:] = 128.0 * torch.exp(delta[:, 2:]) # 宽高修正 14 | '''调整为(x1,y1,x2,y2)格式''' 15 | bbox_xyxy = bbox_cxcywh.clone() 16 | bbox_xyxy[:, :2] = bbox_cxcywh[:, :2] - 0.5 * bbox_cxcywh[:, 2:] 17 | bbox_xyxy[:, 2:] = bbox_cxcywh[:, :2] + 0.5 * bbox_cxcywh[:, 2:] 18 | return bbox_xyxy 19 | 20 | def __call__(self, data): 21 | """ 22 | args: 23 | data - The input data, should contain the fields 'train_images', 'test_images', 'train_anno', 24 | 'test_proposals' and 'proposal_iou'. 25 | 26 | returns: 27 | loss - the training loss 28 | states - dict containing detailed losses 29 | """ 30 | # Run network to obtain bbox prediction for each test image' 31 | '''get prediction''' 32 | pred_dict = self.net(data['train_images'], data['test_images'], data['train_anno']) 33 | corner_pred = pred_dict['corner'] # (batch,4) 34 | 35 | '''get groundtruth''' 36 | bbox_gt = data['test_anno'].squeeze(0) # 测试帧的真值框在裁剪出的搜索区域上的坐标(x1,y1,w,h) 37 | 38 | bbox_gt_xyxy = bbox_gt.clone() 39 | bbox_gt_xyxy[:, 2:] += bbox_gt_xyxy[:, :2] # (x1,y1,x2,y2)格式 40 | 41 | '''get loss function''' 42 | corner_loss_F = self.objective['corner'] 43 | 44 | '''Compute loss for corner''' 45 | loss_corner = corner_loss_F(corner_pred, bbox_gt_xyxy) 46 | loss = loss_corner 47 | 48 | stats = { 49 | 'Loss/total': loss.item(), 50 | 'loss_corner': loss_corner.item(), 51 | } 52 | 53 | return loss, stats 54 | -------------------------------------------------------------------------------- /arena/GOT10k/toolkit/got10k/experiments/trackingnet.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import os 4 | import numpy as np 5 | 6 | from .otb import ExperimentOTB 7 | from ..datasets import TrackingNet 8 | from ..utils.metrics import rect_iou, center_error 9 | 10 | 11 | class ExperimentTrackingNet(ExperimentOTB): 12 | r"""Experiment pipeline and evaluation toolkit for TrackingNet dataset. 13 | Only the TEST subset part implemented. 14 | 15 | Args: 16 | root_dir (string): Root directory of LaSOT dataset. 17 | subset (string, optional): Specify ``train`` or ``test`` 18 | subset of LaSOT. Default is ``test``. 19 | return_meta (bool, optional): whether to fetch meta info 20 | (occlusion or out-of-view). Default is ``False``. 21 | result_dir (string, optional): Directory for storing tracking 22 | results. Default is ``./results``. 23 | report_dir (string, optional): Directory for storing performance 24 | evaluation results. Default is ``./reports``. 25 | """ 26 | def __init__(self, root_dir, subset='test', return_meta=False, 27 | result_dir='results', report_dir='reports'): 28 | assert subset.upper() in ['TRAIN', 'TEST'] 29 | self.dataset = TrackingNet(root_dir, subset, return_meta=return_meta) 30 | self.result_dir = result_dir 31 | self.report_dir = report_dir 32 | 33 | # as nbins_iou increases, the success score 34 | # converges to the average overlap (AO) 35 | self.nbins_iou = 21 36 | self.nbins_ce = 51 37 | 38 | # def _calc_metrics(self, boxes, anno): 39 | # valid = ~np.any(np.isnan(anno), axis=1) 40 | # if len(valid) == 0: 41 | # print('Warning: no valid annotations') 42 | # return None, None 43 | # else: 44 | # ious = rect_iou(boxes[valid, :], anno[valid, :]) 45 | # center_errors = center_error( 46 | # boxes[valid, :], anno[valid, :]) 47 | # return ious, center_errors 48 | -------------------------------------------------------------------------------- /arena/VOT2020/vot/region/io.py: -------------------------------------------------------------------------------- 1 | import math 2 | from typing import Union, TextIO 3 | 4 | from vot.region import Special 5 | from vot.region.shapes import Rectangle, Polygon, Mask 6 | from vot.region.utils import create_mask_from_string 7 | 8 | def parse(string): 9 | """ 10 | parse string to the appropriate region format and return region object 11 | """ 12 | if string[0] == 'm': 13 | # input is a mask - decode it 14 | m_, offset_ = create_mask_from_string(string[1:].split(',')) 15 | return Mask(m_, offset=offset_) 16 | else: 17 | # input is not a mask - check if special, rectangle or polygon 18 | tokens = [float(t) for t in string.split(',')] 19 | if len(tokens) == 1: 20 | return Special(tokens[0]) 21 | if len(tokens) == 4: 22 | if any([math.isnan(el) for el in tokens]): 23 | return Special(0) 24 | else: 25 | return Rectangle(tokens[0], tokens[1], tokens[2], tokens[3]) 26 | elif len(tokens) % 2 == 0 and len(tokens) > 4: 27 | if any([math.isnan(el) for el in tokens]): 28 | return Special(0) 29 | else: 30 | return Polygon([(x_, y_) for x_, y_ in zip(tokens[::2], tokens[1::2])]) 31 | print('Unknown region format.') 32 | return None 33 | 34 | def read_file(fp: Union[str, TextIO]): 35 | if isinstance(fp, str): 36 | with open(fp) as file: 37 | lines = file.readlines() 38 | else: 39 | lines = fp.readlines() 40 | 41 | regions = [0] * len(lines) 42 | # iterate over all lines in the file 43 | for i, line in enumerate(lines): 44 | regions[i] = parse(line.strip()) 45 | return regions 46 | 47 | def write_file(fp: Union[str, TextIO], data): 48 | """ 49 | data is a list where each element is a region 50 | """ 51 | if isinstance(fp, str): 52 | with open(fp, 'w') as file: 53 | for region in data: 54 | file.write('%s\n' % str(region)) 55 | else: 56 | for region in data: 57 | fp.write('%s\n' % str(region)) 58 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | 'pretrained_networks': 'self.workspace_dir + \'/pretrained_networks/\'', 14 | 'lasot_dir': empty_str, 15 | 'got10k_dir': empty_str, 16 | 'trackingnet_dir': empty_str, 17 | 'coco_dir': empty_str, 18 | 'lvis_dir': empty_str, 19 | 'sbd_dir': empty_str, 20 | 'imagenet_dir': empty_str, 21 | 'imagenetdet_dir': empty_str, 22 | 'ecssd_dir': empty_str, 23 | 'hkuis_dir': empty_str, 24 | 'msra10k_dir': empty_str, 25 | 'davis_dir': empty_str, 26 | 'youtubevos_dir': empty_str}) 27 | 28 | comment = {'workspace_dir': 'Base directory for saving network checkpoints.', 29 | 'tensorboard_dir': 'Directory for tensorboard files.'} 30 | 31 | with open(path, 'w') as f: 32 | f.write('class EnvironmentSettings:\n') 33 | f.write(' def __init__(self):\n') 34 | 35 | for attr, attr_val in default_settings.items(): 36 | comment_str = None 37 | if attr in comment: 38 | comment_str = comment[attr] 39 | if comment_str is None: 40 | f.write(' self.{} = {}\n'.format(attr, attr_val)) 41 | else: 42 | f.write(' self.{} = {} # {}\n'.format(attr, attr_val, comment_str)) 43 | 44 | 45 | def env_settings(): 46 | env_module_name = 'ltr.admin.local' 47 | try: 48 | env_module = importlib.import_module(env_module_name) 49 | return env_module.EnvironmentSettings() 50 | except: 51 | env_file = os.path.join(os.path.dirname(__file__), 'local.py') 52 | 53 | create_default_local_file() 54 | 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)) 55 | -------------------------------------------------------------------------------- /arena/VOT2020/utils/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 61 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /arena/GOT10k/rtmdnet_RF.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) SenseTime. All Rights Reserved. 2 | 3 | from __future__ import absolute_import 4 | from __future__ import division 5 | from __future__ import print_function 6 | from __future__ import unicode_literals 7 | 8 | import numpy as np 9 | from external.pysot.pysot.utils.bbox import get_axis_aligned_bbox 10 | 11 | from external.RT_MDNet.RT_MDNet import RT_MDNet 12 | from pytracking.refine_modules.refine_module import RefineModule 13 | 14 | from got10k.trackers import Tracker as GOT10kTracker 15 | from external.RT_MDNet.MDNet_utils import bbox_clip 16 | from arena.GOT10k.common_path import * 17 | 18 | 19 | class RTMDNet_RF(GOT10kTracker): 20 | def __init__(self, rf_model_code, enable_rf=True): 21 | model_name = 'RTMDNet' + '{}-{}'.format(RF_type.format(rf_model_code), selector_path) 22 | if not enable_rf: 23 | model_name = model_name.replace(RF_type.format(rf_model_code), '') 24 | super(RTMDNet_RF, self).__init__(name=model_name) 25 | self.enable_rf = enable_rf 26 | 27 | self.tracker = RT_MDNet() 28 | if self.enable_rf: 29 | self.RF_module = RefineModule(refine_path.format(rf_model_code), selector_path, 30 | search_factor=sr, input_sz=input_sz) 31 | 32 | def init(self, image, box): 33 | image = np.array(image) 34 | self.im_H, self.im_W, _ = image.shape 35 | cx, cy, w, h = get_axis_aligned_bbox(np.array(box)) 36 | gt_bbox_ = [cx - (w - 1) / 2, cy - (h - 1) / 2, w, h] 37 | 38 | # initialize tracker 39 | self.tracker.initialize_seq(image, np.array(gt_bbox_)) 40 | # initilize refine module 41 | if self.enable_rf: 42 | self.RF_module.initialize(image, np.array(gt_bbox_)) 43 | self.box = box 44 | 45 | def update(self, image): 46 | image = np.array(image) 47 | pred_bbox = self.tracker.track(image) 48 | 49 | if self.enable_rf: 50 | # refine tracking results 51 | pred_bbox = self.RF_module.refine(image, np.array(pred_bbox)) 52 | pred_bbox = bbox_clip(pred_bbox, (self.im_H, self.im_W)) # boundary and size limit 53 | '''update state''' 54 | self.tracker.target_bbox = pred_bbox.copy() 55 | return pred_bbox 56 | -------------------------------------------------------------------------------- /external/RT_MDNet/modules/bbreg.py: -------------------------------------------------------------------------------- 1 | from sklearn.linear_model import Ridge 2 | 3 | from external.RT_MDNet.modules.utils import * 4 | 5 | 6 | class BBRegressor(): 7 | def __init__(self, img_size, alpha=1000, overlap=[0.6, 1], scale=[1, 2]): 8 | self.img_size = img_size 9 | self.alpha = alpha 10 | self.overlap_range = overlap 11 | self.scale_range = scale 12 | self.model = Ridge(alpha=self.alpha) 13 | 14 | def train(self, X, bbox, gt): 15 | X = X.cpu().numpy() 16 | bbox = np.copy(bbox) 17 | gt = np.copy(gt) 18 | 19 | if gt.ndim == 1: 20 | gt = gt[None, :] 21 | 22 | r = overlap_ratio(bbox, gt) 23 | s = np.prod(bbox[:, 2:], axis=1) / np.prod(gt[0, 2:]) 24 | idx = (r >= self.overlap_range[0]) * (r <= self.overlap_range[1]) * \ 25 | (s >= self.scale_range[0]) * (s <= self.scale_range[1]) 26 | 27 | X = X[idx] 28 | bbox = bbox[idx] 29 | 30 | Y = self.get_examples(bbox, gt) 31 | 32 | self.model.fit(X, Y) 33 | 34 | def predict(self, X, bbox): 35 | X = X.cpu().numpy() 36 | bbox_ = np.copy(bbox) 37 | 38 | Y = self.model.predict(X) 39 | 40 | bbox_[:, :2] = bbox_[:, :2] + bbox_[:, 2:] / 2 41 | bbox_[:, :2] = Y[:, :2] * bbox_[:, 2:] + bbox_[:, :2] 42 | bbox_[:, 2:] = np.exp(Y[:, 2:]) * bbox_[:, 2:] 43 | bbox_[:, :2] = bbox_[:, :2] - bbox_[:, 2:] / 2 44 | 45 | r = overlap_ratio(bbox, bbox_) 46 | s = np.prod(bbox[:, 2:], axis=1) / np.prod(bbox_[:, 2:], axis=1) 47 | idx = (r >= self.overlap_range[0]) * (r <= self.overlap_range[1]) * \ 48 | (s >= self.scale_range[0]) * (s <= self.scale_range[1]) 49 | idx = np.logical_not(idx) 50 | bbox_[idx] = bbox[idx] 51 | 52 | bbox_[:, :2] = np.maximum(bbox_[:, :2], 0) 53 | bbox_[:, 2:] = np.minimum(bbox_[:, 2:], self.img_size - bbox[:, :2]) 54 | 55 | return bbox_ 56 | 57 | def get_examples(self, bbox, gt): 58 | bbox[:, :2] = bbox[:, :2] + bbox[:, 2:] / 2 59 | gt[:, :2] = gt[:, :2] + gt[:, 2:] / 2 60 | 61 | dst_xy = (gt[:, :2] - bbox[:, :2]) / bbox[:, 2:] 62 | dst_wh = np.log(gt[:, 2:] / bbox[:, 2:]) 63 | 64 | Y = np.concatenate((dst_xy, dst_wh), axis=1) 65 | return Y 66 | -------------------------------------------------------------------------------- /external/pysot/toolkit/datasets/uav.py: -------------------------------------------------------------------------------- 1 | import os 2 | import json 3 | 4 | from tqdm import tqdm 5 | from glob import glob 6 | 7 | from .dataset import Dataset 8 | from .video import Video 9 | 10 | class UAVVideo(Video): 11 | """ 12 | Args: 13 | name: video name 14 | root: dataset root 15 | video_dir: video directory 16 | init_rect: init rectangle 17 | img_names: image names 18 | gt_rect: groundtruth rectangle 19 | attr: attribute of video 20 | """ 21 | def __init__(self, name, root, video_dir, init_rect, img_names, 22 | gt_rect, attr, load_img=False): 23 | super(UAVVideo, self).__init__(name, root, video_dir, 24 | init_rect, img_names, gt_rect, attr, load_img) 25 | 26 | 27 | class UAVDataset(Dataset): 28 | """ 29 | Args: 30 | name: dataset name, should be 'UAV123', 'UAV20L' 31 | dataset_root: dataset root 32 | load_img: wether to load all imgs 33 | """ 34 | def __init__(self, name, dataset_root, load_img=False): 35 | super(UAVDataset, self).__init__(name, dataset_root) 36 | with open(os.path.join(dataset_root, name+'.json'), 'r') as f: 37 | meta_data = json.load(f) 38 | 39 | # load videos 40 | pbar = tqdm(meta_data.keys(), desc='loading '+name, ncols=100) 41 | self.videos = {} 42 | for video in pbar: 43 | pbar.set_postfix_str(video) 44 | self.videos[video] = UAVVideo(video, 45 | dataset_root, 46 | meta_data[video]['video_dir'], 47 | meta_data[video]['init_rect'], 48 | meta_data[video]['img_names'], 49 | meta_data[video]['gt_rect'], 50 | meta_data[video]['attr']) 51 | 52 | # set attr 53 | attr = [] 54 | for x in self.videos.values(): 55 | attr += x.attr 56 | attr = set(attr) 57 | self.attr = {} 58 | self.attr['ALL'] = list(self.videos.keys()) 59 | for x in attr: 60 | self.attr[x] = [] 61 | for k, v in self.videos.items(): 62 | for attr_ in v.attr: 63 | self.attr[attr_].append(k) 64 | 65 | -------------------------------------------------------------------------------- /arena/GOT10k/eval_got10k.py: -------------------------------------------------------------------------------- 1 | import os 2 | from got10k.trackers import Tracker 3 | from got10k.experiments import ExperimentGOT10k 4 | from arena.GOT10k.common_path import _dataset_name, _dataset_root, save_dir 5 | 6 | from arena.GOT10k import DiMPsuper_RF, DiMP50_RF, ATOM_RF, ECO_RF, SiamRPNpp_RF, RTMDNet_RF 7 | 8 | Trackers = { 9 | 'DiMPsuper_RF': DiMPsuper_RF, 10 | 'DiMP50_RF': DiMP50_RF, 11 | 'ATOM_RF': ATOM_RF, 12 | 'ECO_RF': ECO_RF, 13 | 'SiamRPNpp_RF': SiamRPNpp_RF, 14 | 'RTMDNet_RF': RTMDNet_RF 15 | } 16 | 17 | save_dir = os.path.join(save_dir, _dataset_name) 18 | 19 | 20 | def check_dir(dir): 21 | if not os.path.exists(dir): 22 | print('creating directory: {}'.format(dir)) 23 | os.makedirs(dir) 24 | print('using directory: {}'.format(dir)) 25 | return dir 26 | 27 | 28 | class IdentityTracker(Tracker): 29 | def __init__(self): 30 | super(IdentityTracker, self).__init__(name='IdentityTracker') 31 | 32 | def init(self, image, box): 33 | self.box = box 34 | 35 | def update(self, image): 36 | return self.box 37 | 38 | 39 | def parse_args(): 40 | import argparse 41 | parser = argparse.ArgumentParser() 42 | parser.add_argument('--tracker', default='DiMPsuper_RF', 43 | help='whether visualzie result') 44 | parser.add_argument('--rf_code', default='a', 45 | help='whether visualzie result') 46 | parser.add_argument('--overwrite', action='store_true', 47 | help='whether overwrite results') 48 | parser.add_argument('--vis', action='store_true', default=False, 49 | help='whether visualzie result') 50 | return parser.parse_args() 51 | 52 | 53 | if __name__ == '__main__': 54 | args = parse_args() 55 | 56 | # setup tracker 57 | tracker = Trackers[args.tracker](args.rf_code) 58 | 59 | # run experiments on GOT-10k (validation subset) 60 | data_root = os.path.join(_dataset_root, 'GOT10k') 61 | experiment = ExperimentGOT10k( 62 | data_root, subset='test', 63 | result_dir=check_dir(os.path.join(save_dir, 'results')), 64 | report_dir=check_dir(os.path.join(save_dir, 'reports')) 65 | ) 66 | experiment.run(tracker, visualize=args.vis, overwrite_result=args.overwrite) 67 | 68 | # report performance 69 | experiment.report([tracker.name]) 70 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/Reproduce.md: -------------------------------------------------------------------------------- 1 | ## Reproduce Our Experiment Results 2 | 3 | ### Establish Base Trackers 4 | In this project, we introduce DiMP50, DiMPsuper, ATOM, ECO, RTMDNet, SiamRPN++ as our base trackers. 5 | 6 | #### PyTracking Methods 7 | DiMP50, DiMPsuper, ATOM, ECO are trackers from [PyTracking](pytracking). 8 | 9 | The base tracker models trained using PyTracking can be download from [model zoo](https://github.com/visionml/pytracking/blob/master/MODEL_ZOO.md), download them into `pytracking/networks` 10 | 11 | Or you can run the following script to download the models. 12 | 13 | ``` 14 | echo "****************** Downloading networks ******************" 15 | mkdir pytracking/networks 16 | 17 | echo "****************** DiMP Network ******************" 18 | gdown https://drive.google.com/uc\?id\=1qgachgqks2UGjKx-GdO1qylBDdB1f9KN -O pytracking/networks/dimp50.pth 19 | gdown https://drive.google.com/uc\?id\=1MAjrRJDCbL0DSjUKFyDkUuYS1-cYBNjk -O pytracking/networks/dimp18.pth 20 | gdown https://drive.google.com/open?id=1qDptswis2FxihLRYLVRGDvx6aUoAVVLv -O pytracking/networks/super_dimp.pth 21 | 22 | echo "****************** ATOM Network ******************" 23 | gdown https://drive.google.com/uc\?id\=1VNyr-Ds0khjM0zaq6lU-xfY74-iWxBvU -O pytracking/networks/atom_default.pth 24 | 25 | echo "****************** ECO Network ******************" 26 | gdown https://drive.google.com/uc\?id\=1aWC4waLv_te-BULoy0k-n_zS-ONms21S -O pytracking/networks/resnet18_vggmconv1.pth 27 | ``` 28 | 29 | #### [Optional] Other Base Trackers 30 | Please refer to [external/pysot/README.md](external/pysot/README.md) for establishing SiamRPN++ and 31 | [external/RT_MDNet/README.md](external/RT_MDNet/README.md) for establishing RTMDNet. 32 | 33 | 34 | ### Run Evaluation Scripts 35 | 36 | * We provide the evaluation recipes of [LaSOT](doc/arena/LaSOT.md) | [GOT-10K](doc/arena/GOT-10K.md) | 37 | [TrackingNet](doc/arena/TrackingNet.md) | [VOT2020](doc/arena/VOT2020.md). 38 | You can follow these recipes to run the evaluation scripts. 39 | 40 | * For some of the testing scripts, the path to the testing sets should be specified in `pytracking/evaluation/local.py` 41 | 42 | If `pytracking/evaluation/local.py` is not exist, please run 43 | ``` 44 | python -c "from pytracking.evaluation.environment import create_default_local_file; create_default_local_file()" 45 | ``` 46 | An example of `pytracking/evaluation/local.py.example` is provided. 47 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /arena/VOT2020/vot/dataset/proxy.py: -------------------------------------------------------------------------------- 1 | 2 | from typing import List 3 | 4 | from vot.dataset import Channel, Sequence, Frame 5 | 6 | class FrameMapChannel(Channel): 7 | 8 | def __init__(self, source: Channel, frame_map: List[int]): 9 | super().__init__() 10 | self._source = source 11 | self._map = frame_map 12 | 13 | @property 14 | def length(self): 15 | return len(self._map) 16 | 17 | def frame(self, index): 18 | return self._source.frame(self._map[index]) 19 | 20 | def filename(self, index): 21 | return self._source.filename(self._map[index]) 22 | 23 | @property 24 | def size(self): 25 | return self._source.size 26 | 27 | class FrameMapSequence(Sequence): 28 | 29 | def __init__(self, source: Sequence, frame_map: List[int]): 30 | super().__init__(source.name, source.dataset) 31 | self._source = source 32 | self._map = [i for i in frame_map if i >= 0 and i < source.length] 33 | 34 | def __len__(self): 35 | return self.length 36 | 37 | def frame(self, index): 38 | return Frame(self, index) 39 | 40 | def metadata(self, name, default=None): 41 | return self._source.metadata(name, default) 42 | 43 | def channel(self, channel=None): 44 | sourcechannel = self._source.channel(channel) 45 | 46 | if sourcechannel is None: 47 | return None 48 | 49 | return FrameMapChannel(sourcechannel, self._map) 50 | 51 | def channels(self): 52 | return self._source.channels() 53 | 54 | def groundtruth(self, index=None): 55 | if index is None: 56 | groundtruth = [None] * len(self) 57 | for i, m in enumerate(self._map): 58 | groundtruth[i] = self._source.groundtruth(m) 59 | return groundtruth 60 | else: 61 | return self._source.groundtruth(self._map[index]) 62 | 63 | def tags(self, index=None): 64 | if index is None: 65 | return self._source.tags() 66 | else: 67 | return self._source.tags(self._map[index]) 68 | 69 | def values(self, index=None): 70 | if index is None: 71 | return self._source.values() 72 | return self._source.values(self._map[index]) 73 | 74 | @property 75 | def size(self): 76 | return self._source.size 77 | 78 | @property 79 | def length(self): 80 | return len(self._map) 81 | -------------------------------------------------------------------------------- /external/pysot/toolkit/visualization/draw_f1.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import numpy as np 3 | 4 | from matplotlib import rc 5 | from .draw_utils import COLOR, LINE_STYLE 6 | 7 | rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']}) 8 | rc('text', usetex=True) 9 | 10 | def draw_f1(result, bold_name=None): 11 | # drawing f1 contour 12 | fig, ax = plt.subplots() 13 | for f1 in np.arange(0.1, 1, 0.1): 14 | recall = np.arange(f1, 1+0.01, 0.01) 15 | precision = f1 * recall / (2 * recall - f1) 16 | ax.plot(recall, precision, color=[0,1,0], linestyle='-', linewidth=0.5) 17 | ax.plot(precision, recall, color=[0,1,0], linestyle='-', linewidth=0.5) 18 | ax.grid(b=True) 19 | ax.set_aspect(1) 20 | plt.xlabel('Recall') 21 | plt.ylabel('Precision') 22 | plt.axis([0, 1, 0, 1]) 23 | plt.title(r'\textbf{VOT2018-LT Precision vs Recall}') 24 | 25 | # draw result line 26 | all_precision = {} 27 | all_recall = {} 28 | best_f1 = {} 29 | best_idx = {} 30 | for tracker_name, ret in result.items(): 31 | precision = np.mean(list(ret['precision'].values()), axis=0) 32 | recall = np.mean(list(ret['recall'].values()), axis=0) 33 | f1 = 2 * precision * recall / (precision + recall) 34 | max_idx = np.argmax(f1) 35 | all_precision[tracker_name] = precision 36 | all_recall[tracker_name] = recall 37 | best_f1[tracker_name] = f1[max_idx] 38 | best_idx[tracker_name] = max_idx 39 | 40 | for idx, (tracker_name, best_f1) in \ 41 | enumerate(sorted(best_f1.items(), key=lambda x:x[1], reverse=True)): 42 | if tracker_name == bold_name: 43 | label = r"\textbf{[%.3f] Ours}" % (best_f1) 44 | else: 45 | label = "[%.3f] " % (best_f1) + tracker_name 46 | recall = all_recall[tracker_name][:-1] 47 | precision = all_precision[tracker_name][:-1] 48 | ax.plot(recall, precision, color=COLOR[idx], linestyle='-', 49 | label=label) 50 | f1_idx = best_idx[tracker_name] 51 | ax.plot(recall[f1_idx], precision[f1_idx], color=[0,0,0], marker='o', 52 | markerfacecolor=COLOR[idx], markersize=5) 53 | ax.legend(loc='lower right', labelspacing=0.2) 54 | plt.xticks(np.arange(0, 1+0.1, 0.1)) 55 | plt.yticks(np.arange(0, 1+0.1, 0.1)) 56 | plt.show() 57 | 58 | if __name__ == '__main__': 59 | draw_f1(None) 60 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /ltr/models/kys/conv_gru.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | from ltr.models.layers.blocks import conv_block 4 | 5 | 6 | class ConvGRUCell(nn.Module): 7 | def __init__(self, input_dim, hidden_dim, kernel_size, padding_mode='zeros'): 8 | " Referenced from https://github.com/happyjin/ConvGRU-pytorch" 9 | super(ConvGRUCell, self).__init__() 10 | self.hidden_dim = hidden_dim 11 | 12 | if padding_mode == 'zeros': 13 | if not isinstance(kernel_size, (list, tuple)): 14 | kernel_size = (kernel_size, kernel_size) 15 | 16 | padding = kernel_size[0] // 2, kernel_size[1] // 2 17 | self.conv_reset = nn.Conv2d(input_dim + hidden_dim, self.hidden_dim, kernel_size, padding=padding) 18 | self.conv_update = nn.Conv2d(input_dim + hidden_dim, self.hidden_dim, kernel_size, padding=padding) 19 | 20 | self.conv_state_new = nn.Conv2d(input_dim+hidden_dim, self.hidden_dim, kernel_size, padding=padding) 21 | else: 22 | self.conv_reset = conv_block(input_dim + hidden_dim, hidden_dim, kernel_size=kernel_size, stride=1, 23 | padding=int(kernel_size // 2), batch_norm=False, relu=False, 24 | padding_mode=padding_mode) 25 | 26 | self.conv_update = conv_block(input_dim + hidden_dim, hidden_dim, kernel_size=kernel_size, stride=1, 27 | padding=int(kernel_size // 2), batch_norm=False, relu=False, 28 | padding_mode=padding_mode) 29 | 30 | self.conv_state_new = conv_block(input_dim + hidden_dim, hidden_dim, kernel_size=kernel_size, stride=1, 31 | padding=int(kernel_size // 2), batch_norm=False, relu=False, 32 | padding_mode=padding_mode) 33 | 34 | def forward(self, input, state_cur): 35 | input_state_cur = torch.cat([input, state_cur], dim=1) 36 | 37 | reset_gate = torch.sigmoid(self.conv_reset(input_state_cur)) 38 | update_gate = torch.sigmoid(self.conv_update(input_state_cur)) 39 | 40 | input_state_cur_reset = torch.cat([input, reset_gate*state_cur], dim=1) 41 | state_new = torch.tanh(self.conv_state_new(input_state_cur_reset)) 42 | 43 | state_next = (1.0 - update_gate) * state_cur + update_gate * state_new 44 | return state_next 45 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------