├── mmtracking ├── requirements │ ├── build.txt │ ├── readthedocs.txt │ ├── mminstall.txt │ ├── docs.txt │ ├── runtime.txt │ └── tests.txt ├── requirements.txt ├── resources │ └── mmtrack-logo.png ├── configs │ ├── vid │ │ ├── selsa │ │ │ ├── selsa_faster_rcnn_r50_dc5_fp16_1x_imagenetvid.py │ │ │ ├── selsa_faster_rcnn_r101_dc5_1x_imagenetvid.py │ │ │ ├── selsa_faster_rcnn_x101_dc5_1x_imagenetvid.py │ │ │ └── selsa_faster_rcnn_r50_dc5_1x_imagenetvid.py │ │ ├── dff │ │ │ ├── dff_faster_rcnn_r101_dc5_1x_imagenetvid.py │ │ │ ├── dff_faster_rcnn_x101_dc5_1x_imagenetvid.py │ │ │ ├── dff_faster_rcnn_r50_dc5_1x_imagenetvid.py │ │ │ └── metafile.yml │ │ ├── fgfa │ │ │ ├── fgfa_faster_rcnn_r101_dc5_1x_imagenetvid.py │ │ │ ├── fgfa_faster_rcnn_x101_dc5_1x_imagenetvid.py │ │ │ ├── fgfa_faster_rcnn_r50_dc5_1x_imagenetvid.py │ │ │ └── metafile.yml │ │ ├── temporal_roi_align │ │ │ ├── selsa_troialign_faster_rcnn_r101_dc5_7e_imagenetvid.py │ │ │ ├── selsa_troialign_faster_rcnn_x101_dc5_7e_imagenetvid.py │ │ │ └── selsa_troialign_faster_rcnn_r50_dc5_7e_imagenetvid.py │ │ └── README.md │ ├── sot │ │ ├── siamese_rpn │ │ │ ├── siamese_rpn_r50_fp16_20e_lasot.py │ │ │ ├── siamese_rpn_r50_20e_trackingnet.py │ │ │ ├── siamese_rpn_r50_20e_uav123.py │ │ │ └── siamese_rpn_r50_20e_vot2018.py │ │ ├── stark │ │ │ ├── stark_st1_r50_500e_trackingnet.py │ │ │ └── stark_st2_r50_50e_trackingnet.py │ │ └── README.md │ ├── mot │ │ ├── bytetrack │ │ │ ├── bytetrack_yolox_x_crowdhuman_mot17-private.py │ │ │ └── metafile.yml │ │ ├── README.md │ │ ├── tracktor │ │ │ ├── tracktor_faster-rcnn_r50_fpn_fp16_4e_mot17-private-half.py │ │ │ ├── tracktor_faster-rcnn_r50_fpn_4e_mot17-private.py │ │ │ ├── tracktor_faster-rcnn_r50_fpn_4e_mot17-public-half.py │ │ │ ├── tracktor_faster-rcnn_r50_fpn_4e_mot15-private-half.py │ │ │ ├── tracktor_faster-rcnn_r50_fpn_4e_mot16-private-half.py │ │ │ ├── tracktor_faster-rcnn_r50_fpn_8e_mot20-private-half.py │ │ │ ├── tracktor_faster-rcnn_r50_fpn_8e_mot20-public.py │ │ │ ├── tracktor_faster-rcnn_r50_fpn_4e_mot17-public-half_search.py │ │ │ ├── tracktor_faster-rcnn_r50_fpn_4e_mot17-public.py │ │ │ ├── tracktor_faster-rcnn_r50_fpn_4e_mot15-public-half.py │ │ │ └── tracktor_faster-rcnn_r50_fpn_4e_mot16-public-half.py │ │ ├── deepsort │ │ │ ├── sort_faster-rcnn_fpn_4e_mot17-private.py │ │ │ ├── sort_faster-rcnn_fpn_4e_mot17-public.py │ │ │ ├── sort_faster-rcnn_fpn_4e_mot17-public-half.py │ │ │ ├── deepsort_faster-rcnn_fpn_4e_mot17-public-half.py │ │ │ └── sort_faster-rcnn_fpn_4e_mot17-private-half.py │ │ └── qdtrack │ │ │ ├── qdtrack_faster-rcnn_r101_fpn_12e_tao.py │ │ │ ├── qdtrack_faster-rcnn_r101_fpn_24e_lvis.py │ │ │ ├── metafile.yml │ │ │ ├── qdtrack_faster-rcnn_r50_fpn_4e_dancetrack.py │ │ │ ├── qdtrack_faster-rcnn_r50_fpn_4e_mot17-private-half.py │ │ │ └── qdtrack_faster-rcnn_r50_fpn_4e_crowdhuman_mot17-private-half.py │ ├── det │ │ ├── faster-rcnn_r50_fpn_4e_mot17.py │ │ ├── faster-rcnn_r50_fpn_4e_mot15-half.py │ │ ├── faster-rcnn_r50_fpn_4e_mot16-half.py │ │ ├── faster-rcnn_r101_fpn_4e_mot17-half.py │ │ ├── faster-rcnn_r50_fpn_4e_mot17-half.py │ │ ├── faster-rcnn_r50_fpn_8e_mot20.py │ │ └── faster-rcnn_r50_fpn_8e_mot20-half.py │ ├── README.md │ ├── vis │ │ ├── README.md │ │ └── masktrack_rcnn │ │ │ ├── masktrack_rcnn_r101_fpn_12e_youtubevis2019.py │ │ │ ├── masktrack_rcnn_x101_fpn_12e_youtubevis2019.py │ │ │ ├── masktrack_rcnn_r50_fpn_12e_youtubevis2021.py │ │ │ ├── masktrack_rcnn_r101_fpn_12e_youtubevis2021.py │ │ │ └── masktrack_rcnn_x101_fpn_12e_youtubevis2021.py │ ├── reid │ │ ├── resnet50_b32x8_MOT15.py │ │ ├── resnet50_b32x8_MOT16.py │ │ ├── resnet50_b32x8_MOT20.py │ │ └── resnet50_b32x8_MOT17.py │ └── _base_ │ │ ├── default_runtime.py │ │ ├── datasets │ │ ├── lvis_v1_instance.py │ │ ├── lvis_v0.5_instance.py │ │ ├── coco_detection.py │ │ ├── mot_challenge_reid.py │ │ ├── coco_instance.py │ │ ├── coco_instance_semantic.py │ │ └── mot_challenge_det.py │ │ └── models │ │ └── yolox_x_8x8.py ├── docs │ ├── en │ │ ├── _static │ │ │ ├── image │ │ │ │ └── mmtrack-logo.png │ │ │ └── css │ │ │ │ └── readthedocs.css │ │ ├── switch_language.md │ │ ├── tutorials │ │ │ └── index.rst │ │ ├── Makefile │ │ ├── make.bat │ │ ├── index.rst │ │ └── stat.py │ └── zh_cn │ │ ├── _static │ │ ├── image │ │ │ └── mmtrack-logo.png │ │ └── css │ │ │ └── readthedocs.css │ │ ├── switch_language.md │ │ ├── tutorials │ │ └── index.rst │ │ ├── Makefile │ │ ├── make.bat │ │ ├── index.rst │ │ ├── stat.py │ │ └── model_zoo.md ├── mmtrack │ ├── core │ │ ├── motion │ │ │ ├── __init__.py │ │ │ └── flow.py │ │ ├── hook │ │ │ └── __init__.py │ │ ├── anchor │ │ │ └── __init__.py │ │ ├── bbox │ │ │ ├── iou_calculators │ │ │ │ ├── __init__.py │ │ │ │ └── region_iou_calculator.py │ │ │ └── __init__.py │ │ ├── utils │ │ │ ├── __init__.py │ │ │ ├── image.py │ │ │ └── misc.py │ │ ├── optimizer │ │ │ └── __init__.py │ │ ├── __init__.py │ │ ├── track │ │ │ ├── __init__.py │ │ │ ├── correlation.py │ │ │ └── similarity.py │ │ └── evaluation │ │ │ └── __init__.py │ ├── datasets │ │ ├── parsers │ │ │ └── __init__.py │ │ ├── samplers │ │ │ └── __init__.py │ │ ├── dancetrack_dataset.py │ │ ├── pipelines │ │ │ └── __init__.py │ │ ├── __init__.py │ │ ├── dataset_wrappers.py │ │ └── uav123_dataset.py │ ├── models │ │ ├── backbones │ │ │ └── __init__.py │ │ ├── vis │ │ │ └── __init__.py │ │ ├── roi_heads │ │ │ ├── bbox_heads │ │ │ │ └── __init__.py │ │ │ ├── roi_extractors │ │ │ │ ├── __init__.py │ │ │ │ └── single_level_roi_extractor.py │ │ │ └── __init__.py │ │ ├── sot │ │ │ └── __init__.py │ │ ├── aggregators │ │ │ └── __init__.py │ │ ├── vid │ │ │ └── __init__.py │ │ ├── losses │ │ │ └── __init__.py │ │ ├── reid │ │ │ ├── __init__.py │ │ │ ├── gap.py │ │ │ └── base_reid.py │ │ ├── mot │ │ │ └── __init__.py │ │ ├── motion │ │ │ └── __init__.py │ │ ├── trackers │ │ │ └── __init__.py │ │ ├── track_heads │ │ │ └── __init__.py │ │ ├── __init__.py │ │ └── builder.py │ ├── utils │ │ ├── __init__.py │ │ ├── logger.py │ │ └── collect_env.py │ ├── apis │ │ └── __init__.py │ └── version.py ├── tests │ ├── test_data │ │ ├── test_datasets │ │ │ ├── __init__.py │ │ │ ├── utils.py │ │ │ ├── test_vis_dataset.py │ │ │ ├── test_dataset_wrapers.py │ │ │ ├── test_tao_dataset.py │ │ │ └── test_sot_train_dataset.py │ │ └── test_pipelines │ │ │ └── test_loading.py │ ├── test_models │ │ ├── test_forward │ │ │ └── __init__.py │ │ ├── test_aggregators │ │ │ ├── test_selsa_aggregator.py │ │ │ └── test_embed_aggregator.py │ │ ├── test_losses │ │ │ ├── test_triplet_loss.py │ │ │ └── test_multi_pos_cross_entropy_loss.py │ │ ├── test_motion │ │ │ ├── test_camera_motion_compensation.py │ │ │ ├── test_flownet_simple.py │ │ │ └── test_linear_motion.py │ │ ├── test_roi_heads │ │ │ └── test_roi_extractors │ │ │ │ ├── test_single_level_roi_extractor.py │ │ │ │ └── test_temporal_roi_align.py │ │ ├── test_backones │ │ │ └── test_sot_resnet.py │ │ ├── test_trackers │ │ │ ├── test_bytetracker.py │ │ │ └── test_masktrack_rcnn_tracker.py │ │ └── test_reid │ │ │ └── test_base_reid.py │ ├── test_core │ │ ├── test_track │ │ │ ├── test_interpolation.py │ │ │ └── test_similarity.py │ │ └── test_motion │ │ │ └── test_flow.py │ └── test_version.py ├── MANIFEST.in ├── demo │ └── README.md ├── CITATION.cff ├── tools │ ├── analysis │ │ ├── sot │ │ │ ├── dist_sot_siamrpn_search.sh │ │ │ └── slurm_sot_siamrpn_search.sh │ │ ├── mot │ │ │ ├── dist_mot_search.sh │ │ │ ├── slurm_mot_search.sh │ │ │ └── mot_dummy_results.py │ │ ├── print_config.py │ │ └── publish_model.py │ ├── convert_datasets │ │ ├── got10k │ │ │ └── unzip_got10k.sh │ │ ├── otb100 │ │ │ └── unzip_otb100.sh │ │ └── trackingnet │ │ │ └── unzip_trackinget.sh │ ├── dist_test.sh │ ├── dist_train.sh │ ├── slurm_test.sh │ └── slurm_train.sh ├── .readthedocs.yml ├── model-index.yml ├── .dev_scripts │ └── benchmark │ │ └── batch_train_list.txt ├── setup.cfg ├── Interface.py └── .pre-commit-config.yaml ├── yolox ├── __init__.py ├── core │ └── __init__.py ├── evaluators │ └── __init__.py ├── exp │ ├── __init__.py │ ├── default │ │ └── __init__.py │ └── build.py ├── models │ ├── __init__.py │ ├── yolox.py │ └── losses.py ├── utils │ ├── compat.py │ ├── __init__.py │ └── checkpoint.py ├── data │ ├── __init__.py │ ├── datasets │ │ ├── __init__.py │ │ ├── genshin_classes.py │ │ ├── voc_classes.py │ │ └── coco_classes.py │ └── data_prefetcher.py ├── layers │ └── __init__.py └── tools │ └── __init__.py ├── imgs ├── award_mask.png ├── award_temp.png ├── domain_huo.png ├── domain_lei.png ├── domain_yan.png ├── dst_temp.png ├── resin_temp.png ├── start_mask.png ├── start_temp.png ├── team_temp.png ├── domain_bing.png ├── domain_feng.png ├── finish_mask.png ├── finish_temp.png ├── return_temp.png ├── switch_mask.png ├── switch_temp.png ├── domain_chensha.png ├── domain_huaguan.png ├── domain_jueyuan.png ├── domain_qianyan.png └── domain_zongshi.png ├── cfgs └── p1.yaml ├── control ├── __init__.py ├── Selector.py └── script │ └── hutao_shatang.yaml ├── requirements.txt ├── Readme.md └── window_capture.py /mmtracking/requirements/build.txt: -------------------------------------------------------------------------------- 1 | cython 2 | numba==0.53.0 3 | numpy 4 | -------------------------------------------------------------------------------- /mmtracking/requirements/readthedocs.txt: -------------------------------------------------------------------------------- 1 | mmcls 2 | mmcv 3 | mmdet 4 | torch 5 | torchvision 6 | -------------------------------------------------------------------------------- /yolox/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | 4 | __version__ = "0.3.0" 5 | -------------------------------------------------------------------------------- /imgs/award_mask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/award_mask.png -------------------------------------------------------------------------------- /imgs/award_temp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/award_temp.png -------------------------------------------------------------------------------- /imgs/domain_huo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/domain_huo.png -------------------------------------------------------------------------------- /imgs/domain_lei.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/domain_lei.png -------------------------------------------------------------------------------- /imgs/domain_yan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/domain_yan.png -------------------------------------------------------------------------------- /imgs/dst_temp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/dst_temp.png -------------------------------------------------------------------------------- /imgs/resin_temp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/resin_temp.png -------------------------------------------------------------------------------- /imgs/start_mask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/start_mask.png -------------------------------------------------------------------------------- /imgs/start_temp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/start_temp.png -------------------------------------------------------------------------------- /imgs/team_temp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/team_temp.png -------------------------------------------------------------------------------- /mmtracking/requirements/mminstall.txt: -------------------------------------------------------------------------------- 1 | mmcls>=0.16.0 2 | mmcv-full>=1.3.17,<1.6.0 3 | mmdet>=2.19.1,<3.0.0 4 | -------------------------------------------------------------------------------- /imgs/domain_bing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/domain_bing.png -------------------------------------------------------------------------------- /imgs/domain_feng.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/domain_feng.png -------------------------------------------------------------------------------- /imgs/finish_mask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/finish_mask.png -------------------------------------------------------------------------------- /imgs/finish_temp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/finish_temp.png -------------------------------------------------------------------------------- /imgs/return_temp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/return_temp.png -------------------------------------------------------------------------------- /imgs/switch_mask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/switch_mask.png -------------------------------------------------------------------------------- /imgs/switch_temp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/switch_temp.png -------------------------------------------------------------------------------- /imgs/domain_chensha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/domain_chensha.png -------------------------------------------------------------------------------- /imgs/domain_huaguan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/domain_huaguan.png -------------------------------------------------------------------------------- /imgs/domain_jueyuan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/domain_jueyuan.png -------------------------------------------------------------------------------- /imgs/domain_qianyan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/domain_qianyan.png -------------------------------------------------------------------------------- /imgs/domain_zongshi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/imgs/domain_zongshi.png -------------------------------------------------------------------------------- /mmtracking/requirements.txt: -------------------------------------------------------------------------------- 1 | -r requirements/build.txt 2 | -r requirements/runtime.txt 3 | -r requirements/tests.txt 4 | -------------------------------------------------------------------------------- /cfgs/p1.yaml: -------------------------------------------------------------------------------- 1 | - 2 | 秘境: [火, 4] #火本,第四个等级 3 | team: 1 #使用队伍1 4 | 策略: ayaka_cat #战斗策略 5 | - 6 | 秘境: [风, 5] 7 | team: 2 8 | 策略: hutao_shatang -------------------------------------------------------------------------------- /mmtracking/resources/mmtrack-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/mmtracking/resources/mmtrack-logo.png -------------------------------------------------------------------------------- /mmtracking/configs/vid/selsa/selsa_faster_rcnn_r50_dc5_fp16_1x_imagenetvid.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./selsa_faster_rcnn_r50_dc5_1x_imagenetvid.py'] 2 | fp16 = dict(loss_scale=512.) 3 | -------------------------------------------------------------------------------- /mmtracking/docs/en/_static/image/mmtrack-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/mmtracking/docs/en/_static/image/mmtrack-logo.png -------------------------------------------------------------------------------- /mmtracking/mmtrack/core/motion/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .flow import flow_warp_feats 3 | 4 | __all__ = ['flow_warp_feats'] 5 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/datasets/parsers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .coco_video_parser import CocoVID 3 | 4 | __all__ = ['CocoVID'] 5 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/backbones/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .sot_resnet import SOTResNet 3 | 4 | __all__ = ['SOTResNet'] 5 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/vis/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .masktrack_rcnn import MaskTrackRCNN 3 | 4 | __all__ = ['MaskTrackRCNN'] 5 | -------------------------------------------------------------------------------- /mmtracking/docs/zh_cn/_static/image/mmtrack-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IrisRainbowNeko/genshin_autoplay_domain/HEAD/mmtracking/docs/zh_cn/_static/image/mmtrack-logo.png -------------------------------------------------------------------------------- /mmtracking/docs/en/switch_language.md: -------------------------------------------------------------------------------- 1 | ## English 2 | 3 | ## 简体中文 4 | -------------------------------------------------------------------------------- /mmtracking/docs/zh_cn/switch_language.md: -------------------------------------------------------------------------------- 1 | ## English 2 | 3 | ## 简体中文 4 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/core/hook/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .yolox_mode_switch_hook import YOLOXModeSwitchHook 3 | 4 | __all__ = ['YOLOXModeSwitchHook'] 5 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/roi_heads/bbox_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .selsa_bbox_head import SelsaBBoxHead 3 | 4 | __all__ = ['SelsaBBoxHead'] 5 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/sot/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .siamrpn import SiamRPN 3 | from .stark import Stark 4 | 5 | __all__ = ['SiamRPN', 'Stark'] 6 | -------------------------------------------------------------------------------- /mmtracking/tests/test_data/test_datasets/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .utils import _create_coco_gt_results 3 | 4 | __all__ = ['_create_coco_gt_results'] 5 | -------------------------------------------------------------------------------- /yolox/core/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | # Copyright (c) Megvii, Inc. and its affiliates. 4 | 5 | from .launch import launch 6 | from .trainer import Trainer 7 | -------------------------------------------------------------------------------- /mmtracking/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include requirements/*.txt 2 | include mmtrack/.mim/model-index.yml 3 | recursive-include mmtrack/.mim/configs *.py *.yml 4 | recursive-include mmtrack/.mim/tools *.sh *.py 5 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/core/anchor/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .sot_anchor_generator import SiameseRPNAnchorGenerator 3 | 4 | __all__ = ['SiameseRPNAnchorGenerator'] 5 | -------------------------------------------------------------------------------- /mmtracking/requirements/docs.txt: -------------------------------------------------------------------------------- 1 | myst_parser 2 | -e git+https://github.com/open-mmlab/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme 3 | sphinx==4.0.2 4 | sphinx-copybutton 5 | sphinx_markdown_tables 6 | -------------------------------------------------------------------------------- /mmtracking/configs/sot/siamese_rpn/siamese_rpn_r50_fp16_20e_lasot.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./siamese_rpn_r50_20e_lasot.py'] 2 | optimizer_config = dict(type='SiameseRPNFp16OptimizerHook') 3 | fp16 = dict(loss_scale=512.) 4 | -------------------------------------------------------------------------------- /mmtracking/docs/en/_static/css/readthedocs.css: -------------------------------------------------------------------------------- 1 | .header-logo { 2 | background-image: url("../image/mmtrack-logo.png"); 3 | background-size: 145px 40px; 4 | height: 40px; 5 | width: 145px; 6 | } 7 | -------------------------------------------------------------------------------- /mmtracking/docs/zh_cn/_static/css/readthedocs.css: -------------------------------------------------------------------------------- 1 | .header-logo { 2 | background-image: url("../image/mmtrack-logo.png"); 3 | background-size: 145px 40px; 4 | height: 40px; 5 | width: 145px; 6 | } 7 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/core/bbox/iou_calculators/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .region_iou_calculator import calculate_region_overlap 3 | 4 | __all__ = ['calculate_region_overlap'] 5 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .collect_env import collect_env 3 | from .logger import get_root_logger 4 | 5 | __all__ = ['collect_env', 'get_root_logger'] 6 | -------------------------------------------------------------------------------- /mmtracking/tests/test_models/test_forward/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .utils import _demo_mm_inputs, _get_config_module 3 | 4 | __all__ = ['_demo_mm_inputs', '_get_config_module'] 5 | -------------------------------------------------------------------------------- /yolox/evaluators/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | # Copyright (c) Megvii, Inc. and its affiliates. 4 | 5 | from .coco_evaluator import COCOEvaluator 6 | from .voc_evaluator import VOCEvaluator 7 | -------------------------------------------------------------------------------- /yolox/exp/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | # Copyright (c) Megvii Inc. All rights reserved. 4 | 5 | from .base_exp import BaseExp 6 | from .build import get_exp 7 | from .yolox_base import Exp 8 | -------------------------------------------------------------------------------- /control/__init__.py: -------------------------------------------------------------------------------- 1 | from .FollowController import FollowController 2 | from .AwardController import AwardController 3 | 4 | from .ScriptAttacker import ScriptAttacker 5 | 6 | from .DomainSelector import DomainSelector 7 | 8 | from .Selector import * -------------------------------------------------------------------------------- /mmtracking/requirements/runtime.txt: -------------------------------------------------------------------------------- 1 | attributee==0.1.5 2 | dotty_dict 3 | lap 4 | matplotlib 5 | mmcls>=0.16.0 6 | motmetrics 7 | packaging 8 | pandas<=1.3.5 9 | pycocotools<=2.0.2 10 | scipy<=1.7.3 11 | seaborn 12 | terminaltables 13 | tqdm 14 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/aggregators/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .embed_aggregator import EmbedAggregator 3 | from .selsa_aggregator import SelsaAggregator 4 | 5 | __all__ = ['EmbedAggregator', 'SelsaAggregator'] 6 | -------------------------------------------------------------------------------- /mmtracking/requirements/tests.txt: -------------------------------------------------------------------------------- 1 | asynctest 2 | codecov 3 | flake8 4 | interrogate 5 | isort==4.3.21 6 | # Note: used for kwarray.group_items, this may be ported to mmcv in the future. 7 | kwarray 8 | pytest 9 | ubelt 10 | xdoctest>=0.10.0 11 | yapf 12 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/vid/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .base import BaseVideoDetector 3 | from .dff import DFF 4 | from .fgfa import FGFA 5 | from .selsa import SELSA 6 | 7 | __all__ = ['BaseVideoDetector', 'DFF', 'FGFA', 'SELSA'] 8 | -------------------------------------------------------------------------------- /mmtracking/docs/en/tutorials/index.rst: -------------------------------------------------------------------------------- 1 | .. toctree:: 2 | :maxdepth: 2 3 | 4 | config.md 5 | customize_dataset.md 6 | customize_data_pipeline.md 7 | customize_vid_model.md 8 | customize_mot_model.md 9 | customize_sot_model.md 10 | customize_runtime.md 11 | -------------------------------------------------------------------------------- /mmtracking/docs/zh_cn/tutorials/index.rst: -------------------------------------------------------------------------------- 1 | .. toctree:: 2 | :maxdepth: 2 3 | 4 | config.md 5 | customize_dataset.md 6 | customize_data_pipeline.md 7 | customize_vid_model.md 8 | customize_mot_model.md 9 | customize_sot_model.md 10 | customize_runtime.md 11 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/roi_heads/roi_extractors/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .single_level_roi_extractor import SingleRoIExtractor 3 | from .temporal_roi_align import TemporalRoIAlign 4 | 5 | __all__ = ['SingleRoIExtractor', 'TemporalRoIAlign'] 6 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/bytetrack/bytetrack_yolox_x_crowdhuman_mot17-private.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./bytetrack_yolox_x_crowdhuman_mot17-private-half.py'] 2 | 3 | data = dict( 4 | test=dict( 5 | ann_file='data/MOT17/annotations/test_cocoformat.json', 6 | img_prefix='data/MOT17/test')) 7 | -------------------------------------------------------------------------------- /mmtracking/demo/README.md: -------------------------------------------------------------------------------- 1 | # Demo 2 | 3 | Please refer to the inference of [VID](../docs/en/quick_run.md#inference-vid-models), [MOT](../docs/en/quick_run.md#inference-motvis-models), [SOT](../docs/en/quick_run.md#inference-sot-models) and [VIS](../docs/en/quick_run.md#inference-motvis-models) to run demos. 4 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/losses/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .l2_loss import L2Loss 3 | from .multipos_cross_entropy_loss import MultiPosCrossEntropyLoss 4 | from .triplet_loss import TripletLoss 5 | 6 | __all__ = ['L2Loss', 'TripletLoss', 'MultiPosCrossEntropyLoss'] 7 | -------------------------------------------------------------------------------- /mmtracking/CITATION.cff: -------------------------------------------------------------------------------- 1 | cff-version: 1.2.0 2 | message: "If you use this software, please cite it as below." 3 | authors: 4 | - name: "MMTracking Contributors" 5 | title: "OpenMMLab Video Perception Toolbox and Benchmark" 6 | date-released: 2021-01-04 7 | url: "https://github.com/open-mmlab/mmtracking" 8 | license: Apache-2.0 9 | -------------------------------------------------------------------------------- /mmtracking/configs/vid/dff/dff_faster_rcnn_r101_dc5_1x_imagenetvid.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./dff_faster_rcnn_r50_dc5_1x_imagenetvid.py'] 2 | model = dict( 3 | detector=dict( 4 | backbone=dict( 5 | depth=101, 6 | init_cfg=dict( 7 | type='Pretrained', checkpoint='torchvision://resnet101')))) 8 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/datasets/samplers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .quota_sampler import DistributedQuotaSampler 3 | from .video_sampler import DistributedVideoSampler, SOTVideoSampler 4 | 5 | __all__ = [ 6 | 'DistributedVideoSampler', 'SOTVideoSampler', 'DistributedQuotaSampler' 7 | ] 8 | -------------------------------------------------------------------------------- /mmtracking/tools/analysis/sot/dist_sot_siamrpn_search.sh: -------------------------------------------------------------------------------- 1 | CONFIG=$1 2 | GPUS=$2 3 | PORT=${PORT:-29500} 4 | 5 | 6 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 7 | python -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \ 8 | $(dirname "$0")/sot_siamrpn_param_search.py $CONFIG --launcher pytorch ${@:3} 9 | -------------------------------------------------------------------------------- /mmtracking/configs/vid/fgfa/fgfa_faster_rcnn_r101_dc5_1x_imagenetvid.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./fgfa_faster_rcnn_r50_dc5_1x_imagenetvid.py'] 2 | model = dict( 3 | detector=dict( 4 | backbone=dict( 5 | depth=101, 6 | init_cfg=dict( 7 | type='Pretrained', checkpoint='torchvision://resnet101')))) 8 | -------------------------------------------------------------------------------- /mmtracking/configs/vid/selsa/selsa_faster_rcnn_r101_dc5_1x_imagenetvid.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./selsa_faster_rcnn_r50_dc5_1x_imagenetvid.py'] 2 | model = dict( 3 | detector=dict( 4 | backbone=dict( 5 | depth=101, 6 | init_cfg=dict( 7 | type='Pretrained', checkpoint='torchvision://resnet101')))) 8 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/reid/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .base_reid import BaseReID 3 | from .fc_module import FcModule 4 | from .gap import GlobalAveragePooling 5 | from .linear_reid_head import LinearReIDHead 6 | 7 | __all__ = ['BaseReID', 'GlobalAveragePooling', 'LinearReIDHead', 'FcModule'] 8 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/core/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .image import crop_image 3 | from .misc import setup_multi_processes 4 | from .visualization import imshow_mot_errors, imshow_tracks 5 | 6 | __all__ = [ 7 | 'crop_image', 'imshow_tracks', 'imshow_mot_errors', 'setup_multi_processes' 8 | ] 9 | -------------------------------------------------------------------------------- /mmtracking/tools/analysis/mot/dist_mot_search.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CONFIG=$1 4 | GPUS=$2 5 | PORT=${PORT:-29500} 6 | 7 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 8 | python -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \ 9 | $(dirname "$0")/mot_param_search.py $CONFIG --launcher pytorch ${@:3} 10 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/roi_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .bbox_heads import SelsaBBoxHead 3 | from .roi_extractors import SingleRoIExtractor, TemporalRoIAlign 4 | from .selsa_roi_head import SelsaRoIHead 5 | 6 | __all__ = [ 7 | 'SelsaRoIHead', 'SelsaBBoxHead', 'TemporalRoIAlign', 'SingleRoIExtractor' 8 | ] 9 | -------------------------------------------------------------------------------- /mmtracking/configs/sot/stark/stark_st1_r50_500e_trackingnet.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./stark_st1_r50_500e_lasot.py'] 2 | 3 | data_root = 'data/' 4 | data = dict( 5 | test=dict( 6 | type='TrackingNetDataset', 7 | ann_file=data_root + 8 | 'trackingnet/annotations/trackingnet_test_infos.txt', 9 | img_prefix=data_root + 'trackingnet')) 10 | -------------------------------------------------------------------------------- /mmtracking/.readthedocs.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | formats: all 4 | 5 | python: 6 | version: 3.7 7 | install: 8 | - requirements: requirements/build.txt 9 | - requirements: requirements/docs.txt 10 | - requirements: requirements/runtime.txt 11 | - requirements: requirements/readthedocs.txt 12 | - requirements: requirements/mminstall.txt 13 | -------------------------------------------------------------------------------- /mmtracking/configs/vid/temporal_roi_align/selsa_troialign_faster_rcnn_r101_dc5_7e_imagenetvid.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./selsa_troialign_faster_rcnn_r50_dc5_7e_imagenetvid.py'] 2 | model = dict( 3 | detector=dict( 4 | backbone=dict( 5 | depth=101, 6 | init_cfg=dict( 7 | type='Pretrained', checkpoint='torchvision://resnet101')))) 8 | -------------------------------------------------------------------------------- /yolox/models/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | # Copyright (c) Megvii Inc. All rights reserved. 4 | 5 | from .build import * 6 | from .darknet import CSPDarknet, Darknet 7 | from .losses import IOUloss 8 | from .yolo_fpn import YOLOFPN 9 | from .yolo_head import YOLOXHead 10 | from .yolo_pafpn import YOLOPAFPN 11 | from .yolox import YOLOX 12 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/mot/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .base import BaseMultiObjectTracker 3 | from .byte_track import ByteTrack 4 | from .deep_sort import DeepSORT 5 | from .qdtrack import QDTrack 6 | from .tracktor import Tracktor 7 | 8 | __all__ = [ 9 | 'BaseMultiObjectTracker', 'Tracktor', 'DeepSORT', 'ByteTrack', 'QDTrack' 10 | ] 11 | -------------------------------------------------------------------------------- /mmtracking/configs/sot/siamese_rpn/siamese_rpn_r50_20e_trackingnet.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./siamese_rpn_r50_20e_lasot.py'] 2 | 3 | data_root = 'data/' 4 | # dataset settings 5 | data = dict( 6 | test=dict( 7 | type='TrackingNetDataset', 8 | ann_file=data_root + 9 | 'trackingnet/annotations/trackingnet_test_infos.txt', 10 | img_prefix=data_root + 'trackingnet')) 11 | -------------------------------------------------------------------------------- /yolox/utils/compat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | 4 | import torch 5 | 6 | _TORCH_VER = [int(x) for x in torch.__version__.split(".")[:2]] 7 | 8 | __all__ = ["meshgrid"] 9 | 10 | 11 | def meshgrid(*tensors): 12 | if _TORCH_VER >= [1, 10]: 13 | return torch.meshgrid(*tensors, indexing="ij") 14 | else: 15 | return torch.meshgrid(*tensors) 16 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/core/optimizer/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .sot_lr_updater import SiameseRPNLrUpdaterHook 3 | from .sot_optimizer_hook import (SiameseRPNFp16OptimizerHook, 4 | SiameseRPNOptimizerHook) 5 | 6 | __all__ = [ 7 | 'SiameseRPNOptimizerHook', 'SiameseRPNLrUpdaterHook', 8 | 'SiameseRPNFp16OptimizerHook' 9 | ] 10 | -------------------------------------------------------------------------------- /mmtracking/configs/det/faster-rcnn_r50_fpn_4e_mot17.py: -------------------------------------------------------------------------------- 1 | USE_MMDET = True 2 | _base_ = ['./faster-rcnn_r50_fpn_4e_mot17-half.py'] 3 | # data 4 | data_root = 'data/MOT17/' 5 | data = dict( 6 | train=dict(ann_file=data_root + 'annotations/train_cocoformat.json'), 7 | val=dict(ann_file=data_root + 'annotations/train_cocoformat.json'), 8 | test=dict(ann_file=data_root + 'annotations/train_cocoformat.json')) 9 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/motion/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .camera_motion_compensation import CameraMotionCompensation 3 | from .flownet_simple import FlowNetSimple 4 | from .kalman_filter import KalmanFilter 5 | from .linear_motion import LinearMotion 6 | 7 | __all__ = [ 8 | 'FlowNetSimple', 'CameraMotionCompensation', 'LinearMotion', 'KalmanFilter' 9 | ] 10 | -------------------------------------------------------------------------------- /yolox/data/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | # Copyright (c) Megvii, Inc. and its affiliates. 4 | 5 | from .data_augment import TrainTransform, ValTransform 6 | from .data_prefetcher import DataPrefetcher 7 | from .dataloading import DataLoader, get_yolox_datadir, worker_init_reset_seed 8 | from .datasets import * 9 | from .samplers import InfiniteSampler, YoloBatchSampler 10 | -------------------------------------------------------------------------------- /yolox/data/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | # Copyright (c) Megvii, Inc. and its affiliates. 4 | 5 | from .coco import COCODataset 6 | from .coco_classes import COCO_CLASSES 7 | from .genshin_classes import GENSHIN_CLASSES 8 | from .datasets_wrapper import ConcatDataset, Dataset, MixConcatDataset 9 | from .mosaicdetection import MosaicDetection 10 | from .voc import VOCDetection 11 | -------------------------------------------------------------------------------- /mmtracking/configs/sot/stark/stark_st2_r50_50e_trackingnet.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./stark_st2_r50_50e_lasot.py'] 2 | 3 | # model setting 4 | model = dict(test_cfg=dict(update_intervals=[25])) 5 | 6 | data_root = 'data/' 7 | data = dict( 8 | test=dict( 9 | type='TrackingNetDataset', 10 | ann_file=data_root + 11 | 'trackingnet/annotations/trackingnet_test_infos.txt', 12 | img_prefix=data_root + 'trackingnet')) 13 | -------------------------------------------------------------------------------- /mmtracking/configs/vid/dff/dff_faster_rcnn_x101_dc5_1x_imagenetvid.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./dff_faster_rcnn_r50_dc5_1x_imagenetvid.py'] 2 | model = dict( 3 | detector=dict( 4 | backbone=dict( 5 | type='ResNeXt', 6 | depth=101, 7 | groups=64, 8 | base_width=4, 9 | init_cfg=dict( 10 | type='Pretrained', 11 | checkpoint='open-mmlab://resnext101_64x4d')))) 12 | -------------------------------------------------------------------------------- /mmtracking/configs/vid/fgfa/fgfa_faster_rcnn_x101_dc5_1x_imagenetvid.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./fgfa_faster_rcnn_r50_dc5_1x_imagenetvid.py'] 2 | model = dict( 3 | detector=dict( 4 | backbone=dict( 5 | type='ResNeXt', 6 | depth=101, 7 | groups=64, 8 | base_width=4, 9 | init_cfg=dict( 10 | type='Pretrained', 11 | checkpoint='open-mmlab://resnext101_64x4d')))) 12 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/apis/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .inference import inference_mot, inference_sot, inference_vid, init_model 3 | from .test import multi_gpu_test, single_gpu_test 4 | from .train import init_random_seed, train_model 5 | 6 | __all__ = [ 7 | 'init_model', 'multi_gpu_test', 'single_gpu_test', 'train_model', 8 | 'inference_mot', 'inference_sot', 'inference_vid', 'init_random_seed' 9 | ] 10 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/core/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .anchor import * # noqa: F401, F403 3 | from .bbox import * # noqa: F401, F403 4 | from .evaluation import * # noqa: F401, F403 5 | from .hook import * # noqa: F401, F403 6 | from .motion import * # noqa: F401, F403 7 | from .optimizer import * # noqa: F401, F403 8 | from .track import * # noqa: F401, F403 9 | from .utils import * # noqa: F401, F403 10 | -------------------------------------------------------------------------------- /mmtracking/configs/vid/selsa/selsa_faster_rcnn_x101_dc5_1x_imagenetvid.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./selsa_faster_rcnn_r50_dc5_1x_imagenetvid.py'] 2 | model = dict( 3 | detector=dict( 4 | backbone=dict( 5 | type='ResNeXt', 6 | depth=101, 7 | groups=64, 8 | base_width=4, 9 | init_cfg=dict( 10 | type='Pretrained', 11 | checkpoint='open-mmlab://resnext101_64x4d')))) 12 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/core/track/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .correlation import depthwise_correlation 3 | from .interpolation import interpolate_tracks 4 | from .similarity import embed_similarity 5 | from .transforms import imrenormalize, outs2results, results2outs 6 | 7 | __all__ = [ 8 | 'depthwise_correlation', 'outs2results', 'results2outs', 9 | 'embed_similarity', 'imrenormalize', 'interpolate_tracks' 10 | ] 11 | -------------------------------------------------------------------------------- /yolox/layers/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | # Copyright (c) Megvii Inc. All rights reserved. 4 | 5 | # import torch first to make jit op work without `ImportError of libc10.so` 6 | import torch # noqa 7 | 8 | from .jit_ops import FastCOCOEvalOp, JitOp 9 | 10 | try: 11 | from .fast_coco_eval_api import COCOeval_opt 12 | except ImportError: # exception will be raised when users build yolox from source 13 | pass 14 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/core/bbox/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .iou_calculators import calculate_region_overlap 3 | from .transforms import (bbox_cxcyah_to_xyxy, bbox_cxcywh_to_x1y1wh, 4 | bbox_xyxy_to_cxcyah, bbox_xyxy_to_x1y1wh, quad2bbox) 5 | 6 | __all__ = [ 7 | 'quad2bbox', 'bbox_cxcywh_to_x1y1wh', 'bbox_xyxy_to_x1y1wh', 8 | 'calculate_region_overlap', 'bbox_xyxy_to_cxcyah', 'bbox_cxcyah_to_xyxy' 9 | ] 10 | -------------------------------------------------------------------------------- /mmtracking/configs/README.md: -------------------------------------------------------------------------------- 1 | # Usage of configs 2 | 3 | ## Training with configs 4 | 5 | Please refer to [Training](../docs/en/quick_run.md#training) to see the tutorials of training models. 6 | 7 | ## Testing with configs 8 | 9 | Please refer to [Testing](../docs/en/quick_run.md#testing) to see the tutorials of testing models. 10 | 11 | ## Inference with configs 12 | 13 | Please refer to [Inference](../docs/en/quick_run.md#inference) to see the tutorials of inferencing models. 14 | -------------------------------------------------------------------------------- /mmtracking/configs/vid/temporal_roi_align/selsa_troialign_faster_rcnn_x101_dc5_7e_imagenetvid.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./selsa_troialign_faster_rcnn_r50_dc5_7e_imagenetvid.py'] 2 | model = dict( 3 | detector=dict( 4 | backbone=dict( 5 | type='ResNeXt', 6 | depth=101, 7 | groups=64, 8 | base_width=4, 9 | init_cfg=dict( 10 | type='Pretrained', 11 | checkpoint='open-mmlab://resnext101_64x4d')))) 12 | -------------------------------------------------------------------------------- /yolox/data/datasets/genshin_classes.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | # Copyright (c) Megvii, Inc. and its affiliates. 4 | 5 | # VOC_CLASSES = ( '__background__', # always index 0 6 | GENSHIN_CLASSES = ( 7 | '丘丘人', 8 | '雷史莱姆', 9 | '变异雷史莱姆', 10 | '雷莹术士', 11 | '盗宝团', 12 | '火之债务处理人', 13 | '冰史莱姆', 14 | '冰深渊法师', 15 | '岩龙蜥', 16 | '岩龙蜥_雷', 17 | '火史莱姆', 18 | '大丘丘人', 19 | '火深渊法师', 20 | '雷丘丘王', 21 | '雷深渊法师' 22 | ) 23 | -------------------------------------------------------------------------------- /mmtracking/model-index.yml: -------------------------------------------------------------------------------- 1 | Import: 2 | - configs/mot/deepsort/metafile.yml 3 | - configs/mot/tracktor/metafile.yml 4 | - configs/mot/qdtrack/metafile.yml 5 | - configs/mot/bytetrack/metafile.yml 6 | - configs/sot/siamese_rpn/metafile.yml 7 | - configs/sot/stark/metafile.yml 8 | - configs/vid/dff/metafile.yml 9 | - configs/vid/fgfa/metafile.yml 10 | - configs/vid/selsa/metafile.yml 11 | - configs/vid/temporal_roi_align/metafile.yml 12 | - configs/vis/masktrack_rcnn/metafile.yml 13 | -------------------------------------------------------------------------------- /mmtracking/tools/convert_datasets/got10k/unzip_got10k.sh: -------------------------------------------------------------------------------- 1 | #!bin/bash 2 | 3 | train_dir=$1/full_data/train_data 4 | new_train_dir=$1/train 5 | if [ ! -d $new_train_dir ]; then 6 | mkdir $new_train_dir 7 | fi 8 | cp $train_dir/list.txt $new_train_dir 9 | for x in $(ls $train_dir); do 10 | if [ ${x##*.} == zip ]; then 11 | unzip $train_dir/$x -d $new_train_dir 12 | fi 13 | done 14 | test_zip=$1/full_data/test_data.zip 15 | val_zip=$1/full_data/val_data.zip 16 | unzip $test_zip -d $1 17 | unzip $val_zip -d $1 18 | -------------------------------------------------------------------------------- /mmtracking/configs/sot/README.md: -------------------------------------------------------------------------------- 1 | # Usage of SOT configs 2 | 3 | ## Training with SOT configs 4 | 5 | Please refer to [Train SOT models](../../docs/en/quick_run.md#examples-of-training-sot-model) to see the examples. 6 | 7 | ## Testing with SOT configs 8 | 9 | Please refer to [Test SOT models](../../docs/en/quick_run.md#examples-of-testing-sot-model) to see the examples. 10 | 11 | ## Inference with SOT configs 12 | 13 | Please refer to [Inference SOT models](../../docs/en/quick_run.md#inference-sot-models) to see the examples. 14 | -------------------------------------------------------------------------------- /mmtracking/configs/vid/README.md: -------------------------------------------------------------------------------- 1 | # Usage of VID configs 2 | 3 | ## Training with VID configs 4 | 5 | Please refer to [Train VID models](../../docs/en/quick_run.md#examples-of-training-vid-model) to see the examples. 6 | 7 | ## Testing with VID configs 8 | 9 | Please refer to [Test VID models](../../docs/en/quick_run.md#examples-of-testing-vid-model) to see the examples. 10 | 11 | ## Inference with VID configs 12 | 13 | Please refer to [Inference VID models](../../docs/en/quick_run.md#inference-vid-models) to see the examples. 14 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/README.md: -------------------------------------------------------------------------------- 1 | # Usage of MOT configs 2 | 3 | ## Training with MOT configs 4 | 5 | Please refer to [Train MOT models](../../docs/en/quick_run.md#examples-of-training-mot-model) to see the examples. 6 | 7 | ## Testing with MOT configs 8 | 9 | Please refer to [Test MOT models](../../docs/en/quick_run.md#examples-of-testing-mot-model) to see the examples. 10 | 11 | ## Inference with MOT configs 12 | 13 | Please refer to [Inference MOT models](../../docs/en/quick_run.md#inference-motvis-models) to see the examples. 14 | -------------------------------------------------------------------------------- /mmtracking/configs/vis/README.md: -------------------------------------------------------------------------------- 1 | # Usage of VIS configs 2 | 3 | ## Training with VIS configs 4 | 5 | Please refer to [Train VIS models](../../docs/en/quick_run.md#examples-of-training-vis-model) to see the examples. 6 | 7 | ## Testing with VIS configs 8 | 9 | Please refer to [Test VIS models](../../docs/en/quick_run.md#examples-of-testing-vis-model) to see the examples. 10 | 11 | ## Inference with VIS configs 12 | 13 | Please refer to [Inference VIS models](../../docs/en/quick_run.md#inference-motvis-models) to see the examples. 14 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/core/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .eval_hooks import DistEvalHook, EvalHook 3 | from .eval_mot import eval_mot 4 | from .eval_sot_ope import eval_sot_ope 5 | from .eval_sot_vot import (bbox2region, eval_sot_accuracy_robustness, 6 | eval_sot_eao) 7 | from .eval_vis import eval_vis 8 | 9 | __all__ = [ 10 | 'EvalHook', 'DistEvalHook', 'eval_mot', 'eval_sot_ope', 'bbox2region', 11 | 'eval_sot_eao', 'eval_sot_accuracy_robustness', 'eval_vis' 12 | ] 13 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/utils/logger.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import logging 3 | 4 | from mmcv.utils import get_logger 5 | 6 | 7 | def get_root_logger(log_file=None, log_level=logging.INFO): 8 | """Get root logger. 9 | 10 | Args: 11 | log_file (str): File path of log. Defaults to None. 12 | log_level (int): The level of logger. Defaults to logging.INFO. 13 | 14 | Returns: 15 | :obj:`logging.Logger`: The obtained logger 16 | """ 17 | return get_logger('mmtrack', log_file, log_level) 18 | -------------------------------------------------------------------------------- /mmtracking/tools/dist_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CONFIG=$1 4 | GPUS=$2 5 | NNODES=${NNODES:-1} 6 | NODE_RANK=${NODE_RANK:-0} 7 | PORT=${PORT:-29500} 8 | MASTER_ADDR=${MASTER_ADDR:-"127.0.0.1"} 9 | 10 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 11 | python -m torch.distributed.launch \ 12 | --nnodes=$NNODES \ 13 | --node_rank=$NODE_RANK \ 14 | --master_addr=$MASTER_ADDR \ 15 | --nproc_per_node=$GPUS \ 16 | --master_port=$PORT \ 17 | $(dirname "$0")/test.py \ 18 | $CONFIG \ 19 | --launcher pytorch \ 20 | ${@:3} 21 | -------------------------------------------------------------------------------- /mmtracking/tools/dist_train.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CONFIG=$1 4 | GPUS=$2 5 | NNODES=${NNODES:-1} 6 | NODE_RANK=${NODE_RANK:-0} 7 | PORT=${PORT:-29500} 8 | MASTER_ADDR=${MASTER_ADDR:-"127.0.0.1"} 9 | 10 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 11 | python -m torch.distributed.launch \ 12 | --nnodes=$NNODES \ 13 | --node_rank=$NODE_RANK \ 14 | --master_addr=$MASTER_ADDR \ 15 | --nproc_per_node=$GPUS \ 16 | --master_port=$PORT \ 17 | $(dirname "$0")/train.py \ 18 | $CONFIG \ 19 | --launcher pytorch \ 20 | ${@:3} 21 | -------------------------------------------------------------------------------- /yolox/utils/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | # Copyright (c) Megvii Inc. All rights reserved. 4 | 5 | from .allreduce_norm import * 6 | from .boxes import * 7 | from .checkpoint import load_ckpt, save_checkpoint 8 | from .compat import meshgrid 9 | from .demo_utils import * 10 | from .dist import * 11 | from .ema import * 12 | from .logger import WandbLogger, setup_logger 13 | from .lr_scheduler import LRScheduler 14 | from .metric import * 15 | from .model_utils import * 16 | from .setup_env import * 17 | from .visualize import * 18 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/core/bbox/iou_calculators/region_iou_calculator.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | try: 3 | from vot.region import calculate_overlap 4 | except ImportError: 5 | calculate_overlap = None 6 | 7 | 8 | def calculate_region_overlap(*args, **kwargs): 9 | if calculate_overlap is None: 10 | raise ImportError( 11 | 'Please run' 12 | 'pip install git+https://github.com/votchallenge/toolkit.git' 13 | 'to manually install vot-toolkit') 14 | return calculate_overlap(*args, **kwargs) 15 | -------------------------------------------------------------------------------- /mmtracking/tests/test_models/test_aggregators/test_selsa_aggregator.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch 3 | 4 | from mmtrack.models.aggregators import SelsaAggregator 5 | 6 | 7 | def test_selsa_aggregator(): 8 | """Test selsa_aggregator.""" 9 | # Test embed_aggregator forward 10 | model = SelsaAggregator(in_channels=16, num_attention_blocks=4) 11 | model.train() 12 | 13 | target_x = torch.randn(2, 16) 14 | ref_x = torch.randn(4, 16) 15 | agg_x = model(target_x, ref_x) 16 | assert agg_x.shape == target_x.shape 17 | -------------------------------------------------------------------------------- /mmtracking/tests/test_models/test_losses/test_triplet_loss.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch 3 | 4 | from mmtrack.models import TripletLoss 5 | 6 | 7 | def test_triplet_loss(): 8 | feature = torch.Tensor([[1, 1], [1, 1], [0, 0], [0, 0]]) 9 | label = torch.Tensor([1, 1, 0, 0]) 10 | 11 | loss = TripletLoss(margin=0.3, loss_weight=1.0) 12 | assert torch.allclose(loss(feature, label), torch.tensor(0.)) 13 | 14 | label = torch.Tensor([1, 0, 1, 0]) 15 | assert torch.allclose(loss(feature, label), torch.tensor(1.7142)) 16 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/utils/collect_env.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmcv.utils import collect_env as collect_base_env 3 | from mmcv.utils import get_git_hash 4 | 5 | import mmtrack 6 | 7 | 8 | def collect_env(): 9 | """Collect the information of the running environments.""" 10 | env_info = collect_base_env() 11 | env_info['MMTracking'] = mmtrack.__version__ + '+' + get_git_hash()[:7] 12 | return env_info 13 | 14 | 15 | if __name__ == '__main__': 16 | for name, val in collect_env().items(): 17 | print(f'{name}: {val}') 18 | -------------------------------------------------------------------------------- /yolox/data/datasets/voc_classes.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | # Copyright (c) Megvii, Inc. and its affiliates. 4 | 5 | # VOC_CLASSES = ( '__background__', # always index 0 6 | VOC_CLASSES = ( 7 | "aeroplane", 8 | "bicycle", 9 | "bird", 10 | "boat", 11 | "bottle", 12 | "bus", 13 | "car", 14 | "cat", 15 | "chair", 16 | "cow", 17 | "diningtable", 18 | "dog", 19 | "horse", 20 | "motorbike", 21 | "person", 22 | "pottedplant", 23 | "sheep", 24 | "sofa", 25 | "train", 26 | "tvmonitor", 27 | ) 28 | -------------------------------------------------------------------------------- /mmtracking/configs/det/faster-rcnn_r50_fpn_4e_mot15-half.py: -------------------------------------------------------------------------------- 1 | USE_MMDET = True 2 | _base_ = ['./faster-rcnn_r50_fpn_4e_mot17-half.py'] 3 | # data 4 | data_root = 'data/MOT15/' 5 | data = dict( 6 | train=dict( 7 | ann_file=data_root + 'annotations/half-train_cocoformat.json', 8 | img_prefix=data_root + 'train'), 9 | val=dict( 10 | ann_file=data_root + 'annotations/half-val_cocoformat.json', 11 | img_prefix=data_root + 'train'), 12 | test=dict( 13 | ann_file=data_root + 'annotations/half-val_cocoformat.json', 14 | img_prefix=data_root + 'train')) 15 | -------------------------------------------------------------------------------- /mmtracking/configs/det/faster-rcnn_r50_fpn_4e_mot16-half.py: -------------------------------------------------------------------------------- 1 | USE_MMDET = True 2 | _base_ = ['./faster-rcnn_r50_fpn_4e_mot17-half.py'] 3 | # data 4 | data_root = 'data/MOT16/' 5 | data = dict( 6 | train=dict( 7 | ann_file=data_root + 'annotations/half-train_cocoformat.json', 8 | img_prefix=data_root + 'train'), 9 | val=dict( 10 | ann_file=data_root + 'annotations/half-val_cocoformat.json', 11 | img_prefix=data_root + 'train'), 12 | test=dict( 13 | ann_file=data_root + 'annotations/half-val_cocoformat.json', 14 | img_prefix=data_root + 'train')) 15 | -------------------------------------------------------------------------------- /mmtracking/configs/reid/resnet50_b32x8_MOT15.py: -------------------------------------------------------------------------------- 1 | TRAIN_REID = True 2 | _base_ = ['./resnet50_b32x8_MOT17.py'] 3 | model = dict(reid=dict(head=dict(num_classes=368))) 4 | # data 5 | data_root = 'data/MOT15/' 6 | data = dict( 7 | train=dict( 8 | data_prefix=data_root + 'reid/imgs', 9 | ann_file=data_root + 'reid/meta/train_80.txt'), 10 | val=dict( 11 | data_prefix=data_root + 'reid/imgs', 12 | ann_file=data_root + 'reid/meta/val_20.txt'), 13 | test=dict( 14 | data_prefix=data_root + 'reid/imgs', 15 | ann_file=data_root + 'reid/meta/val_20.txt')) 16 | -------------------------------------------------------------------------------- /mmtracking/configs/reid/resnet50_b32x8_MOT16.py: -------------------------------------------------------------------------------- 1 | TRAIN_REID = True 2 | _base_ = ['./resnet50_b32x8_MOT17.py'] 3 | model = dict(reid=dict(head=dict(num_classes=371))) 4 | # data 5 | data_root = 'data/MOT16/' 6 | data = dict( 7 | train=dict( 8 | data_prefix=data_root + 'reid/imgs', 9 | ann_file=data_root + 'reid/meta/train_80.txt'), 10 | val=dict( 11 | data_prefix=data_root + 'reid/imgs', 12 | ann_file=data_root + 'reid/meta/val_20.txt'), 13 | test=dict( 14 | data_prefix=data_root + 'reid/imgs', 15 | ann_file=data_root + 'reid/meta/val_20.txt')) 16 | -------------------------------------------------------------------------------- /mmtracking/configs/reid/resnet50_b32x8_MOT20.py: -------------------------------------------------------------------------------- 1 | TRAIN_REID = True 2 | _base_ = ['./resnet50_b32x8_MOT17.py'] 3 | model = dict(reid=dict(head=dict(num_classes=1701))) 4 | # data 5 | data_root = 'data/MOT20/' 6 | data = dict( 7 | train=dict( 8 | data_prefix=data_root + 'reid/imgs', 9 | ann_file=data_root + 'reid/meta/train_80.txt'), 10 | val=dict( 11 | data_prefix=data_root + 'reid/imgs', 12 | ann_file=data_root + 'reid/meta/val_20.txt'), 13 | test=dict( 14 | data_prefix=data_root + 'reid/imgs', 15 | ann_file=data_root + 'reid/meta/val_20.txt')) 16 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/version.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Open-MMLab. All rights reserved. 2 | 3 | __version__ = '0.13.0' 4 | 5 | 6 | def parse_version_info(version_str): 7 | version_info = [] 8 | for x in version_str.split('.'): 9 | if x.isdigit(): 10 | version_info.append(int(x)) 11 | elif x.find('rc') != -1: 12 | patch_version = x.split('rc') 13 | version_info.append(int(patch_version[0])) 14 | version_info.append(f'rc{patch_version[1]}') 15 | return tuple(version_info) 16 | 17 | 18 | version_info = parse_version_info(__version__) 19 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/trackers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .base_tracker import BaseTracker 3 | from .byte_tracker import ByteTracker 4 | from .masktrack_rcnn_tracker import MaskTrackRCNNTracker 5 | from .quasi_dense_tao_tracker import QuasiDenseTAOTracker 6 | from .quasi_dense_tracker import QuasiDenseTracker 7 | from .sort_tracker import SortTracker 8 | from .tracktor_tracker import TracktorTracker 9 | 10 | __all__ = [ 11 | 'BaseTracker', 'TracktorTracker', 'SortTracker', 'MaskTrackRCNNTracker', 12 | 'ByteTracker', 'QuasiDenseTracker', 'QuasiDenseTAOTracker' 13 | ] 14 | -------------------------------------------------------------------------------- /mmtracking/configs/vis/masktrack_rcnn/masktrack_rcnn_r101_fpn_12e_youtubevis2019.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./masktrack_rcnn_r50_fpn_12e_youtubevis2019.py'] 2 | model = dict( 3 | detector=dict( 4 | backbone=dict( 5 | depth=101, 6 | init_cfg=dict( 7 | type='Pretrained', checkpoint='torchvision://resnet101')), 8 | init_cfg=dict( 9 | type='Pretrained', 10 | checkpoint= # noqa: E251 11 | 'https://download.openmmlab.com/mmdetection/v2.0/mask_rcnn/mask_rcnn_r101_fpn_1x_coco/mask_rcnn_r101_fpn_1x_coco_20200204-1efe0ed5.pth' # noqa: E501 12 | ))) 13 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/track_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .quasi_dense_embed_head import QuasiDenseEmbedHead 3 | from .quasi_dense_track_head import QuasiDenseTrackHead 4 | from .roi_embed_head import RoIEmbedHead 5 | from .roi_track_head import RoITrackHead 6 | from .siamese_rpn_head import CorrelationHead, SiameseRPNHead 7 | from .stark_head import CornerPredictorHead, StarkHead 8 | 9 | __all__ = [ 10 | 'CorrelationHead', 'SiameseRPNHead', 'RoIEmbedHead', 'RoITrackHead', 11 | 'StarkHead', 'CornerPredictorHead', 'QuasiDenseEmbedHead', 12 | 'QuasiDenseTrackHead' 13 | ] 14 | -------------------------------------------------------------------------------- /mmtracking/tests/test_models/test_losses/test_multi_pos_cross_entropy_loss.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch 3 | 4 | from mmtrack.models import MultiPosCrossEntropyLoss 5 | 6 | 7 | def test_mpce_loss(): 8 | costs = torch.tensor([[1, 0], [0, 1]]) 9 | labels = torch.tensor([[1, 1], [0, 0]]) 10 | 11 | loss = MultiPosCrossEntropyLoss(reduction='mean', loss_weight=1.0) 12 | assert torch.allclose(loss(costs, labels), torch.tensor(0.)) 13 | 14 | labels = torch.Tensor([[1, 0], [0, 1]]) 15 | loss(costs, labels) 16 | assert torch.allclose(loss(costs, labels), torch.tensor(0.31326)) 17 | -------------------------------------------------------------------------------- /mmtracking/configs/det/faster-rcnn_r101_fpn_4e_mot17-half.py: -------------------------------------------------------------------------------- 1 | USE_MMDET = True 2 | _base_ = ['./faster-rcnn_r50_fpn_4e_mot17-half.py'] 3 | model = dict( 4 | detector=dict( 5 | backbone=dict( 6 | depth=101, 7 | init_cfg=dict( 8 | type='Pretrained', checkpoint='torchvision://resnet101')), 9 | init_cfg=dict( 10 | type='Pretrained', 11 | checkpoint= # noqa: E251 12 | 'http://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r101_fpn_2x_coco/faster_rcnn_r101_fpn_2x_coco_bbox_mAP-0.398_20200504_210455-1d2dac9c.pth' # noqa: E501 13 | ))) 14 | -------------------------------------------------------------------------------- /control/Selector.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | class Selector: 4 | def select(self, items:torch.Tensor) -> torch.Tensor: 5 | pass 6 | 7 | class PrioritySelector: 8 | def __init__(self, priority_list): 9 | self.priority_list=torch.arange(0,len(priority_list))[priority_list].int() 10 | 11 | def select(self, items: torch.Tensor) -> torch.Tensor: 12 | i_pri = self.priority_list[items[:,4].int()] #类别->优先级 13 | idx = i_pri.argmax() 14 | return items[idx,:] 15 | 16 | class ConfSelector: 17 | def select(self, items: torch.Tensor) -> torch.Tensor: 18 | idx = items[:,5].argmax() 19 | return items[idx,:] -------------------------------------------------------------------------------- /mmtracking/.dev_scripts/benchmark/batch_train_list.txt: -------------------------------------------------------------------------------- 1 | # VID 2 | configs/vid/dff/dff_faster_rcnn_r50_dc5_1x_imagenetvid.py 3 | configs/vid/fgfa/fgfa_faster_rcnn_r50_dc5_1x_imagenetvid.py 4 | configs/vid/selsa/selsa_faster_rcnn_r50_dc5_1x_imagenetvid.py 5 | configs/vid/temporal_roi_align/selsa_troialign_faster_rcnn_r50_dc5_7e_imagenetvid.py 6 | 7 | # MOT 8 | configs/mot/deepsort/deepsort_faster-rcnn_fpn_4e_mot17-private-half.py 9 | configs/mot/tracktor/tracktor_faster-rcnn_r50_fpn_4e_mot17-private-half.py 10 | configs/mot/bytetrack/bytetrack_yolox_x_crowdhuman_mot17-private-half.py 11 | 12 | # SOT 13 | configs/sot/siamese_rpn/siamese_rpn_r50_20e_lasot.py 14 | -------------------------------------------------------------------------------- /mmtracking/setup.cfg: -------------------------------------------------------------------------------- 1 | [isort] 2 | line_length = 79 3 | multi_line_output = 0 4 | extra_standard_library = setuptools 5 | known_first_party = mmtrack 6 | known_third_party = PIL,addict,cv2,dotty_dict,lap,matplotlib,mmcls,mmcv,mmdet,motmetrics,numpy,packaging,pandas,pycocotools,pytest,pytorch_sphinx_theme,requests,scipy,script_utils,seaborn,tao,terminaltables,torch,tqdm 7 | no_lines_before = STDLIB,LOCALFOLDER 8 | default_section = THIRDPARTY 9 | 10 | [yapf] 11 | BASED_ON_STYLE = pep8 12 | BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF = true 13 | SPLIT_BEFORE_EXPRESSION_AFTER_OPENING_PAREN = true 14 | 15 | [codespell] 16 | ignore-words-list = mot 17 | skip = *.json 18 | -------------------------------------------------------------------------------- /mmtracking/tools/slurm_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | 5 | PARTITION=$1 6 | JOB_NAME=$2 7 | CONFIG=$3 8 | GPUS=$4 9 | GPUS_PER_NODE=${GPUS_PER_NODE:-8} 10 | CPUS_PER_TASK=${CPUS_PER_TASK:-2} 11 | PY_ARGS=${@:5} 12 | SRUN_ARGS=${SRUN_ARGS:-""} 13 | 14 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 15 | srun -p ${PARTITION} \ 16 | --job-name=${JOB_NAME} \ 17 | --gres=gpu:${GPUS_PER_NODE} \ 18 | --ntasks=${GPUS} \ 19 | --ntasks-per-node=${GPUS_PER_NODE} \ 20 | --cpus-per-task=${CPUS_PER_TASK} \ 21 | --kill-on-bad-exit=1 \ 22 | ${SRUN_ARGS} \ 23 | python -u $(dirname "$0")/test.py ${CONFIG} --launcher="slurm" ${PY_ARGS} 24 | -------------------------------------------------------------------------------- /mmtracking/tools/analysis/mot/slurm_mot_search.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | 5 | PARTITION=$1 6 | JOB_NAME=$2 7 | CONFIG=$3 8 | GPUS=$4 9 | GPUS_PER_NODE=${GPUS_PER_NODE:-8} 10 | CPUS_PER_TASK=${CPUS_PER_TASK:-2} 11 | PY_ARGS=${@:5} 12 | SRUN_ARGS=${SRUN_ARGS:-""} 13 | 14 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 15 | srun -p ${PARTITION} \ 16 | --job-name=${JOB_NAME} \ 17 | --gres=gpu:${GPUS_PER_NODE} \ 18 | --ntasks=${GPUS} \ 19 | --ntasks-per-node=${GPUS_PER_NODE} \ 20 | --cpus-per-task=${CPUS_PER_TASK} \ 21 | --kill-on-bad-exit=1 \ 22 | ${SRUN_ARGS} \ 23 | python -u $(dirname "$0")/mot_param_search.py ${CONFIG} --launcher="slurm" ${PY_ARGS} 24 | -------------------------------------------------------------------------------- /mmtracking/tests/test_models/test_motion/test_camera_motion_compensation.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import numpy as np 3 | import torch 4 | from mmdet.core.bbox.demodata import random_boxes 5 | 6 | from mmtrack.models.motion import CameraMotionCompensation 7 | 8 | 9 | def test_cmc(): 10 | cmc = CameraMotionCompensation() 11 | img = np.random.randn(256, 256, 3).astype(np.float32) 12 | ref_img = img 13 | 14 | warp_matrix = cmc.get_warp_matrix(img, ref_img) 15 | assert isinstance(warp_matrix, torch.Tensor) 16 | 17 | bboxes = random_boxes(5, 256) 18 | trans_bboxes = cmc.warp_bboxes(bboxes, warp_matrix) 19 | assert (bboxes == trans_bboxes).all() 20 | -------------------------------------------------------------------------------- /mmtracking/tools/slurm_train.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | 5 | PARTITION=$1 6 | JOB_NAME=$2 7 | CONFIG=$3 8 | WORK_DIR=$4 9 | GPUS=$5 10 | GPUS_PER_NODE=${GPUS_PER_NODE:-8} 11 | CPUS_PER_TASK=${CPUS_PER_TASK:-2} 12 | SRUN_ARGS=${SRUN_ARGS:-""} 13 | PY_ARGS=${@:6} 14 | 15 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 16 | srun -p ${PARTITION} \ 17 | --job-name=${JOB_NAME} \ 18 | --gres=gpu:${GPUS_PER_NODE} \ 19 | --ntasks=${GPUS} \ 20 | --ntasks-per-node=${GPUS_PER_NODE} \ 21 | --cpus-per-task=${CPUS_PER_TASK} \ 22 | --kill-on-bad-exit=1 \ 23 | ${SRUN_ARGS} \ 24 | python -u $(dirname "$0")/train.py ${CONFIG} --work-dir=${WORK_DIR} --launcher="slurm" ${PY_ARGS} 25 | -------------------------------------------------------------------------------- /mmtracking/tools/analysis/sot/slurm_sot_siamrpn_search.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | 5 | PARTITION=$1 6 | JOB_NAME=$2 7 | CONFIG=$3 8 | GPUS=$4 9 | GPUS_PER_NODE=${GPUS_PER_NODE:-8} 10 | CPUS_PER_TASK=${CPUS_PER_TASK:-2} 11 | PY_ARGS=${@:5} 12 | SRUN_ARGS=${SRUN_ARGS:-""} 13 | 14 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 15 | srun -p ${PARTITION} \ 16 | --job-name=${JOB_NAME} \ 17 | --gres=gpu:${GPUS_PER_NODE} \ 18 | --ntasks=${GPUS} \ 19 | --ntasks-per-node=${GPUS_PER_NODE} \ 20 | --cpus-per-task=${CPUS_PER_TASK} \ 21 | --kill-on-bad-exit=1 \ 22 | ${SRUN_ARGS} \ 23 | python -u $(dirname "$0")/sot_siamrpn_param_search.py ${CONFIG} --launcher="slurm" ${PY_ARGS} 24 | -------------------------------------------------------------------------------- /mmtracking/configs/sot/siamese_rpn/siamese_rpn_r50_20e_uav123.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./siamese_rpn_r50_20e_lasot.py'] 2 | 3 | # model settings 4 | model = dict( 5 | test_cfg=dict(rpn=dict(penalty_k=0.1, window_influence=0.1, lr=0.5))) 6 | 7 | data_root = 'data/' 8 | # dataset settings 9 | data = dict( 10 | val=dict( 11 | type='UAV123Dataset', 12 | ann_file=data_root + 'UAV123/annotations/uav123_infos.txt', 13 | img_prefix=data_root + 'UAV123', 14 | only_eval_visible=False), 15 | test=dict( 16 | type='UAV123Dataset', 17 | ann_file=data_root + 'UAV123/annotations/uav123_infos.txt', 18 | img_prefix=data_root + 'UAV123', 19 | only_eval_visible=False)) 20 | -------------------------------------------------------------------------------- /mmtracking/tests/test_models/test_motion/test_flownet_simple.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch 3 | 4 | from mmtrack.models.motion import FlowNetSimple 5 | 6 | 7 | def test_flownet_simple(): 8 | # Test flownet_simple forward 9 | model = FlowNetSimple(img_scale_factor=0.5) 10 | model.init_weights() 11 | model.train() 12 | 13 | imgs = torch.randn(2, 6, 224, 224) 14 | img_metas = [ 15 | dict( 16 | img_norm_cfg=dict( 17 | mean=(123.675, 116.28, 103.53), std=(58.395, 57.12, 57.375)), 18 | img_shape=(224, 224, 3)) 19 | ] 20 | flow = model(imgs, img_metas) 21 | assert flow.shape == torch.Size([2, 2, 224, 224]) 22 | -------------------------------------------------------------------------------- /mmtracking/docs/en/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /mmtracking/docs/zh_cn/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /mmtracking/configs/_base_/default_runtime.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001) 3 | optimizer_config = dict(grad_clip=None) 4 | checkpoint_config = dict(interval=1) 5 | # yapf:disable 6 | log_config = dict( 7 | interval=50, 8 | hooks=[ 9 | dict(type='TextLoggerHook'), 10 | # dict(type='TensorboardLoggerHook') 11 | ]) 12 | # yapf:enable 13 | dist_params = dict(backend='nccl') 14 | log_level = 'INFO' 15 | load_from = None 16 | resume_from = None 17 | workflow = [('train', 1)] 18 | 19 | # disable opencv multithreading to avoid system being overloaded 20 | opencv_num_threads = 0 21 | # set multi-process start method as `fork` to speed up the training 22 | mp_start_method = 'fork' 23 | -------------------------------------------------------------------------------- /mmtracking/configs/vis/masktrack_rcnn/masktrack_rcnn_x101_fpn_12e_youtubevis2019.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./masktrack_rcnn_r50_fpn_12e_youtubevis2019.py'] 2 | model = dict( 3 | detector=dict( 4 | backbone=dict( 5 | type='ResNeXt', 6 | depth=101, 7 | groups=64, 8 | base_width=4, 9 | init_cfg=dict( 10 | type='Pretrained', 11 | checkpoint='open-mmlab://resnext101_64x4d')), 12 | init_cfg=dict( 13 | type='Pretrained', 14 | checkpoint= # noqa: E251 15 | 'https://download.openmmlab.com/mmdetection/v2.0/mask_rcnn/mask_rcnn_x101_64x4d_fpn_1x_coco/mask_rcnn_x101_64x4d_fpn_1x_coco_20200201-9352eb0d.pth' # noqa: E501 16 | ))) 17 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/tracktor/tracktor_faster-rcnn_r50_fpn_fp16_4e_mot17-private-half.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./tracktor_faster-rcnn_r50_fpn_4e_mot17-private-half.py'] 2 | 3 | model = dict( 4 | detector=dict( 5 | init_cfg=dict( 6 | type='Pretrained', 7 | checkpoint= # noqa: E251 8 | 'https://download.openmmlab.com/mmtracking/fp16/faster-rcnn_r50_fpn_fp16_4e_mot17-half_20210730_002436-f4ba7d61.pth' # noqa: E501 9 | )), 10 | reid=dict( 11 | init_cfg=dict( 12 | type='Pretrained', 13 | checkpoint= # noqa: E251 14 | 'https://download.openmmlab.com/mmtracking/fp16/reid_r50_fp16_8x32_6e_mot17_20210731_033055-4747ee95.pth' # noqa: E501 15 | ))) 16 | fp16 = dict(loss_scale=512.) 17 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/deepsort/sort_faster-rcnn_fpn_4e_mot17-private.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./sort_faster-rcnn_fpn_4e_mot17-private-half.py'] 2 | model = dict( 3 | detector=dict( 4 | init_cfg=dict( 5 | type='Pretrained', 6 | checkpoint= # noqa: E251 7 | 'https://download.openmmlab.com/mmtracking/mot/faster_rcnn/faster-rcnn_r50_fpn_4e_mot17-ffa52ae7.pth' # noqa: E501 8 | ))) 9 | data_root = 'data/MOT17/' 10 | test_set = 'train' 11 | data = dict( 12 | train=dict(ann_file=data_root + 'annotations/train_cocoformat.json'), 13 | val=dict(ann_file=data_root + 'annotations/train_cocoformat.json'), 14 | test=dict( 15 | ann_file=data_root + f'annotations/{test_set}_cocoformat.json', 16 | img_prefix=data_root + test_set)) 17 | -------------------------------------------------------------------------------- /mmtracking/tools/analysis/print_config.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import argparse 3 | 4 | from mmcv import Config, DictAction 5 | 6 | 7 | def parse_args(): 8 | parser = argparse.ArgumentParser(description='Print the whole config') 9 | parser.add_argument('config', help='config file path') 10 | parser.add_argument( 11 | '--options', nargs='+', action=DictAction, help='arguments in dict') 12 | args = parser.parse_args() 13 | 14 | return args 15 | 16 | 17 | def main(): 18 | args = parse_args() 19 | 20 | cfg = Config.fromfile(args.config) 21 | if args.options is not None: 22 | cfg.merge_from_dict(args.options) 23 | print(f'Config:\n{cfg.pretty_text}') 24 | 25 | 26 | if __name__ == '__main__': 27 | main() 28 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/tracktor/tracktor_faster-rcnn_r50_fpn_4e_mot17-private.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./tracktor_faster-rcnn_r50_fpn_4e_mot17-private-half.py'] 2 | 3 | model = dict( 4 | detector=dict( 5 | init_cfg=dict( 6 | type='Pretrained', 7 | checkpoint= # noqa: E251 8 | 'https://download.openmmlab.com/mmtracking/mot/faster_rcnn/faster-rcnn_r50_fpn_4e_mot17-ffa52ae7.pth' # noqa: E501 9 | ))) 10 | # data 11 | data_root = 'data/MOT17/' 12 | test_set = 'test' 13 | data = dict( 14 | train=dict(ann_file=data_root + 'annotations/train_cocoformat.json'), 15 | val=dict(ann_file=data_root + 'annotations/train_cocoformat.json'), 16 | test=dict( 17 | ann_file=data_root + f'annotations/{test_set}_cocoformat.json', 18 | img_prefix=data_root + test_set)) 19 | -------------------------------------------------------------------------------- /mmtracking/configs/vis/masktrack_rcnn/masktrack_rcnn_r50_fpn_12e_youtubevis2021.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./masktrack_rcnn_r50_fpn_12e_youtubevis2019.py'] 2 | 3 | data_root = 'data/youtube_vis_2021/' 4 | dataset_version = data_root[-5:-1] 5 | data = dict( 6 | train=dict( 7 | dataset_version=dataset_version, 8 | ann_file=data_root + 'annotations/youtube_vis_2021_train.json', 9 | img_prefix=data_root + 'train/JPEGImages'), 10 | val=dict( 11 | dataset_version=dataset_version, 12 | ann_file=data_root + 'annotations/youtube_vis_2021_valid.json', 13 | img_prefix=data_root + 'valid/JPEGImages'), 14 | test=dict( 15 | dataset_version=dataset_version, 16 | ann_file=data_root + 'annotations/youtube_vis_2021_valid.json', 17 | img_prefix=data_root + 'valid/JPEGImages')) 18 | -------------------------------------------------------------------------------- /mmtracking/configs/_base_/datasets/lvis_v1_instance.py: -------------------------------------------------------------------------------- 1 | _base_ = 'coco_instance.py' 2 | dataset_type = 'LVISV1Dataset' 3 | data_root = 'data/lvis_v1/' 4 | data = dict( 5 | samples_per_gpu=2, 6 | workers_per_gpu=2, 7 | train=dict( 8 | _delete_=True, 9 | type='ClassBalancedDataset', 10 | oversample_thr=1e-3, 11 | dataset=dict( 12 | type=dataset_type, 13 | ann_file=data_root + 'annotations/lvis_v1_train.json', 14 | img_prefix=data_root)), 15 | val=dict( 16 | type=dataset_type, 17 | ann_file=data_root + 'annotations/lvis_v1_val.json', 18 | img_prefix=data_root), 19 | test=dict( 20 | type=dataset_type, 21 | ann_file=data_root + 'annotations/lvis_v1_val.json', 22 | img_prefix=data_root)) 23 | evaluation = dict(metric=['bbox', 'segm']) 24 | -------------------------------------------------------------------------------- /mmtracking/configs/sot/siamese_rpn/siamese_rpn_r50_20e_vot2018.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./siamese_rpn_r50_20e_lasot.py'] 2 | 3 | # model settings 4 | model = dict( 5 | test_cfg=dict( 6 | rpn=dict(penalty_k=0.04, window_influence=0.44, lr=0.33), 7 | test_mode='VOT')) 8 | 9 | data_root = 'data/' 10 | # dataset settings 11 | data = dict( 12 | val=dict( 13 | type='VOTDataset', 14 | dataset_type='vot2018', 15 | ann_file=data_root + 'vot2018/annotations/vot2018_infos.txt', 16 | img_prefix=data_root + 'vot2018'), 17 | test=dict( 18 | type='VOTDataset', 19 | dataset_type='vot2018', 20 | ann_file=data_root + 'vot2018/annotations/vot2018_infos.txt', 21 | img_prefix=data_root + 'vot2018')) 22 | evaluation = dict( 23 | metric=['track'], interval=1, start=10, rule='greater', save_best='eao') 24 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | addict==2.4.0 2 | beautifulsoup4==4.11.1 3 | dotty_dict==1.3.1 4 | imutils==0.5.4 5 | lap==0.4.0 6 | loguru==0.5.3 7 | lvis==0.5.3 8 | matplotlib==3.5.0 9 | mmcls==0.23.2 10 | mmcv==1.6.1 11 | mmcv_full==1.5.3 12 | mmdet==2.25.1 13 | model_archiver==1.0.3 14 | motmetrics==1.2.5 15 | ninja==1.10.2.3 16 | numpy==1.20.3 17 | opencv_python_headless==4.5.4.60 18 | packaging==21.3 19 | pandas==1.3.5 20 | Pillow==9.2.0 21 | pycocotools==2.0.2 22 | pytest==7.1.2 23 | pytorch_sphinx_theme==0.0.19 24 | pywin32==302 25 | PyYAML==6.0 26 | requests==2.26.0 27 | scipy==1.6.2 28 | seaborn==0.11.2 29 | setuptools==58.0.4 30 | tabulate==0.8.9 31 | terminaltables==3.1.10 32 | thop==0.0.31.post2005241907 33 | torch==1.8.2+cu111 34 | torchvision==0.9.2+cu111 35 | tqdm==4.62.3 36 | ts==0.5.1 37 | voice==0.1.0 38 | wandb==0.12.18 39 | win32gui==221.6 40 | xlrd==2.0.1 41 | xlutils==2.0.0 42 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/core/track/correlation.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch.nn.functional as F 3 | 4 | 5 | def depthwise_correlation(x, kernel): 6 | """Depthwise cross correlation. 7 | 8 | This function is proposed in 9 | `SiamRPN++ `_. 10 | 11 | Args: 12 | x (Tensor): of shape (N, C, H_x, W_x). 13 | kernel (Tensor): of shape (N, C, H_k, W_k). 14 | 15 | Returns: 16 | Tensor: of shape (N, C, H_o, W_o). H_o = H_x - H_k + 1. So does W_o. 17 | """ 18 | batch = kernel.size(0) 19 | channel = kernel.size(1) 20 | x = x.view(1, batch * channel, x.size(2), x.size(3)) 21 | kernel = kernel.view(batch * channel, 1, kernel.size(2), kernel.size(3)) 22 | out = F.conv2d(x, kernel, groups=batch * channel) 23 | out = out.view(batch, channel, out.size(2), out.size(3)) 24 | return out 25 | -------------------------------------------------------------------------------- /mmtracking/tools/convert_datasets/otb100/unzip_otb100.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | data_dir=$1 4 | if [ ! -d $data_dir/data ]; then 5 | mkdir $data_dir/data 6 | fi 7 | for zips in $(ls "${data_dir}/zips"); do 8 | if [ ${zips##*.} == "zip" ]; then 9 | vid_name=${zips%.zip} 10 | # echo $vid_name 11 | unzip -q $data_dir/zips/$zips -d $data_dir/data/ 12 | 13 | # clean up unnecessary files 14 | for x in $(ls "$data_dir/data/$vid_name/img" -a); do 15 | if [ ! -d $x ] && [[ ${x#*.} != "jpg" ]]; then 16 | echo "delete $data_dir/data/$vid_name/img/$x" 17 | rm -f $data_dir/data/$vid_name/img/$x 18 | fi 19 | done 20 | fi 21 | done 22 | # clean up unnecessary folds 23 | if [ -d "${data_dir}/data/__MACOSX" ]; then 24 | echo delete "${data_dir}/data/__MACOSX" 25 | rm -rf "${data_dir}/data/__MACOSX" 26 | fi 27 | -------------------------------------------------------------------------------- /mmtracking/configs/_base_/datasets/lvis_v0.5_instance.py: -------------------------------------------------------------------------------- 1 | _base_ = 'coco_instance.py' 2 | dataset_type = 'LVISV05Dataset' 3 | data_root = 'data/lvis_v0.5/' 4 | data = dict( 5 | samples_per_gpu=2, 6 | workers_per_gpu=2, 7 | train=dict( 8 | _delete_=True, 9 | type='ClassBalancedDataset', 10 | oversample_thr=1e-3, 11 | dataset=dict( 12 | type=dataset_type, 13 | ann_file=data_root + 'annotations/lvis_v0.5_train.json', 14 | img_prefix=data_root + 'train2017/')), 15 | val=dict( 16 | type=dataset_type, 17 | ann_file=data_root + 'annotations/lvis_v0.5_val.json', 18 | img_prefix=data_root + 'val2017/'), 19 | test=dict( 20 | type=dataset_type, 21 | ann_file=data_root + 'annotations/lvis_v0.5_val.json', 22 | img_prefix=data_root + 'val2017/')) 23 | evaluation = dict(metric=['bbox', 'segm']) 24 | -------------------------------------------------------------------------------- /mmtracking/tools/convert_datasets/trackingnet/unzip_trackinget.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | data_dir=$1 4 | for chunk in $(ls "${data_dir}"); do 5 | # unzip chunk zip 6 | if [ ${chunk##*.} == "zip" ]; then 7 | chunk_name=${chunk%.zip} 8 | unzip_dir=$data_dir/$chunk_name 9 | if [ ! -d $unzip_dir ]; then 10 | mkdir $unzip_dir 11 | fi 12 | unzip -n $data_dir/$chunk -d $unzip_dir 13 | 14 | # unzip zips in every chunk 15 | for zips in $(ls "${unzip_dir}/zips"); do 16 | if [ ${zips##*.} == "zip" ]; then 17 | vid_name=${zips%.zip} 18 | if [ ! -d $unzip_dir/frames/$vid_name ]; then 19 | mkdir -p $unzip_dir/frames/$vid_name 20 | fi 21 | unzip -n $unzip_dir/zips/$zips -d $unzip_dir/frames/$vid_name 22 | fi 23 | done 24 | fi 25 | done 26 | -------------------------------------------------------------------------------- /mmtracking/configs/_base_/models/yolox_x_8x8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | img_scale = (640, 640) 3 | 4 | model = dict( 5 | detector=dict( 6 | type='YOLOX', 7 | input_size=img_scale, 8 | random_size_range=(15, 25), 9 | random_size_interval=10, 10 | backbone=dict( 11 | type='CSPDarknet', deepen_factor=1.33, widen_factor=1.25), 12 | neck=dict( 13 | type='YOLOXPAFPN', 14 | in_channels=[320, 640, 1280], 15 | out_channels=320, 16 | num_csp_blocks=4), 17 | bbox_head=dict( 18 | type='YOLOXHead', 19 | num_classes=80, 20 | in_channels=320, 21 | feat_channels=320), 22 | train_cfg=dict( 23 | assigner=dict(type='SimOTAAssigner', center_radius=2.5)), 24 | test_cfg=dict( 25 | score_thr=0.01, nms=dict(type='nms', iou_threshold=0.65)))) 26 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/roi_heads/roi_extractors/single_level_roi_extractor.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmcv.runner import force_fp32 3 | from mmdet.models.builder import ROI_EXTRACTORS 4 | from mmdet.models.roi_heads.roi_extractors import \ 5 | SingleRoIExtractor as _SingleRoIExtractor 6 | 7 | 8 | @ROI_EXTRACTORS.register_module(force=True) 9 | class SingleRoIExtractor(_SingleRoIExtractor): 10 | """Extract RoI features from a single level feature map. 11 | 12 | This Class is the same as `SingleRoIExtractor` from 13 | `mmdet.models.roi_heads.roi_extractors` except for using `**kwargs` to 14 | accept external arguments. 15 | """ 16 | 17 | @force_fp32(apply_to=('feats', ), out_fp16=True) 18 | def forward(self, feats, rois, roi_scale_factor=None, **kwargs): 19 | """Forward function.""" 20 | return super().forward(feats, rois, roi_scale_factor) 21 | -------------------------------------------------------------------------------- /mmtracking/docs/en/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /mmtracking/docs/zh_cn/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/reid/gap.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch.nn as nn 3 | from mmcls.models.builder import NECKS 4 | from mmcls.models.necks import GlobalAveragePooling as _GlobalAveragePooling 5 | 6 | 7 | @NECKS.register_module(force=True) 8 | class GlobalAveragePooling(_GlobalAveragePooling): 9 | """Global Average Pooling neck. 10 | 11 | Note that we use `view` to remove extra channel after pooling. We do not 12 | use `squeeze` as it will also remove the batch dimension when the tensor 13 | has a batch dimension of size 1, which can lead to unexpected errors. 14 | """ 15 | 16 | def __init__(self, kernel_size=None, stride=None): 17 | super(GlobalAveragePooling, self).__init__() 18 | if kernel_size is None and stride is None: 19 | self.gap = nn.AdaptiveAvgPool2d((1, 1)) 20 | else: 21 | self.gap = nn.AvgPool2d(kernel_size, stride) 22 | -------------------------------------------------------------------------------- /mmtracking/tools/analysis/mot/mot_dummy_results.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import argparse 3 | import os 4 | import os.path as osp 5 | 6 | import mmcv 7 | 8 | 9 | def parse_args(): 10 | parser = argparse.ArgumentParser( 11 | description='Make dummy results for MOT Challenge.') 12 | parser.add_argument('json_file', help='Input JSON file.') 13 | parser.add_argument('out_folder', help='Output folder.') 14 | args = parser.parse_args() 15 | return args 16 | 17 | 18 | def main(): 19 | args = parse_args() 20 | anns = mmcv.load(args.json_file) 21 | 22 | if not osp.exists(args.out_folder): 23 | os.makedirs(args.out_folder) 24 | for video in anns['videos']: 25 | name = video['name'] 26 | txt_name = f'{name}.txt' 27 | f = open(osp.join(args.out_folder, txt_name), 'wt') 28 | f.close() 29 | 30 | 31 | if __name__ == '__main__': 32 | main() 33 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/deepsort/sort_faster-rcnn_fpn_4e_mot17-public.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./sort_faster-rcnn_fpn_4e_mot17-public-half.py'] 2 | model = dict( 3 | detector=dict( 4 | init_cfg=dict( 5 | type='Pretrained', 6 | checkpoint= # noqa: E251 7 | 'https://download.openmmlab.com/mmtracking/mot/faster_rcnn/faster-rcnn_r50_fpn_4e_mot17-ffa52ae7.pth' # noqa: E501 8 | ))) 9 | data_root = 'data/MOT17/' 10 | test_set = 'train' 11 | data = dict( 12 | train=dict(ann_file=data_root + 'annotations/train_cocoformat.json'), 13 | val=dict( 14 | ann_file=data_root + 'annotations/train_cocoformat.json', 15 | detection_file=data_root + 'annotations/train_detections.pkl'), 16 | test=dict( 17 | ann_file=data_root + f'annotations/{test_set}_cocoformat.json', 18 | img_prefix=data_root + test_set, 19 | detection_file=data_root + f'annotations/{test_set}_detections.pkl')) 20 | -------------------------------------------------------------------------------- /mmtracking/docs/zh_cn/index.rst: -------------------------------------------------------------------------------- 1 | 欢迎来到 MMTracking 的中文文档! 2 | ======================================= 3 | 4 | 您可以在页面左下角切换中英文文档。 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | :caption: 开始你的第一步 9 | 10 | install.md 11 | modelzoo_statistics.md 12 | model_zoo.md 13 | 14 | .. toctree:: 15 | :maxdepth: 2 16 | :caption: 快速启动 17 | 18 | dataset.md 19 | quick_run.md 20 | 21 | 22 | .. toctree:: 23 | :maxdepth: 2 24 | :caption: 教程 25 | 26 | tutorials/index.rst 27 | 28 | .. toctree:: 29 | :maxdepth: 2 30 | :caption: 实用工具与脚本 31 | 32 | useful_tools_scripts.md 33 | 34 | .. toctree:: 35 | :maxdepth: 2 36 | :caption: 说明 37 | 38 | changelog.md 39 | 40 | 41 | .. toctree:: 42 | :caption: 语言切换 43 | 44 | switch_language.md 45 | 46 | 47 | .. toctree:: 48 | :caption: 接口文档(英文) 49 | 50 | api.rst 51 | 52 | 53 | Indices and tables 54 | ================== 55 | 56 | * :ref:`genindex` 57 | * :ref:`search` 58 | -------------------------------------------------------------------------------- /mmtracking/configs/det/faster-rcnn_r50_fpn_4e_mot17-half.py: -------------------------------------------------------------------------------- 1 | USE_MMDET = True 2 | _base_ = [ 3 | '../_base_/models/faster_rcnn_r50_fpn.py', 4 | '../_base_/datasets/mot_challenge_det.py', '../_base_/default_runtime.py' 5 | ] 6 | model = dict( 7 | detector=dict( 8 | rpn_head=dict(bbox_coder=dict(clip_border=False)), 9 | roi_head=dict( 10 | bbox_head=dict(bbox_coder=dict(clip_border=False), num_classes=1)), 11 | init_cfg=dict( 12 | type='Pretrained', 13 | checkpoint= # noqa: E251 14 | 'http://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_2x_coco/faster_rcnn_r50_fpn_2x_coco_bbox_mAP-0.384_20200504_210434-a5d8aa15.pth' # noqa: E501 15 | ))) 16 | # learning policy 17 | lr_config = dict( 18 | policy='step', 19 | warmup='linear', 20 | warmup_iters=100, 21 | warmup_ratio=1.0 / 100, 22 | step=[3]) 23 | # runtime settings 24 | total_epochs = 4 25 | -------------------------------------------------------------------------------- /mmtracking/Interface.py: -------------------------------------------------------------------------------- 1 | import os 2 | import os.path as osp 3 | import tempfile 4 | from argparse import ArgumentParser 5 | 6 | import cv2 7 | import mmcv 8 | import torch 9 | 10 | from mmtrack.apis import inference_sot, init_model 11 | 12 | class TrackerInterface: 13 | def __init__(self, config='mmtracking/configs/sot/siamese_rpn/siamese_rpn_r50_20e_lasot.py', 14 | checkpoint='mmtracking/checkpoints/siamese_rpn_r50_20e_lasot_20220420_181845-dd0f151e.pth'): 15 | self.config=config 16 | self.checkpoint=checkpoint 17 | self.device='cuda:0' 18 | 19 | self.model = init_model(config, checkpoint, device=self.device) 20 | 21 | def reset(self, init_bbox): 22 | self.frame_id=0 23 | self.init_bbox=init_bbox 24 | 25 | @torch.no_grad() 26 | def predict(self, img): 27 | result = inference_sot(self.model, img, self.init_bbox, frame_id=self.frame_id) 28 | self.frame_id+=1 29 | return result['track_bboxes'] -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .aggregators import * # noqa: F401,F403 3 | from .backbones import * # noqa: F401,F403 4 | from .builder import (AGGREGATORS, MODELS, MOTION, REID, TRACKERS, 5 | build_aggregator, build_model, build_motion, build_reid, 6 | build_tracker) 7 | from .losses import * # noqa: F401,F403 8 | from .mot import * # noqa: F401,F403 9 | from .motion import * # noqa: F401,F403 10 | from .reid import * # noqa: F401,F403 11 | from .roi_heads import * # noqa: F401,F403 12 | from .sot import * # noqa: F401,F403 13 | from .track_heads import * # noqa: F401,F403 14 | from .trackers import * # noqa: F401,F403 15 | from .vid import * # noqa: F401,F403 16 | from .vis import * # noqa: F401,F403 17 | 18 | __all__ = [ 19 | 'AGGREGATORS', 'MODELS', 'TRACKERS', 'MOTION', 'REID', 'build_model', 20 | 'build_tracker', 'build_motion', 'build_aggregator', 'build_reid' 21 | ] 22 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/qdtrack/qdtrack_faster-rcnn_r101_fpn_12e_tao.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | _base_ = ['./qdtrack_faster-rcnn_r101_fpn_24e_lvis.py'] 3 | model = dict(freeze_detector=True) 4 | data_root = 'data/tao/' 5 | data = dict( 6 | samples_per_gpu=2, 7 | workers_per_gpu=2, 8 | train=dict( 9 | dataset=dict( 10 | classes=data_root + 'annotations/tao_classes.txt', 11 | ann_file=data_root + 'annotations/train_482_classes.json', 12 | img_prefix=data_root + 'train/', 13 | load_as_video=True, 14 | key_img_sampler=dict(interval=1), 15 | ref_img_sampler=dict( 16 | num_ref_imgs=1, frame_range=[-1, 1], method='uniform')))) 17 | # learning policy 18 | lr_config = dict(step=[8, 11]) 19 | total_epochs = 12 20 | optimizer = dict(type='SGD', lr=0.002, momentum=0.9, weight_decay=0.0001) 21 | load_from = None 22 | resume_from = None 23 | evaluation = dict(metric=['track'], start=1, interval=1) 24 | work_dir = None 25 | -------------------------------------------------------------------------------- /mmtracking/configs/det/faster-rcnn_r50_fpn_8e_mot20.py: -------------------------------------------------------------------------------- 1 | USE_MMDET = True 2 | _base_ = ['./faster-rcnn_r50_fpn_4e_mot17-half.py'] 3 | model = dict( 4 | detector=dict( 5 | rpn_head=dict(bbox_coder=dict(clip_border=True)), 6 | roi_head=dict( 7 | bbox_head=dict(bbox_coder=dict(clip_border=True), num_classes=1)))) 8 | # data 9 | data_root = 'data/MOT20/' 10 | data = dict( 11 | train=dict( 12 | ann_file=data_root + 'annotations/train_cocoformat.json', 13 | img_prefix=data_root + 'train'), 14 | val=dict( 15 | ann_file=data_root + 'annotations/train_cocoformat.json', 16 | img_prefix=data_root + 'train'), 17 | test=dict( 18 | ann_file=data_root + 'annotations/train_cocoformat.json', 19 | img_prefix=data_root + 'train')) 20 | # learning policy 21 | lr_config = dict( 22 | policy='step', 23 | warmup='linear', 24 | warmup_iters=100, 25 | warmup_ratio=1.0 / 100, 26 | step=[6]) 27 | # runtime settings 28 | total_epochs = 8 29 | -------------------------------------------------------------------------------- /mmtracking/configs/det/faster-rcnn_r50_fpn_8e_mot20-half.py: -------------------------------------------------------------------------------- 1 | USE_MMDET = True 2 | _base_ = ['./faster-rcnn_r50_fpn_4e_mot17-half.py'] 3 | model = dict( 4 | detector=dict( 5 | rpn_head=dict(bbox_coder=dict(clip_border=True)), 6 | roi_head=dict( 7 | bbox_head=dict(bbox_coder=dict(clip_border=True), num_classes=1)))) 8 | # data 9 | data_root = 'data/MOT20/' 10 | data = dict( 11 | train=dict( 12 | ann_file=data_root + 'annotations/half-train_cocoformat.json', 13 | img_prefix=data_root + 'train'), 14 | val=dict( 15 | ann_file=data_root + 'annotations/half-val_cocoformat.json', 16 | img_prefix=data_root + 'train'), 17 | test=dict( 18 | ann_file=data_root + 'annotations/half-val_cocoformat.json', 19 | img_prefix=data_root + 'train')) 20 | # learning policy 21 | lr_config = dict( 22 | policy='step', 23 | warmup='linear', 24 | warmup_iters=100, 25 | warmup_ratio=1.0 / 100, 26 | step=[6]) 27 | # runtime settings 28 | total_epochs = 8 29 | -------------------------------------------------------------------------------- /mmtracking/tests/test_core/test_track/test_interpolation.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import numpy as np 3 | 4 | 5 | def test_interpolate_tracks(): 6 | from mmtrack.core import interpolate_tracks 7 | frame_id = np.arange(100) // 10 8 | tracklet_id = np.random.randint(low=1, high=5, size=(100)) 9 | bboxes = np.random.random((100, 4)) * 100 10 | scores = np.random.random((100)) * 100 11 | in_results = np.concatenate( 12 | (frame_id[:, None], tracklet_id[:, None], bboxes, scores[:, None]), 13 | axis=1) 14 | out_results = interpolate_tracks(in_results) 15 | assert out_results.shape[1] == in_results.shape[1] 16 | # the range of frame ids should not change 17 | assert min(out_results[:, 0]) == min(in_results[:, 0]) 18 | assert max(out_results[:, 0]) == max(in_results[:, 0]) 19 | # the range of track ids should not change 20 | assert min(out_results[:, 1]) == min(in_results[:, 1]) 21 | assert max(out_results[:, 1]) == max(in_results[:, 1]) 22 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/datasets/dancetrack_dataset.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmdet.datasets import DATASETS 3 | 4 | from .mot_challenge_dataset import MOTChallengeDataset 5 | 6 | 7 | @DATASETS.register_module() 8 | class DanceTrackDataset(MOTChallengeDataset): 9 | """Dataset for DanceTrack: https://github.com/DanceTrack/DanceTrack. 10 | 11 | Most content is inherited from MOTChallengeDataset. 12 | """ 13 | 14 | def get_benchmark_and_eval_split(self): 15 | """Get benchmark and dataset split to evaluate. 16 | 17 | Get benchmark from upeper/lower-case image prefix and the dataset 18 | split to evaluate. 19 | 20 | Returns: 21 | tuple(string): The first string denotes the type of dataset. 22 | The second string denots the split of the dataset to eval. 23 | """ 24 | # As DanceTrack only has train/val and use 'val' for evaluation as 25 | # default, we can directly output the desired split. 26 | return 'DanceTrack', 'val' 27 | -------------------------------------------------------------------------------- /mmtracking/tests/test_models/test_roi_heads/test_roi_extractors/test_single_level_roi_extractor.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch 3 | 4 | from mmtrack.models.roi_heads.roi_extractors import SingleRoIExtractor 5 | 6 | 7 | def test_single_roi_extractor(): 8 | """Tests single roi extractor.""" 9 | single_roi_extractor_config = dict( 10 | roi_layer=dict(type='RoIAlign', output_size=7, sampling_ratio=0), 11 | out_channels=256, 12 | featmap_strides=[4, 8, 16, 32]) 13 | self = SingleRoIExtractor(**single_roi_extractor_config) 14 | 15 | feats = ( 16 | torch.rand((1, 256, 200, 336)), 17 | torch.rand((1, 256, 100, 168)), 18 | torch.rand((1, 256, 50, 84)), 19 | torch.rand((1, 256, 25, 42)), 20 | ) 21 | 22 | rois = torch.tensor([[0.0000, 587.8285, 52.1405, 886.2484, 341.5644]]) 23 | # test allowing to accept external arguments by **kwargs 24 | roi_feats = self(feats, rois, variable=1) 25 | assert roi_feats.shape == torch.Size([1, 256, 7, 7]) 26 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/builder.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmcv.cnn import MODELS as MMCV_MODELS 3 | from mmcv.utils import Registry 4 | 5 | MODELS = Registry('models', parent=MMCV_MODELS) 6 | TRACKERS = MODELS 7 | MOTION = MODELS 8 | REID = MODELS 9 | AGGREGATORS = MODELS 10 | 11 | 12 | def build_tracker(cfg): 13 | """Build tracker.""" 14 | return TRACKERS.build(cfg) 15 | 16 | 17 | def build_motion(cfg): 18 | """Build motion model.""" 19 | return MOTION.build(cfg) 20 | 21 | 22 | def build_reid(cfg): 23 | """Build reid model.""" 24 | return REID.build(cfg) 25 | 26 | 27 | def build_aggregator(cfg): 28 | """Build aggregator model.""" 29 | return AGGREGATORS.build(cfg) 30 | 31 | 32 | def build_model(cfg, train_cfg=None, test_cfg=None): 33 | """Build model.""" 34 | if train_cfg is None and test_cfg is None: 35 | return MODELS.build(cfg) 36 | else: 37 | return MODELS.build(cfg, MODELS, 38 | dict(train_cfg=train_cfg, test_cfg=test_cfg)) 39 | -------------------------------------------------------------------------------- /mmtracking/tests/test_core/test_motion/test_flow.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import pytest 3 | import torch 4 | 5 | from mmtrack.core import flow_warp_feats 6 | 7 | 8 | def test_flow_warp_feats(): 9 | flow = torch.randn(2, 2, 10, 10) 10 | ref_x = torch.randn(2, 8, 32, 32) 11 | x = flow_warp_feats(ref_x, flow) 12 | assert x.shape == ref_x.shape 13 | 14 | with pytest.raises(AssertionError): 15 | # the length of ref_x.shape must be 4 16 | flow = torch.randn(2, 2, 10, 10) 17 | ref_x = torch.randn(2, 8, 32, 32, 32) 18 | x = flow_warp_feats(ref_x, flow) 19 | 20 | with pytest.raises(AssertionError): 21 | # the length of flow.shape must be 4 22 | flow = torch.randn(2, 2, 10, 10, 10) 23 | ref_x = torch.randn(2, 8, 32, 32) 24 | x = flow_warp_feats(ref_x, flow) 25 | 26 | with pytest.raises(AssertionError): 27 | # flow.shape[1] == 2 28 | flow = torch.randn(2, 3, 10, 10) 29 | ref_x = torch.randn(2, 8, 32, 32) 30 | x = flow_warp_feats(ref_x, flow) 31 | -------------------------------------------------------------------------------- /mmtracking/tests/test_data/test_datasets/utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from collections import defaultdict 3 | 4 | import numpy as np 5 | 6 | 7 | def _create_coco_gt_results(dataset): 8 | from mmtrack.core import outs2results 9 | 10 | results = defaultdict(list) 11 | for img_info in dataset.data_infos: 12 | ann = dataset.get_ann_info(img_info) 13 | scores = np.ones((ann['bboxes'].shape[0], 1), dtype=np.float) 14 | bboxes = np.concatenate((ann['bboxes'], scores), axis=1) 15 | det_results = outs2results( 16 | bboxes=bboxes, 17 | labels=ann['labels'], 18 | num_classes=len(dataset.CLASSES)) 19 | track_results = outs2results( 20 | bboxes=bboxes, 21 | labels=ann['labels'], 22 | ids=ann['instance_ids'].astype(np.int), 23 | num_classes=len(dataset.CLASSES)) 24 | results['det_bboxes'].append(det_results['bbox_results']) 25 | results['track_bboxes'].append(track_results['bbox_results']) 26 | return results 27 | -------------------------------------------------------------------------------- /mmtracking/docs/en/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to MMTracking's documentation! 2 | ======================================= 3 | 4 | You can switch between Chinese and English documents in the lower-left corner of the layout. 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | :caption: Get Started 9 | 10 | install.md 11 | modelzoo_statistics.md 12 | model_zoo.md 13 | 14 | .. toctree:: 15 | :maxdepth: 2 16 | :caption: Quick run 17 | 18 | dataset.md 19 | quick_run.md 20 | 21 | 22 | .. toctree:: 23 | :maxdepth: 2 24 | :caption: Tutorials 25 | 26 | tutorials/index.rst 27 | 28 | .. toctree:: 29 | :maxdepth: 2 30 | :caption: Useful Tools and Scripts 31 | 32 | useful_tools_scripts.md 33 | 34 | .. toctree:: 35 | :maxdepth: 2 36 | :caption: Notes 37 | 38 | changelog.md 39 | 40 | 41 | .. toctree:: 42 | :caption: Switch Language 43 | 44 | switch_language.md 45 | 46 | 47 | .. toctree:: 48 | :caption: API Reference 49 | 50 | api.rst 51 | 52 | 53 | Indices and tables 54 | ================== 55 | 56 | * :ref:`genindex` 57 | * :ref:`search` 58 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/core/utils/image.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import cv2 3 | import numpy as np 4 | 5 | 6 | def crop_image(image, crop_region, crop_size, padding=(0, 0, 0)): 7 | """Crop image based on `crop_region` and `crop_size`. 8 | 9 | Args: 10 | image (ndarray): of shape (H, W, 3). 11 | crop_region (ndarray): of shape (4, ) in [x1, y1, x2, y2] format. 12 | crop_size (int): Crop size. 13 | padding (tuple | ndarray): of shape (3, ) denoting the padding values. 14 | 15 | Returns: 16 | ndarray: Cropped image of shape (crop_size, crop_size, 3). 17 | """ 18 | a = crop_size / (crop_region[2] - crop_region[0]) 19 | b = crop_size / (crop_region[3] - crop_region[1]) 20 | c = -a * crop_region[0] 21 | d = -b * crop_region[1] 22 | mapping = np.array([[a, 0, c], [0, b, d]]).astype(np.float32) 23 | crop_image = cv2.warpAffine( 24 | image, 25 | mapping, (crop_size, crop_size), 26 | borderMode=cv2.BORDER_CONSTANT, 27 | borderValue=padding) 28 | return crop_image 29 | -------------------------------------------------------------------------------- /yolox/tools/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | # Copyright (c) Megvii Inc. All rights reserved. 4 | 5 | # This file is used for package installation. Script of train/eval/export will be available. 6 | 7 | import importlib 8 | import sys 9 | from pathlib import Path 10 | 11 | _TOOLS_PATH = Path(__file__).resolve().parent.parent.parent / "tools" 12 | 13 | if _TOOLS_PATH.is_dir(): 14 | # This is true only for in-place installation (pip install -e, setup.py develop), 15 | # where setup(package_dir=) does not work: https://github.com/pypa/setuptools/issues/230 16 | 17 | class _PathFinder(importlib.abc.MetaPathFinder): 18 | 19 | def find_spec(self, name, path, target=None): 20 | if not name.startswith("yolox.tools."): 21 | return 22 | project_name = name.split(".")[-1] + ".py" 23 | target_file = _TOOLS_PATH / project_name 24 | if not target_file.is_file(): 25 | return 26 | return importlib.util.spec_from_file_location(name, target_file) 27 | 28 | sys.meta_path.append(_PathFinder()) 29 | -------------------------------------------------------------------------------- /yolox/exp/default/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | # Copyright (c) Megvii Inc. All rights reserved. 4 | 5 | # This file is used for package installation and find default exp file 6 | 7 | import importlib 8 | import sys 9 | from pathlib import Path 10 | 11 | _EXP_PATH = Path(__file__).resolve().parent.parent.parent.parent / "exps" / "default" 12 | 13 | if _EXP_PATH.is_dir(): 14 | # This is true only for in-place installation (pip install -e, setup.py develop), 15 | # where setup(package_dir=) does not work: https://github.com/pypa/setuptools/issues/230 16 | 17 | class _ExpFinder(importlib.abc.MetaPathFinder): 18 | 19 | def find_spec(self, name, path, target=None): 20 | if not name.startswith("yolox.exp.default"): 21 | return 22 | project_name = name.split(".")[-1] + ".py" 23 | target_file = _EXP_PATH / project_name 24 | if not target_file.is_file(): 25 | return 26 | return importlib.util.spec_from_file_location(name, target_file) 27 | 28 | sys.meta_path.append(_ExpFinder()) 29 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/deepsort/sort_faster-rcnn_fpn_4e_mot17-public-half.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./sort_faster-rcnn_fpn_4e_mot17-private-half.py'] 2 | data_root = 'data/MOT17/' 3 | img_norm_cfg = dict( 4 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 5 | test_pipeline = [ 6 | dict(type='LoadImageFromFile'), 7 | dict(type='LoadDetections'), 8 | dict( 9 | type='MultiScaleFlipAug', 10 | img_scale=(1088, 1088), 11 | flip=False, 12 | transforms=[ 13 | dict(type='Resize', keep_ratio=True), 14 | dict(type='RandomFlip'), 15 | dict(type='Normalize', **img_norm_cfg), 16 | dict(type='Pad', size_divisor=32), 17 | dict(type='ImageToTensor', keys=['img']), 18 | dict(type='VideoCollect', keys=['img', 'public_bboxes']) 19 | ]) 20 | ] 21 | data = dict( 22 | val=dict( 23 | detection_file=data_root + 'annotations/half-val_detections.pkl', 24 | pipeline=test_pipeline), 25 | test=dict( 26 | detection_file=data_root + 'annotations/half-val_detections.pkl', 27 | pipeline=test_pipeline)) 28 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/deepsort/deepsort_faster-rcnn_fpn_4e_mot17-public-half.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./deepsort_faster-rcnn_fpn_4e_mot17-private-half.py'] 2 | data_root = 'data/MOT17/' 3 | img_norm_cfg = dict( 4 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 5 | test_pipeline = [ 6 | dict(type='LoadImageFromFile'), 7 | dict(type='LoadDetections'), 8 | dict( 9 | type='MultiScaleFlipAug', 10 | img_scale=(1088, 1088), 11 | flip=False, 12 | transforms=[ 13 | dict(type='Resize', keep_ratio=True), 14 | dict(type='RandomFlip'), 15 | dict(type='Normalize', **img_norm_cfg), 16 | dict(type='Pad', size_divisor=32), 17 | dict(type='ImageToTensor', keys=['img']), 18 | dict(type='VideoCollect', keys=['img', 'public_bboxes']) 19 | ]) 20 | ] 21 | data = dict( 22 | val=dict( 23 | detection_file=data_root + 'annotations/half-val_detections.pkl', 24 | pipeline=test_pipeline), 25 | test=dict( 26 | detection_file=data_root + 'annotations/half-val_detections.pkl', 27 | pipeline=test_pipeline)) 28 | -------------------------------------------------------------------------------- /mmtracking/tests/test_models/test_aggregators/test_embed_aggregator.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import pytest 3 | import torch 4 | 5 | from mmtrack.models.aggregators import EmbedAggregator 6 | 7 | 8 | def test_embed_aggregator(): 9 | """Test embed_aggregator.""" 10 | with pytest.raises(AssertionError): 11 | # The number of convs must be bigger than 1. 12 | model = EmbedAggregator(num_convs=0, channels=32, kernel_size=3) 13 | 14 | with pytest.raises(AssertionError): 15 | # Only support 'batch_size == 1' for target_x 16 | model = EmbedAggregator(num_convs=3, channels=32, kernel_size=3) 17 | model.train() 18 | 19 | target_x = torch.randn(2, 32, 224, 224) 20 | ref_x = torch.randn(4, 32, 224, 224) 21 | agg_x = model(target_x, ref_x) 22 | 23 | # Test embed_aggregator forward 24 | model = EmbedAggregator(num_convs=3, channels=32, kernel_size=3) 25 | model.train() 26 | 27 | target_x = torch.randn(1, 32, 224, 224) 28 | ref_x = torch.randn(4, 32, 224, 224) 29 | agg_x = model(target_x, ref_x) 30 | assert agg_x.shape == target_x.shape 31 | -------------------------------------------------------------------------------- /mmtracking/tests/test_models/test_roi_heads/test_roi_extractors/test_temporal_roi_align.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch 3 | 4 | from mmtrack.models.roi_heads.roi_extractors import TemporalRoIAlign 5 | 6 | 7 | def test_temporal_roi_align(): 8 | """Test Temporal RoI Align.""" 9 | temporal_roi_align_config = dict( 10 | num_most_similar_points=2, 11 | num_temporal_attention_blocks=4, 12 | roi_layer=dict(type='RoIAlign', output_size=7, sampling_ratio=2), 13 | out_channels=256, 14 | featmap_strides=[16]) 15 | self = TemporalRoIAlign(**temporal_roi_align_config) 16 | 17 | feats = (torch.rand((1, 256, 50, 84)), ) 18 | ref_feats = (feats[0].repeat((2, 1, 1, 1)), ) 19 | rois = torch.tensor([[0.0000, 587.8285, 52.1405, 886.2484, 341.5644]]) 20 | 21 | # test when ref_feats is not None 22 | roi_feats = self(feats, rois, ref_feats=ref_feats) 23 | assert roi_feats.shape == torch.Size([1, 256, 7, 7]) 24 | 25 | # test when ref_feats is None 26 | roi_feats = self(feats, rois, ref_feats=None) 27 | assert roi_feats.shape == torch.Size([1, 256, 7, 7]) 28 | -------------------------------------------------------------------------------- /mmtracking/configs/vid/fgfa/fgfa_faster_rcnn_r50_dc5_1x_imagenetvid.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../../_base_/models/faster_rcnn_r50_dc5.py', 3 | '../../_base_/datasets/imagenet_vid_fgfa_style.py', 4 | '../../_base_/default_runtime.py' 5 | ] 6 | model = dict( 7 | type='FGFA', 8 | motion=dict( 9 | type='FlowNetSimple', 10 | img_scale_factor=0.5, 11 | init_cfg=dict( 12 | type='Pretrained', 13 | checkpoint= # noqa: E251 14 | 'https://download.openmmlab.com/mmtracking/pretrained_weights/flownet_simple.pth' # noqa: E501 15 | )), 16 | aggregator=dict( 17 | type='EmbedAggregator', num_convs=1, channels=512, kernel_size=3)) 18 | 19 | # optimizer 20 | optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) 21 | optimizer_config = dict( 22 | _delete_=True, grad_clip=dict(max_norm=35, norm_type=2)) 23 | # learning policy 24 | lr_config = dict( 25 | policy='step', 26 | warmup='linear', 27 | warmup_iters=500, 28 | warmup_ratio=1.0 / 3, 29 | step=[2, 5]) 30 | # runtime settings 31 | total_epochs = 7 32 | evaluation = dict(metric=['bbox'], interval=7) 33 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/tracktor/tracktor_faster-rcnn_r50_fpn_4e_mot17-public-half.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./tracktor_faster-rcnn_r50_fpn_4e_mot17-private-half.py'] 2 | # data 3 | data_root = 'data/MOT17/' 4 | img_norm_cfg = dict( 5 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 6 | test_pipeline = [ 7 | dict(type='LoadImageFromFile'), 8 | dict(type='LoadDetections'), 9 | dict( 10 | type='MultiScaleFlipAug', 11 | img_scale=(1088, 1088), 12 | flip=False, 13 | transforms=[ 14 | dict(type='Resize', keep_ratio=True), 15 | dict(type='RandomFlip'), 16 | dict(type='Normalize', **img_norm_cfg), 17 | dict(type='Pad', size_divisor=32), 18 | dict(type='ImageToTensor', keys=['img']), 19 | dict(type='VideoCollect', keys=['img', 'public_bboxes']) 20 | ]) 21 | ] 22 | data = dict( 23 | val=dict( 24 | detection_file=data_root + 'annotations/half-val_detections.pkl', 25 | pipeline=test_pipeline), 26 | test=dict( 27 | detection_file=data_root + 'annotations/half-val_detections.pkl', 28 | pipeline=test_pipeline)) 29 | -------------------------------------------------------------------------------- /mmtracking/tests/test_version.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmtrack import digit_version 3 | 4 | 5 | def test_digit_version(): 6 | assert digit_version('0.2.16') == (0, 2, 16, 0, 0, 0) 7 | assert digit_version('1.2.3') == (1, 2, 3, 0, 0, 0) 8 | assert digit_version('1.2.3rc0') == (1, 2, 3, 0, -1, 0) 9 | assert digit_version('1.2.3rc1') == (1, 2, 3, 0, -1, 1) 10 | assert digit_version('1.0rc0') == (1, 0, 0, 0, -1, 0) 11 | assert digit_version('1.0') == digit_version('1.0.0') 12 | assert digit_version('1.5.0+cuda90_cudnn7.6.3_lms') == digit_version('1.5') 13 | assert digit_version('1.0.0dev') < digit_version('1.0.0a') 14 | assert digit_version('1.0.0a') < digit_version('1.0.0a1') 15 | assert digit_version('1.0.0a') < digit_version('1.0.0b') 16 | assert digit_version('1.0.0b') < digit_version('1.0.0rc') 17 | assert digit_version('1.0.0rc1') < digit_version('1.0.0') 18 | assert digit_version('1.0.0') < digit_version('1.0.0post') 19 | assert digit_version('1.0.0post') < digit_version('1.0.0post1') 20 | assert digit_version('v1') == (1, 0, 0, 0, 0, 0) 21 | assert digit_version('v1.1.5') == (1, 1, 5, 0, 0, 0) 22 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/core/track/similarity.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch 3 | import torch.nn.functional as F 4 | 5 | 6 | def embed_similarity(key_embeds, 7 | ref_embeds, 8 | method='dot_product', 9 | temperature=-1): 10 | """Calculate feature similarity from embeddings. 11 | 12 | Args: 13 | key_embeds (Tensor): Shape (N1, C). 14 | ref_embeds (Tensor): Shape (N2, C). 15 | method (str, optional): Method to calculate the similarity, 16 | options are 'dot_product' and 'cosine'. Defaults to 17 | 'dot_product'. 18 | temperature (int, optional): Softmax temperature. Defaults to -1. 19 | 20 | Returns: 21 | Tensor: Similarity matrix of shape (N1, N2). 22 | """ 23 | assert method in ['dot_product', 'cosine'] 24 | 25 | if method == 'cosine': 26 | key_embeds = F.normalize(key_embeds, p=2, dim=1) 27 | ref_embeds = F.normalize(ref_embeds, p=2, dim=1) 28 | 29 | similarity = torch.mm(key_embeds, ref_embeds.T) 30 | 31 | if temperature > 0: 32 | similarity /= float(temperature) 33 | return similarity 34 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/deepsort/sort_faster-rcnn_fpn_4e_mot17-private-half.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../../_base_/models/faster_rcnn_r50_fpn.py', 3 | '../../_base_/datasets/mot_challenge.py', '../../_base_/default_runtime.py' 4 | ] 5 | model = dict( 6 | type='DeepSORT', 7 | detector=dict( 8 | rpn_head=dict(bbox_coder=dict(clip_border=False)), 9 | roi_head=dict( 10 | bbox_head=dict(bbox_coder=dict(clip_border=False), num_classes=1)), 11 | init_cfg=dict( 12 | type='Pretrained', 13 | checkpoint= # noqa: E251 14 | 'https://download.openmmlab.com/mmtracking/mot/faster_rcnn/faster-rcnn_r50_fpn_4e_mot17-half-64ee2ed4.pth' # noqa: E501 15 | )), 16 | motion=dict(type='KalmanFilter', center_only=False), 17 | tracker=dict( 18 | type='SortTracker', obj_score_thr=0.5, match_iou_thr=0.5, reid=None)) 19 | # learning policy 20 | lr_config = dict( 21 | policy='step', 22 | warmup='linear', 23 | warmup_iters=100, 24 | warmup_ratio=1.0 / 100, 25 | step=[3]) 26 | # runtime settings 27 | total_epochs = 4 28 | evaluation = dict(metric=['bbox', 'track'], interval=1) 29 | search_metrics = ['MOTA', 'IDF1', 'FN', 'FP', 'IDs', 'MT', 'ML'] 30 | -------------------------------------------------------------------------------- /mmtracking/tests/test_core/test_track/test_similarity.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch 3 | 4 | 5 | def test_embed_similarity(): 6 | from mmtrack.core import embed_similarity 7 | key_embeds = torch.randn(20, 256) 8 | ref_embeds = torch.randn(10, 256) 9 | 10 | sims = embed_similarity( 11 | key_embeds, ref_embeds, method='dot_product', temperature=-1) 12 | assert sims.size() == (20, 10) 13 | 14 | sims = embed_similarity( 15 | key_embeds, ref_embeds, method='dot_product', temperature=0.07) 16 | assert sims.size() == (20, 10) 17 | 18 | sims = embed_similarity( 19 | key_embeds, ref_embeds, method='cosine', temperature=-1) 20 | assert sims.size() == (20, 10) 21 | assert sims.max() <= 1 22 | 23 | key_embeds = torch.randn(20, 256) 24 | ref_embeds = torch.randn(0, 256) 25 | sims = embed_similarity( 26 | key_embeds, ref_embeds, method='cosine', temperature=-1) 27 | assert sims.size() == (20, 0) 28 | 29 | key_embeds = torch.randn(0, 256) 30 | ref_embeds = torch.randn(10, 256) 31 | sims = embed_similarity( 32 | key_embeds, ref_embeds, method='dot_product', temperature=0.07) 33 | assert sims.size() == (0, 10) 34 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/tracktor/tracktor_faster-rcnn_r50_fpn_4e_mot15-private-half.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./tracktor_faster-rcnn_r50_fpn_4e_mot17-private-half.py'] 2 | 3 | model = dict( 4 | detector=dict( 5 | init_cfg=dict( 6 | type='Pretrained', 7 | checkpoint= # noqa: E251 8 | 'https://download.openmmlab.com/mmtracking/mot/faster_rcnn/faster-rcnn_r50_fpn_4e_mot15-half_20210804_001040-ae733d0c.pth' # noqa: E501 9 | )), 10 | reid=dict( 11 | head=dict(num_classes=375), 12 | init_cfg=dict( 13 | type='Pretrained', 14 | checkpoint= # noqa: E251 15 | 'https://download.openmmlab.com/mmtracking/mot/reid/reid_r50_6e_mot15_20210803_192157-65b5e2d7.pth' # noqa: E501 16 | ))) 17 | # data 18 | data_root = 'data/MOT15/' 19 | data = dict( 20 | train=dict( 21 | ann_file=data_root + 'annotations/half-train_cocoformat.json', 22 | img_prefix=data_root + 'train'), 23 | val=dict( 24 | ann_file=data_root + 'annotations/half-val_cocoformat.json', 25 | img_prefix=data_root + 'train'), 26 | test=dict( 27 | ann_file=data_root + 'annotations/half-val_cocoformat.json', 28 | img_prefix=data_root + 'train')) 29 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/tracktor/tracktor_faster-rcnn_r50_fpn_4e_mot16-private-half.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./tracktor_faster-rcnn_r50_fpn_4e_mot17-private-half.py'] 2 | 3 | model = dict( 4 | detector=dict( 5 | init_cfg=dict( 6 | type='Pretrained', 7 | checkpoint= # noqa: E251 8 | 'https://download.openmmlab.com/mmtracking/mot/faster_rcnn/faster-rcnn_r50_fpn_4e_mot16-half_20210804_001054-73477869.pth' # noqa: E501 9 | )), 10 | reid=dict( 11 | head=dict(num_classes=375), 12 | init_cfg=dict( 13 | type='Pretrained', 14 | checkpoint= # noqa: E251 15 | 'https://download.openmmlab.com/mmtracking/mot/reid/reid_r50_6e_mot16_20210803_204826-1b3e3cfd.pth' # noqa: E501 16 | ))) 17 | # data 18 | data_root = 'data/MOT16/' 19 | data = dict( 20 | train=dict( 21 | ann_file=data_root + 'annotations/half-train_cocoformat.json', 22 | img_prefix=data_root + 'train'), 23 | val=dict( 24 | ann_file=data_root + 'annotations/half-val_cocoformat.json', 25 | img_prefix=data_root + 'train'), 26 | test=dict( 27 | ann_file=data_root + 'annotations/half-val_cocoformat.json', 28 | img_prefix=data_root + 'train')) 29 | -------------------------------------------------------------------------------- /mmtracking/configs/vid/dff/dff_faster_rcnn_r50_dc5_1x_imagenetvid.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../../_base_/models/faster_rcnn_r50_dc5.py', 3 | '../../_base_/datasets/imagenet_vid_dff_style.py', 4 | '../../_base_/default_runtime.py' 5 | ] 6 | model = dict( 7 | type='DFF', 8 | detector=dict( 9 | train_cfg=dict( 10 | rpn_proposal=dict(max_per_img=1000), 11 | rcnn=dict(sampler=dict(num=512)))), 12 | motion=dict( 13 | type='FlowNetSimple', 14 | img_scale_factor=0.5, 15 | init_cfg=dict( 16 | type='Pretrained', 17 | checkpoint= # noqa: E251 18 | 'https://download.openmmlab.com/mmtracking/pretrained_weights/flownet_simple.pth' # noqa: E501 19 | )), 20 | train_cfg=None, 21 | test_cfg=dict(key_frame_interval=10)) 22 | 23 | # optimizer 24 | optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) 25 | optimizer_config = dict( 26 | _delete_=True, grad_clip=dict(max_norm=35, norm_type=2)) 27 | # learning policy 28 | lr_config = dict( 29 | policy='step', 30 | warmup='linear', 31 | warmup_iters=500, 32 | warmup_ratio=1.0 / 3, 33 | step=[2, 5]) 34 | # runtime settings 35 | total_epochs = 7 36 | evaluation = dict(metric=['bbox'], interval=7) 37 | -------------------------------------------------------------------------------- /mmtracking/tests/test_data/test_datasets/test_vis_dataset.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import os.path as osp 3 | from collections import defaultdict 4 | 5 | import mmcv 6 | import numpy as np 7 | 8 | from mmtrack.datasets import DATASETS as DATASETS 9 | 10 | PREFIX = osp.join(osp.dirname(__file__), '../../data') 11 | 12 | DEMO_ANN_FILE = f'{PREFIX}/demo_vis_data/ann.json' 13 | DEMO_RES_FILE = f'{PREFIX}/demo_vis_data/results.json' 14 | 15 | 16 | def test_vis_evaluation(): 17 | dataset_class = DATASETS.get('YouTubeVISDataset') 18 | dataset_object = dataset_class( 19 | '2019', ann_file=DEMO_ANN_FILE, pipeline=[], test_mode=True) 20 | results_json = mmcv.load(DEMO_RES_FILE) 21 | 22 | results = defaultdict(list) 23 | track_bboxes_numpy = [] 24 | for frame_bboxes in results_json['track_bboxes']: 25 | tmp = [] 26 | for bbox in frame_bboxes: 27 | tmp.append(np.array(bbox).reshape(-1, 6)) 28 | track_bboxes_numpy.append(tmp) 29 | results['track_bboxes'] = track_bboxes_numpy 30 | results['track_masks'] = results_json['track_masks'] 31 | 32 | eval_results = dataset_object.evaluate(results, metric=['track_segm']) 33 | assert eval_results['segm_mAP_50'] == 1.0 34 | assert eval_results['segm_mAP'] == 1.0 35 | -------------------------------------------------------------------------------- /mmtracking/configs/vis/masktrack_rcnn/masktrack_rcnn_r101_fpn_12e_youtubevis2021.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./masktrack_rcnn_r50_fpn_12e_youtubevis2019.py'] 2 | model = dict( 3 | detector=dict( 4 | backbone=dict( 5 | depth=101, 6 | init_cfg=dict( 7 | type='Pretrained', checkpoint='torchvision://resnet101')), 8 | init_cfg=dict( 9 | type='Pretrained', 10 | checkpoint= # noqa: E251 11 | 'https://download.openmmlab.com/mmdetection/v2.0/mask_rcnn/mask_rcnn_r101_fpn_1x_coco/mask_rcnn_r101_fpn_1x_coco_20200204-1efe0ed5.pth' # noqa: E501 12 | ))) 13 | 14 | data_root = 'data/youtube_vis_2021/' 15 | dataset_version = data_root[-5:-1] 16 | data = dict( 17 | train=dict( 18 | dataset_version=dataset_version, 19 | ann_file=data_root + 'annotations/youtube_vis_2021_train.json', 20 | img_prefix=data_root + 'train/JPEGImages'), 21 | val=dict( 22 | dataset_version=dataset_version, 23 | ann_file=data_root + 'annotations/youtube_vis_2021_valid.json', 24 | img_prefix=data_root + 'valid/JPEGImages'), 25 | test=dict( 26 | dataset_version=dataset_version, 27 | ann_file=data_root + 'annotations/youtube_vis_2021_valid.json', 28 | img_prefix=data_root + 'valid/JPEGImages')) 29 | -------------------------------------------------------------------------------- /mmtracking/tests/test_models/test_backones/test_sot_resnet.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import pytest 3 | import torch 4 | 5 | from mmtrack.models.backbones import SOTResNet 6 | 7 | 8 | def test_sot_resnet_backbone(): 9 | """Test sot resnet backbone.""" 10 | with pytest.raises(AssertionError): 11 | # ResNet depth should be 50 12 | SOTResNet(20) 13 | 14 | # Test SOTResNet50 with layers 2, 3, 4 out forward 15 | cfg = dict( 16 | depth=50, 17 | out_indices=(1, 2, 3), 18 | frozen_stages=4, 19 | strides=(1, 2, 1, 1), 20 | dilations=(1, 1, 2, 4), 21 | norm_eval=True) 22 | model = SOTResNet(**cfg) 23 | model.init_weights() 24 | model.train() 25 | 26 | imgs = torch.randn(1, 3, 127, 127) 27 | feat = model(imgs) 28 | assert len(feat) == 3 29 | assert feat[0].shape == torch.Size([1, 512, 15, 15]) 30 | assert feat[1].shape == torch.Size([1, 1024, 15, 15]) 31 | assert feat[2].shape == torch.Size([1, 2048, 15, 15]) 32 | 33 | imgs = torch.randn(1, 3, 255, 255) 34 | feat = model(imgs) 35 | assert len(feat) == 3 36 | assert feat[0].shape == torch.Size([1, 512, 31, 31]) 37 | assert feat[1].shape == torch.Size([1, 1024, 31, 31]) 38 | assert feat[2].shape == torch.Size([1, 2048, 31, 31]) 39 | -------------------------------------------------------------------------------- /mmtracking/tests/test_data/test_datasets/test_dataset_wrapers.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import os.path as osp 3 | 4 | from mmtrack.datasets import build_dataset 5 | 6 | PREFIX = osp.join(osp.dirname(__file__), '../../data/demo_sot_data/') 7 | 8 | 9 | def test_random_sample_concatdataset(): 10 | train_cfg = dict( 11 | type='RandomSampleConcatDataset', 12 | dataset_sampling_weights=[1, 1], 13 | dataset_cfgs=[ 14 | dict( 15 | type='GOT10kDataset', 16 | ann_file=PREFIX + 17 | 'trackingnet/annotations/trackingnet_train_infos.txt', 18 | img_prefix=PREFIX + 'trackingnet', 19 | pipeline=[], 20 | split='train', 21 | test_mode=False), 22 | dict( 23 | type='TrackingNetDataset', 24 | chunks_list=[0], 25 | ann_file=PREFIX + 26 | 'trackingnet/annotations/trackingnet_train_infos.txt', 27 | img_prefix=PREFIX + 'trackingnet', 28 | pipeline=[], 29 | split='train', 30 | test_mode=False) 31 | ]) 32 | dataset = build_dataset(train_cfg) 33 | results = dataset[0] 34 | assert len(dataset) == 4 35 | assert dataset.dataset_sampling_probs == [0.5, 0.5] 36 | assert len(results) == 2 37 | -------------------------------------------------------------------------------- /yolox/exp/build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | # Copyright (c) Megvii Inc. All rights reserved. 4 | 5 | import importlib 6 | import os 7 | import sys 8 | 9 | 10 | def get_exp_by_file(exp_file): 11 | try: 12 | sys.path.append(os.path.dirname(exp_file)) 13 | current_exp = importlib.import_module(os.path.basename(exp_file).split(".")[0]) 14 | exp = current_exp.Exp() 15 | except Exception: 16 | raise ImportError("{} doesn't contains class named 'Exp'".format(exp_file)) 17 | return exp 18 | 19 | 20 | def get_exp_by_name(exp_name): 21 | exp = exp_name.replace("-", "_") # convert string like "yolox-s" to "yolox_s" 22 | module_name = ".".join(["yolox", "exp", "default", exp]) 23 | exp_object = importlib.import_module(module_name).Exp() 24 | return exp_object 25 | 26 | 27 | def get_exp(exp_file=None, exp_name=None): 28 | """ 29 | get Exp object by file or name. If exp_file and exp_name 30 | are both provided, get Exp by exp_file. 31 | 32 | Args: 33 | exp_file (str): file path of experiment. 34 | exp_name (str): name of experiment. "yolo-s", 35 | """ 36 | assert ( 37 | exp_file is not None or exp_name is not None 38 | ), "plz provide exp file or exp name." 39 | if exp_file is not None: 40 | return get_exp_by_file(exp_file) 41 | else: 42 | return get_exp_by_name(exp_name) 43 | -------------------------------------------------------------------------------- /mmtracking/configs/vis/masktrack_rcnn/masktrack_rcnn_x101_fpn_12e_youtubevis2021.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./masktrack_rcnn_r50_fpn_12e_youtubevis2019.py'] 2 | model = dict( 3 | detector=dict( 4 | backbone=dict( 5 | type='ResNeXt', 6 | depth=101, 7 | groups=64, 8 | base_width=4, 9 | init_cfg=dict( 10 | type='Pretrained', 11 | checkpoint='open-mmlab://resnext101_64x4d')), 12 | init_cfg=dict( 13 | type='Pretrained', 14 | checkpoint= # noqa: E251 15 | 'https://download.openmmlab.com/mmdetection/v2.0/mask_rcnn/mask_rcnn_x101_64x4d_fpn_1x_coco/mask_rcnn_x101_64x4d_fpn_1x_coco_20200201-9352eb0d.pth' # noqa: E501 16 | ))) 17 | 18 | data_root = 'data/youtube_vis_2021/' 19 | dataset_version = data_root[-5:-1] 20 | data = dict( 21 | train=dict( 22 | dataset_version=dataset_version, 23 | ann_file=data_root + 'annotations/youtube_vis_2021_train.json', 24 | img_prefix=data_root + 'train/JPEGImages'), 25 | val=dict( 26 | dataset_version=dataset_version, 27 | ann_file=data_root + 'annotations/youtube_vis_2021_valid.json', 28 | img_prefix=data_root + 'valid/JPEGImages'), 29 | test=dict( 30 | dataset_version=dataset_version, 31 | ann_file=data_root + 'annotations/youtube_vis_2021_valid.json', 32 | img_prefix=data_root + 'valid/JPEGImages')) 33 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/models/reid/base_reid.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmcls.models import ImageClassifier 3 | from mmcv.runner import auto_fp16 4 | 5 | from ..builder import REID 6 | 7 | 8 | @REID.register_module() 9 | class BaseReID(ImageClassifier): 10 | """Base class for re-identification.""" 11 | 12 | def forward_train(self, img, gt_label, **kwargs): 13 | """"Training forward function.""" 14 | if img.ndim == 5: 15 | # change the shape of image tensor from NxSxCxHxW to NSxCxHxW 16 | # where S is the number of samples by triplet sampling 17 | img = img.view(-1, *img.shape[2:]) 18 | # change the shape of label tensor from NxS to NS 19 | gt_label = gt_label.view(-1) 20 | x = self.extract_feat(img) 21 | head_outputs = self.head.forward_train(x[0]) 22 | 23 | losses = dict() 24 | reid_loss = self.head.loss(gt_label, *head_outputs) 25 | losses.update(reid_loss) 26 | return losses 27 | 28 | @auto_fp16(apply_to=('img', ), out_fp32=True) 29 | def simple_test(self, img, **kwargs): 30 | """Test without augmentation.""" 31 | if img.nelement() > 0: 32 | x = self.extract_feat(img) 33 | head_outputs = self.head.forward_train(x[0]) 34 | feats = head_outputs[0] 35 | return feats 36 | else: 37 | return img.new_zeros(0, self.head.out_channels) 38 | -------------------------------------------------------------------------------- /mmtracking/tests/test_models/test_motion/test_linear_motion.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch 3 | 4 | from mmtrack.models.motion import LinearMotion 5 | 6 | 7 | def test_linear_motion(): 8 | linear_motion = LinearMotion(num_samples=2, center_motion=False) 9 | bboxes = [[1, 1, 1, 1], [3, 3, 3, 3], [6, 6, 6, 6]] 10 | bboxes = [torch.tensor(_, dtype=torch.float32) for _ in bboxes] 11 | bbox = linear_motion.step(bboxes) 12 | assert (bbox == torch.tensor([9., 9., 9., 9.])).all() 13 | 14 | linear_motion = LinearMotion(num_samples=3, center_motion=False) 15 | bboxes = [[1, 1, 1, 1], [3, 3, 3, 3], [6, 6, 6, 6]] 16 | bboxes = [torch.tensor(_, dtype=torch.float32) for _ in bboxes] 17 | bbox = linear_motion.step(bboxes) 18 | assert (bbox == torch.tensor([8.5, 8.5, 8.5, 8.5])).all() 19 | 20 | linear_motion = LinearMotion(num_samples=4, center_motion=False) 21 | bboxes = [[1, 1, 1, 1], [3, 3, 3, 3], [6, 6, 6, 6]] 22 | bboxes = [torch.tensor(_, dtype=torch.float32) for _ in bboxes] 23 | bbox = linear_motion.step(bboxes) 24 | assert (bbox == torch.tensor([8.5, 8.5, 8.5, 8.5])).all() 25 | 26 | linear_motion = LinearMotion(num_samples=4, center_motion=True) 27 | bboxes = [[1, 1, 1, 1], [3, 3, 3, 3], [6, 6, 6, 6]] 28 | bboxes = [torch.tensor(_, dtype=torch.float32) for _ in bboxes] 29 | bbox = linear_motion.step(bboxes) 30 | assert (bbox == torch.tensor([8.5, 8.5, 8.5, 8.5])).all() 31 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # 介绍 2 | 本项目融合了目标检测,目标跟踪模型,以及一些传统cv算法。 3 | 全自动刷原神秘境,全程无需人工操作。 4 | 5 | 目标检测部分通过构建怪物目标检测数据集,用半监督方法学习(标注5%),为整个数据集标注伪标签。 6 | 7 | ## 注意 8 | 原神需要以 **1920x1080** 的分辨率运行,不支持其他分辨率。可以窗口化运行。 9 | 10 | # 安装 11 | 首先安装基本依赖 12 | ```bash 13 | pip install -r requirements.txt 14 | ``` 15 | 16 | 安装mmcv-full 17 | ```bash 18 | pip install openmim 19 | mim install mmcv-full 20 | ``` 21 | 22 | 安装vs2019或以上。 23 | 24 | ## 安装mmtracking 25 | 安装方法参考[mmtracking](https://github.com/open-mmlab/mmtracking) 26 | 27 | 下载训练权重放入```mmtracking/checkpoints/```文件夹中 28 | 29 | [mmtracking训练权重](https://download.openmmlab.com/mmtracking/sot/siamese_rpn/siamese_rpn_r50_1x_lasot/siamese_rpn_r50_20e_lasot_20220420_181845-dd0f151e.pth) 30 | 31 | ## 安装yolox 32 | 安装方法参考[YOLOX](https://github.com/Megvii-BaseDetection/YOLOX) 33 | 34 | 下载原神数据集训练权重放入```yolox/ckpt/```文件夹中 35 | 36 | [yolox训练权重](https://huggingface.co/7eu7d7/genshin_autoplay_domain/blob/main/epoch_60_ckpt_s.pth) 37 | 38 | ## 战斗策略配置 39 | 刷本战斗策略配置文件在```control/script/```文件夹内,目前有两个例子。 40 | 每个文件内可以配置多条战斗策略,每个策略设置一定冷却时间。 41 | 程序会按从上到下的优先级,运行最先冷却完的策略。 42 | 43 | 如果策略内添加了 44 | ```yaml 45 | type: break 46 | ``` 47 | 字段,则这一策略具有最高优先级,只要冷却好就优先执行,可以打断其他正在运行的策略。 48 | 49 | 支持的指令 50 | ``` 51 | switch 4 #切换到4号位角色 52 | delay i #等待i秒 53 | key e #敲击键盘按键e 54 | key down e #按下键盘按键e不放 55 | key up e #抬起键盘按键e 56 | mouse l i #按下左键i秒 57 | mouse r i #按下右键i秒 58 | ``` 59 | 60 | ## 刷本配置 61 | 在```cfgs/```中配置刷本策略,其中有示例文件。 62 | 63 | ## 运行程序 64 | 以管理员模式启动命令行,运行程序: 65 | ```bash 66 | python auto_play.py 67 | ``` -------------------------------------------------------------------------------- /mmtracking/tests/test_data/test_datasets/test_tao_dataset.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import os.path as osp 3 | 4 | from mmtrack.datasets import DATASETS as DATASETS 5 | from .utils import _create_coco_gt_results 6 | 7 | PREFIX = osp.join(osp.dirname(__file__), '../../data') 8 | DEMO_ANN_FILE = f'{PREFIX}/demo_tao_data/ann.json' 9 | DEMO_TAO_DATA = f'{PREFIX}/demo_tao_data/' 10 | 11 | 12 | def test_load_annotation(): 13 | dataset_class = DATASETS.get('TaoDataset') 14 | dataset_object = dataset_class( 15 | ann_file=DEMO_ANN_FILE, classes=['serving_dish', 'baby'], pipeline=[]) 16 | 17 | dataset_object.load_as_video = True 18 | data_infos = dataset_object.load_lvis_anns(DEMO_ANN_FILE) 19 | assert isinstance(data_infos, list) 20 | assert len(data_infos) == 2 21 | 22 | dataset_object.load_as_video = False 23 | data_infos = dataset_object.load_tao_anns(DEMO_ANN_FILE) 24 | assert isinstance(data_infos, list) 25 | assert len(data_infos) == 2 26 | assert len(dataset_object.vid_ids) == 1 27 | 28 | 29 | def test_tao_evaluation(): 30 | dataset_class = DATASETS.get('TaoDataset') 31 | dataset_object = dataset_class( 32 | ann_file=DEMO_ANN_FILE, classes=['serving_dish', 'baby'], pipeline=[]) 33 | results = _create_coco_gt_results(dataset_object) 34 | eval_results = dataset_object.evaluate(results, metric=['track', 'bbox']) 35 | assert eval_results['bbox_AP'] == 1 36 | assert eval_results['track_AP'] == 1 37 | -------------------------------------------------------------------------------- /yolox/utils/checkpoint.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | # Copyright (c) Megvii Inc. All rights reserved. 4 | import os 5 | import shutil 6 | from loguru import logger 7 | 8 | import torch 9 | 10 | 11 | def load_ckpt(model, ckpt): 12 | model_state_dict = model.state_dict() 13 | load_dict = {} 14 | for key_model, v in model_state_dict.items(): 15 | if key_model not in ckpt: 16 | logger.warning( 17 | "{} is not in the ckpt. Please double check and see if this is desired.".format( 18 | key_model 19 | ) 20 | ) 21 | continue 22 | v_ckpt = ckpt[key_model] 23 | if v.shape != v_ckpt.shape: 24 | logger.warning( 25 | "Shape of {} in checkpoint is {}, while shape of {} in model is {}.".format( 26 | key_model, v_ckpt.shape, key_model, v.shape 27 | ) 28 | ) 29 | continue 30 | load_dict[key_model] = v_ckpt 31 | 32 | model.load_state_dict(load_dict, strict=False) 33 | return model 34 | 35 | 36 | def save_checkpoint(state, is_best, save_dir, model_name=""): 37 | if not os.path.exists(save_dir): 38 | os.makedirs(save_dir) 39 | filename = os.path.join(save_dir, model_name + "_ckpt.pth") 40 | torch.save(state, filename) 41 | if is_best: 42 | best_filename = os.path.join(save_dir, "best_ckpt.pth") 43 | shutil.copyfile(filename, best_filename) 44 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/datasets/pipelines/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmdet.datasets.builder import PIPELINES 3 | 4 | from .formatting import (CheckPadMaskValidity, ConcatSameTypeFrames, 5 | ConcatVideoReferences, ReIDFormatBundle, 6 | SeqDefaultFormatBundle, ToList, VideoCollect) 7 | from .loading import (LoadDetections, LoadMultiImagesFromFile, 8 | SeqLoadAnnotations) 9 | from .processing import MatchInstances, PairSampling, TridentSampling 10 | from .transforms import (SeqBboxJitter, SeqBlurAug, SeqBrightnessAug, 11 | SeqColorAug, SeqCropLikeSiamFC, SeqCropLikeStark, 12 | SeqGrayAug, SeqNormalize, SeqPad, 13 | SeqPhotoMetricDistortion, SeqRandomCrop, 14 | SeqRandomFlip, SeqResize, SeqShiftScaleAug) 15 | 16 | __all__ = [ 17 | 'PIPELINES', 'LoadMultiImagesFromFile', 'SeqLoadAnnotations', 'SeqResize', 18 | 'SeqNormalize', 'SeqRandomFlip', 'SeqPad', 'SeqDefaultFormatBundle', 19 | 'VideoCollect', 'CheckPadMaskValidity', 'ConcatVideoReferences', 20 | 'LoadDetections', 'MatchInstances', 'SeqRandomCrop', 21 | 'SeqPhotoMetricDistortion', 'SeqCropLikeSiamFC', 'SeqShiftScaleAug', 22 | 'SeqBlurAug', 'SeqColorAug', 'ToList', 'ReIDFormatBundle', 'SeqGrayAug', 23 | 'SeqBrightnessAug', 'SeqBboxJitter', 'SeqCropLikeStark', 'TridentSampling', 24 | 'ConcatSameTypeFrames', 'PairSampling' 25 | ] 26 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/tracktor/tracktor_faster-rcnn_r50_fpn_8e_mot20-private-half.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./tracktor_faster-rcnn_r50_fpn_4e_mot17-private-half.py'] 2 | 3 | model = dict( 4 | detector=dict( 5 | rpn_head=dict(bbox_coder=dict(clip_border=True)), 6 | roi_head=dict( 7 | bbox_head=dict(bbox_coder=dict(clip_border=True), num_classes=1)), 8 | init_cfg=dict( 9 | type='Pretrained', 10 | checkpoint= # noqa: E251 11 | 'https://download.openmmlab.com/mmtracking/mot/faster_rcnn/faster-rcnn_r50_fpn_8e_mot20-half_20210805_001244-2c323fd1.pth' # noqa: E501 12 | )), 13 | reid=dict( 14 | head=dict(num_classes=1705), 15 | init_cfg=dict( 16 | type='Pretrained', 17 | checkpoint= # noqa: E251 18 | 'https://download.openmmlab.com/mmtracking/mot/reid/reid_r50_6e_mot20_20210803_212426-c83b1c01.pth' # noqa: E501 19 | ))) 20 | # data 21 | data_root = 'data/MOT20/' 22 | data = dict( 23 | train=dict( 24 | ann_file=data_root + 'annotations/half-train_cocoformat.json', 25 | img_prefix=data_root + 'train'), 26 | val=dict( 27 | ann_file=data_root + 'annotations/half-val_cocoformat.json', 28 | img_prefix=data_root + 'train'), 29 | test=dict( 30 | ann_file=data_root + 'annotations/half-val_cocoformat.json', 31 | img_prefix=data_root + 'train')) 32 | # learning policy 33 | lr_config = dict(step=[6]) 34 | # runtime settings 35 | total_epochs = 8 36 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/tracktor/tracktor_faster-rcnn_r50_fpn_8e_mot20-public.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./tracktor_faster-rcnn_r50_fpn_4e_mot17-private-half.py'] 2 | 3 | model = dict( 4 | detector=dict( 5 | rpn_head=dict(bbox_coder=dict(clip_border=True)), 6 | roi_head=dict( 7 | bbox_head=dict(bbox_coder=dict(clip_border=True), num_classes=1)), 8 | init_cfg=dict( 9 | type='Pretrained', 10 | checkpoint= # noqa: E251 11 | 'https://download.openmmlab.com/mmtracking/mot/faster_rcnn/faster-rcnn_r50_fpn_8e_mot20_20210804_162232-7fde5e8d.pth' # noqa: E501 12 | )), 13 | reid=dict( 14 | head=dict(num_classes=1705), 15 | init_cfg=dict( 16 | type='Pretrained', 17 | checkpoint= # noqa: E251 18 | 'https://download.openmmlab.com/mmtracking/mot/reid/reid_r50_6e_mot20_20210803_212426-c83b1c01.pth' # noqa: E501 19 | ))) 20 | data_root = 'data/MOT20/' 21 | test_set = 'test' 22 | data = dict( 23 | train=dict(ann_file=data_root + 'annotations/train_cocoformat.json'), 24 | val=dict( 25 | ann_file=data_root + 'annotations/train_cocoformat.json', 26 | detection_file=data_root + 'annotations/train_detections.pkl'), 27 | test=dict( 28 | ann_file=data_root + f'annotations/{test_set}_cocoformat.json', 29 | img_prefix=data_root + test_set, 30 | detection_file=data_root + f'annotations/{test_set}_detections.pkl')) 31 | # learning policy 32 | lr_config = dict(step=[6]) 33 | # runtime settings 34 | total_epochs = 8 35 | -------------------------------------------------------------------------------- /mmtracking/configs/reid/resnet50_b32x8_MOT17.py: -------------------------------------------------------------------------------- 1 | TRAIN_REID = True 2 | _base_ = [ 3 | '../_base_/datasets/mot_challenge_reid.py', '../_base_/default_runtime.py' 4 | ] 5 | model = dict( 6 | reid=dict( 7 | type='BaseReID', 8 | backbone=dict( 9 | type='ResNet', 10 | depth=50, 11 | num_stages=4, 12 | out_indices=(3, ), 13 | style='pytorch'), 14 | neck=dict(type='GlobalAveragePooling', kernel_size=(8, 4), stride=1), 15 | head=dict( 16 | type='LinearReIDHead', 17 | num_fcs=1, 18 | in_channels=2048, 19 | fc_channels=1024, 20 | out_channels=128, 21 | num_classes=380, 22 | loss=dict(type='CrossEntropyLoss', loss_weight=1.0), 23 | loss_pairwise=dict( 24 | type='TripletLoss', margin=0.3, loss_weight=1.0), 25 | norm_cfg=dict(type='BN1d'), 26 | act_cfg=dict(type='ReLU')), 27 | init_cfg=dict( 28 | type='Pretrained', 29 | checkpoint= # noqa: E251 30 | 'https://download.openmmlab.com/mmclassification/v0/resnet/resnet50_batch256_imagenet_20200708-cfb998bf.pth' # noqa: E501 31 | ))) 32 | # optimizer 33 | optimizer = dict(type='SGD', lr=0.1, momentum=0.9, weight_decay=0.0001) 34 | optimizer_config = dict(grad_clip=None) 35 | # learning policy 36 | lr_config = dict( 37 | policy='step', 38 | warmup='linear', 39 | warmup_iters=1000, 40 | warmup_ratio=1.0 / 1000, 41 | step=[5]) 42 | total_epochs = 6 43 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/core/motion/flow.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch 3 | 4 | 5 | def flow_warp_feats(x, flow): 6 | """Use flow to warp feature map. 7 | 8 | Args: 9 | x (Tensor): of shape (N, C, H_x, W_x). 10 | flow (Tensor): of shape (N, C, H_f, W_f). 11 | 12 | Returns: 13 | Tensor: The warpped feature map with shape (N, C, H_x, W_x). 14 | """ 15 | assert len(x.shape) == 4 16 | assert len(flow.shape) == 4 and flow.shape[1] == 2 17 | # 1. resize the resolution of flow to be the same as x. 18 | scale_factor = float(x.shape[-1]) / flow.shape[-1] 19 | flow = torch.nn.functional.interpolate( 20 | flow, scale_factor=scale_factor, mode='bilinear', align_corners=False) 21 | flow = flow * scale_factor 22 | 23 | # 2. compute the flow_field (grid in the code) used to warp features. 24 | H, W = x.shape[-2:] 25 | h_grid, w_grid = torch.meshgrid(torch.arange(H), torch.arange(W)) 26 | # [1, 1, H, W] 27 | h_grid = h_grid.to(flow)[None, None, ...] 28 | # [1, 1, H, W] 29 | w_grid = w_grid.to(flow)[None, None, ...] 30 | # [1, 2, H, W] 31 | grid = torch.cat((w_grid, h_grid), dim=1) 32 | # [N, 2, H, W] 33 | grid = grid + flow 34 | grid[:, 0] = grid[:, 0] / W * 2 - 1 35 | grid[:, 1] = grid[:, 1] / H * 2 - 1 36 | # [N, H, W, 2] 37 | grid = grid.permute(0, 2, 3, 1) 38 | 39 | # 3. warp features. 40 | x_warp = torch.nn.functional.grid_sample( 41 | x, grid, padding_mode='border', align_corners=True) 42 | return x_warp 43 | -------------------------------------------------------------------------------- /yolox/models/yolox.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- encoding: utf-8 -*- 3 | # Copyright (c) Megvii Inc. All rights reserved. 4 | 5 | import torch.nn as nn 6 | 7 | from .yolo_head import YOLOXHead 8 | from .yolo_pafpn import YOLOPAFPN 9 | 10 | 11 | class YOLOX(nn.Module): 12 | """ 13 | YOLOX model module. The module list is defined by create_yolov3_modules function. 14 | The network returns loss values from three YOLO layers during training 15 | and detection results during test. 16 | """ 17 | 18 | def __init__(self, backbone=None, head=None): 19 | super().__init__() 20 | if backbone is None: 21 | backbone = YOLOPAFPN() 22 | if head is None: 23 | head = YOLOXHead(80) 24 | 25 | self.backbone = backbone 26 | self.head = head 27 | 28 | def forward(self, x, targets=None): 29 | # fpn output content features of [dark3, dark4, dark5] 30 | fpn_outs = self.backbone(x) 31 | 32 | if self.training: 33 | assert targets is not None 34 | loss, iou_loss, conf_loss, cls_loss, l1_loss, num_fg = self.head( 35 | fpn_outs, targets, x 36 | ) 37 | outputs = { 38 | "total_loss": loss, 39 | "iou_loss": iou_loss, 40 | "l1_loss": l1_loss, 41 | "conf_loss": conf_loss, 42 | "cls_loss": cls_loss, 43 | "num_fg": num_fg, 44 | } 45 | else: 46 | outputs = self.head(fpn_outs) 47 | 48 | return outputs 49 | -------------------------------------------------------------------------------- /mmtracking/configs/vid/selsa/selsa_faster_rcnn_r50_dc5_1x_imagenetvid.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../../_base_/models/faster_rcnn_r50_dc5.py', 3 | '../../_base_/datasets/imagenet_vid_fgfa_style.py', 4 | '../../_base_/default_runtime.py' 5 | ] 6 | model = dict( 7 | type='SELSA', 8 | detector=dict( 9 | roi_head=dict( 10 | type='SelsaRoIHead', 11 | bbox_head=dict( 12 | type='SelsaBBoxHead', 13 | num_shared_fcs=2, 14 | aggregator=dict( 15 | type='SelsaAggregator', 16 | in_channels=1024, 17 | num_attention_blocks=16))))) 18 | 19 | # dataset settings 20 | data = dict( 21 | val=dict( 22 | ref_img_sampler=dict( 23 | _delete_=True, 24 | num_ref_imgs=14, 25 | frame_range=[-7, 7], 26 | method='test_with_adaptive_stride')), 27 | test=dict( 28 | ref_img_sampler=dict( 29 | _delete_=True, 30 | num_ref_imgs=14, 31 | frame_range=[-7, 7], 32 | method='test_with_adaptive_stride'))) 33 | 34 | # optimizer 35 | optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) 36 | optimizer_config = dict( 37 | _delete_=True, grad_clip=dict(max_norm=35, norm_type=2)) 38 | # learning policy 39 | lr_config = dict( 40 | policy='step', 41 | warmup='linear', 42 | warmup_iters=500, 43 | warmup_ratio=1.0 / 3, 44 | step=[2, 5]) 45 | # runtime settings 46 | total_epochs = 7 47 | evaluation = dict(metric=['bbox'], interval=7) 48 | -------------------------------------------------------------------------------- /mmtracking/tests/test_models/test_trackers/test_bytetracker.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from unittest.mock import MagicMock 3 | 4 | import torch 5 | from mmdet.core.bbox.demodata import random_boxes 6 | 7 | from mmtrack.models import TRACKERS, KalmanFilter 8 | 9 | 10 | class TestByteTracker(object): 11 | 12 | @classmethod 13 | def setup_class(cls): 14 | cfg = dict( 15 | obj_score_thrs=dict(high=0.6, low=0.1), 16 | init_track_thr=0.7, 17 | weight_iou_with_det_scores=True, 18 | match_iou_thrs=dict(high=0.1, low=0.5, tentative=0.3), 19 | num_tentatives=3, 20 | num_frames_retain=30) 21 | tracker = TRACKERS.get('ByteTracker') 22 | cls.tracker = tracker(**cfg) 23 | cls.tracker.kf = KalmanFilter() 24 | cls.num_objs = 5 25 | 26 | def test_track(self): 27 | img_size = 64 28 | img = torch.rand((1, 3, img_size, img_size)) 29 | 30 | img_metas = [dict(scale_factor=1.0)] 31 | 32 | model = MagicMock() 33 | 34 | bboxes = random_boxes(self.num_objs, img_size) 35 | scores = torch.rand((self.num_objs, 1)) 36 | bboxes = torch.cat((bboxes, scores), dim=1) 37 | 38 | labels = torch.arange(self.num_objs) 39 | 40 | for frame_id in range(3): 41 | bboxes, labels, ids = self.tracker.track( 42 | img, img_metas, model, bboxes, labels, frame_id, rescale=True) 43 | assert bboxes.shape[0] == labels.shape[0] 44 | assert bboxes.shape[0] == ids.shape[0] 45 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/qdtrack/qdtrack_faster-rcnn_r101_fpn_24e_lvis.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | _base_ = [ 3 | './qdtrack_faster-rcnn_r50_fpn_4e_base.py', '../../_base_/datasets/tao.py' 4 | ] 5 | model = dict( 6 | type='QDTrack', 7 | detector=dict( 8 | backbone=dict( 9 | depth=101, 10 | init_cfg=dict( 11 | type='Pretrained', checkpoint='torchvision://resnet101')), 12 | roi_head=dict( 13 | bbox_head=dict( 14 | loss_bbox=dict(type='L1Loss', loss_weight=1.0), 15 | num_classes=482)), 16 | test_cfg=dict( 17 | rcnn=dict( 18 | score_thr=0.0001, 19 | nms=dict(type='nms', iou_threshold=0.5), 20 | max_per_img=300)), 21 | init_cfg=None), 22 | tracker=dict( 23 | _delete_=True, 24 | type='QuasiDenseTAOTracker', 25 | init_score_thr=0.0001, 26 | obj_score_thr=0.0001, 27 | match_score_thr=0.5, 28 | memo_frames=10, 29 | memo_momentum=0.8, 30 | momentum_obj_score=0.5, 31 | obj_score_diff_thr=1.0, 32 | distractor_nms_thr=0.3, 33 | distractor_score_thr=0.5, 34 | match_metric='bisoftmax', 35 | match_with_cosine=True)) 36 | # learning policy 37 | lr_config = dict( 38 | policy='step', 39 | warmup='linear', 40 | warmup_iters=1000, 41 | warmup_ratio=1.0 / 1000, 42 | step=[16, 22]) 43 | total_epochs = 24 44 | load_from = None 45 | resume_from = None 46 | evaluation = dict(metric=['bbox'], start=16, interval=2) 47 | work_dir = None 48 | -------------------------------------------------------------------------------- /mmtracking/.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/PyCQA/flake8 3 | rev: 4.0.1 4 | hooks: 5 | - id: flake8 6 | - repo: https://github.com/PyCQA/isort 7 | rev: 5.10.1 8 | hooks: 9 | - id: isort 10 | - repo: https://github.com/pre-commit/mirrors-yapf 11 | rev: v0.30.0 12 | hooks: 13 | - id: yapf 14 | - repo: https://github.com/pre-commit/pre-commit-hooks 15 | rev: v3.1.0 16 | hooks: 17 | - id: trailing-whitespace 18 | - id: check-yaml 19 | - id: end-of-file-fixer 20 | - id: requirements-txt-fixer 21 | - id: double-quote-string-fixer 22 | - id: check-merge-conflict 23 | - id: fix-encoding-pragma 24 | args: ["--remove"] 25 | - id: mixed-line-ending 26 | args: ["--fix=lf"] 27 | - repo: https://github.com/codespell-project/codespell 28 | rev: v2.1.0 29 | hooks: 30 | - id: codespell 31 | - repo: https://github.com/myint/docformatter 32 | rev: v1.3.1 33 | hooks: 34 | - id: docformatter 35 | args: ["--in-place", "--wrap-descriptions", "79"] 36 | - repo: https://github.com/executablebooks/mdformat 37 | rev: 0.7.9 38 | hooks: 39 | - id: mdformat 40 | args: ["--number"] 41 | additional_dependencies: 42 | - mdformat-openmmlab 43 | - mdformat_frontmatter 44 | - linkify-it-py 45 | - repo: https://github.com/open-mmlab/pre-commit-hooks 46 | rev: v0.2.0 47 | hooks: 48 | - id: check-algo-readme 49 | - id: check-copyright 50 | args: ["mmtrack", "tools", "tests"] 51 | -------------------------------------------------------------------------------- /yolox/data/datasets/coco_classes.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | # Copyright (c) Megvii, Inc. and its affiliates. 4 | 5 | COCO_CLASSES = ( 6 | "person", 7 | "bicycle", 8 | "car", 9 | "motorcycle", 10 | "airplane", 11 | "bus", 12 | "train", 13 | "truck", 14 | "boat", 15 | "traffic light", 16 | "fire hydrant", 17 | "stop sign", 18 | "parking meter", 19 | "bench", 20 | "bird", 21 | "cat", 22 | "dog", 23 | "horse", 24 | "sheep", 25 | "cow", 26 | "elephant", 27 | "bear", 28 | "zebra", 29 | "giraffe", 30 | "backpack", 31 | "umbrella", 32 | "handbag", 33 | "tie", 34 | "suitcase", 35 | "frisbee", 36 | "skis", 37 | "snowboard", 38 | "sports ball", 39 | "kite", 40 | "baseball bat", 41 | "baseball glove", 42 | "skateboard", 43 | "surfboard", 44 | "tennis racket", 45 | "bottle", 46 | "wine glass", 47 | "cup", 48 | "fork", 49 | "knife", 50 | "spoon", 51 | "bowl", 52 | "banana", 53 | "apple", 54 | "sandwich", 55 | "orange", 56 | "broccoli", 57 | "carrot", 58 | "hot dog", 59 | "pizza", 60 | "donut", 61 | "cake", 62 | "chair", 63 | "couch", 64 | "potted plant", 65 | "bed", 66 | "dining table", 67 | "toilet", 68 | "tv", 69 | "laptop", 70 | "mouse", 71 | "remote", 72 | "keyboard", 73 | "cell phone", 74 | "microwave", 75 | "oven", 76 | "toaster", 77 | "sink", 78 | "refrigerator", 79 | "book", 80 | "clock", 81 | "vase", 82 | "scissors", 83 | "teddy bear", 84 | "hair drier", 85 | "toothbrush", 86 | ) 87 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmdet.datasets.builder import DATASETS, build_dataset 3 | 4 | from .base_sot_dataset import BaseSOTDataset 5 | from .builder import build_dataloader 6 | from .coco_video_dataset import CocoVideoDataset 7 | from .dancetrack_dataset import DanceTrackDataset 8 | from .dataset_wrappers import RandomSampleConcatDataset 9 | from .got10k_dataset import GOT10kDataset 10 | from .imagenet_vid_dataset import ImagenetVIDDataset 11 | from .lasot_dataset import LaSOTDataset 12 | from .mot_challenge_dataset import MOTChallengeDataset 13 | from .otb_dataset import OTB100Dataset 14 | from .parsers import CocoVID 15 | from .pipelines import PIPELINES 16 | from .reid_dataset import ReIDDataset 17 | from .sot_coco_dataset import SOTCocoDataset 18 | from .sot_imagenet_vid_dataset import SOTImageNetVIDDataset 19 | from .sot_test_dataset import SOTTestDataset 20 | from .sot_train_dataset import SOTTrainDataset 21 | from .tao_dataset import TaoDataset 22 | from .trackingnet_dataset import TrackingNetDataset 23 | from .uav123_dataset import UAV123Dataset 24 | from .vot_dataset import VOTDataset 25 | from .youtube_vis_dataset import YouTubeVISDataset 26 | 27 | __all__ = [ 28 | 'DATASETS', 'PIPELINES', 'build_dataloader', 'build_dataset', 'CocoVID', 29 | 'CocoVideoDataset', 'ImagenetVIDDataset', 'MOTChallengeDataset', 30 | 'ReIDDataset', 'SOTTrainDataset', 'SOTTestDataset', 'LaSOTDataset', 31 | 'UAV123Dataset', 'TrackingNetDataset', 'OTB100Dataset', 32 | 'YouTubeVISDataset', 'GOT10kDataset', 'VOTDataset', 'BaseSOTDataset', 33 | 'SOTCocoDataset', 'SOTImageNetVIDDataset', 'RandomSampleConcatDataset', 34 | 'TaoDataset', 'DanceTrackDataset' 35 | ] 36 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/tracktor/tracktor_faster-rcnn_r50_fpn_4e_mot17-public-half_search.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./tracktor_faster-rcnn_r50_fpn_4e_mot17-private-half.py'] 2 | model = dict( 3 | tracker=dict( 4 | type='TracktorTracker', 5 | obj_score_thr=[0.4, 0.5, 0.6], 6 | regression=dict( 7 | obj_score_thr=[0.4, 0.5, 0.6], 8 | nms=dict(type='nms', iou_threshold=0.6), 9 | match_iou_thr=[0.3, 0.5]), 10 | reid=dict( 11 | num_samples=10, 12 | img_scale=(256, 128), 13 | img_norm_cfg=None, 14 | match_score_thr=2.0, 15 | match_iou_thr=0.2), 16 | momentums=None, 17 | num_frames_retain=10)) 18 | # data 19 | data_root = 'data/MOT17/' 20 | img_norm_cfg = dict( 21 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 22 | test_pipeline = [ 23 | dict(type='LoadImageFromFile'), 24 | dict(type='LoadDetections'), 25 | dict( 26 | type='MultiScaleFlipAug', 27 | img_scale=(1088, 1088), 28 | flip=False, 29 | transforms=[ 30 | dict(type='Resize', keep_ratio=True), 31 | dict(type='RandomFlip'), 32 | dict(type='Normalize', **img_norm_cfg), 33 | dict(type='Pad', size_divisor=32), 34 | dict(type='ImageToTensor', keys=['img']), 35 | dict(type='VideoCollect', keys=['img', 'public_bboxes']) 36 | ]) 37 | ] 38 | data = dict( 39 | val=dict( 40 | detection_file=data_root + 'annotations/half-val_detections.pkl', 41 | pipeline=test_pipeline), 42 | test=dict( 43 | detection_file=data_root + 'annotations/half-val_detections.pkl', 44 | pipeline=test_pipeline)) 45 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/tracktor/tracktor_faster-rcnn_r50_fpn_4e_mot17-public.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./tracktor_faster-rcnn_r50_fpn_4e_mot17-private-half.py'] 2 | 3 | model = dict( 4 | detector=dict( 5 | init_cfg=dict( 6 | type='Pretrained', 7 | checkpoint= # noqa: E251 8 | 'https://download.openmmlab.com/mmtracking/mot/faster_rcnn/faster-rcnn_r50_fpn_4e_mot17-ffa52ae7.pth' # noqa: E501 9 | ))) 10 | # data 11 | data_root = 'data/MOT17/' 12 | test_set = 'test' 13 | img_norm_cfg = dict( 14 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 15 | test_pipeline = [ 16 | dict(type='LoadImageFromFile'), 17 | dict(type='LoadDetections'), 18 | dict( 19 | type='MultiScaleFlipAug', 20 | img_scale=(1088, 1088), 21 | flip=False, 22 | transforms=[ 23 | dict(type='Resize', keep_ratio=True), 24 | dict(type='RandomFlip'), 25 | dict(type='Normalize', **img_norm_cfg), 26 | dict(type='Pad', size_divisor=32), 27 | dict(type='ImageToTensor', keys=['img']), 28 | dict(type='VideoCollect', keys=['img', 'public_bboxes']) 29 | ]) 30 | ] 31 | data = dict( 32 | train=dict(ann_file=data_root + 'annotations/train_cocoformat.json'), 33 | val=dict( 34 | ann_file=data_root + 'annotations/train_cocoformat.json', 35 | detection_file=data_root + 'annotations/train_detections.pkl', 36 | pipeline=test_pipeline), 37 | test=dict( 38 | ann_file=data_root + f'annotations/{test_set}_cocoformat.json', 39 | img_prefix=data_root + test_set, 40 | detection_file=data_root + f'annotations/{test_set}_detections.pkl', 41 | pipeline=test_pipeline)) 42 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/qdtrack/metafile.yml: -------------------------------------------------------------------------------- 1 | Collections: 2 | - Name: QDTrack 3 | Metadata: 4 | Training Data: MOT17, crowdhuman 5 | Training Techniques: 6 | - SGD 7 | Training Resources: 8x V100 GPUs 8 | Architecture: 9 | - ResNet 10 | Paper: 11 | URL: https://arxiv.org/pdf/2006.06664.pdf 12 | Title: Quasi-Dense Similarity Learning for Multiple Object Tracking 13 | README: configs/mot/qdtrack/README.md 14 | 15 | Models: 16 | - Name: qdtrack_faster-rcnn_r50_fpn_4e_mot17-private-half 17 | In Collection: QDTrack 18 | Config: configs/mot/qdtrack/qdtrack_faster-rcnn_r50_fpn_4e_mot17-private-half.py 19 | Metadata: 20 | Training Data: MOT17 21 | Training Memory (GB): 5.83 22 | Epochs: 4 23 | Results: 24 | - Task: Multi-object Tracking 25 | Dataset: MOT17 26 | Metrics: 27 | HOTA: 57.1 28 | MOTA: 68.2 29 | IDF1: 68.5 30 | Weights: https://download.openmmlab.com/mmtracking/mot/qdtrack/mot_dataset/qdtrack_faster-rcnn_r50_fpn_4e_mot17_20220315_145635-76f295ef.pth 31 | 32 | - Name: qdtrack_faster-rcnn_r50_fpn_4e_crowdhuman_mot17-private-half 33 | In Collection: QDTrack 34 | Config: configs/mot/qdtrack/qdtrack_faster-rcnn_r50_fpn_4e_crowdhuman_mot17-private-half.py 35 | Metadata: 36 | Training Data: MOT17, crowdhuman 37 | Training Memory (GB): 6.31 38 | Epochs: 4 39 | Results: 40 | - Task: Multi-object Tracking 41 | Dataset: MOT17 42 | Metrics: 43 | HOTA: 59.1 44 | MOTA: 71.7 45 | IDF1: 71.6 46 | Weights: https://download.openmmlab.com/mmtracking/mot/qdtrack/mot_dataset/qdtrack_faster-rcnn_r50_fpn_4e_crowdhuman_mot17_20220315_163453-68899b0a.pth 47 | -------------------------------------------------------------------------------- /control/script/hutao_shatang.yaml: -------------------------------------------------------------------------------- 1 | #胡桃砂糖 2 | p1: 3 | interval: 21 4 | action: |- 5 | mouse r 0.2 6 | delay 0.2 7 | switch 1 8 | delay 0.2 9 | key down e 10 | delay 1.2 11 | key up e 12 | delay 0.3 13 | 14 | #砂糖 15 | switch 4 16 | delay 0.5 17 | key e 18 | delay 1.0 19 | key e 20 | delay 1.0 21 | key q 22 | delay 0.8 23 | 24 | #行秋 25 | switch 3 26 | delay 0.5 27 | key e 28 | delay 1.2 29 | key q 30 | delay 1.0 31 | 32 | #胡桃 33 | switch 2 34 | delay 0.2 35 | key e 36 | delay 0.4 37 | 38 | key down a 39 | mouse l 0.8 40 | key up a 41 | delay 0.3 42 | 43 | key down d 44 | mouse l 0.8 45 | key up d 46 | delay 0.3 47 | 48 | key down a 49 | mouse l 0.8 50 | key up a 51 | delay 0.3 52 | 53 | key down d 54 | mouse l 0.8 55 | key up d 56 | delay 0.3 57 | 58 | key down a 59 | mouse l 0.8 60 | key up a 61 | delay 0.3 62 | 63 | key down d 64 | mouse l 0.8 65 | key up d 66 | delay 0.3 67 | 68 | key down a 69 | mouse l 0.8 70 | key up a 71 | delay 0.3 72 | 73 | switch 2 74 | delay 0.8 75 | key q 76 | delay 0.3 77 | 78 | p_else: 79 | interval: 1 80 | action: |- 81 | switch 2 82 | delay 0.1 83 | mouse r 0.2 84 | delay 0.05 85 | 86 | mouse l 0.1 87 | delay 0.2 88 | mouse l 0.1 89 | delay 0.2 90 | 91 | p_shield: 92 | interval: 16 93 | type: break 94 | action: |- 95 | switch 1 96 | delay 0.4 97 | key down e 98 | delay 1.2 99 | key up e 100 | delay 0.3 -------------------------------------------------------------------------------- /mmtracking/docs/zh_cn/stat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (c) OpenMMLab. All rights reserved. 3 | import functools as func 4 | import glob 5 | import os.path as osp 6 | import re 7 | 8 | import numpy as np 9 | 10 | url_prefix = 'https://github.com/open-mmlab/mmtracking/blob/master/' 11 | 12 | files = sorted(glob.glob('../../configs/*/*/README.md')) 13 | 14 | stats = [] 15 | titles = [] 16 | num_ckpts = 0 17 | 18 | for f in files: 19 | url = osp.dirname(f.replace('../../', url_prefix)) 20 | 21 | with open(f, 'r') as content_file: 22 | content = content_file.read() 23 | 24 | title = content.split('\n')[0].replace('#', '').strip() 25 | ckpts = set(x.lower().strip() 26 | for x in re.findall(r'https?://download.*\.pth', content) 27 | if 'mmtracking' in x) 28 | if len(ckpts) == 0: 29 | continue 30 | 31 | _papertype = [x for x in re.findall(r'\s*\[([A-Z]*?)\]\s*', content)] 32 | assert len(_papertype) > 0 33 | papertype = _papertype[0] 34 | 35 | paper = set([(papertype, title)]) 36 | 37 | titles.append(title) 38 | num_ckpts += len(ckpts) 39 | statsmsg = f""" 40 | \t* [{papertype}] [{title}]({url}) ({len(ckpts)} ckpts) 41 | """ 42 | stats.append((paper, ckpts, statsmsg)) 43 | 44 | allpapers = func.reduce(lambda a, b: a.union(b), [p for p, _, _ in stats]) 45 | msglist = '\n'.join(x for _, _, x in stats) 46 | 47 | papertypes, papercounts = np.unique([t for t, _ in allpapers], 48 | return_counts=True) 49 | countstr = '\n'.join( 50 | [f' - {t}: {c}' for t, c in zip(papertypes, papercounts)]) 51 | 52 | modelzoo = f""" 53 | # 模型库统计数据 54 | * 论文数量: {len(set(titles))} 55 | {countstr} 56 | * 模型数量: {num_ckpts} 57 | {msglist} 58 | """ 59 | 60 | with open('modelzoo_statistics.md', 'w') as f: 61 | f.write(modelzoo) 62 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/core/utils/misc.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import multiprocessing as mp 3 | import os 4 | import platform 5 | import warnings 6 | 7 | import cv2 8 | 9 | 10 | def setup_multi_processes(cfg): 11 | # set multi-process start method as `fork` to speed up the training 12 | if platform.system() != 'Windows': 13 | mp_start_method = cfg.get('mp_start_method', 'fork') 14 | mp.set_start_method(mp_start_method) 15 | 16 | # disable opencv multithreading to avoid system being overloaded 17 | opencv_num_threads = cfg.get('opencv_num_threads', 0) 18 | cv2.setNumThreads(opencv_num_threads) 19 | 20 | # setup OMP threads 21 | # This code is referred from https://github.com/pytorch/pytorch/blob/master/torch/distributed/run.py # noqa 22 | if ('OMP_NUM_THREADS' not in os.environ and cfg.data.workers_per_gpu > 1): 23 | omp_num_threads = 1 24 | warnings.warn( 25 | f'Setting OMP_NUM_THREADS environment variable for each process ' 26 | f'to be {omp_num_threads} in default, to avoid your system being ' 27 | f'overloaded, please further tune the variable for optimal ' 28 | f'performance in your application as needed.') 29 | os.environ['OMP_NUM_THREADS'] = str(omp_num_threads) 30 | 31 | # setup MKL threads 32 | if 'MKL_NUM_THREADS' not in os.environ and cfg.data.workers_per_gpu > 1: 33 | mkl_num_threads = 1 34 | warnings.warn( 35 | f'Setting MKL_NUM_THREADS environment variable for each process ' 36 | f'to be {mkl_num_threads} in default, to avoid your system being ' 37 | f'overloaded, please further tune the variable for optimal ' 38 | f'performance in your application as needed.') 39 | os.environ['MKL_NUM_THREADS'] = str(mkl_num_threads) 40 | -------------------------------------------------------------------------------- /yolox/data/data_prefetcher.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | # Copyright (c) Megvii, Inc. and its affiliates. 4 | 5 | import torch 6 | 7 | 8 | class DataPrefetcher: 9 | """ 10 | DataPrefetcher is inspired by code of following file: 11 | https://github.com/NVIDIA/apex/blob/master/examples/imagenet/main_amp.py 12 | It could speedup your pytorch dataloader. For more information, please check 13 | https://github.com/NVIDIA/apex/issues/304#issuecomment-493562789. 14 | """ 15 | 16 | def __init__(self, loader): 17 | self.loader = iter(loader) 18 | self.stream = torch.cuda.Stream() 19 | self.input_cuda = self._input_cuda_for_image 20 | self.record_stream = DataPrefetcher._record_stream_for_image 21 | self.preload() 22 | 23 | def preload(self): 24 | try: 25 | self.next_input, self.next_target, _, _ = next(self.loader) 26 | except StopIteration: 27 | self.next_input = None 28 | self.next_target = None 29 | return 30 | 31 | with torch.cuda.stream(self.stream): 32 | self.input_cuda() 33 | self.next_target = self.next_target.cuda(non_blocking=True) 34 | 35 | def next(self): 36 | torch.cuda.current_stream().wait_stream(self.stream) 37 | input = self.next_input 38 | target = self.next_target 39 | if input is not None: 40 | self.record_stream(input) 41 | if target is not None: 42 | target.record_stream(torch.cuda.current_stream()) 43 | self.preload() 44 | return input, target 45 | 46 | def _input_cuda_for_image(self): 47 | self.next_input = self.next_input.cuda(non_blocking=True) 48 | 49 | @staticmethod 50 | def _record_stream_for_image(input): 51 | input.record_stream(torch.cuda.current_stream()) 52 | -------------------------------------------------------------------------------- /mmtracking/docs/en/stat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (c) OpenMMLab. All rights reserved. 3 | import functools as func 4 | import glob 5 | import os.path as osp 6 | import re 7 | 8 | import numpy as np 9 | 10 | url_prefix = 'https://github.com/open-mmlab/mmtracking/blob/master/' 11 | 12 | files = sorted(glob.glob('../../configs/*/*/README.md')) 13 | 14 | stats = [] 15 | titles = [] 16 | num_ckpts = 0 17 | 18 | for f in files: 19 | url = osp.dirname(f.replace('../../', url_prefix)) 20 | 21 | with open(f, 'r') as content_file: 22 | content = content_file.read() 23 | 24 | title = content.split('\n')[0].replace('#', '').strip() 25 | ckpts = set(x.lower().strip() 26 | for x in re.findall(r'https?://download.*\.pth', content) 27 | if 'mmtracking' in x) 28 | if len(ckpts) == 0: 29 | continue 30 | 31 | _papertype = [x for x in re.findall(r'\s*\[([A-Z]*?)\]\s*', content)] 32 | assert len(_papertype) > 0 33 | papertype = _papertype[0] 34 | 35 | paper = set([(papertype, title)]) 36 | 37 | titles.append(title) 38 | num_ckpts += len(ckpts) 39 | statsmsg = f""" 40 | \t* [{papertype}] [{title}]({url}) ({len(ckpts)} ckpts) 41 | """ 42 | stats.append((paper, ckpts, statsmsg)) 43 | 44 | allpapers = func.reduce(lambda a, b: a.union(b), [p for p, _, _ in stats]) 45 | msglist = '\n'.join(x for _, _, x in stats) 46 | 47 | papertypes, papercounts = np.unique([t for t, _ in allpapers], 48 | return_counts=True) 49 | countstr = '\n'.join( 50 | [f' - {t}: {c}' for t, c in zip(papertypes, papercounts)]) 51 | 52 | modelzoo = f""" 53 | # Model Zoo Statistics 54 | * Number of papers: {len(set(titles))} 55 | {countstr} 56 | * Number of checkpoints: {num_ckpts} 57 | {msglist} 58 | """ 59 | 60 | with open('modelzoo_statistics.md', 'w') as f: 61 | f.write(modelzoo) 62 | -------------------------------------------------------------------------------- /yolox/models/losses.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- encoding: utf-8 -*- 3 | # Copyright (c) Megvii Inc. All rights reserved. 4 | 5 | import torch 6 | import torch.nn as nn 7 | 8 | 9 | class IOUloss(nn.Module): 10 | def __init__(self, reduction="none", loss_type="iou"): 11 | super(IOUloss, self).__init__() 12 | self.reduction = reduction 13 | self.loss_type = loss_type 14 | 15 | def forward(self, pred, target): 16 | assert pred.shape[0] == target.shape[0] 17 | 18 | pred = pred.view(-1, 4) 19 | target = target.view(-1, 4) 20 | tl = torch.max( 21 | (pred[:, :2] - pred[:, 2:] / 2), (target[:, :2] - target[:, 2:] / 2) 22 | ) 23 | br = torch.min( 24 | (pred[:, :2] + pred[:, 2:] / 2), (target[:, :2] + target[:, 2:] / 2) 25 | ) 26 | 27 | area_p = torch.prod(pred[:, 2:], 1) 28 | area_g = torch.prod(target[:, 2:], 1) 29 | 30 | en = (tl < br).type(tl.type()).prod(dim=1) 31 | area_i = torch.prod(br - tl, 1) * en 32 | area_u = area_p + area_g - area_i 33 | iou = (area_i) / (area_u + 1e-16) 34 | 35 | if self.loss_type == "iou": 36 | loss = 1 - iou ** 2 37 | elif self.loss_type == "giou": 38 | c_tl = torch.min( 39 | (pred[:, :2] - pred[:, 2:] / 2), (target[:, :2] - target[:, 2:] / 2) 40 | ) 41 | c_br = torch.max( 42 | (pred[:, :2] + pred[:, 2:] / 2), (target[:, :2] + target[:, 2:] / 2) 43 | ) 44 | area_c = torch.prod(c_br - c_tl, 1) 45 | giou = iou - (area_c - area_u) / area_c.clamp(1e-16) 46 | loss = 1 - giou.clamp(min=-1.0, max=1.0) 47 | 48 | if self.reduction == "mean": 49 | loss = loss.mean() 50 | elif self.reduction == "sum": 51 | loss = loss.sum() 52 | 53 | return loss 54 | -------------------------------------------------------------------------------- /mmtracking/tests/test_data/test_datasets/test_sot_train_dataset.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import os.path as osp 3 | 4 | import pytest 5 | 6 | from mmtrack.datasets import DATASETS as DATASETS 7 | 8 | PREFIX = osp.join(osp.dirname(__file__), '../../data') 9 | # This is a demo annotation file for CocoVideoDataset 10 | # 1 videos, 2 categories ('car', 'person') 11 | # 8 images, 2 instances -> [4, 3] objects 12 | # 1 ignore, 2 crowd 13 | DEMO_ANN_FILE = f'{PREFIX}/demo_cocovid_data/ann.json' 14 | 15 | 16 | @pytest.mark.parametrize('dataset', ['SOTTrainDataset']) 17 | def test_sot_train_dataset_parse_ann_info(dataset): 18 | dataset_class = DATASETS.get(dataset) 19 | 20 | dataset = dataset_class(ann_file=DEMO_ANN_FILE, pipeline=[]) 21 | 22 | # image 5 has 2 objects, we only load the object with instance_id = 1 23 | img_id = 5 24 | instance_id = 1 25 | ann_ids = dataset.coco.get_ann_ids([img_id]) 26 | ann_info = dataset.coco.loadAnns(ann_ids) 27 | ann = dataset._parse_ann_info(instance_id, ann_info) 28 | assert ann['bboxes'].shape == (1, 4) 29 | assert ann['labels'].shape == (1, ) and ann['labels'][0] == 0 30 | 31 | 32 | @pytest.mark.parametrize('dataset', ['SOTTrainDataset']) 33 | def test_sot_train_dataset_prepare_data(dataset): 34 | dataset_class = DATASETS.get(dataset) 35 | 36 | # train 37 | dataset = dataset_class( 38 | ann_file=DEMO_ANN_FILE, 39 | ref_img_sampler=dict( 40 | frame_range=100, 41 | pos_prob=0.8, 42 | filter_key_img=False, 43 | return_key_img=True), 44 | pipeline=[], 45 | test_mode=False) 46 | assert len(dataset) == 1 47 | 48 | results = dataset.prepare_train_img(0) 49 | assert isinstance(results, list) 50 | assert len(results) == 2 51 | assert 'ann_info' in results[0] 52 | assert results[0].keys() == results[1].keys() 53 | -------------------------------------------------------------------------------- /mmtracking/configs/_base_/datasets/coco_detection.py: -------------------------------------------------------------------------------- 1 | dataset_type = 'CocoDataset' 2 | data_root = 'data/coco/' 3 | img_norm_cfg = dict( 4 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 5 | train_pipeline = [ 6 | dict(type='LoadImageFromFile'), 7 | dict(type='LoadAnnotations', with_bbox=True), 8 | dict(type='Resize', img_scale=(1333, 800), keep_ratio=True), 9 | dict(type='RandomFlip', flip_ratio=0.5), 10 | dict(type='Normalize', **img_norm_cfg), 11 | dict(type='Pad', size_divisor=32), 12 | dict(type='DefaultFormatBundle'), 13 | dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']), 14 | ] 15 | test_pipeline = [ 16 | dict(type='LoadImageFromFile'), 17 | dict( 18 | type='MultiScaleFlipAug', 19 | img_scale=(1333, 800), 20 | flip=False, 21 | transforms=[ 22 | dict(type='Resize', keep_ratio=True), 23 | dict(type='RandomFlip'), 24 | dict(type='Normalize', **img_norm_cfg), 25 | dict(type='Pad', size_divisor=32), 26 | dict(type='ImageToTensor', keys=['img']), 27 | dict(type='Collect', keys=['img']), 28 | ]) 29 | ] 30 | data = dict( 31 | samples_per_gpu=2, 32 | workers_per_gpu=2, 33 | train=dict( 34 | type=dataset_type, 35 | ann_file=data_root + 'annotations/instances_train2017.json', 36 | img_prefix=data_root + 'train2017/', 37 | pipeline=train_pipeline), 38 | val=dict( 39 | type=dataset_type, 40 | ann_file=data_root + 'annotations/instances_val2017.json', 41 | img_prefix=data_root + 'val2017/', 42 | pipeline=test_pipeline), 43 | test=dict( 44 | type=dataset_type, 45 | ann_file=data_root + 'annotations/instances_val2017.json', 46 | img_prefix=data_root + 'val2017/', 47 | pipeline=test_pipeline)) 48 | evaluation = dict(interval=1, metric='bbox') 49 | -------------------------------------------------------------------------------- /mmtracking/configs/_base_/datasets/mot_challenge_reid.py: -------------------------------------------------------------------------------- 1 | dataset_type = 'ReIDDataset' 2 | img_norm_cfg = dict( 3 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 4 | train_pipeline = [ 5 | dict(type='LoadMultiImagesFromFile', to_float32=True), 6 | dict( 7 | type='SeqResize', 8 | img_scale=(128, 256), 9 | share_params=False, 10 | keep_ratio=False, 11 | bbox_clip_border=False, 12 | override=False), 13 | dict( 14 | type='SeqRandomFlip', 15 | share_params=False, 16 | flip_ratio=0.5, 17 | direction='horizontal'), 18 | dict(type='SeqNormalize', **img_norm_cfg), 19 | dict(type='VideoCollect', keys=['img', 'gt_label']), 20 | dict(type='ReIDFormatBundle') 21 | ] 22 | test_pipeline = [ 23 | dict(type='LoadImageFromFile'), 24 | dict(type='Resize', img_scale=(128, 256), keep_ratio=False), 25 | dict(type='Normalize', **img_norm_cfg), 26 | dict(type='ImageToTensor', keys=['img']), 27 | dict(type='Collect', keys=['img'], meta_keys=[]) 28 | ] 29 | data_root = 'data/MOT17/' 30 | data = dict( 31 | samples_per_gpu=1, 32 | workers_per_gpu=2, 33 | train=dict( 34 | type=dataset_type, 35 | triplet_sampler=dict(num_ids=8, ins_per_id=4), 36 | data_prefix=data_root + 'reid/imgs', 37 | ann_file=data_root + 'reid/meta/train_80.txt', 38 | pipeline=train_pipeline), 39 | val=dict( 40 | type=dataset_type, 41 | triplet_sampler=None, 42 | data_prefix=data_root + 'reid/imgs', 43 | ann_file=data_root + 'reid/meta/val_20.txt', 44 | pipeline=test_pipeline), 45 | test=dict( 46 | type=dataset_type, 47 | triplet_sampler=None, 48 | data_prefix=data_root + 'reid/imgs', 49 | ann_file=data_root + 'reid/meta/val_20.txt', 50 | pipeline=test_pipeline)) 51 | evaluation = dict(interval=1, metric='mAP') 52 | -------------------------------------------------------------------------------- /mmtracking/configs/_base_/datasets/coco_instance.py: -------------------------------------------------------------------------------- 1 | dataset_type = 'CocoDataset' 2 | data_root = 'data/coco/' 3 | img_norm_cfg = dict( 4 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 5 | train_pipeline = [ 6 | dict(type='LoadImageFromFile'), 7 | dict(type='LoadAnnotations', with_bbox=True, with_mask=True), 8 | dict(type='Resize', img_scale=(1333, 800), keep_ratio=True), 9 | dict(type='RandomFlip', flip_ratio=0.5), 10 | dict(type='Normalize', **img_norm_cfg), 11 | dict(type='Pad', size_divisor=32), 12 | dict(type='DefaultFormatBundle'), 13 | dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']), 14 | ] 15 | test_pipeline = [ 16 | dict(type='LoadImageFromFile'), 17 | dict( 18 | type='MultiScaleFlipAug', 19 | img_scale=(1333, 800), 20 | flip=False, 21 | transforms=[ 22 | dict(type='Resize', keep_ratio=True), 23 | dict(type='RandomFlip'), 24 | dict(type='Normalize', **img_norm_cfg), 25 | dict(type='Pad', size_divisor=32), 26 | dict(type='ImageToTensor', keys=['img']), 27 | dict(type='Collect', keys=['img']), 28 | ]) 29 | ] 30 | data = dict( 31 | samples_per_gpu=2, 32 | workers_per_gpu=2, 33 | train=dict( 34 | type=dataset_type, 35 | ann_file=data_root + 'annotations/instances_train2017.json', 36 | img_prefix=data_root + 'train2017/', 37 | pipeline=train_pipeline), 38 | val=dict( 39 | type=dataset_type, 40 | ann_file=data_root + 'annotations/instances_val2017.json', 41 | img_prefix=data_root + 'val2017/', 42 | pipeline=test_pipeline), 43 | test=dict( 44 | type=dataset_type, 45 | ann_file=data_root + 'annotations/instances_val2017.json', 46 | img_prefix=data_root + 'val2017/', 47 | pipeline=test_pipeline)) 48 | evaluation = dict(metric=['bbox', 'segm']) 49 | -------------------------------------------------------------------------------- /mmtracking/tools/analysis/publish_model.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import argparse 3 | import glob 4 | import os.path as osp 5 | import subprocess 6 | 7 | import torch 8 | 9 | 10 | def parse_args(): 11 | parser = argparse.ArgumentParser( 12 | description='Process a checkpoint to be published') 13 | parser.add_argument('in_file', help='input checkpoint filename') 14 | parser.add_argument('out_file', help='output checkpoint filename') 15 | args = parser.parse_args() 16 | return args 17 | 18 | 19 | def process_checkpoint(in_file, out_file): 20 | exp_dir = osp.dirname(in_file) 21 | log_json_path = list(sorted(glob.glob(osp.join(exp_dir, 22 | '*.log.json'))))[-1] 23 | model_time = osp.split(log_json_path)[-1].split('.')[0] 24 | 25 | checkpoint = torch.load(in_file, map_location='cpu') 26 | # remove optimizer for smaller file size 27 | if 'optimizer' in checkpoint: 28 | del checkpoint['optimizer'] 29 | # if it is necessary to remove some sensitive data in checkpoint['meta'], 30 | # add the code here. 31 | if torch.__version__ >= '1.6': 32 | torch.save(checkpoint, out_file, _use_new_zipfile_serialization=False) 33 | else: 34 | torch.save(checkpoint, out_file) 35 | sha = subprocess.check_output(['sha256sum', out_file]).decode() 36 | if out_file.endswith('.pth'): 37 | out_file_name = out_file[:-4] 38 | else: 39 | out_file_name = out_file 40 | final_file = out_file_name + f'_{model_time}' + f'-{sha[:8]}.pth' 41 | subprocess.Popen(['mv', out_file, final_file]) 42 | cp_log_json_path = out_file_name + f'_{osp.basename(log_json_path)}' 43 | subprocess.Popen(['cp', log_json_path, cp_log_json_path]) 44 | 45 | 46 | def main(): 47 | args = parse_args() 48 | process_checkpoint(args.in_file, args.out_file) 49 | 50 | 51 | if __name__ == '__main__': 52 | main() 53 | -------------------------------------------------------------------------------- /window_capture.py: -------------------------------------------------------------------------------- 1 | import win32api, win32con, win32gui, win32ui 2 | import numpy as np 3 | import cv2 4 | 5 | class WindowCapture: 6 | def __init__(self, name, width=1920, height=1080): 7 | self.WINDOW_NAME = name 8 | self.DEFAULT_MONITOR_WIDTH = width 9 | self.DEFAULT_MONITOR_HEIGHT = height 10 | 11 | self.hwnd = win32gui.FindWindow(None, self.WINDOW_NAME) 12 | self.genshin_window_rect = win32gui.GetWindowRect(self.hwnd) 13 | 14 | self.ofx=0 15 | self.ofy=0 16 | 17 | def set_offset(self, ofx, ofy): 18 | self.ofx=ofx 19 | self.ofy=ofy 20 | 21 | def cap_box(self, box=None, resize=None): 22 | return self.cap(area=[box[0], box[1], box[2]-box[0], box[3]-box[1]], resize=resize) 23 | 24 | def cap(self, area=None, resize=None): 25 | if area is None: 26 | area=[0,0,self.DEFAULT_MONITOR_WIDTH, self.DEFAULT_MONITOR_HEIGHT] 27 | w, h = area[2:] 28 | 29 | wDC = win32gui.GetWindowDC(self.hwnd) 30 | dcObj = win32ui.CreateDCFromHandle(wDC) 31 | cDC = dcObj.CreateCompatibleDC() 32 | dataBitMap = win32ui.CreateBitmap() 33 | 34 | dataBitMap.CreateCompatibleBitmap(dcObj, w, h) 35 | 36 | cDC.SelectObject(dataBitMap) 37 | cDC.BitBlt((0, 0), (w, h), dcObj, (area[0]+self.ofx, area[1]+self.ofy), win32con.SRCCOPY) 38 | # dataBitMap.SaveBitmapFile(cDC, bmpfilenamename) 39 | signedIntsArray = dataBitMap.GetBitmapBits(True) 40 | img = np.frombuffer(signedIntsArray, dtype="uint8") 41 | img.shape = (h, w, 4) 42 | img=cv2.cvtColor(img, cv2.COLOR_BGRA2BGR) 43 | 44 | # Free Resources 45 | dcObj.DeleteDC() 46 | cDC.DeleteDC() 47 | win32gui.ReleaseDC(self.hwnd, wDC) 48 | win32gui.DeleteObject(dataBitMap.GetHandle()) 49 | 50 | if resize is not None: 51 | img=cv2.resize(img, (int(resize[0]), int(resize[1]))) 52 | 53 | return img -------------------------------------------------------------------------------- /mmtracking/configs/vid/temporal_roi_align/selsa_troialign_faster_rcnn_r50_dc5_7e_imagenetvid.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../../_base_/models/faster_rcnn_r50_dc5.py', 3 | '../../_base_/datasets/imagenet_vid_fgfa_style.py', 4 | '../../_base_/default_runtime.py' 5 | ] 6 | model = dict( 7 | type='SELSA', 8 | detector=dict( 9 | roi_head=dict( 10 | type='SelsaRoIHead', 11 | bbox_roi_extractor=dict( 12 | type='TemporalRoIAlign', 13 | num_most_similar_points=2, 14 | num_temporal_attention_blocks=4, 15 | roi_layer=dict( 16 | type='RoIAlign', output_size=7, sampling_ratio=2), 17 | out_channels=512, 18 | featmap_strides=[16]), 19 | bbox_head=dict( 20 | type='SelsaBBoxHead', 21 | num_shared_fcs=3, 22 | aggregator=dict( 23 | type='SelsaAggregator', 24 | in_channels=1024, 25 | num_attention_blocks=16))))) 26 | 27 | # dataset settings 28 | data = dict( 29 | val=dict( 30 | ref_img_sampler=dict( 31 | _delete_=True, 32 | num_ref_imgs=14, 33 | frame_range=[-7, 7], 34 | method='test_with_adaptive_stride')), 35 | test=dict( 36 | ref_img_sampler=dict( 37 | _delete_=True, 38 | num_ref_imgs=14, 39 | frame_range=[-7, 7], 40 | method='test_with_adaptive_stride'))) 41 | 42 | # optimizer 43 | optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) 44 | optimizer_config = dict( 45 | _delete_=True, grad_clip=dict(max_norm=35, norm_type=2)) 46 | # learning policy 47 | lr_config = dict( 48 | policy='step', 49 | warmup='linear', 50 | warmup_iters=500, 51 | warmup_ratio=1.0 / 3, 52 | step=[2, 5]) 53 | # runtime settings 54 | total_epochs = 7 55 | evaluation = dict(metric=['bbox'], interval=7) 56 | -------------------------------------------------------------------------------- /mmtracking/tests/test_data/test_pipelines/test_loading.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import copy 3 | import os.path as osp 4 | 5 | import numpy as np 6 | 7 | from mmtrack.datasets import PIPELINES 8 | 9 | 10 | class TestLoading(object): 11 | 12 | @classmethod 13 | def setup_class(cls): 14 | cls.data_prefix = osp.join(osp.dirname(__file__), '../../data') 15 | 16 | def test_load_seq_imgs(self): 17 | img_names = ['image_1.jpg', 'image_2.jpg', 'image_3.jpg'] 18 | results = [ 19 | dict(img_prefix=self.data_prefix, img_info=dict(filename=name)) 20 | for name in img_names 21 | ] 22 | load = PIPELINES.get('LoadMultiImagesFromFile')() 23 | all_results = load(copy.deepcopy(results)) 24 | assert isinstance(all_results, list) 25 | for i, results in enumerate(all_results): 26 | assert results['filename'] == osp.join(self.data_prefix, 27 | img_names[i]) 28 | assert results['ori_filename'] == img_names[i] 29 | assert results['img'].shape == (256, 512, 3) 30 | assert results['img'].dtype == np.uint8 31 | assert results['img_shape'] == (256, 512, 3) 32 | assert results['ori_shape'] == (256, 512, 3) 33 | 34 | def test_load_detections(self): 35 | results = dict() 36 | results['bbox_fields'] = [] 37 | results['detections'] = [np.random.randn(4, 5), np.random.randn(3, 5)] 38 | load = PIPELINES.get('LoadDetections')() 39 | results = load(results) 40 | assert 'public_bboxes' in results 41 | assert 'public_scores' in results 42 | assert 'public_labels' in results 43 | assert results['public_bboxes'].shape == (7, 4) 44 | assert results['public_scores'].shape == (7, ) 45 | assert results['public_labels'].shape == (7, ) 46 | assert 'public_bboxes' in results['bbox_fields'] 47 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/qdtrack/qdtrack_faster-rcnn_r50_fpn_4e_dancetrack.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | './qdtrack_faster-rcnn_r50_fpn_4e_base.py', 3 | '../../_base_/datasets/dancetrack.py', 4 | ] 5 | img_norm_cfg = dict( 6 | mean=[103.530, 116.280, 123.675], std=[1.0, 1.0, 1.0], to_rgb=False) 7 | train_pipeline = [ 8 | dict(type='LoadMultiImagesFromFile', to_float32=True), 9 | dict(type='SeqLoadAnnotations', with_bbox=True, with_track=True), 10 | dict( 11 | type='SeqResize', 12 | img_scale=(1088, 1088), 13 | share_params=True, 14 | ratio_range=(0.8, 1.2), 15 | keep_ratio=True, 16 | bbox_clip_border=False), 17 | dict(type='SeqPhotoMetricDistortion', share_params=True), 18 | dict( 19 | type='SeqRandomCrop', 20 | share_params=False, 21 | crop_size=(1088, 1088), 22 | bbox_clip_border=False), 23 | dict(type='SeqRandomFlip', share_params=True, flip_ratio=0.5), 24 | dict(type='SeqNormalize', **img_norm_cfg), 25 | dict(type='SeqPad', size_divisor=32), 26 | dict(type='MatchInstances', skip_nomatch=True), 27 | dict( 28 | type='VideoCollect', 29 | keys=[ 30 | 'img', 'gt_bboxes', 'gt_labels', 'gt_match_indices', 31 | 'gt_instance_ids' 32 | ]), 33 | dict(type='SeqDefaultFormatBundle', ref_prefix='ref') 34 | ] 35 | test_pipeline = [ 36 | dict(type='LoadImageFromFile'), 37 | dict( 38 | type='MultiScaleFlipAug', 39 | img_scale=(1088, 1088), 40 | flip=False, 41 | transforms=[ 42 | dict(type='Resize', keep_ratio=True), 43 | dict(type='RandomFlip'), 44 | dict(type='Normalize', **img_norm_cfg), 45 | dict(type='Pad', size_divisor=32), 46 | dict(type='ImageToTensor', keys=['img']), 47 | dict(type='VideoCollect', keys=['img']) 48 | ]) 49 | ] 50 | data = dict( 51 | train=dict(pipeline=train_pipeline), 52 | val=dict(pipeline=test_pipeline), 53 | test=dict(pipeline=test_pipeline)) 54 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/qdtrack/qdtrack_faster-rcnn_r50_fpn_4e_mot17-private-half.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | './qdtrack_faster-rcnn_r50_fpn_4e_base.py', 3 | '../../_base_/datasets/mot_challenge.py', 4 | ] 5 | img_norm_cfg = dict( 6 | mean=[103.530, 116.280, 123.675], std=[1.0, 1.0, 1.0], to_rgb=False) 7 | train_pipeline = [ 8 | dict(type='LoadMultiImagesFromFile', to_float32=True), 9 | dict(type='SeqLoadAnnotations', with_bbox=True, with_track=True), 10 | dict( 11 | type='SeqResize', 12 | img_scale=(1088, 1088), 13 | share_params=True, 14 | ratio_range=(0.8, 1.2), 15 | keep_ratio=True, 16 | bbox_clip_border=False), 17 | dict(type='SeqPhotoMetricDistortion', share_params=True), 18 | dict( 19 | type='SeqRandomCrop', 20 | share_params=False, 21 | crop_size=(1088, 1088), 22 | bbox_clip_border=False), 23 | dict(type='SeqRandomFlip', share_params=True, flip_ratio=0.5), 24 | dict(type='SeqNormalize', **img_norm_cfg), 25 | dict(type='SeqPad', size_divisor=32), 26 | dict(type='MatchInstances', skip_nomatch=True), 27 | dict( 28 | type='VideoCollect', 29 | keys=[ 30 | 'img', 'gt_bboxes', 'gt_labels', 'gt_match_indices', 31 | 'gt_instance_ids' 32 | ]), 33 | dict(type='SeqDefaultFormatBundle', ref_prefix='ref') 34 | ] 35 | test_pipeline = [ 36 | dict(type='LoadImageFromFile'), 37 | dict( 38 | type='MultiScaleFlipAug', 39 | img_scale=(1088, 1088), 40 | flip=False, 41 | transforms=[ 42 | dict(type='Resize', keep_ratio=True), 43 | dict(type='RandomFlip'), 44 | dict(type='Normalize', **img_norm_cfg), 45 | dict(type='Pad', size_divisor=32), 46 | dict(type='ImageToTensor', keys=['img']), 47 | dict(type='VideoCollect', keys=['img']) 48 | ]) 49 | ] 50 | data = dict( 51 | train=dict(pipeline=train_pipeline), 52 | val=dict(pipeline=test_pipeline), 53 | test=dict(pipeline=test_pipeline)) 54 | -------------------------------------------------------------------------------- /mmtracking/configs/vid/dff/metafile.yml: -------------------------------------------------------------------------------- 1 | Collections: 2 | - Name: DFF 3 | Metadata: 4 | Training Data: ImageNet DET, ImageNet VID 5 | Training Techniques: 6 | - SGD with Momentum 7 | Training Resources: 8x V100 GPUs 8 | Architecture: 9 | - ResNet 10 | Paper: 11 | URL: https://arxiv.org/abs/1611.07715 12 | Title: Deep Feature Flow for Video Recognition 13 | README: configs/vid/dff/README.md 14 | 15 | Models: 16 | - Name: dff_faster_rcnn_r50_dc5_1x_imagenetvid 17 | In Collection: DFF 18 | Config: configs/vid/dff/dff_faster_rcnn_r50_dc5_1x_imagenetvid.py 19 | Metadata: 20 | Training Memory (GB): 2.50 21 | Results: 22 | - Task: Video Object Detection 23 | Dataset: ImageNet VID 24 | Metrics: 25 | box AP@0.5: 70.3 26 | Weights: https://download.openmmlab.com/mmtracking/vid/dff/dff_faster_rcnn_r50_dc5_1x_imagenetvid/dff_faster_rcnn_r50_dc5_1x_imagenetvid_20201227_213250-548911a4.pth 27 | 28 | - Name: dff_faster_rcnn_r101_dc5_1x_imagenetvid 29 | In Collection: DFF 30 | Config: configs/vid/dff/dff_faster_rcnn_r101_dc5_1x_imagenetvid.py 31 | Metadata: 32 | Training Memory (GB): 3.25 33 | Results: 34 | - Task: Video Object Detection 35 | Dataset: ImageNet VID 36 | Metrics: 37 | box AP@0.5: 73.5 38 | Weights: https://download.openmmlab.com/mmtracking/vid/dff/dff_faster_rcnn_r101_dc5_1x_imagenetvid/dff_faster_rcnn_r101_dc5_1x_imagenetvid_20201218_172720-ad732e17.pth 39 | 40 | - Name: dff_faster_rcnn_x101_dc5_1x_imagenetvid 41 | In Collection: DFF 42 | Config: configs/vid/dff/dff_faster_rcnn_x101_dc5_1x_imagenetvid.py 43 | Metadata: 44 | Training Memory (GB): 4.95 45 | Results: 46 | - Task: Video Object Detection 47 | Dataset: ImageNet VID 48 | Metrics: 49 | box AP@0.5: 75.5 50 | Weights: https://download.openmmlab.com/mmtracking/vid/dff/dff_faster_rcnn_x101_dc5_1x_imagenetvid/dff_faster_rcnn_x101_dc5_1x_imagenetvid_20210819_095932-0a9e6cb5.pth 51 | -------------------------------------------------------------------------------- /mmtracking/configs/vid/fgfa/metafile.yml: -------------------------------------------------------------------------------- 1 | Collections: 2 | - Name: FGFA 3 | Metadata: 4 | Training Data: ImageNet DET, ImageNet VID 5 | Training Techniques: 6 | - SGD with Momentum 7 | Training Resources: 8x V100 GPUs 8 | Architecture: 9 | - ResNet 10 | Paper: 11 | URL: https://arxiv.org/abs/1703.10025 12 | Title: Flow-Guided Feature Aggregation for Video Object Detection 13 | README: configs/vid/fgfa/README.md 14 | 15 | Models: 16 | - Name: fgfa_faster_rcnn_r50_dc5_1x_imagenetvid 17 | In Collection: FGFA 18 | Config: configs/vid/fgfa/fgfa_faster_rcnn_r50_dc5_1x_imagenetvid.py 19 | Metadata: 20 | Training Memory (GB): 4.10 21 | Results: 22 | - Task: Video Object Detection 23 | Dataset: ImageNet VID 24 | Metrics: 25 | box AP@0.5: 74.7 26 | Weights: https://download.openmmlab.com/mmtracking/vid/fgfa/fgfa_faster_rcnn_r50_dc5_1x_imagenetvid/fgfa_faster_rcnn_r50_dc5_1x_imagenetvid_20201228_022657-f42016f3.pth 27 | 28 | - Name: fgfa_faster_rcnn_r101_dc5_1x_imagenetvid 29 | In Collection: FGFA 30 | Config: configs/vid/fgfa/fgfa_faster_rcnn_r101_dc5_1x_imagenetvid.py 31 | Metadata: 32 | Training Memory (GB): 5.80 33 | Results: 34 | - Task: Video Object Detection 35 | Dataset: ImageNet VID 36 | Metrics: 37 | box AP@0.5: 77.8 38 | Weights: https://download.openmmlab.com/mmtracking/vid/fgfa/fgfa_faster_rcnn_r101_dc5_1x_imagenetvid/fgfa_faster_rcnn_r101_dc5_1x_imagenetvid_20201219_011831-9c9d8183.pth 39 | 40 | - Name: fgfa_faster_rcnn_x101_dc5_1x_imagenetvid 41 | In Collection: FGFA 42 | Config: configs/vid/fgfa/fgfa_faster_rcnn_x101_dc5_1x_imagenetvid.py 43 | Metadata: 44 | Training Memory (GB): 9.74 45 | Results: 46 | - Task: Video Object Detection 47 | Dataset: ImageNet VID 48 | Metrics: 49 | box AP@0.5: 79.6 50 | Weights: https://download.openmmlab.com/mmtracking/vid/fgfa/fgfa_faster_rcnn_x101_dc5_1x_imagenetvid/fgfa_faster_rcnn_x101_dc5_1x_imagenetvid_20210818_223334-8723c594.pth 51 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/qdtrack/qdtrack_faster-rcnn_r50_fpn_4e_crowdhuman_mot17-private-half.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./qdtrack_faster-rcnn_r50_fpn_4e_mot17-private-half.py'] 2 | img_norm_cfg = dict( 3 | mean=[103.530, 116.280, 123.675], std=[1.0, 1.0, 1.0], to_rgb=False) 4 | train_pipeline = [ 5 | dict(type='LoadMultiImagesFromFile', to_float32=True), 6 | dict(type='SeqLoadAnnotations', with_bbox=True, with_track=True), 7 | dict( 8 | type='SeqResize', 9 | img_scale=(1088, 1088), 10 | share_params=True, 11 | ratio_range=(0.8, 1.2), 12 | keep_ratio=True, 13 | bbox_clip_border=False), 14 | dict(type='SeqPhotoMetricDistortion', share_params=True), 15 | dict( 16 | type='SeqRandomCrop', 17 | share_params=False, 18 | crop_size=(1088, 1088), 19 | bbox_clip_border=False), 20 | dict(type='SeqRandomFlip', share_params=True, flip_ratio=0.5), 21 | dict(type='SeqNormalize', **img_norm_cfg), 22 | dict(type='SeqPad', size_divisor=32), 23 | dict(type='MatchInstances', skip_nomatch=True), 24 | dict( 25 | type='VideoCollect', 26 | keys=[ 27 | 'img', 'gt_bboxes', 'gt_labels', 'gt_match_indices', 28 | 'gt_instance_ids' 29 | ]), 30 | dict(type='SeqDefaultFormatBundle', ref_prefix='ref') 31 | ] 32 | mot_cfg = dict( 33 | type='MOTChallengeDataset', 34 | classes=('pedestrian', ), 35 | visibility_thr=-1, 36 | ann_file='data/MOT17/annotations/half-train_cocoformat.json', 37 | img_prefix='data/MOT17/train', 38 | ref_img_sampler=dict(num_ref_imgs=1, frame_range=10, method='uniform'), 39 | pipeline=train_pipeline) 40 | crowdhuman_cfg = dict( 41 | type='CocoVideoDataset', 42 | load_as_video=False, 43 | classes=('pedestrian', ), 44 | ann_file='data/crowdhuman/annotations/crowdhuman_train.json', 45 | img_prefix='data/crowdhuman/train', 46 | pipeline=train_pipeline) 47 | data = dict( 48 | train=dict( 49 | _delete_=True, 50 | type='ConcatDataset', 51 | datasets=[mot_cfg, crowdhuman_cfg], 52 | saparate_eval=False)) 53 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/datasets/dataset_wrappers.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import random 3 | 4 | from mmdet.datasets.builder import DATASETS, build_dataset 5 | from torch.utils.data.dataset import ConcatDataset 6 | 7 | 8 | @DATASETS.register_module() 9 | class RandomSampleConcatDataset(ConcatDataset): 10 | """A wrapper of concatenated dataset. Support randomly sampling one dataset 11 | from concatenated datasets and then getting samples from the sampled 12 | dataset. 13 | 14 | Args: 15 | dataset_cfgs (list[dict]): The list contains all configs of 16 | concatenated datasets. 17 | dataset_sampling_weights (list[float]): The list contains the sampling 18 | weights of each dataset. 19 | """ 20 | 21 | def __init__(self, dataset_cfgs, dataset_sampling_weights=None): 22 | if dataset_sampling_weights is None: 23 | self.dataset_sampling_probs = [1. / len(dataset_cfgs) 24 | ] * len(dataset_cfgs) 25 | else: 26 | for x in dataset_sampling_weights: 27 | assert x >= 0. 28 | prob_total = float(sum(dataset_sampling_weights)) 29 | assert prob_total > 0. 30 | self.dataset_sampling_probs = [ 31 | x / prob_total for x in dataset_sampling_weights 32 | ] 33 | 34 | datasets = [build_dataset(cfg) for cfg in dataset_cfgs] 35 | # add an attribute `CLASSES` for the calling in `tools/train.py` 36 | self.CLASSES = datasets[0].CLASSES 37 | 38 | super().__init__(datasets) 39 | 40 | def __getitem__(self, ind): 41 | """Random sampling a dataset and get samples from this dataset. 42 | 43 | Actually, the input 'ind' is not used in 'dataset'. 44 | """ 45 | while True: 46 | dataset = random.choices(self.datasets, 47 | self.dataset_sampling_probs)[0] 48 | ind = random.randint(0, len(dataset) - 1) 49 | results = dataset[ind] 50 | if results is not None: 51 | return results 52 | -------------------------------------------------------------------------------- /mmtracking/tests/test_models/test_trackers/test_masktrack_rcnn_tracker.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from unittest.mock import MagicMock 3 | 4 | import torch 5 | from mmdet.core.bbox.demodata import random_boxes 6 | 7 | from mmtrack.models import TRACKERS 8 | 9 | 10 | class TestMaskTrackRCNNTracker(object): 11 | 12 | @classmethod 13 | def setup_class(cls): 14 | cfg = dict( 15 | match_weights=dict(det_score=1.0, iou=1.0, det_label=1000.0), ) 16 | tracker = TRACKERS.get('MaskTrackRCNNTracker') 17 | cls.tracker = tracker(**cfg) 18 | cls.num_objs = 5 19 | 20 | def test_track(self): 21 | img_size, feats_channel = 64, 8 22 | img = torch.rand((1, 3, img_size, img_size)) 23 | 24 | img_metas = [dict(scale_factor=1.0)] 25 | 26 | model = MagicMock() 27 | model.track_head.extract_roi_feats = MagicMock( 28 | return_value=(torch.rand(self.num_objs, feats_channel, 7, 7), 29 | [self.num_objs])) 30 | model.track_head.simple_test = MagicMock( 31 | return_value=torch.rand((self.num_objs, self.num_objs + 1))) 32 | 33 | feats = torch.rand((1, feats_channel, img_size, img_size)) 34 | 35 | bboxes = random_boxes(self.num_objs, img_size) 36 | scores = torch.rand((self.num_objs, 1)) 37 | bboxes = torch.cat((bboxes, scores), dim=1) 38 | 39 | labels = torch.arange(self.num_objs) 40 | 41 | masks = torch.zeros((self.num_objs, img_size, img_size)) 42 | 43 | for frame_id in range(3): 44 | bboxes, labels, masks, ids = self.tracker.track( 45 | img, 46 | img_metas, 47 | model, 48 | feats, 49 | bboxes, 50 | labels, 51 | masks, 52 | frame_id, 53 | rescale=True) 54 | assert bboxes.shape[0] == self.num_objs 55 | assert labels.shape[0] == self.num_objs 56 | assert masks.shape == (self.num_objs, img_size, img_size) 57 | assert ids.shape[0] == self.num_objs 58 | -------------------------------------------------------------------------------- /mmtracking/configs/_base_/datasets/coco_instance_semantic.py: -------------------------------------------------------------------------------- 1 | dataset_type = 'CocoDataset' 2 | data_root = 'data/coco/' 3 | img_norm_cfg = dict( 4 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 5 | train_pipeline = [ 6 | dict(type='LoadImageFromFile'), 7 | dict( 8 | type='LoadAnnotations', with_bbox=True, with_mask=True, with_seg=True), 9 | dict(type='Resize', img_scale=(1333, 800), keep_ratio=True), 10 | dict(type='RandomFlip', flip_ratio=0.5), 11 | dict(type='Normalize', **img_norm_cfg), 12 | dict(type='Pad', size_divisor=32), 13 | dict(type='SegRescale', scale_factor=1 / 8), 14 | dict(type='DefaultFormatBundle'), 15 | dict( 16 | type='Collect', 17 | keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks', 'gt_semantic_seg']), 18 | ] 19 | test_pipeline = [ 20 | dict(type='LoadImageFromFile'), 21 | dict( 22 | type='MultiScaleFlipAug', 23 | img_scale=(1333, 800), 24 | flip=False, 25 | transforms=[ 26 | dict(type='Resize', keep_ratio=True), 27 | dict(type='RandomFlip', flip_ratio=0.5), 28 | dict(type='Normalize', **img_norm_cfg), 29 | dict(type='Pad', size_divisor=32), 30 | dict(type='ImageToTensor', keys=['img']), 31 | dict(type='Collect', keys=['img']), 32 | ]) 33 | ] 34 | data = dict( 35 | samples_per_gpu=2, 36 | workers_per_gpu=2, 37 | train=dict( 38 | type=dataset_type, 39 | ann_file=data_root + 'annotations/instances_train2017.json', 40 | img_prefix=data_root + 'train2017/', 41 | seg_prefix=data_root + 'stuffthingmaps/train2017/', 42 | pipeline=train_pipeline), 43 | val=dict( 44 | type=dataset_type, 45 | ann_file=data_root + 'annotations/instances_val2017.json', 46 | img_prefix=data_root + 'val2017/', 47 | pipeline=test_pipeline), 48 | test=dict( 49 | type=dataset_type, 50 | ann_file=data_root + 'annotations/instances_val2017.json', 51 | img_prefix=data_root + 'val2017/', 52 | pipeline=test_pipeline)) 53 | evaluation = dict(metric=['bbox', 'segm']) 54 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/bytetrack/metafile.yml: -------------------------------------------------------------------------------- 1 | Collections: 2 | - Name: ByteTrack 3 | Metadata: 4 | Training Techniques: 5 | - SGD with Momentum 6 | Training Resources: 8x V100 GPUs 7 | Architecture: 8 | - YOLOX 9 | Paper: 10 | URL: https://arxiv.org/abs/2110.06864 11 | Title: ByteTrack Multi-Object Tracking by Associating Every Detection Box 12 | README: configs/mot/bytetrack/README.md 13 | 14 | Models: 15 | - Name: bytetrack_yolox_x_crowdhuman_mot17-private-half 16 | In Collection: ByteTrack 17 | Config: configs/mot/bytetrack/bytetrack_yolox_x_crowdhuman_mot17-private-half.py 18 | Metadata: 19 | Training Data: CrowdHuman + MOT17-half-train 20 | Results: 21 | - Task: Multiple Object Tracking 22 | Dataset: MOT17-half-val 23 | Metrics: 24 | MOTA: 78.6 25 | IDF1: 79.2 26 | Weights: https://download.openmmlab.com/mmtracking/mot/bytetrack/bytetrack_yolox_x/bytetrack_yolox_x_crowdhuman_mot17-private-half_20211218_205500-1985c9f0.pth 27 | 28 | - Name: bytetrack_yolox_x_crowdhuman_mot17-private 29 | In Collection: ByteTrack 30 | Config: configs/mot/bytetrack/bytetrack_yolox_x_crowdhuman_mot17-private.py 31 | Metadata: 32 | Training Data: CrowdHuman + MOT17-half-train 33 | Results: 34 | - Task: Multiple Object Tracking 35 | Dataset: MOT17-test 36 | Metrics: 37 | MOTA: 78.1 38 | IDF1: 74.8 39 | Weights: https://download.openmmlab.com/mmtracking/mot/bytetrack/bytetrack_yolox_x/bytetrack_yolox_x_crowdhuman_mot17-private-half_20211218_205500-1985c9f0.pth 40 | 41 | - Name: bytetrack_yolox_x_crowdhuman_mot20-private 42 | In Collection: ByteTrack 43 | Config: configs/mot/bytetrack/bytetrack_yolox_x_crowdhuman_mot20-private.py 44 | Metadata: 45 | Training Data: CrowdHuman + MOT20-train 46 | Results: 47 | - Task: Multiple Object Tracking 48 | Dataset: MOT20-test 49 | Metrics: 50 | MOTA: 77.0 51 | IDF1: 75.4 52 | Weights: https://download.openmmlab.com/mmtracking/mot/bytetrack/bytetrack_yolox_x/bytetrack_yolox_x_crowdhuman_mot20-private_20220506_101040-9ce38a60.pth 53 | -------------------------------------------------------------------------------- /mmtracking/tests/test_models/test_reid/test_base_reid.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import pytest 3 | import torch 4 | 5 | from mmtrack.models import REID 6 | 7 | 8 | @pytest.mark.parametrize('model_type', ['BaseReID']) 9 | def test_base_reid(model_type): 10 | model_class = REID.get(model_type) 11 | backbone = dict( 12 | type='ResNet', 13 | depth=50, 14 | num_stages=4, 15 | out_indices=(3, ), 16 | style='pytorch') 17 | neck = dict(type='GlobalAveragePooling', kernel_size=(8, 4), stride=1) 18 | head = dict( 19 | type='LinearReIDHead', 20 | num_fcs=1, 21 | in_channels=2048, 22 | fc_channels=1024, 23 | out_channels=128, 24 | num_classes=378, 25 | loss=dict(type='CrossEntropyLoss', loss_weight=1.0), 26 | loss_pairwise=dict(type='TripletLoss', margin=0.3, loss_weight=1.0), 27 | norm_cfg=dict(type='BN1d'), 28 | act_cfg=dict(type='ReLU')) 29 | model = model_class(backbone=backbone, neck=neck, head=head) 30 | model.train() 31 | x = torch.randn(32, 3, 256, 128) 32 | label = torch.randperm(32) 33 | outputs = model.forward_train(x, label) 34 | assert isinstance(outputs, dict) 35 | assert len(outputs) == 3 36 | assert 'triplet_loss' in outputs 37 | assert 'ce_loss' in outputs 38 | assert 'accuracy' in outputs 39 | model.eval() 40 | x = torch.randn(1, 3, 256, 128) 41 | outputs = model.simple_test(x) 42 | assert outputs.shape == (1, 128) 43 | 44 | head['num_classes'] = None 45 | # when loss_pairwise is set, num_classes must be a current number 46 | with pytest.raises(TypeError): 47 | model = model_class(backbone=backbone, neck=neck, head=head) 48 | 49 | head['num_classes'] = 378 50 | head['loss'] = None 51 | # when loss_pairwise is set, num_classes will be ignored. 52 | with pytest.warns(UserWarning): 53 | model = model_class(backbone=backbone, neck=neck, head=head) 54 | 55 | head['loss_pairwise'] = None 56 | # two losses cannot be none at the same time 57 | with pytest.raises(ValueError): 58 | model = model_class(backbone=backbone, neck=neck, head=head) 59 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/tracktor/tracktor_faster-rcnn_r50_fpn_4e_mot15-public-half.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./tracktor_faster-rcnn_r50_fpn_4e_mot17-private-half.py'] 2 | 3 | model = dict( 4 | detector=dict( 5 | init_cfg=dict( 6 | type='Pretrained', 7 | checkpoint= # noqa: E251 8 | 'https://download.openmmlab.com/mmtracking/mot/faster_rcnn/faster-rcnn_r50_fpn_4e_mot15-half_20210804_001040-ae733d0c.pth' # noqa: E501 9 | )), 10 | reid=dict( 11 | head=dict(num_classes=375), 12 | init_cfg=dict( 13 | type='Pretrained', 14 | checkpoint= # noqa: E251 15 | 'https://download.openmmlab.com/mmtracking/mot/reid/reid_r50_6e_mot15_20210803_192157-65b5e2d7.pth' # noqa: E501 16 | ))) 17 | # data 18 | data_root = 'data/MOT15/' 19 | img_norm_cfg = dict( 20 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 21 | test_pipeline = [ 22 | dict(type='LoadImageFromFile'), 23 | dict(type='LoadDetections'), 24 | dict( 25 | type='MultiScaleFlipAug', 26 | img_scale=(1088, 1088), 27 | flip=False, 28 | transforms=[ 29 | dict(type='Resize', keep_ratio=True), 30 | dict(type='RandomFlip'), 31 | dict(type='Normalize', **img_norm_cfg), 32 | dict(type='Pad', size_divisor=32), 33 | dict(type='ImageToTensor', keys=['img']), 34 | dict(type='VideoCollect', keys=['img', 'public_bboxes']) 35 | ]) 36 | ] 37 | data = dict( 38 | train=dict( 39 | ann_file=data_root + 'annotations/half-train_cocoformat.json', 40 | detection_file=data_root + 'annotations/half-train_detections.pkl', 41 | img_prefix=data_root + 'train'), 42 | val=dict( 43 | ann_file=data_root + 'annotations/half-val_cocoformat.json', 44 | detection_file=data_root + 'annotations/half-val_detections.pkl', 45 | img_prefix=data_root + 'train', 46 | pipeline=test_pipeline), 47 | test=dict( 48 | ann_file=data_root + 'annotations/half-val_cocoformat.json', 49 | detection_file=data_root + 'annotations/half-val_detections.pkl', 50 | img_prefix=data_root + 'train', 51 | pipeline=test_pipeline)) 52 | -------------------------------------------------------------------------------- /mmtracking/configs/mot/tracktor/tracktor_faster-rcnn_r50_fpn_4e_mot16-public-half.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./tracktor_faster-rcnn_r50_fpn_4e_mot17-private-half.py'] 2 | 3 | model = dict( 4 | detector=dict( 5 | init_cfg=dict( 6 | type='Pretrained', 7 | checkpoint= # noqa: E251 8 | 'https://download.openmmlab.com/mmtracking/mot/faster_rcnn/faster-rcnn_r50_fpn_4e_mot16-half_20210804_001054-73477869.pth' # noqa: E501 9 | )), 10 | reid=dict( 11 | head=dict(num_classes=375), 12 | init_cfg=dict( 13 | type='Pretrained', 14 | checkpoint= # noqa: E251 15 | 'https://download.openmmlab.com/mmtracking/mot/reid/reid_r50_6e_mot16_20210803_204826-1b3e3cfd.pth' # noqa: E501 16 | ))) 17 | # data 18 | data_root = 'data/MOT16/' 19 | img_norm_cfg = dict( 20 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 21 | test_pipeline = [ 22 | dict(type='LoadImageFromFile'), 23 | dict(type='LoadDetections'), 24 | dict( 25 | type='MultiScaleFlipAug', 26 | img_scale=(1088, 1088), 27 | flip=False, 28 | transforms=[ 29 | dict(type='Resize', keep_ratio=True), 30 | dict(type='RandomFlip'), 31 | dict(type='Normalize', **img_norm_cfg), 32 | dict(type='Pad', size_divisor=32), 33 | dict(type='ImageToTensor', keys=['img']), 34 | dict(type='VideoCollect', keys=['img', 'public_bboxes']) 35 | ]) 36 | ] 37 | data = dict( 38 | train=dict( 39 | ann_file=data_root + 'annotations/half-train_cocoformat.json', 40 | detection_file=data_root + 'annotations/half-train_detections.pkl', 41 | img_prefix=data_root + 'train'), 42 | val=dict( 43 | ann_file=data_root + 'annotations/half-val_cocoformat.json', 44 | detection_file=data_root + 'annotations/half-val_detections.pkl', 45 | img_prefix=data_root + 'train', 46 | pipeline=test_pipeline), 47 | test=dict( 48 | ann_file=data_root + 'annotations/half-val_cocoformat.json', 49 | detection_file=data_root + 'annotations/half-val_detections.pkl', 50 | img_prefix=data_root + 'train', 51 | pipeline=test_pipeline)) 52 | -------------------------------------------------------------------------------- /mmtracking/configs/_base_/datasets/mot_challenge_det.py: -------------------------------------------------------------------------------- 1 | # dataset settings 2 | dataset_type = 'CocoDataset' 3 | img_norm_cfg = dict( 4 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 5 | train_pipeline = [ 6 | dict(type='LoadImageFromFile', to_float32=True), 7 | dict(type='LoadAnnotations', with_bbox=True), 8 | dict( 9 | type='Resize', 10 | img_scale=(1088, 1088), 11 | ratio_range=(0.8, 1.2), 12 | keep_ratio=True, 13 | bbox_clip_border=False), 14 | dict(type='PhotoMetricDistortion'), 15 | dict(type='RandomCrop', crop_size=(1088, 1088), bbox_clip_border=False), 16 | dict(type='RandomFlip', flip_ratio=0.5), 17 | dict(type='Normalize', **img_norm_cfg), 18 | dict(type='Pad', size_divisor=32), 19 | dict(type='DefaultFormatBundle'), 20 | dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']) 21 | ] 22 | test_pipeline = [ 23 | dict(type='LoadImageFromFile'), 24 | dict( 25 | type='MultiScaleFlipAug', 26 | img_scale=(1088, 1088), 27 | flip=False, 28 | transforms=[ 29 | dict(type='Resize', keep_ratio=True), 30 | dict(type='RandomFlip'), 31 | dict(type='Normalize', **img_norm_cfg), 32 | dict(type='Pad', size_divisor=32), 33 | dict(type='ImageToTensor', keys=['img']), 34 | dict(type='Collect', keys=['img']) 35 | ]) 36 | ] 37 | data_root = 'data/MOT17/' 38 | data = dict( 39 | samples_per_gpu=2, 40 | workers_per_gpu=2, 41 | train=dict( 42 | type=dataset_type, 43 | ann_file=data_root + 'annotations/half-train_cocoformat.json', 44 | img_prefix=data_root + 'train', 45 | classes=('pedestrian', ), 46 | pipeline=train_pipeline), 47 | val=dict( 48 | type=dataset_type, 49 | ann_file=data_root + 'annotations/half-val_cocoformat.json', 50 | img_prefix=data_root + 'train', 51 | classes=('pedestrian', ), 52 | pipeline=test_pipeline), 53 | test=dict( 54 | type=dataset_type, 55 | ann_file=data_root + 'annotations/half-val_cocoformat.json', 56 | img_prefix=data_root + 'train', 57 | classes=('pedestrian', ), 58 | pipeline=test_pipeline)) 59 | evaluation = dict(metric=['bbox']) 60 | -------------------------------------------------------------------------------- /mmtracking/mmtrack/datasets/uav123_dataset.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import os 3 | import time 4 | 5 | from mmdet.datasets import DATASETS 6 | 7 | from .base_sot_dataset import BaseSOTDataset 8 | 9 | 10 | @DATASETS.register_module() 11 | class UAV123Dataset(BaseSOTDataset): 12 | """UAV123 dataset of single object tracking. 13 | 14 | The dataset is only used to test. 15 | """ 16 | 17 | def __init__(self, *args, **kwargs): 18 | """Initialization of SOT dataset class.""" 19 | super().__init__(*args, **kwargs) 20 | 21 | def load_data_infos(self, split='test'): 22 | """Load dataset information. 23 | 24 | Args: 25 | split (str, optional): Dataset split. Defaults to 'test'. 26 | 27 | Returns: 28 | list[dict]: The length of the list is the number of videos. The 29 | inner dict is in the following format: 30 | { 31 | 'video_path': the video path 32 | 'ann_path': the annotation path 33 | 'start_frame_id': the starting frame number contained 34 | in the image name 35 | 'end_frame_id': the ending frame number contained in 36 | the image name 37 | 'framename_template': the template of image name 38 | } 39 | """ 40 | print('Loading UAV123 dataset...') 41 | start_time = time.time() 42 | data_infos = [] 43 | data_infos_str = self.loadtxt( 44 | self.ann_file, return_array=False).split('\n') 45 | # the first line of annotation file is a dataset comment. 46 | for line in data_infos_str[1:]: 47 | # compatible with different OS. 48 | line = line.strip().replace('/', os.sep).split(',') 49 | data_info = dict( 50 | video_path=line[0], 51 | ann_path=line[1], 52 | start_frame_id=int(line[2]), 53 | end_frame_id=int(line[3]), 54 | framename_template='%06d.jpg') 55 | data_infos.append(data_info) 56 | print(f'UAV123 dataset loaded! ({time.time()-start_time:.2f} s)') 57 | return data_infos 58 | -------------------------------------------------------------------------------- /mmtracking/docs/zh_cn/model_zoo.md: -------------------------------------------------------------------------------- 1 | # 基准测试与模型库 2 | 3 | ## 通用设置 4 | 5 | - 我们默认使用分布式训练。 6 | 7 | - 所有 pytorch 类型的预训练骨干网络都是来自 Pytorch 的模型库。 8 | 9 | - 为了与其他代码库进行公平比较,我们以全部 8 个 GPU 的 `torch.cuda.max_memory_allocated()` 的最大值作为 GPU 显存使用量。请注意,此值通常小于 `nvidia-smi` 显示的值。 10 | 11 | - 该推理时间不包含数据加载时间,推理时间结果是通过脚本 `tools/analysis/benchmark.py` 获得的,该脚本计算处理 2000 张图像的平均时间。 12 | 13 | - 速度基准测试的环境如下: 14 | 15 | 硬件环境: 16 | 17 | - 8 NVIDIA Tesla V100 (32G) GPUs 18 | - Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz 19 | 20 | 软件环境: 21 | 22 | - Python 3.7 23 | - PyTorch 1.5 24 | - CUDA 10.1 25 | - CUDNN 7.6.03 26 | - NCCL 2.4.08 27 | 28 | ## 视频目标检测基线 29 | 30 | ### DFF (CVPR 2017) 31 | 32 | 详情请参考 [DFF](https://github.com/open-mmlab/mmtracking/blob/master/configs/vid/dff/README.md)。 33 | 34 | ### FGFA (ICCV 2017) 35 | 36 | 详情请参考 [FGFA](https://github.com/open-mmlab/mmtracking/blob/master/configs/vid/fgfa/README.md)。 37 | 38 | ### SELSA (ICCV 2019) 39 | 40 | 详情请参考 [SELSA](https://github.com/open-mmlab/mmtracking/blob/master/configs/vid/selsa/README.md)。 41 | 42 | ### Temporal RoI Align (AAAI 2021) 43 | 44 | 详情请参考 [Temporal RoI Align](https://github.com/open-mmlab/mmtracking/blob/master/configs/vid/temporal_roi_align)。 45 | 46 | ## 多目标跟踪基线 47 | 48 | ### SORT/DeepSORT (ICIP 2016/2017) 49 | 50 | 详情请参考 [SORT/DeepSORT](https://github.com/open-mmlab/mmtracking/blob/master/configs/mot/deepsort/README.md)。 51 | 52 | ### Tracktor (ICCV 2019) 53 | 54 | 详情请参考 [Tracktor](https://github.com/open-mmlab/mmtracking/blob/master/configs/mot/tracktor/README.md)。 55 | 56 | ### QDTrack (CVPR 2021) 57 | 58 | 详情请参考 [QDTrack](https://github.com/open-mmlab/mmtracking/blob/master/configs/mot/qdtrack/README.md)。 59 | 60 | ### ByteTrack (arXiv 2021) 61 | 62 | 详情请参考 [ByteTrack](https://github.com/open-mmlab/mmtracking/blob/master/configs/mot/bytetrack)。 63 | 64 | ## 单目标跟踪基线 65 | 66 | ### SiameseRPN++ (CVPR 2019) 67 | 68 | 详情请参考 [SiameseRPN++](https://github.com/open-mmlab/mmtracking/blob/master/configs/sot/siamese_rpn/README.md)。 69 | 70 | ### STARK (ICCV 2021) 71 | 72 | 详情请参考 [STARK](https://github.com/open-mmlab/mmtracking/blob/master/configs/sot/stark)。 73 | 74 | ## 视频个例分割基线 75 | 76 | ### MaskTrack R-CNN (ICCV 2019) 77 | 78 | 详情请参考 [MaskTrack R-CNN](https://github.com/open-mmlab/mmtracking/blob/master/configs/vis/masktrack_rcnn)。 79 | --------------------------------------------------------------------------------