├── .gitignore ├── README.md ├── compile.sh ├── configs ├── backbone_ablation │ ├── faster_fpn_x101_32x4d.py │ ├── faster_fpn_x50_32x4d.py │ └── fbhit.py ├── faster_rcnn_1333x800_r50_fpn_1x.py ├── faster_rcnn_640x640_r50_fpn_1x.py ├── nas_fpn │ ├── run_faster_detnas_1G_nasfpn_4conv1fc.py │ └── run_faster_nasfpn.py ├── nas_trinity │ ├── 2stage_hitdet.py │ └── __pycache__ │ │ └── 2stage_hitdet.cpython-36.pyc ├── panet │ └── faster_rcnn_r50_panet_syncbn.py ├── pascal_voc │ ├── faster_rcnn_r50_fpn_voc.py │ └── train_hit_paper_voc.py └── retinanet_1333x800_r50_fpn_1x.py ├── env.sh ├── mmcv ├── __init__.py ├── _ext.cpython-36m-x86_64-linux-gnu.so ├── arraymisc │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ └── quantization.cpython-36.pyc │ └── quantization.py ├── cnn │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── alexnet.cpython-36.pyc │ │ ├── resnet.cpython-36.pyc │ │ ├── vgg.cpython-36.pyc │ │ └── weight_init.cpython-36.pyc │ ├── alexnet.py │ ├── resnet.py │ ├── vgg.py │ └── weight_init.py ├── fileio │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── io.cpython-36.pyc │ │ └── parse.cpython-36.pyc │ ├── handlers │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── base.cpython-36.pyc │ │ │ ├── json_handler.cpython-36.pyc │ │ │ ├── pickle_handler.cpython-36.pyc │ │ │ └── yaml_handler.cpython-36.pyc │ │ ├── base.py │ │ ├── json_handler.py │ │ ├── pickle_handler.py │ │ └── yaml_handler.py │ ├── io.py │ └── parse.py ├── image │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ └── io.cpython-36.pyc │ ├── io.py │ └── transforms │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── colorspace.cpython-36.pyc │ │ ├── geometry.cpython-36.pyc │ │ ├── normalize.cpython-36.pyc │ │ └── resize.cpython-36.pyc │ │ ├── colorspace.py │ │ ├── geometry.py │ │ ├── normalize.py │ │ └── resize.py ├── opencv_info.py ├── parallel │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── _functions.cpython-36.pyc │ │ ├── collate.cpython-36.pyc │ │ ├── data_container.cpython-36.pyc │ │ ├── data_parallel.cpython-36.pyc │ │ ├── distributed.cpython-36.pyc │ │ └── scatter_gather.cpython-36.pyc │ ├── _functions.py │ ├── collate.py │ ├── data_container.py │ ├── data_parallel.py │ ├── distributed.py │ └── scatter_gather.py ├── runner │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── checkpoint.cpython-36.pyc │ │ ├── dist_utils.cpython-36.pyc │ │ ├── log_buffer.cpython-36.pyc │ │ ├── parallel_test.cpython-36.pyc │ │ ├── priority.cpython-36.pyc │ │ ├── runner.cpython-36.pyc │ │ └── utils.cpython-36.pyc │ ├── checkpoint.py │ ├── dist_utils.py │ ├── hooks │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── checkpoint.cpython-36.pyc │ │ │ ├── closure.cpython-36.pyc │ │ │ ├── hook.cpython-36.pyc │ │ │ ├── iter_timer.cpython-36.pyc │ │ │ ├── lr_updater.cpython-36.pyc │ │ │ ├── memory.cpython-36.pyc │ │ │ ├── optimizer.cpython-36.pyc │ │ │ └── sampler_seed.cpython-36.pyc │ │ ├── checkpoint.py │ │ ├── closure.py │ │ ├── hook.py │ │ ├── iter_timer.py │ │ ├── logger │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── base.cpython-36.pyc │ │ │ │ ├── pavi.cpython-36.pyc │ │ │ │ ├── tensorboard.cpython-36.pyc │ │ │ │ └── text.cpython-36.pyc │ │ │ ├── base.py │ │ │ ├── pavi.py │ │ │ ├── tensorboard.py │ │ │ └── text.py │ │ ├── lr_updater.py │ │ ├── memory.py │ │ ├── optimizer.py │ │ └── sampler_seed.py │ ├── log_buffer.py │ ├── parallel_test.py │ ├── priority.py │ ├── runner.py │ └── utils.py ├── utils │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── config.cpython-36.pyc │ │ ├── misc.cpython-36.pyc │ │ ├── path.cpython-36.pyc │ │ ├── progressbar.cpython-36.pyc │ │ └── timer.cpython-36.pyc │ ├── config.py │ ├── misc.py │ ├── path.py │ ├── progressbar.py │ └── timer.py ├── version.py ├── video │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── io.cpython-36.pyc │ │ ├── optflow.cpython-36.pyc │ │ └── processing.cpython-36.pyc │ ├── io.py │ ├── optflow.py │ ├── optflow_warp │ │ ├── __init__.py │ │ ├── flow_warp.cpp │ │ ├── flow_warp.hpp │ │ ├── flow_warp_module.cpp │ │ └── flow_warp_module.pyx │ └── processing.py └── visualization │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-36.pyc │ ├── color.cpython-36.pyc │ ├── image.cpython-36.pyc │ └── optflow.cpython-36.pyc │ ├── color.py │ ├── image.py │ └── optflow.py ├── mmdet ├── __init__.py ├── apis │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── env.cpython-36.pyc │ │ ├── inference.cpython-36.pyc │ │ └── train.cpython-36.pyc │ ├── env.py │ ├── inference.py │ └── train.py ├── core │ ├── __init__.py │ ├── __pycache__ │ │ └── __init__.cpython-36.pyc │ ├── anchor │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── anchor_generator.cpython-36.pyc │ │ │ ├── anchor_target.cpython-36.pyc │ │ │ └── guided_anchor_target.cpython-36.pyc │ │ ├── anchor_generator.py │ │ ├── anchor_target.py │ │ └── guided_anchor_target.py │ ├── bbox │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── assign_sampling.cpython-36.pyc │ │ │ ├── bbox_target.cpython-36.pyc │ │ │ ├── geometry.cpython-36.pyc │ │ │ └── transforms.cpython-36.pyc │ │ ├── assign_sampling.py │ │ ├── assigners │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── approx_max_iou_assigner.cpython-36.pyc │ │ │ │ ├── assign_result.cpython-36.pyc │ │ │ │ ├── base_assigner.cpython-36.pyc │ │ │ │ └── max_iou_assigner.cpython-36.pyc │ │ │ ├── approx_max_iou_assigner.py │ │ │ ├── assign_result.py │ │ │ ├── base_assigner.py │ │ │ └── max_iou_assigner.py │ │ ├── bbox_target.py │ │ ├── geometry.py │ │ ├── samplers │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── base_sampler.cpython-36.pyc │ │ │ │ ├── combined_sampler.cpython-36.pyc │ │ │ │ ├── instance_balanced_pos_sampler.cpython-36.pyc │ │ │ │ ├── iou_balanced_neg_sampler.cpython-36.pyc │ │ │ │ ├── ohem_sampler.cpython-36.pyc │ │ │ │ ├── pseudo_sampler.cpython-36.pyc │ │ │ │ ├── random_sampler.cpython-36.pyc │ │ │ │ └── sampling_result.cpython-36.pyc │ │ │ ├── base_sampler.py │ │ │ ├── combined_sampler.py │ │ │ ├── instance_balanced_pos_sampler.py │ │ │ ├── iou_balanced_neg_sampler.py │ │ │ ├── ohem_sampler.py │ │ │ ├── pseudo_sampler.py │ │ │ ├── random_sampler.py │ │ │ └── sampling_result.py │ │ └── transforms.py │ ├── evaluation │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── bbox_overlaps.cpython-36.pyc │ │ │ ├── class_names.cpython-36.pyc │ │ │ ├── eval_hooks.cpython-36.pyc │ │ │ ├── mean_ap.cpython-36.pyc │ │ │ └── recall.cpython-36.pyc │ │ ├── bbox_overlaps.py │ │ ├── class_names.py │ │ ├── coco_utils.py │ │ ├── eval_hooks.py │ │ ├── mean_ap.py │ │ └── recall.py │ ├── fp16 │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── decorators.cpython-36.pyc │ │ │ ├── hooks.cpython-36.pyc │ │ │ └── utils.cpython-36.pyc │ │ ├── decorators.py │ │ ├── hooks.py │ │ └── utils.py │ ├── mask │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── mask_target.cpython-36.pyc │ │ │ └── utils.cpython-36.pyc │ │ ├── mask_target.py │ │ └── utils.py │ ├── post_processing │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── bbox_nms.cpython-36.pyc │ │ │ └── merge_augs.cpython-36.pyc │ │ ├── bbox_nms.py │ │ └── merge_augs.py │ └── utils │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── dist_utils.cpython-36.pyc │ │ └── misc.cpython-36.pyc │ │ ├── dist_utils.py │ │ └── misc.py ├── datasets │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── builder.cpython-36.pyc │ │ ├── cityscapes.cpython-36.pyc │ │ ├── coco.cpython-36.pyc │ │ ├── custom.cpython-36.pyc │ │ ├── dataset_wrappers.cpython-36.pyc │ │ ├── registry.cpython-36.pyc │ │ ├── voc.cpython-36.pyc │ │ ├── wider_face.cpython-36.pyc │ │ └── xml_style.cpython-36.pyc │ ├── builder.py │ ├── cityscapes.py │ ├── coco.py │ ├── custom.py │ ├── dataset_wrappers.py │ ├── loader │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── build_loader.cpython-36.pyc │ │ │ └── sampler.cpython-36.pyc │ │ ├── build_loader.py │ │ └── sampler.py │ ├── pipelines │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── compose.cpython-36.pyc │ │ │ ├── formating.cpython-36.pyc │ │ │ ├── loading.cpython-36.pyc │ │ │ ├── test_aug.cpython-36.pyc │ │ │ └── transforms.cpython-36.pyc │ │ ├── compose.py │ │ ├── formating.py │ │ ├── loading.py │ │ ├── test_aug.py │ │ └── transforms.py │ ├── registry.py │ ├── transforms.py │ ├── utils.py │ ├── voc.py │ ├── wider_face.py │ └── xml_style.py ├── models │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── builder.cpython-36.pyc │ │ └── registry.cpython-36.pyc │ ├── anchor_heads │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── anchor_head.cpython-36.pyc │ │ │ ├── fcos_head.cpython-36.pyc │ │ │ ├── ga_retina_head.cpython-36.pyc │ │ │ ├── ga_rpn_head.cpython-36.pyc │ │ │ ├── guided_anchor_head.cpython-36.pyc │ │ │ ├── retina_head.cpython-36.pyc │ │ │ ├── rpn_head.cpython-36.pyc │ │ │ └── ssd_head.cpython-36.pyc │ │ ├── anchor_head.py │ │ ├── fcos_head.py │ │ ├── ga_retina_head.py │ │ ├── ga_rpn_head.py │ │ ├── guided_anchor_head.py │ │ ├── retina_head.py │ │ ├── rpn_head.py │ │ └── ssd_head.py │ ├── backbones │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── detnas.cpython-36.pyc │ │ │ ├── dropblock.cpython-36.pyc │ │ │ ├── fbnet.cpython-36.pyc │ │ │ ├── fbnet_arch.cpython-36.pyc │ │ │ ├── fbnet_blocks.cpython-36.pyc │ │ │ ├── hrnet.cpython-36.pyc │ │ │ ├── mnasnet.cpython-36.pyc │ │ │ ├── mobilenetv2.cpython-36.pyc │ │ │ ├── resnet.cpython-36.pyc │ │ │ ├── resnext.cpython-36.pyc │ │ │ ├── ssd_vgg.cpython-36.pyc │ │ │ └── utils.cpython-36.pyc │ │ ├── detnas.py │ │ ├── dropblock.py │ │ ├── fbnet.py │ │ ├── fbnet_arch.py │ │ ├── fbnet_blocks.py │ │ ├── hrnet.py │ │ ├── mnasnet.py │ │ ├── mobilenetv2.py │ │ ├── resnet.py │ │ ├── resnext.py │ │ ├── ssd_vgg.py │ │ └── utils.py │ ├── bbox_heads │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── bbox_head.cpython-36.pyc │ │ │ ├── convfc_bbox_head.cpython-36.pyc │ │ │ └── double_bbox_head.cpython-36.pyc │ │ ├── auto_head │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── build_head.cpython-36.pyc │ │ │ │ ├── mbblock_head_search.cpython-36.pyc │ │ │ │ └── mbblock_ops.cpython-36.pyc │ │ │ ├── build_head.py │ │ │ ├── mbblock_head_search.py │ │ │ └── mbblock_ops.py │ │ ├── bbox_head.py │ │ ├── convfc_bbox_head.py │ │ └── double_bbox_head.py │ ├── builder.py │ ├── detectors │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── base.cpython-36.pyc │ │ │ ├── cascade_rcnn.cpython-36.pyc │ │ │ ├── double_head_rcnn.cpython-36.pyc │ │ │ ├── fast_rcnn.cpython-36.pyc │ │ │ ├── faster_rcnn.cpython-36.pyc │ │ │ ├── fcos.cpython-36.pyc │ │ │ ├── grid_rcnn.cpython-36.pyc │ │ │ ├── htc.cpython-36.pyc │ │ │ ├── mask_rcnn.cpython-36.pyc │ │ │ ├── mask_scoring_rcnn.cpython-36.pyc │ │ │ ├── retinanet.cpython-36.pyc │ │ │ ├── rpn.cpython-36.pyc │ │ │ ├── single_stage.cpython-36.pyc │ │ │ ├── test_mixins.cpython-36.pyc │ │ │ └── two_stage.cpython-36.pyc │ │ ├── base.py │ │ ├── cascade_rcnn.py │ │ ├── double_head_rcnn.py │ │ ├── fast_rcnn.py │ │ ├── faster_rcnn.py │ │ ├── fcos.py │ │ ├── grid_rcnn.py │ │ ├── htc.py │ │ ├── mask_rcnn.py │ │ ├── mask_scoring_rcnn.py │ │ ├── retinanet.py │ │ ├── rpn.py │ │ ├── single_stage.py │ │ ├── test_mixins.py │ │ └── two_stage.py │ ├── losses │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── accuracy.cpython-36.pyc │ │ │ ├── balanced_l1_loss.cpython-36.pyc │ │ │ ├── cross_entropy_loss.cpython-36.pyc │ │ │ ├── focal_loss.cpython-36.pyc │ │ │ ├── ghm_loss.cpython-36.pyc │ │ │ ├── iou_loss.cpython-36.pyc │ │ │ ├── mse_loss.cpython-36.pyc │ │ │ ├── smooth_l1_loss.cpython-36.pyc │ │ │ └── utils.cpython-36.pyc │ │ ├── accuracy.py │ │ ├── balanced_l1_loss.py │ │ ├── cross_entropy_loss.py │ │ ├── focal_loss.py │ │ ├── ghm_loss.py │ │ ├── iou_loss.py │ │ ├── mse_loss.py │ │ ├── smooth_l1_loss.py │ │ └── utils.py │ ├── mask_heads │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── fcn_mask_head.cpython-36.pyc │ │ │ ├── fused_semantic_head.cpython-36.pyc │ │ │ ├── grid_head.cpython-36.pyc │ │ │ ├── htc_mask_head.cpython-36.pyc │ │ │ └── maskiou_head.cpython-36.pyc │ │ ├── fcn_mask_head.py │ │ ├── fused_semantic_head.py │ │ ├── grid_head.py │ │ ├── htc_mask_head.py │ │ └── maskiou_head.py │ ├── necks │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── bfp.cpython-36.pyc │ │ │ ├── fpn.cpython-36.pyc │ │ │ ├── fpn_panet.cpython-36.pyc │ │ │ ├── hrfpn.cpython-36.pyc │ │ │ ├── nas_fpn.cpython-36.pyc │ │ │ ├── search_fpn.cpython-36.pyc │ │ │ └── search_pafpn.cpython-36.pyc │ │ ├── auto_neck │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── build_neck.cpython-36.pyc │ │ │ │ ├── hit_neck_search.cpython-36.pyc │ │ │ │ └── hit_ops.cpython-36.pyc │ │ │ ├── build_neck.py │ │ │ ├── hit_neck_search.py │ │ │ └── hit_ops.py │ │ ├── bfp.py │ │ ├── fpn.py │ │ ├── fpn_panet.py │ │ ├── hrfpn.py │ │ ├── nas_fpn.py │ │ └── search_pafpn.py │ ├── plugins │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── generalized_attention.cpython-36.pyc │ │ │ └── non_local.cpython-36.pyc │ │ ├── generalized_attention.py │ │ └── non_local.py │ ├── registry.py │ ├── roi_extractors │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ └── single_level.cpython-36.pyc │ │ └── single_level.py │ ├── shared_heads │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ └── res_layer.cpython-36.pyc │ │ └── res_layer.py │ └── utils │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── conv_module.cpython-36.pyc │ │ ├── conv_ws.cpython-36.pyc │ │ ├── norm.cpython-36.pyc │ │ ├── quant_conv.cpython-36.pyc │ │ ├── scale.cpython-36.pyc │ │ └── weight_init.cpython-36.pyc │ │ ├── conv_module.py │ │ ├── conv_ws.py │ │ ├── norm.py │ │ ├── quant_conv.py │ │ ├── scale.py │ │ └── weight_init.py ├── ops │ ├── __init__.py │ ├── __pycache__ │ │ └── __init__.cpython-36.pyc │ ├── dcn │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ └── __init__.cpython-36.pyc │ │ ├── build │ │ │ ├── lib.linux-x86_64-3.6 │ │ │ │ ├── deform_conv_cuda.cpython-36m-x86_64-linux-gnu.so │ │ │ │ └── deform_pool_cuda.cpython-36m-x86_64-linux-gnu.so │ │ │ └── temp.linux-x86_64-3.6 │ │ │ │ └── src │ │ │ │ ├── deform_conv_cuda.o │ │ │ │ ├── deform_conv_cuda_kernel.o │ │ │ │ ├── deform_pool_cuda.o │ │ │ │ └── deform_pool_cuda_kernel.o │ │ ├── deform_conv_cuda.cpython-36m-x86_64-linux-gnu.so │ │ ├── deform_pool_cuda.cpython-36m-x86_64-linux-gnu.so │ │ ├── functions │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── deform_conv.cpython-36.pyc │ │ │ │ └── deform_pool.cpython-36.pyc │ │ │ ├── deform_conv.py │ │ │ └── deform_pool.py │ │ ├── modules │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── deform_conv.cpython-36.pyc │ │ │ │ └── deform_pool.cpython-36.pyc │ │ │ ├── deform_conv.py │ │ │ └── deform_pool.py │ │ ├── setup.py │ │ └── src │ │ │ ├── deform_conv_cuda.cpp │ │ │ ├── deform_conv_cuda_kernel.cu │ │ │ ├── deform_pool_cuda.cpp │ │ │ └── deform_pool_cuda_kernel.cu │ ├── gcb │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ └── context_block.cpython-36.pyc │ │ └── context_block.py │ ├── masked_conv │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ └── __init__.cpython-36.pyc │ │ ├── build │ │ │ ├── lib.linux-x86_64-3.6 │ │ │ │ └── masked_conv2d_cuda.cpython-36m-x86_64-linux-gnu.so │ │ │ └── temp.linux-x86_64-3.6 │ │ │ │ └── src │ │ │ │ ├── masked_conv2d_cuda.o │ │ │ │ └── masked_conv2d_kernel.o │ │ ├── functions │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ └── masked_conv.cpython-36.pyc │ │ │ └── masked_conv.py │ │ ├── masked_conv2d_cuda.cpython-36m-x86_64-linux-gnu.so │ │ ├── modules │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ └── masked_conv.cpython-36.pyc │ │ │ └── masked_conv.py │ │ ├── setup.py │ │ └── src │ │ │ ├── masked_conv2d_cuda.cpp │ │ │ └── masked_conv2d_kernel.cu │ ├── nms │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ └── nms_wrapper.cpython-36.pyc │ │ ├── build │ │ │ ├── lib.linux-x86_64-3.6 │ │ │ │ ├── nms_cpu.cpython-36m-x86_64-linux-gnu.so │ │ │ │ └── nms_cuda.cpython-36m-x86_64-linux-gnu.so │ │ │ └── temp.linux-x86_64-3.6 │ │ │ │ └── src │ │ │ │ ├── nms_cpu.o │ │ │ │ ├── nms_cuda.o │ │ │ │ ├── nms_kernel.o │ │ │ │ └── soft_nms_cpu.o │ │ ├── nms_cpu.cpython-36m-x86_64-linux-gnu.so │ │ ├── nms_cuda.cpython-36m-x86_64-linux-gnu.so │ │ ├── nms_wrapper.py │ │ ├── setup.py │ │ ├── soft_nms_cpu.cpython-36m-x86_64-linux-gnu.so │ │ └── src │ │ │ ├── nms_cpu.cpp │ │ │ ├── nms_cuda.cpp │ │ │ ├── nms_kernel.cu │ │ │ ├── soft_nms_cpu.cpp │ │ │ └── soft_nms_cpu.pyx │ ├── roi_align │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ └── roi_align.cpython-36.pyc │ │ ├── build │ │ │ ├── lib.linux-x86_64-3.6 │ │ │ │ └── roi_align_cuda.cpython-36m-x86_64-linux-gnu.so │ │ │ └── temp.linux-x86_64-3.6 │ │ │ │ └── src │ │ │ │ ├── roi_align_cuda.o │ │ │ │ └── roi_align_kernel.o │ │ ├── functions │ │ │ ├── __init__.py │ │ │ └── roi_align.py │ │ ├── gradcheck.py │ │ ├── modules │ │ │ ├── __init__.py │ │ │ └── roi_align.py │ │ ├── roi_align.py │ │ ├── roi_align_cuda.cpython-36m-x86_64-linux-gnu.so │ │ ├── setup.py │ │ └── src │ │ │ ├── roi_align_cuda.cpp │ │ │ └── roi_align_kernel.cu │ ├── roi_pool │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ └── __init__.cpython-36.pyc │ │ ├── build │ │ │ ├── lib.linux-x86_64-3.6 │ │ │ │ └── roi_pool_cuda.cpython-36m-x86_64-linux-gnu.so │ │ │ └── temp.linux-x86_64-3.6 │ │ │ │ └── src │ │ │ │ ├── roi_pool_cuda.o │ │ │ │ └── roi_pool_kernel.o │ │ ├── functions │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ └── roi_pool.cpython-36.pyc │ │ │ └── roi_pool.py │ │ ├── gradcheck.py │ │ ├── modules │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ └── roi_pool.cpython-36.pyc │ │ │ └── roi_pool.py │ │ ├── roi_pool_cuda.cpython-36m-x86_64-linux-gnu.so │ │ ├── setup.py │ │ └── src │ │ │ ├── roi_pool_cuda.cpp │ │ │ └── roi_pool_kernel.cu │ └── sigmoid_focal_loss │ │ ├── __init__.py │ │ ├── __pycache__ │ │ └── __init__.cpython-36.pyc │ │ ├── build │ │ ├── lib.linux-x86_64-3.6 │ │ │ └── sigmoid_focal_loss_cuda.cpython-36m-x86_64-linux-gnu.so │ │ └── temp.linux-x86_64-3.6 │ │ │ └── src │ │ │ ├── sigmoid_focal_loss.o │ │ │ └── sigmoid_focal_loss_cuda.o │ │ ├── functions │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ └── sigmoid_focal_loss.cpython-36.pyc │ │ └── sigmoid_focal_loss.py │ │ ├── modules │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ └── sigmoid_focal_loss.cpython-36.pyc │ │ └── sigmoid_focal_loss.py │ │ ├── setup.py │ │ ├── sigmoid_focal_loss_cuda.cpython-36m-x86_64-linux-gnu.so │ │ └── src │ │ ├── sigmoid_focal_loss.cpp │ │ └── sigmoid_focal_loss_cuda.cu ├── utils │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── collect_env.cpython-36.pyc │ │ ├── flops_counter.cpython-36.pyc │ │ ├── logger.cpython-36.pyc │ │ └── registry.cpython-36.pyc │ ├── collect_env.py │ ├── contextmanagers.py │ ├── flops_counter.py │ ├── logger.py │ ├── profiling.py │ ├── registry.py │ └── util_mixins.py └── version.py ├── scripts └── train_hit_det.sh ├── setup.py ├── test.py ├── tools ├── analyze_logs.py ├── coco_eval.py ├── convert_datasets │ └── pascal_voc.py ├── detectron2pytorch.py ├── dist_test.sh ├── dist_train.sh ├── get_flops.py ├── publish_model.py ├── slurm_test.sh ├── slurm_train.sh ├── test.py ├── upgrade_model_version.py └── voc_eval.py └── train.py /.gitignore: -------------------------------------------------------------------------------- 1 | /data 2 | /ImageNet-pretrained 3 | /work_dirs 4 | */__pycache__ 5 | 6 | -------------------------------------------------------------------------------- /compile.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Building roi align op..." 4 | cd mmdet/ops/roi_align 5 | if [ -d "build" ]; then 6 | rm -r build 7 | fi 8 | python setup.py build_ext --inplace 9 | 10 | echo "Building roi pool op..." 11 | cd ../roi_pool 12 | if [ -d "build" ]; then 13 | rm -r build 14 | fi 15 | python setup.py build_ext --inplace 16 | 17 | echo "Building nms op..." 18 | cd ../nms 19 | if [ -d "build" ]; then 20 | rm -r build 21 | fi 22 | python setup.py build_ext --inplace 23 | 24 | echo "Building dcn..." 25 | cd ../dcn 26 | if [ -d "build" ]; then 27 | rm -r build 28 | fi 29 | python setup.py build_ext --inplace 30 | 31 | echo "Building sigmoid focal loss op..." 32 | cd ../sigmoid_focal_loss 33 | if [ -d "build" ]; then 34 | rm -r build 35 | fi 36 | python setup.py build_ext --inplace 37 | 38 | echo "Building masked conv op..." 39 | cd ../masked_conv 40 | if [ -d "build" ]; then 41 | rm -r build 42 | fi 43 | python setup.py build_ext --inplace 44 | -------------------------------------------------------------------------------- /configs/nas_trinity/__pycache__/2stage_hitdet.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/configs/nas_trinity/__pycache__/2stage_hitdet.cpython-36.pyc -------------------------------------------------------------------------------- /env.sh: -------------------------------------------------------------------------------- 1 | # environment 2 | pip install Cython -i https://pypi.tuna.tsinghua.edu.cn/simple 3 | pip install pycocotools -i https://pypi.tuna.tsinghua.edu.cn/simple 4 | pip install torchvision==0.3.0 -i https://pypi.tuna.tsinghua.edu.cn/simple 5 | pip install terminaltables==3.1.0 -i https://pypi.tuna.tsinghua.edu.cn/simple 6 | pip install addict -i https://pypi.tuna.tsinghua.edu.cn/simple 7 | pip install pytest-runner -i https://pypi.tuna.tsinghua.edu.cn/simple 8 | pip install imgaug==0.2.5 -i https://pypi.tuna.tsinghua.edu.cn/simple 9 | pip install opencv-python==4.1.1.26 -i https://pypi.tuna.tsinghua.edu.cn/simple 10 | pip install albumentations==0.4.3 -i https://pypi.tuna.tsinghua.edu.cn/simple 11 | pip install Pillow==6.2.1 -i https://pypi.tuna.tsinghua.edu.cn/simple 12 | pip install numpy==1.17.4 -i https://pypi.tuna.tsinghua.edu.cn/simple 13 | pip install imagecorruptions -i https://pypi.tuna.tsinghua.edu.cn/simple 14 | pip install requests -i https://pypi.tuna.tsinghua.edu.cn/simple -------------------------------------------------------------------------------- /mmcv/__init__.py: -------------------------------------------------------------------------------- 1 | # flake8: noqa 2 | from .arraymisc import * 3 | from .utils import * 4 | from .fileio import * 5 | from .opencv_info import * 6 | from .image import * 7 | from .video import * 8 | from .visualization import * 9 | from .version import __version__ 10 | # The following modules are not imported to this level, so mmcv may be used 11 | # without PyTorch. 12 | # - runner 13 | # - parallel 14 | -------------------------------------------------------------------------------- /mmcv/_ext.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/_ext.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /mmcv/arraymisc/__init__.py: -------------------------------------------------------------------------------- 1 | from .quantization import quantize, dequantize 2 | 3 | __all__ = ['quantize', 'dequantize'] 4 | -------------------------------------------------------------------------------- /mmcv/arraymisc/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/arraymisc/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/arraymisc/__pycache__/quantization.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/arraymisc/__pycache__/quantization.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/cnn/__init__.py: -------------------------------------------------------------------------------- 1 | from .alexnet import AlexNet 2 | from .vgg import VGG, make_vgg_layer 3 | from .resnet import ResNet, make_res_layer 4 | from .weight_init import (constant_init, xavier_init, normal_init, 5 | uniform_init, kaiming_init, caffe2_xavier_init) 6 | 7 | __all__ = [ 8 | 'AlexNet', 'VGG', 'make_vgg_layer', 'ResNet', 'make_res_layer', 9 | 'constant_init', 'xavier_init', 'normal_init', 'uniform_init', 10 | 'kaiming_init', 'caffe2_xavier_init' 11 | ] 12 | -------------------------------------------------------------------------------- /mmcv/cnn/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/cnn/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/cnn/__pycache__/alexnet.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/cnn/__pycache__/alexnet.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/cnn/__pycache__/resnet.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/cnn/__pycache__/resnet.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/cnn/__pycache__/vgg.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/cnn/__pycache__/vgg.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/cnn/__pycache__/weight_init.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/cnn/__pycache__/weight_init.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/fileio/__init__.py: -------------------------------------------------------------------------------- 1 | from .io import load, dump, register_handler 2 | from .handlers import BaseFileHandler, JsonHandler, PickleHandler, YamlHandler 3 | from .parse import list_from_file, dict_from_file 4 | 5 | __all__ = [ 6 | 'load', 'dump', 'register_handler', 'BaseFileHandler', 'JsonHandler', 7 | 'PickleHandler', 'YamlHandler', 'list_from_file', 'dict_from_file' 8 | ] 9 | -------------------------------------------------------------------------------- /mmcv/fileio/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/fileio/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/fileio/__pycache__/io.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/fileio/__pycache__/io.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/fileio/__pycache__/parse.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/fileio/__pycache__/parse.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/fileio/handlers/__init__.py: -------------------------------------------------------------------------------- 1 | from .base import BaseFileHandler 2 | from .json_handler import JsonHandler 3 | from .pickle_handler import PickleHandler 4 | from .yaml_handler import YamlHandler 5 | 6 | __all__ = ['BaseFileHandler', 'JsonHandler', 'PickleHandler', 'YamlHandler'] 7 | -------------------------------------------------------------------------------- /mmcv/fileio/handlers/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/fileio/handlers/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/fileio/handlers/__pycache__/base.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/fileio/handlers/__pycache__/base.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/fileio/handlers/__pycache__/json_handler.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/fileio/handlers/__pycache__/json_handler.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/fileio/handlers/__pycache__/pickle_handler.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/fileio/handlers/__pycache__/pickle_handler.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/fileio/handlers/__pycache__/yaml_handler.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/fileio/handlers/__pycache__/yaml_handler.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/fileio/handlers/base.py: -------------------------------------------------------------------------------- 1 | from abc import ABCMeta, abstractmethod 2 | 3 | 4 | class BaseFileHandler(object): 5 | 6 | __metaclass__ = ABCMeta # python 2 compatibility 7 | 8 | @abstractmethod 9 | def load_from_fileobj(self, file, **kwargs): 10 | pass 11 | 12 | @abstractmethod 13 | def dump_to_fileobj(self, obj, file, **kwargs): 14 | pass 15 | 16 | @abstractmethod 17 | def dump_to_str(self, obj, **kwargs): 18 | pass 19 | 20 | def load_from_path(self, filepath, mode='r', **kwargs): 21 | with open(filepath, mode) as f: 22 | return self.load_from_fileobj(f, **kwargs) 23 | 24 | def dump_to_path(self, obj, filepath, mode='w', **kwargs): 25 | with open(filepath, mode) as f: 26 | self.dump_to_fileobj(obj, f, **kwargs) 27 | -------------------------------------------------------------------------------- /mmcv/fileio/handlers/json_handler.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | from .base import BaseFileHandler 4 | 5 | 6 | class JsonHandler(BaseFileHandler): 7 | 8 | def load_from_fileobj(self, file): 9 | return json.load(file) 10 | 11 | def dump_to_fileobj(self, obj, file, **kwargs): 12 | json.dump(obj, file, **kwargs) 13 | 14 | def dump_to_str(self, obj, **kwargs): 15 | return json.dumps(obj, **kwargs) 16 | -------------------------------------------------------------------------------- /mmcv/fileio/handlers/pickle_handler.py: -------------------------------------------------------------------------------- 1 | from six.moves import cPickle as pickle 2 | 3 | from .base import BaseFileHandler 4 | 5 | 6 | class PickleHandler(BaseFileHandler): 7 | 8 | def load_from_fileobj(self, file, **kwargs): 9 | return pickle.load(file, **kwargs) 10 | 11 | def load_from_path(self, filepath, **kwargs): 12 | return super(PickleHandler, self).load_from_path( 13 | filepath, mode='rb', **kwargs) 14 | 15 | def dump_to_str(self, obj, **kwargs): 16 | kwargs.setdefault('protocol', 2) 17 | return pickle.dumps(obj, **kwargs) 18 | 19 | def dump_to_fileobj(self, obj, file, **kwargs): 20 | kwargs.setdefault('protocol', 2) 21 | pickle.dump(obj, file, **kwargs) 22 | 23 | def dump_to_path(self, obj, filepath, **kwargs): 24 | super(PickleHandler, self).dump_to_path( 25 | obj, filepath, mode='wb', **kwargs) 26 | -------------------------------------------------------------------------------- /mmcv/fileio/handlers/yaml_handler.py: -------------------------------------------------------------------------------- 1 | import yaml 2 | 3 | try: 4 | from yaml import CLoader as Loader, CDumper as Dumper 5 | except ImportError: 6 | from yaml import Loader, Dumper 7 | 8 | from .base import BaseFileHandler # isort:skip 9 | 10 | 11 | class YamlHandler(BaseFileHandler): 12 | 13 | def load_from_fileobj(self, file, **kwargs): 14 | kwargs.setdefault('Loader', Loader) 15 | return yaml.load(file, **kwargs) 16 | 17 | def dump_to_fileobj(self, obj, file, **kwargs): 18 | kwargs.setdefault('Dumper', Dumper) 19 | yaml.dump(obj, file, **kwargs) 20 | 21 | def dump_to_str(self, obj, **kwargs): 22 | kwargs.setdefault('Dumper', Dumper) 23 | return yaml.dump(obj, **kwargs) 24 | -------------------------------------------------------------------------------- /mmcv/fileio/parse.py: -------------------------------------------------------------------------------- 1 | def list_from_file(filename, prefix='', offset=0, max_num=0): 2 | """Load a text file and parse the content as a list of strings. 3 | 4 | Args: 5 | filename (str): Filename. 6 | prefix (str): The prefix to be inserted to the begining of each item. 7 | offset (int): The offset of lines. 8 | max_num (int): The maximum number of lines to be read, 9 | zeros and negatives mean no limitation. 10 | 11 | Returns: 12 | list[str]: A list of strings. 13 | """ 14 | cnt = 0 15 | item_list = [] 16 | with open(filename, 'r') as f: 17 | for _ in range(offset): 18 | f.readline() 19 | for line in f: 20 | if max_num > 0 and cnt >= max_num: 21 | break 22 | item_list.append(prefix + line.rstrip('\n')) 23 | cnt += 1 24 | return item_list 25 | 26 | 27 | def dict_from_file(filename, key_type=str): 28 | """Load a text file and parse the content as a dict. 29 | 30 | Each line of the text file will be two or more columns splited by 31 | whitespaces or tabs. The first column will be parsed as dict keys, and 32 | the following columns will be parsed as dict values. 33 | 34 | Args: 35 | filename(str): Filename. 36 | key_type(type): Type of the dict's keys. str is user by default and 37 | type conversion will be performed if specified. 38 | 39 | Returns: 40 | dict: The parsed contents. 41 | """ 42 | mapping = {} 43 | with open(filename, 'r') as f: 44 | for line in f: 45 | items = line.rstrip('\n').split() 46 | assert len(items) >= 2 47 | key = key_type(items[0]) 48 | val = items[1:] if len(items) > 2 else items[1] 49 | mapping[key] = val 50 | return mapping 51 | -------------------------------------------------------------------------------- /mmcv/image/__init__.py: -------------------------------------------------------------------------------- 1 | from .io import imread, imwrite, imfrombytes 2 | from .transforms import (bgr2gray, gray2bgr, bgr2rgb, rgb2bgr, bgr2hsv, 3 | hsv2bgr, bgr2hls, hls2bgr, iminvert, imflip, imrotate, 4 | imcrop, impad, impad_to_multiple, imnormalize, 5 | imdenormalize, imresize, imresize_like, imrescale) 6 | 7 | __all__ = [ 8 | 'imread', 'imwrite', 'imfrombytes', 'bgr2gray', 'gray2bgr', 'bgr2rgb', 9 | 'rgb2bgr', 'bgr2hsv', 'hsv2bgr', 'bgr2hls', 'hls2bgr', 'iminvert', 10 | 'imflip', 'imrotate', 'imcrop', 'impad', 'impad_to_multiple', 11 | 'imnormalize', 'imdenormalize', 'imresize', 'imresize_like', 'imrescale' 12 | ] 13 | -------------------------------------------------------------------------------- /mmcv/image/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/image/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/image/__pycache__/io.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/image/__pycache__/io.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/image/transforms/__init__.py: -------------------------------------------------------------------------------- 1 | from .colorspace import (bgr2gray, gray2bgr, bgr2rgb, rgb2bgr, bgr2hsv, 2 | hsv2bgr, bgr2hls, hls2bgr, iminvert) 3 | from .geometry import imflip, imrotate, imcrop, impad, impad_to_multiple 4 | from .normalize import imnormalize, imdenormalize 5 | from .resize import imresize, imresize_like, imrescale 6 | 7 | __all__ = [ 8 | 'bgr2gray', 'gray2bgr', 'bgr2rgb', 'rgb2bgr', 'bgr2hsv', 'hsv2bgr', 9 | 'bgr2hls', 'hls2bgr', 'iminvert', 'imflip', 'imrotate', 'imcrop', 'impad', 10 | 'impad_to_multiple', 'imnormalize', 'imdenormalize', 'imresize', 11 | 'imresize_like', 'imrescale' 12 | ] 13 | -------------------------------------------------------------------------------- /mmcv/image/transforms/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/image/transforms/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/image/transforms/__pycache__/colorspace.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/image/transforms/__pycache__/colorspace.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/image/transforms/__pycache__/geometry.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/image/transforms/__pycache__/geometry.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/image/transforms/__pycache__/normalize.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/image/transforms/__pycache__/normalize.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/image/transforms/__pycache__/resize.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/image/transforms/__pycache__/resize.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/image/transforms/normalize.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from .colorspace import bgr2rgb, rgb2bgr 4 | 5 | 6 | def imnormalize(img, mean, std, to_rgb=True): 7 | img = img.astype(np.float32) 8 | if to_rgb: 9 | img = bgr2rgb(img) 10 | return (img - mean) / std 11 | 12 | 13 | def imdenormalize(img, mean, std, to_bgr=True): 14 | img = (img * std) + mean 15 | if to_bgr: 16 | img = rgb2bgr(img) 17 | return img 18 | -------------------------------------------------------------------------------- /mmcv/opencv_info.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | 4 | def use_opencv2(): 5 | try: 6 | major_version = cv2.__version__.split('.')[0] 7 | except TypeError: # solves doc generation issue 8 | major_version = 4 9 | return major_version == '2' 10 | 11 | 12 | USE_OPENCV2 = use_opencv2() 13 | -------------------------------------------------------------------------------- /mmcv/parallel/__init__.py: -------------------------------------------------------------------------------- 1 | from .collate import collate 2 | from .data_container import DataContainer 3 | from .data_parallel import MMDataParallel 4 | from .distributed import MMDistributedDataParallel 5 | from .scatter_gather import scatter, scatter_kwargs 6 | 7 | __all__ = [ 8 | 'collate', 'DataContainer', 'MMDataParallel', 'MMDistributedDataParallel', 9 | 'scatter', 'scatter_kwargs' 10 | ] 11 | -------------------------------------------------------------------------------- /mmcv/parallel/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/parallel/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/parallel/__pycache__/_functions.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/parallel/__pycache__/_functions.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/parallel/__pycache__/collate.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/parallel/__pycache__/collate.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/parallel/__pycache__/data_container.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/parallel/__pycache__/data_container.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/parallel/__pycache__/data_parallel.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/parallel/__pycache__/data_parallel.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/parallel/__pycache__/distributed.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/parallel/__pycache__/distributed.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/parallel/__pycache__/scatter_gather.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/parallel/__pycache__/scatter_gather.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/parallel/data_parallel.py: -------------------------------------------------------------------------------- 1 | from torch.nn.parallel import DataParallel 2 | 3 | from .scatter_gather import scatter_kwargs 4 | 5 | 6 | class MMDataParallel(DataParallel): 7 | 8 | def scatter(self, inputs, kwargs, device_ids): 9 | return scatter_kwargs(inputs, kwargs, device_ids, dim=self.dim) 10 | -------------------------------------------------------------------------------- /mmcv/runner/__init__.py: -------------------------------------------------------------------------------- 1 | from .runner import Runner 2 | from .log_buffer import LogBuffer 3 | from .dist_utils import get_dist_info, init_dist, master_only 4 | from .hooks import (Hook, CheckpointHook, ClosureHook, LrUpdaterHook, 5 | OptimizerHook, OptimizerArchHook, IterTimerHook, DistSamplerSeedHook, 6 | LoggerHook, TextLoggerHook, PaviLoggerHook, 7 | TensorboardLoggerHook) 8 | from .checkpoint import (load_state_dict, load_checkpoint, weights_to_cpu, 9 | save_checkpoint) 10 | from .parallel_test import parallel_test 11 | from .priority import Priority, get_priority 12 | from .utils import (get_host_info, get_dist_info, master_only, get_time_str, 13 | obj_from_dict) 14 | 15 | __all__ = [ 16 | 'Runner', 'LogBuffer', 'Hook', 'CheckpointHook', 'ClosureHook', 17 | 'LrUpdaterHook', 'OptimizerHook', 'OptimizerArchHook', 'IterTimerHook', 'DistSamplerSeedHook', 18 | 'LoggerHook', 'TextLoggerHook', 'PaviLoggerHook', 'TensorboardLoggerHook', 19 | 'load_state_dict', 'load_checkpoint', 'weights_to_cpu', 'save_checkpoint', 20 | 'parallel_test', 'Priority', 'get_priority', 'get_host_info', 21 | 'get_dist_info', 'master_only', 'get_time_str', 'obj_from_dict', 22 | 'init_dist', 'get_dist_info', 'master_only' 23 | ] 24 | -------------------------------------------------------------------------------- /mmcv/runner/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/__pycache__/checkpoint.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/__pycache__/checkpoint.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/__pycache__/dist_utils.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/__pycache__/dist_utils.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/__pycache__/log_buffer.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/__pycache__/log_buffer.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/__pycache__/parallel_test.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/__pycache__/parallel_test.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/__pycache__/priority.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/__pycache__/priority.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/__pycache__/runner.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/__pycache__/runner.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/__pycache__/utils.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/__pycache__/utils.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/hooks/__init__.py: -------------------------------------------------------------------------------- 1 | from .hook import Hook 2 | from .checkpoint import CheckpointHook 3 | from .closure import ClosureHook 4 | from .lr_updater import LrUpdaterHook 5 | from .optimizer import OptimizerHook, OptimizerArchHook 6 | from .iter_timer import IterTimerHook 7 | from .sampler_seed import DistSamplerSeedHook 8 | from .memory import EmptyCacheHook 9 | from .logger import (LoggerHook, TextLoggerHook, PaviLoggerHook, 10 | TensorboardLoggerHook) 11 | 12 | __all__ = [ 13 | 'Hook', 'CheckpointHook', 'ClosureHook', 'LrUpdaterHook', 'OptimizerHook', 'OptimizerArchHook', 14 | 'IterTimerHook', 'DistSamplerSeedHook', 'EmptyCacheHook', 'LoggerHook', 15 | 'TextLoggerHook', 'PaviLoggerHook', 'TensorboardLoggerHook' 16 | ] 17 | -------------------------------------------------------------------------------- /mmcv/runner/hooks/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/hooks/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/hooks/__pycache__/checkpoint.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/hooks/__pycache__/checkpoint.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/hooks/__pycache__/closure.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/hooks/__pycache__/closure.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/hooks/__pycache__/hook.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/hooks/__pycache__/hook.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/hooks/__pycache__/iter_timer.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/hooks/__pycache__/iter_timer.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/hooks/__pycache__/lr_updater.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/hooks/__pycache__/lr_updater.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/hooks/__pycache__/memory.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/hooks/__pycache__/memory.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/hooks/__pycache__/optimizer.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/hooks/__pycache__/optimizer.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/hooks/__pycache__/sampler_seed.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/hooks/__pycache__/sampler_seed.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/hooks/checkpoint.py: -------------------------------------------------------------------------------- 1 | from ..utils import master_only 2 | from .hook import Hook 3 | 4 | 5 | class CheckpointHook(Hook): 6 | 7 | def __init__(self, 8 | interval=-1, 9 | save_optimizer=True, 10 | out_dir=None, 11 | **kwargs): 12 | self.interval = interval 13 | self.save_optimizer = save_optimizer 14 | self.out_dir = out_dir 15 | self.args = kwargs 16 | 17 | @master_only 18 | def after_train_epoch(self, runner): 19 | if not self.every_n_epochs(runner, self.interval): 20 | return 21 | 22 | if not self.out_dir: 23 | self.out_dir = runner.work_dir 24 | runner.save_checkpoint( 25 | self.out_dir, save_optimizer=self.save_optimizer, **self.args) 26 | -------------------------------------------------------------------------------- /mmcv/runner/hooks/closure.py: -------------------------------------------------------------------------------- 1 | from .hook import Hook 2 | 3 | 4 | class ClosureHook(Hook): 5 | 6 | def __init__(self, fn_name, fn): 7 | assert hasattr(self, fn_name) 8 | assert callable(fn) 9 | setattr(self, fn_name, fn) 10 | -------------------------------------------------------------------------------- /mmcv/runner/hooks/hook.py: -------------------------------------------------------------------------------- 1 | class Hook(object): 2 | 3 | def before_run(self, runner): 4 | pass 5 | 6 | def after_run(self, runner): 7 | pass 8 | 9 | def before_epoch(self, runner): 10 | pass 11 | 12 | def after_epoch(self, runner): 13 | pass 14 | 15 | def before_iter(self, runner): 16 | pass 17 | 18 | def after_iter(self, runner): 19 | pass 20 | 21 | def before_train_epoch(self, runner): 22 | self.before_epoch(runner) 23 | 24 | def before_val_epoch(self, runner): 25 | self.before_epoch(runner) 26 | 27 | def after_train_epoch(self, runner): 28 | self.after_epoch(runner) 29 | 30 | def after_val_epoch(self, runner): 31 | self.after_epoch(runner) 32 | 33 | def before_train_iter(self, runner): 34 | self.before_iter(runner) 35 | 36 | def before_val_iter(self, runner): 37 | self.before_iter(runner) 38 | 39 | def after_train_iter(self, runner): 40 | self.after_iter(runner) 41 | 42 | def arch_after_train_iter(self, runner): 43 | self.after_iter(runner) 44 | 45 | def after_val_iter(self, runner): 46 | self.after_iter(runner) 47 | 48 | def every_n_epochs(self, runner, n): 49 | return (runner.epoch + 1) % n == 0 if n > 0 else False 50 | 51 | def every_n_inner_iters(self, runner, n): 52 | return (runner.inner_iter + 1) % n == 0 if n > 0 else False 53 | 54 | def every_n_iters(self, runner, n): 55 | return (runner.iter + 1) % n == 0 if n > 0 else False 56 | 57 | def end_of_epoch(self, runner): 58 | return runner.inner_iter + 1 == len(runner.data_loader) 59 | -------------------------------------------------------------------------------- /mmcv/runner/hooks/iter_timer.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | from .hook import Hook 4 | 5 | 6 | class IterTimerHook(Hook): 7 | 8 | def before_epoch(self, runner): 9 | self.t = time.time() 10 | 11 | def before_iter(self, runner): 12 | runner.log_buffer.update({'data_time': time.time() - self.t}) 13 | 14 | def after_iter(self, runner): 15 | runner.log_buffer.update({'time': time.time() - self.t}) 16 | self.t = time.time() 17 | -------------------------------------------------------------------------------- /mmcv/runner/hooks/logger/__init__.py: -------------------------------------------------------------------------------- 1 | from .base import LoggerHook 2 | from .pavi import PaviLoggerHook 3 | from .tensorboard import TensorboardLoggerHook 4 | from .text import TextLoggerHook 5 | 6 | __all__ = [ 7 | 'LoggerHook', 'TextLoggerHook', 'PaviLoggerHook', 'TensorboardLoggerHook' 8 | ] 9 | -------------------------------------------------------------------------------- /mmcv/runner/hooks/logger/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/hooks/logger/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/hooks/logger/__pycache__/base.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/hooks/logger/__pycache__/base.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/hooks/logger/__pycache__/pavi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/hooks/logger/__pycache__/pavi.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/hooks/logger/__pycache__/tensorboard.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/hooks/logger/__pycache__/tensorboard.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/hooks/logger/__pycache__/text.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/runner/hooks/logger/__pycache__/text.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/runner/hooks/memory.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | from .hook import Hook 4 | 5 | 6 | class EmptyCacheHook(Hook): 7 | 8 | def __init__(self, before_epoch=False, after_epoch=True, after_iter=False): 9 | self._before_epoch = before_epoch 10 | self._after_epoch = after_epoch 11 | self._after_iter = after_iter 12 | 13 | def after_iter(self, runner): 14 | if self._after_iter: 15 | torch.cuda.empty_cache() 16 | 17 | def before_epoch(self, runner): 18 | if self._before_epoch: 19 | torch.cuda.empty_cache() 20 | 21 | def after_epoch(self, runner): 22 | if self._after_epoch: 23 | torch.cuda.empty_cache() 24 | -------------------------------------------------------------------------------- /mmcv/runner/hooks/optimizer.py: -------------------------------------------------------------------------------- 1 | from torch.nn.utils import clip_grad 2 | 3 | from .hook import Hook 4 | 5 | 6 | class OptimizerHook(Hook): 7 | def __init__(self, grad_clip=None): 8 | self.grad_clip = grad_clip 9 | 10 | def clip_grads(self, params): 11 | clip_grad.clip_grad_norm_( 12 | filter(lambda p: p.requires_grad, params), **self.grad_clip) 13 | 14 | def after_train_iter(self, runner): 15 | runner.optimizer.zero_grad() 16 | runner.outputs['loss'].backward() 17 | if self.grad_clip is not None: 18 | self.clip_grads(runner.model.parameters()) 19 | runner.optimizer.step() 20 | 21 | 22 | class OptimizerArchHook(Hook): 23 | def __init__(self, grad_clip=None): 24 | self.grad_clip = grad_clip 25 | 26 | def clip_grads(self, params): 27 | clip_grad.clip_grad_norm_( 28 | filter(lambda p: p.requires_grad, params), **self.grad_clip) 29 | 30 | def arch_after_train_iter(self, runner): 31 | if runner.optimizer_arch is not None: 32 | runner.optimizer_arch.zero_grad() 33 | runner.outputs_arch['loss'].backward() 34 | if runner.optimizer_arch is not None: 35 | runner.optimizer_arch.step() -------------------------------------------------------------------------------- /mmcv/runner/hooks/sampler_seed.py: -------------------------------------------------------------------------------- 1 | from .hook import Hook 2 | 3 | 4 | class DistSamplerSeedHook(Hook): 5 | 6 | def before_epoch(self, runner): 7 | runner.data_loader.sampler.set_epoch(runner.epoch) 8 | -------------------------------------------------------------------------------- /mmcv/runner/log_buffer.py: -------------------------------------------------------------------------------- 1 | from collections import OrderedDict 2 | 3 | import numpy as np 4 | 5 | 6 | class LogBuffer(object): 7 | 8 | def __init__(self): 9 | self.val_history = OrderedDict() 10 | self.n_history = OrderedDict() 11 | self.output = OrderedDict() 12 | self.ready = False 13 | 14 | def clear(self): 15 | self.val_history.clear() 16 | self.n_history.clear() 17 | self.clear_output() 18 | 19 | def clear_output(self): 20 | self.output.clear() 21 | self.ready = False 22 | 23 | def update(self, vars, count=1): 24 | assert isinstance(vars, dict) 25 | for key, var in vars.items(): 26 | if key not in self.val_history: 27 | self.val_history[key] = [] 28 | self.n_history[key] = [] 29 | self.val_history[key].append(var) 30 | self.n_history[key].append(count) 31 | 32 | def average(self, n=0): 33 | """Average latest n values or all values""" 34 | assert n >= 0 35 | for key in self.val_history: 36 | values = np.array(self.val_history[key][-n:]) 37 | nums = np.array(self.n_history[key][-n:]) 38 | avg = np.sum(values * nums) / np.sum(nums) 39 | self.output[key] = avg 40 | self.ready = True 41 | -------------------------------------------------------------------------------- /mmcv/runner/priority.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class Priority(Enum): 5 | """Hook priority levels. 6 | 7 | +------------+------------+ 8 | | Level | Value | 9 | +============+============+ 10 | | HIGHEST | 0 | 11 | +------------+------------+ 12 | | VERY_HIGH | 10 | 13 | +------------+------------+ 14 | | HIGH | 30 | 15 | +------------+------------+ 16 | | NORMAL | 50 | 17 | +------------+------------+ 18 | | LOW | 70 | 19 | +------------+------------+ 20 | | VERY_LOW | 90 | 21 | +------------+------------+ 22 | | LOWEST | 100 | 23 | +------------+------------+ 24 | """ 25 | 26 | HIGHEST = 0 27 | VERY_HIGH = 10 28 | HIGH = 30 29 | NORMAL = 50 30 | LOW = 70 31 | VERY_LOW = 90 32 | LOWEST = 100 33 | 34 | 35 | def get_priority(priority): 36 | """Get priority value. 37 | 38 | Args: 39 | priority (int or str or :obj:`Priority`): Priority. 40 | 41 | Returns: 42 | int: The priority value. 43 | """ 44 | if isinstance(priority, int): 45 | if priority < 0 or priority > 100: 46 | raise ValueError('priority must be between 0 and 100') 47 | return priority 48 | elif isinstance(priority, Priority): 49 | return priority.value 50 | elif isinstance(priority, str): 51 | return Priority[priority.upper()].value 52 | else: 53 | raise TypeError('priority must be an integer or Priority enum value') 54 | -------------------------------------------------------------------------------- /mmcv/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .config import ConfigDict, Config 2 | from .misc import (is_str, iter_cast, list_cast, tuple_cast, is_seq_of, 3 | is_list_of, is_tuple_of, slice_list, concat_list, 4 | check_prerequisites, requires_package, requires_executable) 5 | from .path import (is_filepath, fopen, check_file_exist, mkdir_or_exist, 6 | symlink, scandir, FileNotFoundError) 7 | from .progressbar import ProgressBar, track_progress, track_parallel_progress 8 | from .timer import Timer, TimerError, check_time 9 | 10 | __all__ = [ 11 | 'ConfigDict', 'Config', 'is_str', 'iter_cast', 'list_cast', 'tuple_cast', 12 | 'is_seq_of', 'is_list_of', 'is_tuple_of', 'slice_list', 'concat_list', 13 | 'check_prerequisites', 'requires_package', 'requires_executable', 14 | 'is_filepath', 'fopen', 'check_file_exist', 'mkdir_or_exist', 'symlink', 15 | 'scandir', 'FileNotFoundError', 'ProgressBar', 'track_progress', 16 | 'track_parallel_progress', 'Timer', 'TimerError', 'check_time' 17 | ] 18 | -------------------------------------------------------------------------------- /mmcv/utils/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/utils/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/utils/__pycache__/config.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/utils/__pycache__/config.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/utils/__pycache__/misc.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/utils/__pycache__/misc.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/utils/__pycache__/path.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/utils/__pycache__/path.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/utils/__pycache__/progressbar.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/utils/__pycache__/progressbar.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/utils/__pycache__/timer.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/utils/__pycache__/timer.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/version.py: -------------------------------------------------------------------------------- 1 | __version__ = '0.2.12' 2 | -------------------------------------------------------------------------------- /mmcv/video/__init__.py: -------------------------------------------------------------------------------- 1 | from .io import Cache, VideoReader, frames2video 2 | from .processing import convert_video, resize_video, cut_video, concat_video 3 | from .optflow import (flowread, flowwrite, quantize_flow, dequantize_flow, 4 | flow_warp) 5 | 6 | __all__ = [ 7 | 'Cache', 'VideoReader', 'frames2video', 'convert_video', 'resize_video', 8 | 'cut_video', 'concat_video', 'flowread', 'flowwrite', 'quantize_flow', 9 | 'dequantize_flow', 'flow_warp' 10 | ] 11 | -------------------------------------------------------------------------------- /mmcv/video/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/video/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/video/__pycache__/io.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/video/__pycache__/io.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/video/__pycache__/optflow.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/video/__pycache__/optflow.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/video/__pycache__/processing.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/video/__pycache__/processing.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/video/optflow_warp/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/video/optflow_warp/__init__.py -------------------------------------------------------------------------------- /mmcv/video/optflow_warp/flow_warp.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | void FlowWarp(double* img, double* flow1, double* out, const int height, 7 | const int width, const int channels, const int filling_value, 8 | const int interpolateMode); 9 | 10 | void BilinearInterpolate(const double* img, int width, int height, int channels, 11 | double x, double y, double* out); 12 | 13 | void NNInterpolate(const double* img, int width, int height, int channels, 14 | double x, double y, double* out); 15 | 16 | template 17 | inline T __min__(T a, T b) { 18 | return a > b ? b : a; 19 | } 20 | 21 | template 22 | inline T __max__(T a, T b) { 23 | return (a < b) ? b : a; 24 | } 25 | 26 | template 27 | inline T EnforceRange(const T x, const int MaxValue) { 28 | return __min__(__max__(x, 0), MaxValue); 29 | } 30 | -------------------------------------------------------------------------------- /mmcv/video/optflow_warp/flow_warp_module.pyx: -------------------------------------------------------------------------------- 1 | STUFF = "Hi" 2 | 3 | import numpy as np 4 | cimport numpy as np 5 | 6 | np.import_array() 7 | 8 | cdef extern from "flow_warp.hpp": 9 | void FlowWarp(double* img, double* flow1, double* out, const int height, const int width, const int channels, const int filling_value, const int interpolateMode) 10 | 11 | def flow_warp_c(np.ndarray[double, ndim=3, mode="c"] img_array not None, 12 | np.ndarray[double, ndim=3, mode="c"] flow_array not None, 13 | int filling_value=0, 14 | int interpolate_mode=1): 15 | 16 | out_array = np.zeros_like(img_array) 17 | 18 | FlowWarp( np.PyArray_DATA(img_array), 19 | np.PyArray_DATA(flow_array), 20 | np.PyArray_DATA(out_array), 21 | out_array.shape[0], 22 | out_array.shape[1], 23 | out_array.shape[2], 24 | filling_value, 25 | interpolate_mode) 26 | 27 | return out_array 28 | -------------------------------------------------------------------------------- /mmcv/visualization/__init__.py: -------------------------------------------------------------------------------- 1 | from .color import Color, color_val 2 | from .image import imshow, imshow_bboxes, imshow_det_bboxes 3 | from .optflow import flowshow, flow2rgb, make_color_wheel 4 | 5 | __all__ = [ 6 | 'Color', 'color_val', 'imshow', 'imshow_bboxes', 'imshow_det_bboxes', 7 | 'flowshow', 'flow2rgb', 'make_color_wheel' 8 | ] 9 | -------------------------------------------------------------------------------- /mmcv/visualization/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/visualization/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/visualization/__pycache__/color.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/visualization/__pycache__/color.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/visualization/__pycache__/image.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/visualization/__pycache__/image.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/visualization/__pycache__/optflow.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmcv/visualization/__pycache__/optflow.cpython-36.pyc -------------------------------------------------------------------------------- /mmcv/visualization/color.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | import numpy as np 4 | 5 | from mmcv.utils import is_str 6 | 7 | 8 | class Color(Enum): 9 | """An enum that defines common colors. 10 | 11 | Contains red, green, blue, cyan, yellow, magenta, white and black. 12 | """ 13 | red = (0, 0, 255) 14 | green = (0, 255, 0) 15 | blue = (255, 0, 0) 16 | cyan = (255, 255, 0) 17 | yellow = (0, 255, 255) 18 | magenta = (255, 0, 255) 19 | white = (255, 255, 255) 20 | black = (0, 0, 0) 21 | 22 | 23 | def color_val(color): 24 | """Convert various input to color tuples. 25 | 26 | Args: 27 | color (:obj:`Color`/str/tuple/int/ndarray): Color inputs 28 | 29 | Returns: 30 | tuple[int]: A tuple of 3 integers indicating BGR channels. 31 | """ 32 | if is_str(color): 33 | return Color[color].value 34 | elif isinstance(color, Color): 35 | return color.value 36 | elif isinstance(color, tuple): 37 | assert len(color) == 3 38 | for channel in color: 39 | assert channel >= 0 and channel <= 255 40 | return color 41 | elif isinstance(color, int): 42 | assert color >= 0 and color <= 255 43 | return color, color, color 44 | elif isinstance(color, np.ndarray): 45 | assert color.ndim == 1 and color.size == 3 46 | assert np.all((color >= 0) & (color <= 255)) 47 | color = color.astype(np.uint8) 48 | return tuple(color) 49 | else: 50 | raise TypeError('Invalid type for color: {}'.format(type(color))) 51 | -------------------------------------------------------------------------------- /mmdet/__init__.py: -------------------------------------------------------------------------------- 1 | from .version import __version__, short_version 2 | 3 | __all__ = ['__version__', 'short_version'] 4 | -------------------------------------------------------------------------------- /mmdet/apis/__init__.py: -------------------------------------------------------------------------------- 1 | from .env import get_root_logger, init_dist, set_random_seed 2 | from .inference import (inference_detector, init_detector, show_result, 3 | show_result_pyplot) 4 | from .train import train_detector 5 | 6 | __all__ = [ 7 | 'init_dist', 'get_root_logger', 'set_random_seed', 'train_detector', 8 | 'init_detector', 'inference_detector', 'show_result', 'show_result_pyplot' 9 | ] 10 | -------------------------------------------------------------------------------- /mmdet/apis/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/apis/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/apis/__pycache__/env.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/apis/__pycache__/env.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/apis/__pycache__/inference.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/apis/__pycache__/inference.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/apis/__pycache__/train.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/apis/__pycache__/train.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/__init__.py: -------------------------------------------------------------------------------- 1 | from .anchor import * # noqa: F401, F403 2 | from .bbox import * # noqa: F401, F403 3 | from .evaluation import * # noqa: F401, F403 4 | from .fp16 import * # noqa: F401, F403 5 | from .mask import * # noqa: F401, F403 6 | from .post_processing import * # noqa: F401, F403 7 | from .utils import * # noqa: F401, F403 8 | -------------------------------------------------------------------------------- /mmdet/core/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/anchor/__init__.py: -------------------------------------------------------------------------------- 1 | from .anchor_generator import AnchorGenerator 2 | from .anchor_target import anchor_target, anchor_inside_flags 3 | from .guided_anchor_target import ga_loc_target, ga_shape_target 4 | 5 | __all__ = [ 6 | 'AnchorGenerator', 'anchor_target', 'anchor_inside_flags', 'ga_loc_target', 7 | 'ga_shape_target' 8 | ] 9 | -------------------------------------------------------------------------------- /mmdet/core/anchor/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/anchor/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/anchor/__pycache__/anchor_generator.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/anchor/__pycache__/anchor_generator.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/anchor/__pycache__/anchor_target.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/anchor/__pycache__/anchor_target.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/anchor/__pycache__/guided_anchor_target.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/anchor/__pycache__/guided_anchor_target.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/__init__.py: -------------------------------------------------------------------------------- 1 | from .geometry import bbox_overlaps 2 | from .assigners import BaseAssigner, MaxIoUAssigner, AssignResult 3 | from .samplers import (BaseSampler, PseudoSampler, RandomSampler, 4 | InstanceBalancedPosSampler, IoUBalancedNegSampler, 5 | CombinedSampler, SamplingResult) 6 | from .assign_sampling import build_assigner, build_sampler, assign_and_sample 7 | from .transforms import (bbox2delta, delta2bbox, bbox_flip, bbox_mapping, 8 | bbox_mapping_back, bbox2roi, roi2bbox, bbox2result, 9 | distance2bbox) 10 | from .bbox_target import bbox_target 11 | 12 | __all__ = [ 13 | 'bbox_overlaps', 'BaseAssigner', 'MaxIoUAssigner', 'AssignResult', 14 | 'BaseSampler', 'PseudoSampler', 'RandomSampler', 15 | 'InstanceBalancedPosSampler', 'IoUBalancedNegSampler', 'CombinedSampler', 16 | 'SamplingResult', 'build_assigner', 'build_sampler', 'assign_and_sample', 17 | 'bbox2delta', 'delta2bbox', 'bbox_flip', 'bbox_mapping', 18 | 'bbox_mapping_back', 'bbox2roi', 'roi2bbox', 'bbox2result', 19 | 'distance2bbox', 'bbox_target' 20 | ] 21 | -------------------------------------------------------------------------------- /mmdet/core/bbox/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/__pycache__/assign_sampling.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/__pycache__/assign_sampling.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/__pycache__/bbox_target.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/__pycache__/bbox_target.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/__pycache__/geometry.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/__pycache__/geometry.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/__pycache__/transforms.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/__pycache__/transforms.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/assign_sampling.py: -------------------------------------------------------------------------------- 1 | import mmcv 2 | 3 | from . import assigners, samplers 4 | 5 | 6 | def build_assigner(cfg, **kwargs): 7 | if isinstance(cfg, assigners.BaseAssigner): 8 | return cfg 9 | elif isinstance(cfg, dict): 10 | return mmcv.runner.obj_from_dict(cfg, assigners, default_args=kwargs) 11 | else: 12 | raise TypeError('Invalid type {} for building a sampler'.format( 13 | type(cfg))) 14 | 15 | 16 | def build_sampler(cfg, **kwargs): 17 | if isinstance(cfg, samplers.BaseSampler): 18 | return cfg 19 | elif isinstance(cfg, dict): 20 | return mmcv.runner.obj_from_dict(cfg, samplers, default_args=kwargs) 21 | else: 22 | raise TypeError('Invalid type {} for building a sampler'.format( 23 | type(cfg))) 24 | 25 | 26 | def assign_and_sample(bboxes, gt_bboxes, gt_bboxes_ignore, gt_labels, cfg): 27 | bbox_assigner = build_assigner(cfg.assigner) 28 | bbox_sampler = build_sampler(cfg.sampler) 29 | assign_result = bbox_assigner.assign(bboxes, gt_bboxes, gt_bboxes_ignore, 30 | gt_labels) 31 | sampling_result = bbox_sampler.sample(assign_result, bboxes, gt_bboxes, 32 | gt_labels) 33 | return assign_result, sampling_result 34 | -------------------------------------------------------------------------------- /mmdet/core/bbox/assigners/__init__.py: -------------------------------------------------------------------------------- 1 | from .base_assigner import BaseAssigner 2 | from .max_iou_assigner import MaxIoUAssigner 3 | from .approx_max_iou_assigner import ApproxMaxIoUAssigner 4 | from .assign_result import AssignResult 5 | 6 | __all__ = [ 7 | 'BaseAssigner', 'MaxIoUAssigner', 'ApproxMaxIoUAssigner', 'AssignResult' 8 | ] 9 | -------------------------------------------------------------------------------- /mmdet/core/bbox/assigners/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/assigners/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/assigners/__pycache__/approx_max_iou_assigner.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/assigners/__pycache__/approx_max_iou_assigner.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/assigners/__pycache__/assign_result.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/assigners/__pycache__/assign_result.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/assigners/__pycache__/base_assigner.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/assigners/__pycache__/base_assigner.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/assigners/__pycache__/max_iou_assigner.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/assigners/__pycache__/max_iou_assigner.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/assigners/assign_result.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | class AssignResult(object): 5 | 6 | def __init__(self, num_gts, gt_inds, max_overlaps, labels=None): 7 | self.num_gts = num_gts 8 | self.gt_inds = gt_inds 9 | self.max_overlaps = max_overlaps 10 | self.labels = labels 11 | 12 | def add_gt_(self, gt_labels): 13 | self_inds = torch.arange( 14 | 1, len(gt_labels) + 1, dtype=torch.long, device=gt_labels.device) 15 | self.gt_inds = torch.cat([self_inds, self.gt_inds]) 16 | self.max_overlaps = torch.cat( 17 | [self.max_overlaps.new_ones(self.num_gts), self.max_overlaps]) 18 | if self.labels is not None: 19 | self.labels = torch.cat([gt_labels, self.labels]) 20 | -------------------------------------------------------------------------------- /mmdet/core/bbox/assigners/base_assigner.py: -------------------------------------------------------------------------------- 1 | from abc import ABCMeta, abstractmethod 2 | 3 | 4 | class BaseAssigner(metaclass=ABCMeta): 5 | 6 | @abstractmethod 7 | def assign(self, bboxes, gt_bboxes, gt_bboxes_ignore=None, gt_labels=None): 8 | pass 9 | -------------------------------------------------------------------------------- /mmdet/core/bbox/samplers/__init__.py: -------------------------------------------------------------------------------- 1 | from .base_sampler import BaseSampler 2 | from .pseudo_sampler import PseudoSampler 3 | from .random_sampler import RandomSampler 4 | from .instance_balanced_pos_sampler import InstanceBalancedPosSampler 5 | from .iou_balanced_neg_sampler import IoUBalancedNegSampler 6 | from .combined_sampler import CombinedSampler 7 | from .ohem_sampler import OHEMSampler 8 | from .sampling_result import SamplingResult 9 | 10 | __all__ = [ 11 | 'BaseSampler', 'PseudoSampler', 'RandomSampler', 12 | 'InstanceBalancedPosSampler', 'IoUBalancedNegSampler', 'CombinedSampler', 13 | 'OHEMSampler', 'SamplingResult' 14 | ] 15 | -------------------------------------------------------------------------------- /mmdet/core/bbox/samplers/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/samplers/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/samplers/__pycache__/base_sampler.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/samplers/__pycache__/base_sampler.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/samplers/__pycache__/combined_sampler.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/samplers/__pycache__/combined_sampler.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/samplers/__pycache__/instance_balanced_pos_sampler.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/samplers/__pycache__/instance_balanced_pos_sampler.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/samplers/__pycache__/iou_balanced_neg_sampler.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/samplers/__pycache__/iou_balanced_neg_sampler.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/samplers/__pycache__/ohem_sampler.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/samplers/__pycache__/ohem_sampler.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/samplers/__pycache__/pseudo_sampler.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/samplers/__pycache__/pseudo_sampler.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/samplers/__pycache__/random_sampler.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/samplers/__pycache__/random_sampler.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/samplers/__pycache__/sampling_result.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/bbox/samplers/__pycache__/sampling_result.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/bbox/samplers/combined_sampler.py: -------------------------------------------------------------------------------- 1 | from .base_sampler import BaseSampler 2 | from ..assign_sampling import build_sampler 3 | 4 | 5 | class CombinedSampler(BaseSampler): 6 | 7 | def __init__(self, pos_sampler, neg_sampler, **kwargs): 8 | super(CombinedSampler, self).__init__(**kwargs) 9 | self.pos_sampler = build_sampler(pos_sampler, **kwargs) 10 | self.neg_sampler = build_sampler(neg_sampler, **kwargs) 11 | 12 | def _sample_pos(self, **kwargs): 13 | raise NotImplementedError 14 | 15 | def _sample_neg(self, **kwargs): 16 | raise NotImplementedError 17 | -------------------------------------------------------------------------------- /mmdet/core/bbox/samplers/instance_balanced_pos_sampler.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import torch 3 | 4 | from .random_sampler import RandomSampler 5 | 6 | 7 | class InstanceBalancedPosSampler(RandomSampler): 8 | 9 | def _sample_pos(self, assign_result, num_expected, **kwargs): 10 | pos_inds = torch.nonzero(assign_result.gt_inds > 0) 11 | if pos_inds.numel() != 0: 12 | pos_inds = pos_inds.squeeze(1) 13 | if pos_inds.numel() <= num_expected: 14 | return pos_inds 15 | else: 16 | unique_gt_inds = assign_result.gt_inds[pos_inds].unique() 17 | num_gts = len(unique_gt_inds) 18 | num_per_gt = int(round(num_expected / float(num_gts)) + 1) 19 | sampled_inds = [] 20 | for i in unique_gt_inds: 21 | inds = torch.nonzero(assign_result.gt_inds == i.item()) 22 | if inds.numel() != 0: 23 | inds = inds.squeeze(1) 24 | else: 25 | continue 26 | if len(inds) > num_per_gt: 27 | inds = self.random_choice(inds, num_per_gt) 28 | sampled_inds.append(inds) 29 | sampled_inds = torch.cat(sampled_inds) 30 | if len(sampled_inds) < num_expected: 31 | num_extra = num_expected - len(sampled_inds) 32 | extra_inds = np.array( 33 | list(set(pos_inds.cpu()) - set(sampled_inds.cpu()))) 34 | if len(extra_inds) > num_extra: 35 | extra_inds = self.random_choice(extra_inds, num_extra) 36 | extra_inds = torch.from_numpy(extra_inds).to( 37 | assign_result.gt_inds.device).long() 38 | sampled_inds = torch.cat([sampled_inds, extra_inds]) 39 | elif len(sampled_inds) > num_expected: 40 | sampled_inds = self.random_choice(sampled_inds, num_expected) 41 | return sampled_inds 42 | -------------------------------------------------------------------------------- /mmdet/core/bbox/samplers/pseudo_sampler.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | from .base_sampler import BaseSampler 4 | from .sampling_result import SamplingResult 5 | 6 | 7 | class PseudoSampler(BaseSampler): 8 | 9 | def __init__(self, **kwargs): 10 | pass 11 | 12 | def _sample_pos(self, **kwargs): 13 | raise NotImplementedError 14 | 15 | def _sample_neg(self, **kwargs): 16 | raise NotImplementedError 17 | 18 | def sample(self, assign_result, bboxes, gt_bboxes, **kwargs): 19 | pos_inds = torch.nonzero( 20 | assign_result.gt_inds > 0).squeeze(-1).unique() 21 | neg_inds = torch.nonzero( 22 | assign_result.gt_inds == 0).squeeze(-1).unique() 23 | gt_flags = bboxes.new_zeros(bboxes.shape[0], dtype=torch.uint8) 24 | sampling_result = SamplingResult(pos_inds, neg_inds, bboxes, gt_bboxes, 25 | assign_result, gt_flags) 26 | return sampling_result 27 | -------------------------------------------------------------------------------- /mmdet/core/bbox/samplers/sampling_result.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | class SamplingResult(object): 5 | 6 | def __init__(self, pos_inds, neg_inds, bboxes, gt_bboxes, assign_result, 7 | gt_flags): 8 | self.pos_inds = pos_inds 9 | self.neg_inds = neg_inds 10 | self.pos_bboxes = bboxes[pos_inds] 11 | self.neg_bboxes = bboxes[neg_inds] 12 | self.pos_is_gt = gt_flags[pos_inds] 13 | 14 | self.num_gts = gt_bboxes.shape[0] 15 | self.pos_assigned_gt_inds = assign_result.gt_inds[pos_inds] - 1 16 | self.pos_gt_bboxes = gt_bboxes[self.pos_assigned_gt_inds, :] 17 | if assign_result.labels is not None: 18 | self.pos_gt_labels = assign_result.labels[pos_inds] 19 | else: 20 | self.pos_gt_labels = None 21 | 22 | @property 23 | def bboxes(self): 24 | return torch.cat([self.pos_bboxes, self.neg_bboxes]) 25 | -------------------------------------------------------------------------------- /mmdet/core/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | from .class_names import (coco_classes, dataset_aliases, get_classes, 2 | imagenet_det_classes, imagenet_vid_classes, 3 | voc_classes) 4 | from .eval_hooks import DistEvalHook 5 | from .mean_ap import average_precision, eval_map, print_map_summary 6 | from .recall import (eval_recalls, plot_iou_recall, plot_num_recall, 7 | print_recall_summary) 8 | 9 | __all__ = [ 10 | 'voc_classes', 'imagenet_det_classes', 'imagenet_vid_classes', 11 | 'coco_classes', 'dataset_aliases', 'get_classes', 'DistEvalHook', 12 | 'average_precision', 'eval_map', 'print_map_summary', 'eval_recalls', 13 | 'print_recall_summary', 'plot_num_recall', 'plot_iou_recall' 14 | ] 15 | -------------------------------------------------------------------------------- /mmdet/core/evaluation/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/evaluation/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/evaluation/__pycache__/bbox_overlaps.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/evaluation/__pycache__/bbox_overlaps.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/evaluation/__pycache__/class_names.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/evaluation/__pycache__/class_names.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/evaluation/__pycache__/eval_hooks.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/evaluation/__pycache__/eval_hooks.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/evaluation/__pycache__/mean_ap.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/evaluation/__pycache__/mean_ap.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/evaluation/__pycache__/recall.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/evaluation/__pycache__/recall.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/evaluation/bbox_overlaps.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | def bbox_overlaps(bboxes1, bboxes2, mode='iou'): 5 | """Calculate the ious between each bbox of bboxes1 and bboxes2. 6 | 7 | Args: 8 | bboxes1(ndarray): shape (n, 4) 9 | bboxes2(ndarray): shape (k, 4) 10 | mode(str): iou (intersection over union) or iof (intersection 11 | over foreground) 12 | 13 | Returns: 14 | ious(ndarray): shape (n, k) 15 | """ 16 | 17 | assert mode in ['iou', 'iof'] 18 | 19 | bboxes1 = bboxes1.astype(np.float32) 20 | bboxes2 = bboxes2.astype(np.float32) 21 | rows = bboxes1.shape[0] 22 | cols = bboxes2.shape[0] 23 | ious = np.zeros((rows, cols), dtype=np.float32) 24 | if rows * cols == 0: 25 | return ious 26 | exchange = False 27 | if bboxes1.shape[0] > bboxes2.shape[0]: 28 | bboxes1, bboxes2 = bboxes2, bboxes1 29 | ious = np.zeros((cols, rows), dtype=np.float32) 30 | exchange = True 31 | area1 = (bboxes1[:, 2] - bboxes1[:, 0] + 1) * ( 32 | bboxes1[:, 3] - bboxes1[:, 1] + 1) 33 | area2 = (bboxes2[:, 2] - bboxes2[:, 0] + 1) * ( 34 | bboxes2[:, 3] - bboxes2[:, 1] + 1) 35 | for i in range(bboxes1.shape[0]): 36 | x_start = np.maximum(bboxes1[i, 0], bboxes2[:, 0]) 37 | y_start = np.maximum(bboxes1[i, 1], bboxes2[:, 1]) 38 | x_end = np.minimum(bboxes1[i, 2], bboxes2[:, 2]) 39 | y_end = np.minimum(bboxes1[i, 3], bboxes2[:, 3]) 40 | overlap = np.maximum(x_end - x_start + 1, 0) * np.maximum( 41 | y_end - y_start + 1, 0) 42 | if mode == 'iou': 43 | union = area1[i] + area2 - overlap 44 | else: 45 | union = area1[i] if not exchange else area2 46 | ious[i, :] = overlap / union 47 | if exchange: 48 | ious = ious.T 49 | return ious 50 | -------------------------------------------------------------------------------- /mmdet/core/fp16/__init__.py: -------------------------------------------------------------------------------- 1 | from .decorators import auto_fp16, force_fp32 2 | from .hooks import Fp16OptimizerHook, wrap_fp16_model 3 | 4 | __all__ = ['auto_fp16', 'force_fp32', 'Fp16OptimizerHook', 'wrap_fp16_model'] 5 | -------------------------------------------------------------------------------- /mmdet/core/fp16/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/fp16/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/fp16/__pycache__/decorators.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/fp16/__pycache__/decorators.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/fp16/__pycache__/hooks.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/fp16/__pycache__/hooks.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/fp16/__pycache__/utils.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/fp16/__pycache__/utils.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/fp16/utils.py: -------------------------------------------------------------------------------- 1 | from collections import abc 2 | 3 | import numpy as np 4 | import torch 5 | 6 | 7 | def cast_tensor_type(inputs, src_type, dst_type): 8 | if isinstance(inputs, torch.Tensor): 9 | return inputs.to(dst_type) 10 | elif isinstance(inputs, str): 11 | return inputs 12 | elif isinstance(inputs, np.ndarray): 13 | return inputs 14 | elif isinstance(inputs, abc.Mapping): 15 | return type(inputs)({ 16 | k: cast_tensor_type(v, src_type, dst_type) 17 | for k, v in inputs.items() 18 | }) 19 | elif isinstance(inputs, abc.Iterable): 20 | return type(inputs)( 21 | cast_tensor_type(item, src_type, dst_type) for item in inputs) 22 | else: 23 | return inputs 24 | -------------------------------------------------------------------------------- /mmdet/core/mask/__init__.py: -------------------------------------------------------------------------------- 1 | from .utils import split_combined_polys 2 | from .mask_target import mask_target 3 | 4 | __all__ = ['split_combined_polys', 'mask_target'] 5 | -------------------------------------------------------------------------------- /mmdet/core/mask/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/mask/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/mask/__pycache__/mask_target.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/mask/__pycache__/mask_target.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/mask/__pycache__/utils.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/mask/__pycache__/utils.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/mask/mask_target.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | import mmcv 4 | 5 | 6 | def mask_target(pos_proposals_list, pos_assigned_gt_inds_list, gt_masks_list, 7 | cfg): 8 | cfg_list = [cfg for _ in range(len(pos_proposals_list))] 9 | mask_targets = map(mask_target_single, pos_proposals_list, 10 | pos_assigned_gt_inds_list, gt_masks_list, cfg_list) 11 | mask_targets = torch.cat(list(mask_targets)) 12 | return mask_targets 13 | 14 | 15 | def mask_target_single(pos_proposals, pos_assigned_gt_inds, gt_masks, cfg): 16 | mask_size = cfg.mask_size 17 | num_pos = pos_proposals.size(0) 18 | mask_targets = [] 19 | if num_pos > 0: 20 | proposals_np = pos_proposals.cpu().numpy() 21 | pos_assigned_gt_inds = pos_assigned_gt_inds.cpu().numpy() 22 | for i in range(num_pos): 23 | gt_mask = gt_masks[pos_assigned_gt_inds[i]] 24 | bbox = proposals_np[i, :].astype(np.int32) 25 | x1, y1, x2, y2 = bbox 26 | w = np.maximum(x2 - x1 + 1, 1) 27 | h = np.maximum(y2 - y1 + 1, 1) 28 | # mask is uint8 both before and after resizing 29 | target = mmcv.imresize(gt_mask[y1:y1 + h, x1:x1 + w], 30 | (mask_size, mask_size)) 31 | mask_targets.append(target) 32 | mask_targets = torch.from_numpy(np.stack(mask_targets)).float().to( 33 | pos_proposals.device) 34 | else: 35 | mask_targets = pos_proposals.new_zeros((0, mask_size, mask_size)) 36 | return mask_targets 37 | -------------------------------------------------------------------------------- /mmdet/core/mask/utils.py: -------------------------------------------------------------------------------- 1 | import mmcv 2 | 3 | 4 | def split_combined_polys(polys, poly_lens, polys_per_mask): 5 | """Split the combined 1-D polys into masks. 6 | 7 | A mask is represented as a list of polys, and a poly is represented as 8 | a 1-D array. In dataset, all masks are concatenated into a single 1-D 9 | tensor. Here we need to split the tensor into original representations. 10 | 11 | Args: 12 | polys (list): a list (length = image num) of 1-D tensors 13 | poly_lens (list): a list (length = image num) of poly length 14 | polys_per_mask (list): a list (length = image num) of poly number 15 | of each mask 16 | 17 | Returns: 18 | list: a list (length = image num) of list (length = mask num) of 19 | list (length = poly num) of numpy array 20 | """ 21 | mask_polys_list = [] 22 | for img_id in range(len(polys)): 23 | polys_single = polys[img_id] 24 | polys_lens_single = poly_lens[img_id].tolist() 25 | polys_per_mask_single = polys_per_mask[img_id].tolist() 26 | 27 | split_polys = mmcv.slice_list(polys_single, polys_lens_single) 28 | mask_polys = mmcv.slice_list(split_polys, polys_per_mask_single) 29 | mask_polys_list.append(mask_polys) 30 | return mask_polys_list 31 | -------------------------------------------------------------------------------- /mmdet/core/post_processing/__init__.py: -------------------------------------------------------------------------------- 1 | from .bbox_nms import multiclass_nms 2 | from .merge_augs import (merge_aug_proposals, merge_aug_bboxes, 3 | merge_aug_scores, merge_aug_masks) 4 | 5 | __all__ = [ 6 | 'multiclass_nms', 'merge_aug_proposals', 'merge_aug_bboxes', 7 | 'merge_aug_scores', 'merge_aug_masks' 8 | ] 9 | -------------------------------------------------------------------------------- /mmdet/core/post_processing/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/post_processing/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/post_processing/__pycache__/bbox_nms.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/post_processing/__pycache__/bbox_nms.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/post_processing/__pycache__/merge_augs.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/post_processing/__pycache__/merge_augs.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .dist_utils import allreduce_grads, DistOptimizerHook, DistOptimizerArchHook 2 | from .misc import tensor2imgs, unmap, multi_apply 3 | 4 | __all__ = [ 5 | 'allreduce_grads', 'DistOptimizerHook', 'tensor2imgs', 'unmap', 6 | 'multi_apply', 'DistOptimizerArchHook' 7 | ] 8 | -------------------------------------------------------------------------------- /mmdet/core/utils/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/utils/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/utils/__pycache__/dist_utils.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/utils/__pycache__/dist_utils.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/utils/__pycache__/misc.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/core/utils/__pycache__/misc.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/core/utils/misc.py: -------------------------------------------------------------------------------- 1 | from functools import partial 2 | 3 | import mmcv 4 | import numpy as np 5 | from six.moves import map, zip 6 | 7 | 8 | def tensor2imgs(tensor, mean=(0, 0, 0), std=(1, 1, 1), to_rgb=True): 9 | num_imgs = tensor.size(0) 10 | mean = np.array(mean, dtype=np.float32) 11 | std = np.array(std, dtype=np.float32) 12 | imgs = [] 13 | for img_id in range(num_imgs): 14 | img = tensor[img_id, ...].cpu().numpy().transpose(1, 2, 0) 15 | img = mmcv.imdenormalize( 16 | img, mean, std, to_bgr=to_rgb).astype(np.uint8) 17 | imgs.append(np.ascontiguousarray(img)) 18 | return imgs 19 | 20 | 21 | def multi_apply(func, *args, **kwargs): 22 | pfunc = partial(func, **kwargs) if kwargs else func 23 | map_results = map(pfunc, *args) 24 | return tuple(map(list, zip(*map_results))) 25 | 26 | 27 | def unmap(data, count, inds, fill=0): 28 | """ Unmap a subset of item (data) back to the original set of items (of 29 | size count) """ 30 | if data.dim() == 1: 31 | ret = data.new_full((count, ), fill) 32 | ret[inds] = data 33 | else: 34 | new_size = (count, ) + data.size()[1:] 35 | ret = data.new_full(new_size, fill) 36 | ret[inds, :] = data 37 | return ret 38 | -------------------------------------------------------------------------------- /mmdet/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | from .custom import CustomDataset 2 | from .cityscapes import CityscapesDataset 3 | from .xml_style import XMLDataset 4 | from .coco import CocoDataset 5 | from .voc import VOCDataset 6 | from .wider_face import WIDERFaceDataset 7 | from .loader import GroupSampler, DistributedGroupSampler, build_dataloader, build_dataloader_arch 8 | from .dataset_wrappers import ConcatDataset, RepeatDataset 9 | from .registry import DATASETS 10 | from .builder import build_dataset 11 | 12 | __all__ = [ 13 | 'CustomDataset', 'XMLDataset', 'CocoDataset', 'VOCDataset', 14 | 'CityscapesDataset', 'GroupSampler', 'DistributedGroupSampler', 15 | 'build_dataloader', 'ConcatDataset', 'RepeatDataset', 'WIDERFaceDataset', 16 | 'DATASETS', 'build_dataset', 'build_dataloader_arch' 17 | ] -------------------------------------------------------------------------------- /mmdet/datasets/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/__pycache__/builder.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/__pycache__/builder.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/__pycache__/cityscapes.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/__pycache__/cityscapes.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/__pycache__/coco.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/__pycache__/coco.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/__pycache__/custom.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/__pycache__/custom.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/__pycache__/dataset_wrappers.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/__pycache__/dataset_wrappers.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/__pycache__/registry.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/__pycache__/registry.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/__pycache__/voc.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/__pycache__/voc.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/__pycache__/wider_face.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/__pycache__/wider_face.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/__pycache__/xml_style.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/__pycache__/xml_style.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/builder.py: -------------------------------------------------------------------------------- 1 | import copy 2 | 3 | from mmdet.utils import build_from_cfg 4 | from .dataset_wrappers import ConcatDataset, RepeatDataset 5 | from .registry import DATASETS 6 | 7 | 8 | def _concat_dataset(cfg, default_args=None): 9 | ann_files = cfg['ann_file'] 10 | img_prefixes = cfg.get('img_prefix', None) 11 | seg_prefixes = cfg.get('seg_prefix', None) 12 | proposal_files = cfg.get('proposal_file', None) 13 | 14 | datasets = [] 15 | num_dset = len(ann_files) 16 | for i in range(num_dset): 17 | data_cfg = copy.deepcopy(cfg) 18 | data_cfg['ann_file'] = ann_files[i] 19 | if isinstance(img_prefixes, (list, tuple)): 20 | data_cfg['img_prefix'] = img_prefixes[i] 21 | if isinstance(seg_prefixes, (list, tuple)): 22 | data_cfg['seg_prefix'] = seg_prefixes[i] 23 | if isinstance(proposal_files, (list, tuple)): 24 | data_cfg['proposal_file'] = proposal_files[i] 25 | datasets.append(build_dataset(data_cfg, default_args)) 26 | 27 | return ConcatDataset(datasets) 28 | 29 | 30 | def build_dataset(cfg, default_args=None): 31 | if isinstance(cfg, (list, tuple)): 32 | dataset = ConcatDataset([build_dataset(c, default_args) for c in cfg]) 33 | elif cfg['type'] == 'RepeatDataset': 34 | dataset = RepeatDataset( 35 | build_dataset(cfg['dataset'], default_args), cfg['times']) 36 | elif isinstance(cfg['ann_file'], (list, tuple)): 37 | dataset = _concat_dataset(cfg, default_args) 38 | else: 39 | dataset = build_from_cfg(cfg, DATASETS, default_args) 40 | 41 | return dataset 42 | -------------------------------------------------------------------------------- /mmdet/datasets/cityscapes.py: -------------------------------------------------------------------------------- 1 | from .coco import CocoDataset 2 | from .registry import DATASETS 3 | 4 | 5 | @DATASETS.register_module 6 | class CityscapesDataset(CocoDataset): 7 | 8 | CLASSES = ('person', 'rider', 'car', 'truck', 'bus', 'train', 'motorcycle', 9 | 'bicycle') 10 | -------------------------------------------------------------------------------- /mmdet/datasets/dataset_wrappers.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from torch.utils.data.dataset import ConcatDataset as _ConcatDataset 3 | 4 | from .registry import DATASETS 5 | 6 | 7 | @DATASETS.register_module 8 | class ConcatDataset(_ConcatDataset): 9 | """A wrapper of concatenated dataset. 10 | 11 | Same as :obj:`torch.utils.data.dataset.ConcatDataset`, but 12 | concat the group flag for image aspect ratio. 13 | 14 | Args: 15 | datasets (list[:obj:`Dataset`]): A list of datasets. 16 | """ 17 | 18 | def __init__(self, datasets): 19 | super(ConcatDataset, self).__init__(datasets) 20 | self.CLASSES = datasets[0].CLASSES 21 | if hasattr(datasets[0], 'flag'): 22 | flags = [] 23 | for i in range(0, len(datasets)): 24 | flags.append(datasets[i].flag) 25 | self.flag = np.concatenate(flags) 26 | 27 | 28 | @DATASETS.register_module 29 | class RepeatDataset(object): 30 | """A wrapper of repeated dataset. 31 | 32 | The length of repeated dataset will be `times` larger than the original 33 | dataset. This is useful when the data loading time is long but the dataset 34 | is small. Using RepeatDataset can reduce the data loading time between 35 | epochs. 36 | 37 | Args: 38 | dataset (:obj:`Dataset`): The dataset to be repeated. 39 | times (int): Repeat times. 40 | """ 41 | 42 | def __init__(self, dataset, times): 43 | self.dataset = dataset 44 | self.times = times 45 | self.CLASSES = dataset.CLASSES 46 | if hasattr(self.dataset, 'flag'): 47 | self.flag = np.tile(self.dataset.flag, times) 48 | 49 | self._ori_len = len(self.dataset) 50 | 51 | def __getitem__(self, idx): 52 | return self.dataset[idx % self._ori_len] 53 | 54 | def __len__(self): 55 | return self.times * self._ori_len 56 | -------------------------------------------------------------------------------- /mmdet/datasets/loader/__init__.py: -------------------------------------------------------------------------------- 1 | from .build_loader import build_dataloader, build_dataloader_arch 2 | from .sampler import DistributedGroupSampler, GroupSampler 3 | 4 | __all__ = ['GroupSampler', 'DistributedGroupSampler', 'build_dataloader', 'build_dataloader_arch'] 5 | -------------------------------------------------------------------------------- /mmdet/datasets/loader/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/loader/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/loader/__pycache__/build_loader.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/loader/__pycache__/build_loader.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/loader/__pycache__/sampler.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/loader/__pycache__/sampler.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/pipelines/__init__.py: -------------------------------------------------------------------------------- 1 | from .compose import Compose 2 | from .formating import (Collect, ImageToTensor, ToDataContainer, ToTensor, 3 | Transpose, to_tensor) 4 | from .loading import LoadAnnotations, LoadImageFromFile, LoadProposals 5 | from .test_aug import MultiScaleFlipAug 6 | from .transforms import (Albu, Expand, MinIoURandomCrop, Normalize, Pad, 7 | PhotoMetricDistortion, RandomCrop, RandomFlip, Resize, 8 | SegResizeFlipPadRescale) 9 | 10 | __all__ = [ 11 | 'Compose', 'to_tensor', 'ToTensor', 'ImageToTensor', 'ToDataContainer', 12 | 'Transpose', 'Collect', 'LoadAnnotations', 'LoadImageFromFile', 13 | 'LoadProposals', 'MultiScaleFlipAug', 'Resize', 'RandomFlip', 'Pad', 14 | 'RandomCrop', 'Normalize', 'SegResizeFlipPadRescale', 'MinIoURandomCrop', 15 | 'Expand', 'PhotoMetricDistortion', 'Albu' 16 | ] 17 | -------------------------------------------------------------------------------- /mmdet/datasets/pipelines/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/pipelines/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/pipelines/__pycache__/compose.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/pipelines/__pycache__/compose.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/pipelines/__pycache__/formating.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/pipelines/__pycache__/formating.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/pipelines/__pycache__/loading.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/pipelines/__pycache__/loading.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/pipelines/__pycache__/test_aug.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/pipelines/__pycache__/test_aug.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/pipelines/__pycache__/transforms.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/datasets/pipelines/__pycache__/transforms.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/datasets/pipelines/compose.py: -------------------------------------------------------------------------------- 1 | import collections 2 | 3 | from mmdet.utils import build_from_cfg 4 | from ..registry import PIPELINES 5 | 6 | 7 | @PIPELINES.register_module 8 | class Compose(object): 9 | 10 | def __init__(self, transforms): 11 | assert isinstance(transforms, collections.abc.Sequence) 12 | self.transforms = [] 13 | for transform in transforms: 14 | if isinstance(transform, dict): 15 | transform = build_from_cfg(transform, PIPELINES) 16 | self.transforms.append(transform) 17 | elif callable(transform): 18 | self.transforms.append(transform) 19 | else: 20 | raise TypeError('transform must be callable or a dict') 21 | 22 | def __call__(self, data): 23 | for t in self.transforms: 24 | data = t(data) 25 | if data is None: 26 | return None 27 | return data 28 | 29 | def __repr__(self): 30 | format_string = self.__class__.__name__ + '(' 31 | for t in self.transforms: 32 | format_string += '\n' 33 | format_string += ' {0}'.format(t) 34 | format_string += '\n)' 35 | return format_string 36 | -------------------------------------------------------------------------------- /mmdet/datasets/pipelines/test_aug.py: -------------------------------------------------------------------------------- 1 | import mmcv 2 | 3 | from ..registry import PIPELINES 4 | from .compose import Compose 5 | 6 | 7 | @PIPELINES.register_module 8 | class MultiScaleFlipAug(object): 9 | 10 | def __init__(self, transforms, img_scale, flip=False): 11 | self.transforms = Compose(transforms) 12 | self.img_scale = img_scale if isinstance(img_scale, list) else [img_scale] 13 | assert mmcv.is_list_of(self.img_scale, tuple) 14 | self.flip = flip 15 | 16 | def __call__(self, results): 17 | aug_data = [] 18 | flip_aug = [False, True] if self.flip else [False] 19 | for scale in self.img_scale: 20 | for flip in flip_aug: 21 | _results = results.copy() 22 | _results['scale'] = scale 23 | _results['flip'] = flip 24 | data = self.transforms(_results) 25 | aug_data.append(data) 26 | # list of dict to dict of list 27 | aug_data_dict = {key: [] for key in aug_data[0]} 28 | for data in aug_data: 29 | for key, val in data.items(): 30 | aug_data_dict[key].append(val) 31 | return aug_data_dict 32 | 33 | def __repr__(self): 34 | repr_str = self.__class__.__name__ 35 | repr_str += '(transforms={}, img_scale={}, flip={})'.format( 36 | self.transforms, self.img_scale, self.flip) 37 | return repr_str 38 | -------------------------------------------------------------------------------- /mmdet/datasets/registry.py: -------------------------------------------------------------------------------- 1 | from mmdet.utils import Registry 2 | 3 | DATASETS = Registry('dataset') 4 | PIPELINES = Registry('pipeline') 5 | -------------------------------------------------------------------------------- /mmdet/datasets/wider_face.py: -------------------------------------------------------------------------------- 1 | import os.path as osp 2 | import xml.etree.ElementTree as ET 3 | 4 | import mmcv 5 | 6 | from .registry import DATASETS 7 | from .xml_style import XMLDataset 8 | 9 | 10 | @DATASETS.register_module 11 | class WIDERFaceDataset(XMLDataset): 12 | """ 13 | Reader for the WIDER Face dataset in PASCAL VOC format. 14 | Conversion scripts can be found in 15 | https://github.com/sovrasov/wider-face-pascal-voc-annotations 16 | """ 17 | CLASSES = ('face', ) 18 | 19 | def __init__(self, **kwargs): 20 | super(WIDERFaceDataset, self).__init__(**kwargs) 21 | 22 | def load_annotations(self, ann_file): 23 | img_infos = [] 24 | img_ids = mmcv.list_from_file(ann_file) 25 | for img_id in img_ids: 26 | filename = '{}.jpg'.format(img_id) 27 | xml_path = osp.join(self.img_prefix, 'Annotations', 28 | '{}.xml'.format(img_id)) 29 | tree = ET.parse(xml_path) 30 | root = tree.getroot() 31 | size = root.find('size') 32 | width = int(size.find('width').text) 33 | height = int(size.find('height').text) 34 | folder = root.find('folder').text 35 | img_infos.append( 36 | dict( 37 | id=img_id, 38 | filename=osp.join(folder, filename), 39 | width=width, 40 | height=height)) 41 | 42 | return img_infos 43 | -------------------------------------------------------------------------------- /mmdet/models/__init__.py: -------------------------------------------------------------------------------- 1 | from .backbones import * # noqa: F401,F403 2 | from .necks import * # noqa: F401,F403 3 | from .roi_extractors import * # noqa: F401,F403 4 | from .anchor_heads import * # noqa: F401,F403 5 | from .shared_heads import * # noqa: F401,F403 6 | from .bbox_heads import * # noqa: F401,F403 7 | from .mask_heads import * # noqa: F401,F403 8 | from .losses import * # noqa: F401,F403 9 | from .detectors import * # noqa: F401,F403 10 | from .registry import (BACKBONES, NECKS, ROI_EXTRACTORS, SHARED_HEADS, HEADS, 11 | LOSSES, DETECTORS) 12 | from .builder import (build_backbone, build_neck, build_roi_extractor, 13 | build_shared_head, build_head, build_loss, 14 | build_detector) 15 | 16 | __all__ = [ 17 | 'BACKBONES', 'NECKS', 'ROI_EXTRACTORS', 'SHARED_HEADS', 'HEADS', 'LOSSES', 18 | 'DETECTORS', 'build_backbone', 'build_neck', 'build_roi_extractor', 19 | 'build_shared_head', 'build_head', 'build_loss', 'build_detector' 20 | ] 21 | -------------------------------------------------------------------------------- /mmdet/models/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/__pycache__/builder.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/__pycache__/builder.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/__pycache__/registry.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/__pycache__/registry.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/anchor_heads/__init__.py: -------------------------------------------------------------------------------- 1 | from .anchor_head import AnchorHead 2 | from .guided_anchor_head import GuidedAnchorHead, FeatureAdaption 3 | from .fcos_head import FCOSHead 4 | from .rpn_head import RPNHead 5 | from .ga_rpn_head import GARPNHead 6 | from .retina_head import RetinaHead 7 | from .ga_retina_head import GARetinaHead 8 | from .ssd_head import SSDHead 9 | 10 | __all__ = [ 11 | 'AnchorHead', 'GuidedAnchorHead', 'FeatureAdaption', 'RPNHead', 12 | 'GARPNHead', 'RetinaHead', 'GARetinaHead', 'SSDHead', 'FCOSHead' 13 | ] 14 | -------------------------------------------------------------------------------- /mmdet/models/anchor_heads/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/anchor_heads/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/anchor_heads/__pycache__/anchor_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/anchor_heads/__pycache__/anchor_head.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/anchor_heads/__pycache__/fcos_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/anchor_heads/__pycache__/fcos_head.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/anchor_heads/__pycache__/ga_retina_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/anchor_heads/__pycache__/ga_retina_head.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/anchor_heads/__pycache__/ga_rpn_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/anchor_heads/__pycache__/ga_rpn_head.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/anchor_heads/__pycache__/guided_anchor_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/anchor_heads/__pycache__/guided_anchor_head.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/anchor_heads/__pycache__/retina_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/anchor_heads/__pycache__/retina_head.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/anchor_heads/__pycache__/rpn_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/anchor_heads/__pycache__/rpn_head.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/anchor_heads/__pycache__/ssd_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/anchor_heads/__pycache__/ssd_head.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/backbones/__init__.py: -------------------------------------------------------------------------------- 1 | from .resnet import ResNet, make_res_layer 2 | from .resnext import ResNeXt 3 | from .ssd_vgg import SSDVGG 4 | from .hrnet import HRNet 5 | from .mobilenetv2 import MobileNetV2 6 | from .detnas import DetNas 7 | from .fbnet import FBNet 8 | from .mnasnet import MnasNet 9 | 10 | __all__ = ['ResNet', 'make_res_layer', 'ResNeXt', 'SSDVGG', 'HRNet', 'MobileNetV2', 'DetNas', 'FBNet', 'MnasNet'] 11 | -------------------------------------------------------------------------------- /mmdet/models/backbones/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/backbones/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/backbones/__pycache__/detnas.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/backbones/__pycache__/detnas.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/backbones/__pycache__/dropblock.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/backbones/__pycache__/dropblock.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/backbones/__pycache__/fbnet.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/backbones/__pycache__/fbnet.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/backbones/__pycache__/fbnet_arch.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/backbones/__pycache__/fbnet_arch.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/backbones/__pycache__/fbnet_blocks.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/backbones/__pycache__/fbnet_blocks.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/backbones/__pycache__/hrnet.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/backbones/__pycache__/hrnet.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/backbones/__pycache__/mnasnet.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/backbones/__pycache__/mnasnet.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/backbones/__pycache__/mobilenetv2.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/backbones/__pycache__/mobilenetv2.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/backbones/__pycache__/resnet.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/backbones/__pycache__/resnet.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/backbones/__pycache__/resnext.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/backbones/__pycache__/resnext.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/backbones/__pycache__/ssd_vgg.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/backbones/__pycache__/ssd_vgg.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/backbones/__pycache__/utils.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/backbones/__pycache__/utils.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/backbones/fbnet_arch.py: -------------------------------------------------------------------------------- 1 | predefine_archs = { 2 | 3 | 'fbnet_b': { 4 | 'genotypes' : [ 5 | 'conv3', 'ir_k3_e1', 6 | 'ir_k3_e6', 'ir_k5_e6', 'ir_k3_e1', 'ir_k3_e1', 7 | 'ir_k5_e6', 'ir_k5_e3', 'ir_k3_e6', 'ir_k5_e6', 8 | 'ir_k5_e6', 'ir_k5_e1', 'skip' , 'ir_k5_e3', 9 | 'ir_k5_e6', 'ir_k3_e1', 'ir_k5_e1', 'ir_k5_e3', 10 | 'ir_k5_e6', 'ir_k5_e1', 'ir_k5_e6', 'ir_k5_e6', 11 | 'ir_k3_e6', 'conv1', 'avgpool'], 12 | 'strides' : [ 13 | 2, 1, 14 | 2, 1, 1, 1, 15 | 2, 1, 1, 1, 16 | 2, 1, 1, 1, 17 | 1, 1, 1, 1, 18 | 2, 1, 1, 1, 19 | 1, 1, 7], 20 | 'out_channels' : [ 21 | 16, 16, 22 | 24, 24, 24, 24, 23 | 32, 32, 32, 32, 24 | 64, 64, 64, 64, 25 | 112, 112, 112, 112, 26 | 184, 184, 184, 184, 27 | 352, 1984, 1984, 28 | ], 29 | 'dropout_ratio' : 0.2, 30 | 'search_space': 'fbsb', 31 | }, 32 | 33 | 'fbnet_hit': { 34 | 'genotypes' : [ 35 | 'conv3', 36 | 'ir_k3_e3', 'ir_k3_e3', 'ir_k3_e3_r2', 'ir_k3_e3', 37 | 'ir_k5_e6', 'ir_k5_e6', 'ir_k3_e3', 'ir_k3_e3', 38 | 'ir_k7_e6', 'ir_k5_e6', 'ir_k5_e6_r2', 'ir_k5_e3', 39 | 'ir_k5_e6', 'ir_k5_e6_r2', 'ir_k5_e6', 'ir_k5_e6_r2', 40 | 'ir_k7_e6', 'ir_k5_e6', 'ir_k5_e6_r2', 'ir_k5_e6', 41 | 'ir_k3_e3', 'conv1'], 42 | 'strides' : [ 43 | 2, 44 | 2, 1, 1, 1, 45 | 2, 1, 1, 1, 46 | 2, 1, 1, 1, 47 | 1, 1, 1, 1, 48 | 2, 1, 1, 1, 49 | 1, 1], 50 | 'out_channels' : [ 51 | 16, 52 | 48, 48, 48, 48, 53 | 96, 96, 96, 96, 54 | 184, 184, 184, 184, 55 | 256, 256, 256, 256, 56 | 352, 352, 352, 352, 57 | 1024, 2048 58 | ], 59 | 'dropout_ratio' : 0.2, 60 | 'search_space': 'fbsb', 61 | }, 62 | 63 | } 64 | -------------------------------------------------------------------------------- /mmdet/models/bbox_heads/__init__.py: -------------------------------------------------------------------------------- 1 | from .bbox_head import BBoxHead 2 | from .convfc_bbox_head import ConvFCBBoxHead, SharedFCBBoxHead 3 | from .double_bbox_head import DoubleConvFCBBoxHead 4 | 5 | __all__ = [ 6 | 'BBoxHead', 'ConvFCBBoxHead', 'SharedFCBBoxHead', 'DoubleConvFCBBoxHead' 7 | ] 8 | -------------------------------------------------------------------------------- /mmdet/models/bbox_heads/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/bbox_heads/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/bbox_heads/__pycache__/bbox_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/bbox_heads/__pycache__/bbox_head.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/bbox_heads/__pycache__/convfc_bbox_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/bbox_heads/__pycache__/convfc_bbox_head.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/bbox_heads/__pycache__/double_bbox_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/bbox_heads/__pycache__/double_bbox_head.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/bbox_heads/auto_head/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/bbox_heads/auto_head/__init__.py -------------------------------------------------------------------------------- /mmdet/models/bbox_heads/auto_head/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/bbox_heads/auto_head/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/bbox_heads/auto_head/__pycache__/build_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/bbox_heads/auto_head/__pycache__/build_head.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/bbox_heads/auto_head/__pycache__/mbblock_head_search.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/bbox_heads/auto_head/__pycache__/mbblock_head_search.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/bbox_heads/auto_head/__pycache__/mbblock_ops.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/bbox_heads/auto_head/__pycache__/mbblock_ops.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/bbox_heads/auto_head/build_head.py: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------- 2 | # Copyright (c) 2019 Jianyuan Guo (guojianyuan1@huawei.com) 3 | # -------------------------------------------------------- 4 | 5 | # from .darts_head_search import DartsHead 6 | from .mbblock_head_search import MbblockHead 7 | 8 | 9 | def build_search_head(cfg): 10 | """Build head model from config dict. 11 | """ 12 | if cfg is not None: 13 | cfg_ = cfg.copy() 14 | head_type = cfg_.pop('type') 15 | if head_type == 'DARTS': 16 | raise NotImplementedError 17 | elif head_type == 'MBBlock': 18 | return MbblockHead(**cfg_) 19 | else: 20 | raise KeyError('Invalid head type {}'.fromat(head_type)) 21 | else: 22 | return None -------------------------------------------------------------------------------- /mmdet/models/bbox_heads/auto_head/mbblock_head_search.py: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------- 2 | # Copyright (c) 2019 Jianyuan Guo (guojianyuan1@huawei.com) 3 | # -------------------------------------------------------- 4 | 5 | import torch 6 | import torch.nn as nn 7 | import torch.nn.functional as F 8 | from .mbblock_ops import OPS 9 | 10 | PRIMITIVES = [ 11 | 'ir_k3_e3', 12 | 'ir_k3_e6', 13 | 'ir_k3_e6_r2', 14 | 'ir_k5_e3', 15 | 'ir_k5_e6', 16 | 'ir_k7_e6' 17 | ] 18 | 19 | norm_cfg_ = { 20 | 'BN': nn.BatchNorm2d, 21 | 'SyncBN': nn.SyncBatchNorm, 22 | 'GN': nn.GroupNorm, 23 | } 24 | norm_layer = norm_cfg_['BN'] 25 | 26 | class MbblockHead(nn.Module): 27 | def __init__(self, latency=None, gamma=0.02, genotype=None, **kwargs): 28 | super(MbblockHead, self).__init__() 29 | self.latency = latency 30 | self.gamma = gamma 31 | self.genotype = genotype 32 | self.last_dim = kwargs.get('out_channels', [256])[-1] 33 | self.strides = kwargs.get('strides') 34 | self.out_channels = kwargs.get('out_channels') 35 | bn_type = kwargs.get('bn_type', 'BN') 36 | 37 | self.cells = nn.ModuleList() 38 | input_size = 7 39 | _in_channel = self.last_dim # usually the same as input channel in detector 40 | 41 | for _genotype, _stride, _out_channel in zip(genotype, self.strides, self.out_channels): 42 | self.cells.append(OPS[_genotype](input_size, _in_channel, _out_channel, _stride, bn=bn_type)) 43 | input_size = input_size // _stride 44 | _in_channel = _out_channel 45 | 46 | for m in self.modules(): 47 | if isinstance(m, nn.SyncBatchNorm): 48 | m._specify_ddp_gpu_num(1) 49 | 50 | def forward(self, x): 51 | for cell in self.cells: 52 | x = cell(x) 53 | 54 | return x, None -------------------------------------------------------------------------------- /mmdet/models/builder.py: -------------------------------------------------------------------------------- 1 | from torch import nn 2 | 3 | from mmdet.utils import build_from_cfg 4 | from .registry import (BACKBONES, NECKS, ROI_EXTRACTORS, SHARED_HEADS, HEADS, 5 | LOSSES, DETECTORS) 6 | 7 | 8 | def build(cfg, registry, default_args=None): 9 | if isinstance(cfg, list): 10 | modules = [ 11 | build_from_cfg(cfg_, registry, default_args) for cfg_ in cfg 12 | ] 13 | return nn.Sequential(*modules) 14 | else: 15 | return build_from_cfg(cfg, registry, default_args) 16 | 17 | 18 | def build_backbone(cfg): 19 | return build(cfg, BACKBONES) 20 | 21 | 22 | def build_neck(cfg): 23 | return build(cfg, NECKS) 24 | 25 | 26 | def build_roi_extractor(cfg): 27 | return build(cfg, ROI_EXTRACTORS) 28 | 29 | 30 | def build_shared_head(cfg): 31 | return build(cfg, SHARED_HEADS) 32 | 33 | 34 | def build_head(cfg): 35 | return build(cfg, HEADS) 36 | 37 | 38 | def build_loss(cfg): 39 | return build(cfg, LOSSES) 40 | 41 | 42 | def build_detector(cfg, train_cfg=None, test_cfg=None): 43 | return build(cfg, DETECTORS, dict(train_cfg=train_cfg, test_cfg=test_cfg)) 44 | -------------------------------------------------------------------------------- /mmdet/models/detectors/__init__.py: -------------------------------------------------------------------------------- 1 | from .base import BaseDetector 2 | from .double_head_rcnn import DoubleHeadRCNN 3 | from .single_stage import SingleStageDetector 4 | from .two_stage import TwoStageDetector 5 | from .rpn import RPN 6 | from .fast_rcnn import FastRCNN 7 | from .faster_rcnn import FasterRCNN 8 | from .mask_rcnn import MaskRCNN 9 | from .cascade_rcnn import CascadeRCNN 10 | from .htc import HybridTaskCascade 11 | from .retinanet import RetinaNet 12 | from .fcos import FCOS 13 | from .grid_rcnn import GridRCNN 14 | from .mask_scoring_rcnn import MaskScoringRCNN 15 | 16 | __all__ = [ 17 | 'BaseDetector', 'SingleStageDetector', 'TwoStageDetector', 'RPN', 18 | 'FastRCNN', 'FasterRCNN', 'MaskRCNN', 'CascadeRCNN', 'HybridTaskCascade', 19 | 'RetinaNet', 'FCOS', 'GridRCNN', 'MaskScoringRCNN', 'DoubleHeadRCNN' 20 | ] 21 | -------------------------------------------------------------------------------- /mmdet/models/detectors/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/detectors/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/detectors/__pycache__/base.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/detectors/__pycache__/base.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/detectors/__pycache__/cascade_rcnn.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/detectors/__pycache__/cascade_rcnn.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/detectors/__pycache__/double_head_rcnn.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/detectors/__pycache__/double_head_rcnn.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/detectors/__pycache__/fast_rcnn.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/detectors/__pycache__/fast_rcnn.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/detectors/__pycache__/faster_rcnn.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/detectors/__pycache__/faster_rcnn.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/detectors/__pycache__/fcos.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/detectors/__pycache__/fcos.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/detectors/__pycache__/grid_rcnn.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/detectors/__pycache__/grid_rcnn.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/detectors/__pycache__/htc.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/detectors/__pycache__/htc.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/detectors/__pycache__/mask_rcnn.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/detectors/__pycache__/mask_rcnn.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/detectors/__pycache__/mask_scoring_rcnn.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/detectors/__pycache__/mask_scoring_rcnn.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/detectors/__pycache__/retinanet.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/detectors/__pycache__/retinanet.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/detectors/__pycache__/rpn.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/detectors/__pycache__/rpn.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/detectors/__pycache__/single_stage.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/detectors/__pycache__/single_stage.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/detectors/__pycache__/test_mixins.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/detectors/__pycache__/test_mixins.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/detectors/__pycache__/two_stage.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/detectors/__pycache__/two_stage.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/detectors/faster_rcnn.py: -------------------------------------------------------------------------------- 1 | from .two_stage import TwoStageDetector 2 | from ..registry import DETECTORS 3 | 4 | 5 | @DETECTORS.register_module 6 | class FasterRCNN(TwoStageDetector): 7 | 8 | def __init__(self, 9 | backbone, 10 | rpn_head, 11 | bbox_roi_extractor, 12 | bbox_head, 13 | train_cfg, 14 | test_cfg, 15 | neck=None, 16 | shared_head=None, 17 | cls_roi_scale_factor=None, 18 | reg_roi_scale_factor=None, 19 | pretrained=None): 20 | super(FasterRCNN, self).__init__( 21 | backbone=backbone, 22 | neck=neck, 23 | shared_head=shared_head, 24 | rpn_head=rpn_head, 25 | bbox_roi_extractor=bbox_roi_extractor, 26 | bbox_head=bbox_head, 27 | train_cfg=train_cfg, 28 | test_cfg=test_cfg, 29 | cls_roi_scale_factor = cls_roi_scale_factor, 30 | reg_roi_scale_factor = reg_roi_scale_factor, 31 | pretrained=pretrained) 32 | -------------------------------------------------------------------------------- /mmdet/models/detectors/fcos.py: -------------------------------------------------------------------------------- 1 | from .single_stage import SingleStageDetector 2 | from ..registry import DETECTORS 3 | 4 | 5 | @DETECTORS.register_module 6 | class FCOS(SingleStageDetector): 7 | 8 | def __init__(self, 9 | backbone, 10 | neck, 11 | bbox_head, 12 | train_cfg=None, 13 | test_cfg=None, 14 | pretrained=None): 15 | super(FCOS, self).__init__(backbone, neck, bbox_head, train_cfg, 16 | test_cfg, pretrained) 17 | -------------------------------------------------------------------------------- /mmdet/models/detectors/mask_rcnn.py: -------------------------------------------------------------------------------- 1 | from .two_stage import TwoStageDetector 2 | from ..registry import DETECTORS 3 | 4 | 5 | @DETECTORS.register_module 6 | class MaskRCNN(TwoStageDetector): 7 | 8 | def __init__(self, 9 | backbone, 10 | rpn_head, 11 | bbox_roi_extractor, 12 | bbox_head, 13 | mask_roi_extractor, 14 | mask_head, 15 | train_cfg, 16 | test_cfg, 17 | neck=None, 18 | shared_head=None, 19 | pretrained=None): 20 | super(MaskRCNN, self).__init__( 21 | backbone=backbone, 22 | neck=neck, 23 | shared_head=shared_head, 24 | rpn_head=rpn_head, 25 | bbox_roi_extractor=bbox_roi_extractor, 26 | bbox_head=bbox_head, 27 | mask_roi_extractor=mask_roi_extractor, 28 | mask_head=mask_head, 29 | train_cfg=train_cfg, 30 | test_cfg=test_cfg, 31 | pretrained=pretrained) 32 | -------------------------------------------------------------------------------- /mmdet/models/detectors/retinanet.py: -------------------------------------------------------------------------------- 1 | from .single_stage import SingleStageDetector 2 | from ..registry import DETECTORS 3 | 4 | 5 | @DETECTORS.register_module 6 | class RetinaNet(SingleStageDetector): 7 | 8 | def __init__(self, 9 | backbone, 10 | neck, 11 | bbox_head, 12 | train_cfg=None, 13 | test_cfg=None, 14 | pretrained=None): 15 | super(RetinaNet, self).__init__(backbone, neck, bbox_head, train_cfg, 16 | test_cfg, pretrained) 17 | -------------------------------------------------------------------------------- /mmdet/models/losses/__init__.py: -------------------------------------------------------------------------------- 1 | from .accuracy import accuracy, Accuracy 2 | from .cross_entropy_loss import (cross_entropy, binary_cross_entropy, 3 | mask_cross_entropy, CrossEntropyLoss) 4 | from .focal_loss import sigmoid_focal_loss, FocalLoss 5 | from .smooth_l1_loss import smooth_l1_loss, SmoothL1Loss 6 | from .ghm_loss import GHMC, GHMR 7 | from .balanced_l1_loss import balanced_l1_loss, BalancedL1Loss 8 | from .mse_loss import mse_loss, MSELoss 9 | from .iou_loss import iou_loss, bounded_iou_loss, IoULoss, BoundedIoULoss 10 | from .utils import reduce_loss, weight_reduce_loss, weighted_loss 11 | 12 | __all__ = [ 13 | 'accuracy', 'Accuracy', 'cross_entropy', 'binary_cross_entropy', 14 | 'mask_cross_entropy', 'CrossEntropyLoss', 'sigmoid_focal_loss', 15 | 'FocalLoss', 'smooth_l1_loss', 'SmoothL1Loss', 'balanced_l1_loss', 16 | 'BalancedL1Loss', 'mse_loss', 'MSELoss', 'iou_loss', 'bounded_iou_loss', 17 | 'IoULoss', 'BoundedIoULoss', 'GHMC', 'GHMR', 'reduce_loss', 18 | 'weight_reduce_loss', 'weighted_loss' 19 | ] 20 | -------------------------------------------------------------------------------- /mmdet/models/losses/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/losses/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/losses/__pycache__/accuracy.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/losses/__pycache__/accuracy.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/losses/__pycache__/balanced_l1_loss.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/losses/__pycache__/balanced_l1_loss.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/losses/__pycache__/cross_entropy_loss.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/losses/__pycache__/cross_entropy_loss.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/losses/__pycache__/focal_loss.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/losses/__pycache__/focal_loss.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/losses/__pycache__/ghm_loss.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/losses/__pycache__/ghm_loss.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/losses/__pycache__/iou_loss.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/losses/__pycache__/iou_loss.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/losses/__pycache__/mse_loss.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/losses/__pycache__/mse_loss.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/losses/__pycache__/smooth_l1_loss.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/losses/__pycache__/smooth_l1_loss.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/losses/__pycache__/utils.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/losses/__pycache__/utils.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/losses/accuracy.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | 3 | 4 | def accuracy(pred, target, topk=1): 5 | assert isinstance(topk, (int, tuple)) 6 | if isinstance(topk, int): 7 | topk = (topk, ) 8 | return_single = True 9 | else: 10 | return_single = False 11 | 12 | maxk = max(topk) 13 | _, pred_label = pred.topk(maxk, dim=1) 14 | pred_label = pred_label.t() 15 | correct = pred_label.eq(target.view(1, -1).expand_as(pred_label)) 16 | 17 | res = [] 18 | for k in topk: 19 | correct_k = correct[:k].view(-1).float().sum(0, keepdim=True) 20 | res.append(correct_k.mul_(100.0 / pred.size(0))) 21 | return res[0] if return_single else res 22 | 23 | 24 | class Accuracy(nn.Module): 25 | 26 | def __init__(self, topk=(1, )): 27 | super().__init__() 28 | self.topk = topk 29 | 30 | def forward(self, pred, target): 31 | return accuracy(pred, target, self.topk) 32 | -------------------------------------------------------------------------------- /mmdet/models/losses/mse_loss.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | import torch.nn.functional as F 3 | 4 | from .utils import weighted_loss 5 | from ..registry import LOSSES 6 | 7 | mse_loss = weighted_loss(F.mse_loss) 8 | 9 | 10 | @LOSSES.register_module 11 | class MSELoss(nn.Module): 12 | 13 | def __init__(self, reduction='mean', loss_weight=1.0): 14 | super().__init__() 15 | self.reduction = reduction 16 | self.loss_weight = loss_weight 17 | 18 | def forward(self, pred, target, weight=None, avg_factor=None): 19 | loss = self.loss_weight * mse_loss( 20 | pred, 21 | target, 22 | weight, 23 | reduction=self.reduction, 24 | avg_factor=avg_factor) 25 | return loss 26 | -------------------------------------------------------------------------------- /mmdet/models/losses/smooth_l1_loss.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | 4 | from .utils import weighted_loss 5 | from ..registry import LOSSES 6 | 7 | 8 | @weighted_loss 9 | def smooth_l1_loss(pred, target, beta=1.0): 10 | assert beta > 0 11 | assert pred.size() == target.size() and target.numel() > 0 12 | diff = torch.abs(pred - target) 13 | loss = torch.where(diff < beta, 0.5 * diff * diff / beta, 14 | diff - 0.5 * beta) 15 | return loss 16 | 17 | 18 | @LOSSES.register_module 19 | class SmoothL1Loss(nn.Module): 20 | 21 | def __init__(self, beta=1.0, reduction='mean', loss_weight=1.0): 22 | super(SmoothL1Loss, self).__init__() 23 | self.beta = beta 24 | self.reduction = reduction 25 | self.loss_weight = loss_weight 26 | 27 | def forward(self, 28 | pred, 29 | target, 30 | weight=None, 31 | avg_factor=None, 32 | reduction_override=None, 33 | **kwargs): 34 | assert reduction_override in (None, 'none', 'mean', 'sum') 35 | reduction = ( 36 | reduction_override if reduction_override else self.reduction) 37 | loss_bbox = self.loss_weight * smooth_l1_loss( 38 | pred, 39 | target, 40 | weight, 41 | beta=self.beta, 42 | reduction=reduction, 43 | avg_factor=avg_factor, 44 | **kwargs) 45 | return loss_bbox 46 | -------------------------------------------------------------------------------- /mmdet/models/mask_heads/__init__.py: -------------------------------------------------------------------------------- 1 | from .fcn_mask_head import FCNMaskHead 2 | from .fused_semantic_head import FusedSemanticHead 3 | from .grid_head import GridHead 4 | from .htc_mask_head import HTCMaskHead 5 | from .maskiou_head import MaskIoUHead 6 | 7 | __all__ = [ 8 | 'FCNMaskHead', 'HTCMaskHead', 'FusedSemanticHead', 'GridHead', 9 | 'MaskIoUHead' 10 | ] 11 | -------------------------------------------------------------------------------- /mmdet/models/mask_heads/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/mask_heads/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/mask_heads/__pycache__/fcn_mask_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/mask_heads/__pycache__/fcn_mask_head.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/mask_heads/__pycache__/fused_semantic_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/mask_heads/__pycache__/fused_semantic_head.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/mask_heads/__pycache__/grid_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/mask_heads/__pycache__/grid_head.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/mask_heads/__pycache__/htc_mask_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/mask_heads/__pycache__/htc_mask_head.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/mask_heads/__pycache__/maskiou_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/mask_heads/__pycache__/maskiou_head.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/mask_heads/htc_mask_head.py: -------------------------------------------------------------------------------- 1 | from .fcn_mask_head import FCNMaskHead 2 | from ..registry import HEADS 3 | from ..utils import ConvModule 4 | 5 | 6 | @HEADS.register_module 7 | class HTCMaskHead(FCNMaskHead): 8 | 9 | def __init__(self, *args, **kwargs): 10 | super(HTCMaskHead, self).__init__(*args, **kwargs) 11 | self.conv_res = ConvModule( 12 | self.conv_out_channels, 13 | self.conv_out_channels, 14 | 1, 15 | conv_cfg=self.conv_cfg, 16 | norm_cfg=self.norm_cfg) 17 | 18 | def init_weights(self): 19 | super(HTCMaskHead, self).init_weights() 20 | self.conv_res.init_weights() 21 | 22 | def forward(self, x, res_feat=None, return_logits=True, return_feat=True): 23 | if res_feat is not None: 24 | res_feat = self.conv_res(res_feat) 25 | x = x + res_feat 26 | for conv in self.convs: 27 | x = conv(x) 28 | res_feat = x 29 | outs = [] 30 | if return_logits: 31 | x = self.upsample(x) 32 | if self.upsample_method == 'deconv': 33 | x = self.relu(x) 34 | mask_pred = self.conv_logits(x) 35 | outs.append(mask_pred) 36 | if return_feat: 37 | outs.append(res_feat) 38 | return outs if len(outs) > 1 else outs[0] 39 | -------------------------------------------------------------------------------- /mmdet/models/necks/__init__.py: -------------------------------------------------------------------------------- 1 | from .fpn import FPN 2 | from .fpn_panet import PAFPN 3 | from .bfp import BFP 4 | from .hrfpn import HRFPN 5 | from .nas_fpn import NASFPN 6 | from .search_pafpn import SearchPAFPN 7 | 8 | __all__ = ['FPN', 'BFP', 'HRFPN', 'NASFPN', 9 | 'PAFPN', 'SearchPAFPN'] 10 | -------------------------------------------------------------------------------- /mmdet/models/necks/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/necks/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/necks/__pycache__/bfp.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/necks/__pycache__/bfp.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/necks/__pycache__/fpn.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/necks/__pycache__/fpn.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/necks/__pycache__/fpn_panet.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/necks/__pycache__/fpn_panet.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/necks/__pycache__/hrfpn.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/necks/__pycache__/hrfpn.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/necks/__pycache__/nas_fpn.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/necks/__pycache__/nas_fpn.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/necks/__pycache__/search_fpn.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/necks/__pycache__/search_fpn.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/necks/__pycache__/search_pafpn.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/necks/__pycache__/search_pafpn.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/necks/auto_neck/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/necks/auto_neck/__init__.py -------------------------------------------------------------------------------- /mmdet/models/necks/auto_neck/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/necks/auto_neck/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/necks/auto_neck/__pycache__/build_neck.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/necks/auto_neck/__pycache__/build_neck.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/necks/auto_neck/__pycache__/hit_neck_search.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/necks/auto_neck/__pycache__/hit_neck_search.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/necks/auto_neck/__pycache__/hit_ops.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/necks/auto_neck/__pycache__/hit_ops.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/necks/auto_neck/build_neck.py: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------- 2 | # Copyright (c) 2019 Jianyuan Guo (guojianyuan1@huawei.com) 3 | # -------------------------------------------------------- 4 | 5 | # from .darts_neck_search import DartsNeck 6 | from .hit_neck_search import HitNeck 7 | 8 | 9 | def build_search_neck(cfg): 10 | """Build neck model from config dict. 11 | """ 12 | if cfg is not None: 13 | cfg_ = cfg.copy() 14 | neck_type = cfg_.pop('type') 15 | if neck_type == 'DARTS': 16 | raise NotImplementedError 17 | # return DartsNeck(**cfg_) 18 | elif neck_type == 'HitDet': 19 | return HitNeck(**cfg_) 20 | else: 21 | raise KeyError('Invalid neck type {}'.fromat(neck_type)) 22 | else: 23 | return None -------------------------------------------------------------------------------- /mmdet/models/plugins/__init__.py: -------------------------------------------------------------------------------- 1 | from .non_local import NonLocal2D 2 | from .generalized_attention import GeneralizedAttention 3 | 4 | __all__ = ['NonLocal2D', 'GeneralizedAttention'] 5 | -------------------------------------------------------------------------------- /mmdet/models/plugins/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/plugins/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/plugins/__pycache__/generalized_attention.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/plugins/__pycache__/generalized_attention.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/plugins/__pycache__/non_local.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/plugins/__pycache__/non_local.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/registry.py: -------------------------------------------------------------------------------- 1 | from mmdet.utils import Registry 2 | 3 | BACKBONES = Registry('backbone') 4 | NECKS = Registry('neck') 5 | ROI_EXTRACTORS = Registry('roi_extractor') 6 | SHARED_HEADS = Registry('shared_head') 7 | HEADS = Registry('head') 8 | LOSSES = Registry('loss') 9 | DETECTORS = Registry('detector') -------------------------------------------------------------------------------- /mmdet/models/roi_extractors/__init__.py: -------------------------------------------------------------------------------- 1 | from .single_level import SingleRoIExtractor 2 | 3 | __all__ = ['SingleRoIExtractor'] 4 | -------------------------------------------------------------------------------- /mmdet/models/roi_extractors/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/roi_extractors/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/roi_extractors/__pycache__/single_level.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/roi_extractors/__pycache__/single_level.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/shared_heads/__init__.py: -------------------------------------------------------------------------------- 1 | from .res_layer import ResLayer 2 | 3 | __all__ = ['ResLayer'] 4 | -------------------------------------------------------------------------------- /mmdet/models/shared_heads/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/shared_heads/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/shared_heads/__pycache__/res_layer.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/shared_heads/__pycache__/res_layer.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .conv_ws import conv_ws_2d, ConvWS2d 2 | from .conv_module import build_conv_layer, ConvModule 3 | from .norm import build_norm_layer 4 | from .scale import Scale 5 | from .weight_init import (xavier_init, normal_init, uniform_init, kaiming_init, 6 | bias_init_with_prob) 7 | 8 | __all__ = [ 9 | 'conv_ws_2d', 'ConvWS2d', 'build_conv_layer', 'ConvModule', 10 | 'build_norm_layer', 'xavier_init', 'normal_init', 'uniform_init', 11 | 'kaiming_init', 'bias_init_with_prob', 'Scale' 12 | ] 13 | -------------------------------------------------------------------------------- /mmdet/models/utils/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/utils/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/utils/__pycache__/conv_module.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/utils/__pycache__/conv_module.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/utils/__pycache__/conv_ws.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/utils/__pycache__/conv_ws.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/utils/__pycache__/norm.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/utils/__pycache__/norm.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/utils/__pycache__/quant_conv.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/utils/__pycache__/quant_conv.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/utils/__pycache__/scale.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/utils/__pycache__/scale.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/utils/__pycache__/weight_init.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/models/utils/__pycache__/weight_init.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/models/utils/conv_ws.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | import torch.nn.functional as F 3 | 4 | 5 | def conv_ws_2d(input, 6 | weight, 7 | bias=None, 8 | stride=1, 9 | padding=0, 10 | dilation=1, 11 | groups=1, 12 | eps=1e-5): 13 | c_in = weight.size(0) 14 | weight_flat = weight.view(c_in, -1) 15 | mean = weight_flat.mean(dim=1, keepdim=True).view(c_in, 1, 1, 1) 16 | std = weight_flat.std(dim=1, keepdim=True).view(c_in, 1, 1, 1) 17 | weight = (weight - mean) / (std + eps) 18 | return F.conv2d(input, weight, bias, stride, padding, dilation, groups) 19 | 20 | 21 | class ConvWS2d(nn.Conv2d): 22 | 23 | def __init__(self, 24 | in_channels, 25 | out_channels, 26 | kernel_size, 27 | stride=1, 28 | padding=0, 29 | dilation=1, 30 | groups=1, 31 | bias=True, 32 | eps=1e-5): 33 | super(ConvWS2d, self).__init__( 34 | in_channels, 35 | out_channels, 36 | kernel_size, 37 | stride=stride, 38 | padding=padding, 39 | dilation=dilation, 40 | groups=groups, 41 | bias=bias) 42 | self.eps = eps 43 | 44 | def forward(self, x): 45 | return conv_ws_2d(x, self.weight, self.bias, self.stride, self.padding, 46 | self.dilation, self.groups, self.eps) 47 | -------------------------------------------------------------------------------- /mmdet/models/utils/norm.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | 3 | norm_cfg = { 4 | # format: layer_type: (abbreviation, module) 5 | 'BN': ('bn', nn.BatchNorm2d), 6 | 'SyncBN': ('bn', nn.SyncBatchNorm), 7 | 'GN': ('gn', nn.GroupNorm), 8 | # and potentially 'SN' 9 | } 10 | 11 | 12 | def build_norm_layer(cfg, num_features, postfix=''): 13 | """ Build normalization layer 14 | 15 | Args: 16 | cfg (dict): cfg should contain: 17 | type (str): identify norm layer type. 18 | layer args: args needed to instantiate a norm layer. 19 | requires_grad (bool): [optional] whether stop gradient updates 20 | num_features (int): number of channels from input. 21 | postfix (int, str): appended into norm abbreviation to 22 | create named layer. 23 | 24 | Returns: 25 | name (str): abbreviation + postfix 26 | layer (nn.Module): created norm layer 27 | """ 28 | assert isinstance(cfg, dict) and 'type' in cfg 29 | cfg_ = cfg.copy() 30 | 31 | layer_type = cfg_.pop('type') 32 | if layer_type not in norm_cfg: 33 | raise KeyError('Unrecognized norm type {}'.format(layer_type)) 34 | else: 35 | abbr, norm_layer = norm_cfg[layer_type] 36 | if norm_layer is None: 37 | raise NotImplementedError 38 | 39 | assert isinstance(postfix, (int, str)) 40 | name = abbr + str(postfix) 41 | 42 | requires_grad = cfg_.pop('requires_grad', True) 43 | cfg_.setdefault('eps', 1e-5) 44 | if layer_type != 'GN': 45 | layer = norm_layer(num_features, **cfg_) 46 | if layer_type == 'SyncBN': 47 | layer._specify_ddp_gpu_num(1) 48 | else: 49 | assert 'num_groups' in cfg_ 50 | layer = norm_layer(num_channels=num_features, **cfg_) 51 | 52 | for param in layer.parameters(): 53 | param.requires_grad = requires_grad 54 | 55 | return name, layer 56 | -------------------------------------------------------------------------------- /mmdet/models/utils/scale.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | 4 | 5 | class Scale(nn.Module): 6 | 7 | def __init__(self, scale=1.0): 8 | super(Scale, self).__init__() 9 | self.scale = nn.Parameter(torch.tensor(scale, dtype=torch.float)) 10 | 11 | def forward(self, x): 12 | return x * self.scale 13 | -------------------------------------------------------------------------------- /mmdet/models/utils/weight_init.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import torch.nn as nn 3 | 4 | 5 | def xavier_init(module, gain=1, bias=0, distribution='normal'): 6 | assert distribution in ['uniform', 'normal'] 7 | if distribution == 'uniform': 8 | nn.init.xavier_uniform_(module.weight, gain=gain) 9 | else: 10 | nn.init.xavier_normal_(module.weight, gain=gain) 11 | if hasattr(module, 'bias'): 12 | nn.init.constant_(module.bias, bias) 13 | 14 | 15 | def normal_init(module, mean=0, std=1, bias=0): 16 | nn.init.normal_(module.weight, mean, std) 17 | if hasattr(module, 'bias'): 18 | nn.init.constant_(module.bias, bias) 19 | 20 | 21 | def uniform_init(module, a=0, b=1, bias=0): 22 | nn.init.uniform_(module.weight, a, b) 23 | if hasattr(module, 'bias'): 24 | nn.init.constant_(module.bias, bias) 25 | 26 | 27 | def kaiming_init(module, 28 | mode='fan_out', 29 | nonlinearity='relu', 30 | bias=0, 31 | distribution='normal'): 32 | assert distribution in ['uniform', 'normal'] 33 | if distribution == 'uniform': 34 | nn.init.kaiming_uniform_( 35 | module.weight, mode=mode, nonlinearity=nonlinearity) 36 | else: 37 | nn.init.kaiming_normal_( 38 | module.weight, mode=mode, nonlinearity=nonlinearity) 39 | if hasattr(module, 'bias'): 40 | nn.init.constant_(module.bias, bias) 41 | 42 | 43 | def bias_init_with_prob(prior_prob): 44 | """ initialize conv/fc bias value according to giving probablity""" 45 | bias_init = float(-np.log((1 - prior_prob) / prior_prob)) 46 | return bias_init 47 | -------------------------------------------------------------------------------- /mmdet/ops/__init__.py: -------------------------------------------------------------------------------- 1 | from .dcn import (DeformConv, DeformConvPack, ModulatedDeformConv, 2 | ModulatedDeformConvPack, DeformRoIPooling, 3 | DeformRoIPoolingPack, ModulatedDeformRoIPoolingPack, 4 | deform_conv, modulated_deform_conv, deform_roi_pooling) 5 | from .gcb import ContextBlock 6 | from .nms import nms, soft_nms 7 | from .roi_align import RoIAlign, roi_align 8 | from .roi_pool import RoIPool, roi_pool 9 | from .sigmoid_focal_loss import SigmoidFocalLoss, sigmoid_focal_loss 10 | from .masked_conv import MaskedConv2d 11 | 12 | __all__ = [ 13 | 'nms', 'soft_nms', 'RoIAlign', 'roi_align', 'RoIPool', 'roi_pool', 14 | 'DeformConv', 'DeformConvPack', 'DeformRoIPooling', 'DeformRoIPoolingPack', 15 | 'ModulatedDeformRoIPoolingPack', 'ModulatedDeformConv', 16 | 'ModulatedDeformConvPack', 'deform_conv', 'modulated_deform_conv', 17 | 'deform_roi_pooling', 'SigmoidFocalLoss', 'sigmoid_focal_loss', 18 | 'MaskedConv2d', 'ContextBlock' 19 | ] 20 | -------------------------------------------------------------------------------- /mmdet/ops/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/dcn/__init__.py: -------------------------------------------------------------------------------- 1 | from .functions.deform_conv import deform_conv, modulated_deform_conv 2 | from .functions.deform_pool import deform_roi_pooling 3 | from .modules.deform_conv import (DeformConv, ModulatedDeformConv, 4 | DeformConvPack, ModulatedDeformConvPack) 5 | from .modules.deform_pool import (DeformRoIPooling, DeformRoIPoolingPack, 6 | ModulatedDeformRoIPoolingPack) 7 | 8 | __all__ = [ 9 | 'DeformConv', 'DeformConvPack', 'ModulatedDeformConv', 10 | 'ModulatedDeformConvPack', 'DeformRoIPooling', 'DeformRoIPoolingPack', 11 | 'ModulatedDeformRoIPoolingPack', 'deform_conv', 'modulated_deform_conv', 12 | 'deform_roi_pooling' 13 | ] 14 | -------------------------------------------------------------------------------- /mmdet/ops/dcn/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/dcn/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/dcn/build/lib.linux-x86_64-3.6/deform_conv_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/dcn/build/lib.linux-x86_64-3.6/deform_conv_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /mmdet/ops/dcn/build/lib.linux-x86_64-3.6/deform_pool_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/dcn/build/lib.linux-x86_64-3.6/deform_pool_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /mmdet/ops/dcn/build/temp.linux-x86_64-3.6/src/deform_conv_cuda.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/dcn/build/temp.linux-x86_64-3.6/src/deform_conv_cuda.o -------------------------------------------------------------------------------- /mmdet/ops/dcn/build/temp.linux-x86_64-3.6/src/deform_conv_cuda_kernel.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/dcn/build/temp.linux-x86_64-3.6/src/deform_conv_cuda_kernel.o -------------------------------------------------------------------------------- /mmdet/ops/dcn/build/temp.linux-x86_64-3.6/src/deform_pool_cuda.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/dcn/build/temp.linux-x86_64-3.6/src/deform_pool_cuda.o -------------------------------------------------------------------------------- /mmdet/ops/dcn/build/temp.linux-x86_64-3.6/src/deform_pool_cuda_kernel.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/dcn/build/temp.linux-x86_64-3.6/src/deform_pool_cuda_kernel.o -------------------------------------------------------------------------------- /mmdet/ops/dcn/deform_conv_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/dcn/deform_conv_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /mmdet/ops/dcn/deform_pool_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/dcn/deform_pool_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /mmdet/ops/dcn/functions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/dcn/functions/__init__.py -------------------------------------------------------------------------------- /mmdet/ops/dcn/functions/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/dcn/functions/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/dcn/functions/__pycache__/deform_conv.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/dcn/functions/__pycache__/deform_conv.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/dcn/functions/__pycache__/deform_pool.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/dcn/functions/__pycache__/deform_pool.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/dcn/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/dcn/modules/__init__.py -------------------------------------------------------------------------------- /mmdet/ops/dcn/modules/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/dcn/modules/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/dcn/modules/__pycache__/deform_conv.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/dcn/modules/__pycache__/deform_conv.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/dcn/modules/__pycache__/deform_pool.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/dcn/modules/__pycache__/deform_pool.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/dcn/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | from torch.utils.cpp_extension import BuildExtension, CUDAExtension 3 | 4 | setup( 5 | name='deform_conv', 6 | ext_modules=[ 7 | CUDAExtension('deform_conv_cuda', [ 8 | 'src/deform_conv_cuda.cpp', 9 | 'src/deform_conv_cuda_kernel.cu', 10 | ]), 11 | CUDAExtension( 12 | 'deform_pool_cuda', 13 | ['src/deform_pool_cuda.cpp', 'src/deform_pool_cuda_kernel.cu']), 14 | ], 15 | cmdclass={'build_ext': BuildExtension}) 16 | -------------------------------------------------------------------------------- /mmdet/ops/gcb/__init__.py: -------------------------------------------------------------------------------- 1 | from .context_block import ContextBlock 2 | 3 | __all__ = [ 4 | 'ContextBlock', 5 | ] 6 | -------------------------------------------------------------------------------- /mmdet/ops/gcb/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/gcb/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/gcb/__pycache__/context_block.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/gcb/__pycache__/context_block.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/masked_conv/__init__.py: -------------------------------------------------------------------------------- 1 | from .functions.masked_conv import masked_conv2d 2 | from .modules.masked_conv import MaskedConv2d 3 | 4 | __all__ = ['masked_conv2d', 'MaskedConv2d'] 5 | -------------------------------------------------------------------------------- /mmdet/ops/masked_conv/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/masked_conv/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/masked_conv/build/lib.linux-x86_64-3.6/masked_conv2d_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/masked_conv/build/lib.linux-x86_64-3.6/masked_conv2d_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /mmdet/ops/masked_conv/build/temp.linux-x86_64-3.6/src/masked_conv2d_cuda.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/masked_conv/build/temp.linux-x86_64-3.6/src/masked_conv2d_cuda.o -------------------------------------------------------------------------------- /mmdet/ops/masked_conv/build/temp.linux-x86_64-3.6/src/masked_conv2d_kernel.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/masked_conv/build/temp.linux-x86_64-3.6/src/masked_conv2d_kernel.o -------------------------------------------------------------------------------- /mmdet/ops/masked_conv/functions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/masked_conv/functions/__init__.py -------------------------------------------------------------------------------- /mmdet/ops/masked_conv/functions/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/masked_conv/functions/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/masked_conv/functions/__pycache__/masked_conv.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/masked_conv/functions/__pycache__/masked_conv.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/masked_conv/masked_conv2d_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/masked_conv/masked_conv2d_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /mmdet/ops/masked_conv/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/masked_conv/modules/__init__.py -------------------------------------------------------------------------------- /mmdet/ops/masked_conv/modules/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/masked_conv/modules/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/masked_conv/modules/__pycache__/masked_conv.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/masked_conv/modules/__pycache__/masked_conv.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/masked_conv/modules/masked_conv.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | from ..functions.masked_conv import masked_conv2d 3 | 4 | 5 | class MaskedConv2d(nn.Conv2d): 6 | """A MaskedConv2d which inherits the official Conv2d. 7 | 8 | The masked forward doesn't implement the backward function and only 9 | supports the stride parameter to be 1 currently. 10 | """ 11 | 12 | def __init__(self, 13 | in_channels, 14 | out_channels, 15 | kernel_size, 16 | stride=1, 17 | padding=0, 18 | dilation=1, 19 | groups=1, 20 | bias=True): 21 | super(MaskedConv2d, 22 | self).__init__(in_channels, out_channels, kernel_size, stride, 23 | padding, dilation, groups, bias) 24 | 25 | def forward(self, input, mask=None): 26 | if mask is None: # fallback to the normal Conv2d 27 | return super(MaskedConv2d, self).forward(input) 28 | else: 29 | return masked_conv2d(input, mask, self.weight, self.bias, 30 | self.padding) 31 | -------------------------------------------------------------------------------- /mmdet/ops/masked_conv/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | from torch.utils.cpp_extension import BuildExtension, CUDAExtension 3 | 4 | setup( 5 | name='masked_conv2d_cuda', 6 | ext_modules=[ 7 | CUDAExtension('masked_conv2d_cuda', [ 8 | 'src/masked_conv2d_cuda.cpp', 9 | 'src/masked_conv2d_kernel.cu', 10 | ]), 11 | ], 12 | cmdclass={'build_ext': BuildExtension}) 13 | -------------------------------------------------------------------------------- /mmdet/ops/nms/__init__.py: -------------------------------------------------------------------------------- 1 | from .nms_wrapper import nms, soft_nms 2 | 3 | __all__ = ['nms', 'soft_nms'] 4 | -------------------------------------------------------------------------------- /mmdet/ops/nms/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/nms/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/nms/__pycache__/nms_wrapper.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/nms/__pycache__/nms_wrapper.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/nms/build/lib.linux-x86_64-3.6/nms_cpu.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/nms/build/lib.linux-x86_64-3.6/nms_cpu.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /mmdet/ops/nms/build/lib.linux-x86_64-3.6/nms_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/nms/build/lib.linux-x86_64-3.6/nms_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /mmdet/ops/nms/build/temp.linux-x86_64-3.6/src/nms_cpu.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/nms/build/temp.linux-x86_64-3.6/src/nms_cpu.o -------------------------------------------------------------------------------- /mmdet/ops/nms/build/temp.linux-x86_64-3.6/src/nms_cuda.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/nms/build/temp.linux-x86_64-3.6/src/nms_cuda.o -------------------------------------------------------------------------------- /mmdet/ops/nms/build/temp.linux-x86_64-3.6/src/nms_kernel.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/nms/build/temp.linux-x86_64-3.6/src/nms_kernel.o -------------------------------------------------------------------------------- /mmdet/ops/nms/build/temp.linux-x86_64-3.6/src/soft_nms_cpu.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/nms/build/temp.linux-x86_64-3.6/src/soft_nms_cpu.o -------------------------------------------------------------------------------- /mmdet/ops/nms/nms_cpu.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/nms/nms_cpu.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /mmdet/ops/nms/nms_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/nms/nms_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /mmdet/ops/nms/soft_nms_cpu.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/nms/soft_nms_cpu.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /mmdet/ops/nms/src/nms_cuda.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 2 | #include 3 | 4 | #define CHECK_CUDA(x) AT_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ") 5 | 6 | at::Tensor nms_cuda(const at::Tensor boxes, float nms_overlap_thresh); 7 | 8 | at::Tensor nms(const at::Tensor& dets, const float threshold) { 9 | CHECK_CUDA(dets); 10 | if (dets.numel() == 0) 11 | return at::empty({0}, dets.options().dtype(at::kLong).device(at::kCPU)); 12 | return nms_cuda(dets, threshold); 13 | } 14 | 15 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 16 | m.def("nms", &nms, "non-maximum suppression"); 17 | } -------------------------------------------------------------------------------- /mmdet/ops/roi_align/__init__.py: -------------------------------------------------------------------------------- 1 | from .roi_align import RoIAlign, roi_align 2 | 3 | __all__ = ['roi_align', 'RoIAlign'] 4 | -------------------------------------------------------------------------------- /mmdet/ops/roi_align/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_align/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/roi_align/__pycache__/roi_align.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_align/__pycache__/roi_align.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/roi_align/build/lib.linux-x86_64-3.6/roi_align_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_align/build/lib.linux-x86_64-3.6/roi_align_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /mmdet/ops/roi_align/build/temp.linux-x86_64-3.6/src/roi_align_cuda.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_align/build/temp.linux-x86_64-3.6/src/roi_align_cuda.o -------------------------------------------------------------------------------- /mmdet/ops/roi_align/build/temp.linux-x86_64-3.6/src/roi_align_kernel.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_align/build/temp.linux-x86_64-3.6/src/roi_align_kernel.o -------------------------------------------------------------------------------- /mmdet/ops/roi_align/functions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_align/functions/__init__.py -------------------------------------------------------------------------------- /mmdet/ops/roi_align/gradcheck.py: -------------------------------------------------------------------------------- 1 | import os.path as osp 2 | import sys 3 | 4 | import numpy as np 5 | import torch 6 | from torch.autograd import gradcheck 7 | 8 | sys.path.append(osp.abspath(osp.join(__file__, '../../'))) 9 | from roi_align import RoIAlign # noqa: E402, isort:skip 10 | 11 | feat_size = 15 12 | spatial_scale = 1.0 / 8 13 | img_size = feat_size / spatial_scale 14 | num_imgs = 2 15 | num_rois = 20 16 | 17 | batch_ind = np.random.randint(num_imgs, size=(num_rois, 1)) 18 | rois = np.random.rand(num_rois, 4) * img_size * 0.5 19 | rois[:, 2:] += img_size * 0.5 20 | rois = np.hstack((batch_ind, rois)) 21 | 22 | feat = torch.randn( 23 | num_imgs, 16, feat_size, feat_size, requires_grad=True, device='cuda:0') 24 | rois = torch.from_numpy(rois).float().cuda() 25 | inputs = (feat, rois) 26 | print('Gradcheck for roi align...') 27 | test = gradcheck(RoIAlign(3, spatial_scale), inputs, atol=1e-3, eps=1e-3) 28 | print(test) 29 | test = gradcheck(RoIAlign(3, spatial_scale, 2), inputs, atol=1e-3, eps=1e-3) 30 | print(test) 31 | -------------------------------------------------------------------------------- /mmdet/ops/roi_align/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_align/modules/__init__.py -------------------------------------------------------------------------------- /mmdet/ops/roi_align/modules/roi_align.py: -------------------------------------------------------------------------------- 1 | from torch.nn.modules.module import Module 2 | from ..functions.roi_align import RoIAlignFunction 3 | 4 | 5 | class RoIAlign(Module): 6 | 7 | def __init__(self, out_size, spatial_scale, sample_num=0): 8 | super(RoIAlign, self).__init__() 9 | 10 | self.out_size = out_size 11 | self.spatial_scale = float(spatial_scale) 12 | self.sample_num = int(sample_num) 13 | 14 | def forward(self, features, rois): 15 | return RoIAlignFunction.apply(features, rois, self.out_size, 16 | self.spatial_scale, self.sample_num) 17 | -------------------------------------------------------------------------------- /mmdet/ops/roi_align/roi_align_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_align/roi_align_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /mmdet/ops/roi_align/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | from torch.utils.cpp_extension import BuildExtension, CUDAExtension 3 | 4 | setup( 5 | name='roi_align_cuda', 6 | ext_modules=[ 7 | CUDAExtension('roi_align_cuda', [ 8 | 'src/roi_align_cuda.cpp', 9 | 'src/roi_align_kernel.cu', 10 | ]), 11 | ], 12 | cmdclass={'build_ext': BuildExtension}) 13 | -------------------------------------------------------------------------------- /mmdet/ops/roi_pool/__init__.py: -------------------------------------------------------------------------------- 1 | from .functions.roi_pool import roi_pool 2 | from .modules.roi_pool import RoIPool 3 | 4 | __all__ = ['roi_pool', 'RoIPool'] 5 | -------------------------------------------------------------------------------- /mmdet/ops/roi_pool/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_pool/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/roi_pool/build/lib.linux-x86_64-3.6/roi_pool_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_pool/build/lib.linux-x86_64-3.6/roi_pool_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /mmdet/ops/roi_pool/build/temp.linux-x86_64-3.6/src/roi_pool_cuda.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_pool/build/temp.linux-x86_64-3.6/src/roi_pool_cuda.o -------------------------------------------------------------------------------- /mmdet/ops/roi_pool/build/temp.linux-x86_64-3.6/src/roi_pool_kernel.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_pool/build/temp.linux-x86_64-3.6/src/roi_pool_kernel.o -------------------------------------------------------------------------------- /mmdet/ops/roi_pool/functions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_pool/functions/__init__.py -------------------------------------------------------------------------------- /mmdet/ops/roi_pool/functions/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_pool/functions/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/roi_pool/functions/__pycache__/roi_pool.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_pool/functions/__pycache__/roi_pool.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/roi_pool/gradcheck.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch.autograd import gradcheck 3 | 4 | import os.path as osp 5 | import sys 6 | sys.path.append(osp.abspath(osp.join(__file__, '../../'))) 7 | from roi_pool import RoIPool # noqa: E402 8 | 9 | feat = torch.randn(4, 16, 15, 15, requires_grad=True).cuda() 10 | rois = torch.Tensor([[0, 0, 0, 50, 50], [0, 10, 30, 43, 55], 11 | [1, 67, 40, 110, 120]]).cuda() 12 | inputs = (feat, rois) 13 | print('Gradcheck for roi pooling...') 14 | test = gradcheck(RoIPool(4, 1.0 / 8), inputs, eps=1e-5, atol=1e-3) 15 | print(test) 16 | -------------------------------------------------------------------------------- /mmdet/ops/roi_pool/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_pool/modules/__init__.py -------------------------------------------------------------------------------- /mmdet/ops/roi_pool/modules/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_pool/modules/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/roi_pool/modules/__pycache__/roi_pool.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_pool/modules/__pycache__/roi_pool.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/roi_pool/modules/roi_pool.py: -------------------------------------------------------------------------------- 1 | from torch.nn.modules.module import Module 2 | from ..functions.roi_pool import roi_pool 3 | 4 | 5 | class RoIPool(Module): 6 | 7 | def __init__(self, out_size, spatial_scale): 8 | super(RoIPool, self).__init__() 9 | 10 | self.out_size = out_size 11 | self.spatial_scale = float(spatial_scale) 12 | 13 | def forward(self, features, rois): 14 | return roi_pool(features, rois, self.out_size, self.spatial_scale) 15 | -------------------------------------------------------------------------------- /mmdet/ops/roi_pool/roi_pool_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/roi_pool/roi_pool_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /mmdet/ops/roi_pool/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | from torch.utils.cpp_extension import BuildExtension, CUDAExtension 3 | 4 | setup( 5 | name='roi_pool', 6 | ext_modules=[ 7 | CUDAExtension('roi_pool_cuda', [ 8 | 'src/roi_pool_cuda.cpp', 9 | 'src/roi_pool_kernel.cu', 10 | ]) 11 | ], 12 | cmdclass={'build_ext': BuildExtension}) 13 | -------------------------------------------------------------------------------- /mmdet/ops/sigmoid_focal_loss/__init__.py: -------------------------------------------------------------------------------- 1 | from .modules.sigmoid_focal_loss import SigmoidFocalLoss, sigmoid_focal_loss 2 | 3 | __all__ = ['SigmoidFocalLoss', 'sigmoid_focal_loss'] 4 | -------------------------------------------------------------------------------- /mmdet/ops/sigmoid_focal_loss/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/sigmoid_focal_loss/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/sigmoid_focal_loss/build/lib.linux-x86_64-3.6/sigmoid_focal_loss_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/sigmoid_focal_loss/build/lib.linux-x86_64-3.6/sigmoid_focal_loss_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /mmdet/ops/sigmoid_focal_loss/build/temp.linux-x86_64-3.6/src/sigmoid_focal_loss.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/sigmoid_focal_loss/build/temp.linux-x86_64-3.6/src/sigmoid_focal_loss.o -------------------------------------------------------------------------------- /mmdet/ops/sigmoid_focal_loss/build/temp.linux-x86_64-3.6/src/sigmoid_focal_loss_cuda.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/sigmoid_focal_loss/build/temp.linux-x86_64-3.6/src/sigmoid_focal_loss_cuda.o -------------------------------------------------------------------------------- /mmdet/ops/sigmoid_focal_loss/functions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/sigmoid_focal_loss/functions/__init__.py -------------------------------------------------------------------------------- /mmdet/ops/sigmoid_focal_loss/functions/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/sigmoid_focal_loss/functions/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/sigmoid_focal_loss/functions/__pycache__/sigmoid_focal_loss.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/sigmoid_focal_loss/functions/__pycache__/sigmoid_focal_loss.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/sigmoid_focal_loss/functions/sigmoid_focal_loss.py: -------------------------------------------------------------------------------- 1 | from torch.autograd import Function 2 | from torch.autograd.function import once_differentiable 3 | 4 | from .. import sigmoid_focal_loss_cuda 5 | 6 | 7 | class SigmoidFocalLossFunction(Function): 8 | 9 | @staticmethod 10 | def forward(ctx, input, target, gamma=2.0, alpha=0.25): 11 | ctx.save_for_backward(input, target) 12 | num_classes = input.shape[1] 13 | ctx.num_classes = num_classes 14 | ctx.gamma = gamma 15 | ctx.alpha = alpha 16 | 17 | loss = sigmoid_focal_loss_cuda.forward(input, target, num_classes, 18 | gamma, alpha) 19 | return loss 20 | 21 | @staticmethod 22 | @once_differentiable 23 | def backward(ctx, d_loss): 24 | input, target = ctx.saved_tensors 25 | num_classes = ctx.num_classes 26 | gamma = ctx.gamma 27 | alpha = ctx.alpha 28 | d_loss = d_loss.contiguous() 29 | d_input = sigmoid_focal_loss_cuda.backward(input, target, d_loss, 30 | num_classes, gamma, alpha) 31 | return d_input, None, None, None, None 32 | 33 | 34 | sigmoid_focal_loss = SigmoidFocalLossFunction.apply 35 | -------------------------------------------------------------------------------- /mmdet/ops/sigmoid_focal_loss/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/sigmoid_focal_loss/modules/__init__.py -------------------------------------------------------------------------------- /mmdet/ops/sigmoid_focal_loss/modules/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/sigmoid_focal_loss/modules/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/sigmoid_focal_loss/modules/__pycache__/sigmoid_focal_loss.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/sigmoid_focal_loss/modules/__pycache__/sigmoid_focal_loss.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/ops/sigmoid_focal_loss/modules/sigmoid_focal_loss.py: -------------------------------------------------------------------------------- 1 | from torch import nn 2 | 3 | from ..functions.sigmoid_focal_loss import sigmoid_focal_loss 4 | 5 | 6 | # TODO: remove this module 7 | class SigmoidFocalLoss(nn.Module): 8 | 9 | def __init__(self, gamma, alpha): 10 | super(SigmoidFocalLoss, self).__init__() 11 | self.gamma = gamma 12 | self.alpha = alpha 13 | 14 | def forward(self, logits, targets): 15 | assert logits.is_cuda 16 | loss = sigmoid_focal_loss(logits, targets, self.gamma, self.alpha) 17 | return loss.sum() 18 | 19 | def __repr__(self): 20 | tmpstr = self.__class__.__name__ + "(" 21 | tmpstr += "gamma=" + str(self.gamma) 22 | tmpstr += ", alpha=" + str(self.alpha) 23 | tmpstr += ")" 24 | return tmpstr 25 | -------------------------------------------------------------------------------- /mmdet/ops/sigmoid_focal_loss/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | from torch.utils.cpp_extension import BuildExtension, CUDAExtension 3 | 4 | setup( 5 | name='SigmoidFocalLoss', 6 | ext_modules=[ 7 | CUDAExtension('sigmoid_focal_loss_cuda', [ 8 | 'src/sigmoid_focal_loss.cpp', 9 | 'src/sigmoid_focal_loss_cuda.cu', 10 | ]), 11 | ], 12 | cmdclass={'build_ext': BuildExtension}) 13 | -------------------------------------------------------------------------------- /mmdet/ops/sigmoid_focal_loss/sigmoid_focal_loss_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/ops/sigmoid_focal_loss/sigmoid_focal_loss_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /mmdet/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .collect_env import collect_env 2 | from .flops_counter import get_model_complexity_info 3 | from .logger import get_root_logger, print_log 4 | from .registry import Registry, build_from_cfg 5 | 6 | 7 | __all__ = [ 8 | 'Registry', 'build_from_cfg', 'get_model_complexity_info', 9 | 'get_root_logger', 'print_log', 'collect_env' 10 | ] -------------------------------------------------------------------------------- /mmdet/utils/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/utils/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/utils/__pycache__/collect_env.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/utils/__pycache__/collect_env.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/utils/__pycache__/flops_counter.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/utils/__pycache__/flops_counter.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/utils/__pycache__/logger.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/utils/__pycache__/logger.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/utils/__pycache__/registry.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ggjy/HitDet.pytorch/38aee61ff4f56f79c68e809be66cd2c02809ba0c/mmdet/utils/__pycache__/registry.cpython-36.pyc -------------------------------------------------------------------------------- /mmdet/utils/profiling.py: -------------------------------------------------------------------------------- 1 | import contextlib 2 | import sys 3 | import time 4 | 5 | import torch 6 | 7 | if sys.version_info >= (3, 7): 8 | 9 | @contextlib.contextmanager 10 | def profile_time(trace_name, 11 | name, 12 | enabled=True, 13 | stream=None, 14 | end_stream=None): 15 | """Print time spent by CPU and GPU. 16 | 17 | Useful as a temporary context manager to find sweet spots of 18 | code suitable for async implementation. 19 | 20 | """ 21 | if (not enabled) or not torch.cuda.is_available(): 22 | yield 23 | return 24 | stream = stream if stream else torch.cuda.current_stream() 25 | end_stream = end_stream if end_stream else stream 26 | start = torch.cuda.Event(enable_timing=True) 27 | end = torch.cuda.Event(enable_timing=True) 28 | stream.record_event(start) 29 | try: 30 | cpu_start = time.monotonic() 31 | yield 32 | finally: 33 | cpu_end = time.monotonic() 34 | end_stream.record_event(end) 35 | end.synchronize() 36 | cpu_time = (cpu_end - cpu_start) * 1000 37 | gpu_time = start.elapsed_time(end) 38 | msg = "{} {} cpu_time {:.2f} ms ".format(trace_name, name, 39 | cpu_time) 40 | msg += "gpu_time {:.2f} ms stream {}".format(gpu_time, stream) 41 | print(msg, end_stream) 42 | -------------------------------------------------------------------------------- /mmdet/version.py: -------------------------------------------------------------------------------- 1 | # GENERATED VERSION FILE 2 | # TIME: Sun Aug 18 00:41:58 2019 3 | 4 | __version__ = '0.6.0+unknown' 5 | short_version = '0.6.0' 6 | -------------------------------------------------------------------------------- /scripts/train_hit_det.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd ../ 4 | 5 | GPUs=8 6 | CONFIG='configs/nas_trinity/2stage_hitdet.py' 7 | WORKDIR='./work_dirs/hitdet_1x/' 8 | 9 | python -m torch.distributed.launch \ 10 | --nproc_per_node=${GPUs} train.py \ 11 | --validate \ 12 | --gpus ${GPUs} \ 13 | --launcher pytorch \ 14 | --config ${CONFIG} \ 15 | --work_dir ${WORKDIR} 16 | -------------------------------------------------------------------------------- /tools/coco_eval.py: -------------------------------------------------------------------------------- 1 | from argparse import ArgumentParser 2 | 3 | from mmdet.core import coco_eval 4 | 5 | 6 | def main(): 7 | parser = ArgumentParser(description='COCO Evaluation') 8 | parser.add_argument('result', help='result file path') 9 | parser.add_argument('--ann', help='annotation file path') 10 | parser.add_argument( 11 | '--types', 12 | type=str, 13 | nargs='+', 14 | choices=['proposal_fast', 'proposal', 'bbox', 'segm', 'keypoint'], 15 | default=['bbox'], 16 | help='result types') 17 | parser.add_argument( 18 | '--max-dets', 19 | type=int, 20 | nargs='+', 21 | default=[100, 300, 1000], 22 | help='proposal numbers, only used for recall evaluation') 23 | args = parser.parse_args() 24 | coco_eval(args.result, args.types, args.ann, args.max_dets) 25 | 26 | 27 | if __name__ == '__main__': 28 | main() 29 | -------------------------------------------------------------------------------- /tools/dist_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | PYTHON=${PYTHON:-"python"} 4 | 5 | CONFIG=$1 6 | CHECKPOINT=$2 7 | GPUS=$3 8 | 9 | $PYTHON -m torch.distributed.launch --nproc_per_node=$GPUS \ 10 | $(dirname "$0")/test.py $CONFIG $CHECKPOINT --launcher pytorch ${@:4} 11 | -------------------------------------------------------------------------------- /tools/dist_train.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | PYTHON=${PYTHON:-"python"} 4 | 5 | CONFIG=$1 6 | GPUS=$2 7 | 8 | $PYTHON -m torch.distributed.launch --nproc_per_node=$GPUS \ 9 | $(dirname "$0")/train.py $CONFIG --launcher pytorch ${@:3} 10 | -------------------------------------------------------------------------------- /tools/get_flops.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | 3 | from mmcv import Config 4 | 5 | from mmdet.models import build_detector 6 | from mmdet.utils import get_model_complexity_info 7 | 8 | 9 | def parse_args(): 10 | parser = argparse.ArgumentParser(description='Train a detector') 11 | parser.add_argument('config', help='train config file path') 12 | parser.add_argument( 13 | '--shape', 14 | type=int, 15 | nargs='+', 16 | default=[1280, 800], 17 | help='input image size') 18 | args = parser.parse_args() 19 | return args 20 | 21 | 22 | def main(): 23 | 24 | args = parse_args() 25 | 26 | if len(args.shape) == 1: 27 | input_shape = (3, args.shape[0], args.shape[0]) 28 | elif len(args.shape) == 2: 29 | input_shape = (3, ) + tuple(args.shape) 30 | else: 31 | raise ValueError('invalid input shape') 32 | 33 | cfg = Config.fromfile(args.config) 34 | model = build_detector( 35 | cfg.model, train_cfg=cfg.train_cfg, test_cfg=cfg.test_cfg).cuda() 36 | model.eval() 37 | 38 | if hasattr(model, 'forward_dummy'): 39 | model.forward = model.forward_dummy 40 | else: 41 | raise NotImplementedError( 42 | 'FLOPs counter is currently not currently supported with {}'. 43 | format(model.__class__.__name__)) 44 | 45 | flops, params = get_model_complexity_info(model, input_shape) 46 | split_line = '=' * 30 47 | print('{0}\nInput shape: {1}\nFlops: {2}\nParams: {3}\n{0}'.format( 48 | split_line, input_shape, flops, params)) 49 | 50 | 51 | if __name__ == '__main__': 52 | main() 53 | -------------------------------------------------------------------------------- /tools/publish_model.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import subprocess 3 | import torch 4 | 5 | 6 | def parse_args(): 7 | parser = argparse.ArgumentParser( 8 | description='Process a checkpoint to be published') 9 | parser.add_argument('in_file', help='input checkpoint filename') 10 | parser.add_argument('out_file', help='output checkpoint filename') 11 | args = parser.parse_args() 12 | return args 13 | 14 | 15 | def process_checkpoint(in_file, out_file): 16 | checkpoint = torch.load(in_file, map_location='cpu') 17 | # remove optimizer for smaller file size 18 | if 'optimizer' in checkpoint: 19 | del checkpoint['optimizer'] 20 | # if it is necessary to remove some sensitive data in checkpoint['meta'], 21 | # add the code here. 22 | torch.save(checkpoint, out_file) 23 | sha = subprocess.check_output(['sha256sum', out_file]).decode() 24 | final_file = out_file.rstrip('.pth') + '-{}.pth'.format(sha[:8]) 25 | subprocess.Popen(['mv', out_file, final_file]) 26 | 27 | 28 | def main(): 29 | args = parse_args() 30 | process_checkpoint(args.in_file, args.out_file) 31 | 32 | 33 | if __name__ == '__main__': 34 | main() 35 | -------------------------------------------------------------------------------- /tools/slurm_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | 5 | PARTITION=$1 6 | JOB_NAME=$2 7 | CONFIG=$3 8 | CHECKPOINT=$4 9 | GPUS=${GPUS:-8} 10 | GPUS_PER_NODE=${GPUS_PER_NODE:-8} 11 | CPUS_PER_TASK=${CPUS_PER_TASK:-5} 12 | PY_ARGS=${@:5} 13 | SRUN_ARGS=${SRUN_ARGS:-""} 14 | 15 | srun -p ${PARTITION} \ 16 | --job-name=${JOB_NAME} \ 17 | --gres=gpu:${GPUS_PER_NODE} \ 18 | --ntasks=${GPUS} \ 19 | --ntasks-per-node=${GPUS_PER_NODE} \ 20 | --cpus-per-task=${CPUS_PER_TASK} \ 21 | --kill-on-bad-exit=1 \ 22 | ${SRUN_ARGS} \ 23 | python -u tools/test.py ${CONFIG} ${CHECKPOINT} --launcher="slurm" ${PY_ARGS} 24 | -------------------------------------------------------------------------------- /tools/slurm_train.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | 5 | PARTITION=$1 6 | JOB_NAME=$2 7 | CONFIG=$3 8 | WORK_DIR=$4 9 | GPUS=${5:-8} 10 | GPUS_PER_NODE=${GPUS_PER_NODE:-8} 11 | CPUS_PER_TASK=${CPUS_PER_TASK:-5} 12 | SRUN_ARGS=${SRUN_ARGS:-""} 13 | PY_ARGS=${PY_ARGS:-"--validate"} 14 | 15 | srun -p ${PARTITION} \ 16 | --job-name=${JOB_NAME} \ 17 | --gres=gpu:${GPUS_PER_NODE} \ 18 | --ntasks=${GPUS} \ 19 | --ntasks-per-node=${GPUS_PER_NODE} \ 20 | --cpus-per-task=${CPUS_PER_TASK} \ 21 | --kill-on-bad-exit=1 \ 22 | ${SRUN_ARGS} \ 23 | python -u tools/train.py ${CONFIG} --work_dir=${WORK_DIR} --launcher="slurm" ${PY_ARGS} 24 | -------------------------------------------------------------------------------- /tools/upgrade_model_version.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import re 3 | from collections import OrderedDict 4 | 5 | import torch 6 | 7 | 8 | def convert(in_file, out_file): 9 | """Convert keys in checkpoints. 10 | 11 | There can be some breaking changes during the development of mmdetection, 12 | and this tool is used for upgrading checkpoints trained with old versions 13 | to the latest one. 14 | """ 15 | checkpoint = torch.load(in_file) 16 | in_state_dict = checkpoint.pop('state_dict') 17 | out_state_dict = OrderedDict() 18 | for key, val in in_state_dict.items(): 19 | # Use ConvModule instead of nn.Conv2d in RetinaNet 20 | # cls_convs.0.weight -> cls_convs.0.conv.weight 21 | m = re.search(r'(cls_convs|reg_convs).\d.(weight|bias)', key) 22 | if m is not None: 23 | param = m.groups()[1] 24 | new_key = key.replace(param, 'conv.{}'.format(param)) 25 | out_state_dict[new_key] = val 26 | continue 27 | 28 | out_state_dict[key] = val 29 | checkpoint['state_dict'] = out_state_dict 30 | torch.save(checkpoint, out_file) 31 | 32 | 33 | def main(): 34 | parser = argparse.ArgumentParser(description='Upgrade model version') 35 | parser.add_argument('in_file', help='input checkpoint file') 36 | parser.add_argument('out_file', help='output checkpoint file') 37 | args = parser.parse_args() 38 | convert(args.in_file, args.out_file) 39 | 40 | 41 | if __name__ == '__main__': 42 | main() 43 | --------------------------------------------------------------------------------