├── HOT2022-MMFNet-Results.zip ├── HOTC-MMFNet-Results.zip ├── IMEC25-MMFNet-Results.zip ├── LICENSE ├── MMF_Net_HOT2023_results.zip ├── README.md ├── check_format.sh ├── compile.sh ├── datasets └── OTB │ └── OTB2015 │ └── Bird2.zipm2xpryrc.tmp ├── demo └── readme.txt ├── experiments └── stmtrack │ ├── test │ ├── UAV123 │ │ └── stmtrack-googlenet-uav123.yaml │ ├── got10k │ │ └── stmtrack-googlenet-got.yaml │ ├── lasot │ │ └── stmtrack-googlenet-lasot.yaml │ ├── otb │ │ └── stmtrack-googlenet-otb.yaml │ ├── trackingnet │ │ └── stmtrack-googlenet-trackingnet.yaml │ └── vot │ │ └── stmtrack-googlenet-vot.yaml │ └── train │ ├── fulldata │ └── stmtrack-googlenet-trn-fulldata.yaml │ └── got10k │ └── stmtrack-googlenet-trn.yaml ├── main ├── __pycache__ │ └── paths.cpython-37.pyc ├── paths.py ├── test.py └── train.py ├── readme ├── requirements.txt ├── setup.sh ├── snapshots └── stmtrack-googlenet-got-train │ └── readme.txt ├── test.sh ├── train.sh └── videoanalyst ├── __init__.py ├── __pycache__ └── __init__.cpython-37.pyc ├── config ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-37.pyc │ └── config.cpython-37.pyc ├── config.py └── utils.py ├── data ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-37.pyc │ ├── adaptor_dataset.cpython-37.pyc │ └── builder.cpython-37.pyc ├── adaptor_dataset.py ├── builder.py ├── datapipeline │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── builder.cpython-37.pyc │ │ └── datapipeline_base.cpython-37.pyc │ ├── builder.py │ ├── datapipeline_base.py │ └── datapipeline_impl │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ └── regular_datapipeline.cpython-37.pyc │ │ └── regular_datapipeline.py ├── dataset │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── builder.cpython-37.pyc │ │ └── dataset_base.cpython-37.pyc │ ├── builder.py │ ├── dataset_base.py │ └── dataset_impl │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── coco.cpython-37.pyc │ │ ├── davis.cpython-37.pyc │ │ ├── got10k.cpython-37.pyc │ │ ├── ilsvrc_det.cpython-37.pyc │ │ ├── ilsvrc_vid.cpython-37.pyc │ │ ├── lasot.cpython-37.pyc │ │ ├── trackingnet.cpython-37.pyc │ │ └── ytb_vos.cpython-37.pyc │ │ ├── coco.py │ │ ├── davis.py │ │ ├── got10k.py │ │ ├── ilsvrc_det.py │ │ ├── ilsvrc_vid.py │ │ ├── lasot.py │ │ ├── trackingnet.py │ │ ├── utils │ │ ├── __init__.py │ │ └── unfixed_got10k_list.txt │ │ └── ytb_vos.py ├── filter │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── builder.cpython-37.pyc │ │ └── filter_base.cpython-37.pyc │ ├── builder.py │ ├── filter_base.py │ └── filter_impl │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ └── track_pair_filter.cpython-37.pyc │ │ └── track_pair_filter.py ├── sampler │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── builder.cpython-37.pyc │ │ └── sampler_base.cpython-37.pyc │ ├── builder.py │ ├── sampler_base.py │ └── sampler_impl │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ └── track_pair_sampler.cpython-37.pyc │ │ └── track_pair_sampler.py ├── target │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── builder.cpython-37.pyc │ │ └── target_base.cpython-37.pyc │ ├── builder.py │ ├── target_base.py │ └── target_impl │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ └── densebox_target.cpython-37.pyc │ │ ├── densebox_target.py │ │ └── utils │ │ ├── README.md │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ └── make_densebox_target.cpython-37.pyc │ │ ├── debug_compare_densebox_target.py │ │ ├── debug_compare_tensor.py │ │ └── make_densebox_target.py ├── transformer │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── builder.cpython-37.pyc │ │ └── transformer_base.cpython-37.pyc │ ├── builder.py │ ├── transformer_base.py │ └── transformer_impl │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── common_transformer.cpython-37.pyc │ │ └── random_crop_transformer.cpython-37.pyc │ │ ├── common_transformer.py │ │ └── random_crop_transformer.py └── utils │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-37.pyc │ ├── filter_box.cpython-37.pyc │ └── target_image_crop.cpython-37.pyc │ ├── filter_box.py │ ├── misc.py │ ├── target_image_crop.py │ └── visualization.py ├── engine ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-37.pyc │ └── builder.cpython-37.pyc ├── builder.py ├── monitor │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── builder.cpython-37.pyc │ │ └── monitor_base.cpython-37.pyc │ ├── builder.py │ ├── monitor_base.py │ └── monitor_impl │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── monitor_template.cpython-37.pyc │ │ ├── tensorboard_logger.cpython-37.pyc │ │ └── text_info.cpython-37.pyc │ │ ├── monitor_template.py │ │ ├── tensorboard_logger.py │ │ ├── text_info.py │ │ └── utils.py ├── tester │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── builder.cpython-37.pyc │ │ └── tester_base.cpython-37.pyc │ ├── builder.py │ ├── tester_base.py │ └── tester_impl │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── davis.cpython-37.pyc │ │ ├── got10k.cpython-37.pyc │ │ ├── lasot.cpython-37.pyc │ │ ├── nfs.cpython-37.pyc │ │ ├── otb.cpython-37.pyc │ │ ├── trackingnet.cpython-37.pyc │ │ ├── uav123.cpython-37.pyc │ │ ├── vot.cpython-37.pyc │ │ └── votlt.cpython-37.pyc │ │ ├── davis.py │ │ ├── got10k.py │ │ ├── lasot.py │ │ ├── nfs.py │ │ ├── otb.py │ │ ├── trackingnet.py │ │ ├── uav123.py │ │ ├── utils │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-37.pyc │ │ │ └── got_benchmark_helper.cpython-37.pyc │ │ └── got_benchmark_helper.py │ │ ├── vot.py │ │ └── votlt.py └── trainer │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-37.pyc │ ├── builder.cpython-37.pyc │ └── trainer_base.cpython-37.pyc │ ├── builder.py │ ├── trainer_base.py │ └── trainer_impl │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-37.pyc │ ├── distributed_regular_trainer.cpython-37.pyc │ ├── distributed_sat_trainer.cpython-37.pyc │ └── regular_trainer.cpython-37.pyc │ ├── distributed_regular_trainer.py │ ├── distributed_sat_trainer.py │ └── regular_trainer.py ├── evaluation ├── __init__.py ├── __pycache__ │ └── __init__.cpython-37.pyc ├── davis_benchmark │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── benckmark_helpler.cpython-37.pyc │ │ └── evaluation_method.cpython-37.pyc │ ├── benckmark_helpler.py │ ├── davis2017 │ │ ├── __pycache__ │ │ │ ├── davis.cpython-37.pyc │ │ │ ├── davis_evaluation.cpython-37.pyc │ │ │ ├── metrics.cpython-37.pyc │ │ │ ├── results.cpython-37.pyc │ │ │ └── utils.cpython-37.pyc │ │ ├── davis.py │ │ ├── davis_evaluation.py │ │ ├── metrics.py │ │ ├── results.py │ │ └── utils.py │ └── evaluation_method.py ├── got_benchmark │ ├── __init__.py │ ├── __pycache__ │ │ └── __init__.cpython-37.pyc │ ├── datasets │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-37.pyc │ │ │ ├── dtb70.cpython-37.pyc │ │ │ ├── got10k.cpython-37.pyc │ │ │ ├── lasot.cpython-37.pyc │ │ │ ├── nfs.cpython-37.pyc │ │ │ ├── otb.cpython-37.pyc │ │ │ ├── tcolor128.cpython-37.pyc │ │ │ ├── trackingnet.cpython-37.pyc │ │ │ ├── uav123.cpython-37.pyc │ │ │ ├── vid.cpython-37.pyc │ │ │ └── vot.cpython-37.pyc │ │ ├── dtb70.py │ │ ├── got10k.py │ │ ├── got10k_original.py │ │ ├── lasot.py │ │ ├── nfs.py │ │ ├── otb.py │ │ ├── tcolor128.py │ │ ├── trackingnet.py │ │ ├── uav123.py │ │ ├── vid.py │ │ └── vot.py │ ├── experiments │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-37.pyc │ │ │ ├── dtb70.cpython-37.pyc │ │ │ ├── got10k.cpython-37.pyc │ │ │ ├── lasot.cpython-37.pyc │ │ │ ├── nfs.cpython-37.pyc │ │ │ ├── otb.cpython-37.pyc │ │ │ ├── tcolor128.cpython-37.pyc │ │ │ ├── trackingnet.cpython-37.pyc │ │ │ ├── uav123.cpython-37.pyc │ │ │ └── vot.cpython-37.pyc │ │ ├── dtb70.py │ │ ├── got10k.py │ │ ├── lasot.py │ │ ├── nfs.py │ │ ├── otb.py │ │ ├── tcolor128.py │ │ ├── trackingnet.py │ │ ├── uav123.py │ │ └── vot.py │ ├── trackers │ │ ├── __init__.py │ │ └── identity_tracker.py │ └── utils │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── ioutils.cpython-37.pyc │ │ ├── metrics.cpython-37.pyc │ │ └── viz.cpython-37.pyc │ │ ├── ioutils.py │ │ ├── metrics.py │ │ └── viz.py └── vot_benchmark │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-37.pyc │ ├── bbox_helper.cpython-37.pyc │ └── benchmark_helper.cpython-37.pyc │ ├── bbox_helper.py │ ├── benchmark_helper.py │ ├── make.sh │ ├── pysot │ ├── __init__.py │ ├── __pycache__ │ │ └── __init__.cpython-37.pyc │ ├── datasets │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-37.pyc │ │ │ ├── dataset.cpython-37.pyc │ │ │ ├── video.cpython-37.pyc │ │ │ └── vot.cpython-37.pyc │ │ ├── dataset.py │ │ ├── video.py │ │ └── vot.py │ ├── evaluation │ │ ├── __init__.py │ │ ├── ar_benchmark.py │ │ ├── eao_benchmark.py │ │ ├── f1_benchmark.py │ │ └── ope_benchmark.py │ └── utils │ │ ├── __init__.py │ │ ├── c_region.pxd │ │ ├── misc.py │ │ ├── region.pyx │ │ ├── setup.py │ │ ├── src │ │ ├── buffer.h │ │ └── region.h │ │ └── statistics.py │ └── vot_list │ ├── vot2018 │ └── list.txt │ └── vot2019 │ └── list.txt ├── model ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-37.pyc │ ├── builder.cpython-37.pyc │ └── module_base.cpython-37.pyc ├── backbone │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── backbone_base.cpython-37.pyc │ │ └── builder.cpython-37.pyc │ ├── backbone_base.py │ ├── backbone_impl │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-37.pyc │ │ │ ├── alexnet_bn.cpython-37.pyc │ │ │ ├── googlenet.cpython-37.pyc │ │ │ ├── googlenet_m.cpython-37.pyc │ │ │ ├── googlenet_q.cpython-37.pyc │ │ │ ├── resnet.cpython-37.pyc │ │ │ ├── shufflenet_v2.cpython-37.pyc │ │ │ └── tinyconv.cpython-37.pyc │ │ ├── alexnet_bn.py │ │ ├── googlenet.py │ │ ├── googlenet_m.py │ │ ├── googlenet_q.py │ │ ├── resnet.py │ │ ├── shufflenet_v2.py │ │ └── tinyconv.py │ └── builder.py ├── builder.py ├── common_opr │ ├── __pycache__ │ │ ├── common_block.cpython-37.pyc │ │ └── common_loss.cpython-37.pyc │ ├── common_block.py │ └── common_loss.py ├── loss │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── builder.cpython-37.pyc │ │ └── loss_base.cpython-37.pyc │ ├── builder.py │ ├── loss_base.py │ └── loss_impl │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── focal_loss.cpython-37.pyc │ │ ├── iou_loss.cpython-37.pyc │ │ ├── multi_bceloss.cpython-37.pyc │ │ ├── sigmoid_ce_centerness.cpython-37.pyc │ │ ├── sigmoid_ce_retina.cpython-37.pyc │ │ └── utils.cpython-37.pyc │ │ ├── focal_loss.py │ │ ├── iou_loss.py │ │ ├── multi_bceloss.py │ │ ├── sigmoid_ce_centerness.py │ │ ├── sigmoid_ce_retina.py │ │ └── utils.py ├── module_base.py ├── neck │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── builder.cpython-37.pyc │ │ └── neck_base.cpython-37.pyc │ ├── builder.py │ ├── neck_base.py │ └── neck_impl │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ └── adjust_layer.cpython-37.pyc │ │ └── adjust_layer.py ├── sync_batchnorm │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── batchnorm.cpython-37.pyc │ │ ├── comm.cpython-37.pyc │ │ └── replicate.cpython-37.pyc │ ├── batchnorm.py │ ├── batchnorm_reimpl.py │ ├── comm.py │ ├── replicate.py │ └── unittest.py ├── task_head │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── builder.cpython-37.pyc │ │ └── taskhead_base.cpython-37.pyc │ ├── builder.py │ ├── taskhead_base.py │ └── taskhead_impl │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ └── stm_head.cpython-37.pyc │ │ └── stm_head.py ├── task_model │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── builder.cpython-37.pyc │ │ └── taskmodel_base.cpython-37.pyc │ ├── builder.py │ ├── taskmodel_base.py │ └── taskmodel_impl │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ └── stmtrack_model.cpython-37.pyc │ │ └── stmtrack_model.py └── utils │ ├── TransformerModel.py │ ├── __pycache__ │ ├── TransformerModel.cpython-37.pyc │ ├── load_state.cpython-37.pyc │ └── transformer_utils.cpython-37.pyc │ ├── load_state.py │ └── transformer_utils.py ├── optim ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-37.pyc │ └── builder.cpython-37.pyc ├── builder.py ├── grad_modifier │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── builder.cpython-37.pyc │ │ └── grad_modifier_base.cpython-37.pyc │ ├── builder.py │ ├── grad_modifier_base.py │ └── grad_modifier_impl │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ └── dynamic_freezer.cpython-37.pyc │ │ ├── dynamic_freezer.py │ │ └── utils │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ └── freeze.cpython-37.pyc │ │ └── freeze.py └── optimizer │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-37.pyc │ ├── builder.cpython-37.pyc │ └── optimizer_base.cpython-37.pyc │ ├── builder.py │ ├── optimizer_base.py │ └── optimizer_impl │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-37.pyc │ ├── adam.cpython-37.pyc │ └── sgd.cpython-37.pyc │ ├── adam.py │ ├── sgd.py │ └── utils │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-37.pyc │ ├── lr_multiply.cpython-37.pyc │ └── lr_policy.cpython-37.pyc │ ├── lr_multiply.py │ └── lr_policy.py ├── pipeline ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-37.pyc │ ├── builder.cpython-37.pyc │ └── pipeline_base.cpython-37.pyc ├── builder.py ├── pipeline_base.py ├── tracker_impl │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ └── stmtrack_tracker.cpython-37.pyc │ └── stmtrack_tracker.py └── utils │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-37.pyc │ ├── bbox.cpython-37.pyc │ ├── crop.cpython-37.pyc │ └── misc.cpython-37.pyc │ ├── bbox.py │ ├── crop.py │ ├── misc.py │ └── online_classifier │ ├── __init__.py │ ├── base_classifier.py │ ├── optim.py │ └── utils │ ├── __init__.py │ ├── attention.py │ ├── augmentation.py │ ├── complex.py │ ├── dcf.py │ ├── fourier.py │ ├── operation.py │ ├── optimization.py │ ├── plotting.py │ ├── preprocessing.py │ ├── tensordict.py │ └── tensorlist.py └── utils ├── __init__.py ├── __pycache__ ├── __init__.cpython-37.pyc ├── dist_utils.cpython-37.pyc ├── image.cpython-37.pyc ├── misc.cpython-37.pyc ├── path.cpython-37.pyc ├── torch_module.cpython-37.pyc ├── visualization.cpython-37.pyc └── visualize_score_map.cpython-37.pyc ├── dist_utils.py ├── hpo.py ├── image.py ├── misc.py ├── path.py ├── torch_module.py ├── visualization.py └── visualize_score_map.py /HOT2022-MMFNet-Results.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/HOT2022-MMFNet-Results.zip -------------------------------------------------------------------------------- /HOTC-MMFNet-Results.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/HOTC-MMFNet-Results.zip -------------------------------------------------------------------------------- /IMEC25-MMFNet-Results.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/IMEC25-MMFNet-Results.zip -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2021, Zhihong Fu 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /MMF_Net_HOT2023_results.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/MMF_Net_HOT2023_results.zip -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Quick Start 2 | 3 | ## The soure code of the paper "Material-Guided Multiview Fusion Network for Hyperspectral Object Tracking". 4 | 5 | ## 1. Environment Setting 6 | The environment configuration follows https://github.com/fzh0917/STMTrack. 7 | 8 | Prepare Anaconda, CUDA and the corresponding toolkits. CUDA version required: 10.0+; 9 | 10 | Create a new conda environment and activate it. 11 | ```python 12 | conda create -n MMFNet python=3.7 -y 13 | conda activate MMFNet 14 | ``` 15 | Install pytorch and torchvision. 16 | ```python 17 | conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=10.0 -c pytorch 18 | # pytorch v1.5.0, v1.6.0, or higher should also be OK. 19 | ``` 20 | Install other required packages. 21 | ```python 22 | pip install -r requirements.txt 23 | ``` 24 | ## 2. Dataset 25 | + The hyperspectral videos datasets are from "https://www.hsitracking.com/". 26 | + The Material View is generated by the code from the paper "Material Based Object Tracking in Hyperspectral Videos". 27 | 28 | ## 3. Train 29 | (a) Download pretrained model in 30 | 31 | - https://pan.baidu.com/s/1vBmGFoQ4MRTUeLE3o7pteg 32 | - Access code: 1234 33 | 34 | (b) Change the path of training data in videoanalyst/evaluation/. 35 | 36 | (c) Run: train.sh 37 | 38 | ## 4. Test 39 | (a) Download testing model in 40 | 41 | - https://pan.baidu.com/s/15YdmJRvagPzKcUNWBloiHA 42 | - Access code: 1234 43 | 44 | (b) Put the testing model in snapshots/stmtrack-googlenet-got-train; 45 | 46 | (c) Run: test.sh 47 | 48 | ## 5. Cite 49 | ``` 50 | @ARTICLE{10438474, 51 | author={Li, Zhuanfeng and Xiong, Fengchao and Zhou, Jun and Lu, Jianfeng and Zhao, Zhuang and Qian, Yuntao}, 52 | journal={IEEE Transactions on Geoscience and Remote Sensing}, 53 | title={Material-Guided Multiview Fusion Network for Hyperspectral Object Tracking}, 54 | year={2024}, 55 | volume={62}, 56 | number={}, 57 | pages={1-15}, 58 | keywords={Feature extraction;Hyperspectral imaging;Target tracking;Videos;Object tracking;Visualization;Spatial resolution;Hyperspectral object tracking;hyperspectral unmixing;multihead attention;multiview fusion}, 59 | doi={10.1109/TGRS.2024.3366536}} 60 | ``` 61 | 62 | ## 6. Concat 63 | * lizhuanfeng@njust.edu.cn; 64 | * If you have any questions, just contact me. 65 | -------------------------------------------------------------------------------- /check_format.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DIFF=`yapf -p -r -d --style='{COLUMN_LIMIT:80}' -e "videoanalyst/evaluation/*" -e "debug/*" ./` 4 | if [ ! -z "$DIFF" ] 5 | then 6 | echo "yapf format check failed" 7 | printf -- "$DIFF" 8 | false 9 | else 10 | echo "yapf format check succeeded" 11 | fi 12 | -------------------------------------------------------------------------------- /compile.sh: -------------------------------------------------------------------------------- 1 | # complie evaluation toolkit 2 | pushd videoanalyst/evaluation/vot_benchmark 3 | bash make.sh 4 | popd -------------------------------------------------------------------------------- /datasets/OTB/OTB2015/Bird2.zipm2xpryrc.tmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/datasets/OTB/OTB2015/Bird2.zipm2xpryrc.tmp -------------------------------------------------------------------------------- /demo/readme.txt: -------------------------------------------------------------------------------- 1 | The traking results are saved in this directory. 2 | -------------------------------------------------------------------------------- /experiments/stmtrack/test/UAV123/stmtrack-googlenet-uav123.yaml: -------------------------------------------------------------------------------- 1 | test: 2 | track: 3 | exp_name: &TEST_NAME "uav123" 4 | exp_save: &TEST_SAVE "logs/stmtrack-googlenet-fulldata-test" 5 | model: 6 | backbone_m: 7 | name: "Inception3_M" 8 | Inception3_M: 9 | crop_pad: 4 10 | pruned: True 11 | backbone_q: 12 | name: "Inception3_Q" 13 | Inception3_Q: 14 | crop_pad: 4 15 | pruned: True 16 | neck: 17 | name: "AdjustLayer" 18 | AdjustLayer: 19 | in_channels: 768 20 | out_channels: &OUT_CHANNELS 512 21 | losses: 22 | names: [] 23 | task_head: 24 | name: "STMHead" 25 | STMHead: 26 | total_stride: &TEST_TOTAL_STRIDE 8 27 | score_size: &TEST_SCORE_SIZE 25 28 | q_size: &TEST_Q_SIZE 289 29 | in_channels: *OUT_CHANNELS 30 | task_model: 31 | name: "STMTrack" 32 | STMTrack: 33 | pretrain_model_path: "snapshots/stmtrack-googlenet-fulldata-train/epoch-19.pkl" 34 | pipeline: 35 | name: "STMTrackTracker" 36 | STMTrackTracker: 37 | test_lr: 0.5405424265010361 38 | window_influence: 0.20298940424940976 39 | penalty_k: 0.07067416478817143 40 | total_stride: *TEST_TOTAL_STRIDE 41 | score_size: *TEST_SCORE_SIZE 42 | q_size: *TEST_Q_SIZE 43 | m_size: *TEST_Q_SIZE 44 | gpu_memory_threshold: 1000 45 | search_area_factor: 4.171677449782462 46 | tester: 47 | names: [ "UAVTester", ] 48 | UAVTester: 49 | exp_name: *TEST_NAME 50 | exp_save: *TEST_SAVE 51 | subsets: [ "UAV123" ] 52 | device_num: 10 53 | -------------------------------------------------------------------------------- /experiments/stmtrack/test/got10k/stmtrack-googlenet-got.yaml: -------------------------------------------------------------------------------- 1 | test: 2 | track: 3 | exp_name: &TEST_NAME "got10k" 4 | exp_save: &TEST_SAVE "logs/stmtrack-googlenet-got-test" 5 | model: 6 | backbone_m: 7 | name: "Inception3_M" 8 | Inception3_M: 9 | crop_pad: 4 10 | pruned: True 11 | backbone_q: 12 | name: "Inception3_Q" 13 | Inception3_Q: 14 | crop_pad: 4 15 | pruned: True 16 | neck: 17 | name: "AdjustLayer" 18 | AdjustLayer: 19 | in_channels: 768 20 | out_channels: &OUT_CHANNELS 512 21 | losses: 22 | names: [] 23 | task_head: 24 | name: "STMHead" 25 | STMHead: 26 | total_stride: &TEST_TOTAL_STRIDE 8 27 | score_size: &TEST_SCORE_SIZE 25 28 | q_size: &TEST_Q_SIZE 289 29 | in_channels: *OUT_CHANNELS 30 | task_model: 31 | name: "STMTrack" 32 | STMTrack: 33 | pretrain_model_path: "snapshots/stmtrack-googlenet-got-train/epoch-19.pkl" 34 | pipeline: 35 | name: "STMTrackTracker" 36 | STMTrackTracker: 37 | test_lr: 0.95 38 | window_influence: 0.21 39 | penalty_k: 0.04 40 | total_stride: *TEST_TOTAL_STRIDE 41 | score_size: *TEST_SCORE_SIZE 42 | q_size: *TEST_Q_SIZE 43 | m_size: *TEST_Q_SIZE 44 | gpu_memory_threshold: 1000 45 | search_area_factor: 4.0 46 | tester: 47 | names: ["GOT10kTester",] 48 | GOT10kTester: 49 | exp_name: *TEST_NAME 50 | exp_save: *TEST_SAVE 51 | data_root: "datasets/GOT-10k" 52 | subsets: ["test"] 53 | device_num: 4 54 | # verbose: true -------------------------------------------------------------------------------- /experiments/stmtrack/test/lasot/stmtrack-googlenet-lasot.yaml: -------------------------------------------------------------------------------- 1 | test: 2 | track: 3 | exp_name: &TEST_NAME "lasot" 4 | exp_save: &TEST_SAVE "logs/stmtrack-googlenet-got-test" 5 | model: 6 | backbone_m: 7 | name: "Inception3_M" 8 | Inception3_M: 9 | crop_pad: 4 10 | pruned: True 11 | backbone_q: 12 | name: "Inception3_Q" 13 | Inception3_Q: 14 | crop_pad: 4 15 | pruned: True 16 | neck: 17 | name: "AdjustLayer" 18 | AdjustLayer: 19 | in_channels: 768 20 | out_channels: &OUT_CHANNELS 512 21 | losses: 22 | names: [] 23 | task_head: 24 | name: "STMHead" 25 | STMHead: 26 | total_stride: &TEST_TOTAL_STRIDE 8 27 | score_size: &TEST_SCORE_SIZE 25 28 | q_size: &TEST_Q_SIZE 289 29 | in_channels: *OUT_CHANNELS 30 | task_model: 31 | name: "STMTrack" 32 | STMTrack: 33 | pretrain_model_path: "snapshots/stmtrack-googlenet-got-train/epoch-19.pkl" 34 | pipeline: 35 | name: "STMTrackTracker" 36 | STMTrackTracker: 37 | test_lr: 0.95 38 | window_influence: 0.21 39 | penalty_k: 0.04 40 | total_stride: *TEST_TOTAL_STRIDE 41 | score_size: *TEST_SCORE_SIZE 42 | q_size: *TEST_Q_SIZE 43 | m_size: *TEST_Q_SIZE 44 | gpu_memory_threshold: 1000 45 | search_area_factor: 4.0 46 | tester: 47 | names: ["LaSOTTester",] 48 | LaSOTTester: 49 | exp_name: *TEST_NAME 50 | exp_save: *TEST_SAVE 51 | data_root: "datasets/LaSOT" 52 | subsets: ["test"] 53 | device_num: 2 54 | -------------------------------------------------------------------------------- /experiments/stmtrack/test/otb/stmtrack-googlenet-otb.yaml: -------------------------------------------------------------------------------- 1 | test: 2 | track: 3 | exp_name: &TEST_NAME "otb2015" 4 | exp_save: &TEST_SAVE "logs/stmtrack-googlenet-fulldata-test" 5 | model: 6 | backbone_m: 7 | name: "Inception3_M" 8 | Inception3_M: 9 | crop_pad: 4 10 | pruned: True 11 | backbone_q: 12 | name: "Inception3_Q" 13 | Inception3_Q: 14 | crop_pad: 4 15 | pruned: True 16 | neck: 17 | name: "AdjustLayer" 18 | AdjustLayer: 19 | in_channels: 768 20 | out_channels: &OUT_CHANNELS 512 21 | losses: 22 | names: [] 23 | task_head: 24 | name: "STMHead" 25 | STMHead: 26 | total_stride: &TEST_TOTAL_STRIDE 8 27 | score_size: &TEST_SCORE_SIZE 25 28 | q_size: &TEST_Q_SIZE 289 29 | in_channels: *OUT_CHANNELS 30 | task_model: 31 | name: "STMTrack" 32 | STMTrack: 33 | pretrain_model_path: "snapshots/stmtrack-googlenet-fulldata-train/epoch-19.pkl" 34 | pipeline: 35 | name: "STMTrackTracker" 36 | STMTrackTracker: 37 | test_lr: 0.545 # 0.5501132208837838 38 | window_influence: 0.209 # 0.20534968836733386 39 | penalty_k: 0.545 # 0.07592315864890313 40 | total_stride: *TEST_TOTAL_STRIDE 41 | score_size: *TEST_SCORE_SIZE 42 | q_size: *TEST_Q_SIZE 43 | m_size: *TEST_Q_SIZE 44 | gpu_memory_threshold: 1000 45 | search_area_factor: 4.0 46 | tester: 47 | names: ["OTBTester",] 48 | OTBTester: 49 | exp_name: *TEST_NAME 50 | exp_save: *TEST_SAVE 51 | subsets: [ "otb2015" ] 52 | device_num: 10 53 | -------------------------------------------------------------------------------- /experiments/stmtrack/test/trackingnet/stmtrack-googlenet-trackingnet.yaml: -------------------------------------------------------------------------------- 1 | test: 2 | track: 3 | exp_name: &TEST_NAME "trackingnet" 4 | exp_save: &TEST_SAVE "logs/stmtrack-googlenet-fulldata-test" 5 | model: 6 | backbone_m: 7 | name: "Inception3_M" 8 | Inception3_M: 9 | crop_pad: 4 10 | pruned: True 11 | backbone_q: 12 | name: "Inception3_Q" 13 | Inception3_Q: 14 | crop_pad: 4 15 | pruned: True 16 | neck: 17 | name: "AdjustLayer" 18 | AdjustLayer: 19 | in_channels: 768 20 | out_channels: &OUT_CHANNELS 512 21 | losses: 22 | names: [] 23 | task_head: 24 | name: "STMHead" 25 | STMHead: 26 | total_stride: &TEST_TOTAL_STRIDE 8 27 | score_size: &TEST_SCORE_SIZE 25 28 | q_size: &TEST_Q_SIZE 289 29 | in_channels: *OUT_CHANNELS 30 | task_model: 31 | name: "STMTrack" 32 | STMTrack: 33 | pretrain_model_path: "snapshots/stmtrack-googlenet-fulldata-train/epoch-19.pkl" 34 | pipeline: 35 | name: "STMTrackTracker" 36 | STMTrackTracker: 37 | test_lr: 0.95 38 | window_influence: 0.21 39 | penalty_k: 0.04 40 | total_stride: *TEST_TOTAL_STRIDE 41 | score_size: *TEST_SCORE_SIZE 42 | q_size: *TEST_Q_SIZE 43 | m_size: *TEST_Q_SIZE 44 | gpu_memory_threshold: 1000 45 | search_area_factor: 4.0 46 | tester: 47 | names: ["TrackingNetTester",] 48 | TrackingNetTester: 49 | exp_name: *TEST_NAME 50 | exp_save: *TEST_SAVE 51 | data_root: "datasets/storage_TrackingNet" 52 | subsets: ["test"] 53 | device_num: 10 54 | -------------------------------------------------------------------------------- /experiments/stmtrack/test/vot/stmtrack-googlenet-vot.yaml: -------------------------------------------------------------------------------- 1 | test: 2 | track: 3 | exp_name: &TEST_NAME "vot2018" 4 | exp_save: &TEST_SAVE "logs/stmtrack-googlenet-fulldata-test" 5 | model: 6 | backbone_m: 7 | name: "Inception3_M" 8 | Inception3_M: 9 | crop_pad: 4 10 | pruned: True 11 | backbone_q: 12 | name: "Inception3_Q" 13 | Inception3_Q: 14 | crop_pad: 4 15 | pruned: True 16 | neck: 17 | name: "AdjustLayer" 18 | AdjustLayer: 19 | in_channels: 768 20 | out_channels: &OUT_CHANNELS 512 21 | losses: 22 | names: [] 23 | task_head: 24 | name: "STMHead" 25 | STMHead: 26 | total_stride: &TEST_TOTAL_STRIDE 8 27 | score_size: &TEST_SCORE_SIZE 25 28 | q_size: &TEST_Q_SIZE 289 29 | in_channels: *OUT_CHANNELS 30 | task_model: 31 | name: "STMTrack" 32 | STMTrack: 33 | pretrain_model_path: "snapshots/stmtrack-googlenet-fulldata-train/epoch-19.pkl" 34 | pipeline: 35 | name: "STMTrackTracker" 36 | STMTrackTracker: 37 | test_lr: 0.9629084797864664 38 | window_influence: 0.2674225347735762 39 | penalty_k: 0.04120782242066555 40 | total_stride: *TEST_TOTAL_STRIDE 41 | score_size: *TEST_SCORE_SIZE 42 | q_size: *TEST_Q_SIZE 43 | m_size: *TEST_Q_SIZE 44 | gpu_memory_threshold: -1 45 | search_area_factor: 4.056291055280747 46 | confidence_threshold: 0.0 47 | tester: 48 | names: ["VOTTester",] 49 | VOTTester: 50 | exp_name: *TEST_NAME 51 | exp_save: *TEST_SAVE 52 | dataset_names: ["VOT2018"] 53 | device_num: 10 54 | -------------------------------------------------------------------------------- /main/__pycache__/paths.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/main/__pycache__/paths.cpython-37.pyc -------------------------------------------------------------------------------- /main/paths.py: -------------------------------------------------------------------------------- 1 | r""" 2 | Get root path & root config path & 3 | """ 4 | import os.path as osp 5 | 6 | import sys # isort:skip 7 | 8 | module_name = "main" 9 | p = __file__ 10 | while osp.basename(p) != module_name: 11 | p = osp.dirname(p) 12 | 13 | # video_analyst root 14 | ROOT_PATH = osp.dirname(p) 15 | ROOT_CFG = osp.join(ROOT_PATH, 'config.yaml') 16 | sys.path.insert(0, ROOT_PATH) # isort:skip 17 | -------------------------------------------------------------------------------- /readme: -------------------------------------------------------------------------------- 1 | decoder_epoch-15.pkl come from ../../../../transformer-no-SA/0516/train_v9/v1 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | autoflake 2 | colorama==0.3.7 3 | Cython==0.27.3 4 | future 5 | ipython 6 | isort 7 | loguru==0.4.1 8 | matplotlib 9 | numba==0.45.0 10 | numpy==1.16.0 11 | opencv-python 12 | pandas 13 | pillow 14 | pycocotools 15 | pylint 16 | scikit-image 17 | scipy==1.2.1 18 | shapely==1.7.0 19 | tensorboard 20 | tqdm 21 | wget 22 | yacs 23 | yapf==0.28.0 24 | pre-commit 25 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export MPLBACKEND=TKAgg 3 | export PYTHONPATH=$(pwd) # 4 | -------------------------------------------------------------------------------- /snapshots/stmtrack-googlenet-got-train/readme.txt: -------------------------------------------------------------------------------- 1 | Put the testing model in here. 2 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | CUDA_VISIBLE_DEVICES=1 nohup python -u main/test.py --config experiments/stmtrack/test/otb/stmtrack-googlenet-otb.yaml --root_dir /data/lizf/HOT/dataset/test/test_HSI/ --snapshot snapshots/stmtrack-googlenet-got-train/final_model.pkl > nohup.test.log 2>&1 & 2 | -------------------------------------------------------------------------------- /train.sh: -------------------------------------------------------------------------------- 1 | CUDA_VISIBLE_DEVICES=1 nohup python -u main/train.py --config experiments/stmtrack/train/got10k/stmtrack-googlenet-trn.yaml --gpu_num 1 > nohup.train.log 2>&1 & 2 | -------------------------------------------------------------------------------- /videoanalyst/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | -------------------------------------------------------------------------------- /videoanalyst/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/config/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /videoanalyst/config/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/config/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/config/__pycache__/config.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/config/__pycache__/config.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/config/utils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import os 3 | 4 | from yacs.config import CfgNode 5 | 6 | from videoanalyst.utils import ensure_dir 7 | 8 | 9 | def setup(cfg: CfgNode): 10 | """Setup for working directory 11 | 12 | Parameters 13 | ---------- 14 | cfg : CfgNode 15 | task specific config 16 | """ 17 | ensure_dir(cfg["exp_save"]) 18 | cfg.auto = CfgNode() 19 | 20 | cfg.auto.exp_dir = os.path.join(cfg.exp_save, cfg.exp_name) 21 | ensure_dir(cfg.auto.exp_dir) 22 | 23 | cfg.auto.log_dir = os.path.join(cfg.auto.exp_dir, "logs") 24 | ensure_dir(cfg.auto.log_dir) 25 | 26 | cfg.auto.log_dir = os.path.join(cfg.auto.exp_dir, "snapshots") 27 | ensure_dir(cfg.auto.log_dir) 28 | 29 | cfg.auto.model_dir = os.path.join(cfg.auto.exp_dir, "datasets") 30 | ensure_dir(cfg.auto.model_dir) 31 | 32 | cfg.auto.model_dir = os.path.join(cfg.auto.exp_dir, "models") 33 | ensure_dir(cfg.auto.model_dir) 34 | -------------------------------------------------------------------------------- /videoanalyst/data/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | -------------------------------------------------------------------------------- /videoanalyst/data/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/__pycache__/adaptor_dataset.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/__pycache__/adaptor_dataset.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/adaptor_dataset.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | 3 | from loguru import logger 4 | 5 | import torch 6 | import torch.multiprocessing 7 | from torch.utils.data import Dataset 8 | 9 | from .datapipeline import builder as datapipeline_builder 10 | 11 | # pytorch wrapper for multiprocessing 12 | # https://pytorch.org/docs/stable/multiprocessing.html#strategy-management 13 | _SHARING_STRATETY = "file_system" 14 | if _SHARING_STRATETY in torch.multiprocessing.get_all_sharing_strategies(): 15 | torch.multiprocessing.set_sharing_strategy(_SHARING_STRATETY) 16 | 17 | 18 | class AdaptorDataset(Dataset): 19 | _EXT_SEED_STEP = 30011 # better to be a prime number 20 | _SEED_STEP = 10007 # better to be a prime number 21 | _SEED_DIVIDER = 1000003 # better to be a prime number 22 | 23 | def __init__( 24 | self, 25 | task, 26 | cfg, 27 | num_epochs=1, 28 | nr_image_per_epoch=1, 29 | seed: int = 0, 30 | ): 31 | self.datapipeline = None 32 | self.task = task 33 | self.cfg = cfg 34 | self.num_epochs = num_epochs 35 | self.nr_image_per_epoch = nr_image_per_epoch 36 | self.ext_seed = seed 37 | 38 | def __getitem__(self, item): 39 | if self.datapipeline is None: 40 | # build datapipeline with random seed the first time when __getitem__ is called 41 | # usually, dataset is already spawned (into subprocess) at this point. 42 | seed = (torch.initial_seed() + item * self._SEED_STEP + 43 | self.ext_seed * self._EXT_SEED_STEP) % self._SEED_DIVIDER 44 | self.datapipeline = datapipeline_builder.build(self.task, 45 | self.cfg, 46 | seed=seed) 47 | logger.info("AdaptorDataset #%d built datapipeline with seed=%d" % 48 | (item, seed)) 49 | 50 | training_data = self.datapipeline[item] 51 | 52 | return training_data 53 | 54 | def __len__(self): 55 | return self.nr_image_per_epoch * self.num_epochs 56 | -------------------------------------------------------------------------------- /videoanalyst/data/datapipeline/__init__.py: -------------------------------------------------------------------------------- 1 | from .datapipeline_impl import * # noqa 2 | -------------------------------------------------------------------------------- /videoanalyst/data/datapipeline/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/datapipeline/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/datapipeline/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/datapipeline/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/datapipeline/__pycache__/datapipeline_base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/datapipeline/__pycache__/datapipeline_base.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/datapipeline/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from typing import Dict, List 3 | 4 | from yacs.config import CfgNode 5 | 6 | from videoanalyst.utils import merge_cfg_into_hps 7 | 8 | from ..dataset.builder import get_config as get_dataset_cfg 9 | from ..filter.builder import get_config as get_filter_cfg 10 | from ..sampler.builder import build as build_sampler 11 | from ..target.builder import build as build_target 12 | from ..transformer.builder import build as build_transformer 13 | from .datapipeline_base import TASK_DATAPIPELINES, DatapipelineBase 14 | 15 | 16 | def build(task: str, cfg: CfgNode, seed: int = 0) -> DatapipelineBase: 17 | r""" 18 | Arguments 19 | --------- 20 | task: str 21 | task name (track|vos) 22 | cfg: CfgNode 23 | node name: data 24 | seed: int 25 | seed for rng initialization 26 | """ 27 | assert task in TASK_DATAPIPELINES, "invalid task name" 28 | MODULES = TASK_DATAPIPELINES[task] 29 | 30 | sampler = build_sampler(task, cfg.sampler, seed=seed) 31 | transformers = build_transformer(task, cfg.transformer, seed=seed) 32 | target = build_target(task, cfg.target) 33 | 34 | pipeline = [] 35 | pipeline.extend(transformers) 36 | pipeline.append(target) 37 | 38 | cfg = cfg.datapipeline 39 | name = cfg.name 40 | module = MODULES[name](sampler, pipeline) 41 | 42 | hps = module.get_hps() 43 | hps = merge_cfg_into_hps(cfg[name], hps) 44 | module.set_hps(hps) 45 | module.update_params() 46 | 47 | return module 48 | 49 | 50 | def get_config(task_list: List) -> Dict[str, CfgNode]: 51 | cfg_dict = {name: CfgNode() for name in task_list} 52 | 53 | for cfg_name, modules in TASK_DATAPIPELINES.items(): 54 | cfg = cfg_dict[cfg_name] 55 | cfg["name"] = "" 56 | 57 | for name in modules: 58 | cfg[name] = CfgNode() 59 | module = modules[name] 60 | hps = module.default_hyper_params 61 | for hp_name in hps: 62 | cfg[name][hp_name] = hps[hp_name] 63 | 64 | cfg["submodules"] = CfgNode() 65 | cfg["submodules"] = get_filter_cfg(task_list)[cfg_name] 66 | cfg["submodules"] = get_dataset_cfg(task_list)[cfg_name] 67 | 68 | return cfg_dict 69 | -------------------------------------------------------------------------------- /videoanalyst/data/datapipeline/datapipeline_base.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from abc import ABCMeta 3 | from typing import Dict 4 | 5 | from videoanalyst.utils import Registry 6 | 7 | TRACK_DATAPIPELINES = Registry('TRACK_DATAPIPELINES') 8 | VOS_DATAPIPELINES = Registry('VOS_DATAPIPELINES') 9 | 10 | TASK_DATAPIPELINES = dict( 11 | track=TRACK_DATAPIPELINES, 12 | vos=VOS_DATAPIPELINES, 13 | ) 14 | 15 | 16 | class DatapipelineBase: 17 | __metaclass__ = ABCMeta 18 | r""" 19 | base class for Sampler. Reponsible for sampling from multiple datasets and forming training pair / sequence. 20 | 21 | Define your hyper-parameters here in your sub-class. 22 | """ 23 | default_hyper_params = dict() 24 | 25 | def __init__(self) -> None: 26 | r""" 27 | Data pipeline 28 | """ 29 | self._hyper_params = self.default_hyper_params 30 | self._state = dict() 31 | 32 | def get_hps(self) -> dict: 33 | r""" 34 | Getter function for hyper-parameters 35 | 36 | Returns 37 | ------- 38 | dict 39 | hyper-parameters 40 | """ 41 | return self._hyper_params 42 | 43 | def set_hps(self, hps: dict) -> None: 44 | r""" 45 | Set hyper-parameters 46 | 47 | Arguments 48 | --------- 49 | hps: dict 50 | dict of hyper-parameters, the keys must in self.__hyper_params__ 51 | """ 52 | for key in hps: 53 | if key not in self._hyper_params: 54 | raise KeyError 55 | self._hyper_params[key] = hps[key] 56 | 57 | def update_params(self) -> None: 58 | r""" 59 | an interface for update params 60 | """ 61 | def __getitem__(self, item) -> Dict: 62 | r""" 63 | An interface to load batch data 64 | """ 65 | -------------------------------------------------------------------------------- /videoanalyst/data/datapipeline/datapipeline_impl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import glob 3 | from os.path import basename, dirname, isfile 4 | 5 | modules = glob.glob(dirname(__file__) + "/*.py") 6 | modules = [m for m in modules if not m.endswith(('_bak.py')) 7 | ] # filter file with name ending with '_bak' (debugging) 8 | __all__ = [ 9 | basename(f)[:-3] for f in modules if isfile(f) 10 | and not f.endswith("__init__.py") and not f.endswith("utils.py") 11 | ] 12 | -------------------------------------------------------------------------------- /videoanalyst/data/datapipeline/datapipeline_impl/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/datapipeline/datapipeline_impl/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/datapipeline/datapipeline_impl/__pycache__/regular_datapipeline.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/datapipeline/datapipeline_impl/__pycache__/regular_datapipeline.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/dataset/__init__.py: -------------------------------------------------------------------------------- 1 | from .dataset_impl import * # noqa 2 | -------------------------------------------------------------------------------- /videoanalyst/data/dataset/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/dataset/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/dataset/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/dataset/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/dataset/__pycache__/dataset_base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/dataset/__pycache__/dataset_base.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/dataset/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from typing import Dict, List 4 | 5 | from yacs.config import CfgNode 6 | 7 | from videoanalyst.utils import merge_cfg_into_hps 8 | 9 | from .dataset_base import TASK_DATASETS, DatasetBase 10 | 11 | 12 | def build(task: str, cfg: CfgNode) -> DatasetBase: 13 | r""" 14 | Arguments 15 | --------- 16 | task: str 17 | task name (track|vos) 18 | cfg: CfgNode 19 | node name: dataset 20 | """ 21 | assert task in TASK_DATASETS, "invalid task name" 22 | dataset_modules = TASK_DATASETS[task] 23 | 24 | names = cfg.names 25 | modules = [] 26 | for name in names: 27 | module = dataset_modules[name]() 28 | hps = module.get_hps() 29 | hps = merge_cfg_into_hps(cfg[name], hps) 30 | module.set_hps(hps) 31 | module.update_params() 32 | modules.append(module) 33 | 34 | return modules 35 | 36 | 37 | def get_config(task_list: List) -> Dict[str, CfgNode]: 38 | cfg_dict = {name: CfgNode() for name in task_list} 39 | 40 | for cfg_name, modules in TASK_DATASETS.items(): 41 | cfg = cfg_dict[cfg_name] 42 | cfg["names"] = [] 43 | 44 | for name in modules: 45 | cfg[name] = CfgNode() 46 | module = modules[name] 47 | hps = module.default_hyper_params 48 | for hp_name in hps: 49 | cfg[name][hp_name] = hps[hp_name] 50 | 51 | return cfg_dict 52 | -------------------------------------------------------------------------------- /videoanalyst/data/dataset/dataset_base.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from abc import ABCMeta 3 | from typing import Dict 4 | 5 | from videoanalyst.utils import Registry 6 | 7 | TRACK_DATASETS = Registry('TRACK_DATASETS') 8 | VOS_DATASETS = Registry('VOS_DATASETS') 9 | 10 | TASK_DATASETS = dict( 11 | track=TRACK_DATASETS, 12 | vos=VOS_DATASETS, 13 | ) 14 | 15 | 16 | class DatasetBase: 17 | __metaclass__ = ABCMeta 18 | r""" 19 | base class for DataSet. 20 | Nota. for tracking dataset, we use format (x0, y0, x1, y1) 21 | 22 | Define your hyper-parameters here in your sub-class. 23 | """ 24 | default_hyper_params = dict() 25 | 26 | def __init__(self) -> None: 27 | self._hyper_params = self.default_hyper_params 28 | self._state = dict() 29 | 30 | def get_hps(self) -> Dict: 31 | r""" 32 | Getter function for hyper-parameters 33 | 34 | Returns 35 | ------- 36 | Dict 37 | hyper-parameters 38 | """ 39 | return self._hyper_params 40 | 41 | def set_hps(self, hps: Dict) -> None: 42 | r""" 43 | Set hyper-parameters 44 | 45 | Arguments 46 | --------- 47 | hps: Dict 48 | dict of hyper-parameters, the keys must in self.__hyper_params__ 49 | """ 50 | for key in hps: 51 | if key not in self._hyper_params: 52 | raise KeyError 53 | self._hyper_params[key] = hps[key] 54 | 55 | def update_params(self): 56 | r""" 57 | an interface for update params 58 | """ 59 | def __getitem__(self, item: int) -> Dict: 60 | r""" 61 | An interface to get data item (Index-based Dataset). 62 | """ 63 | def __next__(self) -> Dict: 64 | r""" 65 | An interface to get data item (Sampler-based Dataset). 66 | """ 67 | def __len__(self): 68 | r""" 69 | Length of dataset 70 | 71 | Returns 72 | ------- 73 | int 74 | length of dataset 75 | positive integer if Index-based Dataset 76 | -1 if Sampler-based Dataset 77 | """ 78 | -------------------------------------------------------------------------------- /videoanalyst/data/dataset/dataset_impl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import glob 3 | from os.path import basename, dirname, isfile 4 | 5 | modules = glob.glob(dirname(__file__) + "/*.py") 6 | modules = [m for m in modules if not m.endswith(('_bak.py')) 7 | ] # filter file with name ending with '_bak' (debugging) 8 | __all__ = [ 9 | basename(f)[:-3] for f in modules if isfile(f) 10 | and not f.endswith("__init__.py") and not f.endswith("utils.py") 11 | ] 12 | -------------------------------------------------------------------------------- /videoanalyst/data/dataset/dataset_impl/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/dataset/dataset_impl/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/dataset/dataset_impl/__pycache__/coco.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/dataset/dataset_impl/__pycache__/coco.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/dataset/dataset_impl/__pycache__/davis.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/dataset/dataset_impl/__pycache__/davis.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/dataset/dataset_impl/__pycache__/got10k.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/dataset/dataset_impl/__pycache__/got10k.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/dataset/dataset_impl/__pycache__/ilsvrc_det.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/dataset/dataset_impl/__pycache__/ilsvrc_det.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/dataset/dataset_impl/__pycache__/ilsvrc_vid.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/dataset/dataset_impl/__pycache__/ilsvrc_vid.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/dataset/dataset_impl/__pycache__/lasot.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/dataset/dataset_impl/__pycache__/lasot.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/dataset/dataset_impl/__pycache__/trackingnet.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/dataset/dataset_impl/__pycache__/trackingnet.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/dataset/dataset_impl/__pycache__/ytb_vos.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/dataset/dataset_impl/__pycache__/ytb_vos.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/dataset/dataset_impl/ilsvrc_vid.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import os.path as osp 3 | from typing import Dict 4 | 5 | from videoanalyst.data.dataset.dataset_base import TRACK_DATASETS, DatasetBase 6 | from videoanalyst.evaluation.got_benchmark.datasets import ImageNetVID 7 | from videoanalyst.pipeline.utils.bbox import xywh2xyxy 8 | 9 | _current_dir = osp.dirname(osp.realpath(__file__)) 10 | 11 | 12 | @TRACK_DATASETS.register 13 | class VIDDataset(DatasetBase): 14 | r""" 15 | ILSVRC2015-VID dataset helper 16 | 17 | Hyper-parameters 18 | ---------------- 19 | dataset_root: str 20 | path to root of the dataset 21 | subset: str 22 | dataset split name (train|val|train_val) 23 | ratio: float 24 | dataset ratio. used by sampler (data.sampler). 25 | max_diff: int 26 | maximum difference in index of a pair of sampled frames 27 | check_integrity: bool 28 | if check integrity of dataset or not 29 | """ 30 | default_hyper_params = dict( 31 | dataset_root="datasets/ILSVRC2015", 32 | subset="train", 33 | ratio=1.0, 34 | max_diff=100, 35 | ) 36 | 37 | def __init__(self) -> None: 38 | super(VIDDataset, self).__init__() 39 | self._state["dataset"] = None 40 | 41 | def update_params(self): 42 | r""" 43 | an interface for update params 44 | """ 45 | dataset_root = osp.realpath(self._hyper_params["dataset_root"]) 46 | subset = self._hyper_params["subset"] 47 | subset = [s.strip() for s in subset.split("_")] 48 | cache_dir = osp.join(dataset_root, "cache/vid") 49 | self._state["dataset"] = ImageNetVID(dataset_root, 50 | subset=subset, 51 | cache_dir=cache_dir) 52 | 53 | def __getitem__(self, item: int) -> Dict: 54 | img_files, anno = self._state["dataset"][item] 55 | anno = xywh2xyxy(anno) 56 | sequence_data = dict(image=img_files, anno=anno) 57 | 58 | return sequence_data 59 | 60 | def __len__(self): 61 | return len(self._state["dataset"]) 62 | -------------------------------------------------------------------------------- /videoanalyst/data/dataset/dataset_impl/lasot.py: -------------------------------------------------------------------------------- 1 | import os.path as osp 2 | from typing import Dict 3 | 4 | from videoanalyst.data.dataset.dataset_base import TRACK_DATASETS, DatasetBase 5 | from videoanalyst.evaluation.got_benchmark.datasets import LaSOT 6 | from videoanalyst.pipeline.utils.bbox import xywh2xyxy 7 | 8 | 9 | @TRACK_DATASETS.register 10 | class LaSOTDataset(DatasetBase): 11 | r""" 12 | LaSOT dataset helper 13 | 14 | Hyper-parameters 15 | ---------------- 16 | dataset_root: str 17 | path to root of the dataset 18 | subset: str 19 | dataset split name (train|val|test) 20 | ratio: float 21 | dataset ratio. used by sampler (data.sampler). 22 | max_diff: int 23 | maximum difference in index of a pair of sampled frames 24 | check_integrity: bool 25 | if check integrity of dataset or not 26 | """ 27 | default_hyper_params = dict( 28 | dataset_root="datasets/LaSOT", 29 | subset="train", 30 | ratio=1.0, 31 | max_diff=100, 32 | check_integrity=True, 33 | ) 34 | 35 | def __init__(self) -> None: 36 | r""" 37 | Create dataset with config 38 | 39 | Arguments 40 | --------- 41 | cfg: CfgNode 42 | dataset config 43 | """ 44 | super().__init__() 45 | self._state["dataset"] = None 46 | 47 | def update_params(self): 48 | r""" 49 | an interface for update params 50 | """ 51 | dataset_root = osp.realpath(self._hyper_params["dataset_root"]) 52 | subset = self._hyper_params["subset"] 53 | check_integrity = self._hyper_params["check_integrity"] 54 | self._state["dataset"] = LaSOT(dataset_root, 55 | subset=subset, 56 | check_integrity=check_integrity) 57 | 58 | def __getitem__(self, item: int) -> Dict: 59 | img_files, anno = self._state["dataset"][item] 60 | 61 | anno = xywh2xyxy(anno) 62 | sequence_data = dict(image=img_files, anno=anno) 63 | 64 | return sequence_data 65 | 66 | def __len__(self): 67 | return len(self._state["dataset"]) 68 | -------------------------------------------------------------------------------- /videoanalyst/data/dataset/dataset_impl/trackingnet.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import os.path as osp 3 | from typing import Dict 4 | 5 | from videoanalyst.data.dataset.dataset_base import TRACK_DATASETS, DatasetBase 6 | from videoanalyst.evaluation.got_benchmark.datasets import TrackingNet 7 | from videoanalyst.pipeline.utils.bbox import xywh2xyxy 8 | 9 | _current_dir = osp.dirname(osp.realpath(__file__)) 10 | 11 | 12 | @TRACK_DATASETS.register 13 | class TrackingNetDataset(DatasetBase): 14 | r""" 15 | ILSVRC2015-VID dataset helper 16 | 17 | Hyper-parameters 18 | ---------------- 19 | dataset_root: str 20 | path to root of the dataset 21 | subset: str 22 | dataset split name (train|val|train_val) 23 | ratio: float 24 | dataset ratio. used by sampler (data.sampler). 25 | max_diff: int 26 | maximum difference in index of a pair of sampled frames 27 | check_integrity: bool 28 | if check integrity of dataset or not 29 | """ 30 | default_hyper_params = dict( 31 | dataset_root="datasets/TrackingNet", 32 | subset="train", 33 | ratio=1.0, 34 | max_diff=100, 35 | check_integrity=True, 36 | ) 37 | 38 | def __init__(self) -> None: 39 | super(TrackingNetDataset, self).__init__() 40 | self._state["dataset"] = None 41 | 42 | def update_params(self): 43 | r""" 44 | an interface for update params 45 | """ 46 | dataset_root = osp.realpath(self._hyper_params["dataset_root"]) 47 | subset = self._hyper_params["subset"] 48 | self._hyper_params["check_integrity"] 49 | osp.join(dataset_root, "cache/vid") 50 | self._state["dataset"] = TrackingNet( 51 | dataset_root, 52 | subset=subset, 53 | # cache_dir=cache_dir, 54 | ) 55 | 56 | def __getitem__(self, item: int) -> Dict: 57 | img_files, anno = self._state["dataset"][item] 58 | anno = xywh2xyxy(anno) 59 | sequence_data = dict(image=img_files, anno=anno) 60 | 61 | return sequence_data 62 | 63 | def __len__(self): 64 | return len(self._state["dataset"]) 65 | -------------------------------------------------------------------------------- /videoanalyst/data/dataset/dataset_impl/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /videoanalyst/data/dataset/dataset_impl/utils/unfixed_got10k_list.txt: -------------------------------------------------------------------------------- 1 | GOT-10k_Train_000399 2 | GOT-10k_Train_004225 3 | GOT-10k_Train_004419 4 | GOT-10k_Train_005912 5 | GOT-10k_Train_005914 6 | GOT-10k_Train_005996 7 | GOT-10k_Train_006852 8 | GOT-10k_Train_007086 9 | GOT-10k_Train_007126 10 | GOT-10k_Train_007788 11 | GOT-10k_Train_007947 12 | GOT-10k_Train_007948 13 | GOT-10k_Train_008004 14 | GOT-10k_Train_008005 15 | GOT-10k_Train_008006 16 | GOT-10k_Train_008007 17 | GOT-10k_Train_008008 18 | GOT-10k_Train_008009 19 | GOT-10k_Train_008010 20 | GOT-10k_Train_008011 21 | GOT-10k_Train_008012 22 | GOT-10k_Train_008025 23 | GOT-10k_Train_008249 24 | GOT-10k_Train_008368 25 | GOT-10k_Train_008380 26 | GOT-10k_Train_008604 27 | GOT-10k_Train_008623 28 | GOT-10k_Train_008624 29 | GOT-10k_Train_008625 30 | GOT-10k_Train_008626 31 | GOT-10k_Train_008627 32 | GOT-10k_Train_008628 33 | GOT-10k_Train_008629 34 | GOT-10k_Train_008630 35 | GOT-10k_Train_008631 36 | GOT-10k_Train_008632 37 | GOT-10k_Train_008633 38 | GOT-10k_Train_008634 39 | GOT-10k_Train_008635 40 | GOT-10k_Train_008636 41 | GOT-10k_Train_008637 42 | GOT-10k_Train_009058 43 | GOT-10k_Train_009059 44 | GOT-10k_Train_009186 -------------------------------------------------------------------------------- /videoanalyst/data/filter/__init__.py: -------------------------------------------------------------------------------- 1 | from .filter_impl import * # noqa 2 | -------------------------------------------------------------------------------- /videoanalyst/data/filter/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/filter/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/filter/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/filter/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/filter/__pycache__/filter_base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/filter/__pycache__/filter_base.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/filter/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from typing import Dict, List 4 | 5 | from yacs.config import CfgNode 6 | 7 | from videoanalyst.utils import merge_cfg_into_hps 8 | 9 | from .filter_base import TASK_FILTERS, FilterBase 10 | 11 | 12 | def build(task: str, cfg: CfgNode) -> FilterBase: 13 | assert task in TASK_FILTERS, "invalid task name" 14 | MODULES = TASK_FILTERS[task] 15 | 16 | name = cfg.name 17 | module = MODULES[name]() 18 | hps = module.get_hps() 19 | hps = merge_cfg_into_hps(cfg[name], hps) 20 | module.set_hps(hps) 21 | module.update_params() 22 | 23 | return module 24 | 25 | 26 | def get_config(task_list: List) -> Dict[str, CfgNode]: 27 | cfg_dict = {name: CfgNode() for name in task_list} 28 | 29 | for cfg_name, modules in TASK_FILTERS.items(): 30 | cfg = cfg_dict[cfg_name] 31 | cfg["name"] = "" 32 | 33 | for name in modules: 34 | cfg[name] = CfgNode() 35 | module = modules[name] 36 | hps = module.default_hyper_params 37 | for hp_name in hps: 38 | cfg[name][hp_name] = hps[hp_name] 39 | 40 | return cfg_dict 41 | -------------------------------------------------------------------------------- /videoanalyst/data/filter/filter_impl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import glob 3 | from os.path import basename, dirname, isfile 4 | 5 | modules = glob.glob(dirname(__file__) + "/*.py") 6 | modules = [m for m in modules if not m.endswith(('_bak.py')) 7 | ] # filter file with name ending with '_bak' (debugging) 8 | __all__ = [ 9 | basename(f)[:-3] for f in modules if isfile(f) 10 | and not f.endswith("__init__.py") and not f.endswith("utils.py") 11 | ] 12 | -------------------------------------------------------------------------------- /videoanalyst/data/filter/filter_impl/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/filter/filter_impl/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/filter/filter_impl/__pycache__/track_pair_filter.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/filter/filter_impl/__pycache__/track_pair_filter.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/filter/filter_impl/track_pair_filter.py: -------------------------------------------------------------------------------- 1 | from typing import Dict 2 | 3 | import cv2 4 | from loguru import logger 5 | 6 | from videoanalyst.data.utils.filter_box import \ 7 | filter_unreasonable_training_boxes 8 | from videoanalyst.pipeline.utils.bbox import xyxy2xywh 9 | 10 | from ..filter_base import TRACK_FILTERS, VOS_FILTERS, FilterBase 11 | 12 | 13 | @TRACK_FILTERS.register 14 | @VOS_FILTERS.register 15 | class TrackPairFilter(FilterBase): 16 | r""" 17 | Tracking data filter 18 | 19 | Hyper-parameters 20 | ---------------- 21 | """ 22 | default_hyper_params = dict( 23 | max_area_rate=0.6, 24 | min_area_rate=0.001, 25 | max_ratio=10, 26 | target_type="bbox", 27 | ) 28 | 29 | def __init__(self) -> None: 30 | super().__init__() 31 | 32 | def __call__(self, data: Dict) -> bool: 33 | if data is None: 34 | return True 35 | im, anno = data["hsi_img"], data["anno"] 36 | if self._hyper_params["target_type"] == "bbox": 37 | bbox = xyxy2xywh(anno) 38 | elif self._hyper_params["target_type"] == "mask": 39 | bbox = cv2.boundingRect(anno) 40 | else: 41 | logger.error("unspported target type {} in filter".format( 42 | self._hyper_params["target_type"])) 43 | exit() 44 | filter_flag = filter_unreasonable_training_boxes( 45 | im, bbox, self._hyper_params) 46 | return filter_flag 47 | -------------------------------------------------------------------------------- /videoanalyst/data/sampler/__init__.py: -------------------------------------------------------------------------------- 1 | from .sampler_impl import * # noqa 2 | -------------------------------------------------------------------------------- /videoanalyst/data/sampler/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/sampler/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/sampler/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/sampler/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/sampler/__pycache__/sampler_base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/sampler/__pycache__/sampler_base.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/sampler/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from typing import Dict, List 4 | 5 | from yacs.config import CfgNode 6 | 7 | from videoanalyst.utils import merge_cfg_into_hps 8 | 9 | from ..dataset import builder as dataset_builder 10 | from ..filter import builder as filter_builder 11 | from .sampler_base import TASK_SAMPLERS, DatasetBase 12 | 13 | 14 | def build(task: str, cfg: CfgNode, seed: int = 0) -> DatasetBase: 15 | r""" 16 | Arguments 17 | --------- 18 | task: str 19 | task name (track|vos) 20 | cfg: CfgNode 21 | node name: sampler 22 | seed: int 23 | seed for rng initialization 24 | """ 25 | assert task in TASK_SAMPLERS, "invalid task name" 26 | MODULES = TASK_SAMPLERS[task] 27 | 28 | submodules_cfg = cfg.submodules 29 | 30 | dataset_cfg = submodules_cfg.dataset 31 | datasets = dataset_builder.build(task, dataset_cfg) 32 | 33 | if submodules_cfg.filter.name != "": 34 | filter_cfg = submodules_cfg.filter 35 | data_filter = filter_builder.build(task, filter_cfg) 36 | else: 37 | data_filter = None 38 | 39 | name = cfg.name 40 | module = MODULES[name](datasets, seed=seed, data_filter=data_filter) 41 | 42 | hps = module.get_hps() 43 | hps = merge_cfg_into_hps(cfg[name], hps) 44 | module.set_hps(hps) 45 | module.update_params() 46 | 47 | return module 48 | 49 | 50 | def get_config(task_list: List) -> Dict[str, CfgNode]: 51 | cfg_dict = {name: CfgNode() for name in task_list} 52 | 53 | for cfg_name, modules in TASK_SAMPLERS.items(): 54 | cfg = cfg_dict[cfg_name] 55 | cfg["name"] = "" 56 | 57 | for name in modules: 58 | cfg[name] = CfgNode() 59 | module = modules[name] 60 | hps = module.default_hyper_params 61 | for hp_name in hps: 62 | cfg[name][hp_name] = hps[hp_name] 63 | 64 | cfg["submodules"] = CfgNode() 65 | cfg["submodules"]["dataset"] = dataset_builder.get_config( 66 | task_list)[cfg_name] 67 | cfg["submodules"]["filter"] = filter_builder.get_config( 68 | task_list)[cfg_name] 69 | 70 | return cfg_dict 71 | -------------------------------------------------------------------------------- /videoanalyst/data/sampler/sampler_impl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import glob 3 | from os.path import basename, dirname, isfile 4 | 5 | modules = glob.glob(dirname(__file__) + "/*.py") 6 | modules = [m for m in modules if not m.endswith(('_bak.py')) 7 | ] # filter file with name ending with '_bak' (debugging) 8 | __all__ = [ 9 | basename(f)[:-3] for f in modules if isfile(f) 10 | and not f.endswith("__init__.py") and not f.endswith("utils.py") 11 | ] 12 | -------------------------------------------------------------------------------- /videoanalyst/data/sampler/sampler_impl/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/sampler/sampler_impl/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/sampler/sampler_impl/__pycache__/track_pair_sampler.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/sampler/sampler_impl/__pycache__/track_pair_sampler.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/target/__init__.py: -------------------------------------------------------------------------------- 1 | from .target_impl import * # noqa 2 | -------------------------------------------------------------------------------- /videoanalyst/data/target/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/target/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/target/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/target/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/target/__pycache__/target_base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/target/__pycache__/target_base.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/target/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from typing import Dict, List 4 | 5 | from yacs.config import CfgNode 6 | 7 | from videoanalyst.utils import merge_cfg_into_hps 8 | 9 | from .target_base import TASK_TARGETS, TargetBase 10 | 11 | 12 | def build(task: str, cfg: CfgNode) -> TargetBase: 13 | r""" 14 | Arguments 15 | --------- 16 | task: str 17 | task 18 | cfg: CfgNode 19 | node name: target 20 | """ 21 | assert task in TASK_TARGETS, "invalid task name" 22 | MODULES = TASK_TARGETS[task] 23 | 24 | name = cfg.name 25 | module = MODULES[name]() 26 | hps = module.get_hps() 27 | hps = merge_cfg_into_hps(cfg[name], hps) 28 | module.set_hps(hps) 29 | module.update_params() 30 | 31 | return module 32 | 33 | 34 | def get_config(task_list: List) -> Dict[str, CfgNode]: 35 | cfg_dict = {name: CfgNode() for name in task_list} 36 | 37 | for cfg_name, modules in TASK_TARGETS.items(): 38 | cfg = cfg_dict[cfg_name] 39 | cfg["name"] = "IdentityTarget" 40 | 41 | for name in modules: 42 | cfg[name] = CfgNode() 43 | module = modules[name] 44 | hps = module.default_hyper_params 45 | for hp_name in hps: 46 | cfg[name][hp_name] = hps[hp_name] 47 | 48 | return cfg_dict 49 | -------------------------------------------------------------------------------- /videoanalyst/data/target/target_base.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from abc import ABCMeta 4 | from typing import Dict 5 | 6 | import numpy as np 7 | 8 | import torch 9 | 10 | from videoanalyst.utils import Registry 11 | 12 | TRACK_TARGETS = Registry('TRACK_TARGETS') 13 | VOS_TARGETS = Registry('VOS_TARGETS') 14 | 15 | TASK_TARGETS = dict( 16 | track=TRACK_TARGETS, 17 | vos=VOS_TARGETS, 18 | ) 19 | 20 | 21 | class TargetBase: 22 | __metaclass__ = ABCMeta 23 | r""" 24 | Target maker. 25 | Responsible for transform image (e.g. HWC -> 1CHW), generating training target, etc. 26 | 27 | Define your hyper-parameters here in your sub-class. 28 | """ 29 | default_hyper_params = dict() 30 | 31 | def __init__(self) -> None: 32 | r""" 33 | Target, reponsible for generate training target tensor 34 | 35 | Arguments 36 | --------- 37 | cfg: CfgNode 38 | node name target 39 | """ 40 | self._hyper_params = self.default_hyper_params 41 | self._state = dict() 42 | 43 | def get_hps(self) -> Dict: 44 | r""" 45 | Getter function for hyper-parameters 46 | 47 | Returns 48 | ------- 49 | Dict 50 | hyper-parameters 51 | """ 52 | return self._hyper_params 53 | 54 | def set_hps(self, hps: Dict) -> None: 55 | r""" 56 | Set hyper-parameters 57 | 58 | Arguments 59 | --------- 60 | hps: Dict 61 | Dict of hyper-parameters, the keys must in self.__hyper_params__ 62 | """ 63 | for key in hps: 64 | if key not in self._hyper_params: 65 | raise KeyError 66 | self._hyper_params[key] = hps[key] 67 | 68 | def update_params(self) -> None: 69 | r""" 70 | an interface for update params 71 | """ 72 | def __call__(self, sampled_data: Dict) -> Dict: 73 | r""" 74 | An interface to mkae target 75 | 76 | Arguments 77 | --------- 78 | training_data: Dict 79 | data whose training target will be made 80 | """ 81 | for k in sampled_data: 82 | sampled_data[k] = torch.from_numpy(np.array(sampled_data[k])) 83 | 84 | return sampled_data 85 | -------------------------------------------------------------------------------- /videoanalyst/data/target/target_impl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import glob 3 | from os.path import basename, dirname, isfile 4 | 5 | modules = glob.glob(dirname(__file__) + "/*.py") 6 | modules = [m for m in modules if not m.endswith(('_bak.py')) 7 | ] # filter file with name ending with '_bak' (debugging) 8 | __all__ = [ 9 | basename(f)[:-3] for f in modules if isfile(f) 10 | and not f.endswith("__init__.py") and not f.endswith("utils.py") 11 | ] 12 | -------------------------------------------------------------------------------- /videoanalyst/data/target/target_impl/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/target/target_impl/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/target/target_impl/__pycache__/densebox_target.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/target/target_impl/__pycache__/densebox_target.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/target/target_impl/utils/README.md: -------------------------------------------------------------------------------- 1 | # About debugging in this part 2 | 3 | This part is resposible for training target generation, one of the most critical part in this codebase. Thus debugging codes have been installed inside and tools are provided for unit testing to ensure the correctness. 4 | 5 | ## Comparing the target 6 | 7 | Assuming comparison between _make_densebox_target.py_ and _make_densebox_target_v1.py_ 8 | 9 | Set _DUMP_FLAG_ to _True_ in both _make_densebox_target.py_ and _make_densebox_target_v1.py_ 10 | 11 | Set _gt_boxes_ in _debug_compare_densebox_target.py_ to desired testing inputs. 12 | 13 | ``` 14 | python debug_compare_densebox_target.py 15 | ``` 16 | 17 | See "Values closed" to ensure that targets generated are "acceptably equal" (error within tolerance). 18 | 19 | ## Comparing the intermediate tensors 20 | 21 | Set _tensor_prefix_ in _debug_compare_tensor.py_. 22 | 23 | ``` 24 | python debug_compare_densebox_target.py 25 | python debug_compare_tensor.py 26 | ``` 27 | 28 | ## After debugging 29 | 30 | Clean dumped tensors. 31 | 32 | ``` 33 | rm -r dump 34 | ``` 35 | -------------------------------------------------------------------------------- /videoanalyst/data/target/target_impl/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | from .make_densebox_target import make_densebox_target 3 | 4 | __all__ = [make_densebox_target] 5 | -------------------------------------------------------------------------------- /videoanalyst/data/target/target_impl/utils/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/target/target_impl/utils/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/target/target_impl/utils/__pycache__/make_densebox_target.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/target/target_impl/utils/__pycache__/make_densebox_target.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/target/target_impl/utils/debug_compare_densebox_target.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | # from IPython import embed;embed() 3 | from make_densebox_target import \ 4 | make_densebox_target as make_densebox_target_old 5 | from make_densebox_target_dev import \ 6 | make_densebox_target as make_densebox_target_new 7 | 8 | gt_boxes = np.asarray([[150, 250, 130, 60, 1]]) 9 | config_dict = dict( 10 | x_size=303, 11 | score_size=17, 12 | total_stride=8, 13 | score_offset=(303 - 1 - (17 - 1) * 8) // 2, 14 | ) 15 | 16 | target_old = make_densebox_target_old(gt_boxes, config_dict) 17 | target_new = make_densebox_target_new(gt_boxes, config_dict) 18 | 19 | for v_old, v_new in zip(target_old, target_new): 20 | v_new = v_new.numpy() 21 | # uncomment the next line to inspect tensors in detail 22 | # from IPython import embed;embed() 23 | np.testing.assert_allclose(v_new, v_old, atol=1e-6, verbose=True) 24 | print("Values closed.") 25 | -------------------------------------------------------------------------------- /videoanalyst/data/target/target_impl/utils/debug_compare_tensor.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | DUMP_DIR = "dump" 4 | tensor_prefix = "center" 5 | tensor_suffix_old = "main" 6 | tensor_suffix_new = "dev" 7 | 8 | tensor_old = np.load("{}/{}_{}.npz".format(DUMP_DIR, tensor_prefix, 9 | tensor_suffix_old), 10 | allow_pickle=True) 11 | tensor_new = np.load("{}/{}_{}.npz".format(DUMP_DIR, tensor_prefix, 12 | tensor_suffix_new), 13 | allow_pickle=True) 14 | 15 | # uncomment the next line to inspect tensors in detail 16 | # from IPython import embed;embed() 17 | np.testing.assert_allclose( 18 | tensor_new, 19 | tensor_old, 20 | atol=1e-6, 21 | err_msg="Value not cloased for tensor: {}".format(tensor_prefix), 22 | verbose=True) 23 | print("Values cloased for tensor: {}".format(tensor_prefix)) 24 | -------------------------------------------------------------------------------- /videoanalyst/data/transformer/__init__.py: -------------------------------------------------------------------------------- 1 | from .transformer_impl import * # noqa 2 | -------------------------------------------------------------------------------- /videoanalyst/data/transformer/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/transformer/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/transformer/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/transformer/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/transformer/__pycache__/transformer_base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/transformer/__pycache__/transformer_base.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/transformer/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from typing import Dict, List 4 | 5 | from yacs.config import CfgNode 6 | 7 | from videoanalyst.utils import merge_cfg_into_hps 8 | 9 | from .transformer_base import TASK_TRANSFORMERS, TransformerBase 10 | 11 | 12 | def build(task: str, cfg: CfgNode, seed: int = 0) -> TransformerBase: 13 | r""" 14 | Arguments 15 | --------- 16 | task: str 17 | task 18 | cfg: CfgNode 19 | node name: transformer 20 | """ 21 | assert task in TASK_TRANSFORMERS, "invalid task name" 22 | MODULES = TASK_TRANSFORMERS[task] 23 | 24 | names = cfg.names 25 | modules = [] 26 | 27 | for name in names: 28 | module = MODULES[name](seed=seed) 29 | hps = module.get_hps() 30 | hps = merge_cfg_into_hps(cfg[name], hps) 31 | module.set_hps(hps) 32 | module.update_params() 33 | 34 | modules.append(module) 35 | 36 | return modules 37 | 38 | 39 | def get_config(task_list: List) -> Dict[str, CfgNode]: 40 | cfg_dict = {name: CfgNode() for name in TASK_TRANSFORMERS.keys()} 41 | 42 | for cfg_name, modules in TASK_TRANSFORMERS.items(): 43 | cfg = cfg_dict[cfg_name] 44 | cfg["names"] = [] 45 | 46 | for name in modules: 47 | cfg[name] = CfgNode() 48 | module = modules[name] 49 | hps = module.default_hyper_params 50 | for hp_name in hps: 51 | cfg[name][hp_name] = hps[hp_name] 52 | 53 | return cfg_dict 54 | -------------------------------------------------------------------------------- /videoanalyst/data/transformer/transformer_impl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import glob 3 | from os.path import basename, dirname, isfile 4 | 5 | modules = glob.glob(dirname(__file__) + "/*.py") 6 | modules = [m for m in modules if not m.endswith(('_bak.py')) 7 | ] # filter file with name ending with '_bak' (debugging) 8 | __all__ = [ 9 | basename(f)[:-3] for f in modules if isfile(f) 10 | and not f.endswith("__init__.py") and not f.endswith("utils.py") 11 | ] 12 | -------------------------------------------------------------------------------- /videoanalyst/data/transformer/transformer_impl/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/transformer/transformer_impl/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/transformer/transformer_impl/__pycache__/common_transformer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/transformer/transformer_impl/__pycache__/common_transformer.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/transformer/transformer_impl/__pycache__/random_crop_transformer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/transformer/transformer_impl/__pycache__/random_crop_transformer.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /videoanalyst/data/utils/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/utils/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/utils/__pycache__/filter_box.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/utils/__pycache__/filter_box.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/utils/__pycache__/target_image_crop.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/data/utils/__pycache__/target_image_crop.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/data/utils/misc.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from typing import Dict 3 | 4 | 5 | def index_data(data: Dict, idx: int): 6 | r""" 7 | Arguments 8 | data: Dict 9 | data to be indexed 10 | idx: int 11 | index used for indexing in data's first dimension 12 | """ 13 | ret = dict() 14 | for k in data: 15 | ret[k] = data[k][idx] 16 | 17 | return ret 18 | -------------------------------------------------------------------------------- /videoanalyst/engine/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | -------------------------------------------------------------------------------- /videoanalyst/engine/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from yacs.config import CfgNode 3 | 4 | from .tester import builder as tester_builder 5 | from .trainer import builder as trainer_builder 6 | 7 | TASK_ENGINE_BUILDERS = dict( 8 | tester=tester_builder, 9 | trainer=trainer_builder, 10 | ) 11 | 12 | 13 | def build(task: str, cfg: CfgNode, engine_type: str, *args, **kwargs): 14 | """ 15 | Builder function for trainer/tester 16 | engine_type: trainer or tester 17 | """ 18 | 19 | if engine_type in TASK_ENGINE_BUILDERS: 20 | engine = TASK_ENGINE_BUILDERS[engine_type].build( 21 | task, cfg, *args, **kwargs) 22 | return engine 23 | else: 24 | raise ValueError("Invalid engine_type: %s" % engine_type) 25 | -------------------------------------------------------------------------------- /videoanalyst/engine/monitor/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from .monitor_impl import * # noqa 3 | -------------------------------------------------------------------------------- /videoanalyst/engine/monitor/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/monitor/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/monitor/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/monitor/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/monitor/__pycache__/monitor_base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/monitor/__pycache__/monitor_base.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/monitor/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from typing import Dict, List 3 | 4 | from yacs.config import CfgNode 5 | 6 | from videoanalyst.utils.misc import merge_cfg_into_hps 7 | 8 | from .monitor_base import TASK_MONITORS, MonitorBase 9 | 10 | 11 | def build(task: str, cfg: CfgNode) -> List[MonitorBase]: 12 | r""" 13 | Builder function. 14 | 15 | Arguments 16 | --------- 17 | task: str 18 | builder task name (track|vos) 19 | cfg: CfgNode 20 | node name: monitors 21 | 22 | Returns 23 | ------- 24 | List[MonitorBase] 25 | list of monitors 26 | """ 27 | assert task in TASK_MONITORS, "no tester for task {}".format(task) 28 | modules = TASK_MONITORS[task] 29 | 30 | names = cfg.names 31 | monitors = [] 32 | for name in names: 33 | monitor = modules[name]() 34 | hps = monitor.get_hps() 35 | hps = merge_cfg_into_hps(cfg[name], hps) 36 | monitor.set_hps(hps) 37 | monitor.update_params() 38 | monitors.append(monitor) 39 | 40 | return monitors 41 | 42 | 43 | def get_config(task_list) -> Dict[str, CfgNode]: 44 | cfg_dict = {name: CfgNode() for name in task_list} 45 | 46 | for cfg_name, modules in TASK_MONITORS.items(): 47 | cfg = cfg_dict[cfg_name] 48 | cfg["names"] = [""] 49 | 50 | for name in modules: 51 | cfg[name] = CfgNode() 52 | module = modules[name] 53 | hps = module.default_hyper_params 54 | for hp_name in hps: 55 | cfg[name][hp_name] = hps[hp_name] 56 | 57 | return cfg_dict 58 | -------------------------------------------------------------------------------- /videoanalyst/engine/monitor/monitor_base.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from copy import deepcopy 3 | from typing import Dict 4 | 5 | from videoanalyst.utils import Registry 6 | 7 | TRACK_MONITORS = Registry('TRACK_MONITOR') 8 | VOS_MONITORS = Registry('VOS_MONITOR') 9 | 10 | TASK_MONITORS = dict( 11 | track=TRACK_MONITORS, 12 | vos=VOS_MONITORS, 13 | ) 14 | 15 | 16 | class MonitorBase: 17 | r""" 18 | Monitor base class for engine monitoring (e.g. visualization / tensorboard / training info logging) 19 | """ 20 | # Define your default hyper-parameters here in your sub-class. 21 | default_hyper_params = dict() 22 | 23 | def __init__(self, ): 24 | self._hyper_params = deepcopy( 25 | self.default_hyper_params) # mapping-like object 26 | self._state = dict() # pipeline state 27 | 28 | def get_hps(self) -> Dict: 29 | r""" 30 | Getter function for hyper-parameters 31 | 32 | Returns 33 | ------- 34 | dict 35 | hyper-parameters 36 | """ 37 | return self._hyper_params 38 | 39 | def set_hps(self, hps: Dict) -> None: 40 | r""" 41 | Set hyper-parameters 42 | 43 | Arguments 44 | --------- 45 | hps: dict 46 | dict of hyper-parameters, the keys must in self.__hyper_params__ 47 | """ 48 | for key in hps: 49 | if key not in self._hyper_params: 50 | raise KeyError 51 | self._hyper_params[key] = hps[key] 52 | 53 | def update_params(self): 54 | r""" 55 | an interface for update params 56 | """ 57 | def init(self, engine_state: Dict): 58 | r"""register engine state & initialize monitor 59 | """ 60 | self._state["engine_state"] = engine_state 61 | 62 | def update(self, engine_data: Dict): 63 | """an interface to update with engine_data and update iteration data for monitoring 64 | Execution result will be saved in engine_state 65 | 66 | Parameters 67 | ---------- 68 | engine_state : Dict 69 | _state attribute of engine 70 | engine_data : Dict 71 | data given by engine at each iteration 72 | """ 73 | -------------------------------------------------------------------------------- /videoanalyst/engine/monitor/monitor_impl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import glob 3 | from os.path import basename, dirname, isfile 4 | 5 | modules = glob.glob(dirname(__file__) + "/*.py") 6 | __all__ = [ 7 | basename(f)[:-3] for f in modules if isfile(f) 8 | and not f.endswith("__init__.py") and not f.endswith("utils.py") 9 | ] 10 | -------------------------------------------------------------------------------- /videoanalyst/engine/monitor/monitor_impl/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/monitor/monitor_impl/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/monitor/monitor_impl/__pycache__/monitor_template.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/monitor/monitor_impl/__pycache__/monitor_template.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/monitor/monitor_impl/__pycache__/tensorboard_logger.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/monitor/monitor_impl/__pycache__/tensorboard_logger.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/monitor/monitor_impl/__pycache__/text_info.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/monitor/monitor_impl/__pycache__/text_info.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/monitor/monitor_impl/monitor_template.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from typing import Dict 3 | 4 | from ..monitor_base import TRACK_MONITORS, VOS_MONITORS, MonitorBase 5 | 6 | 7 | @TRACK_MONITORS.register 8 | @VOS_MONITORS.register 9 | class Monitor(MonitorBase): 10 | r""" 11 | 12 | Hyper-parameters 13 | ---------------- 14 | """ 15 | 16 | default_hyper_params = dict() 17 | 18 | def __init__(self, ): 19 | r""" 20 | Arguments 21 | --------- 22 | """ 23 | super(Monitor, self).__init__() 24 | 25 | def init(self, engine_state: Dict): 26 | super(Monitor, self).init(engine_state) 27 | 28 | def update(self, engine_data: Dict): 29 | pass 30 | -------------------------------------------------------------------------------- /videoanalyst/engine/monitor/monitor_impl/text_info.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from typing import Dict 3 | import torch 4 | from ..monitor_base import TRACK_MONITORS, VOS_MONITORS, MonitorBase 5 | 6 | 7 | @TRACK_MONITORS.register 8 | @VOS_MONITORS.register 9 | class TextInfo(MonitorBase): 10 | r""" 11 | Print tracking information during training. 12 | Compatible with _RegularTrainer_ 13 | 14 | Hyper-parameters 15 | ---------------- 16 | """ 17 | 18 | default_hyper_params = dict() 19 | 20 | def __init__(self, ): 21 | r""" 22 | Arguments 23 | --------- 24 | """ 25 | super(TextInfo, self).__init__() 26 | 27 | def init(self, engine_state: Dict): 28 | super(TextInfo, self).init(engine_state) 29 | 30 | def update(self, engine_data: Dict): 31 | r""" 32 | """ 33 | # state 34 | engine_state = self._state["engine_state"] 35 | # data 36 | schedule_info = engine_data["schedule_info"] 37 | training_losses = engine_data["training_losses"] 38 | extras = engine_data["extras"] 39 | time_dict = engine_data["time_dict"] 40 | # schedule information 41 | epoch = engine_state["epoch"] 42 | print_str = 'epoch %d, ' % epoch 43 | for k in schedule_info: 44 | print_str += '%s: %.1e, ' % (k, schedule_info[k]) 45 | # loss info 46 | for k in training_losses: 47 | l = training_losses[k] 48 | print_str += '%s: %.3f, ' % (k, l.detach().cpu().numpy()) 49 | # extra info 50 | for extra in extras.values(): 51 | #if extra: 52 | # extra = dist_utils.reduce_dict(extra) 53 | for k in extra: 54 | l = extra[k] 55 | print_str += '%s: %.3f, ' % (k, l) 56 | # pring elapsed time 57 | # for k in time_dict: 58 | # print_str += "%s: %.1e, " % (k, time_dict[k]) 59 | # max_mem_mb = torch.cuda.max_memory_allocated() / 1024.0 / 1024.0 60 | # print_str += " max mem: {:.1f}M".format(max_mem_mb) 61 | 62 | engine_state["print_str"] = print_str 63 | -------------------------------------------------------------------------------- /videoanalyst/engine/tester/__init__.py: -------------------------------------------------------------------------------- 1 | from .tester_impl import * # noqa 2 | -------------------------------------------------------------------------------- /videoanalyst/engine/tester/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/tester/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/tester/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/tester/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/tester/__pycache__/tester_base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/tester/__pycache__/tester_base.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/tester/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from typing import Dict, List 3 | 4 | from yacs.config import CfgNode 5 | 6 | from videoanalyst.pipeline.pipeline_base import PipelineBase 7 | from videoanalyst.utils import merge_cfg_into_hps 8 | 9 | from .tester_base import TASK_TESTERS 10 | 11 | 12 | def build(task: str, cfg: CfgNode, pipeline: PipelineBase): 13 | r""" 14 | Builder function. 15 | 16 | Arguments 17 | --------- 18 | task: str 19 | builder task name (track|vos) 20 | cfg: CfgNode 21 | buidler configuration, 22 | node nams: tester 23 | 24 | Returns 25 | ------- 26 | TesterBase 27 | tester built by builder 28 | """ 29 | assert task in TASK_TESTERS, "no tester for task {}".format(task) 30 | MODULES = TASK_TESTERS[task] 31 | 32 | names = cfg.names 33 | testers = [] 34 | # tester for multiple experiments 35 | for name in names: 36 | tester = MODULES[name](pipeline) 37 | hps = tester.get_hps() 38 | hps = merge_cfg_into_hps(cfg[name], hps) 39 | tester.set_hps(hps) 40 | tester.update_params() 41 | testers.append(tester) 42 | return testers 43 | 44 | 45 | def get_config(task_list: List) -> Dict[str, CfgNode]: 46 | r""" 47 | Get available component list config 48 | 49 | Returns 50 | ------- 51 | Dict[str, CfgNode] 52 | config with list of available components 53 | """ 54 | cfg_dict = {name: CfgNode() for name in task_list} 55 | 56 | for cfg_name, MODULES in TASK_TESTERS.items(): 57 | cfg = cfg_dict[cfg_name] 58 | cfg["names"] = [] 59 | for name in MODULES: 60 | cfg["names"].append(name) 61 | cfg[name] = CfgNode() 62 | tester = MODULES[name] 63 | hps = tester.default_hyper_params 64 | for hp_name in hps: 65 | cfg[name][hp_name] = hps[hp_name] 66 | return cfg_dict 67 | -------------------------------------------------------------------------------- /videoanalyst/engine/tester/tester_impl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import glob 3 | from os.path import basename, dirname, isfile 4 | 5 | modules = glob.glob(dirname(__file__) + "/*.py") 6 | __all__ = [ 7 | basename(f)[:-3] for f in modules if isfile(f) 8 | and not f.endswith("__init__.py") and not f.endswith("utils.py") 9 | ] 10 | -------------------------------------------------------------------------------- /videoanalyst/engine/tester/tester_impl/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/tester/tester_impl/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/tester/tester_impl/__pycache__/davis.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/tester/tester_impl/__pycache__/davis.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/tester/tester_impl/__pycache__/got10k.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/tester/tester_impl/__pycache__/got10k.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/tester/tester_impl/__pycache__/lasot.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/tester/tester_impl/__pycache__/lasot.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/tester/tester_impl/__pycache__/nfs.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/tester/tester_impl/__pycache__/nfs.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/tester/tester_impl/__pycache__/otb.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/tester/tester_impl/__pycache__/otb.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/tester/tester_impl/__pycache__/trackingnet.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/tester/tester_impl/__pycache__/trackingnet.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/tester/tester_impl/__pycache__/uav123.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/tester/tester_impl/__pycache__/uav123.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/tester/tester_impl/__pycache__/vot.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/tester/tester_impl/__pycache__/vot.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/tester/tester_impl/__pycache__/votlt.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/tester/tester_impl/__pycache__/votlt.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/tester/tester_impl/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | -------------------------------------------------------------------------------- /videoanalyst/engine/tester/tester_impl/utils/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/tester/tester_impl/utils/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/tester/tester_impl/utils/__pycache__/got_benchmark_helper.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/tester/tester_impl/utils/__pycache__/got_benchmark_helper.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/trainer/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from .trainer_impl import * # noqa 3 | -------------------------------------------------------------------------------- /videoanalyst/engine/trainer/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/trainer/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/trainer/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/trainer/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/trainer/__pycache__/trainer_base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/trainer/__pycache__/trainer_base.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/trainer/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from typing import Dict, List 3 | 4 | from yacs.config import CfgNode 5 | 6 | from videoanalyst.utils.misc import merge_cfg_into_hps 7 | 8 | from ..monitor import builder as monitor_builder 9 | from .trainer_base import TASK_TRAINERS, TrainerBase 10 | 11 | 12 | def build(task: str, cfg: CfgNode, optimizer, dataloader, devs=[], 13 | tracker=None) -> TrainerBase: 14 | r""" 15 | Builder function. 16 | 17 | Arguments 18 | --------- 19 | task: str 20 | builder task name (track|vos) 21 | cfg: CfgNode 22 | node name: trainer 23 | 24 | Returns 25 | ------- 26 | TrainerBase 27 | tester built by builder 28 | """ 29 | assert task in TASK_TRAINERS, "no trainer for task {}".format(task) 30 | MODULES = TASK_TRAINERS[task] 31 | 32 | # build monitors 33 | if "monitors" in cfg: 34 | monitor_cfg = cfg.monitors 35 | monitors = monitor_builder.build(task, monitor_cfg) 36 | else: 37 | monitors = [] 38 | 39 | name = cfg.name 40 | if task == "vos": 41 | trainer = MODULES[name](optimizer, dataloader, devs, monitors, tracker) 42 | else: 43 | trainer = MODULES[name](optimizer, dataloader, devs, monitors) 44 | hps = trainer.get_hps() 45 | hps = merge_cfg_into_hps(cfg[name], hps) 46 | trainer.set_hps(hps) 47 | trainer.update_params() 48 | 49 | return trainer 50 | 51 | 52 | def get_config(task_list: List) -> Dict[str, CfgNode]: 53 | r""" 54 | Get available component list config 55 | 56 | Returns 57 | ------- 58 | Dict[str, CfgNode] 59 | config with list of available components 60 | """ 61 | cfg_dict = {name: CfgNode() for name in task_list} 62 | 63 | for cfg_name, MODULES in TASK_TRAINERS.items(): 64 | cfg = cfg_dict[cfg_name] 65 | cfg["name"] = "" 66 | 67 | for name in MODULES: 68 | cfg[name] = CfgNode() 69 | module = MODULES[name] 70 | hps = module.default_hyper_params 71 | for hp_name in hps: 72 | cfg[name][hp_name] = hps[hp_name] 73 | 74 | cfg["monitors"] = monitor_builder.get_config(task_list)[cfg_name] 75 | 76 | return cfg_dict 77 | -------------------------------------------------------------------------------- /videoanalyst/engine/trainer/trainer_impl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import glob 3 | from os.path import basename, dirname, isfile 4 | 5 | modules = glob.glob(dirname(__file__) + "/*.py") 6 | __all__ = [ 7 | basename(f)[:-3] for f in modules if isfile(f) 8 | and not f.endswith("__init__.py") and not f.endswith("utils.py") 9 | ] 10 | -------------------------------------------------------------------------------- /videoanalyst/engine/trainer/trainer_impl/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/trainer/trainer_impl/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/trainer/trainer_impl/__pycache__/distributed_regular_trainer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/trainer/trainer_impl/__pycache__/distributed_regular_trainer.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/trainer/trainer_impl/__pycache__/distributed_sat_trainer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/trainer/trainer_impl/__pycache__/distributed_sat_trainer.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/engine/trainer/trainer_impl/__pycache__/regular_trainer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/engine/trainer/trainer_impl/__pycache__/regular_trainer.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | # from .vot_benchmark.log_helper import init_log, add_file_handler 2 | # from .vot_benchmark.bbox_helper import get_axis_aligned_bbox, cxy_wh_2_rect 3 | # from .vot_benchmark.benchmark_helper import load_dataset, get_img 4 | # from .vot_benchmark.pysot.utils.region import vot_overlap, vot_float2str 5 | # from .vot_benchmark.pysot.datasets import VOTDataset 6 | # from .vot_benchmark.pysot.evaluation import AccuracyRobustnessBenchmark, EAOBenchmark 7 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/davis_benchmark/__init__.py: -------------------------------------------------------------------------------- 1 | from .benckmark_helpler import (MultiBatchIouMeter, label2color, labelcolormap, 2 | load_dataset) 3 | from .davis2017.utils import overlay_semantic_mask 4 | from .evaluation_method import davis2017_eval 5 | 6 | __all__ = [ 7 | load_dataset, label2color, labelcolormap, MultiBatchIouMeter, 8 | davis2017_eval, overlay_semantic_mask 9 | ] 10 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/davis_benchmark/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/davis_benchmark/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/davis_benchmark/__pycache__/benckmark_helpler.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/davis_benchmark/__pycache__/benckmark_helpler.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/davis_benchmark/__pycache__/evaluation_method.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/davis_benchmark/__pycache__/evaluation_method.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/davis_benchmark/davis2017/__pycache__/davis.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/davis_benchmark/davis2017/__pycache__/davis.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/davis_benchmark/davis2017/__pycache__/davis_evaluation.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/davis_benchmark/davis2017/__pycache__/davis_evaluation.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/davis_benchmark/davis2017/__pycache__/metrics.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/davis_benchmark/davis2017/__pycache__/metrics.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/davis_benchmark/davis2017/__pycache__/results.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/davis_benchmark/davis2017/__pycache__/results.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/davis_benchmark/davis2017/__pycache__/utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/davis_benchmark/davis2017/__pycache__/utils.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/davis_benchmark/davis2017/results.py: -------------------------------------------------------------------------------- 1 | import os 2 | import numpy as np 3 | from PIL import Image 4 | import sys 5 | 6 | 7 | class Results(object): 8 | def __init__(self, root_dir): 9 | self.root_dir = root_dir 10 | 11 | def _read_mask(self, sequence, frame_id): 12 | try: 13 | mask_path = os.path.join(self.root_dir, sequence, 14 | '{}.png'.format(frame_id)) 15 | return np.array(Image.open(mask_path)) 16 | except IOError as err: 17 | sys.stdout.write(sequence + " frame %s not found!\n" % frame_id) 18 | sys.stdout.write( 19 | "The frames have to be indexed PNG files placed inside the corespondent sequence " 20 | "folder.\nThe indexes have to match with the initial frame.\n") 21 | sys.stderr.write("IOError: " + err.strerror + "\n") 22 | sys.exit() 23 | 24 | def read_masks(self, sequence, masks_id): 25 | mask_0 = self._read_mask(sequence, masks_id[0]) 26 | masks = np.zeros((len(masks_id), *mask_0.shape)) 27 | for ii, m in enumerate(masks_id): 28 | masks[ii, ...] = self._read_mask(sequence, m) 29 | num_objects = int(np.max(masks)) 30 | tmp = np.ones((num_objects, *masks.shape)) 31 | tmp = tmp * np.arange(1, num_objects + 1)[:, None, None, None] 32 | masks = (tmp == masks[None, ...]) > 0 33 | return masks 34 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/__init__.py -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from .dtb70 import DTB70 4 | from .got10k import GOT10k 5 | from .lasot import LaSOT 6 | from .nfs import NfS 7 | from .otb import OTB 8 | from .tcolor128 import TColor128 9 | from .trackingnet import TrackingNet 10 | from .uav123 import UAV123 11 | from .vid import ImageNetVID 12 | from .vot import VOT 13 | 14 | __all__ = [ 15 | GOT10k, OTB, VOT, DTB70, TColor128, UAV123, NfS, LaSOT, TrackingNet, 16 | ImageNetVID 17 | ] 18 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/datasets/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/datasets/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/datasets/__pycache__/dtb70.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/datasets/__pycache__/dtb70.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/datasets/__pycache__/got10k.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/datasets/__pycache__/got10k.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/datasets/__pycache__/lasot.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/datasets/__pycache__/lasot.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/datasets/__pycache__/nfs.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/datasets/__pycache__/nfs.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/datasets/__pycache__/otb.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/datasets/__pycache__/otb.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/datasets/__pycache__/tcolor128.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/datasets/__pycache__/tcolor128.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/datasets/__pycache__/trackingnet.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/datasets/__pycache__/trackingnet.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/datasets/__pycache__/uav123.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/datasets/__pycache__/uav123.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/datasets/__pycache__/vid.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/datasets/__pycache__/vid.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/datasets/__pycache__/vot.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/datasets/__pycache__/vot.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/experiments/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from .dtb70 import ExperimentDTB70 4 | from .got10k import ExperimentGOT10k 5 | from .lasot import ExperimentLaSOT 6 | from .nfs import ExperimentNfS 7 | from .otb import ExperimentOTB 8 | from .tcolor128 import ExperimentTColor128 9 | from .trackingnet import ExperimentTrackingNet 10 | from .uav123 import ExperimentUAV123 11 | from .vot import ExperimentVOT 12 | 13 | __all__ = [ 14 | ExperimentGOT10k, ExperimentOTB, ExperimentVOT, ExperimentDTB70, 15 | ExperimentUAV123, ExperimentNfS, ExperimentTColor128, ExperimentLaSOT, 16 | ExperimentTrackingNet 17 | ] 18 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/experiments/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/experiments/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/experiments/__pycache__/dtb70.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/experiments/__pycache__/dtb70.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/experiments/__pycache__/got10k.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/experiments/__pycache__/got10k.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/experiments/__pycache__/lasot.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/experiments/__pycache__/lasot.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/experiments/__pycache__/nfs.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/experiments/__pycache__/nfs.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/experiments/__pycache__/otb.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/experiments/__pycache__/otb.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/experiments/__pycache__/tcolor128.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/experiments/__pycache__/tcolor128.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/experiments/__pycache__/trackingnet.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/experiments/__pycache__/trackingnet.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/experiments/__pycache__/uav123.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/experiments/__pycache__/uav123.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/experiments/__pycache__/vot.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/experiments/__pycache__/vot.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/experiments/dtb70.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import os 4 | 5 | from .otb import ExperimentOTB 6 | from ..datasets import DTB70 7 | 8 | 9 | class ExperimentDTB70(ExperimentOTB): 10 | r"""Experiment pipeline and evaluation toolkit for DTB70 dataset. 11 | 12 | Args: 13 | root_dir (string): Root directory of DTB70 dataset. 14 | result_dir (string, optional): Directory for storing tracking 15 | results. Default is ``./results``. 16 | report_dir (string, optional): Directory for storing performance 17 | evaluation results. Default is ``./reports``. 18 | """ 19 | def __init__(self, root_dir, result_dir='results', report_dir='reports'): 20 | self.dataset = DTB70(root_dir) 21 | self.result_dir = os.path.join(result_dir, 'DTB70') 22 | self.report_dir = os.path.join(report_dir, 'DTB70') 23 | # as nbins_iou increases, the success score 24 | # converges to the average overlap (AO) 25 | self.nbins_iou = 21 26 | self.nbins_ce = 51 27 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/experiments/nfs.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import os 4 | 5 | from .otb import ExperimentOTB 6 | from ..datasets import NfS 7 | 8 | 9 | class ExperimentNfS(ExperimentOTB): 10 | r"""Experiment pipeline and evaluation toolkit for NfS dataset. 11 | 12 | Args: 13 | root_dir (string): Root directory of NfS dataset. 14 | result_dir (string, optional): Directory for storing tracking 15 | results. Default is ``./results``. 16 | report_dir (string, optional): Directory for storing performance 17 | evaluation results. Default is ``./reports``. 18 | """ 19 | def __init__(self, 20 | root_dir, 21 | fps=240, 22 | result_dir='results', 23 | report_dir='reports'): 24 | self.dataset = NfS(root_dir, fps) 25 | self.result_dir = os.path.join(result_dir, 'NfS/%d' % fps) 26 | self.report_dir = os.path.join(report_dir, 'NfS/%d' % fps) 27 | # as nbins_iou increases, the success score 28 | # converges to the average overlap (AO) 29 | self.nbins_iou = 21 30 | self.nbins_ce = 51 31 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/experiments/tcolor128.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import os 4 | 5 | from .otb import ExperimentOTB 6 | from ..datasets import TColor128 7 | 8 | 9 | class ExperimentTColor128(ExperimentOTB): 10 | r"""Experiment pipeline and evaluation toolkit for TColor128 dataset. 11 | 12 | Args: 13 | root_dir (string): Root directory of TColor128 dataset. 14 | result_dir (string, optional): Directory for storing tracking 15 | results. Default is ``./results``. 16 | report_dir (string, optional): Directory for storing performance 17 | evaluation results. Default is ``./reports``. 18 | """ 19 | def __init__(self, root_dir, result_dir='results', report_dir='reports'): 20 | self.dataset = TColor128(root_dir) 21 | self.result_dir = os.path.join(result_dir, 'TColor128') 22 | self.report_dir = os.path.join(report_dir, 'TColor128') 23 | # as nbins_iou increases, the success score 24 | # converges to the average overlap (AO) 25 | self.nbins_iou = 21 26 | self.nbins_ce = 51 27 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/experiments/uav123.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import os 4 | import numpy as np 5 | 6 | from .otb import ExperimentOTB 7 | from ..datasets import UAV123 8 | from ..utils.metrics import rect_iou, center_error 9 | 10 | 11 | class ExperimentUAV123(ExperimentOTB): 12 | r"""Experiment pipeline and evaluation toolkit for UAV123 dataset. 13 | 14 | Args: 15 | root_dir (string): Root directory of UAV123 dataset. 16 | result_dir (string, optional): Directory for storing tracking 17 | results. Default is ``./results``. 18 | report_dir (string, optional): Directory for storing performance 19 | evaluation results. Default is ``./reports``. 20 | """ 21 | def __init__(self, 22 | root_dir, 23 | version='UAV123', 24 | result_dir='results', 25 | report_dir='reports'): 26 | assert version.upper() in ['UAV123', 'UAV20L'] 27 | self.dataset = UAV123(root_dir, version) 28 | self.result_dir = os.path.join(result_dir, version.upper()) 29 | self.report_dir = os.path.join(report_dir, version.upper()) 30 | # as nbins_iou increases, the success score 31 | # converges to the average overlap (AO) 32 | self.nbins_iou = 21 33 | self.nbins_ce = 51 34 | 35 | def _calc_metrics(self, boxes, anno): 36 | valid = ~np.any(np.isnan(anno), axis=1) 37 | if len(valid) == 0: 38 | print('Warning: no valid annotations') 39 | return None, None 40 | else: 41 | ious = rect_iou(boxes[valid, :], anno[valid, :]) 42 | center_errors = center_error(boxes[valid, :], anno[valid, :]) 43 | return ious, center_errors 44 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/trackers/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import time 4 | 5 | import numpy as np 6 | from PIL import Image 7 | 8 | from ..utils.viz import show_frame 9 | 10 | 11 | class Tracker(object): 12 | def __init__(self, name, is_deterministic=False): 13 | self.name = name 14 | self.is_deterministic = is_deterministic 15 | 16 | def init(self, image, box): 17 | raise NotImplementedError() 18 | 19 | def update(self, image): 20 | raise NotImplementedError() 21 | 22 | def track(self, img_files, box, visualize=False): 23 | frame_num = len(img_files) 24 | boxes = np.zeros((frame_num, 4)) 25 | boxes[0] = box 26 | times = np.zeros(frame_num) 27 | 28 | for f, img_file in enumerate(img_files): 29 | image = Image.open(img_file) 30 | if not image.mode == 'RGB': 31 | image = image.convert('RGB') 32 | 33 | start_time = time.time() 34 | if f == 0: 35 | self.init(image, box) 36 | else: 37 | boxes[f, :] = self.update(image) 38 | times[f] = time.time() - start_time 39 | 40 | if visualize: 41 | show_frame(image, boxes[f, :]) 42 | 43 | return boxes, times 44 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/trackers/identity_tracker.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from . import Tracker 4 | 5 | 6 | class IdentityTracker(Tracker): 7 | def __init__(self): 8 | super(IdentityTracker, self).__init__(name='IdentityTracker', 9 | is_deterministic=True) 10 | 11 | def init(self, image, box): 12 | self.box = box 13 | 14 | def update(self, image): 15 | return self.box 16 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/utils/__init__.py -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/utils/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/utils/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/utils/__pycache__/ioutils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/utils/__pycache__/ioutils.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/utils/__pycache__/metrics.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/utils/__pycache__/metrics.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/utils/__pycache__/viz.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/got_benchmark/utils/__pycache__/viz.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/got_benchmark/utils/ioutils.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, division 2 | 3 | import os 4 | import shutil 5 | import zipfile 6 | 7 | import wget 8 | 9 | 10 | def download(url, filename): 11 | r"""Download file from the internet. 12 | 13 | Args: 14 | url (string): URL of the internet file. 15 | filename (string): Path to store the downloaded file. 16 | """ 17 | return wget.download(url, out=filename) 18 | 19 | 20 | def extract(filename, extract_dir): 21 | r"""Extract zip file. 22 | 23 | Args: 24 | filename (string): Path of the zip file. 25 | extract_dir (string): Directory to store the extracted results. 26 | """ 27 | if os.path.splitext(filename)[1] == '.zip': 28 | if not os.path.isdir(extract_dir): 29 | os.makedirs(extract_dir) 30 | with zipfile.ZipFile(filename) as z: 31 | z.extractall(extract_dir) 32 | else: 33 | raise Exception( 34 | 'Unsupport extension {} of the compressed file {}.'.format( 35 | os.path.splitext(filename)[1]), filename) 36 | 37 | 38 | def compress(dirname, save_file): 39 | """Compress a folder to a zip file. 40 | 41 | Arguments: 42 | dirname {string} -- Directory of all files to be compressed. 43 | save_file {string} -- Path to store the zip file. 44 | """ 45 | shutil.make_archive(save_file, 'zip', dirname) 46 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/__init__.py: -------------------------------------------------------------------------------- 1 | from .bbox_helper import cxy_wh_2_rect, get_axis_aligned_bbox 2 | from .benchmark_helper import get_img, load_dataset 3 | from .pysot.datasets import VOTDataset, VOTLTDataset 4 | 5 | 6 | def show_result(self, result, topk=10, result_file=None): 7 | """pretty result_file.write result 8 | Args: 9 | result: returned dict from function eval 10 | """ 11 | if len(self.tags) == 1: 12 | tracker_name_len = max((max([len(x) for x in result.keys()]) + 2), 12) 13 | header = ("|{:^" + str(tracker_name_len) + "}|{:^10}|").format( 14 | 'Tracker Name', 'EAO') 15 | bar = '-' * len(header) 16 | formatter = "|{:^20}|{:^10.3f}|" 17 | result_file.write(bar + '\n') 18 | result_file.write(header + '\n') 19 | result_file.write(bar + '\n') 20 | tracker_eao = sorted(result.items(), 21 | key=lambda x: x[1]['all'], 22 | reverse=True)[:topk] 23 | for tracker_name, eao in tracker_eao: 24 | result_file.write(formatter.format(tracker_name, eao) + '\n') 25 | result_file.write(bar + '\n') 26 | else: 27 | header = "|{:^20}|".format('Tracker Name') 28 | header += "{:^7}|{:^15}|{:^14}|{:^15}|{:^13}|{:^11}|{:^7}|".format( 29 | *self.tags) 30 | bar = '-' * len(header) 31 | formatter = "{:^7.3f}|{:^15.3f}|{:^14.3f}|{:^15.3f}|{:^13.3f}|{:^11.3f}|{:^7.3f}|" 32 | result_file.write(bar + '\n') 33 | result_file.write(header + '\n') 34 | result_file.write(bar + '\n') 35 | sorted_tacker = sorted(result.items(), 36 | key=lambda x: x[1]['all'], 37 | reverse=True)[:topk] 38 | sorted_tacker = [x[0] for x in sorted_tacker] 39 | for tracker_name in sorted_tacker: 40 | result_file.write( 41 | "|{:^20}|".format(tracker_name) + 42 | formatter.format(*[result[tracker_name][x] 43 | for x in self.tags]) + '\n') 44 | result_file.write(bar + '\n') 45 | 46 | 47 | __all__ = [ 48 | cxy_wh_2_rect, get_axis_aligned_bbox, get_img, load_dataset, VOTDataset, 49 | VOTLTDataset, show_result 50 | ] 51 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/vot_benchmark/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/__pycache__/bbox_helper.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/vot_benchmark/__pycache__/bbox_helper.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/__pycache__/benchmark_helper.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/vot_benchmark/__pycache__/benchmark_helper.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/make.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd pysot/utils/ 4 | python3 setup.py clean 5 | python3 setup.py build_ext --inplace 6 | cd ../../ 7 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/pysot/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/vot_benchmark/pysot/__init__.py -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/pysot/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/vot_benchmark/pysot/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/pysot/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------- 2 | # Python Single Object Tracking Evaluation 3 | # Licensed under The MIT License [see LICENSE for details] 4 | # Written by Fangyi Zhang 5 | # @author fangyi.zhang@vipl.ict.ac.cn 6 | # @project https://github.com/StrangerZhang/pysot-toolkit.git 7 | # Revised for SiamMask by foolwood 8 | # -------------------------------------------------------- 9 | from .vot import VOTDataset, VOTLTDataset 10 | 11 | 12 | class DatasetFactory(object): 13 | @staticmethod 14 | def create_dataset(**kwargs): 15 | """ 16 | Args: 17 | name: dataset name 'VOT2018', 'VOT2016' 18 | dataset_root: dataset root 19 | Return: 20 | dataset 21 | """ 22 | assert 'name' in kwargs, "should provide dataset name" 23 | name = kwargs['name'] 24 | if 'VOT2018' == name or 'VOT2016' == name or 'VOT2019' == name: 25 | dataset = VOTDataset(**kwargs) 26 | else: 27 | raise Exception("unknow dataset {}".format(kwargs['name'])) 28 | return dataset 29 | 30 | 31 | __all__ = [VOTDataset, VOTLTDataset, DatasetFactory] 32 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/pysot/datasets/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/vot_benchmark/pysot/datasets/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/pysot/datasets/__pycache__/dataset.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/vot_benchmark/pysot/datasets/__pycache__/dataset.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/pysot/datasets/__pycache__/video.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/vot_benchmark/pysot/datasets/__pycache__/video.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/pysot/datasets/__pycache__/vot.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/evaluation/vot_benchmark/pysot/datasets/__pycache__/vot.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/pysot/datasets/dataset.py: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------- 2 | # Python Single Object Tracking Evaluation 3 | # Licensed under The MIT License [see LICENSE for details] 4 | # Written by Fangyi Zhang 5 | # @author fangyi.zhang@vipl.ict.ac.cn 6 | # @project https://github.com/StrangerZhang/pysot-toolkit.git 7 | # Revised for SiamMask by foolwood 8 | # -------------------------------------------------------- 9 | class Dataset(object): 10 | def __init__(self, name, dataset_root): 11 | self.name = name 12 | self.dataset_root = dataset_root 13 | self.videos = None 14 | 15 | def __getitem__(self, idx): 16 | if isinstance(idx, str): 17 | return self.videos[idx] 18 | elif isinstance(idx, int): 19 | return self.videos[sorted(list(self.videos.keys()))[idx]] 20 | 21 | def __len__(self): 22 | return len(self.videos) 23 | 24 | def __iter__(self): 25 | keys = sorted(list(self.videos.keys())) 26 | for key in keys: 27 | yield self.videos[key] 28 | 29 | def set_tracker(self, path, tracker_names): 30 | """ 31 | Args: 32 | path: path to tracker results, 33 | tracker_names: list of tracker name 34 | """ 35 | self.tracker_path = path 36 | self.tracker_names = tracker_names 37 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/pysot/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------- 2 | # Python Single Object Tracking Evaluation 3 | # Licensed under The MIT License [see LICENSE for details] 4 | # Written by Fangyi Zhang 5 | # @author fangyi.zhang@vipl.ict.ac.cn 6 | # @project https://github.com/StrangerZhang/pysot-toolkit.git 7 | # Revised for SiamMask by foolwood 8 | # -------------------------------------------------------- 9 | from .ar_benchmark import AccuracyRobustnessBenchmark 10 | from .eao_benchmark import EAOBenchmark 11 | from .f1_benchmark import F1Benchmark 12 | from .ope_benchmark import OPEBenchmark 13 | 14 | __all__ = [AccuracyRobustnessBenchmark, EAOBenchmark, F1Benchmark, OPEBenchmark] 15 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/pysot/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------- 2 | # Python Single Object Tracking Evaluation 3 | # Licensed under The MIT License [see LICENSE for details] 4 | # Written by Fangyi Zhang 5 | # @author fangyi.zhang@vipl.ict.ac.cn 6 | # @project https://github.com/StrangerZhang/pysot-toolkit.git 7 | # Revised for SiamMask by foolwood 8 | # -------------------------------------------------------- 9 | from . import region # noqa 10 | from .statistics import * # noqa 11 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/pysot/utils/c_region.pxd: -------------------------------------------------------------------------------- 1 | cdef extern from "src/region.h": 2 | ctypedef enum region_type "RegionType": 3 | EMTPY 4 | SPECIAL 5 | RECTANGEL 6 | POLYGON 7 | MASK 8 | 9 | ctypedef struct region_bounds: 10 | float top 11 | float bottom 12 | float left 13 | float right 14 | 15 | ctypedef struct region_rectangle: 16 | float x 17 | float y 18 | float width 19 | float height 20 | 21 | # ctypedef struct region_mask: 22 | # int x 23 | # int y 24 | # int width 25 | # int height 26 | # char *data 27 | 28 | ctypedef struct region_polygon: 29 | int count 30 | float *x 31 | float *y 32 | 33 | ctypedef union region_container_data: 34 | region_rectangle rectangle 35 | region_polygon polygon 36 | # region_mask mask 37 | int special 38 | 39 | ctypedef struct region_container: 40 | region_type type 41 | region_container_data data 42 | 43 | # ctypedef struct region_overlap: 44 | # float overlap 45 | # float only1 46 | # float only2 47 | 48 | # region_overlap region_compute_overlap(const region_container* ra, const region_container* rb, region_bounds bounds) 49 | 50 | float compute_polygon_overlap(const region_polygon* p1, const region_polygon* p2, float *only1, float *only2, region_bounds bounds) 51 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/pysot/utils/misc.py: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------- 2 | # Python Single Object Tracking Evaluation 3 | # Licensed under The MIT License [see LICENSE for details] 4 | # Written by Fangyi Zhang 5 | # @author fangyi.zhang@vipl.ict.ac.cn 6 | # @project https://github.com/StrangerZhang/pysot-toolkit.git 7 | # Revised for SiamMask by foolwood 8 | # -------------------------------------------------------- 9 | import numpy as np 10 | 11 | 12 | def determine_thresholds(confidence, resolution=100): 13 | """choose threshold according to confidence 14 | 15 | Args: 16 | confidence: list or numpy array or numpy array 17 | reolution: number of threshold to choose 18 | 19 | Restures: 20 | threshold: numpy array 21 | """ 22 | if isinstance(confidence, list): 23 | confidence = np.array(confidence) 24 | confidence = confidence.flatten() 25 | confidence = confidence[~np.isnan(confidence)] 26 | confidence.sort() 27 | 28 | assert len(confidence) > resolution and resolution > 2 29 | 30 | thresholds = np.ones((resolution)) 31 | thresholds[0] = -np.inf 32 | thresholds[-1] = np.inf 33 | delta = np.floor(len(confidence) / (resolution - 2)) 34 | idxs = np.linspace(delta, 35 | len(confidence) - delta, 36 | resolution - 2, 37 | dtype=np.int32) 38 | thresholds[1:-1] = confidence[idxs] 39 | return thresholds 40 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/pysot/utils/setup.py: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------- 2 | # Python Single Object Tracking Evaluation 3 | # Licensed under The MIT License [see LICENSE for details] 4 | # Written by Fangyi Zhang 5 | # @author fangyi.zhang@vipl.ict.ac.cn 6 | # @project https://github.com/StrangerZhang/pysot-toolkit.git 7 | # Revised for SiamMask by foolwood 8 | # -------------------------------------------------------- 9 | from distutils.core import setup 10 | from distutils.extension import Extension 11 | 12 | from Cython.Build import cythonize 13 | 14 | setup(ext_modules=cythonize( 15 | [Extension("region", ["region.pyx", "src/region.c"])]), ) 16 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/vot_list/vot2018/list.txt: -------------------------------------------------------------------------------- 1 | ants1 2 | ants3 3 | bag 4 | ball1 5 | ball2 6 | basketball 7 | birds1 8 | blanket 9 | bmx 10 | bolt1 11 | bolt2 12 | book 13 | butterfly 14 | car1 15 | conduction1 16 | crabs1 17 | crossing 18 | dinosaur 19 | drone_across 20 | drone_flip 21 | drone1 22 | fernando 23 | fish1 24 | fish2 25 | fish3 26 | flamingo1 27 | frisbee 28 | girl 29 | glove 30 | godfather 31 | graduate 32 | gymnastics1 33 | gymnastics2 34 | gymnastics3 35 | hand 36 | handball1 37 | handball2 38 | helicopter 39 | iceskater1 40 | iceskater2 41 | leaves 42 | matrix 43 | motocross1 44 | motocross2 45 | nature 46 | pedestrian1 47 | rabbit 48 | racing 49 | road 50 | shaking 51 | sheep 52 | singer2 53 | singer3 54 | soccer1 55 | soccer2 56 | soldier 57 | tiger 58 | traffic 59 | wiper 60 | zebrafish1 61 | -------------------------------------------------------------------------------- /videoanalyst/evaluation/vot_benchmark/vot_list/vot2019/list.txt: -------------------------------------------------------------------------------- 1 | agility 2 | ants1 3 | ball2 4 | ball3 5 | basketball 6 | birds1 7 | bolt1 8 | book 9 | butterfly 10 | car1 11 | conduction1 12 | crabs1 13 | dinosaur 14 | dribble 15 | drone1 16 | drone_across 17 | drone_flip 18 | fernando 19 | fish1 20 | fish2 21 | flamingo1 22 | frisbee 23 | girl 24 | glove 25 | godfather 26 | graduate 27 | gymnastics1 28 | gymnastics2 29 | gymnastics3 30 | hand 31 | hand2 32 | handball1 33 | handball2 34 | helicopter 35 | iceskater1 36 | iceskater2 37 | lamb 38 | leaves 39 | marathon 40 | matrix 41 | monkey 42 | motocross1 43 | nature 44 | pedestrian1 45 | polo 46 | rabbit 47 | rabbit2 48 | road 49 | rowing 50 | shaking 51 | singer2 52 | singer3 53 | soccer1 54 | soccer2 55 | soldier 56 | surfing 57 | tiger 58 | wheel 59 | wiper 60 | zebrafish1 61 | -------------------------------------------------------------------------------- /videoanalyst/model/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | -------------------------------------------------------------------------------- /videoanalyst/model/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/__pycache__/module_base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/__pycache__/module_base.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/backbone/__init__.py: -------------------------------------------------------------------------------- 1 | from .backbone_impl import * # noqa 2 | -------------------------------------------------------------------------------- /videoanalyst/model/backbone/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/backbone/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/backbone/__pycache__/backbone_base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/backbone/__pycache__/backbone_base.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/backbone/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/backbone/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/backbone/backbone_base.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from videoanalyst.utils import Registry 3 | 4 | TRACK_BACKBONES = Registry('TRACK_BACKBONES') 5 | VOS_BACKBONES = Registry('VOS_BACKBONES') 6 | 7 | TASK_BACKBONES = dict( 8 | track=TRACK_BACKBONES, 9 | vos=VOS_BACKBONES, 10 | ) 11 | -------------------------------------------------------------------------------- /videoanalyst/model/backbone/backbone_impl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import glob 3 | from os.path import basename, dirname, isfile 4 | 5 | modules = glob.glob(dirname(__file__) + "/*.py") 6 | modules = [m for m in modules if not m.endswith(('_bak.py')) 7 | ] # filter file with name ending with '_bak' (debugging) 8 | __all__ = [ 9 | basename(f)[:-3] for f in modules if isfile(f) 10 | and not f.endswith("__init__.py") and not f.endswith("utils.py") 11 | ] 12 | -------------------------------------------------------------------------------- /videoanalyst/model/backbone/backbone_impl/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/backbone/backbone_impl/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/backbone/backbone_impl/__pycache__/alexnet_bn.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/backbone/backbone_impl/__pycache__/alexnet_bn.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/backbone/backbone_impl/__pycache__/googlenet.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/backbone/backbone_impl/__pycache__/googlenet.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/backbone/backbone_impl/__pycache__/googlenet_m.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/backbone/backbone_impl/__pycache__/googlenet_m.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/backbone/backbone_impl/__pycache__/googlenet_q.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/backbone/backbone_impl/__pycache__/googlenet_q.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/backbone/backbone_impl/__pycache__/resnet.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/backbone/backbone_impl/__pycache__/resnet.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/backbone/backbone_impl/__pycache__/shufflenet_v2.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/backbone/backbone_impl/__pycache__/shufflenet_v2.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/backbone/backbone_impl/__pycache__/tinyconv.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/backbone/backbone_impl/__pycache__/tinyconv.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/backbone/backbone_impl/alexnet_bn.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | 3 | import torch.nn as nn 4 | 5 | from videoanalyst.model.backbone.backbone_base import (TRACK_BACKBONES, 6 | VOS_BACKBONES) 7 | from videoanalyst.model.common_opr.common_block import conv_bn_relu 8 | from videoanalyst.model.module_base import ModuleBase 9 | 10 | 11 | @VOS_BACKBONES.register 12 | @TRACK_BACKBONES.register 13 | class AlexNet(ModuleBase): 14 | r""" 15 | AlexNet 16 | 17 | Hyper-parameters 18 | ---------------- 19 | pretrain_model_path: string 20 | Path to pretrained backbone parameter file, 21 | Parameter to be loaded in _update_params_ 22 | """ 23 | default_hyper_params = {"pretrain_model_path": ""} 24 | 25 | def __init__(self): 26 | super(AlexNet, self).__init__() 27 | self.conv1 = conv_bn_relu(3, 96, stride=2, kszie=11, pad=0) 28 | self.pool1 = nn.MaxPool2d(3, 2, 0, ceil_mode=True) 29 | self.conv2 = conv_bn_relu(96, 256, 1, 5, 0) 30 | self.pool2 = nn.MaxPool2d(3, 2, 0, ceil_mode=True) 31 | self.conv3 = conv_bn_relu(256, 384, 1, 3, 0) 32 | self.conv4 = conv_bn_relu(384, 384, 1, 3, 0) 33 | self.conv5 = conv_bn_relu(384, 256, 1, 3, 0, has_relu=False) 34 | 35 | def forward(self, x): 36 | x = self.conv1(x) 37 | x = self.pool1(x) 38 | x = self.conv2(x) 39 | x = self.pool2(x) 40 | x = self.conv3(x) 41 | x = self.conv4(x) 42 | x = self.conv5(x) 43 | return x 44 | -------------------------------------------------------------------------------- /videoanalyst/model/backbone/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from typing import Dict, List 3 | 4 | from loguru import logger 5 | from yacs.config import CfgNode 6 | 7 | from videoanalyst.utils import merge_cfg_into_hps 8 | 9 | from .backbone_base import TASK_BACKBONES 10 | 11 | 12 | def build(task: str, cfg: CfgNode, basemodel=None): 13 | r""" 14 | Builder function. 15 | 16 | Arguments 17 | --------- 18 | task: str 19 | builder task name (track|vos) 20 | cfg: CfgNode 21 | buidler configuration 22 | 23 | basemodel: 24 | warp backbone into encoder if not None 25 | 26 | Returns 27 | ------- 28 | torch.nn.Module 29 | module built by builder 30 | """ 31 | if task in TASK_BACKBONES: 32 | modules = TASK_BACKBONES[task] 33 | else: 34 | logger.error("no backbone for task {}".format(task)) 35 | exit(-1) 36 | 37 | name = cfg.name 38 | assert name in modules, "backbone {} not registered for {}!".format( 39 | name, task) 40 | 41 | if basemodel: 42 | module = modules[name](basemodel) 43 | else: 44 | module = modules[name]() 45 | 46 | hps = module.get_hps() 47 | hps = merge_cfg_into_hps(cfg[name], hps) 48 | module.set_hps(hps) 49 | module.update_params() 50 | return module 51 | 52 | 53 | def get_config(task_list: List) -> Dict[str, CfgNode]: 54 | r""" 55 | Get available component list config 56 | 57 | Returns 58 | ------- 59 | Dict[str, CfgNode] 60 | config with list of available components 61 | """ 62 | cfg_dict = {task: CfgNode() for task in task_list} 63 | for cfg_name, module in TASK_BACKBONES.items(): 64 | cfg = cfg_dict[cfg_name] 65 | cfg["name"] = "unknown" 66 | for name in module: 67 | cfg[name] = CfgNode() 68 | backbone = module[name] 69 | hps = backbone.default_hyper_params 70 | for hp_name in hps: 71 | cfg[name][hp_name] = hps[hp_name] 72 | return cfg_dict 73 | -------------------------------------------------------------------------------- /videoanalyst/model/common_opr/__pycache__/common_block.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/common_opr/__pycache__/common_block.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/common_opr/__pycache__/common_loss.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/common_opr/__pycache__/common_loss.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/loss/__init__.py: -------------------------------------------------------------------------------- 1 | from .loss_impl import * # noqa 2 | -------------------------------------------------------------------------------- /videoanalyst/model/loss/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/loss/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/loss/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/loss/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/loss/__pycache__/loss_base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/loss/__pycache__/loss_base.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/loss/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from collections import OrderedDict 3 | from typing import Dict, List 4 | 5 | from loguru import logger 6 | from yacs.config import CfgNode 7 | 8 | from videoanalyst.model.loss.loss_base import TASK_LOSSES 9 | from videoanalyst.utils.misc import merge_cfg_into_hps 10 | 11 | 12 | def build(task: str, cfg: CfgNode): 13 | if task in TASK_LOSSES: 14 | MODULES = TASK_LOSSES[task] 15 | else: 16 | logger.error("no loss for task {}".format(task)) 17 | exit(-1) 18 | 19 | names = cfg.names 20 | loss_dict = OrderedDict() 21 | for name in names: 22 | assert name in MODULES, "loss {} not registered for {}!".format( 23 | name, task) 24 | module = MODULES[name]() 25 | hps = module.get_hps() 26 | hps = merge_cfg_into_hps(cfg[name], hps) 27 | module.set_hps(hps) 28 | module.update_params() 29 | loss_dict[cfg[name].name] = module 30 | 31 | return loss_dict 32 | 33 | 34 | def get_config(task_list: List) -> Dict[str, CfgNode]: 35 | cfg_dict = {name: CfgNode() for name in task_list} 36 | 37 | for cfg_name, modules in TASK_LOSSES.items(): 38 | cfg = cfg_dict[cfg_name] 39 | cfg["names"] = list() 40 | for name in modules: 41 | cfg[name] = CfgNode() 42 | backbone = modules[name] 43 | hps = backbone.default_hyper_params 44 | for hp_name in hps: 45 | cfg[name][hp_name] = hps[hp_name] 46 | return cfg_dict 47 | -------------------------------------------------------------------------------- /videoanalyst/model/loss/loss_base.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from videoanalyst.utils import Registry 3 | 4 | TRACK_LOSSES = Registry('TRACK_LOSSES') 5 | VOS_LOSSES = Registry('VOS_LOSSES') 6 | 7 | TASK_LOSSES = dict( 8 | track=TRACK_LOSSES, 9 | vos=VOS_LOSSES, 10 | ) 11 | -------------------------------------------------------------------------------- /videoanalyst/model/loss/loss_impl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import glob 3 | from os.path import basename, dirname, isfile 4 | 5 | modules = glob.glob(dirname(__file__) + "/*.py") 6 | modules = [m for m in modules if not m.endswith(('_bak.py')) 7 | ] # filter file with name ending with '_bak' (debugging) 8 | __all__ = [ 9 | basename(f)[:-3] for f in modules if isfile(f) 10 | and not f.endswith("__init__.py") and not f.endswith("utils.py") 11 | ] 12 | -------------------------------------------------------------------------------- /videoanalyst/model/loss/loss_impl/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/loss/loss_impl/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/loss/loss_impl/__pycache__/focal_loss.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/loss/loss_impl/__pycache__/focal_loss.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/loss/loss_impl/__pycache__/iou_loss.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/loss/loss_impl/__pycache__/iou_loss.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/loss/loss_impl/__pycache__/multi_bceloss.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/loss/loss_impl/__pycache__/multi_bceloss.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/loss/loss_impl/__pycache__/sigmoid_ce_centerness.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/loss/loss_impl/__pycache__/sigmoid_ce_centerness.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/loss/loss_impl/__pycache__/sigmoid_ce_retina.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/loss/loss_impl/__pycache__/sigmoid_ce_retina.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/loss/loss_impl/__pycache__/utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/loss/loss_impl/__pycache__/utils.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/loss/loss_impl/multi_bceloss.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | import numpy as np 3 | 4 | import torch.nn.functional as F 5 | 6 | from ...module_base import ModuleBase 7 | from ..loss_base import VOS_LOSSES 8 | 9 | eps = np.finfo(np.float32).tiny 10 | 11 | 12 | @VOS_LOSSES.register 13 | class MultiBCELoss(ModuleBase): 14 | 15 | default_hyper_params = dict( 16 | name="multi_bceloss", 17 | sub_loss_weights=[0.1, 0.3, 1.0], 18 | weight=1.0, 19 | top_ratio=0.0, 20 | ) 21 | 22 | def __init__(self): 23 | super(MultiBCELoss, self).__init__() 24 | 25 | def update_params(self, ): 26 | self.sub_loss_weights = self._hyper_params["sub_loss_weights"] 27 | self.weight = self._hyper_params["weight"] 28 | 29 | def forward(self, pred_data_list, target_data): 30 | total_loss = 0 31 | assert len(pred_data_list) == len(self.sub_loss_weights) 32 | for pred_data, sub_loss_weight in zip(pred_data_list, 33 | self.sub_loss_weights): 34 | loss = F.binary_cross_entropy_with_logits(pred_data.flatten(), 35 | target_data.flatten(), 36 | reduction="none") 37 | if self._hyper_params["top_ratio"] > 0 and self._hyper_params[ 38 | "top_ratio"] < 1.0: 39 | loss, _ = loss.topk( 40 | int(loss.numel() * self._hyper_params["top_ratio"])) 41 | loss = loss.mean() * sub_loss_weight 42 | total_loss += loss 43 | extra = dict() 44 | return total_loss * self.weight, extra 45 | -------------------------------------------------------------------------------- /videoanalyst/model/loss/loss_impl/utils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | import numpy as np 3 | 4 | import torch 5 | 6 | from ...module_base import ModuleBase 7 | 8 | eps = np.finfo(np.float32).tiny 9 | 10 | 11 | class SafeLog(ModuleBase): 12 | r""" 13 | Safly perform log operation 14 | """ 15 | default_hyper_params = dict() 16 | 17 | def __init__(self): 18 | super(SafeLog, self).__init__() 19 | self.register_buffer("t_eps", torch.tensor(eps, requires_grad=False)) 20 | # self.t_eps = self.t_eps.cuda() 21 | 22 | def forward(self, t): 23 | return torch.log(torch.max(self.t_eps.cuda(), t)) 24 | -------------------------------------------------------------------------------- /videoanalyst/model/neck/__init__.py: -------------------------------------------------------------------------------- 1 | from .neck_impl import * -------------------------------------------------------------------------------- /videoanalyst/model/neck/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/neck/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/neck/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/neck/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/neck/__pycache__/neck_base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/neck/__pycache__/neck_base.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/neck/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from typing import Dict, List 3 | 4 | from loguru import logger 5 | from yacs.config import CfgNode 6 | 7 | from videoanalyst.model.module_base import ModuleBase 8 | from videoanalyst.model.neck.neck_base import TASK_NECKS 9 | from videoanalyst.utils import merge_cfg_into_hps 10 | 11 | 12 | def build(task: str, cfg: CfgNode): 13 | r""" 14 | Builder function. 15 | 16 | Arguments 17 | --------- 18 | task: str 19 | builder task name (track|vos) 20 | cfg: CfgNode 21 | buidler configuration 22 | 23 | Returns 24 | ------- 25 | torch.nn.Module 26 | module built by builder 27 | """ 28 | if task in TASK_NECKS: 29 | neck_modules = TASK_NECKS[task] 30 | else: 31 | logger.error("no task model for task {}".format(task)) 32 | exit(-1) 33 | 34 | name = cfg.name 35 | neck_module = neck_modules[name]() 36 | hps = neck_module.get_hps() 37 | hps = merge_cfg_into_hps(cfg[name], hps) 38 | neck_module.set_hps(hps) 39 | neck_module.update_params() 40 | 41 | return neck_module 42 | 43 | 44 | def get_config(task_list: List) -> Dict[str, CfgNode]: 45 | r""" 46 | Get available component list config 47 | 48 | Returns 49 | ------- 50 | Dict[str, CfgNode] 51 | config with list of available components 52 | """ 53 | cfg_dict = {task: CfgNode() for task in task_list} 54 | for cfg_name, module in TASK_NECKS.items(): 55 | cfg = cfg_dict[cfg_name] 56 | cfg["name"] = "unknown" 57 | for name in module: 58 | cfg[name] = CfgNode() 59 | task_model = module[name] 60 | hps = task_model.default_hyper_params 61 | for hp_name in hps: 62 | cfg[name][hp_name] = hps[hp_name] 63 | return cfg_dict 64 | -------------------------------------------------------------------------------- /videoanalyst/model/neck/neck_base.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from videoanalyst.utils import Registry 3 | 4 | TRACK_NECKS = Registry('TRACK_NECKS') 5 | TASK_NECKS = dict( 6 | track=TRACK_NECKS, 7 | ) 8 | -------------------------------------------------------------------------------- /videoanalyst/model/neck/neck_impl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import glob 3 | from os.path import basename, dirname, isfile 4 | 5 | modules = glob.glob(dirname(__file__) + "/*.py") 6 | modules = [m for m in modules if not m.endswith(('_bak.py')) 7 | ] # filter file with name ending with '_bak' (debugging) 8 | __all__ = [ 9 | basename(f)[:-3] for f in modules if isfile(f) 10 | and not f.endswith("__init__.py") and not f.endswith("utils.py") 11 | ] 12 | -------------------------------------------------------------------------------- /videoanalyst/model/neck/neck_impl/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/neck/neck_impl/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/neck/neck_impl/__pycache__/adjust_layer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/neck/neck_impl/__pycache__/adjust_layer.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/neck/neck_impl/adjust_layer.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | 4 | from videoanalyst.model.module_base import ModuleBase 5 | from videoanalyst.model.neck.neck_base import TRACK_NECKS 6 | 7 | 8 | @TRACK_NECKS.register 9 | class AdjustLayer(ModuleBase): 10 | default_hyper_params = dict( 11 | in_channels=768, 12 | out_channels=512, 13 | ) 14 | 15 | def __init__(self): 16 | super(AdjustLayer, self).__init__() 17 | 18 | def forward(self, x): 19 | return self.adjustor(x) 20 | 21 | def update_params(self): 22 | super().update_params() 23 | in_channels = self._hyper_params['in_channels'] 24 | out_channels = self._hyper_params['out_channels'] 25 | self.adjustor = nn.Conv2d(in_channels, out_channels, 3, 1, 1) 26 | self._init_weights() 27 | 28 | def _init_weights(self): 29 | conv_weight_std = 0.01 30 | for m in [self.adjustor, ]: 31 | if isinstance(m, nn.Conv2d): 32 | torch.nn.init.normal_(m.weight, std=conv_weight_std) # conv_weight_std=0.01 33 | 34 | -------------------------------------------------------------------------------- /videoanalyst/model/sync_batchnorm/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # File : __init__.py 3 | # Author : Jiayuan Mao 4 | # Email : maojiayuan@gmail.com 5 | # Date : 27/01/2018 6 | # 7 | # This file is part of Synchronized-BatchNorm-PyTorch. 8 | # https://github.com/vacancy/Synchronized-BatchNorm-PyTorch 9 | # Distributed under MIT License. 10 | 11 | from .batchnorm import SynchronizedBatchNorm1d, SynchronizedBatchNorm2d, SynchronizedBatchNorm3d 12 | from .batchnorm import patch_sync_batchnorm, convert_model 13 | from .replicate import DataParallelWithCallback, patch_replication_callback 14 | -------------------------------------------------------------------------------- /videoanalyst/model/sync_batchnorm/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/sync_batchnorm/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/sync_batchnorm/__pycache__/batchnorm.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/sync_batchnorm/__pycache__/batchnorm.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/sync_batchnorm/__pycache__/comm.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/sync_batchnorm/__pycache__/comm.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/sync_batchnorm/__pycache__/replicate.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/sync_batchnorm/__pycache__/replicate.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/sync_batchnorm/unittest.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # File : unittest.py 3 | # Author : Jiayuan Mao 4 | # Email : maojiayuan@gmail.com 5 | # Date : 27/01/2018 6 | # 7 | # This file is part of Synchronized-BatchNorm-PyTorch. 8 | # https://github.com/vacancy/Synchronized-BatchNorm-PyTorch 9 | # Distributed under MIT License. 10 | 11 | import unittest 12 | import torch 13 | 14 | 15 | class TorchTestCase(unittest.TestCase): 16 | def assertTensorClose(self, x, y): 17 | adiff = float((x - y).abs().max()) 18 | if (y == 0).all(): 19 | rdiff = 'NaN' 20 | else: 21 | rdiff = float((adiff / y).abs().max()) 22 | 23 | message = ( 24 | 'Tensor close check failed\n' 25 | 'adiff={}\n' 26 | 'rdiff={}\n' 27 | ).format(adiff, rdiff) 28 | self.assertTrue(torch.allclose(x, y), message) 29 | 30 | -------------------------------------------------------------------------------- /videoanalyst/model/task_head/__init__.py: -------------------------------------------------------------------------------- 1 | from .taskhead_impl import * # noqa 2 | -------------------------------------------------------------------------------- /videoanalyst/model/task_head/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/task_head/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/task_head/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/task_head/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/task_head/__pycache__/taskhead_base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/task_head/__pycache__/taskhead_base.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/task_head/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from typing import Dict, List 3 | 4 | from loguru import logger 5 | from yacs.config import CfgNode 6 | 7 | from videoanalyst.model.task_head.taskhead_base import TASK_HEADS 8 | from videoanalyst.utils import merge_cfg_into_hps 9 | 10 | 11 | def build(task: str, cfg: CfgNode): 12 | r""" 13 | Builder function. 14 | 15 | Arguments 16 | --------- 17 | task: str 18 | builder task name (track|vos) 19 | cfg: CfgNode 20 | buidler configuration 21 | 22 | Returns 23 | ------- 24 | torch.nn.Module 25 | module built by builder 26 | """ 27 | if task in TASK_HEADS: 28 | head_modules = TASK_HEADS[task] 29 | else: 30 | logger.error("no task model for task {}".format(task)) 31 | exit(-1) 32 | 33 | name = cfg.name 34 | head_module = head_modules[name]() 35 | hps = head_module.get_hps() 36 | hps = merge_cfg_into_hps(cfg[name], hps) 37 | head_module.set_hps(hps) 38 | head_module.update_params() 39 | 40 | return head_module 41 | 42 | 43 | def get_config(task_list: List) -> Dict[str, CfgNode]: 44 | r""" 45 | Get available component list config 46 | 47 | Returns 48 | ------- 49 | Dict[str, CfgNode] 50 | config with list of available components 51 | """ 52 | cfg_dict = {task: CfgNode() for task in task_list} 53 | for cfg_name, module in TASK_HEADS.items(): 54 | cfg = cfg_dict[cfg_name] 55 | cfg["name"] = "unknown" 56 | for name in module: 57 | cfg[name] = CfgNode() 58 | task_model = module[name] 59 | hps = task_model.default_hyper_params 60 | for hp_name in hps: 61 | cfg[name][hp_name] = hps[hp_name] 62 | return cfg_dict 63 | -------------------------------------------------------------------------------- /videoanalyst/model/task_head/taskhead_base.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from videoanalyst.utils import Registry 3 | 4 | TRACK_HEADS = Registry('TRACK_HEADS') 5 | VOS_HEADS = Registry('VOS_HEADS') 6 | TASK_HEADS = dict( 7 | track=TRACK_HEADS, 8 | vos=VOS_HEADS, 9 | ) 10 | -------------------------------------------------------------------------------- /videoanalyst/model/task_head/taskhead_impl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import glob 3 | from os.path import basename, dirname, isfile 4 | 5 | modules = glob.glob(dirname(__file__) + "/*.py") 6 | modules = [m for m in modules if not m.endswith(('_bak.py')) 7 | ] # filter file with name ending with '_bak' (debugging) 8 | __all__ = [ 9 | basename(f)[:-3] for f in modules if isfile(f) 10 | and not f.endswith("__init__.py") and not f.endswith("utils.py") 11 | ] 12 | -------------------------------------------------------------------------------- /videoanalyst/model/task_head/taskhead_impl/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/task_head/taskhead_impl/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/task_head/taskhead_impl/__pycache__/stm_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/task_head/taskhead_impl/__pycache__/stm_head.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/task_model/__init__.py: -------------------------------------------------------------------------------- 1 | from .taskmodel_impl import * # noqa 2 | -------------------------------------------------------------------------------- /videoanalyst/model/task_model/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/task_model/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/task_model/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/task_model/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/task_model/__pycache__/taskmodel_base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/task_model/__pycache__/taskmodel_base.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/task_model/taskmodel_base.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from videoanalyst.utils import Registry 3 | 4 | TRACK_TASKMODELS = Registry('TRACK_TASKMODELS') 5 | VOS_TASKMODELS = Registry('VOS_TASKMODELS') 6 | 7 | TASK_TASKMODELS = dict( 8 | track=TRACK_TASKMODELS, 9 | vos=VOS_TASKMODELS, 10 | ) 11 | -------------------------------------------------------------------------------- /videoanalyst/model/task_model/taskmodel_impl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import glob 3 | from os.path import basename, dirname, isfile 4 | 5 | modules = glob.glob(dirname(__file__) + "/*.py") 6 | modules = [m for m in modules if not m.endswith(('_bak.py')) 7 | ] # filter file with name ending with '_bak' (debugging) 8 | __all__ = [ 9 | basename(f)[:-3] for f in modules if isfile(f) 10 | and not f.endswith("__init__.py") and not f.endswith("utils.py") 11 | ] 12 | -------------------------------------------------------------------------------- /videoanalyst/model/task_model/taskmodel_impl/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/task_model/taskmodel_impl/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/task_model/taskmodel_impl/__pycache__/stmtrack_model.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/task_model/taskmodel_impl/__pycache__/stmtrack_model.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/utils/__pycache__/TransformerModel.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/utils/__pycache__/TransformerModel.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/utils/__pycache__/load_state.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/utils/__pycache__/load_state.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/model/utils/__pycache__/transformer_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/model/utils/__pycache__/transformer_utils.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/optim/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/__init__.py -------------------------------------------------------------------------------- /videoanalyst/optim/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/optim/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/optim/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | 3 | from yacs.config import CfgNode 4 | 5 | from torch import nn 6 | 7 | from .grad_modifier import builder as grad_modifier_builder 8 | from .optimizer import builder as optimizer_builder 9 | 10 | 11 | def build( 12 | task: str, 13 | cfg: CfgNode, 14 | model: nn.Module, 15 | ): 16 | r""" 17 | Builder function. 18 | 19 | Arguments 20 | --------- 21 | task: str 22 | builder task name (track|vos) 23 | cfg: CfgNode 24 | node name: model 25 | 26 | Returns 27 | ------- 28 | torch.nn.Module 29 | module built by builder 30 | """ 31 | optimizer = optimizer_builder.build(task, cfg.optimizer, model) 32 | if ("grad_modifier" in cfg) and (cfg.grad_modifier.name != ""): 33 | grad_modifier = grad_modifier_builder.build(task, cfg.grad_modifier) 34 | optimizer.set_grad_modifier(grad_modifier) 35 | 36 | return optimizer 37 | 38 | 39 | def get_config() -> CfgNode: 40 | r""" 41 | Get available component list config 42 | 43 | Returns 44 | ------- 45 | CfgNode 46 | config with list of available components 47 | """ 48 | cfg = CfgNode() 49 | cfg["optimizer"] = optimizer_builder.get_config() 50 | cfg["grad_modifier"] = grad_modifier_builder.get_config() 51 | 52 | return cfg 53 | -------------------------------------------------------------------------------- /videoanalyst/optim/grad_modifier/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from .grad_modifier_impl import * # noqa 3 | -------------------------------------------------------------------------------- /videoanalyst/optim/grad_modifier/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/grad_modifier/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/optim/grad_modifier/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/grad_modifier/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/optim/grad_modifier/__pycache__/grad_modifier_base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/grad_modifier/__pycache__/grad_modifier_base.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/optim/grad_modifier/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from yacs.config import CfgNode 4 | 5 | from videoanalyst.utils import merge_cfg_into_hps 6 | 7 | from .grad_modifier_base import GRAD_MODIFIERS, GradModifierBase 8 | 9 | 10 | def build(task: str, cfg: CfgNode) -> GradModifierBase: 11 | r""" 12 | Arguments 13 | --------- 14 | task: str 15 | task name (track|vos) 16 | cfg: CfgNode 17 | node name: scheduler 18 | seed: int 19 | seed for rng initialization 20 | """ 21 | 22 | name = cfg.name 23 | module = GRAD_MODIFIERS[name]() 24 | 25 | hps = module.get_hps() 26 | hps = merge_cfg_into_hps(cfg[name], hps) 27 | module.set_hps(hps) 28 | module.update_params() 29 | 30 | return module 31 | 32 | 33 | def get_config() -> CfgNode: 34 | cfg = CfgNode() 35 | cfg["name"] = "" 36 | 37 | for name, module in GRAD_MODIFIERS.items(): 38 | cfg[name] = CfgNode() 39 | hps = module.default_hyper_params 40 | for hp_name in hps: 41 | cfg[name][hp_name] = hps[hp_name] 42 | return cfg 43 | -------------------------------------------------------------------------------- /videoanalyst/optim/grad_modifier/grad_modifier_impl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import glob 3 | from os.path import basename, dirname, isfile 4 | 5 | modules = glob.glob(dirname(__file__) + "/*.py") 6 | modules = [m for m in modules if not m.endswith(('_bak.py')) 7 | ] # filter file with name ending with '_bak' (debugging) 8 | __all__ = [ 9 | basename(f)[:-3] for f in modules if isfile(f) 10 | and not f.endswith("__init__.py") and not f.endswith("utils.py") 11 | ] 12 | -------------------------------------------------------------------------------- /videoanalyst/optim/grad_modifier/grad_modifier_impl/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/grad_modifier/grad_modifier_impl/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/optim/grad_modifier/grad_modifier_impl/__pycache__/dynamic_freezer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/grad_modifier/grad_modifier_impl/__pycache__/dynamic_freezer.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/optim/grad_modifier/grad_modifier_impl/dynamic_freezer.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import json 3 | import re 4 | 5 | from torch import nn 6 | 7 | from ..grad_modifier_base import GRAD_MODIFIERS, GradModifierBase 8 | from .utils.freeze import apply_freeze_schedule 9 | 10 | 11 | @GRAD_MODIFIERS.register 12 | class DynamicFreezer(GradModifierBase): 13 | r""" 14 | Learning rate scheduler, including: 15 | - learning rate adjusting 16 | - learning rate multiplying 17 | 18 | Hyper-parameters 19 | ---------------- 20 | phases: Dict 21 | 22 | """ 23 | default_hyper_params = dict(schedule=[], ) 24 | 25 | def __init__(self, ) -> None: 26 | super().__init__() 27 | 28 | def update_params(self) -> None: 29 | r""" 30 | Resolve dynamic freezing schedule 31 | """ 32 | cfg = self._hyper_params["schedule"] 33 | if len(cfg) > 0: 34 | schedule = list() 35 | for freeze_str in cfg: 36 | mult_cfg = json.loads(freeze_str) 37 | compiled_regex = re.compile(mult_cfg["regex"]) 38 | mult_cfg["compiled_regex"] = compiled_regex 39 | schedule.append(mult_cfg) 40 | self._state["schedule"] = [] # schedule 41 | 42 | def modify_grad(self, module: nn.Module, epoch: int, iteration: int = -1): 43 | if (iteration < 0) and ("schedule" in self._state): 44 | # epoch-level scheduling 45 | apply_freeze_schedule(module, epoch, self._state["schedule"]) 46 | else: 47 | # iteration-level scheduling 48 | pass 49 | -------------------------------------------------------------------------------- /videoanalyst/optim/grad_modifier/grad_modifier_impl/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/grad_modifier/grad_modifier_impl/utils/__init__.py -------------------------------------------------------------------------------- /videoanalyst/optim/grad_modifier/grad_modifier_impl/utils/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/grad_modifier/grad_modifier_impl/utils/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/optim/grad_modifier/grad_modifier_impl/utils/__pycache__/freeze.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/grad_modifier/grad_modifier_impl/utils/__pycache__/freeze.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/optim/optimizer/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from .optimizer_impl import * # noqa 3 | -------------------------------------------------------------------------------- /videoanalyst/optim/optimizer/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/optimizer/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/optim/optimizer/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/optimizer/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/optim/optimizer/__pycache__/optimizer_base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/optimizer/__pycache__/optimizer_base.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/optim/optimizer/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from yacs.config import CfgNode 4 | 5 | from torch import nn 6 | 7 | from videoanalyst.utils import merge_cfg_into_hps 8 | 9 | from .optimizer_base import OPTIMIZERS, OptimizerBase 10 | 11 | 12 | def build(task: str, cfg: CfgNode, model: nn.Module) -> OptimizerBase: 13 | r""" 14 | Arguments 15 | --------- 16 | task: str 17 | task name (track|vos) 18 | cfg: CfgNode 19 | node name: optim 20 | """ 21 | name = cfg.name 22 | module = OPTIMIZERS[name](cfg, model) 23 | 24 | hps = module.get_hps() 25 | hps = merge_cfg_into_hps(cfg[name], hps) 26 | module.set_hps(hps) 27 | module.update_params() 28 | 29 | return module 30 | 31 | 32 | def get_config() -> CfgNode: 33 | cfg = CfgNode() 34 | cfg["name"] = "" 35 | for name, module in OPTIMIZERS.items(): 36 | cfg[name] = CfgNode() 37 | hps = module.default_hyper_params 38 | for hp_name in hps: 39 | cfg[name][hp_name] = hps[hp_name] 40 | 41 | return cfg 42 | -------------------------------------------------------------------------------- /videoanalyst/optim/optimizer/optimizer_impl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import glob 3 | from os.path import basename, dirname, isfile 4 | 5 | modules = glob.glob(dirname(__file__) + "/*.py") 6 | modules = [m for m in modules if not m.endswith(('_bak.py')) 7 | ] # filter file with name ending with '_bak' (debugging) 8 | __all__ = [ 9 | basename(f)[:-3] for f in modules if isfile(f) 10 | and not f.endswith("__init__.py") and not f.endswith("utils.py") 11 | ] 12 | -------------------------------------------------------------------------------- /videoanalyst/optim/optimizer/optimizer_impl/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/optimizer/optimizer_impl/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/optim/optimizer/optimizer_impl/__pycache__/adam.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/optimizer/optimizer_impl/__pycache__/adam.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/optim/optimizer/optimizer_impl/__pycache__/sgd.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/optimizer/optimizer_impl/__pycache__/sgd.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/optim/optimizer/optimizer_impl/adam.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import numpy as np 4 | from yacs.config import CfgNode 5 | 6 | import torch 7 | from torch import optim 8 | 9 | from videoanalyst.data.dataset.dataset_base import DatasetBase 10 | from videoanalyst.evaluation.got_benchmark.datasets import got10k 11 | 12 | from ..optimizer_base import OPTIMIZERS, OptimizerBase 13 | 14 | 15 | @OPTIMIZERS.register 16 | class Adam(OptimizerBase): 17 | r""" 18 | Tracking data sampler 19 | 20 | Hyper-parameters 21 | ---------------- 22 | """ 23 | extra_hyper_params = dict( 24 | lr=1e-4, 25 | weight_decay=1e-4, 26 | ) 27 | 28 | def __init__(self, cfg: CfgNode, model: torch.nn.Module) -> None: 29 | super(Adam, self).__init__(cfg, model) 30 | 31 | def update_params(self, ): 32 | super(Adam, self).update_params() 33 | params = self._state["params"] 34 | kwargs = self._hyper_params 35 | valid_keys = self.extra_hyper_params.keys() 36 | kwargs = {k: kwargs[k] for k in valid_keys} 37 | self._optimizer = optim.Adam(params, **kwargs) 38 | 39 | 40 | Adam.default_hyper_params.update(Adam.extra_hyper_params) 41 | -------------------------------------------------------------------------------- /videoanalyst/optim/optimizer/optimizer_impl/sgd.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from yacs.config import CfgNode 4 | 5 | import torch 6 | from torch import optim 7 | 8 | from ..optimizer_base import OPTIMIZERS, OptimizerBase 9 | 10 | 11 | @OPTIMIZERS.register 12 | class SGD(OptimizerBase): 13 | r""" 14 | Tracking data sampler 15 | 16 | Hyper-parameters 17 | ---------------- 18 | """ 19 | extra_hyper_params = dict( 20 | lr=0.1, 21 | momentum=0.9, 22 | weight_decay=0.00005, 23 | ) 24 | 25 | def __init__(self, cfg: CfgNode, model: torch.nn.Module) -> None: 26 | super(SGD, self).__init__(cfg, model) 27 | 28 | def update_params(self, ): 29 | super(SGD, self).update_params() 30 | params = self._state["params"] 31 | kwargs = self._hyper_params 32 | valid_keys = self.extra_hyper_params.keys() 33 | kwargs = {k: kwargs[k] for k in valid_keys} 34 | self._optimizer = optim.SGD(params, **kwargs) 35 | 36 | 37 | SGD.default_hyper_params.update(SGD.extra_hyper_params) 38 | -------------------------------------------------------------------------------- /videoanalyst/optim/optimizer/optimizer_impl/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/optimizer/optimizer_impl/utils/__init__.py -------------------------------------------------------------------------------- /videoanalyst/optim/optimizer/optimizer_impl/utils/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/optimizer/optimizer_impl/utils/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/optim/optimizer/optimizer_impl/utils/__pycache__/lr_multiply.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/optimizer/optimizer_impl/utils/__pycache__/lr_multiply.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/optim/optimizer/optimizer_impl/utils/__pycache__/lr_policy.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/optim/optimizer/optimizer_impl/utils/__pycache__/lr_policy.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/pipeline/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from .tracker_impl import * # noqa 3 | -------------------------------------------------------------------------------- /videoanalyst/pipeline/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/pipeline/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/pipeline/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/pipeline/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/pipeline/__pycache__/pipeline_base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/pipeline/__pycache__/pipeline_base.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/pipeline/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from typing import Dict, List 3 | 4 | from loguru import logger 5 | from yacs.config import CfgNode 6 | 7 | from videoanalyst.model.module_base import ModuleBase 8 | from videoanalyst.pipeline.pipeline_base import PIPELINES 9 | from videoanalyst.utils import merge_cfg_into_hps 10 | 11 | 12 | def build( 13 | task: str, 14 | cfg: CfgNode, 15 | model: ModuleBase = None, 16 | segmenter: ModuleBase = None, 17 | tracker: ModuleBase = None, 18 | ): 19 | assert task in PIPELINES, "no pipeline for task {}".format(task) 20 | pipelines = PIPELINES[task] 21 | pipeline_name = cfg.name 22 | 23 | if task == 'track': 24 | pipeline = pipelines[pipeline_name](model) 25 | elif task == 'vos': 26 | pipeline = pipelines[pipeline_name](segmenter, tracker) 27 | else: 28 | logger.error("unknown task {} for pipline".format(task)) 29 | exit(-1) 30 | hps = pipeline.get_hps() 31 | hps = merge_cfg_into_hps(cfg[pipeline_name], hps) 32 | pipeline.set_hps(hps) 33 | pipeline.update_params() 34 | 35 | return pipeline 36 | 37 | 38 | def get_config(task_list: List) -> Dict[str, CfgNode]: 39 | """ 40 | Get available component list config 41 | 42 | Returns 43 | ------- 44 | Dict[str, CfgNode] 45 | config with list of available components 46 | """ 47 | cfg_dict = {name: CfgNode() for name in task_list} 48 | for cfg_name, task_module in PIPELINES.items(): 49 | cfg = cfg_dict[cfg_name] 50 | cfg["name"] = "unknown" 51 | for name in task_module: 52 | cfg[name] = CfgNode() 53 | task_model = task_module[name] 54 | hps = task_model.default_hyper_params 55 | for hp_name in hps: 56 | cfg[name][hp_name] = hps[hp_name] 57 | return cfg_dict 58 | -------------------------------------------------------------------------------- /videoanalyst/pipeline/tracker_impl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import glob 3 | from os.path import basename, dirname, isfile 4 | 5 | modules = glob.glob(dirname(__file__) + "/*.py") 6 | modules = [m for m in modules if not m.endswith(('_bak.py')) 7 | ] # filter file with name ending with '_bak' (debugging) 8 | __all__ = [ 9 | basename(f)[:-3] for f in modules if isfile(f) 10 | and not f.endswith("__init__.py") and not f.endswith("utils.py") 11 | ] 12 | -------------------------------------------------------------------------------- /videoanalyst/pipeline/tracker_impl/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/pipeline/tracker_impl/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/pipeline/tracker_impl/__pycache__/stmtrack_tracker.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/pipeline/tracker_impl/__pycache__/stmtrack_tracker.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/pipeline/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | 3 | from videoanalyst.evaluation.vot_benchmark.bbox_helper import cxy_wh_2_rect 4 | 5 | from .bbox import (clip_bbox, cxywh2xywh, cxywh2xyxy, xywh2cxywh, xywh2xyxy, 6 | xyxy2cxywh, xyxy2xywh) 7 | from .crop import get_axis_aligned_bbox 8 | from .misc import imarray_to_tensor, tensor_to_numpy 9 | 10 | __all__ = [ 11 | clip_bbox, cxy_wh_2_rect, cxywh2xywh, cxywh2xyxy, xywh2cxywh, xywh2cxywh, 12 | xyxy2cxywh, xyxy2xywh, xywh2xyxy, get_axis_aligned_bbox, imarray_to_tensor, tensor_to_numpy 13 | ] 14 | -------------------------------------------------------------------------------- /videoanalyst/pipeline/utils/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/pipeline/utils/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/pipeline/utils/__pycache__/bbox.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/pipeline/utils/__pycache__/bbox.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/pipeline/utils/__pycache__/crop.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/pipeline/utils/__pycache__/crop.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/pipeline/utils/__pycache__/misc.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/pipeline/utils/__pycache__/misc.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/pipeline/utils/misc.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | 3 | import numpy as np 4 | 5 | import torch 6 | 7 | 8 | def imarray_to_tensor(arr): 9 | r""" 10 | Transpose & convert from numpy.array to torch.Tensor 11 | :param arr: numpy.array, (H, W, C) 12 | :return: torch.Tensor, (1, C, H, W) 13 | """ 14 | arr = np.ascontiguousarray( 15 | arr.transpose(2, 0, 1)[np.newaxis, ...], np.float32) 16 | return torch.from_numpy(arr) 17 | 18 | 19 | def tensor_to_imarray(t): 20 | r""" 21 | Perform naive detach / cpu / numpy process and then transpose 22 | cast dtype to np.uint8 23 | :param t: torch.Tensor, (1, C, H, W) 24 | :return: numpy.array, (H, W, C) 25 | """ 26 | arr = t.detach().cpu().numpy().astype(np.uint8) 27 | if arr.ndim == 4: 28 | arr = arr[0] 29 | return arr.transpose(1, 2, 0) 30 | 31 | 32 | def tensor_to_numpy(t): 33 | r""" 34 | Perform naive detach / cpu / numpy process. 35 | :param t: torch.Tensor, (N, C, H, W) 36 | :return: numpy.array, (N, C, H, W) 37 | """ 38 | arr = t.detach().cpu().numpy() 39 | return arr 40 | -------------------------------------------------------------------------------- /videoanalyst/pipeline/utils/online_classifier/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/pipeline/utils/online_classifier/__init__.py -------------------------------------------------------------------------------- /videoanalyst/pipeline/utils/online_classifier/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .tensordict import TensorDict 2 | from .tensorlist import TensorList 3 | 4 | __all__ = [TensorDict, TensorList] 5 | -------------------------------------------------------------------------------- /videoanalyst/pipeline/utils/online_classifier/utils/attention.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | def normalize(score): 5 | score = (score - np.min(score)) / (np.max(score) - np.min(score)) 6 | return score 7 | 8 | 9 | def normfun(x, mu, sigma): 10 | pdf = np.exp(-((x - mu)**2) / (2 * sigma**2)) 11 | return pdf 12 | 13 | 14 | def generate_xy_attention(center, size): 15 | 16 | a = np.linspace(-size // 2 + 1, size // 2, size) 17 | x = -normfun(a, center[1], 10).reshape((size, 1)) + 2 18 | y = -normfun(a, center[0], 10).reshape((1, size)) + 2 19 | z = normalize(1. / np.dot(np.abs(x), np.abs(y))) 20 | return z 21 | 22 | 23 | if __name__ == '__main__': 24 | generate_xy_attention([0, 0], 31) 25 | -------------------------------------------------------------------------------- /videoanalyst/pipeline/utils/online_classifier/utils/plotting.py: -------------------------------------------------------------------------------- 1 | import matplotlib 2 | 3 | # matplotlib.use('TkAgg') # disabled as Import Error with tk interactive framework 4 | # TODO: verify if this matplotlib backend is necessary 5 | import matplotlib.pyplot as plt 6 | import numpy as np 7 | 8 | import torch 9 | 10 | 11 | def show_tensor(a: torch.Tensor, fig_num=None, title=None): 12 | """Display a 2D tensor. 13 | args: 14 | fig_num: Figure number. 15 | title: Title of figure. 16 | """ 17 | a_np = a.squeeze().cpu().clone().detach().numpy() 18 | if a_np.ndim == 3: 19 | a_np = np.transpose(a_np, (1, 2, 0)) 20 | plt.figure(fig_num) 21 | plt.tight_layout() 22 | plt.cla() 23 | plt.imshow(a_np) 24 | plt.axis('off') 25 | plt.axis('equal') 26 | if title is not None: 27 | plt.title(title) 28 | plt.draw() 29 | plt.pause(0.001) 30 | 31 | 32 | def plot_graph(a: torch.Tensor, fig_num=None, title=None): 33 | """Plot graph. Data is a 1D tensor. 34 | args: 35 | fig_num: Figure number. 36 | title: Title of figure. 37 | """ 38 | a_np = a.squeeze().cpu().clone().detach().numpy() 39 | if a_np.ndim > 1: 40 | raise ValueError 41 | plt.figure(fig_num) 42 | # plt.tight_layout() 43 | plt.cla() 44 | plt.plot(a_np) 45 | if title is not None: 46 | plt.title(title) 47 | plt.draw() 48 | plt.pause(0.001) 49 | -------------------------------------------------------------------------------- /videoanalyst/pipeline/utils/online_classifier/utils/preprocessing.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | import torch 4 | import torch.nn.functional as F 5 | 6 | 7 | def numpy_to_torch(a: np.ndarray): 8 | return torch.from_numpy(a).float().permute(2, 0, 1).unsqueeze(0) 9 | 10 | 11 | def torch_to_numpy(a: torch.Tensor): 12 | return a.squeeze(0).permute(1, 2, 0).numpy() 13 | 14 | 15 | def sample_patch(im: torch.Tensor, 16 | pos: torch.Tensor, 17 | sample_sz: torch.Tensor, 18 | output_sz: torch.Tensor = None): 19 | """Sample an image patch. 20 | 21 | args: 22 | im: Image 23 | pos: center position of crop 24 | sample_sz: size to crop 25 | output_sz: size to resize to 26 | """ 27 | 28 | # copy and convert 29 | posl = pos.long().clone() 30 | 31 | # Compute pre-downsampling factor 32 | if output_sz is not None: 33 | resize_factor = torch.min(sample_sz.float() / output_sz.float()).item() 34 | df = int(max(int(resize_factor - 0.1), 1)) 35 | else: 36 | df = int(1) 37 | 38 | sz = sample_sz.float() / df # new size 39 | 40 | # Do downsampling 41 | if df > 1: 42 | os = posl % df # offset 43 | posl = (posl - os) / df # new position 44 | im2 = im[..., os[0].item()::df, os[1].item()::df] # downsample 45 | else: 46 | im2 = im 47 | 48 | # compute size to crop 49 | szl = torch.max(sz.round(), torch.Tensor([2])).long() 50 | 51 | # Extract top and bottom coordinates 52 | tl = posl - (szl - 1) / 2 53 | br = posl + szl / 2 54 | 55 | # Get image patch 56 | im_patch = F.pad(im2, (-tl[1].item(), br[1].item() - im2.shape[3] + 1, 57 | -tl[0].item(), br[0].item() - im2.shape[2] + 1), 58 | 'replicate') 59 | 60 | if output_sz is None or (im_patch.shape[-2] == output_sz[0] 61 | and im_patch.shape[-1] == output_sz[1]): 62 | return im_patch 63 | 64 | # Resample 65 | im_patch = F.interpolate(im_patch, 66 | output_sz.long().tolist(), 67 | mode='bilinear') 68 | 69 | return im_patch 70 | -------------------------------------------------------------------------------- /videoanalyst/pipeline/utils/online_classifier/utils/tensordict.py: -------------------------------------------------------------------------------- 1 | from collections import OrderedDict 2 | 3 | import torch 4 | 5 | 6 | class TensorDict(OrderedDict): 7 | """Container mainly used for dicts of torch tensors. Extends OrderedDict with pytorch functionality.""" 8 | def concat(self, other): 9 | """Concatenates two dicts without copying internal data.""" 10 | return TensorDict(self, **other) 11 | 12 | def copy(self): 13 | return TensorDict(super(TensorDict, self).copy()) 14 | 15 | def __getattr__(self, name): 16 | if not hasattr(torch.Tensor, name): 17 | raise AttributeError( 18 | '\'TensorDict\' object has not attribute \'{}\''.format(name)) 19 | 20 | def apply_attr(*args, **kwargs): 21 | return TensorDict({ 22 | n: getattr(e, name)(*args, **kwargs) if hasattr(e, name) else e 23 | for n, e in self.items() 24 | }) 25 | 26 | return apply_attr 27 | 28 | def attribute(self, attr: str, *args): 29 | return TensorDict({n: getattr(e, attr, *args) for n, e in self.items()}) 30 | 31 | def apply(self, fn, *args, **kwargs): 32 | return TensorDict({n: fn(e, *args, **kwargs) for n, e in self.items()}) 33 | 34 | @staticmethod 35 | def _iterable(a): 36 | return isinstance(a, (TensorDict, list)) 37 | -------------------------------------------------------------------------------- /videoanalyst/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | from .image import load_image 3 | from .misc import Registry, Timer, load_cfg, md5sum, merge_cfg_into_hps 4 | from .path import complete_path_wt_root_in_cfg, ensure_dir 5 | from .torch_module import (average_gradients, convert_numpy_to_tensor, 6 | convert_tensor_to_numpy, move_data_to_device, 7 | unwrap_model) 8 | from .visualization import VideoWriter 9 | 10 | __all__ = [ 11 | load_image, Registry, Timer, load_cfg, md5sum, merge_cfg_into_hps, 12 | complete_path_wt_root_in_cfg, ensure_dir, average_gradients, 13 | convert_numpy_to_tensor, convert_tensor_to_numpy, move_data_to_device, 14 | unwrap_model, VideoWriter 15 | ] 16 | -------------------------------------------------------------------------------- /videoanalyst/utils/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/utils/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/utils/__pycache__/dist_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/utils/__pycache__/dist_utils.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/utils/__pycache__/image.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/utils/__pycache__/image.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/utils/__pycache__/misc.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/utils/__pycache__/misc.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/utils/__pycache__/path.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/utils/__pycache__/path.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/utils/__pycache__/torch_module.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/utils/__pycache__/torch_module.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/utils/__pycache__/visualization.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/utils/__pycache__/visualization.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/utils/__pycache__/visualize_score_map.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hscv/MMF-Net/1cce4ecc950dfb48953003eedd4484d31285491e/videoanalyst/utils/__pycache__/visualize_score_map.cpython-37.pyc -------------------------------------------------------------------------------- /videoanalyst/utils/path.py: -------------------------------------------------------------------------------- 1 | import os 2 | import os.path as osp 3 | 4 | from yacs.config import CfgNode 5 | 6 | 7 | def ensure_dir(dir_path: str): 8 | r""" 9 | Ensure the existence of path (i.e. mkdir -p) 10 | Arguments 11 | --------- 12 | dir_path: str 13 | path to be ensured 14 | """ 15 | if osp.exists(dir_path): 16 | return 17 | else: 18 | os.makedirs(dir_path) 19 | 20 | 21 | def complete_path_wt_root_in_cfg( 22 | cfg: CfgNode, 23 | root_dir: str, 24 | ): 25 | r""" 26 | Arguments 27 | --------- 28 | cfg: CfgNode 29 | yacs configuration object to be completed 30 | root_dir: str 31 | root path 32 | """ 33 | if isinstance(cfg, CfgNode): 34 | for k in cfg: 35 | cfg[k] = complete_path_wt_root_in_cfg(cfg[k], root_dir) 36 | elif isinstance(cfg, str) and len(cfg) > 0: 37 | realpath = osp.join(root_dir, cfg) 38 | if osp.exists(realpath): 39 | cfg = realpath 40 | # print(realpath) 41 | 42 | return cfg 43 | -------------------------------------------------------------------------------- /videoanalyst/utils/visualization.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | import os 3 | import os.path as osp 4 | 5 | import cv2 6 | from loguru import logger 7 | 8 | 9 | class VideoWriter(object): 10 | """ 11 | Video writer which handles video recording overhead 12 | Usage: 13 | object creation: provide path to write 14 | write: 15 | release: 16 | """ 17 | def __init__(self, video_file, fps=25, scale=1.0): 18 | """ 19 | 20 | :param video_file: path to write video. Perform nothing in case of None 21 | :param fps: frame per second 22 | :param scale: resize scale 23 | """ 24 | self.video_file = video_file 25 | self.fps = fps 26 | self.writer = None 27 | self.scale = scale 28 | 29 | def write(self, frame): 30 | """ 31 | 32 | :param frame: numpy array, (H, W, 3), BGR, frame to write 33 | :return: 34 | """ 35 | h, w = frame.shape[:2] 36 | h_rsz, w_rsz = int(h * self.scale), int(w * self.scale) 37 | frame = cv2.resize(frame, (w_rsz, h_rsz)) 38 | if self.writer is None: 39 | video_dir = osp.dirname(osp.realpath(self.video_file)) 40 | if not osp.exists(video_dir): 41 | os.makedirs(video_dir) 42 | fourcc = cv2.VideoWriter_fourcc(*'MJPG') 43 | self.writer = cv2.VideoWriter(self.video_file, fourcc, self.fps, 44 | tuple(frame.shape[1::-1])) 45 | self.writer.write(frame) 46 | 47 | def release(self): 48 | """ 49 | Manually release 50 | :return: 51 | """ 52 | if self.writer is None: 53 | return 54 | self.writer.release() 55 | logger.info("video file dumped at {}".format(self.video_file)) 56 | 57 | def __del__(self): 58 | self.release() 59 | -------------------------------------------------------------------------------- /videoanalyst/utils/visualize_score_map.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import os 3 | import numpy as np 4 | import shutil 5 | import time 6 | 7 | SAVE_ROOT = './logs/score_map_visualization/score_maps' 8 | 9 | 10 | def rename_dir(): 11 | if os.path.exists(SAVE_ROOT): 12 | shutil.move(SAVE_ROOT, SAVE_ROOT + str(int(time.time()))) 13 | 14 | 15 | def create_dir(): 16 | if not os.path.exists(SAVE_ROOT): 17 | os.makedirs(SAVE_ROOT) 18 | 19 | 20 | def visualize(score, score_size, crop, frame_num, name): 21 | create_dir() 22 | score = score.reshape(score_size, score_size) 23 | score = score[:, :, np.newaxis] 24 | score = cv2.normalize(score, None, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8UC1) 25 | color_map = cv2.applyColorMap(score, cv2.COLORMAP_VIRIDIS) 26 | dst_size = (crop.shape[1] * 2, crop.shape[0] * 2) 27 | color_map = cv2.resize(color_map, dst_size, interpolation=cv2.INTER_LINEAR) 28 | crop = cv2.resize(crop, dst_size, interpolation=cv2.INTER_LINEAR) 29 | final_img = color_map * 0.5 + crop * 0.5 30 | cv2.imwrite(os.path.join(SAVE_ROOT, '{}-{:04d}.jpg'.format(name, frame_num)), final_img) 31 | --------------------------------------------------------------------------------