From ee7dae79359d272606845c3c096da9e284d7d36f Mon Sep 17 00:00:00 2001 From: "li.ding" Date: Thu, 9 Mar 2023 16:25:38 +0800 Subject: [PATCH 1/4] add pytorch SOLO --- .../SOLO/pytorch/.github/CODE_OF_CONDUCT.md | 76 ++ .../SOLO/pytorch/.github/CONTRIBUTING.md | 53 ++ .../pytorch/.github/ISSUE_TEMPLATE/config.yml | 1 + .../.github/ISSUE_TEMPLATE/error-report.md | 41 + .../.github/ISSUE_TEMPLATE/feature_request.md | 22 + .../ISSUE_TEMPLATE/general_questions.md | 10 + .../SOLO/pytorch/.gitignore | 121 +++ .../SOLO/pytorch/.gitmodules | 3 + .../SOLO/pytorch/.isort.cfg | 8 + .../SOLO/pytorch/.pre-commit-config.yaml | 21 + .../SOLO/pytorch/.style.yapf | 4 + .../SOLO/pytorch/.travis.yml | 43 + cv/instance_segmentation/SOLO/pytorch/LICENSE | 25 + .../SOLO/pytorch/README.md | 55 ++ ...ecoupled_solo_light_dcn_r50_fpn_8gpu_3x.py | 136 +++ .../decoupled_solo_light_r50_fpn_8gpu_3x.py | 129 +++ .../solo/decoupled_solo_r101_fpn_8gpu_3x.py | 130 +++ .../solo/decoupled_solo_r50_fpn_8gpu_1x.py | 126 +++ .../solo/decoupled_solo_r50_fpn_8gpu_3x.py | 130 +++ .../configs/solo/solo_r101_fpn_8gpu_3x.py | 130 +++ .../configs/solo/solo_r50_fpn_8gpu_1x.py | 126 +++ .../configs/solo/solo_r50_fpn_8gpu_3x.py | 130 +++ .../SOLO/pytorch/mmdet/__init__.py | 3 + .../SOLO/pytorch/mmdet/apis/__init__.py | 9 + .../SOLO/pytorch/mmdet/apis/inference.py | 290 ++++++ .../SOLO/pytorch/mmdet/apis/train.py | 297 ++++++ .../SOLO/pytorch/mmdet/core/__init__.py | 7 + .../pytorch/mmdet/core/anchor/__init__.py | 12 + .../mmdet/core/anchor/anchor_generator.py | 98 ++ .../mmdet/core/anchor/anchor_target.py | 188 ++++ .../mmdet/core/anchor/guided_anchor_target.py | 287 ++++++ .../mmdet/core/anchor/point_generator.py | 34 + .../pytorch/mmdet/core/anchor/point_target.py | 165 ++++ .../SOLO/pytorch/mmdet/core/bbox/__init__.py | 22 + .../mmdet/core/bbox/assign_sampling.py | 33 + .../mmdet/core/bbox/assigners/__init__.py | 11 + .../bbox/assigners/approx_max_iou_assigner.py | 139 +++ .../core/bbox/assigners/assign_result.py | 192 ++++ .../core/bbox/assigners/atss_assigner.py | 159 ++++ .../core/bbox/assigners/base_assigner.py | 8 + .../core/bbox/assigners/max_iou_assigner.py | 195 ++++ .../core/bbox/assigners/point_assigner.py | 130 +++ .../pytorch/mmdet/core/bbox/bbox_target.py | 73 ++ .../SOLO/pytorch/mmdet/core/bbox/demodata.py | 65 ++ .../SOLO/pytorch/mmdet/core/bbox/geometry.py | 88 ++ .../mmdet/core/bbox/samplers/__init__.py | 14 + .../mmdet/core/bbox/samplers/base_sampler.py | 98 ++ .../core/bbox/samplers/combined_sampler.py | 16 + .../samplers/instance_balanced_pos_sampler.py | 41 + .../bbox/samplers/iou_balanced_neg_sampler.py | 135 +++ .../mmdet/core/bbox/samplers/ohem_sampler.py | 79 ++ .../core/bbox/samplers/pseudo_sampler.py | 26 + .../core/bbox/samplers/random_sampler.py | 54 ++ .../core/bbox/samplers/sampling_result.py | 154 +++ .../pytorch/mmdet/core/bbox/transforms.py | 223 +++++ .../pytorch/mmdet/core/evaluation/__init__.py | 18 + .../mmdet/core/evaluation/bbox_overlaps.py | 49 + .../mmdet/core/evaluation/class_names.py | 116 +++ .../mmdet/core/evaluation/coco_utils.py | 250 +++++ .../mmdet/core/evaluation/eval_hooks.py | 152 +++ .../pytorch/mmdet/core/evaluation/mean_ap.py | 455 +++++++++ .../pytorch/mmdet/core/evaluation/recall.py | 185 ++++ .../SOLO/pytorch/mmdet/core/fp16/__init__.py | 4 + .../pytorch/mmdet/core/fp16/decorators.py | 160 ++++ .../SOLO/pytorch/mmdet/core/fp16/hooks.py | 127 +++ .../SOLO/pytorch/mmdet/core/fp16/utils.py | 23 + .../SOLO/pytorch/mmdet/core/mask/__init__.py | 4 + .../pytorch/mmdet/core/mask/mask_target.py | 41 + .../SOLO/pytorch/mmdet/core/mask/utils.py | 30 + .../mmdet/core/post_processing/__init__.py | 9 + .../mmdet/core/post_processing/bbox_nms.py | 66 ++ .../mmdet/core/post_processing/matrix_nms.py | 117 +++ .../mmdet/core/post_processing/merge_augs.py | 101 ++ .../SOLO/pytorch/mmdet/core/utils/__init__.py | 7 + .../pytorch/mmdet/core/utils/dist_utils.py | 58 ++ .../SOLO/pytorch/mmdet/core/utils/misc.py | 37 + .../SOLO/pytorch/mmdet/datasets/__init__.py | 17 + .../SOLO/pytorch/mmdet/datasets/builder.py | 41 + .../SOLO/pytorch/mmdet/datasets/cityscapes.py | 9 + .../SOLO/pytorch/mmdet/datasets/coco.py | 110 +++ .../SOLO/pytorch/mmdet/datasets/custom.py | 152 +++ .../mmdet/datasets/dataset_wrappers.py | 55 ++ .../pytorch/mmdet/datasets/loader/__init__.py | 4 + .../mmdet/datasets/loader/build_loader.py | 70 ++ .../pytorch/mmdet/datasets/loader/sampler.py | 164 ++++ .../mmdet/datasets/pipelines/__init__.py | 17 + .../mmdet/datasets/pipelines/compose.py | 35 + .../mmdet/datasets/pipelines/formating.py | 192 ++++ .../mmdet/datasets/pipelines/instaboost.py | 91 ++ .../mmdet/datasets/pipelines/loading.py | 144 +++ .../mmdet/datasets/pipelines/test_aug.py | 38 + .../mmdet/datasets/pipelines/transforms.py | 876 ++++++++++++++++++ .../SOLO/pytorch/mmdet/datasets/registry.py | 4 + .../SOLO/pytorch/mmdet/datasets/voc.py | 20 + .../SOLO/pytorch/mmdet/datasets/wider_face.py | 42 + .../SOLO/pytorch/mmdet/datasets/xml_style.py | 86 ++ .../SOLO/pytorch/mmdet/models/__init__.py | 19 + .../mmdet/models/anchor_heads/__init__.py | 25 + .../mmdet/models/anchor_heads/anchor_head.py | 330 +++++++ .../mmdet/models/anchor_heads/atss_head.py | 487 ++++++++++ .../anchor_heads/decoupled_solo_head.py | 484 ++++++++++ .../anchor_heads/decoupled_solo_light_head.py | 479 ++++++++++ .../mmdet/models/anchor_heads/fcos_head.py | 408 ++++++++ .../mmdet/models/anchor_heads/fovea_head.py | 387 ++++++++ .../anchor_heads/free_anchor_retina_head.py | 188 ++++ .../models/anchor_heads/ga_retina_head.py | 107 +++ .../mmdet/models/anchor_heads/ga_rpn_head.py | 127 +++ .../models/anchor_heads/guided_anchor_head.py | 621 +++++++++++++ .../models/anchor_heads/reppoints_head.py | 596 ++++++++++++ .../mmdet/models/anchor_heads/retina_head.py | 103 ++ .../models/anchor_heads/retina_sepbn_head.py | 105 +++ .../mmdet/models/anchor_heads/rpn_head.py | 104 +++ .../mmdet/models/anchor_heads/solo_head.py | 433 +++++++++ .../mmdet/models/anchor_heads/solov2_head.py | 483 ++++++++++ .../models/anchor_heads/solov2_light_head.py | 482 ++++++++++ .../mmdet/models/anchor_heads/ssd_head.py | 201 ++++ .../mmdet/models/backbones/__init__.py | 6 + .../pytorch/mmdet/models/backbones/hrnet.py | 524 +++++++++++ .../pytorch/mmdet/models/backbones/resnet.py | 516 +++++++++++ .../pytorch/mmdet/models/backbones/resnext.py | 222 +++++ .../pytorch/mmdet/models/backbones/ssd_vgg.py | 153 +++ .../mmdet/models/bbox_heads/__init__.py | 7 + .../mmdet/models/bbox_heads/bbox_head.py | 282 ++++++ .../models/bbox_heads/convfc_bbox_head.py | 187 ++++ .../models/bbox_heads/double_bbox_head.py | 170 ++++ .../SOLO/pytorch/mmdet/models/builder.py | 43 + .../mmdet/models/detectors/__init__.py | 27 + .../pytorch/mmdet/models/detectors/atss.py | 16 + .../pytorch/mmdet/models/detectors/base.py | 193 ++++ .../mmdet/models/detectors/cascade_rcnn.py | 520 +++++++++++ .../models/detectors/double_head_rcnn.py | 178 ++++ .../mmdet/models/detectors/fast_rcnn.py | 61 ++ .../mmdet/models/detectors/faster_rcnn.py | 27 + .../pytorch/mmdet/models/detectors/fcos.py | 16 + .../pytorch/mmdet/models/detectors/fovea.py | 16 + .../mmdet/models/detectors/grid_rcnn.py | 229 +++++ .../pytorch/mmdet/models/detectors/htc.py | 516 +++++++++++ .../mmdet/models/detectors/mask_rcnn.py | 31 + .../models/detectors/mask_scoring_rcnn.py | 200 ++++ .../models/detectors/reppoints_detector.py | 81 ++ .../mmdet/models/detectors/retinanet.py | 16 + .../pytorch/mmdet/models/detectors/rpn.py | 97 ++ .../mmdet/models/detectors/single_stage.py | 86 ++ .../models/detectors/single_stage_ins.py | 96 ++ .../pytorch/mmdet/models/detectors/solo.py | 16 + .../pytorch/mmdet/models/detectors/solov2.py | 17 + .../mmdet/models/detectors/test_mixins.py | 266 ++++++ .../mmdet/models/detectors/two_stage.py | 346 +++++++ .../pytorch/mmdet/models/losses/__init__.py | 20 + .../pytorch/mmdet/models/losses/accuracy.py | 31 + .../mmdet/models/losses/balanced_l1_loss.py | 69 ++ .../mmdet/models/losses/cross_entropy_loss.py | 103 ++ .../pytorch/mmdet/models/losses/focal_loss.py | 82 ++ .../pytorch/mmdet/models/losses/ghm_loss.py | 171 ++++ .../pytorch/mmdet/models/losses/iou_loss.py | 212 +++++ .../pytorch/mmdet/models/losses/mse_loss.py | 25 + .../mmdet/models/losses/smooth_l1_loss.py | 45 + .../SOLO/pytorch/mmdet/models/losses/utils.py | 98 ++ .../mmdet/models/mask_heads/__init__.py | 11 + .../mmdet/models/mask_heads/fcn_mask_head.py | 191 ++++ .../models/mask_heads/fused_semantic_head.py | 106 +++ .../mmdet/models/mask_heads/grid_head.py | 361 ++++++++ .../mmdet/models/mask_heads/htc_mask_head.py | 38 + .../mmdet/models/mask_heads/mask_feat_head.py | 119 +++ .../mmdet/models/mask_heads/maskiou_head.py | 190 ++++ .../pytorch/mmdet/models/necks/__init__.py | 6 + .../SOLO/pytorch/mmdet/models/necks/bfp.py | 102 ++ .../SOLO/pytorch/mmdet/models/necks/fpn.py | 141 +++ .../SOLO/pytorch/mmdet/models/necks/hrfpn.py | 100 ++ .../pytorch/mmdet/models/necks/nas_fpn.py | 186 ++++ .../pytorch/mmdet/models/plugins/__init__.py | 4 + .../models/plugins/generalized_attention.py | 383 ++++++++ .../pytorch/mmdet/models/plugins/non_local.py | 114 +++ .../SOLO/pytorch/mmdet/models/registry.py | 9 + .../mmdet/models/roi_extractors/__init__.py | 3 + .../models/roi_extractors/single_level.py | 107 +++ .../mmdet/models/shared_heads/__init__.py | 3 + .../mmdet/models/shared_heads/res_layer.py | 71 ++ .../pytorch/mmdet/models/utils/__init__.py | 12 + .../pytorch/mmdet/models/utils/conv_module.py | 167 ++++ .../pytorch/mmdet/models/utils/conv_ws.py | 46 + .../SOLO/pytorch/mmdet/models/utils/norm.py | 55 ++ .../SOLO/pytorch/mmdet/models/utils/scale.py | 15 + .../pytorch/mmdet/models/utils/weight_init.py | 46 + .../SOLO/pytorch/mmdet/ops/__init__.py | 21 + .../SOLO/pytorch/mmdet/ops/context_block.py | 104 +++ .../SOLO/pytorch/mmdet/ops/dcn/__init__.py | 12 + .../SOLO/pytorch/mmdet/ops/dcn/deform_conv.py | 431 +++++++++ .../SOLO/pytorch/mmdet/ops/dcn/deform_pool.py | 252 +++++ .../mmdet/ops/dcn/src/deform_conv_cuda.cpp | 701 ++++++++++++++ .../ops/dcn/src/deform_conv_cuda_kernel.cu | 867 +++++++++++++++++ .../mmdet/ops/dcn/src/deform_pool_cuda.cpp | 90 ++ .../ops/dcn/src/deform_pool_cuda_kernel.cu | 364 ++++++++ .../pytorch/mmdet/ops/masked_conv/__init__.py | 3 + .../mmdet/ops/masked_conv/masked_conv.py | 89 ++ .../masked_conv/src/masked_conv2d_cuda.cpp | 74 ++ .../masked_conv/src/masked_conv2d_kernel.cu | 114 +++ .../SOLO/pytorch/mmdet/ops/nms/__init__.py | 3 + .../SOLO/pytorch/mmdet/ops/nms/nms_wrapper.py | 102 ++ .../pytorch/mmdet/ops/nms/src/nms_cpu.cpp | 71 ++ .../pytorch/mmdet/ops/nms/src/nms_cuda.cpp | 17 + .../pytorch/mmdet/ops/nms/src/nms_kernel.cu | 139 +++ .../mmdet/ops/nms/src/soft_nms_cpu.pyx | 127 +++ .../pytorch/mmdet/ops/roi_align/__init__.py | 3 + .../pytorch/mmdet/ops/roi_align/gradcheck.py | 30 + .../pytorch/mmdet/ops/roi_align/roi_align.py | 87 ++ .../ops/roi_align/src/roi_align_cuda.cpp | 87 ++ .../ops/roi_align/src/roi_align_kernel.cu | 283 ++++++ .../pytorch/mmdet/ops/roi_pool/__init__.py | 3 + .../pytorch/mmdet/ops/roi_pool/gradcheck.py | 16 + .../pytorch/mmdet/ops/roi_pool/roi_pool.py | 75 ++ .../mmdet/ops/roi_pool/src/roi_pool_cuda.cpp | 86 ++ .../mmdet/ops/roi_pool/src/roi_pool_kernel.cu | 157 ++++ .../mmdet/ops/sigmoid_focal_loss/__init__.py | 3 + .../sigmoid_focal_loss/sigmoid_focal_loss.py | 54 ++ .../src/sigmoid_focal_loss.cpp | 45 + .../src/sigmoid_focal_loss_cuda.cu | 171 ++++ .../SOLO/pytorch/mmdet/ops/utils/__init__.py | 7 + .../mmdet/ops/utils/src/compiling_info.cpp | 56 ++ .../SOLO/pytorch/mmdet/utils/__init__.py | 8 + .../pytorch/mmdet/utils/contextmanagers.py | 126 +++ .../SOLO/pytorch/mmdet/utils/flops_counter.py | 444 +++++++++ .../SOLO/pytorch/mmdet/utils/logger.py | 66 ++ .../SOLO/pytorch/mmdet/utils/profiling.py | 41 + .../SOLO/pytorch/mmdet/utils/registry.py | 79 ++ .../SOLO/pytorch/mmdet/utils/util_mixins.py | 105 +++ .../SOLO/pytorch/pytest.ini | 7 + .../SOLO/pytorch/requirements.txt | 4 + .../SOLO/pytorch/requirements/build.txt | 4 + .../SOLO/pytorch/requirements/optional.txt | 2 + .../SOLO/pytorch/requirements/runtime.txt | 10 + .../SOLO/pytorch/requirements/tests.txt | 11 + .../SOLO/pytorch/setup.py | 301 ++++++ .../SOLO/pytorch/tests/async_benchmark.py | 104 +++ .../SOLO/pytorch/tests/test_assigner.py | 277 ++++++ .../SOLO/pytorch/tests/test_async.py | 78 ++ .../SOLO/pytorch/tests/test_config.py | 172 ++++ .../SOLO/pytorch/tests/test_forward.py | 388 ++++++++ .../SOLO/pytorch/tests/test_heads.py | 340 +++++++ .../SOLO/pytorch/tests/test_nms.py | 70 ++ .../SOLO/pytorch/tests/test_sampler.py | 249 +++++ .../SOLO/pytorch/tests/test_utils.py | 9 + .../SOLO/pytorch/tools/analyze_logs.py | 178 ++++ .../SOLO/pytorch/tools/coco_error_analysis.py | 174 ++++ .../SOLO/pytorch/tools/coco_eval.py | 30 + .../SOLO/pytorch/tools/collect_env.py | 64 ++ .../tools/convert_datasets/pascal_voc.py | 141 +++ .../SOLO/pytorch/tools/detectron2pytorch.py | 88 ++ .../SOLO/pytorch/tools/dist_test.sh | 11 + .../SOLO/pytorch/tools/dist_train.sh | 8 + .../SOLO/pytorch/tools/get_flops.py | 55 ++ .../SOLO/pytorch/tools/publish_model.py | 35 + .../SOLO/pytorch/tools/robustness_eval.py | 256 +++++ .../SOLO/pytorch/tools/slurm_test.sh | 23 + .../SOLO/pytorch/tools/slurm_train.sh | 23 + .../SOLO/pytorch/tools/test.py | 282 ++++++ .../SOLO/pytorch/tools/test_ins.py | 257 +++++ .../SOLO/pytorch/tools/test_ins_vis.py | 296 ++++++ .../SOLO/pytorch/tools/test_robustness.py | 453 +++++++++ .../SOLO/pytorch/tools/train.py | 125 +++ .../pytorch/tools/upgrade_model_version.py | 42 + .../SOLO/pytorch/tools/voc_eval.py | 47 + 262 files changed, 34040 insertions(+) create mode 100644 cv/instance_segmentation/SOLO/pytorch/.github/CODE_OF_CONDUCT.md create mode 100644 cv/instance_segmentation/SOLO/pytorch/.github/CONTRIBUTING.md create mode 100644 cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/config.yml create mode 100644 cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/error-report.md create mode 100644 cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/feature_request.md create mode 100644 cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/general_questions.md create mode 100644 cv/instance_segmentation/SOLO/pytorch/.gitignore create mode 100644 cv/instance_segmentation/SOLO/pytorch/.gitmodules create mode 100644 cv/instance_segmentation/SOLO/pytorch/.isort.cfg create mode 100644 cv/instance_segmentation/SOLO/pytorch/.pre-commit-config.yaml create mode 100644 cv/instance_segmentation/SOLO/pytorch/.style.yapf create mode 100644 cv/instance_segmentation/SOLO/pytorch/.travis.yml create mode 100644 cv/instance_segmentation/SOLO/pytorch/LICENSE create mode 100644 cv/instance_segmentation/SOLO/pytorch/README.md create mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_light_dcn_r50_fpn_8gpu_3x.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_light_r50_fpn_8gpu_3x.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r101_fpn_8gpu_3x.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_8gpu_1x.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_8gpu_3x.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r101_fpn_8gpu_3x.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_8gpu_1x.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_8gpu_3x.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/apis/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/apis/inference.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/apis/train.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/anchor_generator.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/anchor_target.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/guided_anchor_target.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/point_generator.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/point_target.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assign_sampling.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/approx_max_iou_assigner.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/assign_result.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/atss_assigner.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/base_assigner.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/max_iou_assigner.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/point_assigner.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/bbox_target.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/demodata.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/geometry.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/base_sampler.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/combined_sampler.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/instance_balanced_pos_sampler.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/iou_balanced_neg_sampler.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/ohem_sampler.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/pseudo_sampler.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/random_sampler.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/sampling_result.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/transforms.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/bbox_overlaps.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/class_names.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/coco_utils.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/eval_hooks.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/mean_ap.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/recall.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/decorators.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/hooks.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/utils.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/mask_target.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/utils.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/bbox_nms.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/matrix_nms.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/merge_augs.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/dist_utils.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/misc.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/builder.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/cityscapes.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/coco.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/custom.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/dataset_wrappers.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/build_loader.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/sampler.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/compose.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/formating.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/instaboost.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/loading.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/test_aug.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/transforms.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/registry.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/voc.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/wider_face.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/xml_style.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/anchor_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/atss_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/decoupled_solo_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/decoupled_solo_light_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/fcos_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/fovea_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/free_anchor_retina_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ga_retina_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ga_rpn_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/guided_anchor_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/reppoints_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/retina_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/retina_sepbn_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/rpn_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solo_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solov2_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solov2_light_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ssd_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/hrnet.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/resnet.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/resnext.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/ssd_vgg.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/bbox_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/convfc_bbox_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/double_bbox_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/builder.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/atss.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/base.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/cascade_rcnn.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/double_head_rcnn.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fast_rcnn.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/faster_rcnn.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fcos.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fovea.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/grid_rcnn.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/htc.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/mask_rcnn.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/mask_scoring_rcnn.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/reppoints_detector.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/retinanet.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/rpn.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage_ins.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/solo.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/solov2.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/test_mixins.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/two_stage.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/accuracy.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/balanced_l1_loss.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/cross_entropy_loss.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/focal_loss.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/ghm_loss.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/iou_loss.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/mse_loss.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/smooth_l1_loss.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/utils.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/fcn_mask_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/fused_semantic_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/grid_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/htc_mask_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/mask_feat_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/maskiou_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/bfp.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/fpn.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/hrfpn.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/nas_fpn.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/generalized_attention.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/non_local.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/registry.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/roi_extractors/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/roi_extractors/single_level.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/shared_heads/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/shared_heads/res_layer.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/conv_module.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/conv_ws.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/norm.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/scale.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/weight_init.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/context_block.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/deform_conv.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/deform_pool.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_conv_cuda.cpp create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_conv_cuda_kernel.cu create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_pool_cuda.cpp create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_pool_cuda_kernel.cu create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/masked_conv.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/src/masked_conv2d_cuda.cpp create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/src/masked_conv2d_kernel.cu create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/nms_wrapper.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_cpu.cpp create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_cuda.cpp create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_kernel.cu create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/soft_nms_cpu.pyx create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/gradcheck.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/roi_align.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/src/roi_align_cuda.cpp create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/src/roi_align_kernel.cu create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/gradcheck.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/roi_pool.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/src/roi_pool_cuda.cpp create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/src/roi_pool_kernel.cu create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/sigmoid_focal_loss.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss.cpp create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss_cuda.cu create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/utils/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/utils/src/compiling_info.cpp create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/utils/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/utils/contextmanagers.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/utils/flops_counter.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/utils/logger.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/utils/profiling.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/utils/registry.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/utils/util_mixins.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/pytest.ini create mode 100644 cv/instance_segmentation/SOLO/pytorch/requirements.txt create mode 100644 cv/instance_segmentation/SOLO/pytorch/requirements/build.txt create mode 100644 cv/instance_segmentation/SOLO/pytorch/requirements/optional.txt create mode 100644 cv/instance_segmentation/SOLO/pytorch/requirements/runtime.txt create mode 100644 cv/instance_segmentation/SOLO/pytorch/requirements/tests.txt create mode 100644 cv/instance_segmentation/SOLO/pytorch/setup.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tests/async_benchmark.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tests/test_assigner.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tests/test_async.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tests/test_config.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tests/test_forward.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tests/test_heads.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tests/test_nms.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tests/test_sampler.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tests/test_utils.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/analyze_logs.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/coco_error_analysis.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/coco_eval.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/collect_env.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/convert_datasets/pascal_voc.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/detectron2pytorch.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/dist_test.sh create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/dist_train.sh create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/get_flops.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/publish_model.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/robustness_eval.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/slurm_test.sh create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/slurm_train.sh create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/test.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/test_ins.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/test_ins_vis.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/test_robustness.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/train.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/upgrade_model_version.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/voc_eval.py diff --git a/cv/instance_segmentation/SOLO/pytorch/.github/CODE_OF_CONDUCT.md b/cv/instance_segmentation/SOLO/pytorch/.github/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..efd430579 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at chenkaidev@gmail.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/cv/instance_segmentation/SOLO/pytorch/.github/CONTRIBUTING.md b/cv/instance_segmentation/SOLO/pytorch/.github/CONTRIBUTING.md new file mode 100644 index 000000000..39c145a1f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/.github/CONTRIBUTING.md @@ -0,0 +1,53 @@ +# Contributing to mmdetection + +All kinds of contributions are welcome, including but not limited to the following. + +- Fixes (typo, bugs) +- New features and components + +## Workflow + +1. fork and pull the latest mmdetection +2. checkout a new branch (do not use master branch for PRs) +3. commit your changes +4. create a PR + +Note +- If you plan to add some new features that involve large changes, it is encouraged to open an issue for discussion first. +- If you are the author of some papers and would like to include your method to mmdetection, +please contact Kai Chen (chenkaidev[at]gmail[dot]com). We will much appreciate your contribution. + +## Code style + +### Python +We adopt [PEP8](https://www.python.org/dev/peps/pep-0008/) as the preferred code style. + +We use the following tools for linting and formatting: +- [flake8](http://flake8.pycqa.org/en/latest/): linter +- [yapf](https://github.com/google/yapf): formatter +- [isort](https://github.com/timothycrosley/isort): sort imports + +Style configurations of yapf and isort can be found in [.style.yapf](../.style.yapf) and [.isort.cfg](../.isort.cfg). + +We use [pre-commit hook](https://pre-commit.com/) that checks and formats for `flake8`, `yapf`, `isort`, `trailing whitespaces`, + fixes `end-of-files`, sorts `requirments.txt` automatically on every commit. +The config for a pre-commit hook is stored in [.pre-commit-config](../.pre-commit-config.yaml). + +After you clone the repository, you will need to install initialize pre-commit hook. + +``` +pip install -U pre-commit +``` + +From the repository folder +``` +pre-commit install +``` + +After this on every commit check code linters and formatter will be enforced. + + +>Before you create a PR, make sure that your code lints and is formatted by yapf. + +### C++ and CUDA +We follow the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). diff --git a/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/config.yml b/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..3ba13e0ce --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false diff --git a/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/error-report.md b/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/error-report.md new file mode 100644 index 000000000..80e1cc58e --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/error-report.md @@ -0,0 +1,41 @@ +--- +name: Error report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +Thanks for your error report and we appreciate it a lot. + +**Checklist** +1. I have searched related issues but cannot get the expected help. +2. The bug has not been fixed in the latest version. + +**Describe the bug** +A clear and concise description of what the bug is. + +**Reproduction** +1. What command or script did you run? +``` +A placeholder for the command. +``` +2. Did you make any modifications on the code or config? Did you understand what you have modified? +3. What dataset did you use? + +**Environment** + +1. Please run `python tools/collect_env.py` to collect necessary environment infomation and paste it here. +2. You may add addition that may be helpful for locating the problem, such as + - How you installed PyTorch [e.g., pip, conda, source] + - Other environment variables that may be related (such as `$PATH`, `$LD_LIBRARY_PATH`, `$PYTHONPATH`, etc.) + +**Error traceback** +If applicable, paste the error trackback here. +``` +A placeholder for trackback. +``` + +**Bug fix** +If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated! diff --git a/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/feature_request.md b/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..33f9d5f23 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,22 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Describe the feature** + +**Motivation** +A clear and concise description of the motivation of the feature. +Ex1. It is inconvenient when [....]. +Ex2. There is a recent paper [....], which is very helpful for [....]. + +**Related resources** +If there is an official code release or third-party implementations, please also provide the information here, which would be very helpful. + +**Additional context** +Add any other context or screenshots about the feature request here. +If you would like to implement the feature and create a PR, please leave a comment here and that would be much appreciated. diff --git a/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/general_questions.md b/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/general_questions.md new file mode 100644 index 000000000..6211ca283 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/general_questions.md @@ -0,0 +1,10 @@ +--- +name: General questions +about: Ask general questions to get help +title: '' +labels: '' +assignees: '' + +--- + + diff --git a/cv/instance_segmentation/SOLO/pytorch/.gitignore b/cv/instance_segmentation/SOLO/pytorch/.gitignore new file mode 100644 index 000000000..306a2bf4e --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/.gitignore @@ -0,0 +1,121 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +# cython generated cpp +mmdet/ops/nms/src/soft_nms_cpu.cpp +mmdet/version.py +data +.vscode +.idea + +# custom +*.pkl +*.pkl.json +*.segm.json +*.log.json +work_dirs/ + +# Pytorch +*.pth diff --git a/cv/instance_segmentation/SOLO/pytorch/.gitmodules b/cv/instance_segmentation/SOLO/pytorch/.gitmodules new file mode 100644 index 000000000..03b361da1 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/.gitmodules @@ -0,0 +1,3 @@ +[submodule "paddlepaddle/paddledetection"] + path = paddlepaddle/paddledetection + url = https://github.com/PaddlePaddle/PaddleDetection diff --git a/cv/instance_segmentation/SOLO/pytorch/.isort.cfg b/cv/instance_segmentation/SOLO/pytorch/.isort.cfg new file mode 100644 index 000000000..9f43efc7d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/.isort.cfg @@ -0,0 +1,8 @@ +[isort] +line_length = 79 +multi_line_output = 0 +known_standard_library = setuptools +known_first_party = mmdet +known_third_party = Cython,asynctest,cv2,matplotlib,mmcv,numpy,pycocotools,robustness_eval,roi_align,roi_pool,seaborn,six,terminaltables,torch,torchvision +no_lines_before = STDLIB,LOCALFOLDER +default_section = THIRDPARTY diff --git a/cv/instance_segmentation/SOLO/pytorch/.pre-commit-config.yaml b/cv/instance_segmentation/SOLO/pytorch/.pre-commit-config.yaml new file mode 100644 index 000000000..901104c2c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +repos: +- repo: https://github.com/asottile/seed-isort-config + rev: v1.9.3 + hooks: + - id: seed-isort-config +- repo: https://github.com/pre-commit/mirrors-isort + rev: v4.3.21 + hooks: + - id: isort +- repo: https://github.com/pre-commit/mirrors-yapf + rev: v0.29.0 + hooks: + - id: yapf +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.4.0 + hooks: + - id: flake8 + - id: trailing-whitespace + - id: check-yaml + - id: end-of-file-fixer + - id: requirements-txt-fixer diff --git a/cv/instance_segmentation/SOLO/pytorch/.style.yapf b/cv/instance_segmentation/SOLO/pytorch/.style.yapf new file mode 100644 index 000000000..286a3f1d7 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/.style.yapf @@ -0,0 +1,4 @@ +[style] +BASED_ON_STYLE = pep8 +BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF = true +SPLIT_BEFORE_EXPRESSION_AFTER_OPENING_PAREN = true diff --git a/cv/instance_segmentation/SOLO/pytorch/.travis.yml b/cv/instance_segmentation/SOLO/pytorch/.travis.yml new file mode 100644 index 000000000..b39defb3f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/.travis.yml @@ -0,0 +1,43 @@ +dist: bionic # ubuntu 18.04 +language: python + +python: + - "3.5" + - "3.6" + - "3.7" + +env: CUDA=10.1.105-1 CUDA_SHORT=10.1 UBUNTU_VERSION=ubuntu1804 FORCE_CUDA=1 +cache: pip + +# Ref to CUDA installation in Travis: https://github.com/jeremad/cuda-travis +before_install: + - INSTALLER=cuda-repo-${UBUNTU_VERSION}_${CUDA}_amd64.deb + - wget http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/${INSTALLER} + - sudo dpkg -i ${INSTALLER} + - wget https://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/7fa2af80.pub + - sudo apt-key add 7fa2af80.pub + - sudo apt update -qq + - sudo apt install -y cuda-${CUDA_SHORT/./-} cuda-cufft-dev-${CUDA_SHORT/./-} + - sudo apt clean + - CUDA_HOME=/usr/local/cuda-${CUDA_SHORT} + - LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${CUDA_HOME}/include:${LD_LIBRARY_PATH} + - PATH=${CUDA_HOME}/bin:${PATH} + +install: + - pip install Pillow==6.2.2 # remove this line when torchvision>=0.5 + - pip install Cython torch==1.2 torchvision==0.4.0 # TODO: fix CI for pytorch>1.2 + - pip install "git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI" + - pip install -r requirements.txt + +before_script: + - flake8 . + - isort -rc --check-only --diff mmdet/ tools/ tests/ + - yapf -r -d --style .style.yapf mmdet/ tools/ tests/ configs/ + +script: + - python setup.py check -m -s + - python setup.py build_ext --inplace + - coverage run --source mmdet -m py.test -v --xdoctest-modules tests mmdet + +after_success: + - coverage report diff --git a/cv/instance_segmentation/SOLO/pytorch/LICENSE b/cv/instance_segmentation/SOLO/pytorch/LICENSE new file mode 100644 index 000000000..e01680d91 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/LICENSE @@ -0,0 +1,25 @@ +SOLO for non-commercial purposes + +Copyright (c) 2019 the authors +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/cv/instance_segmentation/SOLO/pytorch/README.md b/cv/instance_segmentation/SOLO/pytorch/README.md new file mode 100644 index 000000000..25ab9bb8c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/README.md @@ -0,0 +1,55 @@ +# SOLO: Segmenting Objects by Locations + +## Model description + +We present a new, embarrassingly simple approach to instance segmentation in images. Compared to many other dense prediction tasks, e.g., semantic segmentation, it is the arbitrary number of instances that have made instance segmentation much more challenging. In order to predict a mask for each instance, mainstream approaches either follow the 'detect-thensegment' strategy as used by Mask R-CNN, or predict category masks first then use clustering techniques to group pixels into individual instances. We view the task of instance segmentation from a completely new perspective by introducing the notion of "instance categories", which assigns categories to each pixel within an instance according to the instance's location and size, thus nicely converting instance mask segmentation into a classification-solvable problem. Now instance segmentation is decomposed into two classification tasks. We demonstrate a much simpler and flexible instance segmentation framework with strong performance, achieving on par accuracy with Mask R-CNN and outperforming recent singleshot instance segmenters in accuracy. We hope that this very simple and strong framework can serve as a baseline for many instance-level recognition tasks besides instance segmentation. + +## Prepare + +### Install packages + +```shell + +pip3 install -r requirements/build.txt +pip3 install "git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI" +pip3 install -v -e . + +``` + +### Download dataset + +```shell + +$ mkdir -p data/coco +$ cd data/coco +$ wget http://images.cocodataset.org/zips/annotations_trainval2017.zip +$ wget http://images.cocodataset.org/zips/train2017.zip +$ wget http://images.cocodataset.org/zips/val2017.zip +$ unzip annotations_trainval2017.zip +$ unzip train2017.zip +$ unzip val2017.zip + +``` + +## Training + +### Single GPU + +```shell + +python3 tools/train.py configs/solo/solo_r50_fpn_8gpu_1x.py + +``` + +### Multi GPU + +```shell + +bash ./tools/dist_train.sh configs/solo/solo_r50_fpn_8gpu_1x.py ${GPU_NUM} + +``` + + +## Refrence + +Reference: https://github.com/WXinlong/SOLO \ No newline at end of file diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_light_dcn_r50_fpn_8gpu_3x.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_light_dcn_r50_fpn_8gpu_3x.py new file mode 100644 index 000000000..e72d112ae --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_light_dcn_r50_fpn_8gpu_3x.py @@ -0,0 +1,136 @@ +# model settings +model = dict( + type='SOLO', + pretrained='torchvision://resnet50', + backbone=dict( + type='ResNet', + depth=50, + num_stages=4, + out_indices=(0, 1, 2, 3), # C2, C3, C4, C5 + frozen_stages=1, + style='pytorch', + dcn=dict( + type='DCN', + deformable_groups=1, + fallback_on_stride=False), + stage_with_dcn=(False, True, True, True)), + neck=dict( + type='FPN', + in_channels=[256, 512, 1024, 2048], + out_channels=256, + start_level=0, + num_outs=5), + bbox_head=dict( + type='DecoupledSOLOLightHead', + num_classes=81, + in_channels=256, + stacked_convs=4, + use_dcn_in_tower=True, + type_dcn='DCN', + seg_feat_channels=256, + strides=[8, 8, 16, 32, 32], + scale_ranges=((1, 64), (32, 128), (64, 256), (128, 512), (256, 2048)), + sigma=0.2, + num_grids=[40, 36, 24, 16, 12], + cate_down_pos=0, + loss_ins=dict( + type='DiceLoss', + use_sigmoid=True, + loss_weight=3.0), + loss_cate=dict( + type='FocalLoss', + use_sigmoid=True, + gamma=2.0, + alpha=0.25, + loss_weight=1.0), + )) +# training and testing settings +train_cfg = dict() +test_cfg = dict( + nms_pre=500, + score_thr=0.1, + mask_thr=0.5, + update_thr=0.05, + kernel='gaussian', # gaussian/linear + sigma=2.0, + max_per_img=100) +# dataset settings +dataset_type = 'CocoDataset' +data_root = 'data/coco/' +img_norm_cfg = dict( + mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) +train_pipeline = [ + dict(type='LoadImageFromFile'), + dict(type='LoadAnnotations', with_bbox=True, with_mask=True), + dict(type='Resize', + img_scale=[(852, 512), (852, 480), (852, 448), + (852, 416), (852, 384), (852, 352)], + multiscale_mode='value', + keep_ratio=True), + dict(type='RandomFlip', flip_ratio=0.5), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='DefaultFormatBundle'), + dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']), +] +test_pipeline = [ + dict(type='LoadImageFromFile'), + dict( + type='MultiScaleFlipAug', + img_scale=(852, 512), + flip=False, + transforms=[ + dict(type='Resize', keep_ratio=True), + dict(type='RandomFlip'), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='ImageToTensor', keys=['img']), + dict(type='Collect', keys=['img']), + ]) +] +data = dict( + imgs_per_gpu=2, + workers_per_gpu=2, + train=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_train2017.json', + img_prefix=data_root + 'train2017/', + pipeline=train_pipeline), + val=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_val2017.json', + img_prefix=data_root + 'val2017/', + pipeline=test_pipeline), + test=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_val2017.json', + img_prefix=data_root + 'val2017/', + pipeline=test_pipeline)) +# optimizer +optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) +optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) +# learning policy +lr_config = dict( + policy='step', + warmup='linear', + warmup_iters=500, + warmup_ratio=1.0 / 3, + step=[27, 33]) +checkpoint_config = dict(interval=1) +# yapf:disable +log_config = dict( + interval=50, + hooks=[ + dict(type='TextLoggerHook'), + # dict(type='TensorboardLoggerHook') + ]) +# yapf:enable +# runtime settings +total_epochs = 36 +device_ids = range(8) +dist_params = dict(backend='nccl') +log_level = 'INFO' +work_dir = './work_dirs/decoupled_solo_light_dcn_release_r50_fpn_8gpu_3x' +load_from = None +resume_from = None +workflow = [('train', 1)] diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_light_r50_fpn_8gpu_3x.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_light_r50_fpn_8gpu_3x.py new file mode 100644 index 000000000..d38ee0f5b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_light_r50_fpn_8gpu_3x.py @@ -0,0 +1,129 @@ +# model settings +model = dict( + type='SOLO', + pretrained='torchvision://resnet50', + backbone=dict( + type='ResNet', + depth=50, + num_stages=4, + out_indices=(0, 1, 2, 3), # C2, C3, C4, C5 + frozen_stages=1, + style='pytorch'), + neck=dict( + type='FPN', + in_channels=[256, 512, 1024, 2048], + out_channels=256, + start_level=0, + num_outs=5), + bbox_head=dict( + type='DecoupledSOLOLightHead', + num_classes=81, + in_channels=256, + stacked_convs=4, + seg_feat_channels=256, + strides=[8, 8, 16, 32, 32], + scale_ranges=((1, 64), (32, 128), (64, 256), (128, 512), (256, 2048)), + sigma=0.2, + num_grids=[40, 36, 24, 16, 12], + cate_down_pos=0, + loss_ins=dict( + type='DiceLoss', + use_sigmoid=True, + loss_weight=3.0), + loss_cate=dict( + type='FocalLoss', + use_sigmoid=True, + gamma=2.0, + alpha=0.25, + loss_weight=1.0), + )) +# training and testing settings +train_cfg = dict() +test_cfg = dict( + nms_pre=500, + score_thr=0.1, + mask_thr=0.5, + update_thr=0.05, + kernel='gaussian', # gaussian/linear + sigma=2.0, + max_per_img=100) +# dataset settings +dataset_type = 'CocoDataset' +data_root = 'data/coco/' +img_norm_cfg = dict( + mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) +train_pipeline = [ + dict(type='LoadImageFromFile'), + dict(type='LoadAnnotations', with_bbox=True, with_mask=True), + dict(type='Resize', + img_scale=[(852, 512), (852, 480), (852, 448), + (852, 416), (852, 384), (852, 352)], + multiscale_mode='value', + keep_ratio=True), + dict(type='RandomFlip', flip_ratio=0.5), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='DefaultFormatBundle'), + dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']), +] +test_pipeline = [ + dict(type='LoadImageFromFile'), + dict( + type='MultiScaleFlipAug', + img_scale=(852, 512), + flip=False, + transforms=[ + dict(type='Resize', keep_ratio=True), + dict(type='RandomFlip'), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='ImageToTensor', keys=['img']), + dict(type='Collect', keys=['img']), + ]) +] +data = dict( + imgs_per_gpu=2, + workers_per_gpu=2, + train=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_train2017.json', + img_prefix=data_root + 'train2017/', + pipeline=train_pipeline), + val=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_val2017.json', + img_prefix=data_root + 'val2017/', + pipeline=test_pipeline), + test=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_val2017.json', + img_prefix=data_root + 'val2017/', + pipeline=test_pipeline)) +# optimizer +optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) +optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) +# learning policy +lr_config = dict( + policy='step', + warmup='linear', + warmup_iters=500, + warmup_ratio=1.0 / 3, + step=[27, 33]) +checkpoint_config = dict(interval=1) +# yapf:disable +log_config = dict( + interval=50, + hooks=[ + dict(type='TextLoggerHook'), + # dict(type='TensorboardLoggerHook') + ]) +# yapf:enable +# runtime settings +total_epochs = 36 +device_ids = range(8) +dist_params = dict(backend='nccl') +log_level = 'INFO' +work_dir = './work_dirs/decoupled_solo_light_release_r50_fpn_8gpu_3x' +load_from = None +resume_from = None +workflow = [('train', 1)] diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r101_fpn_8gpu_3x.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r101_fpn_8gpu_3x.py new file mode 100644 index 000000000..d64f0385c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r101_fpn_8gpu_3x.py @@ -0,0 +1,130 @@ +# model settings +model = dict( + type='SOLO', + pretrained='torchvision://resnet101', + backbone=dict( + type='ResNet', + depth=101, + num_stages=4, + out_indices=(0, 1, 2, 3), # C2, C3, C4, C5 + frozen_stages=1, + style='pytorch'), + neck=dict( + type='FPN', + in_channels=[256, 512, 1024, 2048], + out_channels=256, + start_level=0, + num_outs=5), + bbox_head=dict( + type='DecoupledSOLOHead', + num_classes=81, + in_channels=256, + stacked_convs=7, + seg_feat_channels=256, + strides=[8, 8, 16, 32, 32], + scale_ranges=((1, 96), (48, 192), (96, 384), (192, 768), (384, 2048)), + sigma=0.2, + num_grids=[40, 36, 24, 16, 12], + cate_down_pos=0, + with_deform=False, + loss_ins=dict( + type='DiceLoss', + use_sigmoid=True, + loss_weight=3.0), + loss_cate=dict( + type='FocalLoss', + use_sigmoid=True, + gamma=2.0, + alpha=0.25, + loss_weight=1.0), + )) +# training and testing settings +train_cfg = dict() +test_cfg = dict( + nms_pre=500, + score_thr=0.1, + mask_thr=0.5, + update_thr=0.05, + kernel='gaussian', # gaussian/linear + sigma=2.0, + max_per_img=100) +# dataset settings +dataset_type = 'CocoDataset' +data_root = 'data/coco/' +img_norm_cfg = dict( + mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) +train_pipeline = [ + dict(type='LoadImageFromFile'), + dict(type='LoadAnnotations', with_bbox=True, with_mask=True), + dict(type='Resize', + img_scale=[(1333, 800), (1333, 768), (1333, 736), + (1333, 704), (1333, 672), (1333, 640)], + multiscale_mode='value', + keep_ratio=True), + dict(type='RandomFlip', flip_ratio=0.5), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='DefaultFormatBundle'), + dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']), +] +test_pipeline = [ + dict(type='LoadImageFromFile'), + dict( + type='MultiScaleFlipAug', + img_scale=(1333, 800), + flip=False, + transforms=[ + dict(type='Resize', keep_ratio=True), + dict(type='RandomFlip'), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='ImageToTensor', keys=['img']), + dict(type='Collect', keys=['img']), + ]) +] +data = dict( + imgs_per_gpu=2, + workers_per_gpu=2, + train=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_train2017.json', + img_prefix=data_root + 'train2017/', + pipeline=train_pipeline), + val=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_val2017.json', + img_prefix=data_root + 'val2017/', + pipeline=test_pipeline), + test=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_val2017.json', + img_prefix=data_root + 'val2017/', + pipeline=test_pipeline)) +# optimizer +optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) +optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) +# learning policy +lr_config = dict( + policy='step', + warmup='linear', + warmup_iters=500, + warmup_ratio=1.0 / 3, + step=[27, 33]) +checkpoint_config = dict(interval=1) +# yapf:disable +log_config = dict( + interval=50, + hooks=[ + dict(type='TextLoggerHook'), + # dict(type='TensorboardLoggerHook') + ]) +# yapf:enable +# runtime settings +total_epochs = 36 +device_ids = range(8) +dist_params = dict(backend='nccl') +log_level = 'INFO' +work_dir = './work_dirs/decoupled_solo_release_r101_fpn_8gpu_3x' +load_from = None +resume_from = None +workflow = [('train', 1)] diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_8gpu_1x.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_8gpu_1x.py new file mode 100644 index 000000000..e4d6b5edc --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_8gpu_1x.py @@ -0,0 +1,126 @@ +# model settings +model = dict( + type='SOLO', + pretrained='torchvision://resnet50', + backbone=dict( + type='ResNet', + depth=50, + num_stages=4, + out_indices=(0, 1, 2, 3), # C2, C3, C4, C5 + frozen_stages=1, + style='pytorch'), + neck=dict( + type='FPN', + in_channels=[256, 512, 1024, 2048], + out_channels=256, + start_level=0, + num_outs=5), + bbox_head=dict( + type='DecoupledSOLOHead', + num_classes=81, + in_channels=256, + stacked_convs=7, + seg_feat_channels=256, + strides=[8, 8, 16, 32, 32], + scale_ranges=((1, 96), (48, 192), (96, 384), (192, 768), (384, 2048)), + sigma=0.2, + num_grids=[40, 36, 24, 16, 12], + cate_down_pos=0, + with_deform=False, + loss_ins=dict( + type='DiceLoss', + use_sigmoid=True, + loss_weight=3.0), + loss_cate=dict( + type='FocalLoss', + use_sigmoid=True, + gamma=2.0, + alpha=0.25, + loss_weight=1.0), + )) +# training and testing settings +train_cfg = dict() +test_cfg = dict( + nms_pre=500, + score_thr=0.1, + mask_thr=0.5, + update_thr=0.05, + kernel='gaussian', # gaussian/linear + sigma=2.0, + max_per_img=100) +# dataset settings +dataset_type = 'CocoDataset' +data_root = 'data/coco/' +img_norm_cfg = dict( + mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) +train_pipeline = [ + dict(type='LoadImageFromFile'), + dict(type='LoadAnnotations', with_bbox=True, with_mask=True), + dict(type='Resize', img_scale=(1333, 800), keep_ratio=True), + dict(type='RandomFlip', flip_ratio=0.5), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='DefaultFormatBundle'), + dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']), +] +test_pipeline = [ + dict(type='LoadImageFromFile'), + dict( + type='MultiScaleFlipAug', + img_scale=(1333, 800), + flip=False, + transforms=[ + dict(type='Resize', keep_ratio=True), + dict(type='RandomFlip'), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='ImageToTensor', keys=['img']), + dict(type='Collect', keys=['img']), + ]) +] +data = dict( + imgs_per_gpu=2, + workers_per_gpu=2, + train=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_train2017.json', + img_prefix=data_root + 'train2017/', + pipeline=train_pipeline), + val=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_val2017.json', + img_prefix=data_root + 'val2017/', + pipeline=test_pipeline), + test=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_val2017.json', + img_prefix=data_root + 'val2017/', + pipeline=test_pipeline)) +# optimizer +optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) +optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) +# learning policy +lr_config = dict( + policy='step', + warmup='linear', + warmup_iters=500, + warmup_ratio=1.0 / 3, + step=[9, 11]) +checkpoint_config = dict(interval=1) +# yapf:disable +log_config = dict( + interval=50, + hooks=[ + dict(type='TextLoggerHook'), + # dict(type='TensorboardLoggerHook') + ]) +# yapf:enable +# runtime settings +total_epochs = 12 +device_ids = range(8) +dist_params = dict(backend='nccl') +log_level = 'INFO' +work_dir = './work_dirs/decoupled_solo_release_r50_fpn_8gpu_1x' +load_from = None +resume_from = None +workflow = [('train', 1)] diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_8gpu_3x.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_8gpu_3x.py new file mode 100644 index 000000000..fa54fd857 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_8gpu_3x.py @@ -0,0 +1,130 @@ +# model settings +model = dict( + type='SOLO', + pretrained='torchvision://resnet50', + backbone=dict( + type='ResNet', + depth=50, + num_stages=4, + out_indices=(0, 1, 2, 3), # C2, C3, C4, C5 + frozen_stages=1, + style='pytorch'), + neck=dict( + type='FPN', + in_channels=[256, 512, 1024, 2048], + out_channels=256, + start_level=0, + num_outs=5), + bbox_head=dict( + type='DecoupledSOLOHead', + num_classes=81, + in_channels=256, + stacked_convs=7, + seg_feat_channels=256, + strides=[8, 8, 16, 32, 32], + scale_ranges=((1, 96), (48, 192), (96, 384), (192, 768), (384, 2048)), + sigma=0.2, + num_grids=[40, 36, 24, 16, 12], + cate_down_pos=0, + with_deform=False, + loss_ins=dict( + type='DiceLoss', + use_sigmoid=True, + loss_weight=3.0), + loss_cate=dict( + type='FocalLoss', + use_sigmoid=True, + gamma=2.0, + alpha=0.25, + loss_weight=1.0), + )) +# training and testing settings +train_cfg = dict() +test_cfg = dict( + nms_pre=500, + score_thr=0.1, + mask_thr=0.5, + update_thr=0.05, + kernel='gaussian', # gaussian/linear + sigma=2.0, + max_per_img=100) +# dataset settings +dataset_type = 'CocoDataset' +data_root = 'data/coco/' +img_norm_cfg = dict( + mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) +train_pipeline = [ + dict(type='LoadImageFromFile'), + dict(type='LoadAnnotations', with_bbox=True, with_mask=True), + dict(type='Resize', + img_scale=[(1333, 800), (1333, 768), (1333, 736), + (1333, 704), (1333, 672), (1333, 640)], + multiscale_mode='value', + keep_ratio=True), + dict(type='RandomFlip', flip_ratio=0.5), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='DefaultFormatBundle'), + dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']), +] +test_pipeline = [ + dict(type='LoadImageFromFile'), + dict( + type='MultiScaleFlipAug', + img_scale=(1333, 800), + flip=False, + transforms=[ + dict(type='Resize', keep_ratio=True), + dict(type='RandomFlip'), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='ImageToTensor', keys=['img']), + dict(type='Collect', keys=['img']), + ]) +] +data = dict( + imgs_per_gpu=2, + workers_per_gpu=2, + train=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_train2017.json', + img_prefix=data_root + 'train2017/', + pipeline=train_pipeline), + val=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_val2017.json', + img_prefix=data_root + 'val2017/', + pipeline=test_pipeline), + test=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_val2017.json', + img_prefix=data_root + 'val2017/', + pipeline=test_pipeline)) +# optimizer +optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) +optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) +# learning policy +lr_config = dict( + policy='step', + warmup='linear', + warmup_iters=500, + warmup_ratio=1.0 / 3, + step=[27, 33]) +checkpoint_config = dict(interval=1) +# yapf:disable +log_config = dict( + interval=50, + hooks=[ + dict(type='TextLoggerHook'), + # dict(type='TensorboardLoggerHook') + ]) +# yapf:enable +# runtime settings +total_epochs = 36 +device_ids = range(8) +dist_params = dict(backend='nccl') +log_level = 'INFO' +work_dir = './work_dirs/decoupled_solo_release_r50_fpn_8gpu_3x' +load_from = None +resume_from = None +workflow = [('train', 1)] diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r101_fpn_8gpu_3x.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r101_fpn_8gpu_3x.py new file mode 100644 index 000000000..d6a30d917 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r101_fpn_8gpu_3x.py @@ -0,0 +1,130 @@ +# model settings +model = dict( + type='SOLO', + pretrained='torchvision://resnet101', + backbone=dict( + type='ResNet', + depth=101, + num_stages=4, + out_indices=(0, 1, 2, 3), # C2, C3, C4, C5 + frozen_stages=1, + style='pytorch'), + neck=dict( + type='FPN', + in_channels=[256, 512, 1024, 2048], + out_channels=256, + start_level=0, + num_outs=5), + bbox_head=dict( + type='SOLOHead', + num_classes=81, + in_channels=256, + stacked_convs=7, + seg_feat_channels=256, + strides=[8, 8, 16, 32, 32], + scale_ranges=((1, 96), (48, 192), (96, 384), (192, 768), (384, 2048)), + sigma=0.2, + num_grids=[40, 36, 24, 16, 12], + cate_down_pos=0, + with_deform=False, + loss_ins=dict( + type='DiceLoss', + use_sigmoid=True, + loss_weight=3.0), + loss_cate=dict( + type='FocalLoss', + use_sigmoid=True, + gamma=2.0, + alpha=0.25, + loss_weight=1.0), + )) +# training and testing settings +train_cfg = dict() +test_cfg = dict( + nms_pre=500, + score_thr=0.1, + mask_thr=0.5, + update_thr=0.05, + kernel='gaussian', # gaussian/linear + sigma=2.0, + max_per_img=100) +# dataset settings +dataset_type = 'CocoDataset' +data_root = 'data/coco/' +img_norm_cfg = dict( + mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) +train_pipeline = [ + dict(type='LoadImageFromFile'), + dict(type='LoadAnnotations', with_bbox=True, with_mask=True), + dict(type='Resize', + img_scale=[(1333, 800), (1333, 768), (1333, 736), + (1333, 704), (1333, 672), (1333, 640)], + multiscale_mode='value', + keep_ratio=True), + dict(type='RandomFlip', flip_ratio=0.5), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='DefaultFormatBundle'), + dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']), +] +test_pipeline = [ + dict(type='LoadImageFromFile'), + dict( + type='MultiScaleFlipAug', + img_scale=(1333, 800), + flip=False, + transforms=[ + dict(type='Resize', keep_ratio=True), + dict(type='RandomFlip'), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='ImageToTensor', keys=['img']), + dict(type='Collect', keys=['img']), + ]) +] +data = dict( + imgs_per_gpu=2, + workers_per_gpu=2, + train=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_train2017.json', + img_prefix=data_root + 'train2017/', + pipeline=train_pipeline), + val=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_val2017.json', + img_prefix=data_root + 'val2017/', + pipeline=test_pipeline), + test=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_val2017.json', + img_prefix=data_root + 'val2017/', + pipeline=test_pipeline)) +# optimizer +optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) +optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) +# learning policy +lr_config = dict( + policy='step', + warmup='linear', + warmup_iters=500, + warmup_ratio=1.0 / 3, + step=[27, 33]) +checkpoint_config = dict(interval=1) +# yapf:disable +log_config = dict( + interval=50, + hooks=[ + dict(type='TextLoggerHook'), + # dict(type='TensorboardLoggerHook') + ]) +# yapf:enable +# runtime settings +total_epochs = 36 +device_ids = range(8) +dist_params = dict(backend='nccl') +log_level = 'INFO' +work_dir = './work_dirs/solo_release_r101_fpn_8gpu_3x' +load_from = None +resume_from = None +workflow = [('train', 1)] diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_8gpu_1x.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_8gpu_1x.py new file mode 100644 index 000000000..7c1796a10 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_8gpu_1x.py @@ -0,0 +1,126 @@ +# model settings +model = dict( + type='SOLO', + pretrained='torchvision://resnet50', + backbone=dict( + type='ResNet', + depth=50, + num_stages=4, + out_indices=(0, 1, 2, 3), # C2, C3, C4, C5 + frozen_stages=1, + style='pytorch'), + neck=dict( + type='FPN', + in_channels=[256, 512, 1024, 2048], + out_channels=256, + start_level=0, + num_outs=5), + bbox_head=dict( + type='SOLOHead', + num_classes=81, + in_channels=256, + stacked_convs=7, + seg_feat_channels=256, + strides=[8, 8, 16, 32, 32], + scale_ranges=((1, 96), (48, 192), (96, 384), (192, 768), (384, 2048)), + sigma=0.2, + num_grids=[40, 36, 24, 16, 12], + cate_down_pos=0, + with_deform=False, + loss_ins=dict( + type='DiceLoss', + use_sigmoid=True, + loss_weight=3.0), + loss_cate=dict( + type='FocalLoss', + use_sigmoid=True, + gamma=2.0, + alpha=0.25, + loss_weight=1.0), + )) +# training and testing settings +train_cfg = dict() +test_cfg = dict( + nms_pre=500, + score_thr=0.1, + mask_thr=0.5, + update_thr=0.05, + kernel='gaussian', # gaussian/linear + sigma=2.0, + max_per_img=100) +# dataset settings +dataset_type = 'CocoDataset' +data_root = 'data/coco/' +img_norm_cfg = dict( + mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) +train_pipeline = [ + dict(type='LoadImageFromFile'), + dict(type='LoadAnnotations', with_bbox=True, with_mask=True), + dict(type='Resize', img_scale=(1333, 800), keep_ratio=True), + dict(type='RandomFlip', flip_ratio=0.5), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='DefaultFormatBundle'), + dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']), +] +test_pipeline = [ + dict(type='LoadImageFromFile'), + dict( + type='MultiScaleFlipAug', + img_scale=(1333, 800), + flip=False, + transforms=[ + dict(type='Resize', keep_ratio=True), + dict(type='RandomFlip'), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='ImageToTensor', keys=['img']), + dict(type='Collect', keys=['img']), + ]) +] +data = dict( + imgs_per_gpu=2, + workers_per_gpu=2, + train=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_train2017.json', + img_prefix=data_root + 'train2017/', + pipeline=train_pipeline), + val=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_val2017.json', + img_prefix=data_root + 'val2017/', + pipeline=test_pipeline), + test=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_val2017.json', + img_prefix=data_root + 'val2017/', + pipeline=test_pipeline)) +# optimizer +optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) +optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) +# learning policy +lr_config = dict( + policy='step', + warmup='linear', + warmup_iters=500, + warmup_ratio=1.0 / 3, + step=[9, 11]) +checkpoint_config = dict(interval=1) +# yapf:disable +log_config = dict( + interval=50, + hooks=[ + dict(type='TextLoggerHook'), + # dict(type='TensorboardLoggerHook') + ]) +# yapf:enable +# runtime settings +total_epochs = 12 +device_ids = range(8) +dist_params = dict(backend='nccl') +log_level = 'INFO' +work_dir = './work_dirs/solo_release_r50_fpn_8gpu_1x' +load_from = None +resume_from = None +workflow = [('train', 1)] diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_8gpu_3x.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_8gpu_3x.py new file mode 100644 index 000000000..7fc0bed65 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_8gpu_3x.py @@ -0,0 +1,130 @@ +# model settings +model = dict( + type='SOLO', + pretrained='torchvision://resnet50', + backbone=dict( + type='ResNet', + depth=50, + num_stages=4, + out_indices=(0, 1, 2, 3), # C2, C3, C4, C5 + frozen_stages=1, + style='pytorch'), + neck=dict( + type='FPN', + in_channels=[256, 512, 1024, 2048], + out_channels=256, + start_level=0, + num_outs=5), + bbox_head=dict( + type='SOLOHead', + num_classes=81, + in_channels=256, + stacked_convs=7, + seg_feat_channels=256, + strides=[8, 8, 16, 32, 32], + scale_ranges=((1, 96), (48, 192), (96, 384), (192, 768), (384, 2048)), + sigma=0.2, + num_grids=[40, 36, 24, 16, 12], + cate_down_pos=0, + with_deform=False, + loss_ins=dict( + type='DiceLoss', + use_sigmoid=True, + loss_weight=3.0), + loss_cate=dict( + type='FocalLoss', + use_sigmoid=True, + gamma=2.0, + alpha=0.25, + loss_weight=1.0), + )) +# training and testing settings +train_cfg = dict() +test_cfg = dict( + nms_pre=500, + score_thr=0.1, + mask_thr=0.5, + update_thr=0.05, + kernel='gaussian', # gaussian/linear + sigma=2.0, + max_per_img=100) +# dataset settings +dataset_type = 'CocoDataset' +data_root = 'data/coco/' +img_norm_cfg = dict( + mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) +train_pipeline = [ + dict(type='LoadImageFromFile'), + dict(type='LoadAnnotations', with_bbox=True, with_mask=True), + dict(type='Resize', + img_scale=[(1333, 800), (1333, 768), (1333, 736), + (1333, 704), (1333, 672), (1333, 640)], + multiscale_mode='value', + keep_ratio=True), + dict(type='RandomFlip', flip_ratio=0.5), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='DefaultFormatBundle'), + dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']), +] +test_pipeline = [ + dict(type='LoadImageFromFile'), + dict( + type='MultiScaleFlipAug', + img_scale=(1333, 800), + flip=False, + transforms=[ + dict(type='Resize', keep_ratio=True), + dict(type='RandomFlip'), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='ImageToTensor', keys=['img']), + dict(type='Collect', keys=['img']), + ]) +] +data = dict( + imgs_per_gpu=2, + workers_per_gpu=2, + train=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_train2017.json', + img_prefix=data_root + 'train2017/', + pipeline=train_pipeline), + val=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_val2017.json', + img_prefix=data_root + 'val2017/', + pipeline=test_pipeline), + test=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_val2017.json', + img_prefix=data_root + 'val2017/', + pipeline=test_pipeline)) +# optimizer +optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) +optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) +# learning policy +lr_config = dict( + policy='step', + warmup='linear', + warmup_iters=500, + warmup_ratio=1.0 / 3, + step=[27, 33]) +checkpoint_config = dict(interval=1) +# yapf:disable +log_config = dict( + interval=50, + hooks=[ + dict(type='TextLoggerHook'), + # dict(type='TensorboardLoggerHook') + ]) +# yapf:enable +# runtime settings +total_epochs = 36 +device_ids = range(8) +dist_params = dict(backend='nccl') +log_level = 'INFO' +work_dir = './work_dirs/solo_release_r50_fpn_8gpu_3x' +load_from = None +resume_from = None +workflow = [('train', 1)] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/__init__.py new file mode 100644 index 000000000..1c4f7e8fc --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/__init__.py @@ -0,0 +1,3 @@ +from .version import __version__, short_version + +__all__ = ['__version__', 'short_version'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/__init__.py new file mode 100644 index 000000000..164594445 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/__init__.py @@ -0,0 +1,9 @@ +from .inference import (async_inference_detector, inference_detector, + init_detector, show_result, show_result_pyplot, show_result_ins) +from .train import get_root_logger, set_random_seed, train_detector + +__all__ = [ + 'get_root_logger', 'set_random_seed', 'train_detector', 'init_detector', + 'async_inference_detector', 'inference_detector', 'show_result', + 'show_result_pyplot', 'show_result_ins' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/inference.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/inference.py new file mode 100644 index 000000000..9470b6e2a --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/inference.py @@ -0,0 +1,290 @@ +import warnings + +import matplotlib.pyplot as plt +import mmcv +import numpy as np +import pycocotools.mask as maskUtils +import torch +from mmcv.parallel import collate, scatter +from mmcv.runner import load_checkpoint + +from mmdet.core import get_classes +from mmdet.datasets.pipelines import Compose +from mmdet.models import build_detector + +import cv2 +from scipy import ndimage + +def init_detector(config, checkpoint=None, device='cuda:0'): + """Initialize a detector from config file. + + Args: + config (str or :obj:`mmcv.Config`): Config file path or the config + object. + checkpoint (str, optional): Checkpoint path. If left as None, the model + will not load any weights. + + Returns: + nn.Module: The constructed detector. + """ + if isinstance(config, str): + config = mmcv.Config.fromfile(config) + elif not isinstance(config, mmcv.Config): + raise TypeError('config must be a filename or Config object, ' + 'but got {}'.format(type(config))) + config.model.pretrained = None + model = build_detector(config.model, test_cfg=config.test_cfg) + if checkpoint is not None: + checkpoint = load_checkpoint(model, checkpoint) + if 'CLASSES' in checkpoint['meta']: + model.CLASSES = checkpoint['meta']['CLASSES'] + else: + warnings.warn('Class names are not saved in the checkpoint\'s ' + 'meta data, use COCO classes by default.') + model.CLASSES = get_classes('coco') + model.cfg = config # save the config in the model for convenience + model.to(device) + model.eval() + return model + + +class LoadImage(object): + + def __call__(self, results): + if isinstance(results['img'], str): + results['filename'] = results['img'] + else: + results['filename'] = None + img = mmcv.imread(results['img']) + results['img'] = img + results['img_shape'] = img.shape + results['ori_shape'] = img.shape + return results + + +def inference_detector(model, img): + """Inference image(s) with the detector. + + Args: + model (nn.Module): The loaded detector. + imgs (str/ndarray or list[str/ndarray]): Either image files or loaded + images. + + Returns: + If imgs is a str, a generator will be returned, otherwise return the + detection results directly. + """ + cfg = model.cfg + device = next(model.parameters()).device # model device + # build the data pipeline + test_pipeline = [LoadImage()] + cfg.data.test.pipeline[1:] + test_pipeline = Compose(test_pipeline) + # prepare data + data = dict(img=img) + data = test_pipeline(data) + data = scatter(collate([data], samples_per_gpu=1), [device])[0] + # forward the model + with torch.no_grad(): + result = model(return_loss=False, rescale=True, **data) + return result + + +async def async_inference_detector(model, img): + """Async inference image(s) with the detector. + + Args: + model (nn.Module): The loaded detector. + imgs (str/ndarray or list[str/ndarray]): Either image files or loaded + images. + + Returns: + Awaitable detection results. + """ + cfg = model.cfg + device = next(model.parameters()).device # model device + # build the data pipeline + test_pipeline = [LoadImage()] + cfg.data.test.pipeline[1:] + test_pipeline = Compose(test_pipeline) + # prepare data + data = dict(img=img) + data = test_pipeline(data) + data = scatter(collate([data], samples_per_gpu=1), [device])[0] + + # We don't restore `torch.is_grad_enabled()` value during concurrent + # inference since execution can overlap + torch.set_grad_enabled(False) + result = await model.aforward_test(rescale=True, **data) + return result + + +# TODO: merge this method with the one in BaseDetector +def show_result(img, + result, + class_names, + score_thr=0.3, + wait_time=0, + show=True, + out_file=None): + """Visualize the detection results on the image. + + Args: + img (str or np.ndarray): Image filename or loaded image. + result (tuple[list] or list): The detection result, can be either + (bbox, segm) or just bbox. + class_names (list[str] or tuple[str]): A list of class names. + score_thr (float): The threshold to visualize the bboxes and masks. + wait_time (int): Value of waitKey param. + show (bool, optional): Whether to show the image with opencv or not. + out_file (str, optional): If specified, the visualization result will + be written to the out file instead of shown in a window. + + Returns: + np.ndarray or None: If neither `show` nor `out_file` is specified, the + visualized image is returned, otherwise None is returned. + """ + assert isinstance(class_names, (tuple, list)) + img = mmcv.imread(img) + img = img.copy() + if isinstance(result, tuple): + bbox_result, segm_result = result + else: + bbox_result, segm_result = result, None + bboxes = np.vstack(bbox_result) + labels = [ + np.full(bbox.shape[0], i, dtype=np.int32) + for i, bbox in enumerate(bbox_result) + ] + labels = np.concatenate(labels) + # draw segmentation masks + if segm_result is not None: + segms = mmcv.concat_list(segm_result) + inds = np.where(bboxes[:, -1] > score_thr)[0] + np.random.seed(42) + color_masks = [ + np.random.randint(0, 256, (1, 3), dtype=np.uint8) + for _ in range(max(labels) + 1) + ] + for i in inds: + i = int(i) + color_mask = color_masks[labels[i]] + mask = maskUtils.decode(segms[i]).astype(np.bool) + img[mask] = img[mask] * 0.5 + color_mask * 0.5 + # draw bounding boxes + mmcv.imshow_det_bboxes( + img, + bboxes, + labels, + class_names=class_names, + score_thr=score_thr, + show=show, + wait_time=wait_time, + out_file=out_file) + if not (show or out_file): + return img + + +def show_result_pyplot(img, + result, + class_names, + score_thr=0.3, + fig_size=(15, 10)): + """Visualize the detection results on the image. + + Args: + img (str or np.ndarray): Image filename or loaded image. + result (tuple[list] or list): The detection result, can be either + (bbox, segm) or just bbox. + class_names (list[str] or tuple[str]): A list of class names. + score_thr (float): The threshold to visualize the bboxes and masks. + fig_size (tuple): Figure size of the pyplot figure. + out_file (str, optional): If specified, the visualization result will + be written to the out file instead of shown in a window. + """ + img = show_result( + img, result, class_names, score_thr=score_thr, show=False) + plt.figure(figsize=fig_size) + plt.imshow(mmcv.bgr2rgb(img)) + + +def show_result_ins(img, + result, + class_names, + score_thr=0.3, + sort_by_density=False, + out_file=None): + """Visualize the instance segmentation results on the image. + + Args: + img (str or np.ndarray): Image filename or loaded image. + result (tuple[list] or list): The instance segmentation result. + class_names (list[str] or tuple[str]): A list of class names. + score_thr (float): The threshold to visualize the masks. + sort_by_density (bool): sort the masks by their density. + out_file (str, optional): If specified, the visualization result will + be written to the out file instead of shown in a window. + + Returns: + np.ndarray or None: If neither `show` nor `out_file` is specified, the + visualized image is returned, otherwise None is returned. + """ + + assert isinstance(class_names, (tuple, list)) + img = mmcv.imread(img) + img_show = img.copy() + h, w, _ = img.shape + + if not result or result == [None]: + return img_show + cur_result = result[0] + seg_label = cur_result[0] + seg_label = seg_label.cpu().numpy().astype(np.uint8) + cate_label = cur_result[1] + cate_label = cate_label.cpu().numpy() + score = cur_result[2].cpu().numpy() + + vis_inds = score > score_thr + seg_label = seg_label[vis_inds] + num_mask = seg_label.shape[0] + cate_label = cate_label[vis_inds] + cate_score = score[vis_inds] + + if sort_by_density: + mask_density = [] + for idx in range(num_mask): + cur_mask = seg_label[idx, :, :] + cur_mask = mmcv.imresize(cur_mask, (w, h)) + cur_mask = (cur_mask > 0.5).astype(np.int32) + mask_density.append(cur_mask.sum()) + orders = np.argsort(mask_density) + seg_label = seg_label[orders] + cate_label = cate_label[orders] + cate_score = cate_score[orders] + + np.random.seed(42) + color_masks = [ + np.random.randint(0, 256, (1, 3), dtype=np.uint8) + for _ in range(num_mask) + ] + for idx in range(num_mask): + idx = -(idx+1) + cur_mask = seg_label[idx, :, :] + cur_mask = mmcv.imresize(cur_mask, (w, h)) + cur_mask = (cur_mask > 0.5).astype(np.uint8) + if cur_mask.sum() == 0: + continue + color_mask = color_masks[idx] + cur_mask_bool = cur_mask.astype(np.bool) + img_show[cur_mask_bool] = img[cur_mask_bool] * 0.5 + color_mask * 0.5 + + cur_cate = cate_label[idx] + cur_score = cate_score[idx] + label_text = class_names[cur_cate] + #label_text += '|{:.02f}'.format(cur_score) + center_y, center_x = ndimage.measurements.center_of_mass(cur_mask) + vis_pos = (max(int(center_x) - 10, 0), int(center_y)) + cv2.putText(img_show, label_text, vis_pos, + cv2.FONT_HERSHEY_COMPLEX, 0.3, (255, 255, 255)) # green + if out_file is None: + return img_show + else: + mmcv.imwrite(img_show, out_file) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/train.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/train.py new file mode 100644 index 000000000..97c0dc69e --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/train.py @@ -0,0 +1,297 @@ +import random +import re +from collections import OrderedDict + +import numpy as np +import torch +import torch.distributed as dist +from mmcv.parallel import MMDataParallel, MMDistributedDataParallel +from mmcv.runner import DistSamplerSeedHook, Runner, obj_from_dict + +from mmdet import datasets +from mmdet.core import (CocoDistEvalmAPHook, CocoDistEvalRecallHook, + DistEvalmAPHook, DistOptimizerHook, Fp16OptimizerHook) +from mmdet.datasets import DATASETS, build_dataloader +from mmdet.models import RPN +from mmdet.utils import get_root_logger + + +def set_random_seed(seed, deterministic=False): + """Set random seed. + + Args: + seed (int): Seed to be used. + deterministic (bool): Whether to set the deterministic option for + CUDNN backend, i.e., set `torch.backends.cudnn.deterministic` + to True and `torch.backends.cudnn.benchmark` to False. + Default: False. + """ + random.seed(seed) + np.random.seed(seed) + torch.manual_seed(seed) + torch.cuda.manual_seed_all(seed) + if deterministic: + torch.backends.cudnn.deterministic = True + torch.backends.cudnn.benchmark = False + + +def parse_losses(losses): + log_vars = OrderedDict() + for loss_name, loss_value in losses.items(): + if isinstance(loss_value, torch.Tensor): + log_vars[loss_name] = loss_value.mean() + elif isinstance(loss_value, list): + log_vars[loss_name] = sum(_loss.mean() for _loss in loss_value) + else: + raise TypeError( + '{} is not a tensor or list of tensors'.format(loss_name)) + + loss = sum(_value for _key, _value in log_vars.items() if 'loss' in _key) + + log_vars['loss'] = loss + for loss_name, loss_value in log_vars.items(): + # reduce loss when distributed training + if dist.is_available() and dist.is_initialized(): + loss_value = loss_value.data.clone() + dist.all_reduce(loss_value.div_(dist.get_world_size())) + log_vars[loss_name] = loss_value.item() + + return loss, log_vars + + +def batch_processor(model, data, train_mode): + """Process a data batch. + + This method is required as an argument of Runner, which defines how to + process a data batch and obtain proper outputs. The first 3 arguments of + batch_processor are fixed. + + Args: + model (nn.Module): A PyTorch model. + data (dict): The data batch in a dict. + train_mode (bool): Training mode or not. It may be useless for some + models. + + Returns: + dict: A dict containing losses and log vars. + """ + losses = model(**data) + loss, log_vars = parse_losses(losses) + + outputs = dict( + loss=loss, log_vars=log_vars, num_samples=len(data['img'].data)) + + return outputs + + +def train_detector(model, + dataset, + cfg, + distributed=False, + validate=False, + timestamp=None): + logger = get_root_logger(cfg.log_level) + + # start training + if distributed: + _dist_train( + model, + dataset, + cfg, + validate=validate, + logger=logger, + timestamp=timestamp) + else: + _non_dist_train( + model, + dataset, + cfg, + validate=validate, + logger=logger, + timestamp=timestamp) + + +def build_optimizer(model, optimizer_cfg): + """Build optimizer from configs. + + Args: + model (:obj:`nn.Module`): The model with parameters to be optimized. + optimizer_cfg (dict): The config dict of the optimizer. + Positional fields are: + - type: class name of the optimizer. + - lr: base learning rate. + Optional fields are: + - any arguments of the corresponding optimizer type, e.g., + weight_decay, momentum, etc. + - paramwise_options: a dict with 3 accepted fileds + (bias_lr_mult, bias_decay_mult, norm_decay_mult). + `bias_lr_mult` and `bias_decay_mult` will be multiplied to + the lr and weight decay respectively for all bias parameters + (except for the normalization layers), and + `norm_decay_mult` will be multiplied to the weight decay + for all weight and bias parameters of normalization layers. + + Returns: + torch.optim.Optimizer: The initialized optimizer. + + Example: + >>> model = torch.nn.modules.Conv1d(1, 1, 1) + >>> optimizer_cfg = dict(type='SGD', lr=0.01, momentum=0.9, + >>> weight_decay=0.0001) + >>> optimizer = build_optimizer(model, optimizer_cfg) + """ + if hasattr(model, 'module'): + model = model.module + + optimizer_cfg = optimizer_cfg.copy() + paramwise_options = optimizer_cfg.pop('paramwise_options', None) + # if no paramwise option is specified, just use the global setting + if paramwise_options is None: + return obj_from_dict(optimizer_cfg, torch.optim, + dict(params=model.parameters())) + else: + assert isinstance(paramwise_options, dict) + # get base lr and weight decay + base_lr = optimizer_cfg['lr'] + base_wd = optimizer_cfg.get('weight_decay', None) + # weight_decay must be explicitly specified if mult is specified + if ('bias_decay_mult' in paramwise_options + or 'norm_decay_mult' in paramwise_options): + assert base_wd is not None + # get param-wise options + bias_lr_mult = paramwise_options.get('bias_lr_mult', 1.) + bias_decay_mult = paramwise_options.get('bias_decay_mult', 1.) + norm_decay_mult = paramwise_options.get('norm_decay_mult', 1.) + # set param-wise lr and weight decay + params = [] + for name, param in model.named_parameters(): + param_group = {'params': [param]} + if not param.requires_grad: + # FP16 training needs to copy gradient/weight between master + # weight copy and model weight, it is convenient to keep all + # parameters here to align with model.parameters() + params.append(param_group) + continue + + # for norm layers, overwrite the weight decay of weight and bias + # TODO: obtain the norm layer prefixes dynamically + if re.search(r'(bn|gn)(\d+)?.(weight|bias)', name): + if base_wd is not None: + param_group['weight_decay'] = base_wd * norm_decay_mult + # for other layers, overwrite both lr and weight decay of bias + elif name.endswith('.bias'): + param_group['lr'] = base_lr * bias_lr_mult + if base_wd is not None: + param_group['weight_decay'] = base_wd * bias_decay_mult + # otherwise use the global settings + + params.append(param_group) + + optimizer_cls = getattr(torch.optim, optimizer_cfg.pop('type')) + return optimizer_cls(params, **optimizer_cfg) + + +def _dist_train(model, + dataset, + cfg, + validate=False, + logger=None, + timestamp=None): + # prepare data loaders + dataset = dataset if isinstance(dataset, (list, tuple)) else [dataset] + data_loaders = [ + build_dataloader( + ds, cfg.data.imgs_per_gpu, cfg.data.workers_per_gpu, dist=True) + for ds in dataset + ] + # put model on gpus + model = MMDistributedDataParallel(model.cuda()) + + # build runner + optimizer = build_optimizer(model, cfg.optimizer) + runner = Runner( + model, batch_processor, optimizer, cfg.work_dir, logger=logger) + # an ugly walkaround to make the .log and .log.json filenames the same + runner.timestamp = timestamp + + # fp16 setting + fp16_cfg = cfg.get('fp16', None) + if fp16_cfg is not None: + optimizer_config = Fp16OptimizerHook(**cfg.optimizer_config, + **fp16_cfg) + else: + optimizer_config = DistOptimizerHook(**cfg.optimizer_config) + + # register hooks + runner.register_training_hooks(cfg.lr_config, optimizer_config, + cfg.checkpoint_config, cfg.log_config) + runner.register_hook(DistSamplerSeedHook()) + # register eval hooks + if validate: + val_dataset_cfg = cfg.data.val + eval_cfg = cfg.get('evaluation', {}) + if isinstance(model.module, RPN): + # TODO: implement recall hooks for other datasets + runner.register_hook( + CocoDistEvalRecallHook(val_dataset_cfg, **eval_cfg)) + else: + dataset_type = DATASETS.get(val_dataset_cfg.type) + if issubclass(dataset_type, datasets.CocoDataset): + runner.register_hook( + CocoDistEvalmAPHook(val_dataset_cfg, **eval_cfg)) + else: + runner.register_hook( + DistEvalmAPHook(val_dataset_cfg, **eval_cfg)) + + if cfg.resume_from: + runner.resume(cfg.resume_from) + elif cfg.load_from: + runner.load_checkpoint(cfg.load_from) + runner.run(data_loaders, cfg.workflow, cfg.total_epochs) + + +def _non_dist_train(model, + dataset, + cfg, + validate=False, + logger=None, + timestamp=None): + if validate: + raise NotImplementedError('Built-in validation is not implemented ' + 'yet in not-distributed training. Use ' + 'distributed training or test.py and ' + '*eval.py scripts instead.') + # prepare data loaders + dataset = dataset if isinstance(dataset, (list, tuple)) else [dataset] + data_loaders = [ + build_dataloader( + ds, + cfg.data.imgs_per_gpu, + cfg.data.workers_per_gpu, + cfg.gpus, + dist=False) for ds in dataset + ] + # put model on gpus + model = MMDataParallel(model, device_ids=range(cfg.gpus)).cuda() + + # build runner + optimizer = build_optimizer(model, cfg.optimizer) + runner = Runner( + model, batch_processor, optimizer, cfg.work_dir, logger=logger) + # an ugly walkaround to make the .log and .log.json filenames the same + runner.timestamp = timestamp + # fp16 setting + fp16_cfg = cfg.get('fp16', None) + if fp16_cfg is not None: + optimizer_config = Fp16OptimizerHook( + **cfg.optimizer_config, **fp16_cfg, distributed=False) + else: + optimizer_config = cfg.optimizer_config + runner.register_training_hooks(cfg.lr_config, optimizer_config, + cfg.checkpoint_config, cfg.log_config) + + if cfg.resume_from: + runner.resume(cfg.resume_from) + elif cfg.load_from: + runner.load_checkpoint(cfg.load_from) + runner.run(data_loaders, cfg.workflow, cfg.total_epochs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/__init__.py new file mode 100644 index 000000000..f8eb6cba5 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/__init__.py @@ -0,0 +1,7 @@ +from .anchor import * # noqa: F401, F403 +from .bbox import * # noqa: F401, F403 +from .evaluation import * # noqa: F401, F403 +from .fp16 import * # noqa: F401, F403 +from .mask import * # noqa: F401, F403 +from .post_processing import * # noqa: F401, F403 +from .utils import * # noqa: F401, F403 diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/__init__.py new file mode 100644 index 000000000..06e2d1232 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/__init__.py @@ -0,0 +1,12 @@ +from .anchor_generator import AnchorGenerator +from .anchor_target import (anchor_inside_flags, anchor_target, + images_to_levels, unmap) +from .guided_anchor_target import ga_loc_target, ga_shape_target +from .point_generator import PointGenerator +from .point_target import point_target + +__all__ = [ + 'AnchorGenerator', 'anchor_target', 'anchor_inside_flags', 'ga_loc_target', + 'ga_shape_target', 'PointGenerator', 'point_target', 'images_to_levels', + 'unmap' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/anchor_generator.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/anchor_generator.py new file mode 100644 index 000000000..cd227ad06 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/anchor_generator.py @@ -0,0 +1,98 @@ +import torch + + +class AnchorGenerator(object): + """ + Examples: + >>> from mmdet.core import AnchorGenerator + >>> self = AnchorGenerator(9, [1.], [1.]) + >>> all_anchors = self.grid_anchors((2, 2), device='cpu') + >>> print(all_anchors) + tensor([[ 0., 0., 8., 8.], + [16., 0., 24., 8.], + [ 0., 16., 8., 24.], + [16., 16., 24., 24.]]) + """ + + def __init__(self, base_size, scales, ratios, scale_major=True, ctr=None): + self.base_size = base_size + self.scales = torch.Tensor(scales) + self.ratios = torch.Tensor(ratios) + self.scale_major = scale_major + self.ctr = ctr + self.base_anchors = self.gen_base_anchors() + + @property + def num_base_anchors(self): + return self.base_anchors.size(0) + + def gen_base_anchors(self): + w = self.base_size + h = self.base_size + if self.ctr is None: + x_ctr = 0.5 * (w - 1) + y_ctr = 0.5 * (h - 1) + else: + x_ctr, y_ctr = self.ctr + + h_ratios = torch.sqrt(self.ratios) + w_ratios = 1 / h_ratios + if self.scale_major: + ws = (w * w_ratios[:, None] * self.scales[None, :]).view(-1) + hs = (h * h_ratios[:, None] * self.scales[None, :]).view(-1) + else: + ws = (w * self.scales[:, None] * w_ratios[None, :]).view(-1) + hs = (h * self.scales[:, None] * h_ratios[None, :]).view(-1) + + # yapf: disable + base_anchors = torch.stack( + [ + x_ctr - 0.5 * (ws - 1), y_ctr - 0.5 * (hs - 1), + x_ctr + 0.5 * (ws - 1), y_ctr + 0.5 * (hs - 1) + ], + dim=-1).round() + # yapf: enable + + return base_anchors + + def _meshgrid(self, x, y, row_major=True): + xx = x.repeat(len(y)) + yy = y.view(-1, 1).repeat(1, len(x)).view(-1) + if row_major: + return xx, yy + else: + return yy, xx + + def grid_anchors(self, featmap_size, stride=16, device='cuda'): + base_anchors = self.base_anchors.to(device) + + feat_h, feat_w = featmap_size + shift_x = torch.arange(0, feat_w, device=device) * stride + shift_y = torch.arange(0, feat_h, device=device) * stride + shift_xx, shift_yy = self._meshgrid(shift_x, shift_y) + shifts = torch.stack([shift_xx, shift_yy, shift_xx, shift_yy], dim=-1) + shifts = shifts.type_as(base_anchors) + # first feat_w elements correspond to the first row of shifts + # add A anchors (1, A, 4) to K shifts (K, 1, 4) to get + # shifted anchors (K, A, 4), reshape to (K*A, 4) + + all_anchors = base_anchors[None, :, :] + shifts[:, None, :] + all_anchors = all_anchors.view(-1, 4) + # first A rows correspond to A anchors of (0, 0) in feature map, + # then (0, 1), (0, 2), ... + return all_anchors + + def valid_flags(self, featmap_size, valid_size, device='cuda'): + feat_h, feat_w = featmap_size + valid_h, valid_w = valid_size + assert valid_h <= feat_h and valid_w <= feat_w + valid_x = torch.zeros(feat_w, dtype=torch.uint8, device=device) + valid_y = torch.zeros(feat_h, dtype=torch.uint8, device=device) + valid_x[:valid_w] = 1 + valid_y[:valid_h] = 1 + valid_xx, valid_yy = self._meshgrid(valid_x, valid_y) + valid = valid_xx & valid_yy + valid = valid[:, + None].expand(valid.size(0), + self.num_base_anchors).contiguous().view(-1) + return valid diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/anchor_target.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/anchor_target.py new file mode 100644 index 000000000..daf43c45e --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/anchor_target.py @@ -0,0 +1,188 @@ +import torch + +from ..bbox import PseudoSampler, assign_and_sample, bbox2delta, build_assigner +from ..utils import multi_apply + + +def anchor_target(anchor_list, + valid_flag_list, + gt_bboxes_list, + img_metas, + target_means, + target_stds, + cfg, + gt_bboxes_ignore_list=None, + gt_labels_list=None, + label_channels=1, + sampling=True, + unmap_outputs=True): + """Compute regression and classification targets for anchors. + + Args: + anchor_list (list[list]): Multi level anchors of each image. + valid_flag_list (list[list]): Multi level valid flags of each image. + gt_bboxes_list (list[Tensor]): Ground truth bboxes of each image. + img_metas (list[dict]): Meta info of each image. + target_means (Iterable): Mean value of regression targets. + target_stds (Iterable): Std value of regression targets. + cfg (dict): RPN train configs. + + Returns: + tuple + """ + num_imgs = len(img_metas) + assert len(anchor_list) == len(valid_flag_list) == num_imgs + + # anchor number of multi levels + num_level_anchors = [anchors.size(0) for anchors in anchor_list[0]] + # concat all level anchors and flags to a single tensor + for i in range(num_imgs): + assert len(anchor_list[i]) == len(valid_flag_list[i]) + anchor_list[i] = torch.cat(anchor_list[i]) + valid_flag_list[i] = torch.cat(valid_flag_list[i]) + + # compute targets for each image + if gt_bboxes_ignore_list is None: + gt_bboxes_ignore_list = [None for _ in range(num_imgs)] + if gt_labels_list is None: + gt_labels_list = [None for _ in range(num_imgs)] + (all_labels, all_label_weights, all_bbox_targets, all_bbox_weights, + pos_inds_list, neg_inds_list) = multi_apply( + anchor_target_single, + anchor_list, + valid_flag_list, + gt_bboxes_list, + gt_bboxes_ignore_list, + gt_labels_list, + img_metas, + target_means=target_means, + target_stds=target_stds, + cfg=cfg, + label_channels=label_channels, + sampling=sampling, + unmap_outputs=unmap_outputs) + # no valid anchors + if any([labels is None for labels in all_labels]): + return None + # sampled anchors of all images + num_total_pos = sum([max(inds.numel(), 1) for inds in pos_inds_list]) + num_total_neg = sum([max(inds.numel(), 1) for inds in neg_inds_list]) + # split targets to a list w.r.t. multiple levels + labels_list = images_to_levels(all_labels, num_level_anchors) + label_weights_list = images_to_levels(all_label_weights, num_level_anchors) + bbox_targets_list = images_to_levels(all_bbox_targets, num_level_anchors) + bbox_weights_list = images_to_levels(all_bbox_weights, num_level_anchors) + return (labels_list, label_weights_list, bbox_targets_list, + bbox_weights_list, num_total_pos, num_total_neg) + + +def images_to_levels(target, num_level_anchors): + """Convert targets by image to targets by feature level. + + [target_img0, target_img1] -> [target_level0, target_level1, ...] + """ + target = torch.stack(target, 0) + level_targets = [] + start = 0 + for n in num_level_anchors: + end = start + n + level_targets.append(target[:, start:end].squeeze(0)) + start = end + return level_targets + + +def anchor_target_single(flat_anchors, + valid_flags, + gt_bboxes, + gt_bboxes_ignore, + gt_labels, + img_meta, + target_means, + target_stds, + cfg, + label_channels=1, + sampling=True, + unmap_outputs=True): + inside_flags = anchor_inside_flags(flat_anchors, valid_flags, + img_meta['img_shape'][:2], + cfg.allowed_border) + if not inside_flags.any(): + return (None, ) * 6 + # assign gt and sample anchors + anchors = flat_anchors[inside_flags, :] + + if sampling: + assign_result, sampling_result = assign_and_sample( + anchors, gt_bboxes, gt_bboxes_ignore, None, cfg) + else: + bbox_assigner = build_assigner(cfg.assigner) + assign_result = bbox_assigner.assign(anchors, gt_bboxes, + gt_bboxes_ignore, gt_labels) + bbox_sampler = PseudoSampler() + sampling_result = bbox_sampler.sample(assign_result, anchors, + gt_bboxes) + + num_valid_anchors = anchors.shape[0] + bbox_targets = torch.zeros_like(anchors) + bbox_weights = torch.zeros_like(anchors) + labels = anchors.new_zeros(num_valid_anchors, dtype=torch.long) + label_weights = anchors.new_zeros(num_valid_anchors, dtype=torch.float) + + pos_inds = sampling_result.pos_inds + neg_inds = sampling_result.neg_inds + if len(pos_inds) > 0: + pos_bbox_targets = bbox2delta(sampling_result.pos_bboxes, + sampling_result.pos_gt_bboxes, + target_means, target_stds) + bbox_targets[pos_inds, :] = pos_bbox_targets + bbox_weights[pos_inds, :] = 1.0 + if gt_labels is None: + labels[pos_inds] = 1 + else: + labels[pos_inds] = gt_labels[sampling_result.pos_assigned_gt_inds] + if cfg.pos_weight <= 0: + label_weights[pos_inds] = 1.0 + else: + label_weights[pos_inds] = cfg.pos_weight + if len(neg_inds) > 0: + label_weights[neg_inds] = 1.0 + + # map up to original set of anchors + if unmap_outputs: + num_total_anchors = flat_anchors.size(0) + labels = unmap(labels, num_total_anchors, inside_flags) + label_weights = unmap(label_weights, num_total_anchors, inside_flags) + bbox_targets = unmap(bbox_targets, num_total_anchors, inside_flags) + bbox_weights = unmap(bbox_weights, num_total_anchors, inside_flags) + + return (labels, label_weights, bbox_targets, bbox_weights, pos_inds, + neg_inds) + + +def anchor_inside_flags(flat_anchors, + valid_flags, + img_shape, + allowed_border=0): + img_h, img_w = img_shape[:2] + if allowed_border >= 0: + inside_flags = valid_flags & \ + (flat_anchors[:, 0] >= -allowed_border).type(torch.uint8) & \ + (flat_anchors[:, 1] >= -allowed_border).type(torch.uint8) & \ + (flat_anchors[:, 2] < img_w + allowed_border).type(torch.uint8) & \ + (flat_anchors[:, 3] < img_h + allowed_border).type(torch.uint8) + else: + inside_flags = valid_flags + return inside_flags + + +def unmap(data, count, inds, fill=0): + """ Unmap a subset of item (data) back to the original set of items (of + size count) """ + if data.dim() == 1: + ret = data.new_full((count, ), fill) + ret[inds] = data + else: + new_size = (count, ) + data.size()[1:] + ret = data.new_full(new_size, fill) + ret[inds, :] = data + return ret diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/guided_anchor_target.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/guided_anchor_target.py new file mode 100644 index 000000000..21162eb9e --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/guided_anchor_target.py @@ -0,0 +1,287 @@ +import torch + +from ..bbox import PseudoSampler, build_assigner, build_sampler +from ..utils import multi_apply, unmap + + +def calc_region(bbox, ratio, featmap_size=None): + """Calculate a proportional bbox region. + + The bbox center are fixed and the new h' and w' is h * ratio and w * ratio. + + Args: + bbox (Tensor): Bboxes to calculate regions, shape (n, 4) + ratio (float): Ratio of the output region. + featmap_size (tuple): Feature map size used for clipping the boundary. + + Returns: + tuple: x1, y1, x2, y2 + """ + x1 = torch.round((1 - ratio) * bbox[0] + ratio * bbox[2]).long() + y1 = torch.round((1 - ratio) * bbox[1] + ratio * bbox[3]).long() + x2 = torch.round(ratio * bbox[0] + (1 - ratio) * bbox[2]).long() + y2 = torch.round(ratio * bbox[1] + (1 - ratio) * bbox[3]).long() + if featmap_size is not None: + x1 = x1.clamp(min=0, max=featmap_size[1] - 1) + y1 = y1.clamp(min=0, max=featmap_size[0] - 1) + x2 = x2.clamp(min=0, max=featmap_size[1] - 1) + y2 = y2.clamp(min=0, max=featmap_size[0] - 1) + return (x1, y1, x2, y2) + + +def ga_loc_target(gt_bboxes_list, + featmap_sizes, + anchor_scale, + anchor_strides, + center_ratio=0.2, + ignore_ratio=0.5): + """Compute location targets for guided anchoring. + + Each feature map is divided into positive, negative and ignore regions. + - positive regions: target 1, weight 1 + - ignore regions: target 0, weight 0 + - negative regions: target 0, weight 0.1 + + Args: + gt_bboxes_list (list[Tensor]): Gt bboxes of each image. + featmap_sizes (list[tuple]): Multi level sizes of each feature maps. + anchor_scale (int): Anchor scale. + anchor_strides ([list[int]]): Multi level anchor strides. + center_ratio (float): Ratio of center region. + ignore_ratio (float): Ratio of ignore region. + + Returns: + tuple + """ + img_per_gpu = len(gt_bboxes_list) + num_lvls = len(featmap_sizes) + r1 = (1 - center_ratio) / 2 + r2 = (1 - ignore_ratio) / 2 + all_loc_targets = [] + all_loc_weights = [] + all_ignore_map = [] + for lvl_id in range(num_lvls): + h, w = featmap_sizes[lvl_id] + loc_targets = torch.zeros( + img_per_gpu, + 1, + h, + w, + device=gt_bboxes_list[0].device, + dtype=torch.float32) + loc_weights = torch.full_like(loc_targets, -1) + ignore_map = torch.zeros_like(loc_targets) + all_loc_targets.append(loc_targets) + all_loc_weights.append(loc_weights) + all_ignore_map.append(ignore_map) + for img_id in range(img_per_gpu): + gt_bboxes = gt_bboxes_list[img_id] + scale = torch.sqrt((gt_bboxes[:, 2] - gt_bboxes[:, 0] + 1) * + (gt_bboxes[:, 3] - gt_bboxes[:, 1] + 1)) + min_anchor_size = scale.new_full( + (1, ), float(anchor_scale * anchor_strides[0])) + # assign gt bboxes to different feature levels w.r.t. their scales + target_lvls = torch.floor( + torch.log2(scale) - torch.log2(min_anchor_size) + 0.5) + target_lvls = target_lvls.clamp(min=0, max=num_lvls - 1).long() + for gt_id in range(gt_bboxes.size(0)): + lvl = target_lvls[gt_id].item() + # rescaled to corresponding feature map + gt_ = gt_bboxes[gt_id, :4] / anchor_strides[lvl] + # calculate ignore regions + ignore_x1, ignore_y1, ignore_x2, ignore_y2 = calc_region( + gt_, r2, featmap_sizes[lvl]) + # calculate positive (center) regions + ctr_x1, ctr_y1, ctr_x2, ctr_y2 = calc_region( + gt_, r1, featmap_sizes[lvl]) + all_loc_targets[lvl][img_id, 0, ctr_y1:ctr_y2 + 1, + ctr_x1:ctr_x2 + 1] = 1 + all_loc_weights[lvl][img_id, 0, ignore_y1:ignore_y2 + 1, + ignore_x1:ignore_x2 + 1] = 0 + all_loc_weights[lvl][img_id, 0, ctr_y1:ctr_y2 + 1, + ctr_x1:ctr_x2 + 1] = 1 + # calculate ignore map on nearby low level feature + if lvl > 0: + d_lvl = lvl - 1 + # rescaled to corresponding feature map + gt_ = gt_bboxes[gt_id, :4] / anchor_strides[d_lvl] + ignore_x1, ignore_y1, ignore_x2, ignore_y2 = calc_region( + gt_, r2, featmap_sizes[d_lvl]) + all_ignore_map[d_lvl][img_id, 0, ignore_y1:ignore_y2 + 1, + ignore_x1:ignore_x2 + 1] = 1 + # calculate ignore map on nearby high level feature + if lvl < num_lvls - 1: + u_lvl = lvl + 1 + # rescaled to corresponding feature map + gt_ = gt_bboxes[gt_id, :4] / anchor_strides[u_lvl] + ignore_x1, ignore_y1, ignore_x2, ignore_y2 = calc_region( + gt_, r2, featmap_sizes[u_lvl]) + all_ignore_map[u_lvl][img_id, 0, ignore_y1:ignore_y2 + 1, + ignore_x1:ignore_x2 + 1] = 1 + for lvl_id in range(num_lvls): + # ignore negative regions w.r.t. ignore map + all_loc_weights[lvl_id][(all_loc_weights[lvl_id] < 0) + & (all_ignore_map[lvl_id] > 0)] = 0 + # set negative regions with weight 0.1 + all_loc_weights[lvl_id][all_loc_weights[lvl_id] < 0] = 0.1 + # loc average factor to balance loss + loc_avg_factor = sum( + [t.size(0) * t.size(-1) * t.size(-2) for t in all_loc_targets]) / 200 + return all_loc_targets, all_loc_weights, loc_avg_factor + + +def ga_shape_target(approx_list, + inside_flag_list, + square_list, + gt_bboxes_list, + img_metas, + approxs_per_octave, + cfg, + gt_bboxes_ignore_list=None, + sampling=True, + unmap_outputs=True): + """Compute guided anchoring targets. + + Args: + approx_list (list[list]): Multi level approxs of each image. + inside_flag_list (list[list]): Multi level inside flags of each image. + square_list (list[list]): Multi level squares of each image. + gt_bboxes_list (list[Tensor]): Ground truth bboxes of each image. + img_metas (list[dict]): Meta info of each image. + approxs_per_octave (int): number of approxs per octave + cfg (dict): RPN train configs. + gt_bboxes_ignore_list (list[Tensor]): ignore list of gt bboxes. + sampling (bool): sampling or not. + unmap_outputs (bool): unmap outputs or not. + + Returns: + tuple + """ + num_imgs = len(img_metas) + assert len(approx_list) == len(inside_flag_list) == len( + square_list) == num_imgs + # anchor number of multi levels + num_level_squares = [squares.size(0) for squares in square_list[0]] + # concat all level anchors and flags to a single tensor + inside_flag_flat_list = [] + approx_flat_list = [] + square_flat_list = [] + for i in range(num_imgs): + assert len(square_list[i]) == len(inside_flag_list[i]) + inside_flag_flat_list.append(torch.cat(inside_flag_list[i])) + approx_flat_list.append(torch.cat(approx_list[i])) + square_flat_list.append(torch.cat(square_list[i])) + + # compute targets for each image + if gt_bboxes_ignore_list is None: + gt_bboxes_ignore_list = [None for _ in range(num_imgs)] + (all_bbox_anchors, all_bbox_gts, all_bbox_weights, pos_inds_list, + neg_inds_list) = multi_apply( + ga_shape_target_single, + approx_flat_list, + inside_flag_flat_list, + square_flat_list, + gt_bboxes_list, + gt_bboxes_ignore_list, + img_metas, + approxs_per_octave=approxs_per_octave, + cfg=cfg, + sampling=sampling, + unmap_outputs=unmap_outputs) + # no valid anchors + if any([bbox_anchors is None for bbox_anchors in all_bbox_anchors]): + return None + # sampled anchors of all images + num_total_pos = sum([max(inds.numel(), 1) for inds in pos_inds_list]) + num_total_neg = sum([max(inds.numel(), 1) for inds in neg_inds_list]) + # split targets to a list w.r.t. multiple levels + bbox_anchors_list = images_to_levels(all_bbox_anchors, num_level_squares) + bbox_gts_list = images_to_levels(all_bbox_gts, num_level_squares) + bbox_weights_list = images_to_levels(all_bbox_weights, num_level_squares) + return (bbox_anchors_list, bbox_gts_list, bbox_weights_list, num_total_pos, + num_total_neg) + + +def images_to_levels(target, num_level_anchors): + """Convert targets by image to targets by feature level. + + [target_img0, target_img1] -> [target_level0, target_level1, ...] + """ + target = torch.stack(target, 0) + level_targets = [] + start = 0 + for n in num_level_anchors: + end = start + n + level_targets.append(target[:, start:end].squeeze(0)) + start = end + return level_targets + + +def ga_shape_target_single(flat_approxs, + inside_flags, + flat_squares, + gt_bboxes, + gt_bboxes_ignore, + img_meta, + approxs_per_octave, + cfg, + sampling=True, + unmap_outputs=True): + """Compute guided anchoring targets. + + This function returns sampled anchors and gt bboxes directly + rather than calculates regression targets. + + Args: + flat_approxs (Tensor): flat approxs of a single image, + shape (n, 4) + inside_flags (Tensor): inside flags of a single image, + shape (n, ). + flat_squares (Tensor): flat squares of a single image, + shape (approxs_per_octave * n, 4) + gt_bboxes (Tensor): Ground truth bboxes of a single image. + img_meta (dict): Meta info of a single image. + approxs_per_octave (int): number of approxs per octave + cfg (dict): RPN train configs. + sampling (bool): sampling or not. + unmap_outputs (bool): unmap outputs or not. + + Returns: + tuple + """ + if not inside_flags.any(): + return (None, ) * 5 + # assign gt and sample anchors + expand_inside_flags = inside_flags[:, None].expand( + -1, approxs_per_octave).reshape(-1) + approxs = flat_approxs[expand_inside_flags, :] + squares = flat_squares[inside_flags, :] + + bbox_assigner = build_assigner(cfg.ga_assigner) + assign_result = bbox_assigner.assign(approxs, squares, approxs_per_octave, + gt_bboxes, gt_bboxes_ignore) + if sampling: + bbox_sampler = build_sampler(cfg.ga_sampler) + else: + bbox_sampler = PseudoSampler() + sampling_result = bbox_sampler.sample(assign_result, squares, gt_bboxes) + + bbox_anchors = torch.zeros_like(squares) + bbox_gts = torch.zeros_like(squares) + bbox_weights = torch.zeros_like(squares) + + pos_inds = sampling_result.pos_inds + neg_inds = sampling_result.neg_inds + if len(pos_inds) > 0: + bbox_anchors[pos_inds, :] = sampling_result.pos_bboxes + bbox_gts[pos_inds, :] = sampling_result.pos_gt_bboxes + bbox_weights[pos_inds, :] = 1.0 + + # map up to original set of anchors + if unmap_outputs: + num_total_anchors = flat_squares.size(0) + bbox_anchors = unmap(bbox_anchors, num_total_anchors, inside_flags) + bbox_gts = unmap(bbox_gts, num_total_anchors, inside_flags) + bbox_weights = unmap(bbox_weights, num_total_anchors, inside_flags) + + return (bbox_anchors, bbox_gts, bbox_weights, pos_inds, neg_inds) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/point_generator.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/point_generator.py new file mode 100644 index 000000000..c1a34dddd --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/point_generator.py @@ -0,0 +1,34 @@ +import torch + + +class PointGenerator(object): + + def _meshgrid(self, x, y, row_major=True): + xx = x.repeat(len(y)) + yy = y.view(-1, 1).repeat(1, len(x)).view(-1) + if row_major: + return xx, yy + else: + return yy, xx + + def grid_points(self, featmap_size, stride=16, device='cuda'): + feat_h, feat_w = featmap_size + shift_x = torch.arange(0., feat_w, device=device) * stride + shift_y = torch.arange(0., feat_h, device=device) * stride + shift_xx, shift_yy = self._meshgrid(shift_x, shift_y) + stride = shift_x.new_full((shift_xx.shape[0], ), stride) + shifts = torch.stack([shift_xx, shift_yy, stride], dim=-1) + all_points = shifts.to(device) + return all_points + + def valid_flags(self, featmap_size, valid_size, device='cuda'): + feat_h, feat_w = featmap_size + valid_h, valid_w = valid_size + assert valid_h <= feat_h and valid_w <= feat_w + valid_x = torch.zeros(feat_w, dtype=torch.uint8, device=device) + valid_y = torch.zeros(feat_h, dtype=torch.uint8, device=device) + valid_x[:valid_w] = 1 + valid_y[:valid_h] = 1 + valid_xx, valid_yy = self._meshgrid(valid_x, valid_y) + valid = valid_xx & valid_yy + return valid diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/point_target.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/point_target.py new file mode 100644 index 000000000..1ab8d0260 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/point_target.py @@ -0,0 +1,165 @@ +import torch + +from ..bbox import PseudoSampler, assign_and_sample, build_assigner +from ..utils import multi_apply + + +def point_target(proposals_list, + valid_flag_list, + gt_bboxes_list, + img_metas, + cfg, + gt_bboxes_ignore_list=None, + gt_labels_list=None, + label_channels=1, + sampling=True, + unmap_outputs=True): + """Compute corresponding GT box and classification targets for proposals. + + Args: + points_list (list[list]): Multi level points of each image. + valid_flag_list (list[list]): Multi level valid flags of each image. + gt_bboxes_list (list[Tensor]): Ground truth bboxes of each image. + img_metas (list[dict]): Meta info of each image. + cfg (dict): train sample configs. + + Returns: + tuple + """ + num_imgs = len(img_metas) + assert len(proposals_list) == len(valid_flag_list) == num_imgs + + # points number of multi levels + num_level_proposals = [points.size(0) for points in proposals_list[0]] + + # concat all level points and flags to a single tensor + for i in range(num_imgs): + assert len(proposals_list[i]) == len(valid_flag_list[i]) + proposals_list[i] = torch.cat(proposals_list[i]) + valid_flag_list[i] = torch.cat(valid_flag_list[i]) + + # compute targets for each image + if gt_bboxes_ignore_list is None: + gt_bboxes_ignore_list = [None for _ in range(num_imgs)] + if gt_labels_list is None: + gt_labels_list = [None for _ in range(num_imgs)] + (all_labels, all_label_weights, all_bbox_gt, all_proposals, + all_proposal_weights, pos_inds_list, neg_inds_list) = multi_apply( + point_target_single, + proposals_list, + valid_flag_list, + gt_bboxes_list, + gt_bboxes_ignore_list, + gt_labels_list, + cfg=cfg, + label_channels=label_channels, + sampling=sampling, + unmap_outputs=unmap_outputs) + # no valid points + if any([labels is None for labels in all_labels]): + return None + # sampled points of all images + num_total_pos = sum([max(inds.numel(), 1) for inds in pos_inds_list]) + num_total_neg = sum([max(inds.numel(), 1) for inds in neg_inds_list]) + labels_list = images_to_levels(all_labels, num_level_proposals) + label_weights_list = images_to_levels(all_label_weights, + num_level_proposals) + bbox_gt_list = images_to_levels(all_bbox_gt, num_level_proposals) + proposals_list = images_to_levels(all_proposals, num_level_proposals) + proposal_weights_list = images_to_levels(all_proposal_weights, + num_level_proposals) + return (labels_list, label_weights_list, bbox_gt_list, proposals_list, + proposal_weights_list, num_total_pos, num_total_neg) + + +def images_to_levels(target, num_level_grids): + """Convert targets by image to targets by feature level. + + [target_img0, target_img1] -> [target_level0, target_level1, ...] + """ + target = torch.stack(target, 0) + level_targets = [] + start = 0 + for n in num_level_grids: + end = start + n + level_targets.append(target[:, start:end].squeeze(0)) + start = end + return level_targets + + +def point_target_single(flat_proposals, + valid_flags, + gt_bboxes, + gt_bboxes_ignore, + gt_labels, + cfg, + label_channels=1, + sampling=True, + unmap_outputs=True): + inside_flags = valid_flags + if not inside_flags.any(): + return (None, ) * 7 + # assign gt and sample proposals + proposals = flat_proposals[inside_flags, :] + + if sampling: + assign_result, sampling_result = assign_and_sample( + proposals, gt_bboxes, gt_bboxes_ignore, None, cfg) + else: + bbox_assigner = build_assigner(cfg.assigner) + assign_result = bbox_assigner.assign(proposals, gt_bboxes, + gt_bboxes_ignore, gt_labels) + bbox_sampler = PseudoSampler() + sampling_result = bbox_sampler.sample(assign_result, proposals, + gt_bboxes) + + num_valid_proposals = proposals.shape[0] + bbox_gt = proposals.new_zeros([num_valid_proposals, 4]) + pos_proposals = torch.zeros_like(proposals) + proposals_weights = proposals.new_zeros([num_valid_proposals, 4]) + labels = proposals.new_zeros(num_valid_proposals, dtype=torch.long) + label_weights = proposals.new_zeros(num_valid_proposals, dtype=torch.float) + + pos_inds = sampling_result.pos_inds + neg_inds = sampling_result.neg_inds + if len(pos_inds) > 0: + pos_gt_bboxes = sampling_result.pos_gt_bboxes + bbox_gt[pos_inds, :] = pos_gt_bboxes + pos_proposals[pos_inds, :] = proposals[pos_inds, :] + proposals_weights[pos_inds, :] = 1.0 + if gt_labels is None: + labels[pos_inds] = 1 + else: + labels[pos_inds] = gt_labels[sampling_result.pos_assigned_gt_inds] + if cfg.pos_weight <= 0: + label_weights[pos_inds] = 1.0 + else: + label_weights[pos_inds] = cfg.pos_weight + if len(neg_inds) > 0: + label_weights[neg_inds] = 1.0 + + # map up to original set of proposals + if unmap_outputs: + num_total_proposals = flat_proposals.size(0) + labels = unmap(labels, num_total_proposals, inside_flags) + label_weights = unmap(label_weights, num_total_proposals, inside_flags) + bbox_gt = unmap(bbox_gt, num_total_proposals, inside_flags) + pos_proposals = unmap(pos_proposals, num_total_proposals, inside_flags) + proposals_weights = unmap(proposals_weights, num_total_proposals, + inside_flags) + + return (labels, label_weights, bbox_gt, pos_proposals, proposals_weights, + pos_inds, neg_inds) + + +def unmap(data, count, inds, fill=0): + """ Unmap a subset of item (data) back to the original set of items (of + size count) """ + if data.dim() == 1: + ret = data.new_full((count, ), fill) + ret[inds] = data + else: + new_size = (count, ) + data.size()[1:] + ret = data.new_full(new_size, fill) + ret[inds, :] = data + return ret diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/__init__.py new file mode 100644 index 000000000..a0de91724 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/__init__.py @@ -0,0 +1,22 @@ +from .assigners import AssignResult, BaseAssigner, MaxIoUAssigner +from .bbox_target import bbox_target +from .geometry import bbox_overlaps +from .samplers import (BaseSampler, CombinedSampler, + InstanceBalancedPosSampler, IoUBalancedNegSampler, + PseudoSampler, RandomSampler, SamplingResult) +from .transforms import (bbox2delta, bbox2result, bbox2roi, bbox_flip, + bbox_mapping, bbox_mapping_back, delta2bbox, + distance2bbox, roi2bbox) + +from .assign_sampling import ( # isort:skip, avoid recursive imports + assign_and_sample, build_assigner, build_sampler) + +__all__ = [ + 'bbox_overlaps', 'BaseAssigner', 'MaxIoUAssigner', 'AssignResult', + 'BaseSampler', 'PseudoSampler', 'RandomSampler', + 'InstanceBalancedPosSampler', 'IoUBalancedNegSampler', 'CombinedSampler', + 'SamplingResult', 'build_assigner', 'build_sampler', 'assign_and_sample', + 'bbox2delta', 'delta2bbox', 'bbox_flip', 'bbox_mapping', + 'bbox_mapping_back', 'bbox2roi', 'roi2bbox', 'bbox2result', + 'distance2bbox', 'bbox_target' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assign_sampling.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assign_sampling.py new file mode 100644 index 000000000..4267174bb --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assign_sampling.py @@ -0,0 +1,33 @@ +import mmcv + +from . import assigners, samplers + + +def build_assigner(cfg, **kwargs): + if isinstance(cfg, assigners.BaseAssigner): + return cfg + elif isinstance(cfg, dict): + return mmcv.runner.obj_from_dict(cfg, assigners, default_args=kwargs) + else: + raise TypeError('Invalid type {} for building a sampler'.format( + type(cfg))) + + +def build_sampler(cfg, **kwargs): + if isinstance(cfg, samplers.BaseSampler): + return cfg + elif isinstance(cfg, dict): + return mmcv.runner.obj_from_dict(cfg, samplers, default_args=kwargs) + else: + raise TypeError('Invalid type {} for building a sampler'.format( + type(cfg))) + + +def assign_and_sample(bboxes, gt_bboxes, gt_bboxes_ignore, gt_labels, cfg): + bbox_assigner = build_assigner(cfg.assigner) + bbox_sampler = build_sampler(cfg.sampler) + assign_result = bbox_assigner.assign(bboxes, gt_bboxes, gt_bboxes_ignore, + gt_labels) + sampling_result = bbox_sampler.sample(assign_result, bboxes, gt_bboxes, + gt_labels) + return assign_result, sampling_result diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/__init__.py new file mode 100644 index 000000000..4ed1d5643 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/__init__.py @@ -0,0 +1,11 @@ +from .approx_max_iou_assigner import ApproxMaxIoUAssigner +from .assign_result import AssignResult +from .atss_assigner import ATSSAssigner +from .base_assigner import BaseAssigner +from .max_iou_assigner import MaxIoUAssigner +from .point_assigner import PointAssigner + +__all__ = [ + 'BaseAssigner', 'MaxIoUAssigner', 'ApproxMaxIoUAssigner', 'AssignResult', + 'PointAssigner', 'ATSSAssigner' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/approx_max_iou_assigner.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/approx_max_iou_assigner.py new file mode 100644 index 000000000..e7d3510a0 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/approx_max_iou_assigner.py @@ -0,0 +1,139 @@ +import torch + +from ..geometry import bbox_overlaps +from .max_iou_assigner import MaxIoUAssigner + + +class ApproxMaxIoUAssigner(MaxIoUAssigner): + """Assign a corresponding gt bbox or background to each bbox. + + Each proposals will be assigned with `-1`, `0`, or a positive integer + indicating the ground truth index. + + - -1: don't care + - 0: negative sample, no assigned gt + - positive integer: positive sample, index (1-based) of assigned gt + + Args: + pos_iou_thr (float): IoU threshold for positive bboxes. + neg_iou_thr (float or tuple): IoU threshold for negative bboxes. + min_pos_iou (float): Minimum iou for a bbox to be considered as a + positive bbox. Positive samples can have smaller IoU than + pos_iou_thr due to the 4th step (assign max IoU sample to each gt). + gt_max_assign_all (bool): Whether to assign all bboxes with the same + highest overlap with some gt to that gt. + ignore_iof_thr (float): IoF threshold for ignoring bboxes (if + `gt_bboxes_ignore` is specified). Negative values mean not + ignoring any bboxes. + ignore_wrt_candidates (bool): Whether to compute the iof between + `bboxes` and `gt_bboxes_ignore`, or the contrary. + gpu_assign_thr (int): The upper bound of the number of GT for GPU + assign. When the number of gt is above this threshold, will assign + on CPU device. Negative values mean not assign on CPU. + """ + + def __init__(self, + pos_iou_thr, + neg_iou_thr, + min_pos_iou=.0, + gt_max_assign_all=True, + ignore_iof_thr=-1, + ignore_wrt_candidates=True, + gpu_assign_thr=-1): + self.pos_iou_thr = pos_iou_thr + self.neg_iou_thr = neg_iou_thr + self.min_pos_iou = min_pos_iou + self.gt_max_assign_all = gt_max_assign_all + self.ignore_iof_thr = ignore_iof_thr + self.ignore_wrt_candidates = ignore_wrt_candidates + self.gpu_assign_thr = gpu_assign_thr + + def assign(self, + approxs, + squares, + approxs_per_octave, + gt_bboxes, + gt_bboxes_ignore=None, + gt_labels=None): + """Assign gt to approxs. + + This method assign a gt bbox to each group of approxs (bboxes), + each group of approxs is represent by a base approx (bbox) and + will be assigned with -1, 0, or a positive number. + -1 means don't care, 0 means negative sample, + positive number is the index (1-based) of assigned gt. + The assignment is done in following steps, the order matters. + + 1. assign every bbox to -1 + 2. use the max IoU of each group of approxs to assign + 2. assign proposals whose iou with all gts < neg_iou_thr to 0 + 3. for each bbox, if the iou with its nearest gt >= pos_iou_thr, + assign it to that bbox + 4. for each gt bbox, assign its nearest proposals (may be more than + one) to itself + + Args: + approxs (Tensor): Bounding boxes to be assigned, + shape(approxs_per_octave*n, 4). + squares (Tensor): Base Bounding boxes to be assigned, + shape(n, 4). + approxs_per_octave (int): number of approxs per octave + gt_bboxes (Tensor): Groundtruth boxes, shape (k, 4). + gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are + labelled as `ignored`, e.g., crowd boxes in COCO. + gt_labels (Tensor, optional): Label of gt_bboxes, shape (k, ). + + Returns: + :obj:`AssignResult`: The assign result. + """ + num_squares = squares.size(0) + num_gts = gt_bboxes.size(0) + + if num_squares == 0 or num_gts == 0: + # No predictions and/or truth, return empty assignment + overlaps = approxs.new(num_gts, num_squares) + assign_result = self.assign_wrt_overlaps(overlaps, gt_labels) + return assign_result + + # re-organize anchors by approxs_per_octave x num_squares + approxs = torch.transpose( + approxs.view(num_squares, approxs_per_octave, 4), 0, + 1).contiguous().view(-1, 4) + assign_on_cpu = True if (self.gpu_assign_thr > 0) and ( + num_gts > self.gpu_assign_thr) else False + # compute overlap and assign gt on CPU when number of GT is large + if assign_on_cpu: + device = approxs.device + approxs = approxs.cpu() + gt_bboxes = gt_bboxes.cpu() + if gt_bboxes_ignore is not None: + gt_bboxes_ignore = gt_bboxes_ignore.cpu() + if gt_labels is not None: + gt_labels = gt_labels.cpu() + all_overlaps = bbox_overlaps(approxs, gt_bboxes) + + overlaps, _ = all_overlaps.view(approxs_per_octave, num_squares, + num_gts).max(dim=0) + overlaps = torch.transpose(overlaps, 0, 1) + + bboxes = squares[:, :4] + + if (self.ignore_iof_thr > 0) and (gt_bboxes_ignore is not None) and ( + gt_bboxes_ignore.numel() > 0): + if self.ignore_wrt_candidates: + ignore_overlaps = bbox_overlaps( + bboxes, gt_bboxes_ignore, mode='iof') + ignore_max_overlaps, _ = ignore_overlaps.max(dim=1) + else: + ignore_overlaps = bbox_overlaps( + gt_bboxes_ignore, bboxes, mode='iof') + ignore_max_overlaps, _ = ignore_overlaps.max(dim=0) + overlaps[:, ignore_max_overlaps > self.ignore_iof_thr] = -1 + + assign_result = self.assign_wrt_overlaps(overlaps, gt_labels) + if assign_on_cpu: + assign_result.gt_inds = assign_result.gt_inds.to(device) + assign_result.max_overlaps = assign_result.max_overlaps.to(device) + if assign_result.labels is not None: + assign_result.labels = assign_result.labels.to(device) + return assign_result diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/assign_result.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/assign_result.py new file mode 100644 index 000000000..5e81c8978 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/assign_result.py @@ -0,0 +1,192 @@ +import torch + +from mmdet.utils import util_mixins + + +class AssignResult(util_mixins.NiceRepr): + """ + Stores assignments between predicted and truth boxes. + + Attributes: + num_gts (int): the number of truth boxes considered when computing this + assignment + + gt_inds (LongTensor): for each predicted box indicates the 1-based + index of the assigned truth box. 0 means unassigned and -1 means + ignore. + + max_overlaps (FloatTensor): the iou between the predicted box and its + assigned truth box. + + labels (None | LongTensor): If specified, for each predicted box + indicates the category label of the assigned truth box. + + Example: + >>> # An assign result between 4 predicted boxes and 9 true boxes + >>> # where only two boxes were assigned. + >>> num_gts = 9 + >>> max_overlaps = torch.LongTensor([0, .5, .9, 0]) + >>> gt_inds = torch.LongTensor([-1, 1, 2, 0]) + >>> labels = torch.LongTensor([0, 3, 4, 0]) + >>> self = AssignResult(num_gts, gt_inds, max_overlaps, labels) + >>> print(str(self)) # xdoctest: +IGNORE_WANT + + >>> # Force addition of gt labels (when adding gt as proposals) + >>> new_labels = torch.LongTensor([3, 4, 5]) + >>> self.add_gt_(new_labels) + >>> print(str(self)) # xdoctest: +IGNORE_WANT + + """ + + def __init__(self, num_gts, gt_inds, max_overlaps, labels=None): + self.num_gts = num_gts + self.gt_inds = gt_inds + self.max_overlaps = max_overlaps + self.labels = labels + + @property + def num_preds(self): + """ + Return the number of predictions in this assignment + """ + return len(self.gt_inds) + + @property + def info(self): + """ + Returns a dictionary of info about the object + """ + return { + 'num_gts': self.num_gts, + 'num_preds': self.num_preds, + 'gt_inds': self.gt_inds, + 'max_overlaps': self.max_overlaps, + 'labels': self.labels, + } + + def __nice__(self): + """ + Create a "nice" summary string describing this assign result + """ + parts = [] + parts.append('num_gts={!r}'.format(self.num_gts)) + if self.gt_inds is None: + parts.append('gt_inds={!r}'.format(self.gt_inds)) + else: + parts.append('gt_inds.shape={!r}'.format( + tuple(self.gt_inds.shape))) + if self.max_overlaps is None: + parts.append('max_overlaps={!r}'.format(self.max_overlaps)) + else: + parts.append('max_overlaps.shape={!r}'.format( + tuple(self.max_overlaps.shape))) + if self.labels is None: + parts.append('labels={!r}'.format(self.labels)) + else: + parts.append('labels.shape={!r}'.format(tuple(self.labels.shape))) + return ', '.join(parts) + + @classmethod + def random(cls, **kwargs): + """ + Create random AssignResult for tests or debugging. + + Kwargs: + num_preds: number of predicted boxes + num_gts: number of true boxes + p_ignore (float): probability of a predicted box assinged to an + ignored truth + p_assigned (float): probability of a predicted box not being + assigned + p_use_label (float | bool): with labels or not + rng (None | int | numpy.random.RandomState): seed or state + + Returns: + AssignResult : + + Example: + >>> from mmdet.core.bbox.assigners.assign_result import * # NOQA + >>> self = AssignResult.random() + >>> print(self.info) + """ + from mmdet.core.bbox import demodata + rng = demodata.ensure_rng(kwargs.get('rng', None)) + + num_gts = kwargs.get('num_gts', None) + num_preds = kwargs.get('num_preds', None) + p_ignore = kwargs.get('p_ignore', 0.3) + p_assigned = kwargs.get('p_assigned', 0.7) + p_use_label = kwargs.get('p_use_label', 0.5) + num_classes = kwargs.get('p_use_label', 3) + + if num_gts is None: + num_gts = rng.randint(0, 8) + if num_preds is None: + num_preds = rng.randint(0, 16) + + if num_gts == 0: + max_overlaps = torch.zeros(num_preds, dtype=torch.float32) + gt_inds = torch.zeros(num_preds, dtype=torch.int64) + if p_use_label is True or p_use_label < rng.rand(): + labels = torch.zeros(num_preds, dtype=torch.int64) + else: + labels = None + else: + import numpy as np + # Create an overlap for each predicted box + max_overlaps = torch.from_numpy(rng.rand(num_preds)) + + # Construct gt_inds for each predicted box + is_assigned = torch.from_numpy(rng.rand(num_preds) < p_assigned) + # maximum number of assignments constraints + n_assigned = min(num_preds, min(num_gts, is_assigned.sum())) + + assigned_idxs = np.where(is_assigned)[0] + rng.shuffle(assigned_idxs) + assigned_idxs = assigned_idxs[0:n_assigned] + assigned_idxs.sort() + + is_assigned[:] = 0 + is_assigned[assigned_idxs] = True + + is_ignore = torch.from_numpy( + rng.rand(num_preds) < p_ignore) & is_assigned + + gt_inds = torch.zeros(num_preds, dtype=torch.int64) + + true_idxs = np.arange(num_gts) + rng.shuffle(true_idxs) + true_idxs = torch.from_numpy(true_idxs) + gt_inds[is_assigned] = true_idxs[:n_assigned] + + gt_inds = torch.from_numpy( + rng.randint(1, num_gts + 1, size=num_preds)) + gt_inds[is_ignore] = -1 + gt_inds[~is_assigned] = 0 + max_overlaps[~is_assigned] = 0 + + if p_use_label is True or p_use_label < rng.rand(): + if num_classes == 0: + labels = torch.zeros(num_preds, dtype=torch.int64) + else: + labels = torch.from_numpy( + rng.randint(1, num_classes + 1, size=num_preds)) + labels[~is_assigned] = 0 + else: + labels = None + + self = cls(num_gts, gt_inds, max_overlaps, labels) + return self + + def add_gt_(self, gt_labels): + self_inds = torch.arange( + 1, len(gt_labels) + 1, dtype=torch.long, device=gt_labels.device) + self.gt_inds = torch.cat([self_inds, self.gt_inds]) + + self.max_overlaps = torch.cat( + [self.max_overlaps.new_ones(len(gt_labels)), self.max_overlaps]) + + if self.labels is not None: + self.labels = torch.cat([gt_labels, self.labels]) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/atss_assigner.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/atss_assigner.py new file mode 100644 index 000000000..e442ac709 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/atss_assigner.py @@ -0,0 +1,159 @@ +import torch + +from ..geometry import bbox_overlaps +from .assign_result import AssignResult +from .base_assigner import BaseAssigner + + +class ATSSAssigner(BaseAssigner): + """Assign a corresponding gt bbox or background to each bbox. + + Each proposals will be assigned with `0` or a positive integer + indicating the ground truth index. + + - 0: negative sample, no assigned gt + - positive integer: positive sample, index (1-based) of assigned gt + + Args: + topk (float): number of bbox selected in each level + """ + + def __init__(self, topk): + self.topk = topk + + # https://github.com/sfzhang15/ATSS/blob/master/atss_core/modeling/rpn/atss/loss.py + + def assign(self, + bboxes, + num_level_bboxes, + gt_bboxes, + gt_bboxes_ignore=None, + gt_labels=None): + """Assign gt to bboxes. + + The assignment is done in following steps + + 1. compute iou between all bbox (bbox of all pyramid levels) and gt + 2. compute center distance between all bbox and gt + 3. on each pyramid level, for each gt, select k bbox whose center + are closest to the gt center, so we total select k*l bbox as + candidates for each gt + 4. get corresponding iou for the these candidates, and compute the + mean and std, set mean + std as the iou threshold + 5. select these candidates whose iou are greater than or equal to + the threshold as postive + 6. limit the positive sample's center in gt + + + Args: + bboxes (Tensor): Bounding boxes to be assigned, shape(n, 4). + num_level_bboxes (List): num of bboxes in each level + gt_bboxes (Tensor): Groundtruth boxes, shape (k, 4). + gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are + labelled as `ignored`, e.g., crowd boxes in COCO. + gt_labels (Tensor, optional): Label of gt_bboxes, shape (k, ). + + Returns: + :obj:`AssignResult`: The assign result. + """ + INF = 100000000 + bboxes = bboxes[:, :4] + num_gt, num_bboxes = gt_bboxes.size(0), bboxes.size(0) + + # compute iou between all bbox and gt + overlaps = bbox_overlaps(bboxes, gt_bboxes) + + # assign 0 by default + assigned_gt_inds = overlaps.new_full((num_bboxes, ), + 0, + dtype=torch.long) + + if num_gt == 0 or num_bboxes == 0: + # No ground truth or boxes, return empty assignment + max_overlaps = overlaps.new_zeros((num_bboxes, )) + if num_gt == 0: + # No truth, assign everything to background + assigned_gt_inds[:] = 0 + if gt_labels is None: + assigned_labels = None + else: + assigned_labels = overlaps.new_zeros((num_bboxes, ), + dtype=torch.long) + return AssignResult( + num_gt, assigned_gt_inds, max_overlaps, labels=assigned_labels) + + # compute center distance between all bbox and gt + gt_cx = (gt_bboxes[:, 0] + gt_bboxes[:, 2]) / 2.0 + gt_cy = (gt_bboxes[:, 1] + gt_bboxes[:, 3]) / 2.0 + gt_points = torch.stack((gt_cx, gt_cy), dim=1) + + bboxes_cx = (bboxes[:, 0] + bboxes[:, 2]) / 2.0 + bboxes_cy = (bboxes[:, 1] + bboxes[:, 3]) / 2.0 + bboxes_points = torch.stack((bboxes_cx, bboxes_cy), dim=1) + + distances = (bboxes_points[:, None, :] - + gt_points[None, :, :]).pow(2).sum(-1).sqrt() + + # Selecting candidates based on the center distance + candidate_idxs = [] + start_idx = 0 + for level, bboxes_per_level in enumerate(num_level_bboxes): + # on each pyramid level, for each gt, + # select k bbox whose center are closest to the gt center + end_idx = start_idx + bboxes_per_level + distances_per_level = distances[start_idx:end_idx, :] + _, topk_idxs_per_level = distances_per_level.topk( + self.topk, dim=0, largest=False) + candidate_idxs.append(topk_idxs_per_level + start_idx) + start_idx = end_idx + candidate_idxs = torch.cat(candidate_idxs, dim=0) + + # get corresponding iou for the these candidates, and compute the + # mean and std, set mean + std as the iou threshold + candidate_overlaps = overlaps[candidate_idxs, torch.arange(num_gt)] + overlaps_mean_per_gt = candidate_overlaps.mean(0) + overlaps_std_per_gt = candidate_overlaps.std(0) + overlaps_thr_per_gt = overlaps_mean_per_gt + overlaps_std_per_gt + + is_pos = candidate_overlaps >= overlaps_thr_per_gt[None, :] + + # limit the positive sample's center in gt + for gt_idx in range(num_gt): + candidate_idxs[:, gt_idx] += gt_idx * num_bboxes + ep_bboxes_cx = bboxes_cx.view(1, -1).expand( + num_gt, num_bboxes).contiguous().view(-1) + ep_bboxes_cy = bboxes_cy.view(1, -1).expand( + num_gt, num_bboxes).contiguous().view(-1) + candidate_idxs = candidate_idxs.view(-1) + + # calculate the left, top, right, bottom distance between positive + # bbox center and gt side + l_ = ep_bboxes_cx[candidate_idxs].view(-1, num_gt) - gt_bboxes[:, 0] + t_ = ep_bboxes_cy[candidate_idxs].view(-1, num_gt) - gt_bboxes[:, 1] + r_ = gt_bboxes[:, 2] - ep_bboxes_cx[candidate_idxs].view(-1, num_gt) + b_ = gt_bboxes[:, 3] - ep_bboxes_cy[candidate_idxs].view(-1, num_gt) + is_in_gts = torch.stack([l_, t_, r_, b_], dim=1).min(dim=1)[0] > 0.01 + is_pos = is_pos & is_in_gts + + # if an anchor box is assigned to multiple gts, + # the one with the highest IoU will be selected. + overlaps_inf = torch.full_like(overlaps, + -INF).t().contiguous().view(-1) + index = candidate_idxs.view(-1)[is_pos.view(-1)] + overlaps_inf[index] = overlaps.t().contiguous().view(-1)[index] + overlaps_inf = overlaps_inf.view(num_gt, -1).t() + + max_overlaps, argmax_overlaps = overlaps_inf.max(dim=1) + assigned_gt_inds[ + max_overlaps != -INF] = argmax_overlaps[max_overlaps != -INF] + 1 + + if gt_labels is not None: + assigned_labels = assigned_gt_inds.new_zeros((num_bboxes, )) + pos_inds = torch.nonzero(assigned_gt_inds > 0).squeeze() + if pos_inds.numel() > 0: + assigned_labels[pos_inds] = gt_labels[ + assigned_gt_inds[pos_inds] - 1] + else: + assigned_labels = None + return AssignResult( + num_gt, assigned_gt_inds, max_overlaps, labels=assigned_labels) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/base_assigner.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/base_assigner.py new file mode 100644 index 000000000..7bd02dce1 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/base_assigner.py @@ -0,0 +1,8 @@ +from abc import ABCMeta, abstractmethod + + +class BaseAssigner(metaclass=ABCMeta): + + @abstractmethod + def assign(self, bboxes, gt_bboxes, gt_bboxes_ignore=None, gt_labels=None): + pass diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/max_iou_assigner.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/max_iou_assigner.py new file mode 100644 index 000000000..93ffc42ca --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/max_iou_assigner.py @@ -0,0 +1,195 @@ +import torch + +from ..geometry import bbox_overlaps +from .assign_result import AssignResult +from .base_assigner import BaseAssigner + + +class MaxIoUAssigner(BaseAssigner): + """Assign a corresponding gt bbox or background to each bbox. + + Each proposals will be assigned with `-1`, `0`, or a positive integer + indicating the ground truth index. + + - -1: don't care + - 0: negative sample, no assigned gt + - positive integer: positive sample, index (1-based) of assigned gt + + Args: + pos_iou_thr (float): IoU threshold for positive bboxes. + neg_iou_thr (float or tuple): IoU threshold for negative bboxes. + min_pos_iou (float): Minimum iou for a bbox to be considered as a + positive bbox. Positive samples can have smaller IoU than + pos_iou_thr due to the 4th step (assign max IoU sample to each gt). + gt_max_assign_all (bool): Whether to assign all bboxes with the same + highest overlap with some gt to that gt. + ignore_iof_thr (float): IoF threshold for ignoring bboxes (if + `gt_bboxes_ignore` is specified). Negative values mean not + ignoring any bboxes. + ignore_wrt_candidates (bool): Whether to compute the iof between + `bboxes` and `gt_bboxes_ignore`, or the contrary. + gpu_assign_thr (int): The upper bound of the number of GT for GPU + assign. When the number of gt is above this threshold, will assign + on CPU device. Negative values mean not assign on CPU. + """ + + def __init__(self, + pos_iou_thr, + neg_iou_thr, + min_pos_iou=.0, + gt_max_assign_all=True, + ignore_iof_thr=-1, + ignore_wrt_candidates=True, + gpu_assign_thr=-1): + self.pos_iou_thr = pos_iou_thr + self.neg_iou_thr = neg_iou_thr + self.min_pos_iou = min_pos_iou + self.gt_max_assign_all = gt_max_assign_all + self.ignore_iof_thr = ignore_iof_thr + self.ignore_wrt_candidates = ignore_wrt_candidates + self.gpu_assign_thr = gpu_assign_thr + + def assign(self, bboxes, gt_bboxes, gt_bboxes_ignore=None, gt_labels=None): + """Assign gt to bboxes. + + This method assign a gt bbox to every bbox (proposal/anchor), each bbox + will be assigned with -1, 0, or a positive number. -1 means don't care, + 0 means negative sample, positive number is the index (1-based) of + assigned gt. + The assignment is done in following steps, the order matters. + + 1. assign every bbox to -1 + 2. assign proposals whose iou with all gts < neg_iou_thr to 0 + 3. for each bbox, if the iou with its nearest gt >= pos_iou_thr, + assign it to that bbox + 4. for each gt bbox, assign its nearest proposals (may be more than + one) to itself + + Args: + bboxes (Tensor): Bounding boxes to be assigned, shape(n, 4). + gt_bboxes (Tensor): Groundtruth boxes, shape (k, 4). + gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are + labelled as `ignored`, e.g., crowd boxes in COCO. + gt_labels (Tensor, optional): Label of gt_bboxes, shape (k, ). + + Returns: + :obj:`AssignResult`: The assign result. + + Example: + >>> self = MaxIoUAssigner(0.5, 0.5) + >>> bboxes = torch.Tensor([[0, 0, 10, 10], [10, 10, 20, 20]]) + >>> gt_bboxes = torch.Tensor([[0, 0, 10, 9]]) + >>> assign_result = self.assign(bboxes, gt_bboxes) + >>> expected_gt_inds = torch.LongTensor([1, 0]) + >>> assert torch.all(assign_result.gt_inds == expected_gt_inds) + """ + assign_on_cpu = True if (self.gpu_assign_thr > 0) and ( + gt_bboxes.shape[0] > self.gpu_assign_thr) else False + # compute overlap and assign gt on CPU when number of GT is large + if assign_on_cpu: + device = bboxes.device + bboxes = bboxes.cpu() + gt_bboxes = gt_bboxes.cpu() + if gt_bboxes_ignore is not None: + gt_bboxes_ignore = gt_bboxes_ignore.cpu() + if gt_labels is not None: + gt_labels = gt_labels.cpu() + + bboxes = bboxes[:, :4] + overlaps = bbox_overlaps(gt_bboxes, bboxes) + + if (self.ignore_iof_thr > 0) and (gt_bboxes_ignore is not None) and ( + gt_bboxes_ignore.numel() > 0): + if self.ignore_wrt_candidates: + ignore_overlaps = bbox_overlaps( + bboxes, gt_bboxes_ignore, mode='iof') + ignore_max_overlaps, _ = ignore_overlaps.max(dim=1) + else: + ignore_overlaps = bbox_overlaps( + gt_bboxes_ignore, bboxes, mode='iof') + ignore_max_overlaps, _ = ignore_overlaps.max(dim=0) + overlaps[:, ignore_max_overlaps > self.ignore_iof_thr] = -1 + + assign_result = self.assign_wrt_overlaps(overlaps, gt_labels) + if assign_on_cpu: + assign_result.gt_inds = assign_result.gt_inds.to(device) + assign_result.max_overlaps = assign_result.max_overlaps.to(device) + if assign_result.labels is not None: + assign_result.labels = assign_result.labels.to(device) + return assign_result + + def assign_wrt_overlaps(self, overlaps, gt_labels=None): + """Assign w.r.t. the overlaps of bboxes with gts. + + Args: + overlaps (Tensor): Overlaps between k gt_bboxes and n bboxes, + shape(k, n). + gt_labels (Tensor, optional): Labels of k gt_bboxes, shape (k, ). + + Returns: + :obj:`AssignResult`: The assign result. + """ + num_gts, num_bboxes = overlaps.size(0), overlaps.size(1) + + # 1. assign -1 by default + assigned_gt_inds = overlaps.new_full((num_bboxes, ), + -1, + dtype=torch.long) + + if num_gts == 0 or num_bboxes == 0: + # No ground truth or boxes, return empty assignment + max_overlaps = overlaps.new_zeros((num_bboxes, )) + if num_gts == 0: + # No truth, assign everything to background + assigned_gt_inds[:] = 0 + if gt_labels is None: + assigned_labels = None + else: + assigned_labels = overlaps.new_zeros((num_bboxes, ), + dtype=torch.long) + return AssignResult( + num_gts, + assigned_gt_inds, + max_overlaps, + labels=assigned_labels) + + # for each anchor, which gt best overlaps with it + # for each anchor, the max iou of all gts + max_overlaps, argmax_overlaps = overlaps.max(dim=0) + # for each gt, which anchor best overlaps with it + # for each gt, the max iou of all proposals + gt_max_overlaps, gt_argmax_overlaps = overlaps.max(dim=1) + + # 2. assign negative: below + if isinstance(self.neg_iou_thr, float): + assigned_gt_inds[(max_overlaps >= 0) + & (max_overlaps < self.neg_iou_thr)] = 0 + elif isinstance(self.neg_iou_thr, tuple): + assert len(self.neg_iou_thr) == 2 + assigned_gt_inds[(max_overlaps >= self.neg_iou_thr[0]) + & (max_overlaps < self.neg_iou_thr[1])] = 0 + + # 3. assign positive: above positive IoU threshold + pos_inds = max_overlaps >= self.pos_iou_thr + assigned_gt_inds[pos_inds] = argmax_overlaps[pos_inds] + 1 + + # 4. assign fg: for each gt, proposals with highest IoU + for i in range(num_gts): + if gt_max_overlaps[i] >= self.min_pos_iou: + if self.gt_max_assign_all: + max_iou_inds = overlaps[i, :] == gt_max_overlaps[i] + assigned_gt_inds[max_iou_inds] = i + 1 + else: + assigned_gt_inds[gt_argmax_overlaps[i]] = i + 1 + + if gt_labels is not None: + assigned_labels = assigned_gt_inds.new_zeros((num_bboxes, )) + pos_inds = torch.nonzero(assigned_gt_inds > 0).squeeze() + if pos_inds.numel() > 0: + assigned_labels[pos_inds] = gt_labels[ + assigned_gt_inds[pos_inds] - 1] + else: + assigned_labels = None + + return AssignResult( + num_gts, assigned_gt_inds, max_overlaps, labels=assigned_labels) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/point_assigner.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/point_assigner.py new file mode 100644 index 000000000..263b3096c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/point_assigner.py @@ -0,0 +1,130 @@ +import torch + +from .assign_result import AssignResult +from .base_assigner import BaseAssigner + + +class PointAssigner(BaseAssigner): + """Assign a corresponding gt bbox or background to each point. + + Each proposals will be assigned with `0`, or a positive integer + indicating the ground truth index. + + - 0: negative sample, no assigned gt + - positive integer: positive sample, index (1-based) of assigned gt + + """ + + def __init__(self, scale=4, pos_num=3): + self.scale = scale + self.pos_num = pos_num + + def assign(self, points, gt_bboxes, gt_bboxes_ignore=None, gt_labels=None): + """Assign gt to points. + + This method assign a gt bbox to every points set, each points set + will be assigned with 0, or a positive number. + 0 means negative sample, positive number is the index (1-based) of + assigned gt. + The assignment is done in following steps, the order matters. + + 1. assign every points to 0 + 2. A point is assigned to some gt bbox if + (i) the point is within the k closest points to the gt bbox + (ii) the distance between this point and the gt is smaller than + other gt bboxes + + Args: + points (Tensor): points to be assigned, shape(n, 3) while last + dimension stands for (x, y, stride). + gt_bboxes (Tensor): Groundtruth boxes, shape (k, 4). + gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are + labelled as `ignored`, e.g., crowd boxes in COCO. + NOTE: currently unused. + gt_labels (Tensor, optional): Label of gt_bboxes, shape (k, ). + + Returns: + :obj:`AssignResult`: The assign result. + """ + num_points = points.shape[0] + num_gts = gt_bboxes.shape[0] + + if num_gts == 0 or num_points == 0: + # If no truth assign everything to the background + assigned_gt_inds = points.new_full((num_points, ), + 0, + dtype=torch.long) + if gt_labels is None: + assigned_labels = None + else: + assigned_labels = points.new_zeros((num_points, ), + dtype=torch.long) + return AssignResult( + num_gts, assigned_gt_inds, None, labels=assigned_labels) + + points_xy = points[:, :2] + points_stride = points[:, 2] + points_lvl = torch.log2( + points_stride).int() # [3...,4...,5...,6...,7...] + lvl_min, lvl_max = points_lvl.min(), points_lvl.max() + + # assign gt box + gt_bboxes_xy = (gt_bboxes[:, :2] + gt_bboxes[:, 2:]) / 2 + gt_bboxes_wh = (gt_bboxes[:, 2:] - gt_bboxes[:, :2]).clamp(min=1e-6) + scale = self.scale + gt_bboxes_lvl = ((torch.log2(gt_bboxes_wh[:, 0] / scale) + + torch.log2(gt_bboxes_wh[:, 1] / scale)) / 2).int() + gt_bboxes_lvl = torch.clamp(gt_bboxes_lvl, min=lvl_min, max=lvl_max) + + # stores the assigned gt index of each point + assigned_gt_inds = points.new_zeros((num_points, ), dtype=torch.long) + # stores the assigned gt dist (to this point) of each point + assigned_gt_dist = points.new_full((num_points, ), float('inf')) + points_range = torch.arange(points.shape[0]) + + for idx in range(num_gts): + gt_lvl = gt_bboxes_lvl[idx] + # get the index of points in this level + lvl_idx = gt_lvl == points_lvl + points_index = points_range[lvl_idx] + # get the points in this level + lvl_points = points_xy[lvl_idx, :] + # get the center point of gt + gt_point = gt_bboxes_xy[[idx], :] + # get width and height of gt + gt_wh = gt_bboxes_wh[[idx], :] + # compute the distance between gt center and + # all points in this level + points_gt_dist = ((lvl_points - gt_point) / gt_wh).norm(dim=1) + # find the nearest k points to gt center in this level + min_dist, min_dist_index = torch.topk( + points_gt_dist, self.pos_num, largest=False) + # the index of nearest k points to gt center in this level + min_dist_points_index = points_index[min_dist_index] + # The less_than_recorded_index stores the index + # of min_dist that is less then the assigned_gt_dist. Where + # assigned_gt_dist stores the dist from previous assigned gt + # (if exist) to each point. + less_than_recorded_index = min_dist < assigned_gt_dist[ + min_dist_points_index] + # The min_dist_points_index stores the index of points satisfy: + # (1) it is k nearest to current gt center in this level. + # (2) it is closer to current gt center than other gt center. + min_dist_points_index = min_dist_points_index[ + less_than_recorded_index] + # assign the result + assigned_gt_inds[min_dist_points_index] = idx + 1 + assigned_gt_dist[min_dist_points_index] = min_dist[ + less_than_recorded_index] + + if gt_labels is not None: + assigned_labels = assigned_gt_inds.new_zeros((num_points, )) + pos_inds = torch.nonzero(assigned_gt_inds > 0).squeeze() + if pos_inds.numel() > 0: + assigned_labels[pos_inds] = gt_labels[ + assigned_gt_inds[pos_inds] - 1] + else: + assigned_labels = None + + return AssignResult( + num_gts, assigned_gt_inds, None, labels=assigned_labels) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/bbox_target.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/bbox_target.py new file mode 100644 index 000000000..2a918bf87 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/bbox_target.py @@ -0,0 +1,73 @@ +import torch + +from ..utils import multi_apply +from .transforms import bbox2delta + + +def bbox_target(pos_bboxes_list, + neg_bboxes_list, + pos_gt_bboxes_list, + pos_gt_labels_list, + cfg, + reg_classes=1, + target_means=[.0, .0, .0, .0], + target_stds=[1.0, 1.0, 1.0, 1.0], + concat=True): + labels, label_weights, bbox_targets, bbox_weights = multi_apply( + bbox_target_single, + pos_bboxes_list, + neg_bboxes_list, + pos_gt_bboxes_list, + pos_gt_labels_list, + cfg=cfg, + reg_classes=reg_classes, + target_means=target_means, + target_stds=target_stds) + + if concat: + labels = torch.cat(labels, 0) + label_weights = torch.cat(label_weights, 0) + bbox_targets = torch.cat(bbox_targets, 0) + bbox_weights = torch.cat(bbox_weights, 0) + return labels, label_weights, bbox_targets, bbox_weights + + +def bbox_target_single(pos_bboxes, + neg_bboxes, + pos_gt_bboxes, + pos_gt_labels, + cfg, + reg_classes=1, + target_means=[.0, .0, .0, .0], + target_stds=[1.0, 1.0, 1.0, 1.0]): + num_pos = pos_bboxes.size(0) + num_neg = neg_bboxes.size(0) + num_samples = num_pos + num_neg + labels = pos_bboxes.new_zeros(num_samples, dtype=torch.long) + label_weights = pos_bboxes.new_zeros(num_samples) + bbox_targets = pos_bboxes.new_zeros(num_samples, 4) + bbox_weights = pos_bboxes.new_zeros(num_samples, 4) + if num_pos > 0: + labels[:num_pos] = pos_gt_labels + pos_weight = 1.0 if cfg.pos_weight <= 0 else cfg.pos_weight + label_weights[:num_pos] = pos_weight + pos_bbox_targets = bbox2delta(pos_bboxes, pos_gt_bboxes, target_means, + target_stds) + bbox_targets[:num_pos, :] = pos_bbox_targets + bbox_weights[:num_pos, :] = 1 + if num_neg > 0: + label_weights[-num_neg:] = 1.0 + + return labels, label_weights, bbox_targets, bbox_weights + + +def expand_target(bbox_targets, bbox_weights, labels, num_classes): + bbox_targets_expand = bbox_targets.new_zeros( + (bbox_targets.size(0), 4 * num_classes)) + bbox_weights_expand = bbox_weights.new_zeros( + (bbox_weights.size(0), 4 * num_classes)) + for i in torch.nonzero(labels > 0).squeeze(-1): + start, end = labels[i] * 4, (labels[i] + 1) * 4 + bbox_targets_expand[i, start:end] = bbox_targets[i, :] + bbox_weights_expand[i, start:end] = bbox_weights[i, :] + return bbox_targets_expand, bbox_weights_expand diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/demodata.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/demodata.py new file mode 100644 index 000000000..d59d65427 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/demodata.py @@ -0,0 +1,65 @@ +import numpy as np +import torch + + +def ensure_rng(rng=None): + """ + Simple version of the ``kwarray.ensure_rng`` + + Args: + rng (int | numpy.random.RandomState | None): + if None, then defaults to the global rng. Otherwise this can be an + integer or a RandomState class + Returns: + (numpy.random.RandomState) : rng - + a numpy random number generator + + References: + https://gitlab.kitware.com/computer-vision/kwarray/blob/master/kwarray/util_random.py#L270 + """ + + if rng is None: + rng = np.random.mtrand._rand + elif isinstance(rng, int): + rng = np.random.RandomState(rng) + else: + rng = rng + return rng + + +def random_boxes(num=1, scale=1, rng=None): + """ + Simple version of ``kwimage.Boxes.random`` + + Returns: + Tensor: shape (n, 4) in x1, y1, x2, y2 format. + + References: + https://gitlab.kitware.com/computer-vision/kwimage/blob/master/kwimage/structs/boxes.py#L1390 + + Example: + >>> num = 3 + >>> scale = 512 + >>> rng = 0 + >>> boxes = random_boxes(num, scale, rng) + >>> print(boxes) + tensor([[280.9925, 278.9802, 308.6148, 366.1769], + [216.9113, 330.6978, 224.0446, 456.5878], + [405.3632, 196.3221, 493.3953, 270.7942]]) + """ + rng = ensure_rng(rng) + + tlbr = rng.rand(num, 4).astype(np.float32) + + tl_x = np.minimum(tlbr[:, 0], tlbr[:, 2]) + tl_y = np.minimum(tlbr[:, 1], tlbr[:, 3]) + br_x = np.maximum(tlbr[:, 0], tlbr[:, 2]) + br_y = np.maximum(tlbr[:, 1], tlbr[:, 3]) + + tlbr[:, 0] = tl_x * scale + tlbr[:, 1] = tl_y * scale + tlbr[:, 2] = br_x * scale + tlbr[:, 3] = br_y * scale + + boxes = torch.from_numpy(tlbr) + return boxes diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/geometry.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/geometry.py new file mode 100644 index 000000000..ff7c5d4fa --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/geometry.py @@ -0,0 +1,88 @@ +import torch + + +def bbox_overlaps(bboxes1, bboxes2, mode='iou', is_aligned=False): + """Calculate overlap between two set of bboxes. + + If ``is_aligned`` is ``False``, then calculate the ious between each bbox + of bboxes1 and bboxes2, otherwise the ious between each aligned pair of + bboxes1 and bboxes2. + + Args: + bboxes1 (Tensor): shape (m, 4) in format. + bboxes2 (Tensor): shape (n, 4) in format. + If is_aligned is ``True``, then m and n must be equal. + mode (str): "iou" (intersection over union) or iof (intersection over + foreground). + + Returns: + ious(Tensor): shape (m, n) if is_aligned == False else shape (m, 1) + + Example: + >>> bboxes1 = torch.FloatTensor([ + >>> [0, 0, 10, 10], + >>> [10, 10, 20, 20], + >>> [32, 32, 38, 42], + >>> ]) + >>> bboxes2 = torch.FloatTensor([ + >>> [0, 0, 10, 20], + >>> [0, 10, 10, 19], + >>> [10, 10, 20, 20], + >>> ]) + >>> bbox_overlaps(bboxes1, bboxes2) + tensor([[0.5238, 0.0500, 0.0041], + [0.0323, 0.0452, 1.0000], + [0.0000, 0.0000, 0.0000]]) + + Example: + >>> empty = torch.FloatTensor([]) + >>> nonempty = torch.FloatTensor([ + >>> [0, 0, 10, 9], + >>> ]) + >>> assert tuple(bbox_overlaps(empty, nonempty).shape) == (0, 1) + >>> assert tuple(bbox_overlaps(nonempty, empty).shape) == (1, 0) + >>> assert tuple(bbox_overlaps(empty, empty).shape) == (0, 0) + """ + + assert mode in ['iou', 'iof'] + + rows = bboxes1.size(0) + cols = bboxes2.size(0) + if is_aligned: + assert rows == cols + + if rows * cols == 0: + return bboxes1.new(rows, 1) if is_aligned else bboxes1.new(rows, cols) + + if is_aligned: + lt = torch.max(bboxes1[:, :2], bboxes2[:, :2]) # [rows, 2] + rb = torch.min(bboxes1[:, 2:], bboxes2[:, 2:]) # [rows, 2] + + wh = (rb - lt + 1).clamp(min=0) # [rows, 2] + overlap = wh[:, 0] * wh[:, 1] + area1 = (bboxes1[:, 2] - bboxes1[:, 0] + 1) * ( + bboxes1[:, 3] - bboxes1[:, 1] + 1) + + if mode == 'iou': + area2 = (bboxes2[:, 2] - bboxes2[:, 0] + 1) * ( + bboxes2[:, 3] - bboxes2[:, 1] + 1) + ious = overlap / (area1 + area2 - overlap) + else: + ious = overlap / area1 + else: + lt = torch.max(bboxes1[:, None, :2], bboxes2[:, :2]) # [rows, cols, 2] + rb = torch.min(bboxes1[:, None, 2:], bboxes2[:, 2:]) # [rows, cols, 2] + + wh = (rb - lt + 1).clamp(min=0) # [rows, cols, 2] + overlap = wh[:, :, 0] * wh[:, :, 1] + area1 = (bboxes1[:, 2] - bboxes1[:, 0] + 1) * ( + bboxes1[:, 3] - bboxes1[:, 1] + 1) + + if mode == 'iou': + area2 = (bboxes2[:, 2] - bboxes2[:, 0] + 1) * ( + bboxes2[:, 3] - bboxes2[:, 1] + 1) + ious = overlap / (area1[:, None] + area2 - overlap) + else: + ious = overlap / (area1[:, None]) + + return ious diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/__init__.py new file mode 100644 index 000000000..d709d8ecb --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/__init__.py @@ -0,0 +1,14 @@ +from .base_sampler import BaseSampler +from .combined_sampler import CombinedSampler +from .instance_balanced_pos_sampler import InstanceBalancedPosSampler +from .iou_balanced_neg_sampler import IoUBalancedNegSampler +from .ohem_sampler import OHEMSampler +from .pseudo_sampler import PseudoSampler +from .random_sampler import RandomSampler +from .sampling_result import SamplingResult + +__all__ = [ + 'BaseSampler', 'PseudoSampler', 'RandomSampler', + 'InstanceBalancedPosSampler', 'IoUBalancedNegSampler', 'CombinedSampler', + 'OHEMSampler', 'SamplingResult' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/base_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/base_sampler.py new file mode 100644 index 000000000..f437195f6 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/base_sampler.py @@ -0,0 +1,98 @@ +from abc import ABCMeta, abstractmethod + +import torch + +from .sampling_result import SamplingResult + + +class BaseSampler(metaclass=ABCMeta): + + def __init__(self, + num, + pos_fraction, + neg_pos_ub=-1, + add_gt_as_proposals=True, + **kwargs): + self.num = num + self.pos_fraction = pos_fraction + self.neg_pos_ub = neg_pos_ub + self.add_gt_as_proposals = add_gt_as_proposals + self.pos_sampler = self + self.neg_sampler = self + + @abstractmethod + def _sample_pos(self, assign_result, num_expected, **kwargs): + pass + + @abstractmethod + def _sample_neg(self, assign_result, num_expected, **kwargs): + pass + + def sample(self, + assign_result, + bboxes, + gt_bboxes, + gt_labels=None, + **kwargs): + """Sample positive and negative bboxes. + + This is a simple implementation of bbox sampling given candidates, + assigning results and ground truth bboxes. + + Args: + assign_result (:obj:`AssignResult`): Bbox assigning results. + bboxes (Tensor): Boxes to be sampled from. + gt_bboxes (Tensor): Ground truth bboxes. + gt_labels (Tensor, optional): Class labels of ground truth bboxes. + + Returns: + :obj:`SamplingResult`: Sampling result. + + Example: + >>> from mmdet.core.bbox import RandomSampler + >>> from mmdet.core.bbox import AssignResult + >>> from mmdet.core.bbox.demodata import ensure_rng, random_boxes + >>> rng = ensure_rng(None) + >>> assign_result = AssignResult.random(rng=rng) + >>> bboxes = random_boxes(assign_result.num_preds, rng=rng) + >>> gt_bboxes = random_boxes(assign_result.num_gts, rng=rng) + >>> gt_labels = None + >>> self = RandomSampler(num=32, pos_fraction=0.5, neg_pos_ub=-1, + >>> add_gt_as_proposals=False) + >>> self = self.sample(assign_result, bboxes, gt_bboxes, gt_labels) + """ + if len(bboxes.shape) < 2: + bboxes = bboxes[None, :] + + bboxes = bboxes[:, :4] + + gt_flags = bboxes.new_zeros((bboxes.shape[0], ), dtype=torch.uint8) + if self.add_gt_as_proposals and len(gt_bboxes) > 0: + if gt_labels is None: + raise ValueError( + 'gt_labels must be given when add_gt_as_proposals is True') + bboxes = torch.cat([gt_bboxes, bboxes], dim=0) + assign_result.add_gt_(gt_labels) + gt_ones = bboxes.new_ones(gt_bboxes.shape[0], dtype=torch.uint8) + gt_flags = torch.cat([gt_ones, gt_flags]) + + num_expected_pos = int(self.num * self.pos_fraction) + pos_inds = self.pos_sampler._sample_pos( + assign_result, num_expected_pos, bboxes=bboxes, **kwargs) + # We found that sampled indices have duplicated items occasionally. + # (may be a bug of PyTorch) + pos_inds = pos_inds.unique() + num_sampled_pos = pos_inds.numel() + num_expected_neg = self.num - num_sampled_pos + if self.neg_pos_ub >= 0: + _pos = max(1, num_sampled_pos) + neg_upper_bound = int(self.neg_pos_ub * _pos) + if num_expected_neg > neg_upper_bound: + num_expected_neg = neg_upper_bound + neg_inds = self.neg_sampler._sample_neg( + assign_result, num_expected_neg, bboxes=bboxes, **kwargs) + neg_inds = neg_inds.unique() + + sampling_result = SamplingResult(pos_inds, neg_inds, bboxes, gt_bboxes, + assign_result, gt_flags) + return sampling_result diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/combined_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/combined_sampler.py new file mode 100644 index 000000000..351a097f6 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/combined_sampler.py @@ -0,0 +1,16 @@ +from ..assign_sampling import build_sampler +from .base_sampler import BaseSampler + + +class CombinedSampler(BaseSampler): + + def __init__(self, pos_sampler, neg_sampler, **kwargs): + super(CombinedSampler, self).__init__(**kwargs) + self.pos_sampler = build_sampler(pos_sampler, **kwargs) + self.neg_sampler = build_sampler(neg_sampler, **kwargs) + + def _sample_pos(self, **kwargs): + raise NotImplementedError + + def _sample_neg(self, **kwargs): + raise NotImplementedError diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/instance_balanced_pos_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/instance_balanced_pos_sampler.py new file mode 100644 index 000000000..bc829a236 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/instance_balanced_pos_sampler.py @@ -0,0 +1,41 @@ +import numpy as np +import torch + +from .random_sampler import RandomSampler + + +class InstanceBalancedPosSampler(RandomSampler): + + def _sample_pos(self, assign_result, num_expected, **kwargs): + pos_inds = torch.nonzero(assign_result.gt_inds > 0) + if pos_inds.numel() != 0: + pos_inds = pos_inds.squeeze(1) + if pos_inds.numel() <= num_expected: + return pos_inds + else: + unique_gt_inds = assign_result.gt_inds[pos_inds].unique() + num_gts = len(unique_gt_inds) + num_per_gt = int(round(num_expected / float(num_gts)) + 1) + sampled_inds = [] + for i in unique_gt_inds: + inds = torch.nonzero(assign_result.gt_inds == i.item()) + if inds.numel() != 0: + inds = inds.squeeze(1) + else: + continue + if len(inds) > num_per_gt: + inds = self.random_choice(inds, num_per_gt) + sampled_inds.append(inds) + sampled_inds = torch.cat(sampled_inds) + if len(sampled_inds) < num_expected: + num_extra = num_expected - len(sampled_inds) + extra_inds = np.array( + list(set(pos_inds.cpu()) - set(sampled_inds.cpu()))) + if len(extra_inds) > num_extra: + extra_inds = self.random_choice(extra_inds, num_extra) + extra_inds = torch.from_numpy(extra_inds).to( + assign_result.gt_inds.device).long() + sampled_inds = torch.cat([sampled_inds, extra_inds]) + elif len(sampled_inds) > num_expected: + sampled_inds = self.random_choice(sampled_inds, num_expected) + return sampled_inds diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/iou_balanced_neg_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/iou_balanced_neg_sampler.py new file mode 100644 index 000000000..d9239e070 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/iou_balanced_neg_sampler.py @@ -0,0 +1,135 @@ +import numpy as np +import torch + +from .random_sampler import RandomSampler + + +class IoUBalancedNegSampler(RandomSampler): + """IoU Balanced Sampling + + arXiv: https://arxiv.org/pdf/1904.02701.pdf (CVPR 2019) + + Sampling proposals according to their IoU. `floor_fraction` of needed RoIs + are sampled from proposals whose IoU are lower than `floor_thr` randomly. + The others are sampled from proposals whose IoU are higher than + `floor_thr`. These proposals are sampled from some bins evenly, which are + split by `num_bins` via IoU evenly. + + Args: + num (int): number of proposals. + pos_fraction (float): fraction of positive proposals. + floor_thr (float): threshold (minimum) IoU for IoU balanced sampling, + set to -1 if all using IoU balanced sampling. + floor_fraction (float): sampling fraction of proposals under floor_thr. + num_bins (int): number of bins in IoU balanced sampling. + """ + + def __init__(self, + num, + pos_fraction, + floor_thr=-1, + floor_fraction=0, + num_bins=3, + **kwargs): + super(IoUBalancedNegSampler, self).__init__(num, pos_fraction, + **kwargs) + assert floor_thr >= 0 or floor_thr == -1 + assert 0 <= floor_fraction <= 1 + assert num_bins >= 1 + + self.floor_thr = floor_thr + self.floor_fraction = floor_fraction + self.num_bins = num_bins + + def sample_via_interval(self, max_overlaps, full_set, num_expected): + max_iou = max_overlaps.max() + iou_interval = (max_iou - self.floor_thr) / self.num_bins + per_num_expected = int(num_expected / self.num_bins) + + sampled_inds = [] + for i in range(self.num_bins): + start_iou = self.floor_thr + i * iou_interval + end_iou = self.floor_thr + (i + 1) * iou_interval + tmp_set = set( + np.where( + np.logical_and(max_overlaps >= start_iou, + max_overlaps < end_iou))[0]) + tmp_inds = list(tmp_set & full_set) + if len(tmp_inds) > per_num_expected: + tmp_sampled_set = self.random_choice(tmp_inds, + per_num_expected) + else: + tmp_sampled_set = np.array(tmp_inds, dtype=np.int) + sampled_inds.append(tmp_sampled_set) + + sampled_inds = np.concatenate(sampled_inds) + if len(sampled_inds) < num_expected: + num_extra = num_expected - len(sampled_inds) + extra_inds = np.array(list(full_set - set(sampled_inds))) + if len(extra_inds) > num_extra: + extra_inds = self.random_choice(extra_inds, num_extra) + sampled_inds = np.concatenate([sampled_inds, extra_inds]) + + return sampled_inds + + def _sample_neg(self, assign_result, num_expected, **kwargs): + neg_inds = torch.nonzero(assign_result.gt_inds == 0) + if neg_inds.numel() != 0: + neg_inds = neg_inds.squeeze(1) + if len(neg_inds) <= num_expected: + return neg_inds + else: + max_overlaps = assign_result.max_overlaps.cpu().numpy() + # balance sampling for negative samples + neg_set = set(neg_inds.cpu().numpy()) + + if self.floor_thr > 0: + floor_set = set( + np.where( + np.logical_and(max_overlaps >= 0, + max_overlaps < self.floor_thr))[0]) + iou_sampling_set = set( + np.where(max_overlaps >= self.floor_thr)[0]) + elif self.floor_thr == 0: + floor_set = set(np.where(max_overlaps == 0)[0]) + iou_sampling_set = set( + np.where(max_overlaps > self.floor_thr)[0]) + else: + floor_set = set() + iou_sampling_set = set( + np.where(max_overlaps > self.floor_thr)[0]) + # for sampling interval calculation + self.floor_thr = 0 + + floor_neg_inds = list(floor_set & neg_set) + iou_sampling_neg_inds = list(iou_sampling_set & neg_set) + num_expected_iou_sampling = int(num_expected * + (1 - self.floor_fraction)) + if len(iou_sampling_neg_inds) > num_expected_iou_sampling: + if self.num_bins >= 2: + iou_sampled_inds = self.sample_via_interval( + max_overlaps, set(iou_sampling_neg_inds), + num_expected_iou_sampling) + else: + iou_sampled_inds = self.random_choice( + iou_sampling_neg_inds, num_expected_iou_sampling) + else: + iou_sampled_inds = np.array( + iou_sampling_neg_inds, dtype=np.int) + num_expected_floor = num_expected - len(iou_sampled_inds) + if len(floor_neg_inds) > num_expected_floor: + sampled_floor_inds = self.random_choice( + floor_neg_inds, num_expected_floor) + else: + sampled_floor_inds = np.array(floor_neg_inds, dtype=np.int) + sampled_inds = np.concatenate( + (sampled_floor_inds, iou_sampled_inds)) + if len(sampled_inds) < num_expected: + num_extra = num_expected - len(sampled_inds) + extra_inds = np.array(list(neg_set - set(sampled_inds))) + if len(extra_inds) > num_extra: + extra_inds = self.random_choice(extra_inds, num_extra) + sampled_inds = np.concatenate((sampled_inds, extra_inds)) + sampled_inds = torch.from_numpy(sampled_inds).long().to( + assign_result.gt_inds.device) + return sampled_inds diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/ohem_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/ohem_sampler.py new file mode 100644 index 000000000..3701d83ac --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/ohem_sampler.py @@ -0,0 +1,79 @@ +import torch + +from ..transforms import bbox2roi +from .base_sampler import BaseSampler + + +class OHEMSampler(BaseSampler): + """ + Online Hard Example Mining Sampler described in [1]_. + + References: + .. [1] https://arxiv.org/pdf/1604.03540.pdf + """ + + def __init__(self, + num, + pos_fraction, + context, + neg_pos_ub=-1, + add_gt_as_proposals=True, + **kwargs): + super(OHEMSampler, self).__init__(num, pos_fraction, neg_pos_ub, + add_gt_as_proposals) + if not hasattr(context, 'num_stages'): + self.bbox_roi_extractor = context.bbox_roi_extractor + self.bbox_head = context.bbox_head + else: + self.bbox_roi_extractor = context.bbox_roi_extractor[ + context.current_stage] + self.bbox_head = context.bbox_head[context.current_stage] + + def hard_mining(self, inds, num_expected, bboxes, labels, feats): + with torch.no_grad(): + rois = bbox2roi([bboxes]) + bbox_feats = self.bbox_roi_extractor( + feats[:self.bbox_roi_extractor.num_inputs], rois) + cls_score, _ = self.bbox_head(bbox_feats) + loss = self.bbox_head.loss( + cls_score=cls_score, + bbox_pred=None, + labels=labels, + label_weights=cls_score.new_ones(cls_score.size(0)), + bbox_targets=None, + bbox_weights=None, + reduction_override='none')['loss_cls'] + _, topk_loss_inds = loss.topk(num_expected) + return inds[topk_loss_inds] + + def _sample_pos(self, + assign_result, + num_expected, + bboxes=None, + feats=None, + **kwargs): + # Sample some hard positive samples + pos_inds = torch.nonzero(assign_result.gt_inds > 0) + if pos_inds.numel() != 0: + pos_inds = pos_inds.squeeze(1) + if pos_inds.numel() <= num_expected: + return pos_inds + else: + return self.hard_mining(pos_inds, num_expected, bboxes[pos_inds], + assign_result.labels[pos_inds], feats) + + def _sample_neg(self, + assign_result, + num_expected, + bboxes=None, + feats=None, + **kwargs): + # Sample some hard negative samples + neg_inds = torch.nonzero(assign_result.gt_inds == 0) + if neg_inds.numel() != 0: + neg_inds = neg_inds.squeeze(1) + if len(neg_inds) <= num_expected: + return neg_inds + else: + return self.hard_mining(neg_inds, num_expected, bboxes[neg_inds], + assign_result.labels[neg_inds], feats) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/pseudo_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/pseudo_sampler.py new file mode 100644 index 000000000..b4c2ea09b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/pseudo_sampler.py @@ -0,0 +1,26 @@ +import torch + +from .base_sampler import BaseSampler +from .sampling_result import SamplingResult + + +class PseudoSampler(BaseSampler): + + def __init__(self, **kwargs): + pass + + def _sample_pos(self, **kwargs): + raise NotImplementedError + + def _sample_neg(self, **kwargs): + raise NotImplementedError + + def sample(self, assign_result, bboxes, gt_bboxes, **kwargs): + pos_inds = torch.nonzero( + assign_result.gt_inds > 0).squeeze(-1).unique() + neg_inds = torch.nonzero( + assign_result.gt_inds == 0).squeeze(-1).unique() + gt_flags = bboxes.new_zeros(bboxes.shape[0], dtype=torch.uint8) + sampling_result = SamplingResult(pos_inds, neg_inds, bboxes, gt_bboxes, + assign_result, gt_flags) + return sampling_result diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/random_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/random_sampler.py new file mode 100644 index 000000000..3db00bab0 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/random_sampler.py @@ -0,0 +1,54 @@ +import numpy as np +import torch + +from .base_sampler import BaseSampler + + +class RandomSampler(BaseSampler): + + def __init__(self, + num, + pos_fraction, + neg_pos_ub=-1, + add_gt_as_proposals=True, + **kwargs): + from mmdet.core.bbox import demodata + super(RandomSampler, self).__init__(num, pos_fraction, neg_pos_ub, + add_gt_as_proposals) + self.rng = demodata.ensure_rng(kwargs.get('rng', None)) + + def random_choice(self, gallery, num): + """Random select some elements from the gallery. + + It seems that Pytorch's implementation is slower than numpy so we use + numpy to randperm the indices. + """ + assert len(gallery) >= num + if isinstance(gallery, list): + gallery = np.array(gallery) + cands = np.arange(len(gallery)) + self.rng.shuffle(cands) + rand_inds = cands[:num] + if not isinstance(gallery, np.ndarray): + rand_inds = torch.from_numpy(rand_inds).long().to(gallery.device) + return gallery[rand_inds] + + def _sample_pos(self, assign_result, num_expected, **kwargs): + """Randomly sample some positive samples.""" + pos_inds = torch.nonzero(assign_result.gt_inds > 0) + if pos_inds.numel() != 0: + pos_inds = pos_inds.squeeze(1) + if pos_inds.numel() <= num_expected: + return pos_inds + else: + return self.random_choice(pos_inds, num_expected) + + def _sample_neg(self, assign_result, num_expected, **kwargs): + """Randomly sample some negative samples.""" + neg_inds = torch.nonzero(assign_result.gt_inds == 0) + if neg_inds.numel() != 0: + neg_inds = neg_inds.squeeze(1) + if len(neg_inds) <= num_expected: + return neg_inds + else: + return self.random_choice(neg_inds, num_expected) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/sampling_result.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/sampling_result.py new file mode 100644 index 000000000..dcf25eecd --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/sampling_result.py @@ -0,0 +1,154 @@ +import torch + +from mmdet.utils import util_mixins + + +class SamplingResult(util_mixins.NiceRepr): + """ + Example: + >>> # xdoctest: +IGNORE_WANT + >>> from mmdet.core.bbox.samplers.sampling_result import * # NOQA + >>> self = SamplingResult.random(rng=10) + >>> print('self = {}'.format(self)) + self = + """ + + def __init__(self, pos_inds, neg_inds, bboxes, gt_bboxes, assign_result, + gt_flags): + self.pos_inds = pos_inds + self.neg_inds = neg_inds + self.pos_bboxes = bboxes[pos_inds] + self.neg_bboxes = bboxes[neg_inds] + self.pos_is_gt = gt_flags[pos_inds] + + self.num_gts = gt_bboxes.shape[0] + self.pos_assigned_gt_inds = assign_result.gt_inds[pos_inds] - 1 + + if gt_bboxes.numel() == 0: + # hack for index error case + assert self.pos_assigned_gt_inds.numel() == 0 + self.pos_gt_bboxes = torch.empty_like(gt_bboxes).view(-1, 4) + else: + if len(gt_bboxes.shape) < 2: + gt_bboxes = gt_bboxes.view(-1, 4) + + self.pos_gt_bboxes = gt_bboxes[self.pos_assigned_gt_inds, :] + + if assign_result.labels is not None: + self.pos_gt_labels = assign_result.labels[pos_inds] + else: + self.pos_gt_labels = None + + @property + def bboxes(self): + return torch.cat([self.pos_bboxes, self.neg_bboxes]) + + def to(self, device): + """ + Change the device of the data inplace. + + Example: + >>> self = SamplingResult.random() + >>> print('self = {}'.format(self.to(None))) + >>> # xdoctest: +REQUIRES(--gpu) + >>> print('self = {}'.format(self.to(0))) + """ + _dict = self.__dict__ + for key, value in _dict.items(): + if isinstance(value, torch.Tensor): + _dict[key] = value.to(device) + return self + + def __nice__(self): + data = self.info.copy() + data['pos_bboxes'] = data.pop('pos_bboxes').shape + data['neg_bboxes'] = data.pop('neg_bboxes').shape + parts = ['\'{}\': {!r}'.format(k, v) for k, v in sorted(data.items())] + body = ' ' + ',\n '.join(parts) + return '{\n' + body + '\n}' + + @property + def info(self): + """ + Returns a dictionary of info about the object + """ + return { + 'pos_inds': self.pos_inds, + 'neg_inds': self.neg_inds, + 'pos_bboxes': self.pos_bboxes, + 'neg_bboxes': self.neg_bboxes, + 'pos_is_gt': self.pos_is_gt, + 'num_gts': self.num_gts, + 'pos_assigned_gt_inds': self.pos_assigned_gt_inds, + } + + @classmethod + def random(cls, rng=None, **kwargs): + """ + Args: + rng (None | int | numpy.random.RandomState): seed or state + + Kwargs: + num_preds: number of predicted boxes + num_gts: number of true boxes + p_ignore (float): probability of a predicted box assinged to an + ignored truth + p_assigned (float): probability of a predicted box not being + assigned + p_use_label (float | bool): with labels or not + + Returns: + AssignResult : + + Example: + >>> from mmdet.core.bbox.samplers.sampling_result import * # NOQA + >>> self = SamplingResult.random() + >>> print(self.__dict__) + """ + from mmdet.core.bbox.samplers.random_sampler import RandomSampler + from mmdet.core.bbox.assigners.assign_result import AssignResult + from mmdet.core.bbox import demodata + rng = demodata.ensure_rng(rng) + + # make probabalistic? + num = 32 + pos_fraction = 0.5 + neg_pos_ub = -1 + + assign_result = AssignResult.random(rng=rng, **kwargs) + + # Note we could just compute an assignment + bboxes = demodata.random_boxes(assign_result.num_preds, rng=rng) + gt_bboxes = demodata.random_boxes(assign_result.num_gts, rng=rng) + + if rng.rand() > 0.2: + # sometimes algorithms squeeze their data, be robust to that + gt_bboxes = gt_bboxes.squeeze() + bboxes = bboxes.squeeze() + + if assign_result.labels is None: + gt_labels = None + else: + gt_labels = None # todo + + if gt_labels is None: + add_gt_as_proposals = False + else: + add_gt_as_proposals = True # make probabalistic? + + sampler = RandomSampler( + num, + pos_fraction, + neg_pos_ubo=neg_pos_ub, + add_gt_as_proposals=add_gt_as_proposals, + rng=rng) + self = sampler.sample(assign_result, bboxes, gt_bboxes, gt_labels) + return self diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/transforms.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/transforms.py new file mode 100644 index 000000000..b9d1e6605 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/transforms.py @@ -0,0 +1,223 @@ +import mmcv +import numpy as np +import torch + + +def bbox2delta(proposals, gt, means=[0, 0, 0, 0], stds=[1, 1, 1, 1]): + assert proposals.size() == gt.size() + + proposals = proposals.float() + gt = gt.float() + px = (proposals[..., 0] + proposals[..., 2]) * 0.5 + py = (proposals[..., 1] + proposals[..., 3]) * 0.5 + pw = proposals[..., 2] - proposals[..., 0] + 1.0 + ph = proposals[..., 3] - proposals[..., 1] + 1.0 + + gx = (gt[..., 0] + gt[..., 2]) * 0.5 + gy = (gt[..., 1] + gt[..., 3]) * 0.5 + gw = gt[..., 2] - gt[..., 0] + 1.0 + gh = gt[..., 3] - gt[..., 1] + 1.0 + + dx = (gx - px) / pw + dy = (gy - py) / ph + dw = torch.log(gw / pw) + dh = torch.log(gh / ph) + deltas = torch.stack([dx, dy, dw, dh], dim=-1) + + means = deltas.new_tensor(means).unsqueeze(0) + stds = deltas.new_tensor(stds).unsqueeze(0) + deltas = deltas.sub_(means).div_(stds) + + return deltas + + +def delta2bbox(rois, + deltas, + means=[0, 0, 0, 0], + stds=[1, 1, 1, 1], + max_shape=None, + wh_ratio_clip=16 / 1000): + """ + Apply deltas to shift/scale base boxes. + + Typically the rois are anchor or proposed bounding boxes and the deltas are + network outputs used to shift/scale those boxes. + + Args: + rois (Tensor): boxes to be transformed. Has shape (N, 4) + deltas (Tensor): encoded offsets with respect to each roi. + Has shape (N, 4). Note N = num_anchors * W * H when rois is a grid + of anchors. Offset encoding follows [1]_. + means (list): denormalizing means for delta coordinates + stds (list): denormalizing standard deviation for delta coordinates + max_shape (tuple[int, int]): maximum bounds for boxes. specifies (H, W) + wh_ratio_clip (float): maximum aspect ratio for boxes. + + Returns: + Tensor: boxes with shape (N, 4), where columns represent + tl_x, tl_y, br_x, br_y. + + References: + .. [1] https://arxiv.org/abs/1311.2524 + + Example: + >>> rois = torch.Tensor([[ 0., 0., 1., 1.], + >>> [ 0., 0., 1., 1.], + >>> [ 0., 0., 1., 1.], + >>> [ 5., 5., 5., 5.]]) + >>> deltas = torch.Tensor([[ 0., 0., 0., 0.], + >>> [ 1., 1., 1., 1.], + >>> [ 0., 0., 2., -1.], + >>> [ 0.7, -1.9, -0.5, 0.3]]) + >>> delta2bbox(rois, deltas, max_shape=(32, 32)) + tensor([[0.0000, 0.0000, 1.0000, 1.0000], + [0.2817, 0.2817, 4.7183, 4.7183], + [0.0000, 0.6321, 7.3891, 0.3679], + [5.8967, 2.9251, 5.5033, 3.2749]]) + """ + means = deltas.new_tensor(means).repeat(1, deltas.size(1) // 4) + stds = deltas.new_tensor(stds).repeat(1, deltas.size(1) // 4) + denorm_deltas = deltas * stds + means + dx = denorm_deltas[:, 0::4] + dy = denorm_deltas[:, 1::4] + dw = denorm_deltas[:, 2::4] + dh = denorm_deltas[:, 3::4] + max_ratio = np.abs(np.log(wh_ratio_clip)) + dw = dw.clamp(min=-max_ratio, max=max_ratio) + dh = dh.clamp(min=-max_ratio, max=max_ratio) + # Compute center of each roi + px = ((rois[:, 0] + rois[:, 2]) * 0.5).unsqueeze(1).expand_as(dx) + py = ((rois[:, 1] + rois[:, 3]) * 0.5).unsqueeze(1).expand_as(dy) + # Compute width/height of each roi + pw = (rois[:, 2] - rois[:, 0] + 1.0).unsqueeze(1).expand_as(dw) + ph = (rois[:, 3] - rois[:, 1] + 1.0).unsqueeze(1).expand_as(dh) + # Use exp(network energy) to enlarge/shrink each roi + gw = pw * dw.exp() + gh = ph * dh.exp() + # Use network energy to shift the center of each roi + gx = torch.addcmul(px, 1, pw, dx) # gx = px + pw * dx + gy = torch.addcmul(py, 1, ph, dy) # gy = py + ph * dy + # Convert center-xy/width/height to top-left, bottom-right + x1 = gx - gw * 0.5 + 0.5 + y1 = gy - gh * 0.5 + 0.5 + x2 = gx + gw * 0.5 - 0.5 + y2 = gy + gh * 0.5 - 0.5 + if max_shape is not None: + x1 = x1.clamp(min=0, max=max_shape[1] - 1) + y1 = y1.clamp(min=0, max=max_shape[0] - 1) + x2 = x2.clamp(min=0, max=max_shape[1] - 1) + y2 = y2.clamp(min=0, max=max_shape[0] - 1) + bboxes = torch.stack([x1, y1, x2, y2], dim=-1).view_as(deltas) + return bboxes + + +def bbox_flip(bboxes, img_shape): + """Flip bboxes horizontally. + + Args: + bboxes(Tensor or ndarray): Shape (..., 4*k) + img_shape(tuple): Image shape. + + Returns: + Same type as `bboxes`: Flipped bboxes. + """ + if isinstance(bboxes, torch.Tensor): + assert bboxes.shape[-1] % 4 == 0 + flipped = bboxes.clone() + flipped[:, 0::4] = img_shape[1] - bboxes[:, 2::4] - 1 + flipped[:, 2::4] = img_shape[1] - bboxes[:, 0::4] - 1 + return flipped + elif isinstance(bboxes, np.ndarray): + return mmcv.bbox_flip(bboxes, img_shape) + + +def bbox_mapping(bboxes, img_shape, scale_factor, flip): + """Map bboxes from the original image scale to testing scale""" + new_bboxes = bboxes * scale_factor + if flip: + new_bboxes = bbox_flip(new_bboxes, img_shape) + return new_bboxes + + +def bbox_mapping_back(bboxes, img_shape, scale_factor, flip): + """Map bboxes from testing scale to original image scale""" + new_bboxes = bbox_flip(bboxes, img_shape) if flip else bboxes + new_bboxes = new_bboxes / scale_factor + return new_bboxes + + +def bbox2roi(bbox_list): + """Convert a list of bboxes to roi format. + + Args: + bbox_list (list[Tensor]): a list of bboxes corresponding to a batch + of images. + + Returns: + Tensor: shape (n, 5), [batch_ind, x1, y1, x2, y2] + """ + rois_list = [] + for img_id, bboxes in enumerate(bbox_list): + if bboxes.size(0) > 0: + img_inds = bboxes.new_full((bboxes.size(0), 1), img_id) + rois = torch.cat([img_inds, bboxes[:, :4]], dim=-1) + else: + rois = bboxes.new_zeros((0, 5)) + rois_list.append(rois) + rois = torch.cat(rois_list, 0) + return rois + + +def roi2bbox(rois): + bbox_list = [] + img_ids = torch.unique(rois[:, 0].cpu(), sorted=True) + for img_id in img_ids: + inds = (rois[:, 0] == img_id.item()) + bbox = rois[inds, 1:] + bbox_list.append(bbox) + return bbox_list + + +def bbox2result(bboxes, labels, num_classes): + """Convert detection results to a list of numpy arrays. + + Args: + bboxes (Tensor): shape (n, 5) + labels (Tensor): shape (n, ) + num_classes (int): class number, including background class + + Returns: + list(ndarray): bbox results of each class + """ + if bboxes.shape[0] == 0: + return [ + np.zeros((0, 5), dtype=np.float32) for i in range(num_classes - 1) + ] + else: + bboxes = bboxes.cpu().numpy() + labels = labels.cpu().numpy() + return [bboxes[labels == i, :] for i in range(num_classes - 1)] + + +def distance2bbox(points, distance, max_shape=None): + """Decode distance prediction to bounding box. + + Args: + points (Tensor): Shape (n, 2), [x, y]. + distance (Tensor): Distance from the given point to 4 + boundaries (left, top, right, bottom). + max_shape (tuple): Shape of the image. + + Returns: + Tensor: Decoded bboxes. + """ + x1 = points[:, 0] - distance[:, 0] + y1 = points[:, 1] - distance[:, 1] + x2 = points[:, 0] + distance[:, 2] + y2 = points[:, 1] + distance[:, 3] + if max_shape is not None: + x1 = x1.clamp(min=0, max=max_shape[1] - 1) + y1 = y1.clamp(min=0, max=max_shape[0] - 1) + x2 = x2.clamp(min=0, max=max_shape[1] - 1) + y2 = y2.clamp(min=0, max=max_shape[0] - 1) + return torch.stack([x1, y1, x2, y2], -1) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/__init__.py new file mode 100644 index 000000000..2e59f020c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/__init__.py @@ -0,0 +1,18 @@ +from .class_names import (coco_classes, dataset_aliases, get_classes, + imagenet_det_classes, imagenet_vid_classes, + voc_classes) +from .coco_utils import coco_eval, fast_eval_recall, results2json, results2json_segm +from .eval_hooks import (CocoDistEvalmAPHook, CocoDistEvalRecallHook, + DistEvalHook, DistEvalmAPHook) +from .mean_ap import average_precision, eval_map, print_map_summary +from .recall import (eval_recalls, plot_iou_recall, plot_num_recall, + print_recall_summary) + +__all__ = [ + 'voc_classes', 'imagenet_det_classes', 'imagenet_vid_classes', + 'coco_classes', 'dataset_aliases', 'get_classes', 'coco_eval', + 'fast_eval_recall', 'results2json', 'DistEvalHook', 'DistEvalmAPHook', + 'CocoDistEvalRecallHook', 'CocoDistEvalmAPHook', 'average_precision', + 'eval_map', 'print_map_summary', 'eval_recalls', 'print_recall_summary', + 'plot_num_recall', 'plot_iou_recall', 'results2json_segm' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/bbox_overlaps.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/bbox_overlaps.py new file mode 100644 index 000000000..ad4c70523 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/bbox_overlaps.py @@ -0,0 +1,49 @@ +import numpy as np + + +def bbox_overlaps(bboxes1, bboxes2, mode='iou'): + """Calculate the ious between each bbox of bboxes1 and bboxes2. + + Args: + bboxes1(ndarray): shape (n, 4) + bboxes2(ndarray): shape (k, 4) + mode(str): iou (intersection over union) or iof (intersection + over foreground) + + Returns: + ious(ndarray): shape (n, k) + """ + + assert mode in ['iou', 'iof'] + + bboxes1 = bboxes1.astype(np.float32) + bboxes2 = bboxes2.astype(np.float32) + rows = bboxes1.shape[0] + cols = bboxes2.shape[0] + ious = np.zeros((rows, cols), dtype=np.float32) + if rows * cols == 0: + return ious + exchange = False + if bboxes1.shape[0] > bboxes2.shape[0]: + bboxes1, bboxes2 = bboxes2, bboxes1 + ious = np.zeros((cols, rows), dtype=np.float32) + exchange = True + area1 = (bboxes1[:, 2] - bboxes1[:, 0] + 1) * ( + bboxes1[:, 3] - bboxes1[:, 1] + 1) + area2 = (bboxes2[:, 2] - bboxes2[:, 0] + 1) * ( + bboxes2[:, 3] - bboxes2[:, 1] + 1) + for i in range(bboxes1.shape[0]): + x_start = np.maximum(bboxes1[i, 0], bboxes2[:, 0]) + y_start = np.maximum(bboxes1[i, 1], bboxes2[:, 1]) + x_end = np.minimum(bboxes1[i, 2], bboxes2[:, 2]) + y_end = np.minimum(bboxes1[i, 3], bboxes2[:, 3]) + overlap = np.maximum(x_end - x_start + 1, 0) * np.maximum( + y_end - y_start + 1, 0) + if mode == 'iou': + union = area1[i] + area2 - overlap + else: + union = area1[i] if not exchange else area2 + ious[i, :] = overlap / union + if exchange: + ious = ious.T + return ious diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/class_names.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/class_names.py new file mode 100644 index 000000000..784277345 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/class_names.py @@ -0,0 +1,116 @@ +import mmcv + + +def wider_face_classes(): + return ['face'] + + +def voc_classes(): + return [ + 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', + 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', + 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor' + ] + + +def imagenet_det_classes(): + return [ + 'accordion', 'airplane', 'ant', 'antelope', 'apple', 'armadillo', + 'artichoke', 'axe', 'baby_bed', 'backpack', 'bagel', 'balance_beam', + 'banana', 'band_aid', 'banjo', 'baseball', 'basketball', 'bathing_cap', + 'beaker', 'bear', 'bee', 'bell_pepper', 'bench', 'bicycle', 'binder', + 'bird', 'bookshelf', 'bow_tie', 'bow', 'bowl', 'brassiere', 'burrito', + 'bus', 'butterfly', 'camel', 'can_opener', 'car', 'cart', 'cattle', + 'cello', 'centipede', 'chain_saw', 'chair', 'chime', 'cocktail_shaker', + 'coffee_maker', 'computer_keyboard', 'computer_mouse', 'corkscrew', + 'cream', 'croquet_ball', 'crutch', 'cucumber', 'cup_or_mug', 'diaper', + 'digital_clock', 'dishwasher', 'dog', 'domestic_cat', 'dragonfly', + 'drum', 'dumbbell', 'electric_fan', 'elephant', 'face_powder', 'fig', + 'filing_cabinet', 'flower_pot', 'flute', 'fox', 'french_horn', 'frog', + 'frying_pan', 'giant_panda', 'goldfish', 'golf_ball', 'golfcart', + 'guacamole', 'guitar', 'hair_dryer', 'hair_spray', 'hamburger', + 'hammer', 'hamster', 'harmonica', 'harp', 'hat_with_a_wide_brim', + 'head_cabbage', 'helmet', 'hippopotamus', 'horizontal_bar', 'horse', + 'hotdog', 'iPod', 'isopod', 'jellyfish', 'koala_bear', 'ladle', + 'ladybug', 'lamp', 'laptop', 'lemon', 'lion', 'lipstick', 'lizard', + 'lobster', 'maillot', 'maraca', 'microphone', 'microwave', 'milk_can', + 'miniskirt', 'monkey', 'motorcycle', 'mushroom', 'nail', 'neck_brace', + 'oboe', 'orange', 'otter', 'pencil_box', 'pencil_sharpener', 'perfume', + 'person', 'piano', 'pineapple', 'ping-pong_ball', 'pitcher', 'pizza', + 'plastic_bag', 'plate_rack', 'pomegranate', 'popsicle', 'porcupine', + 'power_drill', 'pretzel', 'printer', 'puck', 'punching_bag', 'purse', + 'rabbit', 'racket', 'ray', 'red_panda', 'refrigerator', + 'remote_control', 'rubber_eraser', 'rugby_ball', 'ruler', + 'salt_or_pepper_shaker', 'saxophone', 'scorpion', 'screwdriver', + 'seal', 'sheep', 'ski', 'skunk', 'snail', 'snake', 'snowmobile', + 'snowplow', 'soap_dispenser', 'soccer_ball', 'sofa', 'spatula', + 'squirrel', 'starfish', 'stethoscope', 'stove', 'strainer', + 'strawberry', 'stretcher', 'sunglasses', 'swimming_trunks', 'swine', + 'syringe', 'table', 'tape_player', 'tennis_ball', 'tick', 'tie', + 'tiger', 'toaster', 'traffic_light', 'train', 'trombone', 'trumpet', + 'turtle', 'tv_or_monitor', 'unicycle', 'vacuum', 'violin', + 'volleyball', 'waffle_iron', 'washer', 'water_bottle', 'watercraft', + 'whale', 'wine_bottle', 'zebra' + ] + + +def imagenet_vid_classes(): + return [ + 'airplane', 'antelope', 'bear', 'bicycle', 'bird', 'bus', 'car', + 'cattle', 'dog', 'domestic_cat', 'elephant', 'fox', 'giant_panda', + 'hamster', 'horse', 'lion', 'lizard', 'monkey', 'motorcycle', 'rabbit', + 'red_panda', 'sheep', 'snake', 'squirrel', 'tiger', 'train', 'turtle', + 'watercraft', 'whale', 'zebra' + ] + + +def coco_classes(): + return [ + 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', + 'truck', 'boat', 'traffic_light', 'fire_hydrant', 'stop_sign', + 'parking_meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', + 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', + 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', + 'sports_ball', 'kite', 'baseball_bat', 'baseball_glove', 'skateboard', + 'surfboard', 'tennis_racket', 'bottle', 'wine_glass', 'cup', 'fork', + 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', + 'broccoli', 'carrot', 'hot_dog', 'pizza', 'donut', 'cake', 'chair', + 'couch', 'potted_plant', 'bed', 'dining_table', 'toilet', 'tv', + 'laptop', 'mouse', 'remote', 'keyboard', 'cell_phone', 'microwave', + 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', + 'scissors', 'teddy_bear', 'hair_drier', 'toothbrush' + ] + + +def cityscapes_classes(): + return [ + 'person', 'rider', 'car', 'truck', 'bus', 'train', 'motorcycle', + 'bicycle' + ] + + +dataset_aliases = { + 'voc': ['voc', 'pascal_voc', 'voc07', 'voc12'], + 'imagenet_det': ['det', 'imagenet_det', 'ilsvrc_det'], + 'imagenet_vid': ['vid', 'imagenet_vid', 'ilsvrc_vid'], + 'coco': ['coco', 'mscoco', 'ms_coco'], + 'wider_face': ['WIDERFaceDataset', 'wider_face', 'WDIERFace'], + 'cityscapes': ['cityscapes'] +} + + +def get_classes(dataset): + """Get class names of a dataset.""" + alias2name = {} + for name, aliases in dataset_aliases.items(): + for alias in aliases: + alias2name[alias] = name + + if mmcv.is_str(dataset): + if dataset in alias2name: + labels = eval(alias2name[dataset] + '_classes()') + else: + raise ValueError('Unrecognized dataset: {}'.format(dataset)) + else: + raise TypeError('dataset must a str, but got {}'.format(type(dataset))) + return labels diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/coco_utils.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/coco_utils.py new file mode 100644 index 000000000..d57ca4d19 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/coco_utils.py @@ -0,0 +1,250 @@ +import itertools + +import mmcv +import numpy as np +from pycocotools.coco import COCO +from pycocotools.cocoeval import COCOeval +from terminaltables import AsciiTable + +from .recall import eval_recalls + + +def coco_eval(result_files, + result_types, + coco, + max_dets=(100, 300, 1000), + classwise=False): + for res_type in result_types: + assert res_type in [ + 'proposal', 'proposal_fast', 'bbox', 'segm', 'keypoints' + ] + + if mmcv.is_str(coco): + coco = COCO(coco) + assert isinstance(coco, COCO) + + if result_types == ['proposal_fast']: + ar = fast_eval_recall(result_files, coco, np.array(max_dets)) + for i, num in enumerate(max_dets): + print('AR@{}\t= {:.4f}'.format(num, ar[i])) + return + + for res_type in result_types: + if isinstance(result_files, str): + result_file = result_files + elif isinstance(result_files, dict): + result_file = result_files[res_type] + else: + assert TypeError('result_files must be a str or dict') + assert result_file.endswith('.json') + + coco_dets = coco.loadRes(result_file) + img_ids = coco.getImgIds() + iou_type = 'bbox' if res_type == 'proposal' else res_type + cocoEval = COCOeval(coco, coco_dets, iou_type) + cocoEval.params.imgIds = img_ids + if res_type == 'proposal': + cocoEval.params.useCats = 0 + cocoEval.params.maxDets = list(max_dets) + cocoEval.evaluate() + cocoEval.accumulate() + cocoEval.summarize() + + if classwise: + # Compute per-category AP + # from https://github.com/facebookresearch/detectron2/blob/03064eb5bafe4a3e5750cc7a16672daf5afe8435/detectron2/evaluation/coco_evaluation.py#L259-L283 # noqa + precisions = cocoEval.eval['precision'] + catIds = coco.getCatIds() + # precision has dims (iou, recall, cls, area range, max dets) + assert len(catIds) == precisions.shape[2] + + results_per_category = [] + for idx, catId in enumerate(catIds): + # area range index 0: all area ranges + # max dets index -1: typically 100 per image + nm = coco.loadCats(catId)[0] + precision = precisions[:, :, idx, 0, -1] + precision = precision[precision > -1] + ap = np.mean(precision) if precision.size else float('nan') + results_per_category.append( + ('{}'.format(nm['name']), + '{:0.3f}'.format(float(ap * 100)))) + + N_COLS = min(6, len(results_per_category) * 2) + results_flatten = list(itertools.chain(*results_per_category)) + headers = ['category', 'AP'] * (N_COLS // 2) + results_2d = itertools.zip_longest( + *[results_flatten[i::N_COLS] for i in range(N_COLS)]) + table_data = [headers] + table_data += [result for result in results_2d] + table = AsciiTable(table_data) + print(table.table) + + +def fast_eval_recall(results, + coco, + max_dets, + iou_thrs=np.arange(0.5, 0.96, 0.05)): + if mmcv.is_str(results): + assert results.endswith('.pkl') + results = mmcv.load(results) + elif not isinstance(results, list): + raise TypeError( + 'results must be a list of numpy arrays or a filename, not {}'. + format(type(results))) + + gt_bboxes = [] + img_ids = coco.getImgIds() + for i in range(len(img_ids)): + ann_ids = coco.getAnnIds(imgIds=img_ids[i]) + ann_info = coco.loadAnns(ann_ids) + if len(ann_info) == 0: + gt_bboxes.append(np.zeros((0, 4))) + continue + bboxes = [] + for ann in ann_info: + if ann.get('ignore', False) or ann['iscrowd']: + continue + x1, y1, w, h = ann['bbox'] + bboxes.append([x1, y1, x1 + w - 1, y1 + h - 1]) + bboxes = np.array(bboxes, dtype=np.float32) + if bboxes.shape[0] == 0: + bboxes = np.zeros((0, 4)) + gt_bboxes.append(bboxes) + + recalls = eval_recalls( + gt_bboxes, results, max_dets, iou_thrs, print_summary=False) + ar = recalls.mean(axis=1) + return ar + + +def xyxy2xywh(bbox): + _bbox = bbox.tolist() + return [ + _bbox[0], + _bbox[1], + _bbox[2] - _bbox[0] + 1, + _bbox[3] - _bbox[1] + 1, + ] + + +def proposal2json(dataset, results): + json_results = [] + for idx in range(len(dataset)): + img_id = dataset.img_ids[idx] + bboxes = results[idx] + for i in range(bboxes.shape[0]): + data = dict() + data['image_id'] = img_id + data['bbox'] = xyxy2xywh(bboxes[i]) + data['score'] = float(bboxes[i][4]) + data['category_id'] = 1 + json_results.append(data) + return json_results + + +def det2json(dataset, results): + json_results = [] + for idx in range(len(dataset)): + img_id = dataset.img_ids[idx] + result = results[idx] + for label in range(len(result)): + bboxes = result[label] + for i in range(bboxes.shape[0]): + data = dict() + data['image_id'] = img_id + data['bbox'] = xyxy2xywh(bboxes[i]) + data['score'] = float(bboxes[i][4]) + data['category_id'] = dataset.cat_ids[label] + json_results.append(data) + return json_results + + +def segm2json(dataset, results): + bbox_json_results = [] + segm_json_results = [] + for idx in range(len(dataset)): + img_id = dataset.img_ids[idx] + det, seg = results[idx] + for label in range(len(det)): + # bbox results + bboxes = det[label] + for i in range(bboxes.shape[0]): + data = dict() + data['image_id'] = img_id + data['bbox'] = xyxy2xywh(bboxes[i]) + data['score'] = float(bboxes[i][4]) + data['category_id'] = dataset.cat_ids[label] + bbox_json_results.append(data) + + # segm results + # some detectors use different score for det and segm + if isinstance(seg, tuple): + segms = seg[0][label] + mask_score = seg[1][label] + else: + segms = seg[label] + mask_score = [bbox[4] for bbox in bboxes] + for i in range(bboxes.shape[0]): + data = dict() + data['image_id'] = img_id + data['bbox'] = xyxy2xywh(bboxes[i]) + data['score'] = float(mask_score[i]) + data['category_id'] = dataset.cat_ids[label] + if isinstance(segms[i]['counts'], bytes): + segms[i]['counts'] = segms[i]['counts'].decode() + data['segmentation'] = segms[i] + segm_json_results.append(data) + return bbox_json_results, segm_json_results + + +def segm2json_segm(dataset, results): + segm_json_results = [] + for idx in range(len(dataset)): + img_id = dataset.img_ids[idx] + seg = results[idx] + for label in range(len(seg)): + masks = seg[label] + for i in range(len(masks)): + mask_score = masks[i][1] + segm = masks[i][0] + data = dict() + data['image_id'] = img_id + data['score'] = float(mask_score) + data['category_id'] = dataset.cat_ids[label] + segm['counts'] = segm['counts'].decode() + data['segmentation'] = segm + segm_json_results.append(data) + return segm_json_results + + +def results2json(dataset, results, out_file): + result_files = dict() + if isinstance(results[0], list): + json_results = det2json(dataset, results) + result_files['bbox'] = '{}.{}.json'.format(out_file, 'bbox') + result_files['proposal'] = '{}.{}.json'.format(out_file, 'bbox') + mmcv.dump(json_results, result_files['bbox']) + elif isinstance(results[0], tuple): + json_results = segm2json(dataset, results) + result_files['bbox'] = '{}.{}.json'.format(out_file, 'bbox') + result_files['proposal'] = '{}.{}.json'.format(out_file, 'bbox') + result_files['segm'] = '{}.{}.json'.format(out_file, 'segm') + mmcv.dump(json_results[0], result_files['bbox']) + mmcv.dump(json_results[1], result_files['segm']) + elif isinstance(results[0], np.ndarray): + json_results = proposal2json(dataset, results) + result_files['proposal'] = '{}.{}.json'.format(out_file, 'proposal') + mmcv.dump(json_results, result_files['proposal']) + else: + raise TypeError('invalid type of results') + return result_files + + +def results2json_segm(dataset, results, out_file): + result_files = dict() + json_results = segm2json_segm(dataset, results) + result_files['segm'] = '{}.{}.json'.format(out_file, 'segm') + mmcv.dump(json_results, result_files['segm']) + + return result_files diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/eval_hooks.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/eval_hooks.py new file mode 100644 index 000000000..1a074eec1 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/eval_hooks.py @@ -0,0 +1,152 @@ +import os +import os.path as osp + +import mmcv +import numpy as np +import torch +import torch.distributed as dist +from mmcv.parallel import collate, scatter +from mmcv.runner import Hook +from pycocotools.cocoeval import COCOeval +from torch.utils.data import Dataset + +from mmdet import datasets +from .coco_utils import fast_eval_recall, results2json +from .mean_ap import eval_map + + +class DistEvalHook(Hook): + + def __init__(self, dataset, interval=1): + if isinstance(dataset, Dataset): + self.dataset = dataset + elif isinstance(dataset, dict): + self.dataset = datasets.build_dataset(dataset, {'test_mode': True}) + else: + raise TypeError( + 'dataset must be a Dataset object or a dict, not {}'.format( + type(dataset))) + self.interval = interval + + def after_train_epoch(self, runner): + if not self.every_n_epochs(runner, self.interval): + return + runner.model.eval() + results = [None for _ in range(len(self.dataset))] + if runner.rank == 0: + prog_bar = mmcv.ProgressBar(len(self.dataset)) + for idx in range(runner.rank, len(self.dataset), runner.world_size): + data = self.dataset[idx] + data_gpu = scatter( + collate([data], samples_per_gpu=1), + [torch.cuda.current_device()])[0] + + # compute output + with torch.no_grad(): + result = runner.model( + return_loss=False, rescale=True, **data_gpu) + results[idx] = result + + batch_size = runner.world_size + if runner.rank == 0: + for _ in range(batch_size): + prog_bar.update() + + if runner.rank == 0: + print('\n') + dist.barrier() + for i in range(1, runner.world_size): + tmp_file = osp.join(runner.work_dir, 'temp_{}.pkl'.format(i)) + tmp_results = mmcv.load(tmp_file) + for idx in range(i, len(results), runner.world_size): + results[idx] = tmp_results[idx] + os.remove(tmp_file) + self.evaluate(runner, results) + else: + tmp_file = osp.join(runner.work_dir, + 'temp_{}.pkl'.format(runner.rank)) + mmcv.dump(results, tmp_file) + dist.barrier() + dist.barrier() + + def evaluate(self): + raise NotImplementedError + + +class DistEvalmAPHook(DistEvalHook): + + def evaluate(self, runner, results): + annotations = [ + self.dataset.get_ann_info(i) for i in range(len(self.dataset)) + ] + # If the dataset is VOC2007, then use 11 points mAP evaluation. + if hasattr(self.dataset, 'year') and self.dataset.year == 2007: + ds_name = 'voc07' + else: + ds_name = self.dataset.CLASSES + mean_ap, eval_results = eval_map( + results, + annotations, + scale_ranges=None, + iou_thr=0.5, + dataset=ds_name, + logger=runner.logger) + runner.log_buffer.output['mAP'] = mean_ap + runner.log_buffer.ready = True + + +class CocoDistEvalRecallHook(DistEvalHook): + + def __init__(self, + dataset, + interval=1, + proposal_nums=(100, 300, 1000), + iou_thrs=np.arange(0.5, 0.96, 0.05)): + super(CocoDistEvalRecallHook, self).__init__( + dataset, interval=interval) + self.proposal_nums = np.array(proposal_nums, dtype=np.int32) + self.iou_thrs = np.array(iou_thrs, dtype=np.float32) + + def evaluate(self, runner, results): + # the official coco evaluation is too slow, here we use our own + # implementation instead, which may get slightly different results + ar = fast_eval_recall(results, self.dataset.coco, self.proposal_nums, + self.iou_thrs) + for i, num in enumerate(self.proposal_nums): + runner.log_buffer.output['AR@{}'.format(num)] = ar[i] + runner.log_buffer.ready = True + + +class CocoDistEvalmAPHook(DistEvalHook): + + def evaluate(self, runner, results): + tmp_file = osp.join(runner.work_dir, 'temp_0') + result_files = results2json(self.dataset, results, tmp_file) + + res_types = ['bbox', 'segm' + ] if runner.model.module.with_mask else ['bbox'] + cocoGt = self.dataset.coco + imgIds = cocoGt.getImgIds() + for res_type in res_types: + try: + cocoDt = cocoGt.loadRes(result_files[res_type]) + except IndexError: + print('No prediction found.') + break + iou_type = res_type + cocoEval = COCOeval(cocoGt, cocoDt, iou_type) + cocoEval.params.imgIds = imgIds + cocoEval.evaluate() + cocoEval.accumulate() + cocoEval.summarize() + metrics = ['mAP', 'mAP_50', 'mAP_75', 'mAP_s', 'mAP_m', 'mAP_l'] + for i in range(len(metrics)): + key = '{}_{}'.format(res_type, metrics[i]) + val = float('{:.3f}'.format(cocoEval.stats[i])) + runner.log_buffer.output[key] = val + runner.log_buffer.output['{}_mAP_copypaste'.format(res_type)] = ( + '{ap[0]:.3f} {ap[1]:.3f} {ap[2]:.3f} {ap[3]:.3f} ' + '{ap[4]:.3f} {ap[5]:.3f}').format(ap=cocoEval.stats[:6]) + runner.log_buffer.ready = True + for res_type in res_types: + os.remove(result_files[res_type]) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/mean_ap.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/mean_ap.py new file mode 100644 index 000000000..4e3cd5d07 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/mean_ap.py @@ -0,0 +1,455 @@ +from multiprocessing import Pool + +import mmcv +import numpy as np +from terminaltables import AsciiTable + +from mmdet.utils import print_log +from .bbox_overlaps import bbox_overlaps +from .class_names import get_classes + + +def average_precision(recalls, precisions, mode='area'): + """Calculate average precision (for single or multiple scales). + + Args: + recalls (ndarray): shape (num_scales, num_dets) or (num_dets, ) + precisions (ndarray): shape (num_scales, num_dets) or (num_dets, ) + mode (str): 'area' or '11points', 'area' means calculating the area + under precision-recall curve, '11points' means calculating + the average precision of recalls at [0, 0.1, ..., 1] + + Returns: + float or ndarray: calculated average precision + """ + no_scale = False + if recalls.ndim == 1: + no_scale = True + recalls = recalls[np.newaxis, :] + precisions = precisions[np.newaxis, :] + assert recalls.shape == precisions.shape and recalls.ndim == 2 + num_scales = recalls.shape[0] + ap = np.zeros(num_scales, dtype=np.float32) + if mode == 'area': + zeros = np.zeros((num_scales, 1), dtype=recalls.dtype) + ones = np.ones((num_scales, 1), dtype=recalls.dtype) + mrec = np.hstack((zeros, recalls, ones)) + mpre = np.hstack((zeros, precisions, zeros)) + for i in range(mpre.shape[1] - 1, 0, -1): + mpre[:, i - 1] = np.maximum(mpre[:, i - 1], mpre[:, i]) + for i in range(num_scales): + ind = np.where(mrec[i, 1:] != mrec[i, :-1])[0] + ap[i] = np.sum( + (mrec[i, ind + 1] - mrec[i, ind]) * mpre[i, ind + 1]) + elif mode == '11points': + for i in range(num_scales): + for thr in np.arange(0, 1 + 1e-3, 0.1): + precs = precisions[i, recalls[i, :] >= thr] + prec = precs.max() if precs.size > 0 else 0 + ap[i] += prec + ap /= 11 + else: + raise ValueError( + 'Unrecognized mode, only "area" and "11points" are supported') + if no_scale: + ap = ap[0] + return ap + + +def tpfp_imagenet(det_bboxes, + gt_bboxes, + gt_bboxes_ignore=None, + default_iou_thr=0.5, + area_ranges=None): + """Check if detected bboxes are true positive or false positive. + + Args: + det_bbox (ndarray): Detected bboxes of this image, of shape (m, 5). + gt_bboxes (ndarray): GT bboxes of this image, of shape (n, 4). + gt_bboxes_ignore (ndarray): Ignored gt bboxes of this image, + of shape (k, 4). Default: None + default_iou_thr (float): IoU threshold to be considered as matched for + medium and large bboxes (small ones have special rules). + Default: 0.5. + area_ranges (list[tuple] | None): Range of bbox areas to be evaluated, + in the format [(min1, max1), (min2, max2), ...]. Default: None. + + Returns: + tuple[np.ndarray]: (tp, fp) whose elements are 0 and 1. The shape of + each array is (num_scales, m). + """ + # an indicator of ignored gts + gt_ignore_inds = np.concatenate( + (np.zeros(gt_bboxes.shape[0], dtype=np.bool), + np.ones(gt_bboxes_ignore.shape[0], dtype=np.bool))) + # stack gt_bboxes and gt_bboxes_ignore for convenience + gt_bboxes = np.vstack((gt_bboxes, gt_bboxes_ignore)) + + num_dets = det_bboxes.shape[0] + num_gts = gt_bboxes.shape[0] + if area_ranges is None: + area_ranges = [(None, None)] + num_scales = len(area_ranges) + # tp and fp are of shape (num_scales, num_gts), each row is tp or fp + # of a certain scale. + tp = np.zeros((num_scales, num_dets), dtype=np.float32) + fp = np.zeros((num_scales, num_dets), dtype=np.float32) + if gt_bboxes.shape[0] == 0: + if area_ranges == [(None, None)]: + fp[...] = 1 + else: + det_areas = (det_bboxes[:, 2] - det_bboxes[:, 0] + 1) * ( + det_bboxes[:, 3] - det_bboxes[:, 1] + 1) + for i, (min_area, max_area) in enumerate(area_ranges): + fp[i, (det_areas >= min_area) & (det_areas < max_area)] = 1 + return tp, fp + ious = bbox_overlaps(det_bboxes, gt_bboxes - 1) + gt_w = gt_bboxes[:, 2] - gt_bboxes[:, 0] + 1 + gt_h = gt_bboxes[:, 3] - gt_bboxes[:, 1] + 1 + iou_thrs = np.minimum((gt_w * gt_h) / ((gt_w + 10.0) * (gt_h + 10.0)), + default_iou_thr) + # sort all detections by scores in descending order + sort_inds = np.argsort(-det_bboxes[:, -1]) + for k, (min_area, max_area) in enumerate(area_ranges): + gt_covered = np.zeros(num_gts, dtype=bool) + # if no area range is specified, gt_area_ignore is all False + if min_area is None: + gt_area_ignore = np.zeros_like(gt_ignore_inds, dtype=bool) + else: + gt_areas = gt_w * gt_h + gt_area_ignore = (gt_areas < min_area) | (gt_areas >= max_area) + for i in sort_inds: + max_iou = -1 + matched_gt = -1 + # find best overlapped available gt + for j in range(num_gts): + # different from PASCAL VOC: allow finding other gts if the + # best overlaped ones are already matched by other det bboxes + if gt_covered[j]: + continue + elif ious[i, j] >= iou_thrs[j] and ious[i, j] > max_iou: + max_iou = ious[i, j] + matched_gt = j + # there are 4 cases for a det bbox: + # 1. it matches a gt, tp = 1, fp = 0 + # 2. it matches an ignored gt, tp = 0, fp = 0 + # 3. it matches no gt and within area range, tp = 0, fp = 1 + # 4. it matches no gt but is beyond area range, tp = 0, fp = 0 + if matched_gt >= 0: + gt_covered[matched_gt] = 1 + if not (gt_ignore_inds[matched_gt] + or gt_area_ignore[matched_gt]): + tp[k, i] = 1 + elif min_area is None: + fp[k, i] = 1 + else: + bbox = det_bboxes[i, :4] + area = (bbox[2] - bbox[0] + 1) * (bbox[3] - bbox[1] + 1) + if area >= min_area and area < max_area: + fp[k, i] = 1 + return tp, fp + + +def tpfp_default(det_bboxes, + gt_bboxes, + gt_bboxes_ignore=None, + iou_thr=0.5, + area_ranges=None): + """Check if detected bboxes are true positive or false positive. + + Args: + det_bbox (ndarray): Detected bboxes of this image, of shape (m, 5). + gt_bboxes (ndarray): GT bboxes of this image, of shape (n, 4). + gt_bboxes_ignore (ndarray): Ignored gt bboxes of this image, + of shape (k, 4). Default: None + iou_thr (float): IoU threshold to be considered as matched. + Default: 0.5. + area_ranges (list[tuple] | None): Range of bbox areas to be evaluated, + in the format [(min1, max1), (min2, max2), ...]. Default: None. + + Returns: + tuple[np.ndarray]: (tp, fp) whose elements are 0 and 1. The shape of + each array is (num_scales, m). + """ + # an indicator of ignored gts + gt_ignore_inds = np.concatenate( + (np.zeros(gt_bboxes.shape[0], dtype=np.bool), + np.ones(gt_bboxes_ignore.shape[0], dtype=np.bool))) + # stack gt_bboxes and gt_bboxes_ignore for convenience + gt_bboxes = np.vstack((gt_bboxes, gt_bboxes_ignore)) + + num_dets = det_bboxes.shape[0] + num_gts = gt_bboxes.shape[0] + if area_ranges is None: + area_ranges = [(None, None)] + num_scales = len(area_ranges) + # tp and fp are of shape (num_scales, num_gts), each row is tp or fp of + # a certain scale + tp = np.zeros((num_scales, num_dets), dtype=np.float32) + fp = np.zeros((num_scales, num_dets), dtype=np.float32) + + # if there is no gt bboxes in this image, then all det bboxes + # within area range are false positives + if gt_bboxes.shape[0] == 0: + if area_ranges == [(None, None)]: + fp[...] = 1 + else: + det_areas = (det_bboxes[:, 2] - det_bboxes[:, 0] + 1) * ( + det_bboxes[:, 3] - det_bboxes[:, 1] + 1) + for i, (min_area, max_area) in enumerate(area_ranges): + fp[i, (det_areas >= min_area) & (det_areas < max_area)] = 1 + return tp, fp + + ious = bbox_overlaps(det_bboxes, gt_bboxes) + # for each det, the max iou with all gts + ious_max = ious.max(axis=1) + # for each det, which gt overlaps most with it + ious_argmax = ious.argmax(axis=1) + # sort all dets in descending order by scores + sort_inds = np.argsort(-det_bboxes[:, -1]) + for k, (min_area, max_area) in enumerate(area_ranges): + gt_covered = np.zeros(num_gts, dtype=bool) + # if no area range is specified, gt_area_ignore is all False + if min_area is None: + gt_area_ignore = np.zeros_like(gt_ignore_inds, dtype=bool) + else: + gt_areas = (gt_bboxes[:, 2] - gt_bboxes[:, 0] + 1) * ( + gt_bboxes[:, 3] - gt_bboxes[:, 1] + 1) + gt_area_ignore = (gt_areas < min_area) | (gt_areas >= max_area) + for i in sort_inds: + if ious_max[i] >= iou_thr: + matched_gt = ious_argmax[i] + if not (gt_ignore_inds[matched_gt] + or gt_area_ignore[matched_gt]): + if not gt_covered[matched_gt]: + gt_covered[matched_gt] = True + tp[k, i] = 1 + else: + fp[k, i] = 1 + # otherwise ignore this detected bbox, tp = 0, fp = 0 + elif min_area is None: + fp[k, i] = 1 + else: + bbox = det_bboxes[i, :4] + area = (bbox[2] - bbox[0] + 1) * (bbox[3] - bbox[1] + 1) + if area >= min_area and area < max_area: + fp[k, i] = 1 + return tp, fp + + +def get_cls_results(det_results, annotations, class_id): + """Get det results and gt information of a certain class. + + Args: + det_results (list[list]): Same as `eval_map()`. + annotations (list[dict]): Same as `eval_map()`. + + Returns: + tuple[list[np.ndarray]]: detected bboxes, gt bboxes, ignored gt bboxes + """ + cls_dets = [img_res[class_id] for img_res in det_results] + cls_gts = [] + cls_gts_ignore = [] + for ann in annotations: + gt_inds = ann['labels'] == (class_id + 1) + cls_gts.append(ann['bboxes'][gt_inds, :]) + + if ann.get('labels_ignore', None) is not None: + ignore_inds = ann['labels_ignore'] == (class_id + 1) + cls_gts_ignore.append(ann['bboxes_ignore'][ignore_inds, :]) + else: + cls_gts_ignore.append(np.array((0, 4), dtype=np.float32)) + + return cls_dets, cls_gts, cls_gts_ignore + + +def eval_map(det_results, + annotations, + scale_ranges=None, + iou_thr=0.5, + dataset=None, + logger=None, + nproc=4): + """Evaluate mAP of a dataset. + + Args: + det_results (list[list]): [[cls1_det, cls2_det, ...], ...]. + The outer list indicates images, and the inner list indicates + per-class detected bboxes. + annotations (list[dict]): Ground truth annotations where each item of + the list indicates an image. Keys of annotations are: + - "bboxes": numpy array of shape (n, 4) + - "labels": numpy array of shape (n, ) + - "bboxes_ignore" (optional): numpy array of shape (k, 4) + - "labels_ignore" (optional): numpy array of shape (k, ) + scale_ranges (list[tuple] | None): Range of scales to be evaluated, + in the format [(min1, max1), (min2, max2), ...]. A range of + (32, 64) means the area range between (32**2, 64**2). + Default: None. + iou_thr (float): IoU threshold to be considered as matched. + Default: 0.5. + dataset (list[str] | str | None): Dataset name or dataset classes, + there are minor differences in metrics for different datsets, e.g. + "voc07", "imagenet_det", etc. Default: None. + logger (logging.Logger | str | None): The way to print the mAP + summary. See `mmdet.utils.print_log()` for details. Default: None. + nproc (int): Processes used for computing TP and FP. + Default: 4. + + Returns: + tuple: (mAP, [dict, dict, ...]) + """ + assert len(det_results) == len(annotations) + + num_imgs = len(det_results) + num_scales = len(scale_ranges) if scale_ranges is not None else 1 + num_classes = len(det_results[0]) # positive class num + area_ranges = ([(rg[0]**2, rg[1]**2) for rg in scale_ranges] + if scale_ranges is not None else None) + + pool = Pool(nproc) + eval_results = [] + for i in range(num_classes): + # get gt and det bboxes of this class + cls_dets, cls_gts, cls_gts_ignore = get_cls_results( + det_results, annotations, i) + # choose proper function according to datasets to compute tp and fp + if dataset in ['det', 'vid']: + tpfp_func = tpfp_imagenet + else: + tpfp_func = tpfp_default + # compute tp and fp for each image with multiple processes + tpfp = pool.starmap( + tpfp_func, + zip(cls_dets, cls_gts, cls_gts_ignore, + [iou_thr for _ in range(num_imgs)], + [area_ranges for _ in range(num_imgs)])) + tp, fp = tuple(zip(*tpfp)) + # calculate gt number of each scale + # ignored gts or gts beyond the specific scale are not counted + num_gts = np.zeros(num_scales, dtype=int) + for j, bbox in enumerate(cls_gts): + if area_ranges is None: + num_gts[0] += bbox.shape[0] + else: + gt_areas = (bbox[:, 2] - bbox[:, 0] + 1) * ( + bbox[:, 3] - bbox[:, 1] + 1) + for k, (min_area, max_area) in enumerate(area_ranges): + num_gts[k] += np.sum((gt_areas >= min_area) + & (gt_areas < max_area)) + # sort all det bboxes by score, also sort tp and fp + cls_dets = np.vstack(cls_dets) + num_dets = cls_dets.shape[0] + sort_inds = np.argsort(-cls_dets[:, -1]) + tp = np.hstack(tp)[:, sort_inds] + fp = np.hstack(fp)[:, sort_inds] + # calculate recall and precision with tp and fp + tp = np.cumsum(tp, axis=1) + fp = np.cumsum(fp, axis=1) + eps = np.finfo(np.float32).eps + recalls = tp / np.maximum(num_gts[:, np.newaxis], eps) + precisions = tp / np.maximum((tp + fp), eps) + # calculate AP + if scale_ranges is None: + recalls = recalls[0, :] + precisions = precisions[0, :] + num_gts = num_gts.item() + mode = 'area' if dataset != 'voc07' else '11points' + ap = average_precision(recalls, precisions, mode) + eval_results.append({ + 'num_gts': num_gts, + 'num_dets': num_dets, + 'recall': recalls, + 'precision': precisions, + 'ap': ap + }) + if scale_ranges is not None: + # shape (num_classes, num_scales) + all_ap = np.vstack([cls_result['ap'] for cls_result in eval_results]) + all_num_gts = np.vstack( + [cls_result['num_gts'] for cls_result in eval_results]) + mean_ap = [] + for i in range(num_scales): + if np.any(all_num_gts[:, i] > 0): + mean_ap.append(all_ap[all_num_gts[:, i] > 0, i].mean()) + else: + mean_ap.append(0.0) + else: + aps = [] + for cls_result in eval_results: + if cls_result['num_gts'] > 0: + aps.append(cls_result['ap']) + mean_ap = np.array(aps).mean().item() if aps else 0.0 + + print_map_summary( + mean_ap, eval_results, dataset, area_ranges, logger=logger) + + return mean_ap, eval_results + + +def print_map_summary(mean_ap, + results, + dataset=None, + scale_ranges=None, + logger=None): + """Print mAP and results of each class. + + A table will be printed to show the gts/dets/recall/AP of each class and + the mAP. + + Args: + mean_ap (float): Calculated from `eval_map()`. + results (list[dict]): Calculated from `eval_map()`. + dataset (list[str] | str | None): Dataset name or dataset classes. + scale_ranges (list[tuple] | None): Range of scales to be evaluated. + logger (logging.Logger | str | None): The way to print the mAP + summary. See `mmdet.utils.print_log()` for details. Default: None. + """ + + if logger == 'silent': + return + + if isinstance(results[0]['ap'], np.ndarray): + num_scales = len(results[0]['ap']) + else: + num_scales = 1 + + if scale_ranges is not None: + assert len(scale_ranges) == num_scales + + num_classes = len(results) + + recalls = np.zeros((num_scales, num_classes), dtype=np.float32) + aps = np.zeros((num_scales, num_classes), dtype=np.float32) + num_gts = np.zeros((num_scales, num_classes), dtype=int) + for i, cls_result in enumerate(results): + if cls_result['recall'].size > 0: + recalls[:, i] = np.array(cls_result['recall'], ndmin=2)[:, -1] + aps[:, i] = cls_result['ap'] + num_gts[:, i] = cls_result['num_gts'] + + if dataset is None: + label_names = [str(i) for i in range(1, num_classes + 1)] + elif mmcv.is_str(dataset): + label_names = get_classes(dataset) + else: + label_names = dataset + + if not isinstance(mean_ap, list): + mean_ap = [mean_ap] + + header = ['class', 'gts', 'dets', 'recall', 'ap'] + for i in range(num_scales): + if scale_ranges is not None: + print_log('Scale range {}'.format(scale_ranges[i]), logger=logger) + table_data = [header] + for j in range(num_classes): + row_data = [ + label_names[j], num_gts[i, j], results[j]['num_dets'], + '{:.3f}'.format(recalls[i, j]), '{:.3f}'.format(aps[i, j]) + ] + table_data.append(row_data) + table_data.append(['mAP', '', '', '', '{:.3f}'.format(mean_ap[i])]) + table = AsciiTable(table_data) + table.inner_footing_row_border = True + print_log('\n' + table.table, logger=logger) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/recall.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/recall.py new file mode 100644 index 000000000..2a56f42fd --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/recall.py @@ -0,0 +1,185 @@ +import numpy as np +from terminaltables import AsciiTable + +from .bbox_overlaps import bbox_overlaps + + +def _recalls(all_ious, proposal_nums, thrs): + + img_num = all_ious.shape[0] + total_gt_num = sum([ious.shape[0] for ious in all_ious]) + + _ious = np.zeros((proposal_nums.size, total_gt_num), dtype=np.float32) + for k, proposal_num in enumerate(proposal_nums): + tmp_ious = np.zeros(0) + for i in range(img_num): + ious = all_ious[i][:, :proposal_num].copy() + gt_ious = np.zeros((ious.shape[0])) + if ious.size == 0: + tmp_ious = np.hstack((tmp_ious, gt_ious)) + continue + for j in range(ious.shape[0]): + gt_max_overlaps = ious.argmax(axis=1) + max_ious = ious[np.arange(0, ious.shape[0]), gt_max_overlaps] + gt_idx = max_ious.argmax() + gt_ious[j] = max_ious[gt_idx] + box_idx = gt_max_overlaps[gt_idx] + ious[gt_idx, :] = -1 + ious[:, box_idx] = -1 + tmp_ious = np.hstack((tmp_ious, gt_ious)) + _ious[k, :] = tmp_ious + + _ious = np.fliplr(np.sort(_ious, axis=1)) + recalls = np.zeros((proposal_nums.size, thrs.size)) + for i, thr in enumerate(thrs): + recalls[:, i] = (_ious >= thr).sum(axis=1) / float(total_gt_num) + + return recalls + + +def set_recall_param(proposal_nums, iou_thrs): + """Check proposal_nums and iou_thrs and set correct format. + """ + if isinstance(proposal_nums, list): + _proposal_nums = np.array(proposal_nums) + elif isinstance(proposal_nums, int): + _proposal_nums = np.array([proposal_nums]) + else: + _proposal_nums = proposal_nums + + if iou_thrs is None: + _iou_thrs = np.array([0.5]) + elif isinstance(iou_thrs, list): + _iou_thrs = np.array(iou_thrs) + elif isinstance(iou_thrs, float): + _iou_thrs = np.array([iou_thrs]) + else: + _iou_thrs = iou_thrs + + return _proposal_nums, _iou_thrs + + +def eval_recalls(gts, + proposals, + proposal_nums=None, + iou_thrs=None, + print_summary=True): + """Calculate recalls. + + Args: + gts(list or ndarray): a list of arrays of shape (n, 4) + proposals(list or ndarray): a list of arrays of shape (k, 4) or (k, 5) + proposal_nums(int or list of int or ndarray): top N proposals + thrs(float or list or ndarray): iou thresholds + + Returns: + ndarray: recalls of different ious and proposal nums + """ + + img_num = len(gts) + assert img_num == len(proposals) + + proposal_nums, iou_thrs = set_recall_param(proposal_nums, iou_thrs) + + all_ious = [] + for i in range(img_num): + if proposals[i].ndim == 2 and proposals[i].shape[1] == 5: + scores = proposals[i][:, 4] + sort_idx = np.argsort(scores)[::-1] + img_proposal = proposals[i][sort_idx, :] + else: + img_proposal = proposals[i] + prop_num = min(img_proposal.shape[0], proposal_nums[-1]) + if gts[i] is None or gts[i].shape[0] == 0: + ious = np.zeros((0, img_proposal.shape[0]), dtype=np.float32) + else: + ious = bbox_overlaps(gts[i], img_proposal[:prop_num, :4]) + all_ious.append(ious) + all_ious = np.array(all_ious) + recalls = _recalls(all_ious, proposal_nums, iou_thrs) + if print_summary: + print_recall_summary(recalls, proposal_nums, iou_thrs) + return recalls + + +def print_recall_summary(recalls, + proposal_nums, + iou_thrs, + row_idxs=None, + col_idxs=None): + """Print recalls in a table. + + Args: + recalls(ndarray): calculated from `bbox_recalls` + proposal_nums(ndarray or list): top N proposals + iou_thrs(ndarray or list): iou thresholds + row_idxs(ndarray): which rows(proposal nums) to print + col_idxs(ndarray): which cols(iou thresholds) to print + """ + proposal_nums = np.array(proposal_nums, dtype=np.int32) + iou_thrs = np.array(iou_thrs) + if row_idxs is None: + row_idxs = np.arange(proposal_nums.size) + if col_idxs is None: + col_idxs = np.arange(iou_thrs.size) + row_header = [''] + iou_thrs[col_idxs].tolist() + table_data = [row_header] + for i, num in enumerate(proposal_nums[row_idxs]): + row = [ + '{:.3f}'.format(val) + for val in recalls[row_idxs[i], col_idxs].tolist() + ] + row.insert(0, num) + table_data.append(row) + table = AsciiTable(table_data) + print(table.table) + + +def plot_num_recall(recalls, proposal_nums): + """Plot Proposal_num-Recalls curve. + + Args: + recalls(ndarray or list): shape (k,) + proposal_nums(ndarray or list): same shape as `recalls` + """ + if isinstance(proposal_nums, np.ndarray): + _proposal_nums = proposal_nums.tolist() + else: + _proposal_nums = proposal_nums + if isinstance(recalls, np.ndarray): + _recalls = recalls.tolist() + else: + _recalls = recalls + + import matplotlib.pyplot as plt + f = plt.figure() + plt.plot([0] + _proposal_nums, [0] + _recalls) + plt.xlabel('Proposal num') + plt.ylabel('Recall') + plt.axis([0, proposal_nums.max(), 0, 1]) + f.show() + + +def plot_iou_recall(recalls, iou_thrs): + """Plot IoU-Recalls curve. + + Args: + recalls(ndarray or list): shape (k,) + iou_thrs(ndarray or list): same shape as `recalls` + """ + if isinstance(iou_thrs, np.ndarray): + _iou_thrs = iou_thrs.tolist() + else: + _iou_thrs = iou_thrs + if isinstance(recalls, np.ndarray): + _recalls = recalls.tolist() + else: + _recalls = recalls + + import matplotlib.pyplot as plt + f = plt.figure() + plt.plot(_iou_thrs + [1.0], _recalls + [0.]) + plt.xlabel('IoU') + plt.ylabel('Recall') + plt.axis([iou_thrs.min(), 1, 0, 1]) + f.show() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/__init__.py new file mode 100644 index 000000000..cc655b7c3 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/__init__.py @@ -0,0 +1,4 @@ +from .decorators import auto_fp16, force_fp32 +from .hooks import Fp16OptimizerHook, wrap_fp16_model + +__all__ = ['auto_fp16', 'force_fp32', 'Fp16OptimizerHook', 'wrap_fp16_model'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/decorators.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/decorators.py new file mode 100644 index 000000000..10ffbf898 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/decorators.py @@ -0,0 +1,160 @@ +import functools +from inspect import getfullargspec + +import torch + +from .utils import cast_tensor_type + + +def auto_fp16(apply_to=None, out_fp32=False): + """Decorator to enable fp16 training automatically. + + This decorator is useful when you write custom modules and want to support + mixed precision training. If inputs arguments are fp32 tensors, they will + be converted to fp16 automatically. Arguments other than fp32 tensors are + ignored. + + Args: + apply_to (Iterable, optional): The argument names to be converted. + `None` indicates all arguments. + out_fp32 (bool): Whether to convert the output back to fp32. + + :Example: + + class MyModule1(nn.Module) + + # Convert x and y to fp16 + @auto_fp16() + def forward(self, x, y): + pass + + class MyModule2(nn.Module): + + # convert pred to fp16 + @auto_fp16(apply_to=('pred', )) + def do_something(self, pred, others): + pass + """ + + def auto_fp16_wrapper(old_func): + + @functools.wraps(old_func) + def new_func(*args, **kwargs): + # check if the module has set the attribute `fp16_enabled`, if not, + # just fallback to the original method. + if not isinstance(args[0], torch.nn.Module): + raise TypeError('@auto_fp16 can only be used to decorate the ' + 'method of nn.Module') + if not (hasattr(args[0], 'fp16_enabled') and args[0].fp16_enabled): + return old_func(*args, **kwargs) + # get the arg spec of the decorated method + args_info = getfullargspec(old_func) + # get the argument names to be casted + args_to_cast = args_info.args if apply_to is None else apply_to + # convert the args that need to be processed + new_args = [] + # NOTE: default args are not taken into consideration + if args: + arg_names = args_info.args[:len(args)] + for i, arg_name in enumerate(arg_names): + if arg_name in args_to_cast: + new_args.append( + cast_tensor_type(args[i], torch.float, torch.half)) + else: + new_args.append(args[i]) + # convert the kwargs that need to be processed + new_kwargs = {} + if kwargs: + for arg_name, arg_value in kwargs.items(): + if arg_name in args_to_cast: + new_kwargs[arg_name] = cast_tensor_type( + arg_value, torch.float, torch.half) + else: + new_kwargs[arg_name] = arg_value + # apply converted arguments to the decorated method + output = old_func(*new_args, **new_kwargs) + # cast the results back to fp32 if necessary + if out_fp32: + output = cast_tensor_type(output, torch.half, torch.float) + return output + + return new_func + + return auto_fp16_wrapper + + +def force_fp32(apply_to=None, out_fp16=False): + """Decorator to convert input arguments to fp32 in force. + + This decorator is useful when you write custom modules and want to support + mixed precision training. If there are some inputs that must be processed + in fp32 mode, then this decorator can handle it. If inputs arguments are + fp16 tensors, they will be converted to fp32 automatically. Arguments other + than fp16 tensors are ignored. + + Args: + apply_to (Iterable, optional): The argument names to be converted. + `None` indicates all arguments. + out_fp16 (bool): Whether to convert the output back to fp16. + + :Example: + + class MyModule1(nn.Module) + + # Convert x and y to fp32 + @force_fp32() + def loss(self, x, y): + pass + + class MyModule2(nn.Module): + + # convert pred to fp32 + @force_fp32(apply_to=('pred', )) + def post_process(self, pred, others): + pass + """ + + def force_fp32_wrapper(old_func): + + @functools.wraps(old_func) + def new_func(*args, **kwargs): + # check if the module has set the attribute `fp16_enabled`, if not, + # just fallback to the original method. + if not isinstance(args[0], torch.nn.Module): + raise TypeError('@force_fp32 can only be used to decorate the ' + 'method of nn.Module') + if not (hasattr(args[0], 'fp16_enabled') and args[0].fp16_enabled): + return old_func(*args, **kwargs) + # get the arg spec of the decorated method + args_info = getfullargspec(old_func) + # get the argument names to be casted + args_to_cast = args_info.args if apply_to is None else apply_to + # convert the args that need to be processed + new_args = [] + if args: + arg_names = args_info.args[:len(args)] + for i, arg_name in enumerate(arg_names): + if arg_name in args_to_cast: + new_args.append( + cast_tensor_type(args[i], torch.half, torch.float)) + else: + new_args.append(args[i]) + # convert the kwargs that need to be processed + new_kwargs = dict() + if kwargs: + for arg_name, arg_value in kwargs.items(): + if arg_name in args_to_cast: + new_kwargs[arg_name] = cast_tensor_type( + arg_value, torch.half, torch.float) + else: + new_kwargs[arg_name] = arg_value + # apply converted arguments to the decorated method + output = old_func(*new_args, **new_kwargs) + # cast the results back to fp32 if necessary + if out_fp16: + output = cast_tensor_type(output, torch.float, torch.half) + return output + + return new_func + + return force_fp32_wrapper diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/hooks.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/hooks.py new file mode 100644 index 000000000..6b4dacb1c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/hooks.py @@ -0,0 +1,127 @@ +import copy + +import torch +import torch.nn as nn +from mmcv.runner import OptimizerHook + +from ..utils.dist_utils import allreduce_grads +from .utils import cast_tensor_type + + +class Fp16OptimizerHook(OptimizerHook): + """FP16 optimizer hook. + + The steps of fp16 optimizer is as follows. + 1. Scale the loss value. + 2. BP in the fp16 model. + 2. Copy gradients from fp16 model to fp32 weights. + 3. Update fp32 weights. + 4. Copy updated parameters from fp32 weights to fp16 model. + + Refer to https://arxiv.org/abs/1710.03740 for more details. + + Args: + loss_scale (float): Scale factor multiplied with loss. + """ + + def __init__(self, + grad_clip=None, + coalesce=True, + bucket_size_mb=-1, + loss_scale=512., + distributed=True): + self.grad_clip = grad_clip + self.coalesce = coalesce + self.bucket_size_mb = bucket_size_mb + self.loss_scale = loss_scale + self.distributed = distributed + + def before_run(self, runner): + # keep a copy of fp32 weights + runner.optimizer.param_groups = copy.deepcopy( + runner.optimizer.param_groups) + # convert model to fp16 + wrap_fp16_model(runner.model) + + def copy_grads_to_fp32(self, fp16_net, fp32_weights): + """Copy gradients from fp16 model to fp32 weight copy.""" + for fp32_param, fp16_param in zip(fp32_weights, fp16_net.parameters()): + if fp16_param.grad is not None: + if fp32_param.grad is None: + fp32_param.grad = fp32_param.data.new(fp32_param.size()) + fp32_param.grad.copy_(fp16_param.grad) + + def copy_params_to_fp16(self, fp16_net, fp32_weights): + """Copy updated params from fp32 weight copy to fp16 model.""" + for fp16_param, fp32_param in zip(fp16_net.parameters(), fp32_weights): + fp16_param.data.copy_(fp32_param.data) + + def after_train_iter(self, runner): + # clear grads of last iteration + runner.model.zero_grad() + runner.optimizer.zero_grad() + # scale the loss value + scaled_loss = runner.outputs['loss'] * self.loss_scale + scaled_loss.backward() + # copy fp16 grads in the model to fp32 params in the optimizer + fp32_weights = [] + for param_group in runner.optimizer.param_groups: + fp32_weights += param_group['params'] + self.copy_grads_to_fp32(runner.model, fp32_weights) + # allreduce grads + if self.distributed: + allreduce_grads(fp32_weights, self.coalesce, self.bucket_size_mb) + # scale the gradients back + for param in fp32_weights: + if param.grad is not None: + param.grad.div_(self.loss_scale) + if self.grad_clip is not None: + self.clip_grads(fp32_weights) + # update fp32 params + runner.optimizer.step() + # copy fp32 params to the fp16 model + self.copy_params_to_fp16(runner.model, fp32_weights) + + +def wrap_fp16_model(model): + # convert model to fp16 + model.half() + # patch the normalization layers to make it work in fp32 mode + patch_norm_fp32(model) + # set `fp16_enabled` flag + for m in model.modules(): + if hasattr(m, 'fp16_enabled'): + m.fp16_enabled = True + + +def patch_norm_fp32(module): + if isinstance(module, (nn.modules.batchnorm._BatchNorm, nn.GroupNorm)): + module.float() + module.forward = patch_forward_method(module.forward, torch.half, + torch.float) + for child in module.children(): + patch_norm_fp32(child) + return module + + +def patch_forward_method(func, src_type, dst_type, convert_output=True): + """Patch the forward method of a module. + + Args: + func (callable): The original forward method. + src_type (torch.dtype): Type of input arguments to be converted from. + dst_type (torch.dtype): Type of input arguments to be converted to. + convert_output (bool): Whether to convert the output back to src_type. + + Returns: + callable: The patched forward method. + """ + + def new_forward(*args, **kwargs): + output = func(*cast_tensor_type(args, src_type, dst_type), + **cast_tensor_type(kwargs, src_type, dst_type)) + if convert_output: + output = cast_tensor_type(output, dst_type, src_type) + return output + + return new_forward diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/utils.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/utils.py new file mode 100644 index 000000000..ce691c799 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/utils.py @@ -0,0 +1,23 @@ +from collections import abc + +import numpy as np +import torch + + +def cast_tensor_type(inputs, src_type, dst_type): + if isinstance(inputs, torch.Tensor): + return inputs.to(dst_type) + elif isinstance(inputs, str): + return inputs + elif isinstance(inputs, np.ndarray): + return inputs + elif isinstance(inputs, abc.Mapping): + return type(inputs)({ + k: cast_tensor_type(v, src_type, dst_type) + for k, v in inputs.items() + }) + elif isinstance(inputs, abc.Iterable): + return type(inputs)( + cast_tensor_type(item, src_type, dst_type) for item in inputs) + else: + return inputs diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/__init__.py new file mode 100644 index 000000000..845e7180e --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/__init__.py @@ -0,0 +1,4 @@ +from .mask_target import mask_target +from .utils import split_combined_polys + +__all__ = ['split_combined_polys', 'mask_target'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/mask_target.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/mask_target.py new file mode 100644 index 000000000..6603f11a4 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/mask_target.py @@ -0,0 +1,41 @@ +import mmcv +import numpy as np +import torch +from torch.nn.modules.utils import _pair + + +def mask_target(pos_proposals_list, pos_assigned_gt_inds_list, gt_masks_list, + cfg): + cfg_list = [cfg for _ in range(len(pos_proposals_list))] + mask_targets = map(mask_target_single, pos_proposals_list, + pos_assigned_gt_inds_list, gt_masks_list, cfg_list) + mask_targets = torch.cat(list(mask_targets)) + return mask_targets + + +def mask_target_single(pos_proposals, pos_assigned_gt_inds, gt_masks, cfg): + mask_size = _pair(cfg.mask_size) + num_pos = pos_proposals.size(0) + mask_targets = [] + if num_pos > 0: + proposals_np = pos_proposals.cpu().numpy() + _, maxh, maxw = gt_masks.shape + proposals_np[:, [0, 2]] = np.clip(proposals_np[:, [0, 2]], 0, maxw - 1) + proposals_np[:, [1, 3]] = np.clip(proposals_np[:, [1, 3]], 0, maxh - 1) + pos_assigned_gt_inds = pos_assigned_gt_inds.cpu().numpy() + for i in range(num_pos): + gt_mask = gt_masks[pos_assigned_gt_inds[i]] + bbox = proposals_np[i, :].astype(np.int32) + x1, y1, x2, y2 = bbox + w = np.maximum(x2 - x1 + 1, 1) + h = np.maximum(y2 - y1 + 1, 1) + # mask is uint8 both before and after resizing + # mask_size (h, w) to (w, h) + target = mmcv.imresize(gt_mask[y1:y1 + h, x1:x1 + w], + mask_size[::-1]) + mask_targets.append(target) + mask_targets = torch.from_numpy(np.stack(mask_targets)).float().to( + pos_proposals.device) + else: + mask_targets = pos_proposals.new_zeros((0, ) + mask_size) + return mask_targets diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/utils.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/utils.py new file mode 100644 index 000000000..a68312b17 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/utils.py @@ -0,0 +1,30 @@ +import mmcv + + +def split_combined_polys(polys, poly_lens, polys_per_mask): + """Split the combined 1-D polys into masks. + + A mask is represented as a list of polys, and a poly is represented as + a 1-D array. In dataset, all masks are concatenated into a single 1-D + tensor. Here we need to split the tensor into original representations. + + Args: + polys (list): a list (length = image num) of 1-D tensors + poly_lens (list): a list (length = image num) of poly length + polys_per_mask (list): a list (length = image num) of poly number + of each mask + + Returns: + list: a list (length = image num) of list (length = mask num) of + list (length = poly num) of numpy array + """ + mask_polys_list = [] + for img_id in range(len(polys)): + polys_single = polys[img_id] + polys_lens_single = poly_lens[img_id].tolist() + polys_per_mask_single = polys_per_mask[img_id].tolist() + + split_polys = mmcv.slice_list(polys_single, polys_lens_single) + mask_polys = mmcv.slice_list(split_polys, polys_per_mask_single) + mask_polys_list.append(mask_polys) + return mask_polys_list diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/__init__.py new file mode 100644 index 000000000..73fb1990c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/__init__.py @@ -0,0 +1,9 @@ +from .bbox_nms import multiclass_nms +from .matrix_nms import matrix_nms +from .merge_augs import (merge_aug_bboxes, merge_aug_masks, + merge_aug_proposals, merge_aug_scores) + +__all__ = [ + 'multiclass_nms', 'merge_aug_proposals', 'merge_aug_bboxes', + 'merge_aug_scores', 'merge_aug_masks', 'matrix_nms' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/bbox_nms.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/bbox_nms.py new file mode 100644 index 000000000..ce3794c64 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/bbox_nms.py @@ -0,0 +1,66 @@ +import torch + +from mmdet.ops.nms import nms_wrapper + + +def multiclass_nms(multi_bboxes, + multi_scores, + score_thr, + nms_cfg, + max_num=-1, + score_factors=None): + """NMS for multi-class bboxes. + + Args: + multi_bboxes (Tensor): shape (n, #class*4) or (n, 4) + multi_scores (Tensor): shape (n, #class), where the 0th column + contains scores of the background class, but this will be ignored. + score_thr (float): bbox threshold, bboxes with scores lower than it + will not be considered. + nms_thr (float): NMS IoU threshold + max_num (int): if there are more than max_num bboxes after NMS, + only top max_num will be kept. + score_factors (Tensor): The factors multiplied to scores before + applying NMS + + Returns: + tuple: (bboxes, labels), tensors of shape (k, 5) and (k, 1). Labels + are 0-based. + """ + num_classes = multi_scores.shape[1] + bboxes, labels = [], [] + nms_cfg_ = nms_cfg.copy() + nms_type = nms_cfg_.pop('type', 'nms') + nms_op = getattr(nms_wrapper, nms_type) + for i in range(1, num_classes): + cls_inds = multi_scores[:, i] > score_thr + if not cls_inds.any(): + continue + # get bboxes and scores of this class + if multi_bboxes.shape[1] == 4: + _bboxes = multi_bboxes[cls_inds, :] + else: + _bboxes = multi_bboxes[cls_inds, i * 4:(i + 1) * 4] + _scores = multi_scores[cls_inds, i] + if score_factors is not None: + _scores *= score_factors[cls_inds] + cls_dets = torch.cat([_bboxes, _scores[:, None]], dim=1) + cls_dets, _ = nms_op(cls_dets, **nms_cfg_) + cls_labels = multi_bboxes.new_full((cls_dets.shape[0], ), + i - 1, + dtype=torch.long) + bboxes.append(cls_dets) + labels.append(cls_labels) + if bboxes: + bboxes = torch.cat(bboxes) + labels = torch.cat(labels) + if bboxes.shape[0] > max_num: + _, inds = bboxes[:, -1].sort(descending=True) + inds = inds[:max_num] + bboxes = bboxes[inds] + labels = labels[inds] + else: + bboxes = multi_bboxes.new_zeros((0, 5)) + labels = multi_bboxes.new_zeros((0, ), dtype=torch.long) + + return bboxes, labels diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/matrix_nms.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/matrix_nms.py new file mode 100644 index 000000000..cbbe4209f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/matrix_nms.py @@ -0,0 +1,117 @@ +import torch + + +def matrix_nms(seg_masks, cate_labels, cate_scores, kernel='gaussian', sigma=2.0, sum_masks=None): + """Matrix NMS for multi-class masks. + + Args: + seg_masks (Tensor): shape (n, h, w) + cate_labels (Tensor): shape (n), mask labels in descending order + cate_scores (Tensor): shape (n), mask scores in descending order + kernel (str): 'linear' or 'gauss' + sigma (float): std in gaussian method + sum_masks (Tensor): The sum of seg_masks + + Returns: + Tensor: cate_scores_update, tensors of shape (n) + """ + n_samples = len(cate_labels) + if n_samples == 0: + return [] + if sum_masks is None: + sum_masks = seg_masks.sum((1, 2)).float() + seg_masks = seg_masks.reshape(n_samples, -1).float() + # inter. + inter_matrix = torch.mm(seg_masks, seg_masks.transpose(1, 0)) + # union. + sum_masks_x = sum_masks.expand(n_samples, n_samples) + # iou. + iou_matrix = (inter_matrix / (sum_masks_x + sum_masks_x.transpose(1, 0) - inter_matrix)).triu(diagonal=1) + # label_specific matrix. + cate_labels_x = cate_labels.expand(n_samples, n_samples) + label_matrix = (cate_labels_x == cate_labels_x.transpose(1, 0)).float().triu(diagonal=1) + + # IoU compensation + compensate_iou, _ = (iou_matrix * label_matrix).max(0) + compensate_iou = compensate_iou.expand(n_samples, n_samples).transpose(1, 0) + + # IoU decay + decay_iou = iou_matrix * label_matrix + + # matrix nms + if kernel == 'gaussian': + decay_matrix = torch.exp(-1 * sigma * (decay_iou ** 2)) + compensate_matrix = torch.exp(-1 * sigma * (compensate_iou ** 2)) + decay_coefficient, _ = (decay_matrix / compensate_matrix).min(0) + elif kernel == 'linear': + decay_matrix = (1-decay_iou)/(1-compensate_iou) + decay_coefficient, _ = decay_matrix.min(0) + else: + raise NotImplementedError + + # update the score. + cate_scores_update = cate_scores * decay_coefficient + return cate_scores_update + + +def multiclass_nms(multi_bboxes, + multi_scores, + score_thr, + nms_cfg, + max_num=-1, + score_factors=None): + """NMS for multi-class bboxes. + + Args: + multi_bboxes (Tensor): shape (n, #class*4) or (n, 4) + multi_scores (Tensor): shape (n, #class), where the 0th column + contains scores of the background class, but this will be ignored. + score_thr (float): bbox threshold, bboxes with scores lower than it + will not be considered. + nms_thr (float): NMS IoU threshold + max_num (int): if there are more than max_num bboxes after NMS, + only top max_num will be kept. + score_factors (Tensor): The factors multiplied to scores before + applying NMS + + Returns: + tuple: (bboxes, labels), tensors of shape (k, 5) and (k, 1). Labels + are 0-based. + """ + num_classes = multi_scores.shape[1] + bboxes, labels = [], [] + nms_cfg_ = nms_cfg.copy() + nms_type = nms_cfg_.pop('type', 'nms') + nms_op = getattr(nms_wrapper, nms_type) + for i in range(1, num_classes): + cls_inds = multi_scores[:, i] > score_thr + if not cls_inds.any(): + continue + # get bboxes and scores of this class + if multi_bboxes.shape[1] == 4: + _bboxes = multi_bboxes[cls_inds, :] + else: + _bboxes = multi_bboxes[cls_inds, i * 4:(i + 1) * 4] + _scores = multi_scores[cls_inds, i] + if score_factors is not None: + _scores *= score_factors[cls_inds] + cls_dets = torch.cat([_bboxes, _scores[:, None]], dim=1) + cls_dets, _ = nms_op(cls_dets, **nms_cfg_) + cls_labels = multi_bboxes.new_full((cls_dets.shape[0], ), + i - 1, + dtype=torch.long) + bboxes.append(cls_dets) + labels.append(cls_labels) + if bboxes: + bboxes = torch.cat(bboxes) + labels = torch.cat(labels) + if bboxes.shape[0] > max_num: + _, inds = bboxes[:, -1].sort(descending=True) + inds = inds[:max_num] + bboxes = bboxes[inds] + labels = labels[inds] + else: + bboxes = multi_bboxes.new_zeros((0, 5)) + labels = multi_bboxes.new_zeros((0, ), dtype=torch.long) + + return bboxes, labels diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/merge_augs.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/merge_augs.py new file mode 100644 index 000000000..a0214d63f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/merge_augs.py @@ -0,0 +1,101 @@ +import numpy as np +import torch + +from mmdet.ops import nms +from ..bbox import bbox_mapping_back + + +def merge_aug_proposals(aug_proposals, img_metas, rpn_test_cfg): + """Merge augmented proposals (multiscale, flip, etc.) + + Args: + aug_proposals (list[Tensor]): proposals from different testing + schemes, shape (n, 5). Note that they are not rescaled to the + original image size. + + img_metas (list[dict]): list of image info dict where each dict has: + 'img_shape', 'scale_factor', 'flip', and my also contain + 'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'. + For details on the values of these keys see + `mmdet/datasets/pipelines/formatting.py:Collect`. + + rpn_test_cfg (dict): rpn test config. + + Returns: + Tensor: shape (n, 4), proposals corresponding to original image scale. + """ + recovered_proposals = [] + for proposals, img_info in zip(aug_proposals, img_metas): + img_shape = img_info['img_shape'] + scale_factor = img_info['scale_factor'] + flip = img_info['flip'] + _proposals = proposals.clone() + _proposals[:, :4] = bbox_mapping_back(_proposals[:, :4], img_shape, + scale_factor, flip) + recovered_proposals.append(_proposals) + aug_proposals = torch.cat(recovered_proposals, dim=0) + merged_proposals, _ = nms(aug_proposals, rpn_test_cfg.nms_thr) + scores = merged_proposals[:, 4] + _, order = scores.sort(0, descending=True) + num = min(rpn_test_cfg.max_num, merged_proposals.shape[0]) + order = order[:num] + merged_proposals = merged_proposals[order, :] + return merged_proposals + + +def merge_aug_bboxes(aug_bboxes, aug_scores, img_metas, rcnn_test_cfg): + """Merge augmented detection bboxes and scores. + + Args: + aug_bboxes (list[Tensor]): shape (n, 4*#class) + aug_scores (list[Tensor] or None): shape (n, #class) + img_shapes (list[Tensor]): shape (3, ). + rcnn_test_cfg (dict): rcnn test config. + + Returns: + tuple: (bboxes, scores) + """ + recovered_bboxes = [] + for bboxes, img_info in zip(aug_bboxes, img_metas): + img_shape = img_info[0]['img_shape'] + scale_factor = img_info[0]['scale_factor'] + flip = img_info[0]['flip'] + bboxes = bbox_mapping_back(bboxes, img_shape, scale_factor, flip) + recovered_bboxes.append(bboxes) + bboxes = torch.stack(recovered_bboxes).mean(dim=0) + if aug_scores is None: + return bboxes + else: + scores = torch.stack(aug_scores).mean(dim=0) + return bboxes, scores + + +def merge_aug_scores(aug_scores): + """Merge augmented bbox scores.""" + if isinstance(aug_scores[0], torch.Tensor): + return torch.mean(torch.stack(aug_scores), dim=0) + else: + return np.mean(aug_scores, axis=0) + + +def merge_aug_masks(aug_masks, img_metas, rcnn_test_cfg, weights=None): + """Merge augmented mask prediction. + + Args: + aug_masks (list[ndarray]): shape (n, #class, h, w) + img_shapes (list[ndarray]): shape (3, ). + rcnn_test_cfg (dict): rcnn test config. + + Returns: + tuple: (bboxes, scores) + """ + recovered_masks = [ + mask if not img_info[0]['flip'] else mask[..., ::-1] + for mask, img_info in zip(aug_masks, img_metas) + ] + if weights is None: + merged_masks = np.mean(recovered_masks, axis=0) + else: + merged_masks = np.average( + np.array(recovered_masks), axis=0, weights=np.array(weights)) + return merged_masks diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/__init__.py new file mode 100644 index 000000000..cc999ea10 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/__init__.py @@ -0,0 +1,7 @@ +from .dist_utils import DistOptimizerHook, allreduce_grads +from .misc import multi_apply, tensor2imgs, unmap + +__all__ = [ + 'allreduce_grads', 'DistOptimizerHook', 'tensor2imgs', 'unmap', + 'multi_apply' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/dist_utils.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/dist_utils.py new file mode 100644 index 000000000..be830b6a2 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/dist_utils.py @@ -0,0 +1,58 @@ +from collections import OrderedDict + +import torch.distributed as dist +from mmcv.runner import OptimizerHook +from torch._utils import (_flatten_dense_tensors, _take_tensors, + _unflatten_dense_tensors) + + +def _allreduce_coalesced(tensors, world_size, bucket_size_mb=-1): + if bucket_size_mb > 0: + bucket_size_bytes = bucket_size_mb * 1024 * 1024 + buckets = _take_tensors(tensors, bucket_size_bytes) + else: + buckets = OrderedDict() + for tensor in tensors: + tp = tensor.type() + if tp not in buckets: + buckets[tp] = [] + buckets[tp].append(tensor) + buckets = buckets.values() + + for bucket in buckets: + flat_tensors = _flatten_dense_tensors(bucket) + dist.all_reduce(flat_tensors) + flat_tensors.div_(world_size) + for tensor, synced in zip( + bucket, _unflatten_dense_tensors(flat_tensors, bucket)): + tensor.copy_(synced) + + +def allreduce_grads(params, coalesce=True, bucket_size_mb=-1): + grads = [ + param.grad.data for param in params + if param.requires_grad and param.grad is not None + ] + world_size = dist.get_world_size() + if coalesce: + _allreduce_coalesced(grads, world_size, bucket_size_mb) + else: + for tensor in grads: + dist.all_reduce(tensor.div_(world_size)) + + +class DistOptimizerHook(OptimizerHook): + + def __init__(self, grad_clip=None, coalesce=True, bucket_size_mb=-1): + self.grad_clip = grad_clip + self.coalesce = coalesce + self.bucket_size_mb = bucket_size_mb + + def after_train_iter(self, runner): + runner.optimizer.zero_grad() + runner.outputs['loss'].backward() + allreduce_grads(runner.model.parameters(), self.coalesce, + self.bucket_size_mb) + if self.grad_clip is not None: + self.clip_grads(runner.model.parameters()) + runner.optimizer.step() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/misc.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/misc.py new file mode 100644 index 000000000..262f168e6 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/misc.py @@ -0,0 +1,37 @@ +from functools import partial + +import mmcv +import numpy as np +from six.moves import map, zip + + +def tensor2imgs(tensor, mean=(0, 0, 0), std=(1, 1, 1), to_rgb=True): + num_imgs = tensor.size(0) + mean = np.array(mean, dtype=np.float32) + std = np.array(std, dtype=np.float32) + imgs = [] + for img_id in range(num_imgs): + img = tensor[img_id, ...].cpu().numpy().transpose(1, 2, 0) + img = mmcv.imdenormalize( + img, mean, std, to_bgr=to_rgb).astype(np.uint8) + imgs.append(np.ascontiguousarray(img)) + return imgs + + +def multi_apply(func, *args, **kwargs): + pfunc = partial(func, **kwargs) if kwargs else func + map_results = map(pfunc, *args) + return tuple(map(list, zip(*map_results))) + + +def unmap(data, count, inds, fill=0): + """ Unmap a subset of item (data) back to the original set of items (of + size count) """ + if data.dim() == 1: + ret = data.new_full((count, ), fill) + ret[inds] = data + else: + new_size = (count, ) + data.size()[1:] + ret = data.new_full(new_size, fill) + ret[inds, :] = data + return ret diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/__init__.py new file mode 100644 index 000000000..7ad926d4c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/__init__.py @@ -0,0 +1,17 @@ +from .builder import build_dataset +from .cityscapes import CityscapesDataset +from .coco import CocoDataset +from .custom import CustomDataset +from .dataset_wrappers import ConcatDataset, RepeatDataset +from .loader import DistributedGroupSampler, GroupSampler, build_dataloader +from .registry import DATASETS +from .voc import VOCDataset +from .wider_face import WIDERFaceDataset +from .xml_style import XMLDataset + +__all__ = [ + 'CustomDataset', 'XMLDataset', 'CocoDataset', 'VOCDataset', + 'CityscapesDataset', 'GroupSampler', 'DistributedGroupSampler', + 'build_dataloader', 'ConcatDataset', 'RepeatDataset', 'WIDERFaceDataset', + 'DATASETS', 'build_dataset' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/builder.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/builder.py new file mode 100644 index 000000000..6e707b190 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/builder.py @@ -0,0 +1,41 @@ +import copy + +from mmdet.utils import build_from_cfg +from .dataset_wrappers import ConcatDataset, RepeatDataset +from .registry import DATASETS + + +def _concat_dataset(cfg, default_args=None): + ann_files = cfg['ann_file'] + img_prefixes = cfg.get('img_prefix', None) + seg_prefixes = cfg.get('seg_prefix', None) + proposal_files = cfg.get('proposal_file', None) + + datasets = [] + num_dset = len(ann_files) + for i in range(num_dset): + data_cfg = copy.deepcopy(cfg) + data_cfg['ann_file'] = ann_files[i] + if isinstance(img_prefixes, (list, tuple)): + data_cfg['img_prefix'] = img_prefixes[i] + if isinstance(seg_prefixes, (list, tuple)): + data_cfg['seg_prefix'] = seg_prefixes[i] + if isinstance(proposal_files, (list, tuple)): + data_cfg['proposal_file'] = proposal_files[i] + datasets.append(build_dataset(data_cfg, default_args)) + + return ConcatDataset(datasets) + + +def build_dataset(cfg, default_args=None): + if isinstance(cfg, (list, tuple)): + dataset = ConcatDataset([build_dataset(c, default_args) for c in cfg]) + elif cfg['type'] == 'RepeatDataset': + dataset = RepeatDataset( + build_dataset(cfg['dataset'], default_args), cfg['times']) + elif isinstance(cfg['ann_file'], (list, tuple)): + dataset = _concat_dataset(cfg, default_args) + else: + dataset = build_from_cfg(cfg, DATASETS, default_args) + + return dataset diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/cityscapes.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/cityscapes.py new file mode 100644 index 000000000..51ca04987 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/cityscapes.py @@ -0,0 +1,9 @@ +from .coco import CocoDataset +from .registry import DATASETS + + +@DATASETS.register_module +class CityscapesDataset(CocoDataset): + + CLASSES = ('person', 'rider', 'car', 'truck', 'bus', 'train', 'motorcycle', + 'bicycle') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/coco.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/coco.py new file mode 100644 index 000000000..d041532ab --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/coco.py @@ -0,0 +1,110 @@ +import numpy as np +from pycocotools.coco import COCO + +from .custom import CustomDataset +from .registry import DATASETS + + +@DATASETS.register_module +class CocoDataset(CustomDataset): + + CLASSES = ('person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', + 'train', 'truck', 'boat', 'traffic_light', 'fire_hydrant', + 'stop_sign', 'parking_meter', 'bench', 'bird', 'cat', 'dog', + 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', + 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', + 'skis', 'snowboard', 'sports_ball', 'kite', 'baseball_bat', + 'baseball_glove', 'skateboard', 'surfboard', 'tennis_racket', + 'bottle', 'wine_glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', + 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', + 'hot_dog', 'pizza', 'donut', 'cake', 'chair', 'couch', + 'potted_plant', 'bed', 'dining_table', 'toilet', 'tv', 'laptop', + 'mouse', 'remote', 'keyboard', 'cell_phone', 'microwave', + 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', + 'vase', 'scissors', 'teddy_bear', 'hair_drier', 'toothbrush') + + def load_annotations(self, ann_file): + self.coco = COCO(ann_file) + self.cat_ids = self.coco.getCatIds() + self.cat2label = { + cat_id: i + 1 + for i, cat_id in enumerate(self.cat_ids) + } + self.img_ids = self.coco.getImgIds() + img_infos = [] + for i in self.img_ids: + info = self.coco.loadImgs([i])[0] + info['filename'] = info['file_name'] + img_infos.append(info) + return img_infos + + def get_ann_info(self, idx): + img_id = self.img_infos[idx]['id'] + ann_ids = self.coco.getAnnIds(imgIds=[img_id]) + ann_info = self.coco.loadAnns(ann_ids) + return self._parse_ann_info(self.img_infos[idx], ann_info) + + def _filter_imgs(self, min_size=32): + """Filter images too small or without ground truths.""" + valid_inds = [] + ids_with_ann = set(_['image_id'] for _ in self.coco.anns.values()) + for i, img_info in enumerate(self.img_infos): + if self.filter_empty_gt and self.img_ids[i] not in ids_with_ann: + continue + if min(img_info['width'], img_info['height']) >= min_size: + valid_inds.append(i) + return valid_inds + + def _parse_ann_info(self, img_info, ann_info): + """Parse bbox and mask annotation. + + Args: + ann_info (list[dict]): Annotation info of an image. + with_mask (bool): Whether to parse mask annotations. + + Returns: + dict: A dict containing the following keys: bboxes, bboxes_ignore, + labels, masks, seg_map. "masks" are raw annotations and not + decoded into binary masks. + """ + gt_bboxes = [] + gt_labels = [] + gt_bboxes_ignore = [] + gt_masks_ann = [] + + for i, ann in enumerate(ann_info): + if ann.get('ignore', False): + continue + x1, y1, w, h = ann['bbox'] + if ann['area'] <= 0 or w < 1 or h < 1: + continue + bbox = [x1, y1, x1 + w - 1, y1 + h - 1] + if ann.get('iscrowd', False): + gt_bboxes_ignore.append(bbox) + else: + gt_bboxes.append(bbox) + gt_labels.append(self.cat2label[ann['category_id']]) + gt_masks_ann.append(ann['segmentation']) + + if gt_bboxes: + gt_bboxes = np.array(gt_bboxes, dtype=np.float32) + gt_labels = np.array(gt_labels, dtype=np.int64) + else: + gt_bboxes = np.zeros((0, 4), dtype=np.float32) + gt_labels = np.array([], dtype=np.int64) + + if gt_bboxes_ignore: + gt_bboxes_ignore = np.array(gt_bboxes_ignore, dtype=np.float32) + else: + gt_bboxes_ignore = np.zeros((0, 4), dtype=np.float32) + + seg_map = img_info['filename'].replace('jpg', 'png') + + ann = dict( + bboxes=gt_bboxes, + labels=gt_labels, + bboxes_ignore=gt_bboxes_ignore, + masks=gt_masks_ann, + seg_map=seg_map) + + return ann diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/custom.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/custom.py new file mode 100644 index 000000000..935b39d2c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/custom.py @@ -0,0 +1,152 @@ +import os.path as osp + +import mmcv +import numpy as np +from torch.utils.data import Dataset + +from .pipelines import Compose +from .registry import DATASETS + + +@DATASETS.register_module +class CustomDataset(Dataset): + """Custom dataset for detection. + + Annotation format: + [ + { + 'filename': 'a.jpg', + 'width': 1280, + 'height': 720, + 'ann': { + 'bboxes': (n, 4), + 'labels': (n, ), + 'bboxes_ignore': (k, 4), (optional field) + 'labels_ignore': (k, 4) (optional field) + } + }, + ... + ] + + The `ann` field is optional for testing. + """ + + CLASSES = None + + def __init__(self, + ann_file, + pipeline, + data_root=None, + img_prefix='', + seg_prefix=None, + proposal_file=None, + test_mode=False, + filter_empty_gt=True): + self.ann_file = ann_file + self.data_root = data_root + self.img_prefix = img_prefix + self.seg_prefix = seg_prefix + self.proposal_file = proposal_file + self.test_mode = test_mode + self.filter_empty_gt = filter_empty_gt + + # join paths if data_root is specified + if self.data_root is not None: + if not osp.isabs(self.ann_file): + self.ann_file = osp.join(self.data_root, self.ann_file) + if not (self.img_prefix is None or osp.isabs(self.img_prefix)): + self.img_prefix = osp.join(self.data_root, self.img_prefix) + if not (self.seg_prefix is None or osp.isabs(self.seg_prefix)): + self.seg_prefix = osp.join(self.data_root, self.seg_prefix) + if not (self.proposal_file is None + or osp.isabs(self.proposal_file)): + self.proposal_file = osp.join(self.data_root, + self.proposal_file) + # load annotations (and proposals) + self.img_infos = self.load_annotations(self.ann_file) + if self.proposal_file is not None: + self.proposals = self.load_proposals(self.proposal_file) + else: + self.proposals = None + # filter images too small + if not test_mode: + valid_inds = self._filter_imgs() + self.img_infos = [self.img_infos[i] for i in valid_inds] + if self.proposals is not None: + self.proposals = [self.proposals[i] for i in valid_inds] + # set group flag for the sampler + if not self.test_mode: + self._set_group_flag() + # processing pipeline + self.pipeline = Compose(pipeline) + + def __len__(self): + return len(self.img_infos) + + def load_annotations(self, ann_file): + return mmcv.load(ann_file) + + def load_proposals(self, proposal_file): + return mmcv.load(proposal_file) + + def get_ann_info(self, idx): + return self.img_infos[idx]['ann'] + + def pre_pipeline(self, results): + results['img_prefix'] = self.img_prefix + results['seg_prefix'] = self.seg_prefix + results['proposal_file'] = self.proposal_file + results['bbox_fields'] = [] + results['mask_fields'] = [] + results['seg_fields'] = [] + + def _filter_imgs(self, min_size=32): + """Filter images too small.""" + valid_inds = [] + for i, img_info in enumerate(self.img_infos): + if min(img_info['width'], img_info['height']) >= min_size: + valid_inds.append(i) + return valid_inds + + def _set_group_flag(self): + """Set flag according to image aspect ratio. + + Images with aspect ratio greater than 1 will be set as group 1, + otherwise group 0. + """ + self.flag = np.zeros(len(self), dtype=np.uint8) + for i in range(len(self)): + img_info = self.img_infos[i] + if img_info['width'] / img_info['height'] > 1: + self.flag[i] = 1 + + def _rand_another(self, idx): + pool = np.where(self.flag == self.flag[idx])[0] + return np.random.choice(pool) + + def __getitem__(self, idx): + if self.test_mode: + return self.prepare_test_img(idx) + while True: + data = self.prepare_train_img(idx) + if data is None: + idx = self._rand_another(idx) + continue + return data + + def prepare_train_img(self, idx): + img_info = self.img_infos[idx] + ann_info = self.get_ann_info(idx) + results = dict(img_info=img_info, ann_info=ann_info) + if self.proposals is not None: + results['proposals'] = self.proposals[idx] + self.pre_pipeline(results) + return self.pipeline(results) + + def prepare_test_img(self, idx): + img_info = self.img_infos[idx] + results = dict(img_info=img_info) + if self.proposals is not None: + results['proposals'] = self.proposals[idx] + self.pre_pipeline(results) + return self.pipeline(results) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/dataset_wrappers.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/dataset_wrappers.py new file mode 100644 index 000000000..e749cb076 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/dataset_wrappers.py @@ -0,0 +1,55 @@ +import numpy as np +from torch.utils.data.dataset import ConcatDataset as _ConcatDataset + +from .registry import DATASETS + + +@DATASETS.register_module +class ConcatDataset(_ConcatDataset): + """A wrapper of concatenated dataset. + + Same as :obj:`torch.utils.data.dataset.ConcatDataset`, but + concat the group flag for image aspect ratio. + + Args: + datasets (list[:obj:`Dataset`]): A list of datasets. + """ + + def __init__(self, datasets): + super(ConcatDataset, self).__init__(datasets) + self.CLASSES = datasets[0].CLASSES + if hasattr(datasets[0], 'flag'): + flags = [] + for i in range(0, len(datasets)): + flags.append(datasets[i].flag) + self.flag = np.concatenate(flags) + + +@DATASETS.register_module +class RepeatDataset(object): + """A wrapper of repeated dataset. + + The length of repeated dataset will be `times` larger than the original + dataset. This is useful when the data loading time is long but the dataset + is small. Using RepeatDataset can reduce the data loading time between + epochs. + + Args: + dataset (:obj:`Dataset`): The dataset to be repeated. + times (int): Repeat times. + """ + + def __init__(self, dataset, times): + self.dataset = dataset + self.times = times + self.CLASSES = dataset.CLASSES + if hasattr(self.dataset, 'flag'): + self.flag = np.tile(self.dataset.flag, times) + + self._ori_len = len(self.dataset) + + def __getitem__(self, idx): + return self.dataset[idx % self._ori_len] + + def __len__(self): + return self.times * self._ori_len diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/__init__.py new file mode 100644 index 000000000..4404615be --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/__init__.py @@ -0,0 +1,4 @@ +from .build_loader import build_dataloader +from .sampler import DistributedGroupSampler, GroupSampler + +__all__ = ['GroupSampler', 'DistributedGroupSampler', 'build_dataloader'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/build_loader.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/build_loader.py new file mode 100644 index 000000000..e9431d7ba --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/build_loader.py @@ -0,0 +1,70 @@ +import platform +from functools import partial + +from mmcv.parallel import collate +from mmcv.runner import get_dist_info +from torch.utils.data import DataLoader + +from .sampler import DistributedGroupSampler, DistributedSampler, GroupSampler + +if platform.system() != 'Windows': + # https://github.com/pytorch/pytorch/issues/973 + import resource + rlimit = resource.getrlimit(resource.RLIMIT_NOFILE) + resource.setrlimit(resource.RLIMIT_NOFILE, (4096, rlimit[1])) + + +def build_dataloader(dataset, + imgs_per_gpu, + workers_per_gpu, + num_gpus=1, + dist=True, + shuffle=True, + **kwargs): + """Build PyTorch DataLoader. + + In distributed training, each GPU/process has a dataloader. + In non-distributed training, there is only one dataloader for all GPUs. + + Args: + dataset (Dataset): A PyTorch dataset. + imgs_per_gpu (int): Number of images on each GPU, i.e., batch size of + each GPU. + workers_per_gpu (int): How many subprocesses to use for data loading + for each GPU. + num_gpus (int): Number of GPUs. Only used in non-distributed training. + dist (bool): Distributed training/test or not. Default: True. + shuffle (bool): Whether to shuffle the data at every epoch. + Default: True. + kwargs: any keyword argument to be used to initialize DataLoader + + Returns: + DataLoader: A PyTorch dataloader. + """ + if dist: + rank, world_size = get_dist_info() + # DistributedGroupSampler will definitely shuffle the data to satisfy + # that images on each GPU are in the same group + if shuffle: + sampler = DistributedGroupSampler(dataset, imgs_per_gpu, + world_size, rank) + else: + sampler = DistributedSampler( + dataset, world_size, rank, shuffle=False) + batch_size = imgs_per_gpu + num_workers = workers_per_gpu + else: + sampler = GroupSampler(dataset, imgs_per_gpu) if shuffle else None + batch_size = num_gpus * imgs_per_gpu + num_workers = num_gpus * workers_per_gpu + + data_loader = DataLoader( + dataset, + batch_size=batch_size, + sampler=sampler, + num_workers=num_workers, + collate_fn=partial(collate, samples_per_gpu=imgs_per_gpu), + pin_memory=False, + **kwargs) + + return data_loader diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/sampler.py new file mode 100644 index 000000000..f3dd99620 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/sampler.py @@ -0,0 +1,164 @@ +from __future__ import division +import math + +import numpy as np +import torch +from mmcv.runner import get_dist_info +from torch.utils.data import DistributedSampler as _DistributedSampler +from torch.utils.data import Sampler + + +class DistributedSampler(_DistributedSampler): + + def __init__(self, dataset, num_replicas=None, rank=None, shuffle=True): + super().__init__(dataset, num_replicas=num_replicas, rank=rank) + self.shuffle = shuffle + + def __iter__(self): + # deterministically shuffle based on epoch + if self.shuffle: + g = torch.Generator() + g.manual_seed(self.epoch) + indices = torch.randperm(len(self.dataset), generator=g).tolist() + else: + indices = torch.arange(len(self.dataset)).tolist() + + # add extra samples to make it evenly divisible + indices += indices[:(self.total_size - len(indices))] + assert len(indices) == self.total_size + + # subsample + indices = indices[self.rank:self.total_size:self.num_replicas] + assert len(indices) == self.num_samples + + return iter(indices) + + +class GroupSampler(Sampler): + + def __init__(self, dataset, samples_per_gpu=1): + assert hasattr(dataset, 'flag') + self.dataset = dataset + self.samples_per_gpu = samples_per_gpu + self.flag = dataset.flag.astype(np.int64) + self.group_sizes = np.bincount(self.flag) + self.num_samples = 0 + for i, size in enumerate(self.group_sizes): + self.num_samples += int(np.ceil( + size / self.samples_per_gpu)) * self.samples_per_gpu + + def __iter__(self): + indices = [] + for i, size in enumerate(self.group_sizes): + if size == 0: + continue + indice = np.where(self.flag == i)[0] + assert len(indice) == size + np.random.shuffle(indice) + num_extra = int(np.ceil(size / self.samples_per_gpu) + ) * self.samples_per_gpu - len(indice) + indice = np.concatenate( + [indice, np.random.choice(indice, num_extra)]) + indices.append(indice) + indices = np.concatenate(indices) + indices = [ + indices[i * self.samples_per_gpu:(i + 1) * self.samples_per_gpu] + for i in np.random.permutation( + range(len(indices) // self.samples_per_gpu)) + ] + indices = np.concatenate(indices) + indices = indices.astype(np.int64).tolist() + assert len(indices) == self.num_samples + return iter(indices) + + def __len__(self): + return self.num_samples + + +class DistributedGroupSampler(Sampler): + """Sampler that restricts data loading to a subset of the dataset. + It is especially useful in conjunction with + :class:`torch.nn.parallel.DistributedDataParallel`. In such case, each + process can pass a DistributedSampler instance as a DataLoader sampler, + and load a subset of the original dataset that is exclusive to it. + .. note:: + Dataset is assumed to be of constant size. + Arguments: + dataset: Dataset used for sampling. + num_replicas (optional): Number of processes participating in + distributed training. + rank (optional): Rank of the current process within num_replicas. + """ + + def __init__(self, + dataset, + samples_per_gpu=1, + num_replicas=None, + rank=None): + _rank, _num_replicas = get_dist_info() + if num_replicas is None: + num_replicas = _num_replicas + if rank is None: + rank = _rank + self.dataset = dataset + self.samples_per_gpu = samples_per_gpu + self.num_replicas = num_replicas + self.rank = rank + self.epoch = 0 + + assert hasattr(self.dataset, 'flag') + self.flag = self.dataset.flag + self.group_sizes = np.bincount(self.flag) + + self.num_samples = 0 + for i, j in enumerate(self.group_sizes): + self.num_samples += int( + math.ceil(self.group_sizes[i] * 1.0 / self.samples_per_gpu / + self.num_replicas)) * self.samples_per_gpu + self.total_size = self.num_samples * self.num_replicas + + def __iter__(self): + # deterministically shuffle based on epoch + g = torch.Generator() + g.manual_seed(self.epoch) + + indices = [] + for i, size in enumerate(self.group_sizes): + if size > 0: + indice = np.where(self.flag == i)[0] + assert len(indice) == size + indice = indice[list(torch.randperm(int(size), + generator=g))].tolist() + extra = int( + math.ceil( + size * 1.0 / self.samples_per_gpu / self.num_replicas) + ) * self.samples_per_gpu * self.num_replicas - len(indice) + # pad indice + tmp = indice.copy() + for _ in range(extra // size): + indice.extend(tmp) + indice.extend(tmp[:extra % size]) + indices.extend(indice) + + assert len(indices) == self.total_size + + indices = [ + indices[j] for i in list( + torch.randperm( + len(indices) // self.samples_per_gpu, generator=g)) + for j in range(i * self.samples_per_gpu, (i + 1) * + self.samples_per_gpu) + ] + + # subsample + offset = self.num_samples * self.rank + indices = indices[offset:offset + self.num_samples] + assert len(indices) == self.num_samples + + return iter(indices) + + def __len__(self): + return self.num_samples + + def set_epoch(self, epoch): + self.epoch = epoch diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/__init__.py new file mode 100644 index 000000000..fca8d984c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/__init__.py @@ -0,0 +1,17 @@ +from .compose import Compose +from .formating import (Collect, ImageToTensor, ToDataContainer, ToTensor, + Transpose, to_tensor) +from .instaboost import InstaBoost +from .loading import LoadAnnotations, LoadImageFromFile, LoadProposals +from .test_aug import MultiScaleFlipAug +from .transforms import (Albu, Expand, MinIoURandomCrop, Normalize, Pad, + PhotoMetricDistortion, RandomCrop, RandomFlip, Resize, + SegRescale) + +__all__ = [ + 'Compose', 'to_tensor', 'ToTensor', 'ImageToTensor', 'ToDataContainer', + 'Transpose', 'Collect', 'LoadAnnotations', 'LoadImageFromFile', + 'LoadProposals', 'MultiScaleFlipAug', 'Resize', 'RandomFlip', 'Pad', + 'RandomCrop', 'Normalize', 'SegRescale', 'MinIoURandomCrop', 'Expand', + 'PhotoMetricDistortion', 'Albu', 'InstaBoost' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/compose.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/compose.py new file mode 100644 index 000000000..f160eed97 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/compose.py @@ -0,0 +1,35 @@ +import collections + +from mmdet.utils import build_from_cfg +from ..registry import PIPELINES + + +@PIPELINES.register_module +class Compose(object): + + def __init__(self, transforms): + assert isinstance(transforms, collections.abc.Sequence) + self.transforms = [] + for transform in transforms: + if isinstance(transform, dict): + transform = build_from_cfg(transform, PIPELINES) + self.transforms.append(transform) + elif callable(transform): + self.transforms.append(transform) + else: + raise TypeError('transform must be callable or a dict') + + def __call__(self, data): + for t in self.transforms: + data = t(data) + if data is None: + return None + return data + + def __repr__(self): + format_string = self.__class__.__name__ + '(' + for t in self.transforms: + format_string += '\n' + format_string += ' {0}'.format(t) + format_string += '\n)' + return format_string diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/formating.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/formating.py new file mode 100644 index 000000000..e14dd0a97 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/formating.py @@ -0,0 +1,192 @@ +from collections.abc import Sequence + +import mmcv +import numpy as np +import torch +from mmcv.parallel import DataContainer as DC + +from ..registry import PIPELINES + + +def to_tensor(data): + """Convert objects of various python types to :obj:`torch.Tensor`. + + Supported types are: :class:`numpy.ndarray`, :class:`torch.Tensor`, + :class:`Sequence`, :class:`int` and :class:`float`. + """ + if isinstance(data, torch.Tensor): + return data + elif isinstance(data, np.ndarray): + return torch.from_numpy(data) + elif isinstance(data, Sequence) and not mmcv.is_str(data): + return torch.tensor(data) + elif isinstance(data, int): + return torch.LongTensor([data]) + elif isinstance(data, float): + return torch.FloatTensor([data]) + else: + raise TypeError('type {} cannot be converted to tensor.'.format( + type(data))) + + +@PIPELINES.register_module +class ToTensor(object): + + def __init__(self, keys): + self.keys = keys + + def __call__(self, results): + for key in self.keys: + results[key] = to_tensor(results[key]) + return results + + def __repr__(self): + return self.__class__.__name__ + '(keys={})'.format(self.keys) + + +@PIPELINES.register_module +class ImageToTensor(object): + + def __init__(self, keys): + self.keys = keys + + def __call__(self, results): + for key in self.keys: + img = results[key] + if len(img.shape) < 3: + img = np.expand_dims(img, -1) + results[key] = to_tensor(img.transpose(2, 0, 1)) + return results + + def __repr__(self): + return self.__class__.__name__ + '(keys={})'.format(self.keys) + + +@PIPELINES.register_module +class Transpose(object): + + def __init__(self, keys, order): + self.keys = keys + self.order = order + + def __call__(self, results): + for key in self.keys: + results[key] = results[key].transpose(self.order) + return results + + def __repr__(self): + return self.__class__.__name__ + '(keys={}, order={})'.format( + self.keys, self.order) + + +@PIPELINES.register_module +class ToDataContainer(object): + + def __init__(self, + fields=(dict(key='img', stack=True), dict(key='gt_bboxes'), + dict(key='gt_labels'))): + self.fields = fields + + def __call__(self, results): + for field in self.fields: + field = field.copy() + key = field.pop('key') + results[key] = DC(results[key], **field) + return results + + def __repr__(self): + return self.__class__.__name__ + '(fields={})'.format(self.fields) + + +@PIPELINES.register_module +class DefaultFormatBundle(object): + """Default formatting bundle. + + It simplifies the pipeline of formatting common fields, including "img", + "proposals", "gt_bboxes", "gt_labels", "gt_masks" and "gt_semantic_seg". + These fields are formatted as follows. + + - img: (1)transpose, (2)to tensor, (3)to DataContainer (stack=True) + - proposals: (1)to tensor, (2)to DataContainer + - gt_bboxes: (1)to tensor, (2)to DataContainer + - gt_bboxes_ignore: (1)to tensor, (2)to DataContainer + - gt_labels: (1)to tensor, (2)to DataContainer + - gt_masks: (1)to tensor, (2)to DataContainer (cpu_only=True) + - gt_semantic_seg: (1)unsqueeze dim-0 (2)to tensor, + (3)to DataContainer (stack=True) + """ + + def __call__(self, results): + if 'img' in results: + img = results['img'] + if len(img.shape) < 3: + img = np.expand_dims(img, -1) + img = np.ascontiguousarray(img.transpose(2, 0, 1)) + results['img'] = DC(to_tensor(img), stack=True) + for key in ['proposals', 'gt_bboxes', 'gt_bboxes_ignore', 'gt_labels']: + if key not in results: + continue + results[key] = DC(to_tensor(results[key])) + if 'gt_masks' in results: + results['gt_masks'] = DC(results['gt_masks'], cpu_only=True) + if 'gt_semantic_seg' in results: + results['gt_semantic_seg'] = DC( + to_tensor(results['gt_semantic_seg'][None, ...]), stack=True) + return results + + def __repr__(self): + return self.__class__.__name__ + + +@PIPELINES.register_module +class Collect(object): + """ + Collect data from the loader relevant to the specific task. + + This is usually the last stage of the data loader pipeline. Typically keys + is set to some subset of "img", "proposals", "gt_bboxes", + "gt_bboxes_ignore", "gt_labels", and/or "gt_masks". + + The "img_meta" item is always populated. The contents of the "img_meta" + dictionary depends on "meta_keys". By default this includes: + + - "img_shape": shape of the image input to the network as a tuple + (h, w, c). Note that images may be zero padded on the bottom/right + if the batch tensor is larger than this shape. + + - "scale_factor": a float indicating the preprocessing scale + + - "flip": a boolean indicating if image flip transform was used + + - "filename": path to the image file + + - "ori_shape": original shape of the image as a tuple (h, w, c) + + - "pad_shape": image shape after padding + + - "img_norm_cfg": a dict of normalization information: + - mean - per channel mean subtraction + - std - per channel std divisor + - to_rgb - bool indicating if bgr was converted to rgb + """ + + def __init__(self, + keys, + meta_keys=('filename', 'ori_shape', 'img_shape', 'pad_shape', + 'scale_factor', 'flip', 'img_norm_cfg')): + self.keys = keys + self.meta_keys = meta_keys + + def __call__(self, results): + data = {} + img_meta = {} + for key in self.meta_keys: + img_meta[key] = results[key] + data['img_meta'] = DC(img_meta, cpu_only=True) + for key in self.keys: + data[key] = results[key] + return data + + def __repr__(self): + return self.__class__.__name__ + '(keys={}, meta_keys={})'.format( + self.keys, self.meta_keys) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/instaboost.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/instaboost.py new file mode 100644 index 000000000..6777d4425 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/instaboost.py @@ -0,0 +1,91 @@ +import numpy as np + +from ..registry import PIPELINES + + +@PIPELINES.register_module +class InstaBoost(object): + """ + Data augmentation method in paper "InstaBoost: Boosting Instance + Segmentation Via Probability Map Guided Copy-Pasting" + Implementation details can refer to https://github.com/GothicAi/Instaboost. + """ + + def __init__(self, + action_candidate=('normal', 'horizontal', 'skip'), + action_prob=(1, 0, 0), + scale=(0.8, 1.2), + dx=15, + dy=15, + theta=(-1, 1), + color_prob=0.5, + hflag=False, + aug_ratio=0.5): + try: + import instaboostfast as instaboost + except ImportError: + raise ImportError( + 'Please run "pip install instaboostfast" ' + 'to install instaboostfast first for instaboost augmentation.') + self.cfg = instaboost.InstaBoostConfig(action_candidate, action_prob, + scale, dx, dy, theta, + color_prob, hflag) + self.aug_ratio = aug_ratio + + def _load_anns(self, results): + labels = results['ann_info']['labels'] + masks = results['ann_info']['masks'] + bboxes = results['ann_info']['bboxes'] + n = len(labels) + + anns = [] + for i in range(n): + label = labels[i] + bbox = bboxes[i] + mask = masks[i] + x1, y1, x2, y2 = bbox + bbox = [x1, y1, x2 - x1 + 1, y2 - y1 + 1] + anns.append({ + 'category_id': label, + 'segmentation': mask, + 'bbox': bbox + }) + + return anns + + def _parse_anns(self, results, anns, img): + gt_bboxes = [] + gt_labels = [] + gt_masks_ann = [] + for ann in anns: + x1, y1, w, h = ann['bbox'] + bbox = [x1, y1, x1 + w - 1, y1 + h - 1] + gt_bboxes.append(bbox) + gt_labels.append(ann['category_id']) + gt_masks_ann.append(ann['segmentation']) + gt_bboxes = np.array(gt_bboxes, dtype=np.float32) + gt_labels = np.array(gt_labels, dtype=np.int64) + results['ann_info']['labels'] = gt_labels + results['ann_info']['bboxes'] = gt_bboxes + results['ann_info']['masks'] = gt_masks_ann + results['img'] = img + return results + + def __call__(self, results): + img = results['img'] + anns = self._load_anns(results) + if np.random.choice([0, 1], p=[1 - self.aug_ratio, self.aug_ratio]): + try: + import instaboostfast as instaboost + except ImportError: + raise ImportError('Please run "pip install instaboostfast" ' + 'to install instaboostfast first.') + anns, img = instaboost.get_new_data( + anns, img, self.cfg, background=None) + results = self._parse_anns(results, anns, img) + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += ('(cfg={}, aug_ratio={})').format(self.cfg, self.aug_ratio) + return repr_str diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/loading.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/loading.py new file mode 100644 index 000000000..190773b15 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/loading.py @@ -0,0 +1,144 @@ +import os.path as osp + +import mmcv +import numpy as np +import pycocotools.mask as maskUtils + +from ..registry import PIPELINES + + +@PIPELINES.register_module +class LoadImageFromFile(object): + + def __init__(self, to_float32=False, color_type='color'): + self.to_float32 = to_float32 + self.color_type = color_type + + def __call__(self, results): + if results['img_prefix'] is not None: + filename = osp.join(results['img_prefix'], + results['img_info']['filename']) + else: + filename = results['img_info']['filename'] + img = mmcv.imread(filename, self.color_type) + if self.to_float32: + img = img.astype(np.float32) + results['filename'] = filename + results['img'] = img + results['img_shape'] = img.shape + results['ori_shape'] = img.shape + return results + + def __repr__(self): + return '{} (to_float32={}, color_type={})'.format( + self.__class__.__name__, self.to_float32, self.color_type) + + +@PIPELINES.register_module +class LoadAnnotations(object): + + def __init__(self, + with_bbox=True, + with_label=True, + with_mask=False, + with_seg=False, + poly2mask=True): + self.with_bbox = with_bbox + self.with_label = with_label + self.with_mask = with_mask + self.with_seg = with_seg + self.poly2mask = poly2mask + + def _load_bboxes(self, results): + ann_info = results['ann_info'] + results['gt_bboxes'] = ann_info['bboxes'] + + gt_bboxes_ignore = ann_info.get('bboxes_ignore', None) + if gt_bboxes_ignore is not None: + results['gt_bboxes_ignore'] = gt_bboxes_ignore + results['bbox_fields'].append('gt_bboxes_ignore') + results['bbox_fields'].append('gt_bboxes') + return results + + def _load_labels(self, results): + results['gt_labels'] = results['ann_info']['labels'] + return results + + def _poly2mask(self, mask_ann, img_h, img_w): + if isinstance(mask_ann, list): + # polygon -- a single object might consist of multiple parts + # we merge all parts into one mask rle code + rles = maskUtils.frPyObjects(mask_ann, img_h, img_w) + rle = maskUtils.merge(rles) + elif isinstance(mask_ann['counts'], list): + # uncompressed RLE + rle = maskUtils.frPyObjects(mask_ann, img_h, img_w) + else: + # rle + rle = mask_ann + mask = maskUtils.decode(rle) + return mask + + def _load_masks(self, results): + h, w = results['img_info']['height'], results['img_info']['width'] + gt_masks = results['ann_info']['masks'] + if self.poly2mask: + gt_masks = [self._poly2mask(mask, h, w) for mask in gt_masks] + results['gt_masks'] = gt_masks + results['mask_fields'].append('gt_masks') + return results + + def _load_semantic_seg(self, results): + results['gt_semantic_seg'] = mmcv.imread( + osp.join(results['seg_prefix'], results['ann_info']['seg_map']), + flag='unchanged').squeeze() + results['seg_fields'].append('gt_semantic_seg') + return results + + def __call__(self, results): + if self.with_bbox: + results = self._load_bboxes(results) + if results is None: + return None + if self.with_label: + results = self._load_labels(results) + if self.with_mask: + results = self._load_masks(results) + if self.with_seg: + results = self._load_semantic_seg(results) + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += ('(with_bbox={}, with_label={}, with_mask={},' + ' with_seg={})').format(self.with_bbox, self.with_label, + self.with_mask, self.with_seg) + return repr_str + + +@PIPELINES.register_module +class LoadProposals(object): + + def __init__(self, num_max_proposals=None): + self.num_max_proposals = num_max_proposals + + def __call__(self, results): + proposals = results['proposals'] + if proposals.shape[1] not in (4, 5): + raise AssertionError( + 'proposals should have shapes (n, 4) or (n, 5), ' + 'but found {}'.format(proposals.shape)) + proposals = proposals[:, :4] + + if self.num_max_proposals is not None: + proposals = proposals[:self.num_max_proposals] + + if len(proposals) == 0: + proposals = np.array([[0, 0, 0, 0]], dtype=np.float32) + results['proposals'] = proposals + results['bbox_fields'].append('proposals') + return results + + def __repr__(self): + return self.__class__.__name__ + '(num_max_proposals={})'.format( + self.num_max_proposals) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/test_aug.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/test_aug.py new file mode 100644 index 000000000..b5d218075 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/test_aug.py @@ -0,0 +1,38 @@ +import mmcv + +from ..registry import PIPELINES +from .compose import Compose + + +@PIPELINES.register_module +class MultiScaleFlipAug(object): + + def __init__(self, transforms, img_scale, flip=False): + self.transforms = Compose(transforms) + self.img_scale = img_scale if isinstance(img_scale, + list) else [img_scale] + assert mmcv.is_list_of(self.img_scale, tuple) + self.flip = flip + + def __call__(self, results): + aug_data = [] + flip_aug = [False, True] if self.flip else [False] + for scale in self.img_scale: + for flip in flip_aug: + _results = results.copy() + _results['scale'] = scale + _results['flip'] = flip + data = self.transforms(_results) + aug_data.append(data) + # list of dict to dict of list + aug_data_dict = {key: [] for key in aug_data[0]} + for data in aug_data: + for key, val in data.items(): + aug_data_dict[key].append(val) + return aug_data_dict + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += '(transforms={}, img_scale={}, flip={})'.format( + self.transforms, self.img_scale, self.flip) + return repr_str diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/transforms.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/transforms.py new file mode 100644 index 000000000..58c1c2131 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/transforms.py @@ -0,0 +1,876 @@ +import inspect + +import mmcv +import numpy as np +from numpy import random + +from mmdet.core.evaluation.bbox_overlaps import bbox_overlaps +from ..registry import PIPELINES + +try: + from imagecorruptions import corrupt +except ImportError: + corrupt = None + +try: + import albumentations + from albumentations import Compose +except ImportError: + albumentations = None + Compose = None + + +@PIPELINES.register_module +class Resize(object): + """Resize images & bbox & mask. + + This transform resizes the input image to some scale. Bboxes and masks are + then resized with the same scale factor. If the input dict contains the key + "scale", then the scale in the input dict is used, otherwise the specified + scale in the init method is used. + + `img_scale` can either be a tuple (single-scale) or a list of tuple + (multi-scale). There are 3 multiscale modes: + - `ratio_range` is not None: randomly sample a ratio from the ratio range + and multiply it with the image scale. + - `ratio_range` is None and `multiscale_mode` == "range": randomly sample a + scale from the a range. + - `ratio_range` is None and `multiscale_mode` == "value": randomly sample a + scale from multiple scales. + + Args: + img_scale (tuple or list[tuple]): Images scales for resizing. + multiscale_mode (str): Either "range" or "value". + ratio_range (tuple[float]): (min_ratio, max_ratio) + keep_ratio (bool): Whether to keep the aspect ratio when resizing the + image. + """ + + def __init__(self, + img_scale=None, + multiscale_mode='range', + ratio_range=None, + keep_ratio=True): + if img_scale is None: + self.img_scale = None + else: + if isinstance(img_scale, list): + self.img_scale = img_scale + else: + self.img_scale = [img_scale] + assert mmcv.is_list_of(self.img_scale, tuple) + + if ratio_range is not None: + # mode 1: given a scale and a range of image ratio + assert len(self.img_scale) == 1 + else: + # mode 2: given multiple scales or a range of scales + assert multiscale_mode in ['value', 'range'] + + self.multiscale_mode = multiscale_mode + self.ratio_range = ratio_range + self.keep_ratio = keep_ratio + + @staticmethod + def random_select(img_scales): + assert mmcv.is_list_of(img_scales, tuple) + scale_idx = np.random.randint(len(img_scales)) + img_scale = img_scales[scale_idx] + return img_scale, scale_idx + + @staticmethod + def random_sample(img_scales): + assert mmcv.is_list_of(img_scales, tuple) and len(img_scales) == 2 + img_scale_long = [max(s) for s in img_scales] + img_scale_short = [min(s) for s in img_scales] + long_edge = np.random.randint( + min(img_scale_long), + max(img_scale_long) + 1) + short_edge = np.random.randint( + min(img_scale_short), + max(img_scale_short) + 1) + img_scale = (long_edge, short_edge) + return img_scale, None + + @staticmethod + def random_sample_ratio(img_scale, ratio_range): + assert isinstance(img_scale, tuple) and len(img_scale) == 2 + min_ratio, max_ratio = ratio_range + assert min_ratio <= max_ratio + ratio = np.random.random_sample() * (max_ratio - min_ratio) + min_ratio + scale = int(img_scale[0] * ratio), int(img_scale[1] * ratio) + return scale, None + + def _random_scale(self, results): + if self.ratio_range is not None: + scale, scale_idx = self.random_sample_ratio( + self.img_scale[0], self.ratio_range) + elif len(self.img_scale) == 1: + scale, scale_idx = self.img_scale[0], 0 + elif self.multiscale_mode == 'range': + scale, scale_idx = self.random_sample(self.img_scale) + elif self.multiscale_mode == 'value': + scale, scale_idx = self.random_select(self.img_scale) + else: + raise NotImplementedError + + results['scale'] = scale + results['scale_idx'] = scale_idx + + def _resize_img(self, results): + if self.keep_ratio: + img, scale_factor = mmcv.imrescale( + results['img'], results['scale'], return_scale=True) + else: + img, w_scale, h_scale = mmcv.imresize( + results['img'], results['scale'], return_scale=True) + scale_factor = np.array([w_scale, h_scale, w_scale, h_scale], + dtype=np.float32) + results['img'] = img + results['img_shape'] = img.shape + results['pad_shape'] = img.shape # in case that there is no padding + results['scale_factor'] = scale_factor + results['keep_ratio'] = self.keep_ratio + + def _resize_bboxes(self, results): + img_shape = results['img_shape'] + for key in results.get('bbox_fields', []): + bboxes = results[key] * results['scale_factor'] + bboxes[:, 0::2] = np.clip(bboxes[:, 0::2], 0, img_shape[1] - 1) + bboxes[:, 1::2] = np.clip(bboxes[:, 1::2], 0, img_shape[0] - 1) + results[key] = bboxes + + def _resize_masks(self, results): + for key in results.get('mask_fields', []): + if results[key] is None: + continue + if self.keep_ratio: + masks = [ + mmcv.imrescale( + mask, results['scale_factor'], interpolation='nearest') + for mask in results[key] + ] + else: + mask_size = (results['img_shape'][1], results['img_shape'][0]) + masks = [ + mmcv.imresize(mask, mask_size, interpolation='nearest') + for mask in results[key] + ] + results[key] = np.stack(masks) + + def _resize_seg(self, results): + for key in results.get('seg_fields', []): + if self.keep_ratio: + gt_seg = mmcv.imrescale( + results[key], results['scale'], interpolation='nearest') + else: + gt_seg = mmcv.imresize( + results[key], results['scale'], interpolation='nearest') + results['gt_semantic_seg'] = gt_seg + + def __call__(self, results): + if 'scale' not in results: + self._random_scale(results) + self._resize_img(results) + self._resize_bboxes(results) + self._resize_masks(results) + self._resize_seg(results) + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += ('(img_scale={}, multiscale_mode={}, ratio_range={}, ' + 'keep_ratio={})').format(self.img_scale, + self.multiscale_mode, + self.ratio_range, + self.keep_ratio) + return repr_str + + +@PIPELINES.register_module +class RandomFlip(object): + """Flip the image & bbox & mask. + + If the input dict contains the key "flip", then the flag will be used, + otherwise it will be randomly decided by a ratio specified in the init + method. + + Args: + flip_ratio (float, optional): The flipping probability. + """ + + def __init__(self, flip_ratio=None, direction='horizontal'): + self.flip_ratio = flip_ratio + self.direction = direction + if flip_ratio is not None: + assert flip_ratio >= 0 and flip_ratio <= 1 + assert direction in ['horizontal', 'vertical'] + + def bbox_flip(self, bboxes, img_shape, direction): + """Flip bboxes horizontally. + + Args: + bboxes(ndarray): shape (..., 4*k) + img_shape(tuple): (height, width) + """ + assert bboxes.shape[-1] % 4 == 0 + flipped = bboxes.copy() + if direction == 'horizontal': + w = img_shape[1] + flipped[..., 0::4] = w - bboxes[..., 2::4] - 1 + flipped[..., 2::4] = w - bboxes[..., 0::4] - 1 + elif direction == 'vertical': + h = img_shape[0] + flipped[..., 1::4] = h - bboxes[..., 3::4] - 1 + flipped[..., 3::4] = h - bboxes[..., 1::4] - 1 + else: + raise ValueError( + 'Invalid flipping direction "{}"'.format(direction)) + return flipped + + def __call__(self, results): + if 'flip' not in results: + flip = True if np.random.rand() < self.flip_ratio else False + results['flip'] = flip + if 'flip_direction' not in results: + results['flip_direction'] = self.direction + if results['flip']: + # flip image + results['img'] = mmcv.imflip( + results['img'], direction=results['flip_direction']) + # flip bboxes + for key in results.get('bbox_fields', []): + results[key] = self.bbox_flip(results[key], + results['img_shape'], + results['flip_direction']) + # flip masks + for key in results.get('mask_fields', []): + results[key] = np.stack([ + mmcv.imflip(mask, direction=results['flip_direction']) + for mask in results[key] + ]) + + # flip segs + for key in results.get('seg_fields', []): + results[key] = mmcv.imflip( + results[key], direction=results['flip_direction']) + return results + + def __repr__(self): + return self.__class__.__name__ + '(flip_ratio={})'.format( + self.flip_ratio) + + +@PIPELINES.register_module +class Pad(object): + """Pad the image & mask. + + There are two padding modes: (1) pad to a fixed size and (2) pad to the + minimum size that is divisible by some number. + + Args: + size (tuple, optional): Fixed padding size. + size_divisor (int, optional): The divisor of padded size. + pad_val (float, optional): Padding value, 0 by default. + """ + + def __init__(self, size=None, size_divisor=None, pad_val=0): + self.size = size + self.size_divisor = size_divisor + self.pad_val = pad_val + # only one of size and size_divisor should be valid + assert size is not None or size_divisor is not None + assert size is None or size_divisor is None + + def _pad_img(self, results): + if self.size is not None: + padded_img = mmcv.impad(results['img'], self.size) + elif self.size_divisor is not None: + padded_img = mmcv.impad_to_multiple( + results['img'], self.size_divisor, pad_val=self.pad_val) + results['img'] = padded_img + results['pad_shape'] = padded_img.shape + results['pad_fixed_size'] = self.size + results['pad_size_divisor'] = self.size_divisor + + def _pad_masks(self, results): + pad_shape = results['pad_shape'][:2] + for key in results.get('mask_fields', []): + padded_masks = [ + mmcv.impad(mask, pad_shape, pad_val=self.pad_val) + for mask in results[key] + ] + if padded_masks: + results[key] = np.stack(padded_masks, axis=0) + else: + results[key] = np.empty((0, ) + pad_shape, dtype=np.uint8) + + def _pad_seg(self, results): + for key in results.get('seg_fields', []): + results[key] = mmcv.impad(results[key], results['pad_shape'][:2]) + + def __call__(self, results): + self._pad_img(results) + self._pad_masks(results) + self._pad_seg(results) + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += '(size={}, size_divisor={}, pad_val={})'.format( + self.size, self.size_divisor, self.pad_val) + return repr_str + + +@PIPELINES.register_module +class Normalize(object): + """Normalize the image. + + Args: + mean (sequence): Mean values of 3 channels. + std (sequence): Std values of 3 channels. + to_rgb (bool): Whether to convert the image from BGR to RGB, + default is true. + """ + + def __init__(self, mean, std, to_rgb=True): + self.mean = np.array(mean, dtype=np.float32) + self.std = np.array(std, dtype=np.float32) + self.to_rgb = to_rgb + + def __call__(self, results): + results['img'] = mmcv.imnormalize(results['img'], self.mean, self.std, + self.to_rgb) + results['img_norm_cfg'] = dict( + mean=self.mean, std=self.std, to_rgb=self.to_rgb) + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += '(mean={}, std={}, to_rgb={})'.format( + self.mean, self.std, self.to_rgb) + return repr_str + + +@PIPELINES.register_module +class RandomCrop(object): + """Random crop the image & bboxes & masks. + + Args: + crop_size (tuple): Expected size after cropping, (h, w). + """ + + def __init__(self, crop_size): + self.crop_size = crop_size + + def __call__(self, results): + img = results['img'] + margin_h = max(img.shape[0] - self.crop_size[0], 0) + margin_w = max(img.shape[1] - self.crop_size[1], 0) + offset_h = np.random.randint(0, margin_h + 1) + offset_w = np.random.randint(0, margin_w + 1) + crop_y1, crop_y2 = offset_h, offset_h + self.crop_size[0] + crop_x1, crop_x2 = offset_w, offset_w + self.crop_size[1] + + # crop the image + img = img[crop_y1:crop_y2, crop_x1:crop_x2, ...] + img_shape = img.shape + results['img'] = img + results['img_shape'] = img_shape + + # crop bboxes accordingly and clip to the image boundary + for key in results.get('bbox_fields', []): + bbox_offset = np.array([offset_w, offset_h, offset_w, offset_h], + dtype=np.float32) + bboxes = results[key] - bbox_offset + bboxes[:, 0::2] = np.clip(bboxes[:, 0::2], 0, img_shape[1] - 1) + bboxes[:, 1::2] = np.clip(bboxes[:, 1::2], 0, img_shape[0] - 1) + results[key] = bboxes + + # crop semantic seg + for key in results.get('seg_fields', []): + results[key] = results[key][crop_y1:crop_y2, crop_x1:crop_x2] + + # filter out the gt bboxes that are completely cropped + if 'gt_bboxes' in results: + gt_bboxes = results['gt_bboxes'] + valid_inds = (gt_bboxes[:, 2] > gt_bboxes[:, 0]) & ( + gt_bboxes[:, 3] > gt_bboxes[:, 1]) + # if no gt bbox remains after cropping, just skip this image + if not np.any(valid_inds): + return None + results['gt_bboxes'] = gt_bboxes[valid_inds, :] + if 'gt_labels' in results: + results['gt_labels'] = results['gt_labels'][valid_inds] + + # filter and crop the masks + if 'gt_masks' in results: + valid_gt_masks = [] + for i in np.where(valid_inds)[0]: + gt_mask = results['gt_masks'][i][crop_y1:crop_y2, + crop_x1:crop_x2] + valid_gt_masks.append(gt_mask) + results['gt_masks'] = np.stack(valid_gt_masks) + + return results + + def __repr__(self): + return self.__class__.__name__ + '(crop_size={})'.format( + self.crop_size) + + +@PIPELINES.register_module +class SegRescale(object): + """Rescale semantic segmentation maps. + + Args: + scale_factor (float): The scale factor of the final output. + """ + + def __init__(self, scale_factor=1): + self.scale_factor = scale_factor + + def __call__(self, results): + for key in results.get('seg_fields', []): + if self.scale_factor != 1: + results[key] = mmcv.imrescale( + results[key], self.scale_factor, interpolation='nearest') + return results + + def __repr__(self): + return self.__class__.__name__ + '(scale_factor={})'.format( + self.scale_factor) + + +@PIPELINES.register_module +class PhotoMetricDistortion(object): + """Apply photometric distortion to image sequentially, every transformation + is applied with a probability of 0.5. The position of random contrast is in + second or second to last. + + 1. random brightness + 2. random contrast (mode 0) + 3. convert color from BGR to HSV + 4. random saturation + 5. random hue + 6. convert color from HSV to BGR + 7. random contrast (mode 1) + 8. randomly swap channels + + Args: + brightness_delta (int): delta of brightness. + contrast_range (tuple): range of contrast. + saturation_range (tuple): range of saturation. + hue_delta (int): delta of hue. + """ + + def __init__(self, + brightness_delta=32, + contrast_range=(0.5, 1.5), + saturation_range=(0.5, 1.5), + hue_delta=18): + self.brightness_delta = brightness_delta + self.contrast_lower, self.contrast_upper = contrast_range + self.saturation_lower, self.saturation_upper = saturation_range + self.hue_delta = hue_delta + + def __call__(self, results): + img = results['img'] + # random brightness + if random.randint(2): + delta = random.uniform(-self.brightness_delta, + self.brightness_delta) + img += delta + + # mode == 0 --> do random contrast first + # mode == 1 --> do random contrast last + mode = random.randint(2) + if mode == 1: + if random.randint(2): + alpha = random.uniform(self.contrast_lower, + self.contrast_upper) + img *= alpha + + # convert color from BGR to HSV + img = mmcv.bgr2hsv(img) + + # random saturation + if random.randint(2): + img[..., 1] *= random.uniform(self.saturation_lower, + self.saturation_upper) + + # random hue + if random.randint(2): + img[..., 0] += random.uniform(-self.hue_delta, self.hue_delta) + img[..., 0][img[..., 0] > 360] -= 360 + img[..., 0][img[..., 0] < 0] += 360 + + # convert color from HSV to BGR + img = mmcv.hsv2bgr(img) + + # random contrast + if mode == 0: + if random.randint(2): + alpha = random.uniform(self.contrast_lower, + self.contrast_upper) + img *= alpha + + # randomly swap channels + if random.randint(2): + img = img[..., random.permutation(3)] + + results['img'] = img + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += ('(brightness_delta={}, contrast_range={}, ' + 'saturation_range={}, hue_delta={})').format( + self.brightness_delta, self.contrast_range, + self.saturation_range, self.hue_delta) + return repr_str + + +@PIPELINES.register_module +class Expand(object): + """Random expand the image & bboxes. + + Randomly place the original image on a canvas of 'ratio' x original image + size filled with mean values. The ratio is in the range of ratio_range. + + Args: + mean (tuple): mean value of dataset. + to_rgb (bool): if need to convert the order of mean to align with RGB. + ratio_range (tuple): range of expand ratio. + prob (float): probability of applying this transformation + """ + + def __init__(self, + mean=(0, 0, 0), + to_rgb=True, + ratio_range=(1, 4), + seg_ignore_label=None, + prob=0.5): + self.to_rgb = to_rgb + self.ratio_range = ratio_range + if to_rgb: + self.mean = mean[::-1] + else: + self.mean = mean + self.min_ratio, self.max_ratio = ratio_range + self.seg_ignore_label = seg_ignore_label + self.prob = prob + + def __call__(self, results): + if random.uniform(0, 1) > self.prob: + return results + + img, boxes = [results[k] for k in ('img', 'gt_bboxes')] + + h, w, c = img.shape + ratio = random.uniform(self.min_ratio, self.max_ratio) + expand_img = np.full((int(h * ratio), int(w * ratio), c), + self.mean).astype(img.dtype) + left = int(random.uniform(0, w * ratio - w)) + top = int(random.uniform(0, h * ratio - h)) + expand_img[top:top + h, left:left + w] = img + boxes = boxes + np.tile((left, top), 2).astype(boxes.dtype) + + results['img'] = expand_img + results['gt_bboxes'] = boxes + + if 'gt_masks' in results: + expand_gt_masks = [] + for mask in results['gt_masks']: + expand_mask = np.full((int(h * ratio), int(w * ratio)), + 0).astype(mask.dtype) + expand_mask[top:top + h, left:left + w] = mask + expand_gt_masks.append(expand_mask) + results['gt_masks'] = np.stack(expand_gt_masks) + + # not tested + if 'gt_semantic_seg' in results: + assert self.seg_ignore_label is not None + gt_seg = results['gt_semantic_seg'] + expand_gt_seg = np.full((int(h * ratio), int(w * ratio)), + self.seg_ignore_label).astype(gt_seg.dtype) + expand_gt_seg[top:top + h, left:left + w] = gt_seg + results['gt_semantic_seg'] = expand_gt_seg + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += '(mean={}, to_rgb={}, ratio_range={}, ' \ + 'seg_ignore_label={})'.format( + self.mean, self.to_rgb, self.ratio_range, + self.seg_ignore_label) + return repr_str + + +@PIPELINES.register_module +class MinIoURandomCrop(object): + """Random crop the image & bboxes, the cropped patches have minimum IoU + requirement with original image & bboxes, the IoU threshold is randomly + selected from min_ious. + + Args: + min_ious (tuple): minimum IoU threshold for all intersections with + bounding boxes + min_crop_size (float): minimum crop's size (i.e. h,w := a*h, a*w, + where a >= min_crop_size). + """ + + def __init__(self, min_ious=(0.1, 0.3, 0.5, 0.7, 0.9), min_crop_size=0.3): + # 1: return ori img + self.sample_mode = (1, *min_ious, 0) + self.min_crop_size = min_crop_size + + def __call__(self, results): + img, boxes, labels = [ + results[k] for k in ('img', 'gt_bboxes', 'gt_labels') + ] + h, w, c = img.shape + while True: + mode = random.choice(self.sample_mode) + if mode == 1: + return results + + min_iou = mode + for i in range(50): + new_w = random.uniform(self.min_crop_size * w, w) + new_h = random.uniform(self.min_crop_size * h, h) + + # h / w in [0.5, 2] + if new_h / new_w < 0.5 or new_h / new_w > 2: + continue + + left = random.uniform(w - new_w) + top = random.uniform(h - new_h) + + patch = np.array( + (int(left), int(top), int(left + new_w), int(top + new_h))) + overlaps = bbox_overlaps( + patch.reshape(-1, 4), boxes.reshape(-1, 4)).reshape(-1) + if overlaps.min() < min_iou: + continue + + # center of boxes should inside the crop img + center = (boxes[:, :2] + boxes[:, 2:]) / 2 + mask = ((center[:, 0] > patch[0]) * (center[:, 1] > patch[1]) * + (center[:, 0] < patch[2]) * (center[:, 1] < patch[3])) + if not mask.any(): + continue + boxes = boxes[mask] + labels = labels[mask] + + # adjust boxes + img = img[patch[1]:patch[3], patch[0]:patch[2]] + boxes[:, 2:] = boxes[:, 2:].clip(max=patch[2:]) + boxes[:, :2] = boxes[:, :2].clip(min=patch[:2]) + boxes -= np.tile(patch[:2], 2) + + results['img'] = img + results['gt_bboxes'] = boxes + results['gt_labels'] = labels + + if 'gt_masks' in results: + valid_masks = [ + results['gt_masks'][i] for i in range(len(mask)) + if mask[i] + ] + results['gt_masks'] = np.stack([ + gt_mask[patch[1]:patch[3], patch[0]:patch[2]] + for gt_mask in valid_masks + ]) + + # not tested + if 'gt_semantic_seg' in results: + results['gt_semantic_seg'] = results['gt_semantic_seg'][ + patch[1]:patch[3], patch[0]:patch[2]] + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += '(min_ious={}, min_crop_size={})'.format( + self.min_ious, self.min_crop_size) + return repr_str + + +@PIPELINES.register_module +class Corrupt(object): + + def __init__(self, corruption, severity=1): + self.corruption = corruption + self.severity = severity + + def __call__(self, results): + if corrupt is None: + raise RuntimeError('imagecorruptions is not installed') + results['img'] = corrupt( + results['img'].astype(np.uint8), + corruption_name=self.corruption, + severity=self.severity) + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += '(corruption={}, severity={})'.format( + self.corruption, self.severity) + return repr_str + + +@PIPELINES.register_module +class Albu(object): + + def __init__(self, + transforms, + bbox_params=None, + keymap=None, + update_pad_shape=False, + skip_img_without_anno=False): + """ + Adds custom transformations from Albumentations lib. + Please, visit `https://albumentations.readthedocs.io` + to get more information. + + transforms (list): list of albu transformations + bbox_params (dict): bbox_params for albumentation `Compose` + keymap (dict): contains {'input key':'albumentation-style key'} + skip_img_without_anno (bool): whether to skip the image + if no ann left after aug + """ + if Compose is None: + raise RuntimeError('albumentations is not installed') + + self.transforms = transforms + self.filter_lost_elements = False + self.update_pad_shape = update_pad_shape + self.skip_img_without_anno = skip_img_without_anno + + # A simple workaround to remove masks without boxes + if (isinstance(bbox_params, dict) and 'label_fields' in bbox_params + and 'filter_lost_elements' in bbox_params): + self.filter_lost_elements = True + self.origin_label_fields = bbox_params['label_fields'] + bbox_params['label_fields'] = ['idx_mapper'] + del bbox_params['filter_lost_elements'] + + self.bbox_params = ( + self.albu_builder(bbox_params) if bbox_params else None) + self.aug = Compose([self.albu_builder(t) for t in self.transforms], + bbox_params=self.bbox_params) + + if not keymap: + self.keymap_to_albu = { + 'img': 'image', + 'gt_masks': 'masks', + 'gt_bboxes': 'bboxes' + } + else: + self.keymap_to_albu = keymap + self.keymap_back = {v: k for k, v in self.keymap_to_albu.items()} + + def albu_builder(self, cfg): + """Import a module from albumentations. + Inherits some of `build_from_cfg` logic. + + Args: + cfg (dict): Config dict. It should at least contain the key "type". + Returns: + obj: The constructed object. + """ + assert isinstance(cfg, dict) and "type" in cfg + args = cfg.copy() + + obj_type = args.pop("type") + if mmcv.is_str(obj_type): + if albumentations is None: + raise RuntimeError('albumentations is not installed') + obj_cls = getattr(albumentations, obj_type) + elif inspect.isclass(obj_type): + obj_cls = obj_type + else: + raise TypeError( + 'type must be a str or valid type, but got {}'.format( + type(obj_type))) + + if 'transforms' in args: + args['transforms'] = [ + self.albu_builder(transform) + for transform in args['transforms'] + ] + + return obj_cls(**args) + + @staticmethod + def mapper(d, keymap): + """ + Dictionary mapper. + Renames keys according to keymap provided. + + Args: + d (dict): old dict + keymap (dict): {'old_key':'new_key'} + Returns: + dict: new dict. + """ + updated_dict = {} + for k, v in zip(d.keys(), d.values()): + new_k = keymap.get(k, k) + updated_dict[new_k] = d[k] + return updated_dict + + def __call__(self, results): + # dict to albumentations format + results = self.mapper(results, self.keymap_to_albu) + + if 'bboxes' in results: + # to list of boxes + if isinstance(results['bboxes'], np.ndarray): + results['bboxes'] = [x for x in results['bboxes']] + # add pseudo-field for filtration + if self.filter_lost_elements: + results['idx_mapper'] = np.arange(len(results['bboxes'])) + + results = self.aug(**results) + + if 'bboxes' in results: + if isinstance(results['bboxes'], list): + results['bboxes'] = np.array( + results['bboxes'], dtype=np.float32) + results['bboxes'] = results['bboxes'].reshape(-1, 4) + + # filter label_fields + if self.filter_lost_elements: + + results['idx_mapper'] = np.arange(len(results['bboxes'])) + + for label in self.origin_label_fields: + results[label] = np.array( + [results[label][i] for i in results['idx_mapper']]) + if 'masks' in results: + results['masks'] = np.array( + [results['masks'][i] for i in results['idx_mapper']]) + + if (not len(results['idx_mapper']) + and self.skip_img_without_anno): + return None + + if 'gt_labels' in results: + if isinstance(results['gt_labels'], list): + results['gt_labels'] = np.array(results['gt_labels']) + results['gt_labels'] = results['gt_labels'].astype(np.int64) + + # back to the original format + results = self.mapper(results, self.keymap_back) + + # update final shape + if self.update_pad_shape: + results['pad_shape'] = results['img'].shape + + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += '(transformations={})'.format(self.transformations) + return repr_str diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/registry.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/registry.py new file mode 100644 index 000000000..974a4fbb7 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/registry.py @@ -0,0 +1,4 @@ +from mmdet.utils import Registry + +DATASETS = Registry('dataset') +PIPELINES = Registry('pipeline') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/voc.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/voc.py new file mode 100644 index 000000000..77bffe355 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/voc.py @@ -0,0 +1,20 @@ +from .registry import DATASETS +from .xml_style import XMLDataset + + +@DATASETS.register_module +class VOCDataset(XMLDataset): + + CLASSES = ('aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', + 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', + 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', + 'tvmonitor') + + def __init__(self, **kwargs): + super(VOCDataset, self).__init__(**kwargs) + if 'VOC2007' in self.img_prefix: + self.year = 2007 + elif 'VOC2012' in self.img_prefix: + self.year = 2012 + else: + raise ValueError('Cannot infer dataset year from img_prefix') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/wider_face.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/wider_face.py new file mode 100644 index 000000000..b83e3d664 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/wider_face.py @@ -0,0 +1,42 @@ +import os.path as osp +import xml.etree.ElementTree as ET + +import mmcv + +from .registry import DATASETS +from .xml_style import XMLDataset + + +@DATASETS.register_module +class WIDERFaceDataset(XMLDataset): + """ + Reader for the WIDER Face dataset in PASCAL VOC format. + Conversion scripts can be found in + https://github.com/sovrasov/wider-face-pascal-voc-annotations + """ + CLASSES = ('face', ) + + def __init__(self, **kwargs): + super(WIDERFaceDataset, self).__init__(**kwargs) + + def load_annotations(self, ann_file): + img_infos = [] + img_ids = mmcv.list_from_file(ann_file) + for img_id in img_ids: + filename = '{}.jpg'.format(img_id) + xml_path = osp.join(self.img_prefix, 'Annotations', + '{}.xml'.format(img_id)) + tree = ET.parse(xml_path) + root = tree.getroot() + size = root.find('size') + width = int(size.find('width').text) + height = int(size.find('height').text) + folder = root.find('folder').text + img_infos.append( + dict( + id=img_id, + filename=osp.join(folder, filename), + width=width, + height=height)) + + return img_infos diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/xml_style.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/xml_style.py new file mode 100644 index 000000000..39d57042e --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/xml_style.py @@ -0,0 +1,86 @@ +import os.path as osp +import xml.etree.ElementTree as ET + +import mmcv +import numpy as np + +from .custom import CustomDataset +from .registry import DATASETS + + +@DATASETS.register_module +class XMLDataset(CustomDataset): + + def __init__(self, min_size=None, **kwargs): + super(XMLDataset, self).__init__(**kwargs) + self.cat2label = {cat: i + 1 for i, cat in enumerate(self.CLASSES)} + self.min_size = min_size + + def load_annotations(self, ann_file): + img_infos = [] + img_ids = mmcv.list_from_file(ann_file) + for img_id in img_ids: + filename = 'JPEGImages/{}.jpg'.format(img_id) + xml_path = osp.join(self.img_prefix, 'Annotations', + '{}.xml'.format(img_id)) + tree = ET.parse(xml_path) + root = tree.getroot() + size = root.find('size') + width = int(size.find('width').text) + height = int(size.find('height').text) + img_infos.append( + dict(id=img_id, filename=filename, width=width, height=height)) + return img_infos + + def get_ann_info(self, idx): + img_id = self.img_infos[idx]['id'] + xml_path = osp.join(self.img_prefix, 'Annotations', + '{}.xml'.format(img_id)) + tree = ET.parse(xml_path) + root = tree.getroot() + bboxes = [] + labels = [] + bboxes_ignore = [] + labels_ignore = [] + for obj in root.findall('object'): + name = obj.find('name').text + label = self.cat2label[name] + difficult = int(obj.find('difficult').text) + bnd_box = obj.find('bndbox') + bbox = [ + int(bnd_box.find('xmin').text), + int(bnd_box.find('ymin').text), + int(bnd_box.find('xmax').text), + int(bnd_box.find('ymax').text) + ] + ignore = False + if self.min_size: + assert not self.test_mode + w = bbox[2] - bbox[0] + h = bbox[3] - bbox[1] + if w < self.min_size or h < self.min_size: + ignore = True + if difficult or ignore: + bboxes_ignore.append(bbox) + labels_ignore.append(label) + else: + bboxes.append(bbox) + labels.append(label) + if not bboxes: + bboxes = np.zeros((0, 4)) + labels = np.zeros((0, )) + else: + bboxes = np.array(bboxes, ndmin=2) - 1 + labels = np.array(labels) + if not bboxes_ignore: + bboxes_ignore = np.zeros((0, 4)) + labels_ignore = np.zeros((0, )) + else: + bboxes_ignore = np.array(bboxes_ignore, ndmin=2) - 1 + labels_ignore = np.array(labels_ignore) + ann = dict( + bboxes=bboxes.astype(np.float32), + labels=labels.astype(np.int64), + bboxes_ignore=bboxes_ignore.astype(np.float32), + labels_ignore=labels_ignore.astype(np.int64)) + return ann diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/__init__.py new file mode 100644 index 000000000..35f0a09e3 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/__init__.py @@ -0,0 +1,19 @@ +from .anchor_heads import * # noqa: F401,F403 +from .backbones import * # noqa: F401,F403 +from .bbox_heads import * # noqa: F401,F403 +from .builder import (build_backbone, build_detector, build_head, build_loss, + build_neck, build_roi_extractor, build_shared_head) +from .detectors import * # noqa: F401,F403 +from .losses import * # noqa: F401,F403 +from .mask_heads import * # noqa: F401,F403 +from .necks import * # noqa: F401,F403 +from .registry import (BACKBONES, DETECTORS, HEADS, LOSSES, NECKS, + ROI_EXTRACTORS, SHARED_HEADS) +from .roi_extractors import * # noqa: F401,F403 +from .shared_heads import * # noqa: F401,F403 + +__all__ = [ + 'BACKBONES', 'NECKS', 'ROI_EXTRACTORS', 'SHARED_HEADS', 'HEADS', 'LOSSES', + 'DETECTORS', 'build_backbone', 'build_neck', 'build_roi_extractor', + 'build_shared_head', 'build_head', 'build_loss', 'build_detector' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/__init__.py new file mode 100644 index 000000000..de1d7ef01 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/__init__.py @@ -0,0 +1,25 @@ +from .anchor_head import AnchorHead +from .atss_head import ATSSHead +from .fcos_head import FCOSHead +from .fovea_head import FoveaHead +from .free_anchor_retina_head import FreeAnchorRetinaHead +from .ga_retina_head import GARetinaHead +from .ga_rpn_head import GARPNHead +from .guided_anchor_head import FeatureAdaption, GuidedAnchorHead +from .reppoints_head import RepPointsHead +from .retina_head import RetinaHead +from .retina_sepbn_head import RetinaSepBNHead +from .rpn_head import RPNHead +from .ssd_head import SSDHead +from .solo_head import SOLOHead +from .solov2_head import SOLOv2Head +from .solov2_light_head import SOLOv2LightHead +from .decoupled_solo_head import DecoupledSOLOHead +from .decoupled_solo_light_head import DecoupledSOLOLightHead + +__all__ = [ + 'AnchorHead', 'GuidedAnchorHead', 'FeatureAdaption', 'RPNHead', + 'GARPNHead', 'RetinaHead', 'RetinaSepBNHead', 'GARetinaHead', 'SSDHead', + 'FCOSHead', 'RepPointsHead', 'FoveaHead', 'FreeAnchorRetinaHead', + 'ATSSHead', 'SOLOHead', 'SOLOv2Head', 'SOLOv2LightHead', 'DecoupledSOLOHead', 'DecoupledSOLOLightHead' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/anchor_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/anchor_head.py new file mode 100644 index 000000000..0fdc0aade --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/anchor_head.py @@ -0,0 +1,330 @@ +from __future__ import division + +import numpy as np +import torch +import torch.nn as nn +from mmcv.cnn import normal_init + +from mmdet.core import (AnchorGenerator, anchor_target, delta2bbox, force_fp32, + multi_apply, multiclass_nms) +from ..builder import build_loss +from ..registry import HEADS + + +@HEADS.register_module +class AnchorHead(nn.Module): + """Anchor-based head (RPN, RetinaNet, SSD, etc.). + + Args: + num_classes (int): Number of categories including the background + category. + in_channels (int): Number of channels in the input feature map. + feat_channels (int): Number of hidden channels. Used in child classes. + anchor_scales (Iterable): Anchor scales. + anchor_ratios (Iterable): Anchor aspect ratios. + anchor_strides (Iterable): Anchor strides. + anchor_base_sizes (Iterable): Anchor base sizes. + target_means (Iterable): Mean values of regression targets. + target_stds (Iterable): Std values of regression targets. + loss_cls (dict): Config of classification loss. + loss_bbox (dict): Config of localization loss. + """ # noqa: W605 + + def __init__(self, + num_classes, + in_channels, + feat_channels=256, + anchor_scales=[8, 16, 32], + anchor_ratios=[0.5, 1.0, 2.0], + anchor_strides=[4, 8, 16, 32, 64], + anchor_base_sizes=None, + target_means=(.0, .0, .0, .0), + target_stds=(1.0, 1.0, 1.0, 1.0), + loss_cls=dict( + type='CrossEntropyLoss', + use_sigmoid=True, + loss_weight=1.0), + loss_bbox=dict( + type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0)): + super(AnchorHead, self).__init__() + self.in_channels = in_channels + self.num_classes = num_classes + self.feat_channels = feat_channels + self.anchor_scales = anchor_scales + self.anchor_ratios = anchor_ratios + self.anchor_strides = anchor_strides + self.anchor_base_sizes = list( + anchor_strides) if anchor_base_sizes is None else anchor_base_sizes + self.target_means = target_means + self.target_stds = target_stds + + self.use_sigmoid_cls = loss_cls.get('use_sigmoid', False) + self.sampling = loss_cls['type'] not in ['FocalLoss', 'GHMC'] + if self.use_sigmoid_cls: + self.cls_out_channels = num_classes - 1 + else: + self.cls_out_channels = num_classes + + if self.cls_out_channels <= 0: + raise ValueError('num_classes={} is too small'.format(num_classes)) + + self.loss_cls = build_loss(loss_cls) + self.loss_bbox = build_loss(loss_bbox) + self.fp16_enabled = False + + self.anchor_generators = [] + for anchor_base in self.anchor_base_sizes: + self.anchor_generators.append( + AnchorGenerator(anchor_base, anchor_scales, anchor_ratios)) + + self.num_anchors = len(self.anchor_ratios) * len(self.anchor_scales) + self._init_layers() + + def _init_layers(self): + self.conv_cls = nn.Conv2d(self.in_channels, + self.num_anchors * self.cls_out_channels, 1) + self.conv_reg = nn.Conv2d(self.in_channels, self.num_anchors * 4, 1) + + def init_weights(self): + normal_init(self.conv_cls, std=0.01) + normal_init(self.conv_reg, std=0.01) + + def forward_single(self, x): + cls_score = self.conv_cls(x) + bbox_pred = self.conv_reg(x) + return cls_score, bbox_pred + + def forward(self, feats): + return multi_apply(self.forward_single, feats) + + def get_anchors(self, featmap_sizes, img_metas, device='cuda'): + """Get anchors according to feature map sizes. + + Args: + featmap_sizes (list[tuple]): Multi-level feature map sizes. + img_metas (list[dict]): Image meta info. + device (torch.device | str): device for returned tensors + + Returns: + tuple: anchors of each image, valid flags of each image + """ + num_imgs = len(img_metas) + num_levels = len(featmap_sizes) + + # since feature map sizes of all images are the same, we only compute + # anchors for one time + multi_level_anchors = [] + for i in range(num_levels): + anchors = self.anchor_generators[i].grid_anchors( + featmap_sizes[i], self.anchor_strides[i], device=device) + multi_level_anchors.append(anchors) + anchor_list = [multi_level_anchors for _ in range(num_imgs)] + + # for each image, we compute valid flags of multi level anchors + valid_flag_list = [] + for img_id, img_meta in enumerate(img_metas): + multi_level_flags = [] + for i in range(num_levels): + anchor_stride = self.anchor_strides[i] + feat_h, feat_w = featmap_sizes[i] + h, w = img_meta['pad_shape'][:2] + valid_feat_h = min(int(np.ceil(h / anchor_stride)), feat_h) + valid_feat_w = min(int(np.ceil(w / anchor_stride)), feat_w) + flags = self.anchor_generators[i].valid_flags( + (feat_h, feat_w), (valid_feat_h, valid_feat_w), + device=device) + multi_level_flags.append(flags) + valid_flag_list.append(multi_level_flags) + + return anchor_list, valid_flag_list + + def loss_single(self, cls_score, bbox_pred, labels, label_weights, + bbox_targets, bbox_weights, num_total_samples, cfg): + # classification loss + labels = labels.reshape(-1) + label_weights = label_weights.reshape(-1) + cls_score = cls_score.permute(0, 2, 3, + 1).reshape(-1, self.cls_out_channels) + loss_cls = self.loss_cls( + cls_score, labels, label_weights, avg_factor=num_total_samples) + # regression loss + bbox_targets = bbox_targets.reshape(-1, 4) + bbox_weights = bbox_weights.reshape(-1, 4) + bbox_pred = bbox_pred.permute(0, 2, 3, 1).reshape(-1, 4) + loss_bbox = self.loss_bbox( + bbox_pred, + bbox_targets, + bbox_weights, + avg_factor=num_total_samples) + return loss_cls, loss_bbox + + @force_fp32(apply_to=('cls_scores', 'bbox_preds')) + def loss(self, + cls_scores, + bbox_preds, + gt_bboxes, + gt_labels, + img_metas, + cfg, + gt_bboxes_ignore=None): + featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] + assert len(featmap_sizes) == len(self.anchor_generators) + + device = cls_scores[0].device + + anchor_list, valid_flag_list = self.get_anchors( + featmap_sizes, img_metas, device=device) + label_channels = self.cls_out_channels if self.use_sigmoid_cls else 1 + cls_reg_targets = anchor_target( + anchor_list, + valid_flag_list, + gt_bboxes, + img_metas, + self.target_means, + self.target_stds, + cfg, + gt_bboxes_ignore_list=gt_bboxes_ignore, + gt_labels_list=gt_labels, + label_channels=label_channels, + sampling=self.sampling) + if cls_reg_targets is None: + return None + (labels_list, label_weights_list, bbox_targets_list, bbox_weights_list, + num_total_pos, num_total_neg) = cls_reg_targets + num_total_samples = ( + num_total_pos + num_total_neg if self.sampling else num_total_pos) + losses_cls, losses_bbox = multi_apply( + self.loss_single, + cls_scores, + bbox_preds, + labels_list, + label_weights_list, + bbox_targets_list, + bbox_weights_list, + num_total_samples=num_total_samples, + cfg=cfg) + return dict(loss_cls=losses_cls, loss_bbox=losses_bbox) + + @force_fp32(apply_to=('cls_scores', 'bbox_preds')) + def get_bboxes(self, + cls_scores, + bbox_preds, + img_metas, + cfg, + rescale=False): + """ + Transform network output for a batch into labeled boxes. + + Args: + cls_scores (list[Tensor]): Box scores for each scale level + Has shape (N, num_anchors * num_classes, H, W) + bbox_preds (list[Tensor]): Box energies / deltas for each scale + level with shape (N, num_anchors * 4, H, W) + img_metas (list[dict]): size / scale info for each image + cfg (mmcv.Config): test / postprocessing configuration + rescale (bool): if True, return boxes in original image space + + Returns: + list[tuple[Tensor, Tensor]]: each item in result_list is 2-tuple. + The first item is an (n, 5) tensor, where the first 4 columns + are bounding box positions (tl_x, tl_y, br_x, br_y) and the + 5-th column is a score between 0 and 1. The second item is a + (n,) tensor where each item is the class index of the + corresponding box. + + Example: + >>> import mmcv + >>> self = AnchorHead(num_classes=9, in_channels=1) + >>> img_metas = [{'img_shape': (32, 32, 3), 'scale_factor': 1}] + >>> cfg = mmcv.Config(dict( + >>> score_thr=0.00, + >>> nms=dict(type='nms', iou_thr=1.0), + >>> max_per_img=10)) + >>> feat = torch.rand(1, 1, 3, 3) + >>> cls_score, bbox_pred = self.forward_single(feat) + >>> # note the input lists are over different levels, not images + >>> cls_scores, bbox_preds = [cls_score], [bbox_pred] + >>> result_list = self.get_bboxes(cls_scores, bbox_preds, + >>> img_metas, cfg) + >>> det_bboxes, det_labels = result_list[0] + >>> assert len(result_list) == 1 + >>> assert det_bboxes.shape[1] == 5 + >>> assert len(det_bboxes) == len(det_labels) == cfg.max_per_img + """ + assert len(cls_scores) == len(bbox_preds) + num_levels = len(cls_scores) + + device = cls_scores[0].device + mlvl_anchors = [ + self.anchor_generators[i].grid_anchors( + cls_scores[i].size()[-2:], + self.anchor_strides[i], + device=device) for i in range(num_levels) + ] + result_list = [] + for img_id in range(len(img_metas)): + cls_score_list = [ + cls_scores[i][img_id].detach() for i in range(num_levels) + ] + bbox_pred_list = [ + bbox_preds[i][img_id].detach() for i in range(num_levels) + ] + img_shape = img_metas[img_id]['img_shape'] + scale_factor = img_metas[img_id]['scale_factor'] + proposals = self.get_bboxes_single(cls_score_list, bbox_pred_list, + mlvl_anchors, img_shape, + scale_factor, cfg, rescale) + result_list.append(proposals) + return result_list + + def get_bboxes_single(self, + cls_score_list, + bbox_pred_list, + mlvl_anchors, + img_shape, + scale_factor, + cfg, + rescale=False): + """ + Transform outputs for a single batch item into labeled boxes. + """ + assert len(cls_score_list) == len(bbox_pred_list) == len(mlvl_anchors) + mlvl_bboxes = [] + mlvl_scores = [] + for cls_score, bbox_pred, anchors in zip(cls_score_list, + bbox_pred_list, mlvl_anchors): + assert cls_score.size()[-2:] == bbox_pred.size()[-2:] + cls_score = cls_score.permute(1, 2, + 0).reshape(-1, self.cls_out_channels) + if self.use_sigmoid_cls: + scores = cls_score.sigmoid() + else: + scores = cls_score.softmax(-1) + bbox_pred = bbox_pred.permute(1, 2, 0).reshape(-1, 4) + nms_pre = cfg.get('nms_pre', -1) + if nms_pre > 0 and scores.shape[0] > nms_pre: + # Get maximum scores for foreground classes. + if self.use_sigmoid_cls: + max_scores, _ = scores.max(dim=1) + else: + max_scores, _ = scores[:, 1:].max(dim=1) + _, topk_inds = max_scores.topk(nms_pre) + anchors = anchors[topk_inds, :] + bbox_pred = bbox_pred[topk_inds, :] + scores = scores[topk_inds, :] + bboxes = delta2bbox(anchors, bbox_pred, self.target_means, + self.target_stds, img_shape) + mlvl_bboxes.append(bboxes) + mlvl_scores.append(scores) + mlvl_bboxes = torch.cat(mlvl_bboxes) + if rescale: + mlvl_bboxes /= mlvl_bboxes.new_tensor(scale_factor) + mlvl_scores = torch.cat(mlvl_scores) + if self.use_sigmoid_cls: + # Add a dummy background class to the front when using sigmoid + padding = mlvl_scores.new_zeros(mlvl_scores.shape[0], 1) + mlvl_scores = torch.cat([padding, mlvl_scores], dim=1) + det_bboxes, det_labels = multiclass_nms(mlvl_bboxes, mlvl_scores, + cfg.score_thr, cfg.nms, + cfg.max_per_img) + return det_bboxes, det_labels diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/atss_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/atss_head.py new file mode 100644 index 000000000..e0f2e0abc --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/atss_head.py @@ -0,0 +1,487 @@ +import numpy as np +import torch +import torch.distributed as dist +import torch.nn as nn +from mmcv.cnn import normal_init + +from mmdet.core import (PseudoSampler, anchor_inside_flags, bbox2delta, + build_assigner, delta2bbox, force_fp32, + images_to_levels, multi_apply, multiclass_nms, unmap) +from ..builder import build_loss +from ..registry import HEADS +from ..utils import ConvModule, Scale, bias_init_with_prob +from .anchor_head import AnchorHead + + +def reduce_mean(tensor): + if not (dist.is_available() and dist.is_initialized()): + return tensor + tensor = tensor.clone() + dist.all_reduce(tensor.div_(dist.get_world_size()), op=dist.reduce_op.SUM) + return tensor + + +@HEADS.register_module +class ATSSHead(AnchorHead): + """ + Bridging the Gap Between Anchor-based and Anchor-free Detection via + Adaptive Training Sample Selection + + ATSS head structure is similar with FCOS, however ATSS use anchor boxes + and assign label by Adaptive Training Sample Selection instead max-iou. + + https://arxiv.org/abs/1912.02424 + """ + + def __init__(self, + num_classes, + in_channels, + stacked_convs=4, + octave_base_scale=4, + scales_per_octave=1, + conv_cfg=None, + norm_cfg=dict(type='GN', num_groups=32, requires_grad=True), + loss_centerness=dict( + type='CrossEntropyLoss', + use_sigmoid=True, + loss_weight=1.0), + **kwargs): + self.stacked_convs = stacked_convs + self.octave_base_scale = octave_base_scale + self.scales_per_octave = scales_per_octave + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + + octave_scales = np.array( + [2**(i / scales_per_octave) for i in range(scales_per_octave)]) + anchor_scales = octave_scales * octave_base_scale + super(ATSSHead, self).__init__( + num_classes, in_channels, anchor_scales=anchor_scales, **kwargs) + + self.loss_centerness = build_loss(loss_centerness) + + def _init_layers(self): + self.relu = nn.ReLU(inplace=True) + self.cls_convs = nn.ModuleList() + self.reg_convs = nn.ModuleList() + for i in range(self.stacked_convs): + chn = self.in_channels if i == 0 else self.feat_channels + self.cls_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg)) + self.reg_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg)) + self.atss_cls = nn.Conv2d( + self.feat_channels, + self.num_anchors * self.cls_out_channels, + 3, + padding=1) + self.atss_reg = nn.Conv2d( + self.feat_channels, self.num_anchors * 4, 3, padding=1) + self.atss_centerness = nn.Conv2d( + self.feat_channels, self.num_anchors * 1, 3, padding=1) + self.scales = nn.ModuleList([Scale(1.0) for _ in self.anchor_strides]) + + def init_weights(self): + for m in self.cls_convs: + normal_init(m.conv, std=0.01) + for m in self.reg_convs: + normal_init(m.conv, std=0.01) + bias_cls = bias_init_with_prob(0.01) + normal_init(self.atss_cls, std=0.01, bias=bias_cls) + normal_init(self.atss_reg, std=0.01) + normal_init(self.atss_centerness, std=0.01) + + def forward(self, feats): + return multi_apply(self.forward_single, feats, self.scales) + + def forward_single(self, x, scale): + cls_feat = x + reg_feat = x + for cls_conv in self.cls_convs: + cls_feat = cls_conv(cls_feat) + for reg_conv in self.reg_convs: + reg_feat = reg_conv(reg_feat) + cls_score = self.atss_cls(cls_feat) + # we just follow atss, not apply exp in bbox_pred + bbox_pred = scale(self.atss_reg(reg_feat)).float() + centerness = self.atss_centerness(reg_feat) + return cls_score, bbox_pred, centerness + + def loss_single(self, anchors, cls_score, bbox_pred, centerness, labels, + label_weights, bbox_targets, num_total_samples, cfg): + + anchors = anchors.reshape(-1, 4) + cls_score = cls_score.permute(0, 2, 3, + 1).reshape(-1, self.cls_out_channels) + bbox_pred = bbox_pred.permute(0, 2, 3, 1).reshape(-1, 4) + centerness = centerness.permute(0, 2, 3, 1).reshape(-1) + bbox_targets = bbox_targets.reshape(-1, 4) + labels = labels.reshape(-1) + label_weights = label_weights.reshape(-1) + + # classification loss + loss_cls = self.loss_cls( + cls_score, labels, label_weights, avg_factor=num_total_samples) + + pos_inds = torch.nonzero(labels).squeeze(1) + + if len(pos_inds) > 0: + pos_bbox_targets = bbox_targets[pos_inds] + pos_bbox_pred = bbox_pred[pos_inds] + pos_anchors = anchors[pos_inds] + pos_centerness = centerness[pos_inds] + + centerness_targets = self.centerness_target( + pos_anchors, pos_bbox_targets) + pos_decode_bbox_pred = delta2bbox(pos_anchors, pos_bbox_pred, + self.target_means, + self.target_stds) + pos_decode_bbox_targets = delta2bbox(pos_anchors, pos_bbox_targets, + self.target_means, + self.target_stds) + + # regression loss + loss_bbox = self.loss_bbox( + pos_decode_bbox_pred, + pos_decode_bbox_targets, + weight=centerness_targets, + avg_factor=1.0) + + # centerness loss + loss_centerness = self.loss_centerness( + pos_centerness, + centerness_targets, + avg_factor=num_total_samples) + + else: + loss_bbox = loss_cls * 0 + loss_centerness = loss_bbox * 0 + centerness_targets = torch.tensor(0).cuda() + + return loss_cls, loss_bbox, loss_centerness, centerness_targets.sum() + + @force_fp32(apply_to=('cls_scores', 'bbox_preds', 'centernesses')) + def loss(self, + cls_scores, + bbox_preds, + centernesses, + gt_bboxes, + gt_labels, + img_metas, + cfg, + gt_bboxes_ignore=None): + + featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] + assert len(featmap_sizes) == len(self.anchor_generators) + + device = cls_scores[0].device + anchor_list, valid_flag_list = self.get_anchors( + featmap_sizes, img_metas, device=device) + label_channels = self.cls_out_channels if self.use_sigmoid_cls else 1 + + cls_reg_targets = self.atss_target( + anchor_list, + valid_flag_list, + gt_bboxes, + img_metas, + cfg, + gt_bboxes_ignore_list=gt_bboxes_ignore, + gt_labels_list=gt_labels, + label_channels=label_channels) + if cls_reg_targets is None: + return None + + (anchor_list, labels_list, label_weights_list, bbox_targets_list, + bbox_weights_list, num_total_pos, num_total_neg) = cls_reg_targets + + num_total_samples = reduce_mean( + torch.tensor(num_total_pos).cuda()).item() + num_total_samples = max(num_total_samples, 1.0) + + losses_cls, losses_bbox, loss_centerness,\ + bbox_avg_factor = multi_apply( + self.loss_single, + anchor_list, + cls_scores, + bbox_preds, + centernesses, + labels_list, + label_weights_list, + bbox_targets_list, + num_total_samples=num_total_samples, + cfg=cfg) + + bbox_avg_factor = sum(bbox_avg_factor) + bbox_avg_factor = reduce_mean(bbox_avg_factor).item() + losses_bbox = list(map(lambda x: x / bbox_avg_factor, losses_bbox)) + return dict( + loss_cls=losses_cls, + loss_bbox=losses_bbox, + loss_centerness=loss_centerness) + + def centerness_target(self, anchors, bbox_targets): + # only calculate pos centerness targets, otherwise there may be nan + gts = delta2bbox(anchors, bbox_targets, self.target_means, + self.target_stds) + anchors_cx = (anchors[:, 2] + anchors[:, 0]) / 2 + anchors_cy = (anchors[:, 3] + anchors[:, 1]) / 2 + l_ = anchors_cx - gts[:, 0] + t_ = anchors_cy - gts[:, 1] + r_ = gts[:, 2] - anchors_cx + b_ = gts[:, 3] - anchors_cy + + left_right = torch.stack([l_, r_], dim=1) + top_bottom = torch.stack([t_, b_], dim=1) + centerness = torch.sqrt( + (left_right.min(dim=-1)[0] / left_right.max(dim=-1)[0]) * + (top_bottom.min(dim=-1)[0] / top_bottom.max(dim=-1)[0])) + assert not torch.isnan(centerness).any() + return centerness + + @force_fp32(apply_to=('cls_scores', 'bbox_preds', 'centernesses')) + def get_bboxes(self, + cls_scores, + bbox_preds, + centernesses, + img_metas, + cfg, + rescale=False): + + assert len(cls_scores) == len(bbox_preds) + num_levels = len(cls_scores) + device = cls_scores[0].device + mlvl_anchors = [ + self.anchor_generators[i].grid_anchors( + cls_scores[i].size()[-2:], + self.anchor_strides[i], + device=device) for i in range(num_levels) + ] + + result_list = [] + for img_id in range(len(img_metas)): + cls_score_list = [ + cls_scores[i][img_id].detach() for i in range(num_levels) + ] + bbox_pred_list = [ + bbox_preds[i][img_id].detach() for i in range(num_levels) + ] + centerness_pred_list = [ + centernesses[i][img_id].detach() for i in range(num_levels) + ] + img_shape = img_metas[img_id]['img_shape'] + scale_factor = img_metas[img_id]['scale_factor'] + proposals = self.get_bboxes_single(cls_score_list, bbox_pred_list, + centerness_pred_list, + mlvl_anchors, img_shape, + scale_factor, cfg, rescale) + result_list.append(proposals) + return result_list + + def get_bboxes_single(self, + cls_scores, + bbox_preds, + centernesses, + mlvl_anchors, + img_shape, + scale_factor, + cfg, + rescale=False): + assert len(cls_scores) == len(bbox_preds) == len(mlvl_anchors) + mlvl_bboxes = [] + mlvl_scores = [] + mlvl_centerness = [] + for cls_score, bbox_pred, centerness, anchors in zip( + cls_scores, bbox_preds, centernesses, mlvl_anchors): + assert cls_score.size()[-2:] == bbox_pred.size()[-2:] + + scores = cls_score.permute(1, 2, 0).reshape( + -1, self.cls_out_channels).sigmoid() + bbox_pred = bbox_pred.permute(1, 2, 0).reshape(-1, 4) + centerness = centerness.permute(1, 2, 0).reshape(-1).sigmoid() + + nms_pre = cfg.get('nms_pre', -1) + if nms_pre > 0 and scores.shape[0] > nms_pre: + max_scores, _ = (scores * centerness[:, None]).max(dim=1) + _, topk_inds = max_scores.topk(nms_pre) + anchors = anchors[topk_inds, :] + bbox_pred = bbox_pred[topk_inds, :] + scores = scores[topk_inds, :] + centerness = centerness[topk_inds] + + bboxes = delta2bbox(anchors, bbox_pred, self.target_means, + self.target_stds, img_shape) + mlvl_bboxes.append(bboxes) + mlvl_scores.append(scores) + mlvl_centerness.append(centerness) + + mlvl_bboxes = torch.cat(mlvl_bboxes) + if rescale: + mlvl_bboxes /= mlvl_bboxes.new_tensor(scale_factor) + + mlvl_scores = torch.cat(mlvl_scores) + padding = mlvl_scores.new_zeros(mlvl_scores.shape[0], 1) + mlvl_scores = torch.cat([padding, mlvl_scores], dim=1) + mlvl_centerness = torch.cat(mlvl_centerness) + + det_bboxes, det_labels = multiclass_nms( + mlvl_bboxes, + mlvl_scores, + cfg.score_thr, + cfg.nms, + cfg.max_per_img, + score_factors=mlvl_centerness) + return det_bboxes, det_labels + + def atss_target(self, + anchor_list, + valid_flag_list, + gt_bboxes_list, + img_metas, + cfg, + gt_bboxes_ignore_list=None, + gt_labels_list=None, + label_channels=1, + unmap_outputs=True): + """ + almost the same with anchor_target, with a little modification, + here we need return the anchor + """ + num_imgs = len(img_metas) + assert len(anchor_list) == len(valid_flag_list) == num_imgs + + # anchor number of multi levels + num_level_anchors = [anchors.size(0) for anchors in anchor_list[0]] + num_level_anchors_list = [num_level_anchors] * num_imgs + + # concat all level anchors and flags to a single tensor + for i in range(num_imgs): + assert len(anchor_list[i]) == len(valid_flag_list[i]) + anchor_list[i] = torch.cat(anchor_list[i]) + valid_flag_list[i] = torch.cat(valid_flag_list[i]) + + # compute targets for each image + if gt_bboxes_ignore_list is None: + gt_bboxes_ignore_list = [None for _ in range(num_imgs)] + if gt_labels_list is None: + gt_labels_list = [None for _ in range(num_imgs)] + (all_anchors, all_labels, all_label_weights, all_bbox_targets, + all_bbox_weights, pos_inds_list, neg_inds_list) = multi_apply( + self.atss_target_single, + anchor_list, + valid_flag_list, + num_level_anchors_list, + gt_bboxes_list, + gt_bboxes_ignore_list, + gt_labels_list, + img_metas, + cfg=cfg, + label_channels=label_channels, + unmap_outputs=unmap_outputs) + # no valid anchors + if any([labels is None for labels in all_labels]): + return None + # sampled anchors of all images + num_total_pos = sum([max(inds.numel(), 1) for inds in pos_inds_list]) + num_total_neg = sum([max(inds.numel(), 1) for inds in neg_inds_list]) + # split targets to a list w.r.t. multiple levels + anchors_list = images_to_levels(all_anchors, num_level_anchors) + labels_list = images_to_levels(all_labels, num_level_anchors) + label_weights_list = images_to_levels(all_label_weights, + num_level_anchors) + bbox_targets_list = images_to_levels(all_bbox_targets, + num_level_anchors) + bbox_weights_list = images_to_levels(all_bbox_weights, + num_level_anchors) + return (anchors_list, labels_list, label_weights_list, + bbox_targets_list, bbox_weights_list, num_total_pos, + num_total_neg) + + def atss_target_single(self, + flat_anchors, + valid_flags, + num_level_anchors, + gt_bboxes, + gt_bboxes_ignore, + gt_labels, + img_meta, + cfg, + label_channels=1, + unmap_outputs=True): + inside_flags = anchor_inside_flags(flat_anchors, valid_flags, + img_meta['img_shape'][:2], + cfg.allowed_border) + if not inside_flags.any(): + return (None, ) * 6 + # assign gt and sample anchors + anchors = flat_anchors[inside_flags, :] + + num_level_anchors_inside = self.get_num_level_anchors_inside( + num_level_anchors, inside_flags) + bbox_assigner = build_assigner(cfg.assigner) + assign_result = bbox_assigner.assign(anchors, num_level_anchors_inside, + gt_bboxes, gt_bboxes_ignore, + gt_labels) + + bbox_sampler = PseudoSampler() + sampling_result = bbox_sampler.sample(assign_result, anchors, + gt_bboxes) + + num_valid_anchors = anchors.shape[0] + bbox_targets = torch.zeros_like(anchors) + bbox_weights = torch.zeros_like(anchors) + labels = anchors.new_zeros(num_valid_anchors, dtype=torch.long) + label_weights = anchors.new_zeros(num_valid_anchors, dtype=torch.float) + + pos_inds = sampling_result.pos_inds + neg_inds = sampling_result.neg_inds + if len(pos_inds) > 0: + pos_bbox_targets = bbox2delta(sampling_result.pos_bboxes, + sampling_result.pos_gt_bboxes, + self.target_means, self.target_stds) + bbox_targets[pos_inds, :] = pos_bbox_targets + bbox_weights[pos_inds, :] = 1.0 + if gt_labels is None: + labels[pos_inds] = 1 + else: + labels[pos_inds] = gt_labels[ + sampling_result.pos_assigned_gt_inds] + if cfg.pos_weight <= 0: + label_weights[pos_inds] = 1.0 + else: + label_weights[pos_inds] = cfg.pos_weight + if len(neg_inds) > 0: + label_weights[neg_inds] = 1.0 + + # map up to original set of anchors + if unmap_outputs: + num_total_anchors = flat_anchors.size(0) + anchors = unmap(anchors, num_total_anchors, inside_flags) + labels = unmap(labels, num_total_anchors, inside_flags) + label_weights = unmap(label_weights, num_total_anchors, + inside_flags) + bbox_targets = unmap(bbox_targets, num_total_anchors, inside_flags) + bbox_weights = unmap(bbox_weights, num_total_anchors, inside_flags) + + return (anchors, labels, label_weights, bbox_targets, bbox_weights, + pos_inds, neg_inds) + + def get_num_level_anchors_inside(self, num_level_anchors, inside_flags): + split_inside_flags = torch.split(inside_flags, num_level_anchors) + num_level_anchors_inside = [ + int(flags.sum()) for flags in split_inside_flags + ] + return num_level_anchors_inside diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/decoupled_solo_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/decoupled_solo_head.py new file mode 100644 index 000000000..1b6001142 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/decoupled_solo_head.py @@ -0,0 +1,484 @@ +import mmcv +import torch +import torch.nn as nn +import torch.nn.functional as F +from mmcv.cnn import normal_init +from mmdet.ops import DeformConv, roi_align +from mmdet.core import multi_apply, bbox2roi, matrix_nms +from ..builder import build_loss +from ..registry import HEADS +from ..utils import bias_init_with_prob, ConvModule + +INF = 1e8 + +def center_of_mass(bitmasks): + _, h, w = bitmasks.size() + ys = torch.arange(0, h, dtype=torch.float32, device=bitmasks.device) + xs = torch.arange(0, w, dtype=torch.float32, device=bitmasks.device) + + m00 = bitmasks.sum(dim=-1).sum(dim=-1).clamp(min=1e-6) + m10 = (bitmasks * xs).sum(dim=-1).sum(dim=-1) + m01 = (bitmasks * ys[:, None]).sum(dim=-1).sum(dim=-1) + center_x = m10 / m00 + center_y = m01 / m00 + return center_x, center_y + +def points_nms(heat, kernel=2): + # kernel must be 2 + hmax = nn.functional.max_pool2d( + heat, (kernel, kernel), stride=1, padding=1) + keep = (hmax[:, :, :-1, :-1] == heat).float() + return heat * keep + +def dice_loss(input, target): + input = input.contiguous().view(input.size()[0], -1) + target = target.contiguous().view(target.size()[0], -1).float() + + a = torch.sum(input * target, 1) + b = torch.sum(input * input, 1) + 0.001 + c = torch.sum(target * target, 1) + 0.001 + d = (2 * a) / (b + c) + return 1-d + +@HEADS.register_module +class DecoupledSOLOHead(nn.Module): + def __init__(self, + num_classes, + in_channels, + seg_feat_channels=256, + stacked_convs=4, + strides=(4, 8, 16, 32, 64), + base_edge_list=(16, 32, 64, 128, 256), + scale_ranges=((8, 32), (16, 64), (32, 128), (64, 256), (128, 512)), + sigma=0.4, + num_grids=None, + cate_down_pos=0, + with_deform=False, + loss_ins=None, + loss_cate=None, + conv_cfg=None, + norm_cfg=None): + super(DecoupledSOLOHead, self).__init__() + self.num_classes = num_classes + self.seg_num_grids = num_grids + self.cate_out_channels = self.num_classes - 1 + self.in_channels = in_channels + self.seg_feat_channels = seg_feat_channels + self.stacked_convs = stacked_convs + self.strides = strides + self.sigma = sigma + self.cate_down_pos = cate_down_pos + self.base_edge_list = base_edge_list + self.scale_ranges = scale_ranges + self.with_deform = with_deform + self.loss_cate = build_loss(loss_cate) + self.ins_loss_weight = loss_ins['loss_weight'] + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + self._init_layers() + + def _init_layers(self): + norm_cfg = dict(type='GN', num_groups=32, requires_grad=True) + self.ins_convs_x = nn.ModuleList() + self.ins_convs_y = nn.ModuleList() + self.cate_convs = nn.ModuleList() + + for i in range(self.stacked_convs): + chn = self.in_channels + 1 if i == 0 else self.seg_feat_channels + self.ins_convs_x.append( + ConvModule( + chn, + self.seg_feat_channels, + 3, + stride=1, + padding=1, + norm_cfg=norm_cfg, + bias=norm_cfg is None)) + self.ins_convs_y.append( + ConvModule( + chn, + self.seg_feat_channels, + 3, + stride=1, + padding=1, + norm_cfg=norm_cfg, + bias=norm_cfg is None)) + + chn = self.in_channels if i == 0 else self.seg_feat_channels + self.cate_convs.append( + ConvModule( + chn, + self.seg_feat_channels, + 3, + stride=1, + padding=1, + norm_cfg=norm_cfg, + bias=norm_cfg is None)) + + self.dsolo_ins_list_x = nn.ModuleList() + self.dsolo_ins_list_y = nn.ModuleList() + for seg_num_grid in self.seg_num_grids: + self.dsolo_ins_list_x.append( + nn.Conv2d( + self.seg_feat_channels, seg_num_grid, 3, padding=1)) + self.dsolo_ins_list_y.append( + nn.Conv2d( + self.seg_feat_channels, seg_num_grid, 3, padding=1)) + self.dsolo_cate = nn.Conv2d( + self.seg_feat_channels, self.cate_out_channels, 3, padding=1) + + def init_weights(self): + for m in self.ins_convs_x: + normal_init(m.conv, std=0.01) + for m in self.ins_convs_y: + normal_init(m.conv, std=0.01) + for m in self.cate_convs: + normal_init(m.conv, std=0.01) + bias_ins = bias_init_with_prob(0.01) + for m in self.dsolo_ins_list_x: + normal_init(m, std=0.01, bias=bias_ins) + for m in self.dsolo_ins_list_y: + normal_init(m, std=0.01, bias=bias_ins) + bias_cate = bias_init_with_prob(0.01) + normal_init(self.dsolo_cate, std=0.01, bias=bias_cate) + + def forward(self, feats, eval=False): + new_feats = self.split_feats(feats) + featmap_sizes = [featmap.size()[-2:] for featmap in new_feats] + upsampled_size = (featmap_sizes[0][0] * 2, featmap_sizes[0][1] * 2) + ins_pred_x, ins_pred_y, cate_pred = multi_apply(self.forward_single, new_feats, + list(range(len(self.seg_num_grids))), + eval=eval, upsampled_size=upsampled_size) + return ins_pred_x, ins_pred_y, cate_pred + + def split_feats(self, feats): + return (F.interpolate(feats[0], scale_factor=0.5, mode='bilinear'), + feats[1], + feats[2], + feats[3], + F.interpolate(feats[4], size=feats[3].shape[-2:], mode='bilinear')) + + def forward_single(self, x, idx, eval=False, upsampled_size=None): + ins_feat = x + cate_feat = x + # ins branch + # concat coord + x_range = torch.linspace(-1, 1, ins_feat.shape[-1], device=ins_feat.device) + y_range = torch.linspace(-1, 1, ins_feat.shape[-2], device=ins_feat.device) + y, x = torch.meshgrid(y_range, x_range) + y = y.expand([ins_feat.shape[0], 1, -1, -1]) + x = x.expand([ins_feat.shape[0], 1, -1, -1]) + ins_feat_x = torch.cat([ins_feat, x], 1) + ins_feat_y = torch.cat([ins_feat, y], 1) + + for ins_layer_x, ins_layer_y in zip(self.ins_convs_x, self.ins_convs_y): + ins_feat_x = ins_layer_x(ins_feat_x) + ins_feat_y = ins_layer_y(ins_feat_y) + + ins_feat_x = F.interpolate(ins_feat_x, scale_factor=2, mode='bilinear') + ins_feat_y = F.interpolate(ins_feat_y, scale_factor=2, mode='bilinear') + + ins_pred_x = self.dsolo_ins_list_x[idx](ins_feat_x) + ins_pred_y = self.dsolo_ins_list_y[idx](ins_feat_y) + + # cate branch + for i, cate_layer in enumerate(self.cate_convs): + if i == self.cate_down_pos: + seg_num_grid = self.seg_num_grids[idx] + cate_feat = F.interpolate(cate_feat, size=seg_num_grid, mode='bilinear') + cate_feat = cate_layer(cate_feat) + + cate_pred = self.dsolo_cate(cate_feat) + + if eval: + ins_pred_x = F.interpolate(ins_pred_x.sigmoid(), size=upsampled_size, mode='bilinear') + ins_pred_y = F.interpolate(ins_pred_y.sigmoid(), size=upsampled_size, mode='bilinear') + cate_pred = points_nms(cate_pred.sigmoid(), kernel=2).permute(0, 2, 3, 1) + return ins_pred_x, ins_pred_y, cate_pred + + def loss(self, + ins_preds_x, + ins_preds_y, + cate_preds, + gt_bbox_list, + gt_label_list, + gt_mask_list, + img_metas, + cfg, + gt_bboxes_ignore=None): + featmap_sizes = [featmap.size()[-2:] for featmap in + ins_preds_x] + ins_label_list, cate_label_list, ins_ind_label_list, ins_ind_label_list_xy = multi_apply( + self.solo_target_single, + gt_bbox_list, + gt_label_list, + gt_mask_list, + featmap_sizes=featmap_sizes) + + # ins + ins_labels = [torch.cat([ins_labels_level_img[ins_ind_labels_level_img, ...] + for ins_labels_level_img, ins_ind_labels_level_img in + zip(ins_labels_level, ins_ind_labels_level)], 0) + for ins_labels_level, ins_ind_labels_level in zip(zip(*ins_label_list), zip(*ins_ind_label_list))] + + ins_preds_x_final = [torch.cat([ins_preds_level_img_x[ins_ind_labels_level_img[:, 1], ...] + for ins_preds_level_img_x, ins_ind_labels_level_img in + zip(ins_preds_level_x, ins_ind_labels_level)], 0) + for ins_preds_level_x, ins_ind_labels_level in + zip(ins_preds_x, zip(*ins_ind_label_list_xy))] + + ins_preds_y_final = [torch.cat([ins_preds_level_img_y[ins_ind_labels_level_img[:, 0], ...] + for ins_preds_level_img_y, ins_ind_labels_level_img in + zip(ins_preds_level_y, ins_ind_labels_level)], 0) + for ins_preds_level_y, ins_ind_labels_level in + zip(ins_preds_y, zip(*ins_ind_label_list_xy))] + + num_ins = 0. + # dice loss + loss_ins = [] + for input_x, input_y, target in zip(ins_preds_x_final, ins_preds_y_final, ins_labels): + mask_n = input_x.size(0) + if mask_n == 0: + continue + num_ins += mask_n + input = (input_x.sigmoid())*(input_y.sigmoid()) + loss_ins.append(dice_loss(input, target)) + + loss_ins = torch.cat(loss_ins).mean() * self.ins_loss_weight + + # cate + cate_labels = [ + torch.cat([cate_labels_level_img.flatten() + for cate_labels_level_img in cate_labels_level]) + for cate_labels_level in zip(*cate_label_list) + ] + flatten_cate_labels = torch.cat(cate_labels) + + cate_preds = [ + cate_pred.permute(0, 2, 3, 1).reshape(-1, self.cate_out_channels) + for cate_pred in cate_preds + ] + flatten_cate_preds = torch.cat(cate_preds) + + loss_cate = self.loss_cate(flatten_cate_preds, flatten_cate_labels, avg_factor=num_ins + 1) + return dict( + loss_ins=loss_ins, + loss_cate=loss_cate) + + def solo_target_single(self, + gt_bboxes_raw, + gt_labels_raw, + gt_masks_raw, + featmap_sizes=None): + + device = gt_labels_raw[0].device + # ins + gt_areas = torch.sqrt((gt_bboxes_raw[:, 2] - gt_bboxes_raw[:, 0]) * ( + gt_bboxes_raw[:, 3] - gt_bboxes_raw[:, 1])) + ins_label_list = [] + cate_label_list = [] + ins_ind_label_list = [] + ins_ind_label_list_xy = [] + for (lower_bound, upper_bound), stride, featmap_size, num_grid \ + in zip(self.scale_ranges, self.strides, featmap_sizes, self.seg_num_grids): + + ins_label = torch.zeros([num_grid**2, featmap_size[0], featmap_size[1]], dtype=torch.uint8, device=device) + cate_label = torch.zeros([num_grid, num_grid], dtype=torch.int64, device=device) + ins_ind_label = torch.zeros([num_grid**2], dtype=torch.bool, device=device) + + hit_indices = ((gt_areas >= lower_bound) & (gt_areas <= upper_bound)).nonzero().flatten() + + if len(hit_indices) == 0: + ins_label = torch.zeros([1, featmap_size[0], featmap_size[1]], dtype=torch.uint8, + device=device) + ins_label_list.append(ins_label) + cate_label_list.append(cate_label) + ins_ind_label = torch.zeros([1], dtype=torch.bool, device=device) + ins_ind_label_list.append(ins_ind_label) + ins_ind_label_list_xy.append(cate_label.nonzero()) + continue + gt_bboxes = gt_bboxes_raw[hit_indices] + gt_labels = gt_labels_raw[hit_indices] + gt_masks = gt_masks_raw[hit_indices.cpu().numpy(), ...] + + half_ws = 0.5 * (gt_bboxes[:, 2] - gt_bboxes[:, 0]) * self.sigma + half_hs = 0.5 * (gt_bboxes[:, 3] - gt_bboxes[:, 1]) * self.sigma + + # mass center + gt_masks_pt = torch.from_numpy(gt_masks).to(device=device) + center_ws, center_hs = center_of_mass(gt_masks_pt) + valid_mask_flags = gt_masks_pt.sum(dim=-1).sum(dim=-1) > 0 + + output_stride = stride / 2 + for seg_mask, gt_label, half_h, half_w, center_h, center_w, valid_mask_flag in zip(gt_masks, gt_labels, half_hs, half_ws, center_hs, center_ws, valid_mask_flags): + if not valid_mask_flag: + continue + upsampled_size = (featmap_sizes[0][0] * 4, featmap_sizes[0][1] * 4) + coord_w = int((center_w / upsampled_size[1]) // (1. / num_grid)) + coord_h = int((center_h / upsampled_size[0]) // (1. / num_grid)) + + # left, top, right, down + top_box = max(0, int(((center_h - half_h) / upsampled_size[0]) // (1. / num_grid))) + down_box = min(num_grid - 1, int(((center_h + half_h) / upsampled_size[0]) // (1. / num_grid))) + left_box = max(0, int(((center_w - half_w) / upsampled_size[1]) // (1. / num_grid))) + right_box = min(num_grid - 1, int(((center_w + half_w) / upsampled_size[1]) // (1. / num_grid))) + + top = max(top_box, coord_h-1) + down = min(down_box, coord_h+1) + left = max(coord_w-1, left_box) + right = min(right_box, coord_w+1) + + # squared + cate_label[top:(down+1), left:(right+1)] = gt_label + # ins + seg_mask = mmcv.imrescale(seg_mask, scale=1. / output_stride) + seg_mask = torch.from_numpy(seg_mask).to(device=device) + for i in range(top, down+1): + for j in range(left, right+1): + label = int(i * num_grid + j) + ins_label[label, :seg_mask.shape[0], :seg_mask.shape[1]] = seg_mask + ins_ind_label[label] = True + + ins_label = ins_label[ins_ind_label] + ins_label_list.append(ins_label) + + cate_label_list.append(cate_label) + + ins_ind_label = ins_ind_label[ins_ind_label] + ins_ind_label_list.append(ins_ind_label) + + ins_ind_label_list_xy.append(cate_label.nonzero()) + return ins_label_list, cate_label_list, ins_ind_label_list, ins_ind_label_list_xy + + def get_seg(self, seg_preds_x, seg_preds_y, cate_preds, img_metas, cfg, rescale=None): + assert len(seg_preds_x) == len(cate_preds) + num_levels = len(cate_preds) + featmap_size = seg_preds_x[0].size()[-2:] + + result_list = [] + for img_id in range(len(img_metas)): + cate_pred_list = [ + cate_preds[i][img_id].view(-1, self.cate_out_channels).detach() for i in range(num_levels) + ] + seg_pred_list_x = [ + seg_preds_x[i][img_id].detach() for i in range(num_levels) + ] + seg_pred_list_y = [ + seg_preds_y[i][img_id].detach() for i in range(num_levels) + ] + img_shape = img_metas[img_id]['img_shape'] + scale_factor = img_metas[img_id]['scale_factor'] + ori_shape = img_metas[img_id]['ori_shape'] + + cate_pred_list = torch.cat(cate_pred_list, dim=0) + seg_pred_list_x = torch.cat(seg_pred_list_x, dim=0) + seg_pred_list_y = torch.cat(seg_pred_list_y, dim=0) + + result = self.get_seg_single(cate_pred_list, seg_pred_list_x, seg_pred_list_y, + featmap_size, img_shape, ori_shape, scale_factor, cfg, rescale) + result_list.append(result) + return result_list + + def get_seg_single(self, + cate_preds, + seg_preds_x, + seg_preds_y, + featmap_size, + img_shape, + ori_shape, + scale_factor, + cfg, + rescale=False, debug=False): + + + # overall info. + h, w, _ = img_shape + upsampled_size_out = (featmap_size[0] * 4, featmap_size[1] * 4) + + # trans trans_diff. + trans_size = torch.Tensor(self.seg_num_grids).pow(2).cumsum(0).long() + trans_diff = torch.ones(trans_size[-1].item(), device=cate_preds.device).long() + num_grids = torch.ones(trans_size[-1].item(), device=cate_preds.device).long() + seg_size = torch.Tensor(self.seg_num_grids).cumsum(0).long() + seg_diff = torch.ones(trans_size[-1].item(), device=cate_preds.device).long() + strides = torch.ones(trans_size[-1].item(), device=cate_preds.device) + + n_stage = len(self.seg_num_grids) + trans_diff[:trans_size[0]] *= 0 + seg_diff[:trans_size[0]] *= 0 + num_grids[:trans_size[0]] *= self.seg_num_grids[0] + strides[:trans_size[0]] *= self.strides[0] + + for ind_ in range(1, n_stage): + trans_diff[trans_size[ind_ - 1]:trans_size[ind_]] *= trans_size[ind_ - 1] + seg_diff[trans_size[ind_ - 1]:trans_size[ind_]] *= seg_size[ind_ - 1] + num_grids[trans_size[ind_ - 1]:trans_size[ind_]] *= self.seg_num_grids[ind_] + strides[trans_size[ind_ - 1]:trans_size[ind_]] *= self.strides[ind_] + + # process. + inds = (cate_preds > cfg.score_thr) + cate_scores = cate_preds[inds] + + inds = inds.nonzero() + trans_diff = torch.index_select(trans_diff, dim=0, index=inds[:, 0]) + seg_diff = torch.index_select(seg_diff, dim=0, index=inds[:, 0]) + num_grids = torch.index_select(num_grids, dim=0, index=inds[:, 0]) + strides = torch.index_select(strides, dim=0, index=inds[:, 0]) + + y_inds = (inds[:, 0] - trans_diff) // num_grids + x_inds = (inds[:, 0] - trans_diff) % num_grids + y_inds += seg_diff + x_inds += seg_diff + + cate_labels = inds[:, 1] + seg_masks_soft = seg_preds_x[x_inds, ...] * seg_preds_y[y_inds, ...] + seg_masks = seg_masks_soft > cfg.mask_thr + sum_masks = seg_masks.sum((1, 2)).float() + keep = sum_masks > strides + + seg_masks_soft = seg_masks_soft[keep, ...] + seg_masks = seg_masks[keep, ...] + cate_scores = cate_scores[keep] + sum_masks = sum_masks[keep] + cate_labels = cate_labels[keep] + # maskness + seg_score = (seg_masks_soft * seg_masks.float()).sum((1, 2)) / sum_masks + cate_scores *= seg_score + + if len(cate_scores) == 0: + return None + + # sort and keep top nms_pre + sort_inds = torch.argsort(cate_scores, descending=True) + if len(sort_inds) > cfg.nms_pre: + sort_inds = sort_inds[:cfg.nms_pre] + seg_masks_soft = seg_masks_soft[sort_inds, :, :] + seg_masks = seg_masks[sort_inds, :, :] + cate_scores = cate_scores[sort_inds] + sum_masks = sum_masks[sort_inds] + cate_labels = cate_labels[sort_inds] + + # Matrix NMS + cate_scores = matrix_nms(seg_masks, cate_labels, cate_scores, + kernel=cfg.kernel, sigma=cfg.sigma, sum_masks=sum_masks) + + keep = cate_scores >= cfg.update_thr + seg_masks_soft = seg_masks_soft[keep, :, :] + cate_scores = cate_scores[keep] + cate_labels = cate_labels[keep] + # sort and keep top_k + sort_inds = torch.argsort(cate_scores, descending=True) + if len(sort_inds) > cfg.max_per_img: + sort_inds = sort_inds[:cfg.max_per_img] + seg_masks_soft = seg_masks_soft[sort_inds, :, :] + cate_scores = cate_scores[sort_inds] + cate_labels = cate_labels[sort_inds] + + seg_masks_soft = F.interpolate(seg_masks_soft.unsqueeze(0), + size=upsampled_size_out, + mode='bilinear')[:, :, :h, :w] + seg_masks = F.interpolate(seg_masks_soft, + size=ori_shape[:2], + mode='bilinear').squeeze(0) + seg_masks = seg_masks > cfg.mask_thr + return seg_masks, cate_labels, cate_scores diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/decoupled_solo_light_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/decoupled_solo_light_head.py new file mode 100644 index 000000000..5b52802b2 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/decoupled_solo_light_head.py @@ -0,0 +1,479 @@ +import mmcv +import torch +import torch.nn as nn +import torch.nn.functional as F +from mmcv.cnn import normal_init +from mmdet.ops import DeformConv, roi_align +from mmdet.core import multi_apply, bbox2roi, matrix_nms +from ..builder import build_loss +from ..registry import HEADS +from ..utils import bias_init_with_prob, ConvModule + +INF = 1e8 + +def center_of_mass(bitmasks): + _, h, w = bitmasks.size() + ys = torch.arange(0, h, dtype=torch.float32, device=bitmasks.device) + xs = torch.arange(0, w, dtype=torch.float32, device=bitmasks.device) + + m00 = bitmasks.sum(dim=-1).sum(dim=-1).clamp(min=1e-6) + m10 = (bitmasks * xs).sum(dim=-1).sum(dim=-1) + m01 = (bitmasks * ys[:, None]).sum(dim=-1).sum(dim=-1) + center_x = m10 / m00 + center_y = m01 / m00 + return center_x, center_y + +def points_nms(heat, kernel=2): + # kernel must be 2 + hmax = nn.functional.max_pool2d( + heat, (kernel, kernel), stride=1, padding=1) + keep = (hmax[:, :, :-1, :-1] == heat).float() + return heat * keep + +def dice_loss(input, target): + input = input.contiguous().view(input.size()[0], -1) + target = target.contiguous().view(target.size()[0], -1).float() + + a = torch.sum(input * target, 1) + b = torch.sum(input * input, 1) + 0.001 + c = torch.sum(target * target, 1) + 0.001 + d = (2 * a) / (b + c) + return 1-d + +@HEADS.register_module +class DecoupledSOLOLightHead(nn.Module): + def __init__(self, + num_classes, + in_channels, + seg_feat_channels=256, + stacked_convs=4, + strides=(4, 8, 16, 32, 64), + base_edge_list=(16, 32, 64, 128, 256), + scale_ranges=((8, 32), (16, 64), (32, 128), (64, 256), (128, 512)), + sigma=0.4, + num_grids=None, + cate_down_pos=0, + loss_ins=None, + loss_cate=None, + conv_cfg=None, + norm_cfg=None, + use_dcn_in_tower=False, + type_dcn=None): + super(DecoupledSOLOLightHead, self).__init__() + self.num_classes = num_classes + self.seg_num_grids = num_grids + self.cate_out_channels = self.num_classes - 1 + self.in_channels = in_channels + self.seg_feat_channels = seg_feat_channels + self.stacked_convs = stacked_convs + self.strides = strides + self.sigma = sigma + self.cate_down_pos = cate_down_pos + self.base_edge_list = base_edge_list + self.scale_ranges = scale_ranges + self.loss_cate = build_loss(loss_cate) + self.ins_loss_weight = loss_ins['loss_weight'] + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + self.use_dcn_in_tower = use_dcn_in_tower + self.type_dcn = type_dcn + self._init_layers() + + def _init_layers(self): + norm_cfg = dict(type='GN', num_groups=32, requires_grad=True) + self.ins_convs = nn.ModuleList() + self.cate_convs = nn.ModuleList() + + for i in range(self.stacked_convs): + if self.use_dcn_in_tower and i == self.stacked_convs - 1: + cfg_conv = dict(type=self.type_dcn) + else: + cfg_conv = self.conv_cfg + + chn = self.in_channels + 2 if i == 0 else self.seg_feat_channels + self.ins_convs.append( + ConvModule( + chn, + self.seg_feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=cfg_conv, + norm_cfg=norm_cfg, + bias=norm_cfg is None)) + + chn = self.in_channels if i == 0 else self.seg_feat_channels + self.cate_convs.append( + ConvModule( + chn, + self.seg_feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=cfg_conv, + norm_cfg=norm_cfg, + bias=norm_cfg is None)) + + self.dsolo_ins_list_x = nn.ModuleList() + self.dsolo_ins_list_y = nn.ModuleList() + for seg_num_grid in self.seg_num_grids: + self.dsolo_ins_list_x.append( + nn.Conv2d( + self.seg_feat_channels, seg_num_grid, 3, padding=1)) + self.dsolo_ins_list_y.append( + nn.Conv2d( + self.seg_feat_channels, seg_num_grid, 3, padding=1)) + self.dsolo_cate = nn.Conv2d( + self.seg_feat_channels, self.cate_out_channels, 3, padding=1) + + def init_weights(self): + for m in self.ins_convs: + normal_init(m.conv, std=0.01) + for m in self.cate_convs: + normal_init(m.conv, std=0.01) + bias_ins = bias_init_with_prob(0.01) + for m in self.dsolo_ins_list_x: + normal_init(m, std=0.01, bias=bias_ins) + for m in self.dsolo_ins_list_y: + normal_init(m, std=0.01, bias=bias_ins) + bias_cate = bias_init_with_prob(0.01) + normal_init(self.dsolo_cate, std=0.01, bias=bias_cate) + + def forward(self, feats, eval=False): + new_feats = self.split_feats(feats) + featmap_sizes = [featmap.size()[-2:] for featmap in new_feats] + upsampled_size = (featmap_sizes[0][0] * 2, featmap_sizes[0][1] * 2) + ins_pred_x, ins_pred_y, cate_pred = multi_apply(self.forward_single, new_feats, + list(range(len(self.seg_num_grids))), + eval=eval, upsampled_size=upsampled_size) + return ins_pred_x, ins_pred_y, cate_pred + + def split_feats(self, feats): + return (F.interpolate(feats[0], scale_factor=0.5, mode='bilinear'), + feats[1], + feats[2], + feats[3], + F.interpolate(feats[4], size=feats[3].shape[-2:], mode='bilinear')) + + def forward_single(self, x, idx, eval=False, upsampled_size=None): + ins_feat = x + cate_feat = x + # ins branch + # concat coord + x_range = torch.linspace(-1, 1, ins_feat.shape[-1], device=ins_feat.device) + y_range = torch.linspace(-1, 1, ins_feat.shape[-2], device=ins_feat.device) + y, x = torch.meshgrid(y_range, x_range) + y = y.expand([ins_feat.shape[0], 1, -1, -1]) + x = x.expand([ins_feat.shape[0], 1, -1, -1]) + coord_feat = torch.cat([x, y], 1) + ins_feat = torch.cat([ins_feat, coord_feat], 1) + + for ins_layer in self.ins_convs: + ins_feat = ins_layer(ins_feat) + + ins_feat = F.interpolate(ins_feat, scale_factor=2, mode='bilinear') + + ins_pred_x = self.dsolo_ins_list_x[idx](ins_feat) + ins_pred_y = self.dsolo_ins_list_y[idx](ins_feat) + + # cate branch + for i, cate_layer in enumerate(self.cate_convs): + if i == self.cate_down_pos: + seg_num_grid = self.seg_num_grids[idx] + cate_feat = F.interpolate(cate_feat, size=seg_num_grid, mode='bilinear') + cate_feat = cate_layer(cate_feat) + + cate_pred = self.dsolo_cate(cate_feat) + + if eval: + ins_pred_x = F.interpolate(ins_pred_x.sigmoid(), size=upsampled_size, mode='bilinear') + ins_pred_y = F.interpolate(ins_pred_y.sigmoid(), size=upsampled_size, mode='bilinear') + cate_pred = points_nms(cate_pred.sigmoid(), kernel=2).permute(0, 2, 3, 1) + return ins_pred_x, ins_pred_y, cate_pred + + def loss(self, + ins_preds_x, + ins_preds_y, + cate_preds, + gt_bbox_list, + gt_label_list, + gt_mask_list, + img_metas, + cfg, + gt_bboxes_ignore=None): + featmap_sizes = [featmap.size()[-2:] for featmap in + ins_preds_x] + ins_label_list, cate_label_list, ins_ind_label_list, ins_ind_label_list_xy = multi_apply( + self.solo_target_single, + gt_bbox_list, + gt_label_list, + gt_mask_list, + featmap_sizes=featmap_sizes) + + # ins + ins_labels = [torch.cat([ins_labels_level_img[ins_ind_labels_level_img, ...] + for ins_labels_level_img, ins_ind_labels_level_img in + zip(ins_labels_level, ins_ind_labels_level)], 0) + for ins_labels_level, ins_ind_labels_level in zip(zip(*ins_label_list), zip(*ins_ind_label_list))] + + ins_preds_x_final = [torch.cat([ins_preds_level_img_x[ins_ind_labels_level_img[:, 1], ...] + for ins_preds_level_img_x, ins_ind_labels_level_img in + zip(ins_preds_level_x, ins_ind_labels_level)], 0) + for ins_preds_level_x, ins_ind_labels_level in + zip(ins_preds_x, zip(*ins_ind_label_list_xy))] + + ins_preds_y_final = [torch.cat([ins_preds_level_img_y[ins_ind_labels_level_img[:, 0], ...] + for ins_preds_level_img_y, ins_ind_labels_level_img in + zip(ins_preds_level_y, ins_ind_labels_level)], 0) + for ins_preds_level_y, ins_ind_labels_level in + zip(ins_preds_y, zip(*ins_ind_label_list_xy))] + + num_ins = 0. + # dice loss + loss_ins = [] + for input_x, input_y, target in zip(ins_preds_x_final, ins_preds_y_final, ins_labels): + mask_n = input_x.size(0) + if mask_n == 0: + continue + num_ins += mask_n + input = (input_x.sigmoid())*(input_y.sigmoid()) + loss_ins.append(dice_loss(input, target)) + + loss_ins = torch.cat(loss_ins).mean() * self.ins_loss_weight + + # cate + cate_labels = [ + torch.cat([cate_labels_level_img.flatten() + for cate_labels_level_img in cate_labels_level]) + for cate_labels_level in zip(*cate_label_list) + ] + flatten_cate_labels = torch.cat(cate_labels) + + cate_preds = [ + cate_pred.permute(0, 2, 3, 1).reshape(-1, self.cate_out_channels) + for cate_pred in cate_preds + ] + flatten_cate_preds = torch.cat(cate_preds) + + loss_cate = self.loss_cate(flatten_cate_preds, flatten_cate_labels, avg_factor=num_ins + 1) + return dict( + loss_ins=loss_ins, + loss_cate=loss_cate) + + def solo_target_single(self, + gt_bboxes_raw, + gt_labels_raw, + gt_masks_raw, + featmap_sizes=None): + + device = gt_labels_raw[0].device + # ins + gt_areas = torch.sqrt((gt_bboxes_raw[:, 2] - gt_bboxes_raw[:, 0]) * ( + gt_bboxes_raw[:, 3] - gt_bboxes_raw[:, 1])) + ins_label_list = [] + cate_label_list = [] + ins_ind_label_list = [] + ins_ind_label_list_xy = [] + for (lower_bound, upper_bound), stride, featmap_size, num_grid \ + in zip(self.scale_ranges, self.strides, featmap_sizes, self.seg_num_grids): + + ins_label = torch.zeros([num_grid**2, featmap_size[0], featmap_size[1]], dtype=torch.uint8, device=device) + cate_label = torch.zeros([num_grid, num_grid], dtype=torch.int64, device=device) + ins_ind_label = torch.zeros([num_grid**2], dtype=torch.bool, device=device) + + hit_indices = ((gt_areas >= lower_bound) & (gt_areas <= upper_bound)).nonzero().flatten() + + if len(hit_indices) == 0: + ins_label = torch.zeros([1, featmap_size[0], featmap_size[1]], dtype=torch.uint8, + device=device) + ins_label_list.append(ins_label) + cate_label_list.append(cate_label) + ins_ind_label = torch.zeros([1], dtype=torch.bool, device=device) + ins_ind_label_list.append(ins_ind_label) + ins_ind_label_list_xy.append(cate_label.nonzero()) + continue + gt_bboxes = gt_bboxes_raw[hit_indices] + gt_labels = gt_labels_raw[hit_indices] + gt_masks = gt_masks_raw[hit_indices.cpu().numpy(), ...] + + half_ws = 0.5 * (gt_bboxes[:, 2] - gt_bboxes[:, 0]) * self.sigma + half_hs = 0.5 * (gt_bboxes[:, 3] - gt_bboxes[:, 1]) * self.sigma + + # mass center + gt_masks_pt = torch.from_numpy(gt_masks).to(device=device) + center_ws, center_hs = center_of_mass(gt_masks_pt) + valid_mask_flags = gt_masks_pt.sum(dim=-1).sum(dim=-1) > 0 + + output_stride = stride / 2 + for seg_mask, gt_label, half_h, half_w, center_h, center_w, valid_mask_flag in zip(gt_masks, gt_labels, half_hs, half_ws, center_hs, center_ws, valid_mask_flags): + if not valid_mask_flag: + continue + upsampled_size = (featmap_sizes[0][0] * 4, featmap_sizes[0][1] * 4) + coord_w = int((center_w / upsampled_size[1]) // (1. / num_grid)) + coord_h = int((center_h / upsampled_size[0]) // (1. / num_grid)) + + # left, top, right, down + top_box = max(0, int(((center_h - half_h) / upsampled_size[0]) // (1. / num_grid))) + down_box = min(num_grid - 1, int(((center_h + half_h) / upsampled_size[0]) // (1. / num_grid))) + left_box = max(0, int(((center_w - half_w) / upsampled_size[1]) // (1. / num_grid))) + right_box = min(num_grid - 1, int(((center_w + half_w) / upsampled_size[1]) // (1. / num_grid))) + + top = max(top_box, coord_h-1) + down = min(down_box, coord_h+1) + left = max(coord_w-1, left_box) + right = min(right_box, coord_w+1) + + # squared + cate_label[top:(down+1), left:(right+1)] = gt_label + # ins + seg_mask = mmcv.imrescale(seg_mask, scale=1. / output_stride) + seg_mask = torch.from_numpy(seg_mask).to(device=device) + for i in range(top, down+1): + for j in range(left, right+1): + label = int(i * num_grid + j) + ins_label[label, :seg_mask.shape[0], :seg_mask.shape[1]] = seg_mask + ins_ind_label[label] = True + + ins_label = ins_label[ins_ind_label] + ins_label_list.append(ins_label) + + cate_label_list.append(cate_label) + + ins_ind_label = ins_ind_label[ins_ind_label] + ins_ind_label_list.append(ins_ind_label) + + ins_ind_label_list_xy.append(cate_label.nonzero()) + return ins_label_list, cate_label_list, ins_ind_label_list, ins_ind_label_list_xy + + def get_seg(self, seg_preds_x, seg_preds_y, cate_preds, img_metas, cfg, rescale=None): + assert len(seg_preds_x) == len(cate_preds) + num_levels = len(cate_preds) + featmap_size = seg_preds_x[0].size()[-2:] + + result_list = [] + for img_id in range(len(img_metas)): + cate_pred_list = [ + cate_preds[i][img_id].view(-1, self.cate_out_channels).detach() for i in range(num_levels) + ] + seg_pred_list_x = [ + seg_preds_x[i][img_id].detach() for i in range(num_levels) + ] + seg_pred_list_y = [ + seg_preds_y[i][img_id].detach() for i in range(num_levels) + ] + img_shape = img_metas[img_id]['img_shape'] + scale_factor = img_metas[img_id]['scale_factor'] + ori_shape = img_metas[img_id]['ori_shape'] + + cate_pred_list = torch.cat(cate_pred_list, dim=0) + seg_pred_list_x = torch.cat(seg_pred_list_x, dim=0) + seg_pred_list_y = torch.cat(seg_pred_list_y, dim=0) + + result = self.get_seg_single(cate_pred_list, seg_pred_list_x, seg_pred_list_y, + featmap_size, img_shape, ori_shape, scale_factor, cfg, rescale) + result_list.append(result) + return result_list + + def get_seg_single(self, + cate_preds, + seg_preds_x, + seg_preds_y, + featmap_size, + img_shape, + ori_shape, + scale_factor, + cfg, + rescale=False, debug=False): + + + # overall info. + h, w, _ = img_shape + upsampled_size_out = (featmap_size[0] * 4, featmap_size[1] * 4) + + # trans trans_diff. + trans_size = torch.Tensor(self.seg_num_grids).pow(2).cumsum(0).long() + trans_diff = torch.ones(trans_size[-1].item(), device=cate_preds.device).long() + num_grids = torch.ones(trans_size[-1].item(), device=cate_preds.device).long() + seg_size = torch.Tensor(self.seg_num_grids).cumsum(0).long() + seg_diff = torch.ones(trans_size[-1].item(), device=cate_preds.device).long() + strides = torch.ones(trans_size[-1].item(), device=cate_preds.device) + + n_stage = len(self.seg_num_grids) + trans_diff[:trans_size[0]] *= 0 + seg_diff[:trans_size[0]] *= 0 + num_grids[:trans_size[0]] *= self.seg_num_grids[0] + strides[:trans_size[0]] *= self.strides[0] + + for ind_ in range(1, n_stage): + trans_diff[trans_size[ind_ - 1]:trans_size[ind_]] *= trans_size[ind_ - 1] + seg_diff[trans_size[ind_ - 1]:trans_size[ind_]] *= seg_size[ind_ - 1] + num_grids[trans_size[ind_ - 1]:trans_size[ind_]] *= self.seg_num_grids[ind_] + strides[trans_size[ind_ - 1]:trans_size[ind_]] *= self.strides[ind_] + + # process. + inds = (cate_preds > cfg.score_thr) + cate_scores = cate_preds[inds] + + inds = inds.nonzero() + trans_diff = torch.index_select(trans_diff, dim=0, index=inds[:, 0]) + seg_diff = torch.index_select(seg_diff, dim=0, index=inds[:, 0]) + num_grids = torch.index_select(num_grids, dim=0, index=inds[:, 0]) + strides = torch.index_select(strides, dim=0, index=inds[:, 0]) + + y_inds = (inds[:, 0] - trans_diff) // num_grids + x_inds = (inds[:, 0] - trans_diff) % num_grids + y_inds += seg_diff + x_inds += seg_diff + + cate_labels = inds[:, 1] + seg_masks_soft = seg_preds_x[x_inds, ...] * seg_preds_y[y_inds, ...] + seg_masks = seg_masks_soft > cfg.mask_thr + sum_masks = seg_masks.sum((1, 2)).float() + keep = sum_masks > strides + + seg_masks_soft = seg_masks_soft[keep, ...] + seg_masks = seg_masks[keep, ...] + cate_scores = cate_scores[keep] + sum_masks = sum_masks[keep] + cate_labels = cate_labels[keep] + # maskness + seg_score = (seg_masks_soft * seg_masks.float()).sum((1, 2)) / sum_masks + cate_scores *= seg_score + + if len(cate_scores) == 0: + return None + + # sort and keep top nms_pre + sort_inds = torch.argsort(cate_scores, descending=True) + if len(sort_inds) > cfg.nms_pre: + sort_inds = sort_inds[:cfg.nms_pre] + seg_masks_soft = seg_masks_soft[sort_inds, :, :] + seg_masks = seg_masks[sort_inds, :, :] + cate_scores = cate_scores[sort_inds] + sum_masks = sum_masks[sort_inds] + cate_labels = cate_labels[sort_inds] + + # Matrix NMS + cate_scores = matrix_nms(seg_masks, cate_labels, cate_scores, + kernel=cfg.kernel, sigma=cfg.sigma, sum_masks=sum_masks) + + keep = cate_scores >= cfg.update_thr + seg_masks_soft = seg_masks_soft[keep, :, :] + cate_scores = cate_scores[keep] + cate_labels = cate_labels[keep] + # sort and keep top_k + sort_inds = torch.argsort(cate_scores, descending=True) + if len(sort_inds) > cfg.max_per_img: + sort_inds = sort_inds[:cfg.max_per_img] + seg_masks_soft = seg_masks_soft[sort_inds, :, :] + cate_scores = cate_scores[sort_inds] + cate_labels = cate_labels[sort_inds] + + seg_masks_soft = F.interpolate(seg_masks_soft.unsqueeze(0), + size=upsampled_size_out, + mode='bilinear')[:, :, :h, :w] + seg_masks = F.interpolate(seg_masks_soft, + size=ori_shape[:2], + mode='bilinear').squeeze(0) + seg_masks = seg_masks > cfg.mask_thr + return seg_masks, cate_labels, cate_scores diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/fcos_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/fcos_head.py new file mode 100644 index 000000000..a8c2cd411 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/fcos_head.py @@ -0,0 +1,408 @@ +import torch +import torch.nn as nn +from mmcv.cnn import normal_init + +from mmdet.core import distance2bbox, force_fp32, multi_apply, multiclass_nms +from ..builder import build_loss +from ..registry import HEADS +from ..utils import ConvModule, Scale, bias_init_with_prob + +INF = 1e8 + + +@HEADS.register_module +class FCOSHead(nn.Module): + """ + Fully Convolutional One-Stage Object Detection head from [1]_. + + The FCOS head does not use anchor boxes. Instead bounding boxes are + predicted at each pixel and a centerness measure is used to supress + low-quality predictions. + + References: + .. [1] https://arxiv.org/abs/1904.01355 + + Example: + >>> self = FCOSHead(11, 7) + >>> feats = [torch.rand(1, 7, s, s) for s in [4, 8, 16, 32, 64]] + >>> cls_score, bbox_pred, centerness = self.forward(feats) + >>> assert len(cls_score) == len(self.scales) + """ + + def __init__(self, + num_classes, + in_channels, + feat_channels=256, + stacked_convs=4, + strides=(4, 8, 16, 32, 64), + regress_ranges=((-1, 64), (64, 128), (128, 256), (256, 512), + (512, INF)), + loss_cls=dict( + type='FocalLoss', + use_sigmoid=True, + gamma=2.0, + alpha=0.25, + loss_weight=1.0), + loss_bbox=dict(type='IoULoss', loss_weight=1.0), + loss_centerness=dict( + type='CrossEntropyLoss', + use_sigmoid=True, + loss_weight=1.0), + conv_cfg=None, + norm_cfg=dict(type='GN', num_groups=32, requires_grad=True)): + super(FCOSHead, self).__init__() + + self.num_classes = num_classes + self.cls_out_channels = num_classes - 1 + self.in_channels = in_channels + self.feat_channels = feat_channels + self.stacked_convs = stacked_convs + self.strides = strides + self.regress_ranges = regress_ranges + self.loss_cls = build_loss(loss_cls) + self.loss_bbox = build_loss(loss_bbox) + self.loss_centerness = build_loss(loss_centerness) + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + self.fp16_enabled = False + + self._init_layers() + + def _init_layers(self): + self.cls_convs = nn.ModuleList() + self.reg_convs = nn.ModuleList() + for i in range(self.stacked_convs): + chn = self.in_channels if i == 0 else self.feat_channels + self.cls_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg, + bias=self.norm_cfg is None)) + self.reg_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg, + bias=self.norm_cfg is None)) + self.fcos_cls = nn.Conv2d( + self.feat_channels, self.cls_out_channels, 3, padding=1) + self.fcos_reg = nn.Conv2d(self.feat_channels, 4, 3, padding=1) + self.fcos_centerness = nn.Conv2d(self.feat_channels, 1, 3, padding=1) + + self.scales = nn.ModuleList([Scale(1.0) for _ in self.strides]) + + def init_weights(self): + for m in self.cls_convs: + normal_init(m.conv, std=0.01) + for m in self.reg_convs: + normal_init(m.conv, std=0.01) + bias_cls = bias_init_with_prob(0.01) + normal_init(self.fcos_cls, std=0.01, bias=bias_cls) + normal_init(self.fcos_reg, std=0.01) + normal_init(self.fcos_centerness, std=0.01) + + def forward(self, feats): + return multi_apply(self.forward_single, feats, self.scales) + + def forward_single(self, x, scale): + cls_feat = x + reg_feat = x + + for cls_layer in self.cls_convs: + cls_feat = cls_layer(cls_feat) + cls_score = self.fcos_cls(cls_feat) + centerness = self.fcos_centerness(cls_feat) + + for reg_layer in self.reg_convs: + reg_feat = reg_layer(reg_feat) + # scale the bbox_pred of different level + # float to avoid overflow when enabling FP16 + bbox_pred = scale(self.fcos_reg(reg_feat)).float().exp() + return cls_score, bbox_pred, centerness + + @force_fp32(apply_to=('cls_scores', 'bbox_preds', 'centernesses')) + def loss(self, + cls_scores, + bbox_preds, + centernesses, + gt_bboxes, + gt_labels, + img_metas, + cfg, + gt_bboxes_ignore=None): + assert len(cls_scores) == len(bbox_preds) == len(centernesses) + featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] + all_level_points = self.get_points(featmap_sizes, bbox_preds[0].dtype, + bbox_preds[0].device) + labels, bbox_targets = self.fcos_target(all_level_points, gt_bboxes, + gt_labels) + + num_imgs = cls_scores[0].size(0) + # flatten cls_scores, bbox_preds and centerness + flatten_cls_scores = [ + cls_score.permute(0, 2, 3, 1).reshape(-1, self.cls_out_channels) + for cls_score in cls_scores + ] + flatten_bbox_preds = [ + bbox_pred.permute(0, 2, 3, 1).reshape(-1, 4) + for bbox_pred in bbox_preds + ] + flatten_centerness = [ + centerness.permute(0, 2, 3, 1).reshape(-1) + for centerness in centernesses + ] + flatten_cls_scores = torch.cat(flatten_cls_scores) + flatten_bbox_preds = torch.cat(flatten_bbox_preds) + flatten_centerness = torch.cat(flatten_centerness) + flatten_labels = torch.cat(labels) + flatten_bbox_targets = torch.cat(bbox_targets) + # repeat points to align with bbox_preds + flatten_points = torch.cat( + [points.repeat(num_imgs, 1) for points in all_level_points]) + + pos_inds = flatten_labels.nonzero().reshape(-1) + num_pos = len(pos_inds) + loss_cls = self.loss_cls( + flatten_cls_scores, flatten_labels, + avg_factor=num_pos + num_imgs) # avoid num_pos is 0 + + pos_bbox_preds = flatten_bbox_preds[pos_inds] + pos_centerness = flatten_centerness[pos_inds] + + if num_pos > 0: + pos_bbox_targets = flatten_bbox_targets[pos_inds] + pos_centerness_targets = self.centerness_target(pos_bbox_targets) + pos_points = flatten_points[pos_inds] + pos_decoded_bbox_preds = distance2bbox(pos_points, pos_bbox_preds) + pos_decoded_target_preds = distance2bbox(pos_points, + pos_bbox_targets) + # centerness weighted iou loss + loss_bbox = self.loss_bbox( + pos_decoded_bbox_preds, + pos_decoded_target_preds, + weight=pos_centerness_targets, + avg_factor=pos_centerness_targets.sum()) + loss_centerness = self.loss_centerness(pos_centerness, + pos_centerness_targets) + else: + loss_bbox = pos_bbox_preds.sum() + loss_centerness = pos_centerness.sum() + + return dict( + loss_cls=loss_cls, + loss_bbox=loss_bbox, + loss_centerness=loss_centerness) + + @force_fp32(apply_to=('cls_scores', 'bbox_preds', 'centernesses')) + def get_bboxes(self, + cls_scores, + bbox_preds, + centernesses, + img_metas, + cfg, + rescale=None): + assert len(cls_scores) == len(bbox_preds) + num_levels = len(cls_scores) + + featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] + mlvl_points = self.get_points(featmap_sizes, bbox_preds[0].dtype, + bbox_preds[0].device) + result_list = [] + for img_id in range(len(img_metas)): + cls_score_list = [ + cls_scores[i][img_id].detach() for i in range(num_levels) + ] + bbox_pred_list = [ + bbox_preds[i][img_id].detach() for i in range(num_levels) + ] + centerness_pred_list = [ + centernesses[i][img_id].detach() for i in range(num_levels) + ] + img_shape = img_metas[img_id]['img_shape'] + scale_factor = img_metas[img_id]['scale_factor'] + det_bboxes = self.get_bboxes_single(cls_score_list, bbox_pred_list, + centerness_pred_list, + mlvl_points, img_shape, + scale_factor, cfg, rescale) + result_list.append(det_bboxes) + return result_list + + def get_bboxes_single(self, + cls_scores, + bbox_preds, + centernesses, + mlvl_points, + img_shape, + scale_factor, + cfg, + rescale=False): + assert len(cls_scores) == len(bbox_preds) == len(mlvl_points) + mlvl_bboxes = [] + mlvl_scores = [] + mlvl_centerness = [] + for cls_score, bbox_pred, centerness, points in zip( + cls_scores, bbox_preds, centernesses, mlvl_points): + assert cls_score.size()[-2:] == bbox_pred.size()[-2:] + scores = cls_score.permute(1, 2, 0).reshape( + -1, self.cls_out_channels).sigmoid() + centerness = centerness.permute(1, 2, 0).reshape(-1).sigmoid() + + bbox_pred = bbox_pred.permute(1, 2, 0).reshape(-1, 4) + nms_pre = cfg.get('nms_pre', -1) + if nms_pre > 0 and scores.shape[0] > nms_pre: + max_scores, _ = (scores * centerness[:, None]).max(dim=1) + _, topk_inds = max_scores.topk(nms_pre) + points = points[topk_inds, :] + bbox_pred = bbox_pred[topk_inds, :] + scores = scores[topk_inds, :] + centerness = centerness[topk_inds] + bboxes = distance2bbox(points, bbox_pred, max_shape=img_shape) + mlvl_bboxes.append(bboxes) + mlvl_scores.append(scores) + mlvl_centerness.append(centerness) + mlvl_bboxes = torch.cat(mlvl_bboxes) + if rescale: + mlvl_bboxes /= mlvl_bboxes.new_tensor(scale_factor) + mlvl_scores = torch.cat(mlvl_scores) + padding = mlvl_scores.new_zeros(mlvl_scores.shape[0], 1) + mlvl_scores = torch.cat([padding, mlvl_scores], dim=1) + mlvl_centerness = torch.cat(mlvl_centerness) + det_bboxes, det_labels = multiclass_nms( + mlvl_bboxes, + mlvl_scores, + cfg.score_thr, + cfg.nms, + cfg.max_per_img, + score_factors=mlvl_centerness) + return det_bboxes, det_labels + + def get_points(self, featmap_sizes, dtype, device): + """Get points according to feature map sizes. + + Args: + featmap_sizes (list[tuple]): Multi-level feature map sizes. + dtype (torch.dtype): Type of points. + device (torch.device): Device of points. + + Returns: + tuple: points of each image. + """ + mlvl_points = [] + for i in range(len(featmap_sizes)): + mlvl_points.append( + self.get_points_single(featmap_sizes[i], self.strides[i], + dtype, device)) + return mlvl_points + + def get_points_single(self, featmap_size, stride, dtype, device): + h, w = featmap_size + x_range = torch.arange( + 0, w * stride, stride, dtype=dtype, device=device) + y_range = torch.arange( + 0, h * stride, stride, dtype=dtype, device=device) + y, x = torch.meshgrid(y_range, x_range) + points = torch.stack( + (x.reshape(-1), y.reshape(-1)), dim=-1) + stride // 2 + return points + + def fcos_target(self, points, gt_bboxes_list, gt_labels_list): + assert len(points) == len(self.regress_ranges) + num_levels = len(points) + # expand regress ranges to align with points + expanded_regress_ranges = [ + points[i].new_tensor(self.regress_ranges[i])[None].expand_as( + points[i]) for i in range(num_levels) + ] + # concat all levels points and regress ranges + concat_regress_ranges = torch.cat(expanded_regress_ranges, dim=0) + concat_points = torch.cat(points, dim=0) + # get labels and bbox_targets of each image + labels_list, bbox_targets_list = multi_apply( + self.fcos_target_single, + gt_bboxes_list, + gt_labels_list, + points=concat_points, + regress_ranges=concat_regress_ranges) + + # split to per img, per level + num_points = [center.size(0) for center in points] + labels_list = [labels.split(num_points, 0) for labels in labels_list] + bbox_targets_list = [ + bbox_targets.split(num_points, 0) + for bbox_targets in bbox_targets_list + ] + + # concat per level image + concat_lvl_labels = [] + concat_lvl_bbox_targets = [] + for i in range(num_levels): + concat_lvl_labels.append( + torch.cat([labels[i] for labels in labels_list])) + concat_lvl_bbox_targets.append( + torch.cat( + [bbox_targets[i] for bbox_targets in bbox_targets_list])) + return concat_lvl_labels, concat_lvl_bbox_targets + + def fcos_target_single(self, gt_bboxes, gt_labels, points, regress_ranges): + num_points = points.size(0) + num_gts = gt_labels.size(0) + if num_gts == 0: + return gt_labels.new_zeros(num_points), \ + gt_bboxes.new_zeros((num_points, 4)) + + areas = (gt_bboxes[:, 2] - gt_bboxes[:, 0] + 1) * ( + gt_bboxes[:, 3] - gt_bboxes[:, 1] + 1) + # TODO: figure out why these two are different + # areas = areas[None].expand(num_points, num_gts) + areas = areas[None].repeat(num_points, 1) + regress_ranges = regress_ranges[:, None, :].expand( + num_points, num_gts, 2) + gt_bboxes = gt_bboxes[None].expand(num_points, num_gts, 4) + xs, ys = points[:, 0], points[:, 1] + xs = xs[:, None].expand(num_points, num_gts) + ys = ys[:, None].expand(num_points, num_gts) + + left = xs - gt_bboxes[..., 0] + right = gt_bboxes[..., 2] - xs + top = ys - gt_bboxes[..., 1] + bottom = gt_bboxes[..., 3] - ys + bbox_targets = torch.stack((left, top, right, bottom), -1) + + # condition1: inside a gt bbox + inside_gt_bbox_mask = bbox_targets.min(-1)[0] > 0 + + # condition2: limit the regression range for each location + max_regress_distance = bbox_targets.max(-1)[0] + inside_regress_range = ( + max_regress_distance >= regress_ranges[..., 0]) & ( + max_regress_distance <= regress_ranges[..., 1]) + + # if there are still more than one objects for a location, + # we choose the one with minimal area + areas[inside_gt_bbox_mask == 0] = INF + areas[inside_regress_range == 0] = INF + min_area, min_area_inds = areas.min(dim=1) + + labels = gt_labels[min_area_inds] + labels[min_area == INF] = 0 + bbox_targets = bbox_targets[range(num_points), min_area_inds] + + return labels, bbox_targets + + def centerness_target(self, pos_bbox_targets): + # only calculate pos centerness targets, otherwise there may be nan + left_right = pos_bbox_targets[:, [0, 2]] + top_bottom = pos_bbox_targets[:, [1, 3]] + centerness_targets = ( + left_right.min(dim=-1)[0] / left_right.max(dim=-1)[0]) * ( + top_bottom.min(dim=-1)[0] / top_bottom.max(dim=-1)[0]) + return torch.sqrt(centerness_targets) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/fovea_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/fovea_head.py new file mode 100644 index 000000000..a17e0b127 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/fovea_head.py @@ -0,0 +1,387 @@ +import torch +import torch.nn as nn +from mmcv.cnn import normal_init + +from mmdet.core import multi_apply, multiclass_nms +from mmdet.ops import DeformConv +from ..builder import build_loss +from ..registry import HEADS +from ..utils import ConvModule, bias_init_with_prob + +INF = 1e8 + + +class FeatureAlign(nn.Module): + + def __init__(self, + in_channels, + out_channels, + kernel_size=3, + deformable_groups=4): + super(FeatureAlign, self).__init__() + offset_channels = kernel_size * kernel_size * 2 + self.conv_offset = nn.Conv2d( + 4, deformable_groups * offset_channels, 1, bias=False) + self.conv_adaption = DeformConv( + in_channels, + out_channels, + kernel_size=kernel_size, + padding=(kernel_size - 1) // 2, + deformable_groups=deformable_groups) + self.relu = nn.ReLU(inplace=True) + + def init_weights(self): + normal_init(self.conv_offset, std=0.1) + normal_init(self.conv_adaption, std=0.01) + + def forward(self, x, shape): + offset = self.conv_offset(shape) + x = self.relu(self.conv_adaption(x, offset)) + return x + + +@HEADS.register_module +class FoveaHead(nn.Module): + """FoveaBox: Beyond Anchor-based Object Detector + https://arxiv.org/abs/1904.03797 + """ + + def __init__(self, + num_classes, + in_channels, + feat_channels=256, + stacked_convs=4, + strides=(4, 8, 16, 32, 64), + base_edge_list=(16, 32, 64, 128, 256), + scale_ranges=((8, 32), (16, 64), (32, 128), (64, 256), (128, + 512)), + sigma=0.4, + with_deform=False, + deformable_groups=4, + loss_cls=None, + loss_bbox=None, + conv_cfg=None, + norm_cfg=None): + super(FoveaHead, self).__init__() + self.num_classes = num_classes + self.cls_out_channels = num_classes - 1 + self.in_channels = in_channels + self.feat_channels = feat_channels + self.stacked_convs = stacked_convs + self.strides = strides + self.base_edge_list = base_edge_list + self.scale_ranges = scale_ranges + self.sigma = sigma + self.with_deform = with_deform + self.deformable_groups = deformable_groups + self.loss_cls = build_loss(loss_cls) + self.loss_bbox = build_loss(loss_bbox) + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + self._init_layers() + + def _init_layers(self): + self.cls_convs = nn.ModuleList() + self.reg_convs = nn.ModuleList() + # box branch + for i in range(self.stacked_convs): + chn = self.in_channels if i == 0 else self.feat_channels + self.reg_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg, + bias=self.norm_cfg is None)) + self.fovea_reg = nn.Conv2d(self.feat_channels, 4, 3, padding=1) + # cls branch + if not self.with_deform: + for i in range(self.stacked_convs): + chn = self.in_channels if i == 0 else self.feat_channels + self.cls_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg, + bias=self.norm_cfg is None)) + self.fovea_cls = nn.Conv2d( + self.feat_channels, self.cls_out_channels, 3, padding=1) + else: + self.cls_convs.append( + ConvModule( + self.feat_channels, (self.feat_channels * 4), + 3, + stride=1, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg, + bias=self.norm_cfg is None)) + self.cls_convs.append( + ConvModule((self.feat_channels * 4), (self.feat_channels * 4), + 1, + stride=1, + padding=0, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg, + bias=self.norm_cfg is None)) + self.feature_adaption = FeatureAlign( + self.feat_channels, + self.feat_channels, + kernel_size=3, + deformable_groups=self.deformable_groups) + self.fovea_cls = nn.Conv2d( + int(self.feat_channels * 4), + self.cls_out_channels, + 3, + padding=1) + + def init_weights(self): + for m in self.cls_convs: + normal_init(m.conv, std=0.01) + for m in self.reg_convs: + normal_init(m.conv, std=0.01) + bias_cls = bias_init_with_prob(0.01) + normal_init(self.fovea_cls, std=0.01, bias=bias_cls) + normal_init(self.fovea_reg, std=0.01) + if self.with_deform: + self.feature_adaption.init_weights() + + def forward(self, feats): + return multi_apply(self.forward_single, feats) + + def forward_single(self, x): + cls_feat = x + reg_feat = x + for reg_layer in self.reg_convs: + reg_feat = reg_layer(reg_feat) + bbox_pred = self.fovea_reg(reg_feat) + if self.with_deform: + cls_feat = self.feature_adaption(cls_feat, bbox_pred.exp()) + for cls_layer in self.cls_convs: + cls_feat = cls_layer(cls_feat) + cls_score = self.fovea_cls(cls_feat) + return cls_score, bbox_pred + + def get_points(self, featmap_sizes, dtype, device, flatten=False): + points = [] + for featmap_size in featmap_sizes: + x_range = torch.arange( + featmap_size[1], dtype=dtype, device=device) + 0.5 + y_range = torch.arange( + featmap_size[0], dtype=dtype, device=device) + 0.5 + y, x = torch.meshgrid(y_range, x_range) + if flatten: + points.append((y.flatten(), x.flatten())) + else: + points.append((y, x)) + return points + + def loss(self, + cls_scores, + bbox_preds, + gt_bbox_list, + gt_label_list, + img_metas, + cfg, + gt_bboxes_ignore=None): + assert len(cls_scores) == len(bbox_preds) + + featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] + points = self.get_points(featmap_sizes, bbox_preds[0].dtype, + bbox_preds[0].device) + num_imgs = cls_scores[0].size(0) + flatten_cls_scores = [ + cls_score.permute(0, 2, 3, 1).reshape(-1, self.cls_out_channels) + for cls_score in cls_scores + ] + flatten_bbox_preds = [ + bbox_pred.permute(0, 2, 3, 1).reshape(-1, 4) + for bbox_pred in bbox_preds + ] + flatten_cls_scores = torch.cat(flatten_cls_scores) + flatten_bbox_preds = torch.cat(flatten_bbox_preds) + flatten_labels, flatten_bbox_targets = self.fovea_target( + gt_bbox_list, gt_label_list, featmap_sizes, points) + pos_inds = (flatten_labels > 0).nonzero().view(-1) + num_pos = len(pos_inds) + loss_cls = self.loss_cls( + flatten_cls_scores, flatten_labels, avg_factor=num_pos + num_imgs) + if num_pos > 0: + pos_bbox_preds = flatten_bbox_preds[pos_inds] + pos_bbox_targets = flatten_bbox_targets[pos_inds] + pos_weights = pos_bbox_targets.new_zeros( + pos_bbox_targets.size()) + 1.0 + loss_bbox = self.loss_bbox( + pos_bbox_preds, + pos_bbox_targets, + pos_weights, + avg_factor=num_pos) + else: + loss_bbox = torch.tensor([0], + dtype=flatten_bbox_preds.dtype, + device=flatten_bbox_preds.device) + return dict(loss_cls=loss_cls, loss_bbox=loss_bbox) + + def fovea_target(self, gt_bbox_list, gt_label_list, featmap_sizes, points): + label_list, bbox_target_list = multi_apply( + self.fovea_target_single, + gt_bbox_list, + gt_label_list, + featmap_size_list=featmap_sizes, + point_list=points) + flatten_labels = [ + torch.cat([ + labels_level_img.flatten() for labels_level_img in labels_level + ]) for labels_level in zip(*label_list) + ] + flatten_bbox_targets = [ + torch.cat([ + bbox_targets_level_img.reshape(-1, 4) + for bbox_targets_level_img in bbox_targets_level + ]) for bbox_targets_level in zip(*bbox_target_list) + ] + flatten_labels = torch.cat(flatten_labels) + flatten_bbox_targets = torch.cat(flatten_bbox_targets) + return flatten_labels, flatten_bbox_targets + + def fovea_target_single(self, + gt_bboxes_raw, + gt_labels_raw, + featmap_size_list=None, + point_list=None): + + gt_areas = torch.sqrt((gt_bboxes_raw[:, 2] - gt_bboxes_raw[:, 0]) * + (gt_bboxes_raw[:, 3] - gt_bboxes_raw[:, 1])) + label_list = [] + bbox_target_list = [] + # for each pyramid, find the cls and box target + for base_len, (lower_bound, upper_bound), stride, featmap_size, \ + (y, x) in zip(self.base_edge_list, self.scale_ranges, + self.strides, featmap_size_list, point_list): + labels = gt_labels_raw.new_zeros(featmap_size) + bbox_targets = gt_bboxes_raw.new(featmap_size[0], featmap_size[1], + 4) + 1 + # scale assignment + hit_indices = ((gt_areas >= lower_bound) & + (gt_areas <= upper_bound)).nonzero().flatten() + if len(hit_indices) == 0: + label_list.append(labels) + bbox_target_list.append(torch.log(bbox_targets)) + continue + _, hit_index_order = torch.sort(-gt_areas[hit_indices]) + hit_indices = hit_indices[hit_index_order] + gt_bboxes = gt_bboxes_raw[hit_indices, :] / stride + gt_labels = gt_labels_raw[hit_indices] + half_w = 0.5 * (gt_bboxes[:, 2] - gt_bboxes[:, 0]) + half_h = 0.5 * (gt_bboxes[:, 3] - gt_bboxes[:, 1]) + # valid fovea area: left, right, top, down + pos_left = torch.ceil( + gt_bboxes[:, 0] + (1 - self.sigma) * half_w - 0.5).long().\ + clamp(0, featmap_size[1] - 1) + pos_right = torch.floor( + gt_bboxes[:, 0] + (1 + self.sigma) * half_w - 0.5).long().\ + clamp(0, featmap_size[1] - 1) + pos_top = torch.ceil( + gt_bboxes[:, 1] + (1 - self.sigma) * half_h - 0.5).long().\ + clamp(0, featmap_size[0] - 1) + pos_down = torch.floor( + gt_bboxes[:, 1] + (1 + self.sigma) * half_h - 0.5).long().\ + clamp(0, featmap_size[0] - 1) + for px1, py1, px2, py2, label, (gt_x1, gt_y1, gt_x2, gt_y2) in \ + zip(pos_left, pos_top, pos_right, pos_down, gt_labels, + gt_bboxes_raw[hit_indices, :]): + labels[py1:py2 + 1, px1:px2 + 1] = label + bbox_targets[py1:py2 + 1, px1:px2 + 1, 0] = \ + (stride * x[py1:py2 + 1, px1:px2 + 1] - gt_x1) / base_len + bbox_targets[py1:py2 + 1, px1:px2 + 1, 1] = \ + (stride * y[py1:py2 + 1, px1:px2 + 1] - gt_y1) / base_len + bbox_targets[py1:py2 + 1, px1:px2 + 1, 2] = \ + (gt_x2 - stride * x[py1:py2 + 1, px1:px2 + 1]) / base_len + bbox_targets[py1:py2 + 1, px1:px2 + 1, 3] = \ + (gt_y2 - stride * y[py1:py2 + 1, px1:px2 + 1]) / base_len + bbox_targets = bbox_targets.clamp(min=1. / 16, max=16.) + label_list.append(labels) + bbox_target_list.append(torch.log(bbox_targets)) + return label_list, bbox_target_list + + def get_bboxes(self, cls_scores, bbox_preds, img_metas, cfg, rescale=None): + assert len(cls_scores) == len(bbox_preds) + num_levels = len(cls_scores) + featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] + points = self.get_points( + featmap_sizes, + bbox_preds[0].dtype, + bbox_preds[0].device, + flatten=True) + result_list = [] + for img_id in range(len(img_metas)): + cls_score_list = [ + cls_scores[i][img_id].detach() for i in range(num_levels) + ] + bbox_pred_list = [ + bbox_preds[i][img_id].detach() for i in range(num_levels) + ] + img_shape = img_metas[img_id]['img_shape'] + scale_factor = img_metas[img_id]['scale_factor'] + det_bboxes = self.get_bboxes_single(cls_score_list, bbox_pred_list, + featmap_sizes, points, + img_shape, scale_factor, cfg, + rescale) + result_list.append(det_bboxes) + return result_list + + def get_bboxes_single(self, + cls_scores, + bbox_preds, + featmap_sizes, + point_list, + img_shape, + scale_factor, + cfg, + rescale=False): + assert len(cls_scores) == len(bbox_preds) == len(point_list) + det_bboxes = [] + det_scores = [] + for cls_score, bbox_pred, featmap_size, stride, base_len, (y, x) \ + in zip(cls_scores, bbox_preds, featmap_sizes, self.strides, + self.base_edge_list, point_list): + assert cls_score.size()[-2:] == bbox_pred.size()[-2:] + scores = cls_score.permute(1, 2, 0).reshape( + -1, self.cls_out_channels).sigmoid() + bbox_pred = bbox_pred.permute(1, 2, 0).reshape(-1, 4).exp() + nms_pre = cfg.get('nms_pre', -1) + if (nms_pre > 0) and (scores.shape[0] > nms_pre): + max_scores, _ = scores.max(dim=1) + _, topk_inds = max_scores.topk(nms_pre) + bbox_pred = bbox_pred[topk_inds, :] + scores = scores[topk_inds, :] + y = y[topk_inds] + x = x[topk_inds] + x1 = (stride * x - base_len * bbox_pred[:, 0]).\ + clamp(min=0, max=img_shape[1] - 1) + y1 = (stride * y - base_len * bbox_pred[:, 1]).\ + clamp(min=0, max=img_shape[0] - 1) + x2 = (stride * x + base_len * bbox_pred[:, 2]).\ + clamp(min=0, max=img_shape[1] - 1) + y2 = (stride * y + base_len * bbox_pred[:, 3]).\ + clamp(min=0, max=img_shape[0] - 1) + bboxes = torch.stack([x1, y1, x2, y2], -1) + det_bboxes.append(bboxes) + det_scores.append(scores) + det_bboxes = torch.cat(det_bboxes) + if rescale: + det_bboxes /= det_bboxes.new_tensor(scale_factor) + det_scores = torch.cat(det_scores) + padding = det_scores.new_zeros(det_scores.shape[0], 1) + det_scores = torch.cat([padding, det_scores], dim=1) + det_bboxes, det_labels = multiclass_nms(det_bboxes, det_scores, + cfg.score_thr, cfg.nms, + cfg.max_per_img) + return det_bboxes, det_labels diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/free_anchor_retina_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/free_anchor_retina_head.py new file mode 100644 index 000000000..3179aad20 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/free_anchor_retina_head.py @@ -0,0 +1,188 @@ +import torch +import torch.nn.functional as F + +from mmdet.core import bbox2delta, bbox_overlaps, delta2bbox +from ..registry import HEADS +from .retina_head import RetinaHead + + +@HEADS.register_module +class FreeAnchorRetinaHead(RetinaHead): + + def __init__(self, + num_classes, + in_channels, + stacked_convs=4, + octave_base_scale=4, + scales_per_octave=3, + conv_cfg=None, + norm_cfg=None, + pre_anchor_topk=50, + bbox_thr=0.6, + gamma=2.0, + alpha=0.5, + **kwargs): + super(FreeAnchorRetinaHead, + self).__init__(num_classes, in_channels, stacked_convs, + octave_base_scale, scales_per_octave, conv_cfg, + norm_cfg, **kwargs) + + self.pre_anchor_topk = pre_anchor_topk + self.bbox_thr = bbox_thr + self.gamma = gamma + self.alpha = alpha + + def loss(self, + cls_scores, + bbox_preds, + gt_bboxes, + gt_labels, + img_metas, + cfg, + gt_bboxes_ignore=None): + featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] + assert len(featmap_sizes) == len(self.anchor_generators) + + anchor_list, _ = self.get_anchors(featmap_sizes, img_metas) + anchors = [torch.cat(anchor) for anchor in anchor_list] + + # concatenate each level + cls_scores = [ + cls.permute(0, 2, 3, + 1).reshape(cls.size(0), -1, self.cls_out_channels) + for cls in cls_scores + ] + bbox_preds = [ + bbox_pred.permute(0, 2, 3, 1).reshape(bbox_pred.size(0), -1, 4) + for bbox_pred in bbox_preds + ] + cls_scores = torch.cat(cls_scores, dim=1) + bbox_preds = torch.cat(bbox_preds, dim=1) + + cls_prob = torch.sigmoid(cls_scores) + box_prob = [] + num_pos = 0 + positive_losses = [] + for _, (anchors_, gt_labels_, gt_bboxes_, cls_prob_, + bbox_preds_) in enumerate( + zip(anchors, gt_labels, gt_bboxes, cls_prob, bbox_preds)): + gt_labels_ -= 1 + + with torch.no_grad(): + # box_localization: a_{j}^{loc}, shape: [j, 4] + pred_boxes = delta2bbox(anchors_, bbox_preds_, + self.target_means, self.target_stds) + + # object_box_iou: IoU_{ij}^{loc}, shape: [i, j] + object_box_iou = bbox_overlaps(gt_bboxes_, pred_boxes) + + # object_box_prob: P{a_{j} -> b_{i}}, shape: [i, j] + t1 = self.bbox_thr + t2 = object_box_iou.max( + dim=1, keepdim=True).values.clamp(min=t1 + 1e-12) + object_box_prob = ((object_box_iou - t1) / (t2 - t1)).clamp( + min=0, max=1) + + # object_cls_box_prob: P{a_{j} -> b_{i}}, shape: [i, c, j] + num_obj = gt_labels_.size(0) + indices = torch.stack( + [torch.arange(num_obj).type_as(gt_labels_), gt_labels_], + dim=0) + object_cls_box_prob = torch.sparse_coo_tensor( + indices, object_box_prob) + + # image_box_iou: P{a_{j} \in A_{+}}, shape: [c, j] + """ + from "start" to "end" implement: + image_box_iou = torch.sparse.max(object_cls_box_prob, + dim=0).t() + + """ + # start + box_cls_prob = torch.sparse.sum( + object_cls_box_prob, dim=0).to_dense() + + indices = torch.nonzero(box_cls_prob).t_() + if indices.numel() == 0: + image_box_prob = torch.zeros( + anchors_.size(0), + self.cls_out_channels).type_as(object_box_prob) + else: + nonzero_box_prob = torch.where( + (gt_labels_.unsqueeze(dim=-1) == indices[0]), + object_box_prob[:, indices[1]], + torch.tensor( + [0]).type_as(object_box_prob)).max(dim=0).values + + # upmap to shape [j, c] + image_box_prob = torch.sparse_coo_tensor( + indices.flip([0]), + nonzero_box_prob, + size=(anchors_.size(0), + self.cls_out_channels)).to_dense() + # end + + box_prob.append(image_box_prob) + + # construct bags for objects + match_quality_matrix = bbox_overlaps(gt_bboxes_, anchors_) + _, matched = torch.topk( + match_quality_matrix, + self.pre_anchor_topk, + dim=1, + sorted=False) + del match_quality_matrix + + # matched_cls_prob: P_{ij}^{cls} + matched_cls_prob = torch.gather( + cls_prob_[matched], 2, + gt_labels_.view(-1, 1, 1).repeat(1, self.pre_anchor_topk, + 1)).squeeze(2) + + # matched_box_prob: P_{ij}^{loc} + matched_anchors = anchors_[matched] + matched_object_targets = bbox2delta( + matched_anchors, + gt_bboxes_.unsqueeze(dim=1).expand_as(matched_anchors), + self.target_means, self.target_stds) + loss_bbox = self.loss_bbox( + bbox_preds_[matched], + matched_object_targets, + reduction_override='none').sum(-1) + matched_box_prob = torch.exp(-loss_bbox) + + # positive_losses: {-log( Mean-max(P_{ij}^{cls} * P_{ij}^{loc}) )} + num_pos += len(gt_bboxes_) + positive_losses.append( + self.positive_bag_loss(matched_cls_prob, matched_box_prob)) + positive_loss = torch.cat(positive_losses).sum() / max(1, num_pos) + + # box_prob: P{a_{j} \in A_{+}} + box_prob = torch.stack(box_prob, dim=0) + + # negative_loss: + # \sum_{j}{ FL((1 - P{a_{j} \in A_{+}}) * (1 - P_{j}^{bg})) } / n||B|| + negative_loss = self.negative_bag_loss(cls_prob, box_prob).sum() / max( + 1, num_pos * self.pre_anchor_topk) + + losses = { + 'positive_bag_loss': positive_loss, + 'negative_bag_loss': negative_loss + } + return losses + + def positive_bag_loss(self, matched_cls_prob, matched_box_prob): + # bag_prob = Mean-max(matched_prob) + matched_prob = matched_cls_prob * matched_box_prob + weight = 1 / torch.clamp(1 - matched_prob, 1e-12, None) + weight /= weight.sum(dim=1).unsqueeze(dim=-1) + bag_prob = (weight * matched_prob).sum(dim=1) + # positive_bag_loss = -self.alpha * log(bag_prob) + return self.alpha * F.binary_cross_entropy( + bag_prob, torch.ones_like(bag_prob), reduction='none') + + def negative_bag_loss(self, cls_prob, box_prob): + prob = cls_prob * (1 - box_prob) + negative_bag_loss = prob**self.gamma * F.binary_cross_entropy( + prob, torch.zeros_like(prob), reduction='none') + return (1 - self.alpha) * negative_bag_loss diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ga_retina_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ga_retina_head.py new file mode 100644 index 000000000..73f89d725 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ga_retina_head.py @@ -0,0 +1,107 @@ +import torch.nn as nn +from mmcv.cnn import normal_init + +from mmdet.ops import MaskedConv2d +from ..registry import HEADS +from ..utils import ConvModule, bias_init_with_prob +from .guided_anchor_head import FeatureAdaption, GuidedAnchorHead + + +@HEADS.register_module +class GARetinaHead(GuidedAnchorHead): + """Guided-Anchor-based RetinaNet head.""" + + def __init__(self, + num_classes, + in_channels, + stacked_convs=4, + conv_cfg=None, + norm_cfg=None, + **kwargs): + self.stacked_convs = stacked_convs + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + super(GARetinaHead, self).__init__(num_classes, in_channels, **kwargs) + + def _init_layers(self): + self.relu = nn.ReLU(inplace=True) + self.cls_convs = nn.ModuleList() + self.reg_convs = nn.ModuleList() + for i in range(self.stacked_convs): + chn = self.in_channels if i == 0 else self.feat_channels + self.cls_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg)) + self.reg_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg)) + + self.conv_loc = nn.Conv2d(self.feat_channels, 1, 1) + self.conv_shape = nn.Conv2d(self.feat_channels, self.num_anchors * 2, + 1) + self.feature_adaption_cls = FeatureAdaption( + self.feat_channels, + self.feat_channels, + kernel_size=3, + deformable_groups=self.deformable_groups) + self.feature_adaption_reg = FeatureAdaption( + self.feat_channels, + self.feat_channels, + kernel_size=3, + deformable_groups=self.deformable_groups) + self.retina_cls = MaskedConv2d( + self.feat_channels, + self.num_anchors * self.cls_out_channels, + 3, + padding=1) + self.retina_reg = MaskedConv2d( + self.feat_channels, self.num_anchors * 4, 3, padding=1) + + def init_weights(self): + for m in self.cls_convs: + normal_init(m.conv, std=0.01) + for m in self.reg_convs: + normal_init(m.conv, std=0.01) + + self.feature_adaption_cls.init_weights() + self.feature_adaption_reg.init_weights() + + bias_cls = bias_init_with_prob(0.01) + normal_init(self.conv_loc, std=0.01, bias=bias_cls) + normal_init(self.conv_shape, std=0.01) + normal_init(self.retina_cls, std=0.01, bias=bias_cls) + normal_init(self.retina_reg, std=0.01) + + def forward_single(self, x): + cls_feat = x + reg_feat = x + for cls_conv in self.cls_convs: + cls_feat = cls_conv(cls_feat) + for reg_conv in self.reg_convs: + reg_feat = reg_conv(reg_feat) + + loc_pred = self.conv_loc(cls_feat) + shape_pred = self.conv_shape(reg_feat) + + cls_feat = self.feature_adaption_cls(cls_feat, shape_pred) + reg_feat = self.feature_adaption_reg(reg_feat, shape_pred) + + if not self.training: + mask = loc_pred.sigmoid()[0] >= self.loc_filter_thr + else: + mask = None + cls_score = self.retina_cls(cls_feat, mask) + bbox_pred = self.retina_reg(reg_feat, mask) + return cls_score, bbox_pred, shape_pred, loc_pred diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ga_rpn_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ga_rpn_head.py new file mode 100644 index 000000000..11512ffc5 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ga_rpn_head.py @@ -0,0 +1,127 @@ +import torch +import torch.nn as nn +import torch.nn.functional as F +from mmcv.cnn import normal_init + +from mmdet.core import delta2bbox +from mmdet.ops import nms +from ..registry import HEADS +from .guided_anchor_head import GuidedAnchorHead + + +@HEADS.register_module +class GARPNHead(GuidedAnchorHead): + """Guided-Anchor-based RPN head.""" + + def __init__(self, in_channels, **kwargs): + super(GARPNHead, self).__init__(2, in_channels, **kwargs) + + def _init_layers(self): + self.rpn_conv = nn.Conv2d( + self.in_channels, self.feat_channels, 3, padding=1) + super(GARPNHead, self)._init_layers() + + def init_weights(self): + normal_init(self.rpn_conv, std=0.01) + super(GARPNHead, self).init_weights() + + def forward_single(self, x): + x = self.rpn_conv(x) + x = F.relu(x, inplace=True) + (cls_score, bbox_pred, shape_pred, + loc_pred) = super(GARPNHead, self).forward_single(x) + return cls_score, bbox_pred, shape_pred, loc_pred + + def loss(self, + cls_scores, + bbox_preds, + shape_preds, + loc_preds, + gt_bboxes, + img_metas, + cfg, + gt_bboxes_ignore=None): + losses = super(GARPNHead, self).loss( + cls_scores, + bbox_preds, + shape_preds, + loc_preds, + gt_bboxes, + None, + img_metas, + cfg, + gt_bboxes_ignore=gt_bboxes_ignore) + return dict( + loss_rpn_cls=losses['loss_cls'], + loss_rpn_bbox=losses['loss_bbox'], + loss_anchor_shape=losses['loss_shape'], + loss_anchor_loc=losses['loss_loc']) + + def get_bboxes_single(self, + cls_scores, + bbox_preds, + mlvl_anchors, + mlvl_masks, + img_shape, + scale_factor, + cfg, + rescale=False): + mlvl_proposals = [] + for idx in range(len(cls_scores)): + rpn_cls_score = cls_scores[idx] + rpn_bbox_pred = bbox_preds[idx] + anchors = mlvl_anchors[idx] + mask = mlvl_masks[idx] + assert rpn_cls_score.size()[-2:] == rpn_bbox_pred.size()[-2:] + # if no location is kept, end. + if mask.sum() == 0: + continue + rpn_cls_score = rpn_cls_score.permute(1, 2, 0) + if self.use_sigmoid_cls: + rpn_cls_score = rpn_cls_score.reshape(-1) + scores = rpn_cls_score.sigmoid() + else: + rpn_cls_score = rpn_cls_score.reshape(-1, 2) + scores = rpn_cls_score.softmax(dim=1)[:, 1] + # filter scores, bbox_pred w.r.t. mask. + # anchors are filtered in get_anchors() beforehand. + scores = scores[mask] + rpn_bbox_pred = rpn_bbox_pred.permute(1, 2, 0).reshape(-1, + 4)[mask, :] + if scores.dim() == 0: + rpn_bbox_pred = rpn_bbox_pred.unsqueeze(0) + anchors = anchors.unsqueeze(0) + scores = scores.unsqueeze(0) + # filter anchors, bbox_pred, scores w.r.t. scores + if cfg.nms_pre > 0 and scores.shape[0] > cfg.nms_pre: + _, topk_inds = scores.topk(cfg.nms_pre) + rpn_bbox_pred = rpn_bbox_pred[topk_inds, :] + anchors = anchors[topk_inds, :] + scores = scores[topk_inds] + # get proposals w.r.t. anchors and rpn_bbox_pred + proposals = delta2bbox(anchors, rpn_bbox_pred, self.target_means, + self.target_stds, img_shape) + # filter out too small bboxes + if cfg.min_bbox_size > 0: + w = proposals[:, 2] - proposals[:, 0] + 1 + h = proposals[:, 3] - proposals[:, 1] + 1 + valid_inds = torch.nonzero((w >= cfg.min_bbox_size) & + (h >= cfg.min_bbox_size)).squeeze() + proposals = proposals[valid_inds, :] + scores = scores[valid_inds] + proposals = torch.cat([proposals, scores.unsqueeze(-1)], dim=-1) + # NMS in current level + proposals, _ = nms(proposals, cfg.nms_thr) + proposals = proposals[:cfg.nms_post, :] + mlvl_proposals.append(proposals) + proposals = torch.cat(mlvl_proposals, 0) + if cfg.nms_across_levels: + # NMS across multi levels + proposals, _ = nms(proposals, cfg.nms_thr) + proposals = proposals[:cfg.max_num, :] + else: + scores = proposals[:, 4] + num = min(cfg.max_num, proposals.shape[0]) + _, topk_inds = scores.topk(num) + proposals = proposals[topk_inds, :] + return proposals diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/guided_anchor_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/guided_anchor_head.py new file mode 100644 index 000000000..9fdf4f664 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/guided_anchor_head.py @@ -0,0 +1,621 @@ +from __future__ import division + +import numpy as np +import torch +import torch.nn as nn +from mmcv.cnn import normal_init + +from mmdet.core import (AnchorGenerator, anchor_inside_flags, anchor_target, + delta2bbox, force_fp32, ga_loc_target, ga_shape_target, + multi_apply, multiclass_nms) +from mmdet.ops import DeformConv, MaskedConv2d +from ..builder import build_loss +from ..registry import HEADS +from ..utils import bias_init_with_prob +from .anchor_head import AnchorHead + + +class FeatureAdaption(nn.Module): + """Feature Adaption Module. + + Feature Adaption Module is implemented based on DCN v1. + It uses anchor shape prediction rather than feature map to + predict offsets of deformable conv layer. + + Args: + in_channels (int): Number of channels in the input feature map. + out_channels (int): Number of channels in the output feature map. + kernel_size (int): Deformable conv kernel size. + deformable_groups (int): Deformable conv group size. + """ + + def __init__(self, + in_channels, + out_channels, + kernel_size=3, + deformable_groups=4): + super(FeatureAdaption, self).__init__() + offset_channels = kernel_size * kernel_size * 2 + self.conv_offset = nn.Conv2d( + 2, deformable_groups * offset_channels, 1, bias=False) + self.conv_adaption = DeformConv( + in_channels, + out_channels, + kernel_size=kernel_size, + padding=(kernel_size - 1) // 2, + deformable_groups=deformable_groups) + self.relu = nn.ReLU(inplace=True) + + def init_weights(self): + normal_init(self.conv_offset, std=0.1) + normal_init(self.conv_adaption, std=0.01) + + def forward(self, x, shape): + offset = self.conv_offset(shape.detach()) + x = self.relu(self.conv_adaption(x, offset)) + return x + + +@HEADS.register_module +class GuidedAnchorHead(AnchorHead): + """Guided-Anchor-based head (GA-RPN, GA-RetinaNet, etc.). + + This GuidedAnchorHead will predict high-quality feature guided + anchors and locations where anchors will be kept in inference. + There are mainly 3 categories of bounding-boxes. + - Sampled (9) pairs for target assignment. (approxes) + - The square boxes where the predicted anchors are based on. + (squares) + - Guided anchors. + Please refer to https://arxiv.org/abs/1901.03278 for more details. + + Args: + num_classes (int): Number of classes. + in_channels (int): Number of channels in the input feature map. + feat_channels (int): Number of hidden channels. + octave_base_scale (int): Base octave scale of each level of + feature map. + scales_per_octave (int): Number of octave scales in each level of + feature map + octave_ratios (Iterable): octave aspect ratios. + anchor_strides (Iterable): Anchor strides. + anchor_base_sizes (Iterable): Anchor base sizes. + anchoring_means (Iterable): Mean values of anchoring targets. + anchoring_stds (Iterable): Std values of anchoring targets. + target_means (Iterable): Mean values of regression targets. + target_stds (Iterable): Std values of regression targets. + deformable_groups: (int): Group number of DCN in + FeatureAdaption module. + loc_filter_thr (float): Threshold to filter out unconcerned regions. + loss_loc (dict): Config of location loss. + loss_shape (dict): Config of anchor shape loss. + loss_cls (dict): Config of classification loss. + loss_bbox (dict): Config of bbox regression loss. + """ + + def __init__( + self, + num_classes, + in_channels, + feat_channels=256, + octave_base_scale=8, + scales_per_octave=3, + octave_ratios=[0.5, 1.0, 2.0], + anchor_strides=[4, 8, 16, 32, 64], + anchor_base_sizes=None, + anchoring_means=(.0, .0, .0, .0), + anchoring_stds=(1.0, 1.0, 1.0, 1.0), + target_means=(.0, .0, .0, .0), + target_stds=(1.0, 1.0, 1.0, 1.0), + deformable_groups=4, + loc_filter_thr=0.01, + loss_loc=dict( + type='FocalLoss', + use_sigmoid=True, + gamma=2.0, + alpha=0.25, + loss_weight=1.0), + loss_shape=dict(type='BoundedIoULoss', beta=0.2, loss_weight=1.0), + loss_cls=dict( + type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0), + loss_bbox=dict(type='SmoothL1Loss', beta=1.0, + loss_weight=1.0)): # yapf: disable + super(AnchorHead, self).__init__() + self.in_channels = in_channels + self.num_classes = num_classes + self.feat_channels = feat_channels + self.octave_base_scale = octave_base_scale + self.scales_per_octave = scales_per_octave + self.octave_scales = octave_base_scale * np.array( + [2**(i / scales_per_octave) for i in range(scales_per_octave)]) + self.approxs_per_octave = len(self.octave_scales) * len(octave_ratios) + self.octave_ratios = octave_ratios + self.anchor_strides = anchor_strides + self.anchor_base_sizes = list( + anchor_strides) if anchor_base_sizes is None else anchor_base_sizes + self.anchoring_means = anchoring_means + self.anchoring_stds = anchoring_stds + self.target_means = target_means + self.target_stds = target_stds + self.deformable_groups = deformable_groups + self.loc_filter_thr = loc_filter_thr + self.approx_generators = [] + self.square_generators = [] + for anchor_base in self.anchor_base_sizes: + # Generators for approxs + self.approx_generators.append( + AnchorGenerator(anchor_base, self.octave_scales, + self.octave_ratios)) + # Generators for squares + self.square_generators.append( + AnchorGenerator(anchor_base, [self.octave_base_scale], [1.0])) + # one anchor per location + self.num_anchors = 1 + self.use_sigmoid_cls = loss_cls.get('use_sigmoid', False) + self.cls_focal_loss = loss_cls['type'] in ['FocalLoss'] + self.loc_focal_loss = loss_loc['type'] in ['FocalLoss'] + if self.use_sigmoid_cls: + self.cls_out_channels = self.num_classes - 1 + else: + self.cls_out_channels = self.num_classes + + # build losses + self.loss_loc = build_loss(loss_loc) + self.loss_shape = build_loss(loss_shape) + self.loss_cls = build_loss(loss_cls) + self.loss_bbox = build_loss(loss_bbox) + + self.fp16_enabled = False + + self._init_layers() + + def _init_layers(self): + self.relu = nn.ReLU(inplace=True) + self.conv_loc = nn.Conv2d(self.in_channels, 1, 1) + self.conv_shape = nn.Conv2d(self.in_channels, self.num_anchors * 2, 1) + self.feature_adaption = FeatureAdaption( + self.in_channels, + self.feat_channels, + kernel_size=3, + deformable_groups=self.deformable_groups) + self.conv_cls = MaskedConv2d(self.feat_channels, + self.num_anchors * self.cls_out_channels, + 1) + self.conv_reg = MaskedConv2d(self.feat_channels, self.num_anchors * 4, + 1) + + def init_weights(self): + normal_init(self.conv_cls, std=0.01) + normal_init(self.conv_reg, std=0.01) + + bias_cls = bias_init_with_prob(0.01) + normal_init(self.conv_loc, std=0.01, bias=bias_cls) + normal_init(self.conv_shape, std=0.01) + + self.feature_adaption.init_weights() + + def forward_single(self, x): + loc_pred = self.conv_loc(x) + shape_pred = self.conv_shape(x) + x = self.feature_adaption(x, shape_pred) + # masked conv is only used during inference for speed-up + if not self.training: + mask = loc_pred.sigmoid()[0] >= self.loc_filter_thr + else: + mask = None + cls_score = self.conv_cls(x, mask) + bbox_pred = self.conv_reg(x, mask) + return cls_score, bbox_pred, shape_pred, loc_pred + + def forward(self, feats): + return multi_apply(self.forward_single, feats) + + def get_sampled_approxs(self, + featmap_sizes, + img_metas, + cfg, + device='cuda'): + """Get sampled approxs and inside flags according to feature map sizes. + + Args: + featmap_sizes (list[tuple]): Multi-level feature map sizes. + img_metas (list[dict]): Image meta info. + device (torch.device | str): device for returned tensors + + Returns: + tuple: approxes of each image, inside flags of each image + """ + num_imgs = len(img_metas) + num_levels = len(featmap_sizes) + + # since feature map sizes of all images are the same, we only compute + # approxes for one time + multi_level_approxs = [] + for i in range(num_levels): + approxs = self.approx_generators[i].grid_anchors( + featmap_sizes[i], self.anchor_strides[i], device=device) + multi_level_approxs.append(approxs) + approxs_list = [multi_level_approxs for _ in range(num_imgs)] + + # for each image, we compute inside flags of multi level approxes + inside_flag_list = [] + for img_id, img_meta in enumerate(img_metas): + multi_level_flags = [] + multi_level_approxs = approxs_list[img_id] + for i in range(num_levels): + approxs = multi_level_approxs[i] + anchor_stride = self.anchor_strides[i] + feat_h, feat_w = featmap_sizes[i] + h, w = img_meta['pad_shape'][:2] + valid_feat_h = min(int(np.ceil(h / anchor_stride)), feat_h) + valid_feat_w = min(int(np.ceil(w / anchor_stride)), feat_w) + flags = self.approx_generators[i].valid_flags( + (feat_h, feat_w), (valid_feat_h, valid_feat_w), + device=device) + inside_flags_list = [] + for i in range(self.approxs_per_octave): + split_valid_flags = flags[i::self.approxs_per_octave] + split_approxs = approxs[i::self.approxs_per_octave, :] + inside_flags = anchor_inside_flags( + split_approxs, split_valid_flags, + img_meta['img_shape'][:2], cfg.allowed_border) + inside_flags_list.append(inside_flags) + # inside_flag for a position is true if any anchor in this + # position is true + inside_flags = ( + torch.stack(inside_flags_list, 0).sum(dim=0) > 0) + multi_level_flags.append(inside_flags) + inside_flag_list.append(multi_level_flags) + return approxs_list, inside_flag_list + + def get_anchors(self, + featmap_sizes, + shape_preds, + loc_preds, + img_metas, + use_loc_filter=False, + device='cuda'): + """Get squares according to feature map sizes and guided + anchors. + + Args: + featmap_sizes (list[tuple]): Multi-level feature map sizes. + shape_preds (list[tensor]): Multi-level shape predictions. + loc_preds (list[tensor]): Multi-level location predictions. + img_metas (list[dict]): Image meta info. + use_loc_filter (bool): Use loc filter or not. + device (torch.device | str): device for returned tensors + + Returns: + tuple: square approxs of each image, guided anchors of each image, + loc masks of each image + """ + num_imgs = len(img_metas) + num_levels = len(featmap_sizes) + + # since feature map sizes of all images are the same, we only compute + # squares for one time + multi_level_squares = [] + for i in range(num_levels): + squares = self.square_generators[i].grid_anchors( + featmap_sizes[i], self.anchor_strides[i], device=device) + multi_level_squares.append(squares) + squares_list = [multi_level_squares for _ in range(num_imgs)] + + # for each image, we compute multi level guided anchors + guided_anchors_list = [] + loc_mask_list = [] + for img_id, img_meta in enumerate(img_metas): + multi_level_guided_anchors = [] + multi_level_loc_mask = [] + for i in range(num_levels): + squares = squares_list[img_id][i] + shape_pred = shape_preds[i][img_id] + loc_pred = loc_preds[i][img_id] + guided_anchors, loc_mask = self.get_guided_anchors_single( + squares, + shape_pred, + loc_pred, + use_loc_filter=use_loc_filter) + multi_level_guided_anchors.append(guided_anchors) + multi_level_loc_mask.append(loc_mask) + guided_anchors_list.append(multi_level_guided_anchors) + loc_mask_list.append(multi_level_loc_mask) + return squares_list, guided_anchors_list, loc_mask_list + + def get_guided_anchors_single(self, + squares, + shape_pred, + loc_pred, + use_loc_filter=False): + """Get guided anchors and loc masks for a single level. + + Args: + square (tensor): Squares of a single level. + shape_pred (tensor): Shape predections of a single level. + loc_pred (tensor): Loc predections of a single level. + use_loc_filter (list[tensor]): Use loc filter or not. + + Returns: + tuple: guided anchors, location masks + """ + # calculate location filtering mask + loc_pred = loc_pred.sigmoid().detach() + if use_loc_filter: + loc_mask = loc_pred >= self.loc_filter_thr + else: + loc_mask = loc_pred >= 0.0 + mask = loc_mask.permute(1, 2, 0).expand(-1, -1, self.num_anchors) + mask = mask.contiguous().view(-1) + # calculate guided anchors + squares = squares[mask] + anchor_deltas = shape_pred.permute(1, 2, 0).contiguous().view( + -1, 2).detach()[mask] + bbox_deltas = anchor_deltas.new_full(squares.size(), 0) + bbox_deltas[:, 2:] = anchor_deltas + guided_anchors = delta2bbox( + squares, + bbox_deltas, + self.anchoring_means, + self.anchoring_stds, + wh_ratio_clip=1e-6) + return guided_anchors, mask + + def loss_shape_single(self, shape_pred, bbox_anchors, bbox_gts, + anchor_weights, anchor_total_num): + shape_pred = shape_pred.permute(0, 2, 3, 1).contiguous().view(-1, 2) + bbox_anchors = bbox_anchors.contiguous().view(-1, 4) + bbox_gts = bbox_gts.contiguous().view(-1, 4) + anchor_weights = anchor_weights.contiguous().view(-1, 4) + bbox_deltas = bbox_anchors.new_full(bbox_anchors.size(), 0) + bbox_deltas[:, 2:] += shape_pred + # filter out negative samples to speed-up weighted_bounded_iou_loss + inds = torch.nonzero(anchor_weights[:, 0] > 0).squeeze(1) + bbox_deltas_ = bbox_deltas[inds] + bbox_anchors_ = bbox_anchors[inds] + bbox_gts_ = bbox_gts[inds] + anchor_weights_ = anchor_weights[inds] + pred_anchors_ = delta2bbox( + bbox_anchors_, + bbox_deltas_, + self.anchoring_means, + self.anchoring_stds, + wh_ratio_clip=1e-6) + loss_shape = self.loss_shape( + pred_anchors_, + bbox_gts_, + anchor_weights_, + avg_factor=anchor_total_num) + return loss_shape + + def loss_loc_single(self, loc_pred, loc_target, loc_weight, loc_avg_factor, + cfg): + loss_loc = self.loss_loc( + loc_pred.reshape(-1, 1), + loc_target.reshape(-1, 1).long(), + loc_weight.reshape(-1, 1), + avg_factor=loc_avg_factor) + return loss_loc + + @force_fp32( + apply_to=('cls_scores', 'bbox_preds', 'shape_preds', 'loc_preds')) + def loss(self, + cls_scores, + bbox_preds, + shape_preds, + loc_preds, + gt_bboxes, + gt_labels, + img_metas, + cfg, + gt_bboxes_ignore=None): + featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] + assert len(featmap_sizes) == len(self.approx_generators) + + device = cls_scores[0].device + + # get loc targets + loc_targets, loc_weights, loc_avg_factor = ga_loc_target( + gt_bboxes, + featmap_sizes, + self.octave_base_scale, + self.anchor_strides, + center_ratio=cfg.center_ratio, + ignore_ratio=cfg.ignore_ratio) + + # get sampled approxes + approxs_list, inside_flag_list = self.get_sampled_approxs( + featmap_sizes, img_metas, cfg, device=device) + # get squares and guided anchors + squares_list, guided_anchors_list, _ = self.get_anchors( + featmap_sizes, shape_preds, loc_preds, img_metas, device=device) + + # get shape targets + sampling = False if not hasattr(cfg, 'ga_sampler') else True + shape_targets = ga_shape_target( + approxs_list, + inside_flag_list, + squares_list, + gt_bboxes, + img_metas, + self.approxs_per_octave, + cfg, + sampling=sampling) + if shape_targets is None: + return None + (bbox_anchors_list, bbox_gts_list, anchor_weights_list, anchor_fg_num, + anchor_bg_num) = shape_targets + anchor_total_num = ( + anchor_fg_num if not sampling else anchor_fg_num + anchor_bg_num) + + # get anchor targets + sampling = False if self.cls_focal_loss else True + label_channels = self.cls_out_channels if self.use_sigmoid_cls else 1 + cls_reg_targets = anchor_target( + guided_anchors_list, + inside_flag_list, + gt_bboxes, + img_metas, + self.target_means, + self.target_stds, + cfg, + gt_bboxes_ignore_list=gt_bboxes_ignore, + gt_labels_list=gt_labels, + label_channels=label_channels, + sampling=sampling) + if cls_reg_targets is None: + return None + (labels_list, label_weights_list, bbox_targets_list, bbox_weights_list, + num_total_pos, num_total_neg) = cls_reg_targets + num_total_samples = ( + num_total_pos if self.cls_focal_loss else num_total_pos + + num_total_neg) + + # get classification and bbox regression losses + losses_cls, losses_bbox = multi_apply( + self.loss_single, + cls_scores, + bbox_preds, + labels_list, + label_weights_list, + bbox_targets_list, + bbox_weights_list, + num_total_samples=num_total_samples, + cfg=cfg) + + # get anchor location loss + losses_loc = [] + for i in range(len(loc_preds)): + loss_loc = self.loss_loc_single( + loc_preds[i], + loc_targets[i], + loc_weights[i], + loc_avg_factor=loc_avg_factor, + cfg=cfg) + losses_loc.append(loss_loc) + + # get anchor shape loss + losses_shape = [] + for i in range(len(shape_preds)): + loss_shape = self.loss_shape_single( + shape_preds[i], + bbox_anchors_list[i], + bbox_gts_list[i], + anchor_weights_list[i], + anchor_total_num=anchor_total_num) + losses_shape.append(loss_shape) + + return dict( + loss_cls=losses_cls, + loss_bbox=losses_bbox, + loss_shape=losses_shape, + loss_loc=losses_loc) + + @force_fp32( + apply_to=('cls_scores', 'bbox_preds', 'shape_preds', 'loc_preds')) + def get_bboxes(self, + cls_scores, + bbox_preds, + shape_preds, + loc_preds, + img_metas, + cfg, + rescale=False): + assert len(cls_scores) == len(bbox_preds) == len(shape_preds) == len( + loc_preds) + num_levels = len(cls_scores) + featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] + device = cls_scores[0].device + # get guided anchors + _, guided_anchors, loc_masks = self.get_anchors( + featmap_sizes, + shape_preds, + loc_preds, + img_metas, + use_loc_filter=not self.training, + device=device) + result_list = [] + for img_id in range(len(img_metas)): + cls_score_list = [ + cls_scores[i][img_id].detach() for i in range(num_levels) + ] + bbox_pred_list = [ + bbox_preds[i][img_id].detach() for i in range(num_levels) + ] + guided_anchor_list = [ + guided_anchors[img_id][i].detach() for i in range(num_levels) + ] + loc_mask_list = [ + loc_masks[img_id][i].detach() for i in range(num_levels) + ] + img_shape = img_metas[img_id]['img_shape'] + scale_factor = img_metas[img_id]['scale_factor'] + proposals = self.get_bboxes_single(cls_score_list, bbox_pred_list, + guided_anchor_list, + loc_mask_list, img_shape, + scale_factor, cfg, rescale) + result_list.append(proposals) + return result_list + + def get_bboxes_single(self, + cls_scores, + bbox_preds, + mlvl_anchors, + mlvl_masks, + img_shape, + scale_factor, + cfg, + rescale=False): + assert len(cls_scores) == len(bbox_preds) == len(mlvl_anchors) + mlvl_bboxes = [] + mlvl_scores = [] + for cls_score, bbox_pred, anchors, mask in zip(cls_scores, bbox_preds, + mlvl_anchors, + mlvl_masks): + assert cls_score.size()[-2:] == bbox_pred.size()[-2:] + # if no location is kept, end. + if mask.sum() == 0: + continue + # reshape scores and bbox_pred + cls_score = cls_score.permute(1, 2, + 0).reshape(-1, self.cls_out_channels) + if self.use_sigmoid_cls: + scores = cls_score.sigmoid() + else: + scores = cls_score.softmax(-1) + bbox_pred = bbox_pred.permute(1, 2, 0).reshape(-1, 4) + # filter scores, bbox_pred w.r.t. mask. + # anchors are filtered in get_anchors() beforehand. + scores = scores[mask, :] + bbox_pred = bbox_pred[mask, :] + if scores.dim() == 0: + anchors = anchors.unsqueeze(0) + scores = scores.unsqueeze(0) + bbox_pred = bbox_pred.unsqueeze(0) + # filter anchors, bbox_pred, scores w.r.t. scores + nms_pre = cfg.get('nms_pre', -1) + if nms_pre > 0 and scores.shape[0] > nms_pre: + if self.use_sigmoid_cls: + max_scores, _ = scores.max(dim=1) + else: + max_scores, _ = scores[:, 1:].max(dim=1) + _, topk_inds = max_scores.topk(nms_pre) + anchors = anchors[topk_inds, :] + bbox_pred = bbox_pred[topk_inds, :] + scores = scores[topk_inds, :] + bboxes = delta2bbox(anchors, bbox_pred, self.target_means, + self.target_stds, img_shape) + mlvl_bboxes.append(bboxes) + mlvl_scores.append(scores) + mlvl_bboxes = torch.cat(mlvl_bboxes) + if rescale: + mlvl_bboxes /= mlvl_bboxes.new_tensor(scale_factor) + mlvl_scores = torch.cat(mlvl_scores) + if self.use_sigmoid_cls: + padding = mlvl_scores.new_zeros(mlvl_scores.shape[0], 1) + mlvl_scores = torch.cat([padding, mlvl_scores], dim=1) + # multi class NMS + det_bboxes, det_labels = multiclass_nms(mlvl_bboxes, mlvl_scores, + cfg.score_thr, cfg.nms, + cfg.max_per_img) + return det_bboxes, det_labels diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/reppoints_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/reppoints_head.py new file mode 100644 index 000000000..b3214f357 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/reppoints_head.py @@ -0,0 +1,596 @@ +from __future__ import division + +import numpy as np +import torch +import torch.nn as nn +from mmcv.cnn import normal_init + +from mmdet.core import (PointGenerator, multi_apply, multiclass_nms, + point_target) +from mmdet.ops import DeformConv +from ..builder import build_loss +from ..registry import HEADS +from ..utils import ConvModule, bias_init_with_prob + + +@HEADS.register_module +class RepPointsHead(nn.Module): + """RepPoint head. + + Args: + in_channels (int): Number of channels in the input feature map. + feat_channels (int): Number of channels of the feature map. + point_feat_channels (int): Number of channels of points features. + stacked_convs (int): How many conv layers are used. + gradient_mul (float): The multiplier to gradients from + points refinement and recognition. + point_strides (Iterable): points strides. + point_base_scale (int): bbox scale for assigning labels. + loss_cls (dict): Config of classification loss. + loss_bbox_init (dict): Config of initial points loss. + loss_bbox_refine (dict): Config of points loss in refinement. + use_grid_points (bool): If we use bounding box representation, the + reppoints is represented as grid points on the bounding box. + center_init (bool): Whether to use center point assignment. + transform_method (str): The methods to transform RepPoints to bbox. + """ # noqa: W605 + + def __init__(self, + num_classes, + in_channels, + feat_channels=256, + point_feat_channels=256, + stacked_convs=3, + num_points=9, + gradient_mul=0.1, + point_strides=[8, 16, 32, 64, 128], + point_base_scale=4, + conv_cfg=None, + norm_cfg=None, + loss_cls=dict( + type='FocalLoss', + use_sigmoid=True, + gamma=2.0, + alpha=0.25, + loss_weight=1.0), + loss_bbox_init=dict( + type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=0.5), + loss_bbox_refine=dict( + type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0), + use_grid_points=False, + center_init=True, + transform_method='moment', + moment_mul=0.01): + super(RepPointsHead, self).__init__() + self.in_channels = in_channels + self.num_classes = num_classes + self.feat_channels = feat_channels + self.point_feat_channels = point_feat_channels + self.stacked_convs = stacked_convs + self.num_points = num_points + self.gradient_mul = gradient_mul + self.point_base_scale = point_base_scale + self.point_strides = point_strides + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + self.use_sigmoid_cls = loss_cls.get('use_sigmoid', False) + self.sampling = loss_cls['type'] not in ['FocalLoss'] + self.loss_cls = build_loss(loss_cls) + self.loss_bbox_init = build_loss(loss_bbox_init) + self.loss_bbox_refine = build_loss(loss_bbox_refine) + self.use_grid_points = use_grid_points + self.center_init = center_init + self.transform_method = transform_method + if self.transform_method == 'moment': + self.moment_transfer = nn.Parameter( + data=torch.zeros(2), requires_grad=True) + self.moment_mul = moment_mul + if self.use_sigmoid_cls: + self.cls_out_channels = self.num_classes - 1 + else: + self.cls_out_channels = self.num_classes + self.point_generators = [PointGenerator() for _ in self.point_strides] + # we use deformable conv to extract points features + self.dcn_kernel = int(np.sqrt(num_points)) + self.dcn_pad = int((self.dcn_kernel - 1) / 2) + assert self.dcn_kernel * self.dcn_kernel == num_points, \ + "The points number should be a square number." + assert self.dcn_kernel % 2 == 1, \ + "The points number should be an odd square number." + dcn_base = np.arange(-self.dcn_pad, + self.dcn_pad + 1).astype(np.float64) + dcn_base_y = np.repeat(dcn_base, self.dcn_kernel) + dcn_base_x = np.tile(dcn_base, self.dcn_kernel) + dcn_base_offset = np.stack([dcn_base_y, dcn_base_x], axis=1).reshape( + (-1)) + self.dcn_base_offset = torch.tensor(dcn_base_offset).view(1, -1, 1, 1) + self._init_layers() + + def _init_layers(self): + self.relu = nn.ReLU(inplace=True) + self.cls_convs = nn.ModuleList() + self.reg_convs = nn.ModuleList() + for i in range(self.stacked_convs): + chn = self.in_channels if i == 0 else self.feat_channels + self.cls_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg)) + self.reg_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg)) + pts_out_dim = 4 if self.use_grid_points else 2 * self.num_points + self.reppoints_cls_conv = DeformConv(self.feat_channels, + self.point_feat_channels, + self.dcn_kernel, 1, self.dcn_pad) + self.reppoints_cls_out = nn.Conv2d(self.point_feat_channels, + self.cls_out_channels, 1, 1, 0) + self.reppoints_pts_init_conv = nn.Conv2d(self.feat_channels, + self.point_feat_channels, 3, + 1, 1) + self.reppoints_pts_init_out = nn.Conv2d(self.point_feat_channels, + pts_out_dim, 1, 1, 0) + self.reppoints_pts_refine_conv = DeformConv(self.feat_channels, + self.point_feat_channels, + self.dcn_kernel, 1, + self.dcn_pad) + self.reppoints_pts_refine_out = nn.Conv2d(self.point_feat_channels, + pts_out_dim, 1, 1, 0) + + def init_weights(self): + for m in self.cls_convs: + normal_init(m.conv, std=0.01) + for m in self.reg_convs: + normal_init(m.conv, std=0.01) + bias_cls = bias_init_with_prob(0.01) + normal_init(self.reppoints_cls_conv, std=0.01) + normal_init(self.reppoints_cls_out, std=0.01, bias=bias_cls) + normal_init(self.reppoints_pts_init_conv, std=0.01) + normal_init(self.reppoints_pts_init_out, std=0.01) + normal_init(self.reppoints_pts_refine_conv, std=0.01) + normal_init(self.reppoints_pts_refine_out, std=0.01) + + def points2bbox(self, pts, y_first=True): + """ + Converting the points set into bounding box. + :param pts: the input points sets (fields), each points + set (fields) is represented as 2n scalar. + :param y_first: if y_fisrt=True, the point set is represented as + [y1, x1, y2, x2 ... yn, xn], otherwise the point set is + represented as [x1, y1, x2, y2 ... xn, yn]. + :return: each points set is converting to a bbox [x1, y1, x2, y2]. + """ + pts_reshape = pts.view(pts.shape[0], -1, 2, *pts.shape[2:]) + pts_y = pts_reshape[:, :, 0, ...] if y_first else pts_reshape[:, :, 1, + ...] + pts_x = pts_reshape[:, :, 1, ...] if y_first else pts_reshape[:, :, 0, + ...] + if self.transform_method == 'minmax': + bbox_left = pts_x.min(dim=1, keepdim=True)[0] + bbox_right = pts_x.max(dim=1, keepdim=True)[0] + bbox_up = pts_y.min(dim=1, keepdim=True)[0] + bbox_bottom = pts_y.max(dim=1, keepdim=True)[0] + bbox = torch.cat([bbox_left, bbox_up, bbox_right, bbox_bottom], + dim=1) + elif self.transform_method == 'partial_minmax': + pts_y = pts_y[:, :4, ...] + pts_x = pts_x[:, :4, ...] + bbox_left = pts_x.min(dim=1, keepdim=True)[0] + bbox_right = pts_x.max(dim=1, keepdim=True)[0] + bbox_up = pts_y.min(dim=1, keepdim=True)[0] + bbox_bottom = pts_y.max(dim=1, keepdim=True)[0] + bbox = torch.cat([bbox_left, bbox_up, bbox_right, bbox_bottom], + dim=1) + elif self.transform_method == 'moment': + pts_y_mean = pts_y.mean(dim=1, keepdim=True) + pts_x_mean = pts_x.mean(dim=1, keepdim=True) + pts_y_std = torch.std(pts_y - pts_y_mean, dim=1, keepdim=True) + pts_x_std = torch.std(pts_x - pts_x_mean, dim=1, keepdim=True) + moment_transfer = (self.moment_transfer * self.moment_mul) + ( + self.moment_transfer.detach() * (1 - self.moment_mul)) + moment_width_transfer = moment_transfer[0] + moment_height_transfer = moment_transfer[1] + half_width = pts_x_std * torch.exp(moment_width_transfer) + half_height = pts_y_std * torch.exp(moment_height_transfer) + bbox = torch.cat([ + pts_x_mean - half_width, pts_y_mean - half_height, + pts_x_mean + half_width, pts_y_mean + half_height + ], + dim=1) + else: + raise NotImplementedError + return bbox + + def gen_grid_from_reg(self, reg, previous_boxes): + """ + Base on the previous bboxes and regression values, we compute the + regressed bboxes and generate the grids on the bboxes. + :param reg: the regression value to previous bboxes. + :param previous_boxes: previous bboxes. + :return: generate grids on the regressed bboxes. + """ + b, _, h, w = reg.shape + bxy = (previous_boxes[:, :2, ...] + previous_boxes[:, 2:, ...]) / 2. + bwh = (previous_boxes[:, 2:, ...] - + previous_boxes[:, :2, ...]).clamp(min=1e-6) + grid_topleft = bxy + bwh * reg[:, :2, ...] - 0.5 * bwh * torch.exp( + reg[:, 2:, ...]) + grid_wh = bwh * torch.exp(reg[:, 2:, ...]) + grid_left = grid_topleft[:, [0], ...] + grid_top = grid_topleft[:, [1], ...] + grid_width = grid_wh[:, [0], ...] + grid_height = grid_wh[:, [1], ...] + intervel = torch.linspace(0., 1., self.dcn_kernel).view( + 1, self.dcn_kernel, 1, 1).type_as(reg) + grid_x = grid_left + grid_width * intervel + grid_x = grid_x.unsqueeze(1).repeat(1, self.dcn_kernel, 1, 1, 1) + grid_x = grid_x.view(b, -1, h, w) + grid_y = grid_top + grid_height * intervel + grid_y = grid_y.unsqueeze(2).repeat(1, 1, self.dcn_kernel, 1, 1) + grid_y = grid_y.view(b, -1, h, w) + grid_yx = torch.stack([grid_y, grid_x], dim=2) + grid_yx = grid_yx.view(b, -1, h, w) + regressed_bbox = torch.cat([ + grid_left, grid_top, grid_left + grid_width, grid_top + grid_height + ], 1) + return grid_yx, regressed_bbox + + def forward_single(self, x): + dcn_base_offset = self.dcn_base_offset.type_as(x) + # If we use center_init, the initial reppoints is from center points. + # If we use bounding bbox representation, the initial reppoints is + # from regular grid placed on a pre-defined bbox. + if self.use_grid_points or not self.center_init: + scale = self.point_base_scale / 2 + points_init = dcn_base_offset / dcn_base_offset.max() * scale + bbox_init = x.new_tensor([-scale, -scale, scale, + scale]).view(1, 4, 1, 1) + else: + points_init = 0 + cls_feat = x + pts_feat = x + for cls_conv in self.cls_convs: + cls_feat = cls_conv(cls_feat) + for reg_conv in self.reg_convs: + pts_feat = reg_conv(pts_feat) + # initialize reppoints + pts_out_init = self.reppoints_pts_init_out( + self.relu(self.reppoints_pts_init_conv(pts_feat))) + if self.use_grid_points: + pts_out_init, bbox_out_init = self.gen_grid_from_reg( + pts_out_init, bbox_init.detach()) + else: + pts_out_init = pts_out_init + points_init + # refine and classify reppoints + pts_out_init_grad_mul = (1 - self.gradient_mul) * pts_out_init.detach( + ) + self.gradient_mul * pts_out_init + dcn_offset = pts_out_init_grad_mul - dcn_base_offset + cls_out = self.reppoints_cls_out( + self.relu(self.reppoints_cls_conv(cls_feat, dcn_offset))) + pts_out_refine = self.reppoints_pts_refine_out( + self.relu(self.reppoints_pts_refine_conv(pts_feat, dcn_offset))) + if self.use_grid_points: + pts_out_refine, bbox_out_refine = self.gen_grid_from_reg( + pts_out_refine, bbox_out_init.detach()) + else: + pts_out_refine = pts_out_refine + pts_out_init.detach() + return cls_out, pts_out_init, pts_out_refine + + def forward(self, feats): + return multi_apply(self.forward_single, feats) + + def get_points(self, featmap_sizes, img_metas): + """Get points according to feature map sizes. + + Args: + featmap_sizes (list[tuple]): Multi-level feature map sizes. + img_metas (list[dict]): Image meta info. + + Returns: + tuple: points of each image, valid flags of each image + """ + num_imgs = len(img_metas) + num_levels = len(featmap_sizes) + + # since feature map sizes of all images are the same, we only compute + # points center for one time + multi_level_points = [] + for i in range(num_levels): + points = self.point_generators[i].grid_points( + featmap_sizes[i], self.point_strides[i]) + multi_level_points.append(points) + points_list = [[point.clone() for point in multi_level_points] + for _ in range(num_imgs)] + + # for each image, we compute valid flags of multi level grids + valid_flag_list = [] + for img_id, img_meta in enumerate(img_metas): + multi_level_flags = [] + for i in range(num_levels): + point_stride = self.point_strides[i] + feat_h, feat_w = featmap_sizes[i] + h, w = img_meta['pad_shape'][:2] + valid_feat_h = min(int(np.ceil(h / point_stride)), feat_h) + valid_feat_w = min(int(np.ceil(w / point_stride)), feat_w) + flags = self.point_generators[i].valid_flags( + (feat_h, feat_w), (valid_feat_h, valid_feat_w)) + multi_level_flags.append(flags) + valid_flag_list.append(multi_level_flags) + + return points_list, valid_flag_list + + def centers_to_bboxes(self, point_list): + """Get bboxes according to center points. Only used in MaxIOUAssigner. + """ + bbox_list = [] + for i_img, point in enumerate(point_list): + bbox = [] + for i_lvl in range(len(self.point_strides)): + scale = self.point_base_scale * self.point_strides[i_lvl] * 0.5 + bbox_shift = torch.Tensor([-scale, -scale, scale, + scale]).view(1, 4).type_as(point[0]) + bbox_center = torch.cat( + [point[i_lvl][:, :2], point[i_lvl][:, :2]], dim=1) + bbox.append(bbox_center + bbox_shift) + bbox_list.append(bbox) + return bbox_list + + def offset_to_pts(self, center_list, pred_list): + """Change from point offset to point coordinate. + """ + pts_list = [] + for i_lvl in range(len(self.point_strides)): + pts_lvl = [] + for i_img in range(len(center_list)): + pts_center = center_list[i_img][i_lvl][:, :2].repeat( + 1, self.num_points) + pts_shift = pred_list[i_lvl][i_img] + yx_pts_shift = pts_shift.permute(1, 2, 0).view( + -1, 2 * self.num_points) + y_pts_shift = yx_pts_shift[..., 0::2] + x_pts_shift = yx_pts_shift[..., 1::2] + xy_pts_shift = torch.stack([x_pts_shift, y_pts_shift], -1) + xy_pts_shift = xy_pts_shift.view(*yx_pts_shift.shape[:-1], -1) + pts = xy_pts_shift * self.point_strides[i_lvl] + pts_center + pts_lvl.append(pts) + pts_lvl = torch.stack(pts_lvl, 0) + pts_list.append(pts_lvl) + return pts_list + + def loss_single(self, cls_score, pts_pred_init, pts_pred_refine, labels, + label_weights, bbox_gt_init, bbox_weights_init, + bbox_gt_refine, bbox_weights_refine, stride, + num_total_samples_init, num_total_samples_refine): + # classification loss + labels = labels.reshape(-1) + label_weights = label_weights.reshape(-1) + cls_score = cls_score.permute(0, 2, 3, + 1).reshape(-1, self.cls_out_channels) + loss_cls = self.loss_cls( + cls_score, + labels, + label_weights, + avg_factor=num_total_samples_refine) + + # points loss + bbox_gt_init = bbox_gt_init.reshape(-1, 4) + bbox_weights_init = bbox_weights_init.reshape(-1, 4) + bbox_pred_init = self.points2bbox( + pts_pred_init.reshape(-1, 2 * self.num_points), y_first=False) + bbox_gt_refine = bbox_gt_refine.reshape(-1, 4) + bbox_weights_refine = bbox_weights_refine.reshape(-1, 4) + bbox_pred_refine = self.points2bbox( + pts_pred_refine.reshape(-1, 2 * self.num_points), y_first=False) + normalize_term = self.point_base_scale * stride + loss_pts_init = self.loss_bbox_init( + bbox_pred_init / normalize_term, + bbox_gt_init / normalize_term, + bbox_weights_init, + avg_factor=num_total_samples_init) + loss_pts_refine = self.loss_bbox_refine( + bbox_pred_refine / normalize_term, + bbox_gt_refine / normalize_term, + bbox_weights_refine, + avg_factor=num_total_samples_refine) + return loss_cls, loss_pts_init, loss_pts_refine + + def loss(self, + cls_scores, + pts_preds_init, + pts_preds_refine, + gt_bboxes, + gt_labels, + img_metas, + cfg, + gt_bboxes_ignore=None): + featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] + assert len(featmap_sizes) == len(self.point_generators) + label_channels = self.cls_out_channels if self.use_sigmoid_cls else 1 + + # target for initial stage + center_list, valid_flag_list = self.get_points(featmap_sizes, + img_metas) + pts_coordinate_preds_init = self.offset_to_pts(center_list, + pts_preds_init) + if cfg.init.assigner['type'] == 'PointAssigner': + # Assign target for center list + candidate_list = center_list + else: + # transform center list to bbox list and + # assign target for bbox list + bbox_list = self.centers_to_bboxes(center_list) + candidate_list = bbox_list + cls_reg_targets_init = point_target( + candidate_list, + valid_flag_list, + gt_bboxes, + img_metas, + cfg.init, + gt_bboxes_ignore_list=gt_bboxes_ignore, + gt_labels_list=gt_labels, + label_channels=label_channels, + sampling=self.sampling) + (*_, bbox_gt_list_init, candidate_list_init, bbox_weights_list_init, + num_total_pos_init, num_total_neg_init) = cls_reg_targets_init + num_total_samples_init = ( + num_total_pos_init + + num_total_neg_init if self.sampling else num_total_pos_init) + + # target for refinement stage + center_list, valid_flag_list = self.get_points(featmap_sizes, + img_metas) + pts_coordinate_preds_refine = self.offset_to_pts( + center_list, pts_preds_refine) + bbox_list = [] + for i_img, center in enumerate(center_list): + bbox = [] + for i_lvl in range(len(pts_preds_refine)): + bbox_preds_init = self.points2bbox( + pts_preds_init[i_lvl].detach()) + bbox_shift = bbox_preds_init * self.point_strides[i_lvl] + bbox_center = torch.cat( + [center[i_lvl][:, :2], center[i_lvl][:, :2]], dim=1) + bbox.append(bbox_center + + bbox_shift[i_img].permute(1, 2, 0).reshape(-1, 4)) + bbox_list.append(bbox) + cls_reg_targets_refine = point_target( + bbox_list, + valid_flag_list, + gt_bboxes, + img_metas, + cfg.refine, + gt_bboxes_ignore_list=gt_bboxes_ignore, + gt_labels_list=gt_labels, + label_channels=label_channels, + sampling=self.sampling) + (labels_list, label_weights_list, bbox_gt_list_refine, + candidate_list_refine, bbox_weights_list_refine, num_total_pos_refine, + num_total_neg_refine) = cls_reg_targets_refine + num_total_samples_refine = ( + num_total_pos_refine + + num_total_neg_refine if self.sampling else num_total_pos_refine) + + # compute loss + losses_cls, losses_pts_init, losses_pts_refine = multi_apply( + self.loss_single, + cls_scores, + pts_coordinate_preds_init, + pts_coordinate_preds_refine, + labels_list, + label_weights_list, + bbox_gt_list_init, + bbox_weights_list_init, + bbox_gt_list_refine, + bbox_weights_list_refine, + self.point_strides, + num_total_samples_init=num_total_samples_init, + num_total_samples_refine=num_total_samples_refine) + loss_dict_all = { + 'loss_cls': losses_cls, + 'loss_pts_init': losses_pts_init, + 'loss_pts_refine': losses_pts_refine + } + return loss_dict_all + + def get_bboxes(self, + cls_scores, + pts_preds_init, + pts_preds_refine, + img_metas, + cfg, + rescale=False, + nms=True): + assert len(cls_scores) == len(pts_preds_refine) + bbox_preds_refine = [ + self.points2bbox(pts_pred_refine) + for pts_pred_refine in pts_preds_refine + ] + num_levels = len(cls_scores) + mlvl_points = [ + self.point_generators[i].grid_points(cls_scores[i].size()[-2:], + self.point_strides[i]) + for i in range(num_levels) + ] + result_list = [] + for img_id in range(len(img_metas)): + cls_score_list = [ + cls_scores[i][img_id].detach() for i in range(num_levels) + ] + bbox_pred_list = [ + bbox_preds_refine[i][img_id].detach() + for i in range(num_levels) + ] + img_shape = img_metas[img_id]['img_shape'] + scale_factor = img_metas[img_id]['scale_factor'] + proposals = self.get_bboxes_single(cls_score_list, bbox_pred_list, + mlvl_points, img_shape, + scale_factor, cfg, rescale, nms) + result_list.append(proposals) + return result_list + + def get_bboxes_single(self, + cls_scores, + bbox_preds, + mlvl_points, + img_shape, + scale_factor, + cfg, + rescale=False, + nms=True): + assert len(cls_scores) == len(bbox_preds) == len(mlvl_points) + mlvl_bboxes = [] + mlvl_scores = [] + for i_lvl, (cls_score, bbox_pred, points) in enumerate( + zip(cls_scores, bbox_preds, mlvl_points)): + assert cls_score.size()[-2:] == bbox_pred.size()[-2:] + cls_score = cls_score.permute(1, 2, + 0).reshape(-1, self.cls_out_channels) + if self.use_sigmoid_cls: + scores = cls_score.sigmoid() + else: + scores = cls_score.softmax(-1) + bbox_pred = bbox_pred.permute(1, 2, 0).reshape(-1, 4) + nms_pre = cfg.get('nms_pre', -1) + if nms_pre > 0 and scores.shape[0] > nms_pre: + if self.use_sigmoid_cls: + max_scores, _ = scores.max(dim=1) + else: + max_scores, _ = scores[:, 1:].max(dim=1) + _, topk_inds = max_scores.topk(nms_pre) + points = points[topk_inds, :] + bbox_pred = bbox_pred[topk_inds, :] + scores = scores[topk_inds, :] + bbox_pos_center = torch.cat([points[:, :2], points[:, :2]], dim=1) + bboxes = bbox_pred * self.point_strides[i_lvl] + bbox_pos_center + x1 = bboxes[:, 0].clamp(min=0, max=img_shape[1]) + y1 = bboxes[:, 1].clamp(min=0, max=img_shape[0]) + x2 = bboxes[:, 2].clamp(min=0, max=img_shape[1]) + y2 = bboxes[:, 3].clamp(min=0, max=img_shape[0]) + bboxes = torch.stack([x1, y1, x2, y2], dim=-1) + mlvl_bboxes.append(bboxes) + mlvl_scores.append(scores) + mlvl_bboxes = torch.cat(mlvl_bboxes) + if rescale: + mlvl_bboxes /= mlvl_bboxes.new_tensor(scale_factor) + mlvl_scores = torch.cat(mlvl_scores) + if self.use_sigmoid_cls: + padding = mlvl_scores.new_zeros(mlvl_scores.shape[0], 1) + mlvl_scores = torch.cat([padding, mlvl_scores], dim=1) + if nms: + det_bboxes, det_labels = multiclass_nms(mlvl_bboxes, mlvl_scores, + cfg.score_thr, cfg.nms, + cfg.max_per_img) + return det_bboxes, det_labels + else: + return mlvl_bboxes, mlvl_scores diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/retina_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/retina_head.py new file mode 100644 index 000000000..e3b8143ad --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/retina_head.py @@ -0,0 +1,103 @@ +import numpy as np +import torch.nn as nn +from mmcv.cnn import normal_init + +from ..registry import HEADS +from ..utils import ConvModule, bias_init_with_prob +from .anchor_head import AnchorHead + + +@HEADS.register_module +class RetinaHead(AnchorHead): + """ + An anchor-based head used in [1]_. + + The head contains two subnetworks. The first classifies anchor boxes and + the second regresses deltas for the anchors. + + References: + .. [1] https://arxiv.org/pdf/1708.02002.pdf + + Example: + >>> import torch + >>> self = RetinaHead(11, 7) + >>> x = torch.rand(1, 7, 32, 32) + >>> cls_score, bbox_pred = self.forward_single(x) + >>> # Each anchor predicts a score for each class except background + >>> cls_per_anchor = cls_score.shape[1] / self.num_anchors + >>> box_per_anchor = bbox_pred.shape[1] / self.num_anchors + >>> assert cls_per_anchor == (self.num_classes - 1) + >>> assert box_per_anchor == 4 + """ + + def __init__(self, + num_classes, + in_channels, + stacked_convs=4, + octave_base_scale=4, + scales_per_octave=3, + conv_cfg=None, + norm_cfg=None, + **kwargs): + self.stacked_convs = stacked_convs + self.octave_base_scale = octave_base_scale + self.scales_per_octave = scales_per_octave + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + octave_scales = np.array( + [2**(i / scales_per_octave) for i in range(scales_per_octave)]) + anchor_scales = octave_scales * octave_base_scale + super(RetinaHead, self).__init__( + num_classes, in_channels, anchor_scales=anchor_scales, **kwargs) + + def _init_layers(self): + self.relu = nn.ReLU(inplace=True) + self.cls_convs = nn.ModuleList() + self.reg_convs = nn.ModuleList() + for i in range(self.stacked_convs): + chn = self.in_channels if i == 0 else self.feat_channels + self.cls_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg)) + self.reg_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg)) + self.retina_cls = nn.Conv2d( + self.feat_channels, + self.num_anchors * self.cls_out_channels, + 3, + padding=1) + self.retina_reg = nn.Conv2d( + self.feat_channels, self.num_anchors * 4, 3, padding=1) + + def init_weights(self): + for m in self.cls_convs: + normal_init(m.conv, std=0.01) + for m in self.reg_convs: + normal_init(m.conv, std=0.01) + bias_cls = bias_init_with_prob(0.01) + normal_init(self.retina_cls, std=0.01, bias=bias_cls) + normal_init(self.retina_reg, std=0.01) + + def forward_single(self, x): + cls_feat = x + reg_feat = x + for cls_conv in self.cls_convs: + cls_feat = cls_conv(cls_feat) + for reg_conv in self.reg_convs: + reg_feat = reg_conv(reg_feat) + cls_score = self.retina_cls(cls_feat) + bbox_pred = self.retina_reg(reg_feat) + return cls_score, bbox_pred diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/retina_sepbn_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/retina_sepbn_head.py new file mode 100644 index 000000000..0f0766179 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/retina_sepbn_head.py @@ -0,0 +1,105 @@ +import numpy as np +import torch.nn as nn +from mmcv.cnn import normal_init + +from ..registry import HEADS +from ..utils import ConvModule, bias_init_with_prob +from .anchor_head import AnchorHead + + +@HEADS.register_module +class RetinaSepBNHead(AnchorHead): + """"RetinaHead with separate BN. + + In RetinaHead, conv/norm layers are shared across different FPN levels, + while in RetinaSepBNHead, conv layers are shared across different FPN + levels, but BN layers are separated. + """ + + def __init__(self, + num_classes, + num_ins, + in_channels, + stacked_convs=4, + octave_base_scale=4, + scales_per_octave=3, + conv_cfg=None, + norm_cfg=None, + **kwargs): + self.stacked_convs = stacked_convs + self.octave_base_scale = octave_base_scale + self.scales_per_octave = scales_per_octave + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + self.num_ins = num_ins + octave_scales = np.array( + [2**(i / scales_per_octave) for i in range(scales_per_octave)]) + anchor_scales = octave_scales * octave_base_scale + super(RetinaSepBNHead, self).__init__( + num_classes, in_channels, anchor_scales=anchor_scales, **kwargs) + + def _init_layers(self): + self.relu = nn.ReLU(inplace=True) + self.cls_convs = nn.ModuleList() + self.reg_convs = nn.ModuleList() + for i in range(self.num_ins): + cls_convs = nn.ModuleList() + reg_convs = nn.ModuleList() + for i in range(self.stacked_convs): + chn = self.in_channels if i == 0 else self.feat_channels + cls_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg)) + reg_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg)) + self.cls_convs.append(cls_convs) + self.reg_convs.append(reg_convs) + for i in range(self.stacked_convs): + for j in range(1, self.num_ins): + self.cls_convs[j][i].conv = self.cls_convs[0][i].conv + self.reg_convs[j][i].conv = self.reg_convs[0][i].conv + self.retina_cls = nn.Conv2d( + self.feat_channels, + self.num_anchors * self.cls_out_channels, + 3, + padding=1) + self.retina_reg = nn.Conv2d( + self.feat_channels, self.num_anchors * 4, 3, padding=1) + + def init_weights(self): + for m in self.cls_convs[0]: + normal_init(m.conv, std=0.01) + for m in self.reg_convs[0]: + normal_init(m.conv, std=0.01) + bias_cls = bias_init_with_prob(0.01) + normal_init(self.retina_cls, std=0.01, bias=bias_cls) + normal_init(self.retina_reg, std=0.01) + + def forward(self, feats): + cls_scores = [] + bbox_preds = [] + for i, x in enumerate(feats): + cls_feat = feats[i] + reg_feat = feats[i] + for cls_conv in self.cls_convs[i]: + cls_feat = cls_conv(cls_feat) + for reg_conv in self.reg_convs[i]: + reg_feat = reg_conv(reg_feat) + cls_score = self.retina_cls(cls_feat) + bbox_pred = self.retina_reg(reg_feat) + cls_scores.append(cls_score) + bbox_preds.append(bbox_pred) + return cls_scores, bbox_preds diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/rpn_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/rpn_head.py new file mode 100644 index 000000000..f88b949cf --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/rpn_head.py @@ -0,0 +1,104 @@ +import torch +import torch.nn as nn +import torch.nn.functional as F +from mmcv.cnn import normal_init + +from mmdet.core import delta2bbox +from mmdet.ops import nms +from ..registry import HEADS +from .anchor_head import AnchorHead + + +@HEADS.register_module +class RPNHead(AnchorHead): + + def __init__(self, in_channels, **kwargs): + super(RPNHead, self).__init__(2, in_channels, **kwargs) + + def _init_layers(self): + self.rpn_conv = nn.Conv2d( + self.in_channels, self.feat_channels, 3, padding=1) + self.rpn_cls = nn.Conv2d(self.feat_channels, + self.num_anchors * self.cls_out_channels, 1) + self.rpn_reg = nn.Conv2d(self.feat_channels, self.num_anchors * 4, 1) + + def init_weights(self): + normal_init(self.rpn_conv, std=0.01) + normal_init(self.rpn_cls, std=0.01) + normal_init(self.rpn_reg, std=0.01) + + def forward_single(self, x): + x = self.rpn_conv(x) + x = F.relu(x, inplace=True) + rpn_cls_score = self.rpn_cls(x) + rpn_bbox_pred = self.rpn_reg(x) + return rpn_cls_score, rpn_bbox_pred + + def loss(self, + cls_scores, + bbox_preds, + gt_bboxes, + img_metas, + cfg, + gt_bboxes_ignore=None): + losses = super(RPNHead, self).loss( + cls_scores, + bbox_preds, + gt_bboxes, + None, + img_metas, + cfg, + gt_bboxes_ignore=gt_bboxes_ignore) + return dict( + loss_rpn_cls=losses['loss_cls'], loss_rpn_bbox=losses['loss_bbox']) + + def get_bboxes_single(self, + cls_scores, + bbox_preds, + mlvl_anchors, + img_shape, + scale_factor, + cfg, + rescale=False): + mlvl_proposals = [] + for idx in range(len(cls_scores)): + rpn_cls_score = cls_scores[idx] + rpn_bbox_pred = bbox_preds[idx] + assert rpn_cls_score.size()[-2:] == rpn_bbox_pred.size()[-2:] + rpn_cls_score = rpn_cls_score.permute(1, 2, 0) + if self.use_sigmoid_cls: + rpn_cls_score = rpn_cls_score.reshape(-1) + scores = rpn_cls_score.sigmoid() + else: + rpn_cls_score = rpn_cls_score.reshape(-1, 2) + scores = rpn_cls_score.softmax(dim=1)[:, 1] + rpn_bbox_pred = rpn_bbox_pred.permute(1, 2, 0).reshape(-1, 4) + anchors = mlvl_anchors[idx] + if cfg.nms_pre > 0 and scores.shape[0] > cfg.nms_pre: + _, topk_inds = scores.topk(cfg.nms_pre) + rpn_bbox_pred = rpn_bbox_pred[topk_inds, :] + anchors = anchors[topk_inds, :] + scores = scores[topk_inds] + proposals = delta2bbox(anchors, rpn_bbox_pred, self.target_means, + self.target_stds, img_shape) + if cfg.min_bbox_size > 0: + w = proposals[:, 2] - proposals[:, 0] + 1 + h = proposals[:, 3] - proposals[:, 1] + 1 + valid_inds = torch.nonzero((w >= cfg.min_bbox_size) & + (h >= cfg.min_bbox_size)).squeeze() + proposals = proposals[valid_inds, :] + scores = scores[valid_inds] + proposals = torch.cat([proposals, scores.unsqueeze(-1)], dim=-1) + proposals, _ = nms(proposals, cfg.nms_thr) + proposals = proposals[:cfg.nms_post, :] + mlvl_proposals.append(proposals) + proposals = torch.cat(mlvl_proposals, 0) + if cfg.nms_across_levels: + proposals, _ = nms(proposals, cfg.nms_thr) + proposals = proposals[:cfg.max_num, :] + else: + scores = proposals[:, 4] + num = min(cfg.max_num, proposals.shape[0]) + _, topk_inds = scores.topk(num) + proposals = proposals[topk_inds, :] + return proposals diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solo_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solo_head.py new file mode 100644 index 000000000..e6c060726 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solo_head.py @@ -0,0 +1,433 @@ +import mmcv +import torch +import torch.nn as nn +import torch.nn.functional as F +from mmcv.cnn import normal_init +from mmdet.ops import DeformConv, roi_align +from mmdet.core import multi_apply, bbox2roi, matrix_nms +from ..builder import build_loss +from ..registry import HEADS +from ..utils import bias_init_with_prob, ConvModule + +INF = 1e8 + +def center_of_mass(bitmasks): + _, h, w = bitmasks.size() + ys = torch.arange(0, h, dtype=torch.float32, device=bitmasks.device) + xs = torch.arange(0, w, dtype=torch.float32, device=bitmasks.device) + + m00 = bitmasks.sum(dim=-1).sum(dim=-1).clamp(min=1e-6) + m10 = (bitmasks * xs).sum(dim=-1).sum(dim=-1) + m01 = (bitmasks * ys[:, None]).sum(dim=-1).sum(dim=-1) + center_x = m10 / m00 + center_y = m01 / m00 + return center_x, center_y + +def points_nms(heat, kernel=2): + # kernel must be 2 + hmax = nn.functional.max_pool2d( + heat, (kernel, kernel), stride=1, padding=1) + keep = (hmax[:, :, :-1, :-1] == heat).float() + return heat * keep + +def dice_loss(input, target): + input = input.contiguous().view(input.size()[0], -1) + target = target.contiguous().view(target.size()[0], -1).float() + + a = torch.sum(input * target, 1) + b = torch.sum(input * input, 1) + 0.001 + c = torch.sum(target * target, 1) + 0.001 + d = (2 * a) / (b + c) + return 1-d + +@HEADS.register_module +class SOLOHead(nn.Module): + + def __init__(self, + num_classes, + in_channels, + seg_feat_channels=256, + stacked_convs=4, + strides=(4, 8, 16, 32, 64), + base_edge_list=(16, 32, 64, 128, 256), + scale_ranges=((8, 32), (16, 64), (32, 128), (64, 256), (128, 512)), + sigma=0.4, + num_grids=None, + cate_down_pos=0, + with_deform=False, + loss_ins=None, + loss_cate=None, + conv_cfg=None, + norm_cfg=None): + super(SOLOHead, self).__init__() + self.num_classes = num_classes + self.seg_num_grids = num_grids + self.cate_out_channels = self.num_classes - 1 + self.in_channels = in_channels + self.seg_feat_channels = seg_feat_channels + self.stacked_convs = stacked_convs + self.strides = strides + self.sigma = sigma + self.cate_down_pos = cate_down_pos + self.base_edge_list = base_edge_list + self.scale_ranges = scale_ranges + self.with_deform = with_deform + self.loss_cate = build_loss(loss_cate) + self.ins_loss_weight = loss_ins['loss_weight'] + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + self._init_layers() + + def _init_layers(self): + norm_cfg = dict(type='GN', num_groups=32, requires_grad=True) + self.ins_convs = nn.ModuleList() + self.cate_convs = nn.ModuleList() + for i in range(self.stacked_convs): + chn = self.in_channels + 2 if i == 0 else self.seg_feat_channels + self.ins_convs.append( + ConvModule( + chn, + self.seg_feat_channels, + 3, + stride=1, + padding=1, + norm_cfg=norm_cfg, + bias=norm_cfg is None)) + + chn = self.in_channels if i == 0 else self.seg_feat_channels + self.cate_convs.append( + ConvModule( + chn, + self.seg_feat_channels, + 3, + stride=1, + padding=1, + norm_cfg=norm_cfg, + bias=norm_cfg is None)) + + self.solo_ins_list = nn.ModuleList() + for seg_num_grid in self.seg_num_grids: + self.solo_ins_list.append( + nn.Conv2d( + self.seg_feat_channels, seg_num_grid**2, 1)) + + self.solo_cate = nn.Conv2d( + self.seg_feat_channels, self.cate_out_channels, 3, padding=1) + + def init_weights(self): + for m in self.ins_convs: + normal_init(m.conv, std=0.01) + for m in self.cate_convs: + normal_init(m.conv, std=0.01) + bias_ins = bias_init_with_prob(0.01) + for m in self.solo_ins_list: + normal_init(m, std=0.01, bias=bias_ins) + bias_cate = bias_init_with_prob(0.01) + normal_init(self.solo_cate, std=0.01, bias=bias_cate) + + def forward(self, feats, eval=False): + new_feats = self.split_feats(feats) + featmap_sizes = [featmap.size()[-2:] for featmap in new_feats] + upsampled_size = (featmap_sizes[0][0] * 2, featmap_sizes[0][1] * 2) + ins_pred, cate_pred = multi_apply(self.forward_single, new_feats, + list(range(len(self.seg_num_grids))), + eval=eval, upsampled_size=upsampled_size) + return ins_pred, cate_pred + + def split_feats(self, feats): + return (F.interpolate(feats[0], scale_factor=0.5, mode='bilinear'), + feats[1], + feats[2], + feats[3], + F.interpolate(feats[4], size=feats[3].shape[-2:], mode='bilinear')) + + def forward_single(self, x, idx, eval=False, upsampled_size=None): + ins_feat = x + cate_feat = x + # ins branch + # concat coord + x_range = torch.linspace(-1, 1, ins_feat.shape[-1], device=ins_feat.device) + y_range = torch.linspace(-1, 1, ins_feat.shape[-2], device=ins_feat.device) + y, x = torch.meshgrid(y_range, x_range) + y = y.expand([ins_feat.shape[0], 1, -1, -1]) + x = x.expand([ins_feat.shape[0], 1, -1, -1]) + coord_feat = torch.cat([x, y], 1) + ins_feat = torch.cat([ins_feat, coord_feat], 1) + + for i, ins_layer in enumerate(self.ins_convs): + ins_feat = ins_layer(ins_feat) + + ins_feat = F.interpolate(ins_feat, scale_factor=2, mode='bilinear') + ins_pred = self.solo_ins_list[idx](ins_feat) + + # cate branch + for i, cate_layer in enumerate(self.cate_convs): + if i == self.cate_down_pos: + seg_num_grid = self.seg_num_grids[idx] + cate_feat = F.interpolate(cate_feat, size=seg_num_grid, mode='bilinear') + cate_feat = cate_layer(cate_feat) + + cate_pred = self.solo_cate(cate_feat) + if eval: + ins_pred = F.interpolate(ins_pred.sigmoid(), size=upsampled_size, mode='bilinear') + cate_pred = points_nms(cate_pred.sigmoid(), kernel=2).permute(0, 2, 3, 1) + return ins_pred, cate_pred + + def loss(self, + ins_preds, + cate_preds, + gt_bbox_list, + gt_label_list, + gt_mask_list, + img_metas, + cfg, + gt_bboxes_ignore=None): + featmap_sizes = [featmap.size()[-2:] for featmap in + ins_preds] + ins_label_list, cate_label_list, ins_ind_label_list = multi_apply( + self.solo_target_single, + gt_bbox_list, + gt_label_list, + gt_mask_list, + featmap_sizes=featmap_sizes) + + # ins + ins_labels = [torch.cat([ins_labels_level_img[ins_ind_labels_level_img, ...] + for ins_labels_level_img, ins_ind_labels_level_img in + zip(ins_labels_level, ins_ind_labels_level)], 0) + for ins_labels_level, ins_ind_labels_level in zip(zip(*ins_label_list), zip(*ins_ind_label_list))] + + ins_preds = [torch.cat([ins_preds_level_img[ins_ind_labels_level_img, ...] + for ins_preds_level_img, ins_ind_labels_level_img in + zip(ins_preds_level, ins_ind_labels_level)], 0) + for ins_preds_level, ins_ind_labels_level in zip(ins_preds, zip(*ins_ind_label_list))] + + + ins_ind_labels = [ + torch.cat([ins_ind_labels_level_img.flatten() + for ins_ind_labels_level_img in ins_ind_labels_level]) + for ins_ind_labels_level in zip(*ins_ind_label_list) + ] + flatten_ins_ind_labels = torch.cat(ins_ind_labels) + + num_ins = flatten_ins_ind_labels.sum() + + # dice loss + loss_ins = [] + for input, target in zip(ins_preds, ins_labels): + if input.size()[0] == 0: + continue + input = torch.sigmoid(input) + loss_ins.append(dice_loss(input, target)) + loss_ins = torch.cat(loss_ins).mean() + loss_ins = loss_ins * self.ins_loss_weight + + # cate + cate_labels = [ + torch.cat([cate_labels_level_img.flatten() + for cate_labels_level_img in cate_labels_level]) + for cate_labels_level in zip(*cate_label_list) + ] + flatten_cate_labels = torch.cat(cate_labels) + + cate_preds = [ + cate_pred.permute(0, 2, 3, 1).reshape(-1, self.cate_out_channels) + for cate_pred in cate_preds + ] + flatten_cate_preds = torch.cat(cate_preds) + + loss_cate = self.loss_cate(flatten_cate_preds, flatten_cate_labels, avg_factor=num_ins + 1) + return dict( + loss_ins=loss_ins, + loss_cate=loss_cate) + + def solo_target_single(self, + gt_bboxes_raw, + gt_labels_raw, + gt_masks_raw, + featmap_sizes=None): + + device = gt_labels_raw[0].device + + # ins + gt_areas = torch.sqrt((gt_bboxes_raw[:, 2] - gt_bboxes_raw[:, 0]) * ( + gt_bboxes_raw[:, 3] - gt_bboxes_raw[:, 1])) + + ins_label_list = [] + cate_label_list = [] + ins_ind_label_list = [] + for (lower_bound, upper_bound), stride, featmap_size, num_grid \ + in zip(self.scale_ranges, self.strides, featmap_sizes, self.seg_num_grids): + + ins_label = torch.zeros([num_grid ** 2, featmap_size[0], featmap_size[1]], dtype=torch.uint8, device=device) + cate_label = torch.zeros([num_grid, num_grid], dtype=torch.int64, device=device) + ins_ind_label = torch.zeros([num_grid ** 2], dtype=torch.bool, device=device) + + hit_indices = ((gt_areas >= lower_bound) & (gt_areas <= upper_bound)).nonzero().flatten() + if len(hit_indices) == 0: + ins_label_list.append(ins_label) + cate_label_list.append(cate_label) + ins_ind_label_list.append(ins_ind_label) + continue + gt_bboxes = gt_bboxes_raw[hit_indices] + gt_labels = gt_labels_raw[hit_indices] + gt_masks = gt_masks_raw[hit_indices.cpu().numpy(), ...] + + half_ws = 0.5 * (gt_bboxes[:, 2] - gt_bboxes[:, 0]) * self.sigma + half_hs = 0.5 * (gt_bboxes[:, 3] - gt_bboxes[:, 1]) * self.sigma + + # mass center + gt_masks_pt = torch.from_numpy(gt_masks).to(device=device) + center_ws, center_hs = center_of_mass(gt_masks_pt) + valid_mask_flags = gt_masks_pt.sum(dim=-1).sum(dim=-1) > 0 + + output_stride = stride / 2 + for seg_mask, gt_label, half_h, half_w, center_h, center_w, valid_mask_flag in zip(gt_masks, gt_labels, half_hs, half_ws, center_hs, center_ws, valid_mask_flags): + if not valid_mask_flag: + continue + upsampled_size = (featmap_sizes[0][0] * 4, featmap_sizes[0][1] * 4) + coord_w = int((center_w / upsampled_size[1]) // (1. / num_grid)) + coord_h = int((center_h / upsampled_size[0]) // (1. / num_grid)) + + # left, top, right, down + top_box = max(0, int(((center_h - half_h) / upsampled_size[0]) // (1. / num_grid))) + down_box = min(num_grid - 1, int(((center_h + half_h) / upsampled_size[0]) // (1. / num_grid))) + left_box = max(0, int(((center_w - half_w) / upsampled_size[1]) // (1. / num_grid))) + right_box = min(num_grid - 1, int(((center_w + half_w) / upsampled_size[1]) // (1. / num_grid))) + + top = max(top_box, coord_h-1) + down = min(down_box, coord_h+1) + left = max(coord_w-1, left_box) + right = min(right_box, coord_w+1) + + cate_label[top:(down+1), left:(right+1)] = gt_label + # ins + seg_mask = mmcv.imrescale(seg_mask, scale=1. / output_stride) + seg_mask = torch.from_numpy(seg_mask).to(device=device) + for i in range(top, down+1): + for j in range(left, right+1): + label = int(i * num_grid + j) + ins_label[label, :seg_mask.shape[0], :seg_mask.shape[1]] = seg_mask + ins_ind_label[label] = True + ins_label_list.append(ins_label) + cate_label_list.append(cate_label) + ins_ind_label_list.append(ins_ind_label) + return ins_label_list, cate_label_list, ins_ind_label_list + + def get_seg(self, seg_preds, cate_preds, img_metas, cfg, rescale=None): + assert len(seg_preds) == len(cate_preds) + num_levels = len(cate_preds) + featmap_size = seg_preds[0].size()[-2:] + + result_list = [] + for img_id in range(len(img_metas)): + cate_pred_list = [ + cate_preds[i][img_id].view(-1, self.cate_out_channels).detach() for i in range(num_levels) + ] + seg_pred_list = [ + seg_preds[i][img_id].detach() for i in range(num_levels) + ] + img_shape = img_metas[img_id]['img_shape'] + scale_factor = img_metas[img_id]['scale_factor'] + ori_shape = img_metas[img_id]['ori_shape'] + + cate_pred_list = torch.cat(cate_pred_list, dim=0) + seg_pred_list = torch.cat(seg_pred_list, dim=0) + + result = self.get_seg_single(cate_pred_list, seg_pred_list, + featmap_size, img_shape, ori_shape, scale_factor, cfg, rescale) + result_list.append(result) + return result_list + + def get_seg_single(self, + cate_preds, + seg_preds, + featmap_size, + img_shape, + ori_shape, + scale_factor, + cfg, + rescale=False, debug=False): + assert len(cate_preds) == len(seg_preds) + + # overall info. + h, w, _ = img_shape + upsampled_size_out = (featmap_size[0] * 4, featmap_size[1] * 4) + + # process. + inds = (cate_preds > cfg.score_thr) + # category scores. + cate_scores = cate_preds[inds] + if len(cate_scores) == 0: + return None + # category labels. + inds = inds.nonzero() + cate_labels = inds[:, 1] + + # strides. + size_trans = cate_labels.new_tensor(self.seg_num_grids).pow(2).cumsum(0) + strides = cate_scores.new_ones(size_trans[-1]) + n_stage = len(self.seg_num_grids) + strides[:size_trans[0]] *= self.strides[0] + for ind_ in range(1, n_stage): + strides[size_trans[ind_ - 1]:size_trans[ind_]] *= self.strides[ind_] + strides = strides[inds[:, 0]] + + # masks. + seg_preds = seg_preds[inds[:, 0]] + seg_masks = seg_preds > cfg.mask_thr + sum_masks = seg_masks.sum((1, 2)).float() + + # filter. + keep = sum_masks > strides + if keep.sum() == 0: + return None + + seg_masks = seg_masks[keep, ...] + seg_preds = seg_preds[keep, ...] + sum_masks = sum_masks[keep] + cate_scores = cate_scores[keep] + cate_labels = cate_labels[keep] + + # maskness. + seg_scores = (seg_preds * seg_masks.float()).sum((1, 2)) / sum_masks + cate_scores *= seg_scores + + # sort and keep top nms_pre + sort_inds = torch.argsort(cate_scores, descending=True) + if len(sort_inds) > cfg.nms_pre: + sort_inds = sort_inds[:cfg.nms_pre] + seg_masks = seg_masks[sort_inds, :, :] + seg_preds = seg_preds[sort_inds, :, :] + sum_masks = sum_masks[sort_inds] + cate_scores = cate_scores[sort_inds] + cate_labels = cate_labels[sort_inds] + + # Matrix NMS + cate_scores = matrix_nms(seg_masks, cate_labels, cate_scores, + kernel=cfg.kernel, sigma=cfg.sigma, sum_masks=sum_masks) + + # filter. + keep = cate_scores >= cfg.update_thr + if keep.sum() == 0: + return None + seg_preds = seg_preds[keep, :, :] + cate_scores = cate_scores[keep] + cate_labels = cate_labels[keep] + + # sort and keep top_k + sort_inds = torch.argsort(cate_scores, descending=True) + if len(sort_inds) > cfg.max_per_img: + sort_inds = sort_inds[:cfg.max_per_img] + seg_preds = seg_preds[sort_inds, :, :] + cate_scores = cate_scores[sort_inds] + cate_labels = cate_labels[sort_inds] + + seg_preds = F.interpolate(seg_preds.unsqueeze(0), + size=upsampled_size_out, + mode='bilinear')[:, :, :h, :w] + seg_masks = F.interpolate(seg_preds, + size=ori_shape[:2], + mode='bilinear').squeeze(0) + seg_masks = seg_masks > cfg.mask_thr + return seg_masks, cate_labels, cate_scores diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solov2_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solov2_head.py new file mode 100644 index 000000000..9616b99b1 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solov2_head.py @@ -0,0 +1,483 @@ +import mmcv +import torch +import torch.nn as nn +import torch.nn.functional as F +from mmcv.cnn import normal_init +from mmdet.ops import DeformConv, roi_align +from mmdet.core import multi_apply, matrix_nms +from ..builder import build_loss +from ..registry import HEADS +from ..utils import bias_init_with_prob, ConvModule + +INF = 1e8 + +def center_of_mass(bitmasks): + _, h, w = bitmasks.size() + ys = torch.arange(0, h, dtype=torch.float32, device=bitmasks.device) + xs = torch.arange(0, w, dtype=torch.float32, device=bitmasks.device) + + m00 = bitmasks.sum(dim=-1).sum(dim=-1).clamp(min=1e-6) + m10 = (bitmasks * xs).sum(dim=-1).sum(dim=-1) + m01 = (bitmasks * ys[:, None]).sum(dim=-1).sum(dim=-1) + center_x = m10 / m00 + center_y = m01 / m00 + return center_x, center_y + +def points_nms(heat, kernel=2): + # kernel must be 2 + hmax = nn.functional.max_pool2d( + heat, (kernel, kernel), stride=1, padding=1) + keep = (hmax[:, :, :-1, :-1] == heat).float() + return heat * keep + +def dice_loss(input, target): + input = input.contiguous().view(input.size()[0], -1) + target = target.contiguous().view(target.size()[0], -1).float() + + a = torch.sum(input * target, 1) + b = torch.sum(input * input, 1) + 0.001 + c = torch.sum(target * target, 1) + 0.001 + d = (2 * a) / (b + c) + return 1-d + +@HEADS.register_module +class SOLOv2Head(nn.Module): + + def __init__(self, + num_classes, + in_channels, + seg_feat_channels=256, + stacked_convs=4, + strides=(4, 8, 16, 32, 64), + base_edge_list=(16, 32, 64, 128, 256), + scale_ranges=((8, 32), (16, 64), (32, 128), (64, 256), (128, 512)), + sigma=0.2, + num_grids=None, + ins_out_channels=64, + loss_ins=None, + loss_cate=None, + conv_cfg=None, + norm_cfg=None, + use_dcn_in_tower=False, + type_dcn=None): + super(SOLOv2Head, self).__init__() + self.num_classes = num_classes + self.seg_num_grids = num_grids + self.cate_out_channels = self.num_classes - 1 + self.ins_out_channels = ins_out_channels + self.in_channels = in_channels + self.seg_feat_channels = seg_feat_channels + self.stacked_convs = stacked_convs + self.strides = strides + self.sigma = sigma + self.stacked_convs = stacked_convs + self.kernel_out_channels = self.ins_out_channels * 1 * 1 + self.base_edge_list = base_edge_list + self.scale_ranges = scale_ranges + self.loss_cate = build_loss(loss_cate) + self.ins_loss_weight = loss_ins['loss_weight'] + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + self.use_dcn_in_tower = use_dcn_in_tower + self.type_dcn = type_dcn + self._init_layers() + + def _init_layers(self): + norm_cfg = dict(type='GN', num_groups=32, requires_grad=True) + self.cate_convs = nn.ModuleList() + self.kernel_convs = nn.ModuleList() + for i in range(self.stacked_convs): + if self.use_dcn_in_tower: + cfg_conv = dict(type=self.type_dcn) + else: + cfg_conv = self.conv_cfg + + chn = self.in_channels + 2 if i == 0 else self.seg_feat_channels + self.kernel_convs.append( + ConvModule( + chn, + self.seg_feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=cfg_conv, + norm_cfg=norm_cfg, + bias=norm_cfg is None)) + + chn = self.in_channels if i == 0 else self.seg_feat_channels + self.cate_convs.append( + ConvModule( + chn, + self.seg_feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=cfg_conv, + norm_cfg=norm_cfg, + bias=norm_cfg is None)) + + self.solo_cate = nn.Conv2d( + self.seg_feat_channels, self.cate_out_channels, 3, padding=1) + + self.solo_kernel = nn.Conv2d( + self.seg_feat_channels, self.kernel_out_channels, 3, padding=1) + + def init_weights(self): + for m in self.cate_convs: + normal_init(m.conv, std=0.01) + for m in self.kernel_convs: + normal_init(m.conv, std=0.01) + bias_cate = bias_init_with_prob(0.01) + normal_init(self.solo_cate, std=0.01, bias=bias_cate) + normal_init(self.solo_kernel, std=0.01) + + def forward(self, feats, eval=False): + new_feats = self.split_feats(feats) + featmap_sizes = [featmap.size()[-2:] for featmap in new_feats] + upsampled_size = (featmap_sizes[0][0] * 2, featmap_sizes[0][1] * 2) + cate_pred, kernel_pred = multi_apply(self.forward_single, new_feats, + list(range(len(self.seg_num_grids))), + eval=eval, upsampled_size=upsampled_size) + return cate_pred, kernel_pred + + def split_feats(self, feats): + return (F.interpolate(feats[0], scale_factor=0.5, mode='bilinear'), + feats[1], + feats[2], + feats[3], + F.interpolate(feats[4], size=feats[3].shape[-2:], mode='bilinear')) + + def forward_single(self, x, idx, eval=False, upsampled_size=None): + ins_kernel_feat = x + # ins branch + # concat coord + x_range = torch.linspace(-1, 1, ins_kernel_feat.shape[-1], device=ins_kernel_feat.device) + y_range = torch.linspace(-1, 1, ins_kernel_feat.shape[-2], device=ins_kernel_feat.device) + y, x = torch.meshgrid(y_range, x_range) + y = y.expand([ins_kernel_feat.shape[0], 1, -1, -1]) + x = x.expand([ins_kernel_feat.shape[0], 1, -1, -1]) + coord_feat = torch.cat([x, y], 1) + ins_kernel_feat = torch.cat([ins_kernel_feat, coord_feat], 1) + + # kernel branch + kernel_feat = ins_kernel_feat + seg_num_grid = self.seg_num_grids[idx] + kernel_feat = F.interpolate(kernel_feat, size=seg_num_grid, mode='bilinear') + + cate_feat = kernel_feat[:, :-2, :, :] + + kernel_feat = kernel_feat.contiguous() + for i, kernel_layer in enumerate(self.kernel_convs): + kernel_feat = kernel_layer(kernel_feat) + kernel_pred = self.solo_kernel(kernel_feat) + + # cate branch + cate_feat = cate_feat.contiguous() + for i, cate_layer in enumerate(self.cate_convs): + cate_feat = cate_layer(cate_feat) + cate_pred = self.solo_cate(cate_feat) + + if eval: + cate_pred = points_nms(cate_pred.sigmoid(), kernel=2).permute(0, 2, 3, 1) + return cate_pred, kernel_pred + + def loss(self, + cate_preds, + kernel_preds, + ins_pred, + gt_bbox_list, + gt_label_list, + gt_mask_list, + img_metas, + cfg, + gt_bboxes_ignore=None): + mask_feat_size = ins_pred.size()[-2:] + ins_label_list, cate_label_list, ins_ind_label_list, grid_order_list = multi_apply( + self.solov2_target_single, + gt_bbox_list, + gt_label_list, + gt_mask_list, + mask_feat_size=mask_feat_size) + + # ins + ins_labels = [torch.cat([ins_labels_level_img + for ins_labels_level_img in ins_labels_level], 0) + for ins_labels_level in zip(*ins_label_list)] + + kernel_preds = [[kernel_preds_level_img.view(kernel_preds_level_img.shape[0], -1)[:, grid_orders_level_img] + for kernel_preds_level_img, grid_orders_level_img in + zip(kernel_preds_level, grid_orders_level)] + for kernel_preds_level, grid_orders_level in zip(kernel_preds, zip(*grid_order_list))] + # generate masks + ins_pred = ins_pred + ins_pred_list = [] + for b_kernel_pred in kernel_preds: + b_mask_pred = [] + for idx, kernel_pred in enumerate(b_kernel_pred): + + if kernel_pred.size()[-1] == 0: + continue + cur_ins_pred = ins_pred[idx, ...] + H, W = cur_ins_pred.shape[-2:] + N, I = kernel_pred.shape + cur_ins_pred = cur_ins_pred.unsqueeze(0) + kernel_pred = kernel_pred.permute(1, 0).view(I, -1, 1, 1) + cur_ins_pred = F.conv2d(cur_ins_pred, kernel_pred, stride=1).view(-1, H, W) + b_mask_pred.append(cur_ins_pred) + if len(b_mask_pred) == 0: + b_mask_pred = None + else: + b_mask_pred = torch.cat(b_mask_pred, 0) + ins_pred_list.append(b_mask_pred) + + ins_ind_labels = [ + torch.cat([ins_ind_labels_level_img.flatten() + for ins_ind_labels_level_img in ins_ind_labels_level]) + for ins_ind_labels_level in zip(*ins_ind_label_list) + ] + flatten_ins_ind_labels = torch.cat(ins_ind_labels) + + num_ins = flatten_ins_ind_labels.sum() + + # dice loss + loss_ins = [] + for input, target in zip(ins_pred_list, ins_labels): + if input is None: + continue + input = torch.sigmoid(input) + loss_ins.append(dice_loss(input, target)) + loss_ins = torch.cat(loss_ins).mean() + loss_ins = loss_ins * self.ins_loss_weight + + # cate + cate_labels = [ + torch.cat([cate_labels_level_img.flatten() + for cate_labels_level_img in cate_labels_level]) + for cate_labels_level in zip(*cate_label_list) + ] + flatten_cate_labels = torch.cat(cate_labels) + + cate_preds = [ + cate_pred.permute(0, 2, 3, 1).reshape(-1, self.cate_out_channels) + for cate_pred in cate_preds + ] + flatten_cate_preds = torch.cat(cate_preds) + + loss_cate = self.loss_cate(flatten_cate_preds, flatten_cate_labels, avg_factor=num_ins + 1) + return dict( + loss_ins=loss_ins, + loss_cate=loss_cate) + + def solov2_target_single(self, + gt_bboxes_raw, + gt_labels_raw, + gt_masks_raw, + mask_feat_size): + + device = gt_labels_raw[0].device + + # ins + gt_areas = torch.sqrt((gt_bboxes_raw[:, 2] - gt_bboxes_raw[:, 0]) * ( + gt_bboxes_raw[:, 3] - gt_bboxes_raw[:, 1])) + + ins_label_list = [] + cate_label_list = [] + ins_ind_label_list = [] + grid_order_list = [] + for (lower_bound, upper_bound), stride, num_grid \ + in zip(self.scale_ranges, self.strides, self.seg_num_grids): + + hit_indices = ((gt_areas >= lower_bound) & (gt_areas <= upper_bound)).nonzero().flatten() + num_ins = len(hit_indices) + + ins_label = [] + grid_order = [] + cate_label = torch.zeros([num_grid, num_grid], dtype=torch.int64, device=device) + ins_ind_label = torch.zeros([num_grid ** 2], dtype=torch.bool, device=device) + + if num_ins == 0: + ins_label = torch.zeros([0, mask_feat_size[0], mask_feat_size[1]], dtype=torch.uint8, device=device) + ins_label_list.append(ins_label) + cate_label_list.append(cate_label) + ins_ind_label_list.append(ins_ind_label) + grid_order_list.append([]) + continue + gt_bboxes = gt_bboxes_raw[hit_indices] + gt_labels = gt_labels_raw[hit_indices] + gt_masks = gt_masks_raw[hit_indices.cpu().numpy(), ...] + + half_ws = 0.5 * (gt_bboxes[:, 2] - gt_bboxes[:, 0]) * self.sigma + half_hs = 0.5 * (gt_bboxes[:, 3] - gt_bboxes[:, 1]) * self.sigma + + # mass center + gt_masks_pt = torch.from_numpy(gt_masks).to(device=device) + center_ws, center_hs = center_of_mass(gt_masks_pt) + valid_mask_flags = gt_masks_pt.sum(dim=-1).sum(dim=-1) > 0 + + output_stride = 4 + for seg_mask, gt_label, half_h, half_w, center_h, center_w, valid_mask_flag in zip(gt_masks, gt_labels, half_hs, half_ws, center_hs, center_ws, valid_mask_flags): + if not valid_mask_flag: + continue + upsampled_size = (mask_feat_size[0] * 4, mask_feat_size[1] * 4) + coord_w = int((center_w / upsampled_size[1]) // (1. / num_grid)) + coord_h = int((center_h / upsampled_size[0]) // (1. / num_grid)) + + # left, top, right, down + top_box = max(0, int(((center_h - half_h) / upsampled_size[0]) // (1. / num_grid))) + down_box = min(num_grid - 1, int(((center_h + half_h) / upsampled_size[0]) // (1. / num_grid))) + left_box = max(0, int(((center_w - half_w) / upsampled_size[1]) // (1. / num_grid))) + right_box = min(num_grid - 1, int(((center_w + half_w) / upsampled_size[1]) // (1. / num_grid))) + + top = max(top_box, coord_h-1) + down = min(down_box, coord_h+1) + left = max(coord_w-1, left_box) + right = min(right_box, coord_w+1) + + cate_label[top:(down+1), left:(right+1)] = gt_label + seg_mask = mmcv.imrescale(seg_mask, scale=1. / output_stride) + seg_mask = torch.from_numpy(seg_mask).to(device=device) + for i in range(top, down+1): + for j in range(left, right+1): + label = int(i * num_grid + j) + + cur_ins_label = torch.zeros([mask_feat_size[0], mask_feat_size[1]], dtype=torch.uint8, + device=device) + cur_ins_label[:seg_mask.shape[0], :seg_mask.shape[1]] = seg_mask + ins_label.append(cur_ins_label) + ins_ind_label[label] = True + grid_order.append(label) + if len(ins_label) == 0: + ins_label = torch.zeros([0, mask_feat_size[0], mask_feat_size[1]], dtype=torch.uint8, device=device) + else: + ins_label = torch.stack(ins_label, 0) + ins_label_list.append(ins_label) + cate_label_list.append(cate_label) + ins_ind_label_list.append(ins_ind_label) + grid_order_list.append(grid_order) + return ins_label_list, cate_label_list, ins_ind_label_list, grid_order_list + + def get_seg(self, cate_preds, kernel_preds, seg_pred, img_metas, cfg, rescale=None): + num_levels = len(cate_preds) + featmap_size = seg_pred.size()[-2:] + + result_list = [] + for img_id in range(len(img_metas)): + cate_pred_list = [ + cate_preds[i][img_id].view(-1, self.cate_out_channels).detach() for i in range(num_levels) + ] + seg_pred_list = seg_pred[img_id, ...].unsqueeze(0) + kernel_pred_list = [ + kernel_preds[i][img_id].permute(1, 2, 0).view(-1, self.kernel_out_channels).detach() + for i in range(num_levels) + ] + img_shape = img_metas[img_id]['img_shape'] + scale_factor = img_metas[img_id]['scale_factor'] + ori_shape = img_metas[img_id]['ori_shape'] + + cate_pred_list = torch.cat(cate_pred_list, dim=0) + kernel_pred_list = torch.cat(kernel_pred_list, dim=0) + + result = self.get_seg_single(cate_pred_list, seg_pred_list, kernel_pred_list, + featmap_size, img_shape, ori_shape, scale_factor, cfg, rescale) + result_list.append(result) + return result_list + + def get_seg_single(self, + cate_preds, + seg_preds, + kernel_preds, + featmap_size, + img_shape, + ori_shape, + scale_factor, + cfg, + rescale=False, debug=False): + + assert len(cate_preds) == len(kernel_preds) + + # overall info. + h, w, _ = img_shape + upsampled_size_out = (featmap_size[0] * 4, featmap_size[1] * 4) + + # process. + inds = (cate_preds > cfg.score_thr) + cate_scores = cate_preds[inds] + if len(cate_scores) == 0: + return None + + # cate_labels & kernel_preds + inds = inds.nonzero() + cate_labels = inds[:, 1] + kernel_preds = kernel_preds[inds[:, 0]] + + # trans vector. + size_trans = cate_labels.new_tensor(self.seg_num_grids).pow(2).cumsum(0) + strides = kernel_preds.new_ones(size_trans[-1]) + + n_stage = len(self.seg_num_grids) + strides[:size_trans[0]] *= self.strides[0] + for ind_ in range(1, n_stage): + strides[size_trans[ind_-1]:size_trans[ind_]] *= self.strides[ind_] + strides = strides[inds[:, 0]] + + # mask encoding. + I, N = kernel_preds.shape + kernel_preds = kernel_preds.view(I, N, 1, 1) + seg_preds = F.conv2d(seg_preds, kernel_preds, stride=1).squeeze(0).sigmoid() + # mask. + seg_masks = seg_preds > cfg.mask_thr + sum_masks = seg_masks.sum((1, 2)).float() + + # filter. + keep = sum_masks > strides + if keep.sum() == 0: + return None + + seg_masks = seg_masks[keep, ...] + seg_preds = seg_preds[keep, ...] + sum_masks = sum_masks[keep] + cate_scores = cate_scores[keep] + cate_labels = cate_labels[keep] + + # maskness. + seg_scores = (seg_preds * seg_masks.float()).sum((1, 2)) / sum_masks + cate_scores *= seg_scores + + # sort and keep top nms_pre + sort_inds = torch.argsort(cate_scores, descending=True) + if len(sort_inds) > cfg.nms_pre: + sort_inds = sort_inds[:cfg.nms_pre] + seg_masks = seg_masks[sort_inds, :, :] + seg_preds = seg_preds[sort_inds, :, :] + sum_masks = sum_masks[sort_inds] + cate_scores = cate_scores[sort_inds] + cate_labels = cate_labels[sort_inds] + + # Matrix NMS + cate_scores = matrix_nms(seg_masks, cate_labels, cate_scores, + kernel=cfg.kernel,sigma=cfg.sigma, sum_masks=sum_masks) + + # filter. + keep = cate_scores >= cfg.update_thr + if keep.sum() == 0: + return None + seg_preds = seg_preds[keep, :, :] + cate_scores = cate_scores[keep] + cate_labels = cate_labels[keep] + + # sort and keep top_k + sort_inds = torch.argsort(cate_scores, descending=True) + if len(sort_inds) > cfg.max_per_img: + sort_inds = sort_inds[:cfg.max_per_img] + seg_preds = seg_preds[sort_inds, :, :] + cate_scores = cate_scores[sort_inds] + cate_labels = cate_labels[sort_inds] + + seg_preds = F.interpolate(seg_preds.unsqueeze(0), + size=upsampled_size_out, + mode='bilinear')[:, :, :h, :w] + seg_masks = F.interpolate(seg_preds, + size=ori_shape[:2], + mode='bilinear').squeeze(0) + seg_masks = seg_masks > cfg.mask_thr + return seg_masks, cate_labels, cate_scores diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solov2_light_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solov2_light_head.py new file mode 100644 index 000000000..46e90a159 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solov2_light_head.py @@ -0,0 +1,482 @@ +import mmcv +import torch +import torch.nn as nn +import torch.nn.functional as F +from mmcv.cnn import normal_init +from mmdet.ops import DeformConv, roi_align +from mmdet.core import multi_apply, matrix_nms +from ..builder import build_loss +from ..registry import HEADS +from ..utils import bias_init_with_prob, ConvModule + +INF = 1e8 + +def center_of_mass(bitmasks): + _, h, w = bitmasks.size() + ys = torch.arange(0, h, dtype=torch.float32, device=bitmasks.device) + xs = torch.arange(0, w, dtype=torch.float32, device=bitmasks.device) + + m00 = bitmasks.sum(dim=-1).sum(dim=-1).clamp(min=1e-6) + m10 = (bitmasks * xs).sum(dim=-1).sum(dim=-1) + m01 = (bitmasks * ys[:, None]).sum(dim=-1).sum(dim=-1) + center_x = m10 / m00 + center_y = m01 / m00 + return center_x, center_y + +def points_nms(heat, kernel=2): + # kernel must be 2 + hmax = nn.functional.max_pool2d( + heat, (kernel, kernel), stride=1, padding=1) + keep = (hmax[:, :, :-1, :-1] == heat).float() + return heat * keep + +def dice_loss(input, target): + input = input.contiguous().view(input.size()[0], -1) + target = target.contiguous().view(target.size()[0], -1).float() + + a = torch.sum(input * target, 1) + b = torch.sum(input * input, 1) + 0.001 + c = torch.sum(target * target, 1) + 0.001 + d = (2 * a) / (b + c) + return 1-d + +@HEADS.register_module +class SOLOv2LightHead(nn.Module): + + def __init__(self, + num_classes, + in_channels, + seg_feat_channels=256, + strides=(4, 8, 16, 32, 64), + base_edge_list=(16, 32, 64, 128, 256), + scale_ranges=((8, 32), (16, 64), (32, 128), (64, 256), (128, 512)), + sigma=0.2, + num_grids=None, + ins_out_channels=64, + stacked_convs=4, + loss_ins=None, + loss_cate=None, + conv_cfg=None, + norm_cfg=None, + use_dcn_in_tower=False, + type_dcn=None): + super(SOLOv2LightHead, self).__init__() + self.num_classes = num_classes + self.seg_num_grids = num_grids + self.cate_out_channels = self.num_classes - 1 + self.ins_out_channels = ins_out_channels + self.in_channels = in_channels + self.seg_feat_channels = seg_feat_channels + self.stacked_convs = stacked_convs + self.strides = strides + self.sigma = sigma + self.stacked_convs = stacked_convs + self.kernel_out_channels = self.ins_out_channels * 1 * 1 + self.base_edge_list = base_edge_list + self.scale_ranges = scale_ranges + self.loss_cate = build_loss(loss_cate) + self.ins_loss_weight = loss_ins['loss_weight'] + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + self.use_dcn_in_tower = use_dcn_in_tower + self.type_dcn = type_dcn + self._init_layers() + + def _init_layers(self): + norm_cfg = dict(type='GN', num_groups=32, requires_grad=True) + self.cate_convs = nn.ModuleList() + self.kernel_convs = nn.ModuleList() + for i in range(self.stacked_convs): + if self.use_dcn_in_tower and i == self.stacked_convs - 1: + cfg_conv = dict(type=self.type_dcn) + else: + cfg_conv = self.conv_cfg + + chn = self.in_channels + 2 if i == 0 else self.seg_feat_channels + self.kernel_convs.append( + ConvModule( + chn, + self.seg_feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=cfg_conv, + norm_cfg=norm_cfg, + bias=norm_cfg is None)) + + chn = self.in_channels if i == 0 else self.seg_feat_channels + self.cate_convs.append( + ConvModule( + chn, + self.seg_feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=cfg_conv, + norm_cfg=norm_cfg, + bias=norm_cfg is None)) + + self.solo_cate = nn.Conv2d( + self.seg_feat_channels, self.cate_out_channels, 3, padding=1) + + self.solo_kernel = nn.Conv2d( + self.seg_feat_channels, self.kernel_out_channels, 3, padding=1) + + def init_weights(self): + for m in self.cate_convs: + normal_init(m.conv, std=0.01) + for m in self.kernel_convs: + normal_init(m.conv, std=0.01) + bias_cate = bias_init_with_prob(0.01) + normal_init(self.solo_cate, std=0.01, bias=bias_cate) + normal_init(self.solo_kernel, std=0.01) + + def forward(self, feats, eval=False): + new_feats = self.split_feats(feats) + featmap_sizes = [featmap.size()[-2:] for featmap in new_feats] + upsampled_size = (featmap_sizes[0][0] * 2, featmap_sizes[0][1] * 2) + cate_pred, kernel_pred = multi_apply(self.forward_single, new_feats, + list(range(len(self.seg_num_grids))), + eval=eval, upsampled_size=upsampled_size) + return cate_pred, kernel_pred + + def split_feats(self, feats): + return (F.interpolate(feats[0], scale_factor=0.5, mode='bilinear'), + feats[1], + feats[2], + feats[3], + F.interpolate(feats[4], size=feats[3].shape[-2:], mode='bilinear')) + + def forward_single(self, x, idx, eval=False, upsampled_size=None): + ins_kernel_feat = x + # ins branch + # concat coord + x_range = torch.linspace(-1, 1, ins_kernel_feat.shape[-1], device=ins_kernel_feat.device) + y_range = torch.linspace(-1, 1, ins_kernel_feat.shape[-2], device=ins_kernel_feat.device) + y, x = torch.meshgrid(y_range, x_range) + y = y.expand([ins_kernel_feat.shape[0], 1, -1, -1]) + x = x.expand([ins_kernel_feat.shape[0], 1, -1, -1]) + coord_feat = torch.cat([x, y], 1) + ins_kernel_feat = torch.cat([ins_kernel_feat, coord_feat], 1) + + # kernel branch + kernel_feat = ins_kernel_feat + seg_num_grid = self.seg_num_grids[idx] + kernel_feat = F.interpolate(kernel_feat, size=seg_num_grid, mode='bilinear') + + cate_feat = kernel_feat[:, :-2, :, :] + + kernel_feat = kernel_feat.contiguous() + for i, kernel_layer in enumerate(self.kernel_convs): + kernel_feat = kernel_layer(kernel_feat) + kernel_pred = self.solo_kernel(kernel_feat) + + # cate branch + cate_feat = cate_feat.contiguous() + for i, cate_layer in enumerate(self.cate_convs): + cate_feat = cate_layer(cate_feat) + cate_pred = self.solo_cate(cate_feat) + + if eval: + cate_pred = points_nms(cate_pred.sigmoid(), kernel=2).permute(0, 2, 3, 1) + return cate_pred, kernel_pred + + def loss(self, + cate_preds, + kernel_preds, + ins_pred, + gt_bbox_list, + gt_label_list, + gt_mask_list, + img_metas, + cfg, + gt_bboxes_ignore=None): + mask_feat_size = ins_pred.size()[-2:] + ins_label_list, cate_label_list, ins_ind_label_list, grid_order_list = multi_apply( + self.solov2_target_single, + gt_bbox_list, + gt_label_list, + gt_mask_list, + mask_feat_size=mask_feat_size) + + # ins + ins_labels = [torch.cat([ins_labels_level_img + for ins_labels_level_img in ins_labels_level], 0) + for ins_labels_level in zip(*ins_label_list)] + + kernel_preds = [[kernel_preds_level_img.view(kernel_preds_level_img.shape[0], -1)[:, grid_orders_level_img] + for kernel_preds_level_img, grid_orders_level_img in + zip(kernel_preds_level, grid_orders_level)] + for kernel_preds_level, grid_orders_level in zip(kernel_preds, zip(*grid_order_list))] + # generate masks + ins_pred = ins_pred + ins_pred_list = [] + for b_kernel_pred in kernel_preds: + b_mask_pred = [] + for idx, kernel_pred in enumerate(b_kernel_pred): + + if kernel_pred.size()[-1] == 0: + continue + cur_ins_pred = ins_pred[idx, ...] + H, W = cur_ins_pred.shape[-2:] + N, I = kernel_pred.shape + cur_ins_pred = cur_ins_pred.unsqueeze(0) + kernel_pred = kernel_pred.permute(1, 0).view(I, -1, 1, 1) + cur_ins_pred = F.conv2d(cur_ins_pred, kernel_pred, stride=1).view(-1, H, W) + b_mask_pred.append(cur_ins_pred) + if len(b_mask_pred) == 0: + b_mask_pred = None + else: + b_mask_pred = torch.cat(b_mask_pred, 0) + ins_pred_list.append(b_mask_pred) + + ins_ind_labels = [ + torch.cat([ins_ind_labels_level_img.flatten() + for ins_ind_labels_level_img in ins_ind_labels_level]) + for ins_ind_labels_level in zip(*ins_ind_label_list) + ] + flatten_ins_ind_labels = torch.cat(ins_ind_labels) + + num_ins = flatten_ins_ind_labels.sum() + + # dice loss + loss_ins = [] + for input, target in zip(ins_pred_list, ins_labels): + if input is None: + continue + input = torch.sigmoid(input) + loss_ins.append(dice_loss(input, target)) + loss_ins = torch.cat(loss_ins).mean() + loss_ins = loss_ins * self.ins_loss_weight + + # cate + cate_labels = [ + torch.cat([cate_labels_level_img.flatten() + for cate_labels_level_img in cate_labels_level]) + for cate_labels_level in zip(*cate_label_list) + ] + flatten_cate_labels = torch.cat(cate_labels) + + cate_preds = [ + cate_pred.permute(0, 2, 3, 1).reshape(-1, self.cate_out_channels) + for cate_pred in cate_preds + ] + flatten_cate_preds = torch.cat(cate_preds) + + loss_cate = self.loss_cate(flatten_cate_preds, flatten_cate_labels, avg_factor=num_ins + 1) + return dict( + loss_ins=loss_ins, + loss_cate=loss_cate) + + def solov2_target_single(self, + gt_bboxes_raw, + gt_labels_raw, + gt_masks_raw, + mask_feat_size): + + device = gt_labels_raw[0].device + + # ins + gt_areas = torch.sqrt((gt_bboxes_raw[:, 2] - gt_bboxes_raw[:, 0]) * ( + gt_bboxes_raw[:, 3] - gt_bboxes_raw[:, 1])) + + ins_label_list = [] + cate_label_list = [] + ins_ind_label_list = [] + grid_order_list = [] + for (lower_bound, upper_bound), stride, num_grid \ + in zip(self.scale_ranges, self.strides, self.seg_num_grids): + + hit_indices = ((gt_areas >= lower_bound) & (gt_areas <= upper_bound)).nonzero().flatten() + num_ins = len(hit_indices) + + ins_label = [] + grid_order = [] + cate_label = torch.zeros([num_grid, num_grid], dtype=torch.int64, device=device) + ins_ind_label = torch.zeros([num_grid ** 2], dtype=torch.bool, device=device) + + if num_ins == 0: + ins_label = torch.zeros([0, mask_feat_size[0], mask_feat_size[1]], dtype=torch.uint8, device=device) + ins_label_list.append(ins_label) + cate_label_list.append(cate_label) + ins_ind_label_list.append(ins_ind_label) + grid_order_list.append([]) + continue + gt_bboxes = gt_bboxes_raw[hit_indices] + gt_labels = gt_labels_raw[hit_indices] + gt_masks = gt_masks_raw[hit_indices.cpu().numpy(), ...] + + half_ws = 0.5 * (gt_bboxes[:, 2] - gt_bboxes[:, 0]) * self.sigma + half_hs = 0.5 * (gt_bboxes[:, 3] - gt_bboxes[:, 1]) * self.sigma + + # mass center + gt_masks_pt = torch.from_numpy(gt_masks).to(device=device) + center_ws, center_hs = center_of_mass(gt_masks_pt) + valid_mask_flags = gt_masks_pt.sum(dim=-1).sum(dim=-1) > 0 + output_stride = 4 + for seg_mask, gt_label, half_h, half_w, center_h, center_w, valid_mask_flag in zip(gt_masks, gt_labels, half_hs, half_ws, center_hs, center_ws, valid_mask_flags): + if not valid_mask_flag: + continue + upsampled_size = (mask_feat_size[0] * 4, mask_feat_size[1] * 4) + coord_w = int((center_w / upsampled_size[1]) // (1. / num_grid)) + coord_h = int((center_h / upsampled_size[0]) // (1. / num_grid)) + + # left, top, right, down + top_box = max(0, int(((center_h - half_h) / upsampled_size[0]) // (1. / num_grid))) + down_box = min(num_grid - 1, int(((center_h + half_h) / upsampled_size[0]) // (1. / num_grid))) + left_box = max(0, int(((center_w - half_w) / upsampled_size[1]) // (1. / num_grid))) + right_box = min(num_grid - 1, int(((center_w + half_w) / upsampled_size[1]) // (1. / num_grid))) + + top = max(top_box, coord_h-1) + down = min(down_box, coord_h+1) + left = max(coord_w-1, left_box) + right = min(right_box, coord_w+1) + + cate_label[top:(down+1), left:(right+1)] = gt_label + seg_mask = mmcv.imrescale(seg_mask, scale=1. / output_stride) + seg_mask = torch.from_numpy(seg_mask).to(device=device) + for i in range(top, down+1): + for j in range(left, right+1): + label = int(i * num_grid + j) + + cur_ins_label = torch.zeros([mask_feat_size[0], mask_feat_size[1]], dtype=torch.uint8, + device=device) + cur_ins_label[:seg_mask.shape[0], :seg_mask.shape[1]] = seg_mask + ins_label.append(cur_ins_label) + ins_ind_label[label] = True + grid_order.append(label) + if len(ins_label) == 0: + ins_label = torch.zeros([0, mask_feat_size[0], mask_feat_size[1]], dtype=torch.uint8, device=device) + else: + ins_label = torch.stack(ins_label, 0) + ins_label_list.append(ins_label) + cate_label_list.append(cate_label) + ins_ind_label_list.append(ins_ind_label) + grid_order_list.append(grid_order) + return ins_label_list, cate_label_list, ins_ind_label_list, grid_order_list + + def get_seg(self, cate_preds, kernel_preds, seg_pred, img_metas, cfg, rescale=None): + num_levels = len(cate_preds) + featmap_size = seg_pred.size()[-2:] + + result_list = [] + for img_id in range(len(img_metas)): + cate_pred_list = [ + cate_preds[i][img_id].view(-1, self.cate_out_channels).detach() for i in range(num_levels) + ] + seg_pred_list = seg_pred[img_id, ...].unsqueeze(0) + kernel_pred_list = [ + kernel_preds[i][img_id].permute(1, 2, 0).view(-1, self.kernel_out_channels).detach() + for i in range(num_levels) + ] + img_shape = img_metas[img_id]['img_shape'] + scale_factor = img_metas[img_id]['scale_factor'] + ori_shape = img_metas[img_id]['ori_shape'] + + cate_pred_list = torch.cat(cate_pred_list, dim=0) + kernel_pred_list = torch.cat(kernel_pred_list, dim=0) + + result = self.get_seg_single(cate_pred_list, seg_pred_list, kernel_pred_list, + featmap_size, img_shape, ori_shape, scale_factor, cfg, rescale) + result_list.append(result) + return result_list + + def get_seg_single(self, + cate_preds, + seg_preds, + kernel_preds, + featmap_size, + img_shape, + ori_shape, + scale_factor, + cfg, + rescale=False, debug=False): + + assert len(cate_preds) == len(kernel_preds) + + # overall info. + h, w, _ = img_shape + upsampled_size_out = (featmap_size[0] * 4, featmap_size[1] * 4) + + # process. + inds = (cate_preds > cfg.score_thr) + cate_scores = cate_preds[inds] + if len(cate_scores) == 0: + return None + + # cate_labels & kernel_preds + inds = inds.nonzero() + cate_labels = inds[:, 1] + kernel_preds = kernel_preds[inds[:, 0]] + + # trans vector. + size_trans = cate_labels.new_tensor(self.seg_num_grids).pow(2).cumsum(0) + strides = kernel_preds.new_ones(size_trans[-1]) + + n_stage = len(self.seg_num_grids) + strides[:size_trans[0]] *= self.strides[0] + for ind_ in range(1, n_stage): + strides[size_trans[ind_-1]:size_trans[ind_]] *= self.strides[ind_] + strides = strides[inds[:, 0]] + + # mask encoding. + I, N = kernel_preds.shape + kernel_preds = kernel_preds.view(I, N, 1, 1) + seg_preds = F.conv2d(seg_preds, kernel_preds, stride=1).squeeze(0).sigmoid() + # mask. + seg_masks = seg_preds > cfg.mask_thr + sum_masks = seg_masks.sum((1, 2)).float() + + # filter. + keep = sum_masks > strides + if keep.sum() == 0: + return None + + seg_masks = seg_masks[keep, ...] + seg_preds = seg_preds[keep, ...] + sum_masks = sum_masks[keep] + cate_scores = cate_scores[keep] + cate_labels = cate_labels[keep] + + # maskness. + seg_scores = (seg_preds * seg_masks.float()).sum((1, 2)) / sum_masks + cate_scores *= seg_scores + + # sort and keep top nms_pre + sort_inds = torch.argsort(cate_scores, descending=True) + if len(sort_inds) > cfg.nms_pre: + sort_inds = sort_inds[:cfg.nms_pre] + seg_masks = seg_masks[sort_inds, :, :] + seg_preds = seg_preds[sort_inds, :, :] + sum_masks = sum_masks[sort_inds] + cate_scores = cate_scores[sort_inds] + cate_labels = cate_labels[sort_inds] + + # Matrix NMS + cate_scores = matrix_nms(seg_masks, cate_labels, cate_scores, + kernel=cfg.kernel,sigma=cfg.sigma, sum_masks=sum_masks) + + # filter. + keep = cate_scores >= cfg.update_thr + if keep.sum() == 0: + return None + seg_preds = seg_preds[keep, :, :] + cate_scores = cate_scores[keep] + cate_labels = cate_labels[keep] + + # sort and keep top_k + sort_inds = torch.argsort(cate_scores, descending=True) + if len(sort_inds) > cfg.max_per_img: + sort_inds = sort_inds[:cfg.max_per_img] + seg_preds = seg_preds[sort_inds, :, :] + cate_scores = cate_scores[sort_inds] + cate_labels = cate_labels[sort_inds] + + seg_preds = F.interpolate(seg_preds.unsqueeze(0), + size=upsampled_size_out, + mode='bilinear')[:, :, :h, :w] + seg_masks = F.interpolate(seg_preds, + size=ori_shape[:2], + mode='bilinear').squeeze(0) + seg_masks = seg_masks > cfg.mask_thr + return seg_masks, cate_labels, cate_scores diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ssd_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ssd_head.py new file mode 100644 index 000000000..57113679b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ssd_head.py @@ -0,0 +1,201 @@ +import numpy as np +import torch +import torch.nn as nn +import torch.nn.functional as F +from mmcv.cnn import xavier_init + +from mmdet.core import AnchorGenerator, anchor_target, multi_apply +from ..losses import smooth_l1_loss +from ..registry import HEADS +from .anchor_head import AnchorHead + + +# TODO: add loss evaluator for SSD +@HEADS.register_module +class SSDHead(AnchorHead): + + def __init__(self, + input_size=300, + num_classes=81, + in_channels=(512, 1024, 512, 256, 256, 256), + anchor_strides=(8, 16, 32, 64, 100, 300), + basesize_ratio_range=(0.1, 0.9), + anchor_ratios=([2], [2, 3], [2, 3], [2, 3], [2], [2]), + target_means=(.0, .0, .0, .0), + target_stds=(1.0, 1.0, 1.0, 1.0)): + super(AnchorHead, self).__init__() + self.input_size = input_size + self.num_classes = num_classes + self.in_channels = in_channels + self.cls_out_channels = num_classes + num_anchors = [len(ratios) * 2 + 2 for ratios in anchor_ratios] + reg_convs = [] + cls_convs = [] + for i in range(len(in_channels)): + reg_convs.append( + nn.Conv2d( + in_channels[i], + num_anchors[i] * 4, + kernel_size=3, + padding=1)) + cls_convs.append( + nn.Conv2d( + in_channels[i], + num_anchors[i] * num_classes, + kernel_size=3, + padding=1)) + self.reg_convs = nn.ModuleList(reg_convs) + self.cls_convs = nn.ModuleList(cls_convs) + + min_ratio, max_ratio = basesize_ratio_range + min_ratio = int(min_ratio * 100) + max_ratio = int(max_ratio * 100) + step = int(np.floor(max_ratio - min_ratio) / (len(in_channels) - 2)) + min_sizes = [] + max_sizes = [] + for r in range(int(min_ratio), int(max_ratio) + 1, step): + min_sizes.append(int(input_size * r / 100)) + max_sizes.append(int(input_size * (r + step) / 100)) + if input_size == 300: + if basesize_ratio_range[0] == 0.15: # SSD300 COCO + min_sizes.insert(0, int(input_size * 7 / 100)) + max_sizes.insert(0, int(input_size * 15 / 100)) + elif basesize_ratio_range[0] == 0.2: # SSD300 VOC + min_sizes.insert(0, int(input_size * 10 / 100)) + max_sizes.insert(0, int(input_size * 20 / 100)) + elif input_size == 512: + if basesize_ratio_range[0] == 0.1: # SSD512 COCO + min_sizes.insert(0, int(input_size * 4 / 100)) + max_sizes.insert(0, int(input_size * 10 / 100)) + elif basesize_ratio_range[0] == 0.15: # SSD512 VOC + min_sizes.insert(0, int(input_size * 7 / 100)) + max_sizes.insert(0, int(input_size * 15 / 100)) + self.anchor_generators = [] + self.anchor_strides = anchor_strides + for k in range(len(anchor_strides)): + base_size = min_sizes[k] + stride = anchor_strides[k] + ctr = ((stride - 1) / 2., (stride - 1) / 2.) + scales = [1., np.sqrt(max_sizes[k] / min_sizes[k])] + ratios = [1.] + for r in anchor_ratios[k]: + ratios += [1 / r, r] # 4 or 6 ratio + anchor_generator = AnchorGenerator( + base_size, scales, ratios, scale_major=False, ctr=ctr) + indices = list(range(len(ratios))) + indices.insert(1, len(indices)) + anchor_generator.base_anchors = torch.index_select( + anchor_generator.base_anchors, 0, torch.LongTensor(indices)) + self.anchor_generators.append(anchor_generator) + + self.target_means = target_means + self.target_stds = target_stds + self.use_sigmoid_cls = False + self.cls_focal_loss = False + self.fp16_enabled = False + + def init_weights(self): + for m in self.modules(): + if isinstance(m, nn.Conv2d): + xavier_init(m, distribution='uniform', bias=0) + + def forward(self, feats): + cls_scores = [] + bbox_preds = [] + for feat, reg_conv, cls_conv in zip(feats, self.reg_convs, + self.cls_convs): + cls_scores.append(cls_conv(feat)) + bbox_preds.append(reg_conv(feat)) + return cls_scores, bbox_preds + + def loss_single(self, cls_score, bbox_pred, labels, label_weights, + bbox_targets, bbox_weights, num_total_samples, cfg): + loss_cls_all = F.cross_entropy( + cls_score, labels, reduction='none') * label_weights + pos_inds = (labels > 0).nonzero().view(-1) + neg_inds = (labels == 0).nonzero().view(-1) + + num_pos_samples = pos_inds.size(0) + num_neg_samples = cfg.neg_pos_ratio * num_pos_samples + if num_neg_samples > neg_inds.size(0): + num_neg_samples = neg_inds.size(0) + topk_loss_cls_neg, _ = loss_cls_all[neg_inds].topk(num_neg_samples) + loss_cls_pos = loss_cls_all[pos_inds].sum() + loss_cls_neg = topk_loss_cls_neg.sum() + loss_cls = (loss_cls_pos + loss_cls_neg) / num_total_samples + + loss_bbox = smooth_l1_loss( + bbox_pred, + bbox_targets, + bbox_weights, + beta=cfg.smoothl1_beta, + avg_factor=num_total_samples) + return loss_cls[None], loss_bbox + + def loss(self, + cls_scores, + bbox_preds, + gt_bboxes, + gt_labels, + img_metas, + cfg, + gt_bboxes_ignore=None): + featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] + assert len(featmap_sizes) == len(self.anchor_generators) + + device = cls_scores[0].device + + anchor_list, valid_flag_list = self.get_anchors( + featmap_sizes, img_metas, device=device) + cls_reg_targets = anchor_target( + anchor_list, + valid_flag_list, + gt_bboxes, + img_metas, + self.target_means, + self.target_stds, + cfg, + gt_bboxes_ignore_list=gt_bboxes_ignore, + gt_labels_list=gt_labels, + label_channels=1, + sampling=False, + unmap_outputs=False) + if cls_reg_targets is None: + return None + (labels_list, label_weights_list, bbox_targets_list, bbox_weights_list, + num_total_pos, num_total_neg) = cls_reg_targets + + num_images = len(img_metas) + all_cls_scores = torch.cat([ + s.permute(0, 2, 3, 1).reshape( + num_images, -1, self.cls_out_channels) for s in cls_scores + ], 1) + all_labels = torch.cat(labels_list, -1).view(num_images, -1) + all_label_weights = torch.cat(label_weights_list, + -1).view(num_images, -1) + all_bbox_preds = torch.cat([ + b.permute(0, 2, 3, 1).reshape(num_images, -1, 4) + for b in bbox_preds + ], -2) + all_bbox_targets = torch.cat(bbox_targets_list, + -2).view(num_images, -1, 4) + all_bbox_weights = torch.cat(bbox_weights_list, + -2).view(num_images, -1, 4) + + # check NaN and Inf + assert torch.isfinite(all_cls_scores).all().item(), \ + 'classification scores become infinite or NaN!' + assert torch.isfinite(all_bbox_preds).all().item(), \ + 'bbox predications become infinite or NaN!' + + losses_cls, losses_bbox = multi_apply( + self.loss_single, + all_cls_scores, + all_bbox_preds, + all_labels, + all_label_weights, + all_bbox_targets, + all_bbox_weights, + num_total_samples=num_total_pos, + cfg=cfg) + return dict(loss_cls=losses_cls, loss_bbox=losses_bbox) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/__init__.py new file mode 100644 index 000000000..6fb56d63c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/__init__.py @@ -0,0 +1,6 @@ +from .hrnet import HRNet +from .resnet import ResNet, make_res_layer +from .resnext import ResNeXt +from .ssd_vgg import SSDVGG + +__all__ = ['ResNet', 'make_res_layer', 'ResNeXt', 'SSDVGG', 'HRNet'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/hrnet.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/hrnet.py new file mode 100644 index 000000000..0f7a082cf --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/hrnet.py @@ -0,0 +1,524 @@ +import torch.nn as nn +from mmcv.cnn import constant_init, kaiming_init +from mmcv.runner import load_checkpoint +from torch.nn.modules.batchnorm import _BatchNorm + +from mmdet.utils import get_root_logger +from ..registry import BACKBONES +from ..utils import build_conv_layer, build_norm_layer +from .resnet import BasicBlock, Bottleneck + + +class HRModule(nn.Module): + """ High-Resolution Module for HRNet. In this module, every branch + has 4 BasicBlocks/Bottlenecks. Fusion/Exchange is in this module. + """ + + def __init__(self, + num_branches, + blocks, + num_blocks, + in_channels, + num_channels, + multiscale_output=True, + with_cp=False, + conv_cfg=None, + norm_cfg=dict(type='BN')): + super(HRModule, self).__init__() + self._check_branches(num_branches, num_blocks, in_channels, + num_channels) + + self.in_channels = in_channels + self.num_branches = num_branches + + self.multiscale_output = multiscale_output + self.norm_cfg = norm_cfg + self.conv_cfg = conv_cfg + self.with_cp = with_cp + self.branches = self._make_branches(num_branches, blocks, num_blocks, + num_channels) + self.fuse_layers = self._make_fuse_layers() + self.relu = nn.ReLU(inplace=False) + + def _check_branches(self, num_branches, num_blocks, in_channels, + num_channels): + if num_branches != len(num_blocks): + error_msg = 'NUM_BRANCHES({}) <> NUM_BLOCKS({})'.format( + num_branches, len(num_blocks)) + raise ValueError(error_msg) + + if num_branches != len(num_channels): + error_msg = 'NUM_BRANCHES({}) <> NUM_CHANNELS({})'.format( + num_branches, len(num_channels)) + raise ValueError(error_msg) + + if num_branches != len(in_channels): + error_msg = 'NUM_BRANCHES({}) <> NUM_INCHANNELS({})'.format( + num_branches, len(in_channels)) + raise ValueError(error_msg) + + def _make_one_branch(self, + branch_index, + block, + num_blocks, + num_channels, + stride=1): + downsample = None + if stride != 1 or \ + self.in_channels[branch_index] != \ + num_channels[branch_index] * block.expansion: + downsample = nn.Sequential( + build_conv_layer( + self.conv_cfg, + self.in_channels[branch_index], + num_channels[branch_index] * block.expansion, + kernel_size=1, + stride=stride, + bias=False), + build_norm_layer(self.norm_cfg, num_channels[branch_index] * + block.expansion)[1]) + + layers = [] + layers.append( + block( + self.in_channels[branch_index], + num_channels[branch_index], + stride, + downsample=downsample, + with_cp=self.with_cp, + norm_cfg=self.norm_cfg, + conv_cfg=self.conv_cfg)) + self.in_channels[branch_index] = \ + num_channels[branch_index] * block.expansion + for i in range(1, num_blocks[branch_index]): + layers.append( + block( + self.in_channels[branch_index], + num_channels[branch_index], + with_cp=self.with_cp, + norm_cfg=self.norm_cfg, + conv_cfg=self.conv_cfg)) + + return nn.Sequential(*layers) + + def _make_branches(self, num_branches, block, num_blocks, num_channels): + branches = [] + + for i in range(num_branches): + branches.append( + self._make_one_branch(i, block, num_blocks, num_channels)) + + return nn.ModuleList(branches) + + def _make_fuse_layers(self): + if self.num_branches == 1: + return None + + num_branches = self.num_branches + in_channels = self.in_channels + fuse_layers = [] + num_out_branches = num_branches if self.multiscale_output else 1 + for i in range(num_out_branches): + fuse_layer = [] + for j in range(num_branches): + if j > i: + fuse_layer.append( + nn.Sequential( + build_conv_layer( + self.conv_cfg, + in_channels[j], + in_channels[i], + kernel_size=1, + stride=1, + padding=0, + bias=False), + build_norm_layer(self.norm_cfg, in_channels[i])[1], + nn.Upsample( + scale_factor=2**(j - i), mode='nearest'))) + elif j == i: + fuse_layer.append(None) + else: + conv_downsamples = [] + for k in range(i - j): + if k == i - j - 1: + conv_downsamples.append( + nn.Sequential( + build_conv_layer( + self.conv_cfg, + in_channels[j], + in_channels[i], + kernel_size=3, + stride=2, + padding=1, + bias=False), + build_norm_layer(self.norm_cfg, + in_channels[i])[1])) + else: + conv_downsamples.append( + nn.Sequential( + build_conv_layer( + self.conv_cfg, + in_channels[j], + in_channels[j], + kernel_size=3, + stride=2, + padding=1, + bias=False), + build_norm_layer(self.norm_cfg, + in_channels[j])[1], + nn.ReLU(inplace=False))) + fuse_layer.append(nn.Sequential(*conv_downsamples)) + fuse_layers.append(nn.ModuleList(fuse_layer)) + + return nn.ModuleList(fuse_layers) + + def forward(self, x): + if self.num_branches == 1: + return [self.branches[0](x[0])] + + for i in range(self.num_branches): + x[i] = self.branches[i](x[i]) + + x_fuse = [] + for i in range(len(self.fuse_layers)): + y = 0 + for j in range(self.num_branches): + if i == j: + y += x[j] + else: + y += self.fuse_layers[i][j](x[j]) + x_fuse.append(self.relu(y)) + return x_fuse + + +@BACKBONES.register_module +class HRNet(nn.Module): + """HRNet backbone. + + High-Resolution Representations for Labeling Pixels and Regions + arXiv: https://arxiv.org/abs/1904.04514 + + Args: + extra (dict): detailed configuration for each stage of HRNet. + in_channels (int): Number of input image channels. Normally 3. + conv_cfg (dict): dictionary to construct and config conv layer. + norm_cfg (dict): dictionary to construct and config norm layer. + norm_eval (bool): Whether to set norm layers to eval mode, namely, + freeze running stats (mean and var). Note: Effect on Batch Norm + and its variants only. + with_cp (bool): Use checkpoint or not. Using checkpoint will save some + memory while slowing down the training speed. + zero_init_residual (bool): whether to use zero init for last norm layer + in resblocks to let them behave as identity. + + Example: + >>> from mmdet.models import HRNet + >>> import torch + >>> extra = dict( + >>> stage1=dict( + >>> num_modules=1, + >>> num_branches=1, + >>> block='BOTTLENECK', + >>> num_blocks=(4, ), + >>> num_channels=(64, )), + >>> stage2=dict( + >>> num_modules=1, + >>> num_branches=2, + >>> block='BASIC', + >>> num_blocks=(4, 4), + >>> num_channels=(32, 64)), + >>> stage3=dict( + >>> num_modules=4, + >>> num_branches=3, + >>> block='BASIC', + >>> num_blocks=(4, 4, 4), + >>> num_channels=(32, 64, 128)), + >>> stage4=dict( + >>> num_modules=3, + >>> num_branches=4, + >>> block='BASIC', + >>> num_blocks=(4, 4, 4, 4), + >>> num_channels=(32, 64, 128, 256))) + >>> self = HRNet(extra, in_channels=1) + >>> self.eval() + >>> inputs = torch.rand(1, 1, 32, 32) + >>> level_outputs = self.forward(inputs) + >>> for level_out in level_outputs: + ... print(tuple(level_out.shape)) + (1, 32, 8, 8) + (1, 64, 4, 4) + (1, 128, 2, 2) + (1, 256, 1, 1) + """ + + blocks_dict = {'BASIC': BasicBlock, 'BOTTLENECK': Bottleneck} + + def __init__(self, + extra, + in_channels=3, + conv_cfg=None, + norm_cfg=dict(type='BN'), + norm_eval=True, + with_cp=False, + zero_init_residual=False): + super(HRNet, self).__init__() + self.extra = extra + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + self.norm_eval = norm_eval + self.with_cp = with_cp + self.zero_init_residual = zero_init_residual + + # stem net + self.norm1_name, norm1 = build_norm_layer(self.norm_cfg, 64, postfix=1) + self.norm2_name, norm2 = build_norm_layer(self.norm_cfg, 64, postfix=2) + + self.conv1 = build_conv_layer( + self.conv_cfg, + in_channels, + 64, + kernel_size=3, + stride=2, + padding=1, + bias=False) + + self.add_module(self.norm1_name, norm1) + self.conv2 = build_conv_layer( + self.conv_cfg, + 64, + 64, + kernel_size=3, + stride=2, + padding=1, + bias=False) + + self.add_module(self.norm2_name, norm2) + self.relu = nn.ReLU(inplace=True) + + # stage 1 + self.stage1_cfg = self.extra['stage1'] + num_channels = self.stage1_cfg['num_channels'][0] + block_type = self.stage1_cfg['block'] + num_blocks = self.stage1_cfg['num_blocks'][0] + + block = self.blocks_dict[block_type] + stage1_out_channels = num_channels * block.expansion + self.layer1 = self._make_layer(block, 64, num_channels, num_blocks) + + # stage 2 + self.stage2_cfg = self.extra['stage2'] + num_channels = self.stage2_cfg['num_channels'] + block_type = self.stage2_cfg['block'] + + block = self.blocks_dict[block_type] + num_channels = [channel * block.expansion for channel in num_channels] + self.transition1 = self._make_transition_layer([stage1_out_channels], + num_channels) + self.stage2, pre_stage_channels = self._make_stage( + self.stage2_cfg, num_channels) + + # stage 3 + self.stage3_cfg = self.extra['stage3'] + num_channels = self.stage3_cfg['num_channels'] + block_type = self.stage3_cfg['block'] + + block = self.blocks_dict[block_type] + num_channels = [channel * block.expansion for channel in num_channels] + self.transition2 = self._make_transition_layer(pre_stage_channels, + num_channels) + self.stage3, pre_stage_channels = self._make_stage( + self.stage3_cfg, num_channels) + + # stage 4 + self.stage4_cfg = self.extra['stage4'] + num_channels = self.stage4_cfg['num_channels'] + block_type = self.stage4_cfg['block'] + + block = self.blocks_dict[block_type] + num_channels = [channel * block.expansion for channel in num_channels] + self.transition3 = self._make_transition_layer(pre_stage_channels, + num_channels) + self.stage4, pre_stage_channels = self._make_stage( + self.stage4_cfg, num_channels) + + @property + def norm1(self): + return getattr(self, self.norm1_name) + + @property + def norm2(self): + return getattr(self, self.norm2_name) + + def _make_transition_layer(self, num_channels_pre_layer, + num_channels_cur_layer): + num_branches_cur = len(num_channels_cur_layer) + num_branches_pre = len(num_channels_pre_layer) + + transition_layers = [] + for i in range(num_branches_cur): + if i < num_branches_pre: + if num_channels_cur_layer[i] != num_channels_pre_layer[i]: + transition_layers.append( + nn.Sequential( + build_conv_layer( + self.conv_cfg, + num_channels_pre_layer[i], + num_channels_cur_layer[i], + kernel_size=3, + stride=1, + padding=1, + bias=False), + build_norm_layer(self.norm_cfg, + num_channels_cur_layer[i])[1], + nn.ReLU(inplace=True))) + else: + transition_layers.append(None) + else: + conv_downsamples = [] + for j in range(i + 1 - num_branches_pre): + in_channels = num_channels_pre_layer[-1] + out_channels = num_channels_cur_layer[i] \ + if j == i - num_branches_pre else in_channels + conv_downsamples.append( + nn.Sequential( + build_conv_layer( + self.conv_cfg, + in_channels, + out_channels, + kernel_size=3, + stride=2, + padding=1, + bias=False), + build_norm_layer(self.norm_cfg, out_channels)[1], + nn.ReLU(inplace=True))) + transition_layers.append(nn.Sequential(*conv_downsamples)) + + return nn.ModuleList(transition_layers) + + def _make_layer(self, block, inplanes, planes, blocks, stride=1): + downsample = None + if stride != 1 or inplanes != planes * block.expansion: + downsample = nn.Sequential( + build_conv_layer( + self.conv_cfg, + inplanes, + planes * block.expansion, + kernel_size=1, + stride=stride, + bias=False), + build_norm_layer(self.norm_cfg, planes * block.expansion)[1]) + + layers = [] + layers.append( + block( + inplanes, + planes, + stride, + downsample=downsample, + with_cp=self.with_cp, + norm_cfg=self.norm_cfg, + conv_cfg=self.conv_cfg)) + inplanes = planes * block.expansion + for i in range(1, blocks): + layers.append( + block( + inplanes, + planes, + with_cp=self.with_cp, + norm_cfg=self.norm_cfg, + conv_cfg=self.conv_cfg)) + + return nn.Sequential(*layers) + + def _make_stage(self, layer_config, in_channels, multiscale_output=True): + num_modules = layer_config['num_modules'] + num_branches = layer_config['num_branches'] + num_blocks = layer_config['num_blocks'] + num_channels = layer_config['num_channels'] + block = self.blocks_dict[layer_config['block']] + + hr_modules = [] + for i in range(num_modules): + # multi_scale_output is only used for the last module + if not multiscale_output and i == num_modules - 1: + reset_multiscale_output = False + else: + reset_multiscale_output = True + + hr_modules.append( + HRModule( + num_branches, + block, + num_blocks, + in_channels, + num_channels, + reset_multiscale_output, + with_cp=self.with_cp, + norm_cfg=self.norm_cfg, + conv_cfg=self.conv_cfg)) + + return nn.Sequential(*hr_modules), in_channels + + def init_weights(self, pretrained=None): + if isinstance(pretrained, str): + logger = get_root_logger() + load_checkpoint(self, pretrained, strict=False, logger=logger) + elif pretrained is None: + for m in self.modules(): + if isinstance(m, nn.Conv2d): + kaiming_init(m) + elif isinstance(m, (_BatchNorm, nn.GroupNorm)): + constant_init(m, 1) + + if self.zero_init_residual: + for m in self.modules(): + if isinstance(m, Bottleneck): + constant_init(m.norm3, 0) + elif isinstance(m, BasicBlock): + constant_init(m.norm2, 0) + else: + raise TypeError('pretrained must be a str or None') + + def forward(self, x): + + x = self.conv1(x) + x = self.norm1(x) + x = self.relu(x) + x = self.conv2(x) + x = self.norm2(x) + x = self.relu(x) + x = self.layer1(x) + + x_list = [] + for i in range(self.stage2_cfg['num_branches']): + if self.transition1[i] is not None: + x_list.append(self.transition1[i](x)) + else: + x_list.append(x) + y_list = self.stage2(x_list) + + x_list = [] + for i in range(self.stage3_cfg['num_branches']): + if self.transition2[i] is not None: + x_list.append(self.transition2[i](y_list[-1])) + else: + x_list.append(y_list[i]) + y_list = self.stage3(x_list) + + x_list = [] + for i in range(self.stage4_cfg['num_branches']): + if self.transition3[i] is not None: + x_list.append(self.transition3[i](y_list[-1])) + else: + x_list.append(y_list[i]) + y_list = self.stage4(x_list) + + return y_list + + def train(self, mode=True): + super(HRNet, self).train(mode) + if mode and self.norm_eval: + for m in self.modules(): + # trick: eval have effect on BatchNorm only + if isinstance(m, _BatchNorm): + m.eval() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/resnet.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/resnet.py new file mode 100644 index 000000000..ab6913e82 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/resnet.py @@ -0,0 +1,516 @@ +import torch.nn as nn +import torch.utils.checkpoint as cp +from mmcv.cnn import constant_init, kaiming_init +from mmcv.runner import load_checkpoint +from torch.nn.modules.batchnorm import _BatchNorm + +from mmdet.models.plugins import GeneralizedAttention +from mmdet.ops import ContextBlock +from mmdet.utils import get_root_logger +from ..registry import BACKBONES +from ..utils import build_conv_layer, build_norm_layer + + +class BasicBlock(nn.Module): + expansion = 1 + + def __init__(self, + inplanes, + planes, + stride=1, + dilation=1, + downsample=None, + style='pytorch', + with_cp=False, + conv_cfg=None, + norm_cfg=dict(type='BN'), + dcn=None, + gcb=None, + gen_attention=None): + super(BasicBlock, self).__init__() + assert dcn is None, "Not implemented yet." + assert gen_attention is None, "Not implemented yet." + assert gcb is None, "Not implemented yet." + + self.norm1_name, norm1 = build_norm_layer(norm_cfg, planes, postfix=1) + self.norm2_name, norm2 = build_norm_layer(norm_cfg, planes, postfix=2) + + self.conv1 = build_conv_layer( + conv_cfg, + inplanes, + planes, + 3, + stride=stride, + padding=dilation, + dilation=dilation, + bias=False) + self.add_module(self.norm1_name, norm1) + self.conv2 = build_conv_layer( + conv_cfg, planes, planes, 3, padding=1, bias=False) + self.add_module(self.norm2_name, norm2) + + self.relu = nn.ReLU(inplace=True) + self.downsample = downsample + self.stride = stride + self.dilation = dilation + assert not with_cp + + @property + def norm1(self): + return getattr(self, self.norm1_name) + + @property + def norm2(self): + return getattr(self, self.norm2_name) + + def forward(self, x): + identity = x + + out = self.conv1(x) + out = self.norm1(out) + out = self.relu(out) + + out = self.conv2(out) + out = self.norm2(out) + + if self.downsample is not None: + identity = self.downsample(x) + + out += identity + out = self.relu(out) + + return out + + +class Bottleneck(nn.Module): + expansion = 4 + + def __init__(self, + inplanes, + planes, + stride=1, + dilation=1, + downsample=None, + style='pytorch', + with_cp=False, + conv_cfg=None, + norm_cfg=dict(type='BN'), + dcn=None, + gcb=None, + gen_attention=None): + """Bottleneck block for ResNet. + If style is "pytorch", the stride-two layer is the 3x3 conv layer, + if it is "caffe", the stride-two layer is the first 1x1 conv layer. + """ + super(Bottleneck, self).__init__() + assert style in ['pytorch', 'caffe'] + assert dcn is None or isinstance(dcn, dict) + assert gcb is None or isinstance(gcb, dict) + assert gen_attention is None or isinstance(gen_attention, dict) + + self.inplanes = inplanes + self.planes = planes + self.stride = stride + self.dilation = dilation + self.style = style + self.with_cp = with_cp + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + self.dcn = dcn + self.with_dcn = dcn is not None + self.gcb = gcb + self.with_gcb = gcb is not None + self.gen_attention = gen_attention + self.with_gen_attention = gen_attention is not None + + if self.style == 'pytorch': + self.conv1_stride = 1 + self.conv2_stride = stride + else: + self.conv1_stride = stride + self.conv2_stride = 1 + + self.norm1_name, norm1 = build_norm_layer(norm_cfg, planes, postfix=1) + self.norm2_name, norm2 = build_norm_layer(norm_cfg, planes, postfix=2) + self.norm3_name, norm3 = build_norm_layer( + norm_cfg, planes * self.expansion, postfix=3) + + self.conv1 = build_conv_layer( + conv_cfg, + inplanes, + planes, + kernel_size=1, + stride=self.conv1_stride, + bias=False) + self.add_module(self.norm1_name, norm1) + fallback_on_stride = False + if self.with_dcn: + fallback_on_stride = dcn.pop('fallback_on_stride', False) + if not self.with_dcn or fallback_on_stride: + self.conv2 = build_conv_layer( + conv_cfg, + planes, + planes, + kernel_size=3, + stride=self.conv2_stride, + padding=dilation, + dilation=dilation, + bias=False) + else: + assert self.conv_cfg is None, 'conv_cfg cannot be None for DCN' + self.conv2 = build_conv_layer( + dcn, + planes, + planes, + kernel_size=3, + stride=self.conv2_stride, + padding=dilation, + dilation=dilation, + bias=False) + + self.add_module(self.norm2_name, norm2) + self.conv3 = build_conv_layer( + conv_cfg, + planes, + planes * self.expansion, + kernel_size=1, + bias=False) + self.add_module(self.norm3_name, norm3) + + self.relu = nn.ReLU(inplace=True) + self.downsample = downsample + + if self.with_gcb: + gcb_inplanes = planes * self.expansion + self.context_block = ContextBlock(inplanes=gcb_inplanes, **gcb) + + # gen_attention + if self.with_gen_attention: + self.gen_attention_block = GeneralizedAttention( + planes, **gen_attention) + + @property + def norm1(self): + return getattr(self, self.norm1_name) + + @property + def norm2(self): + return getattr(self, self.norm2_name) + + @property + def norm3(self): + return getattr(self, self.norm3_name) + + def forward(self, x): + + def _inner_forward(x): + identity = x + + out = self.conv1(x) + out = self.norm1(out) + out = self.relu(out) + + out = self.conv2(out) + out = self.norm2(out) + out = self.relu(out) + + if self.with_gen_attention: + out = self.gen_attention_block(out) + + out = self.conv3(out) + out = self.norm3(out) + + if self.with_gcb: + out = self.context_block(out) + + if self.downsample is not None: + identity = self.downsample(x) + + out += identity + + return out + + if self.with_cp and x.requires_grad: + out = cp.checkpoint(_inner_forward, x) + else: + out = _inner_forward(x) + + out = self.relu(out) + + return out + + +def make_res_layer(block, + inplanes, + planes, + blocks, + stride=1, + dilation=1, + style='pytorch', + with_cp=False, + conv_cfg=None, + norm_cfg=dict(type='BN'), + dcn=None, + gcb=None, + gen_attention=None, + gen_attention_blocks=[]): + downsample = None + if stride != 1 or inplanes != planes * block.expansion: + downsample = nn.Sequential( + build_conv_layer( + conv_cfg, + inplanes, + planes * block.expansion, + kernel_size=1, + stride=stride, + bias=False), + build_norm_layer(norm_cfg, planes * block.expansion)[1], + ) + + layers = [] + layers.append( + block( + inplanes=inplanes, + planes=planes, + stride=stride, + dilation=dilation, + downsample=downsample, + style=style, + with_cp=with_cp, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + dcn=dcn, + gcb=gcb, + gen_attention=gen_attention if + (0 in gen_attention_blocks) else None)) + inplanes = planes * block.expansion + for i in range(1, blocks): + layers.append( + block( + inplanes=inplanes, + planes=planes, + stride=1, + dilation=dilation, + style=style, + with_cp=with_cp, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + dcn=dcn, + gcb=gcb, + gen_attention=gen_attention if + (i in gen_attention_blocks) else None)) + + return nn.Sequential(*layers) + + +@BACKBONES.register_module +class ResNet(nn.Module): + """ResNet backbone. + + Args: + depth (int): Depth of resnet, from {18, 34, 50, 101, 152}. + in_channels (int): Number of input image channels. Normally 3. + num_stages (int): Resnet stages, normally 4. + strides (Sequence[int]): Strides of the first block of each stage. + dilations (Sequence[int]): Dilation of each stage. + out_indices (Sequence[int]): Output from which stages. + style (str): `pytorch` or `caffe`. If set to "pytorch", the stride-two + layer is the 3x3 conv layer, otherwise the stride-two layer is + the first 1x1 conv layer. + frozen_stages (int): Stages to be frozen (stop grad and set eval mode). + -1 means not freezing any parameters. + norm_cfg (dict): dictionary to construct and config norm layer. + norm_eval (bool): Whether to set norm layers to eval mode, namely, + freeze running stats (mean and var). Note: Effect on Batch Norm + and its variants only. + with_cp (bool): Use checkpoint or not. Using checkpoint will save some + memory while slowing down the training speed. + zero_init_residual (bool): whether to use zero init for last norm layer + in resblocks to let them behave as identity. + + Example: + >>> from mmdet.models import ResNet + >>> import torch + >>> self = ResNet(depth=18) + >>> self.eval() + >>> inputs = torch.rand(1, 3, 32, 32) + >>> level_outputs = self.forward(inputs) + >>> for level_out in level_outputs: + ... print(tuple(level_out.shape)) + (1, 64, 8, 8) + (1, 128, 4, 4) + (1, 256, 2, 2) + (1, 512, 1, 1) + """ + + arch_settings = { + 18: (BasicBlock, (2, 2, 2, 2)), + 34: (BasicBlock, (3, 4, 6, 3)), + 50: (Bottleneck, (3, 4, 6, 3)), + 101: (Bottleneck, (3, 4, 23, 3)), + 152: (Bottleneck, (3, 8, 36, 3)) + } + + def __init__(self, + depth, + in_channels=3, + num_stages=4, + strides=(1, 2, 2, 2), + dilations=(1, 1, 1, 1), + out_indices=(0, 1, 2, 3), + style='pytorch', + frozen_stages=-1, + conv_cfg=None, + norm_cfg=dict(type='BN', requires_grad=True), + norm_eval=True, + dcn=None, + stage_with_dcn=(False, False, False, False), + gcb=None, + stage_with_gcb=(False, False, False, False), + gen_attention=None, + stage_with_gen_attention=((), (), (), ()), + with_cp=False, + zero_init_residual=True): + super(ResNet, self).__init__() + if depth not in self.arch_settings: + raise KeyError('invalid depth {} for resnet'.format(depth)) + self.depth = depth + self.num_stages = num_stages + assert num_stages >= 1 and num_stages <= 4 + self.strides = strides + self.dilations = dilations + assert len(strides) == len(dilations) == num_stages + self.out_indices = out_indices + assert max(out_indices) < num_stages + self.style = style + self.frozen_stages = frozen_stages + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + self.with_cp = with_cp + self.norm_eval = norm_eval + self.dcn = dcn + self.stage_with_dcn = stage_with_dcn + if dcn is not None: + assert len(stage_with_dcn) == num_stages + self.gen_attention = gen_attention + self.gcb = gcb + self.stage_with_gcb = stage_with_gcb + if gcb is not None: + assert len(stage_with_gcb) == num_stages + self.zero_init_residual = zero_init_residual + self.block, stage_blocks = self.arch_settings[depth] + self.stage_blocks = stage_blocks[:num_stages] + self.inplanes = 64 + + self._make_stem_layer(in_channels) + + self.res_layers = [] + for i, num_blocks in enumerate(self.stage_blocks): + stride = strides[i] + dilation = dilations[i] + dcn = self.dcn if self.stage_with_dcn[i] else None + gcb = self.gcb if self.stage_with_gcb[i] else None + planes = 64 * 2**i + res_layer = make_res_layer( + self.block, + self.inplanes, + planes, + num_blocks, + stride=stride, + dilation=dilation, + style=self.style, + with_cp=with_cp, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + dcn=dcn, + gcb=gcb, + gen_attention=gen_attention, + gen_attention_blocks=stage_with_gen_attention[i]) + self.inplanes = planes * self.block.expansion + layer_name = 'layer{}'.format(i + 1) + self.add_module(layer_name, res_layer) + self.res_layers.append(layer_name) + + self._freeze_stages() + + self.feat_dim = self.block.expansion * 64 * 2**( + len(self.stage_blocks) - 1) + + @property + def norm1(self): + return getattr(self, self.norm1_name) + + def _make_stem_layer(self, in_channels): + self.conv1 = build_conv_layer( + self.conv_cfg, + in_channels, + 64, + kernel_size=7, + stride=2, + padding=3, + bias=False) + self.norm1_name, norm1 = build_norm_layer(self.norm_cfg, 64, postfix=1) + self.add_module(self.norm1_name, norm1) + self.relu = nn.ReLU(inplace=True) + self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1) + + def _freeze_stages(self): + if self.frozen_stages >= 0: + self.norm1.eval() + for m in [self.conv1, self.norm1]: + for param in m.parameters(): + param.requires_grad = False + + for i in range(1, self.frozen_stages + 1): + m = getattr(self, 'layer{}'.format(i)) + m.eval() + for param in m.parameters(): + param.requires_grad = False + + def init_weights(self, pretrained=None): + if isinstance(pretrained, str): + logger = get_root_logger() + load_checkpoint(self, pretrained, strict=False, logger=logger) + elif pretrained is None: + for m in self.modules(): + if isinstance(m, nn.Conv2d): + kaiming_init(m) + elif isinstance(m, (_BatchNorm, nn.GroupNorm)): + constant_init(m, 1) + + if self.dcn is not None: + for m in self.modules(): + if isinstance(m, Bottleneck) and hasattr( + m, 'conv2_offset'): + constant_init(m.conv2_offset, 0) + + if self.zero_init_residual: + for m in self.modules(): + if isinstance(m, Bottleneck): + constant_init(m.norm3, 0) + elif isinstance(m, BasicBlock): + constant_init(m.norm2, 0) + else: + raise TypeError('pretrained must be a str or None') + + def forward(self, x): + x = self.conv1(x) + x = self.norm1(x) + x = self.relu(x) + x = self.maxpool(x) + outs = [] + for i, layer_name in enumerate(self.res_layers): + res_layer = getattr(self, layer_name) + x = res_layer(x) + if i in self.out_indices: + outs.append(x) + return tuple(outs) + + def train(self, mode=True): + super(ResNet, self).train(mode) + self._freeze_stages() + if mode and self.norm_eval: + for m in self.modules(): + # trick: eval have effect on BatchNorm only + if isinstance(m, _BatchNorm): + m.eval() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/resnext.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/resnext.py new file mode 100644 index 000000000..0c184abb6 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/resnext.py @@ -0,0 +1,222 @@ +import math + +import torch.nn as nn + +from ..registry import BACKBONES +from ..utils import build_conv_layer, build_norm_layer +from .resnet import Bottleneck as _Bottleneck +from .resnet import ResNet + + +class Bottleneck(_Bottleneck): + + def __init__(self, inplanes, planes, groups=1, base_width=4, **kwargs): + """Bottleneck block for ResNeXt. + If style is "pytorch", the stride-two layer is the 3x3 conv layer, + if it is "caffe", the stride-two layer is the first 1x1 conv layer. + """ + super(Bottleneck, self).__init__(inplanes, planes, **kwargs) + + if groups == 1: + width = self.planes + else: + width = math.floor(self.planes * (base_width / 64)) * groups + + self.norm1_name, norm1 = build_norm_layer( + self.norm_cfg, width, postfix=1) + self.norm2_name, norm2 = build_norm_layer( + self.norm_cfg, width, postfix=2) + self.norm3_name, norm3 = build_norm_layer( + self.norm_cfg, self.planes * self.expansion, postfix=3) + + self.conv1 = build_conv_layer( + self.conv_cfg, + self.inplanes, + width, + kernel_size=1, + stride=self.conv1_stride, + bias=False) + self.add_module(self.norm1_name, norm1) + fallback_on_stride = False + self.with_modulated_dcn = False + if self.with_dcn: + fallback_on_stride = self.dcn.pop('fallback_on_stride', False) + if not self.with_dcn or fallback_on_stride: + self.conv2 = build_conv_layer( + self.conv_cfg, + width, + width, + kernel_size=3, + stride=self.conv2_stride, + padding=self.dilation, + dilation=self.dilation, + groups=groups, + bias=False) + else: + assert self.conv_cfg is None, 'conv_cfg must be None for DCN' + self.conv2 = build_conv_layer( + self.dcn, + width, + width, + kernel_size=3, + stride=self.conv2_stride, + padding=self.dilation, + dilation=self.dilation, + groups=groups, + bias=False) + + self.add_module(self.norm2_name, norm2) + self.conv3 = build_conv_layer( + self.conv_cfg, + width, + self.planes * self.expansion, + kernel_size=1, + bias=False) + self.add_module(self.norm3_name, norm3) + + +def make_res_layer(block, + inplanes, + planes, + blocks, + stride=1, + dilation=1, + groups=1, + base_width=4, + style='pytorch', + with_cp=False, + conv_cfg=None, + norm_cfg=dict(type='BN'), + dcn=None, + gcb=None): + downsample = None + if stride != 1 or inplanes != planes * block.expansion: + downsample = nn.Sequential( + build_conv_layer( + conv_cfg, + inplanes, + planes * block.expansion, + kernel_size=1, + stride=stride, + bias=False), + build_norm_layer(norm_cfg, planes * block.expansion)[1], + ) + + layers = [] + layers.append( + block( + inplanes=inplanes, + planes=planes, + stride=stride, + dilation=dilation, + downsample=downsample, + groups=groups, + base_width=base_width, + style=style, + with_cp=with_cp, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + dcn=dcn, + gcb=gcb)) + inplanes = planes * block.expansion + for i in range(1, blocks): + layers.append( + block( + inplanes=inplanes, + planes=planes, + stride=1, + dilation=dilation, + groups=groups, + base_width=base_width, + style=style, + with_cp=with_cp, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + dcn=dcn, + gcb=gcb)) + + return nn.Sequential(*layers) + + +@BACKBONES.register_module +class ResNeXt(ResNet): + """ResNeXt backbone. + + Args: + depth (int): Depth of resnet, from {18, 34, 50, 101, 152}. + in_channels (int): Number of input image channels. Normally 3. + num_stages (int): Resnet stages, normally 4. + groups (int): Group of resnext. + base_width (int): Base width of resnext. + strides (Sequence[int]): Strides of the first block of each stage. + dilations (Sequence[int]): Dilation of each stage. + out_indices (Sequence[int]): Output from which stages. + style (str): `pytorch` or `caffe`. If set to "pytorch", the stride-two + layer is the 3x3 conv layer, otherwise the stride-two layer is + the first 1x1 conv layer. + frozen_stages (int): Stages to be frozen (all param fixed). -1 means + not freezing any parameters. + norm_cfg (dict): dictionary to construct and config norm layer. + norm_eval (bool): Whether to set norm layers to eval mode, namely, + freeze running stats (mean and var). Note: Effect on Batch Norm + and its variants only. + with_cp (bool): Use checkpoint or not. Using checkpoint will save some + memory while slowing down the training speed. + zero_init_residual (bool): whether to use zero init for last norm layer + in resblocks to let them behave as identity. + + Example: + >>> from mmdet.models import ResNeXt + >>> import torch + >>> self = ResNeXt(depth=50) + >>> self.eval() + >>> inputs = torch.rand(1, 3, 32, 32) + >>> level_outputs = self.forward(inputs) + >>> for level_out in level_outputs: + ... print(tuple(level_out.shape)) + (1, 256, 8, 8) + (1, 512, 4, 4) + (1, 1024, 2, 2) + (1, 2048, 1, 1) + """ + + arch_settings = { + 50: (Bottleneck, (3, 4, 6, 3)), + 101: (Bottleneck, (3, 4, 23, 3)), + 152: (Bottleneck, (3, 8, 36, 3)) + } + + def __init__(self, groups=1, base_width=4, **kwargs): + super(ResNeXt, self).__init__(**kwargs) + self.groups = groups + self.base_width = base_width + + self.inplanes = 64 + self.res_layers = [] + for i, num_blocks in enumerate(self.stage_blocks): + stride = self.strides[i] + dilation = self.dilations[i] + dcn = self.dcn if self.stage_with_dcn[i] else None + gcb = self.gcb if self.stage_with_gcb[i] else None + planes = 64 * 2**i + res_layer = make_res_layer( + self.block, + self.inplanes, + planes, + num_blocks, + stride=stride, + dilation=dilation, + groups=self.groups, + base_width=self.base_width, + style=self.style, + with_cp=self.with_cp, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg, + dcn=dcn, + gcb=gcb) + self.inplanes = planes * self.block.expansion + layer_name = 'layer{}'.format(i + 1) + self.add_module(layer_name, res_layer) + self.res_layers.append(layer_name) + + self._freeze_stages() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/ssd_vgg.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/ssd_vgg.py new file mode 100644 index 000000000..c7615e2a7 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/ssd_vgg.py @@ -0,0 +1,153 @@ +import torch +import torch.nn as nn +import torch.nn.functional as F +from mmcv.cnn import VGG, constant_init, kaiming_init, normal_init, xavier_init +from mmcv.runner import load_checkpoint + +from mmdet.utils import get_root_logger +from ..registry import BACKBONES + + +@BACKBONES.register_module +class SSDVGG(VGG): + """VGG Backbone network for single-shot-detection + + Args: + input_size (int): width and height of input, from {300, 512}. + depth (int): Depth of vgg, from {11, 13, 16, 19}. + out_indices (Sequence[int]): Output from which stages. + + Example: + >>> self = SSDVGG(input_size=300, depth=11) + >>> self.eval() + >>> inputs = torch.rand(1, 3, 300, 300) + >>> level_outputs = self.forward(inputs) + >>> for level_out in level_outputs: + ... print(tuple(level_out.shape)) + (1, 1024, 19, 19) + (1, 512, 10, 10) + (1, 256, 5, 5) + (1, 256, 3, 3) + (1, 256, 1, 1) + """ + extra_setting = { + 300: (256, 'S', 512, 128, 'S', 256, 128, 256, 128, 256), + 512: (256, 'S', 512, 128, 'S', 256, 128, 'S', 256, 128, 'S', 256, 128), + } + + def __init__(self, + input_size, + depth, + with_last_pool=False, + ceil_mode=True, + out_indices=(3, 4), + out_feature_indices=(22, 34), + l2_norm_scale=20.): + # TODO: in_channels for mmcv.VGG + super(SSDVGG, self).__init__( + depth, + with_last_pool=with_last_pool, + ceil_mode=ceil_mode, + out_indices=out_indices) + assert input_size in (300, 512) + self.input_size = input_size + + self.features.add_module( + str(len(self.features)), + nn.MaxPool2d(kernel_size=3, stride=1, padding=1)) + self.features.add_module( + str(len(self.features)), + nn.Conv2d(512, 1024, kernel_size=3, padding=6, dilation=6)) + self.features.add_module( + str(len(self.features)), nn.ReLU(inplace=True)) + self.features.add_module( + str(len(self.features)), nn.Conv2d(1024, 1024, kernel_size=1)) + self.features.add_module( + str(len(self.features)), nn.ReLU(inplace=True)) + self.out_feature_indices = out_feature_indices + + self.inplanes = 1024 + self.extra = self._make_extra_layers(self.extra_setting[input_size]) + self.l2_norm = L2Norm( + self.features[out_feature_indices[0] - 1].out_channels, + l2_norm_scale) + + def init_weights(self, pretrained=None): + if isinstance(pretrained, str): + logger = get_root_logger() + load_checkpoint(self, pretrained, strict=False, logger=logger) + elif pretrained is None: + for m in self.features.modules(): + if isinstance(m, nn.Conv2d): + kaiming_init(m) + elif isinstance(m, nn.BatchNorm2d): + constant_init(m, 1) + elif isinstance(m, nn.Linear): + normal_init(m, std=0.01) + else: + raise TypeError('pretrained must be a str or None') + + for m in self.extra.modules(): + if isinstance(m, nn.Conv2d): + xavier_init(m, distribution='uniform') + + constant_init(self.l2_norm, self.l2_norm.scale) + + def forward(self, x): + outs = [] + for i, layer in enumerate(self.features): + x = layer(x) + if i in self.out_feature_indices: + outs.append(x) + for i, layer in enumerate(self.extra): + x = F.relu(layer(x), inplace=True) + if i % 2 == 1: + outs.append(x) + outs[0] = self.l2_norm(outs[0]) + if len(outs) == 1: + return outs[0] + else: + return tuple(outs) + + def _make_extra_layers(self, outplanes): + layers = [] + kernel_sizes = (1, 3) + num_layers = 0 + outplane = None + for i in range(len(outplanes)): + if self.inplanes == 'S': + self.inplanes = outplane + continue + k = kernel_sizes[num_layers % 2] + if outplanes[i] == 'S': + outplane = outplanes[i + 1] + conv = nn.Conv2d( + self.inplanes, outplane, k, stride=2, padding=1) + else: + outplane = outplanes[i] + conv = nn.Conv2d( + self.inplanes, outplane, k, stride=1, padding=0) + layers.append(conv) + self.inplanes = outplanes[i] + num_layers += 1 + if self.input_size == 512: + layers.append(nn.Conv2d(self.inplanes, 256, 4, padding=1)) + + return nn.Sequential(*layers) + + +class L2Norm(nn.Module): + + def __init__(self, n_dims, scale=20., eps=1e-10): + super(L2Norm, self).__init__() + self.n_dims = n_dims + self.weight = nn.Parameter(torch.Tensor(self.n_dims)) + self.eps = eps + self.scale = scale + + def forward(self, x): + # normalization layer convert to FP32 in FP16 training + x_float = x.float() + norm = x_float.pow(2).sum(1, keepdim=True).sqrt() + self.eps + return (self.weight[None, :, None, None].float().expand_as(x_float) * + x_float / norm).type_as(x) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/__init__.py new file mode 100644 index 000000000..a668bdb01 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/__init__.py @@ -0,0 +1,7 @@ +from .bbox_head import BBoxHead +from .convfc_bbox_head import ConvFCBBoxHead, SharedFCBBoxHead +from .double_bbox_head import DoubleConvFCBBoxHead + +__all__ = [ + 'BBoxHead', 'ConvFCBBoxHead', 'SharedFCBBoxHead', 'DoubleConvFCBBoxHead' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/bbox_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/bbox_head.py new file mode 100644 index 000000000..8ab878a01 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/bbox_head.py @@ -0,0 +1,282 @@ +import torch +import torch.nn as nn +import torch.nn.functional as F +from torch.nn.modules.utils import _pair + +from mmdet.core import (auto_fp16, bbox_target, delta2bbox, force_fp32, + multiclass_nms) +from ..builder import build_loss +from ..losses import accuracy +from ..registry import HEADS + + +@HEADS.register_module +class BBoxHead(nn.Module): + """Simplest RoI head, with only two fc layers for classification and + regression respectively""" + + def __init__(self, + with_avg_pool=False, + with_cls=True, + with_reg=True, + roi_feat_size=7, + in_channels=256, + num_classes=81, + target_means=[0., 0., 0., 0.], + target_stds=[0.1, 0.1, 0.2, 0.2], + reg_class_agnostic=False, + loss_cls=dict( + type='CrossEntropyLoss', + use_sigmoid=False, + loss_weight=1.0), + loss_bbox=dict( + type='SmoothL1Loss', beta=1.0, loss_weight=1.0)): + super(BBoxHead, self).__init__() + assert with_cls or with_reg + self.with_avg_pool = with_avg_pool + self.with_cls = with_cls + self.with_reg = with_reg + self.roi_feat_size = _pair(roi_feat_size) + self.roi_feat_area = self.roi_feat_size[0] * self.roi_feat_size[1] + self.in_channels = in_channels + self.num_classes = num_classes + self.target_means = target_means + self.target_stds = target_stds + self.reg_class_agnostic = reg_class_agnostic + self.fp16_enabled = False + + self.loss_cls = build_loss(loss_cls) + self.loss_bbox = build_loss(loss_bbox) + + in_channels = self.in_channels + if self.with_avg_pool: + self.avg_pool = nn.AvgPool2d(self.roi_feat_size) + else: + in_channels *= self.roi_feat_area + if self.with_cls: + self.fc_cls = nn.Linear(in_channels, num_classes) + if self.with_reg: + out_dim_reg = 4 if reg_class_agnostic else 4 * num_classes + self.fc_reg = nn.Linear(in_channels, out_dim_reg) + self.debug_imgs = None + + def init_weights(self): + if self.with_cls: + nn.init.normal_(self.fc_cls.weight, 0, 0.01) + nn.init.constant_(self.fc_cls.bias, 0) + if self.with_reg: + nn.init.normal_(self.fc_reg.weight, 0, 0.001) + nn.init.constant_(self.fc_reg.bias, 0) + + @auto_fp16() + def forward(self, x): + if self.with_avg_pool: + x = self.avg_pool(x) + x = x.view(x.size(0), -1) + cls_score = self.fc_cls(x) if self.with_cls else None + bbox_pred = self.fc_reg(x) if self.with_reg else None + return cls_score, bbox_pred + + def get_target(self, sampling_results, gt_bboxes, gt_labels, + rcnn_train_cfg): + pos_proposals = [res.pos_bboxes for res in sampling_results] + neg_proposals = [res.neg_bboxes for res in sampling_results] + pos_gt_bboxes = [res.pos_gt_bboxes for res in sampling_results] + pos_gt_labels = [res.pos_gt_labels for res in sampling_results] + reg_classes = 1 if self.reg_class_agnostic else self.num_classes + cls_reg_targets = bbox_target( + pos_proposals, + neg_proposals, + pos_gt_bboxes, + pos_gt_labels, + rcnn_train_cfg, + reg_classes, + target_means=self.target_means, + target_stds=self.target_stds) + return cls_reg_targets + + @force_fp32(apply_to=('cls_score', 'bbox_pred')) + def loss(self, + cls_score, + bbox_pred, + labels, + label_weights, + bbox_targets, + bbox_weights, + reduction_override=None): + losses = dict() + if cls_score is not None: + avg_factor = max(torch.sum(label_weights > 0).float().item(), 1.) + if cls_score.numel() > 0: + losses['loss_cls'] = self.loss_cls( + cls_score, + labels, + label_weights, + avg_factor=avg_factor, + reduction_override=reduction_override) + losses['acc'] = accuracy(cls_score, labels) + if bbox_pred is not None: + pos_inds = labels > 0 + if pos_inds.any(): + if self.reg_class_agnostic: + pos_bbox_pred = bbox_pred.view(bbox_pred.size(0), + 4)[pos_inds] + else: + pos_bbox_pred = bbox_pred.view(bbox_pred.size(0), -1, + 4)[pos_inds, + labels[pos_inds]] + losses['loss_bbox'] = self.loss_bbox( + pos_bbox_pred, + bbox_targets[pos_inds], + bbox_weights[pos_inds], + avg_factor=bbox_targets.size(0), + reduction_override=reduction_override) + return losses + + @force_fp32(apply_to=('cls_score', 'bbox_pred')) + def get_det_bboxes(self, + rois, + cls_score, + bbox_pred, + img_shape, + scale_factor, + rescale=False, + cfg=None): + if isinstance(cls_score, list): + cls_score = sum(cls_score) / float(len(cls_score)) + scores = F.softmax(cls_score, dim=1) if cls_score is not None else None + + if bbox_pred is not None: + bboxes = delta2bbox(rois[:, 1:], bbox_pred, self.target_means, + self.target_stds, img_shape) + else: + bboxes = rois[:, 1:].clone() + if img_shape is not None: + bboxes[:, [0, 2]].clamp_(min=0, max=img_shape[1] - 1) + bboxes[:, [1, 3]].clamp_(min=0, max=img_shape[0] - 1) + + if rescale: + if isinstance(scale_factor, float): + bboxes /= scale_factor + else: + scale_factor = torch.from_numpy(scale_factor).to(bboxes.device) + bboxes = (bboxes.view(bboxes.size(0), -1, 4) / + scale_factor).view(bboxes.size()[0], -1) + + if cfg is None: + return bboxes, scores + else: + det_bboxes, det_labels = multiclass_nms(bboxes, scores, + cfg.score_thr, cfg.nms, + cfg.max_per_img) + + return det_bboxes, det_labels + + @force_fp32(apply_to=('bbox_preds', )) + def refine_bboxes(self, rois, labels, bbox_preds, pos_is_gts, img_metas): + """Refine bboxes during training. + + Args: + rois (Tensor): Shape (n*bs, 5), where n is image number per GPU, + and bs is the sampled RoIs per image. The first column is + the image id and the next 4 columns are x1, y1, x2, y2. + labels (Tensor): Shape (n*bs, ). + bbox_preds (Tensor): Shape (n*bs, 4) or (n*bs, 4*#class). + pos_is_gts (list[Tensor]): Flags indicating if each positive bbox + is a gt bbox. + img_metas (list[dict]): Meta info of each image. + + Returns: + list[Tensor]: Refined bboxes of each image in a mini-batch. + + Example: + >>> # xdoctest: +REQUIRES(module:kwarray) + >>> import kwarray + >>> import numpy as np + >>> from mmdet.core.bbox.demodata import random_boxes + >>> self = BBoxHead(reg_class_agnostic=True) + >>> n_roi = 2 + >>> n_img = 4 + >>> scale = 512 + >>> rng = np.random.RandomState(0) + >>> img_metas = [{'img_shape': (scale, scale)} + ... for _ in range(n_img)] + >>> # Create rois in the expected format + >>> roi_boxes = random_boxes(n_roi, scale=scale, rng=rng) + >>> img_ids = torch.randint(0, n_img, (n_roi,)) + >>> img_ids = img_ids.float() + >>> rois = torch.cat([img_ids[:, None], roi_boxes], dim=1) + >>> # Create other args + >>> labels = torch.randint(0, 2, (n_roi,)).long() + >>> bbox_preds = random_boxes(n_roi, scale=scale, rng=rng) + >>> # For each image, pretend random positive boxes are gts + >>> is_label_pos = (labels.numpy() > 0).astype(np.int) + >>> lbl_per_img = kwarray.group_items(is_label_pos, + ... img_ids.numpy()) + >>> pos_per_img = [sum(lbl_per_img.get(gid, [])) + ... for gid in range(n_img)] + >>> pos_is_gts = [ + >>> torch.randint(0, 2, (npos,)).byte().sort( + >>> descending=True)[0] + >>> for npos in pos_per_img + >>> ] + >>> bboxes_list = self.refine_bboxes(rois, labels, bbox_preds, + >>> pos_is_gts, img_metas) + >>> print(bboxes_list) + """ + img_ids = rois[:, 0].long().unique(sorted=True) + assert img_ids.numel() <= len(img_metas) + + bboxes_list = [] + for i in range(len(img_metas)): + inds = torch.nonzero(rois[:, 0] == i).squeeze(dim=1) + num_rois = inds.numel() + + bboxes_ = rois[inds, 1:] + label_ = labels[inds] + bbox_pred_ = bbox_preds[inds] + img_meta_ = img_metas[i] + pos_is_gts_ = pos_is_gts[i] + + bboxes = self.regress_by_class(bboxes_, label_, bbox_pred_, + img_meta_) + + # filter gt bboxes + pos_keep = 1 - pos_is_gts_ + keep_inds = pos_is_gts_.new_ones(num_rois) + keep_inds[:len(pos_is_gts_)] = pos_keep + + bboxes_list.append(bboxes[keep_inds]) + + return bboxes_list + + @force_fp32(apply_to=('bbox_pred', )) + def regress_by_class(self, rois, label, bbox_pred, img_meta): + """Regress the bbox for the predicted class. Used in Cascade R-CNN. + + Args: + rois (Tensor): shape (n, 4) or (n, 5) + label (Tensor): shape (n, ) + bbox_pred (Tensor): shape (n, 4*(#class+1)) or (n, 4) + img_meta (dict): Image meta info. + + Returns: + Tensor: Regressed bboxes, the same shape as input rois. + """ + assert rois.size(1) == 4 or rois.size(1) == 5, repr(rois.shape) + + if not self.reg_class_agnostic: + label = label * 4 + inds = torch.stack((label, label + 1, label + 2, label + 3), 1) + bbox_pred = torch.gather(bbox_pred, 1, inds) + assert bbox_pred.size(1) == 4 + + if rois.size(1) == 4: + new_rois = delta2bbox(rois, bbox_pred, self.target_means, + self.target_stds, img_meta['img_shape']) + else: + bboxes = delta2bbox(rois[:, 1:], bbox_pred, self.target_means, + self.target_stds, img_meta['img_shape']) + new_rois = torch.cat((rois[:, [0]], bboxes), dim=1) + + return new_rois diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/convfc_bbox_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/convfc_bbox_head.py new file mode 100644 index 000000000..f0f89778e --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/convfc_bbox_head.py @@ -0,0 +1,187 @@ +import torch.nn as nn + +from ..registry import HEADS +from ..utils import ConvModule +from .bbox_head import BBoxHead + + +@HEADS.register_module +class ConvFCBBoxHead(BBoxHead): + r"""More general bbox head, with shared conv and fc layers and two optional + separated branches. + + /-> cls convs -> cls fcs -> cls + shared convs -> shared fcs + \-> reg convs -> reg fcs -> reg + """ # noqa: W605 + + def __init__(self, + num_shared_convs=0, + num_shared_fcs=0, + num_cls_convs=0, + num_cls_fcs=0, + num_reg_convs=0, + num_reg_fcs=0, + conv_out_channels=256, + fc_out_channels=1024, + conv_cfg=None, + norm_cfg=None, + *args, + **kwargs): + super(ConvFCBBoxHead, self).__init__(*args, **kwargs) + assert (num_shared_convs + num_shared_fcs + num_cls_convs + + num_cls_fcs + num_reg_convs + num_reg_fcs > 0) + if num_cls_convs > 0 or num_reg_convs > 0: + assert num_shared_fcs == 0 + if not self.with_cls: + assert num_cls_convs == 0 and num_cls_fcs == 0 + if not self.with_reg: + assert num_reg_convs == 0 and num_reg_fcs == 0 + self.num_shared_convs = num_shared_convs + self.num_shared_fcs = num_shared_fcs + self.num_cls_convs = num_cls_convs + self.num_cls_fcs = num_cls_fcs + self.num_reg_convs = num_reg_convs + self.num_reg_fcs = num_reg_fcs + self.conv_out_channels = conv_out_channels + self.fc_out_channels = fc_out_channels + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + + # add shared convs and fcs + self.shared_convs, self.shared_fcs, last_layer_dim = \ + self._add_conv_fc_branch( + self.num_shared_convs, self.num_shared_fcs, self.in_channels, + True) + self.shared_out_channels = last_layer_dim + + # add cls specific branch + self.cls_convs, self.cls_fcs, self.cls_last_dim = \ + self._add_conv_fc_branch( + self.num_cls_convs, self.num_cls_fcs, self.shared_out_channels) + + # add reg specific branch + self.reg_convs, self.reg_fcs, self.reg_last_dim = \ + self._add_conv_fc_branch( + self.num_reg_convs, self.num_reg_fcs, self.shared_out_channels) + + if self.num_shared_fcs == 0 and not self.with_avg_pool: + if self.num_cls_fcs == 0: + self.cls_last_dim *= self.roi_feat_area + if self.num_reg_fcs == 0: + self.reg_last_dim *= self.roi_feat_area + + self.relu = nn.ReLU(inplace=True) + # reconstruct fc_cls and fc_reg since input channels are changed + if self.with_cls: + self.fc_cls = nn.Linear(self.cls_last_dim, self.num_classes) + if self.with_reg: + out_dim_reg = (4 if self.reg_class_agnostic else 4 * + self.num_classes) + self.fc_reg = nn.Linear(self.reg_last_dim, out_dim_reg) + + def _add_conv_fc_branch(self, + num_branch_convs, + num_branch_fcs, + in_channels, + is_shared=False): + """Add shared or separable branch + + convs -> avg pool (optional) -> fcs + """ + last_layer_dim = in_channels + # add branch specific conv layers + branch_convs = nn.ModuleList() + if num_branch_convs > 0: + for i in range(num_branch_convs): + conv_in_channels = ( + last_layer_dim if i == 0 else self.conv_out_channels) + branch_convs.append( + ConvModule( + conv_in_channels, + self.conv_out_channels, + 3, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg)) + last_layer_dim = self.conv_out_channels + # add branch specific fc layers + branch_fcs = nn.ModuleList() + if num_branch_fcs > 0: + # for shared branch, only consider self.with_avg_pool + # for separated branches, also consider self.num_shared_fcs + if (is_shared + or self.num_shared_fcs == 0) and not self.with_avg_pool: + last_layer_dim *= self.roi_feat_area + for i in range(num_branch_fcs): + fc_in_channels = ( + last_layer_dim if i == 0 else self.fc_out_channels) + branch_fcs.append( + nn.Linear(fc_in_channels, self.fc_out_channels)) + last_layer_dim = self.fc_out_channels + return branch_convs, branch_fcs, last_layer_dim + + def init_weights(self): + super(ConvFCBBoxHead, self).init_weights() + for module_list in [self.shared_fcs, self.cls_fcs, self.reg_fcs]: + for m in module_list.modules(): + if isinstance(m, nn.Linear): + nn.init.xavier_uniform_(m.weight) + nn.init.constant_(m.bias, 0) + + def forward(self, x): + # shared part + if self.num_shared_convs > 0: + for conv in self.shared_convs: + x = conv(x) + + if self.num_shared_fcs > 0: + if self.with_avg_pool: + x = self.avg_pool(x) + + x = x.flatten(1) + + for fc in self.shared_fcs: + x = self.relu(fc(x)) + # separate branches + x_cls = x + x_reg = x + + for conv in self.cls_convs: + x_cls = conv(x_cls) + if x_cls.dim() > 2: + if self.with_avg_pool: + x_cls = self.avg_pool(x_cls) + x_cls = x_cls.flatten(1) + for fc in self.cls_fcs: + x_cls = self.relu(fc(x_cls)) + + for conv in self.reg_convs: + x_reg = conv(x_reg) + if x_reg.dim() > 2: + if self.with_avg_pool: + x_reg = self.avg_pool(x_reg) + x_reg = x_reg.flatten(1) + for fc in self.reg_fcs: + x_reg = self.relu(fc(x_reg)) + + cls_score = self.fc_cls(x_cls) if self.with_cls else None + bbox_pred = self.fc_reg(x_reg) if self.with_reg else None + return cls_score, bbox_pred + + +@HEADS.register_module +class SharedFCBBoxHead(ConvFCBBoxHead): + + def __init__(self, num_fcs=2, fc_out_channels=1024, *args, **kwargs): + assert num_fcs >= 1 + super(SharedFCBBoxHead, self).__init__( + num_shared_convs=0, + num_shared_fcs=num_fcs, + num_cls_convs=0, + num_cls_fcs=0, + num_reg_convs=0, + num_reg_fcs=0, + fc_out_channels=fc_out_channels, + *args, + **kwargs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/double_bbox_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/double_bbox_head.py new file mode 100644 index 000000000..c8a0e2699 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/double_bbox_head.py @@ -0,0 +1,170 @@ +import torch.nn as nn +from mmcv.cnn.weight_init import normal_init, xavier_init + +from ..backbones.resnet import Bottleneck +from ..registry import HEADS +from ..utils import ConvModule +from .bbox_head import BBoxHead + + +class BasicResBlock(nn.Module): + """Basic residual block. + + This block is a little different from the block in the ResNet backbone. + The kernel size of conv1 is 1 in this block while 3 in ResNet BasicBlock. + + Args: + in_channels (int): Channels of the input feature map. + out_channels (int): Channels of the output feature map. + conv_cfg (dict): The config dict for convolution layers. + norm_cfg (dict): The config dict for normalization layers. + """ + + def __init__(self, + in_channels, + out_channels, + conv_cfg=None, + norm_cfg=dict(type='BN')): + super(BasicResBlock, self).__init__() + + # main path + self.conv1 = ConvModule( + in_channels, + in_channels, + kernel_size=3, + padding=1, + bias=False, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg) + self.conv2 = ConvModule( + in_channels, + out_channels, + kernel_size=1, + bias=False, + activation=None, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg) + + # identity path + self.conv_identity = ConvModule( + in_channels, + out_channels, + kernel_size=1, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + activation=None) + + self.relu = nn.ReLU(inplace=True) + + def forward(self, x): + identity = x + + x = self.conv1(x) + x = self.conv2(x) + + identity = self.conv_identity(identity) + out = x + identity + + out = self.relu(out) + return out + + +@HEADS.register_module +class DoubleConvFCBBoxHead(BBoxHead): + r"""Bbox head used in Double-Head R-CNN + + /-> cls + /-> shared convs -> + \-> reg + roi features + /-> cls + \-> shared fc -> + \-> reg + """ # noqa: W605 + + def __init__(self, + num_convs=0, + num_fcs=0, + conv_out_channels=1024, + fc_out_channels=1024, + conv_cfg=None, + norm_cfg=dict(type='BN'), + **kwargs): + kwargs.setdefault('with_avg_pool', True) + super(DoubleConvFCBBoxHead, self).__init__(**kwargs) + assert self.with_avg_pool + assert num_convs > 0 + assert num_fcs > 0 + self.num_convs = num_convs + self.num_fcs = num_fcs + self.conv_out_channels = conv_out_channels + self.fc_out_channels = fc_out_channels + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + + # increase the channel of input features + self.res_block = BasicResBlock(self.in_channels, + self.conv_out_channels) + + # add conv heads + self.conv_branch = self._add_conv_branch() + # add fc heads + self.fc_branch = self._add_fc_branch() + + out_dim_reg = 4 if self.reg_class_agnostic else 4 * self.num_classes + self.fc_reg = nn.Linear(self.conv_out_channels, out_dim_reg) + + self.fc_cls = nn.Linear(self.fc_out_channels, self.num_classes) + self.relu = nn.ReLU(inplace=True) + + def _add_conv_branch(self): + """Add the fc branch which consists of a sequential of conv layers""" + branch_convs = nn.ModuleList() + for i in range(self.num_convs): + branch_convs.append( + Bottleneck( + inplanes=self.conv_out_channels, + planes=self.conv_out_channels // 4, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg)) + return branch_convs + + def _add_fc_branch(self): + """Add the fc branch which consists of a sequential of fc layers""" + branch_fcs = nn.ModuleList() + for i in range(self.num_fcs): + fc_in_channels = ( + self.in_channels * + self.roi_feat_area if i == 0 else self.fc_out_channels) + branch_fcs.append(nn.Linear(fc_in_channels, self.fc_out_channels)) + return branch_fcs + + def init_weights(self): + normal_init(self.fc_cls, std=0.01) + normal_init(self.fc_reg, std=0.001) + + for m in self.fc_branch.modules(): + if isinstance(m, nn.Linear): + xavier_init(m, distribution='uniform') + + def forward(self, x_cls, x_reg): + # conv head + x_conv = self.res_block(x_reg) + + for conv in self.conv_branch: + x_conv = conv(x_conv) + + if self.with_avg_pool: + x_conv = self.avg_pool(x_conv) + + x_conv = x_conv.view(x_conv.size(0), -1) + bbox_pred = self.fc_reg(x_conv) + + # fc head + x_fc = x_cls.view(x_cls.size(0), -1) + for fc in self.fc_branch: + x_fc = self.relu(fc(x_fc)) + + cls_score = self.fc_cls(x_fc) + + return cls_score, bbox_pred diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/builder.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/builder.py new file mode 100644 index 000000000..dc82ab711 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/builder.py @@ -0,0 +1,43 @@ +from torch import nn + +from mmdet.utils import build_from_cfg +from .registry import (BACKBONES, DETECTORS, HEADS, LOSSES, NECKS, + ROI_EXTRACTORS, SHARED_HEADS) + + +def build(cfg, registry, default_args=None): + if isinstance(cfg, list): + modules = [ + build_from_cfg(cfg_, registry, default_args) for cfg_ in cfg + ] + return nn.Sequential(*modules) + else: + return build_from_cfg(cfg, registry, default_args) + + +def build_backbone(cfg): + return build(cfg, BACKBONES) + + +def build_neck(cfg): + return build(cfg, NECKS) + + +def build_roi_extractor(cfg): + return build(cfg, ROI_EXTRACTORS) + + +def build_shared_head(cfg): + return build(cfg, SHARED_HEADS) + + +def build_head(cfg): + return build(cfg, HEADS) + + +def build_loss(cfg): + return build(cfg, LOSSES) + + +def build_detector(cfg, train_cfg=None, test_cfg=None): + return build(cfg, DETECTORS, dict(train_cfg=train_cfg, test_cfg=test_cfg)) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/__init__.py new file mode 100644 index 000000000..e7aad355d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/__init__.py @@ -0,0 +1,27 @@ +from .atss import ATSS +from .base import BaseDetector +from .cascade_rcnn import CascadeRCNN +from .double_head_rcnn import DoubleHeadRCNN +from .fast_rcnn import FastRCNN +from .faster_rcnn import FasterRCNN +from .fcos import FCOS +from .fovea import FOVEA +from .grid_rcnn import GridRCNN +from .htc import HybridTaskCascade +from .mask_rcnn import MaskRCNN +from .mask_scoring_rcnn import MaskScoringRCNN +from .reppoints_detector import RepPointsDetector +from .retinanet import RetinaNet +from .rpn import RPN +from .single_stage import SingleStageDetector +from .single_stage_ins import SingleStageInsDetector +from .two_stage import TwoStageDetector +from .solo import SOLO +from .solov2 import SOLOv2 + +__all__ = [ + 'ATSS', 'BaseDetector', 'SingleStageDetector', 'TwoStageDetector', 'RPN', + 'FastRCNN', 'FasterRCNN', 'MaskRCNN', 'CascadeRCNN', 'HybridTaskCascade', + 'DoubleHeadRCNN', 'RetinaNet', 'FCOS', 'GridRCNN', 'MaskScoringRCNN', + 'RepPointsDetector', 'FOVEA', 'SingleStageInsDetector', 'SOLO', 'SOLOv2' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/atss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/atss.py new file mode 100644 index 000000000..ac22bf928 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/atss.py @@ -0,0 +1,16 @@ +from ..registry import DETECTORS +from .single_stage import SingleStageDetector + + +@DETECTORS.register_module +class ATSS(SingleStageDetector): + + def __init__(self, + backbone, + neck, + bbox_head, + train_cfg=None, + test_cfg=None, + pretrained=None): + super(ATSS, self).__init__(backbone, neck, bbox_head, train_cfg, + test_cfg, pretrained) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/base.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/base.py new file mode 100644 index 000000000..82f91bd10 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/base.py @@ -0,0 +1,193 @@ +from abc import ABCMeta, abstractmethod + +import mmcv +import numpy as np +import pycocotools.mask as maskUtils +import torch.nn as nn + +from mmdet.core import auto_fp16, get_classes, tensor2imgs +from mmdet.utils import print_log + + +class BaseDetector(nn.Module, metaclass=ABCMeta): + """Base class for detectors""" + + def __init__(self): + super(BaseDetector, self).__init__() + self.fp16_enabled = False + + @property + def with_neck(self): + return hasattr(self, 'neck') and self.neck is not None + + @property + def with_mask_feat_head(self): + return hasattr(self, 'mask_feat_head') and \ + self.mask_feat_head is not None + + @property + def with_shared_head(self): + return hasattr(self, 'shared_head') and self.shared_head is not None + + @property + def with_bbox(self): + return hasattr(self, 'bbox_head') and self.bbox_head is not None + + @property + def with_mask(self): + return hasattr(self, 'mask_head') and self.mask_head is not None + + @abstractmethod + def extract_feat(self, imgs): + pass + + def extract_feats(self, imgs): + assert isinstance(imgs, list) + for img in imgs: + yield self.extract_feat(img) + + @abstractmethod + def forward_train(self, imgs, img_metas, **kwargs): + """ + Args: + img (list[Tensor]): list of tensors of shape (1, C, H, W). + Typically these should be mean centered and std scaled. + + img_metas (list[dict]): list of image info dict where each dict + has: + 'img_shape', 'scale_factor', 'flip', and my also contain + 'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'. + For details on the values of these keys see + `mmdet/datasets/pipelines/formatting.py:Collect`. + + **kwargs: specific to concrete implementation + """ + pass + + async def async_simple_test(self, img, img_meta, **kwargs): + raise NotImplementedError + + @abstractmethod + def simple_test(self, img, img_meta, **kwargs): + pass + + @abstractmethod + def aug_test(self, imgs, img_metas, **kwargs): + pass + + def init_weights(self, pretrained=None): + if pretrained is not None: + print_log('load model from: {}'.format(pretrained), logger='root') + + async def aforward_test(self, *, img, img_meta, **kwargs): + for var, name in [(img, 'img'), (img_meta, 'img_meta')]: + if not isinstance(var, list): + raise TypeError('{} must be a list, but got {}'.format( + name, type(var))) + + num_augs = len(img) + if num_augs != len(img_meta): + raise ValueError( + 'num of augmentations ({}) != num of image meta ({})'.format( + len(img), len(img_meta))) + # TODO: remove the restriction of imgs_per_gpu == 1 when prepared + imgs_per_gpu = img[0].size(0) + assert imgs_per_gpu == 1 + + if num_augs == 1: + return await self.async_simple_test(img[0], img_meta[0], **kwargs) + else: + raise NotImplementedError + + def forward_test(self, imgs, img_metas, **kwargs): + """ + Args: + imgs (List[Tensor]): the outer list indicates test-time + augmentations and inner Tensor should have a shape NxCxHxW, + which contains all images in the batch. + img_meta (List[List[dict]]): the outer list indicates test-time + augs (multiscale, flip, etc.) and the inner list indicates + images in a batch + """ + for var, name in [(imgs, 'imgs'), (img_metas, 'img_metas')]: + if not isinstance(var, list): + raise TypeError('{} must be a list, but got {}'.format( + name, type(var))) + + num_augs = len(imgs) + if num_augs != len(img_metas): + raise ValueError( + 'num of augmentations ({}) != num of image meta ({})'.format( + len(imgs), len(img_metas))) + # TODO: remove the restriction of imgs_per_gpu == 1 when prepared + imgs_per_gpu = imgs[0].size(0) + assert imgs_per_gpu == 1 + + if num_augs == 1: + return self.simple_test(imgs[0], img_metas[0], **kwargs) + else: + return self.aug_test(imgs, img_metas, **kwargs) + + @auto_fp16(apply_to=('img', )) + def forward(self, img, img_meta, return_loss=True, **kwargs): + """ + Calls either forward_train or forward_test depending on whether + return_loss=True. Note this setting will change the expected inputs. + When `return_loss=True`, img and img_meta are single-nested (i.e. + Tensor and List[dict]), and when `resturn_loss=False`, img and img_meta + should be double nested (i.e. List[Tensor], List[List[dict]]), with + the outer list indicating test time augmentations. + """ + if return_loss: + return self.forward_train(img, img_meta, **kwargs) + else: + return self.forward_test(img, img_meta, **kwargs) + + def show_result(self, data, result, dataset=None, score_thr=0.3): + if isinstance(result, tuple): + bbox_result, segm_result = result + else: + bbox_result, segm_result = result, None + + img_tensor = data['img'][0] + img_metas = data['img_meta'][0].data[0] + imgs = tensor2imgs(img_tensor, **img_metas[0]['img_norm_cfg']) + assert len(imgs) == len(img_metas) + + if dataset is None: + class_names = self.CLASSES + elif isinstance(dataset, str): + class_names = get_classes(dataset) + elif isinstance(dataset, (list, tuple)): + class_names = dataset + else: + raise TypeError( + 'dataset must be a valid dataset name or a sequence' + ' of class names, not {}'.format(type(dataset))) + + for img, img_meta in zip(imgs, img_metas): + h, w, _ = img_meta['img_shape'] + img_show = img[:h, :w, :] + + bboxes = np.vstack(bbox_result) + # draw segmentation masks + if segm_result is not None: + segms = mmcv.concat_list(segm_result) + inds = np.where(bboxes[:, -1] > score_thr)[0] + for i in inds: + color_mask = np.random.randint( + 0, 256, (1, 3), dtype=np.uint8) + mask = maskUtils.decode(segms[i]).astype(np.bool) + img_show[mask] = img_show[mask] * 0.5 + color_mask * 0.5 + # draw bounding boxes + labels = [ + np.full(bbox.shape[0], i, dtype=np.int32) + for i, bbox in enumerate(bbox_result) + ] + labels = np.concatenate(labels) + mmcv.imshow_det_bboxes( + img_show, + bboxes, + labels, + class_names=class_names, + score_thr=score_thr) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/cascade_rcnn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/cascade_rcnn.py new file mode 100644 index 000000000..4ab1e5789 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/cascade_rcnn.py @@ -0,0 +1,520 @@ +from __future__ import division + +import torch +import torch.nn as nn + +from mmdet.core import (bbox2result, bbox2roi, bbox_mapping, build_assigner, + build_sampler, merge_aug_bboxes, merge_aug_masks, + multiclass_nms) +from .. import builder +from ..registry import DETECTORS +from .base import BaseDetector +from .test_mixins import RPNTestMixin + + +@DETECTORS.register_module +class CascadeRCNN(BaseDetector, RPNTestMixin): + + def __init__(self, + num_stages, + backbone, + neck=None, + shared_head=None, + rpn_head=None, + bbox_roi_extractor=None, + bbox_head=None, + mask_roi_extractor=None, + mask_head=None, + train_cfg=None, + test_cfg=None, + pretrained=None): + assert bbox_roi_extractor is not None + assert bbox_head is not None + super(CascadeRCNN, self).__init__() + + self.num_stages = num_stages + self.backbone = builder.build_backbone(backbone) + + if neck is not None: + self.neck = builder.build_neck(neck) + + if rpn_head is not None: + self.rpn_head = builder.build_head(rpn_head) + + if shared_head is not None: + self.shared_head = builder.build_shared_head(shared_head) + + if bbox_head is not None: + self.bbox_roi_extractor = nn.ModuleList() + self.bbox_head = nn.ModuleList() + if not isinstance(bbox_roi_extractor, list): + bbox_roi_extractor = [ + bbox_roi_extractor for _ in range(num_stages) + ] + if not isinstance(bbox_head, list): + bbox_head = [bbox_head for _ in range(num_stages)] + assert len(bbox_roi_extractor) == len(bbox_head) == self.num_stages + for roi_extractor, head in zip(bbox_roi_extractor, bbox_head): + self.bbox_roi_extractor.append( + builder.build_roi_extractor(roi_extractor)) + self.bbox_head.append(builder.build_head(head)) + + if mask_head is not None: + self.mask_head = nn.ModuleList() + if not isinstance(mask_head, list): + mask_head = [mask_head for _ in range(num_stages)] + assert len(mask_head) == self.num_stages + for head in mask_head: + self.mask_head.append(builder.build_head(head)) + if mask_roi_extractor is not None: + self.share_roi_extractor = False + self.mask_roi_extractor = nn.ModuleList() + if not isinstance(mask_roi_extractor, list): + mask_roi_extractor = [ + mask_roi_extractor for _ in range(num_stages) + ] + assert len(mask_roi_extractor) == self.num_stages + for roi_extractor in mask_roi_extractor: + self.mask_roi_extractor.append( + builder.build_roi_extractor(roi_extractor)) + else: + self.share_roi_extractor = True + self.mask_roi_extractor = self.bbox_roi_extractor + + self.train_cfg = train_cfg + self.test_cfg = test_cfg + + self.init_weights(pretrained=pretrained) + + @property + def with_rpn(self): + return hasattr(self, 'rpn_head') and self.rpn_head is not None + + def init_weights(self, pretrained=None): + super(CascadeRCNN, self).init_weights(pretrained) + self.backbone.init_weights(pretrained=pretrained) + if self.with_neck: + if isinstance(self.neck, nn.Sequential): + for m in self.neck: + m.init_weights() + else: + self.neck.init_weights() + if self.with_rpn: + self.rpn_head.init_weights() + if self.with_shared_head: + self.shared_head.init_weights(pretrained=pretrained) + for i in range(self.num_stages): + if self.with_bbox: + self.bbox_roi_extractor[i].init_weights() + self.bbox_head[i].init_weights() + if self.with_mask: + if not self.share_roi_extractor: + self.mask_roi_extractor[i].init_weights() + self.mask_head[i].init_weights() + + def extract_feat(self, img): + x = self.backbone(img) + if self.with_neck: + x = self.neck(x) + return x + + def forward_dummy(self, img): + outs = () + # backbone + x = self.extract_feat(img) + # rpn + if self.with_rpn: + rpn_outs = self.rpn_head(x) + outs = outs + (rpn_outs, ) + proposals = torch.randn(1000, 4).cuda() + # bbox heads + rois = bbox2roi([proposals]) + if self.with_bbox: + for i in range(self.num_stages): + bbox_feats = self.bbox_roi_extractor[i]( + x[:self.bbox_roi_extractor[i].num_inputs], rois) + if self.with_shared_head: + bbox_feats = self.shared_head(bbox_feats) + cls_score, bbox_pred = self.bbox_head[i](bbox_feats) + outs = outs + (cls_score, bbox_pred) + # mask heads + if self.with_mask: + mask_rois = rois[:100] + for i in range(self.num_stages): + mask_feats = self.mask_roi_extractor[i]( + x[:self.mask_roi_extractor[i].num_inputs], mask_rois) + if self.with_shared_head: + mask_feats = self.shared_head(mask_feats) + mask_pred = self.mask_head[i](mask_feats) + outs = outs + (mask_pred, ) + return outs + + def forward_train(self, + img, + img_meta, + gt_bboxes, + gt_labels, + gt_bboxes_ignore=None, + gt_masks=None, + proposals=None): + """ + Args: + img (Tensor): of shape (N, C, H, W) encoding input images. + Typically these should be mean centered and std scaled. + + img_meta (list[dict]): list of image info dict where each dict has: + 'img_shape', 'scale_factor', 'flip', and my also contain + 'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'. + For details on the values of these keys see + `mmdet/datasets/pipelines/formatting.py:Collect`. + + gt_bboxes (list[Tensor]): each item are the truth boxes for each + image in [tl_x, tl_y, br_x, br_y] format. + + gt_labels (list[Tensor]): class indices corresponding to each box + + gt_bboxes_ignore (None | list[Tensor]): specify which bounding + boxes can be ignored when computing the loss. + + gt_masks (None | Tensor) : true segmentation masks for each box + used if the architecture supports a segmentation task. + + proposals : override rpn proposals with custom proposals. Use when + `with_rpn` is False. + + Returns: + dict[str, Tensor]: a dictionary of loss components + """ + x = self.extract_feat(img) + + losses = dict() + + if self.with_rpn: + rpn_outs = self.rpn_head(x) + rpn_loss_inputs = rpn_outs + (gt_bboxes, img_meta, + self.train_cfg.rpn) + rpn_losses = self.rpn_head.loss( + *rpn_loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) + losses.update(rpn_losses) + + proposal_cfg = self.train_cfg.get('rpn_proposal', + self.test_cfg.rpn) + proposal_inputs = rpn_outs + (img_meta, proposal_cfg) + proposal_list = self.rpn_head.get_bboxes(*proposal_inputs) + else: + proposal_list = proposals + + for i in range(self.num_stages): + self.current_stage = i + rcnn_train_cfg = self.train_cfg.rcnn[i] + lw = self.train_cfg.stage_loss_weights[i] + + # assign gts and sample proposals + sampling_results = [] + if self.with_bbox or self.with_mask: + bbox_assigner = build_assigner(rcnn_train_cfg.assigner) + bbox_sampler = build_sampler( + rcnn_train_cfg.sampler, context=self) + num_imgs = img.size(0) + if gt_bboxes_ignore is None: + gt_bboxes_ignore = [None for _ in range(num_imgs)] + + for j in range(num_imgs): + assign_result = bbox_assigner.assign( + proposal_list[j], gt_bboxes[j], gt_bboxes_ignore[j], + gt_labels[j]) + sampling_result = bbox_sampler.sample( + assign_result, + proposal_list[j], + gt_bboxes[j], + gt_labels[j], + feats=[lvl_feat[j][None] for lvl_feat in x]) + sampling_results.append(sampling_result) + + # bbox head forward and loss + bbox_roi_extractor = self.bbox_roi_extractor[i] + bbox_head = self.bbox_head[i] + + rois = bbox2roi([res.bboxes for res in sampling_results]) + + if len(rois) == 0: + # If there are no predicted and/or truth boxes, then we cannot + # compute head / mask losses + continue + + bbox_feats = bbox_roi_extractor(x[:bbox_roi_extractor.num_inputs], + rois) + if self.with_shared_head: + bbox_feats = self.shared_head(bbox_feats) + cls_score, bbox_pred = bbox_head(bbox_feats) + + bbox_targets = bbox_head.get_target(sampling_results, gt_bboxes, + gt_labels, rcnn_train_cfg) + loss_bbox = bbox_head.loss(cls_score, bbox_pred, *bbox_targets) + for name, value in loss_bbox.items(): + losses['s{}.{}'.format(i, name)] = ( + value * lw if 'loss' in name else value) + + # mask head forward and loss + if self.with_mask: + if not self.share_roi_extractor: + mask_roi_extractor = self.mask_roi_extractor[i] + pos_rois = bbox2roi( + [res.pos_bboxes for res in sampling_results]) + mask_feats = mask_roi_extractor( + x[:mask_roi_extractor.num_inputs], pos_rois) + if self.with_shared_head: + mask_feats = self.shared_head(mask_feats) + else: + # reuse positive bbox feats + pos_inds = [] + device = bbox_feats.device + for res in sampling_results: + pos_inds.append( + torch.ones( + res.pos_bboxes.shape[0], + device=device, + dtype=torch.uint8)) + pos_inds.append( + torch.zeros( + res.neg_bboxes.shape[0], + device=device, + dtype=torch.uint8)) + pos_inds = torch.cat(pos_inds) + mask_feats = bbox_feats[pos_inds] + mask_head = self.mask_head[i] + mask_pred = mask_head(mask_feats) + mask_targets = mask_head.get_target(sampling_results, gt_masks, + rcnn_train_cfg) + pos_labels = torch.cat( + [res.pos_gt_labels for res in sampling_results]) + loss_mask = mask_head.loss(mask_pred, mask_targets, pos_labels) + for name, value in loss_mask.items(): + losses['s{}.{}'.format(i, name)] = ( + value * lw if 'loss' in name else value) + + # refine bboxes + if i < self.num_stages - 1: + pos_is_gts = [res.pos_is_gt for res in sampling_results] + roi_labels = bbox_targets[0] # bbox_targets is a tuple + with torch.no_grad(): + proposal_list = bbox_head.refine_bboxes( + rois, roi_labels, bbox_pred, pos_is_gts, img_meta) + + return losses + + def simple_test(self, img, img_meta, proposals=None, rescale=False): + """Run inference on a single image. + + Args: + img (Tensor): must be in shape (N, C, H, W) + img_meta (list[dict]): a list with one dictionary element. + See `mmdet/datasets/pipelines/formatting.py:Collect` for + details of meta dicts. + proposals : if specified overrides rpn proposals + rescale (bool): if True returns boxes in original image space + + Returns: + dict: results + """ + x = self.extract_feat(img) + + proposal_list = self.simple_test_rpn( + x, img_meta, self.test_cfg.rpn) if proposals is None else proposals + + img_shape = img_meta[0]['img_shape'] + ori_shape = img_meta[0]['ori_shape'] + scale_factor = img_meta[0]['scale_factor'] + + # "ms" in variable names means multi-stage + ms_bbox_result = {} + ms_segm_result = {} + ms_scores = [] + rcnn_test_cfg = self.test_cfg.rcnn + + rois = bbox2roi(proposal_list) + for i in range(self.num_stages): + bbox_roi_extractor = self.bbox_roi_extractor[i] + bbox_head = self.bbox_head[i] + + bbox_feats = bbox_roi_extractor( + x[:len(bbox_roi_extractor.featmap_strides)], rois) + if self.with_shared_head: + bbox_feats = self.shared_head(bbox_feats) + + cls_score, bbox_pred = bbox_head(bbox_feats) + ms_scores.append(cls_score) + + if i < self.num_stages - 1: + bbox_label = cls_score.argmax(dim=1) + rois = bbox_head.regress_by_class(rois, bbox_label, bbox_pred, + img_meta[0]) + + cls_score = sum(ms_scores) / self.num_stages + det_bboxes, det_labels = self.bbox_head[-1].get_det_bboxes( + rois, + cls_score, + bbox_pred, + img_shape, + scale_factor, + rescale=rescale, + cfg=rcnn_test_cfg) + bbox_result = bbox2result(det_bboxes, det_labels, + self.bbox_head[-1].num_classes) + ms_bbox_result['ensemble'] = bbox_result + + if self.with_mask: + if det_bboxes.shape[0] == 0: + mask_classes = self.mask_head[-1].num_classes - 1 + segm_result = [[] for _ in range(mask_classes)] + else: + if isinstance(scale_factor, float): # aspect ratio fixed + _bboxes = ( + det_bboxes[:, :4] * + scale_factor if rescale else det_bboxes) + else: + _bboxes = ( + det_bboxes[:, :4] * + torch.from_numpy(scale_factor).to(det_bboxes.device) + if rescale else det_bboxes) + + mask_rois = bbox2roi([_bboxes]) + aug_masks = [] + for i in range(self.num_stages): + mask_roi_extractor = self.mask_roi_extractor[i] + mask_feats = mask_roi_extractor( + x[:len(mask_roi_extractor.featmap_strides)], mask_rois) + if self.with_shared_head: + mask_feats = self.shared_head(mask_feats) + mask_pred = self.mask_head[i](mask_feats) + aug_masks.append(mask_pred.sigmoid().cpu().numpy()) + merged_masks = merge_aug_masks(aug_masks, + [img_meta] * self.num_stages, + self.test_cfg.rcnn) + segm_result = self.mask_head[-1].get_seg_masks( + merged_masks, _bboxes, det_labels, rcnn_test_cfg, + ori_shape, scale_factor, rescale) + ms_segm_result['ensemble'] = segm_result + + if self.with_mask: + results = (ms_bbox_result['ensemble'], ms_segm_result['ensemble']) + else: + results = ms_bbox_result['ensemble'] + + return results + + def aug_test(self, imgs, img_metas, proposals=None, rescale=False): + """Test with augmentations. + + If rescale is False, then returned bboxes and masks will fit the scale + of imgs[0]. + """ + # recompute feats to save memory + proposal_list = self.aug_test_rpn( + self.extract_feats(imgs), img_metas, self.test_cfg.rpn) + + rcnn_test_cfg = self.test_cfg.rcnn + aug_bboxes = [] + aug_scores = [] + for x, img_meta in zip(self.extract_feats(imgs), img_metas): + # only one image in the batch + img_shape = img_meta[0]['img_shape'] + scale_factor = img_meta[0]['scale_factor'] + flip = img_meta[0]['flip'] + + proposals = bbox_mapping(proposal_list[0][:, :4], img_shape, + scale_factor, flip) + # "ms" in variable names means multi-stage + ms_scores = [] + + rois = bbox2roi([proposals]) + for i in range(self.num_stages): + bbox_roi_extractor = self.bbox_roi_extractor[i] + bbox_head = self.bbox_head[i] + + bbox_feats = bbox_roi_extractor( + x[:len(bbox_roi_extractor.featmap_strides)], rois) + if self.with_shared_head: + bbox_feats = self.shared_head(bbox_feats) + + cls_score, bbox_pred = bbox_head(bbox_feats) + ms_scores.append(cls_score) + + if i < self.num_stages - 1: + bbox_label = cls_score.argmax(dim=1) + rois = bbox_head.regress_by_class(rois, bbox_label, + bbox_pred, img_meta[0]) + + cls_score = sum(ms_scores) / float(len(ms_scores)) + bboxes, scores = self.bbox_head[-1].get_det_bboxes( + rois, + cls_score, + bbox_pred, + img_shape, + scale_factor, + rescale=False, + cfg=None) + aug_bboxes.append(bboxes) + aug_scores.append(scores) + + # after merging, bboxes will be rescaled to the original image size + merged_bboxes, merged_scores = merge_aug_bboxes( + aug_bboxes, aug_scores, img_metas, rcnn_test_cfg) + det_bboxes, det_labels = multiclass_nms(merged_bboxes, merged_scores, + rcnn_test_cfg.score_thr, + rcnn_test_cfg.nms, + rcnn_test_cfg.max_per_img) + + bbox_result = bbox2result(det_bboxes, det_labels, + self.bbox_head[-1].num_classes) + + if self.with_mask: + if det_bboxes.shape[0] == 0: + segm_result = [[] + for _ in range(self.mask_head[-1].num_classes - + 1)] + else: + aug_masks = [] + aug_img_metas = [] + for x, img_meta in zip(self.extract_feats(imgs), img_metas): + img_shape = img_meta[0]['img_shape'] + scale_factor = img_meta[0]['scale_factor'] + flip = img_meta[0]['flip'] + _bboxes = bbox_mapping(det_bboxes[:, :4], img_shape, + scale_factor, flip) + mask_rois = bbox2roi([_bboxes]) + for i in range(self.num_stages): + mask_feats = self.mask_roi_extractor[i]( + x[:len(self.mask_roi_extractor[i].featmap_strides + )], mask_rois) + if self.with_shared_head: + mask_feats = self.shared_head(mask_feats) + mask_pred = self.mask_head[i](mask_feats) + aug_masks.append(mask_pred.sigmoid().cpu().numpy()) + aug_img_metas.append(img_meta) + merged_masks = merge_aug_masks(aug_masks, aug_img_metas, + self.test_cfg.rcnn) + + ori_shape = img_metas[0][0]['ori_shape'] + segm_result = self.mask_head[-1].get_seg_masks( + merged_masks, + det_bboxes, + det_labels, + rcnn_test_cfg, + ori_shape, + scale_factor=1.0, + rescale=False) + return bbox_result, segm_result + else: + return bbox_result + + def show_result(self, data, result, **kwargs): + if self.with_mask: + ms_bbox_result, ms_segm_result = result + if isinstance(ms_bbox_result, dict): + result = (ms_bbox_result['ensemble'], + ms_segm_result['ensemble']) + else: + if isinstance(result, dict): + result = result['ensemble'] + super(CascadeRCNN, self).show_result(data, result, **kwargs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/double_head_rcnn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/double_head_rcnn.py new file mode 100644 index 000000000..7a783353f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/double_head_rcnn.py @@ -0,0 +1,178 @@ +import torch + +from mmdet.core import bbox2roi, build_assigner, build_sampler +from ..registry import DETECTORS +from .two_stage import TwoStageDetector + + +@DETECTORS.register_module +class DoubleHeadRCNN(TwoStageDetector): + + def __init__(self, reg_roi_scale_factor, **kwargs): + super().__init__(**kwargs) + self.reg_roi_scale_factor = reg_roi_scale_factor + + def forward_dummy(self, img): + outs = () + # backbone + x = self.extract_feat(img) + # rpn + if self.with_rpn: + rpn_outs = self.rpn_head(x) + outs = outs + (rpn_outs, ) + proposals = torch.randn(1000, 4).cuda() + # bbox head + rois = bbox2roi([proposals]) + bbox_cls_feats = self.bbox_roi_extractor( + x[:self.bbox_roi_extractor.num_inputs], rois) + bbox_reg_feats = self.bbox_roi_extractor( + x[:self.bbox_roi_extractor.num_inputs], + rois, + roi_scale_factor=self.reg_roi_scale_factor) + if self.with_shared_head: + bbox_cls_feats = self.shared_head(bbox_cls_feats) + bbox_reg_feats = self.shared_head(bbox_reg_feats) + cls_score, bbox_pred = self.bbox_head(bbox_cls_feats, bbox_reg_feats) + outs += (cls_score, bbox_pred) + return outs + + def forward_train(self, + img, + img_meta, + gt_bboxes, + gt_labels, + gt_bboxes_ignore=None, + gt_masks=None, + proposals=None): + x = self.extract_feat(img) + + losses = dict() + + # RPN forward and loss + if self.with_rpn: + rpn_outs = self.rpn_head(x) + rpn_loss_inputs = rpn_outs + (gt_bboxes, img_meta, + self.train_cfg.rpn) + rpn_losses = self.rpn_head.loss( + *rpn_loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) + losses.update(rpn_losses) + + proposal_cfg = self.train_cfg.get('rpn_proposal', + self.test_cfg.rpn) + proposal_inputs = rpn_outs + (img_meta, proposal_cfg) + proposal_list = self.rpn_head.get_bboxes(*proposal_inputs) + else: + proposal_list = proposals + + # assign gts and sample proposals + if self.with_bbox or self.with_mask: + bbox_assigner = build_assigner(self.train_cfg.rcnn.assigner) + bbox_sampler = build_sampler( + self.train_cfg.rcnn.sampler, context=self) + num_imgs = img.size(0) + if gt_bboxes_ignore is None: + gt_bboxes_ignore = [None for _ in range(num_imgs)] + sampling_results = [] + for i in range(num_imgs): + assign_result = bbox_assigner.assign(proposal_list[i], + gt_bboxes[i], + gt_bboxes_ignore[i], + gt_labels[i]) + sampling_result = bbox_sampler.sample( + assign_result, + proposal_list[i], + gt_bboxes[i], + gt_labels[i], + feats=[lvl_feat[i][None] for lvl_feat in x]) + sampling_results.append(sampling_result) + + # bbox head forward and loss + if self.with_bbox: + rois = bbox2roi([res.bboxes for res in sampling_results]) + # TODO: a more flexible way to decide which feature maps to use + bbox_cls_feats = self.bbox_roi_extractor( + x[:self.bbox_roi_extractor.num_inputs], rois) + bbox_reg_feats = self.bbox_roi_extractor( + x[:self.bbox_roi_extractor.num_inputs], + rois, + roi_scale_factor=self.reg_roi_scale_factor) + if self.with_shared_head: + bbox_cls_feats = self.shared_head(bbox_cls_feats) + bbox_reg_feats = self.shared_head(bbox_reg_feats) + cls_score, bbox_pred = self.bbox_head(bbox_cls_feats, + bbox_reg_feats) + + bbox_targets = self.bbox_head.get_target(sampling_results, + gt_bboxes, gt_labels, + self.train_cfg.rcnn) + loss_bbox = self.bbox_head.loss(cls_score, bbox_pred, + *bbox_targets) + losses.update(loss_bbox) + + # mask head forward and loss + if self.with_mask: + if not self.share_roi_extractor: + pos_rois = bbox2roi( + [res.pos_bboxes for res in sampling_results]) + mask_feats = self.mask_roi_extractor( + x[:self.mask_roi_extractor.num_inputs], pos_rois) + if self.with_shared_head: + mask_feats = self.shared_head(mask_feats) + else: + pos_inds = [] + device = bbox_cls_feats.device + for res in sampling_results: + pos_inds.append( + torch.ones( + res.pos_bboxes.shape[0], + device=device, + dtype=torch.uint8)) + pos_inds.append( + torch.zeros( + res.neg_bboxes.shape[0], + device=device, + dtype=torch.uint8)) + pos_inds = torch.cat(pos_inds) + mask_feats = bbox_cls_feats[pos_inds] + mask_pred = self.mask_head(mask_feats) + + mask_targets = self.mask_head.get_target(sampling_results, + gt_masks, + self.train_cfg.rcnn) + pos_labels = torch.cat( + [res.pos_gt_labels for res in sampling_results]) + loss_mask = self.mask_head.loss(mask_pred, mask_targets, + pos_labels) + losses.update(loss_mask) + + return losses + + def simple_test_bboxes(self, + x, + img_meta, + proposals, + rcnn_test_cfg, + rescale=False): + """Test only det bboxes without augmentation.""" + rois = bbox2roi(proposals) + bbox_cls_feats = self.bbox_roi_extractor( + x[:self.bbox_roi_extractor.num_inputs], rois) + bbox_reg_feats = self.bbox_roi_extractor( + x[:self.bbox_roi_extractor.num_inputs], + rois, + roi_scale_factor=self.reg_roi_scale_factor) + if self.with_shared_head: + bbox_cls_feats = self.shared_head(bbox_cls_feats) + bbox_reg_feats = self.shared_head(bbox_reg_feats) + cls_score, bbox_pred = self.bbox_head(bbox_cls_feats, bbox_reg_feats) + img_shape = img_meta[0]['img_shape'] + scale_factor = img_meta[0]['scale_factor'] + det_bboxes, det_labels = self.bbox_head.get_det_bboxes( + rois, + cls_score, + bbox_pred, + img_shape, + scale_factor, + rescale=rescale, + cfg=rcnn_test_cfg) + return det_bboxes, det_labels diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fast_rcnn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fast_rcnn.py new file mode 100644 index 000000000..8e4231855 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fast_rcnn.py @@ -0,0 +1,61 @@ +from ..registry import DETECTORS +from .two_stage import TwoStageDetector + + +@DETECTORS.register_module +class FastRCNN(TwoStageDetector): + + def __init__(self, + backbone, + bbox_roi_extractor, + bbox_head, + train_cfg, + test_cfg, + neck=None, + shared_head=None, + mask_roi_extractor=None, + mask_head=None, + pretrained=None): + super(FastRCNN, self).__init__( + backbone=backbone, + neck=neck, + shared_head=shared_head, + bbox_roi_extractor=bbox_roi_extractor, + bbox_head=bbox_head, + train_cfg=train_cfg, + test_cfg=test_cfg, + mask_roi_extractor=mask_roi_extractor, + mask_head=mask_head, + pretrained=pretrained) + + def forward_test(self, imgs, img_metas, proposals, **kwargs): + """ + Args: + imgs (List[Tensor]): the outer list indicates test-time + augmentations and inner Tensor should have a shape NxCxHxW, + which contains all images in the batch. + img_meta (List[List[dict]]): the outer list indicates test-time + augs (multiscale, flip, etc.) and the inner list indicates + images in a batch + proposals (List[List[Tensor | None]]): predefiend proposals for + each test-time augmentation and each item. + """ + for var, name in [(imgs, 'imgs'), (img_metas, 'img_metas')]: + if not isinstance(var, list): + raise TypeError('{} must be a list, but got {}'.format( + name, type(var))) + + num_augs = len(imgs) + if num_augs != len(img_metas): + raise ValueError( + 'num of augmentations ({}) != num of image meta ({})'.format( + len(imgs), len(img_metas))) + # TODO: remove the restriction of imgs_per_gpu == 1 when prepared + imgs_per_gpu = imgs[0].size(0) + assert imgs_per_gpu == 1 + + if num_augs == 1: + return self.simple_test(imgs[0], img_metas[0], proposals[0], + **kwargs) + else: + return self.aug_test(imgs, img_metas, proposals, **kwargs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/faster_rcnn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/faster_rcnn.py new file mode 100644 index 000000000..969cd7ccd --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/faster_rcnn.py @@ -0,0 +1,27 @@ +from ..registry import DETECTORS +from .two_stage import TwoStageDetector + + +@DETECTORS.register_module +class FasterRCNN(TwoStageDetector): + + def __init__(self, + backbone, + rpn_head, + bbox_roi_extractor, + bbox_head, + train_cfg, + test_cfg, + neck=None, + shared_head=None, + pretrained=None): + super(FasterRCNN, self).__init__( + backbone=backbone, + neck=neck, + shared_head=shared_head, + rpn_head=rpn_head, + bbox_roi_extractor=bbox_roi_extractor, + bbox_head=bbox_head, + train_cfg=train_cfg, + test_cfg=test_cfg, + pretrained=pretrained) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fcos.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fcos.py new file mode 100644 index 000000000..89cc5929a --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fcos.py @@ -0,0 +1,16 @@ +from ..registry import DETECTORS +from .single_stage import SingleStageDetector + + +@DETECTORS.register_module +class FCOS(SingleStageDetector): + + def __init__(self, + backbone, + neck, + bbox_head, + train_cfg=None, + test_cfg=None, + pretrained=None): + super(FCOS, self).__init__(backbone, neck, bbox_head, train_cfg, + test_cfg, pretrained) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fovea.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fovea.py new file mode 100644 index 000000000..0d264bb24 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fovea.py @@ -0,0 +1,16 @@ +from ..registry import DETECTORS +from .single_stage import SingleStageDetector + + +@DETECTORS.register_module +class FOVEA(SingleStageDetector): + + def __init__(self, + backbone, + neck, + bbox_head, + train_cfg=None, + test_cfg=None, + pretrained=None): + super(FOVEA, self).__init__(backbone, neck, bbox_head, train_cfg, + test_cfg, pretrained) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/grid_rcnn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/grid_rcnn.py new file mode 100644 index 000000000..853242c16 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/grid_rcnn.py @@ -0,0 +1,229 @@ +import torch + +from mmdet.core import bbox2result, bbox2roi, build_assigner, build_sampler +from .. import builder +from ..registry import DETECTORS +from .two_stage import TwoStageDetector + + +@DETECTORS.register_module +class GridRCNN(TwoStageDetector): + """Grid R-CNN. + + This detector is the implementation of: + - Grid R-CNN (https://arxiv.org/abs/1811.12030) + - Grid R-CNN Plus: Faster and Better (https://arxiv.org/abs/1906.05688) + """ + + def __init__(self, + backbone, + rpn_head, + bbox_roi_extractor, + bbox_head, + grid_roi_extractor, + grid_head, + train_cfg, + test_cfg, + neck=None, + shared_head=None, + pretrained=None): + assert grid_head is not None + super(GridRCNN, self).__init__( + backbone=backbone, + neck=neck, + shared_head=shared_head, + rpn_head=rpn_head, + bbox_roi_extractor=bbox_roi_extractor, + bbox_head=bbox_head, + train_cfg=train_cfg, + test_cfg=test_cfg, + pretrained=pretrained) + + if grid_roi_extractor is not None: + self.grid_roi_extractor = builder.build_roi_extractor( + grid_roi_extractor) + self.share_roi_extractor = False + else: + self.share_roi_extractor = True + self.grid_roi_extractor = self.bbox_roi_extractor + self.grid_head = builder.build_head(grid_head) + + self.init_extra_weights() + + def init_extra_weights(self): + self.grid_head.init_weights() + if not self.share_roi_extractor: + self.grid_roi_extractor.init_weights() + + def _random_jitter(self, sampling_results, img_metas, amplitude=0.15): + """Ramdom jitter positive proposals for training.""" + for sampling_result, img_meta in zip(sampling_results, img_metas): + bboxes = sampling_result.pos_bboxes + random_offsets = bboxes.new_empty(bboxes.shape[0], 4).uniform_( + -amplitude, amplitude) + # before jittering + cxcy = (bboxes[:, 2:4] + bboxes[:, :2]) / 2 + wh = (bboxes[:, 2:4] - bboxes[:, :2]).abs() + # after jittering + new_cxcy = cxcy + wh * random_offsets[:, :2] + new_wh = wh * (1 + random_offsets[:, 2:]) + # xywh to xyxy + new_x1y1 = (new_cxcy - new_wh / 2) + new_x2y2 = (new_cxcy + new_wh / 2) + new_bboxes = torch.cat([new_x1y1, new_x2y2], dim=1) + # clip bboxes + max_shape = img_meta['img_shape'] + if max_shape is not None: + new_bboxes[:, 0::2].clamp_(min=0, max=max_shape[1] - 1) + new_bboxes[:, 1::2].clamp_(min=0, max=max_shape[0] - 1) + + sampling_result.pos_bboxes = new_bboxes + return sampling_results + + def forward_dummy(self, img): + outs = () + # backbone + x = self.extract_feat(img) + # rpn + if self.with_rpn: + rpn_outs = self.rpn_head(x) + outs = outs + (rpn_outs, ) + proposals = torch.randn(1000, 4).cuda() + # bbox head + rois = bbox2roi([proposals]) + bbox_feats = self.bbox_roi_extractor( + x[:self.bbox_roi_extractor.num_inputs], rois) + if self.with_shared_head: + bbox_feats = self.shared_head(bbox_feats) + cls_score, bbox_pred = self.bbox_head(bbox_feats) + # grid head + grid_rois = rois[:100] + grid_feats = self.grid_roi_extractor( + x[:self.grid_roi_extractor.num_inputs], grid_rois) + if self.with_shared_head: + grid_feats = self.shared_head(grid_feats) + grid_pred = self.grid_head(grid_feats) + return rpn_outs, cls_score, bbox_pred, grid_pred + + def forward_train(self, + img, + img_meta, + gt_bboxes, + gt_labels, + gt_bboxes_ignore=None, + gt_masks=None, + proposals=None): + x = self.extract_feat(img) + + losses = dict() + + # RPN forward and loss + if self.with_rpn: + rpn_outs = self.rpn_head(x) + rpn_loss_inputs = rpn_outs + (gt_bboxes, img_meta, + self.train_cfg.rpn) + rpn_losses = self.rpn_head.loss( + *rpn_loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) + losses.update(rpn_losses) + + proposal_cfg = self.train_cfg.get('rpn_proposal', + self.test_cfg.rpn) + proposal_inputs = rpn_outs + (img_meta, proposal_cfg) + proposal_list = self.rpn_head.get_bboxes(*proposal_inputs) + else: + proposal_list = proposals + + if self.with_bbox: + # assign gts and sample proposals + bbox_assigner = build_assigner(self.train_cfg.rcnn.assigner) + bbox_sampler = build_sampler( + self.train_cfg.rcnn.sampler, context=self) + num_imgs = img.size(0) + if gt_bboxes_ignore is None: + gt_bboxes_ignore = [None for _ in range(num_imgs)] + sampling_results = [] + for i in range(num_imgs): + assign_result = bbox_assigner.assign(proposal_list[i], + gt_bboxes[i], + gt_bboxes_ignore[i], + gt_labels[i]) + sampling_result = bbox_sampler.sample( + assign_result, + proposal_list[i], + gt_bboxes[i], + gt_labels[i], + feats=[lvl_feat[i][None] for lvl_feat in x]) + sampling_results.append(sampling_result) + + # bbox head forward and loss + rois = bbox2roi([res.bboxes for res in sampling_results]) + # TODO: a more flexible way to decide which feature maps to use + bbox_feats = self.bbox_roi_extractor( + x[:self.bbox_roi_extractor.num_inputs], rois) + if self.with_shared_head: + bbox_feats = self.shared_head(bbox_feats) + cls_score, bbox_pred = self.bbox_head(bbox_feats) + + bbox_targets = self.bbox_head.get_target(sampling_results, + gt_bboxes, gt_labels, + self.train_cfg.rcnn) + loss_bbox = self.bbox_head.loss(cls_score, bbox_pred, + *bbox_targets) + losses.update(loss_bbox) + + # Grid head forward and loss + sampling_results = self._random_jitter(sampling_results, img_meta) + pos_rois = bbox2roi([res.pos_bboxes for res in sampling_results]) + grid_feats = self.grid_roi_extractor( + x[:self.grid_roi_extractor.num_inputs], pos_rois) + if self.with_shared_head: + grid_feats = self.shared_head(grid_feats) + # Accelerate training + max_sample_num_grid = self.train_cfg.rcnn.get('max_num_grid', 192) + sample_idx = torch.randperm( + grid_feats.shape[0])[:min(grid_feats. + shape[0], max_sample_num_grid)] + grid_feats = grid_feats[sample_idx] + + grid_pred = self.grid_head(grid_feats) + + grid_targets = self.grid_head.get_target(sampling_results, + self.train_cfg.rcnn) + grid_targets = grid_targets[sample_idx] + + loss_grid = self.grid_head.loss(grid_pred, grid_targets) + losses.update(loss_grid) + + return losses + + def simple_test(self, img, img_meta, proposals=None, rescale=False): + """Test without augmentation.""" + assert self.with_bbox, "Bbox head must be implemented." + + x = self.extract_feat(img) + + proposal_list = self.simple_test_rpn( + x, img_meta, self.test_cfg.rpn) if proposals is None else proposals + + det_bboxes, det_labels = self.simple_test_bboxes( + x, img_meta, proposal_list, self.test_cfg.rcnn, rescale=False) + + # pack rois into bboxes + grid_rois = bbox2roi([det_bboxes[:, :4]]) + grid_feats = self.grid_roi_extractor( + x[:len(self.grid_roi_extractor.featmap_strides)], grid_rois) + if grid_rois.shape[0] != 0: + self.grid_head.test_mode = True + grid_pred = self.grid_head(grid_feats) + det_bboxes = self.grid_head.get_bboxes(det_bboxes, + grid_pred['fused'], + img_meta) + if rescale: + det_bboxes[:, :4] /= img_meta[0]['scale_factor'] + else: + det_bboxes = torch.Tensor([]) + + bbox_results = bbox2result(det_bboxes, det_labels, + self.bbox_head.num_classes) + + return bbox_results diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/htc.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/htc.py new file mode 100644 index 000000000..a989e17f0 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/htc.py @@ -0,0 +1,516 @@ +import torch +import torch.nn.functional as F + +from mmdet.core import (bbox2result, bbox2roi, bbox_mapping, build_assigner, + build_sampler, merge_aug_bboxes, merge_aug_masks, + multiclass_nms) +from .. import builder +from ..registry import DETECTORS +from .cascade_rcnn import CascadeRCNN + + +@DETECTORS.register_module +class HybridTaskCascade(CascadeRCNN): + + def __init__(self, + num_stages, + backbone, + semantic_roi_extractor=None, + semantic_head=None, + semantic_fusion=('bbox', 'mask'), + interleaved=True, + mask_info_flow=True, + **kwargs): + super(HybridTaskCascade, self).__init__(num_stages, backbone, **kwargs) + assert self.with_bbox and self.with_mask + assert not self.with_shared_head # shared head not supported + if semantic_head is not None: + self.semantic_roi_extractor = builder.build_roi_extractor( + semantic_roi_extractor) + self.semantic_head = builder.build_head(semantic_head) + + self.semantic_fusion = semantic_fusion + self.interleaved = interleaved + self.mask_info_flow = mask_info_flow + + @property + def with_semantic(self): + if hasattr(self, 'semantic_head') and self.semantic_head is not None: + return True + else: + return False + + def _bbox_forward_train(self, + stage, + x, + sampling_results, + gt_bboxes, + gt_labels, + rcnn_train_cfg, + semantic_feat=None): + rois = bbox2roi([res.bboxes for res in sampling_results]) + bbox_roi_extractor = self.bbox_roi_extractor[stage] + bbox_head = self.bbox_head[stage] + bbox_feats = bbox_roi_extractor(x[:bbox_roi_extractor.num_inputs], + rois) + # semantic feature fusion + # element-wise sum for original features and pooled semantic features + if self.with_semantic and 'bbox' in self.semantic_fusion: + bbox_semantic_feat = self.semantic_roi_extractor([semantic_feat], + rois) + if bbox_semantic_feat.shape[-2:] != bbox_feats.shape[-2:]: + bbox_semantic_feat = F.adaptive_avg_pool2d( + bbox_semantic_feat, bbox_feats.shape[-2:]) + bbox_feats += bbox_semantic_feat + + cls_score, bbox_pred = bbox_head(bbox_feats) + + bbox_targets = bbox_head.get_target(sampling_results, gt_bboxes, + gt_labels, rcnn_train_cfg) + loss_bbox = bbox_head.loss(cls_score, bbox_pred, *bbox_targets) + return loss_bbox, rois, bbox_targets, bbox_pred + + def _mask_forward_train(self, + stage, + x, + sampling_results, + gt_masks, + rcnn_train_cfg, + semantic_feat=None): + mask_roi_extractor = self.mask_roi_extractor[stage] + mask_head = self.mask_head[stage] + pos_rois = bbox2roi([res.pos_bboxes for res in sampling_results]) + mask_feats = mask_roi_extractor(x[:mask_roi_extractor.num_inputs], + pos_rois) + + # semantic feature fusion + # element-wise sum for original features and pooled semantic features + if self.with_semantic and 'mask' in self.semantic_fusion: + mask_semantic_feat = self.semantic_roi_extractor([semantic_feat], + pos_rois) + if mask_semantic_feat.shape[-2:] != mask_feats.shape[-2:]: + mask_semantic_feat = F.adaptive_avg_pool2d( + mask_semantic_feat, mask_feats.shape[-2:]) + mask_feats += mask_semantic_feat + + # mask information flow + # forward all previous mask heads to obtain last_feat, and fuse it + # with the normal mask feature + if self.mask_info_flow: + last_feat = None + for i in range(stage): + last_feat = self.mask_head[i]( + mask_feats, last_feat, return_logits=False) + mask_pred = mask_head(mask_feats, last_feat, return_feat=False) + else: + mask_pred = mask_head(mask_feats) + + mask_targets = mask_head.get_target(sampling_results, gt_masks, + rcnn_train_cfg) + pos_labels = torch.cat([res.pos_gt_labels for res in sampling_results]) + loss_mask = mask_head.loss(mask_pred, mask_targets, pos_labels) + return loss_mask + + def _bbox_forward_test(self, stage, x, rois, semantic_feat=None): + bbox_roi_extractor = self.bbox_roi_extractor[stage] + bbox_head = self.bbox_head[stage] + bbox_feats = bbox_roi_extractor( + x[:len(bbox_roi_extractor.featmap_strides)], rois) + if self.with_semantic and 'bbox' in self.semantic_fusion: + bbox_semantic_feat = self.semantic_roi_extractor([semantic_feat], + rois) + if bbox_semantic_feat.shape[-2:] != bbox_feats.shape[-2:]: + bbox_semantic_feat = F.adaptive_avg_pool2d( + bbox_semantic_feat, bbox_feats.shape[-2:]) + bbox_feats += bbox_semantic_feat + cls_score, bbox_pred = bbox_head(bbox_feats) + return cls_score, bbox_pred + + def _mask_forward_test(self, stage, x, bboxes, semantic_feat=None): + mask_roi_extractor = self.mask_roi_extractor[stage] + mask_head = self.mask_head[stage] + mask_rois = bbox2roi([bboxes]) + mask_feats = mask_roi_extractor( + x[:len(mask_roi_extractor.featmap_strides)], mask_rois) + if self.with_semantic and 'mask' in self.semantic_fusion: + mask_semantic_feat = self.semantic_roi_extractor([semantic_feat], + mask_rois) + if mask_semantic_feat.shape[-2:] != mask_feats.shape[-2:]: + mask_semantic_feat = F.adaptive_avg_pool2d( + mask_semantic_feat, mask_feats.shape[-2:]) + mask_feats += mask_semantic_feat + if self.mask_info_flow: + last_feat = None + last_pred = None + for i in range(stage): + mask_pred, last_feat = self.mask_head[i](mask_feats, last_feat) + if last_pred is not None: + mask_pred = mask_pred + last_pred + last_pred = mask_pred + mask_pred = mask_head(mask_feats, last_feat, return_feat=False) + if last_pred is not None: + mask_pred = mask_pred + last_pred + else: + mask_pred = mask_head(mask_feats) + return mask_pred + + def forward_dummy(self, img): + outs = () + # backbone + x = self.extract_feat(img) + # rpn + if self.with_rpn: + rpn_outs = self.rpn_head(x) + outs = outs + (rpn_outs, ) + proposals = torch.randn(1000, 4).cuda() + # semantic head + if self.with_semantic: + _, semantic_feat = self.semantic_head(x) + else: + semantic_feat = None + # bbox heads + rois = bbox2roi([proposals]) + for i in range(self.num_stages): + cls_score, bbox_pred = self._bbox_forward_test( + i, x, rois, semantic_feat=semantic_feat) + outs = outs + (cls_score, bbox_pred) + # mask heads + if self.with_mask: + mask_rois = rois[:100] + mask_roi_extractor = self.mask_roi_extractor[-1] + mask_feats = mask_roi_extractor( + x[:len(mask_roi_extractor.featmap_strides)], mask_rois) + if self.with_semantic and 'mask' in self.semantic_fusion: + mask_semantic_feat = self.semantic_roi_extractor( + [semantic_feat], mask_rois) + mask_feats += mask_semantic_feat + last_feat = None + for i in range(self.num_stages): + mask_head = self.mask_head[i] + if self.mask_info_flow: + mask_pred, last_feat = mask_head(mask_feats, last_feat) + else: + mask_pred = mask_head(mask_feats) + outs = outs + (mask_pred, ) + return outs + + def forward_train(self, + img, + img_meta, + gt_bboxes, + gt_labels, + gt_bboxes_ignore=None, + gt_masks=None, + gt_semantic_seg=None, + proposals=None): + x = self.extract_feat(img) + + losses = dict() + + # RPN part, the same as normal two-stage detectors + if self.with_rpn: + rpn_outs = self.rpn_head(x) + rpn_loss_inputs = rpn_outs + (gt_bboxes, img_meta, + self.train_cfg.rpn) + rpn_losses = self.rpn_head.loss( + *rpn_loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) + losses.update(rpn_losses) + + proposal_cfg = self.train_cfg.get('rpn_proposal', + self.test_cfg.rpn) + proposal_inputs = rpn_outs + (img_meta, proposal_cfg) + proposal_list = self.rpn_head.get_bboxes(*proposal_inputs) + else: + proposal_list = proposals + + # semantic segmentation part + # 2 outputs: segmentation prediction and embedded features + if self.with_semantic: + semantic_pred, semantic_feat = self.semantic_head(x) + loss_seg = self.semantic_head.loss(semantic_pred, gt_semantic_seg) + losses['loss_semantic_seg'] = loss_seg + else: + semantic_feat = None + + for i in range(self.num_stages): + self.current_stage = i + rcnn_train_cfg = self.train_cfg.rcnn[i] + lw = self.train_cfg.stage_loss_weights[i] + + # assign gts and sample proposals + sampling_results = [] + bbox_assigner = build_assigner(rcnn_train_cfg.assigner) + bbox_sampler = build_sampler(rcnn_train_cfg.sampler, context=self) + num_imgs = img.size(0) + if gt_bboxes_ignore is None: + gt_bboxes_ignore = [None for _ in range(num_imgs)] + + for j in range(num_imgs): + assign_result = bbox_assigner.assign(proposal_list[j], + gt_bboxes[j], + gt_bboxes_ignore[j], + gt_labels[j]) + sampling_result = bbox_sampler.sample( + assign_result, + proposal_list[j], + gt_bboxes[j], + gt_labels[j], + feats=[lvl_feat[j][None] for lvl_feat in x]) + sampling_results.append(sampling_result) + + # bbox head forward and loss + loss_bbox, rois, bbox_targets, bbox_pred = \ + self._bbox_forward_train( + i, x, sampling_results, gt_bboxes, gt_labels, + rcnn_train_cfg, semantic_feat) + roi_labels = bbox_targets[0] + + for name, value in loss_bbox.items(): + losses['s{}.{}'.format(i, name)] = ( + value * lw if 'loss' in name else value) + + # mask head forward and loss + if self.with_mask: + # interleaved execution: use regressed bboxes by the box branch + # to train the mask branch + if self.interleaved: + pos_is_gts = [res.pos_is_gt for res in sampling_results] + with torch.no_grad(): + proposal_list = self.bbox_head[i].refine_bboxes( + rois, roi_labels, bbox_pred, pos_is_gts, img_meta) + # re-assign and sample 512 RoIs from 512 RoIs + sampling_results = [] + for j in range(num_imgs): + assign_result = bbox_assigner.assign( + proposal_list[j], gt_bboxes[j], + gt_bboxes_ignore[j], gt_labels[j]) + sampling_result = bbox_sampler.sample( + assign_result, + proposal_list[j], + gt_bboxes[j], + gt_labels[j], + feats=[lvl_feat[j][None] for lvl_feat in x]) + sampling_results.append(sampling_result) + loss_mask = self._mask_forward_train(i, x, sampling_results, + gt_masks, rcnn_train_cfg, + semantic_feat) + for name, value in loss_mask.items(): + losses['s{}.{}'.format(i, name)] = ( + value * lw if 'loss' in name else value) + + # refine bboxes (same as Cascade R-CNN) + if i < self.num_stages - 1 and not self.interleaved: + pos_is_gts = [res.pos_is_gt for res in sampling_results] + with torch.no_grad(): + proposal_list = self.bbox_head[i].refine_bboxes( + rois, roi_labels, bbox_pred, pos_is_gts, img_meta) + + return losses + + def simple_test(self, img, img_meta, proposals=None, rescale=False): + x = self.extract_feat(img) + proposal_list = self.simple_test_rpn( + x, img_meta, self.test_cfg.rpn) if proposals is None else proposals + + if self.with_semantic: + _, semantic_feat = self.semantic_head(x) + else: + semantic_feat = None + + img_shape = img_meta[0]['img_shape'] + ori_shape = img_meta[0]['ori_shape'] + scale_factor = img_meta[0]['scale_factor'] + + # "ms" in variable names means multi-stage + ms_bbox_result = {} + ms_segm_result = {} + ms_scores = [] + rcnn_test_cfg = self.test_cfg.rcnn + + rois = bbox2roi(proposal_list) + for i in range(self.num_stages): + bbox_head = self.bbox_head[i] + cls_score, bbox_pred = self._bbox_forward_test( + i, x, rois, semantic_feat=semantic_feat) + ms_scores.append(cls_score) + + if i < self.num_stages - 1: + bbox_label = cls_score.argmax(dim=1) + rois = bbox_head.regress_by_class(rois, bbox_label, bbox_pred, + img_meta[0]) + + cls_score = sum(ms_scores) / float(len(ms_scores)) + det_bboxes, det_labels = self.bbox_head[-1].get_det_bboxes( + rois, + cls_score, + bbox_pred, + img_shape, + scale_factor, + rescale=rescale, + cfg=rcnn_test_cfg) + bbox_result = bbox2result(det_bboxes, det_labels, + self.bbox_head[-1].num_classes) + ms_bbox_result['ensemble'] = bbox_result + + if self.with_mask: + if det_bboxes.shape[0] == 0: + mask_classes = self.mask_head[-1].num_classes - 1 + segm_result = [[] for _ in range(mask_classes)] + else: + _bboxes = ( + det_bboxes[:, :4] * + scale_factor if rescale else det_bboxes) + + mask_rois = bbox2roi([_bboxes]) + aug_masks = [] + mask_roi_extractor = self.mask_roi_extractor[-1] + mask_feats = mask_roi_extractor( + x[:len(mask_roi_extractor.featmap_strides)], mask_rois) + if self.with_semantic and 'mask' in self.semantic_fusion: + mask_semantic_feat = self.semantic_roi_extractor( + [semantic_feat], mask_rois) + mask_feats += mask_semantic_feat + last_feat = None + for i in range(self.num_stages): + mask_head = self.mask_head[i] + if self.mask_info_flow: + mask_pred, last_feat = mask_head(mask_feats, last_feat) + else: + mask_pred = mask_head(mask_feats) + aug_masks.append(mask_pred.sigmoid().cpu().numpy()) + merged_masks = merge_aug_masks(aug_masks, + [img_meta] * self.num_stages, + self.test_cfg.rcnn) + segm_result = self.mask_head[-1].get_seg_masks( + merged_masks, _bboxes, det_labels, rcnn_test_cfg, + ori_shape, scale_factor, rescale) + ms_segm_result['ensemble'] = segm_result + + if self.with_mask: + results = (ms_bbox_result['ensemble'], ms_segm_result['ensemble']) + else: + results = ms_bbox_result['ensemble'] + + return results + + def aug_test(self, imgs, img_metas, proposals=None, rescale=False): + """Test with augmentations. + + If rescale is False, then returned bboxes and masks will fit the scale + of imgs[0]. + """ + if self.with_semantic: + semantic_feats = [ + self.semantic_head(feat)[1] + for feat in self.extract_feats(imgs) + ] + else: + semantic_feats = [None] * len(img_metas) + + # recompute feats to save memory + proposal_list = self.aug_test_rpn( + self.extract_feats(imgs), img_metas, self.test_cfg.rpn) + + rcnn_test_cfg = self.test_cfg.rcnn + aug_bboxes = [] + aug_scores = [] + for x, img_meta, semantic in zip( + self.extract_feats(imgs), img_metas, semantic_feats): + # only one image in the batch + img_shape = img_meta[0]['img_shape'] + scale_factor = img_meta[0]['scale_factor'] + flip = img_meta[0]['flip'] + + proposals = bbox_mapping(proposal_list[0][:, :4], img_shape, + scale_factor, flip) + # "ms" in variable names means multi-stage + ms_scores = [] + + rois = bbox2roi([proposals]) + for i in range(self.num_stages): + bbox_head = self.bbox_head[i] + cls_score, bbox_pred = self._bbox_forward_test( + i, x, rois, semantic_feat=semantic) + ms_scores.append(cls_score) + + if i < self.num_stages - 1: + bbox_label = cls_score.argmax(dim=1) + rois = bbox_head.regress_by_class(rois, bbox_label, + bbox_pred, img_meta[0]) + + cls_score = sum(ms_scores) / float(len(ms_scores)) + bboxes, scores = self.bbox_head[-1].get_det_bboxes( + rois, + cls_score, + bbox_pred, + img_shape, + scale_factor, + rescale=False, + cfg=None) + aug_bboxes.append(bboxes) + aug_scores.append(scores) + + # after merging, bboxes will be rescaled to the original image size + merged_bboxes, merged_scores = merge_aug_bboxes( + aug_bboxes, aug_scores, img_metas, rcnn_test_cfg) + det_bboxes, det_labels = multiclass_nms(merged_bboxes, merged_scores, + rcnn_test_cfg.score_thr, + rcnn_test_cfg.nms, + rcnn_test_cfg.max_per_img) + + bbox_result = bbox2result(det_bboxes, det_labels, + self.bbox_head[-1].num_classes) + + if self.with_mask: + if det_bboxes.shape[0] == 0: + segm_result = [[] + for _ in range(self.mask_head[-1].num_classes - + 1)] + else: + aug_masks = [] + aug_img_metas = [] + for x, img_meta, semantic in zip( + self.extract_feats(imgs), img_metas, semantic_feats): + img_shape = img_meta[0]['img_shape'] + scale_factor = img_meta[0]['scale_factor'] + flip = img_meta[0]['flip'] + _bboxes = bbox_mapping(det_bboxes[:, :4], img_shape, + scale_factor, flip) + mask_rois = bbox2roi([_bboxes]) + mask_feats = self.mask_roi_extractor[-1]( + x[:len(self.mask_roi_extractor[-1].featmap_strides)], + mask_rois) + if self.with_semantic: + semantic_feat = semantic + mask_semantic_feat = self.semantic_roi_extractor( + [semantic_feat], mask_rois) + if mask_semantic_feat.shape[-2:] != mask_feats.shape[ + -2:]: + mask_semantic_feat = F.adaptive_avg_pool2d( + mask_semantic_feat, mask_feats.shape[-2:]) + mask_feats += mask_semantic_feat + last_feat = None + for i in range(self.num_stages): + mask_head = self.mask_head[i] + if self.mask_info_flow: + mask_pred, last_feat = mask_head( + mask_feats, last_feat) + else: + mask_pred = mask_head(mask_feats) + aug_masks.append(mask_pred.sigmoid().cpu().numpy()) + aug_img_metas.append(img_meta) + merged_masks = merge_aug_masks(aug_masks, aug_img_metas, + self.test_cfg.rcnn) + + ori_shape = img_metas[0][0]['ori_shape'] + segm_result = self.mask_head[-1].get_seg_masks( + merged_masks, + det_bboxes, + det_labels, + rcnn_test_cfg, + ori_shape, + scale_factor=1.0, + rescale=False) + return bbox_result, segm_result + else: + return bbox_result diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/mask_rcnn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/mask_rcnn.py new file mode 100644 index 000000000..becfdad53 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/mask_rcnn.py @@ -0,0 +1,31 @@ +from ..registry import DETECTORS +from .two_stage import TwoStageDetector + + +@DETECTORS.register_module +class MaskRCNN(TwoStageDetector): + + def __init__(self, + backbone, + rpn_head, + bbox_roi_extractor, + bbox_head, + mask_roi_extractor, + mask_head, + train_cfg, + test_cfg, + neck=None, + shared_head=None, + pretrained=None): + super(MaskRCNN, self).__init__( + backbone=backbone, + neck=neck, + shared_head=shared_head, + rpn_head=rpn_head, + bbox_roi_extractor=bbox_roi_extractor, + bbox_head=bbox_head, + mask_roi_extractor=mask_roi_extractor, + mask_head=mask_head, + train_cfg=train_cfg, + test_cfg=test_cfg, + pretrained=pretrained) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/mask_scoring_rcnn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/mask_scoring_rcnn.py new file mode 100644 index 000000000..f184c453b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/mask_scoring_rcnn.py @@ -0,0 +1,200 @@ +import torch + +from mmdet.core import bbox2roi, build_assigner, build_sampler +from .. import builder +from ..registry import DETECTORS +from .two_stage import TwoStageDetector + + +@DETECTORS.register_module +class MaskScoringRCNN(TwoStageDetector): + """Mask Scoring RCNN. + + https://arxiv.org/abs/1903.00241 + """ + + def __init__(self, + backbone, + rpn_head, + bbox_roi_extractor, + bbox_head, + mask_roi_extractor, + mask_head, + train_cfg, + test_cfg, + neck=None, + shared_head=None, + mask_iou_head=None, + pretrained=None): + super(MaskScoringRCNN, self).__init__( + backbone=backbone, + neck=neck, + shared_head=shared_head, + rpn_head=rpn_head, + bbox_roi_extractor=bbox_roi_extractor, + bbox_head=bbox_head, + mask_roi_extractor=mask_roi_extractor, + mask_head=mask_head, + train_cfg=train_cfg, + test_cfg=test_cfg, + pretrained=pretrained) + + self.mask_iou_head = builder.build_head(mask_iou_head) + self.mask_iou_head.init_weights() + + def forward_dummy(self, img): + raise NotImplementedError + + # TODO: refactor forward_train in two stage to reduce code redundancy + def forward_train(self, + img, + img_meta, + gt_bboxes, + gt_labels, + gt_bboxes_ignore=None, + gt_masks=None, + proposals=None): + x = self.extract_feat(img) + + losses = dict() + + # RPN forward and loss + if self.with_rpn: + rpn_outs = self.rpn_head(x) + rpn_loss_inputs = rpn_outs + (gt_bboxes, img_meta, + self.train_cfg.rpn) + rpn_losses = self.rpn_head.loss( + *rpn_loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) + losses.update(rpn_losses) + + proposal_cfg = self.train_cfg.get('rpn_proposal', + self.test_cfg.rpn) + proposal_inputs = rpn_outs + (img_meta, proposal_cfg) + proposal_list = self.rpn_head.get_bboxes(*proposal_inputs) + else: + proposal_list = proposals + + # assign gts and sample proposals + if self.with_bbox or self.with_mask: + bbox_assigner = build_assigner(self.train_cfg.rcnn.assigner) + bbox_sampler = build_sampler( + self.train_cfg.rcnn.sampler, context=self) + num_imgs = img.size(0) + if gt_bboxes_ignore is None: + gt_bboxes_ignore = [None for _ in range(num_imgs)] + sampling_results = [] + for i in range(num_imgs): + assign_result = bbox_assigner.assign(proposal_list[i], + gt_bboxes[i], + gt_bboxes_ignore[i], + gt_labels[i]) + sampling_result = bbox_sampler.sample( + assign_result, + proposal_list[i], + gt_bboxes[i], + gt_labels[i], + feats=[lvl_feat[i][None] for lvl_feat in x]) + sampling_results.append(sampling_result) + + # bbox head forward and loss + if self.with_bbox: + rois = bbox2roi([res.bboxes for res in sampling_results]) + # TODO: a more flexible way to decide which feature maps to use + bbox_feats = self.bbox_roi_extractor( + x[:self.bbox_roi_extractor.num_inputs], rois) + if self.with_shared_head: + bbox_feats = self.shared_head(bbox_feats) + cls_score, bbox_pred = self.bbox_head(bbox_feats) + + bbox_targets = self.bbox_head.get_target(sampling_results, + gt_bboxes, gt_labels, + self.train_cfg.rcnn) + loss_bbox = self.bbox_head.loss(cls_score, bbox_pred, + *bbox_targets) + losses.update(loss_bbox) + + # mask head forward and loss + if self.with_mask: + if not self.share_roi_extractor: + pos_rois = bbox2roi( + [res.pos_bboxes for res in sampling_results]) + mask_feats = self.mask_roi_extractor( + x[:self.mask_roi_extractor.num_inputs], pos_rois) + if self.with_shared_head: + mask_feats = self.shared_head(mask_feats) + else: + pos_inds = [] + device = bbox_feats.device + for res in sampling_results: + pos_inds.append( + torch.ones( + res.pos_bboxes.shape[0], + device=device, + dtype=torch.uint8)) + pos_inds.append( + torch.zeros( + res.neg_bboxes.shape[0], + device=device, + dtype=torch.uint8)) + pos_inds = torch.cat(pos_inds) + mask_feats = bbox_feats[pos_inds] + mask_pred = self.mask_head(mask_feats) + + mask_targets = self.mask_head.get_target(sampling_results, + gt_masks, + self.train_cfg.rcnn) + pos_labels = torch.cat( + [res.pos_gt_labels for res in sampling_results]) + loss_mask = self.mask_head.loss(mask_pred, mask_targets, + pos_labels) + losses.update(loss_mask) + + # mask iou head forward and loss + pos_mask_pred = mask_pred[range(mask_pred.size(0)), pos_labels] + mask_iou_pred = self.mask_iou_head(mask_feats, pos_mask_pred) + pos_mask_iou_pred = mask_iou_pred[range(mask_iou_pred.size(0)), + pos_labels] + mask_iou_targets = self.mask_iou_head.get_target( + sampling_results, gt_masks, pos_mask_pred, mask_targets, + self.train_cfg.rcnn) + loss_mask_iou = self.mask_iou_head.loss(pos_mask_iou_pred, + mask_iou_targets) + losses.update(loss_mask_iou) + return losses + + def simple_test_mask(self, + x, + img_meta, + det_bboxes, + det_labels, + rescale=False): + # image shape of the first image in the batch (only one) + ori_shape = img_meta[0]['ori_shape'] + scale_factor = img_meta[0]['scale_factor'] + + if det_bboxes.shape[0] == 0: + segm_result = [[] for _ in range(self.mask_head.num_classes - 1)] + mask_scores = [[] for _ in range(self.mask_head.num_classes - 1)] + else: + # if det_bboxes is rescaled to the original image size, we need to + # rescale it back to the testing scale to obtain RoIs. + _bboxes = ( + det_bboxes[:, :4] * scale_factor if rescale else det_bboxes) + mask_rois = bbox2roi([_bboxes]) + mask_feats = self.mask_roi_extractor( + x[:len(self.mask_roi_extractor.featmap_strides)], mask_rois) + if self.with_shared_head: + mask_feats = self.shared_head(mask_feats) + mask_pred = self.mask_head(mask_feats) + segm_result = self.mask_head.get_seg_masks(mask_pred, _bboxes, + det_labels, + self.test_cfg.rcnn, + ori_shape, scale_factor, + rescale) + # get mask scores with mask iou head + mask_iou_pred = self.mask_iou_head( + mask_feats, mask_pred[range(det_labels.size(0)), + det_labels + 1]) + mask_scores = self.mask_iou_head.get_mask_scores( + mask_iou_pred, det_bboxes, det_labels) + return segm_result, mask_scores diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/reppoints_detector.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/reppoints_detector.py new file mode 100644 index 000000000..53d698f1f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/reppoints_detector.py @@ -0,0 +1,81 @@ +import torch + +from mmdet.core import bbox2result, bbox_mapping_back, multiclass_nms +from ..registry import DETECTORS +from .single_stage import SingleStageDetector + + +@DETECTORS.register_module +class RepPointsDetector(SingleStageDetector): + """RepPoints: Point Set Representation for Object Detection. + + This detector is the implementation of: + - RepPoints detector (https://arxiv.org/pdf/1904.11490) + """ + + def __init__(self, + backbone, + neck, + bbox_head, + train_cfg=None, + test_cfg=None, + pretrained=None): + super(RepPointsDetector, + self).__init__(backbone, neck, bbox_head, train_cfg, test_cfg, + pretrained) + + def merge_aug_results(self, aug_bboxes, aug_scores, img_metas): + """Merge augmented detection bboxes and scores. + + Args: + aug_bboxes (list[Tensor]): shape (n, 4*#class) + aug_scores (list[Tensor] or None): shape (n, #class) + img_shapes (list[Tensor]): shape (3, ). + + Returns: + tuple: (bboxes, scores) + """ + recovered_bboxes = [] + for bboxes, img_info in zip(aug_bboxes, img_metas): + img_shape = img_info[0]['img_shape'] + scale_factor = img_info[0]['scale_factor'] + flip = img_info[0]['flip'] + bboxes = bbox_mapping_back(bboxes, img_shape, scale_factor, flip) + recovered_bboxes.append(bboxes) + bboxes = torch.cat(recovered_bboxes, dim=0) + if aug_scores is None: + return bboxes + else: + scores = torch.cat(aug_scores, dim=0) + return bboxes, scores + + def aug_test(self, imgs, img_metas, rescale=False): + # recompute feats to save memory + feats = self.extract_feats(imgs) + + aug_bboxes = [] + aug_scores = [] + for x, img_meta in zip(feats, img_metas): + # only one image in the batch + outs = self.bbox_head(x) + bbox_inputs = outs + (img_meta, self.test_cfg, False, False) + det_bboxes, det_scores = self.bbox_head.get_bboxes(*bbox_inputs)[0] + aug_bboxes.append(det_bboxes) + aug_scores.append(det_scores) + + # after merging, bboxes will be rescaled to the original image size + merged_bboxes, merged_scores = self.merge_aug_results( + aug_bboxes, aug_scores, img_metas) + det_bboxes, det_labels = multiclass_nms(merged_bboxes, merged_scores, + self.test_cfg.score_thr, + self.test_cfg.nms, + self.test_cfg.max_per_img) + + if rescale: + _det_bboxes = det_bboxes + else: + _det_bboxes = det_bboxes.clone() + _det_bboxes[:, :4] *= img_metas[0][0]['scale_factor'] + bbox_results = bbox2result(_det_bboxes, det_labels, + self.bbox_head.num_classes) + return bbox_results diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/retinanet.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/retinanet.py new file mode 100644 index 000000000..7c93d7419 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/retinanet.py @@ -0,0 +1,16 @@ +from ..registry import DETECTORS +from .single_stage import SingleStageDetector + + +@DETECTORS.register_module +class RetinaNet(SingleStageDetector): + + def __init__(self, + backbone, + neck, + bbox_head, + train_cfg=None, + test_cfg=None, + pretrained=None): + super(RetinaNet, self).__init__(backbone, neck, bbox_head, train_cfg, + test_cfg, pretrained) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/rpn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/rpn.py new file mode 100644 index 000000000..fafee4fc2 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/rpn.py @@ -0,0 +1,97 @@ +import mmcv + +from mmdet.core import bbox_mapping, tensor2imgs +from .. import builder +from ..registry import DETECTORS +from .base import BaseDetector +from .test_mixins import RPNTestMixin + + +@DETECTORS.register_module +class RPN(BaseDetector, RPNTestMixin): + + def __init__(self, + backbone, + neck, + rpn_head, + train_cfg, + test_cfg, + pretrained=None): + super(RPN, self).__init__() + self.backbone = builder.build_backbone(backbone) + self.neck = builder.build_neck(neck) if neck is not None else None + self.rpn_head = builder.build_head(rpn_head) + self.train_cfg = train_cfg + self.test_cfg = test_cfg + self.init_weights(pretrained=pretrained) + + def init_weights(self, pretrained=None): + super(RPN, self).init_weights(pretrained) + self.backbone.init_weights(pretrained=pretrained) + if self.with_neck: + self.neck.init_weights() + self.rpn_head.init_weights() + + def extract_feat(self, img): + x = self.backbone(img) + if self.with_neck: + x = self.neck(x) + return x + + def forward_dummy(self, img): + x = self.extract_feat(img) + rpn_outs = self.rpn_head(x) + return rpn_outs + + def forward_train(self, + img, + img_meta, + gt_bboxes=None, + gt_bboxes_ignore=None): + if self.train_cfg.rpn.get('debug', False): + self.rpn_head.debug_imgs = tensor2imgs(img) + + x = self.extract_feat(img) + rpn_outs = self.rpn_head(x) + + rpn_loss_inputs = rpn_outs + (gt_bboxes, img_meta, self.train_cfg.rpn) + losses = self.rpn_head.loss( + *rpn_loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) + return losses + + def simple_test(self, img, img_meta, rescale=False): + x = self.extract_feat(img) + proposal_list = self.simple_test_rpn(x, img_meta, self.test_cfg.rpn) + if rescale: + for proposals, meta in zip(proposal_list, img_meta): + proposals[:, :4] /= meta['scale_factor'] + # TODO: remove this restriction + return proposal_list[0].cpu().numpy() + + def aug_test(self, imgs, img_metas, rescale=False): + proposal_list = self.aug_test_rpn( + self.extract_feats(imgs), img_metas, self.test_cfg.rpn) + if not rescale: + for proposals, img_meta in zip(proposal_list, img_metas[0]): + img_shape = img_meta['img_shape'] + scale_factor = img_meta['scale_factor'] + flip = img_meta['flip'] + proposals[:, :4] = bbox_mapping(proposals[:, :4], img_shape, + scale_factor, flip) + # TODO: remove this restriction + return proposal_list[0].cpu().numpy() + + def show_result(self, data, result, dataset=None, top_k=20): + """Show RPN proposals on the image. + + Although we assume batch size is 1, this method supports arbitrary + batch size. + """ + img_tensor = data['img'][0] + img_metas = data['img_meta'][0].data[0] + imgs = tensor2imgs(img_tensor, **img_metas[0]['img_norm_cfg']) + assert len(imgs) == len(img_metas) + for img, img_meta in zip(imgs, img_metas): + h, w, _ = img_meta['img_shape'] + img_show = img[:h, :w, :] + mmcv.imshow_bboxes(img_show, result, top_k=top_k) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage.py new file mode 100644 index 000000000..b25af7b82 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage.py @@ -0,0 +1,86 @@ +import torch.nn as nn + +from mmdet.core import bbox2result +from .. import builder +from ..registry import DETECTORS +from .base import BaseDetector + + +@DETECTORS.register_module +class SingleStageDetector(BaseDetector): + """Base class for single-stage detectors. + + Single-stage detectors directly and densely predict bounding boxes on the + output features of the backbone+neck. + """ + + def __init__(self, + backbone, + neck=None, + bbox_head=None, + train_cfg=None, + test_cfg=None, + pretrained=None): + super(SingleStageDetector, self).__init__() + self.backbone = builder.build_backbone(backbone) + if neck is not None: + self.neck = builder.build_neck(neck) + self.bbox_head = builder.build_head(bbox_head) + self.train_cfg = train_cfg + self.test_cfg = test_cfg + self.init_weights(pretrained=pretrained) + + def init_weights(self, pretrained=None): + super(SingleStageDetector, self).init_weights(pretrained) + self.backbone.init_weights(pretrained=pretrained) + if self.with_neck: + if isinstance(self.neck, nn.Sequential): + for m in self.neck: + m.init_weights() + else: + self.neck.init_weights() + self.bbox_head.init_weights() + + def extract_feat(self, img): + """Directly extract features from the backbone+neck + """ + x = self.backbone(img) + if self.with_neck: + x = self.neck(x) + return x + + def forward_dummy(self, img): + """Used for computing network flops. + + See `mmedetection/tools/get_flops.py` + """ + x = self.extract_feat(img) + outs = self.bbox_head(x) + return outs + + def forward_train(self, + img, + img_metas, + gt_bboxes, + gt_labels, + gt_bboxes_ignore=None): + x = self.extract_feat(img) + outs = self.bbox_head(x) + loss_inputs = outs + (gt_bboxes, gt_labels, img_metas, self.train_cfg) + losses = self.bbox_head.loss( + *loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) + return losses + + def simple_test(self, img, img_meta, rescale=False): + x = self.extract_feat(img) + outs = self.bbox_head(x) + bbox_inputs = outs + (img_meta, self.test_cfg, rescale) + bbox_list = self.bbox_head.get_bboxes(*bbox_inputs) + bbox_results = [ + bbox2result(det_bboxes, det_labels, self.bbox_head.num_classes) + for det_bboxes, det_labels in bbox_list + ] + return bbox_results[0] + + def aug_test(self, imgs, img_metas, rescale=False): + raise NotImplementedError diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage_ins.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage_ins.py new file mode 100644 index 000000000..773d5d22e --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage_ins.py @@ -0,0 +1,96 @@ +import torch.nn as nn + +from mmdet.core import bbox2result +from .. import builder +from ..registry import DETECTORS +from .base import BaseDetector + + +@DETECTORS.register_module +class SingleStageInsDetector(BaseDetector): + + def __init__(self, + backbone, + neck=None, + bbox_head=None, + mask_feat_head=None, + train_cfg=None, + test_cfg=None, + pretrained=None): + super(SingleStageInsDetector, self).__init__() + self.backbone = builder.build_backbone(backbone) + if neck is not None: + self.neck = builder.build_neck(neck) + if mask_feat_head is not None: + self.mask_feat_head = builder.build_head(mask_feat_head) + + self.bbox_head = builder.build_head(bbox_head) + self.train_cfg = train_cfg + self.test_cfg = test_cfg + self.init_weights(pretrained=pretrained) + + def init_weights(self, pretrained=None): + super(SingleStageInsDetector, self).init_weights(pretrained) + self.backbone.init_weights(pretrained=pretrained) + if self.with_neck: + if isinstance(self.neck, nn.Sequential): + for m in self.neck: + m.init_weights() + else: + self.neck.init_weights() + if self.with_mask_feat_head: + if isinstance(self.mask_feat_head, nn.Sequential): + for m in self.mask_feat_head: + m.init_weights() + else: + self.mask_feat_head.init_weights() + self.bbox_head.init_weights() + + def extract_feat(self, img): + x = self.backbone(img) + if self.with_neck: + x = self.neck(x) + return x + + def forward_dummy(self, img): + x = self.extract_feat(img) + outs = self.bbox_head(x) + return outs + + def forward_train(self, + img, + img_metas, + gt_bboxes, + gt_labels, + gt_bboxes_ignore=None, + gt_masks=None): + x = self.extract_feat(img) + outs = self.bbox_head(x) + + if self.with_mask_feat_head: + mask_feat_pred = self.mask_feat_head( + x[self.mask_feat_head. + start_level:self.mask_feat_head.end_level + 1]) + loss_inputs = outs + (mask_feat_pred, gt_bboxes, gt_labels, gt_masks, img_metas, self.train_cfg) + else: + loss_inputs = outs + (gt_bboxes, gt_labels, gt_masks, img_metas, self.train_cfg) + losses = self.bbox_head.loss( + *loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) + return losses + + def simple_test(self, img, img_meta, rescale=False): + x = self.extract_feat(img) + outs = self.bbox_head(x, eval=True) + + if self.with_mask_feat_head: + mask_feat_pred = self.mask_feat_head( + x[self.mask_feat_head. + start_level:self.mask_feat_head.end_level + 1]) + seg_inputs = outs + (mask_feat_pred, img_meta, self.test_cfg, rescale) + else: + seg_inputs = outs + (img_meta, self.test_cfg, rescale) + seg_result = self.bbox_head.get_seg(*seg_inputs) + return seg_result + + def aug_test(self, imgs, img_metas, rescale=False): + raise NotImplementedError diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/solo.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/solo.py new file mode 100644 index 000000000..cd0df7486 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/solo.py @@ -0,0 +1,16 @@ +from .single_stage_ins import SingleStageInsDetector +from ..registry import DETECTORS + + +@DETECTORS.register_module +class SOLO(SingleStageInsDetector): + + def __init__(self, + backbone, + neck, + bbox_head, + train_cfg=None, + test_cfg=None, + pretrained=None): + super(SOLO, self).__init__(backbone, neck, bbox_head, None, train_cfg, + test_cfg, pretrained) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/solov2.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/solov2.py new file mode 100644 index 000000000..02dac9646 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/solov2.py @@ -0,0 +1,17 @@ +from .single_stage_ins import SingleStageInsDetector +from ..registry import DETECTORS + + +@DETECTORS.register_module +class SOLOv2(SingleStageInsDetector): + + def __init__(self, + backbone, + neck, + bbox_head, + mask_feat_head, + train_cfg=None, + test_cfg=None, + pretrained=None): + super(SOLOv2, self).__init__(backbone, neck, bbox_head, mask_feat_head, train_cfg, + test_cfg, pretrained) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/test_mixins.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/test_mixins.py new file mode 100644 index 000000000..84a96d167 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/test_mixins.py @@ -0,0 +1,266 @@ +import logging +import sys + +import torch + +from mmdet.core import (bbox2roi, bbox_mapping, merge_aug_bboxes, + merge_aug_masks, merge_aug_proposals, multiclass_nms) + +logger = logging.getLogger(__name__) + +if sys.version_info >= (3, 7): + from mmdet.utils.contextmanagers import completed + + +class RPNTestMixin(object): + + if sys.version_info >= (3, 7): + + async def async_test_rpn(self, x, img_meta, rpn_test_cfg): + sleep_interval = rpn_test_cfg.pop("async_sleep_interval", 0.025) + async with completed( + __name__, "rpn_head_forward", + sleep_interval=sleep_interval): + rpn_outs = self.rpn_head(x) + + proposal_inputs = rpn_outs + (img_meta, rpn_test_cfg) + + proposal_list = self.rpn_head.get_bboxes(*proposal_inputs) + return proposal_list + + def simple_test_rpn(self, x, img_meta, rpn_test_cfg): + rpn_outs = self.rpn_head(x) + proposal_inputs = rpn_outs + (img_meta, rpn_test_cfg) + proposal_list = self.rpn_head.get_bboxes(*proposal_inputs) + return proposal_list + + def aug_test_rpn(self, feats, img_metas, rpn_test_cfg): + imgs_per_gpu = len(img_metas[0]) + aug_proposals = [[] for _ in range(imgs_per_gpu)] + for x, img_meta in zip(feats, img_metas): + proposal_list = self.simple_test_rpn(x, img_meta, rpn_test_cfg) + for i, proposals in enumerate(proposal_list): + aug_proposals[i].append(proposals) + # reorganize the order of 'img_metas' to match the dimensions + # of 'aug_proposals' + aug_img_metas = [] + for i in range(imgs_per_gpu): + aug_img_meta = [] + for j in range(len(img_metas)): + aug_img_meta.append(img_metas[j][i]) + aug_img_metas.append(aug_img_meta) + # after merging, proposals will be rescaled to the original image size + merged_proposals = [ + merge_aug_proposals(proposals, aug_img_meta, rpn_test_cfg) + for proposals, aug_img_meta in zip(aug_proposals, aug_img_metas) + ] + return merged_proposals + + +class BBoxTestMixin(object): + + if sys.version_info >= (3, 7): + + async def async_test_bboxes(self, + x, + img_meta, + proposals, + rcnn_test_cfg, + rescale=False, + bbox_semaphore=None, + global_lock=None): + """Async test only det bboxes without augmentation.""" + rois = bbox2roi(proposals) + roi_feats = self.bbox_roi_extractor( + x[:len(self.bbox_roi_extractor.featmap_strides)], rois) + if self.with_shared_head: + roi_feats = self.shared_head(roi_feats) + sleep_interval = rcnn_test_cfg.get("async_sleep_interval", 0.017) + + async with completed( + __name__, "bbox_head_forward", + sleep_interval=sleep_interval): + cls_score, bbox_pred = self.bbox_head(roi_feats) + + img_shape = img_meta[0]['img_shape'] + scale_factor = img_meta[0]['scale_factor'] + det_bboxes, det_labels = self.bbox_head.get_det_bboxes( + rois, + cls_score, + bbox_pred, + img_shape, + scale_factor, + rescale=rescale, + cfg=rcnn_test_cfg) + return det_bboxes, det_labels + + def simple_test_bboxes(self, + x, + img_meta, + proposals, + rcnn_test_cfg, + rescale=False): + """Test only det bboxes without augmentation.""" + rois = bbox2roi(proposals) + roi_feats = self.bbox_roi_extractor( + x[:len(self.bbox_roi_extractor.featmap_strides)], rois) + if self.with_shared_head: + roi_feats = self.shared_head(roi_feats) + cls_score, bbox_pred = self.bbox_head(roi_feats) + img_shape = img_meta[0]['img_shape'] + scale_factor = img_meta[0]['scale_factor'] + det_bboxes, det_labels = self.bbox_head.get_det_bboxes( + rois, + cls_score, + bbox_pred, + img_shape, + scale_factor, + rescale=rescale, + cfg=rcnn_test_cfg) + return det_bboxes, det_labels + + def aug_test_bboxes(self, feats, img_metas, proposal_list, rcnn_test_cfg): + aug_bboxes = [] + aug_scores = [] + for x, img_meta in zip(feats, img_metas): + # only one image in the batch + img_shape = img_meta[0]['img_shape'] + scale_factor = img_meta[0]['scale_factor'] + flip = img_meta[0]['flip'] + # TODO more flexible + proposals = bbox_mapping(proposal_list[0][:, :4], img_shape, + scale_factor, flip) + rois = bbox2roi([proposals]) + # recompute feature maps to save GPU memory + roi_feats = self.bbox_roi_extractor( + x[:len(self.bbox_roi_extractor.featmap_strides)], rois) + if self.with_shared_head: + roi_feats = self.shared_head(roi_feats) + cls_score, bbox_pred = self.bbox_head(roi_feats) + bboxes, scores = self.bbox_head.get_det_bboxes( + rois, + cls_score, + bbox_pred, + img_shape, + scale_factor, + rescale=False, + cfg=None) + aug_bboxes.append(bboxes) + aug_scores.append(scores) + # after merging, bboxes will be rescaled to the original image size + merged_bboxes, merged_scores = merge_aug_bboxes( + aug_bboxes, aug_scores, img_metas, rcnn_test_cfg) + det_bboxes, det_labels = multiclass_nms(merged_bboxes, merged_scores, + rcnn_test_cfg.score_thr, + rcnn_test_cfg.nms, + rcnn_test_cfg.max_per_img) + return det_bboxes, det_labels + + +class MaskTestMixin(object): + + if sys.version_info >= (3, 7): + + async def async_test_mask(self, + x, + img_meta, + det_bboxes, + det_labels, + rescale=False, + mask_test_cfg=None): + # image shape of the first image in the batch (only one) + ori_shape = img_meta[0]['ori_shape'] + scale_factor = img_meta[0]['scale_factor'] + if det_bboxes.shape[0] == 0: + segm_result = [[] + for _ in range(self.mask_head.num_classes - 1)] + else: + _bboxes = ( + det_bboxes[:, :4] * + scale_factor if rescale else det_bboxes) + mask_rois = bbox2roi([_bboxes]) + mask_feats = self.mask_roi_extractor( + x[:len(self.mask_roi_extractor.featmap_strides)], + mask_rois) + + if self.with_shared_head: + mask_feats = self.shared_head(mask_feats) + if mask_test_cfg and mask_test_cfg.get('async_sleep_interval'): + sleep_interval = mask_test_cfg['async_sleep_interval'] + else: + sleep_interval = 0.035 + async with completed( + __name__, + "mask_head_forward", + sleep_interval=sleep_interval): + mask_pred = self.mask_head(mask_feats) + segm_result = self.mask_head.get_seg_masks( + mask_pred, _bboxes, det_labels, self.test_cfg.rcnn, + ori_shape, scale_factor, rescale) + return segm_result + + def simple_test_mask(self, + x, + img_meta, + det_bboxes, + det_labels, + rescale=False): + # image shape of the first image in the batch (only one) + ori_shape = img_meta[0]['ori_shape'] + scale_factor = img_meta[0]['scale_factor'] + if det_bboxes.shape[0] == 0: + segm_result = [[] for _ in range(self.mask_head.num_classes - 1)] + else: + # if det_bboxes is rescaled to the original image size, we need to + # rescale it back to the testing scale to obtain RoIs. + if rescale and not isinstance(scale_factor, float): + scale_factor = torch.from_numpy(scale_factor).to( + det_bboxes.device) + _bboxes = ( + det_bboxes[:, :4] * scale_factor if rescale else det_bboxes) + mask_rois = bbox2roi([_bboxes]) + mask_feats = self.mask_roi_extractor( + x[:len(self.mask_roi_extractor.featmap_strides)], mask_rois) + if self.with_shared_head: + mask_feats = self.shared_head(mask_feats) + mask_pred = self.mask_head(mask_feats) + segm_result = self.mask_head.get_seg_masks(mask_pred, _bboxes, + det_labels, + self.test_cfg.rcnn, + ori_shape, scale_factor, + rescale) + return segm_result + + def aug_test_mask(self, feats, img_metas, det_bboxes, det_labels): + if det_bboxes.shape[0] == 0: + segm_result = [[] for _ in range(self.mask_head.num_classes - 1)] + else: + aug_masks = [] + for x, img_meta in zip(feats, img_metas): + img_shape = img_meta[0]['img_shape'] + scale_factor = img_meta[0]['scale_factor'] + flip = img_meta[0]['flip'] + _bboxes = bbox_mapping(det_bboxes[:, :4], img_shape, + scale_factor, flip) + mask_rois = bbox2roi([_bboxes]) + mask_feats = self.mask_roi_extractor( + x[:len(self.mask_roi_extractor.featmap_strides)], + mask_rois) + if self.with_shared_head: + mask_feats = self.shared_head(mask_feats) + mask_pred = self.mask_head(mask_feats) + # convert to numpy array to save memory + aug_masks.append(mask_pred.sigmoid().cpu().numpy()) + merged_masks = merge_aug_masks(aug_masks, img_metas, + self.test_cfg.rcnn) + + ori_shape = img_metas[0][0]['ori_shape'] + segm_result = self.mask_head.get_seg_masks( + merged_masks, + det_bboxes, + det_labels, + self.test_cfg.rcnn, + ori_shape, + scale_factor=1.0, + rescale=False) + return segm_result diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/two_stage.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/two_stage.py new file mode 100644 index 000000000..962e0cb51 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/two_stage.py @@ -0,0 +1,346 @@ +import torch +import torch.nn as nn + +from mmdet.core import bbox2result, bbox2roi, build_assigner, build_sampler +from .. import builder +from ..registry import DETECTORS +from .base import BaseDetector +from .test_mixins import BBoxTestMixin, MaskTestMixin, RPNTestMixin + + +@DETECTORS.register_module +class TwoStageDetector(BaseDetector, RPNTestMixin, BBoxTestMixin, + MaskTestMixin): + """Base class for two-stage detectors. + + Two-stage detectors typically consisting of a region proposal network and a + task-specific regression head. + """ + + def __init__(self, + backbone, + neck=None, + shared_head=None, + rpn_head=None, + bbox_roi_extractor=None, + bbox_head=None, + mask_roi_extractor=None, + mask_head=None, + train_cfg=None, + test_cfg=None, + pretrained=None): + super(TwoStageDetector, self).__init__() + self.backbone = builder.build_backbone(backbone) + + if neck is not None: + self.neck = builder.build_neck(neck) + + if shared_head is not None: + self.shared_head = builder.build_shared_head(shared_head) + + if rpn_head is not None: + self.rpn_head = builder.build_head(rpn_head) + + if bbox_head is not None: + self.bbox_roi_extractor = builder.build_roi_extractor( + bbox_roi_extractor) + self.bbox_head = builder.build_head(bbox_head) + + if mask_head is not None: + if mask_roi_extractor is not None: + self.mask_roi_extractor = builder.build_roi_extractor( + mask_roi_extractor) + self.share_roi_extractor = False + else: + self.share_roi_extractor = True + self.mask_roi_extractor = self.bbox_roi_extractor + self.mask_head = builder.build_head(mask_head) + + self.train_cfg = train_cfg + self.test_cfg = test_cfg + + self.init_weights(pretrained=pretrained) + + @property + def with_rpn(self): + return hasattr(self, 'rpn_head') and self.rpn_head is not None + + def init_weights(self, pretrained=None): + super(TwoStageDetector, self).init_weights(pretrained) + self.backbone.init_weights(pretrained=pretrained) + if self.with_neck: + if isinstance(self.neck, nn.Sequential): + for m in self.neck: + m.init_weights() + else: + self.neck.init_weights() + if self.with_shared_head: + self.shared_head.init_weights(pretrained=pretrained) + if self.with_rpn: + self.rpn_head.init_weights() + if self.with_bbox: + self.bbox_roi_extractor.init_weights() + self.bbox_head.init_weights() + if self.with_mask: + self.mask_head.init_weights() + if not self.share_roi_extractor: + self.mask_roi_extractor.init_weights() + + def extract_feat(self, img): + """Directly extract features from the backbone+neck + """ + x = self.backbone(img) + if self.with_neck: + x = self.neck(x) + return x + + def forward_dummy(self, img): + """Used for computing network flops. + + See `mmedetection/tools/get_flops.py` + """ + outs = () + # backbone + x = self.extract_feat(img) + # rpn + if self.with_rpn: + rpn_outs = self.rpn_head(x) + outs = outs + (rpn_outs, ) + proposals = torch.randn(1000, 4).cuda() + # bbox head + rois = bbox2roi([proposals]) + if self.with_bbox: + bbox_feats = self.bbox_roi_extractor( + x[:self.bbox_roi_extractor.num_inputs], rois) + if self.with_shared_head: + bbox_feats = self.shared_head(bbox_feats) + cls_score, bbox_pred = self.bbox_head(bbox_feats) + outs = outs + (cls_score, bbox_pred) + # mask head + if self.with_mask: + mask_rois = rois[:100] + mask_feats = self.mask_roi_extractor( + x[:self.mask_roi_extractor.num_inputs], mask_rois) + if self.with_shared_head: + mask_feats = self.shared_head(mask_feats) + mask_pred = self.mask_head(mask_feats) + outs = outs + (mask_pred, ) + return outs + + def forward_train(self, + img, + img_meta, + gt_bboxes, + gt_labels, + gt_bboxes_ignore=None, + gt_masks=None, + proposals=None): + """ + Args: + img (Tensor): of shape (N, C, H, W) encoding input images. + Typically these should be mean centered and std scaled. + + img_meta (list[dict]): list of image info dict where each dict has: + 'img_shape', 'scale_factor', 'flip', and may also contain + 'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'. + For details on the values of these keys see + `mmdet/datasets/pipelines/formatting.py:Collect`. + + gt_bboxes (list[Tensor]): each item are the truth boxes for each + image in [tl_x, tl_y, br_x, br_y] format. + + gt_labels (list[Tensor]): class indices corresponding to each box + + gt_bboxes_ignore (None | list[Tensor]): specify which bounding + boxes can be ignored when computing the loss. + + gt_masks (None | Tensor) : true segmentation masks for each box + used if the architecture supports a segmentation task. + + proposals : override rpn proposals with custom proposals. Use when + `with_rpn` is False. + + Returns: + dict[str, Tensor]: a dictionary of loss components + """ + x = self.extract_feat(img) + + losses = dict() + + # RPN forward and loss + if self.with_rpn: + rpn_outs = self.rpn_head(x) + rpn_loss_inputs = rpn_outs + (gt_bboxes, img_meta, + self.train_cfg.rpn) + rpn_losses = self.rpn_head.loss( + *rpn_loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) + losses.update(rpn_losses) + + proposal_cfg = self.train_cfg.get('rpn_proposal', + self.test_cfg.rpn) + proposal_inputs = rpn_outs + (img_meta, proposal_cfg) + proposal_list = self.rpn_head.get_bboxes(*proposal_inputs) + else: + proposal_list = proposals + + # assign gts and sample proposals + if self.with_bbox or self.with_mask: + bbox_assigner = build_assigner(self.train_cfg.rcnn.assigner) + bbox_sampler = build_sampler( + self.train_cfg.rcnn.sampler, context=self) + num_imgs = img.size(0) + if gt_bboxes_ignore is None: + gt_bboxes_ignore = [None for _ in range(num_imgs)] + sampling_results = [] + for i in range(num_imgs): + assign_result = bbox_assigner.assign(proposal_list[i], + gt_bboxes[i], + gt_bboxes_ignore[i], + gt_labels[i]) + sampling_result = bbox_sampler.sample( + assign_result, + proposal_list[i], + gt_bboxes[i], + gt_labels[i], + feats=[lvl_feat[i][None] for lvl_feat in x]) + sampling_results.append(sampling_result) + + # bbox head forward and loss + if self.with_bbox: + rois = bbox2roi([res.bboxes for res in sampling_results]) + # TODO: a more flexible way to decide which feature maps to use + bbox_feats = self.bbox_roi_extractor( + x[:self.bbox_roi_extractor.num_inputs], rois) + if self.with_shared_head: + bbox_feats = self.shared_head(bbox_feats) + cls_score, bbox_pred = self.bbox_head(bbox_feats) + + bbox_targets = self.bbox_head.get_target(sampling_results, + gt_bboxes, gt_labels, + self.train_cfg.rcnn) + loss_bbox = self.bbox_head.loss(cls_score, bbox_pred, + *bbox_targets) + losses.update(loss_bbox) + + # mask head forward and loss + if self.with_mask: + if not self.share_roi_extractor: + pos_rois = bbox2roi( + [res.pos_bboxes for res in sampling_results]) + mask_feats = self.mask_roi_extractor( + x[:self.mask_roi_extractor.num_inputs], pos_rois) + if self.with_shared_head: + mask_feats = self.shared_head(mask_feats) + else: + pos_inds = [] + device = bbox_feats.device + for res in sampling_results: + pos_inds.append( + torch.ones( + res.pos_bboxes.shape[0], + device=device, + dtype=torch.uint8)) + pos_inds.append( + torch.zeros( + res.neg_bboxes.shape[0], + device=device, + dtype=torch.uint8)) + pos_inds = torch.cat(pos_inds) + mask_feats = bbox_feats[pos_inds] + + if mask_feats.shape[0] > 0: + mask_pred = self.mask_head(mask_feats) + mask_targets = self.mask_head.get_target( + sampling_results, gt_masks, self.train_cfg.rcnn) + pos_labels = torch.cat( + [res.pos_gt_labels for res in sampling_results]) + loss_mask = self.mask_head.loss(mask_pred, mask_targets, + pos_labels) + losses.update(loss_mask) + + return losses + + async def async_simple_test(self, + img, + img_meta, + proposals=None, + rescale=False): + """Async test without augmentation.""" + assert self.with_bbox, "Bbox head must be implemented." + x = self.extract_feat(img) + + if proposals is None: + proposal_list = await self.async_test_rpn(x, img_meta, + self.test_cfg.rpn) + else: + proposal_list = proposals + + det_bboxes, det_labels = await self.async_test_bboxes( + x, img_meta, proposal_list, self.test_cfg.rcnn, rescale=rescale) + bbox_results = bbox2result(det_bboxes, det_labels, + self.bbox_head.num_classes) + + if not self.with_mask: + return bbox_results + else: + segm_results = await self.async_test_mask( + x, + img_meta, + det_bboxes, + det_labels, + rescale=rescale, + mask_test_cfg=self.test_cfg.get('mask')) + return bbox_results, segm_results + + def simple_test(self, img, img_meta, proposals=None, rescale=False): + """Test without augmentation.""" + assert self.with_bbox, "Bbox head must be implemented." + + x = self.extract_feat(img) + + if proposals is None: + proposal_list = self.simple_test_rpn(x, img_meta, + self.test_cfg.rpn) + else: + proposal_list = proposals + + det_bboxes, det_labels = self.simple_test_bboxes( + x, img_meta, proposal_list, self.test_cfg.rcnn, rescale=rescale) + bbox_results = bbox2result(det_bboxes, det_labels, + self.bbox_head.num_classes) + + if not self.with_mask: + return bbox_results + else: + segm_results = self.simple_test_mask( + x, img_meta, det_bboxes, det_labels, rescale=rescale) + return bbox_results, segm_results + + def aug_test(self, imgs, img_metas, rescale=False): + """Test with augmentations. + + If rescale is False, then returned bboxes and masks will fit the scale + of imgs[0]. + """ + # recompute feats to save memory + proposal_list = self.aug_test_rpn( + self.extract_feats(imgs), img_metas, self.test_cfg.rpn) + det_bboxes, det_labels = self.aug_test_bboxes( + self.extract_feats(imgs), img_metas, proposal_list, + self.test_cfg.rcnn) + + if rescale: + _det_bboxes = det_bboxes + else: + _det_bboxes = det_bboxes.clone() + _det_bboxes[:, :4] *= img_metas[0][0]['scale_factor'] + bbox_results = bbox2result(_det_bboxes, det_labels, + self.bbox_head.num_classes) + + # det_bboxes always keep the original scale + if self.with_mask: + segm_results = self.aug_test_mask( + self.extract_feats(imgs), img_metas, det_bboxes, det_labels) + return bbox_results, segm_results + else: + return bbox_results diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/__init__.py new file mode 100644 index 000000000..07731d710 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/__init__.py @@ -0,0 +1,20 @@ +from .accuracy import Accuracy, accuracy +from .balanced_l1_loss import BalancedL1Loss, balanced_l1_loss +from .cross_entropy_loss import (CrossEntropyLoss, binary_cross_entropy, + cross_entropy, mask_cross_entropy) +from .focal_loss import FocalLoss, sigmoid_focal_loss +from .ghm_loss import GHMC, GHMR +from .iou_loss import (BoundedIoULoss, GIoULoss, IoULoss, bounded_iou_loss, + iou_loss) +from .mse_loss import MSELoss, mse_loss +from .smooth_l1_loss import SmoothL1Loss, smooth_l1_loss +from .utils import reduce_loss, weight_reduce_loss, weighted_loss + +__all__ = [ + 'accuracy', 'Accuracy', 'cross_entropy', 'binary_cross_entropy', + 'mask_cross_entropy', 'CrossEntropyLoss', 'sigmoid_focal_loss', + 'FocalLoss', 'smooth_l1_loss', 'SmoothL1Loss', 'balanced_l1_loss', + 'BalancedL1Loss', 'mse_loss', 'MSELoss', 'iou_loss', 'bounded_iou_loss', + 'IoULoss', 'BoundedIoULoss', 'GIoULoss', 'GHMC', 'GHMR', 'reduce_loss', + 'weight_reduce_loss', 'weighted_loss' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/accuracy.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/accuracy.py new file mode 100644 index 000000000..20d0ad8cd --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/accuracy.py @@ -0,0 +1,31 @@ +import torch.nn as nn + + +def accuracy(pred, target, topk=1): + assert isinstance(topk, (int, tuple)) + if isinstance(topk, int): + topk = (topk, ) + return_single = True + else: + return_single = False + + maxk = max(topk) + _, pred_label = pred.topk(maxk, dim=1) + pred_label = pred_label.t() + correct = pred_label.eq(target.view(1, -1).expand_as(pred_label)) + + res = [] + for k in topk: + correct_k = correct[:k].view(-1).float().sum(0, keepdim=True) + res.append(correct_k.mul_(100.0 / pred.size(0))) + return res[0] if return_single else res + + +class Accuracy(nn.Module): + + def __init__(self, topk=(1, )): + super().__init__() + self.topk = topk + + def forward(self, pred, target): + return accuracy(pred, target, self.topk) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/balanced_l1_loss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/balanced_l1_loss.py new file mode 100644 index 000000000..fab60dbc6 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/balanced_l1_loss.py @@ -0,0 +1,69 @@ +import numpy as np +import torch +import torch.nn as nn + +from ..registry import LOSSES +from .utils import weighted_loss + + +@weighted_loss +def balanced_l1_loss(pred, + target, + beta=1.0, + alpha=0.5, + gamma=1.5, + reduction='mean'): + assert beta > 0 + assert pred.size() == target.size() and target.numel() > 0 + + diff = torch.abs(pred - target) + b = np.e**(gamma / alpha) - 1 + loss = torch.where( + diff < beta, alpha / b * + (b * diff + 1) * torch.log(b * diff / beta + 1) - alpha * diff, + gamma * diff + gamma / b - alpha * beta) + + return loss + + +@LOSSES.register_module +class BalancedL1Loss(nn.Module): + """Balanced L1 Loss + + arXiv: https://arxiv.org/pdf/1904.02701.pdf (CVPR 2019) + """ + + def __init__(self, + alpha=0.5, + gamma=1.5, + beta=1.0, + reduction='mean', + loss_weight=1.0): + super(BalancedL1Loss, self).__init__() + self.alpha = alpha + self.gamma = gamma + self.beta = beta + self.reduction = reduction + self.loss_weight = loss_weight + + def forward(self, + pred, + target, + weight=None, + avg_factor=None, + reduction_override=None, + **kwargs): + assert reduction_override in (None, 'none', 'mean', 'sum') + reduction = ( + reduction_override if reduction_override else self.reduction) + loss_bbox = self.loss_weight * balanced_l1_loss( + pred, + target, + weight, + alpha=self.alpha, + gamma=self.gamma, + beta=self.beta, + reduction=reduction, + avg_factor=avg_factor, + **kwargs) + return loss_bbox diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/cross_entropy_loss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/cross_entropy_loss.py new file mode 100644 index 000000000..dd9d4776f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/cross_entropy_loss.py @@ -0,0 +1,103 @@ +import torch +import torch.nn as nn +import torch.nn.functional as F + +from ..registry import LOSSES +from .utils import weight_reduce_loss + + +def cross_entropy(pred, label, weight=None, reduction='mean', avg_factor=None): + # element-wise losses + loss = F.cross_entropy(pred, label, reduction='none') + + # apply weights and do the reduction + if weight is not None: + weight = weight.float() + loss = weight_reduce_loss( + loss, weight=weight, reduction=reduction, avg_factor=avg_factor) + + return loss + + +def _expand_binary_labels(labels, label_weights, label_channels): + bin_labels = labels.new_full((labels.size(0), label_channels), 0) + inds = torch.nonzero(labels >= 1).squeeze() + if inds.numel() > 0: + bin_labels[inds, labels[inds] - 1] = 1 + if label_weights is None: + bin_label_weights = None + else: + bin_label_weights = label_weights.view(-1, 1).expand( + label_weights.size(0), label_channels) + return bin_labels, bin_label_weights + + +def binary_cross_entropy(pred, + label, + weight=None, + reduction='mean', + avg_factor=None): + if pred.dim() != label.dim(): + label, weight = _expand_binary_labels(label, weight, pred.size(-1)) + + # weighted element-wise losses + if weight is not None: + weight = weight.float() + loss = F.binary_cross_entropy_with_logits( + pred, label.float(), weight, reduction='none') + # do the reduction for the weighted loss + loss = weight_reduce_loss(loss, reduction=reduction, avg_factor=avg_factor) + + return loss + + +def mask_cross_entropy(pred, target, label, reduction='mean', avg_factor=None): + # TODO: handle these two reserved arguments + assert reduction == 'mean' and avg_factor is None + num_rois = pred.size()[0] + inds = torch.arange(0, num_rois, dtype=torch.long, device=pred.device) + pred_slice = pred[inds, label].squeeze(1) + return F.binary_cross_entropy_with_logits( + pred_slice, target, reduction='mean')[None] + + +@LOSSES.register_module +class CrossEntropyLoss(nn.Module): + + def __init__(self, + use_sigmoid=False, + use_mask=False, + reduction='mean', + loss_weight=1.0): + super(CrossEntropyLoss, self).__init__() + assert (use_sigmoid is False) or (use_mask is False) + self.use_sigmoid = use_sigmoid + self.use_mask = use_mask + self.reduction = reduction + self.loss_weight = loss_weight + + if self.use_sigmoid: + self.cls_criterion = binary_cross_entropy + elif self.use_mask: + self.cls_criterion = mask_cross_entropy + else: + self.cls_criterion = cross_entropy + + def forward(self, + cls_score, + label, + weight=None, + avg_factor=None, + reduction_override=None, + **kwargs): + assert reduction_override in (None, 'none', 'mean', 'sum') + reduction = ( + reduction_override if reduction_override else self.reduction) + loss_cls = self.loss_weight * self.cls_criterion( + cls_score, + label, + weight, + reduction=reduction, + avg_factor=avg_factor, + **kwargs) + return loss_cls diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/focal_loss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/focal_loss.py new file mode 100644 index 000000000..6b28e1257 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/focal_loss.py @@ -0,0 +1,82 @@ +import torch.nn as nn +import torch.nn.functional as F + +from mmdet.ops import sigmoid_focal_loss as _sigmoid_focal_loss +from ..registry import LOSSES +from .utils import weight_reduce_loss + + +# This method is only for debugging +def py_sigmoid_focal_loss(pred, + target, + weight=None, + gamma=2.0, + alpha=0.25, + reduction='mean', + avg_factor=None): + pred_sigmoid = pred.sigmoid() + target = target.type_as(pred) + pt = (1 - pred_sigmoid) * target + pred_sigmoid * (1 - target) + focal_weight = (alpha * target + (1 - alpha) * + (1 - target)) * pt.pow(gamma) + loss = F.binary_cross_entropy_with_logits( + pred, target, reduction='none') * focal_weight + loss = weight_reduce_loss(loss, weight, reduction, avg_factor) + return loss + + +def sigmoid_focal_loss(pred, + target, + weight=None, + gamma=2.0, + alpha=0.25, + reduction='mean', + avg_factor=None): + # Function.apply does not accept keyword arguments, so the decorator + # "weighted_loss" is not applicable + loss = _sigmoid_focal_loss(pred, target, gamma, alpha) + # TODO: find a proper way to handle the shape of weight + if weight is not None: + weight = weight.view(-1, 1) + loss = weight_reduce_loss(loss, weight, reduction, avg_factor) + return loss + + +@LOSSES.register_module +class FocalLoss(nn.Module): + + def __init__(self, + use_sigmoid=True, + gamma=2.0, + alpha=0.25, + reduction='mean', + loss_weight=1.0): + super(FocalLoss, self).__init__() + assert use_sigmoid is True, 'Only sigmoid focal loss supported now.' + self.use_sigmoid = use_sigmoid + self.gamma = gamma + self.alpha = alpha + self.reduction = reduction + self.loss_weight = loss_weight + + def forward(self, + pred, + target, + weight=None, + avg_factor=None, + reduction_override=None): + assert reduction_override in (None, 'none', 'mean', 'sum') + reduction = ( + reduction_override if reduction_override else self.reduction) + if self.use_sigmoid: + loss_cls = self.loss_weight * sigmoid_focal_loss( + pred, + target, + weight, + gamma=self.gamma, + alpha=self.alpha, + reduction=reduction, + avg_factor=avg_factor) + else: + raise NotImplementedError + return loss_cls diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/ghm_loss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/ghm_loss.py new file mode 100644 index 000000000..e62b9904f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/ghm_loss.py @@ -0,0 +1,171 @@ +import torch +import torch.nn as nn +import torch.nn.functional as F + +from ..registry import LOSSES + + +def _expand_binary_labels(labels, label_weights, label_channels): + bin_labels = labels.new_full((labels.size(0), label_channels), 0) + inds = torch.nonzero(labels >= 1).squeeze() + if inds.numel() > 0: + bin_labels[inds, labels[inds] - 1] = 1 + bin_label_weights = label_weights.view(-1, 1).expand( + label_weights.size(0), label_channels) + return bin_labels, bin_label_weights + + +# TODO: code refactoring to make it consistent with other losses +@LOSSES.register_module +class GHMC(nn.Module): + """GHM Classification Loss. + + Details of the theorem can be viewed in the paper + "Gradient Harmonized Single-stage Detector". + https://arxiv.org/abs/1811.05181 + + Args: + bins (int): Number of the unit regions for distribution calculation. + momentum (float): The parameter for moving average. + use_sigmoid (bool): Can only be true for BCE based loss now. + loss_weight (float): The weight of the total GHM-C loss. + """ + + def __init__(self, bins=10, momentum=0, use_sigmoid=True, loss_weight=1.0): + super(GHMC, self).__init__() + self.bins = bins + self.momentum = momentum + edges = torch.arange(bins + 1).float() / bins + self.register_buffer('edges', edges) + self.edges[-1] += 1e-6 + if momentum > 0: + acc_sum = torch.zeros(bins) + self.register_buffer('acc_sum', acc_sum) + self.use_sigmoid = use_sigmoid + if not self.use_sigmoid: + raise NotImplementedError + self.loss_weight = loss_weight + + def forward(self, pred, target, label_weight, *args, **kwargs): + """Calculate the GHM-C loss. + + Args: + pred (float tensor of size [batch_num, class_num]): + The direct prediction of classification fc layer. + target (float tensor of size [batch_num, class_num]): + Binary class target for each sample. + label_weight (float tensor of size [batch_num, class_num]): + the value is 1 if the sample is valid and 0 if ignored. + Returns: + The gradient harmonized loss. + """ + # the target should be binary class label + if pred.dim() != target.dim(): + target, label_weight = _expand_binary_labels( + target, label_weight, pred.size(-1)) + target, label_weight = target.float(), label_weight.float() + edges = self.edges + mmt = self.momentum + weights = torch.zeros_like(pred) + + # gradient length + g = torch.abs(pred.sigmoid().detach() - target) + + valid = label_weight > 0 + tot = max(valid.float().sum().item(), 1.0) + n = 0 # n valid bins + for i in range(self.bins): + inds = (g >= edges[i]) & (g < edges[i + 1]) & valid + num_in_bin = inds.sum().item() + if num_in_bin > 0: + if mmt > 0: + self.acc_sum[i] = mmt * self.acc_sum[i] \ + + (1 - mmt) * num_in_bin + weights[inds] = tot / self.acc_sum[i] + else: + weights[inds] = tot / num_in_bin + n += 1 + if n > 0: + weights = weights / n + + loss = F.binary_cross_entropy_with_logits( + pred, target, weights, reduction='sum') / tot + return loss * self.loss_weight + + +# TODO: code refactoring to make it consistent with other losses +@LOSSES.register_module +class GHMR(nn.Module): + """GHM Regression Loss. + + Details of the theorem can be viewed in the paper + "Gradient Harmonized Single-stage Detector" + https://arxiv.org/abs/1811.05181 + + Args: + mu (float): The parameter for the Authentic Smooth L1 loss. + bins (int): Number of the unit regions for distribution calculation. + momentum (float): The parameter for moving average. + loss_weight (float): The weight of the total GHM-R loss. + """ + + def __init__(self, mu=0.02, bins=10, momentum=0, loss_weight=1.0): + super(GHMR, self).__init__() + self.mu = mu + self.bins = bins + edges = torch.arange(bins + 1).float() / bins + self.register_buffer('edges', edges) + self.edges[-1] = 1e3 + self.momentum = momentum + if momentum > 0: + acc_sum = torch.zeros(bins) + self.register_buffer('acc_sum', acc_sum) + self.loss_weight = loss_weight + + # TODO: support reduction parameter + def forward(self, pred, target, label_weight, avg_factor=None): + """Calculate the GHM-R loss. + + Args: + pred (float tensor of size [batch_num, 4 (* class_num)]): + The prediction of box regression layer. Channel number can be 4 + or 4 * class_num depending on whether it is class-agnostic. + target (float tensor of size [batch_num, 4 (* class_num)]): + The target regression values with the same size of pred. + label_weight (float tensor of size [batch_num, 4 (* class_num)]): + The weight of each sample, 0 if ignored. + Returns: + The gradient harmonized loss. + """ + mu = self.mu + edges = self.edges + mmt = self.momentum + + # ASL1 loss + diff = pred - target + loss = torch.sqrt(diff * diff + mu * mu) - mu + + # gradient length + g = torch.abs(diff / torch.sqrt(mu * mu + diff * diff)).detach() + weights = torch.zeros_like(g) + + valid = label_weight > 0 + tot = max(label_weight.float().sum().item(), 1.0) + n = 0 # n: valid bins + for i in range(self.bins): + inds = (g >= edges[i]) & (g < edges[i + 1]) & valid + num_in_bin = inds.sum().item() + if num_in_bin > 0: + n += 1 + if mmt > 0: + self.acc_sum[i] = mmt * self.acc_sum[i] \ + + (1 - mmt) * num_in_bin + weights[inds] = tot / self.acc_sum[i] + else: + weights[inds] = tot / num_in_bin + if n > 0: + weights /= n + + loss = loss * weights + loss = loss.sum() / tot + return loss * self.loss_weight diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/iou_loss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/iou_loss.py new file mode 100644 index 000000000..c19c1d1d6 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/iou_loss.py @@ -0,0 +1,212 @@ +import torch +import torch.nn as nn + +from mmdet.core import bbox_overlaps +from ..registry import LOSSES +from .utils import weighted_loss + + +@weighted_loss +def iou_loss(pred, target, eps=1e-6): + """IoU loss. + + Computing the IoU loss between a set of predicted bboxes and target bboxes. + The loss is calculated as negative log of IoU. + + Args: + pred (Tensor): Predicted bboxes of format (x1, y1, x2, y2), + shape (n, 4). + target (Tensor): Corresponding gt bboxes, shape (n, 4). + eps (float): Eps to avoid log(0). + + Return: + Tensor: Loss tensor. + """ + ious = bbox_overlaps(pred, target, is_aligned=True).clamp(min=eps) + loss = -ious.log() + return loss + + +@weighted_loss +def bounded_iou_loss(pred, target, beta=0.2, eps=1e-3): + """Improving Object Localization with Fitness NMS and Bounded IoU Loss, + https://arxiv.org/abs/1711.00164. + + Args: + pred (tensor): Predicted bboxes. + target (tensor): Target bboxes. + beta (float): beta parameter in smoothl1. + eps (float): eps to avoid NaN. + """ + pred_ctrx = (pred[:, 0] + pred[:, 2]) * 0.5 + pred_ctry = (pred[:, 1] + pred[:, 3]) * 0.5 + pred_w = pred[:, 2] - pred[:, 0] + 1 + pred_h = pred[:, 3] - pred[:, 1] + 1 + with torch.no_grad(): + target_ctrx = (target[:, 0] + target[:, 2]) * 0.5 + target_ctry = (target[:, 1] + target[:, 3]) * 0.5 + target_w = target[:, 2] - target[:, 0] + 1 + target_h = target[:, 3] - target[:, 1] + 1 + + dx = target_ctrx - pred_ctrx + dy = target_ctry - pred_ctry + + loss_dx = 1 - torch.max( + (target_w - 2 * dx.abs()) / + (target_w + 2 * dx.abs() + eps), torch.zeros_like(dx)) + loss_dy = 1 - torch.max( + (target_h - 2 * dy.abs()) / + (target_h + 2 * dy.abs() + eps), torch.zeros_like(dy)) + loss_dw = 1 - torch.min(target_w / (pred_w + eps), pred_w / + (target_w + eps)) + loss_dh = 1 - torch.min(target_h / (pred_h + eps), pred_h / + (target_h + eps)) + loss_comb = torch.stack([loss_dx, loss_dy, loss_dw, loss_dh], + dim=-1).view(loss_dx.size(0), -1) + + loss = torch.where(loss_comb < beta, 0.5 * loss_comb * loss_comb / beta, + loss_comb - 0.5 * beta) + return loss + + +@weighted_loss +def giou_loss(pred, target, eps=1e-7): + """ + Generalized Intersection over Union: A Metric and A Loss for + Bounding Box Regression + https://arxiv.org/abs/1902.09630 + + code refer to: + https://github.com/sfzhang15/ATSS/blob/master/atss_core/modeling/rpn/atss/loss.py#L36 + + Args: + pred (Tensor): Predicted bboxes of format (x1, y1, x2, y2), + shape (n, 4). + target (Tensor): Corresponding gt bboxes, shape (n, 4). + eps (float): Eps to avoid log(0). + + Return: + Tensor: Loss tensor. + """ + # overlap + lt = torch.max(pred[:, :2], target[:, :2]) + rb = torch.min(pred[:, 2:], target[:, 2:]) + wh = (rb - lt + 1).clamp(min=0) + overlap = wh[:, 0] * wh[:, 1] + + # union + ap = (pred[:, 2] - pred[:, 0] + 1) * (pred[:, 3] - pred[:, 1] + 1) + ag = (target[:, 2] - target[:, 0] + 1) * (target[:, 3] - target[:, 1] + 1) + union = ap + ag - overlap + eps + + # IoU + ious = overlap / union + + # enclose area + enclose_x1y1 = torch.min(pred[:, :2], target[:, :2]) + enclose_x2y2 = torch.max(pred[:, 2:], target[:, 2:]) + enclose_wh = (enclose_x2y2 - enclose_x1y1 + 1).clamp(min=0) + enclose_area = enclose_wh[:, 0] * enclose_wh[:, 1] + eps + + # GIoU + gious = ious - (enclose_area - union) / enclose_area + loss = 1 - gious + return loss + + +@LOSSES.register_module +class IoULoss(nn.Module): + + def __init__(self, eps=1e-6, reduction='mean', loss_weight=1.0): + super(IoULoss, self).__init__() + self.eps = eps + self.reduction = reduction + self.loss_weight = loss_weight + + def forward(self, + pred, + target, + weight=None, + avg_factor=None, + reduction_override=None, + **kwargs): + if weight is not None and not torch.any(weight > 0): + return (pred * weight).sum() # 0 + assert reduction_override in (None, 'none', 'mean', 'sum') + reduction = ( + reduction_override if reduction_override else self.reduction) + loss = self.loss_weight * iou_loss( + pred, + target, + weight, + eps=self.eps, + reduction=reduction, + avg_factor=avg_factor, + **kwargs) + return loss + + +@LOSSES.register_module +class BoundedIoULoss(nn.Module): + + def __init__(self, beta=0.2, eps=1e-3, reduction='mean', loss_weight=1.0): + super(BoundedIoULoss, self).__init__() + self.beta = beta + self.eps = eps + self.reduction = reduction + self.loss_weight = loss_weight + + def forward(self, + pred, + target, + weight=None, + avg_factor=None, + reduction_override=None, + **kwargs): + if weight is not None and not torch.any(weight > 0): + return (pred * weight).sum() # 0 + assert reduction_override in (None, 'none', 'mean', 'sum') + reduction = ( + reduction_override if reduction_override else self.reduction) + loss = self.loss_weight * bounded_iou_loss( + pred, + target, + weight, + beta=self.beta, + eps=self.eps, + reduction=reduction, + avg_factor=avg_factor, + **kwargs) + return loss + + +@LOSSES.register_module +class GIoULoss(nn.Module): + + def __init__(self, eps=1e-6, reduction='mean', loss_weight=1.0): + super(GIoULoss, self).__init__() + self.eps = eps + self.reduction = reduction + self.loss_weight = loss_weight + + def forward(self, + pred, + target, + weight=None, + avg_factor=None, + reduction_override=None, + **kwargs): + if weight is not None and not torch.any(weight > 0): + return (pred * weight).sum() # 0 + assert reduction_override in (None, 'none', 'mean', 'sum') + reduction = ( + reduction_override if reduction_override else self.reduction) + loss = self.loss_weight * giou_loss( + pred, + target, + weight, + eps=self.eps, + reduction=reduction, + avg_factor=avg_factor, + **kwargs) + return loss diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/mse_loss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/mse_loss.py new file mode 100644 index 000000000..a868b2be9 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/mse_loss.py @@ -0,0 +1,25 @@ +import torch.nn as nn +import torch.nn.functional as F + +from ..registry import LOSSES +from .utils import weighted_loss + +mse_loss = weighted_loss(F.mse_loss) + + +@LOSSES.register_module +class MSELoss(nn.Module): + + def __init__(self, reduction='mean', loss_weight=1.0): + super().__init__() + self.reduction = reduction + self.loss_weight = loss_weight + + def forward(self, pred, target, weight=None, avg_factor=None): + loss = self.loss_weight * mse_loss( + pred, + target, + weight, + reduction=self.reduction, + avg_factor=avg_factor) + return loss diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/smooth_l1_loss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/smooth_l1_loss.py new file mode 100644 index 000000000..bc340730b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/smooth_l1_loss.py @@ -0,0 +1,45 @@ +import torch +import torch.nn as nn + +from ..registry import LOSSES +from .utils import weighted_loss + + +@weighted_loss +def smooth_l1_loss(pred, target, beta=1.0): + assert beta > 0 + assert pred.size() == target.size() and target.numel() > 0 + diff = torch.abs(pred - target) + loss = torch.where(diff < beta, 0.5 * diff * diff / beta, + diff - 0.5 * beta) + return loss + + +@LOSSES.register_module +class SmoothL1Loss(nn.Module): + + def __init__(self, beta=1.0, reduction='mean', loss_weight=1.0): + super(SmoothL1Loss, self).__init__() + self.beta = beta + self.reduction = reduction + self.loss_weight = loss_weight + + def forward(self, + pred, + target, + weight=None, + avg_factor=None, + reduction_override=None, + **kwargs): + assert reduction_override in (None, 'none', 'mean', 'sum') + reduction = ( + reduction_override if reduction_override else self.reduction) + loss_bbox = self.loss_weight * smooth_l1_loss( + pred, + target, + weight, + beta=self.beta, + reduction=reduction, + avg_factor=avg_factor, + **kwargs) + return loss_bbox diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/utils.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/utils.py new file mode 100644 index 000000000..3361c6cad --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/utils.py @@ -0,0 +1,98 @@ +import functools + +import torch.nn.functional as F + + +def reduce_loss(loss, reduction): + """Reduce loss as specified. + + Args: + loss (Tensor): Elementwise loss tensor. + reduction (str): Options are "none", "mean" and "sum". + + Return: + Tensor: Reduced loss tensor. + """ + reduction_enum = F._Reduction.get_enum(reduction) + # none: 0, elementwise_mean:1, sum: 2 + if reduction_enum == 0: + return loss + elif reduction_enum == 1: + return loss.mean() + elif reduction_enum == 2: + return loss.sum() + + +def weight_reduce_loss(loss, weight=None, reduction='mean', avg_factor=None): + """Apply element-wise weight and reduce loss. + + Args: + loss (Tensor): Element-wise loss. + weight (Tensor): Element-wise weights. + reduction (str): Same as built-in losses of PyTorch. + avg_factor (float): Avarage factor when computing the mean of losses. + + Returns: + Tensor: Processed loss values. + """ + # if weight is specified, apply element-wise weight + if weight is not None: + loss = loss * weight + + # if avg_factor is not specified, just reduce the loss + if avg_factor is None: + loss = reduce_loss(loss, reduction) + else: + # if reduction is mean, then average the loss by avg_factor + if reduction == 'mean': + loss = loss.sum() / avg_factor + # if reduction is 'none', then do nothing, otherwise raise an error + elif reduction != 'none': + raise ValueError('avg_factor can not be used with reduction="sum"') + return loss + + +def weighted_loss(loss_func): + """Create a weighted version of a given loss function. + + To use this decorator, the loss function must have the signature like + `loss_func(pred, target, **kwargs)`. The function only needs to compute + element-wise loss without any reduction. This decorator will add weight + and reduction arguments to the function. The decorated function will have + the signature like `loss_func(pred, target, weight=None, reduction='mean', + avg_factor=None, **kwargs)`. + + :Example: + + >>> import torch + >>> @weighted_loss + >>> def l1_loss(pred, target): + >>> return (pred - target).abs() + + >>> pred = torch.Tensor([0, 2, 3]) + >>> target = torch.Tensor([1, 1, 1]) + >>> weight = torch.Tensor([1, 0, 1]) + + >>> l1_loss(pred, target) + tensor(1.3333) + >>> l1_loss(pred, target, weight) + tensor(1.) + >>> l1_loss(pred, target, reduction='none') + tensor([1., 1., 2.]) + >>> l1_loss(pred, target, weight, avg_factor=2) + tensor(1.5000) + """ + + @functools.wraps(loss_func) + def wrapper(pred, + target, + weight=None, + reduction='mean', + avg_factor=None, + **kwargs): + # get element-wise loss + loss = loss_func(pred, target, **kwargs) + loss = weight_reduce_loss(loss, weight, reduction, avg_factor) + return loss + + return wrapper diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/__init__.py new file mode 100644 index 000000000..0cae03ac7 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/__init__.py @@ -0,0 +1,11 @@ +from .fcn_mask_head import FCNMaskHead +from .fused_semantic_head import FusedSemanticHead +from .grid_head import GridHead +from .htc_mask_head import HTCMaskHead +from .maskiou_head import MaskIoUHead +from .mask_feat_head import MaskFeatHead + +__all__ = [ + 'FCNMaskHead', 'HTCMaskHead', 'FusedSemanticHead', 'GridHead', + 'MaskIoUHead', 'MaskFeatHead' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/fcn_mask_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/fcn_mask_head.py new file mode 100644 index 000000000..6d11cfffc --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/fcn_mask_head.py @@ -0,0 +1,191 @@ +import mmcv +import numpy as np +import pycocotools.mask as mask_util +import torch +import torch.nn as nn +from torch.nn.modules.utils import _pair + +from mmdet.core import auto_fp16, force_fp32, mask_target +from ..builder import build_loss +from ..registry import HEADS +from ..utils import ConvModule + + +@HEADS.register_module +class FCNMaskHead(nn.Module): + + def __init__(self, + num_convs=4, + roi_feat_size=14, + in_channels=256, + conv_kernel_size=3, + conv_out_channels=256, + upsample_method='deconv', + upsample_ratio=2, + num_classes=81, + class_agnostic=False, + conv_cfg=None, + norm_cfg=None, + loss_mask=dict( + type='CrossEntropyLoss', use_mask=True, loss_weight=1.0)): + super(FCNMaskHead, self).__init__() + if upsample_method not in [None, 'deconv', 'nearest', 'bilinear']: + raise ValueError( + 'Invalid upsample method {}, accepted methods ' + 'are "deconv", "nearest", "bilinear"'.format(upsample_method)) + self.num_convs = num_convs + # WARN: roi_feat_size is reserved and not used + self.roi_feat_size = _pair(roi_feat_size) + self.in_channels = in_channels + self.conv_kernel_size = conv_kernel_size + self.conv_out_channels = conv_out_channels + self.upsample_method = upsample_method + self.upsample_ratio = upsample_ratio + self.num_classes = num_classes + self.class_agnostic = class_agnostic + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + self.fp16_enabled = False + self.loss_mask = build_loss(loss_mask) + + self.convs = nn.ModuleList() + for i in range(self.num_convs): + in_channels = ( + self.in_channels if i == 0 else self.conv_out_channels) + padding = (self.conv_kernel_size - 1) // 2 + self.convs.append( + ConvModule( + in_channels, + self.conv_out_channels, + self.conv_kernel_size, + padding=padding, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg)) + upsample_in_channels = ( + self.conv_out_channels if self.num_convs > 0 else in_channels) + if self.upsample_method is None: + self.upsample = None + elif self.upsample_method == 'deconv': + self.upsample = nn.ConvTranspose2d( + upsample_in_channels, + self.conv_out_channels, + self.upsample_ratio, + stride=self.upsample_ratio) + else: + self.upsample = nn.Upsample( + scale_factor=self.upsample_ratio, mode=self.upsample_method) + + out_channels = 1 if self.class_agnostic else self.num_classes + logits_in_channel = ( + self.conv_out_channels + if self.upsample_method == 'deconv' else upsample_in_channels) + self.conv_logits = nn.Conv2d(logits_in_channel, out_channels, 1) + self.relu = nn.ReLU(inplace=True) + self.debug_imgs = None + + def init_weights(self): + for m in [self.upsample, self.conv_logits]: + if m is None: + continue + nn.init.kaiming_normal_( + m.weight, mode='fan_out', nonlinearity='relu') + nn.init.constant_(m.bias, 0) + + @auto_fp16() + def forward(self, x): + for conv in self.convs: + x = conv(x) + if self.upsample is not None: + x = self.upsample(x) + if self.upsample_method == 'deconv': + x = self.relu(x) + mask_pred = self.conv_logits(x) + return mask_pred + + def get_target(self, sampling_results, gt_masks, rcnn_train_cfg): + pos_proposals = [res.pos_bboxes for res in sampling_results] + pos_assigned_gt_inds = [ + res.pos_assigned_gt_inds for res in sampling_results + ] + mask_targets = mask_target(pos_proposals, pos_assigned_gt_inds, + gt_masks, rcnn_train_cfg) + return mask_targets + + @force_fp32(apply_to=('mask_pred', )) + def loss(self, mask_pred, mask_targets, labels): + loss = dict() + if self.class_agnostic: + loss_mask = self.loss_mask(mask_pred, mask_targets, + torch.zeros_like(labels)) + else: + loss_mask = self.loss_mask(mask_pred, mask_targets, labels) + loss['loss_mask'] = loss_mask + return loss + + def get_seg_masks(self, mask_pred, det_bboxes, det_labels, rcnn_test_cfg, + ori_shape, scale_factor, rescale): + """Get segmentation masks from mask_pred and bboxes. + + Args: + mask_pred (Tensor or ndarray): shape (n, #class+1, h, w). + For single-scale testing, mask_pred is the direct output of + model, whose type is Tensor, while for multi-scale testing, + it will be converted to numpy array outside of this method. + det_bboxes (Tensor): shape (n, 4/5) + det_labels (Tensor): shape (n, ) + img_shape (Tensor): shape (3, ) + rcnn_test_cfg (dict): rcnn testing config + ori_shape: original image size + + Returns: + list[list]: encoded masks + """ + if isinstance(mask_pred, torch.Tensor): + mask_pred = mask_pred.sigmoid().cpu().numpy() + assert isinstance(mask_pred, np.ndarray) + # when enabling mixed precision training, mask_pred may be float16 + # numpy array + mask_pred = mask_pred.astype(np.float32) + + cls_segms = [[] for _ in range(self.num_classes - 1)] + bboxes = det_bboxes.cpu().numpy()[:, :4] + labels = det_labels.cpu().numpy() + 1 + + if rescale: + img_h, img_w = ori_shape[:2] + else: + img_h = np.round(ori_shape[0] * scale_factor).astype(np.int32) + img_w = np.round(ori_shape[1] * scale_factor).astype(np.int32) + scale_factor = 1.0 + + for i in range(bboxes.shape[0]): + if not isinstance(scale_factor, (float, np.ndarray)): + scale_factor = scale_factor.cpu().numpy() + bbox = (bboxes[i, :] / scale_factor).astype(np.int32) + label = labels[i] + w = max(bbox[2] - bbox[0] + 1, 1) + h = max(bbox[3] - bbox[1] + 1, 1) + + if not self.class_agnostic: + mask_pred_ = mask_pred[i, label, :, :] + else: + mask_pred_ = mask_pred[i, 0, :, :] + + bbox_mask = mmcv.imresize(mask_pred_, (w, h)) + bbox_mask = (bbox_mask > rcnn_test_cfg.mask_thr_binary).astype( + np.uint8) + + if rcnn_test_cfg.get('crop_mask', False): + im_mask = bbox_mask + else: + im_mask = np.zeros((img_h, img_w), dtype=np.uint8) + im_mask[bbox[1]:bbox[1] + h, bbox[0]:bbox[0] + w] = bbox_mask + + if rcnn_test_cfg.get('rle_mask_encode', True): + rle = mask_util.encode( + np.array(im_mask[:, :, np.newaxis], order='F'))[0] + cls_segms[label - 1].append(rle) + else: + cls_segms[label - 1].append(im_mask) + + return cls_segms diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/fused_semantic_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/fused_semantic_head.py new file mode 100644 index 000000000..80dab0516 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/fused_semantic_head.py @@ -0,0 +1,106 @@ +import torch.nn as nn +import torch.nn.functional as F +from mmcv.cnn import kaiming_init + +from mmdet.core import auto_fp16, force_fp32 +from ..registry import HEADS +from ..utils import ConvModule + + +@HEADS.register_module +class FusedSemanticHead(nn.Module): + r"""Multi-level fused semantic segmentation head. + + in_1 -> 1x1 conv --- + | + in_2 -> 1x1 conv -- | + || + in_3 -> 1x1 conv - || + ||| /-> 1x1 conv (mask prediction) + in_4 -> 1x1 conv -----> 3x3 convs (*4) + | \-> 1x1 conv (feature) + in_5 -> 1x1 conv --- + """ # noqa: W605 + + def __init__(self, + num_ins, + fusion_level, + num_convs=4, + in_channels=256, + conv_out_channels=256, + num_classes=183, + ignore_label=255, + loss_weight=0.2, + conv_cfg=None, + norm_cfg=None): + super(FusedSemanticHead, self).__init__() + self.num_ins = num_ins + self.fusion_level = fusion_level + self.num_convs = num_convs + self.in_channels = in_channels + self.conv_out_channels = conv_out_channels + self.num_classes = num_classes + self.ignore_label = ignore_label + self.loss_weight = loss_weight + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + self.fp16_enabled = False + + self.lateral_convs = nn.ModuleList() + for i in range(self.num_ins): + self.lateral_convs.append( + ConvModule( + self.in_channels, + self.in_channels, + 1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg, + inplace=False)) + + self.convs = nn.ModuleList() + for i in range(self.num_convs): + in_channels = self.in_channels if i == 0 else conv_out_channels + self.convs.append( + ConvModule( + in_channels, + conv_out_channels, + 3, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg)) + self.conv_embedding = ConvModule( + conv_out_channels, + conv_out_channels, + 1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg) + self.conv_logits = nn.Conv2d(conv_out_channels, self.num_classes, 1) + + self.criterion = nn.CrossEntropyLoss(ignore_index=ignore_label) + + def init_weights(self): + kaiming_init(self.conv_logits) + + @auto_fp16() + def forward(self, feats): + x = self.lateral_convs[self.fusion_level](feats[self.fusion_level]) + fused_size = tuple(x.shape[-2:]) + for i, feat in enumerate(feats): + if i != self.fusion_level: + feat = F.interpolate( + feat, size=fused_size, mode='bilinear', align_corners=True) + x += self.lateral_convs[i](feat) + + for i in range(self.num_convs): + x = self.convs[i](x) + + mask_pred = self.conv_logits(x) + x = self.conv_embedding(x) + return mask_pred, x + + @force_fp32(apply_to=('mask_pred', )) + def loss(self, mask_pred, labels): + labels = labels.squeeze(1).long() + loss_semantic_seg = self.criterion(mask_pred, labels) + loss_semantic_seg *= self.loss_weight + return loss_semantic_seg diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/grid_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/grid_head.py new file mode 100644 index 000000000..72065309b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/grid_head.py @@ -0,0 +1,361 @@ +import numpy as np +import torch +import torch.nn as nn +import torch.nn.functional as F +from mmcv.cnn import kaiming_init, normal_init + +from ..builder import build_loss +from ..registry import HEADS +from ..utils import ConvModule + + +@HEADS.register_module +class GridHead(nn.Module): + + def __init__(self, + grid_points=9, + num_convs=8, + roi_feat_size=14, + in_channels=256, + conv_kernel_size=3, + point_feat_channels=64, + deconv_kernel_size=4, + class_agnostic=False, + loss_grid=dict( + type='CrossEntropyLoss', use_sigmoid=True, + loss_weight=15), + conv_cfg=None, + norm_cfg=dict(type='GN', num_groups=36)): + super(GridHead, self).__init__() + self.grid_points = grid_points + self.num_convs = num_convs + self.roi_feat_size = roi_feat_size + self.in_channels = in_channels + self.conv_kernel_size = conv_kernel_size + self.point_feat_channels = point_feat_channels + self.conv_out_channels = self.point_feat_channels * self.grid_points + self.class_agnostic = class_agnostic + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + if isinstance(norm_cfg, dict) and norm_cfg['type'] == 'GN': + assert self.conv_out_channels % norm_cfg['num_groups'] == 0 + + assert self.grid_points >= 4 + self.grid_size = int(np.sqrt(self.grid_points)) + if self.grid_size * self.grid_size != self.grid_points: + raise ValueError('grid_points must be a square number') + + # the predicted heatmap is half of whole_map_size + if not isinstance(self.roi_feat_size, int): + raise ValueError('Only square RoIs are supporeted in Grid R-CNN') + self.whole_map_size = self.roi_feat_size * 4 + + # compute point-wise sub-regions + self.sub_regions = self.calc_sub_regions() + + self.convs = [] + for i in range(self.num_convs): + in_channels = ( + self.in_channels if i == 0 else self.conv_out_channels) + stride = 2 if i == 0 else 1 + padding = (self.conv_kernel_size - 1) // 2 + self.convs.append( + ConvModule( + in_channels, + self.conv_out_channels, + self.conv_kernel_size, + stride=stride, + padding=padding, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg, + bias=True)) + self.convs = nn.Sequential(*self.convs) + + self.deconv1 = nn.ConvTranspose2d( + self.conv_out_channels, + self.conv_out_channels, + kernel_size=deconv_kernel_size, + stride=2, + padding=(deconv_kernel_size - 2) // 2, + groups=grid_points) + self.norm1 = nn.GroupNorm(grid_points, self.conv_out_channels) + self.deconv2 = nn.ConvTranspose2d( + self.conv_out_channels, + grid_points, + kernel_size=deconv_kernel_size, + stride=2, + padding=(deconv_kernel_size - 2) // 2, + groups=grid_points) + + # find the 4-neighbor of each grid point + self.neighbor_points = [] + grid_size = self.grid_size + for i in range(grid_size): # i-th column + for j in range(grid_size): # j-th row + neighbors = [] + if i > 0: # left: (i - 1, j) + neighbors.append((i - 1) * grid_size + j) + if j > 0: # up: (i, j - 1) + neighbors.append(i * grid_size + j - 1) + if j < grid_size - 1: # down: (i, j + 1) + neighbors.append(i * grid_size + j + 1) + if i < grid_size - 1: # right: (i + 1, j) + neighbors.append((i + 1) * grid_size + j) + self.neighbor_points.append(tuple(neighbors)) + # total edges in the grid + self.num_edges = sum([len(p) for p in self.neighbor_points]) + + self.forder_trans = nn.ModuleList() # first-order feature transition + self.sorder_trans = nn.ModuleList() # second-order feature transition + for neighbors in self.neighbor_points: + fo_trans = nn.ModuleList() + so_trans = nn.ModuleList() + for _ in range(len(neighbors)): + # each transition module consists of a 5x5 depth-wise conv and + # 1x1 conv. + fo_trans.append( + nn.Sequential( + nn.Conv2d( + self.point_feat_channels, + self.point_feat_channels, + 5, + stride=1, + padding=2, + groups=self.point_feat_channels), + nn.Conv2d(self.point_feat_channels, + self.point_feat_channels, 1))) + so_trans.append( + nn.Sequential( + nn.Conv2d( + self.point_feat_channels, + self.point_feat_channels, + 5, + 1, + 2, + groups=self.point_feat_channels), + nn.Conv2d(self.point_feat_channels, + self.point_feat_channels, 1))) + self.forder_trans.append(fo_trans) + self.sorder_trans.append(so_trans) + + self.loss_grid = build_loss(loss_grid) + + def init_weights(self): + for m in self.modules(): + if isinstance(m, nn.Conv2d) or isinstance(m, nn.Linear): + # TODO: compare mode = "fan_in" or "fan_out" + kaiming_init(m) + for m in self.modules(): + if isinstance(m, nn.ConvTranspose2d): + normal_init(m, std=0.001) + nn.init.constant_(self.deconv2.bias, -np.log(0.99 / 0.01)) + + def forward(self, x): + assert x.shape[-1] == x.shape[-2] == self.roi_feat_size + # RoI feature transformation, downsample 2x + x = self.convs(x) + + c = self.point_feat_channels + # first-order fusion + x_fo = [None for _ in range(self.grid_points)] + for i, points in enumerate(self.neighbor_points): + x_fo[i] = x[:, i * c:(i + 1) * c] + for j, point_idx in enumerate(points): + x_fo[i] = x_fo[i] + self.forder_trans[i][j]( + x[:, point_idx * c:(point_idx + 1) * c]) + + # second-order fusion + x_so = [None for _ in range(self.grid_points)] + for i, points in enumerate(self.neighbor_points): + x_so[i] = x[:, i * c:(i + 1) * c] + for j, point_idx in enumerate(points): + x_so[i] = x_so[i] + self.sorder_trans[i][j](x_fo[point_idx]) + + # predicted heatmap with fused features + x2 = torch.cat(x_so, dim=1) + x2 = self.deconv1(x2) + x2 = F.relu(self.norm1(x2), inplace=True) + heatmap = self.deconv2(x2) + + # predicted heatmap with original features (applicable during training) + if self.training: + x1 = x + x1 = self.deconv1(x1) + x1 = F.relu(self.norm1(x1), inplace=True) + heatmap_unfused = self.deconv2(x1) + else: + heatmap_unfused = heatmap + + return dict(fused=heatmap, unfused=heatmap_unfused) + + def calc_sub_regions(self): + """Compute point specific representation regions. + + See Grid R-CNN Plus (https://arxiv.org/abs/1906.05688) for details. + """ + # to make it consistent with the original implementation, half_size + # is computed as 2 * quarter_size, which is smaller + half_size = self.whole_map_size // 4 * 2 + sub_regions = [] + for i in range(self.grid_points): + x_idx = i // self.grid_size + y_idx = i % self.grid_size + if x_idx == 0: + sub_x1 = 0 + elif x_idx == self.grid_size - 1: + sub_x1 = half_size + else: + ratio = x_idx / (self.grid_size - 1) - 0.25 + sub_x1 = max(int(ratio * self.whole_map_size), 0) + + if y_idx == 0: + sub_y1 = 0 + elif y_idx == self.grid_size - 1: + sub_y1 = half_size + else: + ratio = y_idx / (self.grid_size - 1) - 0.25 + sub_y1 = max(int(ratio * self.whole_map_size), 0) + sub_regions.append( + (sub_x1, sub_y1, sub_x1 + half_size, sub_y1 + half_size)) + return sub_regions + + def get_target(self, sampling_results, rcnn_train_cfg): + # mix all samples (across images) together. + pos_bboxes = torch.cat([res.pos_bboxes for res in sampling_results], + dim=0).cpu() + pos_gt_bboxes = torch.cat( + [res.pos_gt_bboxes for res in sampling_results], dim=0).cpu() + assert pos_bboxes.shape == pos_gt_bboxes.shape + + # expand pos_bboxes to 2x of original size + x1 = pos_bboxes[:, 0] - (pos_bboxes[:, 2] - pos_bboxes[:, 0]) / 2 + y1 = pos_bboxes[:, 1] - (pos_bboxes[:, 3] - pos_bboxes[:, 1]) / 2 + x2 = pos_bboxes[:, 2] + (pos_bboxes[:, 2] - pos_bboxes[:, 0]) / 2 + y2 = pos_bboxes[:, 3] + (pos_bboxes[:, 3] - pos_bboxes[:, 1]) / 2 + pos_bboxes = torch.stack([x1, y1, x2, y2], dim=-1) + pos_bbox_ws = (pos_bboxes[:, 2] - pos_bboxes[:, 0]).unsqueeze(-1) + pos_bbox_hs = (pos_bboxes[:, 3] - pos_bboxes[:, 1]).unsqueeze(-1) + + num_rois = pos_bboxes.shape[0] + map_size = self.whole_map_size + # this is not the final target shape + targets = torch.zeros((num_rois, self.grid_points, map_size, map_size), + dtype=torch.float) + + # pre-compute interpolation factors for all grid points. + # the first item is the factor of x-dim, and the second is y-dim. + # for a 9-point grid, factors are like (1, 0), (0.5, 0.5), (0, 1) + factors = [] + for j in range(self.grid_points): + x_idx = j // self.grid_size + y_idx = j % self.grid_size + factors.append((1 - x_idx / (self.grid_size - 1), + 1 - y_idx / (self.grid_size - 1))) + + radius = rcnn_train_cfg.pos_radius + radius2 = radius**2 + for i in range(num_rois): + # ignore small bboxes + if (pos_bbox_ws[i] <= self.grid_size + or pos_bbox_hs[i] <= self.grid_size): + continue + # for each grid point, mark a small circle as positive + for j in range(self.grid_points): + factor_x, factor_y = factors[j] + gridpoint_x = factor_x * pos_gt_bboxes[i, 0] + ( + 1 - factor_x) * pos_gt_bboxes[i, 2] + gridpoint_y = factor_y * pos_gt_bboxes[i, 1] + ( + 1 - factor_y) * pos_gt_bboxes[i, 3] + + cx = int((gridpoint_x - pos_bboxes[i, 0]) / pos_bbox_ws[i] * + map_size) + cy = int((gridpoint_y - pos_bboxes[i, 1]) / pos_bbox_hs[i] * + map_size) + + for x in range(cx - radius, cx + radius + 1): + for y in range(cy - radius, cy + radius + 1): + if x >= 0 and x < map_size and y >= 0 and y < map_size: + if (x - cx)**2 + (y - cy)**2 <= radius2: + targets[i, j, y, x] = 1 + # reduce the target heatmap size by a half + # proposed in Grid R-CNN Plus (https://arxiv.org/abs/1906.05688). + sub_targets = [] + for i in range(self.grid_points): + sub_x1, sub_y1, sub_x2, sub_y2 = self.sub_regions[i] + sub_targets.append(targets[:, [i], sub_y1:sub_y2, sub_x1:sub_x2]) + sub_targets = torch.cat(sub_targets, dim=1) + sub_targets = sub_targets.cuda() + return sub_targets + + def loss(self, grid_pred, grid_targets): + loss_fused = self.loss_grid(grid_pred['fused'], grid_targets) + loss_unfused = self.loss_grid(grid_pred['unfused'], grid_targets) + loss_grid = loss_fused + loss_unfused + return dict(loss_grid=loss_grid) + + def get_bboxes(self, det_bboxes, grid_pred, img_meta): + # TODO: refactoring + assert det_bboxes.shape[0] == grid_pred.shape[0] + det_bboxes = det_bboxes.cpu() + cls_scores = det_bboxes[:, [4]] + det_bboxes = det_bboxes[:, :4] + grid_pred = grid_pred.sigmoid().cpu() + + R, c, h, w = grid_pred.shape + half_size = self.whole_map_size // 4 * 2 + assert h == w == half_size + assert c == self.grid_points + + # find the point with max scores in the half-sized heatmap + grid_pred = grid_pred.view(R * c, h * w) + pred_scores, pred_position = grid_pred.max(dim=1) + xs = pred_position % w + ys = pred_position // w + + # get the position in the whole heatmap instead of half-sized heatmap + for i in range(self.grid_points): + xs[i::self.grid_points] += self.sub_regions[i][0] + ys[i::self.grid_points] += self.sub_regions[i][1] + + # reshape to (num_rois, grid_points) + pred_scores, xs, ys = tuple( + map(lambda x: x.view(R, c), [pred_scores, xs, ys])) + + # get expanded pos_bboxes + widths = (det_bboxes[:, 2] - det_bboxes[:, 0]).unsqueeze(-1) + heights = (det_bboxes[:, 3] - det_bboxes[:, 1]).unsqueeze(-1) + x1 = (det_bboxes[:, 0, None] - widths / 2) + y1 = (det_bboxes[:, 1, None] - heights / 2) + # map the grid point to the absolute coordinates + abs_xs = (xs.float() + 0.5) / w * widths + x1 + abs_ys = (ys.float() + 0.5) / h * heights + y1 + + # get the grid points indices that fall on the bbox boundaries + x1_inds = [i for i in range(self.grid_size)] + y1_inds = [i * self.grid_size for i in range(self.grid_size)] + x2_inds = [ + self.grid_points - self.grid_size + i + for i in range(self.grid_size) + ] + y2_inds = [(i + 1) * self.grid_size - 1 for i in range(self.grid_size)] + + # voting of all grid points on some boundary + bboxes_x1 = (abs_xs[:, x1_inds] * pred_scores[:, x1_inds]).sum( + dim=1, keepdim=True) / ( + pred_scores[:, x1_inds].sum(dim=1, keepdim=True)) + bboxes_y1 = (abs_ys[:, y1_inds] * pred_scores[:, y1_inds]).sum( + dim=1, keepdim=True) / ( + pred_scores[:, y1_inds].sum(dim=1, keepdim=True)) + bboxes_x2 = (abs_xs[:, x2_inds] * pred_scores[:, x2_inds]).sum( + dim=1, keepdim=True) / ( + pred_scores[:, x2_inds].sum(dim=1, keepdim=True)) + bboxes_y2 = (abs_ys[:, y2_inds] * pred_scores[:, y2_inds]).sum( + dim=1, keepdim=True) / ( + pred_scores[:, y2_inds].sum(dim=1, keepdim=True)) + + bbox_res = torch.cat( + [bboxes_x1, bboxes_y1, bboxes_x2, bboxes_y2, cls_scores], dim=1) + bbox_res[:, [0, 2]].clamp_(min=0, max=img_meta[0]['img_shape'][1] - 1) + bbox_res[:, [1, 3]].clamp_(min=0, max=img_meta[0]['img_shape'][0] - 1) + + return bbox_res diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/htc_mask_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/htc_mask_head.py new file mode 100644 index 000000000..7c8125543 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/htc_mask_head.py @@ -0,0 +1,38 @@ +from ..registry import HEADS +from ..utils import ConvModule +from .fcn_mask_head import FCNMaskHead + + +@HEADS.register_module +class HTCMaskHead(FCNMaskHead): + + def __init__(self, *args, **kwargs): + super(HTCMaskHead, self).__init__(*args, **kwargs) + self.conv_res = ConvModule( + self.conv_out_channels, + self.conv_out_channels, + 1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg) + + def init_weights(self): + super(HTCMaskHead, self).init_weights() + self.conv_res.init_weights() + + def forward(self, x, res_feat=None, return_logits=True, return_feat=True): + if res_feat is not None: + res_feat = self.conv_res(res_feat) + x = x + res_feat + for conv in self.convs: + x = conv(x) + res_feat = x + outs = [] + if return_logits: + x = self.upsample(x) + if self.upsample_method == 'deconv': + x = self.relu(x) + mask_pred = self.conv_logits(x) + outs.append(mask_pred) + if return_feat: + outs.append(res_feat) + return outs if len(outs) > 1 else outs[0] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/mask_feat_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/mask_feat_head.py new file mode 100644 index 000000000..980b4ad8f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/mask_feat_head.py @@ -0,0 +1,119 @@ +import torch.nn as nn +import torch.nn.functional as F +from mmcv.cnn import xavier_init, normal_init + +from ..registry import HEADS +from ..builder import build_loss +from ..utils import ConvModule + +import torch +import numpy as np + + +@HEADS.register_module +class MaskFeatHead(nn.Module): + def __init__(self, + in_channels, + out_channels, + start_level, + end_level, + num_classes, + conv_cfg=None, + norm_cfg=None): + super(MaskFeatHead, self).__init__() + + self.in_channels = in_channels + self.out_channels = out_channels + self.start_level = start_level + self.end_level = end_level + assert start_level >= 0 and end_level >= start_level + self.num_classes = num_classes + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + + self.convs_all_levels = nn.ModuleList() + for i in range(self.start_level, self.end_level + 1): + convs_per_level = nn.Sequential() + if i == 0: + one_conv = ConvModule( + self.in_channels, + self.out_channels, + 3, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg, + inplace=False) + convs_per_level.add_module('conv' + str(i), one_conv) + self.convs_all_levels.append(convs_per_level) + continue + + for j in range(i): + if j == 0: + chn = self.in_channels+2 if i==3 else self.in_channels + one_conv = ConvModule( + chn, + self.out_channels, + 3, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg, + inplace=False) + convs_per_level.add_module('conv' + str(j), one_conv) + one_upsample = nn.Upsample( + scale_factor=2, mode='bilinear', align_corners=False) + convs_per_level.add_module( + 'upsample' + str(j), one_upsample) + continue + + one_conv = ConvModule( + self.out_channels, + self.out_channels, + 3, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg, + inplace=False) + convs_per_level.add_module('conv' + str(j), one_conv) + one_upsample = nn.Upsample( + scale_factor=2, + mode='bilinear', + align_corners=False) + convs_per_level.add_module('upsample' + str(j), one_upsample) + + self.convs_all_levels.append(convs_per_level) + + self.conv_pred = nn.Sequential( + ConvModule( + self.out_channels, + self.num_classes, + 1, + padding=0, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg), + ) + + def init_weights(self): + for m in self.modules(): + if isinstance(m, nn.Conv2d): + normal_init(m, std=0.01) + + def forward(self, inputs): + assert len(inputs) == (self.end_level - self.start_level + 1) + + feature_add_all_level = self.convs_all_levels[0](inputs[0]) + for i in range(1, len(inputs)): + input_p = inputs[i] + if i == 3: + input_feat = input_p + x_range = torch.linspace(-1, 1, input_feat.shape[-1], device=input_feat.device) + y_range = torch.linspace(-1, 1, input_feat.shape[-2], device=input_feat.device) + y, x = torch.meshgrid(y_range, x_range) + y = y.expand([input_feat.shape[0], 1, -1, -1]) + x = x.expand([input_feat.shape[0], 1, -1, -1]) + coord_feat = torch.cat([x, y], 1) + input_p = torch.cat([input_p, coord_feat], 1) + + feature_add_all_level += self.convs_all_levels[i](input_p) + + feature_pred = self.conv_pred(feature_add_all_level) + return feature_pred diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/maskiou_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/maskiou_head.py new file mode 100644 index 000000000..d509f177f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/maskiou_head.py @@ -0,0 +1,190 @@ +import numpy as np +import torch +import torch.nn as nn +from mmcv.cnn import kaiming_init, normal_init +from torch.nn.modules.utils import _pair + +from mmdet.core import force_fp32 +from ..builder import build_loss +from ..registry import HEADS + + +@HEADS.register_module +class MaskIoUHead(nn.Module): + """Mask IoU Head. + + This head predicts the IoU of predicted masks and corresponding gt masks. + """ + + def __init__(self, + num_convs=4, + num_fcs=2, + roi_feat_size=14, + in_channels=256, + conv_out_channels=256, + fc_out_channels=1024, + num_classes=81, + loss_iou=dict(type='MSELoss', loss_weight=0.5)): + super(MaskIoUHead, self).__init__() + self.in_channels = in_channels + self.conv_out_channels = conv_out_channels + self.fc_out_channels = fc_out_channels + self.num_classes = num_classes + self.fp16_enabled = False + + self.convs = nn.ModuleList() + for i in range(num_convs): + if i == 0: + # concatenation of mask feature and mask prediction + in_channels = self.in_channels + 1 + else: + in_channels = self.conv_out_channels + stride = 2 if i == num_convs - 1 else 1 + self.convs.append( + nn.Conv2d( + in_channels, + self.conv_out_channels, + 3, + stride=stride, + padding=1)) + + roi_feat_size = _pair(roi_feat_size) + pooled_area = (roi_feat_size[0] // 2) * (roi_feat_size[1] // 2) + self.fcs = nn.ModuleList() + for i in range(num_fcs): + in_channels = ( + self.conv_out_channels * + pooled_area if i == 0 else self.fc_out_channels) + self.fcs.append(nn.Linear(in_channels, self.fc_out_channels)) + + self.fc_mask_iou = nn.Linear(self.fc_out_channels, self.num_classes) + self.relu = nn.ReLU() + self.max_pool = nn.MaxPool2d(2, 2) + self.loss_iou = build_loss(loss_iou) + + def init_weights(self): + for conv in self.convs: + kaiming_init(conv) + for fc in self.fcs: + kaiming_init( + fc, + a=1, + mode='fan_in', + nonlinearity='leaky_relu', + distribution='uniform') + normal_init(self.fc_mask_iou, std=0.01) + + def forward(self, mask_feat, mask_pred): + mask_pred = mask_pred.sigmoid() + mask_pred_pooled = self.max_pool(mask_pred.unsqueeze(1)) + + x = torch.cat((mask_feat, mask_pred_pooled), 1) + + for conv in self.convs: + x = self.relu(conv(x)) + x = x.view(x.size(0), -1) + for fc in self.fcs: + x = self.relu(fc(x)) + mask_iou = self.fc_mask_iou(x) + return mask_iou + + @force_fp32(apply_to=('mask_iou_pred', )) + def loss(self, mask_iou_pred, mask_iou_targets): + pos_inds = mask_iou_targets > 0 + if pos_inds.sum() > 0: + loss_mask_iou = self.loss_iou(mask_iou_pred[pos_inds], + mask_iou_targets[pos_inds]) + else: + loss_mask_iou = mask_iou_pred * 0 + return dict(loss_mask_iou=loss_mask_iou) + + @force_fp32(apply_to=('mask_pred', )) + def get_target(self, sampling_results, gt_masks, mask_pred, mask_targets, + rcnn_train_cfg): + """Compute target of mask IoU. + + Mask IoU target is the IoU of the predicted mask (inside a bbox) and + the gt mask of corresponding gt mask (the whole instance). + The intersection area is computed inside the bbox, and the gt mask area + is computed with two steps, firstly we compute the gt area inside the + bbox, then divide it by the area ratio of gt area inside the bbox and + the gt area of the whole instance. + + Args: + sampling_results (list[:obj:`SamplingResult`]): sampling results. + gt_masks (list[ndarray]): Gt masks (the whole instance) of each + image, binary maps with the same shape of the input image. + mask_pred (Tensor): Predicted masks of each positive proposal, + shape (num_pos, h, w). + mask_targets (Tensor): Gt mask of each positive proposal, + binary map of the shape (num_pos, h, w). + rcnn_train_cfg (dict): Training config for R-CNN part. + + Returns: + Tensor: mask iou target (length == num positive). + """ + pos_proposals = [res.pos_bboxes for res in sampling_results] + pos_assigned_gt_inds = [ + res.pos_assigned_gt_inds for res in sampling_results + ] + + # compute the area ratio of gt areas inside the proposals and + # the whole instance + area_ratios = map(self._get_area_ratio, pos_proposals, + pos_assigned_gt_inds, gt_masks) + area_ratios = torch.cat(list(area_ratios)) + assert mask_targets.size(0) == area_ratios.size(0) + + mask_pred = (mask_pred > rcnn_train_cfg.mask_thr_binary).float() + mask_pred_areas = mask_pred.sum((-1, -2)) + + # mask_pred and mask_targets are binary maps + overlap_areas = (mask_pred * mask_targets).sum((-1, -2)) + + # compute the mask area of the whole instance + gt_full_areas = mask_targets.sum((-1, -2)) / (area_ratios + 1e-7) + + mask_iou_targets = overlap_areas / ( + mask_pred_areas + gt_full_areas - overlap_areas) + return mask_iou_targets + + def _get_area_ratio(self, pos_proposals, pos_assigned_gt_inds, gt_masks): + """Compute area ratio of the gt mask inside the proposal and the gt + mask of the corresponding instance""" + num_pos = pos_proposals.size(0) + if num_pos > 0: + area_ratios = [] + proposals_np = pos_proposals.cpu().numpy() + pos_assigned_gt_inds = pos_assigned_gt_inds.cpu().numpy() + # compute mask areas of gt instances (batch processing for speedup) + gt_instance_mask_area = gt_masks.sum((-1, -2)) + for i in range(num_pos): + gt_mask = gt_masks[pos_assigned_gt_inds[i]] + + # crop the gt mask inside the proposal + x1, y1, x2, y2 = proposals_np[i, :].astype(np.int32) + gt_mask_in_proposal = gt_mask[y1:y2 + 1, x1:x2 + 1] + + ratio = gt_mask_in_proposal.sum() / ( + gt_instance_mask_area[pos_assigned_gt_inds[i]] + 1e-7) + area_ratios.append(ratio) + area_ratios = torch.from_numpy(np.stack(area_ratios)).float().to( + pos_proposals.device) + else: + area_ratios = pos_proposals.new_zeros((0, )) + return area_ratios + + @force_fp32(apply_to=('mask_iou_pred', )) + def get_mask_scores(self, mask_iou_pred, det_bboxes, det_labels): + """Get the mask scores. + + mask_score = bbox_score * mask_iou + """ + inds = range(det_labels.size(0)) + mask_scores = mask_iou_pred[inds, det_labels + 1] * det_bboxes[inds, + -1] + mask_scores = mask_scores.cpu().numpy() + det_labels = det_labels.cpu().numpy() + return [ + mask_scores[det_labels == i] for i in range(self.num_classes - 1) + ] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/__init__.py new file mode 100644 index 000000000..fa5740443 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/__init__.py @@ -0,0 +1,6 @@ +from .bfp import BFP +from .fpn import FPN +from .hrfpn import HRFPN +from .nas_fpn import NASFPN + +__all__ = ['FPN', 'BFP', 'HRFPN', 'NASFPN'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/bfp.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/bfp.py new file mode 100644 index 000000000..03aee106d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/bfp.py @@ -0,0 +1,102 @@ +import torch.nn as nn +import torch.nn.functional as F +from mmcv.cnn import xavier_init + +from ..plugins import NonLocal2D +from ..registry import NECKS +from ..utils import ConvModule + + +@NECKS.register_module +class BFP(nn.Module): + """BFP (Balanced Feature Pyrmamids) + + BFP takes multi-level features as inputs and gather them into a single one, + then refine the gathered feature and scatter the refined results to + multi-level features. This module is used in Libra R-CNN (CVPR 2019), see + https://arxiv.org/pdf/1904.02701.pdf for details. + + Args: + in_channels (int): Number of input channels (feature maps of all levels + should have the same channels). + num_levels (int): Number of input feature levels. + conv_cfg (dict): The config dict for convolution layers. + norm_cfg (dict): The config dict for normalization layers. + refine_level (int): Index of integration and refine level of BSF in + multi-level features from bottom to top. + refine_type (str): Type of the refine op, currently support + [None, 'conv', 'non_local']. + """ + + def __init__(self, + in_channels, + num_levels, + refine_level=2, + refine_type=None, + conv_cfg=None, + norm_cfg=None): + super(BFP, self).__init__() + assert refine_type in [None, 'conv', 'non_local'] + + self.in_channels = in_channels + self.num_levels = num_levels + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + + self.refine_level = refine_level + self.refine_type = refine_type + assert 0 <= self.refine_level < self.num_levels + + if self.refine_type == 'conv': + self.refine = ConvModule( + self.in_channels, + self.in_channels, + 3, + padding=1, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg) + elif self.refine_type == 'non_local': + self.refine = NonLocal2D( + self.in_channels, + reduction=1, + use_scale=False, + conv_cfg=self.conv_cfg, + norm_cfg=self.norm_cfg) + + def init_weights(self): + for m in self.modules(): + if isinstance(m, nn.Conv2d): + xavier_init(m, distribution='uniform') + + def forward(self, inputs): + assert len(inputs) == self.num_levels + + # step 1: gather multi-level features by resize and average + feats = [] + gather_size = inputs[self.refine_level].size()[2:] + for i in range(self.num_levels): + if i < self.refine_level: + gathered = F.adaptive_max_pool2d( + inputs[i], output_size=gather_size) + else: + gathered = F.interpolate( + inputs[i], size=gather_size, mode='nearest') + feats.append(gathered) + + bsf = sum(feats) / len(feats) + + # step 2: refine gathered features + if self.refine_type is not None: + bsf = self.refine(bsf) + + # step 3: scatter refined features to multi-levels by a residual path + outs = [] + for i in range(self.num_levels): + out_size = inputs[i].size()[2:] + if i < self.refine_level: + residual = F.interpolate(bsf, size=out_size, mode='nearest') + else: + residual = F.adaptive_max_pool2d(bsf, output_size=out_size) + outs.append(residual + inputs[i]) + + return tuple(outs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/fpn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/fpn.py new file mode 100644 index 000000000..77dd409c4 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/fpn.py @@ -0,0 +1,141 @@ +import torch.nn as nn +import torch.nn.functional as F +from mmcv.cnn import xavier_init + +from mmdet.core import auto_fp16 +from ..registry import NECKS +from ..utils import ConvModule + + +@NECKS.register_module +class FPN(nn.Module): + + def __init__(self, + in_channels, + out_channels, + num_outs, + start_level=0, + end_level=-1, + add_extra_convs=False, + extra_convs_on_inputs=True, + relu_before_extra_convs=False, + no_norm_on_lateral=False, + conv_cfg=None, + norm_cfg=None, + activation=None): + super(FPN, self).__init__() + assert isinstance(in_channels, list) + self.in_channels = in_channels + self.out_channels = out_channels + self.num_ins = len(in_channels) + self.num_outs = num_outs + self.activation = activation + self.relu_before_extra_convs = relu_before_extra_convs + self.no_norm_on_lateral = no_norm_on_lateral + self.fp16_enabled = False + + if end_level == -1: + self.backbone_end_level = self.num_ins + assert num_outs >= self.num_ins - start_level + else: + # if end_level < inputs, no extra level is allowed + self.backbone_end_level = end_level + assert end_level <= len(in_channels) + assert num_outs == end_level - start_level + self.start_level = start_level + self.end_level = end_level + self.add_extra_convs = add_extra_convs + self.extra_convs_on_inputs = extra_convs_on_inputs + + self.lateral_convs = nn.ModuleList() + self.fpn_convs = nn.ModuleList() + + for i in range(self.start_level, self.backbone_end_level): + l_conv = ConvModule( + in_channels[i], + out_channels, + 1, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg if not self.no_norm_on_lateral else None, + activation=self.activation, + inplace=False) + fpn_conv = ConvModule( + out_channels, + out_channels, + 3, + padding=1, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + activation=self.activation, + inplace=False) + + self.lateral_convs.append(l_conv) + self.fpn_convs.append(fpn_conv) + + # add extra conv layers (e.g., RetinaNet) + extra_levels = num_outs - self.backbone_end_level + self.start_level + if add_extra_convs and extra_levels >= 1: + for i in range(extra_levels): + if i == 0 and self.extra_convs_on_inputs: + in_channels = self.in_channels[self.backbone_end_level - 1] + else: + in_channels = out_channels + extra_fpn_conv = ConvModule( + in_channels, + out_channels, + 3, + stride=2, + padding=1, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + activation=self.activation, + inplace=False) + self.fpn_convs.append(extra_fpn_conv) + + # default init_weights for conv(msra) and norm in ConvModule + def init_weights(self): + for m in self.modules(): + if isinstance(m, nn.Conv2d): + xavier_init(m, distribution='uniform') + + @auto_fp16() + def forward(self, inputs): + assert len(inputs) == len(self.in_channels) + + # build laterals + laterals = [ + lateral_conv(inputs[i + self.start_level]) + for i, lateral_conv in enumerate(self.lateral_convs) + ] + + # build top-down path + used_backbone_levels = len(laterals) + for i in range(used_backbone_levels - 1, 0, -1): + laterals[i - 1] += F.interpolate( + laterals[i], scale_factor=2, mode='nearest') + + # build outputs + # part 1: from original levels + outs = [ + self.fpn_convs[i](laterals[i]) for i in range(used_backbone_levels) + ] + # part 2: add extra levels + if self.num_outs > len(outs): + # use max pool to get more levels on top of outputs + # (e.g., Faster R-CNN, Mask R-CNN) + if not self.add_extra_convs: + for i in range(self.num_outs - used_backbone_levels): + outs.append(F.max_pool2d(outs[-1], 1, stride=2)) + # add conv layers on top of original feature maps (RetinaNet) + else: + if self.extra_convs_on_inputs: + orig = inputs[self.backbone_end_level - 1] + outs.append(self.fpn_convs[used_backbone_levels](orig)) + else: + outs.append(self.fpn_convs[used_backbone_levels](outs[-1])) + for i in range(used_backbone_levels + 1, self.num_outs): + if self.relu_before_extra_convs: + outs.append(self.fpn_convs[i](F.relu(outs[-1]))) + else: + outs.append(self.fpn_convs[i](outs[-1])) + return tuple(outs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/hrfpn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/hrfpn.py new file mode 100644 index 000000000..33155f057 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/hrfpn.py @@ -0,0 +1,100 @@ +import torch +import torch.nn as nn +import torch.nn.functional as F +from mmcv.cnn.weight_init import caffe2_xavier_init +from torch.utils.checkpoint import checkpoint + +from ..registry import NECKS +from ..utils import ConvModule + + +@NECKS.register_module +class HRFPN(nn.Module): + """HRFPN (High Resolution Feature Pyrmamids) + + arXiv: https://arxiv.org/abs/1904.04514 + + Args: + in_channels (list): number of channels for each branch. + out_channels (int): output channels of feature pyramids. + num_outs (int): number of output stages. + pooling_type (str): pooling for generating feature pyramids + from {MAX, AVG}. + conv_cfg (dict): dictionary to construct and config conv layer. + norm_cfg (dict): dictionary to construct and config norm layer. + with_cp (bool): Use checkpoint or not. Using checkpoint will save some + memory while slowing down the training speed. + stride (int): stride of 3x3 convolutional layers + """ + + def __init__(self, + in_channels, + out_channels, + num_outs=5, + pooling_type='AVG', + conv_cfg=None, + norm_cfg=None, + with_cp=False, + stride=1): + super(HRFPN, self).__init__() + assert isinstance(in_channels, list) + self.in_channels = in_channels + self.out_channels = out_channels + self.num_ins = len(in_channels) + self.num_outs = num_outs + self.with_cp = with_cp + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + + self.reduction_conv = ConvModule( + sum(in_channels), + out_channels, + kernel_size=1, + conv_cfg=self.conv_cfg, + activation=None) + + self.fpn_convs = nn.ModuleList() + for i in range(self.num_outs): + self.fpn_convs.append( + ConvModule( + out_channels, + out_channels, + kernel_size=3, + padding=1, + stride=stride, + conv_cfg=self.conv_cfg, + activation=None)) + + if pooling_type == 'MAX': + self.pooling = F.max_pool2d + else: + self.pooling = F.avg_pool2d + + def init_weights(self): + for m in self.modules(): + if isinstance(m, nn.Conv2d): + caffe2_xavier_init(m) + + def forward(self, inputs): + assert len(inputs) == self.num_ins + outs = [inputs[0]] + for i in range(1, self.num_ins): + outs.append( + F.interpolate(inputs[i], scale_factor=2**i, mode='bilinear')) + out = torch.cat(outs, dim=1) + if out.requires_grad and self.with_cp: + out = checkpoint(self.reduction_conv, out) + else: + out = self.reduction_conv(out) + outs = [out] + for i in range(1, self.num_outs): + outs.append(self.pooling(out, kernel_size=2**i, stride=2**i)) + outputs = [] + + for i in range(self.num_outs): + if outs[i].requires_grad and self.with_cp: + tmp_out = checkpoint(self.fpn_convs[i], outs[i]) + else: + tmp_out = self.fpn_convs[i](outs[i]) + outputs.append(tmp_out) + return tuple(outputs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/nas_fpn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/nas_fpn.py new file mode 100644 index 000000000..b0a689837 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/nas_fpn.py @@ -0,0 +1,186 @@ +import torch.nn as nn +import torch.nn.functional as F +from mmcv.cnn import caffe2_xavier_init + +from ..registry import NECKS +from ..utils import ConvModule + + +class MergingCell(nn.Module): + + def __init__(self, channels=256, with_conv=True, norm_cfg=None): + super(MergingCell, self).__init__() + self.with_conv = with_conv + if self.with_conv: + self.conv_out = ConvModule( + channels, + channels, + 3, + padding=1, + norm_cfg=norm_cfg, + order=('act', 'conv', 'norm')) + + def _binary_op(self, x1, x2): + raise NotImplementedError + + def _resize(self, x, size): + if x.shape[-2:] == size: + return x + elif x.shape[-2:] < size: + return F.interpolate(x, size=size, mode='nearest') + else: + assert x.shape[-2] % size[-2] == 0 and x.shape[-1] % size[-1] == 0 + kernel_size = x.shape[-1] // size[-1] + x = F.max_pool2d(x, kernel_size=kernel_size, stride=kernel_size) + return x + + def forward(self, x1, x2, out_size): + assert x1.shape[:2] == x2.shape[:2] + assert len(out_size) == 2 + + x1 = self._resize(x1, out_size) + x2 = self._resize(x2, out_size) + + x = self._binary_op(x1, x2) + if self.with_conv: + x = self.conv_out(x) + return x + + +class SumCell(MergingCell): + + def _binary_op(self, x1, x2): + return x1 + x2 + + +class GPCell(MergingCell): + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.global_pool = nn.AdaptiveAvgPool2d((1, 1)) + + def _binary_op(self, x1, x2): + x2_att = self.global_pool(x2).sigmoid() + return x2 + x2_att * x1 + + +@NECKS.register_module +class NASFPN(nn.Module): + """NAS-FPN. + + NAS-FPN: Learning Scalable Feature Pyramid Architecture for Object + Detection. (https://arxiv.org/abs/1904.07392) + """ + + def __init__(self, + in_channels, + out_channels, + num_outs, + stack_times, + start_level=0, + end_level=-1, + add_extra_convs=False, + norm_cfg=None): + super(NASFPN, self).__init__() + assert isinstance(in_channels, list) + self.in_channels = in_channels + self.out_channels = out_channels + self.num_ins = len(in_channels) # num of input feature levels + self.num_outs = num_outs # num of output feature levels + self.stack_times = stack_times + self.norm_cfg = norm_cfg + + if end_level == -1: + self.backbone_end_level = self.num_ins + assert num_outs >= self.num_ins - start_level + else: + # if end_level < inputs, no extra level is allowed + self.backbone_end_level = end_level + assert end_level <= len(in_channels) + assert num_outs == end_level - start_level + self.start_level = start_level + self.end_level = end_level + self.add_extra_convs = add_extra_convs + + # add lateral connections + self.lateral_convs = nn.ModuleList() + for i in range(self.start_level, self.backbone_end_level): + l_conv = ConvModule( + in_channels[i], + out_channels, + 1, + norm_cfg=norm_cfg, + activation=None) + self.lateral_convs.append(l_conv) + + # add extra downsample layers (stride-2 pooling or conv) + extra_levels = num_outs - self.backbone_end_level + self.start_level + self.extra_downsamples = nn.ModuleList() + for i in range(extra_levels): + extra_conv = ConvModule( + out_channels, + out_channels, + 1, + norm_cfg=norm_cfg, + activation=None) + self.extra_downsamples.append( + nn.Sequential(extra_conv, nn.MaxPool2d(2, 2))) + + # add NAS FPN connections + self.fpn_stages = nn.ModuleList() + for _ in range(self.stack_times): + stage = nn.ModuleDict() + # gp(p6, p4) -> p4_1 + stage['gp_64_4'] = GPCell(out_channels, norm_cfg=norm_cfg) + # sum(p4_1, p4) -> p4_2 + stage['sum_44_4'] = SumCell(out_channels, norm_cfg=norm_cfg) + # sum(p4_2, p3) -> p3_out + stage['sum_43_3'] = SumCell(out_channels, norm_cfg=norm_cfg) + # sum(p3_out, p4_2) -> p4_out + stage['sum_34_4'] = SumCell(out_channels, norm_cfg=norm_cfg) + # sum(p5, gp(p4_out, p3_out)) -> p5_out + stage['gp_43_5'] = GPCell(with_conv=False) + stage['sum_55_5'] = SumCell(out_channels, norm_cfg=norm_cfg) + # sum(p7, gp(p5_out, p4_2)) -> p7_out + stage['gp_54_7'] = GPCell(with_conv=False) + stage['sum_77_7'] = SumCell(out_channels, norm_cfg=norm_cfg) + # gp(p7_out, p5_out) -> p6_out + stage['gp_75_6'] = GPCell(out_channels, norm_cfg=norm_cfg) + self.fpn_stages.append(stage) + + def init_weights(self): + for m in self.modules(): + if isinstance(m, nn.Conv2d): + caffe2_xavier_init(m) + + def forward(self, inputs): + # build P3-P5 + feats = [ + lateral_conv(inputs[i + self.start_level]) + for i, lateral_conv in enumerate(self.lateral_convs) + ] + # build P6-P7 on top of P5 + for downsample in self.extra_downsamples: + feats.append(downsample(feats[-1])) + + p3, p4, p5, p6, p7 = feats + + for stage in self.fpn_stages: + # gp(p6, p4) -> p4_1 + p4_1 = stage['gp_64_4'](p6, p4, out_size=p4.shape[-2:]) + # sum(p4_1, p4) -> p4_2 + p4_2 = stage['sum_44_4'](p4_1, p4, out_size=p4.shape[-2:]) + # sum(p4_2, p3) -> p3_out + p3 = stage['sum_43_3'](p4_2, p3, out_size=p3.shape[-2:]) + # sum(p3_out, p4_2) -> p4_out + p4 = stage['sum_34_4'](p3, p4_2, out_size=p4.shape[-2:]) + # sum(p5, gp(p4_out, p3_out)) -> p5_out + p5_tmp = stage['gp_43_5'](p4, p3, out_size=p5.shape[-2:]) + p5 = stage['sum_55_5'](p5, p5_tmp, out_size=p5.shape[-2:]) + # sum(p7, gp(p5_out, p4_2)) -> p7_out + p7_tmp = stage['gp_54_7'](p5, p4_2, out_size=p7.shape[-2:]) + p7 = stage['sum_77_7'](p7, p7_tmp, out_size=p7.shape[-2:]) + # gp(p7_out, p5_out) -> p6_out + p6 = stage['gp_75_6'](p7, p5, out_size=p6.shape[-2:]) + + return p3, p4, p5, p6, p7 diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/__init__.py new file mode 100644 index 000000000..0ff85f2f5 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/__init__.py @@ -0,0 +1,4 @@ +from .generalized_attention import GeneralizedAttention +from .non_local import NonLocal2D + +__all__ = ['NonLocal2D', 'GeneralizedAttention'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/generalized_attention.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/generalized_attention.py new file mode 100644 index 000000000..86e5b1e9d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/generalized_attention.py @@ -0,0 +1,383 @@ +import math + +import numpy as np +import torch +import torch.nn as nn +import torch.nn.functional as F +from mmcv.cnn import kaiming_init + + +class GeneralizedAttention(nn.Module): + """GeneralizedAttention module. + + See 'An Empirical Study of Spatial Attention Mechanisms in Deep Networks' + (https://arxiv.org/abs/1711.07971) for details. + + Args: + in_dim (int): Channels of the input feature map. + spatial_range (int): The spatial range. + -1 indicates no spatial range constraint. + num_heads (int): The head number of empirical_attention module. + position_embedding_dim (int): The position embedding dimension. + position_magnitude (int): A multiplier acting on coord difference. + kv_stride (int): The feature stride acting on key/value feature map. + q_stride (int): The feature stride acting on query feature map. + attention_type (str): A binary indicator string for indicating which + items in generalized empirical_attention module are used. + '1000' indicates 'query and key content' (appr - appr) item, + '0100' indicates 'query content and relative position' + (appr - position) item, + '0010' indicates 'key content only' (bias - appr) item, + '0001' indicates 'relative position only' (bias - position) item. + """ + + def __init__(self, + in_dim, + spatial_range=-1, + num_heads=9, + position_embedding_dim=-1, + position_magnitude=1, + kv_stride=2, + q_stride=1, + attention_type='1111'): + + super(GeneralizedAttention, self).__init__() + + # hard range means local range for non-local operation + self.position_embedding_dim = ( + position_embedding_dim if position_embedding_dim > 0 else in_dim) + + self.position_magnitude = position_magnitude + self.num_heads = num_heads + self.channel_in = in_dim + self.spatial_range = spatial_range + self.kv_stride = kv_stride + self.q_stride = q_stride + self.attention_type = [bool(int(_)) for _ in attention_type] + self.qk_embed_dim = in_dim // num_heads + out_c = self.qk_embed_dim * num_heads + + if self.attention_type[0] or self.attention_type[1]: + self.query_conv = nn.Conv2d( + in_channels=in_dim, + out_channels=out_c, + kernel_size=1, + bias=False) + self.query_conv.kaiming_init = True + + if self.attention_type[0] or self.attention_type[2]: + self.key_conv = nn.Conv2d( + in_channels=in_dim, + out_channels=out_c, + kernel_size=1, + bias=False) + self.key_conv.kaiming_init = True + + self.v_dim = in_dim // num_heads + self.value_conv = nn.Conv2d( + in_channels=in_dim, + out_channels=self.v_dim * num_heads, + kernel_size=1, + bias=False) + self.value_conv.kaiming_init = True + + if self.attention_type[1] or self.attention_type[3]: + self.appr_geom_fc_x = nn.Linear( + self.position_embedding_dim // 2, out_c, bias=False) + self.appr_geom_fc_x.kaiming_init = True + + self.appr_geom_fc_y = nn.Linear( + self.position_embedding_dim // 2, out_c, bias=False) + self.appr_geom_fc_y.kaiming_init = True + + if self.attention_type[2]: + stdv = 1.0 / math.sqrt(self.qk_embed_dim * 2) + appr_bias_value = -2 * stdv * torch.rand(out_c) + stdv + self.appr_bias = nn.Parameter(appr_bias_value) + + if self.attention_type[3]: + stdv = 1.0 / math.sqrt(self.qk_embed_dim * 2) + geom_bias_value = -2 * stdv * torch.rand(out_c) + stdv + self.geom_bias = nn.Parameter(geom_bias_value) + + self.proj_conv = nn.Conv2d( + in_channels=self.v_dim * num_heads, + out_channels=in_dim, + kernel_size=1, + bias=True) + self.proj_conv.kaiming_init = True + self.gamma = nn.Parameter(torch.zeros(1)) + + if self.spatial_range >= 0: + # only works when non local is after 3*3 conv + if in_dim == 256: + max_len = 84 + elif in_dim == 512: + max_len = 42 + + max_len_kv = int((max_len - 1.0) / self.kv_stride + 1) + local_constraint_map = np.ones( + (max_len, max_len, max_len_kv, max_len_kv), dtype=np.int) + for iy in range(max_len): + for ix in range(max_len): + local_constraint_map[ + iy, ix, + max((iy - self.spatial_range) // + self.kv_stride, 0):min((iy + self.spatial_range + + 1) // self.kv_stride + + 1, max_len), + max((ix - self.spatial_range) // + self.kv_stride, 0):min((ix + self.spatial_range + + 1) // self.kv_stride + + 1, max_len)] = 0 + + self.local_constraint_map = nn.Parameter( + torch.from_numpy(local_constraint_map).byte(), + requires_grad=False) + + if self.q_stride > 1: + self.q_downsample = nn.AvgPool2d( + kernel_size=1, stride=self.q_stride) + else: + self.q_downsample = None + + if self.kv_stride > 1: + self.kv_downsample = nn.AvgPool2d( + kernel_size=1, stride=self.kv_stride) + else: + self.kv_downsample = None + + self.init_weights() + + def get_position_embedding(self, + h, + w, + h_kv, + w_kv, + q_stride, + kv_stride, + device, + feat_dim, + wave_length=1000): + h_idxs = torch.linspace(0, h - 1, h).cuda(device) + h_idxs = h_idxs.view((h, 1)) * q_stride + + w_idxs = torch.linspace(0, w - 1, w).cuda(device) + w_idxs = w_idxs.view((w, 1)) * q_stride + + h_kv_idxs = torch.linspace(0, h_kv - 1, h_kv).cuda(device) + h_kv_idxs = h_kv_idxs.view((h_kv, 1)) * kv_stride + + w_kv_idxs = torch.linspace(0, w_kv - 1, w_kv).cuda(device) + w_kv_idxs = w_kv_idxs.view((w_kv, 1)) * kv_stride + + # (h, h_kv, 1) + h_diff = h_idxs.unsqueeze(1) - h_kv_idxs.unsqueeze(0) + h_diff *= self.position_magnitude + + # (w, w_kv, 1) + w_diff = w_idxs.unsqueeze(1) - w_kv_idxs.unsqueeze(0) + w_diff *= self.position_magnitude + + feat_range = torch.arange(0, feat_dim / 4).cuda(device) + + dim_mat = torch.Tensor([wave_length]).cuda(device) + dim_mat = dim_mat**((4. / feat_dim) * feat_range) + dim_mat = dim_mat.view((1, 1, -1)) + + embedding_x = torch.cat( + ((w_diff / dim_mat).sin(), (w_diff / dim_mat).cos()), dim=2) + + embedding_y = torch.cat( + ((h_diff / dim_mat).sin(), (h_diff / dim_mat).cos()), dim=2) + + return embedding_x, embedding_y + + def forward(self, x_input): + num_heads = self.num_heads + + # use empirical_attention + if self.q_downsample is not None: + x_q = self.q_downsample(x_input) + else: + x_q = x_input + n, _, h, w = x_q.shape + + if self.kv_downsample is not None: + x_kv = self.kv_downsample(x_input) + else: + x_kv = x_input + _, _, h_kv, w_kv = x_kv.shape + + if self.attention_type[0] or self.attention_type[1]: + proj_query = self.query_conv(x_q).view( + (n, num_heads, self.qk_embed_dim, h * w)) + proj_query = proj_query.permute(0, 1, 3, 2) + + if self.attention_type[0] or self.attention_type[2]: + proj_key = self.key_conv(x_kv).view( + (n, num_heads, self.qk_embed_dim, h_kv * w_kv)) + + if self.attention_type[1] or self.attention_type[3]: + position_embed_x, position_embed_y = self.get_position_embedding( + h, w, h_kv, w_kv, self.q_stride, self.kv_stride, + x_input.device, self.position_embedding_dim) + # (n, num_heads, w, w_kv, dim) + position_feat_x = self.appr_geom_fc_x(position_embed_x).\ + view(1, w, w_kv, num_heads, self.qk_embed_dim).\ + permute(0, 3, 1, 2, 4).\ + repeat(n, 1, 1, 1, 1) + + # (n, num_heads, h, h_kv, dim) + position_feat_y = self.appr_geom_fc_y(position_embed_y).\ + view(1, h, h_kv, num_heads, self.qk_embed_dim).\ + permute(0, 3, 1, 2, 4).\ + repeat(n, 1, 1, 1, 1) + + position_feat_x /= math.sqrt(2) + position_feat_y /= math.sqrt(2) + + # accelerate for saliency only + if (np.sum(self.attention_type) == 1) and self.attention_type[2]: + appr_bias = self.appr_bias.\ + view(1, num_heads, 1, self.qk_embed_dim).\ + repeat(n, 1, 1, 1) + + energy = torch.matmul(appr_bias, proj_key).\ + view(n, num_heads, 1, h_kv * w_kv) + + h = 1 + w = 1 + else: + # (n, num_heads, h*w, h_kv*w_kv), query before key, 540mb for + if not self.attention_type[0]: + energy = torch.zeros( + n, + num_heads, + h, + w, + h_kv, + w_kv, + dtype=x_input.dtype, + device=x_input.device) + + # attention_type[0]: appr - appr + # attention_type[1]: appr - position + # attention_type[2]: bias - appr + # attention_type[3]: bias - position + if self.attention_type[0] or self.attention_type[2]: + if self.attention_type[0] and self.attention_type[2]: + appr_bias = self.appr_bias.\ + view(1, num_heads, 1, self.qk_embed_dim) + energy = torch.matmul(proj_query + appr_bias, proj_key).\ + view(n, num_heads, h, w, h_kv, w_kv) + + elif self.attention_type[0]: + energy = torch.matmul(proj_query, proj_key).\ + view(n, num_heads, h, w, h_kv, w_kv) + + elif self.attention_type[2]: + appr_bias = self.appr_bias.\ + view(1, num_heads, 1, self.qk_embed_dim).\ + repeat(n, 1, 1, 1) + + energy += torch.matmul(appr_bias, proj_key).\ + view(n, num_heads, 1, 1, h_kv, w_kv) + + if self.attention_type[1] or self.attention_type[3]: + if self.attention_type[1] and self.attention_type[3]: + geom_bias = self.geom_bias.\ + view(1, num_heads, 1, self.qk_embed_dim) + + proj_query_reshape = (proj_query + geom_bias).\ + view(n, num_heads, h, w, self.qk_embed_dim) + + energy_x = torch.matmul( + proj_query_reshape.permute(0, 1, 3, 2, 4), + position_feat_x.permute(0, 1, 2, 4, 3)) + energy_x = energy_x.\ + permute(0, 1, 3, 2, 4).unsqueeze(4) + + energy_y = torch.matmul( + proj_query_reshape, + position_feat_y.permute(0, 1, 2, 4, 3)) + energy_y = energy_y.unsqueeze(5) + + energy += energy_x + energy_y + + elif self.attention_type[1]: + proj_query_reshape = proj_query.\ + view(n, num_heads, h, w, self.qk_embed_dim) + proj_query_reshape = proj_query_reshape.\ + permute(0, 1, 3, 2, 4) + position_feat_x_reshape = position_feat_x.\ + permute(0, 1, 2, 4, 3) + position_feat_y_reshape = position_feat_y.\ + permute(0, 1, 2, 4, 3) + + energy_x = torch.matmul(proj_query_reshape, + position_feat_x_reshape) + energy_x = energy_x.permute(0, 1, 3, 2, 4).unsqueeze(4) + + energy_y = torch.matmul(proj_query_reshape, + position_feat_y_reshape) + energy_y = energy_y.unsqueeze(5) + + energy += energy_x + energy_y + + elif self.attention_type[3]: + geom_bias = self.geom_bias.\ + view(1, num_heads, self.qk_embed_dim, 1).\ + repeat(n, 1, 1, 1) + + position_feat_x_reshape = position_feat_x.\ + view(n, num_heads, w*w_kv, self.qk_embed_dim) + + position_feat_y_reshape = position_feat_y.\ + view(n, num_heads, h * h_kv, self.qk_embed_dim) + + energy_x = torch.matmul(position_feat_x_reshape, geom_bias) + energy_x = energy_x.view(n, num_heads, 1, w, 1, w_kv) + + energy_y = torch.matmul(position_feat_y_reshape, geom_bias) + energy_y = energy_y.view(n, num_heads, h, 1, h_kv, 1) + + energy += energy_x + energy_y + + energy = energy.view(n, num_heads, h * w, h_kv * w_kv) + + if self.spatial_range >= 0: + cur_local_constraint_map = \ + self.local_constraint_map[:h, :w, :h_kv, :w_kv].\ + contiguous().\ + view(1, 1, h*w, h_kv*w_kv) + + energy = energy.masked_fill_(cur_local_constraint_map, + float('-inf')) + + attention = F.softmax(energy, 3) + + proj_value = self.value_conv(x_kv) + proj_value_reshape = proj_value.\ + view((n, num_heads, self.v_dim, h_kv * w_kv)).\ + permute(0, 1, 3, 2) + + out = torch.matmul(attention, proj_value_reshape).\ + permute(0, 1, 3, 2).\ + contiguous().\ + view(n, self.v_dim * self.num_heads, h, w) + + out = self.proj_conv(out) + out = self.gamma * out + x_input + return out + + def init_weights(self): + for m in self.modules(): + if hasattr(m, 'kaiming_init') and m.kaiming_init: + kaiming_init( + m, + mode='fan_in', + nonlinearity='leaky_relu', + bias=0, + distribution='uniform', + a=1) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/non_local.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/non_local.py new file mode 100644 index 000000000..2e89c2fdc --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/non_local.py @@ -0,0 +1,114 @@ +import torch +import torch.nn as nn +from mmcv.cnn import constant_init, normal_init + +from ..utils import ConvModule + + +class NonLocal2D(nn.Module): + """Non-local module. + + See https://arxiv.org/abs/1711.07971 for details. + + Args: + in_channels (int): Channels of the input feature map. + reduction (int): Channel reduction ratio. + use_scale (bool): Whether to scale pairwise_weight by 1/inter_channels. + conv_cfg (dict): The config dict for convolution layers. + (only applicable to conv_out) + norm_cfg (dict): The config dict for normalization layers. + (only applicable to conv_out) + mode (str): Options are `embedded_gaussian` and `dot_product`. + """ + + def __init__(self, + in_channels, + reduction=2, + use_scale=True, + conv_cfg=None, + norm_cfg=None, + mode='embedded_gaussian'): + super(NonLocal2D, self).__init__() + self.in_channels = in_channels + self.reduction = reduction + self.use_scale = use_scale + self.inter_channels = in_channels // reduction + self.mode = mode + assert mode in ['embedded_gaussian', 'dot_product'] + + # g, theta, phi are actually `nn.Conv2d`. Here we use ConvModule for + # potential usage. + self.g = ConvModule( + self.in_channels, + self.inter_channels, + kernel_size=1, + activation=None) + self.theta = ConvModule( + self.in_channels, + self.inter_channels, + kernel_size=1, + activation=None) + self.phi = ConvModule( + self.in_channels, + self.inter_channels, + kernel_size=1, + activation=None) + self.conv_out = ConvModule( + self.inter_channels, + self.in_channels, + kernel_size=1, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + activation=None) + + self.init_weights() + + def init_weights(self, std=0.01, zeros_init=True): + for m in [self.g, self.theta, self.phi]: + normal_init(m.conv, std=std) + if zeros_init: + constant_init(self.conv_out.conv, 0) + else: + normal_init(self.conv_out.conv, std=std) + + def embedded_gaussian(self, theta_x, phi_x): + # pairwise_weight: [N, HxW, HxW] + pairwise_weight = torch.matmul(theta_x, phi_x) + if self.use_scale: + # theta_x.shape[-1] is `self.inter_channels` + pairwise_weight /= theta_x.shape[-1]**0.5 + pairwise_weight = pairwise_weight.softmax(dim=-1) + return pairwise_weight + + def dot_product(self, theta_x, phi_x): + # pairwise_weight: [N, HxW, HxW] + pairwise_weight = torch.matmul(theta_x, phi_x) + pairwise_weight /= pairwise_weight.shape[-1] + return pairwise_weight + + def forward(self, x): + n, _, h, w = x.shape + + # g_x: [N, HxW, C] + g_x = self.g(x).view(n, self.inter_channels, -1) + g_x = g_x.permute(0, 2, 1) + + # theta_x: [N, HxW, C] + theta_x = self.theta(x).view(n, self.inter_channels, -1) + theta_x = theta_x.permute(0, 2, 1) + + # phi_x: [N, C, HxW] + phi_x = self.phi(x).view(n, self.inter_channels, -1) + + pairwise_func = getattr(self, self.mode) + # pairwise_weight: [N, HxW, HxW] + pairwise_weight = pairwise_func(theta_x, phi_x) + + # y: [N, HxW, C] + y = torch.matmul(pairwise_weight, g_x) + # y: [N, C, H, W] + y = y.permute(0, 2, 1).reshape(n, self.inter_channels, h, w) + + output = x + self.conv_out(y) + + return output diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/registry.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/registry.py new file mode 100644 index 000000000..78ef24815 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/registry.py @@ -0,0 +1,9 @@ +from mmdet.utils import Registry + +BACKBONES = Registry('backbone') +NECKS = Registry('neck') +ROI_EXTRACTORS = Registry('roi_extractor') +SHARED_HEADS = Registry('shared_head') +HEADS = Registry('head') +LOSSES = Registry('loss') +DETECTORS = Registry('detector') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/roi_extractors/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/roi_extractors/__init__.py new file mode 100644 index 000000000..9161708ce --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/roi_extractors/__init__.py @@ -0,0 +1,3 @@ +from .single_level import SingleRoIExtractor + +__all__ = ['SingleRoIExtractor'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/roi_extractors/single_level.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/roi_extractors/single_level.py new file mode 100644 index 000000000..6620d1d86 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/roi_extractors/single_level.py @@ -0,0 +1,107 @@ +from __future__ import division + +import torch +import torch.nn as nn + +from mmdet import ops +from mmdet.core import force_fp32 +from ..registry import ROI_EXTRACTORS + + +@ROI_EXTRACTORS.register_module +class SingleRoIExtractor(nn.Module): + """Extract RoI features from a single level feature map. + + If there are mulitple input feature levels, each RoI is mapped to a level + according to its scale. + + Args: + roi_layer (dict): Specify RoI layer type and arguments. + out_channels (int): Output channels of RoI layers. + featmap_strides (int): Strides of input feature maps. + finest_scale (int): Scale threshold of mapping to level 0. + """ + + def __init__(self, + roi_layer, + out_channels, + featmap_strides, + finest_scale=56): + super(SingleRoIExtractor, self).__init__() + self.roi_layers = self.build_roi_layers(roi_layer, featmap_strides) + self.out_channels = out_channels + self.featmap_strides = featmap_strides + self.finest_scale = finest_scale + self.fp16_enabled = False + + @property + def num_inputs(self): + """int: Input feature map levels.""" + return len(self.featmap_strides) + + def init_weights(self): + pass + + def build_roi_layers(self, layer_cfg, featmap_strides): + cfg = layer_cfg.copy() + layer_type = cfg.pop('type') + assert hasattr(ops, layer_type) + layer_cls = getattr(ops, layer_type) + roi_layers = nn.ModuleList( + [layer_cls(spatial_scale=1 / s, **cfg) for s in featmap_strides]) + return roi_layers + + def map_roi_levels(self, rois, num_levels): + """Map rois to corresponding feature levels by scales. + + - scale < finest_scale * 2: level 0 + - finest_scale * 2 <= scale < finest_scale * 4: level 1 + - finest_scale * 4 <= scale < finest_scale * 8: level 2 + - scale >= finest_scale * 8: level 3 + + Args: + rois (Tensor): Input RoIs, shape (k, 5). + num_levels (int): Total level number. + + Returns: + Tensor: Level index (0-based) of each RoI, shape (k, ) + """ + scale = torch.sqrt( + (rois[:, 3] - rois[:, 1] + 1) * (rois[:, 4] - rois[:, 2] + 1)) + target_lvls = torch.floor(torch.log2(scale / self.finest_scale + 1e-6)) + target_lvls = target_lvls.clamp(min=0, max=num_levels - 1).long() + return target_lvls + + def roi_rescale(self, rois, scale_factor): + cx = (rois[:, 1] + rois[:, 3]) * 0.5 + cy = (rois[:, 2] + rois[:, 4]) * 0.5 + w = rois[:, 3] - rois[:, 1] + 1 + h = rois[:, 4] - rois[:, 2] + 1 + new_w = w * scale_factor + new_h = h * scale_factor + x1 = cx - new_w * 0.5 + 0.5 + x2 = cx + new_w * 0.5 - 0.5 + y1 = cy - new_h * 0.5 + 0.5 + y2 = cy + new_h * 0.5 - 0.5 + new_rois = torch.stack((rois[:, 0], x1, y1, x2, y2), dim=-1) + return new_rois + + @force_fp32(apply_to=('feats', ), out_fp16=True) + def forward(self, feats, rois, roi_scale_factor=None): + if len(feats) == 1: + return self.roi_layers[0](feats[0], rois) + + out_size = self.roi_layers[0].out_size + num_levels = len(feats) + target_lvls = self.map_roi_levels(rois, num_levels) + roi_feats = feats[0].new_zeros( + rois.size(0), self.out_channels, *out_size) + if roi_scale_factor is not None: + rois = self.roi_rescale(rois, roi_scale_factor) + for i in range(num_levels): + inds = target_lvls == i + if inds.any(): + rois_ = rois[inds, :] + roi_feats_t = self.roi_layers[i](feats[i], rois_) + roi_feats[inds] = roi_feats_t + return roi_feats diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/shared_heads/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/shared_heads/__init__.py new file mode 100644 index 000000000..bbe70145b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/shared_heads/__init__.py @@ -0,0 +1,3 @@ +from .res_layer import ResLayer + +__all__ = ['ResLayer'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/shared_heads/res_layer.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/shared_heads/res_layer.py new file mode 100644 index 000000000..e1a1ba0d7 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/shared_heads/res_layer.py @@ -0,0 +1,71 @@ +import torch.nn as nn +from mmcv.cnn import constant_init, kaiming_init +from mmcv.runner import load_checkpoint + +from mmdet.core import auto_fp16 +from mmdet.utils import get_root_logger +from ..backbones import ResNet, make_res_layer +from ..registry import SHARED_HEADS + + +@SHARED_HEADS.register_module +class ResLayer(nn.Module): + + def __init__(self, + depth, + stage=3, + stride=2, + dilation=1, + style='pytorch', + norm_cfg=dict(type='BN', requires_grad=True), + norm_eval=True, + with_cp=False, + dcn=None): + super(ResLayer, self).__init__() + self.norm_eval = norm_eval + self.norm_cfg = norm_cfg + self.stage = stage + self.fp16_enabled = False + block, stage_blocks = ResNet.arch_settings[depth] + stage_block = stage_blocks[stage] + planes = 64 * 2**stage + inplanes = 64 * 2**(stage - 1) * block.expansion + + res_layer = make_res_layer( + block, + inplanes, + planes, + stage_block, + stride=stride, + dilation=dilation, + style=style, + with_cp=with_cp, + norm_cfg=self.norm_cfg, + dcn=dcn) + self.add_module('layer{}'.format(stage + 1), res_layer) + + def init_weights(self, pretrained=None): + if isinstance(pretrained, str): + logger = get_root_logger() + load_checkpoint(self, pretrained, strict=False, logger=logger) + elif pretrained is None: + for m in self.modules(): + if isinstance(m, nn.Conv2d): + kaiming_init(m) + elif isinstance(m, nn.BatchNorm2d): + constant_init(m, 1) + else: + raise TypeError('pretrained must be a str or None') + + @auto_fp16() + def forward(self, x): + res_layer = getattr(self, 'layer{}'.format(self.stage + 1)) + out = res_layer(x) + return out + + def train(self, mode=True): + super(ResLayer, self).train(mode) + if self.norm_eval: + for m in self.modules(): + if isinstance(m, nn.BatchNorm2d): + m.eval() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/__init__.py new file mode 100644 index 000000000..3db40920d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/__init__.py @@ -0,0 +1,12 @@ +from .conv_module import ConvModule, build_conv_layer +from .conv_ws import ConvWS2d, conv_ws_2d +from .norm import build_norm_layer +from .scale import Scale +from .weight_init import (bias_init_with_prob, kaiming_init, normal_init, + uniform_init, xavier_init) + +__all__ = [ + 'conv_ws_2d', 'ConvWS2d', 'build_conv_layer', 'ConvModule', + 'build_norm_layer', 'xavier_init', 'normal_init', 'uniform_init', + 'kaiming_init', 'bias_init_with_prob', 'Scale' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/conv_module.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/conv_module.py new file mode 100644 index 000000000..3be32c3a4 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/conv_module.py @@ -0,0 +1,167 @@ +import warnings + +import torch.nn as nn +from mmcv.cnn import constant_init, kaiming_init + +from mmdet.ops import DeformConvPack, ModulatedDeformConvPack +from .conv_ws import ConvWS2d +from .norm import build_norm_layer + +conv_cfg = { + 'Conv': nn.Conv2d, + 'ConvWS': ConvWS2d, + 'DCN': DeformConvPack, + 'DCNv2': ModulatedDeformConvPack, + # TODO: octave conv +} + + +def build_conv_layer(cfg, *args, **kwargs): + """ Build convolution layer + + Args: + cfg (None or dict): cfg should contain: + type (str): identify conv layer type. + layer args: args needed to instantiate a conv layer. + + Returns: + layer (nn.Module): created conv layer + """ + if cfg is None: + cfg_ = dict(type='Conv') + else: + assert isinstance(cfg, dict) and 'type' in cfg + cfg_ = cfg.copy() + + layer_type = cfg_.pop('type') + if layer_type not in conv_cfg: + raise KeyError('Unrecognized norm type {}'.format(layer_type)) + else: + conv_layer = conv_cfg[layer_type] + + layer = conv_layer(*args, **kwargs, **cfg_) + + return layer + + +class ConvModule(nn.Module): + """A conv block that contains conv/norm/activation layers. + + Args: + in_channels (int): Same as nn.Conv2d. + out_channels (int): Same as nn.Conv2d. + kernel_size (int or tuple[int]): Same as nn.Conv2d. + stride (int or tuple[int]): Same as nn.Conv2d. + padding (int or tuple[int]): Same as nn.Conv2d. + dilation (int or tuple[int]): Same as nn.Conv2d. + groups (int): Same as nn.Conv2d. + bias (bool or str): If specified as `auto`, it will be decided by the + norm_cfg. Bias will be set as True if norm_cfg is None, otherwise + False. + conv_cfg (dict): Config dict for convolution layer. + norm_cfg (dict): Config dict for normalization layer. + activation (str or None): Activation type, "ReLU" by default. + inplace (bool): Whether to use inplace mode for activation. + order (tuple[str]): The order of conv/norm/activation layers. It is a + sequence of "conv", "norm" and "act". Examples are + ("conv", "norm", "act") and ("act", "conv", "norm"). + """ + + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride=1, + padding=0, + dilation=1, + groups=1, + bias='auto', + conv_cfg=None, + norm_cfg=None, + activation='relu', + inplace=True, + order=('conv', 'norm', 'act')): + super(ConvModule, self).__init__() + assert conv_cfg is None or isinstance(conv_cfg, dict) + assert norm_cfg is None or isinstance(norm_cfg, dict) + self.conv_cfg = conv_cfg + self.norm_cfg = norm_cfg + self.activation = activation + self.inplace = inplace + self.order = order + assert isinstance(self.order, tuple) and len(self.order) == 3 + assert set(order) == set(['conv', 'norm', 'act']) + + self.with_norm = norm_cfg is not None + self.with_activation = activation is not None + # if the conv layer is before a norm layer, bias is unnecessary. + if bias == 'auto': + bias = False if self.with_norm else True + self.with_bias = bias + + if self.with_norm and self.with_bias: + warnings.warn('ConvModule has norm and bias at the same time') + + # build convolution layer + self.conv = build_conv_layer( + conv_cfg, + in_channels, + out_channels, + kernel_size, + stride=stride, + padding=padding, + dilation=dilation, + groups=groups, + bias=bias) + # export the attributes of self.conv to a higher level for convenience + self.in_channels = self.conv.in_channels + self.out_channels = self.conv.out_channels + self.kernel_size = self.conv.kernel_size + self.stride = self.conv.stride + self.padding = self.conv.padding + self.dilation = self.conv.dilation + self.transposed = self.conv.transposed + self.output_padding = self.conv.output_padding + self.groups = self.conv.groups + + # build normalization layers + if self.with_norm: + # norm layer is after conv layer + if order.index('norm') > order.index('conv'): + norm_channels = out_channels + else: + norm_channels = in_channels + self.norm_name, norm = build_norm_layer(norm_cfg, norm_channels) + self.add_module(self.norm_name, norm) + + # build activation layer + if self.with_activation: + # TODO: introduce `act_cfg` and supports more activation layers + if self.activation not in ['relu']: + raise ValueError('{} is currently not supported.'.format( + self.activation)) + if self.activation == 'relu': + self.activate = nn.ReLU(inplace=inplace) + + # Use msra init by default + self.init_weights() + + @property + def norm(self): + return getattr(self, self.norm_name) + + def init_weights(self): + nonlinearity = 'relu' if self.activation is None else self.activation + kaiming_init(self.conv, nonlinearity=nonlinearity) + if self.with_norm: + constant_init(self.norm, 1, bias=0) + + def forward(self, x, activate=True, norm=True): + for layer in self.order: + if layer == 'conv': + x = self.conv(x) + elif layer == 'norm' and norm and self.with_norm: + x = self.norm(x) + elif layer == 'act' and activate and self.with_activation: + x = self.activate(x) + return x diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/conv_ws.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/conv_ws.py new file mode 100644 index 000000000..5ccd735fd --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/conv_ws.py @@ -0,0 +1,46 @@ +import torch.nn as nn +import torch.nn.functional as F + + +def conv_ws_2d(input, + weight, + bias=None, + stride=1, + padding=0, + dilation=1, + groups=1, + eps=1e-5): + c_in = weight.size(0) + weight_flat = weight.view(c_in, -1) + mean = weight_flat.mean(dim=1, keepdim=True).view(c_in, 1, 1, 1) + std = weight_flat.std(dim=1, keepdim=True).view(c_in, 1, 1, 1) + weight = (weight - mean) / (std + eps) + return F.conv2d(input, weight, bias, stride, padding, dilation, groups) + + +class ConvWS2d(nn.Conv2d): + + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride=1, + padding=0, + dilation=1, + groups=1, + bias=True, + eps=1e-5): + super(ConvWS2d, self).__init__( + in_channels, + out_channels, + kernel_size, + stride=stride, + padding=padding, + dilation=dilation, + groups=groups, + bias=bias) + self.eps = eps + + def forward(self, x): + return conv_ws_2d(x, self.weight, self.bias, self.stride, self.padding, + self.dilation, self.groups, self.eps) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/norm.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/norm.py new file mode 100644 index 000000000..d5687cbd9 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/norm.py @@ -0,0 +1,55 @@ +import torch.nn as nn + +norm_cfg = { + # format: layer_type: (abbreviation, module) + 'BN': ('bn', nn.BatchNorm2d), + 'SyncBN': ('bn', nn.SyncBatchNorm), + 'GN': ('gn', nn.GroupNorm), + # and potentially 'SN' +} + + +def build_norm_layer(cfg, num_features, postfix=''): + """ Build normalization layer + + Args: + cfg (dict): cfg should contain: + type (str): identify norm layer type. + layer args: args needed to instantiate a norm layer. + requires_grad (bool): [optional] whether stop gradient updates + num_features (int): number of channels from input. + postfix (int, str): appended into norm abbreviation to + create named layer. + + Returns: + name (str): abbreviation + postfix + layer (nn.Module): created norm layer + """ + assert isinstance(cfg, dict) and 'type' in cfg + cfg_ = cfg.copy() + + layer_type = cfg_.pop('type') + if layer_type not in norm_cfg: + raise KeyError('Unrecognized norm type {}'.format(layer_type)) + else: + abbr, norm_layer = norm_cfg[layer_type] + if norm_layer is None: + raise NotImplementedError + + assert isinstance(postfix, (int, str)) + name = abbr + str(postfix) + + requires_grad = cfg_.pop('requires_grad', True) + cfg_.setdefault('eps', 1e-5) + if layer_type != 'GN': + layer = norm_layer(num_features, **cfg_) + if layer_type == 'SyncBN': + layer._specify_ddp_gpu_num(1) + else: + assert 'num_groups' in cfg_ + layer = norm_layer(num_channels=num_features, **cfg_) + + for param in layer.parameters(): + param.requires_grad = requires_grad + + return name, layer diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/scale.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/scale.py new file mode 100644 index 000000000..2461af8a6 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/scale.py @@ -0,0 +1,15 @@ +import torch +import torch.nn as nn + + +class Scale(nn.Module): + """ + A learnable scale parameter + """ + + def __init__(self, scale=1.0): + super(Scale, self).__init__() + self.scale = nn.Parameter(torch.tensor(scale, dtype=torch.float)) + + def forward(self, x): + return x * self.scale diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/weight_init.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/weight_init.py new file mode 100644 index 000000000..17d49880f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/weight_init.py @@ -0,0 +1,46 @@ +import numpy as np +import torch.nn as nn + + +def xavier_init(module, gain=1, bias=0, distribution='normal'): + assert distribution in ['uniform', 'normal'] + if distribution == 'uniform': + nn.init.xavier_uniform_(module.weight, gain=gain) + else: + nn.init.xavier_normal_(module.weight, gain=gain) + if hasattr(module, 'bias'): + nn.init.constant_(module.bias, bias) + + +def normal_init(module, mean=0, std=1, bias=0): + nn.init.normal_(module.weight, mean, std) + if hasattr(module, 'bias'): + nn.init.constant_(module.bias, bias) + + +def uniform_init(module, a=0, b=1, bias=0): + nn.init.uniform_(module.weight, a, b) + if hasattr(module, 'bias'): + nn.init.constant_(module.bias, bias) + + +def kaiming_init(module, + mode='fan_out', + nonlinearity='relu', + bias=0, + distribution='normal'): + assert distribution in ['uniform', 'normal'] + if distribution == 'uniform': + nn.init.kaiming_uniform_( + module.weight, mode=mode, nonlinearity=nonlinearity) + else: + nn.init.kaiming_normal_( + module.weight, mode=mode, nonlinearity=nonlinearity) + if hasattr(module, 'bias'): + nn.init.constant_(module.bias, bias) + + +def bias_init_with_prob(prior_prob): + """ initialize conv/fc bias value according to giving probablity""" + bias_init = float(-np.log((1 - prior_prob) / prior_prob)) + return bias_init diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/__init__.py new file mode 100644 index 000000000..5c6a1f37c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/__init__.py @@ -0,0 +1,21 @@ +from .context_block import ContextBlock +from .dcn import (DeformConv, DeformConvPack, DeformRoIPooling, + DeformRoIPoolingPack, ModulatedDeformConv, + ModulatedDeformConvPack, ModulatedDeformRoIPoolingPack, + deform_conv, deform_roi_pooling, modulated_deform_conv) +from .masked_conv import MaskedConv2d +from .nms import nms, soft_nms +from .roi_align import RoIAlign, roi_align +from .roi_pool import RoIPool, roi_pool +from .sigmoid_focal_loss import SigmoidFocalLoss, sigmoid_focal_loss +from .utils import get_compiler_version, get_compiling_cuda_version + +__all__ = [ + 'nms', 'soft_nms', 'RoIAlign', 'roi_align', 'RoIPool', 'roi_pool', + 'DeformConv', 'DeformConvPack', 'DeformRoIPooling', 'DeformRoIPoolingPack', + 'ModulatedDeformRoIPoolingPack', 'ModulatedDeformConv', + 'ModulatedDeformConvPack', 'deform_conv', 'modulated_deform_conv', + 'deform_roi_pooling', 'SigmoidFocalLoss', 'sigmoid_focal_loss', + 'MaskedConv2d', 'ContextBlock', 'get_compiler_version', + 'get_compiling_cuda_version' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/context_block.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/context_block.py new file mode 100644 index 000000000..be9092c48 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/context_block.py @@ -0,0 +1,104 @@ +import torch +from mmcv.cnn import constant_init, kaiming_init +from torch import nn + + +def last_zero_init(m): + if isinstance(m, nn.Sequential): + constant_init(m[-1], val=0) + else: + constant_init(m, val=0) + + +class ContextBlock(nn.Module): + + def __init__(self, + inplanes, + ratio, + pooling_type='att', + fusion_types=('channel_add', )): + super(ContextBlock, self).__init__() + assert pooling_type in ['avg', 'att'] + assert isinstance(fusion_types, (list, tuple)) + valid_fusion_types = ['channel_add', 'channel_mul'] + assert all([f in valid_fusion_types for f in fusion_types]) + assert len(fusion_types) > 0, 'at least one fusion should be used' + self.inplanes = inplanes + self.ratio = ratio + self.planes = int(inplanes * ratio) + self.pooling_type = pooling_type + self.fusion_types = fusion_types + if pooling_type == 'att': + self.conv_mask = nn.Conv2d(inplanes, 1, kernel_size=1) + self.softmax = nn.Softmax(dim=2) + else: + self.avg_pool = nn.AdaptiveAvgPool2d(1) + if 'channel_add' in fusion_types: + self.channel_add_conv = nn.Sequential( + nn.Conv2d(self.inplanes, self.planes, kernel_size=1), + nn.LayerNorm([self.planes, 1, 1]), + nn.ReLU(inplace=True), # yapf: disable + nn.Conv2d(self.planes, self.inplanes, kernel_size=1)) + else: + self.channel_add_conv = None + if 'channel_mul' in fusion_types: + self.channel_mul_conv = nn.Sequential( + nn.Conv2d(self.inplanes, self.planes, kernel_size=1), + nn.LayerNorm([self.planes, 1, 1]), + nn.ReLU(inplace=True), # yapf: disable + nn.Conv2d(self.planes, self.inplanes, kernel_size=1)) + else: + self.channel_mul_conv = None + self.reset_parameters() + + def reset_parameters(self): + if self.pooling_type == 'att': + kaiming_init(self.conv_mask, mode='fan_in') + self.conv_mask.inited = True + + if self.channel_add_conv is not None: + last_zero_init(self.channel_add_conv) + if self.channel_mul_conv is not None: + last_zero_init(self.channel_mul_conv) + + def spatial_pool(self, x): + batch, channel, height, width = x.size() + if self.pooling_type == 'att': + input_x = x + # [N, C, H * W] + input_x = input_x.view(batch, channel, height * width) + # [N, 1, C, H * W] + input_x = input_x.unsqueeze(1) + # [N, 1, H, W] + context_mask = self.conv_mask(x) + # [N, 1, H * W] + context_mask = context_mask.view(batch, 1, height * width) + # [N, 1, H * W] + context_mask = self.softmax(context_mask) + # [N, 1, H * W, 1] + context_mask = context_mask.unsqueeze(-1) + # [N, 1, C, 1] + context = torch.matmul(input_x, context_mask) + # [N, C, 1, 1] + context = context.view(batch, channel, 1, 1) + else: + # [N, C, 1, 1] + context = self.avg_pool(x) + + return context + + def forward(self, x): + # [N, C, 1, 1] + context = self.spatial_pool(x) + + out = x + if self.channel_mul_conv is not None: + # [N, C, 1, 1] + channel_mul_term = torch.sigmoid(self.channel_mul_conv(context)) + out = out * channel_mul_term + if self.channel_add_conv is not None: + # [N, C, 1, 1] + channel_add_term = self.channel_add_conv(context) + out = out + channel_add_term + + return out diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/__init__.py new file mode 100644 index 000000000..79594c90b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/__init__.py @@ -0,0 +1,12 @@ +from .deform_conv import (DeformConv, DeformConvPack, ModulatedDeformConv, + ModulatedDeformConvPack, deform_conv, + modulated_deform_conv) +from .deform_pool import (DeformRoIPooling, DeformRoIPoolingPack, + ModulatedDeformRoIPoolingPack, deform_roi_pooling) + +__all__ = [ + 'DeformConv', 'DeformConvPack', 'ModulatedDeformConv', + 'ModulatedDeformConvPack', 'DeformRoIPooling', 'DeformRoIPoolingPack', + 'ModulatedDeformRoIPoolingPack', 'deform_conv', 'modulated_deform_conv', + 'deform_roi_pooling' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/deform_conv.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/deform_conv.py new file mode 100644 index 000000000..5ba5a5e8f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/deform_conv.py @@ -0,0 +1,431 @@ +import math + +import torch +import torch.nn as nn +from torch.autograd import Function +from torch.autograd.function import once_differentiable +from torch.nn.modules.utils import _pair, _single + +from mmdet.utils import print_log +from . import deform_conv_cuda + + +class DeformConvFunction(Function): + + @staticmethod + def forward(ctx, + input, + offset, + weight, + stride=1, + padding=0, + dilation=1, + groups=1, + deformable_groups=1, + im2col_step=64): + if input is not None and input.dim() != 4: + raise ValueError( + 'Expected 4D tensor as input, got {}D tensor instead.'.format( + input.dim())) + ctx.stride = _pair(stride) + ctx.padding = _pair(padding) + ctx.dilation = _pair(dilation) + ctx.groups = groups + ctx.deformable_groups = deformable_groups + ctx.im2col_step = im2col_step + + ctx.save_for_backward(input, offset, weight) + + output = input.new_empty( + DeformConvFunction._output_size(input, weight, ctx.padding, + ctx.dilation, ctx.stride)) + + ctx.bufs_ = [input.new_empty(0), input.new_empty(0)] # columns, ones + + if not input.is_cuda: + raise NotImplementedError + else: + cur_im2col_step = min(ctx.im2col_step, input.shape[0]) + assert (input.shape[0] % + cur_im2col_step) == 0, 'im2col step must divide batchsize' + deform_conv_cuda.deform_conv_forward_cuda( + input, weight, offset, output, ctx.bufs_[0], ctx.bufs_[1], + weight.size(3), weight.size(2), ctx.stride[1], ctx.stride[0], + ctx.padding[1], ctx.padding[0], ctx.dilation[1], + ctx.dilation[0], ctx.groups, ctx.deformable_groups, + cur_im2col_step) + return output + + @staticmethod + @once_differentiable + def backward(ctx, grad_output): + input, offset, weight = ctx.saved_tensors + + grad_input = grad_offset = grad_weight = None + + if not grad_output.is_cuda: + raise NotImplementedError + else: + cur_im2col_step = min(ctx.im2col_step, input.shape[0]) + assert (input.shape[0] % + cur_im2col_step) == 0, 'im2col step must divide batchsize' + + if ctx.needs_input_grad[0] or ctx.needs_input_grad[1]: + grad_input = torch.zeros_like(input) + grad_offset = torch.zeros_like(offset) + deform_conv_cuda.deform_conv_backward_input_cuda( + input, offset, grad_output, grad_input, + grad_offset, weight, ctx.bufs_[0], weight.size(3), + weight.size(2), ctx.stride[1], ctx.stride[0], + ctx.padding[1], ctx.padding[0], ctx.dilation[1], + ctx.dilation[0], ctx.groups, ctx.deformable_groups, + cur_im2col_step) + + if ctx.needs_input_grad[2]: + grad_weight = torch.zeros_like(weight) + deform_conv_cuda.deform_conv_backward_parameters_cuda( + input, offset, grad_output, + grad_weight, ctx.bufs_[0], ctx.bufs_[1], weight.size(3), + weight.size(2), ctx.stride[1], ctx.stride[0], + ctx.padding[1], ctx.padding[0], ctx.dilation[1], + ctx.dilation[0], ctx.groups, ctx.deformable_groups, 1, + cur_im2col_step) + + return (grad_input, grad_offset, grad_weight, None, None, None, None, + None) + + @staticmethod + def _output_size(input, weight, padding, dilation, stride): + channels = weight.size(0) + output_size = (input.size(0), channels) + for d in range(input.dim() - 2): + in_size = input.size(d + 2) + pad = padding[d] + kernel = dilation[d] * (weight.size(d + 2) - 1) + 1 + stride_ = stride[d] + output_size += ((in_size + (2 * pad) - kernel) // stride_ + 1, ) + if not all(map(lambda s: s > 0, output_size)): + raise ValueError( + 'convolution input is too small (output would be {})'.format( + 'x'.join(map(str, output_size)))) + return output_size + + +class ModulatedDeformConvFunction(Function): + + @staticmethod + def forward(ctx, + input, + offset, + mask, + weight, + bias=None, + stride=1, + padding=0, + dilation=1, + groups=1, + deformable_groups=1): + ctx.stride = stride + ctx.padding = padding + ctx.dilation = dilation + ctx.groups = groups + ctx.deformable_groups = deformable_groups + ctx.with_bias = bias is not None + if not ctx.with_bias: + bias = input.new_empty(1) # fake tensor + if not input.is_cuda: + raise NotImplementedError + if weight.requires_grad or mask.requires_grad or offset.requires_grad \ + or input.requires_grad: + ctx.save_for_backward(input, offset, mask, weight, bias) + output = input.new_empty( + ModulatedDeformConvFunction._infer_shape(ctx, input, weight)) + ctx._bufs = [input.new_empty(0), input.new_empty(0)] + deform_conv_cuda.modulated_deform_conv_cuda_forward( + input, weight, bias, ctx._bufs[0], offset, mask, output, + ctx._bufs[1], weight.shape[2], weight.shape[3], ctx.stride, + ctx.stride, ctx.padding, ctx.padding, ctx.dilation, ctx.dilation, + ctx.groups, ctx.deformable_groups, ctx.with_bias) + return output + + @staticmethod + @once_differentiable + def backward(ctx, grad_output): + if not grad_output.is_cuda: + raise NotImplementedError + input, offset, mask, weight, bias = ctx.saved_tensors + grad_input = torch.zeros_like(input) + grad_offset = torch.zeros_like(offset) + grad_mask = torch.zeros_like(mask) + grad_weight = torch.zeros_like(weight) + grad_bias = torch.zeros_like(bias) + deform_conv_cuda.modulated_deform_conv_cuda_backward( + input, weight, bias, ctx._bufs[0], offset, mask, ctx._bufs[1], + grad_input, grad_weight, grad_bias, grad_offset, grad_mask, + grad_output, weight.shape[2], weight.shape[3], ctx.stride, + ctx.stride, ctx.padding, ctx.padding, ctx.dilation, ctx.dilation, + ctx.groups, ctx.deformable_groups, ctx.with_bias) + if not ctx.with_bias: + grad_bias = None + + return (grad_input, grad_offset, grad_mask, grad_weight, grad_bias, + None, None, None, None, None) + + @staticmethod + def _infer_shape(ctx, input, weight): + n = input.size(0) + channels_out = weight.size(0) + height, width = input.shape[2:4] + kernel_h, kernel_w = weight.shape[2:4] + height_out = (height + 2 * ctx.padding - + (ctx.dilation * (kernel_h - 1) + 1)) // ctx.stride + 1 + width_out = (width + 2 * ctx.padding - + (ctx.dilation * (kernel_w - 1) + 1)) // ctx.stride + 1 + return n, channels_out, height_out, width_out + + +deform_conv = DeformConvFunction.apply +modulated_deform_conv = ModulatedDeformConvFunction.apply + + +class DeformConv(nn.Module): + + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride=1, + padding=0, + dilation=1, + groups=1, + deformable_groups=1, + bias=False): + super(DeformConv, self).__init__() + + assert not bias + assert in_channels % groups == 0, \ + 'in_channels {} cannot be divisible by groups {}'.format( + in_channels, groups) + assert out_channels % groups == 0, \ + 'out_channels {} cannot be divisible by groups {}'.format( + out_channels, groups) + + self.in_channels = in_channels + self.out_channels = out_channels + self.kernel_size = _pair(kernel_size) + self.stride = _pair(stride) + self.padding = _pair(padding) + self.dilation = _pair(dilation) + self.groups = groups + self.deformable_groups = deformable_groups + # enable compatibility with nn.Conv2d + self.transposed = False + self.output_padding = _single(0) + + self.weight = nn.Parameter( + torch.Tensor(out_channels, in_channels // self.groups, + *self.kernel_size)) + + self.reset_parameters() + + def reset_parameters(self): + n = self.in_channels + for k in self.kernel_size: + n *= k + stdv = 1. / math.sqrt(n) + self.weight.data.uniform_(-stdv, stdv) + + def forward(self, x, offset): + return deform_conv(x, offset, self.weight, self.stride, self.padding, + self.dilation, self.groups, self.deformable_groups) + + +class DeformConvPack(DeformConv): + """A Deformable Conv Encapsulation that acts as normal Conv layers. + + Args: + in_channels (int): Same as nn.Conv2d. + out_channels (int): Same as nn.Conv2d. + kernel_size (int or tuple[int]): Same as nn.Conv2d. + stride (int or tuple[int]): Same as nn.Conv2d. + padding (int or tuple[int]): Same as nn.Conv2d. + dilation (int or tuple[int]): Same as nn.Conv2d. + groups (int): Same as nn.Conv2d. + bias (bool or str): If specified as `auto`, it will be decided by the + norm_cfg. Bias will be set as True if norm_cfg is None, otherwise + False. + """ + + _version = 2 + + def __init__(self, *args, **kwargs): + super(DeformConvPack, self).__init__(*args, **kwargs) + + self.conv_offset = nn.Conv2d( + self.in_channels, + self.deformable_groups * 2 * self.kernel_size[0] * + self.kernel_size[1], + kernel_size=self.kernel_size, + stride=_pair(self.stride), + padding=_pair(self.padding), + bias=True) + self.init_offset() + + def init_offset(self): + self.conv_offset.weight.data.zero_() + self.conv_offset.bias.data.zero_() + + def forward(self, x): + offset = self.conv_offset(x) + return deform_conv(x, offset, self.weight, self.stride, self.padding, + self.dilation, self.groups, self.deformable_groups) + + def _load_from_state_dict(self, state_dict, prefix, local_metadata, strict, + missing_keys, unexpected_keys, error_msgs): + version = local_metadata.get('version', None) + + if version is None or version < 2: + # the key is different in early versions + # In version < 2, DeformConvPack loads previous benchmark models. + if (prefix + 'conv_offset.weight' not in state_dict + and prefix[:-1] + '_offset.weight' in state_dict): + state_dict[prefix + 'conv_offset.weight'] = state_dict.pop( + prefix[:-1] + '_offset.weight') + if (prefix + 'conv_offset.bias' not in state_dict + and prefix[:-1] + '_offset.bias' in state_dict): + state_dict[prefix + + 'conv_offset.bias'] = state_dict.pop(prefix[:-1] + + '_offset.bias') + + if version is not None and version > 1: + print_log( + 'DeformConvPack {} is upgraded to version 2.'.format( + prefix.rstrip('.')), + logger='root') + + super()._load_from_state_dict(state_dict, prefix, local_metadata, + strict, missing_keys, unexpected_keys, + error_msgs) + + +class ModulatedDeformConv(nn.Module): + + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride=1, + padding=0, + dilation=1, + groups=1, + deformable_groups=1, + bias=True): + super(ModulatedDeformConv, self).__init__() + self.in_channels = in_channels + self.out_channels = out_channels + self.kernel_size = _pair(kernel_size) + self.stride = stride + self.padding = padding + self.dilation = dilation + self.groups = groups + self.deformable_groups = deformable_groups + self.with_bias = bias + # enable compatibility with nn.Conv2d + self.transposed = False + self.output_padding = _single(0) + + self.weight = nn.Parameter( + torch.Tensor(out_channels, in_channels // groups, + *self.kernel_size)) + if bias: + self.bias = nn.Parameter(torch.Tensor(out_channels)) + else: + self.register_parameter('bias', None) + self.reset_parameters() + + def reset_parameters(self): + n = self.in_channels + for k in self.kernel_size: + n *= k + stdv = 1. / math.sqrt(n) + self.weight.data.uniform_(-stdv, stdv) + if self.bias is not None: + self.bias.data.zero_() + + def forward(self, x, offset, mask): + return modulated_deform_conv(x, offset, mask, self.weight, self.bias, + self.stride, self.padding, self.dilation, + self.groups, self.deformable_groups) + + +class ModulatedDeformConvPack(ModulatedDeformConv): + """A ModulatedDeformable Conv Encapsulation that acts as normal Conv layers. + + Args: + in_channels (int): Same as nn.Conv2d. + out_channels (int): Same as nn.Conv2d. + kernel_size (int or tuple[int]): Same as nn.Conv2d. + stride (int or tuple[int]): Same as nn.Conv2d. + padding (int or tuple[int]): Same as nn.Conv2d. + dilation (int or tuple[int]): Same as nn.Conv2d. + groups (int): Same as nn.Conv2d. + bias (bool or str): If specified as `auto`, it will be decided by the + norm_cfg. Bias will be set as True if norm_cfg is None, otherwise + False. + """ + + _version = 2 + + def __init__(self, *args, **kwargs): + super(ModulatedDeformConvPack, self).__init__(*args, **kwargs) + + self.conv_offset = nn.Conv2d( + self.in_channels, + self.deformable_groups * 3 * self.kernel_size[0] * + self.kernel_size[1], + kernel_size=self.kernel_size, + stride=_pair(self.stride), + padding=_pair(self.padding), + bias=True) + self.init_offset() + + def init_offset(self): + self.conv_offset.weight.data.zero_() + self.conv_offset.bias.data.zero_() + + def forward(self, x): + out = self.conv_offset(x) + o1, o2, mask = torch.chunk(out, 3, dim=1) + offset = torch.cat((o1, o2), dim=1) + mask = torch.sigmoid(mask) + return modulated_deform_conv(x, offset, mask, self.weight, self.bias, + self.stride, self.padding, self.dilation, + self.groups, self.deformable_groups) + + def _load_from_state_dict(self, state_dict, prefix, local_metadata, strict, + missing_keys, unexpected_keys, error_msgs): + version = local_metadata.get('version', None) + + if version is None or version < 2: + # the key is different in early versions + # In version < 2, ModulatedDeformConvPack + # loads previous benchmark models. + if (prefix + 'conv_offset.weight' not in state_dict + and prefix[:-1] + '_offset.weight' in state_dict): + state_dict[prefix + 'conv_offset.weight'] = state_dict.pop( + prefix[:-1] + '_offset.weight') + if (prefix + 'conv_offset.bias' not in state_dict + and prefix[:-1] + '_offset.bias' in state_dict): + state_dict[prefix + + 'conv_offset.bias'] = state_dict.pop(prefix[:-1] + + '_offset.bias') + + if version is not None and version > 1: + print_log( + 'ModulatedDeformConvPack {} is upgraded to version 2.'.format( + prefix.rstrip('.')), + logger='root') + + super()._load_from_state_dict(state_dict, prefix, local_metadata, + strict, missing_keys, unexpected_keys, + error_msgs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/deform_pool.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/deform_pool.py new file mode 100644 index 000000000..99a4a3618 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/deform_pool.py @@ -0,0 +1,252 @@ +import torch +import torch.nn as nn +from torch.autograd import Function +from torch.autograd.function import once_differentiable +from torch.nn.modules.utils import _pair + +from . import deform_pool_cuda + + +class DeformRoIPoolingFunction(Function): + + @staticmethod + def forward(ctx, + data, + rois, + offset, + spatial_scale, + out_size, + out_channels, + no_trans, + group_size=1, + part_size=None, + sample_per_part=4, + trans_std=.0): + # TODO: support unsquare RoIs + out_h, out_w = _pair(out_size) + assert isinstance(out_h, int) and isinstance(out_w, int) + assert out_h == out_w + out_size = out_h # out_h and out_w must be equal + + ctx.spatial_scale = spatial_scale + ctx.out_size = out_size + ctx.out_channels = out_channels + ctx.no_trans = no_trans + ctx.group_size = group_size + ctx.part_size = out_size if part_size is None else part_size + ctx.sample_per_part = sample_per_part + ctx.trans_std = trans_std + + assert 0.0 <= ctx.trans_std <= 1.0 + if not data.is_cuda: + raise NotImplementedError + + n = rois.shape[0] + output = data.new_empty(n, out_channels, out_size, out_size) + output_count = data.new_empty(n, out_channels, out_size, out_size) + deform_pool_cuda.deform_psroi_pooling_cuda_forward( + data, rois, offset, output, output_count, ctx.no_trans, + ctx.spatial_scale, ctx.out_channels, ctx.group_size, ctx.out_size, + ctx.part_size, ctx.sample_per_part, ctx.trans_std) + + if data.requires_grad or rois.requires_grad or offset.requires_grad: + ctx.save_for_backward(data, rois, offset) + ctx.output_count = output_count + + return output + + @staticmethod + @once_differentiable + def backward(ctx, grad_output): + if not grad_output.is_cuda: + raise NotImplementedError + + data, rois, offset = ctx.saved_tensors + output_count = ctx.output_count + grad_input = torch.zeros_like(data) + grad_rois = None + grad_offset = torch.zeros_like(offset) + + deform_pool_cuda.deform_psroi_pooling_cuda_backward( + grad_output, data, rois, offset, output_count, grad_input, + grad_offset, ctx.no_trans, ctx.spatial_scale, ctx.out_channels, + ctx.group_size, ctx.out_size, ctx.part_size, ctx.sample_per_part, + ctx.trans_std) + return (grad_input, grad_rois, grad_offset, None, None, None, None, + None, None, None, None) + + +deform_roi_pooling = DeformRoIPoolingFunction.apply + + +class DeformRoIPooling(nn.Module): + + def __init__(self, + spatial_scale, + out_size, + out_channels, + no_trans, + group_size=1, + part_size=None, + sample_per_part=4, + trans_std=.0): + super(DeformRoIPooling, self).__init__() + self.spatial_scale = spatial_scale + self.out_size = _pair(out_size) + self.out_channels = out_channels + self.no_trans = no_trans + self.group_size = group_size + self.part_size = out_size if part_size is None else part_size + self.sample_per_part = sample_per_part + self.trans_std = trans_std + + def forward(self, data, rois, offset): + if self.no_trans: + offset = data.new_empty(0) + return deform_roi_pooling(data, rois, offset, self.spatial_scale, + self.out_size, self.out_channels, + self.no_trans, self.group_size, + self.part_size, self.sample_per_part, + self.trans_std) + + +class DeformRoIPoolingPack(DeformRoIPooling): + + def __init__(self, + spatial_scale, + out_size, + out_channels, + no_trans, + group_size=1, + part_size=None, + sample_per_part=4, + trans_std=.0, + num_offset_fcs=3, + deform_fc_channels=1024): + super(DeformRoIPoolingPack, + self).__init__(spatial_scale, out_size, out_channels, no_trans, + group_size, part_size, sample_per_part, trans_std) + + self.num_offset_fcs = num_offset_fcs + self.deform_fc_channels = deform_fc_channels + + if not no_trans: + seq = [] + ic = self.out_size[0] * self.out_size[1] * self.out_channels + for i in range(self.num_offset_fcs): + if i < self.num_offset_fcs - 1: + oc = self.deform_fc_channels + else: + oc = self.out_size[0] * self.out_size[1] * 2 + seq.append(nn.Linear(ic, oc)) + ic = oc + if i < self.num_offset_fcs - 1: + seq.append(nn.ReLU(inplace=True)) + self.offset_fc = nn.Sequential(*seq) + self.offset_fc[-1].weight.data.zero_() + self.offset_fc[-1].bias.data.zero_() + + def forward(self, data, rois): + assert data.size(1) == self.out_channels + if self.no_trans: + offset = data.new_empty(0) + return deform_roi_pooling(data, rois, offset, self.spatial_scale, + self.out_size, self.out_channels, + self.no_trans, self.group_size, + self.part_size, self.sample_per_part, + self.trans_std) + else: + n = rois.shape[0] + offset = data.new_empty(0) + x = deform_roi_pooling(data, rois, offset, self.spatial_scale, + self.out_size, self.out_channels, True, + self.group_size, self.part_size, + self.sample_per_part, self.trans_std) + offset = self.offset_fc(x.view(n, -1)) + offset = offset.view(n, 2, self.out_size[0], self.out_size[1]) + return deform_roi_pooling(data, rois, offset, self.spatial_scale, + self.out_size, self.out_channels, + self.no_trans, self.group_size, + self.part_size, self.sample_per_part, + self.trans_std) + + +class ModulatedDeformRoIPoolingPack(DeformRoIPooling): + + def __init__(self, + spatial_scale, + out_size, + out_channels, + no_trans, + group_size=1, + part_size=None, + sample_per_part=4, + trans_std=.0, + num_offset_fcs=3, + num_mask_fcs=2, + deform_fc_channels=1024): + super(ModulatedDeformRoIPoolingPack, + self).__init__(spatial_scale, out_size, out_channels, no_trans, + group_size, part_size, sample_per_part, trans_std) + + self.num_offset_fcs = num_offset_fcs + self.num_mask_fcs = num_mask_fcs + self.deform_fc_channels = deform_fc_channels + + if not no_trans: + offset_fc_seq = [] + ic = self.out_size[0] * self.out_size[1] * self.out_channels + for i in range(self.num_offset_fcs): + if i < self.num_offset_fcs - 1: + oc = self.deform_fc_channels + else: + oc = self.out_size[0] * self.out_size[1] * 2 + offset_fc_seq.append(nn.Linear(ic, oc)) + ic = oc + if i < self.num_offset_fcs - 1: + offset_fc_seq.append(nn.ReLU(inplace=True)) + self.offset_fc = nn.Sequential(*offset_fc_seq) + self.offset_fc[-1].weight.data.zero_() + self.offset_fc[-1].bias.data.zero_() + + mask_fc_seq = [] + ic = self.out_size[0] * self.out_size[1] * self.out_channels + for i in range(self.num_mask_fcs): + if i < self.num_mask_fcs - 1: + oc = self.deform_fc_channels + else: + oc = self.out_size[0] * self.out_size[1] + mask_fc_seq.append(nn.Linear(ic, oc)) + ic = oc + if i < self.num_mask_fcs - 1: + mask_fc_seq.append(nn.ReLU(inplace=True)) + else: + mask_fc_seq.append(nn.Sigmoid()) + self.mask_fc = nn.Sequential(*mask_fc_seq) + self.mask_fc[-2].weight.data.zero_() + self.mask_fc[-2].bias.data.zero_() + + def forward(self, data, rois): + assert data.size(1) == self.out_channels + if self.no_trans: + offset = data.new_empty(0) + return deform_roi_pooling(data, rois, offset, self.spatial_scale, + self.out_size, self.out_channels, + self.no_trans, self.group_size, + self.part_size, self.sample_per_part, + self.trans_std) + else: + n = rois.shape[0] + offset = data.new_empty(0) + x = deform_roi_pooling(data, rois, offset, self.spatial_scale, + self.out_size, self.out_channels, True, + self.group_size, self.part_size, + self.sample_per_part, self.trans_std) + offset = self.offset_fc(x.view(n, -1)) + offset = offset.view(n, 2, self.out_size[0], self.out_size[1]) + mask = self.mask_fc(x.view(n, -1)) + mask = mask.view(n, 1, self.out_size[0], self.out_size[1]) + return deform_roi_pooling( + data, rois, offset, self.spatial_scale, self.out_size, + self.out_channels, self.no_trans, self.group_size, + self.part_size, self.sample_per_part, self.trans_std) * mask diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_conv_cuda.cpp b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_conv_cuda.cpp new file mode 100644 index 000000000..ffe740dba --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_conv_cuda.cpp @@ -0,0 +1,701 @@ +// modify from +// https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/mmdetection/mmdet/ops/dcn/src/deform_conv_cuda.c + +#include +#include + +#include +#include + +void deformable_im2col(const at::Tensor data_im, const at::Tensor data_offset, + const int channels, const int height, const int width, + const int ksize_h, const int ksize_w, const int pad_h, + const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int parallel_imgs, const int deformable_group, + at::Tensor data_col); + +void deformable_col2im(const at::Tensor data_col, const at::Tensor data_offset, + const int channels, const int height, const int width, + const int ksize_h, const int ksize_w, const int pad_h, + const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int parallel_imgs, const int deformable_group, + at::Tensor grad_im); + +void deformable_col2im_coord( + const at::Tensor data_col, const at::Tensor data_im, + const at::Tensor data_offset, const int channels, const int height, + const int width, const int ksize_h, const int ksize_w, const int pad_h, + const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, const int parallel_imgs, + const int deformable_group, at::Tensor grad_offset); + +void modulated_deformable_im2col_cuda( + const at::Tensor data_im, const at::Tensor data_offset, + const at::Tensor data_mask, const int batch_size, const int channels, + const int height_im, const int width_im, const int height_col, + const int width_col, const int kernel_h, const int kenerl_w, + const int pad_h, const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, const int deformable_group, + at::Tensor data_col); + +void modulated_deformable_col2im_cuda( + const at::Tensor data_col, const at::Tensor data_offset, + const at::Tensor data_mask, const int batch_size, const int channels, + const int height_im, const int width_im, const int height_col, + const int width_col, const int kernel_h, const int kenerl_w, + const int pad_h, const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, const int deformable_group, + at::Tensor grad_im); + +void modulated_deformable_col2im_coord_cuda( + const at::Tensor data_col, const at::Tensor data_im, + const at::Tensor data_offset, const at::Tensor data_mask, + const int batch_size, const int channels, const int height_im, + const int width_im, const int height_col, const int width_col, + const int kernel_h, const int kenerl_w, const int pad_h, const int pad_w, + const int stride_h, const int stride_w, const int dilation_h, + const int dilation_w, const int deformable_group, at::Tensor grad_offset, + at::Tensor grad_mask); + +void shape_check(at::Tensor input, at::Tensor offset, at::Tensor *gradOutput, + at::Tensor weight, int kH, int kW, int dH, int dW, int padH, + int padW, int dilationH, int dilationW, int group, + int deformable_group) { + TORCH_CHECK(weight.ndimension() == 4, + "4D weight tensor (nOutputPlane,nInputPlane,kH,kW) expected, " + "but got: %s", + weight.ndimension()); + + TORCH_CHECK(weight.is_contiguous(), "weight tensor has to be contiguous"); + + TORCH_CHECK(kW > 0 && kH > 0, + "kernel size should be greater than zero, but got kH: %d kW: %d", kH, + kW); + + TORCH_CHECK((weight.size(2) == kH && weight.size(3) == kW), + "kernel size should be consistent with weight, ", + "but got kH: %d kW: %d weight.size(2): %d, weight.size(3): %d", kH, + kW, weight.size(2), weight.size(3)); + + TORCH_CHECK(dW > 0 && dH > 0, + "stride should be greater than zero, but got dH: %d dW: %d", dH, dW); + + TORCH_CHECK( + dilationW > 0 && dilationH > 0, + "dilation should be greater than 0, but got dilationH: %d dilationW: %d", + dilationH, dilationW); + + int ndim = input.ndimension(); + int dimf = 0; + int dimh = 1; + int dimw = 2; + + if (ndim == 4) { + dimf++; + dimh++; + dimw++; + } + + TORCH_CHECK(ndim == 3 || ndim == 4, "3D or 4D input tensor expected but got: %s", + ndim); + + long nInputPlane = weight.size(1) * group; + long inputHeight = input.size(dimh); + long inputWidth = input.size(dimw); + long nOutputPlane = weight.size(0); + long outputHeight = + (inputHeight + 2 * padH - (dilationH * (kH - 1) + 1)) / dH + 1; + long outputWidth = + (inputWidth + 2 * padW - (dilationW * (kW - 1) + 1)) / dW + 1; + + TORCH_CHECK(nInputPlane % deformable_group == 0, + "input channels must divide deformable group size"); + + if (outputWidth < 1 || outputHeight < 1) + AT_ERROR( + "Given input size: (%ld x %ld x %ld). " + "Calculated output size: (%ld x %ld x %ld). Output size is too small", + nInputPlane, inputHeight, inputWidth, nOutputPlane, outputHeight, + outputWidth); + + TORCH_CHECK(input.size(1) == nInputPlane, + "invalid number of input planes, expected: %d, but got: %d", + nInputPlane, input.size(1)); + + TORCH_CHECK((inputHeight >= kH && inputWidth >= kW), + "input image is smaller than kernel"); + + TORCH_CHECK((offset.size(2) == outputHeight && offset.size(3) == outputWidth), + "invalid spatial size of offset, expected height: %d width: %d, but " + "got height: %d width: %d", + outputHeight, outputWidth, offset.size(2), offset.size(3)); + + TORCH_CHECK((offset.size(1) == deformable_group * 2 * kH * kW), + "invalid number of channels of offset"); + + if (gradOutput != NULL) { + TORCH_CHECK(gradOutput->size(dimf) == nOutputPlane, + "invalid number of gradOutput planes, expected: %d, but got: %d", + nOutputPlane, gradOutput->size(dimf)); + + TORCH_CHECK((gradOutput->size(dimh) == outputHeight && + gradOutput->size(dimw) == outputWidth), + "invalid size of gradOutput, expected height: %d width: %d , but " + "got height: %d width: %d", + outputHeight, outputWidth, gradOutput->size(dimh), + gradOutput->size(dimw)); + } +} + +int deform_conv_forward_cuda(at::Tensor input, at::Tensor weight, + at::Tensor offset, at::Tensor output, + at::Tensor columns, at::Tensor ones, int kW, + int kH, int dW, int dH, int padW, int padH, + int dilationW, int dilationH, int group, + int deformable_group, int im2col_step) { + // todo: resize columns to include im2col: done + // todo: add im2col_step as input + // todo: add new output buffer and transpose it to output (or directly + // transpose output) todo: possibly change data indexing because of + // parallel_imgs + + shape_check(input, offset, NULL, weight, kH, kW, dH, dW, padH, padW, + dilationH, dilationW, group, deformable_group); + at::DeviceGuard guard(input.device()); + + input = input.contiguous(); + offset = offset.contiguous(); + weight = weight.contiguous(); + + int batch = 1; + if (input.ndimension() == 3) { + // Force batch + batch = 0; + input.unsqueeze_(0); + offset.unsqueeze_(0); + } + + // todo: assert batchsize dividable by im2col_step + + long batchSize = input.size(0); + long nInputPlane = input.size(1); + long inputHeight = input.size(2); + long inputWidth = input.size(3); + + long nOutputPlane = weight.size(0); + + long outputWidth = + (inputWidth + 2 * padW - (dilationW * (kW - 1) + 1)) / dW + 1; + long outputHeight = + (inputHeight + 2 * padH - (dilationH * (kH - 1) + 1)) / dH + 1; + + TORCH_CHECK((offset.size(0) == batchSize), "invalid batch size of offset"); + + output = output.view({batchSize / im2col_step, im2col_step, nOutputPlane, + outputHeight, outputWidth}); + columns = at::zeros( + {nInputPlane * kW * kH, im2col_step * outputHeight * outputWidth}, + input.options()); + + if (ones.ndimension() != 2 || + ones.size(0) * ones.size(1) < outputHeight * outputWidth) { + ones = at::ones({outputHeight, outputWidth}, input.options()); + } + + input = input.view({batchSize / im2col_step, im2col_step, nInputPlane, + inputHeight, inputWidth}); + offset = + offset.view({batchSize / im2col_step, im2col_step, + deformable_group * 2 * kH * kW, outputHeight, outputWidth}); + + at::Tensor output_buffer = + at::zeros({batchSize / im2col_step, nOutputPlane, + im2col_step * outputHeight, outputWidth}, + output.options()); + + output_buffer = output_buffer.view( + {output_buffer.size(0), group, output_buffer.size(1) / group, + output_buffer.size(2), output_buffer.size(3)}); + + for (int elt = 0; elt < batchSize / im2col_step; elt++) { + deformable_im2col(input[elt], offset[elt], nInputPlane, inputHeight, + inputWidth, kH, kW, padH, padW, dH, dW, dilationH, + dilationW, im2col_step, deformable_group, columns); + + columns = columns.view({group, columns.size(0) / group, columns.size(1)}); + weight = weight.view({group, weight.size(0) / group, weight.size(1), + weight.size(2), weight.size(3)}); + + for (int g = 0; g < group; g++) { + output_buffer[elt][g] = output_buffer[elt][g] + .flatten(1) + .addmm_(weight[g].flatten(1), columns[g]) + .view_as(output_buffer[elt][g]); + } + } + + output_buffer = output_buffer.view( + {output_buffer.size(0), output_buffer.size(1) * output_buffer.size(2), + output_buffer.size(3), output_buffer.size(4)}); + + output_buffer = output_buffer.view({batchSize / im2col_step, nOutputPlane, + im2col_step, outputHeight, outputWidth}); + output_buffer.transpose_(1, 2); + output.copy_(output_buffer); + output = output.view({batchSize, nOutputPlane, outputHeight, outputWidth}); + + input = input.view({batchSize, nInputPlane, inputHeight, inputWidth}); + offset = offset.view( + {batchSize, deformable_group * 2 * kH * kW, outputHeight, outputWidth}); + + if (batch == 0) { + output = output.view({nOutputPlane, outputHeight, outputWidth}); + input = input.view({nInputPlane, inputHeight, inputWidth}); + offset = offset.view({offset.size(1), offset.size(2), offset.size(3)}); + } + + return 1; +} + +int deform_conv_backward_input_cuda(at::Tensor input, at::Tensor offset, + at::Tensor gradOutput, at::Tensor gradInput, + at::Tensor gradOffset, at::Tensor weight, + at::Tensor columns, int kW, int kH, int dW, + int dH, int padW, int padH, int dilationW, + int dilationH, int group, + int deformable_group, int im2col_step) { + shape_check(input, offset, &gradOutput, weight, kH, kW, dH, dW, padH, padW, + dilationH, dilationW, group, deformable_group); + at::DeviceGuard guard(input.device()); + + input = input.contiguous(); + offset = offset.contiguous(); + gradOutput = gradOutput.contiguous(); + weight = weight.contiguous(); + + int batch = 1; + + if (input.ndimension() == 3) { + // Force batch + batch = 0; + input = input.view({1, input.size(0), input.size(1), input.size(2)}); + offset = offset.view({1, offset.size(0), offset.size(1), offset.size(2)}); + gradOutput = gradOutput.view( + {1, gradOutput.size(0), gradOutput.size(1), gradOutput.size(2)}); + } + + long batchSize = input.size(0); + long nInputPlane = input.size(1); + long inputHeight = input.size(2); + long inputWidth = input.size(3); + + long nOutputPlane = weight.size(0); + + long outputWidth = + (inputWidth + 2 * padW - (dilationW * (kW - 1) + 1)) / dW + 1; + long outputHeight = + (inputHeight + 2 * padH - (dilationH * (kH - 1) + 1)) / dH + 1; + + TORCH_CHECK((offset.size(0) == batchSize), 3, "invalid batch size of offset"); + gradInput = gradInput.view({batchSize, nInputPlane, inputHeight, inputWidth}); + columns = at::zeros( + {nInputPlane * kW * kH, im2col_step * outputHeight * outputWidth}, + input.options()); + + // change order of grad output + gradOutput = gradOutput.view({batchSize / im2col_step, im2col_step, + nOutputPlane, outputHeight, outputWidth}); + gradOutput.transpose_(1, 2); + + gradInput = gradInput.view({batchSize / im2col_step, im2col_step, nInputPlane, + inputHeight, inputWidth}); + input = input.view({batchSize / im2col_step, im2col_step, nInputPlane, + inputHeight, inputWidth}); + gradOffset = gradOffset.view({batchSize / im2col_step, im2col_step, + deformable_group * 2 * kH * kW, outputHeight, + outputWidth}); + offset = + offset.view({batchSize / im2col_step, im2col_step, + deformable_group * 2 * kH * kW, outputHeight, outputWidth}); + + for (int elt = 0; elt < batchSize / im2col_step; elt++) { + // divide into groups + columns = columns.view({group, columns.size(0) / group, columns.size(1)}); + weight = weight.view({group, weight.size(0) / group, weight.size(1), + weight.size(2), weight.size(3)}); + gradOutput = gradOutput.view( + {gradOutput.size(0), group, gradOutput.size(1) / group, + gradOutput.size(2), gradOutput.size(3), gradOutput.size(4)}); + + for (int g = 0; g < group; g++) { + columns[g] = columns[g].addmm_(weight[g].flatten(1).transpose(0, 1), + gradOutput[elt][g].flatten(1), 0.0f, 1.0f); + } + + columns = + columns.view({columns.size(0) * columns.size(1), columns.size(2)}); + gradOutput = gradOutput.view( + {gradOutput.size(0), gradOutput.size(1) * gradOutput.size(2), + gradOutput.size(3), gradOutput.size(4), gradOutput.size(5)}); + + deformable_col2im_coord(columns, input[elt], offset[elt], nInputPlane, + inputHeight, inputWidth, kH, kW, padH, padW, dH, dW, + dilationH, dilationW, im2col_step, deformable_group, + gradOffset[elt]); + + deformable_col2im(columns, offset[elt], nInputPlane, inputHeight, + inputWidth, kH, kW, padH, padW, dH, dW, dilationH, + dilationW, im2col_step, deformable_group, gradInput[elt]); + } + + gradOutput.transpose_(1, 2); + gradOutput = + gradOutput.view({batchSize, nOutputPlane, outputHeight, outputWidth}); + + gradInput = gradInput.view({batchSize, nInputPlane, inputHeight, inputWidth}); + input = input.view({batchSize, nInputPlane, inputHeight, inputWidth}); + gradOffset = gradOffset.view( + {batchSize, deformable_group * 2 * kH * kW, outputHeight, outputWidth}); + offset = offset.view( + {batchSize, deformable_group * 2 * kH * kW, outputHeight, outputWidth}); + + if (batch == 0) { + gradOutput = gradOutput.view({nOutputPlane, outputHeight, outputWidth}); + input = input.view({nInputPlane, inputHeight, inputWidth}); + gradInput = gradInput.view({nInputPlane, inputHeight, inputWidth}); + offset = offset.view({offset.size(1), offset.size(2), offset.size(3)}); + gradOffset = + gradOffset.view({offset.size(1), offset.size(2), offset.size(3)}); + } + + return 1; +} + +int deform_conv_backward_parameters_cuda( + at::Tensor input, at::Tensor offset, at::Tensor gradOutput, + at::Tensor gradWeight, // at::Tensor gradBias, + at::Tensor columns, at::Tensor ones, int kW, int kH, int dW, int dH, + int padW, int padH, int dilationW, int dilationH, int group, + int deformable_group, float scale, int im2col_step) { + // todo: transpose and reshape outGrad + // todo: reshape columns + // todo: add im2col_step as input + + shape_check(input, offset, &gradOutput, gradWeight, kH, kW, dH, dW, padH, + padW, dilationH, dilationW, group, deformable_group); + at::DeviceGuard guard(input.device()); + + input = input.contiguous(); + offset = offset.contiguous(); + gradOutput = gradOutput.contiguous(); + + int batch = 1; + + if (input.ndimension() == 3) { + // Force batch + batch = 0; + input = input.view( + at::IntList({1, input.size(0), input.size(1), input.size(2)})); + gradOutput = gradOutput.view( + {1, gradOutput.size(0), gradOutput.size(1), gradOutput.size(2)}); + } + + long batchSize = input.size(0); + long nInputPlane = input.size(1); + long inputHeight = input.size(2); + long inputWidth = input.size(3); + + long nOutputPlane = gradWeight.size(0); + + long outputWidth = + (inputWidth + 2 * padW - (dilationW * (kW - 1) + 1)) / dW + 1; + long outputHeight = + (inputHeight + 2 * padH - (dilationH * (kH - 1) + 1)) / dH + 1; + + TORCH_CHECK((offset.size(0) == batchSize), "invalid batch size of offset"); + + columns = at::zeros( + {nInputPlane * kW * kH, im2col_step * outputHeight * outputWidth}, + input.options()); + + gradOutput = gradOutput.view({batchSize / im2col_step, im2col_step, + nOutputPlane, outputHeight, outputWidth}); + gradOutput.transpose_(1, 2); + + at::Tensor gradOutputBuffer = at::zeros_like(gradOutput); + gradOutputBuffer = + gradOutputBuffer.view({batchSize / im2col_step, nOutputPlane, im2col_step, + outputHeight, outputWidth}); + gradOutputBuffer.copy_(gradOutput); + gradOutputBuffer = + gradOutputBuffer.view({batchSize / im2col_step, nOutputPlane, + im2col_step * outputHeight, outputWidth}); + + gradOutput.transpose_(1, 2); + gradOutput = + gradOutput.view({batchSize, nOutputPlane, outputHeight, outputWidth}); + + input = input.view({batchSize / im2col_step, im2col_step, nInputPlane, + inputHeight, inputWidth}); + offset = + offset.view({batchSize / im2col_step, im2col_step, + deformable_group * 2 * kH * kW, outputHeight, outputWidth}); + + for (int elt = 0; elt < batchSize / im2col_step; elt++) { + deformable_im2col(input[elt], offset[elt], nInputPlane, inputHeight, + inputWidth, kH, kW, padH, padW, dH, dW, dilationH, + dilationW, im2col_step, deformable_group, columns); + + // divide into group + gradOutputBuffer = gradOutputBuffer.view( + {gradOutputBuffer.size(0), group, gradOutputBuffer.size(1) / group, + gradOutputBuffer.size(2), gradOutputBuffer.size(3)}); + columns = columns.view({group, columns.size(0) / group, columns.size(1)}); + gradWeight = + gradWeight.view({group, gradWeight.size(0) / group, gradWeight.size(1), + gradWeight.size(2), gradWeight.size(3)}); + + for (int g = 0; g < group; g++) { + gradWeight[g] = gradWeight[g] + .flatten(1) + .addmm_(gradOutputBuffer[elt][g].flatten(1), + columns[g].transpose(1, 0), 1.0, scale) + .view_as(gradWeight[g]); + } + gradOutputBuffer = gradOutputBuffer.view( + {gradOutputBuffer.size(0), + gradOutputBuffer.size(1) * gradOutputBuffer.size(2), + gradOutputBuffer.size(3), gradOutputBuffer.size(4)}); + columns = + columns.view({columns.size(0) * columns.size(1), columns.size(2)}); + gradWeight = gradWeight.view({gradWeight.size(0) * gradWeight.size(1), + gradWeight.size(2), gradWeight.size(3), + gradWeight.size(4)}); + } + + input = input.view({batchSize, nInputPlane, inputHeight, inputWidth}); + offset = offset.view( + {batchSize, deformable_group * 2 * kH * kW, outputHeight, outputWidth}); + + if (batch == 0) { + gradOutput = gradOutput.view({nOutputPlane, outputHeight, outputWidth}); + input = input.view({nInputPlane, inputHeight, inputWidth}); + } + + return 1; +} + +void modulated_deform_conv_cuda_forward( + at::Tensor input, at::Tensor weight, at::Tensor bias, at::Tensor ones, + at::Tensor offset, at::Tensor mask, at::Tensor output, at::Tensor columns, + int kernel_h, int kernel_w, const int stride_h, const int stride_w, + const int pad_h, const int pad_w, const int dilation_h, + const int dilation_w, const int group, const int deformable_group, + const bool with_bias) { + TORCH_CHECK(input.is_contiguous(), "input tensor has to be contiguous"); + TORCH_CHECK(weight.is_contiguous(), "weight tensor has to be contiguous"); + at::DeviceGuard guard(input.device()); + + const int batch = input.size(0); + const int channels = input.size(1); + const int height = input.size(2); + const int width = input.size(3); + + const int channels_out = weight.size(0); + const int channels_kernel = weight.size(1); + const int kernel_h_ = weight.size(2); + const int kernel_w_ = weight.size(3); + + if (kernel_h_ != kernel_h || kernel_w_ != kernel_w) + AT_ERROR("Input shape and kernel shape wont match: (%d x %d vs %d x %d).", + kernel_h_, kernel_w, kernel_h_, kernel_w_); + if (channels != channels_kernel * group) + AT_ERROR("Input shape and kernel channels wont match: (%d vs %d).", + channels, channels_kernel * group); + + const int height_out = + (height + 2 * pad_h - (dilation_h * (kernel_h - 1) + 1)) / stride_h + 1; + const int width_out = + (width + 2 * pad_w - (dilation_w * (kernel_w - 1) + 1)) / stride_w + 1; + + if (ones.ndimension() != 2 || + ones.size(0) * ones.size(1) < height_out * width_out) { + // Resize plane and fill with ones... + ones = at::ones({height_out, width_out}, input.options()); + } + + // resize output + output = output.view({batch, channels_out, height_out, width_out}).zero_(); + // resize temporary columns + columns = + at::zeros({channels * kernel_h * kernel_w, 1 * height_out * width_out}, + input.options()); + + output = output.view({output.size(0), group, output.size(1) / group, + output.size(2), output.size(3)}); + + for (int b = 0; b < batch; b++) { + modulated_deformable_im2col_cuda( + input[b], offset[b], mask[b], 1, channels, height, width, height_out, + width_out, kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, + dilation_h, dilation_w, deformable_group, columns); + + // divide into group + weight = weight.view({group, weight.size(0) / group, weight.size(1), + weight.size(2), weight.size(3)}); + columns = columns.view({group, columns.size(0) / group, columns.size(1)}); + + for (int g = 0; g < group; g++) { + output[b][g] = output[b][g] + .flatten(1) + .addmm_(weight[g].flatten(1), columns[g]) + .view_as(output[b][g]); + } + + weight = weight.view({weight.size(0) * weight.size(1), weight.size(2), + weight.size(3), weight.size(4)}); + columns = + columns.view({columns.size(0) * columns.size(1), columns.size(2)}); + } + + output = output.view({output.size(0), output.size(1) * output.size(2), + output.size(3), output.size(4)}); + + if (with_bias) { + output += bias.view({1, bias.size(0), 1, 1}); + } +} + +void modulated_deform_conv_cuda_backward( + at::Tensor input, at::Tensor weight, at::Tensor bias, at::Tensor ones, + at::Tensor offset, at::Tensor mask, at::Tensor columns, + at::Tensor grad_input, at::Tensor grad_weight, at::Tensor grad_bias, + at::Tensor grad_offset, at::Tensor grad_mask, at::Tensor grad_output, + int kernel_h, int kernel_w, int stride_h, int stride_w, int pad_h, + int pad_w, int dilation_h, int dilation_w, int group, int deformable_group, + const bool with_bias) { + TORCH_CHECK(input.is_contiguous(), "input tensor has to be contiguous"); + TORCH_CHECK(weight.is_contiguous(), "weight tensor has to be contiguous"); + at::DeviceGuard guard(input.device()); + + const int batch = input.size(0); + const int channels = input.size(1); + const int height = input.size(2); + const int width = input.size(3); + + const int channels_kernel = weight.size(1); + const int kernel_h_ = weight.size(2); + const int kernel_w_ = weight.size(3); + if (kernel_h_ != kernel_h || kernel_w_ != kernel_w) + AT_ERROR("Input shape and kernel shape wont match: (%d x %d vs %d x %d).", + kernel_h_, kernel_w, kernel_h_, kernel_w_); + if (channels != channels_kernel * group) + AT_ERROR("Input shape and kernel channels wont match: (%d vs %d).", + channels, channels_kernel * group); + + const int height_out = + (height + 2 * pad_h - (dilation_h * (kernel_h - 1) + 1)) / stride_h + 1; + const int width_out = + (width + 2 * pad_w - (dilation_w * (kernel_w - 1) + 1)) / stride_w + 1; + + if (ones.ndimension() != 2 || + ones.size(0) * ones.size(1) < height_out * width_out) { + // Resize plane and fill with ones... + ones = at::ones({height_out, width_out}, input.options()); + } + + grad_input = grad_input.view({batch, channels, height, width}); + columns = at::zeros({channels * kernel_h * kernel_w, height_out * width_out}, + input.options()); + + grad_output = + grad_output.view({grad_output.size(0), group, grad_output.size(1) / group, + grad_output.size(2), grad_output.size(3)}); + + for (int b = 0; b < batch; b++) { + // divide int group + columns = columns.view({group, columns.size(0) / group, columns.size(1)}); + weight = weight.view({group, weight.size(0) / group, weight.size(1), + weight.size(2), weight.size(3)}); + + for (int g = 0; g < group; g++) { + columns[g].addmm_(weight[g].flatten(1).transpose(0, 1), + grad_output[b][g].flatten(1), 0.0f, 1.0f); + } + + columns = + columns.view({columns.size(0) * columns.size(1), columns.size(2)}); + weight = weight.view({weight.size(0) * weight.size(1), weight.size(2), + weight.size(3), weight.size(4)}); + + // gradient w.r.t. input coordinate data + modulated_deformable_col2im_coord_cuda( + columns, input[b], offset[b], mask[b], 1, channels, height, width, + height_out, width_out, kernel_h, kernel_w, pad_h, pad_w, stride_h, + stride_w, dilation_h, dilation_w, deformable_group, grad_offset[b], + grad_mask[b]); + // gradient w.r.t. input data + modulated_deformable_col2im_cuda( + columns, offset[b], mask[b], 1, channels, height, width, height_out, + width_out, kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, + dilation_h, dilation_w, deformable_group, grad_input[b]); + + // gradient w.r.t. weight, dWeight should accumulate across the batch and + // group + modulated_deformable_im2col_cuda( + input[b], offset[b], mask[b], 1, channels, height, width, height_out, + width_out, kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, + dilation_h, dilation_w, deformable_group, columns); + + columns = columns.view({group, columns.size(0) / group, columns.size(1)}); + grad_weight = grad_weight.view({group, grad_weight.size(0) / group, + grad_weight.size(1), grad_weight.size(2), + grad_weight.size(3)}); + if (with_bias) + grad_bias = grad_bias.view({group, grad_bias.size(0) / group}); + + for (int g = 0; g < group; g++) { + grad_weight[g] = + grad_weight[g] + .flatten(1) + .addmm_(grad_output[b][g].flatten(1), columns[g].transpose(0, 1)) + .view_as(grad_weight[g]); + if (with_bias) { + grad_bias[g] = + grad_bias[g] + .view({-1, 1}) + .addmm_(grad_output[b][g].flatten(1), ones.view({-1, 1})) + .view(-1); + } + } + + columns = + columns.view({columns.size(0) * columns.size(1), columns.size(2)}); + grad_weight = grad_weight.view({grad_weight.size(0) * grad_weight.size(1), + grad_weight.size(2), grad_weight.size(3), + grad_weight.size(4)}); + if (with_bias) + grad_bias = grad_bias.view({grad_bias.size(0) * grad_bias.size(1)}); + } + grad_output = grad_output.view({grad_output.size(0) * grad_output.size(1), + grad_output.size(2), grad_output.size(3), + grad_output.size(4)}); +} + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + m.def("deform_conv_forward_cuda", &deform_conv_forward_cuda, + "deform forward (CUDA)"); + m.def("deform_conv_backward_input_cuda", &deform_conv_backward_input_cuda, + "deform_conv_backward_input (CUDA)"); + m.def("deform_conv_backward_parameters_cuda", + &deform_conv_backward_parameters_cuda, + "deform_conv_backward_parameters (CUDA)"); + m.def("modulated_deform_conv_cuda_forward", + &modulated_deform_conv_cuda_forward, + "modulated deform conv forward (CUDA)"); + m.def("modulated_deform_conv_cuda_backward", + &modulated_deform_conv_cuda_backward, + "modulated deform conv backward (CUDA)"); +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_conv_cuda_kernel.cu b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_conv_cuda_kernel.cu new file mode 100644 index 000000000..e7a26f2e8 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_conv_cuda_kernel.cu @@ -0,0 +1,867 @@ +/*! + ******************* BEGIN Caffe Copyright Notice and Disclaimer **************** + * + * COPYRIGHT + * + * All contributions by the University of California: + * Copyright (c) 2014-2017 The Regents of the University of California (Regents) + * All rights reserved. + * + * All other contributions: + * Copyright (c) 2014-2017, the respective contributors + * All rights reserved. + * + * Caffe uses a shared copyright model: each contributor holds copyright over + * their contributions to Caffe. The project versioning records all such + * contribution and copyright details. If a contributor wants to further mark + * their specific copyright on a particular contribution, they should indicate + * their copyright solely in the commit message of the change when it is + * committed. + * + * LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * CONTRIBUTION AGREEMENT + * + * By contributing to the BVLC/caffe repository through pull-request, comment, + * or otherwise, the contributor releases their content to the + * license and copyright terms herein. + * + ***************** END Caffe Copyright Notice and Disclaimer ******************** + * + * Copyright (c) 2018 Microsoft + * Licensed under The MIT License [see LICENSE for details] + * \file modulated_deformable_im2col.cuh + * \brief Function definitions of converting an image to + * column matrix based on kernel, padding, dilation, and offset. + * These functions are mainly used in deformable convolution operators. + * \ref: https://arxiv.org/abs/1703.06211 + * \author Yuwen Xiong, Haozhi Qi, Jifeng Dai, Xizhou Zhu, Han Hu, Dazhi Cheng + */ + +// modified from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/mmdetection/mmdet/ops/dcn/src/deform_conv_cuda_kernel.cu + +#include +#include +#include +#include +#include +#include + +using namespace at; + +#define CUDA_KERNEL_LOOP(i, n) \ + for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < (n); \ + i += blockDim.x * gridDim.x) + +const int CUDA_NUM_THREADS = 1024; +const int kMaxGridNum = 65535; + +inline int GET_BLOCKS(const int N) +{ + return std::min(kMaxGridNum, (N + CUDA_NUM_THREADS - 1) / CUDA_NUM_THREADS); +} + +template +__device__ scalar_t deformable_im2col_bilinear(const scalar_t *bottom_data, const int data_width, + const int height, const int width, scalar_t h, scalar_t w) +{ + + int h_low = floor(h); + int w_low = floor(w); + int h_high = h_low + 1; + int w_high = w_low + 1; + + scalar_t lh = h - h_low; + scalar_t lw = w - w_low; + scalar_t hh = 1 - lh, hw = 1 - lw; + + scalar_t v1 = 0; + if (h_low >= 0 && w_low >= 0) + v1 = bottom_data[h_low * data_width + w_low]; + scalar_t v2 = 0; + if (h_low >= 0 && w_high <= width - 1) + v2 = bottom_data[h_low * data_width + w_high]; + scalar_t v3 = 0; + if (h_high <= height - 1 && w_low >= 0) + v3 = bottom_data[h_high * data_width + w_low]; + scalar_t v4 = 0; + if (h_high <= height - 1 && w_high <= width - 1) + v4 = bottom_data[h_high * data_width + w_high]; + + scalar_t w1 = hh * hw, w2 = hh * lw, w3 = lh * hw, w4 = lh * lw; + + scalar_t val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); + return val; +} + +template +__device__ scalar_t get_gradient_weight(scalar_t argmax_h, scalar_t argmax_w, + const int h, const int w, const int height, const int width) +{ + + if (argmax_h <= -1 || argmax_h >= height || argmax_w <= -1 || argmax_w >= width) + { + //empty + return 0; + } + + int argmax_h_low = floor(argmax_h); + int argmax_w_low = floor(argmax_w); + int argmax_h_high = argmax_h_low + 1; + int argmax_w_high = argmax_w_low + 1; + + scalar_t weight = 0; + if (h == argmax_h_low && w == argmax_w_low) + weight = (h + 1 - argmax_h) * (w + 1 - argmax_w); + if (h == argmax_h_low && w == argmax_w_high) + weight = (h + 1 - argmax_h) * (argmax_w + 1 - w); + if (h == argmax_h_high && w == argmax_w_low) + weight = (argmax_h + 1 - h) * (w + 1 - argmax_w); + if (h == argmax_h_high && w == argmax_w_high) + weight = (argmax_h + 1 - h) * (argmax_w + 1 - w); + return weight; +} + +template +__device__ scalar_t get_coordinate_weight(scalar_t argmax_h, scalar_t argmax_w, + const int height, const int width, const scalar_t *im_data, + const int data_width, const int bp_dir) +{ + + if (argmax_h <= -1 || argmax_h >= height || argmax_w <= -1 || argmax_w >= width) + { + //empty + return 0; + } + + int argmax_h_low = floor(argmax_h); + int argmax_w_low = floor(argmax_w); + int argmax_h_high = argmax_h_low + 1; + int argmax_w_high = argmax_w_low + 1; + + scalar_t weight = 0; + + if (bp_dir == 0) + { + if (argmax_h_low >= 0 && argmax_w_low >= 0) + weight += -1 * (argmax_w_low + 1 - argmax_w) * im_data[argmax_h_low * data_width + argmax_w_low]; + if (argmax_h_low >= 0 && argmax_w_high <= width - 1) + weight += -1 * (argmax_w - argmax_w_low) * im_data[argmax_h_low * data_width + argmax_w_high]; + if (argmax_h_high <= height - 1 && argmax_w_low >= 0) + weight += (argmax_w_low + 1 - argmax_w) * im_data[argmax_h_high * data_width + argmax_w_low]; + if (argmax_h_high <= height - 1 && argmax_w_high <= width - 1) + weight += (argmax_w - argmax_w_low) * im_data[argmax_h_high * data_width + argmax_w_high]; + } + else if (bp_dir == 1) + { + if (argmax_h_low >= 0 && argmax_w_low >= 0) + weight += -1 * (argmax_h_low + 1 - argmax_h) * im_data[argmax_h_low * data_width + argmax_w_low]; + if (argmax_h_low >= 0 && argmax_w_high <= width - 1) + weight += (argmax_h_low + 1 - argmax_h) * im_data[argmax_h_low * data_width + argmax_w_high]; + if (argmax_h_high <= height - 1 && argmax_w_low >= 0) + weight += -1 * (argmax_h - argmax_h_low) * im_data[argmax_h_high * data_width + argmax_w_low]; + if (argmax_h_high <= height - 1 && argmax_w_high <= width - 1) + weight += (argmax_h - argmax_h_low) * im_data[argmax_h_high * data_width + argmax_w_high]; + } + + return weight; +} + +template +__global__ void deformable_im2col_gpu_kernel(const int n, const scalar_t *data_im, const scalar_t *data_offset, + const int height, const int width, const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, const int channel_per_deformable_group, + const int batch_size, const int num_channels, const int deformable_group, + const int height_col, const int width_col, + scalar_t *data_col) +{ + CUDA_KERNEL_LOOP(index, n) + { + // index index of output matrix + const int w_col = index % width_col; + const int h_col = (index / width_col) % height_col; + const int b_col = (index / width_col / height_col) % batch_size; + const int c_im = (index / width_col / height_col) / batch_size; + const int c_col = c_im * kernel_h * kernel_w; + + // compute deformable group index + const int deformable_group_index = c_im / channel_per_deformable_group; + + const int h_in = h_col * stride_h - pad_h; + const int w_in = w_col * stride_w - pad_w; + scalar_t *data_col_ptr = data_col + ((c_col * batch_size + b_col) * height_col + h_col) * width_col + w_col; + //const scalar_t* data_im_ptr = data_im + ((b_col * num_channels + c_im) * height + h_in) * width + w_in; + const scalar_t *data_im_ptr = data_im + (b_col * num_channels + c_im) * height * width; + const scalar_t *data_offset_ptr = data_offset + (b_col * deformable_group + deformable_group_index) * 2 * kernel_h * kernel_w * height_col * width_col; + + for (int i = 0; i < kernel_h; ++i) + { + for (int j = 0; j < kernel_w; ++j) + { + const int data_offset_h_ptr = ((2 * (i * kernel_w + j)) * height_col + h_col) * width_col + w_col; + const int data_offset_w_ptr = ((2 * (i * kernel_w + j) + 1) * height_col + h_col) * width_col + w_col; + const scalar_t offset_h = data_offset_ptr[data_offset_h_ptr]; + const scalar_t offset_w = data_offset_ptr[data_offset_w_ptr]; + scalar_t val = static_cast(0); + const scalar_t h_im = h_in + i * dilation_h + offset_h; + const scalar_t w_im = w_in + j * dilation_w + offset_w; + if (h_im > -1 && w_im > -1 && h_im < height && w_im < width) + { + //const scalar_t map_h = i * dilation_h + offset_h; + //const scalar_t map_w = j * dilation_w + offset_w; + //const int cur_height = height - h_in; + //const int cur_width = width - w_in; + //val = deformable_im2col_bilinear(data_im_ptr, width, cur_height, cur_width, map_h, map_w); + val = deformable_im2col_bilinear(data_im_ptr, width, height, width, h_im, w_im); + } + *data_col_ptr = val; + data_col_ptr += batch_size * height_col * width_col; + } + } + } +} + +void deformable_im2col( + const at::Tensor data_im, const at::Tensor data_offset, const int channels, + const int height, const int width, const int ksize_h, const int ksize_w, + const int pad_h, const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, const int parallel_imgs, + const int deformable_group, at::Tensor data_col) +{ + // num_axes should be smaller than block size + // todo: check parallel_imgs is correctly passed in + int height_col = (height + 2 * pad_h - (dilation_h * (ksize_h - 1) + 1)) / stride_h + 1; + int width_col = (width + 2 * pad_w - (dilation_w * (ksize_w - 1) + 1)) / stride_w + 1; + int num_kernels = channels * height_col * width_col * parallel_imgs; + int channel_per_deformable_group = channels / deformable_group; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + data_im.scalar_type(), "deformable_im2col_gpu", ([&] { + const scalar_t *data_im_ = data_im.data(); + const scalar_t *data_offset_ = data_offset.data(); + scalar_t *data_col_ = data_col.data(); + + deformable_im2col_gpu_kernel<<>>( + num_kernels, data_im_, data_offset_, height, width, ksize_h, ksize_w, + pad_h, pad_w, stride_h, stride_w, dilation_h, dilation_w, + channel_per_deformable_group, parallel_imgs, channels, deformable_group, + height_col, width_col, data_col_); + })); + + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) + { + printf("error in deformable_im2col: %s\n", cudaGetErrorString(err)); + } +} + +template +__global__ void deformable_col2im_gpu_kernel( + const int n, const scalar_t *data_col, const scalar_t *data_offset, + const int channels, const int height, const int width, + const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, + const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int channel_per_deformable_group, + const int batch_size, const int deformable_group, + const int height_col, const int width_col, + scalar_t *grad_im) +{ + CUDA_KERNEL_LOOP(index, n) + { + const int j = (index / width_col / height_col / batch_size) % kernel_w; + const int i = (index / width_col / height_col / batch_size / kernel_w) % kernel_h; + const int c = index / width_col / height_col / batch_size / kernel_w / kernel_h; + // compute the start and end of the output + + const int deformable_group_index = c / channel_per_deformable_group; + + int w_out = index % width_col; + int h_out = (index / width_col) % height_col; + int b = (index / width_col / height_col) % batch_size; + int w_in = w_out * stride_w - pad_w; + int h_in = h_out * stride_h - pad_h; + + const scalar_t *data_offset_ptr = data_offset + (b * deformable_group + deformable_group_index) * + 2 * kernel_h * kernel_w * height_col * width_col; + const int data_offset_h_ptr = ((2 * (i * kernel_w + j)) * height_col + h_out) * width_col + w_out; + const int data_offset_w_ptr = ((2 * (i * kernel_w + j) + 1) * height_col + h_out) * width_col + w_out; + const scalar_t offset_h = data_offset_ptr[data_offset_h_ptr]; + const scalar_t offset_w = data_offset_ptr[data_offset_w_ptr]; + const scalar_t cur_inv_h_data = h_in + i * dilation_h + offset_h; + const scalar_t cur_inv_w_data = w_in + j * dilation_w + offset_w; + + const scalar_t cur_top_grad = data_col[index]; + const int cur_h = (int)cur_inv_h_data; + const int cur_w = (int)cur_inv_w_data; + for (int dy = -2; dy <= 2; dy++) + { + for (int dx = -2; dx <= 2; dx++) + { + if (cur_h + dy >= 0 && cur_h + dy < height && + cur_w + dx >= 0 && cur_w + dx < width && + abs(cur_inv_h_data - (cur_h + dy)) < 1 && + abs(cur_inv_w_data - (cur_w + dx)) < 1) + { + int cur_bottom_grad_pos = ((b * channels + c) * height + cur_h + dy) * width + cur_w + dx; + scalar_t weight = get_gradient_weight(cur_inv_h_data, cur_inv_w_data, cur_h + dy, cur_w + dx, height, width); + atomicAdd(grad_im + cur_bottom_grad_pos, weight * cur_top_grad); + } + } + } + } +} + +void deformable_col2im( + const at::Tensor data_col, const at::Tensor data_offset, const int channels, + const int height, const int width, const int ksize_h, + const int ksize_w, const int pad_h, const int pad_w, + const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int parallel_imgs, const int deformable_group, + at::Tensor grad_im) +{ + + // todo: make sure parallel_imgs is passed in correctly + int height_col = (height + 2 * pad_h - (dilation_h * (ksize_h - 1) + 1)) / stride_h + 1; + int width_col = (width + 2 * pad_w - (dilation_w * (ksize_w - 1) + 1)) / stride_w + 1; + int num_kernels = channels * ksize_h * ksize_w * height_col * width_col * parallel_imgs; + int channel_per_deformable_group = channels / deformable_group; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + data_col.scalar_type(), "deformable_col2im_gpu", ([&] { + const scalar_t *data_col_ = data_col.data(); + const scalar_t *data_offset_ = data_offset.data(); + scalar_t *grad_im_ = grad_im.data(); + + deformable_col2im_gpu_kernel<<>>( + num_kernels, data_col_, data_offset_, channels, height, width, ksize_h, + ksize_w, pad_h, pad_w, stride_h, stride_w, + dilation_h, dilation_w, channel_per_deformable_group, + parallel_imgs, deformable_group, height_col, width_col, grad_im_); + })); + + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) + { + printf("error in deformable_col2im: %s\n", cudaGetErrorString(err)); + } +} + +template +__global__ void deformable_col2im_coord_gpu_kernel(const int n, const scalar_t *data_col, + const scalar_t *data_im, const scalar_t *data_offset, + const int channels, const int height, const int width, + const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, + const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int channel_per_deformable_group, + const int batch_size, const int offset_channels, const int deformable_group, + const int height_col, const int width_col, scalar_t *grad_offset) +{ + CUDA_KERNEL_LOOP(index, n) + { + scalar_t val = 0; + int w = index % width_col; + int h = (index / width_col) % height_col; + int c = (index / width_col / height_col) % offset_channels; + int b = (index / width_col / height_col) / offset_channels; + // compute the start and end of the output + + const int deformable_group_index = c / (2 * kernel_h * kernel_w); + const int col_step = kernel_h * kernel_w; + int cnt = 0; + const scalar_t *data_col_ptr = data_col + deformable_group_index * channel_per_deformable_group * + batch_size * width_col * height_col; + const scalar_t *data_im_ptr = data_im + (b * deformable_group + deformable_group_index) * + channel_per_deformable_group / kernel_h / kernel_w * height * width; + const scalar_t *data_offset_ptr = data_offset + (b * deformable_group + deformable_group_index) * 2 * + kernel_h * kernel_w * height_col * width_col; + + const int offset_c = c - deformable_group_index * 2 * kernel_h * kernel_w; + + for (int col_c = (offset_c / 2); col_c < channel_per_deformable_group; col_c += col_step) + { + const int col_pos = (((col_c * batch_size + b) * height_col) + h) * width_col + w; + const int bp_dir = offset_c % 2; + + int j = (col_pos / width_col / height_col / batch_size) % kernel_w; + int i = (col_pos / width_col / height_col / batch_size / kernel_w) % kernel_h; + int w_out = col_pos % width_col; + int h_out = (col_pos / width_col) % height_col; + int w_in = w_out * stride_w - pad_w; + int h_in = h_out * stride_h - pad_h; + const int data_offset_h_ptr = (((2 * (i * kernel_w + j)) * height_col + h_out) * width_col + w_out); + const int data_offset_w_ptr = (((2 * (i * kernel_w + j) + 1) * height_col + h_out) * width_col + w_out); + const scalar_t offset_h = data_offset_ptr[data_offset_h_ptr]; + const scalar_t offset_w = data_offset_ptr[data_offset_w_ptr]; + scalar_t inv_h = h_in + i * dilation_h + offset_h; + scalar_t inv_w = w_in + j * dilation_w + offset_w; + if (inv_h <= -1 || inv_w <= -1 || inv_h >= height || inv_w >= width) + { + inv_h = inv_w = -2; + } + const scalar_t weight = get_coordinate_weight( + inv_h, inv_w, + height, width, data_im_ptr + cnt * height * width, width, bp_dir); + val += weight * data_col_ptr[col_pos]; + cnt += 1; + } + + grad_offset[index] = val; + } +} + +void deformable_col2im_coord( + const at::Tensor data_col, const at::Tensor data_im, const at::Tensor data_offset, + const int channels, const int height, const int width, const int ksize_h, + const int ksize_w, const int pad_h, const int pad_w, const int stride_h, + const int stride_w, const int dilation_h, const int dilation_w, + const int parallel_imgs, const int deformable_group, at::Tensor grad_offset) +{ + + int height_col = (height + 2 * pad_h - (dilation_h * (ksize_h - 1) + 1)) / stride_h + 1; + int width_col = (width + 2 * pad_w - (dilation_w * (ksize_w - 1) + 1)) / stride_w + 1; + int num_kernels = height_col * width_col * 2 * ksize_h * ksize_w * deformable_group * parallel_imgs; + int channel_per_deformable_group = channels * ksize_h * ksize_w / deformable_group; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + data_col.scalar_type(), "deformable_col2im_coord_gpu", ([&] { + const scalar_t *data_col_ = data_col.data(); + const scalar_t *data_im_ = data_im.data(); + const scalar_t *data_offset_ = data_offset.data(); + scalar_t *grad_offset_ = grad_offset.data(); + + deformable_col2im_coord_gpu_kernel<<>>( + num_kernels, data_col_, data_im_, data_offset_, channels, height, width, + ksize_h, ksize_w, pad_h, pad_w, stride_h, stride_w, + dilation_h, dilation_w, channel_per_deformable_group, + parallel_imgs, 2 * ksize_h * ksize_w * deformable_group, deformable_group, + height_col, width_col, grad_offset_); + })); +} + +template +__device__ scalar_t dmcn_im2col_bilinear(const scalar_t *bottom_data, const int data_width, + const int height, const int width, scalar_t h, scalar_t w) +{ + int h_low = floor(h); + int w_low = floor(w); + int h_high = h_low + 1; + int w_high = w_low + 1; + + scalar_t lh = h - h_low; + scalar_t lw = w - w_low; + scalar_t hh = 1 - lh, hw = 1 - lw; + + scalar_t v1 = 0; + if (h_low >= 0 && w_low >= 0) + v1 = bottom_data[h_low * data_width + w_low]; + scalar_t v2 = 0; + if (h_low >= 0 && w_high <= width - 1) + v2 = bottom_data[h_low * data_width + w_high]; + scalar_t v3 = 0; + if (h_high <= height - 1 && w_low >= 0) + v3 = bottom_data[h_high * data_width + w_low]; + scalar_t v4 = 0; + if (h_high <= height - 1 && w_high <= width - 1) + v4 = bottom_data[h_high * data_width + w_high]; + + scalar_t w1 = hh * hw, w2 = hh * lw, w3 = lh * hw, w4 = lh * lw; + + scalar_t val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); + return val; +} + +template +__device__ scalar_t dmcn_get_gradient_weight(scalar_t argmax_h, scalar_t argmax_w, + const int h, const int w, const int height, const int width) +{ + if (argmax_h <= -1 || argmax_h >= height || argmax_w <= -1 || argmax_w >= width) + { + //empty + return 0; + } + + int argmax_h_low = floor(argmax_h); + int argmax_w_low = floor(argmax_w); + int argmax_h_high = argmax_h_low + 1; + int argmax_w_high = argmax_w_low + 1; + + scalar_t weight = 0; + if (h == argmax_h_low && w == argmax_w_low) + weight = (h + 1 - argmax_h) * (w + 1 - argmax_w); + if (h == argmax_h_low && w == argmax_w_high) + weight = (h + 1 - argmax_h) * (argmax_w + 1 - w); + if (h == argmax_h_high && w == argmax_w_low) + weight = (argmax_h + 1 - h) * (w + 1 - argmax_w); + if (h == argmax_h_high && w == argmax_w_high) + weight = (argmax_h + 1 - h) * (argmax_w + 1 - w); + return weight; +} + +template +__device__ scalar_t dmcn_get_coordinate_weight(scalar_t argmax_h, scalar_t argmax_w, + const int height, const int width, const scalar_t *im_data, + const int data_width, const int bp_dir) +{ + if (argmax_h <= -1 || argmax_h >= height || argmax_w <= -1 || argmax_w >= width) + { + //empty + return 0; + } + + int argmax_h_low = floor(argmax_h); + int argmax_w_low = floor(argmax_w); + int argmax_h_high = argmax_h_low + 1; + int argmax_w_high = argmax_w_low + 1; + + scalar_t weight = 0; + + if (bp_dir == 0) + { + if (argmax_h_low >= 0 && argmax_w_low >= 0) + weight += -1 * (argmax_w_low + 1 - argmax_w) * im_data[argmax_h_low * data_width + argmax_w_low]; + if (argmax_h_low >= 0 && argmax_w_high <= width - 1) + weight += -1 * (argmax_w - argmax_w_low) * im_data[argmax_h_low * data_width + argmax_w_high]; + if (argmax_h_high <= height - 1 && argmax_w_low >= 0) + weight += (argmax_w_low + 1 - argmax_w) * im_data[argmax_h_high * data_width + argmax_w_low]; + if (argmax_h_high <= height - 1 && argmax_w_high <= width - 1) + weight += (argmax_w - argmax_w_low) * im_data[argmax_h_high * data_width + argmax_w_high]; + } + else if (bp_dir == 1) + { + if (argmax_h_low >= 0 && argmax_w_low >= 0) + weight += -1 * (argmax_h_low + 1 - argmax_h) * im_data[argmax_h_low * data_width + argmax_w_low]; + if (argmax_h_low >= 0 && argmax_w_high <= width - 1) + weight += (argmax_h_low + 1 - argmax_h) * im_data[argmax_h_low * data_width + argmax_w_high]; + if (argmax_h_high <= height - 1 && argmax_w_low >= 0) + weight += -1 * (argmax_h - argmax_h_low) * im_data[argmax_h_high * data_width + argmax_w_low]; + if (argmax_h_high <= height - 1 && argmax_w_high <= width - 1) + weight += (argmax_h - argmax_h_low) * im_data[argmax_h_high * data_width + argmax_w_high]; + } + + return weight; +} + +template +__global__ void modulated_deformable_im2col_gpu_kernel(const int n, + const scalar_t *data_im, const scalar_t *data_offset, const scalar_t *data_mask, + const int height, const int width, const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, + const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int channel_per_deformable_group, + const int batch_size, const int num_channels, const int deformable_group, + const int height_col, const int width_col, + scalar_t *data_col) +{ + CUDA_KERNEL_LOOP(index, n) + { + // index index of output matrix + const int w_col = index % width_col; + const int h_col = (index / width_col) % height_col; + const int b_col = (index / width_col / height_col) % batch_size; + const int c_im = (index / width_col / height_col) / batch_size; + const int c_col = c_im * kernel_h * kernel_w; + + // compute deformable group index + const int deformable_group_index = c_im / channel_per_deformable_group; + + const int h_in = h_col * stride_h - pad_h; + const int w_in = w_col * stride_w - pad_w; + + scalar_t *data_col_ptr = data_col + ((c_col * batch_size + b_col) * height_col + h_col) * width_col + w_col; + //const float* data_im_ptr = data_im + ((b_col * num_channels + c_im) * height + h_in) * width + w_in; + const scalar_t *data_im_ptr = data_im + (b_col * num_channels + c_im) * height * width; + const scalar_t *data_offset_ptr = data_offset + (b_col * deformable_group + deformable_group_index) * 2 * kernel_h * kernel_w * height_col * width_col; + + const scalar_t *data_mask_ptr = data_mask + (b_col * deformable_group + deformable_group_index) * kernel_h * kernel_w * height_col * width_col; + + for (int i = 0; i < kernel_h; ++i) + { + for (int j = 0; j < kernel_w; ++j) + { + const int data_offset_h_ptr = ((2 * (i * kernel_w + j)) * height_col + h_col) * width_col + w_col; + const int data_offset_w_ptr = ((2 * (i * kernel_w + j) + 1) * height_col + h_col) * width_col + w_col; + const int data_mask_hw_ptr = ((i * kernel_w + j) * height_col + h_col) * width_col + w_col; + const scalar_t offset_h = data_offset_ptr[data_offset_h_ptr]; + const scalar_t offset_w = data_offset_ptr[data_offset_w_ptr]; + const scalar_t mask = data_mask_ptr[data_mask_hw_ptr]; + scalar_t val = static_cast(0); + const scalar_t h_im = h_in + i * dilation_h + offset_h; + const scalar_t w_im = w_in + j * dilation_w + offset_w; + //if (h_im >= 0 && w_im >= 0 && h_im < height && w_im < width) { + if (h_im > -1 && w_im > -1 && h_im < height && w_im < width) + { + //const float map_h = i * dilation_h + offset_h; + //const float map_w = j * dilation_w + offset_w; + //const int cur_height = height - h_in; + //const int cur_width = width - w_in; + //val = dmcn_im2col_bilinear(data_im_ptr, width, cur_height, cur_width, map_h, map_w); + val = dmcn_im2col_bilinear(data_im_ptr, width, height, width, h_im, w_im); + } + *data_col_ptr = val * mask; + data_col_ptr += batch_size * height_col * width_col; + //data_col_ptr += height_col * width_col; + } + } + } +} + +template +__global__ void modulated_deformable_col2im_gpu_kernel(const int n, + const scalar_t *data_col, const scalar_t *data_offset, const scalar_t *data_mask, + const int channels, const int height, const int width, + const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, + const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int channel_per_deformable_group, + const int batch_size, const int deformable_group, + const int height_col, const int width_col, + scalar_t *grad_im) +{ + CUDA_KERNEL_LOOP(index, n) + { + const int j = (index / width_col / height_col / batch_size) % kernel_w; + const int i = (index / width_col / height_col / batch_size / kernel_w) % kernel_h; + const int c = index / width_col / height_col / batch_size / kernel_w / kernel_h; + // compute the start and end of the output + + const int deformable_group_index = c / channel_per_deformable_group; + + int w_out = index % width_col; + int h_out = (index / width_col) % height_col; + int b = (index / width_col / height_col) % batch_size; + int w_in = w_out * stride_w - pad_w; + int h_in = h_out * stride_h - pad_h; + + const scalar_t *data_offset_ptr = data_offset + (b * deformable_group + deformable_group_index) * 2 * kernel_h * kernel_w * height_col * width_col; + const scalar_t *data_mask_ptr = data_mask + (b * deformable_group + deformable_group_index) * kernel_h * kernel_w * height_col * width_col; + const int data_offset_h_ptr = ((2 * (i * kernel_w + j)) * height_col + h_out) * width_col + w_out; + const int data_offset_w_ptr = ((2 * (i * kernel_w + j) + 1) * height_col + h_out) * width_col + w_out; + const int data_mask_hw_ptr = ((i * kernel_w + j) * height_col + h_out) * width_col + w_out; + const scalar_t offset_h = data_offset_ptr[data_offset_h_ptr]; + const scalar_t offset_w = data_offset_ptr[data_offset_w_ptr]; + const scalar_t mask = data_mask_ptr[data_mask_hw_ptr]; + const scalar_t cur_inv_h_data = h_in + i * dilation_h + offset_h; + const scalar_t cur_inv_w_data = w_in + j * dilation_w + offset_w; + + const scalar_t cur_top_grad = data_col[index] * mask; + const int cur_h = (int)cur_inv_h_data; + const int cur_w = (int)cur_inv_w_data; + for (int dy = -2; dy <= 2; dy++) + { + for (int dx = -2; dx <= 2; dx++) + { + if (cur_h + dy >= 0 && cur_h + dy < height && + cur_w + dx >= 0 && cur_w + dx < width && + abs(cur_inv_h_data - (cur_h + dy)) < 1 && + abs(cur_inv_w_data - (cur_w + dx)) < 1) + { + int cur_bottom_grad_pos = ((b * channels + c) * height + cur_h + dy) * width + cur_w + dx; + scalar_t weight = dmcn_get_gradient_weight(cur_inv_h_data, cur_inv_w_data, cur_h + dy, cur_w + dx, height, width); + atomicAdd(grad_im + cur_bottom_grad_pos, weight * cur_top_grad); + } + } + } + } +} + +template +__global__ void modulated_deformable_col2im_coord_gpu_kernel(const int n, + const scalar_t *data_col, const scalar_t *data_im, + const scalar_t *data_offset, const scalar_t *data_mask, + const int channels, const int height, const int width, + const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, + const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int channel_per_deformable_group, + const int batch_size, const int offset_channels, const int deformable_group, + const int height_col, const int width_col, + scalar_t *grad_offset, scalar_t *grad_mask) +{ + CUDA_KERNEL_LOOP(index, n) + { + scalar_t val = 0, mval = 0; + int w = index % width_col; + int h = (index / width_col) % height_col; + int c = (index / width_col / height_col) % offset_channels; + int b = (index / width_col / height_col) / offset_channels; + // compute the start and end of the output + + const int deformable_group_index = c / (2 * kernel_h * kernel_w); + const int col_step = kernel_h * kernel_w; + int cnt = 0; + const scalar_t *data_col_ptr = data_col + deformable_group_index * channel_per_deformable_group * batch_size * width_col * height_col; + const scalar_t *data_im_ptr = data_im + (b * deformable_group + deformable_group_index) * channel_per_deformable_group / kernel_h / kernel_w * height * width; + const scalar_t *data_offset_ptr = data_offset + (b * deformable_group + deformable_group_index) * 2 * kernel_h * kernel_w * height_col * width_col; + const scalar_t *data_mask_ptr = data_mask + (b * deformable_group + deformable_group_index) * kernel_h * kernel_w * height_col * width_col; + + const int offset_c = c - deformable_group_index * 2 * kernel_h * kernel_w; + + for (int col_c = (offset_c / 2); col_c < channel_per_deformable_group; col_c += col_step) + { + const int col_pos = (((col_c * batch_size + b) * height_col) + h) * width_col + w; + const int bp_dir = offset_c % 2; + + int j = (col_pos / width_col / height_col / batch_size) % kernel_w; + int i = (col_pos / width_col / height_col / batch_size / kernel_w) % kernel_h; + int w_out = col_pos % width_col; + int h_out = (col_pos / width_col) % height_col; + int w_in = w_out * stride_w - pad_w; + int h_in = h_out * stride_h - pad_h; + const int data_offset_h_ptr = (((2 * (i * kernel_w + j)) * height_col + h_out) * width_col + w_out); + const int data_offset_w_ptr = (((2 * (i * kernel_w + j) + 1) * height_col + h_out) * width_col + w_out); + const int data_mask_hw_ptr = (((i * kernel_w + j) * height_col + h_out) * width_col + w_out); + const scalar_t offset_h = data_offset_ptr[data_offset_h_ptr]; + const scalar_t offset_w = data_offset_ptr[data_offset_w_ptr]; + const scalar_t mask = data_mask_ptr[data_mask_hw_ptr]; + scalar_t inv_h = h_in + i * dilation_h + offset_h; + scalar_t inv_w = w_in + j * dilation_w + offset_w; + if (inv_h <= -1 || inv_w <= -1 || inv_h >= height || inv_w >= width) + { + inv_h = inv_w = -2; + } + else + { + mval += data_col_ptr[col_pos] * dmcn_im2col_bilinear(data_im_ptr + cnt * height * width, width, height, width, inv_h, inv_w); + } + const scalar_t weight = dmcn_get_coordinate_weight( + inv_h, inv_w, + height, width, data_im_ptr + cnt * height * width, width, bp_dir); + val += weight * data_col_ptr[col_pos] * mask; + cnt += 1; + } + // KERNEL_ASSIGN(grad_offset[index], offset_req, val); + grad_offset[index] = val; + if (offset_c % 2 == 0) + // KERNEL_ASSIGN(grad_mask[(((b * deformable_group + deformable_group_index) * kernel_h * kernel_w + offset_c / 2) * height_col + h) * width_col + w], mask_req, mval); + grad_mask[(((b * deformable_group + deformable_group_index) * kernel_h * kernel_w + offset_c / 2) * height_col + h) * width_col + w] = mval; + } +} + +void modulated_deformable_im2col_cuda( + const at::Tensor data_im, const at::Tensor data_offset, const at::Tensor data_mask, + const int batch_size, const int channels, const int height_im, const int width_im, + const int height_col, const int width_col, const int kernel_h, const int kenerl_w, + const int pad_h, const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int deformable_group, at::Tensor data_col) +{ + // num_axes should be smaller than block size + const int channel_per_deformable_group = channels / deformable_group; + const int num_kernels = channels * batch_size * height_col * width_col; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + data_im.scalar_type(), "modulated_deformable_im2col_gpu", ([&] { + const scalar_t *data_im_ = data_im.data(); + const scalar_t *data_offset_ = data_offset.data(); + const scalar_t *data_mask_ = data_mask.data(); + scalar_t *data_col_ = data_col.data(); + + modulated_deformable_im2col_gpu_kernel<<>>( + num_kernels, data_im_, data_offset_, data_mask_, height_im, width_im, kernel_h, kenerl_w, + pad_h, pad_w, stride_h, stride_w, dilation_h, dilation_w, channel_per_deformable_group, + batch_size, channels, deformable_group, height_col, width_col, data_col_); + })); + + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) + { + printf("error in modulated_deformable_im2col_cuda: %s\n", cudaGetErrorString(err)); + } +} + +void modulated_deformable_col2im_cuda( + const at::Tensor data_col, const at::Tensor data_offset, const at::Tensor data_mask, + const int batch_size, const int channels, const int height_im, const int width_im, + const int height_col, const int width_col, const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int deformable_group, at::Tensor grad_im) +{ + + const int channel_per_deformable_group = channels / deformable_group; + const int num_kernels = channels * kernel_h * kernel_w * batch_size * height_col * width_col; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + data_col.scalar_type(), "modulated_deformable_col2im_gpu", ([&] { + const scalar_t *data_col_ = data_col.data(); + const scalar_t *data_offset_ = data_offset.data(); + const scalar_t *data_mask_ = data_mask.data(); + scalar_t *grad_im_ = grad_im.data(); + + modulated_deformable_col2im_gpu_kernel<<>>( + num_kernels, data_col_, data_offset_, data_mask_, channels, height_im, width_im, + kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, + dilation_h, dilation_w, channel_per_deformable_group, + batch_size, deformable_group, height_col, width_col, grad_im_); + })); + + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) + { + printf("error in modulated_deformable_col2im_cuda: %s\n", cudaGetErrorString(err)); + } +} + +void modulated_deformable_col2im_coord_cuda( + const at::Tensor data_col, const at::Tensor data_im, const at::Tensor data_offset, const at::Tensor data_mask, + const int batch_size, const int channels, const int height_im, const int width_im, + const int height_col, const int width_col, const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int deformable_group, + at::Tensor grad_offset, at::Tensor grad_mask) +{ + const int num_kernels = batch_size * height_col * width_col * 2 * kernel_h * kernel_w * deformable_group; + const int channel_per_deformable_group = channels * kernel_h * kernel_w / deformable_group; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + data_col.scalar_type(), "modulated_deformable_col2im_coord_gpu", ([&] { + const scalar_t *data_col_ = data_col.data(); + const scalar_t *data_im_ = data_im.data(); + const scalar_t *data_offset_ = data_offset.data(); + const scalar_t *data_mask_ = data_mask.data(); + scalar_t *grad_offset_ = grad_offset.data(); + scalar_t *grad_mask_ = grad_mask.data(); + + modulated_deformable_col2im_coord_gpu_kernel<<>>( + num_kernels, data_col_, data_im_, data_offset_, data_mask_, channels, height_im, width_im, + kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, + dilation_h, dilation_w, channel_per_deformable_group, + batch_size, 2 * kernel_h * kernel_w * deformable_group, deformable_group, height_col, width_col, + grad_offset_, grad_mask_); + })); + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) + { + printf("error in modulated_deformable_col2im_coord_cuda: %s\n", cudaGetErrorString(err)); + } +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_pool_cuda.cpp b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_pool_cuda.cpp new file mode 100644 index 000000000..f6f087b88 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_pool_cuda.cpp @@ -0,0 +1,90 @@ +// modify from +// https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/mmdetection/mmdet/ops/dcn/src/modulated_dcn_cuda.c + +// based on +// author: Charles Shang +// https://github.com/torch/cunn/blob/master/lib/THCUNN/generic/SpatialConvolutionMM.cu + +#include +#include + +#include +#include + +void DeformablePSROIPoolForward( + const at::Tensor data, const at::Tensor bbox, const at::Tensor trans, + at::Tensor out, at::Tensor top_count, const int batch, const int channels, + const int height, const int width, const int num_bbox, + const int channels_trans, const int no_trans, const float spatial_scale, + const int output_dim, const int group_size, const int pooled_size, + const int part_size, const int sample_per_part, const float trans_std); + +void DeformablePSROIPoolBackwardAcc( + const at::Tensor out_grad, const at::Tensor data, const at::Tensor bbox, + const at::Tensor trans, const at::Tensor top_count, at::Tensor in_grad, + at::Tensor trans_grad, const int batch, const int channels, + const int height, const int width, const int num_bbox, + const int channels_trans, const int no_trans, const float spatial_scale, + const int output_dim, const int group_size, const int pooled_size, + const int part_size, const int sample_per_part, const float trans_std); + +void deform_psroi_pooling_cuda_forward( + at::Tensor input, at::Tensor bbox, at::Tensor trans, at::Tensor out, + at::Tensor top_count, const int no_trans, const float spatial_scale, + const int output_dim, const int group_size, const int pooled_size, + const int part_size, const int sample_per_part, const float trans_std) { + TORCH_CHECK(input.is_contiguous(), "input tensor has to be contiguous"); + at::DeviceGuard guard(input.device()); + + const int batch = input.size(0); + const int channels = input.size(1); + const int height = input.size(2); + const int width = input.size(3); + const int channels_trans = no_trans ? 2 : trans.size(1); + + const int num_bbox = bbox.size(0); + if (num_bbox != out.size(0)) + AT_ERROR("Output shape and bbox number wont match: (%d vs %d).", + out.size(0), num_bbox); + + DeformablePSROIPoolForward( + input, bbox, trans, out, top_count, batch, channels, height, width, + num_bbox, channels_trans, no_trans, spatial_scale, output_dim, group_size, + pooled_size, part_size, sample_per_part, trans_std); +} + +void deform_psroi_pooling_cuda_backward( + at::Tensor out_grad, at::Tensor input, at::Tensor bbox, at::Tensor trans, + at::Tensor top_count, at::Tensor input_grad, at::Tensor trans_grad, + const int no_trans, const float spatial_scale, const int output_dim, + const int group_size, const int pooled_size, const int part_size, + const int sample_per_part, const float trans_std) { + TORCH_CHECK(out_grad.is_contiguous(), "out_grad tensor has to be contiguous"); + TORCH_CHECK(input.is_contiguous(), "input tensor has to be contiguous"); + at::DeviceGuard guard(input.device()); + + const int batch = input.size(0); + const int channels = input.size(1); + const int height = input.size(2); + const int width = input.size(3); + const int channels_trans = no_trans ? 2 : trans.size(1); + + const int num_bbox = bbox.size(0); + if (num_bbox != out_grad.size(0)) + AT_ERROR("Output shape and bbox number wont match: (%d vs %d).", + out_grad.size(0), num_bbox); + + DeformablePSROIPoolBackwardAcc( + out_grad, input, bbox, trans, top_count, input_grad, trans_grad, batch, + channels, height, width, num_bbox, channels_trans, no_trans, + spatial_scale, output_dim, group_size, pooled_size, part_size, + sample_per_part, trans_std); +} + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + m.def("deform_psroi_pooling_cuda_forward", &deform_psroi_pooling_cuda_forward, + "deform psroi pooling forward(CUDA)"); + m.def("deform_psroi_pooling_cuda_backward", + &deform_psroi_pooling_cuda_backward, + "deform psroi pooling backward(CUDA)"); +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_pool_cuda_kernel.cu b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_pool_cuda_kernel.cu new file mode 100644 index 000000000..05b00d4be --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_pool_cuda_kernel.cu @@ -0,0 +1,364 @@ +/*! + * Copyright (c) 2017 Microsoft + * Licensed under The MIT License [see LICENSE for details] + * \file deformable_psroi_pooling.cu + * \brief + * \author Yi Li, Guodong Zhang, Jifeng Dai +*/ +/***************** Adapted by Charles Shang *********************/ +// modify from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/mmdetection/mmdet/ops/dcn/src/cuda/deform_psroi_pooling_cuda.cu + +#include +#include +#include +#include +#include + +using namespace at; + +#define CUDA_KERNEL_LOOP(i, n) \ + for (int i = blockIdx.x * blockDim.x + threadIdx.x; \ + i < (n); \ + i += blockDim.x * gridDim.x) + +const int CUDA_NUM_THREADS = 1024; +inline int GET_BLOCKS(const int N) +{ + return (N + CUDA_NUM_THREADS - 1) / CUDA_NUM_THREADS; +} + +template +__device__ scalar_t bilinear_interp( + const scalar_t *data, + const scalar_t x, + const scalar_t y, + const int width, + const int height) +{ + int x1 = floor(x); + int x2 = ceil(x); + int y1 = floor(y); + int y2 = ceil(y); + scalar_t dist_x = (scalar_t)(x - x1); + scalar_t dist_y = (scalar_t)(y - y1); + scalar_t value11 = data[y1 * width + x1]; + scalar_t value12 = data[y2 * width + x1]; + scalar_t value21 = data[y1 * width + x2]; + scalar_t value22 = data[y2 * width + x2]; + scalar_t value = (1 - dist_x) * (1 - dist_y) * value11 + (1 - dist_x) * dist_y * value12 + dist_x * (1 - dist_y) * value21 + dist_x * dist_y * value22; + return value; +} + +template +__global__ void DeformablePSROIPoolForwardKernel( + const int count, + const scalar_t *bottom_data, + const scalar_t spatial_scale, + const int channels, + const int height, const int width, + const int pooled_height, const int pooled_width, + const scalar_t *bottom_rois, const scalar_t *bottom_trans, + const int no_trans, + const scalar_t trans_std, + const int sample_per_part, + const int output_dim, + const int group_size, + const int part_size, + const int num_classes, + const int channels_each_class, + scalar_t *top_data, + scalar_t *top_count) +{ + CUDA_KERNEL_LOOP(index, count) + { + // The output is in order (n, ctop, ph, pw) + int pw = index % pooled_width; + int ph = (index / pooled_width) % pooled_height; + int ctop = (index / pooled_width / pooled_height) % output_dim; + int n = index / pooled_width / pooled_height / output_dim; + + // [start, end) interval for spatial sampling + const scalar_t *offset_bottom_rois = bottom_rois + n * 5; + int roi_batch_ind = offset_bottom_rois[0]; + scalar_t roi_start_w = (scalar_t)(round(offset_bottom_rois[1])) * spatial_scale - 0.5; + scalar_t roi_start_h = (scalar_t)(round(offset_bottom_rois[2])) * spatial_scale - 0.5; + scalar_t roi_end_w = (scalar_t)(round(offset_bottom_rois[3]) + 1.) * spatial_scale - 0.5; + scalar_t roi_end_h = (scalar_t)(round(offset_bottom_rois[4]) + 1.) * spatial_scale - 0.5; + + // Force too small ROIs to be 1x1 + scalar_t roi_width = max(roi_end_w - roi_start_w, 0.1); //avoid 0 + scalar_t roi_height = max(roi_end_h - roi_start_h, 0.1); + + // Compute w and h at bottom + scalar_t bin_size_h = roi_height / (scalar_t)(pooled_height); + scalar_t bin_size_w = roi_width / (scalar_t)(pooled_width); + + scalar_t sub_bin_size_h = bin_size_h / (scalar_t)(sample_per_part); + scalar_t sub_bin_size_w = bin_size_w / (scalar_t)(sample_per_part); + + int part_h = floor((scalar_t)(ph) / pooled_height * part_size); + int part_w = floor((scalar_t)(pw) / pooled_width * part_size); + int class_id = ctop / channels_each_class; + scalar_t trans_x = no_trans ? (scalar_t)(0) : bottom_trans[(((n * num_classes + class_id) * 2) * part_size + part_h) * part_size + part_w] * (scalar_t)trans_std; + scalar_t trans_y = no_trans ? (scalar_t)(0) : bottom_trans[(((n * num_classes + class_id) * 2 + 1) * part_size + part_h) * part_size + part_w] * (scalar_t)trans_std; + + scalar_t wstart = (scalar_t)(pw)*bin_size_w + roi_start_w; + wstart += trans_x * roi_width; + scalar_t hstart = (scalar_t)(ph)*bin_size_h + roi_start_h; + hstart += trans_y * roi_height; + + scalar_t sum = 0; + int count = 0; + int gw = floor((scalar_t)(pw)*group_size / pooled_width); + int gh = floor((scalar_t)(ph)*group_size / pooled_height); + gw = min(max(gw, 0), group_size - 1); + gh = min(max(gh, 0), group_size - 1); + + const scalar_t *offset_bottom_data = bottom_data + (roi_batch_ind * channels) * height * width; + for (int ih = 0; ih < sample_per_part; ih++) + { + for (int iw = 0; iw < sample_per_part; iw++) + { + scalar_t w = wstart + iw * sub_bin_size_w; + scalar_t h = hstart + ih * sub_bin_size_h; + // bilinear interpolation + if (w < -0.5 || w > width - 0.5 || h < -0.5 || h > height - 0.5) + { + continue; + } + w = min(max(w, 0.), width - 1.); + h = min(max(h, 0.), height - 1.); + int c = (ctop * group_size + gh) * group_size + gw; + scalar_t val = bilinear_interp(offset_bottom_data + c * height * width, w, h, width, height); + sum += val; + count++; + } + } + top_data[index] = count == 0 ? (scalar_t)(0) : sum / count; + top_count[index] = count; + } +} + +template +__global__ void DeformablePSROIPoolBackwardAccKernel( + const int count, + const scalar_t *top_diff, + const scalar_t *top_count, + const int num_rois, + const scalar_t spatial_scale, + const int channels, + const int height, const int width, + const int pooled_height, const int pooled_width, + const int output_dim, + scalar_t *bottom_data_diff, scalar_t *bottom_trans_diff, + const scalar_t *bottom_data, + const scalar_t *bottom_rois, + const scalar_t *bottom_trans, + const int no_trans, + const scalar_t trans_std, + const int sample_per_part, + const int group_size, + const int part_size, + const int num_classes, + const int channels_each_class) +{ + CUDA_KERNEL_LOOP(index, count) + { + // The output is in order (n, ctop, ph, pw) + int pw = index % pooled_width; + int ph = (index / pooled_width) % pooled_height; + int ctop = (index / pooled_width / pooled_height) % output_dim; + int n = index / pooled_width / pooled_height / output_dim; + + // [start, end) interval for spatial sampling + const scalar_t *offset_bottom_rois = bottom_rois + n * 5; + int roi_batch_ind = offset_bottom_rois[0]; + scalar_t roi_start_w = (scalar_t)(round(offset_bottom_rois[1])) * spatial_scale - 0.5; + scalar_t roi_start_h = (scalar_t)(round(offset_bottom_rois[2])) * spatial_scale - 0.5; + scalar_t roi_end_w = (scalar_t)(round(offset_bottom_rois[3]) + 1.) * spatial_scale - 0.5; + scalar_t roi_end_h = (scalar_t)(round(offset_bottom_rois[4]) + 1.) * spatial_scale - 0.5; + + // Force too small ROIs to be 1x1 + scalar_t roi_width = max(roi_end_w - roi_start_w, 0.1); //avoid 0 + scalar_t roi_height = max(roi_end_h - roi_start_h, 0.1); + + // Compute w and h at bottom + scalar_t bin_size_h = roi_height / (scalar_t)(pooled_height); + scalar_t bin_size_w = roi_width / (scalar_t)(pooled_width); + + scalar_t sub_bin_size_h = bin_size_h / (scalar_t)(sample_per_part); + scalar_t sub_bin_size_w = bin_size_w / (scalar_t)(sample_per_part); + + int part_h = floor((scalar_t)(ph) / pooled_height * part_size); + int part_w = floor((scalar_t)(pw) / pooled_width * part_size); + int class_id = ctop / channels_each_class; + scalar_t trans_x = no_trans ? (scalar_t)(0) : bottom_trans[(((n * num_classes + class_id) * 2) * part_size + part_h) * part_size + part_w] * (scalar_t)trans_std; + scalar_t trans_y = no_trans ? (scalar_t)(0) : bottom_trans[(((n * num_classes + class_id) * 2 + 1) * part_size + part_h) * part_size + part_w] * (scalar_t)trans_std; + + scalar_t wstart = (scalar_t)(pw)*bin_size_w + roi_start_w; + wstart += trans_x * roi_width; + scalar_t hstart = (scalar_t)(ph)*bin_size_h + roi_start_h; + hstart += trans_y * roi_height; + + if (top_count[index] <= 0) + { + continue; + } + scalar_t diff_val = top_diff[index] / top_count[index]; + const scalar_t *offset_bottom_data = bottom_data + roi_batch_ind * channels * height * width; + scalar_t *offset_bottom_data_diff = bottom_data_diff + roi_batch_ind * channels * height * width; + int gw = floor((scalar_t)(pw)*group_size / pooled_width); + int gh = floor((scalar_t)(ph)*group_size / pooled_height); + gw = min(max(gw, 0), group_size - 1); + gh = min(max(gh, 0), group_size - 1); + + for (int ih = 0; ih < sample_per_part; ih++) + { + for (int iw = 0; iw < sample_per_part; iw++) + { + scalar_t w = wstart + iw * sub_bin_size_w; + scalar_t h = hstart + ih * sub_bin_size_h; + // bilinear interpolation + if (w < -0.5 || w > width - 0.5 || h < -0.5 || h > height - 0.5) + { + continue; + } + w = min(max(w, 0.), width - 1.); + h = min(max(h, 0.), height - 1.); + int c = (ctop * group_size + gh) * group_size + gw; + // backward on feature + int x0 = floor(w); + int x1 = ceil(w); + int y0 = floor(h); + int y1 = ceil(h); + scalar_t dist_x = w - x0, dist_y = h - y0; + scalar_t q00 = (1 - dist_x) * (1 - dist_y); + scalar_t q01 = (1 - dist_x) * dist_y; + scalar_t q10 = dist_x * (1 - dist_y); + scalar_t q11 = dist_x * dist_y; + int bottom_index_base = c * height * width; + atomicAdd(offset_bottom_data_diff + bottom_index_base + y0 * width + x0, q00 * diff_val); + atomicAdd(offset_bottom_data_diff + bottom_index_base + y1 * width + x0, q01 * diff_val); + atomicAdd(offset_bottom_data_diff + bottom_index_base + y0 * width + x1, q10 * diff_val); + atomicAdd(offset_bottom_data_diff + bottom_index_base + y1 * width + x1, q11 * diff_val); + + if (no_trans) + { + continue; + } + scalar_t U00 = offset_bottom_data[bottom_index_base + y0 * width + x0]; + scalar_t U01 = offset_bottom_data[bottom_index_base + y1 * width + x0]; + scalar_t U10 = offset_bottom_data[bottom_index_base + y0 * width + x1]; + scalar_t U11 = offset_bottom_data[bottom_index_base + y1 * width + x1]; + scalar_t diff_x = (U11 * dist_y + U10 * (1 - dist_y) - U01 * dist_y - U00 * (1 - dist_y)) * trans_std * diff_val; + diff_x *= roi_width; + scalar_t diff_y = (U11 * dist_x + U01 * (1 - dist_x) - U10 * dist_x - U00 * (1 - dist_x)) * trans_std * diff_val; + diff_y *= roi_height; + + atomicAdd(bottom_trans_diff + (((n * num_classes + class_id) * 2) * part_size + part_h) * part_size + part_w, diff_x); + atomicAdd(bottom_trans_diff + (((n * num_classes + class_id) * 2 + 1) * part_size + part_h) * part_size + part_w, diff_y); + } + } + } +} + +void DeformablePSROIPoolForward(const at::Tensor data, + const at::Tensor bbox, + const at::Tensor trans, + at::Tensor out, + at::Tensor top_count, + const int batch, + const int channels, + const int height, + const int width, + const int num_bbox, + const int channels_trans, + const int no_trans, + const float spatial_scale, + const int output_dim, + const int group_size, + const int pooled_size, + const int part_size, + const int sample_per_part, + const float trans_std) +{ + const int pooled_height = pooled_size; + const int pooled_width = pooled_size; + const int count = num_bbox * output_dim * pooled_height * pooled_width; + const int num_classes = no_trans ? 1 : channels_trans / 2; + const int channels_each_class = no_trans ? output_dim : output_dim / num_classes; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + data.scalar_type(), "deformable_psroi_pool_forward", ([&] { + const scalar_t *bottom_data = data.data(); + const scalar_t *bottom_rois = bbox.data(); + const scalar_t *bottom_trans = no_trans ? NULL : trans.data(); + scalar_t *top_data = out.data(); + scalar_t *top_count_data = top_count.data(); + + DeformablePSROIPoolForwardKernel<<>>( + count, bottom_data, (scalar_t)spatial_scale, channels, height, width, pooled_height, pooled_width, + bottom_rois, bottom_trans, no_trans, (scalar_t)trans_std, sample_per_part, output_dim, + group_size, part_size, num_classes, channels_each_class, top_data, top_count_data); + })); + + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) + { + printf("error in DeformablePSROIPoolForward: %s\n", cudaGetErrorString(err)); + } +} + +void DeformablePSROIPoolBackwardAcc(const at::Tensor out_grad, + const at::Tensor data, + const at::Tensor bbox, + const at::Tensor trans, + const at::Tensor top_count, + at::Tensor in_grad, + at::Tensor trans_grad, + const int batch, + const int channels, + const int height, + const int width, + const int num_bbox, + const int channels_trans, + const int no_trans, + const float spatial_scale, + const int output_dim, + const int group_size, + const int pooled_size, + const int part_size, + const int sample_per_part, + const float trans_std) +{ + // LOG(INFO) << "DeformablePSROIPoolBackward"; + const int num_rois = num_bbox; + const int pooled_height = pooled_size; + const int pooled_width = pooled_size; + const int count = num_bbox * output_dim * pooled_height * pooled_width; + const int num_classes = no_trans ? 1 : channels_trans / 2; + const int channels_each_class = no_trans ? output_dim : output_dim / num_classes; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + out_grad.scalar_type(), "deformable_psroi_pool_backward_acc", ([&] { + const scalar_t *top_diff = out_grad.data(); + const scalar_t *bottom_data = data.data(); + const scalar_t *bottom_rois = bbox.data(); + const scalar_t *bottom_trans = no_trans ? NULL : trans.data(); + scalar_t *bottom_data_diff = in_grad.data(); + scalar_t *bottom_trans_diff = no_trans ? NULL : trans_grad.data(); + const scalar_t *top_count_data = top_count.data(); + + DeformablePSROIPoolBackwardAccKernel<<>>( + count, top_diff, top_count_data, num_rois, (scalar_t)spatial_scale, channels, height, width, + pooled_height, pooled_width, output_dim, bottom_data_diff, bottom_trans_diff, + bottom_data, bottom_rois, bottom_trans, no_trans, (scalar_t)trans_std, sample_per_part, + group_size, part_size, num_classes, channels_each_class); + })); + + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) + { + printf("error in DeformablePSROIPoolForward: %s\n", cudaGetErrorString(err)); + } +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/__init__.py new file mode 100644 index 000000000..f537ace08 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/__init__.py @@ -0,0 +1,3 @@ +from .masked_conv import MaskedConv2d, masked_conv2d + +__all__ = ['masked_conv2d', 'MaskedConv2d'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/masked_conv.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/masked_conv.py new file mode 100644 index 000000000..7d84f503c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/masked_conv.py @@ -0,0 +1,89 @@ +import math + +import torch +import torch.nn as nn +from torch.autograd import Function +from torch.autograd.function import once_differentiable +from torch.nn.modules.utils import _pair + +from . import masked_conv2d_cuda + + +class MaskedConv2dFunction(Function): + + @staticmethod + def forward(ctx, features, mask, weight, bias, padding=0, stride=1): + assert mask.dim() == 3 and mask.size(0) == 1 + assert features.dim() == 4 and features.size(0) == 1 + assert features.size()[2:] == mask.size()[1:] + pad_h, pad_w = _pair(padding) + stride_h, stride_w = _pair(stride) + if stride_h != 1 or stride_w != 1: + raise ValueError( + 'Stride could not only be 1 in masked_conv2d currently.') + if not features.is_cuda: + raise NotImplementedError + + out_channel, in_channel, kernel_h, kernel_w = weight.size() + + batch_size = features.size(0) + out_h = int( + math.floor((features.size(2) + 2 * pad_h - + (kernel_h - 1) - 1) / stride_h + 1)) + out_w = int( + math.floor((features.size(3) + 2 * pad_w - + (kernel_h - 1) - 1) / stride_w + 1)) + mask_inds = torch.nonzero(mask[0] > 0) + output = features.new_zeros(batch_size, out_channel, out_h, out_w) + if mask_inds.numel() > 0: + mask_h_idx = mask_inds[:, 0].contiguous() + mask_w_idx = mask_inds[:, 1].contiguous() + data_col = features.new_zeros(in_channel * kernel_h * kernel_w, + mask_inds.size(0)) + masked_conv2d_cuda.masked_im2col_forward(features, mask_h_idx, + mask_w_idx, kernel_h, + kernel_w, pad_h, pad_w, + data_col) + + masked_output = torch.addmm(1, bias[:, None], 1, + weight.view(out_channel, -1), data_col) + masked_conv2d_cuda.masked_col2im_forward(masked_output, mask_h_idx, + mask_w_idx, out_h, out_w, + out_channel, output) + return output + + @staticmethod + @once_differentiable + def backward(ctx, grad_output): + return (None, ) * 5 + + +masked_conv2d = MaskedConv2dFunction.apply + + +class MaskedConv2d(nn.Conv2d): + """A MaskedConv2d which inherits the official Conv2d. + + The masked forward doesn't implement the backward function and only + supports the stride parameter to be 1 currently. + """ + + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride=1, + padding=0, + dilation=1, + groups=1, + bias=True): + super(MaskedConv2d, + self).__init__(in_channels, out_channels, kernel_size, stride, + padding, dilation, groups, bias) + + def forward(self, input, mask=None): + if mask is None: # fallback to the normal Conv2d + return super(MaskedConv2d, self).forward(input) + else: + return masked_conv2d(input, mask, self.weight, self.bias, + self.padding) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/src/masked_conv2d_cuda.cpp b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/src/masked_conv2d_cuda.cpp new file mode 100644 index 000000000..6e495abe3 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/src/masked_conv2d_cuda.cpp @@ -0,0 +1,74 @@ +#include + +#include +#include + +int MaskedIm2colForwardLaucher(const at::Tensor im, const int height, + const int width, const int channels, + const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, + const at::Tensor mask_h_idx, + const at::Tensor mask_w_idx, const int mask_cnt, + at::Tensor col); + +int MaskedCol2imForwardLaucher(const at::Tensor col, const int height, + const int width, const int channels, + const at::Tensor mask_h_idx, + const at::Tensor mask_w_idx, const int mask_cnt, + at::Tensor im); + +#define CHECK_CUDA(x) TORCH_CHECK(x.is_cuda(), #x, " must be a CUDAtensor ") +#define CHECK_CONTIGUOUS(x) \ + TORCH_CHECK(x.is_contiguous(), #x, " must be contiguous ") +#define CHECK_INPUT(x) \ + CHECK_CUDA(x); \ + CHECK_CONTIGUOUS(x) + +int masked_im2col_forward_cuda(const at::Tensor im, const at::Tensor mask_h_idx, + const at::Tensor mask_w_idx, const int kernel_h, + const int kernel_w, const int pad_h, + const int pad_w, at::Tensor col) { + CHECK_INPUT(im); + CHECK_INPUT(mask_h_idx); + CHECK_INPUT(mask_w_idx); + CHECK_INPUT(col); + // im: (n, ic, h, w), kernel size (kh, kw) + // kernel: (oc, ic * kh * kw), col: (kh * kw * ic, ow * oh) + + int channels = im.size(1); + int height = im.size(2); + int width = im.size(3); + int mask_cnt = mask_h_idx.size(0); + + MaskedIm2colForwardLaucher(im, height, width, channels, kernel_h, kernel_w, + pad_h, pad_w, mask_h_idx, mask_w_idx, mask_cnt, + col); + + return 1; +} + +int masked_col2im_forward_cuda(const at::Tensor col, + const at::Tensor mask_h_idx, + const at::Tensor mask_w_idx, int height, + int width, int channels, at::Tensor im) { + CHECK_INPUT(col); + CHECK_INPUT(mask_h_idx); + CHECK_INPUT(mask_w_idx); + CHECK_INPUT(im); + // im: (n, ic, h, w), kernel size (kh, kw) + // kernel: (oc, ic * kh * kh), col: (kh * kw * ic, ow * oh) + + int mask_cnt = mask_h_idx.size(0); + + MaskedCol2imForwardLaucher(col, height, width, channels, mask_h_idx, + mask_w_idx, mask_cnt, im); + + return 1; +} + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + m.def("masked_im2col_forward", &masked_im2col_forward_cuda, + "masked_im2col forward (CUDA)"); + m.def("masked_col2im_forward", &masked_col2im_forward_cuda, + "masked_col2im forward (CUDA)"); +} \ No newline at end of file diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/src/masked_conv2d_kernel.cu b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/src/masked_conv2d_kernel.cu new file mode 100644 index 000000000..0f66eb71b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/src/masked_conv2d_kernel.cu @@ -0,0 +1,114 @@ +#include +#include +#include + +#define CUDA_1D_KERNEL_LOOP(i, n) \ + for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ + i += blockDim.x * gridDim.x) + +#define THREADS_PER_BLOCK 1024 + +inline int GET_BLOCKS(const int N) { + int optimal_block_num = (N + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK; + int max_block_num = 65000; + return optimal_block_num - max_block_num < 0? optimal_block_num: max_block_num; +} + +template +__global__ void MaskedIm2colForward(const int n, const scalar_t *data_im, + const int height, const int width, + const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, + const int64_t *mask_h_idx, + const int64_t *mask_w_idx, + const int mask_cnt, scalar_t *data_col) { + // mask_cnt * channels + CUDA_1D_KERNEL_LOOP(index, n) { + const int m_index = index % mask_cnt; + const int h_col = mask_h_idx[m_index]; + const int w_col = mask_w_idx[m_index]; + const int c_im = index / mask_cnt; + const int c_col = c_im * kernel_h * kernel_w; + const int h_offset = h_col - pad_h; + const int w_offset = w_col - pad_w; + scalar_t *data_col_ptr = data_col + c_col * mask_cnt + m_index; + for (int i = 0; i < kernel_h; ++i) { + int h_im = h_offset + i; + for (int j = 0; j < kernel_w; ++j) { + int w_im = w_offset + j; + if (h_im >= 0 && w_im >= 0 && h_im < height && w_im < width) { + *data_col_ptr = + (scalar_t)data_im[(c_im * height + h_im) * width + w_im]; + } else { + *data_col_ptr = 0.0; + } + data_col_ptr += mask_cnt; + } + } + } +} + +int MaskedIm2colForwardLaucher(const at::Tensor bottom_data, const int height, + const int width, const int channels, + const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, + const at::Tensor mask_h_idx, + const at::Tensor mask_w_idx, const int mask_cnt, + at::Tensor top_data) { + const int output_size = mask_cnt * channels; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + bottom_data.scalar_type(), "MaskedIm2colLaucherForward", ([&] { + const scalar_t *bottom_data_ = bottom_data.data(); + const int64_t *mask_h_idx_ = mask_h_idx.data(); + const int64_t *mask_w_idx_ = mask_w_idx.data(); + scalar_t *top_data_ = top_data.data(); + MaskedIm2colForward + <<>>( + output_size, bottom_data_, height, width, kernel_h, kernel_w, + pad_h, pad_w, mask_h_idx_, mask_w_idx_, mask_cnt, top_data_); + })); + THCudaCheck(cudaGetLastError()); + return 1; +} + +template +__global__ void MaskedCol2imForward(const int n, const scalar_t *data_col, + const int height, const int width, + const int channels, + const int64_t *mask_h_idx, + const int64_t *mask_w_idx, + const int mask_cnt, scalar_t *data_im) { + CUDA_1D_KERNEL_LOOP(index, n) { + const int m_index = index % mask_cnt; + const int h_im = mask_h_idx[m_index]; + const int w_im = mask_w_idx[m_index]; + const int c_im = index / mask_cnt; + // compute the start and end of the output + data_im[(c_im * height + h_im) * width + w_im] = data_col[index]; + } +} + +int MaskedCol2imForwardLaucher(const at::Tensor bottom_data, const int height, + const int width, const int channels, + const at::Tensor mask_h_idx, + const at::Tensor mask_w_idx, const int mask_cnt, + at::Tensor top_data) { + const int output_size = mask_cnt * channels; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + bottom_data.scalar_type(), "MaskedCol2imLaucherForward", ([&] { + const scalar_t *bottom_data_ = bottom_data.data(); + const int64_t *mask_h_idx_ = mask_h_idx.data(); + const int64_t *mask_w_idx_ = mask_w_idx.data(); + scalar_t *top_data_ = top_data.data(); + + MaskedCol2imForward + <<>>( + output_size, bottom_data_, height, width, channels, mask_h_idx_, + mask_w_idx_, mask_cnt, top_data_); + })); + THCudaCheck(cudaGetLastError()); + return 1; +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/__init__.py new file mode 100644 index 000000000..c4407041a --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/__init__.py @@ -0,0 +1,3 @@ +from .nms_wrapper import nms, soft_nms + +__all__ = ['nms', 'soft_nms'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/nms_wrapper.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/nms_wrapper.py new file mode 100644 index 000000000..b82e49345 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/nms_wrapper.py @@ -0,0 +1,102 @@ +import numpy as np +import torch + +from . import nms_cpu, nms_cuda +from .soft_nms_cpu import soft_nms_cpu + + +def nms(dets, iou_thr, device_id=None): + """Dispatch to either CPU or GPU NMS implementations. + + The input can be either a torch tensor or numpy array. GPU NMS will be used + if the input is a gpu tensor or device_id is specified, otherwise CPU NMS + will be used. The returned type will always be the same as inputs. + + Arguments: + dets (torch.Tensor or np.ndarray): bboxes with scores. + iou_thr (float): IoU threshold for NMS. + device_id (int, optional): when `dets` is a numpy array, if `device_id` + is None, then cpu nms is used, otherwise gpu_nms will be used. + + Returns: + tuple: kept bboxes and indice, which is always the same data type as + the input. + + Example: + >>> dets = np.array([[49.1, 32.4, 51.0, 35.9, 0.9], + >>> [49.3, 32.9, 51.0, 35.3, 0.9], + >>> [49.2, 31.8, 51.0, 35.4, 0.5], + >>> [35.1, 11.5, 39.1, 15.7, 0.5], + >>> [35.6, 11.8, 39.3, 14.2, 0.5], + >>> [35.3, 11.5, 39.9, 14.5, 0.4], + >>> [35.2, 11.7, 39.7, 15.7, 0.3]], dtype=np.float32) + >>> iou_thr = 0.7 + >>> supressed, inds = nms(dets, iou_thr) + >>> assert len(inds) == len(supressed) == 3 + """ + # convert dets (tensor or numpy array) to tensor + if isinstance(dets, torch.Tensor): + is_numpy = False + dets_th = dets + elif isinstance(dets, np.ndarray): + is_numpy = True + device = 'cpu' if device_id is None else 'cuda:{}'.format(device_id) + dets_th = torch.from_numpy(dets).to(device) + else: + raise TypeError( + 'dets must be either a Tensor or numpy array, but got {}'.format( + type(dets))) + + # execute cpu or cuda nms + if dets_th.shape[0] == 0: + inds = dets_th.new_zeros(0, dtype=torch.long) + else: + if dets_th.is_cuda: + inds = nms_cuda.nms(dets_th, iou_thr) + else: + inds = nms_cpu.nms(dets_th, iou_thr) + + if is_numpy: + inds = inds.cpu().numpy() + return dets[inds, :], inds + + +def soft_nms(dets, iou_thr, method='linear', sigma=0.5, min_score=1e-3): + """ + Example: + >>> dets = np.array([[4., 3., 5., 3., 0.9], + >>> [4., 3., 5., 4., 0.9], + >>> [3., 1., 3., 1., 0.5], + >>> [3., 1., 3., 1., 0.5], + >>> [3., 1., 3., 1., 0.4], + >>> [3., 1., 3., 1., 0.0]], dtype=np.float32) + >>> iou_thr = 0.7 + >>> supressed, inds = soft_nms(dets, iou_thr, sigma=0.5) + >>> assert len(inds) == len(supressed) == 3 + """ + if isinstance(dets, torch.Tensor): + is_tensor = True + dets_np = dets.detach().cpu().numpy() + elif isinstance(dets, np.ndarray): + is_tensor = False + dets_np = dets + else: + raise TypeError( + 'dets must be either a Tensor or numpy array, but got {}'.format( + type(dets))) + + method_codes = {'linear': 1, 'gaussian': 2} + if method not in method_codes: + raise ValueError('Invalid method for SoftNMS: {}'.format(method)) + new_dets, inds = soft_nms_cpu( + dets_np, + iou_thr, + method=method_codes[method], + sigma=sigma, + min_score=min_score) + + if is_tensor: + return dets.new_tensor(new_dets), dets.new_tensor( + inds, dtype=torch.long) + else: + return new_dets.astype(np.float32), inds.astype(np.int64) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_cpu.cpp b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_cpu.cpp new file mode 100644 index 000000000..f7cffb490 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_cpu.cpp @@ -0,0 +1,71 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +#include + +template +at::Tensor nms_cpu_kernel(const at::Tensor& dets, const float threshold) { + AT_ASSERTM(!dets.type().is_cuda(), "dets must be a CPU tensor"); + + if (dets.numel() == 0) { + return at::empty({0}, dets.options().dtype(at::kLong).device(at::kCPU)); + } + + auto x1_t = dets.select(1, 0).contiguous(); + auto y1_t = dets.select(1, 1).contiguous(); + auto x2_t = dets.select(1, 2).contiguous(); + auto y2_t = dets.select(1, 3).contiguous(); + auto scores = dets.select(1, 4).contiguous(); + + at::Tensor areas_t = (x2_t - x1_t + 1) * (y2_t - y1_t + 1); + + auto order_t = std::get<1>(scores.sort(0, /* descending=*/true)); + + auto ndets = dets.size(0); + at::Tensor suppressed_t = + at::zeros({ndets}, dets.options().dtype(at::kByte).device(at::kCPU)); + + auto suppressed = suppressed_t.data(); + auto order = order_t.data(); + auto x1 = x1_t.data(); + auto y1 = y1_t.data(); + auto x2 = x2_t.data(); + auto y2 = y2_t.data(); + auto areas = areas_t.data(); + + for (int64_t _i = 0; _i < ndets; _i++) { + auto i = order[_i]; + if (suppressed[i] == 1) continue; + auto ix1 = x1[i]; + auto iy1 = y1[i]; + auto ix2 = x2[i]; + auto iy2 = y2[i]; + auto iarea = areas[i]; + + for (int64_t _j = _i + 1; _j < ndets; _j++) { + auto j = order[_j]; + if (suppressed[j] == 1) continue; + auto xx1 = std::max(ix1, x1[j]); + auto yy1 = std::max(iy1, y1[j]); + auto xx2 = std::min(ix2, x2[j]); + auto yy2 = std::min(iy2, y2[j]); + + auto w = std::max(static_cast(0), xx2 - xx1 + 1); + auto h = std::max(static_cast(0), yy2 - yy1 + 1); + auto inter = w * h; + auto ovr = inter / (iarea + areas[j] - inter); + if (ovr >= threshold) suppressed[j] = 1; + } + } + return at::nonzero(suppressed_t == 0).squeeze(1); +} + +at::Tensor nms(const at::Tensor& dets, const float threshold) { + at::Tensor result; + AT_DISPATCH_FLOATING_TYPES(dets.scalar_type(), "nms", [&] { + result = nms_cpu_kernel(dets, threshold); + }); + return result; +} + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + m.def("nms", &nms, "non-maximum suppression"); +} \ No newline at end of file diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_cuda.cpp b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_cuda.cpp new file mode 100644 index 000000000..2ac6cd23f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_cuda.cpp @@ -0,0 +1,17 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +#include + +#define CHECK_CUDA(x) TORCH_CHECK(x.is_cuda(), #x, " must be a CUDAtensor ") + +at::Tensor nms_cuda(const at::Tensor boxes, float nms_overlap_thresh); + +at::Tensor nms(const at::Tensor& dets, const float threshold) { + CHECK_CUDA(dets); + if (dets.numel() == 0) + return at::empty({0}, dets.options().dtype(at::kLong).device(at::kCPU)); + return nms_cuda(dets, threshold); +} + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + m.def("nms", &nms, "non-maximum suppression"); +} \ No newline at end of file diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_kernel.cu b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_kernel.cu new file mode 100644 index 000000000..ada9bea25 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_kernel.cu @@ -0,0 +1,139 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +#include +#include +#include + +#include +#include + +#include +#include + +int const threadsPerBlock = sizeof(unsigned long long) * 8; + +__device__ inline float devIoU(float const * const a, float const * const b) { + float left = max(a[0], b[0]), right = min(a[2], b[2]); + float top = max(a[1], b[1]), bottom = min(a[3], b[3]); + float width = max(right - left + 1, 0.f), height = max(bottom - top + 1, 0.f); + float interS = width * height; + float Sa = (a[2] - a[0] + 1) * (a[3] - a[1] + 1); + float Sb = (b[2] - b[0] + 1) * (b[3] - b[1] + 1); + return interS / (Sa + Sb - interS); +} + +__global__ void nms_kernel(const int n_boxes, const float nms_overlap_thresh, + const float *dev_boxes, unsigned long long *dev_mask) { + const int row_start = blockIdx.y; + const int col_start = blockIdx.x; + + // if (row_start > col_start) return; + + const int row_size = + min(n_boxes - row_start * threadsPerBlock, threadsPerBlock); + const int col_size = + min(n_boxes - col_start * threadsPerBlock, threadsPerBlock); + + __shared__ float block_boxes[threadsPerBlock * 5]; + if (threadIdx.x < col_size) { + block_boxes[threadIdx.x * 5 + 0] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 0]; + block_boxes[threadIdx.x * 5 + 1] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 1]; + block_boxes[threadIdx.x * 5 + 2] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 2]; + block_boxes[threadIdx.x * 5 + 3] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 3]; + block_boxes[threadIdx.x * 5 + 4] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 4]; + } + __syncthreads(); + + if (threadIdx.x < row_size) { + const int cur_box_idx = threadsPerBlock * row_start + threadIdx.x; + const float *cur_box = dev_boxes + cur_box_idx * 5; + int i = 0; + unsigned long long t = 0; + int start = 0; + if (row_start == col_start) { + start = threadIdx.x + 1; + } + for (i = start; i < col_size; i++) { + if (devIoU(cur_box, block_boxes + i * 5) > nms_overlap_thresh) { + t |= 1ULL << i; + } + } + const int col_blocks = THCCeilDiv(n_boxes, threadsPerBlock); + dev_mask[cur_box_idx * col_blocks + col_start] = t; + } +} + +// boxes is a N x 5 tensor +at::Tensor nms_cuda(const at::Tensor boxes, float nms_overlap_thresh) { + + // Ensure CUDA uses the input tensor device. + at::DeviceGuard guard(boxes.device()); + + using scalar_t = float; + AT_ASSERTM(boxes.type().is_cuda(), "boxes must be a CUDA tensor"); + auto scores = boxes.select(1, 4); + auto order_t = std::get<1>(scores.sort(0, /* descending=*/true)); + auto boxes_sorted = boxes.index_select(0, order_t); + + int boxes_num = boxes.size(0); + + const int col_blocks = THCCeilDiv(boxes_num, threadsPerBlock); + + scalar_t* boxes_dev = boxes_sorted.data(); + + THCState *state = at::globalContext().lazyInitCUDA(); // TODO replace with getTHCState + + unsigned long long* mask_dev = NULL; + //THCudaCheck(THCudaMalloc(state, (void**) &mask_dev, + // boxes_num * col_blocks * sizeof(unsigned long long))); + + mask_dev = (unsigned long long*) THCudaMalloc(state, boxes_num * col_blocks * sizeof(unsigned long long)); + + dim3 blocks(THCCeilDiv(boxes_num, threadsPerBlock), + THCCeilDiv(boxes_num, threadsPerBlock)); + dim3 threads(threadsPerBlock); + nms_kernel<<>>(boxes_num, + nms_overlap_thresh, + boxes_dev, + mask_dev); + + std::vector mask_host(boxes_num * col_blocks); + THCudaCheck(cudaMemcpyAsync( + &mask_host[0], + mask_dev, + sizeof(unsigned long long) * boxes_num * col_blocks, + cudaMemcpyDeviceToHost, + at::cuda::getCurrentCUDAStream() + )); + + std::vector remv(col_blocks); + memset(&remv[0], 0, sizeof(unsigned long long) * col_blocks); + + at::Tensor keep = at::empty({boxes_num}, boxes.options().dtype(at::kLong).device(at::kCPU)); + int64_t* keep_out = keep.data(); + + int num_to_keep = 0; + for (int i = 0; i < boxes_num; i++) { + int nblock = i / threadsPerBlock; + int inblock = i % threadsPerBlock; + + if (!(remv[nblock] & (1ULL << inblock))) { + keep_out[num_to_keep++] = i; + unsigned long long *p = &mask_host[0] + i * col_blocks; + for (int j = nblock; j < col_blocks; j++) { + remv[j] |= p[j]; + } + } + } + + THCudaFree(state, mask_dev); + // TODO improve this part + return std::get<0>(order_t.index({ + keep.narrow(/*dim=*/0, /*start=*/0, /*length=*/num_to_keep).to( + order_t.device(), keep.scalar_type()) + }).sort(0, false)); +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/soft_nms_cpu.pyx b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/soft_nms_cpu.pyx new file mode 100644 index 000000000..97f53f18d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/soft_nms_cpu.pyx @@ -0,0 +1,127 @@ +# ---------------------------------------------------------- +# Soft-NMS: Improving Object Detection With One Line of Code +# Copyright (c) University of Maryland, College Park +# Licensed under The MIT License [see LICENSE for details] +# Written by Navaneeth Bodla and Bharat Singh +# Modified by Kai Chen +# ---------------------------------------------------------- + +# cython: language_level=3, boundscheck=False + +import numpy as np +cimport numpy as np + + +cdef inline np.float32_t max(np.float32_t a, np.float32_t b): + return a if a >= b else b + +cdef inline np.float32_t min(np.float32_t a, np.float32_t b): + return a if a <= b else b + + +def soft_nms_cpu( + np.ndarray[float, ndim=2] boxes_in, + float iou_thr, + unsigned int method=1, + float sigma=0.5, + float min_score=0.001, +): + boxes = boxes_in.copy() + cdef int N = boxes.shape[0] + cdef float iw, ih, box_area + cdef float ua + cdef int pos = 0 + cdef float maxscore = 0 + cdef int maxpos = 0 + cdef float x1, x2, y1, y2, tx1, tx2, ty1, ty2, ts, area, weight, ov + inds = np.arange(N) + + for i in range(N): + maxscore = boxes[i, 4] + maxpos = i + + tx1 = boxes[i, 0] + ty1 = boxes[i, 1] + tx2 = boxes[i, 2] + ty2 = boxes[i, 3] + ts = boxes[i, 4] + ti = inds[i] + + pos = i + 1 + # get max box + while pos < N: + if maxscore < boxes[pos, 4]: + maxscore = boxes[pos, 4] + maxpos = pos + pos = pos + 1 + + # add max box as a detection + boxes[i, 0] = boxes[maxpos, 0] + boxes[i, 1] = boxes[maxpos, 1] + boxes[i, 2] = boxes[maxpos, 2] + boxes[i, 3] = boxes[maxpos, 3] + boxes[i, 4] = boxes[maxpos, 4] + inds[i] = inds[maxpos] + + # swap ith box with position of max box + boxes[maxpos, 0] = tx1 + boxes[maxpos, 1] = ty1 + boxes[maxpos, 2] = tx2 + boxes[maxpos, 3] = ty2 + boxes[maxpos, 4] = ts + inds[maxpos] = ti + + tx1 = boxes[i, 0] + ty1 = boxes[i, 1] + tx2 = boxes[i, 2] + ty2 = boxes[i, 3] + ts = boxes[i, 4] + + pos = i + 1 + # NMS iterations, note that N changes if detection boxes fall below + # threshold + while pos < N: + x1 = boxes[pos, 0] + y1 = boxes[pos, 1] + x2 = boxes[pos, 2] + y2 = boxes[pos, 3] + s = boxes[pos, 4] + + area = (x2 - x1 + 1) * (y2 - y1 + 1) + iw = (min(tx2, x2) - max(tx1, x1) + 1) + if iw > 0: + ih = (min(ty2, y2) - max(ty1, y1) + 1) + if ih > 0: + ua = float((tx2 - tx1 + 1) * (ty2 - ty1 + 1) + area - iw * ih) + ov = iw * ih / ua # iou between max box and detection box + + if method == 1: # linear + if ov > iou_thr: + weight = 1 - ov + else: + weight = 1 + elif method == 2: # gaussian + weight = np.exp(-(ov * ov) / sigma) + else: # original NMS + if ov > iou_thr: + weight = 0 + else: + weight = 1 + + boxes[pos, 4] = weight * boxes[pos, 4] + + # if box score falls below threshold, discard the box by + # swapping with last box update N + if boxes[pos, 4] < min_score: + boxes[pos, 0] = boxes[N-1, 0] + boxes[pos, 1] = boxes[N-1, 1] + boxes[pos, 2] = boxes[N-1, 2] + boxes[pos, 3] = boxes[N-1, 3] + boxes[pos, 4] = boxes[N-1, 4] + inds[pos] = inds[N - 1] + N = N - 1 + pos = pos - 1 + + pos = pos + 1 + + return boxes[:N], inds[:N] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/__init__.py new file mode 100644 index 000000000..6da98298f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/__init__.py @@ -0,0 +1,3 @@ +from .roi_align import RoIAlign, roi_align + +__all__ = ['roi_align', 'RoIAlign'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/gradcheck.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/gradcheck.py new file mode 100644 index 000000000..136456b39 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/gradcheck.py @@ -0,0 +1,30 @@ +import os.path as osp +import sys + +import numpy as np +import torch +from torch.autograd import gradcheck + +sys.path.append(osp.abspath(osp.join(__file__, '../../'))) +from roi_align import RoIAlign # noqa: E402, isort:skip + +feat_size = 15 +spatial_scale = 1.0 / 8 +img_size = feat_size / spatial_scale +num_imgs = 2 +num_rois = 20 + +batch_ind = np.random.randint(num_imgs, size=(num_rois, 1)) +rois = np.random.rand(num_rois, 4) * img_size * 0.5 +rois[:, 2:] += img_size * 0.5 +rois = np.hstack((batch_ind, rois)) + +feat = torch.randn( + num_imgs, 16, feat_size, feat_size, requires_grad=True, device='cuda:0') +rois = torch.from_numpy(rois).float().cuda() +inputs = (feat, rois) +print('Gradcheck for roi align...') +test = gradcheck(RoIAlign(3, spatial_scale), inputs, atol=1e-3, eps=1e-3) +print(test) +test = gradcheck(RoIAlign(3, spatial_scale, 2), inputs, atol=1e-3, eps=1e-3) +print(test) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/roi_align.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/roi_align.py new file mode 100644 index 000000000..a4cf24459 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/roi_align.py @@ -0,0 +1,87 @@ +import torch.nn as nn +from torch.autograd import Function +from torch.autograd.function import once_differentiable +from torch.nn.modules.utils import _pair + +from . import roi_align_cuda + + +class RoIAlignFunction(Function): + + @staticmethod + def forward(ctx, features, rois, out_size, spatial_scale, sample_num=0): + out_h, out_w = _pair(out_size) + assert isinstance(out_h, int) and isinstance(out_w, int) + ctx.spatial_scale = spatial_scale + ctx.sample_num = sample_num + ctx.save_for_backward(rois) + ctx.feature_size = features.size() + + batch_size, num_channels, data_height, data_width = features.size() + num_rois = rois.size(0) + + output = features.new_zeros(num_rois, num_channels, out_h, out_w) + if features.is_cuda: + roi_align_cuda.forward(features, rois, out_h, out_w, spatial_scale, + sample_num, output) + else: + raise NotImplementedError + + return output + + @staticmethod + @once_differentiable + def backward(ctx, grad_output): + feature_size = ctx.feature_size + spatial_scale = ctx.spatial_scale + sample_num = ctx.sample_num + rois = ctx.saved_tensors[0] + assert (feature_size is not None and grad_output.is_cuda) + + batch_size, num_channels, data_height, data_width = feature_size + out_w = grad_output.size(3) + out_h = grad_output.size(2) + + grad_input = grad_rois = None + if ctx.needs_input_grad[0]: + grad_input = rois.new_zeros(batch_size, num_channels, data_height, + data_width) + roi_align_cuda.backward(grad_output.contiguous(), rois, out_h, + out_w, spatial_scale, sample_num, + grad_input) + + return grad_input, grad_rois, None, None, None + + +roi_align = RoIAlignFunction.apply + + +class RoIAlign(nn.Module): + + def __init__(self, + out_size, + spatial_scale, + sample_num=0, + use_torchvision=False): + super(RoIAlign, self).__init__() + + self.out_size = _pair(out_size) + self.spatial_scale = float(spatial_scale) + self.sample_num = int(sample_num) + self.use_torchvision = use_torchvision + + def forward(self, features, rois): + if self.use_torchvision: + from torchvision.ops import roi_align as tv_roi_align + return tv_roi_align(features, rois, self.out_size, + self.spatial_scale, self.sample_num) + else: + return roi_align(features, rois, self.out_size, self.spatial_scale, + self.sample_num) + + def __repr__(self): + format_str = self.__class__.__name__ + format_str += '(out_size={}, spatial_scale={}, sample_num={}'.format( + self.out_size, self.spatial_scale, self.sample_num) + format_str += ', use_torchvision={})'.format(self.use_torchvision) + return format_str diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/src/roi_align_cuda.cpp b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/src/roi_align_cuda.cpp new file mode 100644 index 000000000..66a557252 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/src/roi_align_cuda.cpp @@ -0,0 +1,87 @@ +#include + +#include + +#include +#include + +int ROIAlignForwardLaucher(const at::Tensor features, const at::Tensor rois, + const float spatial_scale, const int sample_num, + const int channels, const int height, + const int width, const int num_rois, + const int pooled_height, const int pooled_width, + at::Tensor output); + +int ROIAlignBackwardLaucher(const at::Tensor top_grad, const at::Tensor rois, + const float spatial_scale, const int sample_num, + const int channels, const int height, + const int width, const int num_rois, + const int pooled_height, const int pooled_width, + at::Tensor bottom_grad); + +#define CHECK_CUDA(x) TORCH_CHECK(x.is_cuda(), #x, " must be a CUDAtensor ") +#define CHECK_CONTIGUOUS(x) \ + TORCH_CHECK(x.is_contiguous(), #x, " must be contiguous ") +#define CHECK_INPUT(x) \ + CHECK_CUDA(x); \ + CHECK_CONTIGUOUS(x) + +int roi_align_forward_cuda(at::Tensor features, at::Tensor rois, + int pooled_height, int pooled_width, + float spatial_scale, int sample_num, + at::Tensor output) { + CHECK_INPUT(features); + CHECK_INPUT(rois); + CHECK_INPUT(output); + + // Number of ROIs + int num_rois = rois.size(0); + int size_rois = rois.size(1); + + if (size_rois != 5) { + printf("wrong roi size\n"); + return 0; + } + + int num_channels = features.size(1); + int data_height = features.size(2); + int data_width = features.size(3); + + ROIAlignForwardLaucher(features, rois, spatial_scale, sample_num, + num_channels, data_height, data_width, num_rois, + pooled_height, pooled_width, output); + + return 1; +} + +int roi_align_backward_cuda(at::Tensor top_grad, at::Tensor rois, + int pooled_height, int pooled_width, + float spatial_scale, int sample_num, + at::Tensor bottom_grad) { + CHECK_INPUT(top_grad); + CHECK_INPUT(rois); + CHECK_INPUT(bottom_grad); + + // Number of ROIs + int num_rois = rois.size(0); + int size_rois = rois.size(1); + if (size_rois != 5) { + printf("wrong roi size\n"); + return 0; + } + + int num_channels = bottom_grad.size(1); + int data_height = bottom_grad.size(2); + int data_width = bottom_grad.size(3); + + ROIAlignBackwardLaucher(top_grad, rois, spatial_scale, sample_num, + num_channels, data_height, data_width, num_rois, + pooled_height, pooled_width, bottom_grad); + + return 1; +} + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + m.def("forward", &roi_align_forward_cuda, "Roi_Align forward (CUDA)"); + m.def("backward", &roi_align_backward_cuda, "Roi_Align backward (CUDA)"); +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/src/roi_align_kernel.cu b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/src/roi_align_kernel.cu new file mode 100644 index 000000000..038fc23e0 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/src/roi_align_kernel.cu @@ -0,0 +1,283 @@ +#include +#include +#include + +#define CUDA_1D_KERNEL_LOOP(i, n) \ + for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ + i += blockDim.x * gridDim.x) + +#define THREADS_PER_BLOCK 1024 + +inline int GET_BLOCKS(const int N) { + int optimal_block_num = (N + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK; + int max_block_num = 65000; + return optimal_block_num - max_block_num < 0? optimal_block_num: max_block_num; +} + +template +__device__ scalar_t bilinear_interpolate(const scalar_t *bottom_data, + const int height, const int width, + scalar_t y, scalar_t x) { + // deal with cases that inverse elements are out of feature map boundary + if (y < -1.0 || y > height || x < -1.0 || x > width) { + return 0; + } + + if (y <= 0) y = 0; + if (x <= 0) x = 0; + + int y_low = (int)y; + int x_low = (int)x; + int y_high; + int x_high; + + if (y_low >= height - 1) { + y_high = y_low = height - 1; + y = (scalar_t)y_low; + } else { + y_high = y_low + 1; + } + + if (x_low >= width - 1) { + x_high = x_low = width - 1; + x = (scalar_t)x_low; + } else { + x_high = x_low + 1; + } + + scalar_t ly = y - y_low; + scalar_t lx = x - x_low; + scalar_t hy = 1. - ly; + scalar_t hx = 1. - lx; + // do bilinear interpolation + scalar_t lt = bottom_data[y_low * width + x_low]; + scalar_t rt = bottom_data[y_low * width + x_high]; + scalar_t lb = bottom_data[y_high * width + x_low]; + scalar_t rb = bottom_data[y_high * width + x_high]; + scalar_t w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; + + scalar_t val = (w1 * lt + w2 * rt + w3 * lb + w4 * rb); + + return val; +} + +template +__global__ void ROIAlignForward(const int nthreads, const scalar_t *bottom_data, + const scalar_t *bottom_rois, + const scalar_t spatial_scale, + const int sample_num, const int channels, + const int height, const int width, + const int pooled_height, const int pooled_width, + scalar_t *top_data) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + // (n, c, ph, pw) is an element in the aligned output + int pw = index % pooled_width; + int ph = (index / pooled_width) % pooled_height; + int c = (index / pooled_width / pooled_height) % channels; + int n = index / pooled_width / pooled_height / channels; + + const scalar_t *offset_bottom_rois = bottom_rois + n * 5; + int roi_batch_ind = offset_bottom_rois[0]; + scalar_t roi_start_w = offset_bottom_rois[1] * spatial_scale; + scalar_t roi_start_h = offset_bottom_rois[2] * spatial_scale; + scalar_t roi_end_w = (offset_bottom_rois[3] + 1) * spatial_scale; + scalar_t roi_end_h = (offset_bottom_rois[4] + 1) * spatial_scale; + + // Force malformed ROIs to be 1x1 + scalar_t roi_width = fmaxf((scalar_t)roi_end_w - roi_start_w, 0.); + scalar_t roi_height = fmaxf((scalar_t)roi_end_h - roi_start_h, 0.); + + scalar_t bin_size_h = roi_height / pooled_height; + scalar_t bin_size_w = roi_width / pooled_width; + + const scalar_t *offset_bottom_data = + bottom_data + (roi_batch_ind * channels + c) * height * width; + + int sample_num_h = (sample_num > 0) + ? sample_num + : ceil(roi_height / pooled_height); // e.g., = 2 + int sample_num_w = + (sample_num > 0) ? sample_num : ceil(roi_width / pooled_width); + + scalar_t output_val = 0; + for (int iy = 0; iy < sample_num_h; iy++) { + const scalar_t y = roi_start_h + ph * bin_size_h + + (scalar_t)(iy + scalar_t(.5f)) * bin_size_h / + (scalar_t)(sample_num_h); + for (int ix = 0; ix < sample_num_w; ix++) { + const scalar_t x = roi_start_w + pw * bin_size_w + + (scalar_t)(ix + scalar_t(.5f)) * bin_size_w / + (scalar_t)(sample_num_w); + scalar_t val = bilinear_interpolate(offset_bottom_data, + height, width, y, x); + output_val += val; + } + } + output_val /= (sample_num_h * sample_num_w); + top_data[index] = output_val; + } +} + +int ROIAlignForwardLaucher(const at::Tensor features, const at::Tensor rois, + const float spatial_scale, const int sample_num, + const int channels, const int height, + const int width, const int num_rois, + const int pooled_height, const int pooled_width, + at::Tensor output) { + const int output_size = num_rois * pooled_height * pooled_width * channels; + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + features.scalar_type(), "ROIAlignLaucherForward", ([&] { + const scalar_t *bottom_data = features.data(); + const scalar_t *rois_data = rois.data(); + scalar_t *top_data = output.data(); + + ROIAlignForward + <<>>( + output_size, bottom_data, rois_data, scalar_t(spatial_scale), + sample_num, channels, height, width, pooled_height, + pooled_width, top_data); + })); + THCudaCheck(cudaGetLastError()); + return 1; +} + +template +__device__ void bilinear_interpolate_gradient(const int height, const int width, + scalar_t y, scalar_t x, + scalar_t &w1, scalar_t &w2, + scalar_t &w3, scalar_t &w4, + int &x_low, int &x_high, + int &y_low, int &y_high) { + // deal with cases that inverse elements are out of feature map boundary + if (y < -1.0 || y > height || x < -1.0 || x > width) { + w1 = w2 = w3 = w4 = 0.; + x_low = x_high = y_low = y_high = -1; + return; + } + + if (y <= 0) y = 0; + if (x <= 0) x = 0; + + y_low = (int)y; + x_low = (int)x; + + if (y_low >= height - 1) { + y_high = y_low = height - 1; + y = (scalar_t)y_low; + } else { + y_high = y_low + 1; + } + + if (x_low >= width - 1) { + x_high = x_low = width - 1; + x = (scalar_t)x_low; + } else { + x_high = x_low + 1; + } + + scalar_t ly = y - y_low; + scalar_t lx = x - x_low; + scalar_t hy = 1. - ly; + scalar_t hx = 1. - lx; + + w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; + + return; +} + +template +__global__ void ROIAlignBackward( + const int nthreads, const scalar_t *top_diff, const scalar_t *bottom_rois, + const scalar_t spatial_scale, const int sample_num, const int channels, + const int height, const int width, const int pooled_height, + const int pooled_width, scalar_t *bottom_diff) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + // (n, c, ph, pw) is an element in the aligned output + int pw = index % pooled_width; + int ph = (index / pooled_width) % pooled_height; + int c = (index / pooled_width / pooled_height) % channels; + int n = index / pooled_width / pooled_height / channels; + + const scalar_t *offset_bottom_rois = bottom_rois + n * 5; + int roi_batch_ind = offset_bottom_rois[0]; + scalar_t roi_start_w = offset_bottom_rois[1] * spatial_scale; + scalar_t roi_start_h = offset_bottom_rois[2] * spatial_scale; + scalar_t roi_end_w = (offset_bottom_rois[3] + 1) * spatial_scale; + scalar_t roi_end_h = (offset_bottom_rois[4] + 1) * spatial_scale; + + // Force malformed ROIs to be 1x1 + scalar_t roi_width = fmaxf((scalar_t)roi_end_w - roi_start_w, 0.); + scalar_t roi_height = fmaxf((scalar_t)roi_end_h - roi_start_h, 0.); + + scalar_t bin_size_h = roi_height / pooled_height; + scalar_t bin_size_w = roi_width / pooled_width; + + scalar_t *offset_bottom_diff = + bottom_diff + (roi_batch_ind * channels + c) * height * width; + int offset_top = (n * channels + c) * pooled_height * pooled_width + + ph * pooled_width + pw; + scalar_t offset_top_diff = top_diff[offset_top]; + + int sample_num_h = (sample_num > 0) + ? sample_num + : ceil(roi_height / pooled_height); // e.g., = 2 + int sample_num_w = + (sample_num > 0) ? sample_num : ceil(roi_width / pooled_width); + + const scalar_t count = (scalar_t)(sample_num_h * sample_num_w); + + for (int iy = 0; iy < sample_num_h; iy++) { + const scalar_t y = + roi_start_h + ph * bin_size_h + + (scalar_t)(iy + .5f) * bin_size_h / (scalar_t)(sample_num_h); + for (int ix = 0; ix < sample_num_w; ix++) { + const scalar_t x = + roi_start_w + pw * bin_size_w + + (scalar_t)(ix + .5f) * bin_size_w / (scalar_t)(sample_num_w); + scalar_t w1, w2, w3, w4; + int x_low, x_high, y_low, y_high; + + bilinear_interpolate_gradient( + height, width, y, x, w1, w2, w3, w4, x_low, x_high, y_low, y_high); + scalar_t g1 = offset_top_diff * w1 / count; + scalar_t g2 = offset_top_diff * w2 / count; + scalar_t g3 = offset_top_diff * w3 / count; + scalar_t g4 = offset_top_diff * w4 / count; + if (x_low >= 0 && x_high >= 0 && y_low >= 0 && y_high >= 0) { + atomicAdd(offset_bottom_diff + y_low * width + x_low, g1); + atomicAdd(offset_bottom_diff + y_low * width + x_high, g2); + atomicAdd(offset_bottom_diff + y_high * width + x_low, g3); + atomicAdd(offset_bottom_diff + y_high * width + x_high, g4); + } + } + } + } +} + +int ROIAlignBackwardLaucher(const at::Tensor top_grad, const at::Tensor rois, + const float spatial_scale, const int sample_num, + const int channels, const int height, + const int width, const int num_rois, + const int pooled_height, const int pooled_width, + at::Tensor bottom_grad) { + const int output_size = num_rois * pooled_height * pooled_width * channels; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + top_grad.scalar_type(), "ROIAlignLaucherBackward", ([&] { + const scalar_t *top_diff = top_grad.data(); + const scalar_t *rois_data = rois.data(); + scalar_t *bottom_diff = bottom_grad.data(); + if (sizeof(scalar_t) == sizeof(double)) { + fprintf(stderr, "double is not supported\n"); + exit(-1); + } + + ROIAlignBackward + <<>>( + output_size, top_diff, rois_data, spatial_scale, sample_num, + channels, height, width, pooled_height, pooled_width, + bottom_diff); + })); + THCudaCheck(cudaGetLastError()); + return 1; +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/__init__.py new file mode 100644 index 000000000..9f0474e59 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/__init__.py @@ -0,0 +1,3 @@ +from .roi_pool import RoIPool, roi_pool + +__all__ = ['roi_pool', 'RoIPool'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/gradcheck.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/gradcheck.py new file mode 100644 index 000000000..d11af7902 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/gradcheck.py @@ -0,0 +1,16 @@ +import os.path as osp +import sys + +import torch +from torch.autograd import gradcheck + +sys.path.append(osp.abspath(osp.join(__file__, '../../'))) +from roi_pool import RoIPool # noqa: E402, isort:skip + +feat = torch.randn(4, 16, 15, 15, requires_grad=True).cuda() +rois = torch.Tensor([[0, 0, 0, 50, 50], [0, 10, 30, 43, 55], + [1, 67, 40, 110, 120]]).cuda() +inputs = (feat, rois) +print('Gradcheck for roi pooling...') +test = gradcheck(RoIPool(4, 1.0 / 8), inputs, eps=1e-5, atol=1e-3) +print(test) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/roi_pool.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/roi_pool.py new file mode 100644 index 000000000..26d900f78 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/roi_pool.py @@ -0,0 +1,75 @@ +import torch +import torch.nn as nn +from torch.autograd import Function +from torch.autograd.function import once_differentiable +from torch.nn.modules.utils import _pair + +from . import roi_pool_cuda + + +class RoIPoolFunction(Function): + + @staticmethod + def forward(ctx, features, rois, out_size, spatial_scale): + assert features.is_cuda + out_h, out_w = _pair(out_size) + assert isinstance(out_h, int) and isinstance(out_w, int) + ctx.save_for_backward(rois) + num_channels = features.size(1) + num_rois = rois.size(0) + out_size = (num_rois, num_channels, out_h, out_w) + output = features.new_zeros(out_size) + argmax = features.new_zeros(out_size, dtype=torch.int) + roi_pool_cuda.forward(features, rois, out_h, out_w, spatial_scale, + output, argmax) + ctx.spatial_scale = spatial_scale + ctx.feature_size = features.size() + ctx.argmax = argmax + + return output + + @staticmethod + @once_differentiable + def backward(ctx, grad_output): + assert grad_output.is_cuda + spatial_scale = ctx.spatial_scale + feature_size = ctx.feature_size + argmax = ctx.argmax + rois = ctx.saved_tensors[0] + assert feature_size is not None + + grad_input = grad_rois = None + if ctx.needs_input_grad[0]: + grad_input = grad_output.new_zeros(feature_size) + roi_pool_cuda.backward(grad_output.contiguous(), rois, argmax, + spatial_scale, grad_input) + + return grad_input, grad_rois, None, None + + +roi_pool = RoIPoolFunction.apply + + +class RoIPool(nn.Module): + + def __init__(self, out_size, spatial_scale, use_torchvision=False): + super(RoIPool, self).__init__() + + self.out_size = _pair(out_size) + self.spatial_scale = float(spatial_scale) + self.use_torchvision = use_torchvision + + def forward(self, features, rois): + if self.use_torchvision: + from torchvision.ops import roi_pool as tv_roi_pool + return tv_roi_pool(features, rois, self.out_size, + self.spatial_scale) + else: + return roi_pool(features, rois, self.out_size, self.spatial_scale) + + def __repr__(self): + format_str = self.__class__.__name__ + format_str += '(out_size={}, spatial_scale={}'.format( + self.out_size, self.spatial_scale) + format_str += ', use_torchvision={})'.format(self.use_torchvision) + return format_str diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/src/roi_pool_cuda.cpp b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/src/roi_pool_cuda.cpp new file mode 100644 index 000000000..740c6fdcf --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/src/roi_pool_cuda.cpp @@ -0,0 +1,86 @@ +#include + +#include +#include + +int ROIPoolForwardLaucher(const at::Tensor features, const at::Tensor rois, + const float spatial_scale, const int channels, + const int height, const int width, const int num_rois, + const int pooled_h, const int pooled_w, + at::Tensor output, at::Tensor argmax); + +int ROIPoolBackwardLaucher(const at::Tensor top_grad, const at::Tensor rois, + const at::Tensor argmax, const float spatial_scale, + const int batch_size, const int channels, + const int height, const int width, + const int num_rois, const int pooled_h, + const int pooled_w, at::Tensor bottom_grad); + +#define CHECK_CUDA(x) TORCH_CHECK(x.is_cuda(), #x, " must be a CUDAtensor ") +#define CHECK_CONTIGUOUS(x) \ + TORCH_CHECK(x.is_contiguous(), #x, " must be contiguous ") +#define CHECK_INPUT(x) \ + CHECK_CUDA(x); \ + CHECK_CONTIGUOUS(x) + +int roi_pooling_forward_cuda(at::Tensor features, at::Tensor rois, + int pooled_height, int pooled_width, + float spatial_scale, at::Tensor output, + at::Tensor argmax) { + CHECK_INPUT(features); + CHECK_INPUT(rois); + CHECK_INPUT(output); + CHECK_INPUT(argmax); + + // Number of ROIs + int num_rois = rois.size(0); + int size_rois = rois.size(1); + + if (size_rois != 5) { + printf("wrong roi size\n"); + return 0; + } + + int channels = features.size(1); + int height = features.size(2); + int width = features.size(3); + + ROIPoolForwardLaucher(features, rois, spatial_scale, channels, height, width, + num_rois, pooled_height, pooled_width, output, argmax); + + return 1; +} + +int roi_pooling_backward_cuda(at::Tensor top_grad, at::Tensor rois, + at::Tensor argmax, float spatial_scale, + at::Tensor bottom_grad) { + CHECK_INPUT(top_grad); + CHECK_INPUT(rois); + CHECK_INPUT(argmax); + CHECK_INPUT(bottom_grad); + + int pooled_height = top_grad.size(2); + int pooled_width = top_grad.size(3); + int num_rois = rois.size(0); + int size_rois = rois.size(1); + + if (size_rois != 5) { + printf("wrong roi size\n"); + return 0; + } + int batch_size = bottom_grad.size(0); + int channels = bottom_grad.size(1); + int height = bottom_grad.size(2); + int width = bottom_grad.size(3); + + ROIPoolBackwardLaucher(top_grad, rois, argmax, spatial_scale, batch_size, + channels, height, width, num_rois, pooled_height, + pooled_width, bottom_grad); + + return 1; +} + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + m.def("forward", &roi_pooling_forward_cuda, "Roi_Pooling forward (CUDA)"); + m.def("backward", &roi_pooling_backward_cuda, "Roi_Pooling backward (CUDA)"); +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/src/roi_pool_kernel.cu b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/src/roi_pool_kernel.cu new file mode 100644 index 000000000..82a70beaa --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/src/roi_pool_kernel.cu @@ -0,0 +1,157 @@ +#include +#include +#include + +#define CUDA_1D_KERNEL_LOOP(i, n) \ + for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ + i += blockDim.x * gridDim.x) + +#define THREADS_PER_BLOCK 1024 + +inline int GET_BLOCKS(const int N) { + int optimal_block_num = (N + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK; + int max_block_num = 65000; + return optimal_block_num - max_block_num < 0? optimal_block_num: max_block_num; +} + +template +__global__ void ROIPoolForward(const int nthreads, const scalar_t *bottom_data, + const scalar_t *rois, + const scalar_t spatial_scale, const int channels, + const int height, const int width, + const int pooled_h, const int pooled_w, + scalar_t *top_data, int *argmax_data) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + // (n, c, ph, pw) is an element in the pooled output + int pw = index % pooled_w; + int ph = (index / pooled_w) % pooled_h; + int c = (index / pooled_w / pooled_h) % channels; + int n = index / pooled_w / pooled_h / channels; + + const scalar_t *offset_rois = rois + n * 5; + int roi_batch_ind = offset_rois[0]; + // calculate the roi region on feature maps + scalar_t roi_x1 = offset_rois[1] * spatial_scale; + scalar_t roi_y1 = offset_rois[2] * spatial_scale; + scalar_t roi_x2 = (offset_rois[3] + 1) * spatial_scale; + scalar_t roi_y2 = (offset_rois[4] + 1) * spatial_scale; + + // force malformed rois to be 1x1 + scalar_t roi_w = roi_x2 - roi_x1; + scalar_t roi_h = roi_y2 - roi_y1; + if (roi_w <= 0 || roi_h <= 0) continue; + + scalar_t bin_size_w = roi_w / static_cast(pooled_w); + scalar_t bin_size_h = roi_h / static_cast(pooled_h); + + // the corresponding bin region + int bin_x1 = floor(static_cast(pw) * bin_size_w + roi_x1); + int bin_y1 = floor(static_cast(ph) * bin_size_h + roi_y1); + int bin_x2 = ceil(static_cast(pw + 1) * bin_size_w + roi_x1); + int bin_y2 = ceil(static_cast(ph + 1) * bin_size_h + roi_y1); + + // add roi offsets and clip to input boundaries + bin_x1 = min(max(bin_x1, 0), width); + bin_y1 = min(max(bin_y1, 0), height); + bin_x2 = min(max(bin_x2, 0), width); + bin_y2 = min(max(bin_y2, 0), height); + bool is_empty = (bin_y2 <= bin_y1) || (bin_x2 <= bin_x1); + + // If nothing is pooled, argmax = -1 causes nothing to be backprop'd + int max_idx = -1; + bottom_data += (roi_batch_ind * channels + c) * height * width; + + // Define an empty pooling region to be zero + scalar_t max_val = is_empty ? static_cast(0) + : bottom_data[bin_y1 * width + bin_x1] - 1; + + for (int h = bin_y1; h < bin_y2; ++h) { + for (int w = bin_x1; w < bin_x2; ++w) { + int offset = h * width + w; + if (bottom_data[offset] > max_val) { + max_val = bottom_data[offset]; + max_idx = offset; + } + } + } + top_data[index] = max_val; + if (argmax_data != NULL) argmax_data[index] = max_idx; + } +} + +int ROIPoolForwardLaucher(const at::Tensor features, const at::Tensor rois, + const float spatial_scale, const int channels, + const int height, const int width, const int num_rois, + const int pooled_h, const int pooled_w, + at::Tensor output, at::Tensor argmax) { + const int output_size = num_rois * channels * pooled_h * pooled_w; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + features.scalar_type(), "ROIPoolLaucherForward", ([&] { + const scalar_t *bottom_data = features.data(); + const scalar_t *rois_data = rois.data(); + scalar_t *top_data = output.data(); + int *argmax_data = argmax.data(); + + ROIPoolForward + <<>>( + output_size, bottom_data, rois_data, scalar_t(spatial_scale), + channels, height, width, pooled_h, pooled_w, top_data, + argmax_data); + })); + THCudaCheck(cudaGetLastError()); + return 1; +} + +template +__global__ void ROIPoolBackward(const int nthreads, const scalar_t *top_diff, + const scalar_t *rois, const int *argmax_data, + const scalar_t spatial_scale, + const int channels, const int height, + const int width, const int pooled_h, + const int pooled_w, scalar_t *bottom_diff) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + int pw = index % pooled_w; + int ph = (index / pooled_w) % pooled_h; + int c = (index / pooled_w / pooled_h) % channels; + int n = index / pooled_w / pooled_h / channels; + + int roi_batch_ind = rois[n * 5]; + int bottom_index = argmax_data[(n * channels + c) * pooled_h * pooled_w + + ph * pooled_w + pw]; + + atomicAdd(bottom_diff + (roi_batch_ind * channels + c) * height * width + + bottom_index, + top_diff[index]); + } +} + +int ROIPoolBackwardLaucher(const at::Tensor top_grad, const at::Tensor rois, + const at::Tensor argmax, const float spatial_scale, + const int batch_size, const int channels, + const int height, const int width, + const int num_rois, const int pooled_h, + const int pooled_w, at::Tensor bottom_grad) { + const int output_size = num_rois * pooled_h * pooled_w * channels; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + top_grad.scalar_type(), "ROIPoolLaucherBackward", ([&] { + const scalar_t *top_diff = top_grad.data(); + const scalar_t *rois_data = rois.data(); + const int *argmax_data = argmax.data(); + scalar_t *bottom_diff = bottom_grad.data(); + + if (sizeof(scalar_t) == sizeof(double)) { + fprintf(stderr, "double is not supported\n"); + exit(-1); + } + + ROIPoolBackward + <<>>( + output_size, top_diff, rois_data, argmax_data, + scalar_t(spatial_scale), channels, height, width, pooled_h, + pooled_w, bottom_diff); + })); + THCudaCheck(cudaGetLastError()); + return 1; +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/__init__.py new file mode 100644 index 000000000..218032945 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/__init__.py @@ -0,0 +1,3 @@ +from .sigmoid_focal_loss import SigmoidFocalLoss, sigmoid_focal_loss + +__all__ = ['SigmoidFocalLoss', 'sigmoid_focal_loss'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/sigmoid_focal_loss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/sigmoid_focal_loss.py new file mode 100644 index 000000000..8298f433f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/sigmoid_focal_loss.py @@ -0,0 +1,54 @@ +import torch.nn as nn +from torch.autograd import Function +from torch.autograd.function import once_differentiable + +from . import sigmoid_focal_loss_cuda + + +class SigmoidFocalLossFunction(Function): + + @staticmethod + def forward(ctx, input, target, gamma=2.0, alpha=0.25): + ctx.save_for_backward(input, target) + num_classes = input.shape[1] + ctx.num_classes = num_classes + ctx.gamma = gamma + ctx.alpha = alpha + + loss = sigmoid_focal_loss_cuda.forward(input, target, num_classes, + gamma, alpha) + return loss + + @staticmethod + @once_differentiable + def backward(ctx, d_loss): + input, target = ctx.saved_tensors + num_classes = ctx.num_classes + gamma = ctx.gamma + alpha = ctx.alpha + d_loss = d_loss.contiguous() + d_input = sigmoid_focal_loss_cuda.backward(input, target, d_loss, + num_classes, gamma, alpha) + return d_input, None, None, None, None + + +sigmoid_focal_loss = SigmoidFocalLossFunction.apply + + +# TODO: remove this module +class SigmoidFocalLoss(nn.Module): + + def __init__(self, gamma, alpha): + super(SigmoidFocalLoss, self).__init__() + self.gamma = gamma + self.alpha = alpha + + def forward(self, logits, targets): + assert logits.is_cuda + loss = sigmoid_focal_loss(logits, targets, self.gamma, self.alpha) + return loss.sum() + + def __repr__(self): + tmpstr = self.__class__.__name__ + '(gamma={}, alpha={})'.format( + self.gamma, self.alpha) + return tmpstr diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss.cpp b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss.cpp new file mode 100644 index 000000000..8330c9b45 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss.cpp @@ -0,0 +1,45 @@ +// modify from +// https://github.com/facebookresearch/maskrcnn-benchmark/blob/master/maskrcnn_benchmark/csrc/SigmoidFocalLoss.h +#include + +at::Tensor SigmoidFocalLoss_forward_cuda(const at::Tensor &logits, + const at::Tensor &targets, + const int num_classes, + const float gamma, const float alpha); + +at::Tensor SigmoidFocalLoss_backward_cuda(const at::Tensor &logits, + const at::Tensor &targets, + const at::Tensor &d_losses, + const int num_classes, + const float gamma, const float alpha); + +// Interface for Python +at::Tensor SigmoidFocalLoss_forward(const at::Tensor &logits, + const at::Tensor &targets, + const int num_classes, const float gamma, + const float alpha) { + if (logits.type().is_cuda()) { + return SigmoidFocalLoss_forward_cuda(logits, targets, num_classes, gamma, + alpha); + } + AT_ERROR("SigmoidFocalLoss is not implemented on the CPU"); +} + +at::Tensor SigmoidFocalLoss_backward(const at::Tensor &logits, + const at::Tensor &targets, + const at::Tensor &d_losses, + const int num_classes, const float gamma, + const float alpha) { + if (logits.is_cuda()) { + return SigmoidFocalLoss_backward_cuda(logits, targets, d_losses, + num_classes, gamma, alpha); + } + AT_ERROR("SigmoidFocalLoss is not implemented on the CPU"); +} + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + m.def("forward", &SigmoidFocalLoss_forward, + "SigmoidFocalLoss forward (CUDA)"); + m.def("backward", &SigmoidFocalLoss_backward, + "SigmoidFocalLoss backward (CUDA)"); +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss_cuda.cu b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss_cuda.cu new file mode 100644 index 000000000..0e152d38f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss_cuda.cu @@ -0,0 +1,171 @@ +// modified from +// https://github.com/facebookresearch/maskrcnn-benchmark/blob/master/maskrcnn_benchmark/csrc/cuda/SigmoidFocalLoss_cuda.cu + +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +// This file is modified from +// https://github.com/pytorch/pytorch/blob/master/modules/detectron/sigmoid_focal_loss_op.cu +// Cheng-Yang Fu +// cyfu@cs.unc.edu +#include +#include + +#include +#include +#include + +#include + +// TODO make it in a common file +#define CUDA_1D_KERNEL_LOOP(i, n) \ + for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ + i += blockDim.x * gridDim.x) + +template +__global__ void SigmoidFocalLossForward(const int nthreads, + const scalar_t *logits, + const int64_t *targets, + const int num_classes, + const float gamma, const float alpha, + const int num, scalar_t *losses) { + CUDA_1D_KERNEL_LOOP(i, nthreads) { + int n = i / num_classes; + int d = i % num_classes; // current class[0~79]; + int t = targets[n]; // target class [1~80]; + + // Decide it is positive or negative case. + scalar_t c1 = (t == (d + 1)); + scalar_t c2 = (t >= 0 & t != (d + 1)); + + scalar_t zn = (1.0 - alpha); + scalar_t zp = (alpha); + + // p = 1. / 1. + expf(-x); p = sigmoid(x) + scalar_t p = 1. / (1. + expf(-logits[i])); + + // (1-p)**gamma * log(p) where + scalar_t term1 = powf((1. - p), gamma) * logf(max(p, FLT_MIN)); + + // p**gamma * log(1-p) + scalar_t term2 = + powf(p, gamma) * + (-1. * logits[i] * (logits[i] >= 0) - + logf(1. + expf(logits[i] - 2. * logits[i] * (logits[i] >= 0)))); + + losses[i] = 0.0; + losses[i] += -c1 * term1 * zp; + losses[i] += -c2 * term2 * zn; + + } // CUDA_1D_KERNEL_LOOP +} // SigmoidFocalLossForward + +template +__global__ void SigmoidFocalLossBackward( + const int nthreads, const scalar_t *logits, const int64_t *targets, + const scalar_t *d_losses, const int num_classes, const float gamma, + const float alpha, const int num, scalar_t *d_logits) { + CUDA_1D_KERNEL_LOOP(i, nthreads) { + int n = i / num_classes; + int d = i % num_classes; // current class[0~79]; + int t = targets[n]; // target class [1~80], 0 is background; + + // Decide it is positive or negative case. + scalar_t c1 = (t == (d + 1)); + scalar_t c2 = (t >= 0 & t != (d + 1)); + + scalar_t zn = (1.0 - alpha); + scalar_t zp = (alpha); + // p = 1. / 1. + expf(-x); p = sigmoid(x) + scalar_t p = 1. / (1. + expf(-logits[i])); + + // (1-p)**g * (1 - p - g*p*log(p) + scalar_t term1 = + powf((1. - p), gamma) * (1. - p - (p * gamma * logf(max(p, FLT_MIN)))); + + // (p**g) * (g*(1-p)*log(1-p) - p) + scalar_t term2 = + powf(p, gamma) * + ((-1. * logits[i] * (logits[i] >= 0) - + logf(1. + expf(logits[i] - 2. * logits[i] * (logits[i] >= 0)))) * + (1. - p) * gamma - + p); + d_logits[i] = 0.0; + d_logits[i] += -c1 * term1 * zp; + d_logits[i] += -c2 * term2 * zn; + d_logits[i] = d_logits[i] * d_losses[i]; + + } // CUDA_1D_KERNEL_LOOP +} // SigmoidFocalLossBackward + +at::Tensor SigmoidFocalLoss_forward_cuda(const at::Tensor &logits, + const at::Tensor &targets, + const int num_classes, + const float gamma, const float alpha) { + AT_ASSERTM(logits.type().is_cuda(), "logits must be a CUDA tensor"); + AT_ASSERTM(targets.type().is_cuda(), "targets must be a CUDA tensor"); + AT_ASSERTM(logits.dim() == 2, "logits should be NxClass"); + + const int num_samples = logits.size(0); + + auto losses = at::empty({num_samples, logits.size(1)}, logits.options()); + auto losses_size = num_samples * logits.size(1); + + dim3 grid( + std::min(THCCeilDiv((int64_t)losses_size, (int64_t)512), (int64_t)4096)); + dim3 block(512); + + if (losses.numel() == 0) { + THCudaCheck(cudaGetLastError()); + return losses; + } + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + logits.scalar_type(), "SigmoidFocalLoss_forward", [&] { + SigmoidFocalLossForward<<>>( + losses_size, logits.contiguous().data(), + targets.contiguous().data(), num_classes, gamma, alpha, + num_samples, losses.data()); + }); + THCudaCheck(cudaGetLastError()); + return losses; +} + +at::Tensor SigmoidFocalLoss_backward_cuda(const at::Tensor &logits, + const at::Tensor &targets, + const at::Tensor &d_losses, + const int num_classes, + const float gamma, + const float alpha) { + AT_ASSERTM(logits.type().is_cuda(), "logits must be a CUDA tensor"); + AT_ASSERTM(targets.type().is_cuda(), "targets must be a CUDA tensor"); + AT_ASSERTM(d_losses.type().is_cuda(), "d_losses must be a CUDA tensor"); + + AT_ASSERTM(logits.dim() == 2, "logits should be NxClass"); + + const int num_samples = logits.size(0); + AT_ASSERTM(logits.size(1) == num_classes, + "logits.size(1) should be num_classes"); + + auto d_logits = at::zeros({num_samples, num_classes}, logits.options()); + auto d_logits_size = num_samples * logits.size(1); + + dim3 grid(std::min(THCCeilDiv((int64_t)d_logits_size, (int64_t)512), + (int64_t)4096)); + dim3 block(512); + + if (d_logits.numel() == 0) { + THCudaCheck(cudaGetLastError()); + return d_logits; + } + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + logits.scalar_type(), "SigmoidFocalLoss_backward", [&] { + SigmoidFocalLossBackward<<>>( + d_logits_size, logits.contiguous().data(), + targets.contiguous().data(), + d_losses.contiguous().data(), num_classes, gamma, alpha, + num_samples, d_logits.data()); + }); + + THCudaCheck(cudaGetLastError()); + return d_logits; +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/utils/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/utils/__init__.py new file mode 100644 index 000000000..0244c0f54 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/utils/__init__.py @@ -0,0 +1,7 @@ +# from . import compiling_info +from .compiling_info import get_compiler_version, get_compiling_cuda_version + +# get_compiler_version = compiling_info.get_compiler_version +# get_compiling_cuda_version = compiling_info.get_compiling_cuda_version + +__all__ = ['get_compiler_version', 'get_compiling_cuda_version'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/utils/src/compiling_info.cpp b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/utils/src/compiling_info.cpp new file mode 100644 index 000000000..fd62aabcf --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/utils/src/compiling_info.cpp @@ -0,0 +1,56 @@ +// modified from +// https://github.com/facebookresearch/detectron2/blob/master/detectron2/layers/csrc/vision.cpp +#include +#include + +#ifdef WITH_CUDA +int get_cudart_version() { return CUDART_VERSION; } +#endif + +std::string get_compiling_cuda_version() { +#ifdef WITH_CUDA + std::ostringstream oss; + + // copied from + // https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/cuda/detail/CUDAHooks.cpp#L231 + auto printCudaStyleVersion = [&](int v) { + oss << (v / 1000) << "." << (v / 10 % 100); + if (v % 10 != 0) { + oss << "." << (v % 10); + } + }; + printCudaStyleVersion(get_cudart_version()); + return oss.str(); +#else + return std::string("not available"); +#endif +} + +// similar to +// https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/Version.cpp +std::string get_compiler_version() { + std::ostringstream ss; +#if defined(__GNUC__) +#ifndef __clang__ + { ss << "GCC " << __GNUC__ << "." << __GNUC_MINOR__; } +#endif +#endif + +#if defined(__clang_major__) + { + ss << "clang " << __clang_major__ << "." << __clang_minor__ << "." + << __clang_patchlevel__; + } +#endif + +#if defined(_MSC_VER) + { ss << "MSVC " << _MSC_FULL_VER; } +#endif + return ss.str(); +} + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + m.def("get_compiler_version", &get_compiler_version, "get_compiler_version"); + m.def("get_compiling_cuda_version", &get_compiling_cuda_version, + "get_compiling_cuda_version"); +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/__init__.py new file mode 100644 index 000000000..537a34a13 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/__init__.py @@ -0,0 +1,8 @@ +from .flops_counter import get_model_complexity_info +from .logger import get_root_logger, print_log +from .registry import Registry, build_from_cfg + +__all__ = [ + 'Registry', 'build_from_cfg', 'get_model_complexity_info', + 'get_root_logger', 'print_log' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/contextmanagers.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/contextmanagers.py new file mode 100644 index 000000000..0363f0145 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/contextmanagers.py @@ -0,0 +1,126 @@ +# coding: utf-8 +import asyncio +import contextlib +import logging +import os +import time +from typing import List + +import torch + +logger = logging.getLogger(__name__) + +DEBUG_COMPLETED_TIME = bool(os.environ.get('DEBUG_COMPLETED_TIME', False)) + + +@contextlib.asynccontextmanager +async def completed(trace_name='', + name='', + sleep_interval=0.05, + streams: List[torch.cuda.Stream] = None): + """ + Async context manager that waits for work to complete on + given CUDA streams. + + """ + if not torch.cuda.is_available(): + yield + return + + stream_before_context_switch = torch.cuda.current_stream() + if not streams: + streams = [stream_before_context_switch] + else: + streams = [s if s else stream_before_context_switch for s in streams] + + end_events = [ + torch.cuda.Event(enable_timing=DEBUG_COMPLETED_TIME) for _ in streams + ] + + if DEBUG_COMPLETED_TIME: + start = torch.cuda.Event(enable_timing=True) + stream_before_context_switch.record_event(start) + + cpu_start = time.monotonic() + logger.debug('%s %s starting, streams: %s', trace_name, name, streams) + grad_enabled_before = torch.is_grad_enabled() + try: + yield + finally: + current_stream = torch.cuda.current_stream() + assert current_stream == stream_before_context_switch + + if DEBUG_COMPLETED_TIME: + cpu_end = time.monotonic() + for i, stream in enumerate(streams): + event = end_events[i] + stream.record_event(event) + + grad_enabled_after = torch.is_grad_enabled() + + # observed change of torch.is_grad_enabled() during concurrent run of + # async_test_bboxes code + assert (grad_enabled_before == grad_enabled_after + ), 'Unexpected is_grad_enabled() value change' + + are_done = [e.query() for e in end_events] + logger.debug('%s %s completed: %s streams: %s', trace_name, name, + are_done, streams) + with torch.cuda.stream(stream_before_context_switch): + while not all(are_done): + await asyncio.sleep(sleep_interval) + are_done = [e.query() for e in end_events] + logger.debug( + '%s %s completed: %s streams: %s', + trace_name, + name, + are_done, + streams, + ) + + current_stream = torch.cuda.current_stream() + assert current_stream == stream_before_context_switch + + if DEBUG_COMPLETED_TIME: + cpu_time = (cpu_end - cpu_start) * 1000 + stream_times_ms = '' + for i, stream in enumerate(streams): + elapsed_time = start.elapsed_time(end_events[i]) + stream_times_ms += ' {} {:.2f} ms'.format(stream, elapsed_time) + logger.info('%s %s %.2f ms %s', trace_name, name, cpu_time, + stream_times_ms) + + +@contextlib.asynccontextmanager +async def concurrent(streamqueue: asyncio.Queue, + trace_name='concurrent', + name='stream'): + """Run code concurrently in different streams. + + :param streamqueue: asyncio.Queue instance. + + Queue tasks define the pool of streams used for concurrent execution. + + """ + if not torch.cuda.is_available(): + yield + return + + initial_stream = torch.cuda.current_stream() + + with torch.cuda.stream(initial_stream): + stream = await streamqueue.get() + assert isinstance(stream, torch.cuda.Stream) + + try: + with torch.cuda.stream(stream): + logger.debug('%s %s is starting, stream: %s', trace_name, name, + stream) + yield + current = torch.cuda.current_stream() + assert current == stream + logger.debug('%s %s has finished, stream: %s', trace_name, + name, stream) + finally: + streamqueue.task_done() + streamqueue.put_nowait(stream) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/flops_counter.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/flops_counter.py new file mode 100644 index 000000000..df2163fd7 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/flops_counter.py @@ -0,0 +1,444 @@ +# Modified from flops-counter.pytorch by Vladislav Sovrasov +# original repo: https://github.com/sovrasov/flops-counter.pytorch + +# MIT License + +# Copyright (c) 2018 Vladislav Sovrasov + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import sys + +import numpy as np +import torch +import torch.nn as nn +from torch.nn.modules.batchnorm import _BatchNorm +from torch.nn.modules.conv import _ConvNd, _ConvTransposeMixin +from torch.nn.modules.pooling import (_AdaptiveAvgPoolNd, _AdaptiveMaxPoolNd, + _AvgPoolNd, _MaxPoolNd) + + +def get_model_complexity_info(model, + input_res, + print_per_layer_stat=True, + as_strings=True, + input_constructor=None, + ost=sys.stdout): + assert type(input_res) is tuple + assert len(input_res) >= 2 + flops_model = add_flops_counting_methods(model) + flops_model.eval().start_flops_count() + if input_constructor: + input = input_constructor(input_res) + _ = flops_model(**input) + else: + batch = torch.ones(()).new_empty( + (1, *input_res), + dtype=next(flops_model.parameters()).dtype, + device=next(flops_model.parameters()).device) + flops_model(batch) + + if print_per_layer_stat: + print_model_with_flops(flops_model, ost=ost) + flops_count = flops_model.compute_average_flops_cost() + params_count = get_model_parameters_number(flops_model) + flops_model.stop_flops_count() + + if as_strings: + return flops_to_string(flops_count), params_to_string(params_count) + + return flops_count, params_count + + +def flops_to_string(flops, units='GMac', precision=2): + if units is None: + if flops // 10**9 > 0: + return str(round(flops / 10.**9, precision)) + ' GMac' + elif flops // 10**6 > 0: + return str(round(flops / 10.**6, precision)) + ' MMac' + elif flops // 10**3 > 0: + return str(round(flops / 10.**3, precision)) + ' KMac' + else: + return str(flops) + ' Mac' + else: + if units == 'GMac': + return str(round(flops / 10.**9, precision)) + ' ' + units + elif units == 'MMac': + return str(round(flops / 10.**6, precision)) + ' ' + units + elif units == 'KMac': + return str(round(flops / 10.**3, precision)) + ' ' + units + else: + return str(flops) + ' Mac' + + +def params_to_string(params_num): + """converting number to string + + :param float params_num: number + :returns str: number + + >>> params_to_string(1e9) + '1000.0 M' + >>> params_to_string(2e5) + '200.0 k' + >>> params_to_string(3e-9) + '3e-09' + """ + if params_num // 10**6 > 0: + return str(round(params_num / 10**6, 2)) + ' M' + elif params_num // 10**3: + return str(round(params_num / 10**3, 2)) + ' k' + else: + return str(params_num) + + +def print_model_with_flops(model, units='GMac', precision=3, ost=sys.stdout): + total_flops = model.compute_average_flops_cost() + + def accumulate_flops(self): + if is_supported_instance(self): + return self.__flops__ / model.__batch_counter__ + else: + sum = 0 + for m in self.children(): + sum += m.accumulate_flops() + return sum + + def flops_repr(self): + accumulated_flops_cost = self.accumulate_flops() + return ', '.join([ + flops_to_string( + accumulated_flops_cost, units=units, precision=precision), + '{:.3%} MACs'.format(accumulated_flops_cost / total_flops), + self.original_extra_repr() + ]) + + def add_extra_repr(m): + m.accumulate_flops = accumulate_flops.__get__(m) + flops_extra_repr = flops_repr.__get__(m) + if m.extra_repr != flops_extra_repr: + m.original_extra_repr = m.extra_repr + m.extra_repr = flops_extra_repr + assert m.extra_repr != m.original_extra_repr + + def del_extra_repr(m): + if hasattr(m, 'original_extra_repr'): + m.extra_repr = m.original_extra_repr + del m.original_extra_repr + if hasattr(m, 'accumulate_flops'): + del m.accumulate_flops + + model.apply(add_extra_repr) + print(model, file=ost) + model.apply(del_extra_repr) + + +def get_model_parameters_number(model): + params_num = sum(p.numel() for p in model.parameters() if p.requires_grad) + return params_num + + +def add_flops_counting_methods(net_main_module): + # adding additional methods to the existing module object, + # this is done this way so that each function has access to self object + net_main_module.start_flops_count = start_flops_count.__get__( + net_main_module) + net_main_module.stop_flops_count = stop_flops_count.__get__( + net_main_module) + net_main_module.reset_flops_count = reset_flops_count.__get__( + net_main_module) + net_main_module.compute_average_flops_cost = \ + compute_average_flops_cost.__get__(net_main_module) + + net_main_module.reset_flops_count() + + # Adding variables necessary for masked flops computation + net_main_module.apply(add_flops_mask_variable_or_reset) + + return net_main_module + + +def compute_average_flops_cost(self): + """ + A method that will be available after add_flops_counting_methods() is + called on a desired net object. + Returns current mean flops consumption per image. + """ + + batches_count = self.__batch_counter__ + flops_sum = 0 + for module in self.modules(): + if is_supported_instance(module): + flops_sum += module.__flops__ + + return flops_sum / batches_count + + +def start_flops_count(self): + """ + A method that will be available after add_flops_counting_methods() is + called on a desired net object. + Activates the computation of mean flops consumption per image. + Call it before you run the network. + """ + add_batch_counter_hook_function(self) + self.apply(add_flops_counter_hook_function) + + +def stop_flops_count(self): + """ + A method that will be available after add_flops_counting_methods() is + called on a desired net object. + Stops computing the mean flops consumption per image. + Call whenever you want to pause the computation. + """ + remove_batch_counter_hook_function(self) + self.apply(remove_flops_counter_hook_function) + + +def reset_flops_count(self): + """ + A method that will be available after add_flops_counting_methods() is + called on a desired net object. + Resets statistics computed so far. + """ + add_batch_counter_variables_or_reset(self) + self.apply(add_flops_counter_variable_or_reset) + + +def add_flops_mask(module, mask): + + def add_flops_mask_func(module): + if isinstance(module, torch.nn.Conv2d): + module.__mask__ = mask + + module.apply(add_flops_mask_func) + + +def remove_flops_mask(module): + module.apply(add_flops_mask_variable_or_reset) + + +def is_supported_instance(module): + for mod in hook_mapping: + if issubclass(type(module), mod): + return True + return False + + +def empty_flops_counter_hook(module, input, output): + module.__flops__ += 0 + + +def upsample_flops_counter_hook(module, input, output): + output_size = output[0] + batch_size = output_size.shape[0] + output_elements_count = batch_size + for val in output_size.shape[1:]: + output_elements_count *= val + module.__flops__ += int(output_elements_count) + + +def relu_flops_counter_hook(module, input, output): + active_elements_count = output.numel() + module.__flops__ += int(active_elements_count) + + +def linear_flops_counter_hook(module, input, output): + input = input[0] + batch_size = input.shape[0] + module.__flops__ += int(batch_size * input.shape[1] * output.shape[1]) + + +def pool_flops_counter_hook(module, input, output): + input = input[0] + module.__flops__ += int(np.prod(input.shape)) + + +def bn_flops_counter_hook(module, input, output): + input = input[0] + + batch_flops = np.prod(input.shape) + if module.affine: + batch_flops *= 2 + module.__flops__ += int(batch_flops) + + +def gn_flops_counter_hook(module, input, output): + elems = np.prod(input[0].shape) + # there is no precise FLOPs estimation of computing mean and variance, + # and we just set it 2 * elems: half muladds for computing + # means and half for computing vars + batch_flops = 3 * elems + if module.affine: + batch_flops += elems + module.__flops__ += int(batch_flops) + + +def deconv_flops_counter_hook(conv_module, input, output): + # Can have multiple inputs, getting the first one + input = input[0] + + batch_size = input.shape[0] + input_height, input_width = input.shape[2:] + + kernel_height, kernel_width = conv_module.kernel_size + in_channels = conv_module.in_channels + out_channels = conv_module.out_channels + groups = conv_module.groups + + filters_per_channel = out_channels // groups + conv_per_position_flops = ( + kernel_height * kernel_width * in_channels * filters_per_channel) + + active_elements_count = batch_size * input_height * input_width + overall_conv_flops = conv_per_position_flops * active_elements_count + bias_flops = 0 + if conv_module.bias is not None: + output_height, output_width = output.shape[2:] + bias_flops = out_channels * batch_size * output_height * output_height + overall_flops = overall_conv_flops + bias_flops + + conv_module.__flops__ += int(overall_flops) + + +def conv_flops_counter_hook(conv_module, input, output): + # Can have multiple inputs, getting the first one + input = input[0] + + batch_size = input.shape[0] + output_dims = list(output.shape[2:]) + + kernel_dims = list(conv_module.kernel_size) + in_channels = conv_module.in_channels + out_channels = conv_module.out_channels + groups = conv_module.groups + + filters_per_channel = out_channels // groups + conv_per_position_flops = np.prod( + kernel_dims) * in_channels * filters_per_channel + + active_elements_count = batch_size * np.prod(output_dims) + + if conv_module.__mask__ is not None: + # (b, 1, h, w) + output_height, output_width = output.shape[2:] + flops_mask = conv_module.__mask__.expand(batch_size, 1, output_height, + output_width) + active_elements_count = flops_mask.sum() + + overall_conv_flops = conv_per_position_flops * active_elements_count + + bias_flops = 0 + + if conv_module.bias is not None: + + bias_flops = out_channels * active_elements_count + + overall_flops = overall_conv_flops + bias_flops + + conv_module.__flops__ += int(overall_flops) + + +hook_mapping = { + # conv + _ConvNd: conv_flops_counter_hook, + # deconv + _ConvTransposeMixin: deconv_flops_counter_hook, + # fc + nn.Linear: linear_flops_counter_hook, + # pooling + _AvgPoolNd: pool_flops_counter_hook, + _MaxPoolNd: pool_flops_counter_hook, + _AdaptiveAvgPoolNd: pool_flops_counter_hook, + _AdaptiveMaxPoolNd: pool_flops_counter_hook, + # activation + nn.ReLU: relu_flops_counter_hook, + nn.PReLU: relu_flops_counter_hook, + nn.ELU: relu_flops_counter_hook, + nn.LeakyReLU: relu_flops_counter_hook, + nn.ReLU6: relu_flops_counter_hook, + # normalization + _BatchNorm: bn_flops_counter_hook, + nn.GroupNorm: gn_flops_counter_hook, + # upsample + nn.Upsample: upsample_flops_counter_hook, +} + + +def batch_counter_hook(module, input, output): + batch_size = 1 + if len(input) > 0: + # Can have multiple inputs, getting the first one + input = input[0] + batch_size = len(input) + else: + print('Warning! No positional inputs found for a module, ' + 'assuming batch size is 1.') + module.__batch_counter__ += batch_size + + +def add_batch_counter_variables_or_reset(module): + module.__batch_counter__ = 0 + + +def add_batch_counter_hook_function(module): + if hasattr(module, '__batch_counter_handle__'): + return + + handle = module.register_forward_hook(batch_counter_hook) + module.__batch_counter_handle__ = handle + + +def remove_batch_counter_hook_function(module): + if hasattr(module, '__batch_counter_handle__'): + module.__batch_counter_handle__.remove() + del module.__batch_counter_handle__ + + +def add_flops_counter_variable_or_reset(module): + if is_supported_instance(module): + module.__flops__ = 0 + + +def add_flops_counter_hook_function(module): + if is_supported_instance(module): + if hasattr(module, '__flops_handle__'): + return + + for mod_type, counter_hook in hook_mapping.items(): + if issubclass(type(module), mod_type): + handle = module.register_forward_hook(counter_hook) + break + + module.__flops_handle__ = handle + + +def remove_flops_counter_hook_function(module): + if is_supported_instance(module): + if hasattr(module, '__flops_handle__'): + module.__flops_handle__.remove() + del module.__flops_handle__ + + +# --- Masked flops counting +# Also being run in the initialization +def add_flops_mask_variable_or_reset(module): + if is_supported_instance(module): + module.__mask__ = None diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/logger.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/logger.py new file mode 100644 index 000000000..3e6a1396b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/logger.py @@ -0,0 +1,66 @@ +import logging + +from mmcv.runner import get_dist_info + + +def get_root_logger(log_file=None, log_level=logging.INFO): + """Get the root logger. + + The logger will be initialized if it has not been initialized. By default a + StreamHandler will be added. If `log_file` is specified, a FileHandler will + also be added. The name of the root logger is the top-level package name, + e.g., "mmdet". + + Args: + log_file (str | None): The log filename. If specified, a FileHandler + will be added to the root logger. + log_level (int): The root logger level. Note that only the process of + rank 0 is affected, while other processes will set the level to + "Error" and be silent most of the time. + + Returns: + logging.Logger: The root logger. + """ + logger = logging.getLogger(__name__.split('.')[0]) # i.e., mmdet + # if the logger has been initialized, just return it + if logger.hasHandlers(): + return logger + + format_str = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' + logging.basicConfig(format=format_str, level=log_level) + rank, _ = get_dist_info() + if rank != 0: + logger.setLevel('ERROR') + elif log_file is not None: + file_handler = logging.FileHandler(log_file, 'w') + file_handler.setFormatter(logging.Formatter(format_str)) + file_handler.setLevel(log_level) + logger.addHandler(file_handler) + + return logger + + +def print_log(msg, logger=None, level=logging.INFO): + """Print a log message. + + Args: + msg (str): The message to be logged. + logger (logging.Logger | str | None): The logger to be used. Some + special loggers are: + - "root": the root logger obtained with `get_root_logger()`. + - "silent": no message will be printed. + - None: The `print()` method will be used to print log messages. + level (int): Logging level. Only available when `logger` is a Logger + object or "root". + """ + if logger is None: + print(msg) + elif logger == 'root': + _logger = get_root_logger() + _logger.log(level, msg) + elif isinstance(logger, logging.Logger): + logger.log(level, msg) + elif logger != 'silent': + raise TypeError( + 'logger should be either a logging.Logger object, "root", ' + '"silent" or None, but got {}'.format(logger)) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/profiling.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/profiling.py new file mode 100644 index 000000000..58b1c87dd --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/profiling.py @@ -0,0 +1,41 @@ +import contextlib +import sys +import time + +import torch + +if sys.version_info >= (3, 7): + + @contextlib.contextmanager + def profile_time(trace_name, + name, + enabled=True, + stream=None, + end_stream=None): + """Print time spent by CPU and GPU. + + Useful as a temporary context manager to find sweet spots of + code suitable for async implementation. + + """ + if (not enabled) or not torch.cuda.is_available(): + yield + return + stream = stream if stream else torch.cuda.current_stream() + end_stream = end_stream if end_stream else stream + start = torch.cuda.Event(enable_timing=True) + end = torch.cuda.Event(enable_timing=True) + stream.record_event(start) + try: + cpu_start = time.monotonic() + yield + finally: + cpu_end = time.monotonic() + end_stream.record_event(end) + end.synchronize() + cpu_time = (cpu_end - cpu_start) * 1000 + gpu_time = start.elapsed_time(end) + msg = "{} {} cpu_time {:.2f} ms ".format(trace_name, name, + cpu_time) + msg += "gpu_time {:.2f} ms stream {}".format(gpu_time, stream) + print(msg, end_stream) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/registry.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/registry.py new file mode 100644 index 000000000..4ad9f876c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/registry.py @@ -0,0 +1,79 @@ +import inspect +from functools import partial + +import mmcv + + +class Registry(object): + + def __init__(self, name): + self._name = name + self._module_dict = dict() + + def __repr__(self): + format_str = self.__class__.__name__ + '(name={}, items={})'.format( + self._name, list(self._module_dict.keys())) + return format_str + + @property + def name(self): + return self._name + + @property + def module_dict(self): + return self._module_dict + + def get(self, key): + return self._module_dict.get(key, None) + + def _register_module(self, module_class, force=False): + """Register a module. + + Args: + module (:obj:`nn.Module`): Module to be registered. + """ + if not inspect.isclass(module_class): + raise TypeError('module must be a class, but got {}'.format( + type(module_class))) + module_name = module_class.__name__ + if not force and module_name in self._module_dict: + raise KeyError('{} is already registered in {}'.format( + module_name, self.name)) + self._module_dict[module_name] = module_class + + def register_module(self, cls=None, force=False): + if cls is None: + return partial(self.register_module, force=force) + self._register_module(cls, force=force) + return cls + + +def build_from_cfg(cfg, registry, default_args=None): + """Build a module from config dict. + + Args: + cfg (dict): Config dict. It should at least contain the key "type". + registry (:obj:`Registry`): The registry to search the type from. + default_args (dict, optional): Default initialization arguments. + + Returns: + obj: The constructed object. + """ + assert isinstance(cfg, dict) and 'type' in cfg + assert isinstance(default_args, dict) or default_args is None + args = cfg.copy() + obj_type = args.pop('type') + if mmcv.is_str(obj_type): + obj_cls = registry.get(obj_type) + if obj_cls is None: + raise KeyError('{} is not in the {} registry'.format( + obj_type, registry.name)) + elif inspect.isclass(obj_type): + obj_cls = obj_type + else: + raise TypeError('type must be a str or valid type, but got {}'.format( + type(obj_type))) + if default_args is not None: + for name, value in default_args.items(): + args.setdefault(name, value) + return obj_cls(**args) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/util_mixins.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/util_mixins.py new file mode 100644 index 000000000..5585ac652 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/util_mixins.py @@ -0,0 +1,105 @@ +# -*- coding: utf-8 -*- +""" +This module defines the :class:`NiceRepr` mixin class, which defines a +``__repr__`` and ``__str__`` method that only depend on a custom ``__nice__`` +method, which you must define. This means you only have to overload one +function instead of two. Furthermore, if the object defines a ``__len__`` +method, then the ``__nice__`` method defaults to something sensible, otherwise +it is treated as abstract and raises ``NotImplementedError``. + +To use simply have your object inherit from :class:`NiceRepr` +(multi-inheritance should be ok). + +This code was copied from the ubelt library: https://github.com/Erotemic/ubelt + +Example: + >>> # Objects that define __nice__ have a default __str__ and __repr__ + >>> class Student(NiceRepr): + ... def __init__(self, name): + ... self.name = name + ... def __nice__(self): + ... return self.name + >>> s1 = Student('Alice') + >>> s2 = Student('Bob') + >>> print('s1 = {}'.format(s1)) + >>> print('s2 = {}'.format(s2)) + s1 = + s2 = + +Example: + >>> # Objects that define __len__ have a default __nice__ + >>> class Group(NiceRepr): + ... def __init__(self, data): + ... self.data = data + ... def __len__(self): + ... return len(self.data) + >>> g = Group([1, 2, 3]) + >>> print('g = {}'.format(g)) + g = + +""" +import warnings + + +class NiceRepr(object): + """ + Inherit from this class and define ``__nice__`` to "nicely" print your + objects. + + Defines ``__str__`` and ``__repr__`` in terms of ``__nice__`` function + Classes that inherit from :class:`NiceRepr` should redefine ``__nice__``. + If the inheriting class has a ``__len__``, method then the default + ``__nice__`` method will return its length. + + Example: + >>> class Foo(NiceRepr): + ... def __nice__(self): + ... return 'info' + >>> foo = Foo() + >>> assert str(foo) == '' + >>> assert repr(foo).startswith('>> class Bar(NiceRepr): + ... pass + >>> bar = Bar() + >>> import pytest + >>> with pytest.warns(None) as record: + >>> assert 'object at' in str(bar) + >>> assert 'object at' in repr(bar) + + Example: + >>> class Baz(NiceRepr): + ... def __len__(self): + ... return 5 + >>> baz = Baz() + >>> assert str(baz) == '' + """ + + def __nice__(self): + if hasattr(self, '__len__'): + # It is a common pattern for objects to use __len__ in __nice__ + # As a convenience we define a default __nice__ for these objects + return str(len(self)) + else: + # In all other cases force the subclass to overload __nice__ + raise NotImplementedError( + 'Define the __nice__ method for {!r}'.format(self.__class__)) + + def __repr__(self): + try: + nice = self.__nice__() + classname = self.__class__.__name__ + return '<{0}({1}) at {2}>'.format(classname, nice, hex(id(self))) + except NotImplementedError as ex: + warnings.warn(str(ex), category=RuntimeWarning) + return object.__repr__(self) + + def __str__(self): + try: + classname = self.__class__.__name__ + nice = self.__nice__() + return '<{0}({1})>'.format(classname, nice) + except NotImplementedError as ex: + warnings.warn(str(ex), category=RuntimeWarning) + return object.__repr__(self) diff --git a/cv/instance_segmentation/SOLO/pytorch/pytest.ini b/cv/instance_segmentation/SOLO/pytorch/pytest.ini new file mode 100644 index 000000000..9796e871e --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/pytest.ini @@ -0,0 +1,7 @@ +[pytest] +addopts = --xdoctest --xdoctest-style=auto +norecursedirs = .git ignore build __pycache__ data docker docs .eggs + +filterwarnings= default + ignore:.*No cfgstr given in Cacher constructor or call.*:Warning + ignore:.*Define the __nice__ method for.*:Warning diff --git a/cv/instance_segmentation/SOLO/pytorch/requirements.txt b/cv/instance_segmentation/SOLO/pytorch/requirements.txt new file mode 100644 index 000000000..52ee8f552 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/requirements.txt @@ -0,0 +1,4 @@ +-r requirements/runtime.txt +-r requirements/optional.txt +-r requirements/tests.txt +-r requirements/build.txt diff --git a/cv/instance_segmentation/SOLO/pytorch/requirements/build.txt b/cv/instance_segmentation/SOLO/pytorch/requirements/build.txt new file mode 100644 index 000000000..a24ea0c6f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/requirements/build.txt @@ -0,0 +1,4 @@ +# These must be installed before building mmdetection +cython +numpy +torch>=1.1 diff --git a/cv/instance_segmentation/SOLO/pytorch/requirements/optional.txt b/cv/instance_segmentation/SOLO/pytorch/requirements/optional.txt new file mode 100644 index 000000000..eb36729e0 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/requirements/optional.txt @@ -0,0 +1,2 @@ +albumentations>=0.3.2 +imagecorruptions diff --git a/cv/instance_segmentation/SOLO/pytorch/requirements/runtime.txt b/cv/instance_segmentation/SOLO/pytorch/requirements/runtime.txt new file mode 100644 index 000000000..0d0178788 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/requirements/runtime.txt @@ -0,0 +1,10 @@ +matplotlib +mmcv==0.2.16 +numpy +scipy +# need older pillow until torchvision is fixed +Pillow<=6.2.2 +six +terminaltables +torch>=1.1 +torchvision diff --git a/cv/instance_segmentation/SOLO/pytorch/requirements/tests.txt b/cv/instance_segmentation/SOLO/pytorch/requirements/tests.txt new file mode 100644 index 000000000..d45e54096 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/requirements/tests.txt @@ -0,0 +1,11 @@ +asynctest +codecov +flake8 +isort +pytest +pytest-cov +pytest-runner +xdoctest >= 0.10.0 +yapf +# Note: used for kwarray.group_items, this may be ported to mmcv in the future. +kwarray diff --git a/cv/instance_segmentation/SOLO/pytorch/setup.py b/cv/instance_segmentation/SOLO/pytorch/setup.py new file mode 100644 index 000000000..aee4ddbf6 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/setup.py @@ -0,0 +1,301 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import os +import platform +import subprocess +import time +from setuptools import Extension, dist, find_packages, setup + +import torch +from torch.utils.cpp_extension import BuildExtension, CUDAExtension + +dist.Distribution().fetch_build_eggs(['Cython', 'numpy>=1.11.1']) +import numpy as np # noqa: E402, isort:skip +from Cython.Build import cythonize # noqa: E402, isort:skip + + +def readme(): + with open('README.md', encoding='utf-8') as f: + content = f.read() + return content + + +MAJOR = 1 +MINOR = 0 +PATCH = 0 +SUFFIX = '' +if PATCH != '': + SHORT_VERSION = '{}.{}.{}{}'.format(MAJOR, MINOR, PATCH, SUFFIX) +else: + SHORT_VERSION = '{}.{}{}'.format(MAJOR, MINOR, SUFFIX) + +version_file = 'mmdet/version.py' + + +def get_git_hash(): + + def _minimal_ext_cmd(cmd): + # construct minimal environment + env = {} + for k in ['SYSTEMROOT', 'PATH', 'HOME']: + v = os.environ.get(k) + if v is not None: + env[k] = v + # LANGUAGE is used on win32 + env['LANGUAGE'] = 'C' + env['LANG'] = 'C' + env['LC_ALL'] = 'C' + out = subprocess.Popen( + cmd, stdout=subprocess.PIPE, env=env).communicate()[0] + return out + + try: + out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD']) + sha = out.strip().decode('ascii') + except OSError: + sha = 'unknown' + + return sha + + +def get_hash(): + if os.path.exists('.git'): + sha = get_git_hash()[:7] + elif os.path.exists(version_file): + try: + from mmdet.version import __version__ + sha = __version__.split('+')[-1] + except ImportError: + raise ImportError('Unable to get git version') + else: + sha = 'unknown' + + return sha + + +def write_version_py(): + content = """# GENERATED VERSION FILE +# TIME: {} + +__version__ = '{}' +short_version = '{}' +""" + sha = get_hash() + VERSION = SHORT_VERSION + '+' + sha + + with open(version_file, 'w') as f: + f.write(content.format(time.asctime(), VERSION, SHORT_VERSION)) + + +def get_version(): + with open(version_file, 'r') as f: + exec(compile(f.read(), version_file, 'exec')) + return locals()['__version__'] + + +def make_cuda_ext(name, module, sources): + + define_macros = [] + + if torch.cuda.is_available() or os.getenv('FORCE_CUDA', '0') == '1': + define_macros += [("WITH_CUDA", None)] + else: + raise EnvironmentError('CUDA is required to compile MMDetection!') + + return CUDAExtension( + name='{}.{}'.format(module, name), + sources=[os.path.join(*module.split('.'), p) for p in sources], + define_macros=define_macros, + extra_compile_args={ + 'cxx': [], + 'nvcc': [ + '-D__CUDA_NO_HALF_OPERATORS__', + '-D__CUDA_NO_HALF_CONVERSIONS__', + '-D__CUDA_NO_HALF2_OPERATORS__', + ] + }) + + +def make_cython_ext(name, module, sources): + extra_compile_args = None + if platform.system() != 'Windows': + extra_compile_args = { + 'cxx': ['-Wno-unused-function', '-Wno-write-strings'] + } + + extension = Extension( + '{}.{}'.format(module, name), + [os.path.join(*module.split('.'), p) for p in sources], + include_dirs=[np.get_include()], + language='c++', + extra_compile_args=extra_compile_args) + extension, = cythonize(extension) + return extension + + +def parse_requirements(fname='requirements.txt', with_version=True): + """ + Parse the package dependencies listed in a requirements file but strips + specific versioning information. + + Args: + fname (str): path to requirements file + with_version (bool, default=False): if True include version specs + + Returns: + List[str]: list of requirements items + + CommandLine: + python -c "import setup; print(setup.parse_requirements())" + """ + import sys + from os.path import exists + import re + require_fpath = fname + + def parse_line(line): + """ + Parse information from a line in a requirements text file + """ + if line.startswith('-r '): + # Allow specifying requirements in other files + target = line.split(' ')[1] + for info in parse_require_file(target): + yield info + else: + info = {'line': line} + if line.startswith('-e '): + info['package'] = line.split('#egg=')[1] + else: + # Remove versioning from the package + pat = '(' + '|'.join(['>=', '==', '>']) + ')' + parts = re.split(pat, line, maxsplit=1) + parts = [p.strip() for p in parts] + + info['package'] = parts[0] + if len(parts) > 1: + op, rest = parts[1:] + if ';' in rest: + # Handle platform specific dependencies + # http://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-platform-specific-dependencies + version, platform_deps = map(str.strip, + rest.split(';')) + info['platform_deps'] = platform_deps + else: + version = rest # NOQA + info['version'] = (op, version) + yield info + + def parse_require_file(fpath): + with open(fpath, 'r') as f: + for line in f.readlines(): + line = line.strip() + if line and not line.startswith('#'): + for info in parse_line(line): + yield info + + def gen_packages_items(): + if exists(require_fpath): + for info in parse_require_file(require_fpath): + parts = [info['package']] + if with_version and 'version' in info: + parts.extend(info['version']) + if not sys.version.startswith('3.4'): + # apparently package_deps are broken in 3.4 + platform_deps = info.get('platform_deps') + if platform_deps is not None: + parts.append(';' + platform_deps) + item = ''.join(parts) + yield item + + packages = list(gen_packages_items()) + return packages + + +if __name__ == '__main__': + write_version_py() + setup( + name='mmdet', + version=get_version(), + description='Open MMLab Detection Toolbox and Benchmark', + long_description=readme(), + author='OpenMMLab', + author_email='chenkaidev@gmail.com', + keywords='computer vision, object detection', + url='https://github.com/open-mmlab/mmdetection', + packages=find_packages(exclude=('configs', 'tools', 'demo')), + package_data={'mmdet.ops': ['*/*.so']}, + classifiers=[ + 'Development Status :: 4 - Beta', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + ], + license='Apache License 2.0', + setup_requires=parse_requirements('requirements/build.txt'), + tests_require=parse_requirements('requirements/tests.txt'), + install_requires=parse_requirements('requirements/runtime.txt'), + extras_require={ + 'all': parse_requirements('requirements.txt'), + 'tests': parse_requirements('requirements/tests.txt'), + 'build': parse_requirements('requirements/build.txt'), + 'optional': parse_requirements('requirements/optional.txt'), + }, + ext_modules=[ + make_cuda_ext( + name='compiling_info', + module='mmdet.ops.utils', + sources=['src/compiling_info.cpp']), + make_cython_ext( + name='soft_nms_cpu', + module='mmdet.ops.nms', + sources=['src/soft_nms_cpu.pyx']), + make_cuda_ext( + name='nms_cpu', + module='mmdet.ops.nms', + sources=['src/nms_cpu.cpp']), + make_cuda_ext( + name='nms_cuda', + module='mmdet.ops.nms', + sources=['src/nms_cuda.cpp', 'src/nms_kernel.cu']), + make_cuda_ext( + name='roi_align_cuda', + module='mmdet.ops.roi_align', + sources=['src/roi_align_cuda.cpp', 'src/roi_align_kernel.cu']), + make_cuda_ext( + name='roi_pool_cuda', + module='mmdet.ops.roi_pool', + sources=['src/roi_pool_cuda.cpp', 'src/roi_pool_kernel.cu']), + make_cuda_ext( + name='deform_conv_cuda', + module='mmdet.ops.dcn', + sources=[ + 'src/deform_conv_cuda.cpp', + 'src/deform_conv_cuda_kernel.cu' + ]), + make_cuda_ext( + name='deform_pool_cuda', + module='mmdet.ops.dcn', + sources=[ + 'src/deform_pool_cuda.cpp', + 'src/deform_pool_cuda_kernel.cu' + ]), + make_cuda_ext( + name='sigmoid_focal_loss_cuda', + module='mmdet.ops.sigmoid_focal_loss', + sources=[ + 'src/sigmoid_focal_loss.cpp', + 'src/sigmoid_focal_loss_cuda.cu' + ]), + make_cuda_ext( + name='masked_conv2d_cuda', + module='mmdet.ops.masked_conv', + sources=[ + 'src/masked_conv2d_cuda.cpp', 'src/masked_conv2d_kernel.cu' + ]), + ], + cmdclass={'build_ext': BuildExtension}, + zip_safe=False) diff --git a/cv/instance_segmentation/SOLO/pytorch/tests/async_benchmark.py b/cv/instance_segmentation/SOLO/pytorch/tests/async_benchmark.py new file mode 100644 index 000000000..0017783d3 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tests/async_benchmark.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +import asyncio +import os +import shutil +import urllib + +import mmcv +import torch + +from mmdet.apis import (async_inference_detector, inference_detector, + init_detector, show_result) +from mmdet.utils.contextmanagers import concurrent +from mmdet.utils.profiling import profile_time + + +async def main(): + """ + + Benchmark between async and synchronous inference interfaces. + + Sample runs for 20 demo images on K80 GPU, model - mask_rcnn_r50_fpn_1x: + + async sync + + 7981.79 ms 9660.82 ms + 8074.52 ms 9660.94 ms + 7976.44 ms 9406.83 ms + + Async variant takes about 0.83-0.85 of the time of the synchronous + interface. + + """ + project_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + + config_file = os.path.join(project_dir, 'configs/mask_rcnn_r50_fpn_1x.py') + checkpoint_file = os.path.join( + project_dir, 'checkpoints/mask_rcnn_r50_fpn_1x_20181010-069fa190.pth') + + if not os.path.exists(checkpoint_file): + url = ('https://s3.ap-northeast-2.amazonaws.com/open-mmlab/mmdetection' + '/models/mask_rcnn_r50_fpn_1x_20181010-069fa190.pth') + print('Downloading {} ...'.format(url)) + local_filename, _ = urllib.request.urlretrieve(url) + os.makedirs(os.path.dirname(checkpoint_file), exist_ok=True) + shutil.move(local_filename, checkpoint_file) + print('Saved as {}'.format(checkpoint_file)) + else: + print('Using existing checkpoint {}'.format(checkpoint_file)) + + device = 'cuda:0' + model = init_detector( + config_file, checkpoint=checkpoint_file, device=device) + + # queue is used for concurrent inference of multiple images + streamqueue = asyncio.Queue() + # queue size defines concurrency level + streamqueue_size = 4 + + for _ in range(streamqueue_size): + streamqueue.put_nowait(torch.cuda.Stream(device=device)) + + # test a single image and show the results + img = mmcv.imread(os.path.join(project_dir, 'demo/demo.jpg')) + + # warmup + await async_inference_detector(model, img) + + async def detect(img): + async with concurrent(streamqueue): + return await async_inference_detector(model, img) + + num_of_images = 20 + with profile_time('benchmark', 'async'): + tasks = [ + asyncio.create_task(detect(img)) for _ in range(num_of_images) + ] + async_results = await asyncio.gather(*tasks) + + with torch.cuda.stream(torch.cuda.default_stream()): + with profile_time('benchmark', 'sync'): + sync_results = [ + inference_detector(model, img) for _ in range(num_of_images) + ] + + result_dir = os.path.join(project_dir, 'demo') + show_result( + img, + async_results[0], + model.CLASSES, + score_thr=0.5, + show=False, + out_file=os.path.join(result_dir, 'result_async.jpg')) + show_result( + img, + sync_results[0], + model.CLASSES, + score_thr=0.5, + show=False, + out_file=os.path.join(result_dir, 'result_sync.jpg')) + + +if __name__ == '__main__': + asyncio.run(main()) diff --git a/cv/instance_segmentation/SOLO/pytorch/tests/test_assigner.py b/cv/instance_segmentation/SOLO/pytorch/tests/test_assigner.py new file mode 100644 index 000000000..5348eaba3 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tests/test_assigner.py @@ -0,0 +1,277 @@ +""" +Tests the Assigner objects. + +CommandLine: + pytest tests/test_assigner.py + xdoctest tests/test_assigner.py zero + + + +""" +import torch + +from mmdet.core import MaxIoUAssigner +from mmdet.core.bbox.assigners import ApproxMaxIoUAssigner, PointAssigner + + +def test_max_iou_assigner(): + self = MaxIoUAssigner( + pos_iou_thr=0.5, + neg_iou_thr=0.5, + ) + bboxes = torch.FloatTensor([ + [0, 0, 10, 10], + [10, 10, 20, 20], + [5, 5, 15, 15], + [32, 32, 38, 42], + ]) + gt_bboxes = torch.FloatTensor([ + [0, 0, 10, 9], + [0, 10, 10, 19], + ]) + gt_labels = torch.LongTensor([2, 3]) + assign_result = self.assign(bboxes, gt_bboxes, gt_labels=gt_labels) + assert len(assign_result.gt_inds) == 4 + assert len(assign_result.labels) == 4 + + expected_gt_inds = torch.LongTensor([1, 0, 2, 0]) + assert torch.all(assign_result.gt_inds == expected_gt_inds) + + +def test_max_iou_assigner_with_ignore(): + self = MaxIoUAssigner( + pos_iou_thr=0.5, + neg_iou_thr=0.5, + ignore_iof_thr=0.5, + ignore_wrt_candidates=False, + ) + bboxes = torch.FloatTensor([ + [0, 0, 10, 10], + [10, 10, 20, 20], + [5, 5, 15, 15], + [32, 32, 38, 42], + ]) + gt_bboxes = torch.FloatTensor([ + [0, 0, 10, 9], + [0, 10, 10, 19], + ]) + gt_bboxes_ignore = torch.Tensor([ + [30, 30, 40, 40], + ]) + assign_result = self.assign( + bboxes, gt_bboxes, gt_bboxes_ignore=gt_bboxes_ignore) + + expected_gt_inds = torch.LongTensor([1, 0, 2, -1]) + assert torch.all(assign_result.gt_inds == expected_gt_inds) + + +def test_max_iou_assigner_with_empty_gt(): + """ + Test corner case where an image might have no true detections + """ + self = MaxIoUAssigner( + pos_iou_thr=0.5, + neg_iou_thr=0.5, + ) + bboxes = torch.FloatTensor([ + [0, 0, 10, 10], + [10, 10, 20, 20], + [5, 5, 15, 15], + [32, 32, 38, 42], + ]) + gt_bboxes = torch.FloatTensor([]) + assign_result = self.assign(bboxes, gt_bboxes) + + expected_gt_inds = torch.LongTensor([0, 0, 0, 0]) + assert torch.all(assign_result.gt_inds == expected_gt_inds) + + +def test_max_iou_assigner_with_empty_boxes(): + """ + Test corner case where an network might predict no boxes + """ + self = MaxIoUAssigner( + pos_iou_thr=0.5, + neg_iou_thr=0.5, + ) + bboxes = torch.empty((0, 4)) + gt_bboxes = torch.FloatTensor([ + [0, 0, 10, 9], + [0, 10, 10, 19], + ]) + gt_labels = torch.LongTensor([2, 3]) + + # Test with gt_labels + assign_result = self.assign(bboxes, gt_bboxes, gt_labels=gt_labels) + assert len(assign_result.gt_inds) == 0 + assert tuple(assign_result.labels.shape) == (0, ) + + # Test without gt_labels + assign_result = self.assign(bboxes, gt_bboxes, gt_labels=None) + assert len(assign_result.gt_inds) == 0 + assert assign_result.labels is None + + +def test_max_iou_assigner_with_empty_boxes_and_gt(): + """ + Test corner case where an network might predict no boxes and no gt + """ + self = MaxIoUAssigner( + pos_iou_thr=0.5, + neg_iou_thr=0.5, + ) + bboxes = torch.empty((0, 4)) + gt_bboxes = torch.empty((0, 4)) + assign_result = self.assign(bboxes, gt_bboxes) + assert len(assign_result.gt_inds) == 0 + + +def test_point_assigner(): + self = PointAssigner() + points = torch.FloatTensor([ # [x, y, stride] + [0, 0, 1], + [10, 10, 1], + [5, 5, 1], + [32, 32, 1], + ]) + gt_bboxes = torch.FloatTensor([ + [0, 0, 10, 9], + [0, 10, 10, 19], + ]) + assign_result = self.assign(points, gt_bboxes) + expected_gt_inds = torch.LongTensor([1, 2, 1, 0]) + assert torch.all(assign_result.gt_inds == expected_gt_inds) + + +def test_point_assigner_with_empty_gt(): + """ + Test corner case where an image might have no true detections + """ + self = PointAssigner() + points = torch.FloatTensor([ # [x, y, stride] + [0, 0, 1], + [10, 10, 1], + [5, 5, 1], + [32, 32, 1], + ]) + gt_bboxes = torch.FloatTensor([]) + assign_result = self.assign(points, gt_bboxes) + + expected_gt_inds = torch.LongTensor([0, 0, 0, 0]) + assert torch.all(assign_result.gt_inds == expected_gt_inds) + + +def test_point_assigner_with_empty_boxes_and_gt(): + """ + Test corner case where an image might predict no points and no gt + """ + self = PointAssigner() + points = torch.FloatTensor([]) + gt_bboxes = torch.FloatTensor([]) + assign_result = self.assign(points, gt_bboxes) + assert len(assign_result.gt_inds) == 0 + + +def test_approx_iou_assigner(): + self = ApproxMaxIoUAssigner( + pos_iou_thr=0.5, + neg_iou_thr=0.5, + ) + bboxes = torch.FloatTensor([ + [0, 0, 10, 10], + [10, 10, 20, 20], + [5, 5, 15, 15], + [32, 32, 38, 42], + ]) + gt_bboxes = torch.FloatTensor([ + [0, 0, 10, 9], + [0, 10, 10, 19], + ]) + approxs_per_octave = 1 + approxs = bboxes + squares = bboxes + assign_result = self.assign(approxs, squares, approxs_per_octave, + gt_bboxes) + + expected_gt_inds = torch.LongTensor([1, 0, 2, 0]) + assert torch.all(assign_result.gt_inds == expected_gt_inds) + + +def test_approx_iou_assigner_with_empty_gt(): + """ + Test corner case where an image might have no true detections + """ + self = ApproxMaxIoUAssigner( + pos_iou_thr=0.5, + neg_iou_thr=0.5, + ) + bboxes = torch.FloatTensor([ + [0, 0, 10, 10], + [10, 10, 20, 20], + [5, 5, 15, 15], + [32, 32, 38, 42], + ]) + gt_bboxes = torch.FloatTensor([]) + approxs_per_octave = 1 + approxs = bboxes + squares = bboxes + assign_result = self.assign(approxs, squares, approxs_per_octave, + gt_bboxes) + + expected_gt_inds = torch.LongTensor([0, 0, 0, 0]) + assert torch.all(assign_result.gt_inds == expected_gt_inds) + + +def test_approx_iou_assigner_with_empty_boxes(): + """ + Test corner case where an network might predict no boxes + """ + self = ApproxMaxIoUAssigner( + pos_iou_thr=0.5, + neg_iou_thr=0.5, + ) + bboxes = torch.empty((0, 4)) + gt_bboxes = torch.FloatTensor([ + [0, 0, 10, 9], + [0, 10, 10, 19], + ]) + approxs_per_octave = 1 + approxs = bboxes + squares = bboxes + assign_result = self.assign(approxs, squares, approxs_per_octave, + gt_bboxes) + assert len(assign_result.gt_inds) == 0 + + +def test_approx_iou_assigner_with_empty_boxes_and_gt(): + """ + Test corner case where an network might predict no boxes and no gt + """ + self = ApproxMaxIoUAssigner( + pos_iou_thr=0.5, + neg_iou_thr=0.5, + ) + bboxes = torch.empty((0, 4)) + gt_bboxes = torch.empty((0, 4)) + approxs_per_octave = 1 + approxs = bboxes + squares = bboxes + assign_result = self.assign(approxs, squares, approxs_per_octave, + gt_bboxes) + assert len(assign_result.gt_inds) == 0 + + +def test_random_assign_result(): + """ + Test random instantiation of assign result to catch corner cases + """ + from mmdet.core.bbox.assigners.assign_result import AssignResult + AssignResult.random() + + AssignResult.random(num_gts=0, num_preds=0) + AssignResult.random(num_gts=0, num_preds=3) + AssignResult.random(num_gts=3, num_preds=3) + AssignResult.random(num_gts=0, num_preds=3) + AssignResult.random(num_gts=7, num_preds=7) + AssignResult.random(num_gts=7, num_preds=64) + AssignResult.random(num_gts=24, num_preds=3) diff --git a/cv/instance_segmentation/SOLO/pytorch/tests/test_async.py b/cv/instance_segmentation/SOLO/pytorch/tests/test_async.py new file mode 100644 index 000000000..68ecde33d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tests/test_async.py @@ -0,0 +1,78 @@ +"""Tests for async interface.""" + +import asyncio +import os +import sys + +import asynctest +import mmcv +import torch + +from mmdet.apis import async_inference_detector, init_detector + +if sys.version_info >= (3, 7): + from mmdet.utils.contextmanagers import concurrent + + +class AsyncTestCase(asynctest.TestCase): + use_default_loop = False + forbid_get_event_loop = True + + TEST_TIMEOUT = int(os.getenv("ASYNCIO_TEST_TIMEOUT", "30")) + + def _run_test_method(self, method): + result = method() + if asyncio.iscoroutine(result): + self.loop.run_until_complete( + asyncio.wait_for(result, timeout=self.TEST_TIMEOUT)) + + +class MaskRCNNDetector: + + def __init__(self, + model_config, + checkpoint=None, + streamqueue_size=3, + device="cuda:0"): + + self.streamqueue_size = streamqueue_size + self.device = device + # build the model and load checkpoint + self.model = init_detector( + model_config, checkpoint=None, device=self.device) + self.streamqueue = None + + async def init(self): + self.streamqueue = asyncio.Queue() + for _ in range(self.streamqueue_size): + stream = torch.cuda.Stream(device=self.device) + self.streamqueue.put_nowait(stream) + + if sys.version_info >= (3, 7): + + async def apredict(self, img): + if isinstance(img, str): + img = mmcv.imread(img) + async with concurrent(self.streamqueue): + result = await async_inference_detector(self.model, img) + return result + + +class AsyncInferenceTestCase(AsyncTestCase): + + if sys.version_info >= (3, 7): + + async def test_simple_inference(self): + if not torch.cuda.is_available(): + import pytest + + pytest.skip("test requires GPU and torch+cuda") + + root_dir = os.path.dirname(os.path.dirname(__name__)) + model_config = os.path.join(root_dir, + "configs/mask_rcnn_r50_fpn_1x.py") + detector = MaskRCNNDetector(model_config) + await detector.init() + img_path = os.path.join(root_dir, "demo/demo.jpg") + bboxes, _ = await detector.apredict(img_path) + self.assertTrue(bboxes) diff --git a/cv/instance_segmentation/SOLO/pytorch/tests/test_config.py b/cv/instance_segmentation/SOLO/pytorch/tests/test_config.py new file mode 100644 index 000000000..ebc399ff3 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tests/test_config.py @@ -0,0 +1,172 @@ +from os.path import dirname, exists, join + + +def _get_config_directory(): + """ Find the predefined detector config directory """ + try: + # Assume we are running in the source mmdetection repo + repo_dpath = dirname(dirname(__file__)) + except NameError: + # For IPython development when this __file__ is not defined + import mmdet + repo_dpath = dirname(dirname(mmdet.__file__)) + config_dpath = join(repo_dpath, 'configs') + if not exists(config_dpath): + raise Exception('Cannot find config path') + return config_dpath + + +def test_config_build_detector(): + """ + Test that all detection models defined in the configs can be initialized. + """ + from xdoctest.utils import import_module_from_path + from mmdet.models import build_detector + + config_dpath = _get_config_directory() + print('Found config_dpath = {!r}'.format(config_dpath)) + + # import glob + # config_fpaths = list(glob.glob(join(config_dpath, '**', '*.py'))) + # config_names = [relpath(p, config_dpath) for p in config_fpaths] + + # Only tests a representative subset of configurations + + config_names = [ + # 'dcn/faster_rcnn_dconv_c3-c5_r50_fpn_1x.py', + # 'dcn/cascade_mask_rcnn_dconv_c3-c5_r50_fpn_1x.py', + # 'dcn/faster_rcnn_dpool_r50_fpn_1x.py', + 'dcn/mask_rcnn_dconv_c3-c5_r50_fpn_1x.py', + # 'dcn/faster_rcnn_dconv_c3-c5_x101_32x4d_fpn_1x.py', + # 'dcn/cascade_rcnn_dconv_c3-c5_r50_fpn_1x.py', + # 'dcn/faster_rcnn_mdpool_r50_fpn_1x.py', + # 'dcn/faster_rcnn_mdconv_c3-c5_group4_r50_fpn_1x.py', + # 'dcn/faster_rcnn_mdconv_c3-c5_r50_fpn_1x.py', + # --- + # 'htc/htc_x101_32x4d_fpn_20e_16gpu.py', + 'htc/htc_without_semantic_r50_fpn_1x.py', + # 'htc/htc_dconv_c3-c5_mstrain_400_1400_x101_64x4d_fpn_20e.py', + # 'htc/htc_x101_64x4d_fpn_20e_16gpu.py', + # 'htc/htc_r50_fpn_1x.py', + # 'htc/htc_r101_fpn_20e.py', + # 'htc/htc_r50_fpn_20e.py', + # --- + 'cityscapes/mask_rcnn_r50_fpn_1x_cityscapes.py', + # 'cityscapes/faster_rcnn_r50_fpn_1x_cityscapes.py', + # --- + # 'scratch/scratch_faster_rcnn_r50_fpn_gn_6x.py', + # 'scratch/scratch_mask_rcnn_r50_fpn_gn_6x.py', + # --- + # 'grid_rcnn/grid_rcnn_gn_head_x101_32x4d_fpn_2x.py', + 'grid_rcnn/grid_rcnn_gn_head_r50_fpn_2x.py', + # --- + 'double_heads/dh_faster_rcnn_r50_fpn_1x.py', + # --- + 'empirical_attention/faster_rcnn_r50_fpn_attention_0010_dcn_1x.py', + # 'empirical_attention/faster_rcnn_r50_fpn_attention_1111_1x.py', + # 'empirical_attention/faster_rcnn_r50_fpn_attention_0010_1x.py', + # 'empirical_attention/faster_rcnn_r50_fpn_attention_1111_dcn_1x.py', + # --- + # 'ms_rcnn/ms_rcnn_r101_caffe_fpn_1x.py', + # 'ms_rcnn/ms_rcnn_x101_64x4d_fpn_1x.py', + # 'ms_rcnn/ms_rcnn_r50_caffe_fpn_1x.py', + # --- + # 'guided_anchoring/ga_faster_x101_32x4d_fpn_1x.py', + # 'guided_anchoring/ga_rpn_x101_32x4d_fpn_1x.py', + # 'guided_anchoring/ga_retinanet_r50_caffe_fpn_1x.py', + # 'guided_anchoring/ga_fast_r50_caffe_fpn_1x.py', + # 'guided_anchoring/ga_retinanet_x101_32x4d_fpn_1x.py', + # 'guided_anchoring/ga_rpn_r101_caffe_rpn_1x.py', + # 'guided_anchoring/ga_faster_r50_caffe_fpn_1x.py', + 'guided_anchoring/ga_rpn_r50_caffe_fpn_1x.py', + # --- + 'foveabox/fovea_r50_fpn_4gpu_1x.py', + # 'foveabox/fovea_align_gn_ms_r101_fpn_4gpu_2x.py', + # 'foveabox/fovea_align_gn_r50_fpn_4gpu_2x.py', + # 'foveabox/fovea_align_gn_r101_fpn_4gpu_2x.py', + 'foveabox/fovea_align_gn_ms_r50_fpn_4gpu_2x.py', + # --- + # 'hrnet/cascade_rcnn_hrnetv2p_w32_20e.py', + # 'hrnet/mask_rcnn_hrnetv2p_w32_1x.py', + # 'hrnet/cascade_mask_rcnn_hrnetv2p_w32_20e.py', + # 'hrnet/htc_hrnetv2p_w32_20e.py', + # 'hrnet/faster_rcnn_hrnetv2p_w18_1x.py', + # 'hrnet/mask_rcnn_hrnetv2p_w18_1x.py', + # 'hrnet/faster_rcnn_hrnetv2p_w32_1x.py', + # 'hrnet/faster_rcnn_hrnetv2p_w40_1x.py', + 'hrnet/fcos_hrnetv2p_w32_gn_1x_4gpu.py', + # --- + # 'gn+ws/faster_rcnn_r50_fpn_gn_ws_1x.py', + # 'gn+ws/mask_rcnn_x101_32x4d_fpn_gn_ws_2x.py', + 'gn+ws/mask_rcnn_r50_fpn_gn_ws_2x.py', + # 'gn+ws/mask_rcnn_r50_fpn_gn_ws_20_23_24e.py', + # --- + # 'wider_face/ssd300_wider_face.py', + # --- + 'pascal_voc/ssd300_voc.py', + 'pascal_voc/faster_rcnn_r50_fpn_1x_voc0712.py', + 'pascal_voc/ssd512_voc.py', + # --- + # 'gcnet/mask_rcnn_r4_gcb_c3-c5_r50_fpn_syncbn_1x.py', + # 'gcnet/mask_rcnn_r16_gcb_c3-c5_r50_fpn_syncbn_1x.py', + # 'gcnet/mask_rcnn_r4_gcb_c3-c5_r50_fpn_1x.py', + # 'gcnet/mask_rcnn_r16_gcb_c3-c5_r50_fpn_1x.py', + 'gcnet/mask_rcnn_r50_fpn_sbn_1x.py', + # --- + 'gn/mask_rcnn_r50_fpn_gn_contrib_2x.py', + # 'gn/mask_rcnn_r50_fpn_gn_2x.py', + # 'gn/mask_rcnn_r101_fpn_gn_2x.py', + # --- + # 'reppoints/reppoints_moment_x101_dcn_fpn_2x.py', + 'reppoints/reppoints_moment_r50_fpn_2x.py', + # 'reppoints/reppoints_moment_x101_dcn_fpn_2x_mt.py', + 'reppoints/reppoints_partial_minmax_r50_fpn_1x.py', + 'reppoints/bbox_r50_grid_center_fpn_1x.py', + # 'reppoints/reppoints_moment_r101_dcn_fpn_2x.py', + # 'reppoints/reppoints_moment_r101_fpn_2x_mt.py', + # 'reppoints/reppoints_moment_r50_fpn_2x_mt.py', + 'reppoints/reppoints_minmax_r50_fpn_1x.py', + # 'reppoints/reppoints_moment_r50_fpn_1x.py', + # 'reppoints/reppoints_moment_r101_fpn_2x.py', + # 'reppoints/reppoints_moment_r101_dcn_fpn_2x_mt.py', + 'reppoints/bbox_r50_grid_fpn_1x.py', + # --- + # 'fcos/fcos_mstrain_640_800_x101_64x4d_fpn_gn_2x.py', + # 'fcos/fcos_mstrain_640_800_r101_caffe_fpn_gn_2x_4gpu.py', + 'fcos/fcos_r50_caffe_fpn_gn_1x_4gpu.py', + # --- + 'albu_example/mask_rcnn_r50_fpn_1x.py', + # --- + 'libra_rcnn/libra_faster_rcnn_r50_fpn_1x.py', + # 'libra_rcnn/libra_retinanet_r50_fpn_1x.py', + # 'libra_rcnn/libra_faster_rcnn_r101_fpn_1x.py', + # 'libra_rcnn/libra_faster_rcnn_x101_64x4d_fpn_1x.py', + # 'libra_rcnn/libra_fast_rcnn_r50_fpn_1x.py', + # --- + # 'ghm/retinanet_ghm_r50_fpn_1x.py', + # --- + # 'fp16/retinanet_r50_fpn_fp16_1x.py', + 'fp16/mask_rcnn_r50_fpn_fp16_1x.py', + 'fp16/faster_rcnn_r50_fpn_fp16_1x.py' + ] + + print('Using {} config files'.format(len(config_names))) + + for config_fname in config_names: + config_fpath = join(config_dpath, config_fname) + config_mod = import_module_from_path(config_fpath) + + config_mod.model + config_mod.train_cfg + config_mod.test_cfg + print('Building detector, config_fpath = {!r}'.format(config_fpath)) + + # Remove pretrained keys to allow for testing in an offline environment + if 'pretrained' in config_mod.model: + config_mod.model['pretrained'] = None + + detector = build_detector( + config_mod.model, + train_cfg=config_mod.train_cfg, + test_cfg=config_mod.test_cfg) + assert detector is not None diff --git a/cv/instance_segmentation/SOLO/pytorch/tests/test_forward.py b/cv/instance_segmentation/SOLO/pytorch/tests/test_forward.py new file mode 100644 index 000000000..5ba56bf24 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tests/test_forward.py @@ -0,0 +1,388 @@ +""" +pytest tests/test_forward.py +""" +import copy +from os.path import dirname, exists, join + +import numpy as np +import torch + + +def _get_config_directory(): + """ Find the predefined detector config directory """ + try: + # Assume we are running in the source mmdetection repo + repo_dpath = dirname(dirname(__file__)) + except NameError: + # For IPython development when this __file__ is not defined + import mmdet + repo_dpath = dirname(dirname(mmdet.__file__)) + config_dpath = join(repo_dpath, 'configs') + if not exists(config_dpath): + raise Exception('Cannot find config path') + return config_dpath + + +def _get_config_module(fname): + """ + Load a configuration as a python module + """ + from xdoctest.utils import import_module_from_path + config_dpath = _get_config_directory() + config_fpath = join(config_dpath, fname) + config_mod = import_module_from_path(config_fpath) + return config_mod + + +def _get_detector_cfg(fname): + """ + Grab configs necessary to create a detector. These are deep copied to allow + for safe modification of parameters without influencing other tests. + """ + import mmcv + config = _get_config_module(fname) + model = copy.deepcopy(config.model) + train_cfg = mmcv.Config(copy.deepcopy(config.train_cfg)) + test_cfg = mmcv.Config(copy.deepcopy(config.test_cfg)) + return model, train_cfg, test_cfg + + +def test_ssd300_forward(): + model, train_cfg, test_cfg = _get_detector_cfg('ssd300_coco.py') + model['pretrained'] = None + + from mmdet.models import build_detector + detector = build_detector(model, train_cfg=train_cfg, test_cfg=test_cfg) + + input_shape = (1, 3, 300, 300) + mm_inputs = _demo_mm_inputs(input_shape) + + imgs = mm_inputs.pop('imgs') + img_metas = mm_inputs.pop('img_metas') + + # Test forward train + gt_bboxes = mm_inputs['gt_bboxes'] + gt_labels = mm_inputs['gt_labels'] + losses = detector.forward( + imgs, + img_metas, + gt_bboxes=gt_bboxes, + gt_labels=gt_labels, + return_loss=True) + assert isinstance(losses, dict) + + # Test forward test + with torch.no_grad(): + img_list = [g[None, :] for g in imgs] + batch_results = [] + for one_img, one_meta in zip(img_list, img_metas): + result = detector.forward([one_img], [[one_meta]], + return_loss=False) + batch_results.append(result) + + +def test_rpn_forward(): + model, train_cfg, test_cfg = _get_detector_cfg('rpn_r50_fpn_1x.py') + model['pretrained'] = None + + from mmdet.models import build_detector + detector = build_detector(model, train_cfg=train_cfg, test_cfg=test_cfg) + + input_shape = (1, 3, 224, 224) + mm_inputs = _demo_mm_inputs(input_shape) + + imgs = mm_inputs.pop('imgs') + img_metas = mm_inputs.pop('img_metas') + + # Test forward train + gt_bboxes = mm_inputs['gt_bboxes'] + losses = detector.forward( + imgs, img_metas, gt_bboxes=gt_bboxes, return_loss=True) + assert isinstance(losses, dict) + + # Test forward test + with torch.no_grad(): + img_list = [g[None, :] for g in imgs] + batch_results = [] + for one_img, one_meta in zip(img_list, img_metas): + result = detector.forward([one_img], [[one_meta]], + return_loss=False) + batch_results.append(result) + + +def test_retina_ghm_forward(): + model, train_cfg, test_cfg = _get_detector_cfg( + 'ghm/retinanet_ghm_r50_fpn_1x.py') + model['pretrained'] = None + + from mmdet.models import build_detector + detector = build_detector(model, train_cfg=train_cfg, test_cfg=test_cfg) + + input_shape = (3, 3, 224, 224) + mm_inputs = _demo_mm_inputs(input_shape) + + imgs = mm_inputs.pop('imgs') + img_metas = mm_inputs.pop('img_metas') + + # Test forward train + gt_bboxes = mm_inputs['gt_bboxes'] + gt_labels = mm_inputs['gt_labels'] + losses = detector.forward( + imgs, + img_metas, + gt_bboxes=gt_bboxes, + gt_labels=gt_labels, + return_loss=True) + assert isinstance(losses, dict) + + # Test forward test + with torch.no_grad(): + img_list = [g[None, :] for g in imgs] + batch_results = [] + for one_img, one_meta in zip(img_list, img_metas): + result = detector.forward([one_img], [[one_meta]], + return_loss=False) + batch_results.append(result) + + if torch.cuda.is_available(): + detector = detector.cuda() + imgs = imgs.cuda() + # Test forward train + gt_bboxes = [b.cuda() for b in mm_inputs['gt_bboxes']] + gt_labels = [g.cuda() for g in mm_inputs['gt_labels']] + losses = detector.forward( + imgs, + img_metas, + gt_bboxes=gt_bboxes, + gt_labels=gt_labels, + return_loss=True) + assert isinstance(losses, dict) + + # Test forward test + with torch.no_grad(): + img_list = [g[None, :] for g in imgs] + batch_results = [] + for one_img, one_meta in zip(img_list, img_metas): + result = detector.forward([one_img], [[one_meta]], + return_loss=False) + batch_results.append(result) + + +def test_cascade_forward(): + try: + from torchvision import _C as C # NOQA + except ImportError: + import pytest + raise pytest.skip('requires torchvision on cpu') + + model, train_cfg, test_cfg = _get_detector_cfg( + 'cascade_rcnn_r50_fpn_1x.py') + model['pretrained'] = None + # torchvision roi align supports CPU + model['bbox_roi_extractor']['roi_layer']['use_torchvision'] = True + + from mmdet.models import build_detector + detector = build_detector(model, train_cfg=train_cfg, test_cfg=test_cfg) + + input_shape = (1, 3, 256, 256) + + # Test forward train with a non-empty truth batch + mm_inputs = _demo_mm_inputs(input_shape, num_items=[10]) + imgs = mm_inputs.pop('imgs') + img_metas = mm_inputs.pop('img_metas') + gt_bboxes = mm_inputs['gt_bboxes'] + gt_labels = mm_inputs['gt_labels'] + losses = detector.forward( + imgs, + img_metas, + gt_bboxes=gt_bboxes, + gt_labels=gt_labels, + return_loss=True) + assert isinstance(losses, dict) + from mmdet.apis.train import parse_losses + total_loss = float(parse_losses(losses)[0].item()) + assert total_loss > 0 + + # Test forward train with an empty truth batch + mm_inputs = _demo_mm_inputs(input_shape, num_items=[0]) + imgs = mm_inputs.pop('imgs') + img_metas = mm_inputs.pop('img_metas') + gt_bboxes = mm_inputs['gt_bboxes'] + gt_labels = mm_inputs['gt_labels'] + losses = detector.forward( + imgs, + img_metas, + gt_bboxes=gt_bboxes, + gt_labels=gt_labels, + return_loss=True) + assert isinstance(losses, dict) + from mmdet.apis.train import parse_losses + total_loss = float(parse_losses(losses)[0].item()) + assert total_loss > 0 + + +def test_faster_rcnn_forward(): + try: + from torchvision import _C as C # NOQA + except ImportError: + import pytest + raise pytest.skip('requires torchvision on cpu') + + model, train_cfg, test_cfg = _get_detector_cfg('faster_rcnn_r50_fpn_1x.py') + model['pretrained'] = None + # torchvision roi align supports CPU + model['bbox_roi_extractor']['roi_layer']['use_torchvision'] = True + + from mmdet.models import build_detector + detector = build_detector(model, train_cfg=train_cfg, test_cfg=test_cfg) + + input_shape = (1, 3, 256, 256) + + # Test forward train with a non-empty truth batch + mm_inputs = _demo_mm_inputs(input_shape, num_items=[10]) + imgs = mm_inputs.pop('imgs') + img_metas = mm_inputs.pop('img_metas') + gt_bboxes = mm_inputs['gt_bboxes'] + gt_labels = mm_inputs['gt_labels'] + losses = detector.forward( + imgs, + img_metas, + gt_bboxes=gt_bboxes, + gt_labels=gt_labels, + return_loss=True) + assert isinstance(losses, dict) + from mmdet.apis.train import parse_losses + total_loss = float(parse_losses(losses)[0].item()) + assert total_loss > 0 + + # Test forward train with an empty truth batch + mm_inputs = _demo_mm_inputs(input_shape, num_items=[0]) + imgs = mm_inputs.pop('imgs') + img_metas = mm_inputs.pop('img_metas') + gt_bboxes = mm_inputs['gt_bboxes'] + gt_labels = mm_inputs['gt_labels'] + losses = detector.forward( + imgs, + img_metas, + gt_bboxes=gt_bboxes, + gt_labels=gt_labels, + return_loss=True) + assert isinstance(losses, dict) + from mmdet.apis.train import parse_losses + total_loss = float(parse_losses(losses)[0].item()) + assert total_loss > 0 + + +def test_faster_rcnn_ohem_forward(): + try: + from torchvision import _C as C # NOQA + except ImportError: + import pytest + raise pytest.skip('requires torchvision on cpu') + + model, train_cfg, test_cfg = _get_detector_cfg( + 'faster_rcnn_ohem_r50_fpn_1x.py') + model['pretrained'] = None + # torchvision roi align supports CPU + model['bbox_roi_extractor']['roi_layer']['use_torchvision'] = True + + from mmdet.models import build_detector + detector = build_detector(model, train_cfg=train_cfg, test_cfg=test_cfg) + + input_shape = (1, 3, 256, 256) + + # Test forward train with a non-empty truth batch + mm_inputs = _demo_mm_inputs(input_shape, num_items=[10]) + imgs = mm_inputs.pop('imgs') + img_metas = mm_inputs.pop('img_metas') + gt_bboxes = mm_inputs['gt_bboxes'] + gt_labels = mm_inputs['gt_labels'] + losses = detector.forward( + imgs, + img_metas, + gt_bboxes=gt_bboxes, + gt_labels=gt_labels, + return_loss=True) + assert isinstance(losses, dict) + from mmdet.apis.train import parse_losses + total_loss = float(parse_losses(losses)[0].item()) + assert total_loss > 0 + + # Test forward train with an empty truth batch + mm_inputs = _demo_mm_inputs(input_shape, num_items=[0]) + imgs = mm_inputs.pop('imgs') + img_metas = mm_inputs.pop('img_metas') + gt_bboxes = mm_inputs['gt_bboxes'] + gt_labels = mm_inputs['gt_labels'] + losses = detector.forward( + imgs, + img_metas, + gt_bboxes=gt_bboxes, + gt_labels=gt_labels, + return_loss=True) + assert isinstance(losses, dict) + from mmdet.apis.train import parse_losses + total_loss = float(parse_losses(losses)[0].item()) + assert total_loss > 0 + + +def _demo_mm_inputs(input_shape=(1, 3, 300, 300), + num_items=None, num_classes=10): # yapf: disable + """ + Create a superset of inputs needed to run test or train batches. + + Args: + input_shape (tuple): + input batch dimensions + + num_items (None | List[int]): + specifies the number of boxes in each batch item + + num_classes (int): + number of different labels a box might have + """ + (N, C, H, W) = input_shape + + rng = np.random.RandomState(0) + + imgs = rng.rand(*input_shape) + + img_metas = [{ + 'img_shape': (H, W, C), + 'ori_shape': (H, W, C), + 'pad_shape': (H, W, C), + 'filename': '.png', + 'scale_factor': 1.0, + 'flip': False, + } for _ in range(N)] + + gt_bboxes = [] + gt_labels = [] + + for batch_idx in range(N): + if num_items is None: + num_boxes = rng.randint(1, 10) + else: + num_boxes = num_items[batch_idx] + + cx, cy, bw, bh = rng.rand(num_boxes, 4).T + + tl_x = ((cx * W) - (W * bw / 2)).clip(0, W) + tl_y = ((cy * H) - (H * bh / 2)).clip(0, H) + br_x = ((cx * W) + (W * bw / 2)).clip(0, W) + br_y = ((cy * H) + (H * bh / 2)).clip(0, H) + + boxes = np.vstack([tl_x, tl_y, br_x, br_y]).T + class_idxs = rng.randint(1, num_classes, size=num_boxes) + + gt_bboxes.append(torch.FloatTensor(boxes)) + gt_labels.append(torch.LongTensor(class_idxs)) + + mm_inputs = { + 'imgs': torch.FloatTensor(imgs), + 'img_metas': img_metas, + 'gt_bboxes': gt_bboxes, + 'gt_labels': gt_labels, + 'gt_bboxes_ignore': None, + } + return mm_inputs diff --git a/cv/instance_segmentation/SOLO/pytorch/tests/test_heads.py b/cv/instance_segmentation/SOLO/pytorch/tests/test_heads.py new file mode 100644 index 000000000..b1e4ceebf --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tests/test_heads.py @@ -0,0 +1,340 @@ +import mmcv +import torch + +from mmdet.core import build_assigner, build_sampler +from mmdet.models.anchor_heads import AnchorHead +from mmdet.models.bbox_heads import BBoxHead + + +def test_anchor_head_loss(): + """ + Tests anchor head loss when truth is empty and non-empty + """ + self = AnchorHead(num_classes=4, in_channels=1) + s = 256 + img_metas = [{ + 'img_shape': (s, s, 3), + 'scale_factor': 1, + 'pad_shape': (s, s, 3) + }] + + cfg = mmcv.Config({ + 'assigner': { + 'type': 'MaxIoUAssigner', + 'pos_iou_thr': 0.7, + 'neg_iou_thr': 0.3, + 'min_pos_iou': 0.3, + 'ignore_iof_thr': -1 + }, + 'sampler': { + 'type': 'RandomSampler', + 'num': 256, + 'pos_fraction': 0.5, + 'neg_pos_ub': -1, + 'add_gt_as_proposals': False + }, + 'allowed_border': 0, + 'pos_weight': -1, + 'debug': False + }) + + # Anchor head expects a multiple levels of features per image + feat = [ + torch.rand(1, 1, s // (2**(i + 2)), s // (2**(i + 2))) + for i in range(len(self.anchor_generators)) + ] + cls_scores, bbox_preds = self.forward(feat) + + # Test that empty ground truth encourages the network to predict background + gt_bboxes = [torch.empty((0, 4))] + gt_labels = [torch.LongTensor([])] + + gt_bboxes_ignore = None + empty_gt_losses = self.loss(cls_scores, bbox_preds, gt_bboxes, gt_labels, + img_metas, cfg, gt_bboxes_ignore) + # When there is no truth, the cls loss should be nonzero but there should + # be no box loss. + empty_cls_loss = sum(empty_gt_losses['loss_cls']) + empty_box_loss = sum(empty_gt_losses['loss_bbox']) + assert empty_cls_loss.item() > 0, 'cls loss should be non-zero' + assert empty_box_loss.item() == 0, ( + 'there should be no box loss when there are no true boxes') + + # When truth is non-empty then both cls and box loss should be nonzero for + # random inputs + gt_bboxes = [ + torch.Tensor([[23.6667, 23.8757, 238.6326, 151.8874]]), + ] + gt_labels = [torch.LongTensor([2])] + one_gt_losses = self.loss(cls_scores, bbox_preds, gt_bboxes, gt_labels, + img_metas, cfg, gt_bboxes_ignore) + onegt_cls_loss = sum(one_gt_losses['loss_cls']) + onegt_box_loss = sum(one_gt_losses['loss_bbox']) + assert onegt_cls_loss.item() > 0, 'cls loss should be non-zero' + assert onegt_box_loss.item() > 0, 'box loss should be non-zero' + + +def test_bbox_head_loss(): + """ + Tests bbox head loss when truth is empty and non-empty + """ + self = BBoxHead(in_channels=8, roi_feat_size=3) + + num_imgs = 1 + feat = torch.rand(1, 1, 3, 3) + + # Dummy proposals + proposal_list = [ + torch.Tensor([[23.6667, 23.8757, 228.6326, 153.8874]]), + ] + + target_cfg = mmcv.Config({'pos_weight': 1}) + + def _dummy_bbox_sampling(proposal_list, gt_bboxes, gt_labels): + """ + Create sample results that can be passed to BBoxHead.get_target + """ + assign_config = { + 'type': 'MaxIoUAssigner', + 'pos_iou_thr': 0.5, + 'neg_iou_thr': 0.5, + 'min_pos_iou': 0.5, + 'ignore_iof_thr': -1 + } + sampler_config = { + 'type': 'RandomSampler', + 'num': 512, + 'pos_fraction': 0.25, + 'neg_pos_ub': -1, + 'add_gt_as_proposals': True + } + bbox_assigner = build_assigner(assign_config) + bbox_sampler = build_sampler(sampler_config) + gt_bboxes_ignore = [None for _ in range(num_imgs)] + sampling_results = [] + for i in range(num_imgs): + assign_result = bbox_assigner.assign(proposal_list[i], + gt_bboxes[i], + gt_bboxes_ignore[i], + gt_labels[i]) + sampling_result = bbox_sampler.sample( + assign_result, + proposal_list[i], + gt_bboxes[i], + gt_labels[i], + feats=feat) + sampling_results.append(sampling_result) + return sampling_results + + # Test bbox loss when truth is empty + gt_bboxes = [torch.empty((0, 4))] + gt_labels = [torch.LongTensor([])] + + sampling_results = _dummy_bbox_sampling(proposal_list, gt_bboxes, + gt_labels) + + bbox_targets = self.get_target(sampling_results, gt_bboxes, gt_labels, + target_cfg) + labels, label_weights, bbox_targets, bbox_weights = bbox_targets + + # Create dummy features "extracted" for each sampled bbox + num_sampled = sum(len(res.bboxes) for res in sampling_results) + dummy_feats = torch.rand(num_sampled, 8 * 3 * 3) + cls_scores, bbox_preds = self.forward(dummy_feats) + + losses = self.loss(cls_scores, bbox_preds, labels, label_weights, + bbox_targets, bbox_weights) + assert losses.get('loss_cls', 0) > 0, 'cls-loss should be non-zero' + assert losses.get('loss_bbox', 0) == 0, 'empty gt loss should be zero' + + # Test bbox loss when truth is non-empty + gt_bboxes = [ + torch.Tensor([[23.6667, 23.8757, 238.6326, 151.8874]]), + ] + gt_labels = [torch.LongTensor([2])] + + sampling_results = _dummy_bbox_sampling(proposal_list, gt_bboxes, + gt_labels) + + bbox_targets = self.get_target(sampling_results, gt_bboxes, gt_labels, + target_cfg) + labels, label_weights, bbox_targets, bbox_weights = bbox_targets + + # Create dummy features "extracted" for each sampled bbox + num_sampled = sum(len(res.bboxes) for res in sampling_results) + dummy_feats = torch.rand(num_sampled, 8 * 3 * 3) + cls_scores, bbox_preds = self.forward(dummy_feats) + + losses = self.loss(cls_scores, bbox_preds, labels, label_weights, + bbox_targets, bbox_weights) + assert losses.get('loss_cls', 0) > 0, 'cls-loss should be non-zero' + assert losses.get('loss_bbox', 0) > 0, 'box-loss should be non-zero' + + +def test_refine_boxes(): + """ + Mirrors the doctest in + ``mmdet.models.bbox_heads.bbox_head.BBoxHead.refine_boxes`` but checks for + multiple values of n_roi / n_img. + """ + self = BBoxHead(reg_class_agnostic=True) + + test_settings = [ + + # Corner case: less rois than images + { + 'n_roi': 2, + 'n_img': 4, + 'rng': 34285940 + }, + + # Corner case: no images + { + 'n_roi': 0, + 'n_img': 0, + 'rng': 52925222 + }, + + # Corner cases: few images / rois + { + 'n_roi': 1, + 'n_img': 1, + 'rng': 1200281 + }, + { + 'n_roi': 2, + 'n_img': 1, + 'rng': 1200282 + }, + { + 'n_roi': 2, + 'n_img': 2, + 'rng': 1200283 + }, + { + 'n_roi': 1, + 'n_img': 2, + 'rng': 1200284 + }, + + # Corner case: no rois few images + { + 'n_roi': 0, + 'n_img': 1, + 'rng': 23955860 + }, + { + 'n_roi': 0, + 'n_img': 2, + 'rng': 25830516 + }, + + # Corner case: no rois many images + { + 'n_roi': 0, + 'n_img': 10, + 'rng': 671346 + }, + { + 'n_roi': 0, + 'n_img': 20, + 'rng': 699807 + }, + + # Corner case: similar num rois and images + { + 'n_roi': 20, + 'n_img': 20, + 'rng': 1200238 + }, + { + 'n_roi': 10, + 'n_img': 20, + 'rng': 1200238 + }, + { + 'n_roi': 5, + 'n_img': 5, + 'rng': 1200238 + }, + + # ---------------------------------- + # Common case: more rois than images + { + 'n_roi': 100, + 'n_img': 1, + 'rng': 337156 + }, + { + 'n_roi': 150, + 'n_img': 2, + 'rng': 275898 + }, + { + 'n_roi': 500, + 'n_img': 5, + 'rng': 4903221 + }, + ] + + for demokw in test_settings: + try: + n_roi = demokw['n_roi'] + n_img = demokw['n_img'] + rng = demokw['rng'] + + print('Test refine_boxes case: {!r}'.format(demokw)) + tup = _demodata_refine_boxes(n_roi, n_img, rng=rng) + rois, labels, bbox_preds, pos_is_gts, img_metas = tup + bboxes_list = self.refine_bboxes(rois, labels, bbox_preds, + pos_is_gts, img_metas) + assert len(bboxes_list) == n_img + assert sum(map(len, bboxes_list)) <= n_roi + assert all(b.shape[1] == 4 for b in bboxes_list) + except Exception: + print('Test failed with demokw={!r}'.format(demokw)) + raise + + +def _demodata_refine_boxes(n_roi, n_img, rng=0): + """ + Create random test data for the + ``mmdet.models.bbox_heads.bbox_head.BBoxHead.refine_boxes`` method + """ + import numpy as np + from mmdet.core.bbox.demodata import random_boxes + from mmdet.core.bbox.demodata import ensure_rng + try: + import kwarray + except ImportError: + import pytest + pytest.skip('kwarray is required for this test') + scale = 512 + rng = ensure_rng(rng) + img_metas = [{'img_shape': (scale, scale)} for _ in range(n_img)] + # Create rois in the expected format + roi_boxes = random_boxes(n_roi, scale=scale, rng=rng) + if n_img == 0: + assert n_roi == 0, 'cannot have any rois if there are no images' + img_ids = torch.empty((0, ), dtype=torch.long) + roi_boxes = torch.empty((0, 4), dtype=torch.float32) + else: + img_ids = rng.randint(0, n_img, (n_roi, )) + img_ids = torch.from_numpy(img_ids) + rois = torch.cat([img_ids[:, None].float(), roi_boxes], dim=1) + # Create other args + labels = rng.randint(0, 2, (n_roi, )) + labels = torch.from_numpy(labels).long() + bbox_preds = random_boxes(n_roi, scale=scale, rng=rng) + # For each image, pretend random positive boxes are gts + is_label_pos = (labels.numpy() > 0).astype(np.int) + lbl_per_img = kwarray.group_items(is_label_pos, img_ids.numpy()) + pos_per_img = [sum(lbl_per_img.get(gid, [])) for gid in range(n_img)] + # randomly generate with numpy then sort with torch + _pos_is_gts = [ + rng.randint(0, 2, (npos, )).astype(np.uint8) for npos in pos_per_img + ] + pos_is_gts = [ + torch.from_numpy(p).sort(descending=True)[0] for p in _pos_is_gts + ] + return rois, labels, bbox_preds, pos_is_gts, img_metas diff --git a/cv/instance_segmentation/SOLO/pytorch/tests/test_nms.py b/cv/instance_segmentation/SOLO/pytorch/tests/test_nms.py new file mode 100644 index 000000000..6861f1e59 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tests/test_nms.py @@ -0,0 +1,70 @@ +""" +CommandLine: + pytest tests/test_nms.py +""" +import numpy as np +import torch + +from mmdet.ops.nms.nms_wrapper import nms + + +def test_nms_device_and_dtypes_cpu(): + """ + CommandLine: + xdoctest -m tests/test_nms.py test_nms_device_and_dtypes_cpu + """ + iou_thr = 0.7 + base_dets = np.array([[49.1, 32.4, 51.0, 35.9, 0.9], + [49.3, 32.9, 51.0, 35.3, 0.9], + [35.3, 11.5, 39.9, 14.5, 0.4], + [35.2, 11.7, 39.7, 15.7, 0.3]]) + + # CPU can handle float32 and float64 + dets = base_dets.astype(np.float32) + supressed, inds = nms(dets, iou_thr) + assert dets.dtype == supressed.dtype + assert len(inds) == len(supressed) == 3 + + dets = torch.FloatTensor(base_dets) + surpressed, inds = nms(dets, iou_thr) + assert dets.dtype == surpressed.dtype + assert len(inds) == len(surpressed) == 3 + + dets = base_dets.astype(np.float64) + supressed, inds = nms(dets, iou_thr) + assert dets.dtype == supressed.dtype + assert len(inds) == len(supressed) == 3 + + dets = torch.DoubleTensor(base_dets) + surpressed, inds = nms(dets, iou_thr) + assert dets.dtype == surpressed.dtype + assert len(inds) == len(surpressed) == 3 + + +def test_nms_device_and_dtypes_gpu(): + """ + CommandLine: + xdoctest -m tests/test_nms.py test_nms_device_and_dtypes_gpu + """ + if not torch.cuda.is_available(): + import pytest + pytest.skip('test requires GPU and torch+cuda') + + iou_thr = 0.7 + base_dets = np.array([[49.1, 32.4, 51.0, 35.9, 0.9], + [49.3, 32.9, 51.0, 35.3, 0.9], + [35.3, 11.5, 39.9, 14.5, 0.4], + [35.2, 11.7, 39.7, 15.7, 0.3]]) + + for device_id in range(torch.cuda.device_count()): + print('Run NMS on device_id = {!r}'.format(device_id)) + # GPU can handle float32 but not float64 + dets = base_dets.astype(np.float32) + supressed, inds = nms(dets, iou_thr, device_id) + assert dets.dtype == supressed.dtype + assert len(inds) == len(supressed) == 3 + + dets = torch.FloatTensor(base_dets).to(device_id) + surpressed, inds = nms(dets, iou_thr) + assert dets.dtype == surpressed.dtype + assert len(inds) == len(surpressed) == 3 diff --git a/cv/instance_segmentation/SOLO/pytorch/tests/test_sampler.py b/cv/instance_segmentation/SOLO/pytorch/tests/test_sampler.py new file mode 100644 index 000000000..c75360268 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tests/test_sampler.py @@ -0,0 +1,249 @@ +import torch + +from mmdet.core import MaxIoUAssigner +from mmdet.core.bbox.samplers import OHEMSampler, RandomSampler + + +def test_random_sampler(): + assigner = MaxIoUAssigner( + pos_iou_thr=0.5, + neg_iou_thr=0.5, + ignore_iof_thr=0.5, + ignore_wrt_candidates=False, + ) + bboxes = torch.FloatTensor([ + [0, 0, 10, 10], + [10, 10, 20, 20], + [5, 5, 15, 15], + [32, 32, 38, 42], + ]) + gt_bboxes = torch.FloatTensor([ + [0, 0, 10, 9], + [0, 10, 10, 19], + ]) + gt_labels = torch.LongTensor([1, 2]) + gt_bboxes_ignore = torch.Tensor([ + [30, 30, 40, 40], + ]) + assign_result = assigner.assign( + bboxes, + gt_bboxes, + gt_bboxes_ignore=gt_bboxes_ignore, + gt_labels=gt_labels) + + sampler = RandomSampler( + num=10, pos_fraction=0.5, neg_pos_ub=-1, add_gt_as_proposals=True) + + sample_result = sampler.sample(assign_result, bboxes, gt_bboxes, gt_labels) + + assert len(sample_result.pos_bboxes) == len(sample_result.pos_inds) + assert len(sample_result.neg_bboxes) == len(sample_result.neg_inds) + + +def test_random_sampler_empty_gt(): + assigner = MaxIoUAssigner( + pos_iou_thr=0.5, + neg_iou_thr=0.5, + ignore_iof_thr=0.5, + ignore_wrt_candidates=False, + ) + bboxes = torch.FloatTensor([ + [0, 0, 10, 10], + [10, 10, 20, 20], + [5, 5, 15, 15], + [32, 32, 38, 42], + ]) + gt_bboxes = torch.empty(0, 4) + gt_labels = torch.empty(0, ).long() + assign_result = assigner.assign(bboxes, gt_bboxes, gt_labels=gt_labels) + + sampler = RandomSampler( + num=10, pos_fraction=0.5, neg_pos_ub=-1, add_gt_as_proposals=True) + + sample_result = sampler.sample(assign_result, bboxes, gt_bboxes, gt_labels) + + assert len(sample_result.pos_bboxes) == len(sample_result.pos_inds) + assert len(sample_result.neg_bboxes) == len(sample_result.neg_inds) + + +def test_random_sampler_empty_pred(): + assigner = MaxIoUAssigner( + pos_iou_thr=0.5, + neg_iou_thr=0.5, + ignore_iof_thr=0.5, + ignore_wrt_candidates=False, + ) + bboxes = torch.empty(0, 4) + gt_bboxes = torch.FloatTensor([ + [0, 0, 10, 9], + [0, 10, 10, 19], + ]) + gt_labels = torch.LongTensor([1, 2]) + assign_result = assigner.assign(bboxes, gt_bboxes, gt_labels=gt_labels) + + sampler = RandomSampler( + num=10, pos_fraction=0.5, neg_pos_ub=-1, add_gt_as_proposals=True) + + sample_result = sampler.sample(assign_result, bboxes, gt_bboxes, gt_labels) + + assert len(sample_result.pos_bboxes) == len(sample_result.pos_inds) + assert len(sample_result.neg_bboxes) == len(sample_result.neg_inds) + + +def _context_for_ohem(): + try: + from test_forward import _get_detector_cfg + except ImportError: + # Hack: grab testing utils from test_forward to make a context for ohem + import sys + from os.path import dirname + sys.path.insert(0, dirname(__file__)) + from test_forward import _get_detector_cfg + model, train_cfg, test_cfg = _get_detector_cfg( + 'faster_rcnn_ohem_r50_fpn_1x.py') + model['pretrained'] = None + # torchvision roi align supports CPU + model['bbox_roi_extractor']['roi_layer']['use_torchvision'] = True + from mmdet.models import build_detector + context = build_detector(model, train_cfg=train_cfg, test_cfg=test_cfg) + return context + + +def test_ohem_sampler(): + + assigner = MaxIoUAssigner( + pos_iou_thr=0.5, + neg_iou_thr=0.5, + ignore_iof_thr=0.5, + ignore_wrt_candidates=False, + ) + bboxes = torch.FloatTensor([ + [0, 0, 10, 10], + [10, 10, 20, 20], + [5, 5, 15, 15], + [32, 32, 38, 42], + ]) + gt_bboxes = torch.FloatTensor([ + [0, 0, 10, 9], + [0, 10, 10, 19], + ]) + gt_labels = torch.LongTensor([1, 2]) + gt_bboxes_ignore = torch.Tensor([ + [30, 30, 40, 40], + ]) + assign_result = assigner.assign( + bboxes, + gt_bboxes, + gt_bboxes_ignore=gt_bboxes_ignore, + gt_labels=gt_labels) + + context = _context_for_ohem() + + sampler = OHEMSampler( + num=10, + pos_fraction=0.5, + context=context, + neg_pos_ub=-1, + add_gt_as_proposals=True) + + feats = [torch.rand(1, 256, int(2**i), int(2**i)) for i in [6, 5, 4, 3, 2]] + sample_result = sampler.sample( + assign_result, bboxes, gt_bboxes, gt_labels, feats=feats) + + assert len(sample_result.pos_bboxes) == len(sample_result.pos_inds) + assert len(sample_result.neg_bboxes) == len(sample_result.neg_inds) + + +def test_ohem_sampler_empty_gt(): + + assigner = MaxIoUAssigner( + pos_iou_thr=0.5, + neg_iou_thr=0.5, + ignore_iof_thr=0.5, + ignore_wrt_candidates=False, + ) + bboxes = torch.FloatTensor([ + [0, 0, 10, 10], + [10, 10, 20, 20], + [5, 5, 15, 15], + [32, 32, 38, 42], + ]) + gt_bboxes = torch.empty(0, 4) + gt_labels = torch.LongTensor([]) + gt_bboxes_ignore = torch.Tensor([]) + assign_result = assigner.assign( + bboxes, + gt_bboxes, + gt_bboxes_ignore=gt_bboxes_ignore, + gt_labels=gt_labels) + + context = _context_for_ohem() + + sampler = OHEMSampler( + num=10, + pos_fraction=0.5, + context=context, + neg_pos_ub=-1, + add_gt_as_proposals=True) + + feats = [torch.rand(1, 256, int(2**i), int(2**i)) for i in [6, 5, 4, 3, 2]] + + sample_result = sampler.sample( + assign_result, bboxes, gt_bboxes, gt_labels, feats=feats) + + assert len(sample_result.pos_bboxes) == len(sample_result.pos_inds) + assert len(sample_result.neg_bboxes) == len(sample_result.neg_inds) + + +def test_ohem_sampler_empty_pred(): + assigner = MaxIoUAssigner( + pos_iou_thr=0.5, + neg_iou_thr=0.5, + ignore_iof_thr=0.5, + ignore_wrt_candidates=False, + ) + bboxes = torch.empty(0, 4) + gt_bboxes = torch.FloatTensor([ + [0, 0, 10, 10], + [10, 10, 20, 20], + [5, 5, 15, 15], + [32, 32, 38, 42], + ]) + gt_labels = torch.LongTensor([1, 2, 2, 3]) + gt_bboxes_ignore = torch.Tensor([]) + assign_result = assigner.assign( + bboxes, + gt_bboxes, + gt_bboxes_ignore=gt_bboxes_ignore, + gt_labels=gt_labels) + + context = _context_for_ohem() + + sampler = OHEMSampler( + num=10, + pos_fraction=0.5, + context=context, + neg_pos_ub=-1, + add_gt_as_proposals=True) + + feats = [torch.rand(1, 256, int(2**i), int(2**i)) for i in [6, 5, 4, 3, 2]] + + sample_result = sampler.sample( + assign_result, bboxes, gt_bboxes, gt_labels, feats=feats) + + assert len(sample_result.pos_bboxes) == len(sample_result.pos_inds) + assert len(sample_result.neg_bboxes) == len(sample_result.neg_inds) + + +def test_random_sample_result(): + from mmdet.core.bbox.samplers.sampling_result import SamplingResult + SamplingResult.random(num_gts=0, num_preds=0) + SamplingResult.random(num_gts=0, num_preds=3) + SamplingResult.random(num_gts=3, num_preds=3) + SamplingResult.random(num_gts=0, num_preds=3) + SamplingResult.random(num_gts=7, num_preds=7) + SamplingResult.random(num_gts=7, num_preds=64) + SamplingResult.random(num_gts=24, num_preds=3) + + for i in range(3): + SamplingResult.random(rng=i) diff --git a/cv/instance_segmentation/SOLO/pytorch/tests/test_utils.py b/cv/instance_segmentation/SOLO/pytorch/tests/test_utils.py new file mode 100644 index 000000000..cdefd2df2 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tests/test_utils.py @@ -0,0 +1,9 @@ +import numpy.testing as npt + +from mmdet.utils.flops_counter import params_to_string + + +def test_params_to_string(): + npt.assert_equal(params_to_string(1e9), '1000.0 M') + npt.assert_equal(params_to_string(2e5), '200.0 k') + npt.assert_equal(params_to_string(3e-9), '3e-09') diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/analyze_logs.py b/cv/instance_segmentation/SOLO/pytorch/tools/analyze_logs.py new file mode 100644 index 000000000..2810c98f1 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/analyze_logs.py @@ -0,0 +1,178 @@ +import argparse +import json +from collections import defaultdict + +import matplotlib.pyplot as plt +import numpy as np +import seaborn as sns + + +def cal_train_time(log_dicts, args): + for i, log_dict in enumerate(log_dicts): + print('{}Analyze train time of {}{}'.format('-' * 5, args.json_logs[i], + '-' * 5)) + all_times = [] + for epoch in log_dict.keys(): + if args.include_outliers: + all_times.append(log_dict[epoch]['time']) + else: + all_times.append(log_dict[epoch]['time'][1:]) + all_times = np.array(all_times) + epoch_ave_time = all_times.mean(-1) + slowest_epoch = epoch_ave_time.argmax() + fastest_epoch = epoch_ave_time.argmin() + std_over_epoch = epoch_ave_time.std() + print('slowest epoch {}, average time is {:.4f}'.format( + slowest_epoch + 1, epoch_ave_time[slowest_epoch])) + print('fastest epoch {}, average time is {:.4f}'.format( + fastest_epoch + 1, epoch_ave_time[fastest_epoch])) + print('time std over epochs is {:.4f}'.format(std_over_epoch)) + print('average iter time: {:.4f} s/iter'.format(np.mean(all_times))) + print() + + +def plot_curve(log_dicts, args): + if args.backend is not None: + plt.switch_backend(args.backend) + sns.set_style(args.style) + # if legend is None, use {filename}_{key} as legend + legend = args.legend + if legend is None: + legend = [] + for json_log in args.json_logs: + for metric in args.keys: + legend.append('{}_{}'.format(json_log, metric)) + assert len(legend) == (len(args.json_logs) * len(args.keys)) + metrics = args.keys + + num_metrics = len(metrics) + for i, log_dict in enumerate(log_dicts): + epochs = list(log_dict.keys()) + for j, metric in enumerate(metrics): + print('plot curve of {}, metric is {}'.format( + args.json_logs[i], metric)) + if metric not in log_dict[epochs[0]]: + raise KeyError('{} does not contain metric {}'.format( + args.json_logs[i], metric)) + + if 'mAP' in metric: + xs = np.arange(1, max(epochs) + 1) + ys = [] + for epoch in epochs: + ys += log_dict[epoch][metric] + ax = plt.gca() + ax.set_xticks(xs) + plt.xlabel('epoch') + plt.plot(xs, ys, label=legend[i * num_metrics + j], marker='o') + else: + xs = [] + ys = [] + num_iters_per_epoch = log_dict[epochs[0]]['iter'][-1] + for epoch in epochs: + iters = log_dict[epoch]['iter'] + if log_dict[epoch]['mode'][-1] == 'val': + iters = iters[:-1] + xs.append( + np.array(iters) + (epoch - 1) * num_iters_per_epoch) + ys.append(np.array(log_dict[epoch][metric][:len(iters)])) + xs = np.concatenate(xs) + ys = np.concatenate(ys) + plt.xlabel('iter') + plt.plot( + xs, ys, label=legend[i * num_metrics + j], linewidth=0.5) + plt.legend() + if args.title is not None: + plt.title(args.title) + if args.out is None: + plt.show() + else: + print('save curve to: {}'.format(args.out)) + plt.savefig(args.out) + plt.cla() + + +def add_plot_parser(subparsers): + parser_plt = subparsers.add_parser( + 'plot_curve', help='parser for plotting curves') + parser_plt.add_argument( + 'json_logs', + type=str, + nargs='+', + help='path of train log in json format') + parser_plt.add_argument( + '--keys', + type=str, + nargs='+', + default=['bbox_mAP'], + help='the metric that you want to plot') + parser_plt.add_argument('--title', type=str, help='title of figure') + parser_plt.add_argument( + '--legend', + type=str, + nargs='+', + default=None, + help='legend of each plot') + parser_plt.add_argument( + '--backend', type=str, default=None, help='backend of plt') + parser_plt.add_argument( + '--style', type=str, default='dark', help='style of plt') + parser_plt.add_argument('--out', type=str, default=None) + + +def add_time_parser(subparsers): + parser_time = subparsers.add_parser( + 'cal_train_time', + help='parser for computing the average time per training iteration') + parser_time.add_argument( + 'json_logs', + type=str, + nargs='+', + help='path of train log in json format') + parser_time.add_argument( + '--include-outliers', + action='store_true', + help='include the first value of every epoch when computing ' + 'the average time') + + +def parse_args(): + parser = argparse.ArgumentParser(description='Analyze Json Log') + # currently only support plot curve and calculate average train time + subparsers = parser.add_subparsers(dest='task', help='task parser') + add_plot_parser(subparsers) + add_time_parser(subparsers) + args = parser.parse_args() + return args + + +def load_json_logs(json_logs): + # load and convert json_logs to log_dict, key is epoch, value is a sub dict + # keys of sub dict is different metrics, e.g. memory, bbox_mAP + # value of sub dict is a list of corresponding values of all iterations + log_dicts = [dict() for _ in json_logs] + for json_log, log_dict in zip(json_logs, log_dicts): + with open(json_log, 'r') as log_file: + for l in log_file: + log = json.loads(l.strip()) + epoch = log.pop('epoch') + if epoch not in log_dict: + log_dict[epoch] = defaultdict(list) + for k, v in log.items(): + log_dict[epoch][k].append(v) + return log_dicts + + +def main(): + args = parse_args() + + json_logs = args.json_logs + for json_log in json_logs: + assert json_log.endswith('.json') + + log_dicts = load_json_logs(json_logs) + + eval(args.task)(log_dicts, args) + + +if __name__ == '__main__': + main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/coco_error_analysis.py b/cv/instance_segmentation/SOLO/pytorch/tools/coco_error_analysis.py new file mode 100644 index 000000000..6aeadadb9 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/coco_error_analysis.py @@ -0,0 +1,174 @@ +import copy +import os +from argparse import ArgumentParser +from multiprocessing import Pool + +import matplotlib.pyplot as plt +import numpy as np +from pycocotools.coco import COCO +from pycocotools.cocoeval import COCOeval + + +def makeplot(rs, ps, outDir, class_name, iou_type): + cs = np.vstack([ + np.ones((2, 3)), + np.array([.31, .51, .74]), + np.array([.75, .31, .30]), + np.array([.36, .90, .38]), + np.array([.50, .39, .64]), + np.array([1, .6, 0]) + ]) + areaNames = ['allarea', 'small', 'medium', 'large'] + types = ['C75', 'C50', 'Loc', 'Sim', 'Oth', 'BG', 'FN'] + for i in range(len(areaNames)): + area_ps = ps[..., i, 0] + figure_tile = iou_type + '-' + class_name + '-' + areaNames[i] + aps = [ps_.mean() for ps_ in area_ps] + ps_curve = [ + ps_.mean(axis=1) if ps_.ndim > 1 else ps_ for ps_ in area_ps + ] + ps_curve.insert(0, np.zeros(ps_curve[0].shape)) + fig = plt.figure() + ax = plt.subplot(111) + for k in range(len(types)): + ax.plot(rs, ps_curve[k + 1], color=[0, 0, 0], linewidth=0.5) + ax.fill_between( + rs, + ps_curve[k], + ps_curve[k + 1], + color=cs[k], + label=str('[{:.3f}'.format(aps[k]) + ']' + types[k])) + plt.xlabel('recall') + plt.ylabel('precision') + plt.xlim(0, 1.) + plt.ylim(0, 1.) + plt.title(figure_tile) + plt.legend() + # plt.show() + fig.savefig(outDir + '/{}.png'.format(figure_tile)) + plt.close(fig) + + +def analyze_individual_category(k, cocoDt, cocoGt, catId, iou_type): + nm = cocoGt.loadCats(catId)[0] + print('--------------analyzing {}-{}---------------'.format( + k + 1, nm['name'])) + ps_ = {} + dt = copy.deepcopy(cocoDt) + nm = cocoGt.loadCats(catId)[0] + imgIds = cocoGt.getImgIds() + dt_anns = dt.dataset['annotations'] + select_dt_anns = [] + for ann in dt_anns: + if ann['category_id'] == catId: + select_dt_anns.append(ann) + dt.dataset['annotations'] = select_dt_anns + dt.createIndex() + # compute precision but ignore superclass confusion + gt = copy.deepcopy(cocoGt) + child_catIds = gt.getCatIds(supNms=[nm['supercategory']]) + for idx, ann in enumerate(gt.dataset['annotations']): + if (ann['category_id'] in child_catIds + and ann['category_id'] != catId): + gt.dataset['annotations'][idx]['ignore'] = 1 + gt.dataset['annotations'][idx]['iscrowd'] = 1 + gt.dataset['annotations'][idx]['category_id'] = catId + cocoEval = COCOeval(gt, copy.deepcopy(dt), iou_type) + cocoEval.params.imgIds = imgIds + cocoEval.params.maxDets = [100] + cocoEval.params.iouThrs = [.1] + cocoEval.params.useCats = 1 + cocoEval.evaluate() + cocoEval.accumulate() + ps_supercategory = cocoEval.eval['precision'][0, :, k, :, :] + ps_['ps_supercategory'] = ps_supercategory + # compute precision but ignore any class confusion + gt = copy.deepcopy(cocoGt) + for idx, ann in enumerate(gt.dataset['annotations']): + if ann['category_id'] != catId: + gt.dataset['annotations'][idx]['ignore'] = 1 + gt.dataset['annotations'][idx]['iscrowd'] = 1 + gt.dataset['annotations'][idx]['category_id'] = catId + cocoEval = COCOeval(gt, copy.deepcopy(dt), iou_type) + cocoEval.params.imgIds = imgIds + cocoEval.params.maxDets = [100] + cocoEval.params.iouThrs = [.1] + cocoEval.params.useCats = 1 + cocoEval.evaluate() + cocoEval.accumulate() + ps_allcategory = cocoEval.eval['precision'][0, :, k, :, :] + ps_['ps_allcategory'] = ps_allcategory + return k, ps_ + + +def analyze_results(res_file, ann_file, res_types, out_dir): + for res_type in res_types: + assert res_type in ['bbox', 'segm'] + + directory = os.path.dirname(out_dir + '/') + if not os.path.exists(directory): + print('-------------create {}-----------------'.format(out_dir)) + os.makedirs(directory) + + cocoGt = COCO(ann_file) + cocoDt = cocoGt.loadRes(res_file) + imgIds = cocoGt.getImgIds() + for res_type in res_types: + res_out_dir = out_dir + '/' + res_type + '/' + res_directory = os.path.dirname(res_out_dir) + if not os.path.exists(res_directory): + print( + '-------------create {}-----------------'.format(res_out_dir)) + os.makedirs(res_directory) + iou_type = res_type + cocoEval = COCOeval( + copy.deepcopy(cocoGt), copy.deepcopy(cocoDt), iou_type) + cocoEval.params.imgIds = imgIds + cocoEval.params.iouThrs = [.75, .5, .1] + cocoEval.params.maxDets = [100] + cocoEval.evaluate() + cocoEval.accumulate() + ps = cocoEval.eval['precision'] + ps = np.vstack([ps, np.zeros((4, *ps.shape[1:]))]) + catIds = cocoGt.getCatIds() + recThrs = cocoEval.params.recThrs + with Pool(processes=48) as pool: + args = [(k, cocoDt, cocoGt, catId, iou_type) + for k, catId in enumerate(catIds)] + analyze_results = pool.starmap(analyze_individual_category, args) + for k, catId in enumerate(catIds): + nm = cocoGt.loadCats(catId)[0] + print('--------------saving {}-{}---------------'.format( + k + 1, nm['name'])) + analyze_result = analyze_results[k] + assert k == analyze_result[0] + ps_supercategory = analyze_result[1]['ps_supercategory'] + ps_allcategory = analyze_result[1]['ps_allcategory'] + # compute precision but ignore superclass confusion + ps[3, :, k, :, :] = ps_supercategory + # compute precision but ignore any class confusion + ps[4, :, k, :, :] = ps_allcategory + # fill in background and false negative errors and plot + ps[ps == -1] = 0 + ps[5, :, k, :, :] = (ps[4, :, k, :, :] > 0) + ps[6, :, k, :, :] = 1.0 + makeplot(recThrs, ps[:, :, k], res_out_dir, nm['name'], iou_type) + makeplot(recThrs, ps, res_out_dir, 'allclass', iou_type) + + +def main(): + parser = ArgumentParser(description='COCO Error Analysis Tool') + parser.add_argument('result', help='result file (json format) path') + parser.add_argument('out_dir', help='dir to save analyze result images') + parser.add_argument( + '--ann', + default='data/coco/annotations/instances_val2017.json', + help='annotation file path') + parser.add_argument( + '--types', type=str, nargs='+', default=['bbox'], help='result types') + args = parser.parse_args() + analyze_results(args.result, args.ann, args.types, out_dir=args.out_dir) + + +if __name__ == '__main__': + main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/coco_eval.py b/cv/instance_segmentation/SOLO/pytorch/tools/coco_eval.py new file mode 100644 index 000000000..bc3c96b3c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/coco_eval.py @@ -0,0 +1,30 @@ +from argparse import ArgumentParser + +from mmdet.core import coco_eval + + +def main(): + parser = ArgumentParser(description='COCO Evaluation') + parser.add_argument('result', help='result file path') + parser.add_argument('--ann', help='annotation file path') + parser.add_argument( + '--types', + type=str, + nargs='+', + choices=['proposal_fast', 'proposal', 'bbox', 'segm', 'keypoint'], + default=['bbox'], + help='result types') + parser.add_argument( + '--max-dets', + type=int, + nargs='+', + default=[100, 300, 1000], + help='proposal numbers, only used for recall evaluation') + parser.add_argument( + '--classwise', action='store_true', help='whether eval class wise ap') + args = parser.parse_args() + coco_eval(args.result, args.types, args.ann, args.max_dets, args.classwise) + + +if __name__ == '__main__': + main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/collect_env.py b/cv/instance_segmentation/SOLO/pytorch/tools/collect_env.py new file mode 100644 index 000000000..81d6c7aaa --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/collect_env.py @@ -0,0 +1,64 @@ +import os.path as osp +import subprocess +import sys +from collections import defaultdict + +import cv2 +import mmcv +import torch +import torchvision + +import mmdet +from mmdet.ops import get_compiler_version, get_compiling_cuda_version + + +def collect_env(): + env_info = {} + env_info['sys.platform'] = sys.platform + env_info['Python'] = sys.version.replace('\n', '') + + cuda_available = torch.cuda.is_available() + env_info['CUDA available'] = cuda_available + + if cuda_available: + from torch.utils.cpp_extension import CUDA_HOME + env_info['CUDA_HOME'] = CUDA_HOME + + if CUDA_HOME is not None and osp.isdir(CUDA_HOME): + try: + nvcc = osp.join(CUDA_HOME, 'bin/nvcc') + nvcc = subprocess.check_output( + '"{}" -V | tail -n1'.format(nvcc), shell=True) + nvcc = nvcc.decode('utf-8').strip() + except subprocess.SubprocessError: + nvcc = 'Not Available' + env_info['NVCC'] = nvcc + + devices = defaultdict(list) + for k in range(torch.cuda.device_count()): + devices[torch.cuda.get_device_name(k)].append(str(k)) + for name, devids in devices.items(): + env_info['GPU ' + ','.join(devids)] = name + + gcc = subprocess.check_output('gcc --version | head -n1', shell=True) + gcc = gcc.decode('utf-8').strip() + env_info['GCC'] = gcc + + env_info['PyTorch'] = torch.__version__ + env_info['PyTorch compiling details'] = torch.__config__.show() + + env_info['TorchVision'] = torchvision.__version__ + + env_info['OpenCV'] = cv2.__version__ + + env_info['MMCV'] = mmcv.__version__ + env_info['MMDetection'] = mmdet.__version__ + env_info['MMDetection Compiler'] = get_compiler_version() + env_info['MMDetection CUDA Compiler'] = get_compiling_cuda_version() + + for name, val in env_info.items(): + print('{}: {}'.format(name, val)) + + +if __name__ == "__main__": + collect_env() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/convert_datasets/pascal_voc.py b/cv/instance_segmentation/SOLO/pytorch/tools/convert_datasets/pascal_voc.py new file mode 100644 index 000000000..029eeb0a9 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/convert_datasets/pascal_voc.py @@ -0,0 +1,141 @@ +import argparse +import os.path as osp +import xml.etree.ElementTree as ET + +import mmcv +import numpy as np + +from mmdet.core import voc_classes + +label_ids = {name: i + 1 for i, name in enumerate(voc_classes())} + + +def parse_xml(args): + xml_path, img_path = args + tree = ET.parse(xml_path) + root = tree.getroot() + size = root.find('size') + w = int(size.find('width').text) + h = int(size.find('height').text) + bboxes = [] + labels = [] + bboxes_ignore = [] + labels_ignore = [] + for obj in root.findall('object'): + name = obj.find('name').text + label = label_ids[name] + difficult = int(obj.find('difficult').text) + bnd_box = obj.find('bndbox') + bbox = [ + int(bnd_box.find('xmin').text), + int(bnd_box.find('ymin').text), + int(bnd_box.find('xmax').text), + int(bnd_box.find('ymax').text) + ] + if difficult: + bboxes_ignore.append(bbox) + labels_ignore.append(label) + else: + bboxes.append(bbox) + labels.append(label) + if not bboxes: + bboxes = np.zeros((0, 4)) + labels = np.zeros((0, )) + else: + bboxes = np.array(bboxes, ndmin=2) - 1 + labels = np.array(labels) + if not bboxes_ignore: + bboxes_ignore = np.zeros((0, 4)) + labels_ignore = np.zeros((0, )) + else: + bboxes_ignore = np.array(bboxes_ignore, ndmin=2) - 1 + labels_ignore = np.array(labels_ignore) + annotation = { + 'filename': img_path, + 'width': w, + 'height': h, + 'ann': { + 'bboxes': bboxes.astype(np.float32), + 'labels': labels.astype(np.int64), + 'bboxes_ignore': bboxes_ignore.astype(np.float32), + 'labels_ignore': labels_ignore.astype(np.int64) + } + } + return annotation + + +def cvt_annotations(devkit_path, years, split, out_file): + if not isinstance(years, list): + years = [years] + annotations = [] + for year in years: + filelist = osp.join(devkit_path, + 'VOC{}/ImageSets/Main/{}.txt'.format(year, split)) + if not osp.isfile(filelist): + print('filelist does not exist: {}, skip voc{} {}'.format( + filelist, year, split)) + return + img_names = mmcv.list_from_file(filelist) + xml_paths = [ + osp.join(devkit_path, + 'VOC{}/Annotations/{}.xml'.format(year, img_name)) + for img_name in img_names + ] + img_paths = [ + 'VOC{}/JPEGImages/{}.jpg'.format(year, img_name) + for img_name in img_names + ] + part_annotations = mmcv.track_progress(parse_xml, + list(zip(xml_paths, img_paths))) + annotations.extend(part_annotations) + mmcv.dump(annotations, out_file) + return annotations + + +def parse_args(): + parser = argparse.ArgumentParser( + description='Convert PASCAL VOC annotations to mmdetection format') + parser.add_argument('devkit_path', help='pascal voc devkit path') + parser.add_argument('-o', '--out-dir', help='output path') + args = parser.parse_args() + return args + + +def main(): + args = parse_args() + devkit_path = args.devkit_path + out_dir = args.out_dir if args.out_dir else devkit_path + mmcv.mkdir_or_exist(out_dir) + + years = [] + if osp.isdir(osp.join(devkit_path, 'VOC2007')): + years.append('2007') + if osp.isdir(osp.join(devkit_path, 'VOC2012')): + years.append('2012') + if '2007' in years and '2012' in years: + years.append(['2007', '2012']) + if not years: + raise IOError('The devkit path {} contains neither "VOC2007" nor ' + '"VOC2012" subfolder'.format(devkit_path)) + for year in years: + if year == '2007': + prefix = 'voc07' + elif year == '2012': + prefix = 'voc12' + elif year == ['2007', '2012']: + prefix = 'voc0712' + for split in ['train', 'val', 'trainval']: + dataset_name = prefix + '_' + split + print('processing {} ...'.format(dataset_name)) + cvt_annotations(devkit_path, year, split, + osp.join(out_dir, dataset_name + '.pkl')) + if not isinstance(year, list): + dataset_name = prefix + '_test' + print('processing {} ...'.format(dataset_name)) + cvt_annotations(devkit_path, year, 'test', + osp.join(out_dir, dataset_name + '.pkl')) + print('Done!') + + +if __name__ == '__main__': + main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/detectron2pytorch.py b/cv/instance_segmentation/SOLO/pytorch/tools/detectron2pytorch.py new file mode 100644 index 000000000..0a90ad172 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/detectron2pytorch.py @@ -0,0 +1,88 @@ +import argparse +from collections import OrderedDict + +import mmcv +import torch + +arch_settings = {50: (3, 4, 6, 3), 101: (3, 4, 23, 3)} + + +def convert_bn(blobs, state_dict, caffe_name, torch_name, converted_names): + # detectron replace bn with affine channel layer + state_dict[torch_name + '.bias'] = torch.from_numpy(blobs[caffe_name + + '_b']) + state_dict[torch_name + '.weight'] = torch.from_numpy(blobs[caffe_name + + '_s']) + bn_size = state_dict[torch_name + '.weight'].size() + state_dict[torch_name + '.running_mean'] = torch.zeros(bn_size) + state_dict[torch_name + '.running_var'] = torch.ones(bn_size) + converted_names.add(caffe_name + '_b') + converted_names.add(caffe_name + '_s') + + +def convert_conv_fc(blobs, state_dict, caffe_name, torch_name, + converted_names): + state_dict[torch_name + '.weight'] = torch.from_numpy(blobs[caffe_name + + '_w']) + converted_names.add(caffe_name + '_w') + if caffe_name + '_b' in blobs: + state_dict[torch_name + '.bias'] = torch.from_numpy(blobs[caffe_name + + '_b']) + converted_names.add(caffe_name + '_b') + + +def convert(src, dst, depth): + """Convert keys in detectron pretrained ResNet models to pytorch style.""" + # load arch_settings + if depth not in arch_settings: + raise ValueError('Only support ResNet-50 and ResNet-101 currently') + block_nums = arch_settings[depth] + # load caffe model + caffe_model = mmcv.load(src, encoding='latin1') + blobs = caffe_model['blobs'] if 'blobs' in caffe_model else caffe_model + # convert to pytorch style + state_dict = OrderedDict() + converted_names = set() + convert_conv_fc(blobs, state_dict, 'conv1', 'conv1', converted_names) + convert_bn(blobs, state_dict, 'res_conv1_bn', 'bn1', converted_names) + for i in range(1, len(block_nums) + 1): + for j in range(block_nums[i - 1]): + if j == 0: + convert_conv_fc(blobs, state_dict, + 'res{}_{}_branch1'.format(i + 1, j), + 'layer{}.{}.downsample.0'.format(i, j), + converted_names) + convert_bn(blobs, state_dict, + 'res{}_{}_branch1_bn'.format(i + 1, j), + 'layer{}.{}.downsample.1'.format(i, j), + converted_names) + for k, letter in enumerate(['a', 'b', 'c']): + convert_conv_fc(blobs, state_dict, + 'res{}_{}_branch2{}'.format(i + 1, j, letter), + 'layer{}.{}.conv{}'.format(i, j, k + 1), + converted_names) + convert_bn(blobs, state_dict, + 'res{}_{}_branch2{}_bn'.format(i + 1, j, letter), + 'layer{}.{}.bn{}'.format(i, j, + k + 1), converted_names) + # check if all layers are converted + for key in blobs: + if key not in converted_names: + print('Not Convert: {}'.format(key)) + # save checkpoint + checkpoint = dict() + checkpoint['state_dict'] = state_dict + torch.save(checkpoint, dst) + + +def main(): + parser = argparse.ArgumentParser(description='Convert model keys') + parser.add_argument('src', help='src detectron model path') + parser.add_argument('dst', help='save path') + parser.add_argument('depth', type=int, help='ResNet model depth') + args = parser.parse_args() + convert(args.src, args.dst, args.depth) + + +if __name__ == '__main__': + main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/dist_test.sh b/cv/instance_segmentation/SOLO/pytorch/tools/dist_test.sh new file mode 100644 index 000000000..efab6ea27 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/dist_test.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +PYTHON=${PYTHON:-"python"} + +CONFIG=$1 +CHECKPOINT=$2 +GPUS=$3 +PORT=${PORT:-29500} + +$PYTHON -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \ + $(dirname "$0")/test_ins.py $CONFIG $CHECKPOINT --launcher pytorch ${@:4} diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/dist_train.sh b/cv/instance_segmentation/SOLO/pytorch/tools/dist_train.sh new file mode 100644 index 000000000..0b8adf711 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/dist_train.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +CONFIG=$1 +GPUS=$2 +PORT=${PORT:-29500} + +python3 -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \ + $(dirname "$0")/train.py $CONFIG --launcher pytorch ${@:3} diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/get_flops.py b/cv/instance_segmentation/SOLO/pytorch/tools/get_flops.py new file mode 100644 index 000000000..6c9cb2340 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/get_flops.py @@ -0,0 +1,55 @@ +import argparse + +from mmcv import Config + +from mmdet.models import build_detector +from mmdet.utils import get_model_complexity_info + + +def parse_args(): + parser = argparse.ArgumentParser(description='Train a detector') + parser.add_argument('config', help='train config file path') + parser.add_argument( + '--shape', + type=int, + nargs='+', + default=[1280, 800], + help='input image size') + args = parser.parse_args() + return args + + +def main(): + + args = parse_args() + + if len(args.shape) == 1: + input_shape = (3, args.shape[0], args.shape[0]) + elif len(args.shape) == 2: + input_shape = (3, ) + tuple(args.shape) + else: + raise ValueError('invalid input shape') + + cfg = Config.fromfile(args.config) + model = build_detector( + cfg.model, train_cfg=cfg.train_cfg, test_cfg=cfg.test_cfg).cuda() + model.eval() + + if hasattr(model, 'forward_dummy'): + model.forward = model.forward_dummy + else: + raise NotImplementedError( + 'FLOPs counter is currently not currently supported with {}'. + format(model.__class__.__name__)) + + flops, params = get_model_complexity_info(model, input_shape) + split_line = '=' * 30 + print('{0}\nInput shape: {1}\nFlops: {2}\nParams: {3}\n{0}'.format( + split_line, input_shape, flops, params)) + print('!!!Please be cautious if you use the results in papers. ' + 'You may need to check if all ops are supported and verify that the ' + 'flops computation is correct.') + + +if __name__ == '__main__': + main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/publish_model.py b/cv/instance_segmentation/SOLO/pytorch/tools/publish_model.py new file mode 100644 index 000000000..a049f1767 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/publish_model.py @@ -0,0 +1,35 @@ +import argparse +import subprocess + +import torch + + +def parse_args(): + parser = argparse.ArgumentParser( + description='Process a checkpoint to be published') + parser.add_argument('in_file', help='input checkpoint filename') + parser.add_argument('out_file', help='output checkpoint filename') + args = parser.parse_args() + return args + + +def process_checkpoint(in_file, out_file): + checkpoint = torch.load(in_file, map_location='cpu') + # remove optimizer for smaller file size + if 'optimizer' in checkpoint: + del checkpoint['optimizer'] + # if it is necessary to remove some sensitive data in checkpoint['meta'], + # add the code here. + torch.save(checkpoint, out_file) + sha = subprocess.check_output(['sha256sum', out_file]).decode() + final_file = out_file.rstrip('.pth') + '-{}.pth'.format(sha[:8]) + subprocess.Popen(['mv', out_file, final_file]) + + +def main(): + args = parse_args() + process_checkpoint(args.in_file, args.out_file) + + +if __name__ == '__main__': + main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/robustness_eval.py b/cv/instance_segmentation/SOLO/pytorch/tools/robustness_eval.py new file mode 100644 index 000000000..a07aa0159 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/robustness_eval.py @@ -0,0 +1,256 @@ +import os.path as osp +from argparse import ArgumentParser + +import mmcv +import numpy as np + + +def print_coco_results(results): + + def _print(result, ap=1, iouThr=None, areaRng='all', maxDets=100): + iStr = ' {:<18} {} @[ IoU={:<9} | \ + area={:>6s} | maxDets={:>3d} ] = {:0.3f}' + + titleStr = 'Average Precision' if ap == 1 else 'Average Recall' + typeStr = '(AP)' if ap == 1 else '(AR)' + iouStr = '{:0.2f}:{:0.2f}'.format(.5, .95) \ + if iouThr is None else '{:0.2f}'.format(iouThr) + print(iStr.format(titleStr, typeStr, iouStr, areaRng, maxDets, result)) + + stats = np.zeros((12, )) + stats[0] = _print(results[0], 1) + stats[1] = _print(results[1], 1, iouThr=.5) + stats[2] = _print(results[2], 1, iouThr=.75) + stats[3] = _print(results[3], 1, areaRng='small') + stats[4] = _print(results[4], 1, areaRng='medium') + stats[5] = _print(results[5], 1, areaRng='large') + stats[6] = _print(results[6], 0, maxDets=1) + stats[7] = _print(results[7], 0, maxDets=10) + stats[8] = _print(results[8], 0) + stats[9] = _print(results[9], 0, areaRng='small') + stats[10] = _print(results[10], 0, areaRng='medium') + stats[11] = _print(results[11], 0, areaRng='large') + + +def get_coco_style_results(filename, + task='bbox', + metric=None, + prints='mPC', + aggregate='benchmark'): + + assert aggregate in ['benchmark', 'all'] + + if prints == 'all': + prints = ['P', 'mPC', 'rPC'] + elif isinstance(prints, str): + prints = [prints] + for p in prints: + assert p in ['P', 'mPC', 'rPC'] + + if metric is None: + metrics = [ + 'AP', 'AP50', 'AP75', 'APs', 'APm', 'APl', 'AR1', 'AR10', 'AR100', + 'ARs', 'ARm', 'ARl' + ] + elif isinstance(metric, list): + metrics = metric + else: + metrics = [metric] + + for metric_name in metrics: + assert metric_name in [ + 'AP', 'AP50', 'AP75', 'APs', 'APm', 'APl', 'AR1', 'AR10', 'AR100', + 'ARs', 'ARm', 'ARl' + ] + + eval_output = mmcv.load(filename) + + num_distortions = len(list(eval_output.keys())) + results = np.zeros((num_distortions, 6, len(metrics)), dtype='float32') + + for corr_i, distortion in enumerate(eval_output): + for severity in eval_output[distortion]: + for metric_j, metric_name in enumerate(metrics): + mAP = eval_output[distortion][severity][task][metric_name] + results[corr_i, severity, metric_j] = mAP + + P = results[0, 0, :] + if aggregate == 'benchmark': + mPC = np.mean(results[:15, 1:, :], axis=(0, 1)) + else: + mPC = np.mean(results[:, 1:, :], axis=(0, 1)) + rPC = mPC / P + + print('\nmodel: {}'.format(osp.basename(filename))) + if metric is None: + if 'P' in prints: + print('Performance on Clean Data [P] ({})'.format(task)) + print_coco_results(P) + if 'mPC' in prints: + print('Mean Performance under Corruption [mPC] ({})'.format(task)) + print_coco_results(mPC) + if 'rPC' in prints: + print('Realtive Performance under Corruption [rPC] ({})'.format( + task)) + print_coco_results(rPC) + else: + if 'P' in prints: + print('Performance on Clean Data [P] ({})'.format(task)) + for metric_i, metric_name in enumerate(metrics): + print('{:5} = {:0.3f}'.format(metric_name, P[metric_i])) + if 'mPC' in prints: + print('Mean Performance under Corruption [mPC] ({})'.format(task)) + for metric_i, metric_name in enumerate(metrics): + print('{:5} = {:0.3f}'.format(metric_name, mPC[metric_i])) + if 'rPC' in prints: + print('Relative Performance under Corruption [rPC] ({})'.format( + task)) + for metric_i, metric_name in enumerate(metrics): + print('{:5} => {:0.1f} %'.format(metric_name, + rPC[metric_i] * 100)) + + return results + + +def get_voc_style_results(filename, prints='mPC', aggregate='benchmark'): + + assert aggregate in ['benchmark', 'all'] + + if prints == 'all': + prints = ['P', 'mPC', 'rPC'] + elif isinstance(prints, str): + prints = [prints] + for p in prints: + assert p in ['P', 'mPC', 'rPC'] + + eval_output = mmcv.load(filename) + + num_distortions = len(list(eval_output.keys())) + results = np.zeros((num_distortions, 6, 20), dtype='float32') + + for i, distortion in enumerate(eval_output): + for severity in eval_output[distortion]: + mAP = [ + eval_output[distortion][severity][j]['ap'] + for j in range(len(eval_output[distortion][severity])) + ] + results[i, severity, :] = mAP + + P = results[0, 0, :] + if aggregate == 'benchmark': + mPC = np.mean(results[:15, 1:, :], axis=(0, 1)) + else: + mPC = np.mean(results[:, 1:, :], axis=(0, 1)) + rPC = mPC / P + + print('\nmodel: {}'.format(osp.basename(filename))) + if 'P' in prints: + print('{:48} = {:0.3f}'.format('Performance on Clean Data [P] in AP50', + np.mean(P))) + if 'mPC' in prints: + print('{:48} = {:0.3f}'.format( + 'Mean Performance under Corruption [mPC] in AP50', np.mean(mPC))) + if 'rPC' in prints: + print('{:48} = {:0.1f}'.format( + 'Realtive Performance under Corruption [rPC] in %', + np.mean(rPC) * 100)) + + return np.mean(results, axis=2, keepdims=True) + + +def get_results(filename, + dataset='coco', + task='bbox', + metric=None, + prints='mPC', + aggregate='benchmark'): + assert dataset in ['coco', 'voc', 'cityscapes'] + + if dataset in ['coco', 'cityscapes']: + results = get_coco_style_results( + filename, + task=task, + metric=metric, + prints=prints, + aggregate=aggregate) + elif dataset == 'voc': + if task != 'bbox': + print('Only bbox analysis is supported for Pascal VOC') + print('Will report bbox results\n') + if metric not in [None, ['AP'], ['AP50']]: + print('Only the AP50 metric is supported for Pascal VOC') + print('Will report AP50 metric\n') + results = get_voc_style_results( + filename, prints=prints, aggregate=aggregate) + + return results + + +def get_distortions_from_file(filename): + + eval_output = mmcv.load(filename) + + return get_distortions_from_results(eval_output) + + +def get_distortions_from_results(eval_output): + distortions = [] + for i, distortion in enumerate(eval_output): + distortions.append(distortion.replace("_", " ")) + return distortions + + +def main(): + parser = ArgumentParser(description='Corruption Result Analysis') + parser.add_argument('filename', help='result file path') + parser.add_argument( + '--dataset', + type=str, + choices=['coco', 'voc', 'cityscapes'], + default='coco', + help='dataset type') + parser.add_argument( + '--task', + type=str, + nargs='+', + choices=['bbox', 'segm'], + default=['bbox'], + help='task to report') + parser.add_argument( + '--metric', + nargs='+', + choices=[ + None, 'AP', 'AP50', 'AP75', 'APs', 'APm', 'APl', 'AR1', 'AR10', + 'AR100', 'ARs', 'ARm', 'ARl' + ], + default=None, + help='metric to report') + parser.add_argument( + '--prints', + type=str, + nargs='+', + choices=['P', 'mPC', 'rPC'], + default='mPC', + help='corruption benchmark metric to print') + parser.add_argument( + '--aggregate', + type=str, + choices=['all', 'benchmark'], + default='benchmark', + help='aggregate all results or only those \ + for benchmark corruptions') + + args = parser.parse_args() + + for task in args.task: + get_results( + args.filename, + dataset=args.dataset, + task=task, + metric=args.metric, + prints=args.prints, + aggregate=args.aggregate) + + +if __name__ == '__main__': + main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/slurm_test.sh b/cv/instance_segmentation/SOLO/pytorch/tools/slurm_test.sh new file mode 100644 index 000000000..8950bc816 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/slurm_test.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -x + +PARTITION=$1 +JOB_NAME=$2 +CONFIG=$3 +CHECKPOINT=$4 +GPUS=${GPUS:-8} +GPUS_PER_NODE=${GPUS_PER_NODE:-8} +CPUS_PER_TASK=${CPUS_PER_TASK:-5} +PY_ARGS=${@:5} +SRUN_ARGS=${SRUN_ARGS:-""} + +srun -p ${PARTITION} \ + --job-name=${JOB_NAME} \ + --gres=gpu:${GPUS_PER_NODE} \ + --ntasks=${GPUS} \ + --ntasks-per-node=${GPUS_PER_NODE} \ + --cpus-per-task=${CPUS_PER_TASK} \ + --kill-on-bad-exit=1 \ + ${SRUN_ARGS} \ + python -u tools/test.py ${CONFIG} ${CHECKPOINT} --launcher="slurm" ${PY_ARGS} diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/slurm_train.sh b/cv/instance_segmentation/SOLO/pytorch/tools/slurm_train.sh new file mode 100644 index 000000000..45474c46a --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/slurm_train.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -x + +PARTITION=$1 +JOB_NAME=$2 +CONFIG=$3 +WORK_DIR=$4 +GPUS=${5:-8} +GPUS_PER_NODE=${GPUS_PER_NODE:-8} +CPUS_PER_TASK=${CPUS_PER_TASK:-5} +SRUN_ARGS=${SRUN_ARGS:-""} +PY_ARGS=${PY_ARGS:-"--validate"} + +srun -p ${PARTITION} \ + --job-name=${JOB_NAME} \ + --gres=gpu:${GPUS_PER_NODE} \ + --ntasks=${GPUS} \ + --ntasks-per-node=${GPUS_PER_NODE} \ + --cpus-per-task=${CPUS_PER_TASK} \ + --kill-on-bad-exit=1 \ + ${SRUN_ARGS} \ + python -u tools/train.py ${CONFIG} --work_dir=${WORK_DIR} --launcher="slurm" ${PY_ARGS} diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/test.py b/cv/instance_segmentation/SOLO/pytorch/tools/test.py new file mode 100644 index 000000000..b39cf13ab --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/test.py @@ -0,0 +1,282 @@ +import argparse +import os +import os.path as osp +import pickle +import shutil +import tempfile + +import mmcv +import torch +import torch.distributed as dist +from mmcv.parallel import MMDataParallel, MMDistributedDataParallel +from mmcv.runner import get_dist_info, init_dist, load_checkpoint + +from mmdet.core import coco_eval, results2json, wrap_fp16_model +from mmdet.datasets import build_dataloader, build_dataset +from mmdet.models import build_detector + + +def single_gpu_test(model, data_loader, show=False): + model.eval() + results = [] + dataset = data_loader.dataset + prog_bar = mmcv.ProgressBar(len(dataset)) + for i, data in enumerate(data_loader): + with torch.no_grad(): + result = model(return_loss=False, rescale=not show, **data) + results.append(result) + + if show: + model.module.show_result(data, result) + + batch_size = data['img'][0].size(0) + for _ in range(batch_size): + prog_bar.update() + return results + + +def multi_gpu_test(model, data_loader, tmpdir=None, gpu_collect=False): + """Test model with multiple gpus. + + This method tests model with multiple gpus and collects the results + under two different modes: gpu and cpu modes. By setting 'gpu_collect=True' + it encodes results to gpu tensors and use gpu communication for results + collection. On cpu mode it saves the results on different gpus to 'tmpdir' + and collects them by the rank 0 worker. + + Args: + model (nn.Module): Model to be tested. + data_loader (nn.Dataloader): Pytorch data loader. + tmpdir (str): Path of directory to save the temporary results from + different gpus under cpu mode. + gpu_collect (bool): Option to use either gpu or cpu to collect results. + + Returns: + list: The prediction results. + """ + model.eval() + results = [] + dataset = data_loader.dataset + rank, world_size = get_dist_info() + if rank == 0: + prog_bar = mmcv.ProgressBar(len(dataset)) + for i, data in enumerate(data_loader): + with torch.no_grad(): + result = model(return_loss=False, rescale=True, **data) + results.append(result) + + if rank == 0: + batch_size = data['img'][0].size(0) + for _ in range(batch_size * world_size): + prog_bar.update() + + # collect results from all ranks + if gpu_collect: + results = collect_results_gpu(results, len(dataset)) + else: + results = collect_results_cpu(results, len(dataset), tmpdir) + return results + + +def collect_results_cpu(result_part, size, tmpdir=None): + rank, world_size = get_dist_info() + # create a tmp dir if it is not specified + if tmpdir is None: + MAX_LEN = 512 + # 32 is whitespace + dir_tensor = torch.full((MAX_LEN, ), + 32, + dtype=torch.uint8, + device='cuda') + if rank == 0: + tmpdir = tempfile.mkdtemp() + tmpdir = torch.tensor( + bytearray(tmpdir.encode()), dtype=torch.uint8, device='cuda') + dir_tensor[:len(tmpdir)] = tmpdir + dist.broadcast(dir_tensor, 0) + tmpdir = dir_tensor.cpu().numpy().tobytes().decode().rstrip() + else: + mmcv.mkdir_or_exist(tmpdir) + # dump the part result to the dir + mmcv.dump(result_part, osp.join(tmpdir, 'part_{}.pkl'.format(rank))) + dist.barrier() + # collect all parts + if rank != 0: + return None + else: + # load results of all parts from tmp dir + part_list = [] + for i in range(world_size): + part_file = osp.join(tmpdir, 'part_{}.pkl'.format(i)) + part_list.append(mmcv.load(part_file)) + # sort the results + ordered_results = [] + for res in zip(*part_list): + ordered_results.extend(list(res)) + # the dataloader may pad some samples + ordered_results = ordered_results[:size] + # remove tmp dir + shutil.rmtree(tmpdir) + return ordered_results + + +def collect_results_gpu(result_part, size): + rank, world_size = get_dist_info() + # dump result part to tensor with pickle + part_tensor = torch.tensor( + bytearray(pickle.dumps(result_part)), dtype=torch.uint8, device='cuda') + # gather all result part tensor shape + shape_tensor = torch.tensor(part_tensor.shape, device='cuda') + shape_list = [shape_tensor.clone() for _ in range(world_size)] + dist.all_gather(shape_list, shape_tensor) + # padding result part tensor to max length + shape_max = torch.tensor(shape_list).max() + part_send = torch.zeros(shape_max, dtype=torch.uint8, device='cuda') + part_send[:shape_tensor[0]] = part_tensor + part_recv_list = [ + part_tensor.new_zeros(shape_max) for _ in range(world_size) + ] + # gather all result part + dist.all_gather(part_recv_list, part_send) + + if rank == 0: + part_list = [] + for recv, shape in zip(part_recv_list, shape_list): + part_list.append( + pickle.loads(recv[:shape[0]].cpu().numpy().tobytes())) + # sort the results + ordered_results = [] + for res in zip(*part_list): + ordered_results.extend(list(res)) + # the dataloader may pad some samples + ordered_results = ordered_results[:size] + return ordered_results + + +def parse_args(): + parser = argparse.ArgumentParser(description='MMDet test detector') + parser.add_argument('config', help='test config file path') + parser.add_argument('checkpoint', help='checkpoint file') + parser.add_argument('--out', help='output result file') + parser.add_argument( + '--json_out', + help='output result file name without extension', + type=str) + parser.add_argument( + '--eval', + type=str, + nargs='+', + choices=['proposal', 'proposal_fast', 'bbox', 'segm', 'keypoints'], + help='eval types') + parser.add_argument('--show', action='store_true', help='show results') + parser.add_argument( + '--gpu_collect', + action='store_true', + help='whether to use gpu to collect results') + parser.add_argument('--tmpdir', help='tmp dir for writing some results') + parser.add_argument( + '--launcher', + choices=['none', 'pytorch', 'slurm', 'mpi'], + default='none', + help='job launcher') + parser.add_argument('--local_rank', type=int, default=0) + args = parser.parse_args() + if 'LOCAL_RANK' not in os.environ: + os.environ['LOCAL_RANK'] = str(args.local_rank) + return args + + +def main(): + args = parse_args() + + assert args.out or args.show or args.json_out, \ + ('Please specify at least one operation (save or show the results) ' + 'with the argument "--out" or "--show" or "--json_out"') + + if args.out is not None and not args.out.endswith(('.pkl', '.pickle')): + raise ValueError('The output file must be a pkl file.') + + if args.json_out is not None and args.json_out.endswith('.json'): + args.json_out = args.json_out[:-5] + + cfg = mmcv.Config.fromfile(args.config) + # set cudnn_benchmark + if cfg.get('cudnn_benchmark', False): + torch.backends.cudnn.benchmark = True + cfg.model.pretrained = None + cfg.data.test.test_mode = True + + # init distributed env first, since logger depends on the dist info. + if args.launcher == 'none': + distributed = False + else: + distributed = True + init_dist(args.launcher, **cfg.dist_params) + + # build the dataloader + # TODO: support multiple images per gpu (only minor changes are needed) + dataset = build_dataset(cfg.data.test) + data_loader = build_dataloader( + dataset, + imgs_per_gpu=1, + workers_per_gpu=cfg.data.workers_per_gpu, + dist=distributed, + shuffle=False) + + # build the model and load checkpoint + model = build_detector(cfg.model, train_cfg=None, test_cfg=cfg.test_cfg) + fp16_cfg = cfg.get('fp16', None) + if fp16_cfg is not None: + wrap_fp16_model(model) + checkpoint = load_checkpoint(model, args.checkpoint, map_location='cpu') + # old versions did not save class info in checkpoints, this walkaround is + # for backward compatibility + if 'CLASSES' in checkpoint['meta']: + model.CLASSES = checkpoint['meta']['CLASSES'] + else: + model.CLASSES = dataset.CLASSES + + if not distributed: + model = MMDataParallel(model, device_ids=[0]) + outputs = single_gpu_test(model, data_loader, args.show) + else: + model = MMDistributedDataParallel(model.cuda()) + outputs = multi_gpu_test(model, data_loader, args.tmpdir, + args.gpu_collect) + + rank, _ = get_dist_info() + if args.out and rank == 0: + print('\nwriting results to {}'.format(args.out)) + mmcv.dump(outputs, args.out) + eval_types = args.eval + if eval_types: + print('Starting evaluate {}'.format(' and '.join(eval_types))) + if eval_types == ['proposal_fast']: + result_file = args.out + coco_eval(result_file, eval_types, dataset.coco) + else: + if not isinstance(outputs[0], dict): + result_files = results2json(dataset, outputs, args.out) + coco_eval(result_files, eval_types, dataset.coco) + else: + for name in outputs[0]: + print('\nEvaluating {}'.format(name)) + outputs_ = [out[name] for out in outputs] + result_file = args.out + '.{}'.format(name) + result_files = results2json(dataset, outputs_, + result_file) + coco_eval(result_files, eval_types, dataset.coco) + + # Save predictions in the COCO json format + if args.json_out and rank == 0: + if not isinstance(outputs[0], dict): + results2json(dataset, outputs, args.json_out) + else: + for name in outputs[0]: + outputs_ = [out[name] for out in outputs] + result_file = args.json_out + '.{}'.format(name) + results2json(dataset, outputs_, result_file) + + +if __name__ == '__main__': + main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/test_ins.py b/cv/instance_segmentation/SOLO/pytorch/tools/test_ins.py new file mode 100644 index 000000000..66843fb1d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/test_ins.py @@ -0,0 +1,257 @@ +import argparse +import os +import os.path as osp +import shutil +import tempfile + +import mmcv +import torch +import torch.nn.functional as F +import torch.distributed as dist +from mmcv.parallel import MMDataParallel, MMDistributedDataParallel +from mmcv.runner import init_dist, get_dist_info, load_checkpoint + +from mmdet.core import coco_eval, results2json, results2json_segm, wrap_fp16_model, tensor2imgs, get_classes +from mmdet.datasets import build_dataloader, build_dataset +from mmdet.models import build_detector +import time +import numpy as np +import pycocotools.mask as mask_util + + +def get_masks(result, num_classes=80): + for cur_result in result: + masks = [[] for _ in range(num_classes)] + if cur_result is None: + return masks + seg_pred = cur_result[0].cpu().numpy().astype(np.uint8) + cate_label = cur_result[1].cpu().numpy().astype(np.int) + cate_score = cur_result[2].cpu().numpy().astype(np.float) + num_ins = seg_pred.shape[0] + for idx in range(num_ins): + cur_mask = seg_pred[idx, ...] + rle = mask_util.encode( + np.array(cur_mask[:, :, np.newaxis], order='F'))[0] + rst = (rle, cate_score[idx]) + masks[cate_label[idx]].append(rst) + + return masks + + +def single_gpu_test(model, data_loader, show=False, verbose=True): + model.eval() + results = [] + dataset = data_loader.dataset + + num_classes = len(dataset.CLASSES) + + prog_bar = mmcv.ProgressBar(len(dataset)) + for i, data in enumerate(data_loader): + with torch.no_grad(): + seg_result = model(return_loss=False, rescale=not show, **data) + + result = get_masks(seg_result, num_classes=num_classes) + results.append(result) + + batch_size = data['img'][0].size(0) + for _ in range(batch_size): + prog_bar.update() + return results + + +def multi_gpu_test(model, data_loader, tmpdir=None): + model.eval() + results = [] + dataset = data_loader.dataset + num_classes = len(dataset.CLASSES) + + rank, world_size = get_dist_info() + if rank == 0: + prog_bar = mmcv.ProgressBar(len(dataset)) + for i, data in enumerate(data_loader): + with torch.no_grad(): + seg_result = model(return_loss=False, rescale=True, **data) + + result = get_masks(seg_result, num_classes=num_classes) + results.append(result) + + if rank == 0: + batch_size = data['img'][0].size(0) + for _ in range(batch_size * world_size): + prog_bar.update() + + # collect results from all ranks + results = collect_results(results, len(dataset), tmpdir) + + return results + + +def collect_results(result_part, size, tmpdir=None): + rank, world_size = get_dist_info() + # create a tmp dir if it is not specified + if tmpdir is None: + MAX_LEN = 512 + # 32 is whitespace + dir_tensor = torch.full((MAX_LEN, ), + 32, + dtype=torch.uint8, + device='cuda') + if rank == 0: + tmpdir = tempfile.mkdtemp() + tmpdir = torch.tensor( + bytearray(tmpdir.encode()), dtype=torch.uint8, device='cuda') + dir_tensor[:len(tmpdir)] = tmpdir + dist.broadcast(dir_tensor, 0) + tmpdir = dir_tensor.cpu().numpy().tobytes().decode().rstrip() + else: + mmcv.mkdir_or_exist(tmpdir) + # dump the part result to the dir + mmcv.dump(result_part, osp.join(tmpdir, 'part_{}.pkl'.format(rank))) + dist.barrier() + # collect all parts + if rank != 0: + return None + else: + # load results of all parts from tmp dir + part_list = [] + for i in range(world_size): + part_file = osp.join(tmpdir, 'part_{}.pkl'.format(i)) + part_list.append(mmcv.load(part_file)) + # sort the results + ordered_results = [] + for res in zip(*part_list): + ordered_results.extend(list(res)) + # the dataloader may pad some samples + ordered_results = ordered_results[:size] + # remove tmp dir + shutil.rmtree(tmpdir) + return ordered_results + + +def parse_args(): + parser = argparse.ArgumentParser(description='MMDet test detector') + parser.add_argument('config', help='test config file path') + parser.add_argument('checkpoint', help='checkpoint file') + parser.add_argument('--out', help='output result file') + parser.add_argument( + '--json_out', + help='output result file name without extension', + type=str) + parser.add_argument( + '--eval', + type=str, + nargs='+', + choices=['proposal', 'proposal_fast', 'bbox', 'segm', 'keypoints'], + help='eval types') + parser.add_argument('--show', action='store_true', help='show results') + parser.add_argument('--tmpdir', help='tmp dir for writing some results') + parser.add_argument( + '--launcher', + choices=['none', 'pytorch', 'slurm', 'mpi'], + default='none', + help='job launcher') + parser.add_argument('--local_rank', type=int, default=0) + args = parser.parse_args() + if 'LOCAL_RANK' not in os.environ: + os.environ['LOCAL_RANK'] = str(args.local_rank) + return args + + +def main(): + args = parse_args() + + assert args.out or args.show or args.json_out, \ + ('Please specify at least one operation (save or show the results) ' + 'with the argument "--out" or "--show" or "--json_out"') + + if args.out is not None and not args.out.endswith(('.pkl', '.pickle')): + raise ValueError('The output file must be a pkl file.') + + if args.json_out is not None and args.json_out.endswith('.json'): + args.json_out = args.json_out[:-5] + + cfg = mmcv.Config.fromfile(args.config) + # set cudnn_benchmark + if cfg.get('cudnn_benchmark', False): + torch.backends.cudnn.benchmark = True + cfg.model.pretrained = None + cfg.data.test.test_mode = True + + # init distributed env first, since logger depends on the dist info. + if args.launcher == 'none': + distributed = False + else: + distributed = True + init_dist(args.launcher, **cfg.dist_params) + + # build the dataloader + # TODO: support multiple images per gpu (only minor changes are needed) + dataset = build_dataset(cfg.data.test) + data_loader = build_dataloader( + dataset, + imgs_per_gpu=1, + workers_per_gpu=cfg.data.workers_per_gpu, + dist=distributed, + shuffle=False) + + # build the model and load checkpoint + model = build_detector(cfg.model, train_cfg=None, test_cfg=cfg.test_cfg) + fp16_cfg = cfg.get('fp16', None) + if fp16_cfg is not None: + wrap_fp16_model(model) + + while not osp.isfile(args.checkpoint): + print('Waiting for {} to exist...'.format(args.checkpoint)) + time.sleep(60) + + checkpoint = load_checkpoint(model, args.checkpoint, map_location='cpu') + # old versions did not save class info in checkpoints, this walkaround is + # for backward compatibility + if 'CLASSES' in checkpoint['meta']: + model.CLASSES = checkpoint['meta']['CLASSES'] + else: + model.CLASSES = dataset.CLASSES + + if not distributed: + model = MMDataParallel(model, device_ids=[0]) + outputs = single_gpu_test(model, data_loader) + else: + model = MMDistributedDataParallel(model.cuda()) + outputs = multi_gpu_test(model, data_loader, args.tmpdir) + + rank, _ = get_dist_info() + if args.out and rank == 0: + print('\nwriting results to {}'.format(args.out)) + mmcv.dump(outputs, args.out) + eval_types = args.eval + if eval_types: + print('Starting evaluate {}'.format(' and '.join(eval_types))) + if eval_types == ['proposal_fast']: + result_file = args.out + coco_eval(result_file, eval_types, dataset.coco) + else: + if not isinstance(outputs[0], dict): + result_files = results2json_segm(dataset, outputs, args.out) + coco_eval(result_files, eval_types, dataset.coco) + else: + for name in outputs[0]: + print('\nEvaluating {}'.format(name)) + outputs_ = [out[name] for out in outputs] + result_file = args.out + '.{}'.format(name) + result_files = results2json(dataset, outputs_, + result_file) + coco_eval(result_files, eval_types, dataset.coco) + + # Save predictions in the COCO json format + if args.json_out and rank == 0: + if not isinstance(outputs[0], dict): + results2json(dataset, outputs, args.json_out) + else: + for name in outputs[0]: + outputs_ = [out[name] for out in outputs] + result_file = args.json_out + '.{}'.format(name) + results2json(dataset, outputs_, result_file) + + +if __name__ == '__main__': + main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/test_ins_vis.py b/cv/instance_segmentation/SOLO/pytorch/tools/test_ins_vis.py new file mode 100644 index 000000000..e4490d25e --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/test_ins_vis.py @@ -0,0 +1,296 @@ +import argparse +import os +import os.path as osp +import shutil +import tempfile +from scipy import ndimage +import mmcv +import torch +import torch.distributed as dist +from mmcv.parallel import MMDataParallel, MMDistributedDataParallel +from mmcv.runner import init_dist, get_dist_info, load_checkpoint + +from mmdet.core import coco_eval, results2json, wrap_fp16_model, tensor2imgs, get_classes +from mmdet.datasets import build_dataloader, build_dataset +from mmdet.models import build_detector +import cv2 + +import numpy as np +import matplotlib.cm as cm + +def vis_seg(data, result, img_norm_cfg, data_id, colors, score_thr, save_dir): + img_tensor = data['img'][0] + img_metas = data['img_meta'][0].data[0] + imgs = tensor2imgs(img_tensor, **img_norm_cfg) + assert len(imgs) == len(img_metas) + class_names = get_classes('coco') + + for img, img_meta, cur_result in zip(imgs, img_metas, result): + if cur_result is None: + continue + h, w, _ = img_meta['img_shape'] + img_show = img[:h, :w, :] + + seg_label = cur_result[0] + seg_label = seg_label.cpu().numpy().astype(np.uint8) + cate_label = cur_result[1] + cate_label = cate_label.cpu().numpy() + score = cur_result[2].cpu().numpy() + + vis_inds = score > score_thr + seg_label = seg_label[vis_inds] + num_mask = seg_label.shape[0] + cate_label = cate_label[vis_inds] + cate_score = score[vis_inds] + + mask_density = [] + for idx in range(num_mask): + cur_mask = seg_label[idx, :, :] + cur_mask = mmcv.imresize(cur_mask, (w, h)) + cur_mask = (cur_mask > 0.5).astype(np.int32) + mask_density.append(cur_mask.sum()) + orders = np.argsort(mask_density) + seg_label = seg_label[orders] + cate_label = cate_label[orders] + cate_score = cate_score[orders] + + seg_show = img_show.copy() + for idx in range(num_mask): + idx = -(idx+1) + cur_mask = seg_label[idx, :,:] + cur_mask = mmcv.imresize(cur_mask, (w, h)) + cur_mask = (cur_mask > 0.5).astype(np.uint8) + if cur_mask.sum() == 0: + continue + color_mask = np.random.randint( + 0, 256, (1, 3), dtype=np.uint8) + cur_mask_bool = cur_mask.astype(np.bool) + seg_show[cur_mask_bool] = img_show[cur_mask_bool] * 0.5 + color_mask * 0.5 + + cur_cate = cate_label[idx] + cur_score = cate_score[idx] + + label_text = class_names[cur_cate] + #label_text += '|{:.02f}'.format(cur_score) + # center + center_y, center_x = ndimage.measurements.center_of_mass(cur_mask) + vis_pos = (max(int(center_x) - 10, 0), int(center_y)) + cv2.putText(seg_show, label_text, vis_pos, + cv2.FONT_HERSHEY_COMPLEX, 0.3, (255, 255, 255)) # green + mmcv.imwrite(seg_show, '{}/{}.jpg'.format(save_dir, data_id)) + + +def single_gpu_test(model, data_loader, args, cfg=None, verbose=True): + model.eval() + results = [] + dataset = data_loader.dataset + + class_num = 1000 # ins + colors = [(np.random.random((1, 3)) * 255).tolist()[0] for i in range(class_num)] + + prog_bar = mmcv.ProgressBar(len(dataset)) + for i, data in enumerate(data_loader): + with torch.no_grad(): + seg_result = model(return_loss=False, rescale=True, **data) + result = None + results.append(result) + + if verbose: + vis_seg(data, seg_result, cfg.img_norm_cfg, data_id=i, colors=colors, score_thr=args.score_thr, save_dir=args.save_dir) + + batch_size = data['img'][0].size(0) + for _ in range(batch_size): + prog_bar.update() + return results + + +def multi_gpu_test(model, data_loader, tmpdir=None): + model.eval() + results = [] + dataset = data_loader.dataset + rank, world_size = get_dist_info() + if rank == 0: + prog_bar = mmcv.ProgressBar(len(dataset)) + for i, data in enumerate(data_loader): + with torch.no_grad(): + result = model(return_loss=False, rescale=True, **data) + results.append(result) + + if rank == 0: + batch_size = data['img'][0].size(0) + for _ in range(batch_size * world_size): + prog_bar.update() + + # collect results from all ranks + results = collect_results(results, len(dataset), tmpdir) + + return results + + +def collect_results(result_part, size, tmpdir=None): + rank, world_size = get_dist_info() + # create a tmp dir if it is not specified + if tmpdir is None: + MAX_LEN = 512 + # 32 is whitespace + dir_tensor = torch.full((MAX_LEN, ), + 32, + dtype=torch.uint8, + device='cuda') + if rank == 0: + tmpdir = tempfile.mkdtemp() + tmpdir = torch.tensor( + bytearray(tmpdir.encode()), dtype=torch.uint8, device='cuda') + dir_tensor[:len(tmpdir)] = tmpdir + dist.broadcast(dir_tensor, 0) + tmpdir = dir_tensor.cpu().numpy().tobytes().decode().rstrip() + else: + mmcv.mkdir_or_exist(tmpdir) + # dump the part result to the dir + mmcv.dump(result_part, osp.join(tmpdir, 'part_{}.pkl'.format(rank))) + dist.barrier() + # collect all parts + if rank != 0: + return None + else: + # load results of all parts from tmp dir + part_list = [] + for i in range(world_size): + part_file = osp.join(tmpdir, 'part_{}.pkl'.format(i)) + part_list.append(mmcv.load(part_file)) + # sort the results + ordered_results = [] + for res in zip(*part_list): + ordered_results.extend(list(res)) + # the dataloader may pad some samples + ordered_results = ordered_results[:size] + # remove tmp dir + shutil.rmtree(tmpdir) + return ordered_results + + +def parse_args(): + parser = argparse.ArgumentParser(description='MMDet test detector') + parser.add_argument('config', help='test config file path') + parser.add_argument('checkpoint', help='checkpoint file') + parser.add_argument('--out', help='output result file') + parser.add_argument( + '--json_out', + help='output result file name without extension', + type=str) + parser.add_argument( + '--eval', + type=str, + nargs='+', + choices=['proposal', 'proposal_fast', 'bbox', 'segm', 'keypoints'], + help='eval types') + parser.add_argument('--show', action='store_true', help='show results') + parser.add_argument('--score_thr', type=float, default=0.3, help='score threshold for visualization') + parser.add_argument('--tmpdir', help='tmp dir for writing some results') + parser.add_argument('--save_dir', help='dir for saveing visualized images') + parser.add_argument( + '--launcher', + choices=['none', 'pytorch', 'slurm', 'mpi'], + default='none', + help='job launcher') + parser.add_argument('--local_rank', type=int, default=0) + args = parser.parse_args() + if 'LOCAL_RANK' not in os.environ: + os.environ['LOCAL_RANK'] = str(args.local_rank) + return args + + +def main(): + args = parse_args() + + assert args.out or args.show or args.json_out, \ + ('Please specify at least one operation (save or show the results) ' + 'with the argument "--out" or "--show" or "--json_out"') + + if args.out is not None and not args.out.endswith(('.pkl', '.pickle')): + raise ValueError('The output file must be a pkl file.') + + if args.json_out is not None and args.json_out.endswith('.json'): + args.json_out = args.json_out[:-5] + + cfg = mmcv.Config.fromfile(args.config) + # set cudnn_benchmark + if cfg.get('cudnn_benchmark', False): + torch.backends.cudnn.benchmark = True + cfg.model.pretrained = None + cfg.data.test.test_mode = True + + # init distributed env first, since logger depends on the dist info. + if args.launcher == 'none': + distributed = False + else: + distributed = True + init_dist(args.launcher, **cfg.dist_params) + + # build the dataloader + # TODO: support multiple images per gpu (only minor changes are needed) + dataset = build_dataset(cfg.data.test) + data_loader = build_dataloader( + dataset, + imgs_per_gpu=1, + workers_per_gpu=cfg.data.workers_per_gpu, + dist=distributed, + shuffle=False) + + # build the model and load checkpoint + model = build_detector(cfg.model, train_cfg=None, test_cfg=cfg.test_cfg) + fp16_cfg = cfg.get('fp16', None) + if fp16_cfg is not None: + wrap_fp16_model(model) + checkpoint = load_checkpoint(model, args.checkpoint, map_location='cpu') + # old versions did not save class info in checkpoints, this walkaround is + # for backward compatibility + if 'CLASSES' in checkpoint['meta']: + model.CLASSES = checkpoint['meta']['CLASSES'] + else: + model.CLASSES = dataset.CLASSES + + assert not distributed + if not distributed: + model = MMDataParallel(model, device_ids=[0]) + outputs = single_gpu_test(model, data_loader, args, cfg=cfg) + else: + model = MMDistributedDataParallel(model.cuda()) + outputs = multi_gpu_test(model, data_loader, args.tmpdir) + + rank, _ = get_dist_info() + if args.out and rank == 0: + print('\nwriting results to {}'.format(args.out)) + mmcv.dump(outputs, args.out) + eval_types = args.eval + if eval_types: + print('Starting evaluate {}'.format(' and '.join(eval_types))) + if eval_types == ['proposal_fast']: + result_file = args.out + coco_eval(result_file, eval_types, dataset.coco) + else: + if not isinstance(outputs[0], dict): + result_files = results2json(dataset, outputs, args.out) + coco_eval(result_files, eval_types, dataset.coco) + else: + for name in outputs[0]: + print('\nEvaluating {}'.format(name)) + outputs_ = [out[name] for out in outputs] + result_file = args.out + '.{}'.format(name) + result_files = results2json(dataset, outputs_, + result_file) + coco_eval(result_files, eval_types, dataset.coco) + + # Save predictions in the COCO json format + if args.json_out and rank == 0: + if not isinstance(outputs[0], dict): + results2json(dataset, outputs, args.json_out) + else: + for name in outputs[0]: + outputs_ = [out[name] for out in outputs] + result_file = args.json_out + '.{}'.format(name) + results2json(dataset, outputs_, result_file) + + +if __name__ == '__main__': + main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/test_robustness.py b/cv/instance_segmentation/SOLO/pytorch/tools/test_robustness.py new file mode 100644 index 000000000..2271f4c06 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/test_robustness.py @@ -0,0 +1,453 @@ +import argparse +import copy +import os +import os.path as osp +import shutil +import tempfile + +import mmcv +import numpy as np +import torch +import torch.distributed as dist +from mmcv.parallel import MMDataParallel, MMDistributedDataParallel +from mmcv.runner import get_dist_info, init_dist, load_checkpoint +from pycocotools.coco import COCO +from pycocotools.cocoeval import COCOeval +from robustness_eval import get_results + +from mmdet import datasets +from mmdet.apis import set_random_seed +from mmdet.core import (eval_map, fast_eval_recall, results2json, + wrap_fp16_model) +from mmdet.datasets import build_dataloader, build_dataset +from mmdet.models import build_detector + + +def coco_eval_with_return(result_files, + result_types, + coco, + max_dets=(100, 300, 1000)): + for res_type in result_types: + assert res_type in [ + 'proposal', 'proposal_fast', 'bbox', 'segm', 'keypoints' + ] + + if mmcv.is_str(coco): + coco = COCO(coco) + assert isinstance(coco, COCO) + + if result_types == ['proposal_fast']: + ar = fast_eval_recall(result_files, coco, np.array(max_dets)) + for i, num in enumerate(max_dets): + print('AR@{}\t= {:.4f}'.format(num, ar[i])) + return + + eval_results = {} + for res_type in result_types: + result_file = result_files[res_type] + assert result_file.endswith('.json') + + coco_dets = coco.loadRes(result_file) + img_ids = coco.getImgIds() + iou_type = 'bbox' if res_type == 'proposal' else res_type + cocoEval = COCOeval(coco, coco_dets, iou_type) + cocoEval.params.imgIds = img_ids + if res_type == 'proposal': + cocoEval.params.useCats = 0 + cocoEval.params.maxDets = list(max_dets) + cocoEval.evaluate() + cocoEval.accumulate() + cocoEval.summarize() + if res_type == 'segm' or res_type == 'bbox': + metric_names = [ + 'AP', 'AP50', 'AP75', 'APs', 'APm', 'APl', 'AR1', 'AR10', + 'AR100', 'ARs', 'ARm', 'ARl' + ] + eval_results[res_type] = { + metric_names[i]: cocoEval.stats[i] + for i in range(len(metric_names)) + } + else: + eval_results[res_type] = cocoEval.stats + + return eval_results + + +def voc_eval_with_return(result_file, + dataset, + iou_thr=0.5, + logger='print', + only_ap=True): + det_results = mmcv.load(result_file) + annotations = [dataset.get_ann_info(i) for i in range(len(dataset))] + if hasattr(dataset, 'year') and dataset.year == 2007: + dataset_name = 'voc07' + else: + dataset_name = dataset.CLASSES + mean_ap, eval_results = eval_map( + det_results, + annotations, + scale_ranges=None, + iou_thr=iou_thr, + dataset=dataset_name, + logger=logger) + + if only_ap: + eval_results = [{ + 'ap': eval_results[i]['ap'] + } for i in range(len(eval_results))] + + return mean_ap, eval_results + + +def single_gpu_test(model, data_loader, show=False): + model.eval() + results = [] + dataset = data_loader.dataset + prog_bar = mmcv.ProgressBar(len(dataset)) + for i, data in enumerate(data_loader): + with torch.no_grad(): + result = model(return_loss=False, rescale=not show, **data) + results.append(result) + + if show: + model.module.show_result(data, result, dataset.img_norm_cfg) + + batch_size = data['img'][0].size(0) + for _ in range(batch_size): + prog_bar.update() + return results + + +def multi_gpu_test(model, data_loader, tmpdir=None): + model.eval() + results = [] + dataset = data_loader.dataset + rank, world_size = get_dist_info() + if rank == 0: + prog_bar = mmcv.ProgressBar(len(dataset)) + for i, data in enumerate(data_loader): + with torch.no_grad(): + result = model(return_loss=False, rescale=True, **data) + results.append(result) + + if rank == 0: + batch_size = data['img'][0].size(0) + for _ in range(batch_size * world_size): + prog_bar.update() + + # collect results from all ranks + results = collect_results(results, len(dataset), tmpdir) + + return results + + +def collect_results(result_part, size, tmpdir=None): + rank, world_size = get_dist_info() + # create a tmp dir if it is not specified + if tmpdir is None: + MAX_LEN = 512 + # 32 is whitespace + dir_tensor = torch.full((MAX_LEN, ), + 32, + dtype=torch.uint8, + device='cuda') + if rank == 0: + tmpdir = tempfile.mkdtemp() + tmpdir = torch.tensor( + bytearray(tmpdir.encode()), dtype=torch.uint8, device='cuda') + dir_tensor[:len(tmpdir)] = tmpdir + dist.broadcast(dir_tensor, 0) + tmpdir = dir_tensor.cpu().numpy().tobytes().decode().rstrip() + else: + mmcv.mkdir_or_exist(tmpdir) + # dump the part result to the dir + mmcv.dump(result_part, osp.join(tmpdir, 'part_{}.pkl'.format(rank))) + dist.barrier() + # collect all parts + if rank != 0: + return None + else: + # load results of all parts from tmp dir + part_list = [] + for i in range(world_size): + part_file = osp.join(tmpdir, 'part_{}.pkl'.format(i)) + part_list.append(mmcv.load(part_file)) + # sort the results + ordered_results = [] + for res in zip(*part_list): + ordered_results.extend(list(res)) + # the dataloader may pad some samples + ordered_results = ordered_results[:size] + # remove tmp dir + shutil.rmtree(tmpdir) + return ordered_results + + +def parse_args(): + parser = argparse.ArgumentParser(description='MMDet test detector') + parser.add_argument('config', help='test config file path') + parser.add_argument('checkpoint', help='checkpoint file') + parser.add_argument('--out', help='output result file') + parser.add_argument( + '--corruptions', + type=str, + nargs='+', + default='benchmark', + choices=[ + 'all', 'benchmark', 'noise', 'blur', 'weather', 'digital', + 'holdout', 'None', 'gaussian_noise', 'shot_noise', 'impulse_noise', + 'defocus_blur', 'glass_blur', 'motion_blur', 'zoom_blur', 'snow', + 'frost', 'fog', 'brightness', 'contrast', 'elastic_transform', + 'pixelate', 'jpeg_compression', 'speckle_noise', 'gaussian_blur', + 'spatter', 'saturate' + ], + help='corruptions') + parser.add_argument( + '--severities', + type=int, + nargs='+', + default=[0, 1, 2, 3, 4, 5], + help='corruption severity levels') + parser.add_argument( + '--eval', + type=str, + nargs='+', + choices=['proposal', 'proposal_fast', 'bbox', 'segm', 'keypoints'], + help='eval types') + parser.add_argument( + '--iou-thr', + type=float, + default=0.5, + help='IoU threshold for pascal voc evaluation') + parser.add_argument( + '--summaries', + type=bool, + default=False, + help='Print summaries for every corruption and severity') + parser.add_argument( + '--workers', type=int, default=32, help='workers per gpu') + parser.add_argument('--show', action='store_true', help='show results') + parser.add_argument('--tmpdir', help='tmp dir for writing some results') + parser.add_argument('--seed', type=int, default=None, help='random seed') + parser.add_argument( + '--launcher', + choices=['none', 'pytorch', 'slurm', 'mpi'], + default='none', + help='job launcher') + parser.add_argument('--local_rank', type=int, default=0) + parser.add_argument( + '--final-prints', + type=str, + nargs='+', + choices=['P', 'mPC', 'rPC'], + default='mPC', + help='corruption benchmark metric to print at the end') + parser.add_argument( + '--final-prints-aggregate', + type=str, + choices=['all', 'benchmark'], + default='benchmark', + help='aggregate all results or only those for benchmark corruptions') + args = parser.parse_args() + if 'LOCAL_RANK' not in os.environ: + os.environ['LOCAL_RANK'] = str(args.local_rank) + return args + + +def main(): + args = parse_args() + + assert args.out or args.show, \ + ('Please specify at least one operation (save or show the results) ' + 'with the argument "--out" or "--show"') + + if args.out is not None and not args.out.endswith(('.pkl', '.pickle')): + raise ValueError('The output file must be a pkl file.') + + cfg = mmcv.Config.fromfile(args.config) + # set cudnn_benchmark + if cfg.get('cudnn_benchmark', False): + torch.backends.cudnn.benchmark = True + cfg.model.pretrained = None + cfg.data.test.test_mode = True + if args.workers == 0: + args.workers = cfg.data.workers_per_gpu + + # init distributed env first, since logger depends on the dist info. + if args.launcher == 'none': + distributed = False + else: + distributed = True + init_dist(args.launcher, **cfg.dist_params) + + # set random seeds + if args.seed is not None: + set_random_seed(args.seed) + + if 'all' in args.corruptions: + corruptions = [ + 'gaussian_noise', 'shot_noise', 'impulse_noise', 'defocus_blur', + 'glass_blur', 'motion_blur', 'zoom_blur', 'snow', 'frost', 'fog', + 'brightness', 'contrast', 'elastic_transform', 'pixelate', + 'jpeg_compression', 'speckle_noise', 'gaussian_blur', 'spatter', + 'saturate' + ] + elif 'benchmark' in args.corruptions: + corruptions = [ + 'gaussian_noise', 'shot_noise', 'impulse_noise', 'defocus_blur', + 'glass_blur', 'motion_blur', 'zoom_blur', 'snow', 'frost', 'fog', + 'brightness', 'contrast', 'elastic_transform', 'pixelate', + 'jpeg_compression' + ] + elif 'noise' in args.corruptions: + corruptions = ['gaussian_noise', 'shot_noise', 'impulse_noise'] + elif 'blur' in args.corruptions: + corruptions = [ + 'defocus_blur', 'glass_blur', 'motion_blur', 'zoom_blur' + ] + elif 'weather' in args.corruptions: + corruptions = ['snow', 'frost', 'fog', 'brightness'] + elif 'digital' in args.corruptions: + corruptions = [ + 'contrast', 'elastic_transform', 'pixelate', 'jpeg_compression' + ] + elif 'holdout' in args.corruptions: + corruptions = ['speckle_noise', 'gaussian_blur', 'spatter', 'saturate'] + elif 'None' in args.corruptions: + corruptions = ['None'] + args.severities = [0] + else: + corruptions = args.corruptions + + aggregated_results = {} + for corr_i, corruption in enumerate(corruptions): + aggregated_results[corruption] = {} + for sev_i, corruption_severity in enumerate(args.severities): + # evaluate severity 0 (= no corruption) only once + if corr_i > 0 and corruption_severity == 0: + aggregated_results[corruption][0] = \ + aggregated_results[corruptions[0]][0] + continue + + test_data_cfg = copy.deepcopy(cfg.data.test) + # assign corruption and severity + if corruption_severity > 0: + corruption_trans = dict( + type='Corrupt', + corruption=corruption, + severity=corruption_severity) + # TODO: hard coded "1", we assume that the first step is + # loading images, which needs to be fixed in the future + test_data_cfg['pipeline'].insert(1, corruption_trans) + + # print info + print('\nTesting {} at severity {}'.format(corruption, + corruption_severity)) + + # build the dataloader + # TODO: support multiple images per gpu + # (only minor changes are needed) + dataset = build_dataset(test_data_cfg) + data_loader = build_dataloader( + dataset, + imgs_per_gpu=1, + workers_per_gpu=args.workers, + dist=distributed, + shuffle=False) + + # build the model and load checkpoint + model = build_detector( + cfg.model, train_cfg=None, test_cfg=cfg.test_cfg) + fp16_cfg = cfg.get('fp16', None) + if fp16_cfg is not None: + wrap_fp16_model(model) + checkpoint = load_checkpoint( + model, args.checkpoint, map_location='cpu') + # old versions did not save class info in checkpoints, + # this walkaround is for backward compatibility + if 'CLASSES' in checkpoint['meta']: + model.CLASSES = checkpoint['meta']['CLASSES'] + else: + model.CLASSES = dataset.CLASSES + + if not distributed: + model = MMDataParallel(model, device_ids=[0]) + outputs = single_gpu_test(model, data_loader, args.show) + else: + model = MMDistributedDataParallel(model.cuda()) + outputs = multi_gpu_test(model, data_loader, args.tmpdir) + + rank, _ = get_dist_info() + if args.out and rank == 0: + eval_results_filename = ( + osp.splitext(args.out)[0] + '_results' + + osp.splitext(args.out)[1]) + mmcv.dump(outputs, args.out) + eval_types = args.eval + if cfg.dataset_type == 'VOCDataset': + if eval_types: + for eval_type in eval_types: + if eval_type == 'bbox': + test_dataset = mmcv.runner.obj_from_dict( + cfg.data.test, datasets) + logger = 'print' if args.summaries else None + mean_ap, eval_results = \ + voc_eval_with_return( + args.out, test_dataset, + args.iou_thr, logger) + aggregated_results[corruption][ + corruption_severity] = eval_results + else: + print('\nOnly "bbox" evaluation \ + is supported for pascal voc') + else: + if eval_types: + print('Starting evaluate {}'.format( + ' and '.join(eval_types))) + if eval_types == ['proposal_fast']: + result_file = args.out + else: + if not isinstance(outputs[0], dict): + result_files = results2json( + dataset, outputs, args.out) + else: + for name in outputs[0]: + print('\nEvaluating {}'.format(name)) + outputs_ = [out[name] for out in outputs] + result_file = args.out + + '.{}'.format(name) + result_files = results2json( + dataset, outputs_, result_file) + eval_results = coco_eval_with_return( + result_files, eval_types, dataset.coco) + aggregated_results[corruption][ + corruption_severity] = eval_results + else: + print('\nNo task was selected for evaluation;' + '\nUse --eval to select a task') + + # save results after each evaluation + mmcv.dump(aggregated_results, eval_results_filename) + + # print filan results + print('\nAggregated results:') + prints = args.final_prints + aggregate = args.final_prints_aggregate + + if cfg.dataset_type == 'VOCDataset': + get_results( + eval_results_filename, + dataset='voc', + prints=prints, + aggregate=aggregate) + else: + get_results( + eval_results_filename, + dataset='coco', + prints=prints, + aggregate=aggregate) + + +if __name__ == '__main__': + main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/train.py b/cv/instance_segmentation/SOLO/pytorch/tools/train.py new file mode 100644 index 000000000..7f89795d5 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/train.py @@ -0,0 +1,125 @@ +from __future__ import division +import argparse +import os +import os.path as osp +import time + +import mmcv +import torch +from mmcv import Config +from mmcv.runner import init_dist + +from mmdet import __version__ +from mmdet.apis import set_random_seed, train_detector +from mmdet.datasets import build_dataset +from mmdet.models import build_detector +from mmdet.utils import get_root_logger + + +def parse_args(): + parser = argparse.ArgumentParser(description='Train a detector') + parser.add_argument('config', help='train config file path') + parser.add_argument('--work_dir', help='the dir to save logs and models') + parser.add_argument( + '--resume_from', help='the checkpoint file to resume from') + parser.add_argument( + '--validate', + action='store_true', + help='whether to evaluate the checkpoint during training') + parser.add_argument( + '--gpus', + type=int, + default=1, + help='number of gpus to use ' + '(only applicable to non-distributed training)') + parser.add_argument('--seed', type=int, default=None, help='random seed') + parser.add_argument( + '--deterministic', + action='store_true', + help='whether to set deterministic options for CUDNN backend.') + parser.add_argument( + '--launcher', + choices=['none', 'pytorch', 'slurm', 'mpi'], + default='none', + help='job launcher') + parser.add_argument('--local_rank', type=int, default=0) + parser.add_argument( + '--autoscale-lr', + action='store_true', + help='automatically scale lr with the number of gpus') + args = parser.parse_args() + if 'LOCAL_RANK' not in os.environ: + os.environ['LOCAL_RANK'] = str(args.local_rank) + + return args + + +def main(): + args = parse_args() + + cfg = Config.fromfile(args.config) + # set cudnn_benchmark + if cfg.get('cudnn_benchmark', False): + torch.backends.cudnn.benchmark = True + # update configs according to CLI args + if args.work_dir is not None: + cfg.work_dir = args.work_dir + if args.resume_from is not None: + cfg.resume_from = args.resume_from + cfg.gpus = args.gpus + + if args.autoscale_lr: + # apply the linear scaling rule (https://arxiv.org/abs/1706.02677) + cfg.optimizer['lr'] = cfg.optimizer['lr'] * cfg.gpus / 8 + + # init distributed env first, since logger depends on the dist info. + if args.launcher == 'none': + distributed = False + else: + distributed = True + init_dist(args.launcher, **cfg.dist_params) + + # create work_dir + mmcv.mkdir_or_exist(osp.abspath(cfg.work_dir)) + # init the logger before other steps + timestamp = time.strftime('%Y%m%d_%H%M%S', time.localtime()) + log_file = osp.join(cfg.work_dir, '{}.log'.format(timestamp)) + logger = get_root_logger(log_file=log_file, log_level=cfg.log_level) + + # log some basic info + logger.info('Distributed training: {}'.format(distributed)) + logger.info('MMDetection Version: {}'.format(__version__)) + logger.info('Config:\n{}'.format(cfg.text)) + + # set random seeds + if args.seed is not None: + logger.info('Set random seed to {}, deterministic: {}'.format( + args.seed, args.deterministic)) + set_random_seed(args.seed, deterministic=args.deterministic) + + model = build_detector( + cfg.model, train_cfg=cfg.train_cfg, test_cfg=cfg.test_cfg) + + datasets = [build_dataset(cfg.data.train)] + if len(cfg.workflow) == 2: + datasets.append(build_dataset(cfg.data.val)) + if cfg.checkpoint_config is not None: + # save mmdet version, config file content and class names in + # checkpoints as meta data + cfg.checkpoint_config.meta = dict( + mmdet_version=__version__, + config=cfg.text, + CLASSES=datasets[0].CLASSES) + # add an attribute for visualization convenience + model.CLASSES = datasets[0].CLASSES + train_detector( + model, + datasets, + cfg, + distributed=distributed, + validate=args.validate, + timestamp=timestamp) + + +if __name__ == '__main__': + main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/upgrade_model_version.py b/cv/instance_segmentation/SOLO/pytorch/tools/upgrade_model_version.py new file mode 100644 index 000000000..00bcdf44a --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/upgrade_model_version.py @@ -0,0 +1,42 @@ +import argparse +import re +from collections import OrderedDict + +import torch + + +def convert(in_file, out_file): + """Convert keys in checkpoints. + + There can be some breaking changes during the development of mmdetection, + and this tool is used for upgrading checkpoints trained with old versions + to the latest one. + """ + checkpoint = torch.load(in_file) + in_state_dict = checkpoint.pop('state_dict') + out_state_dict = OrderedDict() + for key, val in in_state_dict.items(): + # Use ConvModule instead of nn.Conv2d in RetinaNet + # cls_convs.0.weight -> cls_convs.0.conv.weight + m = re.search(r'(cls_convs|reg_convs).\d.(weight|bias)', key) + if m is not None: + param = m.groups()[1] + new_key = key.replace(param, 'conv.{}'.format(param)) + out_state_dict[new_key] = val + continue + + out_state_dict[key] = val + checkpoint['state_dict'] = out_state_dict + torch.save(checkpoint, out_file) + + +def main(): + parser = argparse.ArgumentParser(description='Upgrade model version') + parser.add_argument('in_file', help='input checkpoint file') + parser.add_argument('out_file', help='output checkpoint file') + args = parser.parse_args() + convert(args.in_file, args.out_file) + + +if __name__ == '__main__': + main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/voc_eval.py b/cv/instance_segmentation/SOLO/pytorch/tools/voc_eval.py new file mode 100644 index 000000000..be0bde6db --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/tools/voc_eval.py @@ -0,0 +1,47 @@ +from argparse import ArgumentParser + +import mmcv + +from mmdet import datasets +from mmdet.core import eval_map + + +def voc_eval(result_file, dataset, iou_thr=0.5, nproc=4): + det_results = mmcv.load(result_file) + annotations = [dataset.get_ann_info(i) for i in range(len(dataset))] + if hasattr(dataset, 'year') and dataset.year == 2007: + dataset_name = 'voc07' + else: + dataset_name = dataset.CLASSES + eval_map( + det_results, + annotations, + scale_ranges=None, + iou_thr=iou_thr, + dataset=dataset_name, + logger='print', + nproc=nproc) + + +def main(): + parser = ArgumentParser(description='VOC Evaluation') + parser.add_argument('result', help='result file path') + parser.add_argument('config', help='config file path') + parser.add_argument( + '--iou-thr', + type=float, + default=0.5, + help='IoU threshold for evaluation') + parser.add_argument( + '--nproc', + type=int, + default=4, + help='Processes to be used for computing mAP') + args = parser.parse_args() + cfg = mmcv.Config.fromfile(args.config) + test_dataset = mmcv.runner.obj_from_dict(cfg.data.test, datasets) + voc_eval(args.result, test_dataset, args.iou_thr, args.nproc) + + +if __name__ == '__main__': + main() -- Gitee From 9bac65c93777edb31d76c69a9c4b4b08fe2809ff Mon Sep 17 00:00:00 2001 From: "li.ding" Date: Fri, 10 Mar 2023 20:06:13 +0800 Subject: [PATCH 2/4] Add pytorch SOLO --- cv/instance_segmentation/SOLO.zip | Bin 0 -> 604461 bytes .../SOLO/pytorch/.github/CODE_OF_CONDUCT.md | 76 - .../SOLO/pytorch/.github/CONTRIBUTING.md | 53 - .../pytorch/.github/ISSUE_TEMPLATE/config.yml | 1 - .../.github/ISSUE_TEMPLATE/error-report.md | 41 - .../.github/ISSUE_TEMPLATE/feature_request.md | 22 - .../ISSUE_TEMPLATE/general_questions.md | 10 - .../SOLO/pytorch/.gitignore | 15 +- .../SOLO/pytorch/.gitmodules | 3 - .../SOLO/pytorch/.isort.cfg | 8 - .../SOLO/pytorch/.pre-commit-config.yaml | 21 - .../SOLO/pytorch/.style.yapf | 4 - .../SOLO/pytorch/.travis.yml | 43 - cv/instance_segmentation/SOLO/pytorch/LICENSE | 228 +- .../SOLO/pytorch/README.md | 43 +- .../datasets/coco_instance.py} | 81 +- .../pytorch/configs/_base_/default_runtime.py | 27 + .../configs/_base_/schedules/schedule_1x.py | 11 + .../SOLO/pytorch/configs/solo/README.md | 54 + ...ecoupled_solo_light_dcn_r50_fpn_8gpu_3x.py | 136 - ...> decoupled_solo_light_r50_fpn_3x_coco.py} | 110 +- .../solo/decoupled_solo_r101_fpn_8gpu_3x.py | 130 - .../solo/decoupled_solo_r50_fpn_1x_coco.py | 28 + .../solo/decoupled_solo_r50_fpn_3x_coco.py | 25 + .../solo/decoupled_solo_r50_fpn_8gpu_1x.py | 126 - .../solo/decoupled_solo_r50_fpn_8gpu_3x.py | 130 - .../SOLO/pytorch/configs/solo/metafile.yml | 115 + .../configs/solo/solo_r101_fpn_8gpu_3x.py | 130 - .../configs/solo/solo_r50_fpn_1x_coco.py | 53 + .../configs/solo/solo_r50_fpn_3x_coco.py | 28 + .../configs/solo/solo_r50_fpn_8gpu_3x.py | 130 - .../SOLO/pytorch/docker/Dockerfile | 25 + .../SOLO/pytorch/docker/serve/Dockerfile | 49 + .../pytorch/docker/serve/config.properties | 5 + .../SOLO/pytorch/docker/serve/entrypoint.sh | 12 + .../SOLO/pytorch/mmcv/__init__.py | 11 + .../SOLO/pytorch/mmcv/cnn/__init__.py | 41 + .../SOLO/pytorch/mmcv/cnn/alexnet.py | 61 + .../SOLO/pytorch/mmcv/cnn/bricks/__init__.py | 35 + .../pytorch/mmcv/cnn/bricks/activation.py | 92 + .../ops => mmcv/cnn/bricks}/context_block.py | 39 +- .../SOLO/pytorch/mmcv/cnn/bricks/conv.py | 44 + .../cnn/bricks/conv2d_adaptive_padding.py | 62 + .../utils => mmcv/cnn/bricks}/conv_module.py | 179 +- .../SOLO/pytorch/mmcv/cnn/bricks/conv_ws.py | 148 + .../bricks/depthwise_separable_conv_module.py | 96 + .../SOLO/pytorch/mmcv/cnn/bricks/drop.py | 65 + .../cnn/bricks}/generalized_attention.py | 81 +- .../SOLO/pytorch/mmcv/cnn/bricks/hsigmoid.py | 34 + .../SOLO/pytorch/mmcv/cnn/bricks/hswish.py | 29 + .../SOLO/pytorch/mmcv/cnn/bricks/non_local.py | 306 ++ .../SOLO/pytorch/mmcv/cnn/bricks/norm.py | 144 + .../SOLO/pytorch/mmcv/cnn/bricks/padding.py | 36 + .../SOLO/pytorch/mmcv/cnn/bricks/plugin.py | 88 + .../SOLO/pytorch/mmcv/cnn/bricks/registry.py | 16 + .../models/utils => mmcv/cnn/bricks}/scale.py | 10 +- .../SOLO/pytorch/mmcv/cnn/bricks/swish.py | 25 + .../pytorch/mmcv/cnn/bricks/transformer.py | 595 ++++ .../SOLO/pytorch/mmcv/cnn/bricks/upsample.py | 84 + .../SOLO/pytorch/mmcv/cnn/bricks/wrappers.py | 180 ++ .../SOLO/pytorch/mmcv/cnn/builder.py | 30 + .../SOLO/pytorch/mmcv/cnn/resnet.py | 316 ++ .../SOLO/pytorch/mmcv/cnn/utils/__init__.py | 19 + .../cnn}/utils/flops_counter.py | 481 ++-- .../pytorch/mmcv/cnn/utils/fuse_conv_bn.py | 59 + .../SOLO/pytorch/mmcv/cnn/utils/sync_bn.py | 59 + .../pytorch/mmcv/cnn/utils/weight_init.py | 684 +++++ .../SOLO/pytorch/mmcv/cnn/vgg.py | 175 ++ .../SOLO/pytorch/mmcv/engine/__init__.py | 8 + .../SOLO/pytorch/mmcv/engine/test.py | 202 ++ .../SOLO/pytorch/mmcv/fileio/__init__.py | 11 + .../SOLO/pytorch/mmcv/fileio/file_client.py | 1148 ++++++++ .../pytorch/mmcv/fileio/handlers/__init__.py | 7 + .../SOLO/pytorch/mmcv/fileio/handlers/base.py | 30 + .../mmcv/fileio/handlers/json_handler.py | 36 + .../mmcv/fileio/handlers/pickle_handler.py | 28 + .../mmcv/fileio/handlers/yaml_handler.py | 24 + .../SOLO/pytorch/mmcv/fileio/io.py | 151 + .../SOLO/pytorch/mmcv/fileio/parse.py | 97 + .../SOLO/pytorch/mmcv/image/__init__.py | 28 + .../SOLO/pytorch/mmcv/image/colorspace.py | 306 ++ .../SOLO/pytorch/mmcv/image/geometric.py | 728 +++++ .../SOLO/pytorch/mmcv/image/io.py | 258 ++ .../SOLO/pytorch/mmcv/image/misc.py | 44 + .../SOLO/pytorch/mmcv/image/photometric.py | 428 +++ .../pytorch/mmcv/model_zoo/deprecated.json | 6 + .../SOLO/pytorch/mmcv/model_zoo/mmcls.json | 31 + .../pytorch/mmcv/model_zoo/open_mmlab.json | 50 + .../SOLO/pytorch/mmcv/ops/__init__.py | 13 + .../SOLO/pytorch/mmcv/ops/csrc/README.md | 169 ++ .../csrc/common/cuda/common_cuda_helper.hpp | 112 + .../ops/csrc/common/cuda/nms_cuda_kernel.cuh | 74 + .../ops/csrc/common/cuda/nms_rotated_cuda.cuh | 135 + .../common/cuda/roi_align_cuda_kernel.cuh | 212 ++ .../csrc/common/cuda/roi_pool_cuda_kernel.cuh | 93 + .../cuda/sigmoid_focal_loss_cuda_kernel.cuh | 71 + .../cuda/softmax_focal_loss_cuda_kernel.cuh | 72 + .../csrc/common/cuda/sync_bn_cuda_kernel.cuh | 331 +++ .../ops/csrc/common/pytorch_cpp_helper.hpp | 24 + .../ops/csrc/common/pytorch_cuda_helper.hpp | 19 + .../ops/csrc/pytorch/cuda/focal_loss_cuda.cu | 111 + .../mmcv/ops/csrc/pytorch/cuda/nms_cuda.cu | 53 + .../ops/csrc/pytorch/cuda/roi_align_cuda.cu | 58 + .../ops/csrc/pytorch/cuda/roi_pool_cuda.cu | 50 + .../ops/csrc/pytorch/cuda/sync_bn_cuda.cu | 110 + .../mmcv/ops/csrc/pytorch/focal_loss.cpp | 131 + .../ops/csrc/pytorch/info.cpp} | 22 +- .../pytorch/mmcv/ops/csrc/pytorch/nms.cpp | 261 ++ .../pytorch/mmcv/ops/csrc/pytorch/pybind.cpp | 131 + .../mmcv/ops/csrc/pytorch/roi_align.cpp | 130 + .../mmcv/ops/csrc/pytorch/roi_align_cpu.cpp | 431 +++ .../mmcv/ops/csrc/pytorch/roi_pool.cpp | 67 + .../pytorch/mmcv/ops/csrc/pytorch/sync_bn.cpp | 159 ++ .../pytorch/mmcv/ops/deprecated_wrappers.py | 43 + .../SOLO/pytorch/mmcv/ops/focal_loss.py | 212 ++ .../SOLO/pytorch/mmcv/ops/info.py | 36 + .../SOLO/pytorch/mmcv/ops/nms.py | 417 +++ .../SOLO/pytorch/mmcv/ops/point_sample.py | 336 +++ .../SOLO/pytorch/mmcv/ops/roi_align.py | 223 ++ .../SOLO/pytorch/mmcv/ops/roi_pool.py | 86 + .../SOLO/pytorch/mmcv/ops/sync_bn.py | 279 ++ .../SOLO/pytorch/mmcv/parallel/__init__.py | 13 + .../SOLO/pytorch/mmcv/parallel/_functions.py | 79 + .../SOLO/pytorch/mmcv/parallel/collate.py | 84 + .../pytorch/mmcv/parallel/data_container.py | 89 + .../pytorch/mmcv/parallel/data_parallel.py | 89 + .../SOLO/pytorch/mmcv/parallel/distributed.py | 112 + .../mmcv/parallel/distributed_deprecated.py | 70 + .../SOLO/pytorch/mmcv/parallel/registry.py | 8 + .../pytorch/mmcv/parallel/scatter_gather.py | 59 + .../SOLO/pytorch/mmcv/parallel/utils.py | 20 + .../SOLO/pytorch/mmcv/runner/__init__.py | 47 + .../SOLO/pytorch/mmcv/runner/base_module.py | 195 ++ .../SOLO/pytorch/mmcv/runner/base_runner.py | 542 ++++ .../SOLO/pytorch/mmcv/runner/builder.py | 24 + .../SOLO/pytorch/mmcv/runner/checkpoint.py | 707 +++++ .../mmcv/runner/default_constructor.py | 44 + .../SOLO/pytorch/mmcv/runner/dist_utils.py | 164 ++ .../pytorch/mmcv/runner/epoch_based_runner.py | 187 ++ .../runner/fp16_utils.py} | 312 +- .../pytorch/mmcv/runner/hooks/__init__.py | 29 + .../pytorch/mmcv/runner/hooks/checkpoint.py | 167 ++ .../SOLO/pytorch/mmcv/runner/hooks/closure.py | 11 + .../SOLO/pytorch/mmcv/runner/hooks/ema.py | 89 + .../pytorch/mmcv/runner/hooks/evaluation.py | 509 ++++ .../SOLO/pytorch/mmcv/runner/hooks/hook.py | 92 + .../pytorch/mmcv/runner/hooks/iter_timer.py | 18 + .../mmcv/runner/hooks/logger/__init__.py | 15 + .../pytorch/mmcv/runner/hooks/logger/base.py | 166 ++ .../mmcv/runner/hooks/logger/dvclive.py | 58 + .../mmcv/runner/hooks/logger/mlflow.py | 78 + .../mmcv/runner/hooks/logger/neptune.py | 82 + .../pytorch/mmcv/runner/hooks/logger/pavi.py | 117 + .../mmcv/runner/hooks/logger/tensorboard.py | 57 + .../pytorch/mmcv/runner/hooks/logger/text.py | 256 ++ .../pytorch/mmcv/runner/hooks/logger/wandb.py | 56 + .../pytorch/mmcv/runner/hooks/lr_updater.py | 670 +++++ .../SOLO/pytorch/mmcv/runner/hooks/memory.py | 25 + .../mmcv/runner/hooks/momentum_updater.py | 493 ++++ .../pytorch/mmcv/runner/hooks/optimizer.py | 508 ++++ .../pytorch/mmcv/runner/hooks/profiler.py | 180 ++ .../pytorch/mmcv/runner/hooks/sampler_seed.py | 20 + .../pytorch/mmcv/runner/hooks/sync_buffer.py | 22 + .../pytorch/mmcv/runner/iter_based_runner.py | 273 ++ .../SOLO/pytorch/mmcv/runner/log_buffer.py | 41 + .../pytorch/mmcv/runner/optimizer/__init__.py | 9 + .../pytorch/mmcv/runner/optimizer/builder.py | 44 + .../runner/optimizer/default_constructor.py | 247 ++ .../SOLO/pytorch/mmcv/runner/priority.py | 60 + .../SOLO/pytorch/mmcv/runner/utils.py | 93 + .../SOLO/pytorch/mmcv/utils/__init__.py | 69 + .../SOLO/pytorch/mmcv/utils/config.py | 688 +++++ .../collect_env.py => mmcv/utils/env.py} | 81 +- .../SOLO/pytorch/mmcv/utils/ext_loader.py | 71 + .../SOLO/pytorch/mmcv/utils/logging.py | 110 + .../SOLO/pytorch/mmcv/utils/misc.py | 377 +++ .../SOLO/pytorch/mmcv/utils/parrots_jit.py | 41 + .../pytorch/mmcv/utils/parrots_wrapper.py | 107 + .../SOLO/pytorch/mmcv/utils/path.py | 101 + .../SOLO/pytorch/mmcv/utils/progressbar.py | 208 ++ .../SOLO/pytorch/mmcv/utils/registry.py | 315 ++ .../SOLO/pytorch/mmcv/utils/testing.py | 140 + .../SOLO/pytorch/mmcv/utils/timer.py | 118 + .../SOLO/pytorch/mmcv/utils/trace.py | 23 + .../SOLO/pytorch/mmcv/utils/version_utils.py | 90 + .../SOLO/pytorch/mmcv/version.py | 35 + .../SOLO/pytorch/mmdet/__init__.py | 26 + .../SOLO/pytorch/mmdet/apis/__init__.py | 11 +- .../SOLO/pytorch/mmdet/apis/inference.py | 363 ++- .../pytorch/{tools => mmdet/apis}/test.py | 221 +- .../SOLO/pytorch/mmdet/apis/train.py | 417 ++- .../SOLO/pytorch/mmdet/core/__init__.py | 5 +- .../pytorch/mmdet/core/anchor/__init__.py | 20 +- .../mmdet/core/anchor/anchor_generator.py | 858 +++++- .../mmdet/core/anchor/anchor_target.py | 188 -- .../SOLO/pytorch/mmdet/core/anchor/builder.py | 19 + .../mmdet/core/anchor/guided_anchor_target.py | 287 -- .../mmdet/core/anchor/point_generator.py | 235 +- .../pytorch/mmdet/core/anchor/point_target.py | 165 -- .../SOLO/pytorch/mmdet/core/anchor/utils.py | 72 + .../SOLO/pytorch/mmdet/core/bbox/__init__.py | 38 +- .../mmdet/core/bbox/assign_sampling.py | 33 - .../mmdet/core/bbox/assigners/__init__.py | 13 +- .../bbox/assigners/approx_max_iou_assigner.py | 49 +- .../core/bbox/assigners/assign_result.py | 70 +- .../core/bbox/assigners/atss_assigner.py | 101 +- .../core/bbox/assigners/base_assigner.py | 4 +- .../bbox/assigners/center_region_assigner.py | 336 +++ .../core/bbox/assigners/grid_assigner.py | 156 + .../core/bbox/assigners/hungarian_assigner.py | 146 + .../bbox/assigners/mask_hungarian_assigner.py | 132 + .../core/bbox/assigners/max_iou_assigner.py | 79 +- .../core/bbox/assigners/point_assigner.py | 20 +- .../core/bbox/assigners/region_assigner.py | 222 ++ .../core/bbox/assigners/sim_ota_assigner.py | 257 ++ .../bbox/assigners/task_aligned_assigner.py | 151 + .../core/bbox/assigners/uniform_assigner.py | 135 + .../pytorch/mmdet/core/bbox/bbox_target.py | 73 - .../SOLO/pytorch/mmdet/core/bbox/builder.py | 21 + .../pytorch/mmdet/core/bbox/coder/__init__.py | 15 + .../mmdet/core/bbox/coder/base_bbox_coder.py | 18 + .../core/bbox/coder/bucketing_bbox_coder.py | 351 +++ .../core/bbox/coder/delta_xywh_bbox_coder.py | 392 +++ .../bbox/coder/distance_point_bbox_coder.py | 63 + .../coder/legacy_delta_xywh_bbox_coder.py | 216 ++ .../core/bbox/coder/pseudo_bbox_coder.py | 19 + .../mmdet/core/bbox/coder/tblr_bbox_coder.py | 206 ++ .../mmdet/core/bbox/coder/yolo_bbox_coder.py | 83 + .../SOLO/pytorch/mmdet/core/bbox/demodata.py | 29 +- .../SOLO/pytorch/mmdet/core/bbox/geometry.py | 88 - .../core/bbox/iou_calculators/__init__.py | 5 + .../core/bbox/iou_calculators/builder.py | 9 + .../bbox/iou_calculators/iou2d_calculator.py | 261 ++ .../mmdet/core/bbox/match_costs/__init__.py | 9 + .../mmdet/core/bbox/match_costs/builder.py | 9 + .../mmdet/core/bbox/match_costs/match_cost.py | 359 +++ .../mmdet/core/bbox/samplers/__init__.py | 7 +- .../mmdet/core/bbox/samplers/base_sampler.py | 4 + .../core/bbox/samplers/combined_sampler.py | 7 +- .../samplers/instance_balanced_pos_sampler.py | 19 +- .../bbox/samplers/iou_balanced_neg_sampler.py | 27 +- .../core/bbox/samplers/mask_pseudo_sampler.py | 44 + .../bbox/samplers/mask_sampling_result.py | 60 + .../mmdet/core/bbox/samplers/ohem_sampler.py | 68 +- .../core/bbox/samplers/pseudo_sampler.py | 22 +- .../core/bbox/samplers/random_sampler.py | 54 +- .../core/bbox/samplers/sampling_result.py | 49 +- .../core/bbox/samplers/score_hlr_sampler.py | 265 ++ .../pytorch/mmdet/core/bbox/transforms.py | 341 ++- .../mmdet/core/data_structures/__init__.py | 5 + .../core/data_structures/general_data.py | 326 +++ .../core/data_structures/instance_data.py | 188 ++ .../pytorch/mmdet/core/evaluation/__init__.py | 23 +- .../mmdet/core/evaluation/bbox_overlaps.py | 40 +- .../mmdet/core/evaluation/class_names.py | 224 +- .../mmdet/core/evaluation/coco_utils.py | 250 -- .../mmdet/core/evaluation/eval_hooks.py | 276 +- .../pytorch/mmdet/core/evaluation/mean_ap.py | 425 ++- .../mmdet/core/evaluation/panoptic_utils.py | 6 + .../pytorch/mmdet/core/evaluation/recall.py | 64 +- .../pytorch/mmdet/core/export/__init__.py | 12 + .../mmdet/core/export/model_wrappers.py | 183 ++ .../pytorch/mmdet/core/export/onnx_helper.py | 223 ++ .../pytorch/mmdet/core/export/pytorch2onnx.py | 159 ++ .../SOLO/pytorch/mmdet/core/fp16/__init__.py | 4 - .../SOLO/pytorch/mmdet/core/fp16/hooks.py | 127 - .../SOLO/pytorch/mmdet/core/fp16/utils.py | 23 - .../SOLO/pytorch/mmdet/core/hook/__init__.py | 17 + .../pytorch/mmdet/core/hook/checkloss_hook.py | 24 + .../SOLO/pytorch/mmdet/core/hook/ema.py | 130 + .../mmdet/core/hook/memory_profiler_hook.py | 55 + .../mmdet/core/hook/set_epoch_info_hook.py | 15 + .../pytorch/mmdet/core/hook/sync_norm_hook.py | 52 + .../mmdet/core/hook/sync_random_size_hook.py | 72 + .../mmdet/core/hook/wandblogger_hook.py | 587 ++++ .../mmdet/core/hook/yolox_lrupdater_hook.py | 67 + .../mmdet/core/hook/yolox_mode_switch_hook.py | 52 + .../SOLO/pytorch/mmdet/core/mask/__init__.py | 9 +- .../pytorch/mmdet/core/mask/mask_target.py | 124 +- .../pytorch/mmdet/core/mask/structures.py | 1102 +++++++ .../SOLO/pytorch/mmdet/core/mask/utils.py | 63 +- .../pytorch/mmdet/core/optimizers/__init__.py | 9 + .../pytorch/mmdet/core/optimizers/builder.py | 33 + .../layer_decay_optimizer_constructor.py | 154 + .../mmdet/core/post_processing/__init__.py | 7 +- .../mmdet/core/post_processing/bbox_nms.py | 193 +- .../mmdet/core/post_processing/matrix_nms.py | 186 +- .../mmdet/core/post_processing/merge_augs.py | 77 +- .../SOLO/pytorch/mmdet/core/utils/__init__.py | 14 +- .../pytorch/mmdet/core/utils/dist_utils.py | 163 +- .../SOLO/pytorch/mmdet/core/utils/misc.py | 205 +- .../mmdet/core/visualization/__init__.py | 9 + .../pytorch/mmdet/core/visualization/image.py | 559 ++++ .../mmdet/core/visualization/palette.py | 63 + .../SOLO/pytorch/mmdet/datasets/__init__.py | 23 +- .../mmdet/datasets/api_wrappers/__init__.py | 7 + .../mmdet/datasets/api_wrappers/coco_api.py | 47 + .../api_wrappers/panoptic_evaluation.py | 228 ++ .../SOLO/pytorch/mmdet/datasets/builder.py | 184 +- .../SOLO/pytorch/mmdet/datasets/cityscapes.py | 9 - .../SOLO/pytorch/mmdet/datasets/coco.py | 605 +++- .../SOLO/pytorch/mmdet/datasets/custom.py | 322 ++- .../mmdet/datasets/dataset_wrappers.py | 411 ++- .../pytorch/mmdet/datasets/loader/__init__.py | 4 - .../mmdet/datasets/loader/build_loader.py | 70 - .../mmdet/datasets/pipelines/__init__.py | 28 +- .../mmdet/datasets/pipelines/compose.py | 30 +- .../mmdet/datasets/pipelines/formating.py | 197 +- .../mmdet/datasets/pipelines/formatting.py | 392 +++ .../mmdet/datasets/pipelines/instaboost.py | 91 - .../mmdet/datasets/pipelines/loading.py | 549 +++- .../mmdet/datasets/pipelines/test_aug.py | 38 - .../mmdet/datasets/pipelines/test_time_aug.py | 121 + .../mmdet/datasets/pipelines/transforms.py | 2541 +++++++++++++++-- .../SOLO/pytorch/mmdet/datasets/registry.py | 4 - .../mmdet/datasets/samplers/__init__.py | 10 + .../datasets/samplers/class_aware_sampler.py | 176 ++ .../datasets/samplers/distributed_sampler.py | 54 + .../sampler.py => samplers/group_sampler.py} | 48 +- .../datasets/samplers/infinite_sampler.py | 186 ++ .../SOLO/pytorch/mmdet/datasets/utils.py | 164 ++ .../SOLO/pytorch/mmdet/datasets/voc.py | 20 - .../SOLO/pytorch/mmdet/datasets/wider_face.py | 42 - .../SOLO/pytorch/mmdet/datasets/xml_style.py | 86 - .../SOLO/pytorch/mmdet/models/__init__.py | 15 +- .../mmdet/models/anchor_heads/__init__.py | 25 - .../mmdet/models/anchor_heads/anchor_head.py | 330 --- .../mmdet/models/anchor_heads/atss_head.py | 487 ---- .../anchor_heads/decoupled_solo_head.py | 484 ---- .../anchor_heads/decoupled_solo_light_head.py | 479 ---- .../mmdet/models/anchor_heads/fcos_head.py | 408 --- .../mmdet/models/anchor_heads/fovea_head.py | 387 --- .../anchor_heads/free_anchor_retina_head.py | 188 -- .../models/anchor_heads/ga_retina_head.py | 107 - .../mmdet/models/anchor_heads/ga_rpn_head.py | 127 - .../models/anchor_heads/guided_anchor_head.py | 621 ---- .../models/anchor_heads/reppoints_head.py | 596 ---- .../mmdet/models/anchor_heads/retina_head.py | 103 - .../models/anchor_heads/retina_sepbn_head.py | 105 - .../mmdet/models/anchor_heads/rpn_head.py | 104 - .../mmdet/models/anchor_heads/solo_head.py | 433 --- .../mmdet/models/anchor_heads/solov2_head.py | 483 ---- .../models/anchor_heads/solov2_light_head.py | 482 ---- .../mmdet/models/anchor_heads/ssd_head.py | 201 -- .../mmdet/models/backbones/__init__.py | 10 +- .../pytorch/mmdet/models/backbones/hrnet.py | 524 ---- .../pytorch/mmdet/models/backbones/resnet.py | 536 ++-- .../pytorch/mmdet/models/backbones/resnext.py | 222 -- .../pytorch/mmdet/models/backbones/ssd_vgg.py | 153 - .../mmdet/models/bbox_heads/__init__.py | 7 - .../mmdet/models/bbox_heads/bbox_head.py | 282 -- .../models/bbox_heads/convfc_bbox_head.py | 187 -- .../models/bbox_heads/double_bbox_head.py | 170 -- .../SOLO/pytorch/mmdet/models/builder.py | 54 +- .../mmdet/models/dense_heads/__init__.py | 3 + .../mmdet/models/dense_heads/anchor_head.py | 542 ++++ .../models/dense_heads/base_dense_head.py | 526 ++++ .../models/dense_heads/base_mask_head.py | 116 + .../models/dense_heads/dense_test_mixins.py | 206 ++ .../mmdet/models/dense_heads/solo_head.py | 1177 ++++++++ .../mmdet/models/detectors/__init__.py | 29 +- .../pytorch/mmdet/models/detectors/atss.py | 16 - .../pytorch/mmdet/models/detectors/base.py | 381 ++- .../mmdet/models/detectors/cascade_rcnn.py | 520 ---- .../models/detectors/double_head_rcnn.py | 178 -- .../mmdet/models/detectors/fast_rcnn.py | 61 - .../mmdet/models/detectors/faster_rcnn.py | 27 - .../pytorch/mmdet/models/detectors/fcos.py | 16 - .../pytorch/mmdet/models/detectors/fovea.py | 16 - .../mmdet/models/detectors/grid_rcnn.py | 229 -- .../pytorch/mmdet/models/detectors/htc.py | 516 ---- .../mmdet/models/detectors/mask_rcnn.py | 31 - .../models/detectors/mask_scoring_rcnn.py | 200 -- .../models/detectors/reppoints_detector.py | 81 - .../mmdet/models/detectors/retinanet.py | 16 - .../pytorch/mmdet/models/detectors/rpn.py | 97 - .../mmdet/models/detectors/single_stage.py | 86 - .../models/detectors/single_stage_ins.py | 96 - .../detectors/single_stage_instance_seg.py | 343 +++ .../pytorch/mmdet/models/detectors/solo.py | 30 +- .../pytorch/mmdet/models/detectors/solov2.py | 17 - .../mmdet/models/detectors/test_mixins.py | 266 -- .../mmdet/models/detectors/two_stage.py | 346 --- .../pytorch/mmdet/models/losses/__init__.py | 23 +- .../pytorch/mmdet/models/losses/accuracy.py | 62 +- .../mmdet/models/losses/balanced_l1_loss.py | 69 - .../mmdet/models/losses/cross_entropy_loss.py | 103 - .../pytorch/mmdet/models/losses/dice_loss.py | 146 + .../pytorch/mmdet/models/losses/focal_loss.py | 178 +- .../pytorch/mmdet/models/losses/ghm_loss.py | 171 -- .../pytorch/mmdet/models/losses/iou_loss.py | 330 ++- .../pytorch/mmdet/models/losses/mse_loss.py | 25 - .../mmdet/models/losses/smooth_l1_loss.py | 45 - .../SOLO/pytorch/mmdet/models/losses/utils.py | 11 +- .../mmdet/models/mask_heads/__init__.py | 11 - .../mmdet/models/mask_heads/fcn_mask_head.py | 191 -- .../models/mask_heads/fused_semantic_head.py | 106 - .../mmdet/models/mask_heads/grid_head.py | 361 --- .../mmdet/models/mask_heads/htc_mask_head.py | 38 - .../mmdet/models/mask_heads/mask_feat_head.py | 119 - .../mmdet/models/mask_heads/maskiou_head.py | 190 -- .../pytorch/mmdet/models/necks/__init__.py | 9 +- .../SOLO/pytorch/mmdet/models/necks/bfp.py | 102 - .../SOLO/pytorch/mmdet/models/necks/fpn.py | 119 +- .../SOLO/pytorch/mmdet/models/necks/hrfpn.py | 100 - .../pytorch/mmdet/models/necks/nas_fpn.py | 186 -- .../pytorch/mmdet/models/plugins/__init__.py | 4 - .../pytorch/mmdet/models/plugins/non_local.py | 114 - .../SOLO/pytorch/mmdet/models/registry.py | 9 - .../mmdet/models/roi_extractors/__init__.py | 3 - .../models/roi_extractors/single_level.py | 107 - .../mmdet/models/shared_heads/__init__.py | 3 - .../mmdet/models/shared_heads/res_layer.py | 71 - .../pytorch/mmdet/models/utils/__init__.py | 15 +- .../pytorch/mmdet/models/utils/conv_ws.py | 46 - .../SOLO/pytorch/mmdet/models/utils/norm.py | 55 - .../pytorch/mmdet/models/utils/res_layer.py | 190 ++ .../pytorch/mmdet/models/utils/weight_init.py | 46 - .../SOLO/pytorch/mmdet/ops/__init__.py | 21 - .../SOLO/pytorch/mmdet/ops/dcn/__init__.py | 12 - .../SOLO/pytorch/mmdet/ops/dcn/deform_conv.py | 431 --- .../SOLO/pytorch/mmdet/ops/dcn/deform_pool.py | 252 -- .../mmdet/ops/dcn/src/deform_conv_cuda.cpp | 701 ----- .../ops/dcn/src/deform_conv_cuda_kernel.cu | 867 ------ .../mmdet/ops/dcn/src/deform_pool_cuda.cpp | 90 - .../ops/dcn/src/deform_pool_cuda_kernel.cu | 364 --- .../pytorch/mmdet/ops/masked_conv/__init__.py | 3 - .../mmdet/ops/masked_conv/masked_conv.py | 89 - .../masked_conv/src/masked_conv2d_cuda.cpp | 74 - .../masked_conv/src/masked_conv2d_kernel.cu | 114 - .../SOLO/pytorch/mmdet/ops/nms/__init__.py | 3 - .../SOLO/pytorch/mmdet/ops/nms/nms_wrapper.py | 102 - .../pytorch/mmdet/ops/nms/src/nms_cpu.cpp | 71 - .../pytorch/mmdet/ops/nms/src/nms_cuda.cpp | 17 - .../pytorch/mmdet/ops/nms/src/nms_kernel.cu | 139 - .../mmdet/ops/nms/src/soft_nms_cpu.pyx | 127 - .../pytorch/mmdet/ops/roi_align/__init__.py | 3 - .../pytorch/mmdet/ops/roi_align/gradcheck.py | 30 - .../pytorch/mmdet/ops/roi_align/roi_align.py | 87 - .../ops/roi_align/src/roi_align_cuda.cpp | 87 - .../ops/roi_align/src/roi_align_kernel.cu | 283 -- .../pytorch/mmdet/ops/roi_pool/__init__.py | 3 - .../pytorch/mmdet/ops/roi_pool/gradcheck.py | 16 - .../pytorch/mmdet/ops/roi_pool/roi_pool.py | 75 - .../mmdet/ops/roi_pool/src/roi_pool_cuda.cpp | 86 - .../mmdet/ops/roi_pool/src/roi_pool_kernel.cu | 157 - .../mmdet/ops/sigmoid_focal_loss/__init__.py | 3 - .../sigmoid_focal_loss/sigmoid_focal_loss.py | 54 - .../src/sigmoid_focal_loss.cpp | 45 - .../src/sigmoid_focal_loss_cuda.cu | 171 -- .../SOLO/pytorch/mmdet/ops/utils/__init__.py | 7 - .../SOLO/pytorch/mmdet/utils/__init__.py | 19 +- .../SOLO/pytorch/mmdet/utils/collect_env.py | 17 + .../SOLO/pytorch/mmdet/utils/compat_config.py | 139 + .../pytorch/mmdet/utils/contextmanagers.py | 12 +- .../SOLO/pytorch/mmdet/utils/logger.py | 97 +- .../SOLO/pytorch/mmdet/utils/memory.py | 213 ++ .../SOLO/pytorch/mmdet/utils/misc.py | 76 + .../SOLO/pytorch/mmdet/utils/profiling.py | 11 +- .../SOLO/pytorch/mmdet/utils/registry.py | 79 - .../pytorch/mmdet/utils/replace_cfg_vals.py | 70 + .../SOLO/pytorch/mmdet/utils/setup_env.py | 53 + .../SOLO/pytorch/mmdet/utils/split_batch.py | 45 + .../pytorch/mmdet/utils/util_distribution.py | 74 + .../SOLO/pytorch/mmdet/utils/util_mixins.py | 26 +- .../SOLO/pytorch/mmdet/utils/util_random.py | 34 + .../SOLO/pytorch/mmdet/version.py | 19 + .../SOLO/pytorch/requirements.txt | 11 +- .../SOLO/pytorch/requirements/build.txt | 4 - .../SOLO/pytorch/requirements/optional.txt | 2 - .../SOLO/pytorch/requirements/runtime.txt | 10 - .../SOLO/pytorch/requirements/tests.txt | 11 - .../SOLO/pytorch/setup.py | 489 ++-- .../SOLO/pytorch/tests/async_benchmark.py | 104 - .../SOLO/pytorch/tests/test_assigner.py | 277 -- .../SOLO/pytorch/tests/test_async.py | 78 - .../SOLO/pytorch/tests/test_config.py | 172 -- .../SOLO/pytorch/tests/test_forward.py | 388 --- .../SOLO/pytorch/tests/test_heads.py | 340 --- .../SOLO/pytorch/tests/test_nms.py | 70 - .../SOLO/pytorch/tests/test_sampler.py | 249 -- .../SOLO/pytorch/tests/test_utils.py | 9 - .../SOLO/pytorch/tools/analyze_logs.py | 178 -- .../SOLO/pytorch/tools/coco_error_analysis.py | 174 -- .../SOLO/pytorch/tools/coco_eval.py | 30 - .../tools/convert_datasets/pascal_voc.py | 141 - .../SOLO/pytorch/tools/detectron2pytorch.py | 88 - .../SOLO/pytorch/tools/dist_test.sh | 11 - .../SOLO/pytorch/tools/dist_train.sh | 8 - .../SOLO/pytorch/tools/get_flops.py | 55 - .../SOLO/pytorch/tools/publish_model.py | 35 - .../SOLO/pytorch/tools/robustness_eval.py | 256 -- .../SOLO/pytorch/tools/slurm_test.sh | 23 - .../SOLO/pytorch/tools/slurm_train.sh | 23 - .../SOLO/pytorch/tools/test_ins.py | 257 -- .../SOLO/pytorch/tools/test_ins_vis.py | 296 -- .../SOLO/pytorch/tools/test_robustness.py | 453 --- .../SOLO/pytorch/tools/train.py | 125 - .../pytorch/tools/upgrade_model_version.py | 42 - .../SOLO/pytorch/tools/voc_eval.py | 47 - .../SOLO/pytorch/train.py | 243 ++ .../SOLO/pytorch/train.sh | 17 + .../SOLO/pytorch/train_dist.sh | 33 + 503 files changed, 46490 insertions(+), 27464 deletions(-) create mode 100644 cv/instance_segmentation/SOLO.zip delete mode 100644 cv/instance_segmentation/SOLO/pytorch/.github/CODE_OF_CONDUCT.md delete mode 100644 cv/instance_segmentation/SOLO/pytorch/.github/CONTRIBUTING.md delete mode 100644 cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/config.yml delete mode 100644 cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/error-report.md delete mode 100644 cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/feature_request.md delete mode 100644 cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/general_questions.md delete mode 100644 cv/instance_segmentation/SOLO/pytorch/.gitmodules delete mode 100644 cv/instance_segmentation/SOLO/pytorch/.isort.cfg delete mode 100644 cv/instance_segmentation/SOLO/pytorch/.pre-commit-config.yaml delete mode 100644 cv/instance_segmentation/SOLO/pytorch/.style.yapf delete mode 100644 cv/instance_segmentation/SOLO/pytorch/.travis.yml rename cv/instance_segmentation/SOLO/pytorch/configs/{solo/solo_r50_fpn_8gpu_1x.py => _base_/datasets/coco_instance.py} (44%) create mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/_base_/default_runtime.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/_base_/schedules/schedule_1x.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/README.md delete mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_light_dcn_r50_fpn_8gpu_3x.py rename cv/instance_segmentation/SOLO/pytorch/configs/solo/{decoupled_solo_light_r50_fpn_8gpu_3x.py => decoupled_solo_light_r50_fpn_3x_coco.py} (36%) delete mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r101_fpn_8gpu_3x.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_1x_coco.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_3x_coco.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_8gpu_1x.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_8gpu_3x.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/metafile.yml delete mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r101_fpn_8gpu_3x.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_1x_coco.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_3x_coco.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_8gpu_3x.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/docker/Dockerfile create mode 100644 cv/instance_segmentation/SOLO/pytorch/docker/serve/Dockerfile create mode 100644 cv/instance_segmentation/SOLO/pytorch/docker/serve/config.properties create mode 100644 cv/instance_segmentation/SOLO/pytorch/docker/serve/entrypoint.sh create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/alexnet.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/activation.py rename cv/instance_segmentation/SOLO/pytorch/{mmdet/ops => mmcv/cnn/bricks}/context_block.py (69%) create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/conv.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/conv2d_adaptive_padding.py rename cv/instance_segmentation/SOLO/pytorch/{mmdet/models/utils => mmcv/cnn/bricks}/conv_module.py (35%) create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/conv_ws.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/depthwise_separable_conv_module.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/drop.py rename cv/instance_segmentation/SOLO/pytorch/{mmdet/models/plugins => mmcv/cnn/bricks}/generalized_attention.py (85%) create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/hsigmoid.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/hswish.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/non_local.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/norm.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/padding.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/plugin.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/registry.py rename cv/instance_segmentation/SOLO/pytorch/{mmdet/models/utils => mmcv/cnn/bricks}/scale.py (47%) create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/swish.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/transformer.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/upsample.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/wrappers.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/builder.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/resnet.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/__init__.py rename cv/instance_segmentation/SOLO/pytorch/{mmdet => mmcv/cnn}/utils/flops_counter.py (38%) create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/fuse_conv_bn.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/sync_bn.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/weight_init.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/vgg.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/engine/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/engine/test.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/file_client.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/base.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/json_handler.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/pickle_handler.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/yaml_handler.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/io.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/parse.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/image/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/image/colorspace.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/image/geometric.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/image/io.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/image/misc.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/image/photometric.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/model_zoo/deprecated.json create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/model_zoo/mmcls.json create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/model_zoo/open_mmlab.json create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/README.md create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/common_cuda_helper.hpp create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/nms_cuda_kernel.cuh create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/nms_rotated_cuda.cuh create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/roi_align_cuda_kernel.cuh create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/roi_pool_cuda_kernel.cuh create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/sigmoid_focal_loss_cuda_kernel.cuh create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/softmax_focal_loss_cuda_kernel.cuh create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/sync_bn_cuda_kernel.cuh create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/pytorch_cpp_helper.hpp create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/pytorch_cuda_helper.hpp create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/focal_loss_cuda.cu create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/nms_cuda.cu create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/roi_align_cuda.cu create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/roi_pool_cuda.cu create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/sync_bn_cuda.cu create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/focal_loss.cpp rename cv/instance_segmentation/SOLO/pytorch/{mmdet/ops/utils/src/compiling_info.cpp => mmcv/ops/csrc/pytorch/info.cpp} (79%) create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/nms.cpp create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/pybind.cpp create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/roi_align.cpp create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/roi_align_cpu.cpp create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/roi_pool.cpp create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/sync_bn.cpp create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/deprecated_wrappers.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/focal_loss.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/info.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/nms.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/point_sample.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/roi_align.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/roi_pool.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/ops/sync_bn.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/_functions.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/collate.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/data_container.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/data_parallel.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/distributed.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/distributed_deprecated.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/registry.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/scatter_gather.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/utils.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/base_module.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/base_runner.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/builder.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/checkpoint.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/default_constructor.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/dist_utils.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/epoch_based_runner.py rename cv/instance_segmentation/SOLO/pytorch/{mmdet/core/fp16/decorators.py => mmcv/runner/fp16_utils.py} (33%) create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/checkpoint.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/closure.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/ema.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/evaluation.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/hook.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/iter_timer.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/base.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/dvclive.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/mlflow.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/neptune.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/pavi.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/tensorboard.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/text.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/wandb.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/lr_updater.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/memory.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/momentum_updater.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/optimizer.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/profiler.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/sampler_seed.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/sync_buffer.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/iter_based_runner.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/log_buffer.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/optimizer/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/optimizer/builder.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/optimizer/default_constructor.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/priority.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/runner/utils.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/utils/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/utils/config.py rename cv/instance_segmentation/SOLO/pytorch/{tools/collect_env.py => mmcv/utils/env.py} (32%) create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/utils/ext_loader.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/utils/logging.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/utils/misc.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/utils/parrots_jit.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/utils/parrots_wrapper.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/utils/path.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/utils/progressbar.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/utils/registry.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/utils/testing.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/utils/timer.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/utils/trace.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/utils/version_utils.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmcv/version.py rename cv/instance_segmentation/SOLO/pytorch/{tools => mmdet/apis}/test.py (44%) delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/anchor_target.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/builder.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/guided_anchor_target.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/point_target.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/utils.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assign_sampling.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/center_region_assigner.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/grid_assigner.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/hungarian_assigner.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/mask_hungarian_assigner.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/region_assigner.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/sim_ota_assigner.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/task_aligned_assigner.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/uniform_assigner.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/bbox_target.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/builder.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/base_bbox_coder.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/bucketing_bbox_coder.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/delta_xywh_bbox_coder.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/distance_point_bbox_coder.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/legacy_delta_xywh_bbox_coder.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/pseudo_bbox_coder.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/tblr_bbox_coder.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/yolo_bbox_coder.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/geometry.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/iou_calculators/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/iou_calculators/builder.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/iou_calculators/iou2d_calculator.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/match_costs/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/match_costs/builder.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/match_costs/match_cost.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/mask_pseudo_sampler.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/mask_sampling_result.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/score_hlr_sampler.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/data_structures/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/data_structures/general_data.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/data_structures/instance_data.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/coco_utils.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/panoptic_utils.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/export/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/export/model_wrappers.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/export/onnx_helper.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/export/pytorch2onnx.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/__init__.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/hooks.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/utils.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/checkloss_hook.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/ema.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/memory_profiler_hook.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/set_epoch_info_hook.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/sync_norm_hook.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/sync_random_size_hook.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/wandblogger_hook.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/yolox_lrupdater_hook.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/yolox_mode_switch_hook.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/structures.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/optimizers/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/optimizers/builder.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/optimizers/layer_decay_optimizer_constructor.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/visualization/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/visualization/image.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/core/visualization/palette.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/api_wrappers/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/api_wrappers/coco_api.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/api_wrappers/panoptic_evaluation.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/cityscapes.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/__init__.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/build_loader.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/formatting.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/instaboost.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/test_aug.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/test_time_aug.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/registry.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/class_aware_sampler.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/distributed_sampler.py rename cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/{loader/sampler.py => samplers/group_sampler.py} (79%) create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/infinite_sampler.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/utils.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/voc.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/wider_face.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/xml_style.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/__init__.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/anchor_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/atss_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/decoupled_solo_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/decoupled_solo_light_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/fcos_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/fovea_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/free_anchor_retina_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ga_retina_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ga_rpn_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/guided_anchor_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/reppoints_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/retina_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/retina_sepbn_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/rpn_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solo_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solov2_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solov2_light_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ssd_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/hrnet.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/resnext.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/ssd_vgg.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/__init__.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/bbox_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/convfc_bbox_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/double_bbox_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/anchor_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/base_dense_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/base_mask_head.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/dense_test_mixins.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/solo_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/atss.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/cascade_rcnn.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/double_head_rcnn.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fast_rcnn.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/faster_rcnn.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fcos.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fovea.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/grid_rcnn.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/htc.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/mask_rcnn.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/mask_scoring_rcnn.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/reppoints_detector.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/retinanet.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/rpn.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage_ins.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage_instance_seg.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/solov2.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/test_mixins.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/two_stage.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/balanced_l1_loss.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/cross_entropy_loss.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/dice_loss.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/ghm_loss.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/mse_loss.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/smooth_l1_loss.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/__init__.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/fcn_mask_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/fused_semantic_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/grid_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/htc_mask_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/mask_feat_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/maskiou_head.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/bfp.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/hrfpn.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/nas_fpn.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/__init__.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/non_local.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/registry.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/roi_extractors/__init__.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/roi_extractors/single_level.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/shared_heads/__init__.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/shared_heads/res_layer.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/conv_ws.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/norm.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/res_layer.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/weight_init.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/__init__.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/__init__.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/deform_conv.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/deform_pool.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_conv_cuda.cpp delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_conv_cuda_kernel.cu delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_pool_cuda.cpp delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_pool_cuda_kernel.cu delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/__init__.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/masked_conv.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/src/masked_conv2d_cuda.cpp delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/src/masked_conv2d_kernel.cu delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/__init__.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/nms_wrapper.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_cpu.cpp delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_cuda.cpp delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_kernel.cu delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/soft_nms_cpu.pyx delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/__init__.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/gradcheck.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/roi_align.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/src/roi_align_cuda.cpp delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/src/roi_align_kernel.cu delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/__init__.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/gradcheck.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/roi_pool.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/src/roi_pool_cuda.cpp delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/src/roi_pool_kernel.cu delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/__init__.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/sigmoid_focal_loss.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss.cpp delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss_cuda.cu delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/ops/utils/__init__.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/utils/collect_env.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/utils/compat_config.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/utils/memory.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/utils/misc.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/utils/registry.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/utils/replace_cfg_vals.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/utils/setup_env.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/utils/split_batch.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/utils/util_distribution.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/utils/util_random.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/mmdet/version.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/requirements/build.txt delete mode 100644 cv/instance_segmentation/SOLO/pytorch/requirements/optional.txt delete mode 100644 cv/instance_segmentation/SOLO/pytorch/requirements/runtime.txt delete mode 100644 cv/instance_segmentation/SOLO/pytorch/requirements/tests.txt delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tests/async_benchmark.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tests/test_assigner.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tests/test_async.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tests/test_config.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tests/test_forward.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tests/test_heads.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tests/test_nms.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tests/test_sampler.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tests/test_utils.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/analyze_logs.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/coco_error_analysis.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/coco_eval.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/convert_datasets/pascal_voc.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/detectron2pytorch.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/dist_test.sh delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/dist_train.sh delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/get_flops.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/publish_model.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/robustness_eval.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/slurm_test.sh delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/slurm_train.sh delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/test_ins.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/test_ins_vis.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/test_robustness.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/train.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/upgrade_model_version.py delete mode 100644 cv/instance_segmentation/SOLO/pytorch/tools/voc_eval.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/train.py create mode 100644 cv/instance_segmentation/SOLO/pytorch/train.sh create mode 100644 cv/instance_segmentation/SOLO/pytorch/train_dist.sh diff --git a/cv/instance_segmentation/SOLO.zip b/cv/instance_segmentation/SOLO.zip new file mode 100644 index 0000000000000000000000000000000000000000..bf78bb57d9197c7157c70878cc67ebac9c6c3b2a GIT binary patch literal 604461 zcmbSy18^)_x^-;Z&WY`u*tTU=S35KYqfq%~k&P;=g`Dd_CK`IojA8n9|Ap*D45rYCkiTqq___bYK90 z3s3+6q(7~qH8FEEGqJX@H?mTajM-p?>B7G8L5R&p!+o2{57|n;0uzg)_P3ssl*6c> zsB1EaC?9cig@3suHJWtPd>{&!y}gyUnOINKJGKq;4(@FPBYqp~K6v{b0&h%bUtUoi zQPE)SUu|)IRvmV(8q%L*|C_ctDuX6WUaOO#8>@vL!s&Pfyj;D%9Mip{-c5X(&DfV-gdW#>uX2Rhnbg7Wqkb+G;WYOtSnzG z%g74IQ6`tq1v7$rhO{jBe`}>e#QpiT+f{F^A-XY6*U%q zc5fZ#K(nwsSpjHlX8C~#laA$$2f>t9%+Ak)Pe`79a^x_ctAnMRAU0!POb{S0w>4Ov zQKr-->8cMMf0NM+wcw*0kkM#eB%#D_%Zmf!)C!j*`@*A(M~h9ZiXy#=s(_HpSS%?< z)fE}yM^~)qb=ga$M)A`I$=czPDT0lf8aWBDBvl=Kmc5Y@)au*3>-71AJXcS=6(SO7 zfw>J1WRSH0F(j3_u?HDcQW0BVMkV%@ZN0}OteCFnF z!sovKR(vACRw8O4W}wAP4{41(N_)tP9JQauP$QXo_g{%C7P!D=8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0~x&&D7z)sGRBGJ2TIoroiEZ@zLGIW=oz&3At9m5w_u zJXFDhE5A&`j*V7y{q>q;rJz^&8EBJtBT$|lJLn2nzj!w#fzk55-4-hq(P@NCuO~_e zQ_yRhH4iXWKBUz|=Q*aLJa}BcxGT@=!ESUvOrc|AWkSPJg@i4I3NJly+CB7`0w*tT ziojY0NWk)D5c}b~OSU|)T&=%dm|cx*4P8t!@cluDIx+a~5(;eq1+{MVw zU$Cc`Wu8$?x0hnfBd6adCqvq~1D6HZwDZ(X2{R;I9Z9aI$fs_f^P;HVtWB`JwS8i& zP*R(;pFNiWY8qr3HWTb=se}rntzsfW)S*zdMDPpC@4r&q_RBAY5!2?q7UO;zp($eo z<}`vbogMzWpsg5}USZ_?^vVSa*I?XYH0X%4Q-oq}b@OkN2#F^IoQ8!v?<|HBekde< z^Jes)`dhc6bj@7igmC#MYuWDv=`I4Kl+204&g-TC7pU>&WOK=ilLig`y_<#A@J64FWPkdiI;n!>J@ZS~QlO8#F}(&L4Za~$&FGZeYGdLc^NF;k3OW{uMs zLvW*)Fg}NsHpZ(IWZ^E^({KwqQ=64`DD7XL5{1%^9e!p08_2UTk8^|HPNEoHFIK)u4yBUDCkZij$A7+A z3H;?7Sk8>W`1%9JVApOv`@7nQ`27g+YlUiPB<()nx=UAclD2t;6)w%b(E~{LgFjYb zj=qu@5&jdS0wes%$Bs1ikui}!BK3Vwg<0UVE0iEa*PSaA=E#QaqYgmjJ=TeQETJ*r zk^fo2U*-=;7}lKeEjwhOEcty`Bf|bAVg&bmr@aA?xxC=VS%jq%C0XE!ZXh2FU-nb7Do z`FGwP<4%m(L1v64LeNO30YpnSaU25X1$!3eN!!|}s(-tE`Gfp?^g8civl~Md33vDm QlMEXkfD^rVSe_032gFu>FaQ7m literal 0 HcmV?d00001 diff --git a/cv/instance_segmentation/SOLO/pytorch/.github/CODE_OF_CONDUCT.md b/cv/instance_segmentation/SOLO/pytorch/.github/CODE_OF_CONDUCT.md deleted file mode 100644 index efd430579..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/.github/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,76 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, sex characteristics, gender identity and expression, -level of experience, education, socio-economic status, nationality, personal -appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment -include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at chenkaidev@gmail.com. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html - -[homepage]: https://www.contributor-covenant.org - -For answers to common questions about this code of conduct, see -https://www.contributor-covenant.org/faq diff --git a/cv/instance_segmentation/SOLO/pytorch/.github/CONTRIBUTING.md b/cv/instance_segmentation/SOLO/pytorch/.github/CONTRIBUTING.md deleted file mode 100644 index 39c145a1f..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/.github/CONTRIBUTING.md +++ /dev/null @@ -1,53 +0,0 @@ -# Contributing to mmdetection - -All kinds of contributions are welcome, including but not limited to the following. - -- Fixes (typo, bugs) -- New features and components - -## Workflow - -1. fork and pull the latest mmdetection -2. checkout a new branch (do not use master branch for PRs) -3. commit your changes -4. create a PR - -Note -- If you plan to add some new features that involve large changes, it is encouraged to open an issue for discussion first. -- If you are the author of some papers and would like to include your method to mmdetection, -please contact Kai Chen (chenkaidev[at]gmail[dot]com). We will much appreciate your contribution. - -## Code style - -### Python -We adopt [PEP8](https://www.python.org/dev/peps/pep-0008/) as the preferred code style. - -We use the following tools for linting and formatting: -- [flake8](http://flake8.pycqa.org/en/latest/): linter -- [yapf](https://github.com/google/yapf): formatter -- [isort](https://github.com/timothycrosley/isort): sort imports - -Style configurations of yapf and isort can be found in [.style.yapf](../.style.yapf) and [.isort.cfg](../.isort.cfg). - -We use [pre-commit hook](https://pre-commit.com/) that checks and formats for `flake8`, `yapf`, `isort`, `trailing whitespaces`, - fixes `end-of-files`, sorts `requirments.txt` automatically on every commit. -The config for a pre-commit hook is stored in [.pre-commit-config](../.pre-commit-config.yaml). - -After you clone the repository, you will need to install initialize pre-commit hook. - -``` -pip install -U pre-commit -``` - -From the repository folder -``` -pre-commit install -``` - -After this on every commit check code linters and formatter will be enforced. - - ->Before you create a PR, make sure that your code lints and is formatted by yapf. - -### C++ and CUDA -We follow the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). diff --git a/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/config.yml b/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index 3ba13e0ce..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1 +0,0 @@ -blank_issues_enabled: false diff --git a/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/error-report.md b/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/error-report.md deleted file mode 100644 index 80e1cc58e..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/error-report.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -name: Error report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -Thanks for your error report and we appreciate it a lot. - -**Checklist** -1. I have searched related issues but cannot get the expected help. -2. The bug has not been fixed in the latest version. - -**Describe the bug** -A clear and concise description of what the bug is. - -**Reproduction** -1. What command or script did you run? -``` -A placeholder for the command. -``` -2. Did you make any modifications on the code or config? Did you understand what you have modified? -3. What dataset did you use? - -**Environment** - -1. Please run `python tools/collect_env.py` to collect necessary environment infomation and paste it here. -2. You may add addition that may be helpful for locating the problem, such as - - How you installed PyTorch [e.g., pip, conda, source] - - Other environment variables that may be related (such as `$PATH`, `$LD_LIBRARY_PATH`, `$PYTHONPATH`, etc.) - -**Error traceback** -If applicable, paste the error trackback here. -``` -A placeholder for trackback. -``` - -**Bug fix** -If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated! diff --git a/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/feature_request.md b/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 33f9d5f23..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - ---- - -**Describe the feature** - -**Motivation** -A clear and concise description of the motivation of the feature. -Ex1. It is inconvenient when [....]. -Ex2. There is a recent paper [....], which is very helpful for [....]. - -**Related resources** -If there is an official code release or third-party implementations, please also provide the information here, which would be very helpful. - -**Additional context** -Add any other context or screenshots about the feature request here. -If you would like to implement the feature and create a PR, please leave a comment here and that would be much appreciated. diff --git a/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/general_questions.md b/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/general_questions.md deleted file mode 100644 index 6211ca283..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/.github/ISSUE_TEMPLATE/general_questions.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -name: General questions -about: Ask general questions to get help -title: '' -labels: '' -assignees: '' - ---- - - diff --git a/cv/instance_segmentation/SOLO/pytorch/.gitignore b/cv/instance_segmentation/SOLO/pytorch/.gitignore index 306a2bf4e..a47ecb183 100644 --- a/cv/instance_segmentation/SOLO/pytorch/.gitignore +++ b/cv/instance_segmentation/SOLO/pytorch/.gitignore @@ -64,7 +64,8 @@ instance/ .scrapy # Sphinx documentation -docs/_build/ +docs/en/_build/ +docs/zh_cn/_build/ # PyBuilder target/ @@ -103,19 +104,23 @@ venv.bak/ # mypy .mypy_cache/ -# cython generated cpp -mmdet/ops/nms/src/soft_nms_cpu.cpp -mmdet/version.py +data/ data .vscode .idea +.DS_Store # custom *.pkl *.pkl.json -*.segm.json *.log.json +docs/modelzoo_statistics.md +mmdet/.mim work_dirs/ # Pytorch *.pth +*.py~ +*.sh~ +demo/ +docs/ diff --git a/cv/instance_segmentation/SOLO/pytorch/.gitmodules b/cv/instance_segmentation/SOLO/pytorch/.gitmodules deleted file mode 100644 index 03b361da1..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "paddlepaddle/paddledetection"] - path = paddlepaddle/paddledetection - url = https://github.com/PaddlePaddle/PaddleDetection diff --git a/cv/instance_segmentation/SOLO/pytorch/.isort.cfg b/cv/instance_segmentation/SOLO/pytorch/.isort.cfg deleted file mode 100644 index 9f43efc7d..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/.isort.cfg +++ /dev/null @@ -1,8 +0,0 @@ -[isort] -line_length = 79 -multi_line_output = 0 -known_standard_library = setuptools -known_first_party = mmdet -known_third_party = Cython,asynctest,cv2,matplotlib,mmcv,numpy,pycocotools,robustness_eval,roi_align,roi_pool,seaborn,six,terminaltables,torch,torchvision -no_lines_before = STDLIB,LOCALFOLDER -default_section = THIRDPARTY diff --git a/cv/instance_segmentation/SOLO/pytorch/.pre-commit-config.yaml b/cv/instance_segmentation/SOLO/pytorch/.pre-commit-config.yaml deleted file mode 100644 index 901104c2c..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/.pre-commit-config.yaml +++ /dev/null @@ -1,21 +0,0 @@ -repos: -- repo: https://github.com/asottile/seed-isort-config - rev: v1.9.3 - hooks: - - id: seed-isort-config -- repo: https://github.com/pre-commit/mirrors-isort - rev: v4.3.21 - hooks: - - id: isort -- repo: https://github.com/pre-commit/mirrors-yapf - rev: v0.29.0 - hooks: - - id: yapf -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.4.0 - hooks: - - id: flake8 - - id: trailing-whitespace - - id: check-yaml - - id: end-of-file-fixer - - id: requirements-txt-fixer diff --git a/cv/instance_segmentation/SOLO/pytorch/.style.yapf b/cv/instance_segmentation/SOLO/pytorch/.style.yapf deleted file mode 100644 index 286a3f1d7..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/.style.yapf +++ /dev/null @@ -1,4 +0,0 @@ -[style] -BASED_ON_STYLE = pep8 -BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF = true -SPLIT_BEFORE_EXPRESSION_AFTER_OPENING_PAREN = true diff --git a/cv/instance_segmentation/SOLO/pytorch/.travis.yml b/cv/instance_segmentation/SOLO/pytorch/.travis.yml deleted file mode 100644 index b39defb3f..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/.travis.yml +++ /dev/null @@ -1,43 +0,0 @@ -dist: bionic # ubuntu 18.04 -language: python - -python: - - "3.5" - - "3.6" - - "3.7" - -env: CUDA=10.1.105-1 CUDA_SHORT=10.1 UBUNTU_VERSION=ubuntu1804 FORCE_CUDA=1 -cache: pip - -# Ref to CUDA installation in Travis: https://github.com/jeremad/cuda-travis -before_install: - - INSTALLER=cuda-repo-${UBUNTU_VERSION}_${CUDA}_amd64.deb - - wget http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/${INSTALLER} - - sudo dpkg -i ${INSTALLER} - - wget https://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/7fa2af80.pub - - sudo apt-key add 7fa2af80.pub - - sudo apt update -qq - - sudo apt install -y cuda-${CUDA_SHORT/./-} cuda-cufft-dev-${CUDA_SHORT/./-} - - sudo apt clean - - CUDA_HOME=/usr/local/cuda-${CUDA_SHORT} - - LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${CUDA_HOME}/include:${LD_LIBRARY_PATH} - - PATH=${CUDA_HOME}/bin:${PATH} - -install: - - pip install Pillow==6.2.2 # remove this line when torchvision>=0.5 - - pip install Cython torch==1.2 torchvision==0.4.0 # TODO: fix CI for pytorch>1.2 - - pip install "git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI" - - pip install -r requirements.txt - -before_script: - - flake8 . - - isort -rc --check-only --diff mmdet/ tools/ tests/ - - yapf -r -d --style .style.yapf mmdet/ tools/ tests/ configs/ - -script: - - python setup.py check -m -s - - python setup.py build_ext --inplace - - coverage run --source mmdet -m py.test -v --xdoctest-modules tests mmdet - -after_success: - - coverage report diff --git a/cv/instance_segmentation/SOLO/pytorch/LICENSE b/cv/instance_segmentation/SOLO/pytorch/LICENSE index e01680d91..1bfc23e48 100644 --- a/cv/instance_segmentation/SOLO/pytorch/LICENSE +++ b/cv/instance_segmentation/SOLO/pytorch/LICENSE @@ -1,25 +1,203 @@ -SOLO for non-commercial purposes - -Copyright (c) 2019 the authors -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Copyright 2018-2023 OpenMMLab. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2018-2023 OpenMMLab. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cv/instance_segmentation/SOLO/pytorch/README.md b/cv/instance_segmentation/SOLO/pytorch/README.md index 25ab9bb8c..17fdb4e63 100644 --- a/cv/instance_segmentation/SOLO/pytorch/README.md +++ b/cv/instance_segmentation/SOLO/pytorch/README.md @@ -4,22 +4,16 @@ We present a new, embarrassingly simple approach to instance segmentation in images. Compared to many other dense prediction tasks, e.g., semantic segmentation, it is the arbitrary number of instances that have made instance segmentation much more challenging. In order to predict a mask for each instance, mainstream approaches either follow the 'detect-thensegment' strategy as used by Mask R-CNN, or predict category masks first then use clustering techniques to group pixels into individual instances. We view the task of instance segmentation from a completely new perspective by introducing the notion of "instance categories", which assigns categories to each pixel within an instance according to the instance's location and size, thus nicely converting instance mask segmentation into a classification-solvable problem. Now instance segmentation is decomposed into two classification tasks. We demonstrate a much simpler and flexible instance segmentation framework with strong performance, achieving on par accuracy with Mask R-CNN and outperforming recent singleshot instance segmenters in accuracy. We hope that this very simple and strong framework can serve as a baseline for many instance-level recognition tasks besides instance segmentation. -## Prepare - -### Install packages - -```shell - -pip3 install -r requirements/build.txt -pip3 install "git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI" -pip3 install -v -e . +## Step 1: Installing packages +```bash +$ pip3 install -r requirements.txt +$ MMCV_WITH_OPS=1 python3 setup.py build && cp build/lib.linux*/mmcv/_ext.cpython* mmcv ``` -### Download dataset - -```shell +## Step 2: Preparing datasets +```bash $ mkdir -p data/coco $ cd data/coco $ wget http://images.cocodataset.org/zips/annotations_trainval2017.zip @@ -28,28 +22,23 @@ $ wget http://images.cocodataset.org/zips/val2017.zip $ unzip annotations_trainval2017.zip $ unzip train2017.zip $ unzip val2017.zip - ``` -## Training +## Step 3: Training -### Single GPU - -```shell - -python3 tools/train.py configs/solo/solo_r50_fpn_8gpu_1x.py +### One single GPU +```bash +bash train.sh ``` -### Multi GPU - -```shell - -bash ./tools/dist_train.sh configs/solo/solo_r50_fpn_8gpu_1x.py ${GPU_NUM} +### Multiple GPUs on one machine +```bash +$ bash dist_train.sh [training args] # config file can be found in the configs directory +# Avaiable configs are in configs/solo ``` +## Reference -## Refrence - -Reference: https://github.com/WXinlong/SOLO \ No newline at end of file +Reference: https://github.com/WXinlong/SOLO diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_8gpu_1x.py b/cv/instance_segmentation/SOLO/pytorch/configs/_base_/datasets/coco_instance.py similarity index 44% rename from cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_8gpu_1x.py rename to cv/instance_segmentation/SOLO/pytorch/configs/_base_/datasets/coco_instance.py index 7c1796a10..9901a8584 100644 --- a/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_8gpu_1x.py +++ b/cv/instance_segmentation/SOLO/pytorch/configs/_base_/datasets/coco_instance.py @@ -1,53 +1,3 @@ -# model settings -model = dict( - type='SOLO', - pretrained='torchvision://resnet50', - backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(0, 1, 2, 3), # C2, C3, C4, C5 - frozen_stages=1, - style='pytorch'), - neck=dict( - type='FPN', - in_channels=[256, 512, 1024, 2048], - out_channels=256, - start_level=0, - num_outs=5), - bbox_head=dict( - type='SOLOHead', - num_classes=81, - in_channels=256, - stacked_convs=7, - seg_feat_channels=256, - strides=[8, 8, 16, 32, 32], - scale_ranges=((1, 96), (48, 192), (96, 384), (192, 768), (384, 2048)), - sigma=0.2, - num_grids=[40, 36, 24, 16, 12], - cate_down_pos=0, - with_deform=False, - loss_ins=dict( - type='DiceLoss', - use_sigmoid=True, - loss_weight=3.0), - loss_cate=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=1.0), - )) -# training and testing settings -train_cfg = dict() -test_cfg = dict( - nms_pre=500, - score_thr=0.1, - mask_thr=0.5, - update_thr=0.05, - kernel='gaussian', # gaussian/linear - sigma=2.0, - max_per_img=100) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' @@ -79,7 +29,7 @@ test_pipeline = [ ]) ] data = dict( - imgs_per_gpu=2, + samples_per_gpu=2, workers_per_gpu=2, train=dict( type=dataset_type, @@ -96,31 +46,4 @@ data = dict( ann_file=data_root + 'annotations/instances_val2017.json', img_prefix=data_root + 'val2017/', pipeline=test_pipeline)) -# optimizer -optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - step=[9, 11]) -checkpoint_config = dict(interval=1) -# yapf:disable -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - # dict(type='TensorboardLoggerHook') - ]) -# yapf:enable -# runtime settings -total_epochs = 12 -device_ids = range(8) -dist_params = dict(backend='nccl') -log_level = 'INFO' -work_dir = './work_dirs/solo_release_r50_fpn_8gpu_1x' -load_from = None -resume_from = None -workflow = [('train', 1)] +evaluation = dict(metric=['bbox', 'segm']) diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/_base_/default_runtime.py b/cv/instance_segmentation/SOLO/pytorch/configs/_base_/default_runtime.py new file mode 100644 index 000000000..5b0b1452c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/configs/_base_/default_runtime.py @@ -0,0 +1,27 @@ +checkpoint_config = dict(interval=1) +# yapf:disable +log_config = dict( + interval=50, + hooks=[ + dict(type='TextLoggerHook'), + # dict(type='TensorboardLoggerHook') + ]) +# yapf:enable +custom_hooks = [dict(type='NumClassCheckHook')] + +dist_params = dict(backend='nccl') +log_level = 'INFO' +load_from = None +resume_from = None +workflow = [('train', 1)] + +# disable opencv multithreading to avoid system being overloaded +opencv_num_threads = 0 +# set multi-process start method as `fork` to speed up the training +mp_start_method = 'fork' + +# Default setting for scaling LR automatically +# - `enable` means enable scaling LR automatically +# or not by default. +# - `base_batch_size` = (8 GPUs) x (2 samples per GPU). +auto_scale_lr = dict(enable=False, base_batch_size=16) diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/_base_/schedules/schedule_1x.py b/cv/instance_segmentation/SOLO/pytorch/configs/_base_/schedules/schedule_1x.py new file mode 100644 index 000000000..13b3783cb --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/configs/_base_/schedules/schedule_1x.py @@ -0,0 +1,11 @@ +# optimizer +optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001) +optimizer_config = dict(grad_clip=None) +# learning policy +lr_config = dict( + policy='step', + warmup='linear', + warmup_iters=500, + warmup_ratio=0.001, + step=[8, 11]) +runner = dict(type='EpochBasedRunner', max_epochs=12) diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/README.md b/cv/instance_segmentation/SOLO/pytorch/configs/solo/README.md new file mode 100644 index 000000000..8bd043255 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/configs/solo/README.md @@ -0,0 +1,54 @@ +# SOLO + +> [SOLO: Segmenting Objects by Locations](https://arxiv.org/abs/1912.04488) + + + +## Abstract + +We present a new, embarrassingly simple approach to instance segmentation in images. Compared to many other dense prediction tasks, e.g., semantic segmentation, it is the arbitrary number of instances that have made instance segmentation much more challenging. In order to predict a mask for each instance, mainstream approaches either follow the 'detect-thensegment' strategy as used by Mask R-CNN, or predict category masks first then use clustering techniques to group pixels into individual instances. We view the task of instance segmentation from a completely new perspective by introducing the notion of "instance categories", which assigns categories to each pixel within an instance according to the instance's location and size, thus nicely converting instance mask segmentation into a classification-solvable problem. Now instance segmentation is decomposed into two classification tasks. We demonstrate a much simpler and flexible instance segmentation framework with strong performance, achieving on par accuracy with Mask R-CNN and outperforming recent singleshot instance segmenters in accuracy. We hope that this very simple and strong framework can serve as a baseline for many instance-level recognition tasks besides instance segmentation. + +

    + +## Results and Models + +### SOLO + +| Backbone | Style | MS train | Lr schd | Mem (GB) | Inf time (fps) | mask AP | Download | +|:---------:|:-------:|:--------:|:-------:|:--------:|:--------------:|:------:|:--------:| +| R-50 | pytorch | N | 1x | 8.0 | 14.0 | 33.1 | [model](https://download.openmmlab.com/mmdetection/v2.0/solo/solo_r50_fpn_1x_coco/solo_r50_fpn_1x_coco_20210821_035055-2290a6b8.pth) | [log](https://download.openmmlab.com/mmdetection/v2.0/solo/solo_r50_fpn_1x_coco/solo_r50_fpn_1x_coco_20210821_035055.log.json) | +| R-50 | pytorch | Y | 3x | 7.4 | 14.0 | 35.9 | [model](https://download.openmmlab.com/mmdetection/v2.0/solo/solo_r50_fpn_3x_coco/solo_r50_fpn_3x_coco_20210901_012353-11d224d7.pth) | [log](https://download.openmmlab.com/mmdetection/v2.0/solo/solo_r50_fpn_3x_coco/solo_r50_fpn_3x_coco_20210901_012353.log.json) | + +### Decoupled SOLO + +| Backbone | Style | MS train | Lr schd | Mem (GB) | Inf time (fps) | mask AP | Download | +|:---------:|:-------:|:--------:|:-------:|:--------:|:--------------:|:-------:|:--------:| +| R-50 | pytorch | N | 1x | 7.8 | 12.5 | 33.9 | [model](https://download.openmmlab.com/mmdetection/v2.0/solo/decoupled_solo_r50_fpn_1x_coco/decoupled_solo_r50_fpn_1x_coco_20210820_233348-6337c589.pth) | [log](https://download.openmmlab.com/mmdetection/v2.0/solo/decoupled_solo_r50_fpn_1x_coco/decoupled_solo_r50_fpn_1x_coco_20210820_233348.log.json) | +| R-50 | pytorch | Y | 3x | 7.9 | 12.5 | 36.7 | [model](https://download.openmmlab.com/mmdetection/v2.0/solo/decoupled_solo_r50_fpn_3x_coco/decoupled_solo_r50_fpn_3x_coco_20210821_042504-7b3301ec.pth) | [log](https://download.openmmlab.com/mmdetection/v2.0/solo/decoupled_solo_r50_fpn_3x_coco/decoupled_solo_r50_fpn_3x_coco_20210821_042504.log.json) | + +- Decoupled SOLO has a decoupled head which is different from SOLO head. +Decoupled SOLO serves as an efficient and equivalent variant in accuracy +of SOLO. Please refer to the corresponding config files for details. + +### Decoupled Light SOLO + +| Backbone | Style | MS train | Lr schd | Mem (GB) | Inf time (fps) | mask AP | Download | +|:---------:|:-------:|:--------:|:-------:|:--------:|:--------------:|:------:|:--------:| +| R-50 | pytorch | Y | 3x | 2.2 | 31.2 | 32.9 | [model](https://download.openmmlab.com/mmdetection/v2.0/solo/decoupled_solo_light_r50_fpn_3x_coco/decoupled_solo_light_r50_fpn_3x_coco_20210906_142703-e70e226f.pth) | [log](https://download.openmmlab.com/mmdetection/v2.0/solo/decoupled_solo_light_r50_fpn_3x_coco/decoupled_solo_light_r50_fpn_3x_coco_20210906_142703.log.json) | + +- Decoupled Light SOLO using decoupled structure similar to Decoupled +SOLO head, with light-weight head and smaller input size, Please refer +to the corresponding config files for details. + +## Citation + +```latex +@inproceedings{wang2020solo, + title = {{SOLO}: Segmenting Objects by Locations}, + author = {Wang, Xinlong and Kong, Tao and Shen, Chunhua and Jiang, Yuning and Li, Lei}, + booktitle = {Proc. Eur. Conf. Computer Vision (ECCV)}, + year = {2020} +} +``` diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_light_dcn_r50_fpn_8gpu_3x.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_light_dcn_r50_fpn_8gpu_3x.py deleted file mode 100644 index e72d112ae..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_light_dcn_r50_fpn_8gpu_3x.py +++ /dev/null @@ -1,136 +0,0 @@ -# model settings -model = dict( - type='SOLO', - pretrained='torchvision://resnet50', - backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(0, 1, 2, 3), # C2, C3, C4, C5 - frozen_stages=1, - style='pytorch', - dcn=dict( - type='DCN', - deformable_groups=1, - fallback_on_stride=False), - stage_with_dcn=(False, True, True, True)), - neck=dict( - type='FPN', - in_channels=[256, 512, 1024, 2048], - out_channels=256, - start_level=0, - num_outs=5), - bbox_head=dict( - type='DecoupledSOLOLightHead', - num_classes=81, - in_channels=256, - stacked_convs=4, - use_dcn_in_tower=True, - type_dcn='DCN', - seg_feat_channels=256, - strides=[8, 8, 16, 32, 32], - scale_ranges=((1, 64), (32, 128), (64, 256), (128, 512), (256, 2048)), - sigma=0.2, - num_grids=[40, 36, 24, 16, 12], - cate_down_pos=0, - loss_ins=dict( - type='DiceLoss', - use_sigmoid=True, - loss_weight=3.0), - loss_cate=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=1.0), - )) -# training and testing settings -train_cfg = dict() -test_cfg = dict( - nms_pre=500, - score_thr=0.1, - mask_thr=0.5, - update_thr=0.05, - kernel='gaussian', # gaussian/linear - sigma=2.0, - max_per_img=100) -# dataset settings -dataset_type = 'CocoDataset' -data_root = 'data/coco/' -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) -train_pipeline = [ - dict(type='LoadImageFromFile'), - dict(type='LoadAnnotations', with_bbox=True, with_mask=True), - dict(type='Resize', - img_scale=[(852, 512), (852, 480), (852, 448), - (852, 416), (852, 384), (852, 352)], - multiscale_mode='value', - keep_ratio=True), - dict(type='RandomFlip', flip_ratio=0.5), - dict(type='Normalize', **img_norm_cfg), - dict(type='Pad', size_divisor=32), - dict(type='DefaultFormatBundle'), - dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']), -] -test_pipeline = [ - dict(type='LoadImageFromFile'), - dict( - type='MultiScaleFlipAug', - img_scale=(852, 512), - flip=False, - transforms=[ - dict(type='Resize', keep_ratio=True), - dict(type='RandomFlip'), - dict(type='Normalize', **img_norm_cfg), - dict(type='Pad', size_divisor=32), - dict(type='ImageToTensor', keys=['img']), - dict(type='Collect', keys=['img']), - ]) -] -data = dict( - imgs_per_gpu=2, - workers_per_gpu=2, - train=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_train2017.json', - img_prefix=data_root + 'train2017/', - pipeline=train_pipeline), - val=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_val2017.json', - img_prefix=data_root + 'val2017/', - pipeline=test_pipeline), - test=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_val2017.json', - img_prefix=data_root + 'val2017/', - pipeline=test_pipeline)) -# optimizer -optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - step=[27, 33]) -checkpoint_config = dict(interval=1) -# yapf:disable -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - # dict(type='TensorboardLoggerHook') - ]) -# yapf:enable -# runtime settings -total_epochs = 36 -device_ids = range(8) -dist_params = dict(backend='nccl') -log_level = 'INFO' -work_dir = './work_dirs/decoupled_solo_light_dcn_release_r50_fpn_8gpu_3x' -load_from = None -resume_from = None -workflow = [('train', 1)] diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_light_r50_fpn_8gpu_3x.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_light_r50_fpn_3x_coco.py similarity index 36% rename from cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_light_r50_fpn_8gpu_3x.py rename to cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_light_r50_fpn_3x_coco.py index d38ee0f5b..101f8f1d3 100644 --- a/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_light_r50_fpn_8gpu_3x.py +++ b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_light_r50_fpn_3x_coco.py @@ -1,65 +1,40 @@ +_base_ = './decoupled_solo_r50_fpn_3x_coco.py' + # model settings model = dict( - type='SOLO', - pretrained='torchvision://resnet50', - backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(0, 1, 2, 3), # C2, C3, C4, C5 - frozen_stages=1, - style='pytorch'), - neck=dict( - type='FPN', - in_channels=[256, 512, 1024, 2048], - out_channels=256, - start_level=0, - num_outs=5), - bbox_head=dict( + mask_head=dict( type='DecoupledSOLOLightHead', - num_classes=81, + num_classes=80, in_channels=256, stacked_convs=4, - seg_feat_channels=256, + feat_channels=256, strides=[8, 8, 16, 32, 32], scale_ranges=((1, 64), (32, 128), (64, 256), (128, 512), (256, 2048)), - sigma=0.2, + pos_scale=0.2, num_grids=[40, 36, 24, 16, 12], - cate_down_pos=0, - loss_ins=dict( - type='DiceLoss', - use_sigmoid=True, + cls_down_index=0, + loss_mask=dict( + type='DiceLoss', use_sigmoid=True, activate=False, loss_weight=3.0), - loss_cate=dict( + loss_cls=dict( type='FocalLoss', use_sigmoid=True, gamma=2.0, alpha=0.25, loss_weight=1.0), - )) -# training and testing settings -train_cfg = dict() -test_cfg = dict( - nms_pre=500, - score_thr=0.1, - mask_thr=0.5, - update_thr=0.05, - kernel='gaussian', # gaussian/linear - sigma=2.0, - max_per_img=100) -# dataset settings -dataset_type = 'CocoDataset' -data_root = 'data/coco/' + norm_cfg=dict(type='GN', num_groups=32, requires_grad=True))) + img_norm_cfg = dict( mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) train_pipeline = [ dict(type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), - dict(type='Resize', - img_scale=[(852, 512), (852, 480), (852, 448), - (852, 416), (852, 384), (852, 352)], - multiscale_mode='value', - keep_ratio=True), + dict( + type='Resize', + img_scale=[(852, 512), (852, 480), (852, 448), (852, 416), (852, 384), + (852, 352)], + multiscale_mode='value', + keep_ratio=True), dict(type='RandomFlip', flip_ratio=0.5), dict(type='Normalize', **img_norm_cfg), dict(type='Pad', size_divisor=32), @@ -81,49 +56,8 @@ test_pipeline = [ dict(type='Collect', keys=['img']), ]) ] + data = dict( - imgs_per_gpu=2, - workers_per_gpu=2, - train=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_train2017.json', - img_prefix=data_root + 'train2017/', - pipeline=train_pipeline), - val=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_val2017.json', - img_prefix=data_root + 'val2017/', - pipeline=test_pipeline), - test=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_val2017.json', - img_prefix=data_root + 'val2017/', - pipeline=test_pipeline)) -# optimizer -optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - step=[27, 33]) -checkpoint_config = dict(interval=1) -# yapf:disable -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - # dict(type='TensorboardLoggerHook') - ]) -# yapf:enable -# runtime settings -total_epochs = 36 -device_ids = range(8) -dist_params = dict(backend='nccl') -log_level = 'INFO' -work_dir = './work_dirs/decoupled_solo_light_release_r50_fpn_8gpu_3x' -load_from = None -resume_from = None -workflow = [('train', 1)] + train=dict(pipeline=train_pipeline), + val=dict(pipeline=test_pipeline), + test=dict(pipeline=test_pipeline)) diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r101_fpn_8gpu_3x.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r101_fpn_8gpu_3x.py deleted file mode 100644 index d64f0385c..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r101_fpn_8gpu_3x.py +++ /dev/null @@ -1,130 +0,0 @@ -# model settings -model = dict( - type='SOLO', - pretrained='torchvision://resnet101', - backbone=dict( - type='ResNet', - depth=101, - num_stages=4, - out_indices=(0, 1, 2, 3), # C2, C3, C4, C5 - frozen_stages=1, - style='pytorch'), - neck=dict( - type='FPN', - in_channels=[256, 512, 1024, 2048], - out_channels=256, - start_level=0, - num_outs=5), - bbox_head=dict( - type='DecoupledSOLOHead', - num_classes=81, - in_channels=256, - stacked_convs=7, - seg_feat_channels=256, - strides=[8, 8, 16, 32, 32], - scale_ranges=((1, 96), (48, 192), (96, 384), (192, 768), (384, 2048)), - sigma=0.2, - num_grids=[40, 36, 24, 16, 12], - cate_down_pos=0, - with_deform=False, - loss_ins=dict( - type='DiceLoss', - use_sigmoid=True, - loss_weight=3.0), - loss_cate=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=1.0), - )) -# training and testing settings -train_cfg = dict() -test_cfg = dict( - nms_pre=500, - score_thr=0.1, - mask_thr=0.5, - update_thr=0.05, - kernel='gaussian', # gaussian/linear - sigma=2.0, - max_per_img=100) -# dataset settings -dataset_type = 'CocoDataset' -data_root = 'data/coco/' -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) -train_pipeline = [ - dict(type='LoadImageFromFile'), - dict(type='LoadAnnotations', with_bbox=True, with_mask=True), - dict(type='Resize', - img_scale=[(1333, 800), (1333, 768), (1333, 736), - (1333, 704), (1333, 672), (1333, 640)], - multiscale_mode='value', - keep_ratio=True), - dict(type='RandomFlip', flip_ratio=0.5), - dict(type='Normalize', **img_norm_cfg), - dict(type='Pad', size_divisor=32), - dict(type='DefaultFormatBundle'), - dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']), -] -test_pipeline = [ - dict(type='LoadImageFromFile'), - dict( - type='MultiScaleFlipAug', - img_scale=(1333, 800), - flip=False, - transforms=[ - dict(type='Resize', keep_ratio=True), - dict(type='RandomFlip'), - dict(type='Normalize', **img_norm_cfg), - dict(type='Pad', size_divisor=32), - dict(type='ImageToTensor', keys=['img']), - dict(type='Collect', keys=['img']), - ]) -] -data = dict( - imgs_per_gpu=2, - workers_per_gpu=2, - train=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_train2017.json', - img_prefix=data_root + 'train2017/', - pipeline=train_pipeline), - val=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_val2017.json', - img_prefix=data_root + 'val2017/', - pipeline=test_pipeline), - test=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_val2017.json', - img_prefix=data_root + 'val2017/', - pipeline=test_pipeline)) -# optimizer -optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - step=[27, 33]) -checkpoint_config = dict(interval=1) -# yapf:disable -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - # dict(type='TensorboardLoggerHook') - ]) -# yapf:enable -# runtime settings -total_epochs = 36 -device_ids = range(8) -dist_params = dict(backend='nccl') -log_level = 'INFO' -work_dir = './work_dirs/decoupled_solo_release_r101_fpn_8gpu_3x' -load_from = None -resume_from = None -workflow = [('train', 1)] diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_1x_coco.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_1x_coco.py new file mode 100644 index 000000000..b611cdf4d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_1x_coco.py @@ -0,0 +1,28 @@ +_base_ = [ + './solo_r50_fpn_1x_coco.py', +] +# model settings +model = dict( + mask_head=dict( + type='DecoupledSOLOHead', + num_classes=80, + in_channels=256, + stacked_convs=7, + feat_channels=256, + strides=[8, 8, 16, 32, 32], + scale_ranges=((1, 96), (48, 192), (96, 384), (192, 768), (384, 2048)), + pos_scale=0.2, + num_grids=[40, 36, 24, 16, 12], + cls_down_index=0, + loss_mask=dict( + type='DiceLoss', use_sigmoid=True, activate=False, + loss_weight=3.0), + loss_cls=dict( + type='FocalLoss', + use_sigmoid=True, + gamma=2.0, + alpha=0.25, + loss_weight=1.0), + norm_cfg=dict(type='GN', num_groups=32, requires_grad=True))) + +optimizer = dict(type='SGD', lr=0.01) diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_3x_coco.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_3x_coco.py new file mode 100644 index 000000000..4a8c19dec --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_3x_coco.py @@ -0,0 +1,25 @@ +_base_ = './solo_r50_fpn_3x_coco.py' + +# model settings +model = dict( + mask_head=dict( + type='DecoupledSOLOHead', + num_classes=80, + in_channels=256, + stacked_convs=7, + feat_channels=256, + strides=[8, 8, 16, 32, 32], + scale_ranges=((1, 96), (48, 192), (96, 384), (192, 768), (384, 2048)), + pos_scale=0.2, + num_grids=[40, 36, 24, 16, 12], + cls_down_index=0, + loss_mask=dict( + type='DiceLoss', use_sigmoid=True, activate=False, + loss_weight=3.0), + loss_cls=dict( + type='FocalLoss', + use_sigmoid=True, + gamma=2.0, + alpha=0.25, + loss_weight=1.0), + norm_cfg=dict(type='GN', num_groups=32, requires_grad=True))) diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_8gpu_1x.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_8gpu_1x.py deleted file mode 100644 index e4d6b5edc..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_8gpu_1x.py +++ /dev/null @@ -1,126 +0,0 @@ -# model settings -model = dict( - type='SOLO', - pretrained='torchvision://resnet50', - backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(0, 1, 2, 3), # C2, C3, C4, C5 - frozen_stages=1, - style='pytorch'), - neck=dict( - type='FPN', - in_channels=[256, 512, 1024, 2048], - out_channels=256, - start_level=0, - num_outs=5), - bbox_head=dict( - type='DecoupledSOLOHead', - num_classes=81, - in_channels=256, - stacked_convs=7, - seg_feat_channels=256, - strides=[8, 8, 16, 32, 32], - scale_ranges=((1, 96), (48, 192), (96, 384), (192, 768), (384, 2048)), - sigma=0.2, - num_grids=[40, 36, 24, 16, 12], - cate_down_pos=0, - with_deform=False, - loss_ins=dict( - type='DiceLoss', - use_sigmoid=True, - loss_weight=3.0), - loss_cate=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=1.0), - )) -# training and testing settings -train_cfg = dict() -test_cfg = dict( - nms_pre=500, - score_thr=0.1, - mask_thr=0.5, - update_thr=0.05, - kernel='gaussian', # gaussian/linear - sigma=2.0, - max_per_img=100) -# dataset settings -dataset_type = 'CocoDataset' -data_root = 'data/coco/' -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) -train_pipeline = [ - dict(type='LoadImageFromFile'), - dict(type='LoadAnnotations', with_bbox=True, with_mask=True), - dict(type='Resize', img_scale=(1333, 800), keep_ratio=True), - dict(type='RandomFlip', flip_ratio=0.5), - dict(type='Normalize', **img_norm_cfg), - dict(type='Pad', size_divisor=32), - dict(type='DefaultFormatBundle'), - dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']), -] -test_pipeline = [ - dict(type='LoadImageFromFile'), - dict( - type='MultiScaleFlipAug', - img_scale=(1333, 800), - flip=False, - transforms=[ - dict(type='Resize', keep_ratio=True), - dict(type='RandomFlip'), - dict(type='Normalize', **img_norm_cfg), - dict(type='Pad', size_divisor=32), - dict(type='ImageToTensor', keys=['img']), - dict(type='Collect', keys=['img']), - ]) -] -data = dict( - imgs_per_gpu=2, - workers_per_gpu=2, - train=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_train2017.json', - img_prefix=data_root + 'train2017/', - pipeline=train_pipeline), - val=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_val2017.json', - img_prefix=data_root + 'val2017/', - pipeline=test_pipeline), - test=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_val2017.json', - img_prefix=data_root + 'val2017/', - pipeline=test_pipeline)) -# optimizer -optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - step=[9, 11]) -checkpoint_config = dict(interval=1) -# yapf:disable -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - # dict(type='TensorboardLoggerHook') - ]) -# yapf:enable -# runtime settings -total_epochs = 12 -device_ids = range(8) -dist_params = dict(backend='nccl') -log_level = 'INFO' -work_dir = './work_dirs/decoupled_solo_release_r50_fpn_8gpu_1x' -load_from = None -resume_from = None -workflow = [('train', 1)] diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_8gpu_3x.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_8gpu_3x.py deleted file mode 100644 index fa54fd857..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/configs/solo/decoupled_solo_r50_fpn_8gpu_3x.py +++ /dev/null @@ -1,130 +0,0 @@ -# model settings -model = dict( - type='SOLO', - pretrained='torchvision://resnet50', - backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(0, 1, 2, 3), # C2, C3, C4, C5 - frozen_stages=1, - style='pytorch'), - neck=dict( - type='FPN', - in_channels=[256, 512, 1024, 2048], - out_channels=256, - start_level=0, - num_outs=5), - bbox_head=dict( - type='DecoupledSOLOHead', - num_classes=81, - in_channels=256, - stacked_convs=7, - seg_feat_channels=256, - strides=[8, 8, 16, 32, 32], - scale_ranges=((1, 96), (48, 192), (96, 384), (192, 768), (384, 2048)), - sigma=0.2, - num_grids=[40, 36, 24, 16, 12], - cate_down_pos=0, - with_deform=False, - loss_ins=dict( - type='DiceLoss', - use_sigmoid=True, - loss_weight=3.0), - loss_cate=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=1.0), - )) -# training and testing settings -train_cfg = dict() -test_cfg = dict( - nms_pre=500, - score_thr=0.1, - mask_thr=0.5, - update_thr=0.05, - kernel='gaussian', # gaussian/linear - sigma=2.0, - max_per_img=100) -# dataset settings -dataset_type = 'CocoDataset' -data_root = 'data/coco/' -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) -train_pipeline = [ - dict(type='LoadImageFromFile'), - dict(type='LoadAnnotations', with_bbox=True, with_mask=True), - dict(type='Resize', - img_scale=[(1333, 800), (1333, 768), (1333, 736), - (1333, 704), (1333, 672), (1333, 640)], - multiscale_mode='value', - keep_ratio=True), - dict(type='RandomFlip', flip_ratio=0.5), - dict(type='Normalize', **img_norm_cfg), - dict(type='Pad', size_divisor=32), - dict(type='DefaultFormatBundle'), - dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']), -] -test_pipeline = [ - dict(type='LoadImageFromFile'), - dict( - type='MultiScaleFlipAug', - img_scale=(1333, 800), - flip=False, - transforms=[ - dict(type='Resize', keep_ratio=True), - dict(type='RandomFlip'), - dict(type='Normalize', **img_norm_cfg), - dict(type='Pad', size_divisor=32), - dict(type='ImageToTensor', keys=['img']), - dict(type='Collect', keys=['img']), - ]) -] -data = dict( - imgs_per_gpu=2, - workers_per_gpu=2, - train=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_train2017.json', - img_prefix=data_root + 'train2017/', - pipeline=train_pipeline), - val=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_val2017.json', - img_prefix=data_root + 'val2017/', - pipeline=test_pipeline), - test=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_val2017.json', - img_prefix=data_root + 'val2017/', - pipeline=test_pipeline)) -# optimizer -optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - step=[27, 33]) -checkpoint_config = dict(interval=1) -# yapf:disable -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - # dict(type='TensorboardLoggerHook') - ]) -# yapf:enable -# runtime settings -total_epochs = 36 -device_ids = range(8) -dist_params = dict(backend='nccl') -log_level = 'INFO' -work_dir = './work_dirs/decoupled_solo_release_r50_fpn_8gpu_3x' -load_from = None -resume_from = None -workflow = [('train', 1)] diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/metafile.yml b/cv/instance_segmentation/SOLO/pytorch/configs/solo/metafile.yml new file mode 100644 index 000000000..b6244e80f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/configs/solo/metafile.yml @@ -0,0 +1,115 @@ +Collections: + - Name: SOLO + Metadata: + Training Data: COCO + Training Techniques: + - SGD with Momentum + - Weight Decay + Training Resources: 8x V100 GPUs + Architecture: + - FPN + - Convolution + - ResNet + Paper: https://arxiv.org/abs/1912.04488 + README: configs/solo/README.md + +Models: + - Name: decoupled_solo_r50_fpn_1x_coco + In Collection: SOLO + Config: configs/solo/decoupled_solo_r50_fpn_1x_coco.py + Metadata: + Training Memory (GB): 7.8 + Epochs: 12 + inference time (ms/im): + - value: 116.4 + hardware: V100 + backend: PyTorch + batch size: 1 + mode: FP32 + resolution: (1333, 800) + Results: + - Task: Instance Segmentation + Dataset: COCO + Metrics: + mask AP: 33.9 + Weights: https://download.openmmlab.com/mmdetection/v2.0/solo/decoupled_solo_r50_fpn_1x_coco/decoupled_solo_r50_fpn_1x_coco_20210820_233348-6337c589.pth + + - Name: decoupled_solo_r50_fpn_3x_coco + In Collection: SOLO + Config: configs/solo/decoupled_solo_r50_fpn_3x_coco.py + Metadata: + Training Memory (GB): 7.9 + Epochs: 36 + inference time (ms/im): + - value: 117.2 + hardware: V100 + backend: PyTorch + batch size: 1 + mode: FP32 + resolution: (1333, 800) + Results: + - Task: Instance Segmentation + Dataset: COCO + Metrics: + mask AP: 36.7 + Weights: https://download.openmmlab.com/mmdetection/v2.0/solo/decoupled_solo_r50_fpn_3x_coco/decoupled_solo_r50_fpn_3x_coco_20210821_042504-7b3301ec.pth + + - Name: decoupled_solo_light_r50_fpn_3x_coco + In Collection: SOLO + Config: configs/solo/decoupled_solo_light_r50_fpn_3x_coco.py + Metadata: + Training Memory (GB): 2.2 + Epochs: 36 + inference time (ms/im): + - value: 35.0 + hardware: V100 + backend: PyTorch + batch size: 1 + mode: FP32 + resolution: (852, 512) + Results: + - Task: Instance Segmentation + Dataset: COCO + Metrics: + mask AP: 32.9 + Weights: https://download.openmmlab.com/mmdetection/v2.0/solo/decoupled_solo_light_r50_fpn_3x_coco/decoupled_solo_light_r50_fpn_3x_coco_20210906_142703-e70e226f.pth + + - Name: solo_r50_fpn_3x_coco + In Collection: SOLO + Config: configs/solo/solo_r50_fpn_3x_coco.py + Metadata: + Training Memory (GB): 7.4 + Epochs: 36 + inference time (ms/im): + - value: 94.2 + hardware: V100 + backend: PyTorch + batch size: 1 + mode: FP32 + resolution: (1333, 800) + Results: + - Task: Instance Segmentation + Dataset: COCO + Metrics: + mask AP: 35.9 + Weights: https://download.openmmlab.com/mmdetection/v2.0/solo/solo_r50_fpn_3x_coco/solo_r50_fpn_3x_coco_20210901_012353-11d224d7.pth + + - Name: solo_r50_fpn_1x_coco + In Collection: SOLO + Config: configs/solo/solo_r50_fpn_1x_coco.py + Metadata: + Training Memory (GB): 8.0 + Epochs: 12 + inference time (ms/im): + - value: 95.1 + hardware: V100 + backend: PyTorch + batch size: 1 + mode: FP32 + resolution: (1333, 800) + Results: + - Task: Instance Segmentation + Dataset: COCO + Metrics: + mask AP: 33.1 + Weights: https://download.openmmlab.com/mmdetection/v2.0/solo/solo_r50_fpn_1x_coco/solo_r50_fpn_1x_coco_20210821_035055-2290a6b8.pth diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r101_fpn_8gpu_3x.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r101_fpn_8gpu_3x.py deleted file mode 100644 index d6a30d917..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r101_fpn_8gpu_3x.py +++ /dev/null @@ -1,130 +0,0 @@ -# model settings -model = dict( - type='SOLO', - pretrained='torchvision://resnet101', - backbone=dict( - type='ResNet', - depth=101, - num_stages=4, - out_indices=(0, 1, 2, 3), # C2, C3, C4, C5 - frozen_stages=1, - style='pytorch'), - neck=dict( - type='FPN', - in_channels=[256, 512, 1024, 2048], - out_channels=256, - start_level=0, - num_outs=5), - bbox_head=dict( - type='SOLOHead', - num_classes=81, - in_channels=256, - stacked_convs=7, - seg_feat_channels=256, - strides=[8, 8, 16, 32, 32], - scale_ranges=((1, 96), (48, 192), (96, 384), (192, 768), (384, 2048)), - sigma=0.2, - num_grids=[40, 36, 24, 16, 12], - cate_down_pos=0, - with_deform=False, - loss_ins=dict( - type='DiceLoss', - use_sigmoid=True, - loss_weight=3.0), - loss_cate=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=1.0), - )) -# training and testing settings -train_cfg = dict() -test_cfg = dict( - nms_pre=500, - score_thr=0.1, - mask_thr=0.5, - update_thr=0.05, - kernel='gaussian', # gaussian/linear - sigma=2.0, - max_per_img=100) -# dataset settings -dataset_type = 'CocoDataset' -data_root = 'data/coco/' -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) -train_pipeline = [ - dict(type='LoadImageFromFile'), - dict(type='LoadAnnotations', with_bbox=True, with_mask=True), - dict(type='Resize', - img_scale=[(1333, 800), (1333, 768), (1333, 736), - (1333, 704), (1333, 672), (1333, 640)], - multiscale_mode='value', - keep_ratio=True), - dict(type='RandomFlip', flip_ratio=0.5), - dict(type='Normalize', **img_norm_cfg), - dict(type='Pad', size_divisor=32), - dict(type='DefaultFormatBundle'), - dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']), -] -test_pipeline = [ - dict(type='LoadImageFromFile'), - dict( - type='MultiScaleFlipAug', - img_scale=(1333, 800), - flip=False, - transforms=[ - dict(type='Resize', keep_ratio=True), - dict(type='RandomFlip'), - dict(type='Normalize', **img_norm_cfg), - dict(type='Pad', size_divisor=32), - dict(type='ImageToTensor', keys=['img']), - dict(type='Collect', keys=['img']), - ]) -] -data = dict( - imgs_per_gpu=2, - workers_per_gpu=2, - train=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_train2017.json', - img_prefix=data_root + 'train2017/', - pipeline=train_pipeline), - val=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_val2017.json', - img_prefix=data_root + 'val2017/', - pipeline=test_pipeline), - test=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_val2017.json', - img_prefix=data_root + 'val2017/', - pipeline=test_pipeline)) -# optimizer -optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - step=[27, 33]) -checkpoint_config = dict(interval=1) -# yapf:disable -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - # dict(type='TensorboardLoggerHook') - ]) -# yapf:enable -# runtime settings -total_epochs = 36 -device_ids = range(8) -dist_params = dict(backend='nccl') -log_level = 'INFO' -work_dir = './work_dirs/solo_release_r101_fpn_8gpu_3x' -load_from = None -resume_from = None -workflow = [('train', 1)] diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_1x_coco.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_1x_coco.py new file mode 100644 index 000000000..9093a5048 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_1x_coco.py @@ -0,0 +1,53 @@ +_base_ = [ + '../_base_/datasets/coco_instance.py', + '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py' +] + +# model settings +model = dict( + type='SOLO', + backbone=dict( + type='ResNet', + depth=50, + num_stages=4, + out_indices=(0, 1, 2, 3), + frozen_stages=1, + init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet50'), + style='pytorch'), + neck=dict( + type='FPN', + in_channels=[256, 512, 1024, 2048], + out_channels=256, + start_level=0, + num_outs=5), + mask_head=dict( + type='SOLOHead', + num_classes=80, + in_channels=256, + stacked_convs=7, + feat_channels=256, + strides=[8, 8, 16, 32, 32], + scale_ranges=((1, 96), (48, 192), (96, 384), (192, 768), (384, 2048)), + pos_scale=0.2, + num_grids=[40, 36, 24, 16, 12], + cls_down_index=0, + loss_mask=dict(type='DiceLoss', use_sigmoid=True, loss_weight=3.0), + loss_cls=dict( + type='FocalLoss', + use_sigmoid=True, + gamma=2.0, + alpha=0.25, + loss_weight=1.0), + norm_cfg=dict(type='GN', num_groups=32, requires_grad=True)), + # model training and testing settings + test_cfg=dict( + nms_pre=500, + score_thr=0.1, + mask_thr=0.5, + filter_thr=0.05, + kernel='gaussian', # gaussian/linear + sigma=2.0, + max_per_img=100)) + +# optimizer +optimizer = dict(type='SGD', lr=0.01) diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_3x_coco.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_3x_coco.py new file mode 100644 index 000000000..52302cdf9 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_3x_coco.py @@ -0,0 +1,28 @@ +_base_ = './solo_r50_fpn_1x_coco.py' + +img_norm_cfg = dict( + mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) +train_pipeline = [ + dict(type='LoadImageFromFile'), + dict(type='LoadAnnotations', with_bbox=True, with_mask=True), + dict( + type='Resize', + img_scale=[(1333, 800), (1333, 768), (1333, 736), (1333, 704), + (1333, 672), (1333, 640)], + multiscale_mode='value', + keep_ratio=True), + dict(type='RandomFlip', flip_ratio=0.5), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='DefaultFormatBundle'), + dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']), +] +data = dict(train=dict(pipeline=train_pipeline)) + +lr_config = dict( + policy='step', + warmup='linear', + warmup_iters=500, + warmup_ratio=1.0 / 3, + step=[27, 33]) +runner = dict(type='EpochBasedRunner', max_epochs=36) diff --git a/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_8gpu_3x.py b/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_8gpu_3x.py deleted file mode 100644 index 7fc0bed65..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/configs/solo/solo_r50_fpn_8gpu_3x.py +++ /dev/null @@ -1,130 +0,0 @@ -# model settings -model = dict( - type='SOLO', - pretrained='torchvision://resnet50', - backbone=dict( - type='ResNet', - depth=50, - num_stages=4, - out_indices=(0, 1, 2, 3), # C2, C3, C4, C5 - frozen_stages=1, - style='pytorch'), - neck=dict( - type='FPN', - in_channels=[256, 512, 1024, 2048], - out_channels=256, - start_level=0, - num_outs=5), - bbox_head=dict( - type='SOLOHead', - num_classes=81, - in_channels=256, - stacked_convs=7, - seg_feat_channels=256, - strides=[8, 8, 16, 32, 32], - scale_ranges=((1, 96), (48, 192), (96, 384), (192, 768), (384, 2048)), - sigma=0.2, - num_grids=[40, 36, 24, 16, 12], - cate_down_pos=0, - with_deform=False, - loss_ins=dict( - type='DiceLoss', - use_sigmoid=True, - loss_weight=3.0), - loss_cate=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=1.0), - )) -# training and testing settings -train_cfg = dict() -test_cfg = dict( - nms_pre=500, - score_thr=0.1, - mask_thr=0.5, - update_thr=0.05, - kernel='gaussian', # gaussian/linear - sigma=2.0, - max_per_img=100) -# dataset settings -dataset_type = 'CocoDataset' -data_root = 'data/coco/' -img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) -train_pipeline = [ - dict(type='LoadImageFromFile'), - dict(type='LoadAnnotations', with_bbox=True, with_mask=True), - dict(type='Resize', - img_scale=[(1333, 800), (1333, 768), (1333, 736), - (1333, 704), (1333, 672), (1333, 640)], - multiscale_mode='value', - keep_ratio=True), - dict(type='RandomFlip', flip_ratio=0.5), - dict(type='Normalize', **img_norm_cfg), - dict(type='Pad', size_divisor=32), - dict(type='DefaultFormatBundle'), - dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']), -] -test_pipeline = [ - dict(type='LoadImageFromFile'), - dict( - type='MultiScaleFlipAug', - img_scale=(1333, 800), - flip=False, - transforms=[ - dict(type='Resize', keep_ratio=True), - dict(type='RandomFlip'), - dict(type='Normalize', **img_norm_cfg), - dict(type='Pad', size_divisor=32), - dict(type='ImageToTensor', keys=['img']), - dict(type='Collect', keys=['img']), - ]) -] -data = dict( - imgs_per_gpu=2, - workers_per_gpu=2, - train=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_train2017.json', - img_prefix=data_root + 'train2017/', - pipeline=train_pipeline), - val=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_val2017.json', - img_prefix=data_root + 'val2017/', - pipeline=test_pipeline), - test=dict( - type=dataset_type, - ann_file=data_root + 'annotations/instances_val2017.json', - img_prefix=data_root + 'val2017/', - pipeline=test_pipeline)) -# optimizer -optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) -optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) -# learning policy -lr_config = dict( - policy='step', - warmup='linear', - warmup_iters=500, - warmup_ratio=1.0 / 3, - step=[27, 33]) -checkpoint_config = dict(interval=1) -# yapf:disable -log_config = dict( - interval=50, - hooks=[ - dict(type='TextLoggerHook'), - # dict(type='TensorboardLoggerHook') - ]) -# yapf:enable -# runtime settings -total_epochs = 36 -device_ids = range(8) -dist_params = dict(backend='nccl') -log_level = 'INFO' -work_dir = './work_dirs/solo_release_r50_fpn_8gpu_3x' -load_from = None -resume_from = None -workflow = [('train', 1)] diff --git a/cv/instance_segmentation/SOLO/pytorch/docker/Dockerfile b/cv/instance_segmentation/SOLO/pytorch/docker/Dockerfile new file mode 100644 index 000000000..5ee7a370e --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/docker/Dockerfile @@ -0,0 +1,25 @@ +ARG PYTORCH="1.6.0" +ARG CUDA="10.1" +ARG CUDNN="7" + +FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel + +ENV TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0+PTX" +ENV TORCH_NVCC_FLAGS="-Xfatbin -compress-all" +ENV CMAKE_PREFIX_PATH="$(dirname $(which conda))/../" + +RUN apt-get update && apt-get install -y ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Install MMCV +RUN pip install --no-cache-dir --upgrade pip wheel setuptools +RUN pip install --no-cache-dir mmcv-full==1.3.17 -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.6.0/index.html + +# Install MMDetection +RUN conda clean --all +RUN git clone https://github.com/open-mmlab/mmdetection.git /mmdetection +WORKDIR /mmdetection +ENV FORCE_CUDA="1" +RUN pip install --no-cache-dir -r requirements/build.txt +RUN pip install --no-cache-dir -e . diff --git a/cv/instance_segmentation/SOLO/pytorch/docker/serve/Dockerfile b/cv/instance_segmentation/SOLO/pytorch/docker/serve/Dockerfile new file mode 100644 index 000000000..37d88f6e7 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/docker/serve/Dockerfile @@ -0,0 +1,49 @@ +ARG PYTORCH="1.6.0" +ARG CUDA="10.1" +ARG CUDNN="7" +FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel + +ARG MMCV="1.3.17" +ARG MMDET="2.25.0" + +ENV PYTHONUNBUFFERED TRUE + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ + ca-certificates \ + g++ \ + openjdk-11-jre-headless \ + # MMDet Requirements + ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 \ + && rm -rf /var/lib/apt/lists/* + +ENV PATH="/opt/conda/bin:$PATH" +RUN export FORCE_CUDA=1 + +# TORCHSEVER +RUN pip install torchserve torch-model-archiver + +# MMLAB +ARG PYTORCH +ARG CUDA +RUN ["/bin/bash", "-c", "pip install mmcv-full==${MMCV} -f https://download.openmmlab.com/mmcv/dist/cu${CUDA//./}/torch${PYTORCH}/index.html"] +RUN pip install mmdet==${MMDET} + +RUN useradd -m model-server \ + && mkdir -p /home/model-server/tmp + +COPY entrypoint.sh /usr/local/bin/entrypoint.sh + +RUN chmod +x /usr/local/bin/entrypoint.sh \ + && chown -R model-server /home/model-server + +COPY config.properties /home/model-server/config.properties +RUN mkdir /home/model-server/model-store && chown -R model-server /home/model-server/model-store + +EXPOSE 8080 8081 8082 + +USER model-server +WORKDIR /home/model-server +ENV TEMP=/home/model-server/tmp +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] +CMD ["serve"] diff --git a/cv/instance_segmentation/SOLO/pytorch/docker/serve/config.properties b/cv/instance_segmentation/SOLO/pytorch/docker/serve/config.properties new file mode 100644 index 000000000..efb9c47e4 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/docker/serve/config.properties @@ -0,0 +1,5 @@ +inference_address=http://0.0.0.0:8080 +management_address=http://0.0.0.0:8081 +metrics_address=http://0.0.0.0:8082 +model_store=/home/model-server/model-store +load_models=all diff --git a/cv/instance_segmentation/SOLO/pytorch/docker/serve/entrypoint.sh b/cv/instance_segmentation/SOLO/pytorch/docker/serve/entrypoint.sh new file mode 100644 index 000000000..41ba00b04 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/docker/serve/entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -e + +if [[ "$1" = "serve" ]]; then + shift 1 + torchserve --start --ts-config /home/model-server/config.properties +else + eval "$@" +fi + +# prevent docker exit +tail -f /dev/null diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/__init__.py new file mode 100644 index 000000000..87c01b07c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/__init__.py @@ -0,0 +1,11 @@ +# Copyright (c) OpenMMLab. All rights reserved. +# flake8: noqa +from .fileio import * +from .image import * +from .utils import * +from .version import * +# The following modules are not imported to this level, so mmcv may be used +# without PyTorch. +# - runner +# - parallel +# - op diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/__init__.py new file mode 100644 index 000000000..7246c8974 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/__init__.py @@ -0,0 +1,41 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .alexnet import AlexNet +# yapf: disable +from .bricks import (ACTIVATION_LAYERS, CONV_LAYERS, NORM_LAYERS, + PADDING_LAYERS, PLUGIN_LAYERS, UPSAMPLE_LAYERS, + ContextBlock, Conv2d, Conv3d, ConvAWS2d, ConvModule, + ConvTranspose2d, ConvTranspose3d, ConvWS2d, + DepthwiseSeparableConvModule, GeneralizedAttention, + HSigmoid, HSwish, Linear, MaxPool2d, MaxPool3d, + NonLocal1d, NonLocal2d, NonLocal3d, Scale, Swish, + build_activation_layer, build_conv_layer, + build_norm_layer, build_padding_layer, build_plugin_layer, + build_upsample_layer, conv_ws_2d, is_norm) +from .builder import MODELS, build_model_from_cfg +# yapf: enable +from .resnet import ResNet, make_res_layer +from .utils import (INITIALIZERS, Caffe2XavierInit, ConstantInit, KaimingInit, + NormalInit, PretrainedInit, TruncNormalInit, UniformInit, + XavierInit, bias_init_with_prob, caffe2_xavier_init, + constant_init, fuse_conv_bn, get_model_complexity_info, + initialize, kaiming_init, normal_init, trunc_normal_init, + uniform_init, xavier_init) +from .vgg import VGG, make_vgg_layer + +__all__ = [ + 'AlexNet', 'VGG', 'make_vgg_layer', 'ResNet', 'make_res_layer', + 'constant_init', 'xavier_init', 'normal_init', 'trunc_normal_init', + 'uniform_init', 'kaiming_init', 'caffe2_xavier_init', + 'bias_init_with_prob', 'ConvModule', 'build_activation_layer', + 'build_conv_layer', 'build_norm_layer', 'build_padding_layer', + 'build_upsample_layer', 'build_plugin_layer', 'is_norm', 'NonLocal1d', + 'NonLocal2d', 'NonLocal3d', 'ContextBlock', 'HSigmoid', 'Swish', 'HSwish', + 'GeneralizedAttention', 'ACTIVATION_LAYERS', 'CONV_LAYERS', 'NORM_LAYERS', + 'PADDING_LAYERS', 'UPSAMPLE_LAYERS', 'PLUGIN_LAYERS', 'Scale', + 'get_model_complexity_info', 'conv_ws_2d', 'ConvAWS2d', 'ConvWS2d', + 'fuse_conv_bn', 'DepthwiseSeparableConvModule', 'Linear', 'Conv2d', + 'ConvTranspose2d', 'MaxPool2d', 'ConvTranspose3d', 'MaxPool3d', 'Conv3d', + 'initialize', 'INITIALIZERS', 'ConstantInit', 'XavierInit', 'NormalInit', + 'TruncNormalInit', 'UniformInit', 'KaimingInit', 'PretrainedInit', + 'Caffe2XavierInit', 'MODELS', 'build_model_from_cfg' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/alexnet.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/alexnet.py new file mode 100644 index 000000000..89e36b8c7 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/alexnet.py @@ -0,0 +1,61 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import logging + +import torch.nn as nn + + +class AlexNet(nn.Module): + """AlexNet backbone. + + Args: + num_classes (int): number of classes for classification. + """ + + def __init__(self, num_classes=-1): + super(AlexNet, self).__init__() + self.num_classes = num_classes + self.features = nn.Sequential( + nn.Conv2d(3, 64, kernel_size=11, stride=4, padding=2), + nn.ReLU(inplace=True), + nn.MaxPool2d(kernel_size=3, stride=2), + nn.Conv2d(64, 192, kernel_size=5, padding=2), + nn.ReLU(inplace=True), + nn.MaxPool2d(kernel_size=3, stride=2), + nn.Conv2d(192, 384, kernel_size=3, padding=1), + nn.ReLU(inplace=True), + nn.Conv2d(384, 256, kernel_size=3, padding=1), + nn.ReLU(inplace=True), + nn.Conv2d(256, 256, kernel_size=3, padding=1), + nn.ReLU(inplace=True), + nn.MaxPool2d(kernel_size=3, stride=2), + ) + if self.num_classes > 0: + self.classifier = nn.Sequential( + nn.Dropout(), + nn.Linear(256 * 6 * 6, 4096), + nn.ReLU(inplace=True), + nn.Dropout(), + nn.Linear(4096, 4096), + nn.ReLU(inplace=True), + nn.Linear(4096, num_classes), + ) + + def init_weights(self, pretrained=None): + if isinstance(pretrained, str): + logger = logging.getLogger() + from ..runner import load_checkpoint + load_checkpoint(self, pretrained, strict=False, logger=logger) + elif pretrained is None: + # use default initializer + pass + else: + raise TypeError('pretrained must be a str or None') + + def forward(self, x): + + x = self.features(x) + if self.num_classes > 0: + x = x.view(x.size(0), 256 * 6 * 6) + x = self.classifier(x) + + return x diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/__init__.py new file mode 100644 index 000000000..0f33124ed --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/__init__.py @@ -0,0 +1,35 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .activation import build_activation_layer +from .context_block import ContextBlock +from .conv import build_conv_layer +from .conv2d_adaptive_padding import Conv2dAdaptivePadding +from .conv_module import ConvModule +from .conv_ws import ConvAWS2d, ConvWS2d, conv_ws_2d +from .depthwise_separable_conv_module import DepthwiseSeparableConvModule +from .drop import Dropout, DropPath +from .generalized_attention import GeneralizedAttention +from .hsigmoid import HSigmoid +from .hswish import HSwish +from .non_local import NonLocal1d, NonLocal2d, NonLocal3d +from .norm import build_norm_layer, is_norm +from .padding import build_padding_layer +from .plugin import build_plugin_layer +from .registry import (ACTIVATION_LAYERS, CONV_LAYERS, NORM_LAYERS, + PADDING_LAYERS, PLUGIN_LAYERS, UPSAMPLE_LAYERS) +from .scale import Scale +from .swish import Swish +from .upsample import build_upsample_layer +from .wrappers import (Conv2d, Conv3d, ConvTranspose2d, ConvTranspose3d, + Linear, MaxPool2d, MaxPool3d) + +__all__ = [ + 'ConvModule', 'build_activation_layer', 'build_conv_layer', + 'build_norm_layer', 'build_padding_layer', 'build_upsample_layer', + 'build_plugin_layer', 'is_norm', 'HSigmoid', 'HSwish', 'NonLocal1d', + 'NonLocal2d', 'NonLocal3d', 'ContextBlock', 'GeneralizedAttention', + 'ACTIVATION_LAYERS', 'CONV_LAYERS', 'NORM_LAYERS', 'PADDING_LAYERS', + 'UPSAMPLE_LAYERS', 'PLUGIN_LAYERS', 'Scale', 'ConvAWS2d', 'ConvWS2d', + 'conv_ws_2d', 'DepthwiseSeparableConvModule', 'Swish', 'Linear', + 'Conv2dAdaptivePadding', 'Conv2d', 'ConvTranspose2d', 'MaxPool2d', + 'ConvTranspose3d', 'MaxPool3d', 'Conv3d', 'Dropout', 'DropPath' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/activation.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/activation.py new file mode 100644 index 000000000..79f198838 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/activation.py @@ -0,0 +1,92 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch +import torch.nn as nn +import torch.nn.functional as F + +from mmcv.utils import TORCH_VERSION, build_from_cfg, digit_version +from .registry import ACTIVATION_LAYERS + +for module in [ + nn.ReLU, nn.LeakyReLU, nn.PReLU, nn.RReLU, nn.ReLU6, nn.ELU, + nn.Sigmoid, nn.Tanh +]: + ACTIVATION_LAYERS.register_module(module=module) + + +@ACTIVATION_LAYERS.register_module(name='Clip') +@ACTIVATION_LAYERS.register_module() +class Clamp(nn.Module): + """Clamp activation layer. + + This activation function is to clamp the feature map value within + :math:`[min, max]`. More details can be found in ``torch.clamp()``. + + Args: + min (Number | optional): Lower-bound of the range to be clamped to. + Default to -1. + max (Number | optional): Upper-bound of the range to be clamped to. + Default to 1. + """ + + def __init__(self, min=-1., max=1.): + super(Clamp, self).__init__() + self.min = min + self.max = max + + def forward(self, x): + """Forward function. + + Args: + x (torch.Tensor): The input tensor. + + Returns: + torch.Tensor: Clamped tensor. + """ + return torch.clamp(x, min=self.min, max=self.max) + + +class GELU(nn.Module): + r"""Applies the Gaussian Error Linear Units function: + + .. math:: + \text{GELU}(x) = x * \Phi(x) + where :math:`\Phi(x)` is the Cumulative Distribution Function for + Gaussian Distribution. + + Shape: + - Input: :math:`(N, *)` where `*` means, any number of additional + dimensions + - Output: :math:`(N, *)`, same shape as the input + + .. image:: scripts/activation_images/GELU.png + + Examples:: + + >>> m = nn.GELU() + >>> input = torch.randn(2) + >>> output = m(input) + """ + + def forward(self, input): + return F.gelu(input) + + +if (TORCH_VERSION == 'parrots' + or digit_version(TORCH_VERSION) < digit_version('1.4')): + ACTIVATION_LAYERS.register_module(module=GELU) +else: + ACTIVATION_LAYERS.register_module(module=nn.GELU) + + +def build_activation_layer(cfg): + """Build activation layer. + + Args: + cfg (dict): The activation layer config, which should contain: + - type (str): Layer type. + - layer args: Args needed to instantiate an activation layer. + + Returns: + nn.Module: Created activation layer. + """ + return build_from_cfg(cfg, ACTIVATION_LAYERS) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/context_block.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/context_block.py similarity index 69% rename from cv/instance_segmentation/SOLO/pytorch/mmdet/ops/context_block.py rename to cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/context_block.py index be9092c48..d60fdb904 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/context_block.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/context_block.py @@ -1,7 +1,10 @@ +# Copyright (c) OpenMMLab. All rights reserved. import torch -from mmcv.cnn import constant_init, kaiming_init from torch import nn +from ..utils import constant_init, kaiming_init +from .registry import PLUGIN_LAYERS + def last_zero_init(m): if isinstance(m, nn.Sequential): @@ -10,10 +13,28 @@ def last_zero_init(m): constant_init(m, val=0) +@PLUGIN_LAYERS.register_module() class ContextBlock(nn.Module): + """ContextBlock module in GCNet. + + See 'GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond' + (https://arxiv.org/abs/1904.11492) for details. + + Args: + in_channels (int): Channels of the input feature map. + ratio (float): Ratio of channels of transform bottleneck + pooling_type (str): Pooling method for context modeling. + Options are 'att' and 'avg', stand for attention pooling and + average pooling respectively. Default: 'att'. + fusion_types (Sequence[str]): Fusion method for feature fusion, + Options are 'channels_add', 'channel_mul', stand for channelwise + addition and multiplication respectively. Default: ('channel_add',) + """ + + _abbr_ = 'context_block' def __init__(self, - inplanes, + in_channels, ratio, pooling_type='att', fusion_types=('channel_add', )): @@ -23,30 +44,30 @@ class ContextBlock(nn.Module): valid_fusion_types = ['channel_add', 'channel_mul'] assert all([f in valid_fusion_types for f in fusion_types]) assert len(fusion_types) > 0, 'at least one fusion should be used' - self.inplanes = inplanes + self.in_channels = in_channels self.ratio = ratio - self.planes = int(inplanes * ratio) + self.planes = int(in_channels * ratio) self.pooling_type = pooling_type self.fusion_types = fusion_types if pooling_type == 'att': - self.conv_mask = nn.Conv2d(inplanes, 1, kernel_size=1) + self.conv_mask = nn.Conv2d(in_channels, 1, kernel_size=1) self.softmax = nn.Softmax(dim=2) else: self.avg_pool = nn.AdaptiveAvgPool2d(1) if 'channel_add' in fusion_types: self.channel_add_conv = nn.Sequential( - nn.Conv2d(self.inplanes, self.planes, kernel_size=1), + nn.Conv2d(self.in_channels, self.planes, kernel_size=1), nn.LayerNorm([self.planes, 1, 1]), nn.ReLU(inplace=True), # yapf: disable - nn.Conv2d(self.planes, self.inplanes, kernel_size=1)) + nn.Conv2d(self.planes, self.in_channels, kernel_size=1)) else: self.channel_add_conv = None if 'channel_mul' in fusion_types: self.channel_mul_conv = nn.Sequential( - nn.Conv2d(self.inplanes, self.planes, kernel_size=1), + nn.Conv2d(self.in_channels, self.planes, kernel_size=1), nn.LayerNorm([self.planes, 1, 1]), nn.ReLU(inplace=True), # yapf: disable - nn.Conv2d(self.planes, self.inplanes, kernel_size=1)) + nn.Conv2d(self.planes, self.in_channels, kernel_size=1)) else: self.channel_mul_conv = None self.reset_parameters() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/conv.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/conv.py new file mode 100644 index 000000000..cf5449199 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/conv.py @@ -0,0 +1,44 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from torch import nn + +from .registry import CONV_LAYERS + +CONV_LAYERS.register_module('Conv1d', module=nn.Conv1d) +CONV_LAYERS.register_module('Conv2d', module=nn.Conv2d) +CONV_LAYERS.register_module('Conv3d', module=nn.Conv3d) +CONV_LAYERS.register_module('Conv', module=nn.Conv2d) + + +def build_conv_layer(cfg, *args, **kwargs): + """Build convolution layer. + + Args: + cfg (None or dict): The conv layer config, which should contain: + - type (str): Layer type. + - layer args: Args needed to instantiate an conv layer. + args (argument list): Arguments passed to the `__init__` + method of the corresponding conv layer. + kwargs (keyword arguments): Keyword arguments passed to the `__init__` + method of the corresponding conv layer. + + Returns: + nn.Module: Created conv layer. + """ + if cfg is None: + cfg_ = dict(type='Conv2d') + else: + if not isinstance(cfg, dict): + raise TypeError('cfg must be a dict') + if 'type' not in cfg: + raise KeyError('the cfg dict must contain the key "type"') + cfg_ = cfg.copy() + + layer_type = cfg_.pop('type') + if layer_type not in CONV_LAYERS: + raise KeyError(f'Unrecognized norm type {layer_type}') + else: + conv_layer = CONV_LAYERS.get(layer_type) + + layer = conv_layer(*args, **kwargs, **cfg_) + + return layer diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/conv2d_adaptive_padding.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/conv2d_adaptive_padding.py new file mode 100644 index 000000000..b45e758ac --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/conv2d_adaptive_padding.py @@ -0,0 +1,62 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import math + +from torch import nn +from torch.nn import functional as F + +from .registry import CONV_LAYERS + + +@CONV_LAYERS.register_module() +class Conv2dAdaptivePadding(nn.Conv2d): + """Implementation of 2D convolution in tensorflow with `padding` as "same", + which applies padding to input (if needed) so that input image gets fully + covered by filter and stride you specified. For stride 1, this will ensure + that output image size is same as input. For stride of 2, output dimensions + will be half, for example. + + Args: + in_channels (int): Number of channels in the input image + out_channels (int): Number of channels produced by the convolution + kernel_size (int or tuple): Size of the convolving kernel + stride (int or tuple, optional): Stride of the convolution. Default: 1 + padding (int or tuple, optional): Zero-padding added to both sides of + the input. Default: 0 + dilation (int or tuple, optional): Spacing between kernel elements. + Default: 1 + groups (int, optional): Number of blocked connections from input + channels to output channels. Default: 1 + bias (bool, optional): If ``True``, adds a learnable bias to the + output. Default: ``True`` + """ + + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride=1, + padding=0, + dilation=1, + groups=1, + bias=True): + super().__init__(in_channels, out_channels, kernel_size, stride, 0, + dilation, groups, bias) + + def forward(self, x): + img_h, img_w = x.size()[-2:] + kernel_h, kernel_w = self.weight.size()[-2:] + stride_h, stride_w = self.stride + output_h = math.ceil(img_h / stride_h) + output_w = math.ceil(img_w / stride_w) + pad_h = ( + max((output_h - 1) * self.stride[0] + + (kernel_h - 1) * self.dilation[0] + 1 - img_h, 0)) + pad_w = ( + max((output_w - 1) * self.stride[1] + + (kernel_w - 1) * self.dilation[1] + 1 - img_w, 0)) + if pad_h > 0 or pad_w > 0: + x = F.pad(x, [ + pad_w // 2, pad_w - pad_w // 2, pad_h // 2, pad_h - pad_h // 2 + ]) + return F.conv2d(x, self.weight, self.bias, self.stride, self.padding, + self.dilation, self.groups) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/conv_module.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/conv_module.py similarity index 35% rename from cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/conv_module.py rename to cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/conv_module.py index 3be32c3a4..4f19f1d0c 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/conv_module.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/conv_module.py @@ -1,72 +1,72 @@ +# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch.nn as nn -from mmcv.cnn import constant_init, kaiming_init -from mmdet.ops import DeformConvPack, ModulatedDeformConvPack -from .conv_ws import ConvWS2d +from mmcv.utils import _BatchNorm, _InstanceNorm +from ..utils import constant_init, kaiming_init +from .activation import build_activation_layer +from .conv import build_conv_layer from .norm import build_norm_layer +from .padding import build_padding_layer +from .registry import PLUGIN_LAYERS -conv_cfg = { - 'Conv': nn.Conv2d, - 'ConvWS': ConvWS2d, - 'DCN': DeformConvPack, - 'DCNv2': ModulatedDeformConvPack, - # TODO: octave conv -} +@PLUGIN_LAYERS.register_module() +class ConvModule(nn.Module): + """A conv block that bundles conv/norm/activation layers. -def build_conv_layer(cfg, *args, **kwargs): - """ Build convolution layer - - Args: - cfg (None or dict): cfg should contain: - type (str): identify conv layer type. - layer args: args needed to instantiate a conv layer. - - Returns: - layer (nn.Module): created conv layer - """ - if cfg is None: - cfg_ = dict(type='Conv') - else: - assert isinstance(cfg, dict) and 'type' in cfg - cfg_ = cfg.copy() - - layer_type = cfg_.pop('type') - if layer_type not in conv_cfg: - raise KeyError('Unrecognized norm type {}'.format(layer_type)) - else: - conv_layer = conv_cfg[layer_type] - - layer = conv_layer(*args, **kwargs, **cfg_) - - return layer - + This block simplifies the usage of convolution layers, which are commonly + used with a norm layer (e.g., BatchNorm) and activation layer (e.g., ReLU). + It is based upon three build methods: `build_conv_layer()`, + `build_norm_layer()` and `build_activation_layer()`. -class ConvModule(nn.Module): - """A conv block that contains conv/norm/activation layers. + Besides, we add some additional features in this module. + 1. Automatically set `bias` of the conv layer. + 2. Spectral norm is supported. + 3. More padding modes are supported. Before PyTorch 1.5, nn.Conv2d only + supports zero and circular padding, and we add "reflect" padding mode. Args: - in_channels (int): Same as nn.Conv2d. - out_channels (int): Same as nn.Conv2d. - kernel_size (int or tuple[int]): Same as nn.Conv2d. - stride (int or tuple[int]): Same as nn.Conv2d. - padding (int or tuple[int]): Same as nn.Conv2d. - dilation (int or tuple[int]): Same as nn.Conv2d. - groups (int): Same as nn.Conv2d. - bias (bool or str): If specified as `auto`, it will be decided by the - norm_cfg. Bias will be set as True if norm_cfg is None, otherwise - False. - conv_cfg (dict): Config dict for convolution layer. - norm_cfg (dict): Config dict for normalization layer. - activation (str or None): Activation type, "ReLU" by default. + in_channels (int): Number of channels in the input feature map. + Same as that in ``nn._ConvNd``. + out_channels (int): Number of channels produced by the convolution. + Same as that in ``nn._ConvNd``. + kernel_size (int | tuple[int]): Size of the convolving kernel. + Same as that in ``nn._ConvNd``. + stride (int | tuple[int]): Stride of the convolution. + Same as that in ``nn._ConvNd``. + padding (int | tuple[int]): Zero-padding added to both sides of + the input. Same as that in ``nn._ConvNd``. + dilation (int | tuple[int]): Spacing between kernel elements. + Same as that in ``nn._ConvNd``. + groups (int): Number of blocked connections from input channels to + output channels. Same as that in ``nn._ConvNd``. + bias (bool | str): If specified as `auto`, it will be decided by the + norm_cfg. Bias will be set as True if `norm_cfg` is None, otherwise + False. Default: "auto". + conv_cfg (dict): Config dict for convolution layer. Default: None, + which means using conv2d. + norm_cfg (dict): Config dict for normalization layer. Default: None. + act_cfg (dict): Config dict for activation layer. + Default: dict(type='ReLU'). inplace (bool): Whether to use inplace mode for activation. + Default: True. + with_spectral_norm (bool): Whether use spectral norm in conv module. + Default: False. + padding_mode (str): If the `padding_mode` has not been supported by + current `Conv2d` in PyTorch, we will use our own padding layer + instead. Currently, we support ['zeros', 'circular'] with official + implementation and ['reflect'] with our own implementation. + Default: 'zeros'. order (tuple[str]): The order of conv/norm/activation layers. It is a - sequence of "conv", "norm" and "act". Examples are + sequence of "conv", "norm" and "act". Common examples are ("conv", "norm", "act") and ("act", "conv", "norm"). + Default: ('conv', 'norm', 'act'). """ + _abbr_ = 'conv_block' + def __init__(self, in_channels, out_channels, @@ -78,30 +78,39 @@ class ConvModule(nn.Module): bias='auto', conv_cfg=None, norm_cfg=None, - activation='relu', + act_cfg=dict(type='ReLU'), inplace=True, + with_spectral_norm=False, + padding_mode='zeros', order=('conv', 'norm', 'act')): super(ConvModule, self).__init__() assert conv_cfg is None or isinstance(conv_cfg, dict) assert norm_cfg is None or isinstance(norm_cfg, dict) + assert act_cfg is None or isinstance(act_cfg, dict) + official_padding_mode = ['zeros', 'circular'] self.conv_cfg = conv_cfg self.norm_cfg = norm_cfg - self.activation = activation + self.act_cfg = act_cfg self.inplace = inplace + self.with_spectral_norm = with_spectral_norm + self.with_explicit_padding = padding_mode not in official_padding_mode self.order = order assert isinstance(self.order, tuple) and len(self.order) == 3 assert set(order) == set(['conv', 'norm', 'act']) self.with_norm = norm_cfg is not None - self.with_activation = activation is not None + self.with_activation = act_cfg is not None # if the conv layer is before a norm layer, bias is unnecessary. if bias == 'auto': - bias = False if self.with_norm else True + bias = not self.with_norm self.with_bias = bias - if self.with_norm and self.with_bias: - warnings.warn('ConvModule has norm and bias at the same time') + if self.with_explicit_padding: + pad_cfg = dict(type=padding_mode) + self.padding_layer = build_padding_layer(pad_cfg, padding) + # reset padding to 0 for conv module + conv_padding = 0 if self.with_explicit_padding else padding # build convolution layer self.conv = build_conv_layer( conv_cfg, @@ -109,7 +118,7 @@ class ConvModule(nn.Module): out_channels, kernel_size, stride=stride, - padding=padding, + padding=conv_padding, dilation=dilation, groups=groups, bias=bias) @@ -118,12 +127,15 @@ class ConvModule(nn.Module): self.out_channels = self.conv.out_channels self.kernel_size = self.conv.kernel_size self.stride = self.conv.stride - self.padding = self.conv.padding + self.padding = padding self.dilation = self.conv.dilation self.transposed = self.conv.transposed self.output_padding = self.conv.output_padding self.groups = self.conv.groups + if self.with_spectral_norm: + self.conv = nn.utils.spectral_norm(self.conv) + # build normalization layers if self.with_norm: # norm layer is after conv layer @@ -133,32 +145,59 @@ class ConvModule(nn.Module): norm_channels = in_channels self.norm_name, norm = build_norm_layer(norm_cfg, norm_channels) self.add_module(self.norm_name, norm) + if self.with_bias: + if isinstance(norm, (_BatchNorm, _InstanceNorm)): + warnings.warn( + 'Unnecessary conv bias before batch/instance norm') + else: + self.norm_name = None # build activation layer if self.with_activation: - # TODO: introduce `act_cfg` and supports more activation layers - if self.activation not in ['relu']: - raise ValueError('{} is currently not supported.'.format( - self.activation)) - if self.activation == 'relu': - self.activate = nn.ReLU(inplace=inplace) + act_cfg_ = act_cfg.copy() + # nn.Tanh has no 'inplace' argument + if act_cfg_['type'] not in [ + 'Tanh', 'PReLU', 'Sigmoid', 'HSigmoid', 'Swish' + ]: + act_cfg_.setdefault('inplace', inplace) + self.activate = build_activation_layer(act_cfg_) # Use msra init by default self.init_weights() @property def norm(self): - return getattr(self, self.norm_name) + if self.norm_name: + return getattr(self, self.norm_name) + else: + return None def init_weights(self): - nonlinearity = 'relu' if self.activation is None else self.activation - kaiming_init(self.conv, nonlinearity=nonlinearity) + # 1. It is mainly for customized conv layers with their own + # initialization manners by calling their own ``init_weights()``, + # and we do not want ConvModule to override the initialization. + # 2. For customized conv layers without their own initialization + # manners (that is, they don't have their own ``init_weights()``) + # and PyTorch's conv layers, they will be initialized by + # this method with default ``kaiming_init``. + # Note: For PyTorch's conv layers, they will be overwritten by our + # initialization implementation using default ``kaiming_init``. + if not hasattr(self.conv, 'init_weights'): + if self.with_activation and self.act_cfg['type'] == 'LeakyReLU': + nonlinearity = 'leaky_relu' + a = self.act_cfg.get('negative_slope', 0.01) + else: + nonlinearity = 'relu' + a = 0 + kaiming_init(self.conv, a=a, nonlinearity=nonlinearity) if self.with_norm: constant_init(self.norm, 1, bias=0) def forward(self, x, activate=True, norm=True): for layer in self.order: if layer == 'conv': + if self.with_explicit_padding: + x = self.padding_layer(x) x = self.conv(x) elif layer == 'norm' and norm and self.with_norm: x = self.norm(x) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/conv_ws.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/conv_ws.py new file mode 100644 index 000000000..a3941e278 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/conv_ws.py @@ -0,0 +1,148 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch +import torch.nn as nn +import torch.nn.functional as F + +from .registry import CONV_LAYERS + + +def conv_ws_2d(input, + weight, + bias=None, + stride=1, + padding=0, + dilation=1, + groups=1, + eps=1e-5): + c_in = weight.size(0) + weight_flat = weight.view(c_in, -1) + mean = weight_flat.mean(dim=1, keepdim=True).view(c_in, 1, 1, 1) + std = weight_flat.std(dim=1, keepdim=True).view(c_in, 1, 1, 1) + weight = (weight - mean) / (std + eps) + return F.conv2d(input, weight, bias, stride, padding, dilation, groups) + + +@CONV_LAYERS.register_module('ConvWS') +class ConvWS2d(nn.Conv2d): + + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride=1, + padding=0, + dilation=1, + groups=1, + bias=True, + eps=1e-5): + super(ConvWS2d, self).__init__( + in_channels, + out_channels, + kernel_size, + stride=stride, + padding=padding, + dilation=dilation, + groups=groups, + bias=bias) + self.eps = eps + + def forward(self, x): + return conv_ws_2d(x, self.weight, self.bias, self.stride, self.padding, + self.dilation, self.groups, self.eps) + + +@CONV_LAYERS.register_module(name='ConvAWS') +class ConvAWS2d(nn.Conv2d): + """AWS (Adaptive Weight Standardization) + + This is a variant of Weight Standardization + (https://arxiv.org/pdf/1903.10520.pdf) + It is used in DetectoRS to avoid NaN + (https://arxiv.org/pdf/2006.02334.pdf) + + Args: + in_channels (int): Number of channels in the input image + out_channels (int): Number of channels produced by the convolution + kernel_size (int or tuple): Size of the conv kernel + stride (int or tuple, optional): Stride of the convolution. Default: 1 + padding (int or tuple, optional): Zero-padding added to both sides of + the input. Default: 0 + dilation (int or tuple, optional): Spacing between kernel elements. + Default: 1 + groups (int, optional): Number of blocked connections from input + channels to output channels. Default: 1 + bias (bool, optional): If set True, adds a learnable bias to the + output. Default: True + """ + + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride=1, + padding=0, + dilation=1, + groups=1, + bias=True): + super().__init__( + in_channels, + out_channels, + kernel_size, + stride=stride, + padding=padding, + dilation=dilation, + groups=groups, + bias=bias) + self.register_buffer('weight_gamma', + torch.ones(self.out_channels, 1, 1, 1)) + self.register_buffer('weight_beta', + torch.zeros(self.out_channels, 1, 1, 1)) + + def _get_weight(self, weight): + weight_flat = weight.view(weight.size(0), -1) + mean = weight_flat.mean(dim=1).view(-1, 1, 1, 1) + std = torch.sqrt(weight_flat.var(dim=1) + 1e-5).view(-1, 1, 1, 1) + weight = (weight - mean) / std + weight = self.weight_gamma * weight + self.weight_beta + return weight + + def forward(self, x): + weight = self._get_weight(self.weight) + return F.conv2d(x, weight, self.bias, self.stride, self.padding, + self.dilation, self.groups) + + def _load_from_state_dict(self, state_dict, prefix, local_metadata, strict, + missing_keys, unexpected_keys, error_msgs): + """Override default load function. + + AWS overrides the function _load_from_state_dict to recover + weight_gamma and weight_beta if they are missing. If weight_gamma and + weight_beta are found in the checkpoint, this function will return + after super()._load_from_state_dict. Otherwise, it will compute the + mean and std of the pretrained weights and store them in weight_beta + and weight_gamma. + """ + + self.weight_gamma.data.fill_(-1) + local_missing_keys = [] + super()._load_from_state_dict(state_dict, prefix, local_metadata, + strict, local_missing_keys, + unexpected_keys, error_msgs) + if self.weight_gamma.data.mean() > 0: + for k in local_missing_keys: + missing_keys.append(k) + return + weight = self.weight.data + weight_flat = weight.view(weight.size(0), -1) + mean = weight_flat.mean(dim=1).view(-1, 1, 1, 1) + std = torch.sqrt(weight_flat.var(dim=1) + 1e-5).view(-1, 1, 1, 1) + self.weight_beta.data.copy_(mean) + self.weight_gamma.data.copy_(std) + missing_gamma_beta = [ + k for k in local_missing_keys + if k.endswith('weight_gamma') or k.endswith('weight_beta') + ] + for k in missing_gamma_beta: + local_missing_keys.remove(k) + for k in local_missing_keys: + missing_keys.append(k) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/depthwise_separable_conv_module.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/depthwise_separable_conv_module.py new file mode 100644 index 000000000..722d5d8d7 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/depthwise_separable_conv_module.py @@ -0,0 +1,96 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch.nn as nn + +from .conv_module import ConvModule + + +class DepthwiseSeparableConvModule(nn.Module): + """Depthwise separable convolution module. + + See https://arxiv.org/pdf/1704.04861.pdf for details. + + This module can replace a ConvModule with the conv block replaced by two + conv block: depthwise conv block and pointwise conv block. The depthwise + conv block contains depthwise-conv/norm/activation layers. The pointwise + conv block contains pointwise-conv/norm/activation layers. It should be + noted that there will be norm/activation layer in the depthwise conv block + if `norm_cfg` and `act_cfg` are specified. + + Args: + in_channels (int): Number of channels in the input feature map. + Same as that in ``nn._ConvNd``. + out_channels (int): Number of channels produced by the convolution. + Same as that in ``nn._ConvNd``. + kernel_size (int | tuple[int]): Size of the convolving kernel. + Same as that in ``nn._ConvNd``. + stride (int | tuple[int]): Stride of the convolution. + Same as that in ``nn._ConvNd``. Default: 1. + padding (int | tuple[int]): Zero-padding added to both sides of + the input. Same as that in ``nn._ConvNd``. Default: 0. + dilation (int | tuple[int]): Spacing between kernel elements. + Same as that in ``nn._ConvNd``. Default: 1. + norm_cfg (dict): Default norm config for both depthwise ConvModule and + pointwise ConvModule. Default: None. + act_cfg (dict): Default activation config for both depthwise ConvModule + and pointwise ConvModule. Default: dict(type='ReLU'). + dw_norm_cfg (dict): Norm config of depthwise ConvModule. If it is + 'default', it will be the same as `norm_cfg`. Default: 'default'. + dw_act_cfg (dict): Activation config of depthwise ConvModule. If it is + 'default', it will be the same as `act_cfg`. Default: 'default'. + pw_norm_cfg (dict): Norm config of pointwise ConvModule. If it is + 'default', it will be the same as `norm_cfg`. Default: 'default'. + pw_act_cfg (dict): Activation config of pointwise ConvModule. If it is + 'default', it will be the same as `act_cfg`. Default: 'default'. + kwargs (optional): Other shared arguments for depthwise and pointwise + ConvModule. See ConvModule for ref. + """ + + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride=1, + padding=0, + dilation=1, + norm_cfg=None, + act_cfg=dict(type='ReLU'), + dw_norm_cfg='default', + dw_act_cfg='default', + pw_norm_cfg='default', + pw_act_cfg='default', + **kwargs): + super(DepthwiseSeparableConvModule, self).__init__() + assert 'groups' not in kwargs, 'groups should not be specified' + + # if norm/activation config of depthwise/pointwise ConvModule is not + # specified, use default config. + dw_norm_cfg = dw_norm_cfg if dw_norm_cfg != 'default' else norm_cfg + dw_act_cfg = dw_act_cfg if dw_act_cfg != 'default' else act_cfg + pw_norm_cfg = pw_norm_cfg if pw_norm_cfg != 'default' else norm_cfg + pw_act_cfg = pw_act_cfg if pw_act_cfg != 'default' else act_cfg + + # depthwise convolution + self.depthwise_conv = ConvModule( + in_channels, + in_channels, + kernel_size, + stride=stride, + padding=padding, + dilation=dilation, + groups=in_channels, + norm_cfg=dw_norm_cfg, + act_cfg=dw_act_cfg, + **kwargs) + + self.pointwise_conv = ConvModule( + in_channels, + out_channels, + 1, + norm_cfg=pw_norm_cfg, + act_cfg=pw_act_cfg, + **kwargs) + + def forward(self, x): + x = self.depthwise_conv(x) + x = self.pointwise_conv(x) + return x diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/drop.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/drop.py new file mode 100644 index 000000000..b0a026654 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/drop.py @@ -0,0 +1,65 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch +import torch.nn as nn + +from mmcv import build_from_cfg +from .registry import DROPOUT_LAYERS + + +def drop_path(x, drop_prob=0., training=False): + """Drop paths (Stochastic Depth) per sample (when applied in main path of + residual blocks). + + We follow the implementation + https://github.com/rwightman/pytorch-image-models/blob/a2727c1bf78ba0d7b5727f5f95e37fb7f8866b1f/timm/models/layers/drop.py # noqa: E501 + """ + if drop_prob == 0. or not training: + return x + keep_prob = 1 - drop_prob + # handle tensors with different dimensions, not just 4D tensors. + shape = (x.shape[0], ) + (1, ) * (x.ndim - 1) + random_tensor = keep_prob + torch.rand( + shape, dtype=x.dtype, device=x.device) + output = x.div(keep_prob) * random_tensor.floor() + return output + + +@DROPOUT_LAYERS.register_module() +class DropPath(nn.Module): + """Drop paths (Stochastic Depth) per sample (when applied in main path of + residual blocks). + + We follow the implementation + https://github.com/rwightman/pytorch-image-models/blob/a2727c1bf78ba0d7b5727f5f95e37fb7f8866b1f/timm/models/layers/drop.py # noqa: E501 + + Args: + drop_prob (float): Probability of the path to be zeroed. Default: 0.1 + """ + + def __init__(self, drop_prob=0.1): + super(DropPath, self).__init__() + self.drop_prob = drop_prob + + def forward(self, x): + return drop_path(x, self.drop_prob, self.training) + + +@DROPOUT_LAYERS.register_module() +class Dropout(nn.Dropout): + """A wrapper for ``torch.nn.Dropout``, We rename the ``p`` of + ``torch.nn.Dropout`` to ``drop_prob`` so as to be consistent with + ``DropPath`` + + Args: + drop_prob (float): Probability of the elements to be + zeroed. Default: 0.5. + inplace (bool): Do the operation inplace or not. Default: False. + """ + + def __init__(self, drop_prob=0.5, inplace=False): + super().__init__(p=drop_prob, inplace=inplace) + + +def build_dropout(cfg, default_args=None): + """Builder for drop out layers.""" + return build_from_cfg(cfg, DROPOUT_LAYERS, default_args) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/generalized_attention.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/generalized_attention.py similarity index 85% rename from cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/generalized_attention.py rename to cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/generalized_attention.py index 86e5b1e9d..988d9adf2 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/generalized_attention.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/generalized_attention.py @@ -1,12 +1,16 @@ +# Copyright (c) OpenMMLab. All rights reserved. import math import numpy as np import torch import torch.nn as nn import torch.nn.functional as F -from mmcv.cnn import kaiming_init +from ..utils import kaiming_init +from .registry import PLUGIN_LAYERS + +@PLUGIN_LAYERS.register_module() class GeneralizedAttention(nn.Module): """GeneralizedAttention module. @@ -14,25 +18,34 @@ class GeneralizedAttention(nn.Module): (https://arxiv.org/abs/1711.07971) for details. Args: - in_dim (int): Channels of the input feature map. - spatial_range (int): The spatial range. - -1 indicates no spatial range constraint. + in_channels (int): Channels of the input feature map. + spatial_range (int): The spatial range. -1 indicates no spatial range + constraint. Default: -1. num_heads (int): The head number of empirical_attention module. + Default: 9. position_embedding_dim (int): The position embedding dimension. + Default: -1. position_magnitude (int): A multiplier acting on coord difference. + Default: 1. kv_stride (int): The feature stride acting on key/value feature map. + Default: 2. q_stride (int): The feature stride acting on query feature map. + Default: 1. attention_type (str): A binary indicator string for indicating which items in generalized empirical_attention module are used. - '1000' indicates 'query and key content' (appr - appr) item, - '0100' indicates 'query content and relative position' + Default: '1111'. + + - '1000' indicates 'query and key content' (appr - appr) item, + - '0100' indicates 'query content and relative position' (appr - position) item, - '0010' indicates 'key content only' (bias - appr) item, - '0001' indicates 'relative position only' (bias - position) item. + - '0010' indicates 'key content only' (bias - appr) item, + - '0001' indicates 'relative position only' (bias - position) item. """ + _abbr_ = 'gen_attention_block' + def __init__(self, - in_dim, + in_channels, spatial_range=-1, num_heads=9, position_embedding_dim=-1, @@ -45,21 +58,22 @@ class GeneralizedAttention(nn.Module): # hard range means local range for non-local operation self.position_embedding_dim = ( - position_embedding_dim if position_embedding_dim > 0 else in_dim) + position_embedding_dim + if position_embedding_dim > 0 else in_channels) self.position_magnitude = position_magnitude self.num_heads = num_heads - self.channel_in = in_dim + self.in_channels = in_channels self.spatial_range = spatial_range self.kv_stride = kv_stride self.q_stride = q_stride self.attention_type = [bool(int(_)) for _ in attention_type] - self.qk_embed_dim = in_dim // num_heads + self.qk_embed_dim = in_channels // num_heads out_c = self.qk_embed_dim * num_heads if self.attention_type[0] or self.attention_type[1]: self.query_conv = nn.Conv2d( - in_channels=in_dim, + in_channels=in_channels, out_channels=out_c, kernel_size=1, bias=False) @@ -67,15 +81,15 @@ class GeneralizedAttention(nn.Module): if self.attention_type[0] or self.attention_type[2]: self.key_conv = nn.Conv2d( - in_channels=in_dim, + in_channels=in_channels, out_channels=out_c, kernel_size=1, bias=False) self.key_conv.kaiming_init = True - self.v_dim = in_dim // num_heads + self.v_dim = in_channels // num_heads self.value_conv = nn.Conv2d( - in_channels=in_dim, + in_channels=in_channels, out_channels=self.v_dim * num_heads, kernel_size=1, bias=False) @@ -102,7 +116,7 @@ class GeneralizedAttention(nn.Module): self.proj_conv = nn.Conv2d( in_channels=self.v_dim * num_heads, - out_channels=in_dim, + out_channels=in_channels, kernel_size=1, bias=True) self.proj_conv.kaiming_init = True @@ -110,9 +124,9 @@ class GeneralizedAttention(nn.Module): if self.spatial_range >= 0: # only works when non local is after 3*3 conv - if in_dim == 256: + if in_channels == 256: max_len = 84 - elif in_dim == 512: + elif in_channels == 512: max_len = 42 max_len_kv = int((max_len - 1.0) / self.kv_stride + 1) @@ -157,18 +171,23 @@ class GeneralizedAttention(nn.Module): q_stride, kv_stride, device, + dtype, feat_dim, wave_length=1000): - h_idxs = torch.linspace(0, h - 1, h).cuda(device) + # the default type of Tensor is float32, leading to type mismatch + # in fp16 mode. Cast it to support fp16 mode. + h_idxs = torch.linspace(0, h - 1, h).to(device=device, dtype=dtype) h_idxs = h_idxs.view((h, 1)) * q_stride - w_idxs = torch.linspace(0, w - 1, w).cuda(device) + w_idxs = torch.linspace(0, w - 1, w).to(device=device, dtype=dtype) w_idxs = w_idxs.view((w, 1)) * q_stride - h_kv_idxs = torch.linspace(0, h_kv - 1, h_kv).cuda(device) + h_kv_idxs = torch.linspace(0, h_kv - 1, h_kv).to( + device=device, dtype=dtype) h_kv_idxs = h_kv_idxs.view((h_kv, 1)) * kv_stride - w_kv_idxs = torch.linspace(0, w_kv - 1, w_kv).cuda(device) + w_kv_idxs = torch.linspace(0, w_kv - 1, w_kv).to( + device=device, dtype=dtype) w_kv_idxs = w_kv_idxs.view((w_kv, 1)) * kv_stride # (h, h_kv, 1) @@ -179,9 +198,10 @@ class GeneralizedAttention(nn.Module): w_diff = w_idxs.unsqueeze(1) - w_kv_idxs.unsqueeze(0) w_diff *= self.position_magnitude - feat_range = torch.arange(0, feat_dim / 4).cuda(device) + feat_range = torch.arange(0, feat_dim / 4).to( + device=device, dtype=dtype) - dim_mat = torch.Tensor([wave_length]).cuda(device) + dim_mat = torch.Tensor([wave_length]).to(device=device, dtype=dtype) dim_mat = dim_mat**((4. / feat_dim) * feat_range) dim_mat = dim_mat.view((1, 1, -1)) @@ -221,7 +241,7 @@ class GeneralizedAttention(nn.Module): if self.attention_type[1] or self.attention_type[3]: position_embed_x, position_embed_y = self.get_position_embedding( h, w, h_kv, w_kv, self.q_stride, self.kv_stride, - x_input.device, self.position_embedding_dim) + x_input.device, x_input.dtype, self.position_embedding_dim) # (n, num_heads, w, w_kv, dim) position_feat_x = self.appr_geom_fc_x(position_embed_x).\ view(1, w, w_kv, num_heads, self.qk_embed_dim).\ @@ -368,6 +388,15 @@ class GeneralizedAttention(nn.Module): view(n, self.v_dim * self.num_heads, h, w) out = self.proj_conv(out) + + # output is downsampled, upsample back to input size + if self.q_downsample is not None: + out = F.interpolate( + out, + size=x_input.shape[2:], + mode='bilinear', + align_corners=False) + out = self.gamma * out + x_input return out diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/hsigmoid.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/hsigmoid.py new file mode 100644 index 000000000..30b1a3d65 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/hsigmoid.py @@ -0,0 +1,34 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch.nn as nn + +from .registry import ACTIVATION_LAYERS + + +@ACTIVATION_LAYERS.register_module() +class HSigmoid(nn.Module): + """Hard Sigmoid Module. Apply the hard sigmoid function: + Hsigmoid(x) = min(max((x + bias) / divisor, min_value), max_value) + Default: Hsigmoid(x) = min(max((x + 1) / 2, 0), 1) + + Args: + bias (float): Bias of the input feature map. Default: 1.0. + divisor (float): Divisor of the input feature map. Default: 2.0. + min_value (float): Lower bound value. Default: 0.0. + max_value (float): Upper bound value. Default: 1.0. + + Returns: + Tensor: The output tensor. + """ + + def __init__(self, bias=1.0, divisor=2.0, min_value=0.0, max_value=1.0): + super(HSigmoid, self).__init__() + self.bias = bias + self.divisor = divisor + assert self.divisor != 0 + self.min_value = min_value + self.max_value = max_value + + def forward(self, x): + x = (x + self.bias) / self.divisor + + return x.clamp_(self.min_value, self.max_value) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/hswish.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/hswish.py new file mode 100644 index 000000000..7e0c090ff --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/hswish.py @@ -0,0 +1,29 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch.nn as nn + +from .registry import ACTIVATION_LAYERS + + +@ACTIVATION_LAYERS.register_module() +class HSwish(nn.Module): + """Hard Swish Module. + + This module applies the hard swish function: + + .. math:: + Hswish(x) = x * ReLU6(x + 3) / 6 + + Args: + inplace (bool): can optionally do the operation in-place. + Default: False. + + Returns: + Tensor: The output tensor. + """ + + def __init__(self, inplace=False): + super(HSwish, self).__init__() + self.act = nn.ReLU6(inplace) + + def forward(self, x): + return x * self.act(x + 3) / 6 diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/non_local.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/non_local.py new file mode 100644 index 000000000..92d00155e --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/non_local.py @@ -0,0 +1,306 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from abc import ABCMeta + +import torch +import torch.nn as nn + +from ..utils import constant_init, normal_init +from .conv_module import ConvModule +from .registry import PLUGIN_LAYERS + + +class _NonLocalNd(nn.Module, metaclass=ABCMeta): + """Basic Non-local module. + + This module is proposed in + "Non-local Neural Networks" + Paper reference: https://arxiv.org/abs/1711.07971 + Code reference: https://github.com/AlexHex7/Non-local_pytorch + + Args: + in_channels (int): Channels of the input feature map. + reduction (int): Channel reduction ratio. Default: 2. + use_scale (bool): Whether to scale pairwise_weight by + `1/sqrt(inter_channels)` when the mode is `embedded_gaussian`. + Default: True. + conv_cfg (None | dict): The config dict for convolution layers. + If not specified, it will use `nn.Conv2d` for convolution layers. + Default: None. + norm_cfg (None | dict): The config dict for normalization layers. + Default: None. (This parameter is only applicable to conv_out.) + mode (str): Options are `gaussian`, `concatenation`, + `embedded_gaussian` and `dot_product`. Default: embedded_gaussian. + """ + + def __init__(self, + in_channels, + reduction=2, + use_scale=True, + conv_cfg=None, + norm_cfg=None, + mode='embedded_gaussian', + **kwargs): + super(_NonLocalNd, self).__init__() + self.in_channels = in_channels + self.reduction = reduction + self.use_scale = use_scale + self.inter_channels = max(in_channels // reduction, 1) + self.mode = mode + + if mode not in [ + 'gaussian', 'embedded_gaussian', 'dot_product', 'concatenation' + ]: + raise ValueError("Mode should be in 'gaussian', 'concatenation', " + f"'embedded_gaussian' or 'dot_product', but got " + f'{mode} instead.') + + # g, theta, phi are defaulted as `nn.ConvNd`. + # Here we use ConvModule for potential usage. + self.g = ConvModule( + self.in_channels, + self.inter_channels, + kernel_size=1, + conv_cfg=conv_cfg, + act_cfg=None) + self.conv_out = ConvModule( + self.inter_channels, + self.in_channels, + kernel_size=1, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + act_cfg=None) + + if self.mode != 'gaussian': + self.theta = ConvModule( + self.in_channels, + self.inter_channels, + kernel_size=1, + conv_cfg=conv_cfg, + act_cfg=None) + self.phi = ConvModule( + self.in_channels, + self.inter_channels, + kernel_size=1, + conv_cfg=conv_cfg, + act_cfg=None) + + if self.mode == 'concatenation': + self.concat_project = ConvModule( + self.inter_channels * 2, + 1, + kernel_size=1, + stride=1, + padding=0, + bias=False, + act_cfg=dict(type='ReLU')) + + self.init_weights(**kwargs) + + def init_weights(self, std=0.01, zeros_init=True): + if self.mode != 'gaussian': + for m in [self.g, self.theta, self.phi]: + normal_init(m.conv, std=std) + else: + normal_init(self.g.conv, std=std) + if zeros_init: + if self.conv_out.norm_cfg is None: + constant_init(self.conv_out.conv, 0) + else: + constant_init(self.conv_out.norm, 0) + else: + if self.conv_out.norm_cfg is None: + normal_init(self.conv_out.conv, std=std) + else: + normal_init(self.conv_out.norm, std=std) + + def gaussian(self, theta_x, phi_x): + # NonLocal1d pairwise_weight: [N, H, H] + # NonLocal2d pairwise_weight: [N, HxW, HxW] + # NonLocal3d pairwise_weight: [N, TxHxW, TxHxW] + pairwise_weight = torch.matmul(theta_x, phi_x) + pairwise_weight = pairwise_weight.softmax(dim=-1) + return pairwise_weight + + def embedded_gaussian(self, theta_x, phi_x): + # NonLocal1d pairwise_weight: [N, H, H] + # NonLocal2d pairwise_weight: [N, HxW, HxW] + # NonLocal3d pairwise_weight: [N, TxHxW, TxHxW] + pairwise_weight = torch.matmul(theta_x, phi_x) + if self.use_scale: + # theta_x.shape[-1] is `self.inter_channels` + pairwise_weight /= theta_x.shape[-1]**0.5 + pairwise_weight = pairwise_weight.softmax(dim=-1) + return pairwise_weight + + def dot_product(self, theta_x, phi_x): + # NonLocal1d pairwise_weight: [N, H, H] + # NonLocal2d pairwise_weight: [N, HxW, HxW] + # NonLocal3d pairwise_weight: [N, TxHxW, TxHxW] + pairwise_weight = torch.matmul(theta_x, phi_x) + pairwise_weight /= pairwise_weight.shape[-1] + return pairwise_weight + + def concatenation(self, theta_x, phi_x): + # NonLocal1d pairwise_weight: [N, H, H] + # NonLocal2d pairwise_weight: [N, HxW, HxW] + # NonLocal3d pairwise_weight: [N, TxHxW, TxHxW] + h = theta_x.size(2) + w = phi_x.size(3) + theta_x = theta_x.repeat(1, 1, 1, w) + phi_x = phi_x.repeat(1, 1, h, 1) + + concat_feature = torch.cat([theta_x, phi_x], dim=1) + pairwise_weight = self.concat_project(concat_feature) + n, _, h, w = pairwise_weight.size() + pairwise_weight = pairwise_weight.view(n, h, w) + pairwise_weight /= pairwise_weight.shape[-1] + + return pairwise_weight + + def forward(self, x): + # Assume `reduction = 1`, then `inter_channels = C` + # or `inter_channels = C` when `mode="gaussian"` + + # NonLocal1d x: [N, C, H] + # NonLocal2d x: [N, C, H, W] + # NonLocal3d x: [N, C, T, H, W] + n = x.size(0) + + # NonLocal1d g_x: [N, H, C] + # NonLocal2d g_x: [N, HxW, C] + # NonLocal3d g_x: [N, TxHxW, C] + g_x = self.g(x).view(n, self.inter_channels, -1) + g_x = g_x.permute(0, 2, 1) + + # NonLocal1d theta_x: [N, H, C], phi_x: [N, C, H] + # NonLocal2d theta_x: [N, HxW, C], phi_x: [N, C, HxW] + # NonLocal3d theta_x: [N, TxHxW, C], phi_x: [N, C, TxHxW] + if self.mode == 'gaussian': + theta_x = x.view(n, self.in_channels, -1) + theta_x = theta_x.permute(0, 2, 1) + if self.sub_sample: + phi_x = self.phi(x).view(n, self.in_channels, -1) + else: + phi_x = x.view(n, self.in_channels, -1) + elif self.mode == 'concatenation': + theta_x = self.theta(x).view(n, self.inter_channels, -1, 1) + phi_x = self.phi(x).view(n, self.inter_channels, 1, -1) + else: + theta_x = self.theta(x).view(n, self.inter_channels, -1) + theta_x = theta_x.permute(0, 2, 1) + phi_x = self.phi(x).view(n, self.inter_channels, -1) + + pairwise_func = getattr(self, self.mode) + # NonLocal1d pairwise_weight: [N, H, H] + # NonLocal2d pairwise_weight: [N, HxW, HxW] + # NonLocal3d pairwise_weight: [N, TxHxW, TxHxW] + pairwise_weight = pairwise_func(theta_x, phi_x) + + # NonLocal1d y: [N, H, C] + # NonLocal2d y: [N, HxW, C] + # NonLocal3d y: [N, TxHxW, C] + y = torch.matmul(pairwise_weight, g_x) + # NonLocal1d y: [N, C, H] + # NonLocal2d y: [N, C, H, W] + # NonLocal3d y: [N, C, T, H, W] + y = y.permute(0, 2, 1).contiguous().reshape(n, self.inter_channels, + *x.size()[2:]) + + output = x + self.conv_out(y) + + return output + + +class NonLocal1d(_NonLocalNd): + """1D Non-local module. + + Args: + in_channels (int): Same as `NonLocalND`. + sub_sample (bool): Whether to apply max pooling after pairwise + function (Note that the `sub_sample` is applied on spatial only). + Default: False. + conv_cfg (None | dict): Same as `NonLocalND`. + Default: dict(type='Conv1d'). + """ + + def __init__(self, + in_channels, + sub_sample=False, + conv_cfg=dict(type='Conv1d'), + **kwargs): + super(NonLocal1d, self).__init__( + in_channels, conv_cfg=conv_cfg, **kwargs) + + self.sub_sample = sub_sample + + if sub_sample: + max_pool_layer = nn.MaxPool1d(kernel_size=2) + self.g = nn.Sequential(self.g, max_pool_layer) + if self.mode != 'gaussian': + self.phi = nn.Sequential(self.phi, max_pool_layer) + else: + self.phi = max_pool_layer + + +@PLUGIN_LAYERS.register_module() +class NonLocal2d(_NonLocalNd): + """2D Non-local module. + + Args: + in_channels (int): Same as `NonLocalND`. + sub_sample (bool): Whether to apply max pooling after pairwise + function (Note that the `sub_sample` is applied on spatial only). + Default: False. + conv_cfg (None | dict): Same as `NonLocalND`. + Default: dict(type='Conv2d'). + """ + + _abbr_ = 'nonlocal_block' + + def __init__(self, + in_channels, + sub_sample=False, + conv_cfg=dict(type='Conv2d'), + **kwargs): + super(NonLocal2d, self).__init__( + in_channels, conv_cfg=conv_cfg, **kwargs) + + self.sub_sample = sub_sample + + if sub_sample: + max_pool_layer = nn.MaxPool2d(kernel_size=(2, 2)) + self.g = nn.Sequential(self.g, max_pool_layer) + if self.mode != 'gaussian': + self.phi = nn.Sequential(self.phi, max_pool_layer) + else: + self.phi = max_pool_layer + + +class NonLocal3d(_NonLocalNd): + """3D Non-local module. + + Args: + in_channels (int): Same as `NonLocalND`. + sub_sample (bool): Whether to apply max pooling after pairwise + function (Note that the `sub_sample` is applied on spatial only). + Default: False. + conv_cfg (None | dict): Same as `NonLocalND`. + Default: dict(type='Conv3d'). + """ + + def __init__(self, + in_channels, + sub_sample=False, + conv_cfg=dict(type='Conv3d'), + **kwargs): + super(NonLocal3d, self).__init__( + in_channels, conv_cfg=conv_cfg, **kwargs) + self.sub_sample = sub_sample + + if sub_sample: + max_pool_layer = nn.MaxPool3d(kernel_size=(1, 2, 2)) + self.g = nn.Sequential(self.g, max_pool_layer) + if self.mode != 'gaussian': + self.phi = nn.Sequential(self.phi, max_pool_layer) + else: + self.phi = max_pool_layer diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/norm.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/norm.py new file mode 100644 index 000000000..cfb326bdb --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/norm.py @@ -0,0 +1,144 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import inspect + +import torch.nn as nn + +from mmcv.utils import is_tuple_of +from mmcv.utils.parrots_wrapper import SyncBatchNorm, _BatchNorm, _InstanceNorm +from .registry import NORM_LAYERS + +NORM_LAYERS.register_module('BN', module=nn.BatchNorm2d) +NORM_LAYERS.register_module('BN1d', module=nn.BatchNorm1d) +NORM_LAYERS.register_module('BN2d', module=nn.BatchNorm2d) +NORM_LAYERS.register_module('BN3d', module=nn.BatchNorm3d) +NORM_LAYERS.register_module('SyncBN', module=SyncBatchNorm) +NORM_LAYERS.register_module('GN', module=nn.GroupNorm) +NORM_LAYERS.register_module('LN', module=nn.LayerNorm) +NORM_LAYERS.register_module('IN', module=nn.InstanceNorm2d) +NORM_LAYERS.register_module('IN1d', module=nn.InstanceNorm1d) +NORM_LAYERS.register_module('IN2d', module=nn.InstanceNorm2d) +NORM_LAYERS.register_module('IN3d', module=nn.InstanceNorm3d) + + +def infer_abbr(class_type): + """Infer abbreviation from the class name. + + When we build a norm layer with `build_norm_layer()`, we want to preserve + the norm type in variable names, e.g, self.bn1, self.gn. This method will + infer the abbreviation to map class types to abbreviations. + + Rule 1: If the class has the property "_abbr_", return the property. + Rule 2: If the parent class is _BatchNorm, GroupNorm, LayerNorm or + InstanceNorm, the abbreviation of this layer will be "bn", "gn", "ln" and + "in" respectively. + Rule 3: If the class name contains "batch", "group", "layer" or "instance", + the abbreviation of this layer will be "bn", "gn", "ln" and "in" + respectively. + Rule 4: Otherwise, the abbreviation falls back to "norm". + + Args: + class_type (type): The norm layer type. + + Returns: + str: The inferred abbreviation. + """ + if not inspect.isclass(class_type): + raise TypeError( + f'class_type must be a type, but got {type(class_type)}') + if hasattr(class_type, '_abbr_'): + return class_type._abbr_ + if issubclass(class_type, _InstanceNorm): # IN is a subclass of BN + return 'in' + elif issubclass(class_type, _BatchNorm): + return 'bn' + elif issubclass(class_type, nn.GroupNorm): + return 'gn' + elif issubclass(class_type, nn.LayerNorm): + return 'ln' + else: + class_name = class_type.__name__.lower() + if 'batch' in class_name: + return 'bn' + elif 'group' in class_name: + return 'gn' + elif 'layer' in class_name: + return 'ln' + elif 'instance' in class_name: + return 'in' + else: + return 'norm_layer' + + +def build_norm_layer(cfg, num_features, postfix=''): + """Build normalization layer. + + Args: + cfg (dict): The norm layer config, which should contain: + + - type (str): Layer type. + - layer args: Args needed to instantiate a norm layer. + - requires_grad (bool, optional): Whether stop gradient updates. + num_features (int): Number of input channels. + postfix (int | str): The postfix to be appended into norm abbreviation + to create named layer. + + Returns: + (str, nn.Module): The first element is the layer name consisting of + abbreviation and postfix, e.g., bn1, gn. The second element is the + created norm layer. + """ + if not isinstance(cfg, dict): + raise TypeError('cfg must be a dict') + if 'type' not in cfg: + raise KeyError('the cfg dict must contain the key "type"') + cfg_ = cfg.copy() + + layer_type = cfg_.pop('type') + if layer_type not in NORM_LAYERS: + raise KeyError(f'Unrecognized norm type {layer_type}') + + norm_layer = NORM_LAYERS.get(layer_type) + abbr = infer_abbr(norm_layer) + + assert isinstance(postfix, (int, str)) + name = abbr + str(postfix) + + requires_grad = cfg_.pop('requires_grad', True) + cfg_.setdefault('eps', 1e-5) + if layer_type != 'GN': + layer = norm_layer(num_features, **cfg_) + if layer_type == 'SyncBN' and hasattr(layer, '_specify_ddp_gpu_num'): + layer._specify_ddp_gpu_num(1) + else: + assert 'num_groups' in cfg_ + layer = norm_layer(num_channels=num_features, **cfg_) + + for param in layer.parameters(): + param.requires_grad = requires_grad + + return name, layer + + +def is_norm(layer, exclude=None): + """Check if a layer is a normalization layer. + + Args: + layer (nn.Module): The layer to be checked. + exclude (type | tuple[type]): Types to be excluded. + + Returns: + bool: Whether the layer is a norm layer. + """ + if exclude is not None: + if not isinstance(exclude, tuple): + exclude = (exclude, ) + if not is_tuple_of(exclude, type): + raise TypeError( + f'"exclude" must be either None or type or a tuple of types, ' + f'but got {type(exclude)}: {exclude}') + + if exclude and isinstance(layer, exclude): + return False + + all_norm_bases = (_BatchNorm, _InstanceNorm, nn.GroupNorm, nn.LayerNorm) + return isinstance(layer, all_norm_bases) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/padding.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/padding.py new file mode 100644 index 000000000..e4ac6b28a --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/padding.py @@ -0,0 +1,36 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch.nn as nn + +from .registry import PADDING_LAYERS + +PADDING_LAYERS.register_module('zero', module=nn.ZeroPad2d) +PADDING_LAYERS.register_module('reflect', module=nn.ReflectionPad2d) +PADDING_LAYERS.register_module('replicate', module=nn.ReplicationPad2d) + + +def build_padding_layer(cfg, *args, **kwargs): + """Build padding layer. + + Args: + cfg (None or dict): The padding layer config, which should contain: + - type (str): Layer type. + - layer args: Args needed to instantiate a padding layer. + + Returns: + nn.Module: Created padding layer. + """ + if not isinstance(cfg, dict): + raise TypeError('cfg must be a dict') + if 'type' not in cfg: + raise KeyError('the cfg dict must contain the key "type"') + + cfg_ = cfg.copy() + padding_type = cfg_.pop('type') + if padding_type not in PADDING_LAYERS: + raise KeyError(f'Unrecognized padding type {padding_type}.') + else: + padding_layer = PADDING_LAYERS.get(padding_type) + + layer = padding_layer(*args, **kwargs, **cfg_) + + return layer diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/plugin.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/plugin.py new file mode 100644 index 000000000..07c010d40 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/plugin.py @@ -0,0 +1,88 @@ +import inspect +import platform + +from .registry import PLUGIN_LAYERS + +if platform.system() == 'Windows': + import regex as re +else: + import re + + +def infer_abbr(class_type): + """Infer abbreviation from the class name. + + This method will infer the abbreviation to map class types to + abbreviations. + + Rule 1: If the class has the property "abbr", return the property. + Rule 2: Otherwise, the abbreviation falls back to snake case of class + name, e.g. the abbreviation of ``FancyBlock`` will be ``fancy_block``. + + Args: + class_type (type): The norm layer type. + + Returns: + str: The inferred abbreviation. + """ + + def camel2snack(word): + """Convert camel case word into snack case. + + Modified from `inflection lib + `_. + + Example:: + + >>> camel2snack("FancyBlock") + 'fancy_block' + """ + + word = re.sub(r'([A-Z]+)([A-Z][a-z])', r'\1_\2', word) + word = re.sub(r'([a-z\d])([A-Z])', r'\1_\2', word) + word = word.replace('-', '_') + return word.lower() + + if not inspect.isclass(class_type): + raise TypeError( + f'class_type must be a type, but got {type(class_type)}') + if hasattr(class_type, '_abbr_'): + return class_type._abbr_ + else: + return camel2snack(class_type.__name__) + + +def build_plugin_layer(cfg, postfix='', **kwargs): + """Build plugin layer. + + Args: + cfg (None or dict): cfg should contain: + type (str): identify plugin layer type. + layer args: args needed to instantiate a plugin layer. + postfix (int, str): appended into norm abbreviation to + create named layer. Default: ''. + + Returns: + tuple[str, nn.Module]: + name (str): abbreviation + postfix + layer (nn.Module): created plugin layer + """ + if not isinstance(cfg, dict): + raise TypeError('cfg must be a dict') + if 'type' not in cfg: + raise KeyError('the cfg dict must contain the key "type"') + cfg_ = cfg.copy() + + layer_type = cfg_.pop('type') + if layer_type not in PLUGIN_LAYERS: + raise KeyError(f'Unrecognized plugin type {layer_type}') + + plugin_layer = PLUGIN_LAYERS.get(layer_type) + abbr = infer_abbr(plugin_layer) + + assert isinstance(postfix, (int, str)) + name = abbr + str(postfix) + + layer = plugin_layer(**kwargs, **cfg_) + + return name, layer diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/registry.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/registry.py new file mode 100644 index 000000000..c29279776 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/registry.py @@ -0,0 +1,16 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from mmcv.utils import Registry + +CONV_LAYERS = Registry('conv layer') +NORM_LAYERS = Registry('norm layer') +ACTIVATION_LAYERS = Registry('activation layer') +PADDING_LAYERS = Registry('padding layer') +UPSAMPLE_LAYERS = Registry('upsample layer') +PLUGIN_LAYERS = Registry('plugin layer') + +DROPOUT_LAYERS = Registry('drop out layers') +POSITIONAL_ENCODING = Registry('position encoding') +ATTENTION = Registry('attention') +FEEDFORWARD_NETWORK = Registry('feed-forward Network') +TRANSFORMER_LAYER = Registry('transformerLayer') +TRANSFORMER_LAYER_SEQUENCE = Registry('transformer-layers sequence') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/scale.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/scale.py similarity index 47% rename from cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/scale.py rename to cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/scale.py index 2461af8a6..c905fffcc 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/scale.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/scale.py @@ -1,10 +1,16 @@ +# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn class Scale(nn.Module): - """ - A learnable scale parameter + """A learnable scale parameter. + + This layer scales the input by a learnable factor. It multiplies a + learnable scale parameter of shape (1,) with input of any shape. + + Args: + scale (float): Initial value of scale factor. Default: 1.0 """ def __init__(self, scale=1.0): diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/swish.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/swish.py new file mode 100644 index 000000000..e2ca8ed7b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/swish.py @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch +import torch.nn as nn + +from .registry import ACTIVATION_LAYERS + + +@ACTIVATION_LAYERS.register_module() +class Swish(nn.Module): + """Swish Module. + + This module applies the swish function: + + .. math:: + Swish(x) = x * Sigmoid(x) + + Returns: + Tensor: The output tensor. + """ + + def __init__(self): + super(Swish, self).__init__() + + def forward(self, x): + return x * torch.sigmoid(x) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/transformer.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/transformer.py new file mode 100644 index 000000000..ed32688af --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/transformer.py @@ -0,0 +1,595 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import copy +import warnings + +import torch +import torch.nn as nn + +from mmcv import ConfigDict, deprecated_api_warning +from mmcv.cnn import Linear, build_activation_layer, build_norm_layer +from mmcv.runner.base_module import BaseModule, ModuleList, Sequential +from mmcv.utils import build_from_cfg +from .drop import build_dropout +from .registry import (ATTENTION, FEEDFORWARD_NETWORK, POSITIONAL_ENCODING, + TRANSFORMER_LAYER, TRANSFORMER_LAYER_SEQUENCE) + +# Avoid BC-breaking of importing MultiScaleDeformableAttention from this file +try: + from mmcv.ops.multi_scale_deform_attn import MultiScaleDeformableAttention # noqa F401 + warnings.warn( + ImportWarning( + '``MultiScaleDeformableAttention`` has been moved to ' + '``mmcv.ops.multi_scale_deform_attn``, please change original path ' # noqa E501 + '``from mmcv.cnn.bricks.transformer import MultiScaleDeformableAttention`` ' # noqa E501 + 'to ``from mmcv.ops.multi_scale_deform_attn import MultiScaleDeformableAttention`` ' # noqa E501 + )) + +except ImportError: + warnings.warn('Fail to import ``MultiScaleDeformableAttention`` from ' + '``mmcv.ops.multi_scale_deform_attn``, ' + 'You should install ``mmcv-full`` if you need this module. ') + + +def build_positional_encoding(cfg, default_args=None): + """Builder for Position Encoding.""" + return build_from_cfg(cfg, POSITIONAL_ENCODING, default_args) + + +def build_attention(cfg, default_args=None): + """Builder for attention.""" + return build_from_cfg(cfg, ATTENTION, default_args) + + +def build_feedforward_network(cfg, default_args=None): + """Builder for feed-forward network (FFN).""" + return build_from_cfg(cfg, FEEDFORWARD_NETWORK, default_args) + + +def build_transformer_layer(cfg, default_args=None): + """Builder for transformer layer.""" + return build_from_cfg(cfg, TRANSFORMER_LAYER, default_args) + + +def build_transformer_layer_sequence(cfg, default_args=None): + """Builder for transformer encoder and transformer decoder.""" + return build_from_cfg(cfg, TRANSFORMER_LAYER_SEQUENCE, default_args) + + +@ATTENTION.register_module() +class MultiheadAttention(BaseModule): + """A wrapper for ``torch.nn.MultiheadAttention``. + + This module implements MultiheadAttention with identity connection, + and positional encoding is also passed as input. + + Args: + embed_dims (int): The embedding dimension. + num_heads (int): Parallel attention heads. + attn_drop (float): A Dropout layer on attn_output_weights. + Default: 0.0. + proj_drop (float): A Dropout layer after `nn.MultiheadAttention`. + Default: 0.0. + dropout_layer (obj:`ConfigDict`): The dropout_layer used + when adding the shortcut. + init_cfg (obj:`mmcv.ConfigDict`): The Config for initialization. + Default: None. + batch_first (bool): When it is True, Key, Query and Value are shape of + (batch, n, embed_dim), otherwise (n, batch, embed_dim). + Default to False. + """ + + def __init__(self, + embed_dims, + num_heads, + attn_drop=0., + proj_drop=0., + dropout_layer=dict(type='Dropout', drop_prob=0.), + init_cfg=None, + batch_first=False, + **kwargs): + super(MultiheadAttention, self).__init__(init_cfg) + if 'dropout' in kwargs: + warnings.warn('The arguments `dropout` in MultiheadAttention ' + 'has been deprecated, now you can separately ' + 'set `attn_drop`(float), proj_drop(float), ' + 'and `dropout_layer`(dict) ') + attn_drop = kwargs['dropout'] + dropout_layer['drop_prob'] = kwargs.pop('dropout') + + self.embed_dims = embed_dims + self.num_heads = num_heads + self.batch_first = batch_first + + self.attn = nn.MultiheadAttention(embed_dims, num_heads, attn_drop, + **kwargs) + + self.proj_drop = nn.Dropout(proj_drop) + self.dropout_layer = build_dropout( + dropout_layer) if dropout_layer else nn.Identity() + + @deprecated_api_warning({'residual': 'identity'}, + cls_name='MultiheadAttention') + def forward(self, + query, + key=None, + value=None, + identity=None, + query_pos=None, + key_pos=None, + attn_mask=None, + key_padding_mask=None, + **kwargs): + """Forward function for `MultiheadAttention`. + + **kwargs allow passing a more general data flow when combining + with other operations in `transformerlayer`. + + Args: + query (Tensor): The input query with shape [num_queries, bs, + embed_dims] if self.batch_first is False, else + [bs, num_queries embed_dims]. + key (Tensor): The key tensor with shape [num_keys, bs, + embed_dims] if self.batch_first is False, else + [bs, num_keys, embed_dims] . + If None, the ``query`` will be used. Defaults to None. + value (Tensor): The value tensor with same shape as `key`. + Same in `nn.MultiheadAttention.forward`. Defaults to None. + If None, the `key` will be used. + identity (Tensor): This tensor, with the same shape as x, + will be used for the identity link. + If None, `x` will be used. Defaults to None. + query_pos (Tensor): The positional encoding for query, with + the same shape as `x`. If not None, it will + be added to `x` before forward function. Defaults to None. + key_pos (Tensor): The positional encoding for `key`, with the + same shape as `key`. Defaults to None. If not None, it will + be added to `key` before forward function. If None, and + `query_pos` has the same shape as `key`, then `query_pos` + will be used for `key_pos`. Defaults to None. + attn_mask (Tensor): ByteTensor mask with shape [num_queries, + num_keys]. Same in `nn.MultiheadAttention.forward`. + Defaults to None. + key_padding_mask (Tensor): ByteTensor with shape [bs, num_keys]. + Defaults to None. + + Returns: + Tensor: forwarded results with shape + [num_queries, bs, embed_dims] + if self.batch_first is False, else + [bs, num_queries embed_dims]. + """ + + if key is None: + key = query + if value is None: + value = key + if identity is None: + identity = query + if key_pos is None: + if query_pos is not None: + # use query_pos if key_pos is not available + if query_pos.shape == key.shape: + key_pos = query_pos + else: + warnings.warn(f'position encoding of key is' + f'missing in {self.__class__.__name__}.') + if query_pos is not None: + query = query + query_pos + if key_pos is not None: + key = key + key_pos + + # Because the dataflow('key', 'query', 'value') of + # ``torch.nn.MultiheadAttention`` is (num_query, batch, + # embed_dims), We should adjust the shape of dataflow from + # batch_first (batch, num_query, embed_dims) to num_query_first + # (num_query ,batch, embed_dims), and recover ``attn_output`` + # from num_query_first to batch_first. + if self.batch_first: + query = query.transpose(0, 1) + key = key.transpose(0, 1) + value = value.transpose(0, 1) + + out = self.attn( + query=query, + key=key, + value=value, + attn_mask=attn_mask, + key_padding_mask=key_padding_mask)[0] + + if self.batch_first: + out = out.transpose(0, 1) + + return identity + self.dropout_layer(self.proj_drop(out)) + + +@FEEDFORWARD_NETWORK.register_module() +class FFN(BaseModule): + """Implements feed-forward networks (FFNs) with identity connection. + + Args: + embed_dims (int): The feature dimension. Same as + `MultiheadAttention`. Defaults: 256. + feedforward_channels (int): The hidden dimension of FFNs. + Defaults: 1024. + num_fcs (int, optional): The number of fully-connected layers in + FFNs. Default: 2. + act_cfg (dict, optional): The activation config for FFNs. + Default: dict(type='ReLU') + ffn_drop (float, optional): Probability of an element to be + zeroed in FFN. Default 0.0. + add_identity (bool, optional): Whether to add the + identity connection. Default: `True`. + dropout_layer (obj:`ConfigDict`): The dropout_layer used + when adding the shortcut. + init_cfg (obj:`mmcv.ConfigDict`): The Config for initialization. + Default: None. + """ + + @deprecated_api_warning( + { + 'dropout': 'ffn_drop', + 'add_residual': 'add_identity' + }, + cls_name='FFN') + def __init__(self, + embed_dims=256, + feedforward_channels=1024, + num_fcs=2, + act_cfg=dict(type='ReLU', inplace=True), + ffn_drop=0., + dropout_layer=None, + add_identity=True, + init_cfg=None, + **kwargs): + super(FFN, self).__init__(init_cfg) + assert num_fcs >= 2, 'num_fcs should be no less ' \ + f'than 2. got {num_fcs}.' + self.embed_dims = embed_dims + self.feedforward_channels = feedforward_channels + self.num_fcs = num_fcs + self.act_cfg = act_cfg + self.activate = build_activation_layer(act_cfg) + + layers = [] + in_channels = embed_dims + for _ in range(num_fcs - 1): + layers.append( + Sequential( + Linear(in_channels, feedforward_channels), self.activate, + nn.Dropout(ffn_drop))) + in_channels = feedforward_channels + layers.append(Linear(feedforward_channels, embed_dims)) + layers.append(nn.Dropout(ffn_drop)) + self.layers = Sequential(*layers) + self.dropout_layer = build_dropout( + dropout_layer) if dropout_layer else torch.nn.Identity() + self.add_identity = add_identity + + @deprecated_api_warning({'residual': 'identity'}, cls_name='FFN') + def forward(self, x, identity=None): + """Forward function for `FFN`. + + The function would add x to the output tensor if residue is None. + """ + out = self.layers(x) + if not self.add_identity: + return self.dropout_layer(out) + if identity is None: + identity = x + return identity + self.dropout_layer(out) + + +@TRANSFORMER_LAYER.register_module() +class BaseTransformerLayer(BaseModule): + """Base `TransformerLayer` for vision transformer. + + It can be built from `mmcv.ConfigDict` and support more flexible + customization, for example, using any number of `FFN or LN ` and + use different kinds of `attention` by specifying a list of `ConfigDict` + named `attn_cfgs`. It is worth mentioning that it supports `prenorm` + when you specifying `norm` as the first element of `operation_order`. + More details about the `prenorm`: `On Layer Normalization in the + Transformer Architecture `_ . + + Args: + attn_cfgs (list[`mmcv.ConfigDict`] | obj:`mmcv.ConfigDict` | None )): + Configs for `self_attention` or `cross_attention` modules, + The order of the configs in the list should be consistent with + corresponding attentions in operation_order. + If it is a dict, all of the attention modules in operation_order + will be built with this config. Default: None. + ffn_cfgs (list[`mmcv.ConfigDict`] | obj:`mmcv.ConfigDict` | None )): + Configs for FFN, The order of the configs in the list should be + consistent with corresponding ffn in operation_order. + If it is a dict, all of the attention modules in operation_order + will be built with this config. + operation_order (tuple[str]): The execution order of operation + in transformer. Such as ('self_attn', 'norm', 'ffn', 'norm'). + Support `prenorm` when you specifying first element as `norm`. + Default:None. + norm_cfg (dict): Config dict for normalization layer. + Default: dict(type='LN'). + init_cfg (obj:`mmcv.ConfigDict`): The Config for initialization. + Default: None. + batch_first (bool): Key, Query and Value are shape + of (batch, n, embed_dim) + or (n, batch, embed_dim). Default to False. + """ + + def __init__(self, + attn_cfgs=None, + ffn_cfgs=dict( + type='FFN', + embed_dims=256, + feedforward_channels=1024, + num_fcs=2, + ffn_drop=0., + act_cfg=dict(type='ReLU', inplace=True), + ), + operation_order=None, + norm_cfg=dict(type='LN'), + init_cfg=None, + batch_first=False, + **kwargs): + + deprecated_args = dict( + feedforward_channels='feedforward_channels', + ffn_dropout='ffn_drop', + ffn_num_fcs='num_fcs') + for ori_name, new_name in deprecated_args.items(): + if ori_name in kwargs: + warnings.warn( + f'The arguments `{ori_name}` in BaseTransformerLayer ' + f'has been deprecated, now you should set `{new_name}` ' + f'and other FFN related arguments ' + f'to a dict named `ffn_cfgs`. ') + ffn_cfgs[new_name] = kwargs[ori_name] + + super(BaseTransformerLayer, self).__init__(init_cfg) + + self.batch_first = batch_first + + assert set(operation_order) & set( + ['self_attn', 'norm', 'ffn', 'cross_attn']) == \ + set(operation_order), f'The operation_order of' \ + f' {self.__class__.__name__} should ' \ + f'contains all four operation type ' \ + f"{['self_attn', 'norm', 'ffn', 'cross_attn']}" + + num_attn = operation_order.count('self_attn') + operation_order.count( + 'cross_attn') + if isinstance(attn_cfgs, dict): + attn_cfgs = [copy.deepcopy(attn_cfgs) for _ in range(num_attn)] + else: + assert num_attn == len(attn_cfgs), f'The length ' \ + f'of attn_cfg {num_attn} is ' \ + f'not consistent with the number of attention' \ + f'in operation_order {operation_order}.' + + self.num_attn = num_attn + self.operation_order = operation_order + self.norm_cfg = norm_cfg + self.pre_norm = operation_order[0] == 'norm' + self.attentions = ModuleList() + + index = 0 + for operation_name in operation_order: + if operation_name in ['self_attn', 'cross_attn']: + if 'batch_first' in attn_cfgs[index]: + assert self.batch_first == attn_cfgs[index]['batch_first'] + else: + attn_cfgs[index]['batch_first'] = self.batch_first + attention = build_attention(attn_cfgs[index]) + # Some custom attentions used as `self_attn` + # or `cross_attn` can have different behavior. + attention.operation_name = operation_name + self.attentions.append(attention) + index += 1 + + self.embed_dims = self.attentions[0].embed_dims + + self.ffns = ModuleList() + num_ffns = operation_order.count('ffn') + if isinstance(ffn_cfgs, dict): + ffn_cfgs = ConfigDict(ffn_cfgs) + if isinstance(ffn_cfgs, dict): + ffn_cfgs = [copy.deepcopy(ffn_cfgs) for _ in range(num_ffns)] + assert len(ffn_cfgs) == num_ffns + for ffn_index in range(num_ffns): + if 'embed_dims' not in ffn_cfgs[ffn_index]: + ffn_cfgs['embed_dims'] = self.embed_dims + else: + assert ffn_cfgs[ffn_index]['embed_dims'] == self.embed_dims + self.ffns.append( + build_feedforward_network(ffn_cfgs[ffn_index], + dict(type='FFN'))) + + self.norms = ModuleList() + num_norms = operation_order.count('norm') + for _ in range(num_norms): + self.norms.append(build_norm_layer(norm_cfg, self.embed_dims)[1]) + + def forward(self, + query, + key=None, + value=None, + query_pos=None, + key_pos=None, + attn_masks=None, + query_key_padding_mask=None, + key_padding_mask=None, + **kwargs): + """Forward function for `TransformerDecoderLayer`. + + **kwargs contains some specific arguments of attentions. + + Args: + query (Tensor): The input query with shape + [num_queries, bs, embed_dims] if + self.batch_first is False, else + [bs, num_queries embed_dims]. + key (Tensor): The key tensor with shape [num_keys, bs, + embed_dims] if self.batch_first is False, else + [bs, num_keys, embed_dims] . + value (Tensor): The value tensor with same shape as `key`. + query_pos (Tensor): The positional encoding for `query`. + Default: None. + key_pos (Tensor): The positional encoding for `key`. + Default: None. + attn_masks (List[Tensor] | None): 2D Tensor used in + calculation of corresponding attention. The length of + it should equal to the number of `attention` in + `operation_order`. Default: None. + query_key_padding_mask (Tensor): ByteTensor for `query`, with + shape [bs, num_queries]. Only used in `self_attn` layer. + Defaults to None. + key_padding_mask (Tensor): ByteTensor for `query`, with + shape [bs, num_keys]. Default: None. + + Returns: + Tensor: forwarded results with shape [num_queries, bs, embed_dims]. + """ + + norm_index = 0 + attn_index = 0 + ffn_index = 0 + identity = query + if attn_masks is None: + attn_masks = [None for _ in range(self.num_attn)] + elif isinstance(attn_masks, torch.Tensor): + attn_masks = [ + copy.deepcopy(attn_masks) for _ in range(self.num_attn) + ] + warnings.warn(f'Use same attn_mask in all attentions in ' + f'{self.__class__.__name__} ') + else: + assert len(attn_masks) == self.num_attn, f'The length of ' \ + f'attn_masks {len(attn_masks)} must be equal ' \ + f'to the number of attention in ' \ + f'operation_order {self.num_attn}' + + for layer in self.operation_order: + if layer == 'self_attn': + temp_key = temp_value = query + query = self.attentions[attn_index]( + query, + temp_key, + temp_value, + identity if self.pre_norm else None, + query_pos=query_pos, + key_pos=query_pos, + attn_mask=attn_masks[attn_index], + key_padding_mask=query_key_padding_mask, + **kwargs) + attn_index += 1 + identity = query + + elif layer == 'norm': + query = self.norms[norm_index](query) + norm_index += 1 + + elif layer == 'cross_attn': + query = self.attentions[attn_index]( + query, + key, + value, + identity if self.pre_norm else None, + query_pos=query_pos, + key_pos=key_pos, + attn_mask=attn_masks[attn_index], + key_padding_mask=key_padding_mask, + **kwargs) + attn_index += 1 + identity = query + + elif layer == 'ffn': + query = self.ffns[ffn_index]( + query, identity if self.pre_norm else None) + ffn_index += 1 + + return query + + +@TRANSFORMER_LAYER_SEQUENCE.register_module() +class TransformerLayerSequence(BaseModule): + """Base class for TransformerEncoder and TransformerDecoder in vision + transformer. + + As base-class of Encoder and Decoder in vision transformer. + Support customization such as specifying different kind + of `transformer_layer` in `transformer_coder`. + + Args: + transformerlayer (list[obj:`mmcv.ConfigDict`] | + obj:`mmcv.ConfigDict`): Config of transformerlayer + in TransformerCoder. If it is obj:`mmcv.ConfigDict`, + it would be repeated `num_layer` times to a + list[`mmcv.ConfigDict`]. Default: None. + num_layers (int): The number of `TransformerLayer`. Default: None. + init_cfg (obj:`mmcv.ConfigDict`): The Config for initialization. + Default: None. + """ + + def __init__(self, transformerlayers=None, num_layers=None, init_cfg=None): + super(TransformerLayerSequence, self).__init__(init_cfg) + if isinstance(transformerlayers, dict): + transformerlayers = [ + copy.deepcopy(transformerlayers) for _ in range(num_layers) + ] + else: + assert isinstance(transformerlayers, list) and \ + len(transformerlayers) == num_layers + self.num_layers = num_layers + self.layers = ModuleList() + for i in range(num_layers): + self.layers.append(build_transformer_layer(transformerlayers[i])) + self.embed_dims = self.layers[0].embed_dims + self.pre_norm = self.layers[0].pre_norm + + def forward(self, + query, + key, + value, + query_pos=None, + key_pos=None, + attn_masks=None, + query_key_padding_mask=None, + key_padding_mask=None, + **kwargs): + """Forward function for `TransformerCoder`. + + Args: + query (Tensor): Input query with shape + `(num_queries, bs, embed_dims)`. + key (Tensor): The key tensor with shape + `(num_keys, bs, embed_dims)`. + value (Tensor): The value tensor with shape + `(num_keys, bs, embed_dims)`. + query_pos (Tensor): The positional encoding for `query`. + Default: None. + key_pos (Tensor): The positional encoding for `key`. + Default: None. + attn_masks (List[Tensor], optional): Each element is 2D Tensor + which is used in calculation of corresponding attention in + operation_order. Default: None. + query_key_padding_mask (Tensor): ByteTensor for `query`, with + shape [bs, num_queries]. Only used in self-attention + Default: None. + key_padding_mask (Tensor): ByteTensor for `query`, with + shape [bs, num_keys]. Default: None. + + Returns: + Tensor: results with shape [num_queries, bs, embed_dims]. + """ + for layer in self.layers: + query = layer( + query, + key, + value, + query_pos=query_pos, + key_pos=key_pos, + attn_masks=attn_masks, + query_key_padding_mask=query_key_padding_mask, + key_padding_mask=key_padding_mask, + **kwargs) + return query diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/upsample.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/upsample.py new file mode 100644 index 000000000..a1a353767 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/upsample.py @@ -0,0 +1,84 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch.nn as nn +import torch.nn.functional as F + +from ..utils import xavier_init +from .registry import UPSAMPLE_LAYERS + +UPSAMPLE_LAYERS.register_module('nearest', module=nn.Upsample) +UPSAMPLE_LAYERS.register_module('bilinear', module=nn.Upsample) + + +@UPSAMPLE_LAYERS.register_module(name='pixel_shuffle') +class PixelShufflePack(nn.Module): + """Pixel Shuffle upsample layer. + + This module packs `F.pixel_shuffle()` and a nn.Conv2d module together to + achieve a simple upsampling with pixel shuffle. + + Args: + in_channels (int): Number of input channels. + out_channels (int): Number of output channels. + scale_factor (int): Upsample ratio. + upsample_kernel (int): Kernel size of the conv layer to expand the + channels. + """ + + def __init__(self, in_channels, out_channels, scale_factor, + upsample_kernel): + super(PixelShufflePack, self).__init__() + self.in_channels = in_channels + self.out_channels = out_channels + self.scale_factor = scale_factor + self.upsample_kernel = upsample_kernel + self.upsample_conv = nn.Conv2d( + self.in_channels, + self.out_channels * scale_factor * scale_factor, + self.upsample_kernel, + padding=(self.upsample_kernel - 1) // 2) + self.init_weights() + + def init_weights(self): + xavier_init(self.upsample_conv, distribution='uniform') + + def forward(self, x): + x = self.upsample_conv(x) + x = F.pixel_shuffle(x, self.scale_factor) + return x + + +def build_upsample_layer(cfg, *args, **kwargs): + """Build upsample layer. + + Args: + cfg (dict): The upsample layer config, which should contain: + + - type (str): Layer type. + - scale_factor (int): Upsample ratio, which is not applicable to + deconv. + - layer args: Args needed to instantiate a upsample layer. + args (argument list): Arguments passed to the ``__init__`` + method of the corresponding conv layer. + kwargs (keyword arguments): Keyword arguments passed to the + ``__init__`` method of the corresponding conv layer. + + Returns: + nn.Module: Created upsample layer. + """ + if not isinstance(cfg, dict): + raise TypeError(f'cfg must be a dict, but got {type(cfg)}') + if 'type' not in cfg: + raise KeyError( + f'the cfg dict must contain the key "type", but got {cfg}') + cfg_ = cfg.copy() + + layer_type = cfg_.pop('type') + if layer_type not in UPSAMPLE_LAYERS: + raise KeyError(f'Unrecognized upsample type {layer_type}') + else: + upsample = UPSAMPLE_LAYERS.get(layer_type) + + if upsample is nn.Upsample: + cfg_['mode'] = layer_type + layer = upsample(*args, **kwargs, **cfg_) + return layer diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/wrappers.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/wrappers.py new file mode 100644 index 000000000..8aebf67bf --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/bricks/wrappers.py @@ -0,0 +1,180 @@ +# Copyright (c) OpenMMLab. All rights reserved. +r"""Modified from https://github.com/facebookresearch/detectron2/blob/master/detectron2/layers/wrappers.py # noqa: E501 + +Wrap some nn modules to support empty tensor input. Currently, these wrappers +are mainly used in mask heads like fcn_mask_head and maskiou_heads since mask +heads are trained on only positive RoIs. +""" +import math + +import torch +import torch.nn as nn +from torch.nn.modules.utils import _pair, _triple + +from .registry import CONV_LAYERS, UPSAMPLE_LAYERS + +if torch.__version__ == 'parrots': + TORCH_VERSION = torch.__version__ +else: + # torch.__version__ could be 1.3.1+cu92, we only need the first two + # for comparison + TORCH_VERSION = tuple(int(x) for x in torch.__version__.split('.')[:2]) + + +def obsolete_torch_version(torch_version, version_threshold): + return torch_version == 'parrots' or torch_version <= version_threshold + + +class NewEmptyTensorOp(torch.autograd.Function): + + @staticmethod + def forward(ctx, x, new_shape): + ctx.shape = x.shape + return x.new_empty(new_shape) + + @staticmethod + def backward(ctx, grad): + shape = ctx.shape + return NewEmptyTensorOp.apply(grad, shape), None + + +@CONV_LAYERS.register_module('Conv', force=True) +class Conv2d(nn.Conv2d): + + def forward(self, x): + if x.numel() == 0 and obsolete_torch_version(TORCH_VERSION, (1, 4)): + out_shape = [x.shape[0], self.out_channels] + for i, k, p, s, d in zip(x.shape[-2:], self.kernel_size, + self.padding, self.stride, self.dilation): + o = (i + 2 * p - (d * (k - 1) + 1)) // s + 1 + out_shape.append(o) + empty = NewEmptyTensorOp.apply(x, out_shape) + if self.training: + # produce dummy gradient to avoid DDP warning. + dummy = sum(x.view(-1)[0] for x in self.parameters()) * 0.0 + return empty + dummy + else: + return empty + + return super().forward(x) + + +@CONV_LAYERS.register_module('Conv3d', force=True) +class Conv3d(nn.Conv3d): + + def forward(self, x): + if x.numel() == 0 and obsolete_torch_version(TORCH_VERSION, (1, 4)): + out_shape = [x.shape[0], self.out_channels] + for i, k, p, s, d in zip(x.shape[-3:], self.kernel_size, + self.padding, self.stride, self.dilation): + o = (i + 2 * p - (d * (k - 1) + 1)) // s + 1 + out_shape.append(o) + empty = NewEmptyTensorOp.apply(x, out_shape) + if self.training: + # produce dummy gradient to avoid DDP warning. + dummy = sum(x.view(-1)[0] for x in self.parameters()) * 0.0 + return empty + dummy + else: + return empty + + return super().forward(x) + + +@CONV_LAYERS.register_module() +@CONV_LAYERS.register_module('deconv') +@UPSAMPLE_LAYERS.register_module('deconv', force=True) +class ConvTranspose2d(nn.ConvTranspose2d): + + def forward(self, x): + if x.numel() == 0 and obsolete_torch_version(TORCH_VERSION, (1, 4)): + out_shape = [x.shape[0], self.out_channels] + for i, k, p, s, d, op in zip(x.shape[-2:], self.kernel_size, + self.padding, self.stride, + self.dilation, self.output_padding): + out_shape.append((i - 1) * s - 2 * p + (d * (k - 1) + 1) + op) + empty = NewEmptyTensorOp.apply(x, out_shape) + if self.training: + # produce dummy gradient to avoid DDP warning. + dummy = sum(x.view(-1)[0] for x in self.parameters()) * 0.0 + return empty + dummy + else: + return empty + + return super().forward(x) + + +@CONV_LAYERS.register_module() +@CONV_LAYERS.register_module('deconv3d') +@UPSAMPLE_LAYERS.register_module('deconv3d', force=True) +class ConvTranspose3d(nn.ConvTranspose3d): + + def forward(self, x): + if x.numel() == 0 and obsolete_torch_version(TORCH_VERSION, (1, 4)): + out_shape = [x.shape[0], self.out_channels] + for i, k, p, s, d, op in zip(x.shape[-3:], self.kernel_size, + self.padding, self.stride, + self.dilation, self.output_padding): + out_shape.append((i - 1) * s - 2 * p + (d * (k - 1) + 1) + op) + empty = NewEmptyTensorOp.apply(x, out_shape) + if self.training: + # produce dummy gradient to avoid DDP warning. + dummy = sum(x.view(-1)[0] for x in self.parameters()) * 0.0 + return empty + dummy + else: + return empty + + return super().forward(x) + + +class MaxPool2d(nn.MaxPool2d): + + def forward(self, x): + # PyTorch 1.9 does not support empty tensor inference yet + if x.numel() == 0 and obsolete_torch_version(TORCH_VERSION, (1, 9)): + out_shape = list(x.shape[:2]) + for i, k, p, s, d in zip(x.shape[-2:], _pair(self.kernel_size), + _pair(self.padding), _pair(self.stride), + _pair(self.dilation)): + o = (i + 2 * p - (d * (k - 1) + 1)) / s + 1 + o = math.ceil(o) if self.ceil_mode else math.floor(o) + out_shape.append(o) + empty = NewEmptyTensorOp.apply(x, out_shape) + return empty + + return super().forward(x) + + +class MaxPool3d(nn.MaxPool3d): + + def forward(self, x): + # PyTorch 1.9 does not support empty tensor inference yet + if x.numel() == 0 and obsolete_torch_version(TORCH_VERSION, (1, 9)): + out_shape = list(x.shape[:2]) + for i, k, p, s, d in zip(x.shape[-3:], _triple(self.kernel_size), + _triple(self.padding), + _triple(self.stride), + _triple(self.dilation)): + o = (i + 2 * p - (d * (k - 1) + 1)) / s + 1 + o = math.ceil(o) if self.ceil_mode else math.floor(o) + out_shape.append(o) + empty = NewEmptyTensorOp.apply(x, out_shape) + return empty + + return super().forward(x) + + +class Linear(torch.nn.Linear): + + def forward(self, x): + # empty tensor forward of Linear layer is supported in Pytorch 1.6 + if x.numel() == 0 and obsolete_torch_version(TORCH_VERSION, (1, 5)): + out_shape = [x.shape[0], self.out_features] + empty = NewEmptyTensorOp.apply(x, out_shape) + if self.training: + # produce dummy gradient to avoid DDP warning. + dummy = sum(x.view(-1)[0] for x in self.parameters()) * 0.0 + return empty + dummy + else: + return empty + + return super().forward(x) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/builder.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/builder.py new file mode 100644 index 000000000..7567316c5 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/builder.py @@ -0,0 +1,30 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from ..runner import Sequential +from ..utils import Registry, build_from_cfg + + +def build_model_from_cfg(cfg, registry, default_args=None): + """Build a PyTorch model from config dict(s). Different from + ``build_from_cfg``, if cfg is a list, a ``nn.Sequential`` will be built. + + Args: + cfg (dict, list[dict]): The config of modules, is is either a config + dict or a list of config dicts. If cfg is a list, a + the built modules will be wrapped with ``nn.Sequential``. + registry (:obj:`Registry`): A registry the module belongs to. + default_args (dict, optional): Default arguments to build the module. + Defaults to None. + + Returns: + nn.Module: A built nn module. + """ + if isinstance(cfg, list): + modules = [ + build_from_cfg(cfg_, registry, default_args) for cfg_ in cfg + ] + return Sequential(*modules) + else: + return build_from_cfg(cfg, registry, default_args) + + +MODELS = Registry('model', build_func=build_model_from_cfg) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/resnet.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/resnet.py new file mode 100644 index 000000000..1cb3ac057 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/resnet.py @@ -0,0 +1,316 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import logging + +import torch.nn as nn +import torch.utils.checkpoint as cp + +from .utils import constant_init, kaiming_init + + +def conv3x3(in_planes, out_planes, stride=1, dilation=1): + """3x3 convolution with padding.""" + return nn.Conv2d( + in_planes, + out_planes, + kernel_size=3, + stride=stride, + padding=dilation, + dilation=dilation, + bias=False) + + +class BasicBlock(nn.Module): + expansion = 1 + + def __init__(self, + inplanes, + planes, + stride=1, + dilation=1, + downsample=None, + style='pytorch', + with_cp=False): + super(BasicBlock, self).__init__() + assert style in ['pytorch', 'caffe'] + self.conv1 = conv3x3(inplanes, planes, stride, dilation) + self.bn1 = nn.BatchNorm2d(planes) + self.relu = nn.ReLU(inplace=True) + self.conv2 = conv3x3(planes, planes) + self.bn2 = nn.BatchNorm2d(planes) + self.downsample = downsample + self.stride = stride + self.dilation = dilation + assert not with_cp + + def forward(self, x): + residual = x + + out = self.conv1(x) + out = self.bn1(out) + out = self.relu(out) + + out = self.conv2(out) + out = self.bn2(out) + + if self.downsample is not None: + residual = self.downsample(x) + + out += residual + out = self.relu(out) + + return out + + +class Bottleneck(nn.Module): + expansion = 4 + + def __init__(self, + inplanes, + planes, + stride=1, + dilation=1, + downsample=None, + style='pytorch', + with_cp=False): + """Bottleneck block. + + If style is "pytorch", the stride-two layer is the 3x3 conv layer, if + it is "caffe", the stride-two layer is the first 1x1 conv layer. + """ + super(Bottleneck, self).__init__() + assert style in ['pytorch', 'caffe'] + if style == 'pytorch': + conv1_stride = 1 + conv2_stride = stride + else: + conv1_stride = stride + conv2_stride = 1 + self.conv1 = nn.Conv2d( + inplanes, planes, kernel_size=1, stride=conv1_stride, bias=False) + self.conv2 = nn.Conv2d( + planes, + planes, + kernel_size=3, + stride=conv2_stride, + padding=dilation, + dilation=dilation, + bias=False) + + self.bn1 = nn.BatchNorm2d(planes) + self.bn2 = nn.BatchNorm2d(planes) + self.conv3 = nn.Conv2d( + planes, planes * self.expansion, kernel_size=1, bias=False) + self.bn3 = nn.BatchNorm2d(planes * self.expansion) + self.relu = nn.ReLU(inplace=True) + self.downsample = downsample + self.stride = stride + self.dilation = dilation + self.with_cp = with_cp + + def forward(self, x): + + def _inner_forward(x): + residual = x + + out = self.conv1(x) + out = self.bn1(out) + out = self.relu(out) + + out = self.conv2(out) + out = self.bn2(out) + out = self.relu(out) + + out = self.conv3(out) + out = self.bn3(out) + + if self.downsample is not None: + residual = self.downsample(x) + + out += residual + + return out + + if self.with_cp and x.requires_grad: + out = cp.checkpoint(_inner_forward, x) + else: + out = _inner_forward(x) + + out = self.relu(out) + + return out + + +def make_res_layer(block, + inplanes, + planes, + blocks, + stride=1, + dilation=1, + style='pytorch', + with_cp=False): + downsample = None + if stride != 1 or inplanes != planes * block.expansion: + downsample = nn.Sequential( + nn.Conv2d( + inplanes, + planes * block.expansion, + kernel_size=1, + stride=stride, + bias=False), + nn.BatchNorm2d(planes * block.expansion), + ) + + layers = [] + layers.append( + block( + inplanes, + planes, + stride, + dilation, + downsample, + style=style, + with_cp=with_cp)) + inplanes = planes * block.expansion + for _ in range(1, blocks): + layers.append( + block(inplanes, planes, 1, dilation, style=style, with_cp=with_cp)) + + return nn.Sequential(*layers) + + +class ResNet(nn.Module): + """ResNet backbone. + + Args: + depth (int): Depth of resnet, from {18, 34, 50, 101, 152}. + num_stages (int): Resnet stages, normally 4. + strides (Sequence[int]): Strides of the first block of each stage. + dilations (Sequence[int]): Dilation of each stage. + out_indices (Sequence[int]): Output from which stages. + style (str): `pytorch` or `caffe`. If set to "pytorch", the stride-two + layer is the 3x3 conv layer, otherwise the stride-two layer is + the first 1x1 conv layer. + frozen_stages (int): Stages to be frozen (all param fixed). -1 means + not freezing any parameters. + bn_eval (bool): Whether to set BN layers as eval mode, namely, freeze + running stats (mean and var). + bn_frozen (bool): Whether to freeze weight and bias of BN layers. + with_cp (bool): Use checkpoint or not. Using checkpoint will save some + memory while slowing down the training speed. + """ + + arch_settings = { + 18: (BasicBlock, (2, 2, 2, 2)), + 34: (BasicBlock, (3, 4, 6, 3)), + 50: (Bottleneck, (3, 4, 6, 3)), + 101: (Bottleneck, (3, 4, 23, 3)), + 152: (Bottleneck, (3, 8, 36, 3)) + } + + def __init__(self, + depth, + num_stages=4, + strides=(1, 2, 2, 2), + dilations=(1, 1, 1, 1), + out_indices=(0, 1, 2, 3), + style='pytorch', + frozen_stages=-1, + bn_eval=True, + bn_frozen=False, + with_cp=False): + super(ResNet, self).__init__() + if depth not in self.arch_settings: + raise KeyError(f'invalid depth {depth} for resnet') + assert num_stages >= 1 and num_stages <= 4 + block, stage_blocks = self.arch_settings[depth] + stage_blocks = stage_blocks[:num_stages] + assert len(strides) == len(dilations) == num_stages + assert max(out_indices) < num_stages + + self.out_indices = out_indices + self.style = style + self.frozen_stages = frozen_stages + self.bn_eval = bn_eval + self.bn_frozen = bn_frozen + self.with_cp = with_cp + + self.inplanes = 64 + self.conv1 = nn.Conv2d( + 3, 64, kernel_size=7, stride=2, padding=3, bias=False) + self.bn1 = nn.BatchNorm2d(64) + self.relu = nn.ReLU(inplace=True) + self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1) + + self.res_layers = [] + for i, num_blocks in enumerate(stage_blocks): + stride = strides[i] + dilation = dilations[i] + planes = 64 * 2**i + res_layer = make_res_layer( + block, + self.inplanes, + planes, + num_blocks, + stride=stride, + dilation=dilation, + style=self.style, + with_cp=with_cp) + self.inplanes = planes * block.expansion + layer_name = f'layer{i + 1}' + self.add_module(layer_name, res_layer) + self.res_layers.append(layer_name) + + self.feat_dim = block.expansion * 64 * 2**(len(stage_blocks) - 1) + + def init_weights(self, pretrained=None): + if isinstance(pretrained, str): + logger = logging.getLogger() + from ..runner import load_checkpoint + load_checkpoint(self, pretrained, strict=False, logger=logger) + elif pretrained is None: + for m in self.modules(): + if isinstance(m, nn.Conv2d): + kaiming_init(m) + elif isinstance(m, nn.BatchNorm2d): + constant_init(m, 1) + else: + raise TypeError('pretrained must be a str or None') + + def forward(self, x): + x = self.conv1(x) + x = self.bn1(x) + x = self.relu(x) + x = self.maxpool(x) + outs = [] + for i, layer_name in enumerate(self.res_layers): + res_layer = getattr(self, layer_name) + x = res_layer(x) + if i in self.out_indices: + outs.append(x) + if len(outs) == 1: + return outs[0] + else: + return tuple(outs) + + def train(self, mode=True): + super(ResNet, self).train(mode) + if self.bn_eval: + for m in self.modules(): + if isinstance(m, nn.BatchNorm2d): + m.eval() + if self.bn_frozen: + for params in m.parameters(): + params.requires_grad = False + if mode and self.frozen_stages >= 0: + for param in self.conv1.parameters(): + param.requires_grad = False + for param in self.bn1.parameters(): + param.requires_grad = False + self.bn1.eval() + self.bn1.weight.requires_grad = False + self.bn1.bias.requires_grad = False + for i in range(1, self.frozen_stages + 1): + mod = getattr(self, f'layer{i}') + mod.eval() + for param in mod.parameters(): + param.requires_grad = False diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/__init__.py new file mode 100644 index 000000000..a263e31c1 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/__init__.py @@ -0,0 +1,19 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .flops_counter import get_model_complexity_info +from .fuse_conv_bn import fuse_conv_bn +from .sync_bn import revert_sync_batchnorm +from .weight_init import (INITIALIZERS, Caffe2XavierInit, ConstantInit, + KaimingInit, NormalInit, PretrainedInit, + TruncNormalInit, UniformInit, XavierInit, + bias_init_with_prob, caffe2_xavier_init, + constant_init, initialize, kaiming_init, normal_init, + trunc_normal_init, uniform_init, xavier_init) + +__all__ = [ + 'get_model_complexity_info', 'bias_init_with_prob', 'caffe2_xavier_init', + 'constant_init', 'kaiming_init', 'normal_init', 'trunc_normal_init', + 'uniform_init', 'xavier_init', 'fuse_conv_bn', 'initialize', + 'INITIALIZERS', 'ConstantInit', 'XavierInit', 'NormalInit', + 'TruncNormalInit', 'UniformInit', 'KaimingInit', 'PretrainedInit', + 'Caffe2XavierInit', 'revert_sync_batchnorm' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/flops_counter.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/flops_counter.py similarity index 38% rename from cv/instance_segmentation/SOLO/pytorch/mmdet/utils/flops_counter.py rename to cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/flops_counter.py index df2163fd7..dceeb398b 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/flops_counter.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/flops_counter.py @@ -24,40 +24,89 @@ # SOFTWARE. import sys +from functools import partial import numpy as np import torch import torch.nn as nn -from torch.nn.modules.batchnorm import _BatchNorm -from torch.nn.modules.conv import _ConvNd, _ConvTransposeMixin -from torch.nn.modules.pooling import (_AdaptiveAvgPoolNd, _AdaptiveMaxPoolNd, - _AvgPoolNd, _MaxPoolNd) + +import mmcv def get_model_complexity_info(model, - input_res, + input_shape, print_per_layer_stat=True, as_strings=True, input_constructor=None, + flush=False, ost=sys.stdout): - assert type(input_res) is tuple - assert len(input_res) >= 2 + """Get complexity information of a model. + + This method can calculate FLOPs and parameter counts of a model with + corresponding input shape. It can also print complexity information for + each layer in a model. + + Supported layers are listed as below: + - Convolutions: ``nn.Conv1d``, ``nn.Conv2d``, ``nn.Conv3d``. + - Activations: ``nn.ReLU``, ``nn.PReLU``, ``nn.ELU``, ``nn.LeakyReLU``, + ``nn.ReLU6``. + - Poolings: ``nn.MaxPool1d``, ``nn.MaxPool2d``, ``nn.MaxPool3d``, + ``nn.AvgPool1d``, ``nn.AvgPool2d``, ``nn.AvgPool3d``, + ``nn.AdaptiveMaxPool1d``, ``nn.AdaptiveMaxPool2d``, + ``nn.AdaptiveMaxPool3d``, ``nn.AdaptiveAvgPool1d``, + ``nn.AdaptiveAvgPool2d``, ``nn.AdaptiveAvgPool3d``. + - BatchNorms: ``nn.BatchNorm1d``, ``nn.BatchNorm2d``, + ``nn.BatchNorm3d``, ``nn.GroupNorm``, ``nn.InstanceNorm1d``, + ``InstanceNorm2d``, ``InstanceNorm3d``, ``nn.LayerNorm``. + - Linear: ``nn.Linear``. + - Deconvolution: ``nn.ConvTranspose2d``. + - Upsample: ``nn.Upsample``. + + Args: + model (nn.Module): The model for complexity calculation. + input_shape (tuple): Input shape used for calculation. + print_per_layer_stat (bool): Whether to print complexity information + for each layer in a model. Default: True. + as_strings (bool): Output FLOPs and params counts in a string form. + Default: True. + input_constructor (None | callable): If specified, it takes a callable + method that generates input. otherwise, it will generate a random + tensor with input shape to calculate FLOPs. Default: None. + flush (bool): same as that in :func:`print`. Default: False. + ost (stream): same as ``file`` param in :func:`print`. + Default: sys.stdout. + + Returns: + tuple[float | str]: If ``as_strings`` is set to True, it will return + FLOPs and parameter counts in a string format. otherwise, it will + return those in a float number format. + """ + assert type(input_shape) is tuple + assert len(input_shape) >= 1 + assert isinstance(model, nn.Module) flops_model = add_flops_counting_methods(model) - flops_model.eval().start_flops_count() + flops_model.eval() + flops_model.start_flops_count() if input_constructor: - input = input_constructor(input_res) + input = input_constructor(input_shape) _ = flops_model(**input) else: - batch = torch.ones(()).new_empty( - (1, *input_res), - dtype=next(flops_model.parameters()).dtype, - device=next(flops_model.parameters()).device) - flops_model(batch) - + try: + batch = torch.ones(()).new_empty( + (1, *input_shape), + dtype=next(flops_model.parameters()).dtype, + device=next(flops_model.parameters()).device) + except StopIteration: + # Avoid StopIteration for models which have no parameters, + # like `nn.Relu()`, `nn.AvgPool2d`, etc. + batch = torch.ones(()).new_empty((1, *input_shape)) + + _ = flops_model(batch) + + flops_count, params_count = flops_model.compute_average_flops_cost() if print_per_layer_stat: - print_model_with_flops(flops_model, ost=ost) - flops_count = flops_model.compute_average_flops_cost() - params_count = get_model_parameters_number(flops_model) + print_model_with_flops( + flops_model, flops_count, params_count, ost=ost, flush=flush) flops_model.stop_flops_count() if as_strings: @@ -66,50 +115,151 @@ def get_model_complexity_info(model, return flops_count, params_count -def flops_to_string(flops, units='GMac', precision=2): +def flops_to_string(flops, units='GFLOPs', precision=2): + """Convert FLOPs number into a string. + + Note that Here we take a multiply-add counts as one FLOP. + + Args: + flops (float): FLOPs number to be converted. + units (str | None): Converted FLOPs units. Options are None, 'GFLOPs', + 'MFLOPs', 'KFLOPs', 'FLOPs'. If set to None, it will automatically + choose the most suitable unit for FLOPs. Default: 'GFLOPs'. + precision (int): Digit number after the decimal point. Default: 2. + + Returns: + str: The converted FLOPs number with units. + + Examples: + >>> flops_to_string(1e9) + '1.0 GFLOPs' + >>> flops_to_string(2e5, 'MFLOPs') + '0.2 MFLOPs' + >>> flops_to_string(3e-9, None) + '3e-09 FLOPs' + """ if units is None: if flops // 10**9 > 0: - return str(round(flops / 10.**9, precision)) + ' GMac' + return str(round(flops / 10.**9, precision)) + ' GFLOPs' elif flops // 10**6 > 0: - return str(round(flops / 10.**6, precision)) + ' MMac' + return str(round(flops / 10.**6, precision)) + ' MFLOPs' elif flops // 10**3 > 0: - return str(round(flops / 10.**3, precision)) + ' KMac' + return str(round(flops / 10.**3, precision)) + ' KFLOPs' else: - return str(flops) + ' Mac' + return str(flops) + ' FLOPs' else: - if units == 'GMac': + if units == 'GFLOPs': return str(round(flops / 10.**9, precision)) + ' ' + units - elif units == 'MMac': + elif units == 'MFLOPs': return str(round(flops / 10.**6, precision)) + ' ' + units - elif units == 'KMac': + elif units == 'KFLOPs': return str(round(flops / 10.**3, precision)) + ' ' + units else: - return str(flops) + ' Mac' + return str(flops) + ' FLOPs' + +def params_to_string(num_params, units=None, precision=2): + """Convert parameter number into a string. -def params_to_string(params_num): - """converting number to string + Args: + num_params (float): Parameter number to be converted. + units (str | None): Converted FLOPs units. Options are None, 'M', + 'K' and ''. If set to None, it will automatically choose the most + suitable unit for Parameter number. Default: None. + precision (int): Digit number after the decimal point. Default: 2. - :param float params_num: number - :returns str: number + Returns: + str: The converted parameter number with units. - >>> params_to_string(1e9) - '1000.0 M' - >>> params_to_string(2e5) - '200.0 k' - >>> params_to_string(3e-9) - '3e-09' + Examples: + >>> params_to_string(1e9) + '1000.0 M' + >>> params_to_string(2e5) + '200.0 k' + >>> params_to_string(3e-9) + '3e-09' """ - if params_num // 10**6 > 0: - return str(round(params_num / 10**6, 2)) + ' M' - elif params_num // 10**3: - return str(round(params_num / 10**3, 2)) + ' k' + if units is None: + if num_params // 10**6 > 0: + return str(round(num_params / 10**6, precision)) + ' M' + elif num_params // 10**3: + return str(round(num_params / 10**3, precision)) + ' k' + else: + return str(num_params) else: - return str(params_num) - + if units == 'M': + return str(round(num_params / 10.**6, precision)) + ' ' + units + elif units == 'K': + return str(round(num_params / 10.**3, precision)) + ' ' + units + else: + return str(num_params) + + +def print_model_with_flops(model, + total_flops, + total_params, + units='GFLOPs', + precision=3, + ost=sys.stdout, + flush=False): + """Print a model with FLOPs for each layer. + + Args: + model (nn.Module): The model to be printed. + total_flops (float): Total FLOPs of the model. + total_params (float): Total parameter counts of the model. + units (str | None): Converted FLOPs units. Default: 'GFLOPs'. + precision (int): Digit number after the decimal point. Default: 3. + ost (stream): same as `file` param in :func:`print`. + Default: sys.stdout. + flush (bool): same as that in :func:`print`. Default: False. + + Example: + >>> class ExampleModel(nn.Module): + + >>> def __init__(self): + >>> super().__init__() + >>> self.conv1 = nn.Conv2d(3, 8, 3) + >>> self.conv2 = nn.Conv2d(8, 256, 3) + >>> self.conv3 = nn.Conv2d(256, 8, 3) + >>> self.avg_pool = nn.AdaptiveAvgPool2d((1, 1)) + >>> self.flatten = nn.Flatten() + >>> self.fc = nn.Linear(8, 1) + + >>> def forward(self, x): + >>> x = self.conv1(x) + >>> x = self.conv2(x) + >>> x = self.conv3(x) + >>> x = self.avg_pool(x) + >>> x = self.flatten(x) + >>> x = self.fc(x) + >>> return x + + >>> model = ExampleModel() + >>> x = (3, 16, 16) + to print the complexity information state for each layer, you can use + >>> get_model_complexity_info(model, x) + or directly use + >>> print_model_with_flops(model, 4579784.0, 37361) + ExampleModel( + 0.037 M, 100.000% Params, 0.005 GFLOPs, 100.000% FLOPs, + (conv1): Conv2d(0.0 M, 0.600% Params, 0.0 GFLOPs, 0.959% FLOPs, 3, 8, kernel_size=(3, 3), stride=(1, 1)) # noqa: E501 + (conv2): Conv2d(0.019 M, 50.020% Params, 0.003 GFLOPs, 58.760% FLOPs, 8, 256, kernel_size=(3, 3), stride=(1, 1)) + (conv3): Conv2d(0.018 M, 49.356% Params, 0.002 GFLOPs, 40.264% FLOPs, 256, 8, kernel_size=(3, 3), stride=(1, 1)) + (avg_pool): AdaptiveAvgPool2d(0.0 M, 0.000% Params, 0.0 GFLOPs, 0.017% FLOPs, output_size=(1, 1)) + (flatten): Flatten(0.0 M, 0.000% Params, 0.0 GFLOPs, 0.000% FLOPs, ) + (fc): Linear(0.0 M, 0.024% Params, 0.0 GFLOPs, 0.000% FLOPs, in_features=8, out_features=1, bias=True) + ) + """ -def print_model_with_flops(model, units='GMac', precision=3, ost=sys.stdout): - total_flops = model.compute_average_flops_cost() + def accumulate_params(self): + if is_supported_instance(self): + return self.__params__ + else: + sum = 0 + for m in self.children(): + sum += m.accumulate_params() + return sum def accumulate_flops(self): if is_supported_instance(self): @@ -121,16 +271,21 @@ def print_model_with_flops(model, units='GMac', precision=3, ost=sys.stdout): return sum def flops_repr(self): + accumulated_num_params = self.accumulate_params() accumulated_flops_cost = self.accumulate_flops() return ', '.join([ + params_to_string( + accumulated_num_params, units='M', precision=precision), + '{:.3%} Params'.format(accumulated_num_params / total_params), flops_to_string( accumulated_flops_cost, units=units, precision=precision), - '{:.3%} MACs'.format(accumulated_flops_cost / total_flops), + '{:.3%} FLOPs'.format(accumulated_flops_cost / total_flops), self.original_extra_repr() ]) def add_extra_repr(m): m.accumulate_flops = accumulate_flops.__get__(m) + m.accumulate_params = accumulate_params.__get__(m) flops_extra_repr = flops_repr.__get__(m) if m.extra_repr != flops_extra_repr: m.original_extra_repr = m.extra_repr @@ -145,13 +300,21 @@ def print_model_with_flops(model, units='GMac', precision=3, ost=sys.stdout): del m.accumulate_flops model.apply(add_extra_repr) - print(model, file=ost) + print(model, file=ost, flush=flush) model.apply(del_extra_repr) def get_model_parameters_number(model): - params_num = sum(p.numel() for p in model.parameters() if p.requires_grad) - return params_num + """Calculate parameter number of a model. + + Args: + model (nn.module): The model for parameter number calculation. + + Returns: + float: Parameter number of the model. + """ + num_params = sum(p.numel() for p in model.parameters() if p.requires_grad) + return num_params def add_flops_counting_methods(net_main_module): @@ -163,85 +326,77 @@ def add_flops_counting_methods(net_main_module): net_main_module) net_main_module.reset_flops_count = reset_flops_count.__get__( net_main_module) - net_main_module.compute_average_flops_cost = \ - compute_average_flops_cost.__get__(net_main_module) + net_main_module.compute_average_flops_cost = compute_average_flops_cost.__get__( # noqa: E501 + net_main_module) net_main_module.reset_flops_count() - # Adding variables necessary for masked flops computation - net_main_module.apply(add_flops_mask_variable_or_reset) - return net_main_module def compute_average_flops_cost(self): - """ - A method that will be available after add_flops_counting_methods() is - called on a desired net object. - Returns current mean flops consumption per image. - """ + """Compute average FLOPs cost. + + A method to compute average FLOPs cost, which will be available after + `add_flops_counting_methods()` is called on a desired net object. + Returns: + float: Current mean flops consumption per image. + """ batches_count = self.__batch_counter__ flops_sum = 0 for module in self.modules(): if is_supported_instance(module): flops_sum += module.__flops__ - - return flops_sum / batches_count + params_sum = get_model_parameters_number(self) + return flops_sum / batches_count, params_sum def start_flops_count(self): - """ - A method that will be available after add_flops_counting_methods() is - called on a desired net object. - Activates the computation of mean flops consumption per image. - Call it before you run the network. + """Activate the computation of mean flops consumption per image. + + A method to activate the computation of mean flops consumption per image. + which will be available after ``add_flops_counting_methods()`` is called on + a desired net object. It should be called before running the network. """ add_batch_counter_hook_function(self) - self.apply(add_flops_counter_hook_function) + + def add_flops_counter_hook_function(module): + if is_supported_instance(module): + if hasattr(module, '__flops_handle__'): + return + + else: + handle = module.register_forward_hook( + get_modules_mapping()[type(module)]) + + module.__flops_handle__ = handle + + self.apply(partial(add_flops_counter_hook_function)) def stop_flops_count(self): - """ - A method that will be available after add_flops_counting_methods() is - called on a desired net object. - Stops computing the mean flops consumption per image. - Call whenever you want to pause the computation. + """Stop computing the mean flops consumption per image. + + A method to stop computing the mean flops consumption per image, which will + be available after ``add_flops_counting_methods()`` is called on a desired + net object. It can be called to pause the computation whenever. """ remove_batch_counter_hook_function(self) self.apply(remove_flops_counter_hook_function) def reset_flops_count(self): - """ - A method that will be available after add_flops_counting_methods() is - called on a desired net object. - Resets statistics computed so far. + """Reset statistics computed so far. + + A method to Reset computed statistics, which will be available after + `add_flops_counting_methods()` is called on a desired net object. """ add_batch_counter_variables_or_reset(self) self.apply(add_flops_counter_variable_or_reset) -def add_flops_mask(module, mask): - - def add_flops_mask_func(module): - if isinstance(module, torch.nn.Conv2d): - module.__mask__ = mask - - module.apply(add_flops_mask_func) - - -def remove_flops_mask(module): - module.apply(add_flops_mask_variable_or_reset) - - -def is_supported_instance(module): - for mod in hook_mapping: - if issubclass(type(module), mod): - return True - return False - - +# ---- Internal functions def empty_flops_counter_hook(module, input, output): module.__flops__ += 0 @@ -262,8 +417,9 @@ def relu_flops_counter_hook(module, input, output): def linear_flops_counter_hook(module, input, output): input = input[0] - batch_size = input.shape[0] - module.__flops__ += int(batch_size * input.shape[1] * output.shape[1]) + output_last_dim = output.shape[ + -1] # pytorch checks dimensions, so here we don't care much + module.__flops__ += int(np.prod(input.shape) * output_last_dim) def pool_flops_counter_hook(module, input, output): @@ -271,26 +427,16 @@ def pool_flops_counter_hook(module, input, output): module.__flops__ += int(np.prod(input.shape)) -def bn_flops_counter_hook(module, input, output): +def norm_flops_counter_hook(module, input, output): input = input[0] batch_flops = np.prod(input.shape) - if module.affine: + if (getattr(module, 'affine', False) + or getattr(module, 'elementwise_affine', False)): batch_flops *= 2 module.__flops__ += int(batch_flops) -def gn_flops_counter_hook(module, input, output): - elems = np.prod(input[0].shape) - # there is no precise FLOPs estimation of computing mean and variance, - # and we just set it 2 * elems: half muladds for computing - # means and half for computing vars - batch_flops = 3 * elems - if module.affine: - batch_flops += elems - module.__flops__ += int(batch_flops) - - def deconv_flops_counter_hook(conv_module, input, output): # Can have multiple inputs, getting the first one input = input[0] @@ -331,17 +477,10 @@ def conv_flops_counter_hook(conv_module, input, output): groups = conv_module.groups filters_per_channel = out_channels // groups - conv_per_position_flops = np.prod( - kernel_dims) * in_channels * filters_per_channel + conv_per_position_flops = int( + np.prod(kernel_dims)) * in_channels * filters_per_channel - active_elements_count = batch_size * np.prod(output_dims) - - if conv_module.__mask__ is not None: - # (b, 1, h, w) - output_height, output_width = output.shape[2:] - flops_mask = conv_module.__mask__.expand(batch_size, 1, output_height, - output_width) - active_elements_count = flops_mask.sum() + active_elements_count = batch_size * int(np.prod(output_dims)) overall_conv_flops = conv_per_position_flops * active_elements_count @@ -356,32 +495,6 @@ def conv_flops_counter_hook(conv_module, input, output): conv_module.__flops__ += int(overall_flops) -hook_mapping = { - # conv - _ConvNd: conv_flops_counter_hook, - # deconv - _ConvTransposeMixin: deconv_flops_counter_hook, - # fc - nn.Linear: linear_flops_counter_hook, - # pooling - _AvgPoolNd: pool_flops_counter_hook, - _MaxPoolNd: pool_flops_counter_hook, - _AdaptiveAvgPoolNd: pool_flops_counter_hook, - _AdaptiveMaxPoolNd: pool_flops_counter_hook, - # activation - nn.ReLU: relu_flops_counter_hook, - nn.PReLU: relu_flops_counter_hook, - nn.ELU: relu_flops_counter_hook, - nn.LeakyReLU: relu_flops_counter_hook, - nn.ReLU6: relu_flops_counter_hook, - # normalization - _BatchNorm: bn_flops_counter_hook, - nn.GroupNorm: gn_flops_counter_hook, - # upsample - nn.Upsample: upsample_flops_counter_hook, -} - - def batch_counter_hook(module, input, output): batch_size = 1 if len(input) > 0: @@ -389,12 +502,14 @@ def batch_counter_hook(module, input, output): input = input[0] batch_size = len(input) else: + pass print('Warning! No positional inputs found for a module, ' 'assuming batch size is 1.') module.__batch_counter__ += batch_size def add_batch_counter_variables_or_reset(module): + module.__batch_counter__ = 0 @@ -414,20 +529,18 @@ def remove_batch_counter_hook_function(module): def add_flops_counter_variable_or_reset(module): if is_supported_instance(module): + if hasattr(module, '__flops__') or hasattr(module, '__params__'): + print('Warning: variables __flops__ or __params__ are already ' + 'defined for the module' + type(module).__name__ + + ' ptflops can affect your code!') module.__flops__ = 0 + module.__params__ = get_model_parameters_number(module) -def add_flops_counter_hook_function(module): - if is_supported_instance(module): - if hasattr(module, '__flops_handle__'): - return - - for mod_type, counter_hook in hook_mapping.items(): - if issubclass(type(module), mod_type): - handle = module.register_forward_hook(counter_hook) - break - - module.__flops_handle__ = handle +def is_supported_instance(module): + if type(module) in get_modules_mapping(): + return True + return False def remove_flops_counter_hook_function(module): @@ -437,8 +550,50 @@ def remove_flops_counter_hook_function(module): del module.__flops_handle__ -# --- Masked flops counting -# Also being run in the initialization -def add_flops_mask_variable_or_reset(module): - if is_supported_instance(module): - module.__mask__ = None +def get_modules_mapping(): + return { + # convolutions + nn.Conv1d: conv_flops_counter_hook, + nn.Conv2d: conv_flops_counter_hook, + mmcv.cnn.bricks.Conv2d: conv_flops_counter_hook, + nn.Conv3d: conv_flops_counter_hook, + mmcv.cnn.bricks.Conv3d: conv_flops_counter_hook, + # activations + nn.ReLU: relu_flops_counter_hook, + nn.PReLU: relu_flops_counter_hook, + nn.ELU: relu_flops_counter_hook, + nn.LeakyReLU: relu_flops_counter_hook, + nn.ReLU6: relu_flops_counter_hook, + # poolings + nn.MaxPool1d: pool_flops_counter_hook, + nn.AvgPool1d: pool_flops_counter_hook, + nn.AvgPool2d: pool_flops_counter_hook, + nn.MaxPool2d: pool_flops_counter_hook, + mmcv.cnn.bricks.MaxPool2d: pool_flops_counter_hook, + nn.MaxPool3d: pool_flops_counter_hook, + mmcv.cnn.bricks.MaxPool3d: pool_flops_counter_hook, + nn.AvgPool3d: pool_flops_counter_hook, + nn.AdaptiveMaxPool1d: pool_flops_counter_hook, + nn.AdaptiveAvgPool1d: pool_flops_counter_hook, + nn.AdaptiveMaxPool2d: pool_flops_counter_hook, + nn.AdaptiveAvgPool2d: pool_flops_counter_hook, + nn.AdaptiveMaxPool3d: pool_flops_counter_hook, + nn.AdaptiveAvgPool3d: pool_flops_counter_hook, + # normalizations + nn.BatchNorm1d: norm_flops_counter_hook, + nn.BatchNorm2d: norm_flops_counter_hook, + nn.BatchNorm3d: norm_flops_counter_hook, + nn.GroupNorm: norm_flops_counter_hook, + nn.InstanceNorm1d: norm_flops_counter_hook, + nn.InstanceNorm2d: norm_flops_counter_hook, + nn.InstanceNorm3d: norm_flops_counter_hook, + nn.LayerNorm: norm_flops_counter_hook, + # FC + nn.Linear: linear_flops_counter_hook, + mmcv.cnn.bricks.Linear: linear_flops_counter_hook, + # Upscale + nn.Upsample: upsample_flops_counter_hook, + # Deconvolution + nn.ConvTranspose2d: deconv_flops_counter_hook, + mmcv.cnn.bricks.ConvTranspose2d: deconv_flops_counter_hook, + } diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/fuse_conv_bn.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/fuse_conv_bn.py new file mode 100644 index 000000000..cb7076f80 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/fuse_conv_bn.py @@ -0,0 +1,59 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch +import torch.nn as nn + + +def _fuse_conv_bn(conv, bn): + """Fuse conv and bn into one module. + + Args: + conv (nn.Module): Conv to be fused. + bn (nn.Module): BN to be fused. + + Returns: + nn.Module: Fused module. + """ + conv_w = conv.weight + conv_b = conv.bias if conv.bias is not None else torch.zeros_like( + bn.running_mean) + + factor = bn.weight / torch.sqrt(bn.running_var + bn.eps) + conv.weight = nn.Parameter(conv_w * + factor.reshape([conv.out_channels, 1, 1, 1])) + conv.bias = nn.Parameter((conv_b - bn.running_mean) * factor + bn.bias) + return conv + + +def fuse_conv_bn(module): + """Recursively fuse conv and bn in a module. + + During inference, the functionary of batch norm layers is turned off + but only the mean and var alone channels are used, which exposes the + chance to fuse it with the preceding conv layers to save computations and + simplify network structures. + + Args: + module (nn.Module): Module to be fused. + + Returns: + nn.Module: Fused module. + """ + last_conv = None + last_conv_name = None + + for name, child in module.named_children(): + if isinstance(child, + (nn.modules.batchnorm._BatchNorm, nn.SyncBatchNorm)): + if last_conv is None: # only fuse BN that is after Conv + continue + fused_conv = _fuse_conv_bn(last_conv, child) + module._modules[last_conv_name] = fused_conv + # To reduce changes, set BN as Identity instead of deleting it. + module._modules[name] = nn.Identity() + last_conv = None + elif isinstance(child, nn.Conv2d): + last_conv = child + last_conv_name = name + else: + fuse_conv_bn(child) + return module diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/sync_bn.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/sync_bn.py new file mode 100644 index 000000000..8a79ff4a4 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/sync_bn.py @@ -0,0 +1,59 @@ +import torch + +import mmcv + + +class _BatchNormXd(torch.nn.modules.batchnorm._BatchNorm): + """A general BatchNorm layer without input dimension check. + + Reproduced from @kapily's work: + (https://github.com/pytorch/pytorch/issues/41081#issuecomment-783961547) + The only difference between BatchNorm1d, BatchNorm2d, BatchNorm3d, etc + is `_check_input_dim` that is designed for tensor sanity checks. + The check has been bypassed in this class for the convenience of converting + SyncBatchNorm. + """ + + def _check_input_dim(self, input): + return + + +def revert_sync_batchnorm(module): + """Helper function to convert all `SyncBatchNorm` (SyncBN) and + `mmcv.ops.sync_bn.SyncBatchNorm`(MMSyncBN) layers in the model to + `BatchNormXd` layers. + + Adapted from @kapily's work: + (https://github.com/pytorch/pytorch/issues/41081#issuecomment-783961547) + + Args: + module (nn.Module): The module containing `SyncBatchNorm` layers. + + Returns: + module_output: The converted module with `BatchNormXd` layers. + """ + module_output = module + module_checklist = [torch.nn.modules.batchnorm.SyncBatchNorm] + if hasattr(mmcv, 'ops'): + module_checklist.append(mmcv.ops.SyncBatchNorm) + if isinstance(module, tuple(module_checklist)): + module_output = _BatchNormXd(module.num_features, module.eps, + module.momentum, module.affine, + module.track_running_stats) + if module.affine: + # no_grad() may not be needed here but + # just to be consistent with `convert_sync_batchnorm()` + with torch.no_grad(): + module_output.weight = module.weight + module_output.bias = module.bias + module_output.running_mean = module.running_mean + module_output.running_var = module.running_var + module_output.num_batches_tracked = module.num_batches_tracked + module_output.training = module.training + # qconfig exists in quantized models + if hasattr(module, 'qconfig'): + module_output.qconfig = module.qconfig + for name, child in module.named_children(): + module_output.add_module(name, revert_sync_batchnorm(child)) + del module + return module_output diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/weight_init.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/weight_init.py new file mode 100644 index 000000000..e1ac999e2 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/utils/weight_init.py @@ -0,0 +1,684 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import copy +import math +import warnings + +import numpy as np +import torch +import torch.nn as nn +from torch import Tensor + +from mmcv.utils import Registry, build_from_cfg, get_logger, print_log + +INITIALIZERS = Registry('initializer') + + +def update_init_info(module, init_info): + """Update the `_params_init_info` in the module if the value of parameters + are changed. + + Args: + module (obj:`nn.Module`): The module of PyTorch with a user-defined + attribute `_params_init_info` which records the initialization + information. + init_info (str): The string that describes the initialization. + """ + assert hasattr( + module, + '_params_init_info'), f'Can not find `_params_init_info` in {module}' + for name, param in module.named_parameters(): + + assert param in module._params_init_info, ( + f'Find a new :obj:`Parameter` ' + f'named `{name}` during executing the ' + f'`init_weights` of ' + f'`{module.__class__.__name__}`. ' + f'Please do not add or ' + f'replace parameters during executing ' + f'the `init_weights`. ') + + # The parameter has been changed during executing the + # `init_weights` of module + mean_value = param.data.mean() + if module._params_init_info[param]['tmp_mean_value'] != mean_value: + module._params_init_info[param]['init_info'] = init_info + module._params_init_info[param]['tmp_mean_value'] = mean_value + + +def constant_init(module, val, bias=0): + if hasattr(module, 'weight') and module.weight is not None: + nn.init.constant_(module.weight, val) + if hasattr(module, 'bias') and module.bias is not None: + nn.init.constant_(module.bias, bias) + + +def xavier_init(module, gain=1, bias=0, distribution='normal'): + assert distribution in ['uniform', 'normal'] + if hasattr(module, 'weight') and module.weight is not None: + if distribution == 'uniform': + nn.init.xavier_uniform_(module.weight, gain=gain) + else: + nn.init.xavier_normal_(module.weight, gain=gain) + if hasattr(module, 'bias') and module.bias is not None: + nn.init.constant_(module.bias, bias) + + +def normal_init(module, mean=0, std=1, bias=0): + if hasattr(module, 'weight') and module.weight is not None: + nn.init.normal_(module.weight, mean, std) + if hasattr(module, 'bias') and module.bias is not None: + nn.init.constant_(module.bias, bias) + + +def trunc_normal_init(module: nn.Module, + mean: float = 0, + std: float = 1, + a: float = -2, + b: float = 2, + bias: float = 0) -> None: + if hasattr(module, 'weight') and module.weight is not None: + trunc_normal_(module.weight, mean, std, a, b) # type: ignore + if hasattr(module, 'bias') and module.bias is not None: + nn.init.constant_(module.bias, bias) # type: ignore + + +def uniform_init(module, a=0, b=1, bias=0): + if hasattr(module, 'weight') and module.weight is not None: + nn.init.uniform_(module.weight, a, b) + if hasattr(module, 'bias') and module.bias is not None: + nn.init.constant_(module.bias, bias) + + +def kaiming_init(module, + a=0, + mode='fan_out', + nonlinearity='relu', + bias=0, + distribution='normal'): + assert distribution in ['uniform', 'normal'] + if hasattr(module, 'weight') and module.weight is not None: + if distribution == 'uniform': + nn.init.kaiming_uniform_( + module.weight, a=a, mode=mode, nonlinearity=nonlinearity) + else: + nn.init.kaiming_normal_( + module.weight, a=a, mode=mode, nonlinearity=nonlinearity) + if hasattr(module, 'bias') and module.bias is not None: + nn.init.constant_(module.bias, bias) + + +def caffe2_xavier_init(module, bias=0): + # `XavierFill` in Caffe2 corresponds to `kaiming_uniform_` in PyTorch + # Acknowledgment to FAIR's internal code + kaiming_init( + module, + a=1, + mode='fan_in', + nonlinearity='leaky_relu', + bias=bias, + distribution='uniform') + + +def bias_init_with_prob(prior_prob): + """initialize conv/fc bias value according to a given probability value.""" + bias_init = float(-np.log((1 - prior_prob) / prior_prob)) + return bias_init + + +def _get_bases_name(m): + return [b.__name__ for b in m.__class__.__bases__] + + +class BaseInit(object): + + def __init__(self, *, bias=0, bias_prob=None, layer=None): + self.wholemodule = False + if not isinstance(bias, (int, float)): + raise TypeError(f'bias must be a number, but got a {type(bias)}') + + if bias_prob is not None: + if not isinstance(bias_prob, float): + raise TypeError(f'bias_prob type must be float, \ + but got {type(bias_prob)}') + + if layer is not None: + if not isinstance(layer, (str, list)): + raise TypeError(f'layer must be a str or a list of str, \ + but got a {type(layer)}') + else: + layer = [] + + if bias_prob is not None: + self.bias = bias_init_with_prob(bias_prob) + else: + self.bias = bias + self.layer = [layer] if isinstance(layer, str) else layer + + def _get_init_info(self): + info = f'{self.__class__.__name__}, bias={self.bias}' + return info + + +@INITIALIZERS.register_module(name='Constant') +class ConstantInit(BaseInit): + """Initialize module parameters with constant values. + + Args: + val (int | float): the value to fill the weights in the module with + bias (int | float): the value to fill the bias. Defaults to 0. + bias_prob (float, optional): the probability for bias initialization. + Defaults to None. + layer (str | list[str], optional): the layer will be initialized. + Defaults to None. + """ + + def __init__(self, val, **kwargs): + super().__init__(**kwargs) + self.val = val + + def __call__(self, module): + + def init(m): + if self.wholemodule: + constant_init(m, self.val, self.bias) + else: + layername = m.__class__.__name__ + basesname = _get_bases_name(m) + if len(set(self.layer) & set([layername] + basesname)): + constant_init(m, self.val, self.bias) + + module.apply(init) + if hasattr(module, '_params_init_info'): + update_init_info(module, init_info=self._get_init_info()) + + def _get_init_info(self): + info = f'{self.__class__.__name__}: val={self.val}, bias={self.bias}' + return info + + +@INITIALIZERS.register_module(name='Xavier') +class XavierInit(BaseInit): + r"""Initialize module parameters with values according to the method + described in `Understanding the difficulty of training deep feedforward + neural networks - Glorot, X. & Bengio, Y. (2010). + `_ + + Args: + gain (int | float): an optional scaling factor. Defaults to 1. + bias (int | float): the value to fill the bias. Defaults to 0. + bias_prob (float, optional): the probability for bias initialization. + Defaults to None. + distribution (str): distribution either be ``'normal'`` + or ``'uniform'``. Defaults to ``'normal'``. + layer (str | list[str], optional): the layer will be initialized. + Defaults to None. + """ + + def __init__(self, gain=1, distribution='normal', **kwargs): + super().__init__(**kwargs) + self.gain = gain + self.distribution = distribution + + def __call__(self, module): + + def init(m): + if self.wholemodule: + xavier_init(m, self.gain, self.bias, self.distribution) + else: + layername = m.__class__.__name__ + basesname = _get_bases_name(m) + if len(set(self.layer) & set([layername] + basesname)): + xavier_init(m, self.gain, self.bias, self.distribution) + + module.apply(init) + if hasattr(module, '_params_init_info'): + update_init_info(module, init_info=self._get_init_info()) + + def _get_init_info(self): + info = f'{self.__class__.__name__}: gain={self.gain}, ' \ + f'distribution={self.distribution}, bias={self.bias}' + return info + + +@INITIALIZERS.register_module(name='Normal') +class NormalInit(BaseInit): + r"""Initialize module parameters with the values drawn from the normal + distribution :math:`\mathcal{N}(\text{mean}, \text{std}^2)`. + + Args: + mean (int | float):the mean of the normal distribution. Defaults to 0. + std (int | float): the standard deviation of the normal distribution. + Defaults to 1. + bias (int | float): the value to fill the bias. Defaults to 0. + bias_prob (float, optional): the probability for bias initialization. + Defaults to None. + layer (str | list[str], optional): the layer will be initialized. + Defaults to None. + + """ + + def __init__(self, mean=0, std=1, **kwargs): + super().__init__(**kwargs) + self.mean = mean + self.std = std + + def __call__(self, module): + + def init(m): + if self.wholemodule: + normal_init(m, self.mean, self.std, self.bias) + else: + layername = m.__class__.__name__ + basesname = _get_bases_name(m) + if len(set(self.layer) & set([layername] + basesname)): + normal_init(m, self.mean, self.std, self.bias) + + module.apply(init) + if hasattr(module, '_params_init_info'): + update_init_info(module, init_info=self._get_init_info()) + + def _get_init_info(self): + info = f'{self.__class__.__name__}: mean={self.mean},' \ + f' std={self.std}, bias={self.bias}' + return info + + +@INITIALIZERS.register_module(name='TruncNormal') +class TruncNormalInit(BaseInit): + r"""Initialize module parameters with the values drawn from the normal + distribution :math:`\mathcal{N}(\text{mean}, \text{std}^2)` with values + outside :math:`[a, b]`. + + Args: + mean (float): the mean of the normal distribution. Defaults to 0. + std (float): the standard deviation of the normal distribution. + Defaults to 1. + a (float): The minimum cutoff value. + b ( float): The maximum cutoff value. + bias (float): the value to fill the bias. Defaults to 0. + bias_prob (float, optional): the probability for bias initialization. + Defaults to None. + layer (str | list[str], optional): the layer will be initialized. + Defaults to None. + + """ + + def __init__(self, + mean: float = 0, + std: float = 1, + a: float = -2, + b: float = 2, + **kwargs) -> None: + super().__init__(**kwargs) + self.mean = mean + self.std = std + self.a = a + self.b = b + + def __call__(self, module: nn.Module) -> None: + + def init(m): + if self.wholemodule: + trunc_normal_init(m, self.mean, self.std, self.a, self.b, + self.bias) + else: + layername = m.__class__.__name__ + basesname = _get_bases_name(m) + if len(set(self.layer) & set([layername] + basesname)): + trunc_normal_init(m, self.mean, self.std, self.a, self.b, + self.bias) + + module.apply(init) + if hasattr(module, '_params_init_info'): + update_init_info(module, init_info=self._get_init_info()) + + def _get_init_info(self): + info = f'{self.__class__.__name__}: a={self.a}, b={self.b},' \ + f' mean={self.mean}, std={self.std}, bias={self.bias}' + return info + + +@INITIALIZERS.register_module(name='Uniform') +class UniformInit(BaseInit): + r"""Initialize module parameters with values drawn from the uniform + distribution :math:`\mathcal{U}(a, b)`. + + Args: + a (int | float): the lower bound of the uniform distribution. + Defaults to 0. + b (int | float): the upper bound of the uniform distribution. + Defaults to 1. + bias (int | float): the value to fill the bias. Defaults to 0. + bias_prob (float, optional): the probability for bias initialization. + Defaults to None. + layer (str | list[str], optional): the layer will be initialized. + Defaults to None. + """ + + def __init__(self, a=0, b=1, **kwargs): + super().__init__(**kwargs) + self.a = a + self.b = b + + def __call__(self, module): + + def init(m): + if self.wholemodule: + uniform_init(m, self.a, self.b, self.bias) + else: + layername = m.__class__.__name__ + basesname = _get_bases_name(m) + if len(set(self.layer) & set([layername] + basesname)): + uniform_init(m, self.a, self.b, self.bias) + + module.apply(init) + if hasattr(module, '_params_init_info'): + update_init_info(module, init_info=self._get_init_info()) + + def _get_init_info(self): + info = f'{self.__class__.__name__}: a={self.a},' \ + f' b={self.b}, bias={self.bias}' + return info + + +@INITIALIZERS.register_module(name='Kaiming') +class KaimingInit(BaseInit): + r"""Initialize module parameters with the values according to the method + described in `Delving deep into rectifiers: Surpassing human-level + performance on ImageNet classification - He, K. et al. (2015). + `_ + + Args: + a (int | float): the negative slope of the rectifier used after this + layer (only used with ``'leaky_relu'``). Defaults to 0. + mode (str): either ``'fan_in'`` or ``'fan_out'``. Choosing + ``'fan_in'`` preserves the magnitude of the variance of the weights + in the forward pass. Choosing ``'fan_out'`` preserves the + magnitudes in the backwards pass. Defaults to ``'fan_out'``. + nonlinearity (str): the non-linear function (`nn.functional` name), + recommended to use only with ``'relu'`` or ``'leaky_relu'`` . + Defaults to 'relu'. + bias (int | float): the value to fill the bias. Defaults to 0. + bias_prob (float, optional): the probability for bias initialization. + Defaults to None. + distribution (str): distribution either be ``'normal'`` or + ``'uniform'``. Defaults to ``'normal'``. + layer (str | list[str], optional): the layer will be initialized. + Defaults to None. + """ + + def __init__(self, + a=0, + mode='fan_out', + nonlinearity='relu', + distribution='normal', + **kwargs): + super().__init__(**kwargs) + self.a = a + self.mode = mode + self.nonlinearity = nonlinearity + self.distribution = distribution + + def __call__(self, module): + + def init(m): + if self.wholemodule: + kaiming_init(m, self.a, self.mode, self.nonlinearity, + self.bias, self.distribution) + else: + layername = m.__class__.__name__ + basesname = _get_bases_name(m) + if len(set(self.layer) & set([layername] + basesname)): + kaiming_init(m, self.a, self.mode, self.nonlinearity, + self.bias, self.distribution) + + module.apply(init) + if hasattr(module, '_params_init_info'): + update_init_info(module, init_info=self._get_init_info()) + + def _get_init_info(self): + info = f'{self.__class__.__name__}: a={self.a}, mode={self.mode}, ' \ + f'nonlinearity={self.nonlinearity}, ' \ + f'distribution ={self.distribution}, bias={self.bias}' + return info + + +@INITIALIZERS.register_module(name='Caffe2Xavier') +class Caffe2XavierInit(KaimingInit): + # `XavierFill` in Caffe2 corresponds to `kaiming_uniform_` in PyTorch + # Acknowledgment to FAIR's internal code + def __init__(self, **kwargs): + super().__init__( + a=1, + mode='fan_in', + nonlinearity='leaky_relu', + distribution='uniform', + **kwargs) + + def __call__(self, module): + super().__call__(module) + + +@INITIALIZERS.register_module(name='Pretrained') +class PretrainedInit(object): + """Initialize module by loading a pretrained model. + + Args: + checkpoint (str): the checkpoint file of the pretrained model should + be load. + prefix (str, optional): the prefix of a sub-module in the pretrained + model. it is for loading a part of the pretrained model to + initialize. For example, if we would like to only load the + backbone of a detector model, we can set ``prefix='backbone.'``. + Defaults to None. + map_location (str): map tensors into proper locations. + """ + + def __init__(self, checkpoint, prefix=None, map_location=None): + self.checkpoint = checkpoint + self.prefix = prefix + self.map_location = map_location + + def __call__(self, module): + from mmcv.runner import (_load_checkpoint_with_prefix, load_checkpoint, + load_state_dict) + logger = get_logger('mmcv') + if self.prefix is None: + print_log(f'load model from: {self.checkpoint}', logger=logger) + load_checkpoint( + module, + self.checkpoint, + map_location=self.map_location, + strict=False, + logger=logger) + else: + print_log( + f'load {self.prefix} in model from: {self.checkpoint}', + logger=logger) + state_dict = _load_checkpoint_with_prefix( + self.prefix, self.checkpoint, map_location=self.map_location) + load_state_dict(module, state_dict, strict=False, logger=logger) + + if hasattr(module, '_params_init_info'): + update_init_info(module, init_info=self._get_init_info()) + + def _get_init_info(self): + info = f'{self.__class__.__name__}: load from {self.checkpoint}' + return info + + +def _initialize(module, cfg, wholemodule=False): + func = build_from_cfg(cfg, INITIALIZERS) + # wholemodule flag is for override mode, there is no layer key in override + # and initializer will give init values for the whole module with the name + # in override. + func.wholemodule = wholemodule + func(module) + + +def _initialize_override(module, override, cfg): + if not isinstance(override, (dict, list)): + raise TypeError(f'override must be a dict or a list of dict, \ + but got {type(override)}') + + override = [override] if isinstance(override, dict) else override + + for override_ in override: + + cp_override = copy.deepcopy(override_) + name = cp_override.pop('name', None) + if name is None: + raise ValueError('`override` must contain the key "name",' + f'but got {cp_override}') + # if override only has name key, it means use args in init_cfg + if not cp_override: + cp_override.update(cfg) + # if override has name key and other args except type key, it will + # raise error + elif 'type' not in cp_override.keys(): + raise ValueError( + f'`override` need "type" key, but got {cp_override}') + + if hasattr(module, name): + _initialize(getattr(module, name), cp_override, wholemodule=True) + else: + raise RuntimeError(f'module did not have attribute {name}, ' + f'but init_cfg is {cp_override}.') + + +def initialize(module, init_cfg): + """Initialize a module. + + Args: + module (``torch.nn.Module``): the module will be initialized. + init_cfg (dict | list[dict]): initialization configuration dict to + define initializer. OpenMMLab has implemented 6 initializers + including ``Constant``, ``Xavier``, ``Normal``, ``Uniform``, + ``Kaiming``, and ``Pretrained``. + Example: + >>> module = nn.Linear(2, 3, bias=True) + >>> init_cfg = dict(type='Constant', layer='Linear', val =1 , bias =2) + >>> initialize(module, init_cfg) + + >>> module = nn.Sequential(nn.Conv1d(3, 1, 3), nn.Linear(1,2)) + >>> # define key ``'layer'`` for initializing layer with different + >>> # configuration + >>> init_cfg = [dict(type='Constant', layer='Conv1d', val=1), + dict(type='Constant', layer='Linear', val=2)] + >>> initialize(module, init_cfg) + + >>> # define key``'override'`` to initialize some specific part in + >>> # module + >>> class FooNet(nn.Module): + >>> def __init__(self): + >>> super().__init__() + >>> self.feat = nn.Conv2d(3, 16, 3) + >>> self.reg = nn.Conv2d(16, 10, 3) + >>> self.cls = nn.Conv2d(16, 5, 3) + >>> model = FooNet() + >>> init_cfg = dict(type='Constant', val=1, bias=2, layer='Conv2d', + >>> override=dict(type='Constant', name='reg', val=3, bias=4)) + >>> initialize(model, init_cfg) + + >>> model = ResNet(depth=50) + >>> # Initialize weights with the pretrained model. + >>> init_cfg = dict(type='Pretrained', + checkpoint='torchvision://resnet50') + >>> initialize(model, init_cfg) + + >>> # Initialize weights of a sub-module with the specific part of + >>> # a pretrained model by using "prefix". + >>> url = 'http://download.openmmlab.com/mmdetection/v2.0/retinanet/'\ + >>> 'retinanet_r50_fpn_1x_coco/'\ + >>> 'retinanet_r50_fpn_1x_coco_20200130-c2398f9e.pth' + >>> init_cfg = dict(type='Pretrained', + checkpoint=url, prefix='backbone.') + """ + if not isinstance(init_cfg, (dict, list)): + raise TypeError(f'init_cfg must be a dict or a list of dict, \ + but got {type(init_cfg)}') + + if isinstance(init_cfg, dict): + init_cfg = [init_cfg] + + for cfg in init_cfg: + # should deeply copy the original config because cfg may be used by + # other modules, e.g., one init_cfg shared by multiple bottleneck + # blocks, the expected cfg will be changed after pop and will change + # the initialization behavior of other modules + cp_cfg = copy.deepcopy(cfg) + override = cp_cfg.pop('override', None) + _initialize(module, cp_cfg) + + if override is not None: + cp_cfg.pop('layer', None) + _initialize_override(module, override, cp_cfg) + else: + # All attributes in module have same initialization. + pass + + +def _no_grad_trunc_normal_(tensor: Tensor, mean: float, std: float, a: float, + b: float) -> Tensor: + # Method based on + # https://people.sc.fsu.edu/~jburkardt/presentations/truncated_normal.pdf + # Modified from + # https://github.com/pytorch/pytorch/blob/master/torch/nn/init.py + def norm_cdf(x): + # Computes standard normal cumulative distribution function + return (1. + math.erf(x / math.sqrt(2.))) / 2. + + if (mean < a - 2 * std) or (mean > b + 2 * std): + warnings.warn( + 'mean is more than 2 std from [a, b] in nn.init.trunc_normal_. ' + 'The distribution of values may be incorrect.', + stacklevel=2) + + with torch.no_grad(): + # Values are generated by using a truncated uniform distribution and + # then using the inverse CDF for the normal distribution. + # Get upper and lower cdf values + lower = norm_cdf((a - mean) / std) + upper = norm_cdf((b - mean) / std) + + # Uniformly fill tensor with values from [lower, upper], then translate + # to [2lower-1, 2upper-1]. + tensor.uniform_(2 * lower - 1, 2 * upper - 1) + + # Use inverse cdf transform for normal distribution to get truncated + # standard normal + tensor.erfinv_() + + # Transform to proper mean, std + tensor.mul_(std * math.sqrt(2.)) + tensor.add_(mean) + + # Clamp to ensure it's in the proper range + tensor.clamp_(min=a, max=b) + return tensor + + +def trunc_normal_(tensor: Tensor, + mean: float = 0., + std: float = 1., + a: float = -2., + b: float = 2.) -> Tensor: + r"""Fills the input Tensor with values drawn from a truncated + normal distribution. The values are effectively drawn from the + normal distribution :math:`\mathcal{N}(\text{mean}, \text{std}^2)` + with values outside :math:`[a, b]` redrawn until they are within + the bounds. The method used for generating the random values works + best when :math:`a \leq \text{mean} \leq b`. + + Modified from + https://github.com/pytorch/pytorch/blob/master/torch/nn/init.py + + Args: + tensor (``torch.Tensor``): an n-dimensional `torch.Tensor`. + mean (float): the mean of the normal distribution. + std (float): the standard deviation of the normal distribution. + a (float): the minimum cutoff value. + b (float): the maximum cutoff value. + """ + return _no_grad_trunc_normal_(tensor, mean, std, a, b) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/vgg.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/vgg.py new file mode 100644 index 000000000..8778b6495 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/cnn/vgg.py @@ -0,0 +1,175 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import logging + +import torch.nn as nn + +from .utils import constant_init, kaiming_init, normal_init + + +def conv3x3(in_planes, out_planes, dilation=1): + """3x3 convolution with padding.""" + return nn.Conv2d( + in_planes, + out_planes, + kernel_size=3, + padding=dilation, + dilation=dilation) + + +def make_vgg_layer(inplanes, + planes, + num_blocks, + dilation=1, + with_bn=False, + ceil_mode=False): + layers = [] + for _ in range(num_blocks): + layers.append(conv3x3(inplanes, planes, dilation)) + if with_bn: + layers.append(nn.BatchNorm2d(planes)) + layers.append(nn.ReLU(inplace=True)) + inplanes = planes + layers.append(nn.MaxPool2d(kernel_size=2, stride=2, ceil_mode=ceil_mode)) + + return layers + + +class VGG(nn.Module): + """VGG backbone. + + Args: + depth (int): Depth of vgg, from {11, 13, 16, 19}. + with_bn (bool): Use BatchNorm or not. + num_classes (int): number of classes for classification. + num_stages (int): VGG stages, normally 5. + dilations (Sequence[int]): Dilation of each stage. + out_indices (Sequence[int]): Output from which stages. + frozen_stages (int): Stages to be frozen (all param fixed). -1 means + not freezing any parameters. + bn_eval (bool): Whether to set BN layers as eval mode, namely, freeze + running stats (mean and var). + bn_frozen (bool): Whether to freeze weight and bias of BN layers. + """ + + arch_settings = { + 11: (1, 1, 2, 2, 2), + 13: (2, 2, 2, 2, 2), + 16: (2, 2, 3, 3, 3), + 19: (2, 2, 4, 4, 4) + } + + def __init__(self, + depth, + with_bn=False, + num_classes=-1, + num_stages=5, + dilations=(1, 1, 1, 1, 1), + out_indices=(0, 1, 2, 3, 4), + frozen_stages=-1, + bn_eval=True, + bn_frozen=False, + ceil_mode=False, + with_last_pool=True): + super(VGG, self).__init__() + if depth not in self.arch_settings: + raise KeyError(f'invalid depth {depth} for vgg') + assert num_stages >= 1 and num_stages <= 5 + stage_blocks = self.arch_settings[depth] + self.stage_blocks = stage_blocks[:num_stages] + assert len(dilations) == num_stages + assert max(out_indices) <= num_stages + + self.num_classes = num_classes + self.out_indices = out_indices + self.frozen_stages = frozen_stages + self.bn_eval = bn_eval + self.bn_frozen = bn_frozen + + self.inplanes = 3 + start_idx = 0 + vgg_layers = [] + self.range_sub_modules = [] + for i, num_blocks in enumerate(self.stage_blocks): + num_modules = num_blocks * (2 + with_bn) + 1 + end_idx = start_idx + num_modules + dilation = dilations[i] + planes = 64 * 2**i if i < 4 else 512 + vgg_layer = make_vgg_layer( + self.inplanes, + planes, + num_blocks, + dilation=dilation, + with_bn=with_bn, + ceil_mode=ceil_mode) + vgg_layers.extend(vgg_layer) + self.inplanes = planes + self.range_sub_modules.append([start_idx, end_idx]) + start_idx = end_idx + if not with_last_pool: + vgg_layers.pop(-1) + self.range_sub_modules[-1][1] -= 1 + self.module_name = 'features' + self.add_module(self.module_name, nn.Sequential(*vgg_layers)) + + if self.num_classes > 0: + self.classifier = nn.Sequential( + nn.Linear(512 * 7 * 7, 4096), + nn.ReLU(True), + nn.Dropout(), + nn.Linear(4096, 4096), + nn.ReLU(True), + nn.Dropout(), + nn.Linear(4096, num_classes), + ) + + def init_weights(self, pretrained=None): + if isinstance(pretrained, str): + logger = logging.getLogger() + from ..runner import load_checkpoint + load_checkpoint(self, pretrained, strict=False, logger=logger) + elif pretrained is None: + for m in self.modules(): + if isinstance(m, nn.Conv2d): + kaiming_init(m) + elif isinstance(m, nn.BatchNorm2d): + constant_init(m, 1) + elif isinstance(m, nn.Linear): + normal_init(m, std=0.01) + else: + raise TypeError('pretrained must be a str or None') + + def forward(self, x): + outs = [] + vgg_layers = getattr(self, self.module_name) + for i in range(len(self.stage_blocks)): + for j in range(*self.range_sub_modules[i]): + vgg_layer = vgg_layers[j] + x = vgg_layer(x) + if i in self.out_indices: + outs.append(x) + if self.num_classes > 0: + x = x.view(x.size(0), -1) + x = self.classifier(x) + outs.append(x) + if len(outs) == 1: + return outs[0] + else: + return tuple(outs) + + def train(self, mode=True): + super(VGG, self).train(mode) + if self.bn_eval: + for m in self.modules(): + if isinstance(m, nn.BatchNorm2d): + m.eval() + if self.bn_frozen: + for params in m.parameters(): + params.requires_grad = False + vgg_layers = getattr(self, self.module_name) + if mode and self.frozen_stages >= 0: + for i in range(self.frozen_stages): + for j in range(*self.range_sub_modules[i]): + mod = vgg_layers[j] + mod.eval() + for param in mod.parameters(): + param.requires_grad = False diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/engine/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/engine/__init__.py new file mode 100644 index 000000000..3193b7f66 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/engine/__init__.py @@ -0,0 +1,8 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .test import (collect_results_cpu, collect_results_gpu, multi_gpu_test, + single_gpu_test) + +__all__ = [ + 'collect_results_cpu', 'collect_results_gpu', 'multi_gpu_test', + 'single_gpu_test' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/engine/test.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/engine/test.py new file mode 100644 index 000000000..f236b1cda --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/engine/test.py @@ -0,0 +1,202 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import os.path as osp +import pickle +import shutil +import tempfile +import time + +import torch +import torch.distributed as dist + +import mmcv +from mmcv.runner import get_dist_info + + +def single_gpu_test(model, data_loader): + """Test model with a single gpu. + + This method tests model with a single gpu and displays test progress bar. + + Args: + model (nn.Module): Model to be tested. + data_loader (nn.Dataloader): Pytorch data loader. + + Returns: + list: The prediction results. + """ + model.eval() + results = [] + dataset = data_loader.dataset + prog_bar = mmcv.ProgressBar(len(dataset)) + for data in data_loader: + with torch.no_grad(): + result = model(return_loss=False, **data) + results.extend(result) + + # Assume result has the same length of batch_size + # refer to https://github.com/open-mmlab/mmcv/issues/985 + batch_size = len(result) + for _ in range(batch_size): + prog_bar.update() + return results + + +def multi_gpu_test(model, data_loader, tmpdir=None, gpu_collect=False): + """Test model with multiple gpus. + + This method tests model with multiple gpus and collects the results + under two different modes: gpu and cpu modes. By setting + ``gpu_collect=True``, it encodes results to gpu tensors and use gpu + communication for results collection. On cpu mode it saves the results on + different gpus to ``tmpdir`` and collects them by the rank 0 worker. + + Args: + model (nn.Module): Model to be tested. + data_loader (nn.Dataloader): Pytorch data loader. + tmpdir (str): Path of directory to save the temporary results from + different gpus under cpu mode. + gpu_collect (bool): Option to use either gpu or cpu to collect results. + + Returns: + list: The prediction results. + """ + model.eval() + results = [] + dataset = data_loader.dataset + rank, world_size = get_dist_info() + if rank == 0: + prog_bar = mmcv.ProgressBar(len(dataset)) + time.sleep(2) # This line can prevent deadlock problem in some cases. + for i, data in enumerate(data_loader): + with torch.no_grad(): + result = model(return_loss=False, **data) + results.extend(result) + + if rank == 0: + batch_size = len(result) + batch_size_all = batch_size * world_size + if batch_size_all + prog_bar.completed > len(dataset): + batch_size_all = len(dataset) - prog_bar.completed + for _ in range(batch_size_all): + prog_bar.update() + + # collect results from all ranks + if gpu_collect: + results = collect_results_gpu(results, len(dataset)) + else: + results = collect_results_cpu(results, len(dataset), tmpdir) + return results + + +def collect_results_cpu(result_part, size, tmpdir=None): + """Collect results under cpu mode. + + On cpu mode, this function will save the results on different gpus to + ``tmpdir`` and collect them by the rank 0 worker. + + Args: + result_part (list): Result list containing result parts + to be collected. + size (int): Size of the results, commonly equal to length of + the results. + tmpdir (str | None): temporal directory for collected results to + store. If set to None, it will create a random temporal directory + for it. + + Returns: + list: The collected results. + """ + rank, world_size = get_dist_info() + # create a tmp dir if it is not specified + if tmpdir is None: + MAX_LEN = 512 + # 32 is whitespace + dir_tensor = torch.full((MAX_LEN, ), + 32, + dtype=torch.uint8, + device='cuda') + if rank == 0: + mmcv.mkdir_or_exist('.dist_test') + tmpdir = tempfile.mkdtemp(dir='.dist_test') + tmpdir = torch.tensor( + bytearray(tmpdir.encode()), dtype=torch.uint8, device='cuda') + dir_tensor[:len(tmpdir)] = tmpdir + dist.broadcast(dir_tensor, 0) + tmpdir = dir_tensor.cpu().numpy().tobytes().decode().rstrip() + else: + mmcv.mkdir_or_exist(tmpdir) + # dump the part result to the dir + mmcv.dump(result_part, osp.join(tmpdir, f'part_{rank}.pkl')) + dist.barrier() + # collect all parts + if rank != 0: + return None + else: + # load results of all parts from tmp dir + part_list = [] + for i in range(world_size): + part_file = osp.join(tmpdir, f'part_{i}.pkl') + part_result = mmcv.load(part_file) + # When data is severely insufficient, an empty part_result + # on a certain gpu could makes the overall outputs empty. + if part_result: + part_list.append(part_result) + # sort the results + ordered_results = [] + for res in zip(*part_list): + ordered_results.extend(list(res)) + # the dataloader may pad some samples + ordered_results = ordered_results[:size] + # remove tmp dir + shutil.rmtree(tmpdir) + return ordered_results + + +def collect_results_gpu(result_part, size): + """Collect results under gpu mode. + + On gpu mode, this function will encode results to gpu tensors and use gpu + communication for results collection. + + Args: + result_part (list): Result list containing result parts + to be collected. + size (int): Size of the results, commonly equal to length of + the results. + + Returns: + list: The collected results. + """ + rank, world_size = get_dist_info() + # dump result part to tensor with pickle + part_tensor = torch.tensor( + bytearray(pickle.dumps(result_part)), dtype=torch.uint8, device='cuda') + # gather all result part tensor shape + shape_tensor = torch.tensor(part_tensor.shape, device='cuda') + shape_list = [shape_tensor.clone() for _ in range(world_size)] + dist.all_gather(shape_list, shape_tensor) + # padding result part tensor to max length + shape_max = torch.tensor(shape_list).max() + part_send = torch.zeros(shape_max, dtype=torch.uint8, device='cuda') + part_send[:shape_tensor[0]] = part_tensor + part_recv_list = [ + part_tensor.new_zeros(shape_max) for _ in range(world_size) + ] + # gather all result part + dist.all_gather(part_recv_list, part_send) + + if rank == 0: + part_list = [] + for recv, shape in zip(part_recv_list, shape_list): + part_result = pickle.loads(recv[:shape[0]].cpu().numpy().tobytes()) + # When data is severely insufficient, an empty part_result + # on a certain gpu could makes the overall outputs empty. + if part_result: + part_list.append(part_result) + # sort the results + ordered_results = [] + for res in zip(*part_list): + ordered_results.extend(list(res)) + # the dataloader may pad some samples + ordered_results = ordered_results[:size] + return ordered_results diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/__init__.py new file mode 100644 index 000000000..2051b85f7 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/__init__.py @@ -0,0 +1,11 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .file_client import BaseStorageBackend, FileClient +from .handlers import BaseFileHandler, JsonHandler, PickleHandler, YamlHandler +from .io import dump, load, register_handler +from .parse import dict_from_file, list_from_file + +__all__ = [ + 'BaseStorageBackend', 'FileClient', 'load', 'dump', 'register_handler', + 'BaseFileHandler', 'JsonHandler', 'PickleHandler', 'YamlHandler', + 'list_from_file', 'dict_from_file' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/file_client.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/file_client.py new file mode 100644 index 000000000..b2d622868 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/file_client.py @@ -0,0 +1,1148 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import inspect +import os +import os.path as osp +import re +import tempfile +import warnings +from abc import ABCMeta, abstractmethod +from contextlib import contextmanager +from pathlib import Path +from typing import Iterable, Iterator, Optional, Tuple, Union +from urllib.request import urlopen + +import mmcv +from mmcv.utils.misc import has_method +from mmcv.utils.path import is_filepath + + +class BaseStorageBackend(metaclass=ABCMeta): + """Abstract class of storage backends. + + All backends need to implement two apis: ``get()`` and ``get_text()``. + ``get()`` reads the file as a byte stream and ``get_text()`` reads the file + as texts. + """ + + # a flag to indicate whether the backend can create a symlink for a file + _allow_symlink = False + + @property + def name(self): + return self.__class__.__name__ + + @property + def allow_symlink(self): + return self._allow_symlink + + @abstractmethod + def get(self, filepath): + pass + + @abstractmethod + def get_text(self, filepath): + pass + + +class CephBackend(BaseStorageBackend): + """Ceph storage backend (for internal use). + + Args: + path_mapping (dict|None): path mapping dict from local path to Petrel + path. When ``path_mapping={'src': 'dst'}``, ``src`` in ``filepath`` + will be replaced by ``dst``. Default: None. + + .. warning:: + :class:`mmcv.fileio.file_client.CephBackend` will be deprecated, + please use :class:`mmcv.fileio.file_client.PetrelBackend` instead. + """ + + def __init__(self, path_mapping=None): + try: + import ceph + except ImportError: + raise ImportError('Please install ceph to enable CephBackend.') + + warnings.warn( + 'CephBackend will be deprecated, please use PetrelBackend instead') + self._client = ceph.S3Client() + assert isinstance(path_mapping, dict) or path_mapping is None + self.path_mapping = path_mapping + + def get(self, filepath): + filepath = str(filepath) + if self.path_mapping is not None: + for k, v in self.path_mapping.items(): + filepath = filepath.replace(k, v) + value = self._client.Get(filepath) + value_buf = memoryview(value) + return value_buf + + def get_text(self, filepath, encoding=None): + raise NotImplementedError + + +class PetrelBackend(BaseStorageBackend): + """Petrel storage backend (for internal use). + + PetrelBackend supports reading and writing data to multiple clusters. + If the file path contains the cluster name, PetrelBackend will read data + from specified cluster or write data to it. Otherwise, PetrelBackend will + access the default cluster. + + Args: + path_mapping (dict, optional): Path mapping dict from local path to + Petrel path. When ``path_mapping={'src': 'dst'}``, ``src`` in + ``filepath`` will be replaced by ``dst``. Default: None. + enable_mc (bool, optional): Whether to enable memcached support. + Default: True. + + Examples: + >>> filepath1 = 's3://path/of/file' + >>> filepath2 = 'cluster-name:s3://path/of/file' + >>> client = PetrelBackend() + >>> client.get(filepath1) # get data from default cluster + >>> client.get(filepath2) # get data from 'cluster-name' cluster + """ + + def __init__(self, + path_mapping: Optional[dict] = None, + enable_mc: bool = True): + try: + from petrel_client import client + except ImportError: + raise ImportError('Please install petrel_client to enable ' + 'PetrelBackend.') + + self._client = client.Client(enable_mc=enable_mc) + assert isinstance(path_mapping, dict) or path_mapping is None + self.path_mapping = path_mapping + + def _map_path(self, filepath: Union[str, Path]) -> str: + """Map ``filepath`` to a string path whose prefix will be replaced by + :attr:`self.path_mapping`. + + Args: + filepath (str): Path to be mapped. + """ + filepath = str(filepath) + if self.path_mapping is not None: + for k, v in self.path_mapping.items(): + filepath = filepath.replace(k, v) + return filepath + + def _format_path(self, filepath: str) -> str: + """Convert a ``filepath`` to standard format of petrel oss. + + If the ``filepath`` is concatenated by ``os.path.join``, in a Windows + environment, the ``filepath`` will be the format of + 's3://bucket_name\\image.jpg'. By invoking :meth:`_format_path`, the + above ``filepath`` will be converted to 's3://bucket_name/image.jpg'. + + Args: + filepath (str): Path to be formatted. + """ + return re.sub(r'\\+', '/', filepath) + + def get(self, filepath: Union[str, Path]) -> memoryview: + """Read data from a given ``filepath`` with 'rb' mode. + + Args: + filepath (str or Path): Path to read data. + + Returns: + memoryview: A memory view of expected bytes object to avoid + copying. The memoryview object can be converted to bytes by + ``value_buf.tobytes()``. + """ + filepath = self._map_path(filepath) + filepath = self._format_path(filepath) + value = self._client.Get(filepath) + value_buf = memoryview(value) + return value_buf + + def get_text(self, + filepath: Union[str, Path], + encoding: str = 'utf-8') -> str: + """Read data from a given ``filepath`` with 'r' mode. + + Args: + filepath (str or Path): Path to read data. + encoding (str): The encoding format used to open the ``filepath``. + Default: 'utf-8'. + + Returns: + str: Expected text reading from ``filepath``. + """ + return str(self.get(filepath), encoding=encoding) + + def put(self, obj: bytes, filepath: Union[str, Path]) -> None: + """Save data to a given ``filepath``. + + Args: + obj (bytes): Data to be saved. + filepath (str or Path): Path to write data. + """ + filepath = self._map_path(filepath) + filepath = self._format_path(filepath) + self._client.put(filepath, obj) + + def put_text(self, + obj: str, + filepath: Union[str, Path], + encoding: str = 'utf-8') -> None: + """Save data to a given ``filepath``. + + Args: + obj (str): Data to be written. + filepath (str or Path): Path to write data. + encoding (str): The encoding format used to encode the ``obj``. + Default: 'utf-8'. + """ + self.put(bytes(obj, encoding=encoding), filepath) + + def remove(self, filepath: Union[str, Path]) -> None: + """Remove a file. + + Args: + filepath (str or Path): Path to be removed. + """ + if not has_method(self._client, 'delete'): + raise NotImplementedError( + ('Current version of Petrel Python SDK has not supported ' + 'the `delete` method, please use a higher version or dev' + ' branch instead.')) + + filepath = self._map_path(filepath) + filepath = self._format_path(filepath) + self._client.delete(filepath) + + def exists(self, filepath: Union[str, Path]) -> bool: + """Check whether a file path exists. + + Args: + filepath (str or Path): Path to be checked whether exists. + + Returns: + bool: Return ``True`` if ``filepath`` exists, ``False`` otherwise. + """ + if not (has_method(self._client, 'contains') + and has_method(self._client, 'isdir')): + raise NotImplementedError( + ('Current version of Petrel Python SDK has not supported ' + 'the `contains` and `isdir` methods, please use a higher' + 'version or dev branch instead.')) + + filepath = self._map_path(filepath) + filepath = self._format_path(filepath) + return self._client.contains(filepath) or self._client.isdir(filepath) + + def isdir(self, filepath: Union[str, Path]) -> bool: + """Check whether a file path is a directory. + + Args: + filepath (str or Path): Path to be checked whether it is a + directory. + + Returns: + bool: Return ``True`` if ``filepath`` points to a directory, + ``False`` otherwise. + """ + if not has_method(self._client, 'isdir'): + raise NotImplementedError( + ('Current version of Petrel Python SDK has not supported ' + 'the `isdir` method, please use a higher version or dev' + ' branch instead.')) + + filepath = self._map_path(filepath) + filepath = self._format_path(filepath) + return self._client.isdir(filepath) + + def isfile(self, filepath: Union[str, Path]) -> bool: + """Check whether a file path is a file. + + Args: + filepath (str or Path): Path to be checked whether it is a file. + + Returns: + bool: Return ``True`` if ``filepath`` points to a file, ``False`` + otherwise. + """ + if not has_method(self._client, 'contains'): + raise NotImplementedError( + ('Current version of Petrel Python SDK has not supported ' + 'the `contains` method, please use a higher version or ' + 'dev branch instead.')) + + filepath = self._map_path(filepath) + filepath = self._format_path(filepath) + return self._client.contains(filepath) + + def join_path(self, filepath: Union[str, Path], + *filepaths: Union[str, Path]) -> str: + """Concatenate all file paths. + + Args: + filepath (str or Path): Path to be concatenated. + + Returns: + str: The result after concatenation. + """ + filepath = self._format_path(self._map_path(filepath)) + if filepath.endswith('/'): + filepath = filepath[:-1] + formatted_paths = [filepath] + for path in filepaths: + formatted_paths.append(self._format_path(self._map_path(path))) + return '/'.join(formatted_paths) + + @contextmanager + def get_local_path(self, filepath: Union[str, Path]) -> Iterable[str]: + """Download a file from ``filepath`` and return a temporary path. + + ``get_local_path`` is decorated by :meth:`contxtlib.contextmanager`. It + can be called with ``with`` statement, and when exists from the + ``with`` statement, the temporary path will be released. + + Args: + filepath (str | Path): Download a file from ``filepath``. + + Examples: + >>> client = PetrelBackend() + >>> # After existing from the ``with`` clause, + >>> # the path will be removed + >>> with client.get_local_path('s3://path/of/your/file') as path: + ... # do something here + + Yields: + Iterable[str]: Only yield one temporary path. + """ + filepath = self._map_path(filepath) + filepath = self._format_path(filepath) + assert self.isfile(filepath) + try: + f = tempfile.NamedTemporaryFile(delete=False) + f.write(self.get(filepath)) + f.close() + yield f.name + finally: + os.remove(f.name) + + def list_dir_or_file(self, + dir_path: Union[str, Path], + list_dir: bool = True, + list_file: bool = True, + suffix: Optional[Union[str, Tuple[str]]] = None, + recursive: bool = False) -> Iterator[str]: + """Scan a directory to find the interested directories or files in + arbitrary order. + + Note: + Petrel has no concept of directories but it simulates the directory + hierarchy in the filesystem through public prefixes. In addition, + if the returned path ends with '/', it means the path is a public + prefix which is a logical directory. + + Note: + :meth:`list_dir_or_file` returns the path relative to ``dir_path``. + In addition, the returned path of directory will not contains the + suffix '/' which is consistent with other backends. + + Args: + dir_path (str | Path): Path of the directory. + list_dir (bool): List the directories. Default: True. + list_file (bool): List the path of files. Default: True. + suffix (str or tuple[str], optional): File suffix + that we are interested in. Default: None. + recursive (bool): If set to True, recursively scan the + directory. Default: False. + + Yields: + Iterable[str]: A relative path to ``dir_path``. + """ + if not has_method(self._client, 'list'): + raise NotImplementedError( + ('Current version of Petrel Python SDK has not supported ' + 'the `list` method, please use a higher version or dev' + ' branch instead.')) + + dir_path = self._map_path(dir_path) + dir_path = self._format_path(dir_path) + if list_dir and suffix is not None: + raise TypeError( + '`list_dir` should be False when `suffix` is not None') + + if (suffix is not None) and not isinstance(suffix, (str, tuple)): + raise TypeError('`suffix` must be a string or tuple of strings') + + # Petrel's simulated directory hierarchy assumes that directory paths + # should end with `/` + if not dir_path.endswith('/'): + dir_path += '/' + + root = dir_path + + def _list_dir_or_file(dir_path, list_dir, list_file, suffix, + recursive): + for path in self._client.list(dir_path): + # the `self.isdir` is not used here to determine whether path + # is a directory, because `self.isdir` relies on + # `self._client.list` + if path.endswith('/'): # a directory path + next_dir_path = self.join_path(dir_path, path) + if list_dir: + # get the relative path and exclude the last + # character '/' + rel_dir = next_dir_path[len(root):-1] + yield rel_dir + if recursive: + yield from _list_dir_or_file(next_dir_path, list_dir, + list_file, suffix, + recursive) + else: # a file path + absolute_path = self.join_path(dir_path, path) + rel_path = absolute_path[len(root):] + if (suffix is None + or rel_path.endswith(suffix)) and list_file: + yield rel_path + + return _list_dir_or_file(dir_path, list_dir, list_file, suffix, + recursive) + + +class MemcachedBackend(BaseStorageBackend): + """Memcached storage backend. + + Attributes: + server_list_cfg (str): Config file for memcached server list. + client_cfg (str): Config file for memcached client. + sys_path (str | None): Additional path to be appended to `sys.path`. + Default: None. + """ + + def __init__(self, server_list_cfg, client_cfg, sys_path=None): + if sys_path is not None: + import sys + sys.path.append(sys_path) + try: + import mc + except ImportError: + raise ImportError( + 'Please install memcached to enable MemcachedBackend.') + + self.server_list_cfg = server_list_cfg + self.client_cfg = client_cfg + self._client = mc.MemcachedClient.GetInstance(self.server_list_cfg, + self.client_cfg) + # mc.pyvector servers as a point which points to a memory cache + self._mc_buffer = mc.pyvector() + + def get(self, filepath): + filepath = str(filepath) + import mc + self._client.Get(filepath, self._mc_buffer) + value_buf = mc.ConvertBuffer(self._mc_buffer) + return value_buf + + def get_text(self, filepath, encoding=None): + raise NotImplementedError + + +class LmdbBackend(BaseStorageBackend): + """Lmdb storage backend. + + Args: + db_path (str): Lmdb database path. + readonly (bool, optional): Lmdb environment parameter. If True, + disallow any write operations. Default: True. + lock (bool, optional): Lmdb environment parameter. If False, when + concurrent access occurs, do not lock the database. Default: False. + readahead (bool, optional): Lmdb environment parameter. If False, + disable the OS filesystem readahead mechanism, which may improve + random read performance when a database is larger than RAM. + Default: False. + + Attributes: + db_path (str): Lmdb database path. + """ + + def __init__(self, + db_path, + readonly=True, + lock=False, + readahead=False, + **kwargs): + try: + import lmdb + except ImportError: + raise ImportError('Please install lmdb to enable LmdbBackend.') + + self.db_path = str(db_path) + self._client = lmdb.open( + self.db_path, + readonly=readonly, + lock=lock, + readahead=readahead, + **kwargs) + + def get(self, filepath): + """Get values according to the filepath. + + Args: + filepath (str | obj:`Path`): Here, filepath is the lmdb key. + """ + filepath = str(filepath) + with self._client.begin(write=False) as txn: + value_buf = txn.get(filepath.encode('ascii')) + return value_buf + + def get_text(self, filepath, encoding=None): + raise NotImplementedError + + +class HardDiskBackend(BaseStorageBackend): + """Raw hard disks storage backend.""" + + _allow_symlink = True + + def get(self, filepath: Union[str, Path]) -> bytes: + """Read data from a given ``filepath`` with 'rb' mode. + + Args: + filepath (str or Path): Path to read data. + + Returns: + bytes: Expected bytes object. + """ + with open(filepath, 'rb') as f: + value_buf = f.read() + return value_buf + + def get_text(self, + filepath: Union[str, Path], + encoding: str = 'utf-8') -> str: + """Read data from a given ``filepath`` with 'r' mode. + + Args: + filepath (str or Path): Path to read data. + encoding (str): The encoding format used to open the ``filepath``. + Default: 'utf-8'. + + Returns: + str: Expected text reading from ``filepath``. + """ + with open(filepath, 'r', encoding=encoding) as f: + value_buf = f.read() + return value_buf + + def put(self, obj: bytes, filepath: Union[str, Path]) -> None: + """Write data to a given ``filepath`` with 'wb' mode. + + Note: + ``put`` will create a directory if the directory of ``filepath`` + does not exist. + + Args: + obj (bytes): Data to be written. + filepath (str or Path): Path to write data. + """ + mmcv.mkdir_or_exist(osp.dirname(filepath)) + with open(filepath, 'wb') as f: + f.write(obj) + + def put_text(self, + obj: str, + filepath: Union[str, Path], + encoding: str = 'utf-8') -> None: + """Write data to a given ``filepath`` with 'w' mode. + + Note: + ``put_text`` will create a directory if the directory of + ``filepath`` does not exist. + + Args: + obj (str): Data to be written. + filepath (str or Path): Path to write data. + encoding (str): The encoding format used to open the ``filepath``. + Default: 'utf-8'. + """ + mmcv.mkdir_or_exist(osp.dirname(filepath)) + with open(filepath, 'w', encoding=encoding) as f: + f.write(obj) + + def remove(self, filepath: Union[str, Path]) -> None: + """Remove a file. + + Args: + filepath (str or Path): Path to be removed. + """ + os.remove(filepath) + + def exists(self, filepath: Union[str, Path]) -> bool: + """Check whether a file path exists. + + Args: + filepath (str or Path): Path to be checked whether exists. + + Returns: + bool: Return ``True`` if ``filepath`` exists, ``False`` otherwise. + """ + return osp.exists(filepath) + + def isdir(self, filepath: Union[str, Path]) -> bool: + """Check whether a file path is a directory. + + Args: + filepath (str or Path): Path to be checked whether it is a + directory. + + Returns: + bool: Return ``True`` if ``filepath`` points to a directory, + ``False`` otherwise. + """ + return osp.isdir(filepath) + + def isfile(self, filepath: Union[str, Path]) -> bool: + """Check whether a file path is a file. + + Args: + filepath (str or Path): Path to be checked whether it is a file. + + Returns: + bool: Return ``True`` if ``filepath`` points to a file, ``False`` + otherwise. + """ + return osp.isfile(filepath) + + def join_path(self, filepath: Union[str, Path], + *filepaths: Union[str, Path]) -> str: + """Concatenate all file paths. + + Join one or more filepath components intelligently. The return value + is the concatenation of filepath and any members of *filepaths. + + Args: + filepath (str or Path): Path to be concatenated. + + Returns: + str: The result of concatenation. + """ + return osp.join(filepath, *filepaths) + + @contextmanager + def get_local_path( + self, filepath: Union[str, Path]) -> Iterable[Union[str, Path]]: + """Only for unified API and do nothing.""" + yield filepath + + def list_dir_or_file(self, + dir_path: Union[str, Path], + list_dir: bool = True, + list_file: bool = True, + suffix: Optional[Union[str, Tuple[str]]] = None, + recursive: bool = False) -> Iterator[str]: + """Scan a directory to find the interested directories or files in + arbitrary order. + + Note: + :meth:`list_dir_or_file` returns the path relative to ``dir_path``. + + Args: + dir_path (str | Path): Path of the directory. + list_dir (bool): List the directories. Default: True. + list_file (bool): List the path of files. Default: True. + suffix (str or tuple[str], optional): File suffix + that we are interested in. Default: None. + recursive (bool): If set to True, recursively scan the + directory. Default: False. + + Yields: + Iterable[str]: A relative path to ``dir_path``. + """ + if list_dir and suffix is not None: + raise TypeError('`suffix` should be None when `list_dir` is True') + + if (suffix is not None) and not isinstance(suffix, (str, tuple)): + raise TypeError('`suffix` must be a string or tuple of strings') + + root = dir_path + + def _list_dir_or_file(dir_path, list_dir, list_file, suffix, + recursive): + for entry in os.scandir(dir_path): + if not entry.name.startswith('.') and entry.is_file(): + rel_path = osp.relpath(entry.path, root) + if (suffix is None + or rel_path.endswith(suffix)) and list_file: + yield rel_path + elif osp.isdir(entry.path): + if list_dir: + rel_dir = osp.relpath(entry.path, root) + yield rel_dir + if recursive: + yield from _list_dir_or_file(entry.path, list_dir, + list_file, suffix, + recursive) + + return _list_dir_or_file(dir_path, list_dir, list_file, suffix, + recursive) + + +class HTTPBackend(BaseStorageBackend): + """HTTP and HTTPS storage bachend.""" + + def get(self, filepath): + value_buf = urlopen(filepath).read() + return value_buf + + def get_text(self, filepath, encoding='utf-8'): + value_buf = urlopen(filepath).read() + return value_buf.decode(encoding) + + @contextmanager + def get_local_path(self, filepath: str) -> Iterable[str]: + """Download a file from ``filepath``. + + ``get_local_path`` is decorated by :meth:`contxtlib.contextmanager`. It + can be called with ``with`` statement, and when exists from the + ``with`` statement, the temporary path will be released. + + Args: + filepath (str): Download a file from ``filepath``. + + Examples: + >>> client = HTTPBackend() + >>> # After existing from the ``with`` clause, + >>> # the path will be removed + >>> with client.get_local_path('http://path/of/your/file') as path: + ... # do something here + """ + try: + f = tempfile.NamedTemporaryFile(delete=False) + f.write(self.get(filepath)) + f.close() + yield f.name + finally: + os.remove(f.name) + + +class FileClient: + """A general file client to access files in different backends. + + The client loads a file or text in a specified backend from its path + and returns it as a binary or text file. There are two ways to choose a + backend, the name of backend and the prefix of path. Although both of them + can be used to choose a storage backend, ``backend`` has a higher priority + that is if they are all set, the storage backend will be chosen by the + backend argument. If they are all `None`, the disk backend will be chosen. + Note that It can also register other backend accessor with a given name, + prefixes, and backend class. In addition, We use the singleton pattern to + avoid repeated object creation. If the arguments are the same, the same + object will be returned. + + Args: + backend (str, optional): The storage backend type. Options are "disk", + "ceph", "memcached", "lmdb", "http" and "petrel". Default: None. + prefix (str, optional): The prefix of the registered storage backend. + Options are "s3", "http", "https". Default: None. + + Examples: + >>> # only set backend + >>> file_client = FileClient(backend='petrel') + >>> # only set prefix + >>> file_client = FileClient(prefix='s3') + >>> # set both backend and prefix but use backend to choose client + >>> file_client = FileClient(backend='petrel', prefix='s3') + >>> # if the arguments are the same, the same object is returned + >>> file_client1 = FileClient(backend='petrel') + >>> file_client1 is file_client + True + + Attributes: + client (:obj:`BaseStorageBackend`): The backend object. + """ + + _backends = { + 'disk': HardDiskBackend, + 'ceph': CephBackend, + 'memcached': MemcachedBackend, + 'lmdb': LmdbBackend, + 'petrel': PetrelBackend, + 'http': HTTPBackend, + } + # This collection is used to record the overridden backends, and when a + # backend appears in the collection, the singleton pattern is disabled for + # that backend, because if the singleton pattern is used, then the object + # returned will be the backend before overwriting + _overridden_backends = set() + _prefix_to_backends = { + 's3': PetrelBackend, + 'http': HTTPBackend, + 'https': HTTPBackend, + } + _overridden_prefixes = set() + + _instances = {} + + def __new__(cls, backend=None, prefix=None, **kwargs): + if backend is None and prefix is None: + backend = 'disk' + if backend is not None and backend not in cls._backends: + raise ValueError( + f'Backend {backend} is not supported. Currently supported ones' + f' are {list(cls._backends.keys())}') + if prefix is not None and prefix not in cls._prefix_to_backends: + raise ValueError( + f'prefix {prefix} is not supported. Currently supported ones ' + f'are {list(cls._prefix_to_backends.keys())}') + + # concatenate the arguments to a unique key for determining whether + # objects with the same arguments were created + arg_key = f'{backend}:{prefix}' + for key, value in kwargs.items(): + arg_key += f':{key}:{value}' + + # if a backend was overridden, it will create a new object + if (arg_key in cls._instances + and backend not in cls._overridden_backends + and prefix not in cls._overridden_prefixes): + _instance = cls._instances[arg_key] + else: + # create a new object and put it to _instance + _instance = super().__new__(cls) + if backend is not None: + _instance.client = cls._backends[backend](**kwargs) + else: + _instance.client = cls._prefix_to_backends[prefix](**kwargs) + + cls._instances[arg_key] = _instance + + return _instance + + @property + def name(self): + return self.client.name + + @property + def allow_symlink(self): + return self.client.allow_symlink + + @staticmethod + def parse_uri_prefix(uri: Union[str, Path]) -> Optional[str]: + """Parse the prefix of a uri. + + Args: + uri (str | Path): Uri to be parsed that contains the file prefix. + + Examples: + >>> FileClient.parse_uri_prefix('s3://path/of/your/file') + 's3' + + Returns: + str | None: Return the prefix of uri if the uri contains '://' + else ``None``. + """ + assert is_filepath(uri) + uri = str(uri) + if '://' not in uri: + return None + else: + prefix, _ = uri.split('://') + # In the case of PetrelBackend, the prefix may contains the cluster + # name like clusterName:s3 + if ':' in prefix: + _, prefix = prefix.split(':') + return prefix + + @classmethod + def infer_client(cls, + file_client_args: Optional[dict] = None, + uri: Optional[Union[str, Path]] = None) -> 'FileClient': + """Infer a suitable file client based on the URI and arguments. + + Args: + file_client_args (dict, optional): Arguments to instantiate a + FileClient. Default: None. + uri (str | Path, optional): Uri to be parsed that contains the file + prefix. Default: None. + + Examples: + >>> uri = 's3://path/of/your/file' + >>> file_client = FileClient.infer_client(uri=uri) + >>> file_client_args = {'backend': 'petrel'} + >>> file_client = FileClient.infer_client(file_client_args) + + Returns: + FileClient: Instantiated FileClient object. + """ + assert file_client_args is not None or uri is not None + if file_client_args is None: + file_prefix = cls.parse_uri_prefix(uri) # type: ignore + return cls(prefix=file_prefix) + else: + return cls(**file_client_args) + + @classmethod + def _register_backend(cls, name, backend, force=False, prefixes=None): + if not isinstance(name, str): + raise TypeError('the backend name should be a string, ' + f'but got {type(name)}') + if not inspect.isclass(backend): + raise TypeError( + f'backend should be a class but got {type(backend)}') + if not issubclass(backend, BaseStorageBackend): + raise TypeError( + f'backend {backend} is not a subclass of BaseStorageBackend') + if not force and name in cls._backends: + raise KeyError( + f'{name} is already registered as a storage backend, ' + 'add "force=True" if you want to override it') + + if name in cls._backends and force: + cls._overridden_backends.add(name) + cls._backends[name] = backend + + if prefixes is not None: + if isinstance(prefixes, str): + prefixes = [prefixes] + else: + assert isinstance(prefixes, (list, tuple)) + for prefix in prefixes: + if prefix not in cls._prefix_to_backends: + cls._prefix_to_backends[prefix] = backend + elif (prefix in cls._prefix_to_backends) and force: + cls._overridden_prefixes.add(prefix) + cls._prefix_to_backends[prefix] = backend + else: + raise KeyError( + f'{prefix} is already registered as a storage backend,' + ' add "force=True" if you want to override it') + + @classmethod + def register_backend(cls, name, backend=None, force=False, prefixes=None): + """Register a backend to FileClient. + + This method can be used as a normal class method or a decorator. + + .. code-block:: python + + class NewBackend(BaseStorageBackend): + + def get(self, filepath): + return filepath + + def get_text(self, filepath): + return filepath + + FileClient.register_backend('new', NewBackend) + + or + + .. code-block:: python + + @FileClient.register_backend('new') + class NewBackend(BaseStorageBackend): + + def get(self, filepath): + return filepath + + def get_text(self, filepath): + return filepath + + Args: + name (str): The name of the registered backend. + backend (class, optional): The backend class to be registered, + which must be a subclass of :class:`BaseStorageBackend`. + When this method is used as a decorator, backend is None. + Defaults to None. + force (bool, optional): Whether to override the backend if the name + has already been registered. Defaults to False. + prefixes (str or list[str] or tuple[str], optional): The prefixes + of the registered storage backend. Default: None. + `New in version 1.3.15.` + """ + if backend is not None: + cls._register_backend( + name, backend, force=force, prefixes=prefixes) + return + + def _register(backend_cls): + cls._register_backend( + name, backend_cls, force=force, prefixes=prefixes) + return backend_cls + + return _register + + def get(self, filepath: Union[str, Path]) -> Union[bytes, memoryview]: + """Read data from a given ``filepath`` with 'rb' mode. + + Note: + There are two types of return values for ``get``, one is ``bytes`` + and the other is ``memoryview``. The advantage of using memoryview + is that you can avoid copying, and if you want to convert it to + ``bytes``, you can use ``.tobytes()``. + + Args: + filepath (str or Path): Path to read data. + + Returns: + bytes | memoryview: Expected bytes object or a memory view of the + bytes object. + """ + return self.client.get(filepath) + + def get_text(self, filepath: Union[str, Path], encoding='utf-8') -> str: + """Read data from a given ``filepath`` with 'r' mode. + + Args: + filepath (str or Path): Path to read data. + encoding (str): The encoding format used to open the ``filepath``. + Default: 'utf-8'. + + Returns: + str: Expected text reading from ``filepath``. + """ + return self.client.get_text(filepath, encoding) + + def put(self, obj: bytes, filepath: Union[str, Path]) -> None: + """Write data to a given ``filepath`` with 'wb' mode. + + Note: + ``put`` should create a directory if the directory of ``filepath`` + does not exist. + + Args: + obj (bytes): Data to be written. + filepath (str or Path): Path to write data. + """ + self.client.put(obj, filepath) + + def put_text(self, obj: str, filepath: Union[str, Path]) -> None: + """Write data to a given ``filepath`` with 'w' mode. + + Note: + ``put_text`` should create a directory if the directory of + ``filepath`` does not exist. + + Args: + obj (str): Data to be written. + filepath (str or Path): Path to write data. + encoding (str, optional): The encoding format used to open the + `filepath`. Default: 'utf-8'. + """ + self.client.put_text(obj, filepath) + + def remove(self, filepath: Union[str, Path]) -> None: + """Remove a file. + + Args: + filepath (str, Path): Path to be removed. + """ + self.client.remove(filepath) + + def exists(self, filepath: Union[str, Path]) -> bool: + """Check whether a file path exists. + + Args: + filepath (str or Path): Path to be checked whether exists. + + Returns: + bool: Return ``True`` if ``filepath`` exists, ``False`` otherwise. + """ + return self.client.exists(filepath) + + def isdir(self, filepath: Union[str, Path]) -> bool: + """Check whether a file path is a directory. + + Args: + filepath (str or Path): Path to be checked whether it is a + directory. + + Returns: + bool: Return ``True`` if ``filepath`` points to a directory, + ``False`` otherwise. + """ + return self.client.isdir(filepath) + + def isfile(self, filepath: Union[str, Path]) -> bool: + """Check whether a file path is a file. + + Args: + filepath (str or Path): Path to be checked whether it is a file. + + Returns: + bool: Return ``True`` if ``filepath`` points to a file, ``False`` + otherwise. + """ + return self.client.isfile(filepath) + + def join_path(self, filepath: Union[str, Path], + *filepaths: Union[str, Path]) -> str: + """Concatenate all file paths. + + Join one or more filepath components intelligently. The return value + is the concatenation of filepath and any members of *filepaths. + + Args: + filepath (str or Path): Path to be concatenated. + + Returns: + str: The result of concatenation. + """ + return self.client.join_path(filepath, *filepaths) + + @contextmanager + def get_local_path(self, filepath: Union[str, Path]) -> Iterable[str]: + """Download data from ``filepath`` and write the data to local path. + + ``get_local_path`` is decorated by :meth:`contxtlib.contextmanager`. It + can be called with ``with`` statement, and when exists from the + ``with`` statement, the temporary path will be released. + + Note: + If the ``filepath`` is a local path, just return itself. + + .. warning:: + ``get_local_path`` is an experimental interface that may change in + the future. + + Args: + filepath (str or Path): Path to be read data. + + Examples: + >>> file_client = FileClient(prefix='s3') + >>> with file_client.get_local_path('s3://bucket/abc.jpg') as path: + ... # do something here + + Yields: + Iterable[str]: Only yield one path. + """ + with self.client.get_local_path(str(filepath)) as local_path: + yield local_path + + def list_dir_or_file(self, + dir_path: Union[str, Path], + list_dir: bool = True, + list_file: bool = True, + suffix: Optional[Union[str, Tuple[str]]] = None, + recursive: bool = False) -> Iterator[str]: + """Scan a directory to find the interested directories or files in + arbitrary order. + + Note: + :meth:`list_dir_or_file` returns the path relative to ``dir_path``. + + Args: + dir_path (str | Path): Path of the directory. + list_dir (bool): List the directories. Default: True. + list_file (bool): List the path of files. Default: True. + suffix (str or tuple[str], optional): File suffix + that we are interested in. Default: None. + recursive (bool): If set to True, recursively scan the + directory. Default: False. + + Yields: + Iterable[str]: A relative path to ``dir_path``. + """ + yield from self.client.list_dir_or_file(dir_path, list_dir, list_file, + suffix, recursive) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/__init__.py new file mode 100644 index 000000000..aa24d9197 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/__init__.py @@ -0,0 +1,7 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .base import BaseFileHandler +from .json_handler import JsonHandler +from .pickle_handler import PickleHandler +from .yaml_handler import YamlHandler + +__all__ = ['BaseFileHandler', 'JsonHandler', 'PickleHandler', 'YamlHandler'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/base.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/base.py new file mode 100644 index 000000000..288878bc5 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/base.py @@ -0,0 +1,30 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from abc import ABCMeta, abstractmethod + + +class BaseFileHandler(metaclass=ABCMeta): + # `str_like` is a flag to indicate whether the type of file object is + # str-like object or bytes-like object. Pickle only processes bytes-like + # objects but json only processes str-like object. If it is str-like + # object, `StringIO` will be used to process the buffer. + str_like = True + + @abstractmethod + def load_from_fileobj(self, file, **kwargs): + pass + + @abstractmethod + def dump_to_fileobj(self, obj, file, **kwargs): + pass + + @abstractmethod + def dump_to_str(self, obj, **kwargs): + pass + + def load_from_path(self, filepath, mode='r', **kwargs): + with open(filepath, mode) as f: + return self.load_from_fileobj(f, **kwargs) + + def dump_to_path(self, obj, filepath, mode='w', **kwargs): + with open(filepath, mode) as f: + self.dump_to_fileobj(obj, f, **kwargs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/json_handler.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/json_handler.py new file mode 100644 index 000000000..18d4f15f7 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/json_handler.py @@ -0,0 +1,36 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import json + +import numpy as np + +from .base import BaseFileHandler + + +def set_default(obj): + """Set default json values for non-serializable values. + + It helps convert ``set``, ``range`` and ``np.ndarray`` data types to list. + It also converts ``np.generic`` (including ``np.int32``, ``np.float32``, + etc.) into plain numbers of plain python built-in types. + """ + if isinstance(obj, (set, range)): + return list(obj) + elif isinstance(obj, np.ndarray): + return obj.tolist() + elif isinstance(obj, np.generic): + return obj.item() + raise TypeError(f'{type(obj)} is unsupported for json dump') + + +class JsonHandler(BaseFileHandler): + + def load_from_fileobj(self, file): + return json.load(file) + + def dump_to_fileobj(self, obj, file, **kwargs): + kwargs.setdefault('default', set_default) + json.dump(obj, file, **kwargs) + + def dump_to_str(self, obj, **kwargs): + kwargs.setdefault('default', set_default) + return json.dumps(obj, **kwargs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/pickle_handler.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/pickle_handler.py new file mode 100644 index 000000000..b37c79bed --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/pickle_handler.py @@ -0,0 +1,28 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import pickle + +from .base import BaseFileHandler + + +class PickleHandler(BaseFileHandler): + + str_like = False + + def load_from_fileobj(self, file, **kwargs): + return pickle.load(file, **kwargs) + + def load_from_path(self, filepath, **kwargs): + return super(PickleHandler, self).load_from_path( + filepath, mode='rb', **kwargs) + + def dump_to_str(self, obj, **kwargs): + kwargs.setdefault('protocol', 2) + return pickle.dumps(obj, **kwargs) + + def dump_to_fileobj(self, obj, file, **kwargs): + kwargs.setdefault('protocol', 2) + pickle.dump(obj, file, **kwargs) + + def dump_to_path(self, obj, filepath, **kwargs): + super(PickleHandler, self).dump_to_path( + obj, filepath, mode='wb', **kwargs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/yaml_handler.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/yaml_handler.py new file mode 100644 index 000000000..c5aa2eea1 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/handlers/yaml_handler.py @@ -0,0 +1,24 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import yaml + +try: + from yaml import CLoader as Loader, CDumper as Dumper +except ImportError: + from yaml import Loader, Dumper + +from .base import BaseFileHandler # isort:skip + + +class YamlHandler(BaseFileHandler): + + def load_from_fileobj(self, file, **kwargs): + kwargs.setdefault('Loader', Loader) + return yaml.load(file, **kwargs) + + def dump_to_fileobj(self, obj, file, **kwargs): + kwargs.setdefault('Dumper', Dumper) + yaml.dump(obj, file, **kwargs) + + def dump_to_str(self, obj, **kwargs): + kwargs.setdefault('Dumper', Dumper) + return yaml.dump(obj, **kwargs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/io.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/io.py new file mode 100644 index 000000000..aaefde58a --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/io.py @@ -0,0 +1,151 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from io import BytesIO, StringIO +from pathlib import Path + +from ..utils import is_list_of, is_str +from .file_client import FileClient +from .handlers import BaseFileHandler, JsonHandler, PickleHandler, YamlHandler + +file_handlers = { + 'json': JsonHandler(), + 'yaml': YamlHandler(), + 'yml': YamlHandler(), + 'pickle': PickleHandler(), + 'pkl': PickleHandler() +} + + +def load(file, file_format=None, file_client_args=None, **kwargs): + """Load data from json/yaml/pickle files. + + This method provides a unified api for loading data from serialized files. + + Note: + In v1.3.16 and later, ``load`` supports loading data from serialized + files those can be storaged in different backends. + + Args: + file (str or :obj:`Path` or file-like object): Filename or a file-like + object. + file_format (str, optional): If not specified, the file format will be + inferred from the file extension, otherwise use the specified one. + Currently supported formats include "json", "yaml/yml" and + "pickle/pkl". + file_client_args (dict, optional): Arguments to instantiate a + FileClient. See :class:`mmcv.fileio.FileClient` for details. + Default: None. + + Examples: + >>> load('/path/of/your/file') # file is storaged in disk + >>> load('https://path/of/your/file') # file is storaged in Internet + >>> load('s3://path/of/your/file') # file is storaged in petrel + + Returns: + The content from the file. + """ + if isinstance(file, Path): + file = str(file) + if file_format is None and is_str(file): + file_format = file.split('.')[-1] + if file_format not in file_handlers: + raise TypeError(f'Unsupported format: {file_format}') + + handler = file_handlers[file_format] + if is_str(file): + file_client = FileClient.infer_client(file_client_args, file) + if handler.str_like: + with StringIO(file_client.get_text(file)) as f: + obj = handler.load_from_fileobj(f, **kwargs) + else: + with BytesIO(file_client.get(file)) as f: + obj = handler.load_from_fileobj(f, **kwargs) + elif hasattr(file, 'read'): + obj = handler.load_from_fileobj(file, **kwargs) + else: + raise TypeError('"file" must be a filepath str or a file-object') + return obj + + +def dump(obj, file=None, file_format=None, file_client_args=None, **kwargs): + """Dump data to json/yaml/pickle strings or files. + + This method provides a unified api for dumping data as strings or to files, + and also supports custom arguments for each file format. + + Note: + In v1.3.16 and later, ``dump`` supports dumping data as strings or to + files which is saved to different backends. + + Args: + obj (any): The python object to be dumped. + file (str or :obj:`Path` or file-like object, optional): If not + specified, then the object is dumped to a str, otherwise to a file + specified by the filename or file-like object. + file_format (str, optional): Same as :func:`load`. + file_client_args (dict, optional): Arguments to instantiate a + FileClient. See :class:`mmcv.fileio.FileClient` for details. + Default: None. + + Examples: + >>> dump('hello world', '/path/of/your/file') # disk + >>> dump('hello world', 's3://path/of/your/file') # ceph or petrel + + Returns: + bool: True for success, False otherwise. + """ + if isinstance(file, Path): + file = str(file) + if file_format is None: + if is_str(file): + file_format = file.split('.')[-1] + elif file is None: + raise ValueError( + 'file_format must be specified since file is None') + if file_format not in file_handlers: + raise TypeError(f'Unsupported format: {file_format}') + + handler = file_handlers[file_format] + if file is None: + return handler.dump_to_str(obj, **kwargs) + elif is_str(file): + file_client = FileClient.infer_client(file_client_args, file) + if handler.str_like: + with StringIO() as f: + handler.dump_to_fileobj(obj, f, **kwargs) + file_client.put_text(f.getvalue(), file) + else: + with BytesIO() as f: + handler.dump_to_fileobj(obj, f, **kwargs) + file_client.put(f.getvalue(), file) + elif hasattr(file, 'write'): + handler.dump_to_fileobj(obj, file, **kwargs) + else: + raise TypeError('"file" must be a filename str or a file-object') + + +def _register_handler(handler, file_formats): + """Register a handler for some file extensions. + + Args: + handler (:obj:`BaseFileHandler`): Handler to be registered. + file_formats (str or list[str]): File formats to be handled by this + handler. + """ + if not isinstance(handler, BaseFileHandler): + raise TypeError( + f'handler must be a child of BaseFileHandler, not {type(handler)}') + if isinstance(file_formats, str): + file_formats = [file_formats] + if not is_list_of(file_formats, str): + raise TypeError('file_formats must be a str or a list of str') + for ext in file_formats: + file_handlers[ext] = handler + + +def register_handler(file_formats, **kwargs): + + def wrap(cls): + _register_handler(cls(**kwargs), file_formats) + return cls + + return wrap diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/parse.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/parse.py new file mode 100644 index 000000000..f60f0d611 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/fileio/parse.py @@ -0,0 +1,97 @@ +# Copyright (c) OpenMMLab. All rights reserved. + +from io import StringIO + +from .file_client import FileClient + + +def list_from_file(filename, + prefix='', + offset=0, + max_num=0, + encoding='utf-8', + file_client_args=None): + """Load a text file and parse the content as a list of strings. + + Note: + In v1.3.16 and later, ``list_from_file`` supports loading a text file + which can be storaged in different backends and parsing the content as + a list for strings. + + Args: + filename (str): Filename. + prefix (str): The prefix to be inserted to the beginning of each item. + offset (int): The offset of lines. + max_num (int): The maximum number of lines to be read, + zeros and negatives mean no limitation. + encoding (str): Encoding used to open the file. Default utf-8. + file_client_args (dict, optional): Arguments to instantiate a + FileClient. See :class:`mmcv.fileio.FileClient` for details. + Default: None. + + Examples: + >>> list_from_file('/path/of/your/file') # disk + ['hello', 'world'] + >>> list_from_file('s3://path/of/your/file') # ceph or petrel + ['hello', 'world'] + + Returns: + list[str]: A list of strings. + """ + cnt = 0 + item_list = [] + file_client = FileClient.infer_client(file_client_args, filename) + with StringIO(file_client.get_text(filename, encoding)) as f: + for _ in range(offset): + f.readline() + for line in f: + if 0 < max_num <= cnt: + break + item_list.append(prefix + line.rstrip('\n\r')) + cnt += 1 + return item_list + + +def dict_from_file(filename, + key_type=str, + encoding='utf-8', + file_client_args=None): + """Load a text file and parse the content as a dict. + + Each line of the text file will be two or more columns split by + whitespaces or tabs. The first column will be parsed as dict keys, and + the following columns will be parsed as dict values. + + Note: + In v1.3.16 and later, ``dict_from_file`` supports loading a text file + which can be storaged in different backends and parsing the content as + a dict. + + Args: + filename(str): Filename. + key_type(type): Type of the dict keys. str is user by default and + type conversion will be performed if specified. + encoding (str): Encoding used to open the file. Default utf-8. + file_client_args (dict, optional): Arguments to instantiate a + FileClient. See :class:`mmcv.fileio.FileClient` for details. + Default: None. + + Examples: + >>> dict_from_file('/path/of/your/file') # disk + {'key1': 'value1', 'key2': 'value2'} + >>> dict_from_file('s3://path/of/your/file') # ceph or petrel + {'key1': 'value1', 'key2': 'value2'} + + Returns: + dict: The parsed contents. + """ + mapping = {} + file_client = FileClient.infer_client(file_client_args, filename) + with StringIO(file_client.get_text(filename, encoding)) as f: + for line in f: + items = line.rstrip('\n').split() + assert len(items) >= 2 + key = key_type(items[0]) + val = items[1:] if len(items) > 2 else items[1] + mapping[key] = val + return mapping diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/image/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/image/__init__.py new file mode 100644 index 000000000..d0051d609 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/image/__init__.py @@ -0,0 +1,28 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .colorspace import (bgr2gray, bgr2hls, bgr2hsv, bgr2rgb, bgr2ycbcr, + gray2bgr, gray2rgb, hls2bgr, hsv2bgr, imconvert, + rgb2bgr, rgb2gray, rgb2ycbcr, ycbcr2bgr, ycbcr2rgb) +from .geometric import (cutout, imcrop, imflip, imflip_, impad, + impad_to_multiple, imrescale, imresize, imresize_like, + imresize_to_multiple, imrotate, imshear, imtranslate, + rescale_size) +from .io import imfrombytes, imread, imwrite, supported_backends, use_backend +from .misc import tensor2imgs +from .photometric import (adjust_brightness, adjust_color, adjust_contrast, + adjust_lighting, adjust_sharpness, auto_contrast, + clahe, imdenormalize, imequalize, iminvert, + imnormalize, imnormalize_, lut_transform, posterize, + solarize) + +__all__ = [ + 'bgr2gray', 'bgr2hls', 'bgr2hsv', 'bgr2rgb', 'gray2bgr', 'gray2rgb', + 'hls2bgr', 'hsv2bgr', 'imconvert', 'rgb2bgr', 'rgb2gray', 'imrescale', + 'imresize', 'imresize_like', 'imresize_to_multiple', 'rescale_size', + 'imcrop', 'imflip', 'imflip_', 'impad', 'impad_to_multiple', 'imrotate', + 'imfrombytes', 'imread', 'imwrite', 'supported_backends', 'use_backend', + 'imdenormalize', 'imnormalize', 'imnormalize_', 'iminvert', 'posterize', + 'solarize', 'rgb2ycbcr', 'bgr2ycbcr', 'ycbcr2rgb', 'ycbcr2bgr', + 'tensor2imgs', 'imshear', 'imtranslate', 'adjust_color', 'imequalize', + 'adjust_brightness', 'adjust_contrast', 'lut_transform', 'clahe', + 'adjust_sharpness', 'auto_contrast', 'cutout', 'adjust_lighting' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/image/colorspace.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/image/colorspace.py new file mode 100644 index 000000000..814533952 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/image/colorspace.py @@ -0,0 +1,306 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import cv2 +import numpy as np + + +def imconvert(img, src, dst): + """Convert an image from the src colorspace to dst colorspace. + + Args: + img (ndarray): The input image. + src (str): The source colorspace, e.g., 'rgb', 'hsv'. + dst (str): The destination colorspace, e.g., 'rgb', 'hsv'. + + Returns: + ndarray: The converted image. + """ + code = getattr(cv2, f'COLOR_{src.upper()}2{dst.upper()}') + out_img = cv2.cvtColor(img, code) + return out_img + + +def bgr2gray(img, keepdim=False): + """Convert a BGR image to grayscale image. + + Args: + img (ndarray): The input image. + keepdim (bool): If False (by default), then return the grayscale image + with 2 dims, otherwise 3 dims. + + Returns: + ndarray: The converted grayscale image. + """ + out_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) + if keepdim: + out_img = out_img[..., None] + return out_img + + +def rgb2gray(img, keepdim=False): + """Convert a RGB image to grayscale image. + + Args: + img (ndarray): The input image. + keepdim (bool): If False (by default), then return the grayscale image + with 2 dims, otherwise 3 dims. + + Returns: + ndarray: The converted grayscale image. + """ + out_img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) + if keepdim: + out_img = out_img[..., None] + return out_img + + +def gray2bgr(img): + """Convert a grayscale image to BGR image. + + Args: + img (ndarray): The input image. + + Returns: + ndarray: The converted BGR image. + """ + img = img[..., None] if img.ndim == 2 else img + out_img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) + return out_img + + +def gray2rgb(img): + """Convert a grayscale image to RGB image. + + Args: + img (ndarray): The input image. + + Returns: + ndarray: The converted RGB image. + """ + img = img[..., None] if img.ndim == 2 else img + out_img = cv2.cvtColor(img, cv2.COLOR_GRAY2RGB) + return out_img + + +def _convert_input_type_range(img): + """Convert the type and range of the input image. + + It converts the input image to np.float32 type and range of [0, 1]. + It is mainly used for pre-processing the input image in colorspace + conversion functions such as rgb2ycbcr and ycbcr2rgb. + + Args: + img (ndarray): The input image. It accepts: + 1. np.uint8 type with range [0, 255]; + 2. np.float32 type with range [0, 1]. + + Returns: + (ndarray): The converted image with type of np.float32 and range of + [0, 1]. + """ + img_type = img.dtype + img = img.astype(np.float32) + if img_type == np.float32: + pass + elif img_type == np.uint8: + img /= 255. + else: + raise TypeError('The img type should be np.float32 or np.uint8, ' + f'but got {img_type}') + return img + + +def _convert_output_type_range(img, dst_type): + """Convert the type and range of the image according to dst_type. + + It converts the image to desired type and range. If `dst_type` is np.uint8, + images will be converted to np.uint8 type with range [0, 255]. If + `dst_type` is np.float32, it converts the image to np.float32 type with + range [0, 1]. + It is mainly used for post-processing images in colorspace conversion + functions such as rgb2ycbcr and ycbcr2rgb. + + Args: + img (ndarray): The image to be converted with np.float32 type and + range [0, 255]. + dst_type (np.uint8 | np.float32): If dst_type is np.uint8, it + converts the image to np.uint8 type with range [0, 255]. If + dst_type is np.float32, it converts the image to np.float32 type + with range [0, 1]. + + Returns: + (ndarray): The converted image with desired type and range. + """ + if dst_type not in (np.uint8, np.float32): + raise TypeError('The dst_type should be np.float32 or np.uint8, ' + f'but got {dst_type}') + if dst_type == np.uint8: + img = img.round() + else: + img /= 255. + return img.astype(dst_type) + + +def rgb2ycbcr(img, y_only=False): + """Convert a RGB image to YCbCr image. + + This function produces the same results as Matlab's `rgb2ycbcr` function. + It implements the ITU-R BT.601 conversion for standard-definition + television. See more details in + https://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.601_conversion. + + It differs from a similar function in cv2.cvtColor: `RGB <-> YCrCb`. + In OpenCV, it implements a JPEG conversion. See more details in + https://en.wikipedia.org/wiki/YCbCr#JPEG_conversion. + + Args: + img (ndarray): The input image. It accepts: + 1. np.uint8 type with range [0, 255]; + 2. np.float32 type with range [0, 1]. + y_only (bool): Whether to only return Y channel. Default: False. + + Returns: + ndarray: The converted YCbCr image. The output image has the same type + and range as input image. + """ + img_type = img.dtype + img = _convert_input_type_range(img) + if y_only: + out_img = np.dot(img, [65.481, 128.553, 24.966]) + 16.0 + else: + out_img = np.matmul( + img, [[65.481, -37.797, 112.0], [128.553, -74.203, -93.786], + [24.966, 112.0, -18.214]]) + [16, 128, 128] + out_img = _convert_output_type_range(out_img, img_type) + return out_img + + +def bgr2ycbcr(img, y_only=False): + """Convert a BGR image to YCbCr image. + + The bgr version of rgb2ycbcr. + It implements the ITU-R BT.601 conversion for standard-definition + television. See more details in + https://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.601_conversion. + + It differs from a similar function in cv2.cvtColor: `BGR <-> YCrCb`. + In OpenCV, it implements a JPEG conversion. See more details in + https://en.wikipedia.org/wiki/YCbCr#JPEG_conversion. + + Args: + img (ndarray): The input image. It accepts: + 1. np.uint8 type with range [0, 255]; + 2. np.float32 type with range [0, 1]. + y_only (bool): Whether to only return Y channel. Default: False. + + Returns: + ndarray: The converted YCbCr image. The output image has the same type + and range as input image. + """ + img_type = img.dtype + img = _convert_input_type_range(img) + if y_only: + out_img = np.dot(img, [24.966, 128.553, 65.481]) + 16.0 + else: + out_img = np.matmul( + img, [[24.966, 112.0, -18.214], [128.553, -74.203, -93.786], + [65.481, -37.797, 112.0]]) + [16, 128, 128] + out_img = _convert_output_type_range(out_img, img_type) + return out_img + + +def ycbcr2rgb(img): + """Convert a YCbCr image to RGB image. + + This function produces the same results as Matlab's ycbcr2rgb function. + It implements the ITU-R BT.601 conversion for standard-definition + television. See more details in + https://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.601_conversion. + + It differs from a similar function in cv2.cvtColor: `YCrCb <-> RGB`. + In OpenCV, it implements a JPEG conversion. See more details in + https://en.wikipedia.org/wiki/YCbCr#JPEG_conversion. + + Args: + img (ndarray): The input image. It accepts: + 1. np.uint8 type with range [0, 255]; + 2. np.float32 type with range [0, 1]. + + Returns: + ndarray: The converted RGB image. The output image has the same type + and range as input image. + """ + img_type = img.dtype + img = _convert_input_type_range(img) * 255 + out_img = np.matmul(img, [[0.00456621, 0.00456621, 0.00456621], + [0, -0.00153632, 0.00791071], + [0.00625893, -0.00318811, 0]]) * 255.0 + [ + -222.921, 135.576, -276.836 + ] + out_img = _convert_output_type_range(out_img, img_type) + return out_img + + +def ycbcr2bgr(img): + """Convert a YCbCr image to BGR image. + + The bgr version of ycbcr2rgb. + It implements the ITU-R BT.601 conversion for standard-definition + television. See more details in + https://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.601_conversion. + + It differs from a similar function in cv2.cvtColor: `YCrCb <-> BGR`. + In OpenCV, it implements a JPEG conversion. See more details in + https://en.wikipedia.org/wiki/YCbCr#JPEG_conversion. + + Args: + img (ndarray): The input image. It accepts: + 1. np.uint8 type with range [0, 255]; + 2. np.float32 type with range [0, 1]. + + Returns: + ndarray: The converted BGR image. The output image has the same type + and range as input image. + """ + img_type = img.dtype + img = _convert_input_type_range(img) * 255 + out_img = np.matmul(img, [[0.00456621, 0.00456621, 0.00456621], + [0.00791071, -0.00153632, 0], + [0, -0.00318811, 0.00625893]]) * 255.0 + [ + -276.836, 135.576, -222.921 + ] + out_img = _convert_output_type_range(out_img, img_type) + return out_img + + +def convert_color_factory(src, dst): + + code = getattr(cv2, f'COLOR_{src.upper()}2{dst.upper()}') + + def convert_color(img): + out_img = cv2.cvtColor(img, code) + return out_img + + convert_color.__doc__ = f"""Convert a {src.upper()} image to {dst.upper()} + image. + + Args: + img (ndarray or str): The input image. + + Returns: + ndarray: The converted {dst.upper()} image. + """ + + return convert_color + + +bgr2rgb = convert_color_factory('bgr', 'rgb') + +rgb2bgr = convert_color_factory('rgb', 'bgr') + +bgr2hsv = convert_color_factory('bgr', 'hsv') + +hsv2bgr = convert_color_factory('hsv', 'bgr') + +bgr2hls = convert_color_factory('bgr', 'hls') + +hls2bgr = convert_color_factory('hls', 'bgr') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/image/geometric.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/image/geometric.py new file mode 100644 index 000000000..cf97c201c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/image/geometric.py @@ -0,0 +1,728 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import numbers + +import cv2 +import numpy as np + +from ..utils import to_2tuple +from .io import imread_backend + +try: + from PIL import Image +except ImportError: + Image = None + + +def _scale_size(size, scale): + """Rescale a size by a ratio. + + Args: + size (tuple[int]): (w, h). + scale (float | tuple(float)): Scaling factor. + + Returns: + tuple[int]: scaled size. + """ + if isinstance(scale, (float, int)): + scale = (scale, scale) + w, h = size + return int(w * float(scale[0]) + 0.5), int(h * float(scale[1]) + 0.5) + + +cv2_interp_codes = { + 'nearest': cv2.INTER_NEAREST, + 'bilinear': cv2.INTER_LINEAR, + 'bicubic': cv2.INTER_CUBIC, + 'area': cv2.INTER_AREA, + 'lanczos': cv2.INTER_LANCZOS4 +} + +if Image is not None: + pillow_interp_codes = { + 'nearest': Image.NEAREST, + 'bilinear': Image.BILINEAR, + 'bicubic': Image.BICUBIC, + 'box': Image.BOX, + 'lanczos': Image.LANCZOS, + 'hamming': Image.HAMMING + } + + +def imresize(img, + size, + return_scale=False, + interpolation='bilinear', + out=None, + backend=None): + """Resize image to a given size. + + Args: + img (ndarray): The input image. + size (tuple[int]): Target size (w, h). + return_scale (bool): Whether to return `w_scale` and `h_scale`. + interpolation (str): Interpolation method, accepted values are + "nearest", "bilinear", "bicubic", "area", "lanczos" for 'cv2' + backend, "nearest", "bilinear" for 'pillow' backend. + out (ndarray): The output destination. + backend (str | None): The image resize backend type. Options are `cv2`, + `pillow`, `None`. If backend is None, the global imread_backend + specified by ``mmcv.use_backend()`` will be used. Default: None. + + Returns: + tuple | ndarray: (`resized_img`, `w_scale`, `h_scale`) or + `resized_img`. + """ + h, w = img.shape[:2] + if backend is None: + backend = imread_backend + if backend not in ['cv2', 'pillow']: + raise ValueError(f'backend: {backend} is not supported for resize.' + f"Supported backends are 'cv2', 'pillow'") + + if backend == 'pillow': + assert img.dtype == np.uint8, 'Pillow backend only support uint8 type' + pil_image = Image.fromarray(img) + pil_image = pil_image.resize(size, pillow_interp_codes[interpolation]) + resized_img = np.array(pil_image) + else: + resized_img = cv2.resize( + img, size, dst=out, interpolation=cv2_interp_codes[interpolation]) + if not return_scale: + return resized_img + else: + w_scale = size[0] / w + h_scale = size[1] / h + return resized_img, w_scale, h_scale + + +def imresize_to_multiple(img, + divisor, + size=None, + scale_factor=None, + keep_ratio=False, + return_scale=False, + interpolation='bilinear', + out=None, + backend=None): + """Resize image according to a given size or scale factor and then rounds + up the the resized or rescaled image size to the nearest value that can be + divided by the divisor. + + Args: + img (ndarray): The input image. + divisor (int | tuple): Resized image size will be a multiple of + divisor. If divisor is a tuple, divisor should be + (w_divisor, h_divisor). + size (None | int | tuple[int]): Target size (w, h). Default: None. + scale_factor (None | float | tuple[float]): Multiplier for spatial + size. Should match input size if it is a tuple and the 2D style is + (w_scale_factor, h_scale_factor). Default: None. + keep_ratio (bool): Whether to keep the aspect ratio when resizing the + image. Default: False. + return_scale (bool): Whether to return `w_scale` and `h_scale`. + interpolation (str): Interpolation method, accepted values are + "nearest", "bilinear", "bicubic", "area", "lanczos" for 'cv2' + backend, "nearest", "bilinear" for 'pillow' backend. + out (ndarray): The output destination. + backend (str | None): The image resize backend type. Options are `cv2`, + `pillow`, `None`. If backend is None, the global imread_backend + specified by ``mmcv.use_backend()`` will be used. Default: None. + + Returns: + tuple | ndarray: (`resized_img`, `w_scale`, `h_scale`) or + `resized_img`. + """ + h, w = img.shape[:2] + if size is not None and scale_factor is not None: + raise ValueError('only one of size or scale_factor should be defined') + elif size is None and scale_factor is None: + raise ValueError('one of size or scale_factor should be defined') + elif size is not None: + size = to_2tuple(size) + if keep_ratio: + size = rescale_size((w, h), size, return_scale=False) + else: + size = _scale_size((w, h), scale_factor) + + divisor = to_2tuple(divisor) + size = tuple([int(np.ceil(s / d)) * d for s, d in zip(size, divisor)]) + resized_img, w_scale, h_scale = imresize( + img, + size, + return_scale=True, + interpolation=interpolation, + out=out, + backend=backend) + if return_scale: + return resized_img, w_scale, h_scale + else: + return resized_img + + +def imresize_like(img, + dst_img, + return_scale=False, + interpolation='bilinear', + backend=None): + """Resize image to the same size of a given image. + + Args: + img (ndarray): The input image. + dst_img (ndarray): The target image. + return_scale (bool): Whether to return `w_scale` and `h_scale`. + interpolation (str): Same as :func:`resize`. + backend (str | None): Same as :func:`resize`. + + Returns: + tuple or ndarray: (`resized_img`, `w_scale`, `h_scale`) or + `resized_img`. + """ + h, w = dst_img.shape[:2] + return imresize(img, (w, h), return_scale, interpolation, backend=backend) + + +def rescale_size(old_size, scale, return_scale=False): + """Calculate the new size to be rescaled to. + + Args: + old_size (tuple[int]): The old size (w, h) of image. + scale (float | tuple[int]): The scaling factor or maximum size. + If it is a float number, then the image will be rescaled by this + factor, else if it is a tuple of 2 integers, then the image will + be rescaled as large as possible within the scale. + return_scale (bool): Whether to return the scaling factor besides the + rescaled image size. + + Returns: + tuple[int]: The new rescaled image size. + """ + w, h = old_size + if isinstance(scale, (float, int)): + if scale <= 0: + raise ValueError(f'Invalid scale {scale}, must be positive.') + scale_factor = scale + elif isinstance(scale, tuple): + max_long_edge = max(scale) + max_short_edge = min(scale) + scale_factor = min(max_long_edge / max(h, w), + max_short_edge / min(h, w)) + else: + raise TypeError( + f'Scale must be a number or tuple of int, but got {type(scale)}') + + new_size = _scale_size((w, h), scale_factor) + + if return_scale: + return new_size, scale_factor + else: + return new_size + + +def imrescale(img, + scale, + return_scale=False, + interpolation='bilinear', + backend=None): + """Resize image while keeping the aspect ratio. + + Args: + img (ndarray): The input image. + scale (float | tuple[int]): The scaling factor or maximum size. + If it is a float number, then the image will be rescaled by this + factor, else if it is a tuple of 2 integers, then the image will + be rescaled as large as possible within the scale. + return_scale (bool): Whether to return the scaling factor besides the + rescaled image. + interpolation (str): Same as :func:`resize`. + backend (str | None): Same as :func:`resize`. + + Returns: + ndarray: The rescaled image. + """ + h, w = img.shape[:2] + new_size, scale_factor = rescale_size((w, h), scale, return_scale=True) + rescaled_img = imresize( + img, new_size, interpolation=interpolation, backend=backend) + if return_scale: + return rescaled_img, scale_factor + else: + return rescaled_img + + +def imflip(img, direction='horizontal'): + """Flip an image horizontally or vertically. + + Args: + img (ndarray): Image to be flipped. + direction (str): The flip direction, either "horizontal" or + "vertical" or "diagonal". + + Returns: + ndarray: The flipped image. + """ + assert direction in ['horizontal', 'vertical', 'diagonal'] + if direction == 'horizontal': + return np.flip(img, axis=1) + elif direction == 'vertical': + return np.flip(img, axis=0) + else: + return np.flip(img, axis=(0, 1)) + + +def imflip_(img, direction='horizontal'): + """Inplace flip an image horizontally or vertically. + + Args: + img (ndarray): Image to be flipped. + direction (str): The flip direction, either "horizontal" or + "vertical" or "diagonal". + + Returns: + ndarray: The flipped image (inplace). + """ + assert direction in ['horizontal', 'vertical', 'diagonal'] + if direction == 'horizontal': + return cv2.flip(img, 1, img) + elif direction == 'vertical': + return cv2.flip(img, 0, img) + else: + return cv2.flip(img, -1, img) + + +def imrotate(img, + angle, + center=None, + scale=1.0, + border_value=0, + interpolation='bilinear', + auto_bound=False): + """Rotate an image. + + Args: + img (ndarray): Image to be rotated. + angle (float): Rotation angle in degrees, positive values mean + clockwise rotation. + center (tuple[float], optional): Center point (w, h) of the rotation in + the source image. If not specified, the center of the image will be + used. + scale (float): Isotropic scale factor. + border_value (int): Border value. + interpolation (str): Same as :func:`resize`. + auto_bound (bool): Whether to adjust the image size to cover the whole + rotated image. + + Returns: + ndarray: The rotated image. + """ + if center is not None and auto_bound: + raise ValueError('`auto_bound` conflicts with `center`') + h, w = img.shape[:2] + if center is None: + center = ((w - 1) * 0.5, (h - 1) * 0.5) + assert isinstance(center, tuple) + + matrix = cv2.getRotationMatrix2D(center, -angle, scale) + if auto_bound: + cos = np.abs(matrix[0, 0]) + sin = np.abs(matrix[0, 1]) + new_w = h * sin + w * cos + new_h = h * cos + w * sin + matrix[0, 2] += (new_w - w) * 0.5 + matrix[1, 2] += (new_h - h) * 0.5 + w = int(np.round(new_w)) + h = int(np.round(new_h)) + rotated = cv2.warpAffine( + img, + matrix, (w, h), + flags=cv2_interp_codes[interpolation], + borderValue=border_value) + return rotated + + +def bbox_clip(bboxes, img_shape): + """Clip bboxes to fit the image shape. + + Args: + bboxes (ndarray): Shape (..., 4*k) + img_shape (tuple[int]): (height, width) of the image. + + Returns: + ndarray: Clipped bboxes. + """ + assert bboxes.shape[-1] % 4 == 0 + cmin = np.empty(bboxes.shape[-1], dtype=bboxes.dtype) + cmin[0::2] = img_shape[1] - 1 + cmin[1::2] = img_shape[0] - 1 + clipped_bboxes = np.maximum(np.minimum(bboxes, cmin), 0) + return clipped_bboxes + + +def bbox_scaling(bboxes, scale, clip_shape=None): + """Scaling bboxes w.r.t the box center. + + Args: + bboxes (ndarray): Shape(..., 4). + scale (float): Scaling factor. + clip_shape (tuple[int], optional): If specified, bboxes that exceed the + boundary will be clipped according to the given shape (h, w). + + Returns: + ndarray: Scaled bboxes. + """ + if float(scale) == 1.0: + scaled_bboxes = bboxes.copy() + else: + w = bboxes[..., 2] - bboxes[..., 0] + 1 + h = bboxes[..., 3] - bboxes[..., 1] + 1 + dw = (w * (scale - 1)) * 0.5 + dh = (h * (scale - 1)) * 0.5 + scaled_bboxes = bboxes + np.stack((-dw, -dh, dw, dh), axis=-1) + if clip_shape is not None: + return bbox_clip(scaled_bboxes, clip_shape) + else: + return scaled_bboxes + + +def imcrop(img, bboxes, scale=1.0, pad_fill=None): + """Crop image patches. + + 3 steps: scale the bboxes -> clip bboxes -> crop and pad. + + Args: + img (ndarray): Image to be cropped. + bboxes (ndarray): Shape (k, 4) or (4, ), location of cropped bboxes. + scale (float, optional): Scale ratio of bboxes, the default value + 1.0 means no padding. + pad_fill (Number | list[Number]): Value to be filled for padding. + Default: None, which means no padding. + + Returns: + list[ndarray] | ndarray: The cropped image patches. + """ + chn = 1 if img.ndim == 2 else img.shape[2] + if pad_fill is not None: + if isinstance(pad_fill, (int, float)): + pad_fill = [pad_fill for _ in range(chn)] + assert len(pad_fill) == chn + + _bboxes = bboxes[None, ...] if bboxes.ndim == 1 else bboxes + scaled_bboxes = bbox_scaling(_bboxes, scale).astype(np.int32) + clipped_bbox = bbox_clip(scaled_bboxes, img.shape) + + patches = [] + for i in range(clipped_bbox.shape[0]): + x1, y1, x2, y2 = tuple(clipped_bbox[i, :]) + if pad_fill is None: + patch = img[y1:y2 + 1, x1:x2 + 1, ...] + else: + _x1, _y1, _x2, _y2 = tuple(scaled_bboxes[i, :]) + if chn == 1: + patch_shape = (_y2 - _y1 + 1, _x2 - _x1 + 1) + else: + patch_shape = (_y2 - _y1 + 1, _x2 - _x1 + 1, chn) + patch = np.array( + pad_fill, dtype=img.dtype) * np.ones( + patch_shape, dtype=img.dtype) + x_start = 0 if _x1 >= 0 else -_x1 + y_start = 0 if _y1 >= 0 else -_y1 + w = x2 - x1 + 1 + h = y2 - y1 + 1 + patch[y_start:y_start + h, x_start:x_start + w, + ...] = img[y1:y1 + h, x1:x1 + w, ...] + patches.append(patch) + + if bboxes.ndim == 1: + return patches[0] + else: + return patches + + +def impad(img, + *, + shape=None, + padding=None, + pad_val=0, + padding_mode='constant'): + """Pad the given image to a certain shape or pad on all sides with + specified padding mode and padding value. + + Args: + img (ndarray): Image to be padded. + shape (tuple[int]): Expected padding shape (h, w). Default: None. + padding (int or tuple[int]): Padding on each border. If a single int is + provided this is used to pad all borders. If tuple of length 2 is + provided this is the padding on left/right and top/bottom + respectively. If a tuple of length 4 is provided this is the + padding for the left, top, right and bottom borders respectively. + Default: None. Note that `shape` and `padding` can not be both + set. + pad_val (Number | Sequence[Number]): Values to be filled in padding + areas when padding_mode is 'constant'. Default: 0. + padding_mode (str): Type of padding. Should be: constant, edge, + reflect or symmetric. Default: constant. + + - constant: pads with a constant value, this value is specified + with pad_val. + - edge: pads with the last value at the edge of the image. + - reflect: pads with reflection of image without repeating the + last value on the edge. For example, padding [1, 2, 3, 4] + with 2 elements on both sides in reflect mode will result + in [3, 2, 1, 2, 3, 4, 3, 2]. + - symmetric: pads with reflection of image repeating the last + value on the edge. For example, padding [1, 2, 3, 4] with + 2 elements on both sides in symmetric mode will result in + [2, 1, 1, 2, 3, 4, 4, 3] + + Returns: + ndarray: The padded image. + """ + + assert (shape is not None) ^ (padding is not None) + if shape is not None: + padding = (0, 0, shape[1] - img.shape[1], shape[0] - img.shape[0]) + + # check pad_val + if isinstance(pad_val, tuple): + assert len(pad_val) == img.shape[-1] + elif not isinstance(pad_val, numbers.Number): + raise TypeError('pad_val must be a int or a tuple. ' + f'But received {type(pad_val)}') + + # check padding + if isinstance(padding, tuple) and len(padding) in [2, 4]: + if len(padding) == 2: + padding = (padding[0], padding[1], padding[0], padding[1]) + elif isinstance(padding, numbers.Number): + padding = (padding, padding, padding, padding) + else: + raise ValueError('Padding must be a int or a 2, or 4 element tuple.' + f'But received {padding}') + + # check padding mode + assert padding_mode in ['constant', 'edge', 'reflect', 'symmetric'] + + border_type = { + 'constant': cv2.BORDER_CONSTANT, + 'edge': cv2.BORDER_REPLICATE, + 'reflect': cv2.BORDER_REFLECT_101, + 'symmetric': cv2.BORDER_REFLECT + } + img = cv2.copyMakeBorder( + img, + padding[1], + padding[3], + padding[0], + padding[2], + border_type[padding_mode], + value=pad_val) + + return img + + +def impad_to_multiple(img, divisor, pad_val=0): + """Pad an image to ensure each edge to be multiple to some number. + + Args: + img (ndarray): Image to be padded. + divisor (int): Padded image edges will be multiple to divisor. + pad_val (Number | Sequence[Number]): Same as :func:`impad`. + + Returns: + ndarray: The padded image. + """ + pad_h = int(np.ceil(img.shape[0] / divisor)) * divisor + pad_w = int(np.ceil(img.shape[1] / divisor)) * divisor + return impad(img, shape=(pad_h, pad_w), pad_val=pad_val) + + +def cutout(img, shape, pad_val=0): + """Randomly cut out a rectangle from the original img. + + Args: + img (ndarray): Image to be cutout. + shape (int | tuple[int]): Expected cutout shape (h, w). If given as a + int, the value will be used for both h and w. + pad_val (int | float | tuple[int | float]): Values to be filled in the + cut area. Defaults to 0. + + Returns: + ndarray: The cutout image. + """ + + channels = 1 if img.ndim == 2 else img.shape[2] + if isinstance(shape, int): + cut_h, cut_w = shape, shape + else: + assert isinstance(shape, tuple) and len(shape) == 2, \ + f'shape must be a int or a tuple with length 2, but got type ' \ + f'{type(shape)} instead.' + cut_h, cut_w = shape + if isinstance(pad_val, (int, float)): + pad_val = tuple([pad_val] * channels) + elif isinstance(pad_val, tuple): + assert len(pad_val) == channels, \ + 'Expected the num of elements in tuple equals the channels' \ + 'of input image. Found {} vs {}'.format( + len(pad_val), channels) + else: + raise TypeError(f'Invalid type {type(pad_val)} for `pad_val`') + + img_h, img_w = img.shape[:2] + y0 = np.random.uniform(img_h) + x0 = np.random.uniform(img_w) + + y1 = int(max(0, y0 - cut_h / 2.)) + x1 = int(max(0, x0 - cut_w / 2.)) + y2 = min(img_h, y1 + cut_h) + x2 = min(img_w, x1 + cut_w) + + if img.ndim == 2: + patch_shape = (y2 - y1, x2 - x1) + else: + patch_shape = (y2 - y1, x2 - x1, channels) + + img_cutout = img.copy() + patch = np.array( + pad_val, dtype=img.dtype) * np.ones( + patch_shape, dtype=img.dtype) + img_cutout[y1:y2, x1:x2, ...] = patch + + return img_cutout + + +def _get_shear_matrix(magnitude, direction='horizontal'): + """Generate the shear matrix for transformation. + + Args: + magnitude (int | float): The magnitude used for shear. + direction (str): The flip direction, either "horizontal" + or "vertical". + + Returns: + ndarray: The shear matrix with dtype float32. + """ + if direction == 'horizontal': + shear_matrix = np.float32([[1, magnitude, 0], [0, 1, 0]]) + elif direction == 'vertical': + shear_matrix = np.float32([[1, 0, 0], [magnitude, 1, 0]]) + return shear_matrix + + +def imshear(img, + magnitude, + direction='horizontal', + border_value=0, + interpolation='bilinear'): + """Shear an image. + + Args: + img (ndarray): Image to be sheared with format (h, w) + or (h, w, c). + magnitude (int | float): The magnitude used for shear. + direction (str): The flip direction, either "horizontal" + or "vertical". + border_value (int | tuple[int]): Value used in case of a + constant border. + interpolation (str): Same as :func:`resize`. + + Returns: + ndarray: The sheared image. + """ + assert direction in ['horizontal', + 'vertical'], f'Invalid direction: {direction}' + height, width = img.shape[:2] + if img.ndim == 2: + channels = 1 + elif img.ndim == 3: + channels = img.shape[-1] + if isinstance(border_value, int): + border_value = tuple([border_value] * channels) + elif isinstance(border_value, tuple): + assert len(border_value) == channels, \ + 'Expected the num of elements in tuple equals the channels' \ + 'of input image. Found {} vs {}'.format( + len(border_value), channels) + else: + raise ValueError( + f'Invalid type {type(border_value)} for `border_value`') + shear_matrix = _get_shear_matrix(magnitude, direction) + sheared = cv2.warpAffine( + img, + shear_matrix, + (width, height), + # Note case when the number elements in `border_value` + # greater than 3 (e.g. shearing masks whose channels large + # than 3) will raise TypeError in `cv2.warpAffine`. + # Here simply slice the first 3 values in `border_value`. + borderValue=border_value[:3], + flags=cv2_interp_codes[interpolation]) + return sheared + + +def _get_translate_matrix(offset, direction='horizontal'): + """Generate the translate matrix. + + Args: + offset (int | float): The offset used for translate. + direction (str): The translate direction, either + "horizontal" or "vertical". + + Returns: + ndarray: The translate matrix with dtype float32. + """ + if direction == 'horizontal': + translate_matrix = np.float32([[1, 0, offset], [0, 1, 0]]) + elif direction == 'vertical': + translate_matrix = np.float32([[1, 0, 0], [0, 1, offset]]) + return translate_matrix + + +def imtranslate(img, + offset, + direction='horizontal', + border_value=0, + interpolation='bilinear'): + """Translate an image. + + Args: + img (ndarray): Image to be translated with format + (h, w) or (h, w, c). + offset (int | float): The offset used for translate. + direction (str): The translate direction, either "horizontal" + or "vertical". + border_value (int | tuple[int]): Value used in case of a + constant border. + interpolation (str): Same as :func:`resize`. + + Returns: + ndarray: The translated image. + """ + assert direction in ['horizontal', + 'vertical'], f'Invalid direction: {direction}' + height, width = img.shape[:2] + if img.ndim == 2: + channels = 1 + elif img.ndim == 3: + channels = img.shape[-1] + if isinstance(border_value, int): + border_value = tuple([border_value] * channels) + elif isinstance(border_value, tuple): + assert len(border_value) == channels, \ + 'Expected the num of elements in tuple equals the channels' \ + 'of input image. Found {} vs {}'.format( + len(border_value), channels) + else: + raise ValueError( + f'Invalid type {type(border_value)} for `border_value`.') + translate_matrix = _get_translate_matrix(offset, direction) + translated = cv2.warpAffine( + img, + translate_matrix, + (width, height), + # Note case when the number elements in `border_value` + # greater than 3 (e.g. translating masks whose channels + # large than 3) will raise TypeError in `cv2.warpAffine`. + # Here simply slice the first 3 values in `border_value`. + borderValue=border_value[:3], + flags=cv2_interp_codes[interpolation]) + return translated diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/image/io.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/image/io.py new file mode 100644 index 000000000..d47aaa845 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/image/io.py @@ -0,0 +1,258 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import io +import os.path as osp +from pathlib import Path + +import cv2 +import numpy as np +from cv2 import (IMREAD_COLOR, IMREAD_GRAYSCALE, IMREAD_IGNORE_ORIENTATION, + IMREAD_UNCHANGED) + +from mmcv.utils import check_file_exist, is_str, mkdir_or_exist + +try: + from turbojpeg import TJCS_RGB, TJPF_BGR, TJPF_GRAY, TurboJPEG +except ImportError: + TJCS_RGB = TJPF_GRAY = TJPF_BGR = TurboJPEG = None + +try: + from PIL import Image, ImageOps +except ImportError: + Image = None + +try: + import tifffile +except ImportError: + tifffile = None + +jpeg = None +supported_backends = ['cv2', 'turbojpeg', 'pillow', 'tifffile'] + +imread_flags = { + 'color': IMREAD_COLOR, + 'grayscale': IMREAD_GRAYSCALE, + 'unchanged': IMREAD_UNCHANGED, + 'color_ignore_orientation': IMREAD_IGNORE_ORIENTATION | IMREAD_COLOR, + 'grayscale_ignore_orientation': + IMREAD_IGNORE_ORIENTATION | IMREAD_GRAYSCALE +} + +imread_backend = 'cv2' + + +def use_backend(backend): + """Select a backend for image decoding. + + Args: + backend (str): The image decoding backend type. Options are `cv2`, + `pillow`, `turbojpeg` (see https://github.com/lilohuang/PyTurboJPEG) + and `tifffile`. `turbojpeg` is faster but it only supports `.jpeg` + file format. + """ + assert backend in supported_backends + global imread_backend + imread_backend = backend + if imread_backend == 'turbojpeg': + if TurboJPEG is None: + raise ImportError('`PyTurboJPEG` is not installed') + global jpeg + if jpeg is None: + jpeg = TurboJPEG() + elif imread_backend == 'pillow': + if Image is None: + raise ImportError('`Pillow` is not installed') + elif imread_backend == 'tifffile': + if tifffile is None: + raise ImportError('`tifffile` is not installed') + + +def _jpegflag(flag='color', channel_order='bgr'): + channel_order = channel_order.lower() + if channel_order not in ['rgb', 'bgr']: + raise ValueError('channel order must be either "rgb" or "bgr"') + + if flag == 'color': + if channel_order == 'bgr': + return TJPF_BGR + elif channel_order == 'rgb': + return TJCS_RGB + elif flag == 'grayscale': + return TJPF_GRAY + else: + raise ValueError('flag must be "color" or "grayscale"') + + +def _pillow2array(img, flag='color', channel_order='bgr'): + """Convert a pillow image to numpy array. + + Args: + img (:obj:`PIL.Image.Image`): The image loaded using PIL + flag (str): Flags specifying the color type of a loaded image, + candidates are 'color', 'grayscale' and 'unchanged'. + Default to 'color'. + channel_order (str): The channel order of the output image array, + candidates are 'bgr' and 'rgb'. Default to 'bgr'. + + Returns: + np.ndarray: The converted numpy array + """ + channel_order = channel_order.lower() + if channel_order not in ['rgb', 'bgr']: + raise ValueError('channel order must be either "rgb" or "bgr"') + + if flag == 'unchanged': + array = np.array(img) + if array.ndim >= 3 and array.shape[2] >= 3: # color image + array[:, :, :3] = array[:, :, (2, 1, 0)] # RGB to BGR + else: + # Handle exif orientation tag + if flag in ['color', 'grayscale']: + img = ImageOps.exif_transpose(img) + # If the image mode is not 'RGB', convert it to 'RGB' first. + if img.mode != 'RGB': + if img.mode != 'LA': + # Most formats except 'LA' can be directly converted to RGB + img = img.convert('RGB') + else: + # When the mode is 'LA', the default conversion will fill in + # the canvas with black, which sometimes shadows black objects + # in the foreground. + # + # Therefore, a random color (124, 117, 104) is used for canvas + img_rgba = img.convert('RGBA') + img = Image.new('RGB', img_rgba.size, (124, 117, 104)) + img.paste(img_rgba, mask=img_rgba.split()[3]) # 3 is alpha + if flag in ['color', 'color_ignore_orientation']: + array = np.array(img) + if channel_order != 'rgb': + array = array[:, :, ::-1] # RGB to BGR + elif flag in ['grayscale', 'grayscale_ignore_orientation']: + img = img.convert('L') + array = np.array(img) + else: + raise ValueError( + 'flag must be "color", "grayscale", "unchanged", ' + f'"color_ignore_orientation" or "grayscale_ignore_orientation"' + f' but got {flag}') + return array + + +def imread(img_or_path, flag='color', channel_order='bgr', backend=None): + """Read an image. + + Args: + img_or_path (ndarray or str or Path): Either a numpy array or str or + pathlib.Path. If it is a numpy array (loaded image), then + it will be returned as is. + flag (str): Flags specifying the color type of a loaded image, + candidates are `color`, `grayscale`, `unchanged`, + `color_ignore_orientation` and `grayscale_ignore_orientation`. + By default, `cv2` and `pillow` backend would rotate the image + according to its EXIF info unless called with `unchanged` or + `*_ignore_orientation` flags. `turbojpeg` and `tifffile` backend + always ignore image's EXIF info regardless of the flag. + The `turbojpeg` backend only supports `color` and `grayscale`. + channel_order (str): Order of channel, candidates are `bgr` and `rgb`. + backend (str | None): The image decoding backend type. Options are + `cv2`, `pillow`, `turbojpeg`, `tifffile`, `None`. + If backend is None, the global imread_backend specified by + ``mmcv.use_backend()`` will be used. Default: None. + + Returns: + ndarray: Loaded image array. + """ + + if backend is None: + backend = imread_backend + if backend not in supported_backends: + raise ValueError(f'backend: {backend} is not supported. Supported ' + "backends are 'cv2', 'turbojpeg', 'pillow'") + if isinstance(img_or_path, Path): + img_or_path = str(img_or_path) + + if isinstance(img_or_path, np.ndarray): + return img_or_path + elif is_str(img_or_path): + check_file_exist(img_or_path, + f'img file does not exist: {img_or_path}') + if backend == 'turbojpeg': + with open(img_or_path, 'rb') as in_file: + img = jpeg.decode(in_file.read(), + _jpegflag(flag, channel_order)) + if img.shape[-1] == 1: + img = img[:, :, 0] + return img + elif backend == 'pillow': + img = Image.open(img_or_path) + img = _pillow2array(img, flag, channel_order) + return img + elif backend == 'tifffile': + img = tifffile.imread(img_or_path) + return img + else: + flag = imread_flags[flag] if is_str(flag) else flag + img = cv2.imread(img_or_path, flag) + if flag == IMREAD_COLOR and channel_order == 'rgb': + cv2.cvtColor(img, cv2.COLOR_BGR2RGB, img) + return img + else: + raise TypeError('"img" must be a numpy array or a str or ' + 'a pathlib.Path object') + + +def imfrombytes(content, flag='color', channel_order='bgr', backend=None): + """Read an image from bytes. + + Args: + content (bytes): Image bytes got from files or other streams. + flag (str): Same as :func:`imread`. + backend (str | None): The image decoding backend type. Options are + `cv2`, `pillow`, `turbojpeg`, `None`. If backend is None, the + global imread_backend specified by ``mmcv.use_backend()`` will be + used. Default: None. + + Returns: + ndarray: Loaded image array. + """ + + if backend is None: + backend = imread_backend + if backend not in supported_backends: + raise ValueError(f'backend: {backend} is not supported. Supported ' + "backends are 'cv2', 'turbojpeg', 'pillow'") + if backend == 'turbojpeg': + img = jpeg.decode(content, _jpegflag(flag, channel_order)) + if img.shape[-1] == 1: + img = img[:, :, 0] + return img + elif backend == 'pillow': + buff = io.BytesIO(content) + img = Image.open(buff) + img = _pillow2array(img, flag, channel_order) + return img + else: + img_np = np.frombuffer(content, np.uint8) + flag = imread_flags[flag] if is_str(flag) else flag + img = cv2.imdecode(img_np, flag) + if flag == IMREAD_COLOR and channel_order == 'rgb': + cv2.cvtColor(img, cv2.COLOR_BGR2RGB, img) + return img + + +def imwrite(img, file_path, params=None, auto_mkdir=True): + """Write image to file. + + Args: + img (ndarray): Image array to be written. + file_path (str): Image file path. + params (None or list): Same as opencv :func:`imwrite` interface. + auto_mkdir (bool): If the parent folder of `file_path` does not exist, + whether to create it automatically. + + Returns: + bool: Successful or not. + """ + if auto_mkdir: + dir_name = osp.abspath(osp.dirname(file_path)) + mkdir_or_exist(dir_name) + return cv2.imwrite(file_path, img, params) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/image/misc.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/image/misc.py new file mode 100644 index 000000000..dfc4a9c6e --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/image/misc.py @@ -0,0 +1,44 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import numpy as np + +import mmcv + +try: + import torch +except ImportError: + torch = None + + +def tensor2imgs(tensor, mean=(0, 0, 0), std=(1, 1, 1), to_rgb=True): + """Convert tensor to 3-channel images. + + Args: + tensor (torch.Tensor): Tensor that contains multiple images, shape ( + N, C, H, W). + mean (tuple[float], optional): Mean of images. Defaults to (0, 0, 0). + std (tuple[float], optional): Standard deviation of images. + Defaults to (1, 1, 1). + to_rgb (bool, optional): Whether the tensor was converted to RGB + format in the first place. If so, convert it back to BGR. + Defaults to True. + + Returns: + list[np.ndarray]: A list that contains multiple images. + """ + + if torch is None: + raise RuntimeError('pytorch is not installed') + assert torch.is_tensor(tensor) and tensor.ndim == 4 + assert len(mean) == 3 + assert len(std) == 3 + + num_imgs = tensor.size(0) + mean = np.array(mean, dtype=np.float32) + std = np.array(std, dtype=np.float32) + imgs = [] + for img_id in range(num_imgs): + img = tensor[img_id, ...].cpu().numpy().transpose(1, 2, 0) + img = mmcv.imdenormalize( + img, mean, std, to_bgr=to_rgb).astype(np.uint8) + imgs.append(np.ascontiguousarray(img)) + return imgs diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/image/photometric.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/image/photometric.py new file mode 100644 index 000000000..5085d0120 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/image/photometric.py @@ -0,0 +1,428 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import cv2 +import numpy as np + +from ..utils import is_tuple_of +from .colorspace import bgr2gray, gray2bgr + + +def imnormalize(img, mean, std, to_rgb=True): + """Normalize an image with mean and std. + + Args: + img (ndarray): Image to be normalized. + mean (ndarray): The mean to be used for normalize. + std (ndarray): The std to be used for normalize. + to_rgb (bool): Whether to convert to rgb. + + Returns: + ndarray: The normalized image. + """ + img = img.copy().astype(np.float32) + return imnormalize_(img, mean, std, to_rgb) + + +def imnormalize_(img, mean, std, to_rgb=True): + """Inplace normalize an image with mean and std. + + Args: + img (ndarray): Image to be normalized. + mean (ndarray): The mean to be used for normalize. + std (ndarray): The std to be used for normalize. + to_rgb (bool): Whether to convert to rgb. + + Returns: + ndarray: The normalized image. + """ + # cv2 inplace normalization does not accept uint8 + assert img.dtype != np.uint8 + mean = np.float64(mean.reshape(1, -1)) + stdinv = 1 / np.float64(std.reshape(1, -1)) + if to_rgb: + cv2.cvtColor(img, cv2.COLOR_BGR2RGB, img) # inplace + cv2.subtract(img, mean, img) # inplace + cv2.multiply(img, stdinv, img) # inplace + return img + + +def imdenormalize(img, mean, std, to_bgr=True): + assert img.dtype != np.uint8 + mean = mean.reshape(1, -1).astype(np.float64) + std = std.reshape(1, -1).astype(np.float64) + img = cv2.multiply(img, std) # make a copy + cv2.add(img, mean, img) # inplace + if to_bgr: + cv2.cvtColor(img, cv2.COLOR_RGB2BGR, img) # inplace + return img + + +def iminvert(img): + """Invert (negate) an image. + + Args: + img (ndarray): Image to be inverted. + + Returns: + ndarray: The inverted image. + """ + return np.full_like(img, 255) - img + + +def solarize(img, thr=128): + """Solarize an image (invert all pixel values above a threshold) + + Args: + img (ndarray): Image to be solarized. + thr (int): Threshold for solarizing (0 - 255). + + Returns: + ndarray: The solarized image. + """ + img = np.where(img < thr, img, 255 - img) + return img + + +def posterize(img, bits): + """Posterize an image (reduce the number of bits for each color channel) + + Args: + img (ndarray): Image to be posterized. + bits (int): Number of bits (1 to 8) to use for posterizing. + + Returns: + ndarray: The posterized image. + """ + shift = 8 - bits + img = np.left_shift(np.right_shift(img, shift), shift) + return img + + +def adjust_color(img, alpha=1, beta=None, gamma=0): + r"""It blends the source image and its gray image: + + .. math:: + output = img * alpha + gray\_img * beta + gamma + + Args: + img (ndarray): The input source image. + alpha (int | float): Weight for the source image. Default 1. + beta (int | float): Weight for the converted gray image. + If None, it's assigned the value (1 - `alpha`). + gamma (int | float): Scalar added to each sum. + Same as :func:`cv2.addWeighted`. Default 0. + + Returns: + ndarray: Colored image which has the same size and dtype as input. + """ + gray_img = bgr2gray(img) + gray_img = np.tile(gray_img[..., None], [1, 1, 3]) + if beta is None: + beta = 1 - alpha + colored_img = cv2.addWeighted(img, alpha, gray_img, beta, gamma) + if not colored_img.dtype == np.uint8: + # Note when the dtype of `img` is not the default `np.uint8` + # (e.g. np.float32), the value in `colored_img` got from cv2 + # is not guaranteed to be in range [0, 255], so here clip + # is needed. + colored_img = np.clip(colored_img, 0, 255) + return colored_img + + +def imequalize(img): + """Equalize the image histogram. + + This function applies a non-linear mapping to the input image, + in order to create a uniform distribution of grayscale values + in the output image. + + Args: + img (ndarray): Image to be equalized. + + Returns: + ndarray: The equalized image. + """ + + def _scale_channel(im, c): + """Scale the data in the corresponding channel.""" + im = im[:, :, c] + # Compute the histogram of the image channel. + histo = np.histogram(im, 256, (0, 255))[0] + # For computing the step, filter out the nonzeros. + nonzero_histo = histo[histo > 0] + step = (np.sum(nonzero_histo) - nonzero_histo[-1]) // 255 + if not step: + lut = np.array(range(256)) + else: + # Compute the cumulative sum, shifted by step // 2 + # and then normalized by step. + lut = (np.cumsum(histo) + (step // 2)) // step + # Shift lut, prepending with 0. + lut = np.concatenate([[0], lut[:-1]], 0) + # handle potential integer overflow + lut[lut > 255] = 255 + # If step is zero, return the original image. + # Otherwise, index from lut. + return np.where(np.equal(step, 0), im, lut[im]) + + # Scales each channel independently and then stacks + # the result. + s1 = _scale_channel(img, 0) + s2 = _scale_channel(img, 1) + s3 = _scale_channel(img, 2) + equalized_img = np.stack([s1, s2, s3], axis=-1) + return equalized_img.astype(img.dtype) + + +def adjust_brightness(img, factor=1.): + """Adjust image brightness. + + This function controls the brightness of an image. An + enhancement factor of 0.0 gives a black image. + A factor of 1.0 gives the original image. This function + blends the source image and the degenerated black image: + + .. math:: + output = img * factor + degenerated * (1 - factor) + + Args: + img (ndarray): Image to be brightened. + factor (float): A value controls the enhancement. + Factor 1.0 returns the original image, lower + factors mean less color (brightness, contrast, + etc), and higher values more. Default 1. + + Returns: + ndarray: The brightened image. + """ + degenerated = np.zeros_like(img) + # Note manually convert the dtype to np.float32, to + # achieve as close results as PIL.ImageEnhance.Brightness. + # Set beta=1-factor, and gamma=0 + brightened_img = cv2.addWeighted( + img.astype(np.float32), factor, degenerated.astype(np.float32), + 1 - factor, 0) + brightened_img = np.clip(brightened_img, 0, 255) + return brightened_img.astype(img.dtype) + + +def adjust_contrast(img, factor=1.): + """Adjust image contrast. + + This function controls the contrast of an image. An + enhancement factor of 0.0 gives a solid grey + image. A factor of 1.0 gives the original image. It + blends the source image and the degenerated mean image: + + .. math:: + output = img * factor + degenerated * (1 - factor) + + Args: + img (ndarray): Image to be contrasted. BGR order. + factor (float): Same as :func:`mmcv.adjust_brightness`. + + Returns: + ndarray: The contrasted image. + """ + gray_img = bgr2gray(img) + hist = np.histogram(gray_img, 256, (0, 255))[0] + mean = round(np.sum(gray_img) / np.sum(hist)) + degenerated = (np.ones_like(img[..., 0]) * mean).astype(img.dtype) + degenerated = gray2bgr(degenerated) + contrasted_img = cv2.addWeighted( + img.astype(np.float32), factor, degenerated.astype(np.float32), + 1 - factor, 0) + contrasted_img = np.clip(contrasted_img, 0, 255) + return contrasted_img.astype(img.dtype) + + +def auto_contrast(img, cutoff=0): + """Auto adjust image contrast. + + This function maximize (normalize) image contrast by first removing cutoff + percent of the lightest and darkest pixels from the histogram and remapping + the image so that the darkest pixel becomes black (0), and the lightest + becomes white (255). + + Args: + img (ndarray): Image to be contrasted. BGR order. + cutoff (int | float | tuple): The cutoff percent of the lightest and + darkest pixels to be removed. If given as tuple, it shall be + (low, high). Otherwise, the single value will be used for both. + Defaults to 0. + + Returns: + ndarray: The contrasted image. + """ + + def _auto_contrast_channel(im, c, cutoff): + im = im[:, :, c] + # Compute the histogram of the image channel. + histo = np.histogram(im, 256, (0, 255))[0] + # Remove cut-off percent pixels from histo + histo_sum = np.cumsum(histo) + cut_low = histo_sum[-1] * cutoff[0] // 100 + cut_high = histo_sum[-1] - histo_sum[-1] * cutoff[1] // 100 + histo_sum = np.clip(histo_sum, cut_low, cut_high) - cut_low + histo = np.concatenate([[histo_sum[0]], np.diff(histo_sum)], 0) + + # Compute mapping + low, high = np.nonzero(histo)[0][0], np.nonzero(histo)[0][-1] + # If all the values have been cut off, return the origin img + if low >= high: + return im + scale = 255.0 / (high - low) + offset = -low * scale + lut = np.array(range(256)) + lut = lut * scale + offset + lut = np.clip(lut, 0, 255) + return lut[im] + + if isinstance(cutoff, (int, float)): + cutoff = (cutoff, cutoff) + else: + assert isinstance(cutoff, tuple), 'cutoff must be of type int, ' \ + f'float or tuple, but got {type(cutoff)} instead.' + # Auto adjusts contrast for each channel independently and then stacks + # the result. + s1 = _auto_contrast_channel(img, 0, cutoff) + s2 = _auto_contrast_channel(img, 1, cutoff) + s3 = _auto_contrast_channel(img, 2, cutoff) + contrasted_img = np.stack([s1, s2, s3], axis=-1) + return contrasted_img.astype(img.dtype) + + +def adjust_sharpness(img, factor=1., kernel=None): + """Adjust image sharpness. + + This function controls the sharpness of an image. An + enhancement factor of 0.0 gives a blurred image. A + factor of 1.0 gives the original image. And a factor + of 2.0 gives a sharpened image. It blends the source + image and the degenerated mean image: + + .. math:: + output = img * factor + degenerated * (1 - factor) + + Args: + img (ndarray): Image to be sharpened. BGR order. + factor (float): Same as :func:`mmcv.adjust_brightness`. + kernel (np.ndarray, optional): Filter kernel to be applied on the img + to obtain the degenerated img. Defaults to None. + + Note: + No value sanity check is enforced on the kernel set by users. So with + an inappropriate kernel, the ``adjust_sharpness`` may fail to perform + the function its name indicates but end up performing whatever + transform determined by the kernel. + + Returns: + ndarray: The sharpened image. + """ + + if kernel is None: + # adopted from PIL.ImageFilter.SMOOTH + kernel = np.array([[1., 1., 1.], [1., 5., 1.], [1., 1., 1.]]) / 13 + assert isinstance(kernel, np.ndarray), \ + f'kernel must be of type np.ndarray, but got {type(kernel)} instead.' + assert kernel.ndim == 2, \ + f'kernel must have a dimension of 2, but got {kernel.ndim} instead.' + + degenerated = cv2.filter2D(img, -1, kernel) + sharpened_img = cv2.addWeighted( + img.astype(np.float32), factor, degenerated.astype(np.float32), + 1 - factor, 0) + sharpened_img = np.clip(sharpened_img, 0, 255) + return sharpened_img.astype(img.dtype) + + +def adjust_lighting(img, eigval, eigvec, alphastd=0.1, to_rgb=True): + """AlexNet-style PCA jitter. + + This data augmentation is proposed in `ImageNet Classification with Deep + Convolutional Neural Networks + `_. + + Args: + img (ndarray): Image to be adjusted lighting. BGR order. + eigval (ndarray): the eigenvalue of the convariance matrix of pixel + values, respectively. + eigvec (ndarray): the eigenvector of the convariance matrix of pixel + values, respectively. + alphastd (float): The standard deviation for distribution of alpha. + Defaults to 0.1 + to_rgb (bool): Whether to convert img to rgb. + + Returns: + ndarray: The adjusted image. + """ + assert isinstance(eigval, np.ndarray) and isinstance(eigvec, np.ndarray), \ + f'eigval and eigvec should both be of type np.ndarray, got ' \ + f'{type(eigval)} and {type(eigvec)} instead.' + + assert eigval.ndim == 1 and eigvec.ndim == 2 + assert eigvec.shape == (3, eigval.shape[0]) + n_eigval = eigval.shape[0] + assert isinstance(alphastd, float), 'alphastd should be of type float, ' \ + f'got {type(alphastd)} instead.' + + img = img.copy().astype(np.float32) + if to_rgb: + cv2.cvtColor(img, cv2.COLOR_BGR2RGB, img) # inplace + + alpha = np.random.normal(0, alphastd, n_eigval) + alter = eigvec \ + * np.broadcast_to(alpha.reshape(1, n_eigval), (3, n_eigval)) \ + * np.broadcast_to(eigval.reshape(1, n_eigval), (3, n_eigval)) + alter = np.broadcast_to(alter.sum(axis=1).reshape(1, 1, 3), img.shape) + img_adjusted = img + alter + return img_adjusted + + +def lut_transform(img, lut_table): + """Transform array by look-up table. + + The function lut_transform fills the output array with values from the + look-up table. Indices of the entries are taken from the input array. + + Args: + img (ndarray): Image to be transformed. + lut_table (ndarray): look-up table of 256 elements; in case of + multi-channel input array, the table should either have a single + channel (in this case the same table is used for all channels) or + the same number of channels as in the input array. + + Returns: + ndarray: The transformed image. + """ + assert isinstance(img, np.ndarray) + assert 0 <= np.min(img) and np.max(img) <= 255 + assert isinstance(lut_table, np.ndarray) + assert lut_table.shape == (256, ) + + return cv2.LUT(np.array(img, dtype=np.uint8), lut_table) + + +def clahe(img, clip_limit=40.0, tile_grid_size=(8, 8)): + """Use CLAHE method to process the image. + + See `ZUIDERVELD,K. Contrast Limited Adaptive Histogram Equalization[J]. + Graphics Gems, 1994:474-485.` for more information. + + Args: + img (ndarray): Image to be processed. + clip_limit (float): Threshold for contrast limiting. Default: 40.0. + tile_grid_size (tuple[int]): Size of grid for histogram equalization. + Input image will be divided into equally sized rectangular tiles. + It defines the number of tiles in row and column. Default: (8, 8). + + Returns: + ndarray: The processed image. + """ + assert isinstance(img, np.ndarray) + assert img.ndim == 2 + assert isinstance(clip_limit, (float, int)) + assert is_tuple_of(tile_grid_size, int) + assert len(tile_grid_size) == 2 + + clahe = cv2.createCLAHE(clip_limit, tile_grid_size) + return clahe.apply(np.array(img, dtype=np.uint8)) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/model_zoo/deprecated.json b/cv/instance_segmentation/SOLO/pytorch/mmcv/model_zoo/deprecated.json new file mode 100644 index 000000000..25cf6f28c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/model_zoo/deprecated.json @@ -0,0 +1,6 @@ +{ + "resnet50_caffe": "detectron/resnet50_caffe", + "resnet50_caffe_bgr": "detectron2/resnet50_caffe_bgr", + "resnet101_caffe": "detectron/resnet101_caffe", + "resnet101_caffe_bgr": "detectron2/resnet101_caffe_bgr" +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/model_zoo/mmcls.json b/cv/instance_segmentation/SOLO/pytorch/mmcv/model_zoo/mmcls.json new file mode 100644 index 000000000..bdb311d9f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/model_zoo/mmcls.json @@ -0,0 +1,31 @@ +{ + "vgg11": "https://download.openmmlab.com/mmclassification/v0/vgg/vgg11_batch256_imagenet_20210208-4271cd6c.pth", + "vgg13": "https://download.openmmlab.com/mmclassification/v0/vgg/vgg13_batch256_imagenet_20210208-4d1d6080.pth", + "vgg16": "https://download.openmmlab.com/mmclassification/v0/vgg/vgg16_batch256_imagenet_20210208-db26f1a5.pth", + "vgg19": "https://download.openmmlab.com/mmclassification/v0/vgg/vgg19_batch256_imagenet_20210208-e6920e4a.pth", + "vgg11_bn": "https://download.openmmlab.com/mmclassification/v0/vgg/vgg11_bn_batch256_imagenet_20210207-f244902c.pth", + "vgg13_bn": "https://download.openmmlab.com/mmclassification/v0/vgg/vgg13_bn_batch256_imagenet_20210207-1a8b7864.pth", + "vgg16_bn": "https://download.openmmlab.com/mmclassification/v0/vgg/vgg16_bn_batch256_imagenet_20210208-7e55cd29.pth", + "vgg19_bn": "https://download.openmmlab.com/mmclassification/v0/vgg/vgg19_bn_batch256_imagenet_20210208-da620c4f.pth", + "resnet18": "https://download.openmmlab.com/mmclassification/v0/resnet/resnet18_batch256_imagenet_20200708-34ab8f90.pth", + "resnet34": "https://download.openmmlab.com/mmclassification/v0/resnet/resnet34_batch256_imagenet_20200708-32ffb4f7.pth", + "resnet50": "https://download.openmmlab.com/mmclassification/v0/resnet/resnet50_batch256_imagenet_20200708-cfb998bf.pth", + "resnet101": "https://download.openmmlab.com/mmclassification/v0/resnet/resnet101_batch256_imagenet_20200708-753f3608.pth", + "resnet152": "https://download.openmmlab.com/mmclassification/v0/resnet/resnet152_batch256_imagenet_20200708-ec25b1f9.pth", + "resnet50_v1d": "https://download.openmmlab.com/mmclassification/v0/resnet/resnetv1d50_batch256_imagenet_20200708-1ad0ce94.pth", + "resnet101_v1d": "https://download.openmmlab.com/mmclassification/v0/resnet/resnetv1d101_batch256_imagenet_20200708-9cb302ef.pth", + "resnet152_v1d": "https://download.openmmlab.com/mmclassification/v0/resnet/resnetv1d152_batch256_imagenet_20200708-e79cb6a2.pth", + "resnext50_32x4d": "https://download.openmmlab.com/mmclassification/v0/resnext/resnext50_32x4d_b32x8_imagenet_20210429-56066e27.pth", + "resnext101_32x4d": "https://download.openmmlab.com/mmclassification/v0/resnext/resnext101_32x4d_b32x8_imagenet_20210506-e0fa3dd5.pth", + "resnext101_32x8d": "https://download.openmmlab.com/mmclassification/v0/resnext/resnext101_32x8d_b32x8_imagenet_20210506-23a247d5.pth", + "resnext152_32x4d": "https://download.openmmlab.com/mmclassification/v0/resnext/resnext152_32x4d_b32x8_imagenet_20210524-927787be.pth", + "se-resnet50": "https://download.openmmlab.com/mmclassification/v0/se-resnet/se-resnet50_batch256_imagenet_20200804-ae206104.pth", + "se-resnet101": "https://download.openmmlab.com/mmclassification/v0/se-resnet/se-resnet101_batch256_imagenet_20200804-ba5b51d4.pth", + "resnest50": "https://download.openmmlab.com/mmclassification/v0/resnest/resnest50_imagenet_converted-1ebf0afe.pth", + "resnest101": "https://download.openmmlab.com/mmclassification/v0/resnest/resnest101_imagenet_converted-032caa52.pth", + "resnest200": "https://download.openmmlab.com/mmclassification/v0/resnest/resnest200_imagenet_converted-581a60f2.pth", + "resnest269": "https://download.openmmlab.com/mmclassification/v0/resnest/resnest269_imagenet_converted-59930960.pth", + "shufflenet_v1": "https://download.openmmlab.com/mmclassification/v0/shufflenet_v1/shufflenet_v1_batch1024_imagenet_20200804-5d6cec73.pth", + "shufflenet_v2": "https://download.openmmlab.com/mmclassification/v0/shufflenet_v2/shufflenet_v2_batch1024_imagenet_20200812-5bf4721e.pth", + "mobilenet_v2": "https://download.openmmlab.com/mmclassification/v0/mobilenet_v2/mobilenet_v2_batch256_imagenet_20200708-3b2dc3af.pth" +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/model_zoo/open_mmlab.json b/cv/instance_segmentation/SOLO/pytorch/mmcv/model_zoo/open_mmlab.json new file mode 100644 index 000000000..8311db4fe --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/model_zoo/open_mmlab.json @@ -0,0 +1,50 @@ +{ + "vgg16_caffe": "https://download.openmmlab.com/pretrain/third_party/vgg16_caffe-292e1171.pth", + "detectron/resnet50_caffe": "https://download.openmmlab.com/pretrain/third_party/resnet50_caffe-788b5fa3.pth", + "detectron2/resnet50_caffe": "https://download.openmmlab.com/pretrain/third_party/resnet50_msra-5891d200.pth", + "detectron/resnet101_caffe": "https://download.openmmlab.com/pretrain/third_party/resnet101_caffe-3ad79236.pth", + "detectron2/resnet101_caffe": "https://download.openmmlab.com/pretrain/third_party/resnet101_msra-6cc46731.pth", + "detectron2/resnext101_32x8d": "https://download.openmmlab.com/pretrain/third_party/resnext101_32x8d-1516f1aa.pth", + "resnext50_32x4d": "https://download.openmmlab.com/pretrain/third_party/resnext50-32x4d-0ab1a123.pth", + "resnext101_32x4d": "https://download.openmmlab.com/pretrain/third_party/resnext101_32x4d-a5af3160.pth", + "resnext101_64x4d": "https://download.openmmlab.com/pretrain/third_party/resnext101_64x4d-ee2c6f71.pth", + "contrib/resnet50_gn": "https://download.openmmlab.com/pretrain/third_party/resnet50_gn_thangvubk-ad1730dd.pth", + "detectron/resnet50_gn": "https://download.openmmlab.com/pretrain/third_party/resnet50_gn-9186a21c.pth", + "detectron/resnet101_gn": "https://download.openmmlab.com/pretrain/third_party/resnet101_gn-cac0ab98.pth", + "jhu/resnet50_gn_ws": "https://download.openmmlab.com/pretrain/third_party/resnet50_gn_ws-15beedd8.pth", + "jhu/resnet101_gn_ws": "https://download.openmmlab.com/pretrain/third_party/resnet101_gn_ws-3e3c308c.pth", + "jhu/resnext50_32x4d_gn_ws": "https://download.openmmlab.com/pretrain/third_party/resnext50_32x4d_gn_ws-0d87ac85.pth", + "jhu/resnext101_32x4d_gn_ws": "https://download.openmmlab.com/pretrain/third_party/resnext101_32x4d_gn_ws-34ac1a9e.pth", + "jhu/resnext50_32x4d_gn": "https://download.openmmlab.com/pretrain/third_party/resnext50_32x4d_gn-c7e8b754.pth", + "jhu/resnext101_32x4d_gn": "https://download.openmmlab.com/pretrain/third_party/resnext101_32x4d_gn-ac3bb84e.pth", + "msra/hrnetv2_w18_small": "https://download.openmmlab.com/pretrain/third_party/hrnetv2_w18_small-b5a04e21.pth", + "msra/hrnetv2_w18": "https://download.openmmlab.com/pretrain/third_party/hrnetv2_w18-00eb2006.pth", + "msra/hrnetv2_w32": "https://download.openmmlab.com/pretrain/third_party/hrnetv2_w32-dc9eeb4f.pth", + "msra/hrnetv2_w40": "https://download.openmmlab.com/pretrain/third_party/hrnetv2_w40-ed0b031c.pth", + "msra/hrnetv2_w48": "https://download.openmmlab.com/pretrain/third_party/hrnetv2_w48-d2186c55.pth", + "bninception_caffe": "https://download.openmmlab.com/pretrain/third_party/bn_inception_caffe-ed2e8665.pth", + "kin400/i3d_r50_f32s2_k400": "https://download.openmmlab.com/pretrain/third_party/i3d_r50_f32s2_k400-2c57e077.pth", + "kin400/nl3d_r50_f32s2_k400": "https://download.openmmlab.com/pretrain/third_party/nl3d_r50_f32s2_k400-fa7e7caa.pth", + "res2net101_v1d_26w_4s": "https://download.openmmlab.com/pretrain/third_party/res2net101_v1d_26w_4s_mmdetv2-f0a600f9.pth", + "regnetx_400mf": "https://download.openmmlab.com/pretrain/third_party/regnetx_400mf-a5b10d96.pth", + "regnetx_800mf": "https://download.openmmlab.com/pretrain/third_party/regnetx_800mf-1f4be4c7.pth", + "regnetx_1.6gf": "https://download.openmmlab.com/pretrain/third_party/regnetx_1.6gf-5791c176.pth", + "regnetx_3.2gf": "https://download.openmmlab.com/pretrain/third_party/regnetx_3.2gf-c2599b0f.pth", + "regnetx_4.0gf": "https://download.openmmlab.com/pretrain/third_party/regnetx_4.0gf-a88f671e.pth", + "regnetx_6.4gf": "https://download.openmmlab.com/pretrain/third_party/regnetx_6.4gf-006af45d.pth", + "regnetx_8.0gf": "https://download.openmmlab.com/pretrain/third_party/regnetx_8.0gf-3c68abe7.pth", + "regnetx_12gf": "https://download.openmmlab.com/pretrain/third_party/regnetx_12gf-4c2a3350.pth", + "resnet18_v1c": "https://download.openmmlab.com/pretrain/third_party/resnet18_v1c-b5776b93.pth", + "resnet50_v1c": "https://download.openmmlab.com/pretrain/third_party/resnet50_v1c-2cccc1ad.pth", + "resnet101_v1c": "https://download.openmmlab.com/pretrain/third_party/resnet101_v1c-e67eebb6.pth", + "mmedit/vgg16": "https://download.openmmlab.com/mmediting/third_party/vgg_state_dict.pth", + "mmedit/res34_en_nomixup": "https://download.openmmlab.com/mmediting/third_party/model_best_resnet34_En_nomixup.pth", + "mmedit/mobilenet_v2": "https://download.openmmlab.com/mmediting/third_party/mobilenet_v2.pth", + "contrib/mobilenet_v3_large": "https://download.openmmlab.com/pretrain/third_party/mobilenet_v3_large-bc2c3fd3.pth", + "contrib/mobilenet_v3_small": "https://download.openmmlab.com/pretrain/third_party/mobilenet_v3_small-47085aa1.pth", + "resnest50": "https://download.openmmlab.com/pretrain/third_party/resnest50_d2-7497a55b.pth", + "resnest101": "https://download.openmmlab.com/pretrain/third_party/resnest101_d2-f3b931b2.pth", + "resnest200": "https://download.openmmlab.com/pretrain/third_party/resnest200_d2-ca88e41f.pth", + "darknet53": "https://download.openmmlab.com/pretrain/third_party/darknet53-a628ea1b.pth", + "mmdet/mobilenet_v2": "https://download.openmmlab.com/mmdetection/v2.0/third_party/mobilenet_v2_batch256_imagenet-ff34753d.pth" +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/__init__.py new file mode 100644 index 000000000..7a100d849 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/__init__.py @@ -0,0 +1,13 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .deprecated_wrappers import Conv2d_deprecated as Conv2d +from .deprecated_wrappers import ConvTranspose2d_deprecated as ConvTranspose2d +from .deprecated_wrappers import Linear_deprecated as Linear +from .deprecated_wrappers import MaxPool2d_deprecated as MaxPool2d +from .focal_loss import (SigmoidFocalLoss, SoftmaxFocalLoss, + sigmoid_focal_loss, softmax_focal_loss) +from .info import (get_compiler_version, get_compiling_cuda_version, + get_onnxruntime_op_path) +from .nms import batched_nms, nms, nms_match, soft_nms +from .roi_align import RoIAlign, roi_align +from .roi_pool import RoIPool, roi_pool +from .sync_bn import SyncBatchNorm \ No newline at end of file diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/README.md b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/README.md new file mode 100644 index 000000000..91c237f3d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/README.md @@ -0,0 +1,169 @@ +# Code Structure of CUDA operators + +This folder contains all non-python code for MMCV custom ops. Please follow the same architecture if you want to add new ops. + +## Directories Tree + +```folder +. +├── common +│ ├── box_iou_rotated_utils.hpp +│ ├── parrots_cpp_helper.hpp +│ ├── parrots_cuda_helper.hpp +│ ├── pytorch_cpp_helper.hpp +│ ├── pytorch_cuda_helper.hpp +│   └── cuda +│   ├── common_cuda_helper.hpp +│   ├── parrots_cudawarpfunction.cuh +│   ├── ... +│   └── ops_cuda_kernel.cuh +├── onnxruntime +│   ├── onnxruntime_register.h +│   ├── onnxruntime_session_options_config_keys.h +│   ├── ort_mmcv_utils.h +│   ├── ... +│   ├── onnx_ops.h +│   └── cpu +│ ├── onnxruntime_register.cpp +│      ├── ... +│      └── onnx_ops_impl.cpp +├── parrots +│   ├── ... +│   ├── ops.cpp +│   ├── ops_parrots.cpp +│   └── ops_pytorch.h +├── pytorch +│   ├── info.cpp +│   ├── pybind.cpp +│   ├── ... +│   ├── ops.cpp +│   └── cuda +│      ├── ... +│      └── ops_cuda.cu +└── tensorrt + ├── trt_cuda_helper.cuh + ├── trt_plugin_helper.hpp + ├── trt_plugin.hpp + ├── trt_serialize.hpp + ├── ... + ├── trt_ops.hpp + └── plugins +    ├── trt_cuda_helper.cu +    ├── trt_plugin.cpp +    ├── ... +    ├── trt_ops.cpp +    └── trt_ops_kernel.cu +``` + +## Components + +- `common`: This directory contains all tools and shared codes. + - `cuda`: The cuda kernels which can be shared by all backends. **HIP** kernel is also here since they have similar syntax. +- `onnxruntime`: **ONNX Runtime** support for custom ops. + - `cpu`: CPU implementation of supported ops. +- `parrots`: **Parrots** is a deep learning frame for model training and inference. Parrots custom ops are placed in this directory. +- `pytorch`: **PyTorch** custom ops are supported by binding C++ to Python with **pybind11**. The ops implementation and binding codes are placed in this directory. + - `cuda`: This directory contains cuda kernel launchers, which feed memory pointers of tensor to the cuda kernel in `common/cuda`. The launchers provide c++ interface of cuda implementation of corresponding custom ops. +- `tensorrt`: **TensorRT** support for custom ops. + - `plugins`: This directory contains the implementation of the supported custom ops. Some ops might also use shared cuda kernel in `common/cuda`. + +## How to add new PyTorch ops? + +1. (Optional) Add shared kernel in `common` to support special hardware platform. + + ```c++ + // src/common/cuda/new_ops_cuda_kernel.cuh + + template + __global__ void new_ops_forward_cuda_kernel(const T* input, T* output, ...) { + // forward here + } + + ``` + + Add cuda kernel launcher in `pytorch/cuda`. + + ```c++ + // src/pytorch/cuda + #include + + void NewOpsForwardCUDAKernelLauncher(Tensor input, Tensor output, ...){ + // initialize + at::cuda::CUDAGuard device_guard(input.device()); + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + ... + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + input.scalar_type(), "new_ops_forward_cuda_kernel", ([&] { + new_ops_forward_cuda_kernel + <<>>( + input.data_ptr(), output.data_ptr(),...); + })); + AT_CUDA_CHECK(cudaGetLastError()); + } + ``` + +2. Add ops implementation in `pytorch` directory. Select different implementations according to device type. + + ```c++ + // src/pytorch/new_ops.cpp + #ifdef MMCV_WITH_CUDA + Tensor new_ops_forward_cuda(Tensor input, Tensor output, ...){ + // implement cuda forward here + // use `NewOpsForwardCUDAKernelLauncher` here + } + #else + + Tensor new_ops_forward_cpu(Tensor input, Tensor output, ...){ + // implement cpu forward here + } + + ... + + Tensor new_ops_forward(Tensor input, Tensor output, ...){ + // select implementation by input device type + if (boxes.device().is_cuda()) { + #ifdef MMCV_WITH_CUDA + CHECK_CUDA_INPUT(input); + CHECK_CUDA_INPUT(output); + return new_ops_forward_cuda(input, output, ...); + #else + AT_ERROR("new ops is not compiled with GPU support"); + #endif + } else { + CHECK_CPU_INPUT(input); + CHECK_CPU_INPUT(output); + return new_ops_forward_cpu(input, output, ...); + } + } + ``` + +3. Binding the implementation in `pytorch/pybind.cpp` + + ```c++ + // src/pytorch/pybind.cpp + + ... + + Tensor new_ops_forward(Tensor input, Tensor output, ...); + + ... + + // bind with pybind11 + m.def("new_ops_forward", &new_ops_forward, "new_ops_forward", + py::arg("input"), py::arg("output"), ...); + + ... + + ``` + +4. Build MMCV again. Enjoy new ops in python + + ```python + from ..utils import ext_loader + ext_module = ext_loader.load_ext('_ext', ['new_ops_forward']) + + ... + + ext_module.new_ops_forward(input, output, ...) + + ``` diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/common_cuda_helper.hpp b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/common_cuda_helper.hpp new file mode 100644 index 000000000..a1e926adb --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/common_cuda_helper.hpp @@ -0,0 +1,112 @@ +#ifndef COMMON_CUDA_HELPER +#define COMMON_CUDA_HELPER + +#include + +#define CUDA_1D_KERNEL_LOOP(i, n) \ + for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < (n); \ + i += blockDim.x * gridDim.x) + +#define THREADS_PER_BLOCK 512 + +#define DIVUP(m, n) ((m) / (n) + ((m) % (n) > 0)) + +inline int GET_BLOCKS(const int N) { + int optimal_block_num = (N + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK; + int max_block_num = 4096; + return std::min(optimal_block_num, max_block_num); +} + +template +__device__ T bilinear_interpolate(const T* input, const int height, + const int width, T y, T x, + const int index /* index for debug only*/) { + // deal with cases that inverse elements are out of feature map boundary + if (y < -1.0 || y > height || x < -1.0 || x > width) return 0; + + if (y <= 0) y = 0; + if (x <= 0) x = 0; + + int y_low = (int)y; + int x_low = (int)x; + int y_high; + int x_high; + + if (y_low >= height - 1) { + y_high = y_low = height - 1; + y = (T)y_low; + } else { + y_high = y_low + 1; + } + + if (x_low >= width - 1) { + x_high = x_low = width - 1; + x = (T)x_low; + } else { + x_high = x_low + 1; + } + + T ly = y - y_low; + T lx = x - x_low; + T hy = 1. - ly, hx = 1. - lx; + // do bilinear interpolation + T v1 = input[y_low * width + x_low]; + T v2 = input[y_low * width + x_high]; + T v3 = input[y_high * width + x_low]; + T v4 = input[y_high * width + x_high]; + T w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; + + T val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); + + return val; +} + +template +__device__ void bilinear_interpolate_gradient( + const int height, const int width, T y, T x, T& w1, T& w2, T& w3, T& w4, + int& x_low, int& x_high, int& y_low, int& y_high, + const int index /* index for debug only*/) { + // deal with cases that inverse elements are out of feature map boundary + if (y < -1.0 || y > height || x < -1.0 || x > width) { + // empty + w1 = w2 = w3 = w4 = 0.; + x_low = x_high = y_low = y_high = -1; + return; + } + + if (y <= 0) y = 0; + if (x <= 0) x = 0; + + y_low = (int)y; + x_low = (int)x; + + if (y_low >= height - 1) { + y_high = y_low = height - 1; + y = (T)y_low; + } else { + y_high = y_low + 1; + } + + if (x_low >= width - 1) { + x_high = x_low = width - 1; + x = (T)x_low; + } else { + x_high = x_low + 1; + } + + T ly = y - y_low; + T lx = x - x_low; + T hy = 1. - ly, hx = 1. - lx; + + // reference in forward + // T v1 = input[y_low * width + x_low]; + // T v2 = input[y_low * width + x_high]; + // T v3 = input[y_high * width + x_low]; + // T v4 = input[y_high * width + x_high]; + // T val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); + + w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; + + return; +} +#endif // COMMON_CUDA_HELPER diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/nms_cuda_kernel.cuh b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/nms_cuda_kernel.cuh new file mode 100644 index 000000000..40a2f4622 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/nms_cuda_kernel.cuh @@ -0,0 +1,74 @@ +// Copyright (c) OpenMMLab. All rights reserved +#ifndef NMS_CUDA_KERNEL_CUH +#define NMS_CUDA_KERNEL_CUH + +#include +#ifdef MMCV_WITH_TRT +#include "common_cuda_helper.hpp" +#else // MMCV_WITH_TRT +#ifdef MMCV_USE_PARROTS +#include "parrots_cuda_helper.hpp" +#else // MMCV_USE_PARROTS +#include "pytorch_cuda_helper.hpp" +#endif // MMCV_USE_PARROTS +#endif // MMCV_WITH_TRT + +int const threadsPerBlock = sizeof(unsigned long long int) * 8; + +__device__ inline bool devIoU(float const *const a, float const *const b, + const int offset, const float threshold) { + float left = fmaxf(a[0], b[0]), right = fminf(a[2], b[2]); + float top = fmaxf(a[1], b[1]), bottom = fminf(a[3], b[3]); + float width = fmaxf(right - left + offset, 0.f), + height = fmaxf(bottom - top + offset, 0.f); + float interS = width * height; + float Sa = (a[2] - a[0] + offset) * (a[3] - a[1] + offset); + float Sb = (b[2] - b[0] + offset) * (b[3] - b[1] + offset); + return interS > threshold * (Sa + Sb - interS); +} + +__global__ void nms_cuda(const int n_boxes, const float iou_threshold, + const int offset, const float *dev_boxes, + unsigned long long *dev_mask) { + const int row_start = blockIdx.y; + const int col_start = blockIdx.x; + const int tid = threadIdx.x; + + if (row_start > col_start) return; + + const int row_size = + fminf(n_boxes - row_start * threadsPerBlock, threadsPerBlock); + const int col_size = + fminf(n_boxes - col_start * threadsPerBlock, threadsPerBlock); + + __shared__ float block_boxes[threadsPerBlock * 4]; + if (tid < col_size) { + block_boxes[tid * 4 + 0] = + dev_boxes[(threadsPerBlock * col_start + tid) * 4 + 0]; + block_boxes[tid * 4 + 1] = + dev_boxes[(threadsPerBlock * col_start + tid) * 4 + 1]; + block_boxes[tid * 4 + 2] = + dev_boxes[(threadsPerBlock * col_start + tid) * 4 + 2]; + block_boxes[tid * 4 + 3] = + dev_boxes[(threadsPerBlock * col_start + tid) * 4 + 3]; + } + __syncthreads(); + + if (tid < row_size) { + const int cur_box_idx = threadsPerBlock * row_start + tid; + const float *cur_box = dev_boxes + cur_box_idx * 4; + int i = 0; + unsigned long long int t = 0; + int start = 0; + if (row_start == col_start) { + start = tid + 1; + } + for (i = start; i < col_size; i++) { + if (devIoU(cur_box, block_boxes + i * 4, offset, iou_threshold)) { + t |= 1ULL << i; + } + } + dev_mask[cur_box_idx * gridDim.y + col_start] = t; + } +} +#endif // NMS_CUDA_KERNEL_CUH diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/nms_rotated_cuda.cuh b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/nms_rotated_cuda.cuh new file mode 100644 index 000000000..80bed9681 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/nms_rotated_cuda.cuh @@ -0,0 +1,135 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved +// modified from +// https://github.com/facebookresearch/detectron2/blob/master/detectron2/layers/csrc/nms_rotated/nms_rotated_cuda.cu +#ifndef NMS_ROTATED_CUDA_CUH +#define NMS_ROTATED_CUDA_CUH + +#ifdef MMCV_USE_PARROTS +#include "parrots_cuda_helper.hpp" +#else +#include "pytorch_cuda_helper.hpp" +#endif +#include "box_iou_rotated_utils.hpp" + +__host__ __device__ inline int divideUP(const int x, const int y) { + return (((x) + (y)-1) / (y)); +} + +namespace { +int const threadsPerBlock = sizeof(unsigned long long) * 8; +} + +template +__global__ void nms_rotated_cuda_kernel(const int n_boxes, + const float iou_threshold, + const T* dev_boxes, + unsigned long long* dev_mask, + const int multi_label) { + // nms_rotated_cuda_kernel is modified from torchvision's nms_cuda_kernel + + if (multi_label == 1) { + const int row_start = blockIdx.y; + const int col_start = blockIdx.x; + + // if (row_start > col_start) return; + + const int row_size = + min(n_boxes - row_start * threadsPerBlock, threadsPerBlock); + const int col_size = + min(n_boxes - col_start * threadsPerBlock, threadsPerBlock); + + // Compared to nms_cuda_kernel, where each box is represented with 4 values + // (x1, y1, x2, y2), each rotated box is represented with 5 values + // (x_center, y_center, width, height, angle_degrees) here. + __shared__ T block_boxes[threadsPerBlock * 5]; + if (threadIdx.x < col_size) { + block_boxes[threadIdx.x * 6 + 0] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 6 + 0]; + block_boxes[threadIdx.x * 6 + 1] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 6 + 1]; + block_boxes[threadIdx.x * 6 + 2] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 6 + 2]; + block_boxes[threadIdx.x * 6 + 3] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 6 + 3]; + block_boxes[threadIdx.x * 6 + 4] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 6 + 4]; + block_boxes[threadIdx.x * 6 + 5] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 6 + 5]; + } + __syncthreads(); + + if (threadIdx.x < row_size) { + const int cur_box_idx = threadsPerBlock * row_start + threadIdx.x; + const T* cur_box = dev_boxes + cur_box_idx * 6; + int i = 0; + unsigned long long t = 0; + int start = 0; + if (row_start == col_start) { + start = threadIdx.x + 1; + } + for (i = start; i < col_size; i++) { + // Instead of devIoU used by original horizontal nms, here + // we use the single_box_iou_rotated function from + // box_iou_rotated_utils.h + if (single_box_iou_rotated(cur_box, block_boxes + i * 6, 0) > + iou_threshold) { + t |= 1ULL << i; + } + } + const int col_blocks = divideUP(n_boxes, threadsPerBlock); + dev_mask[cur_box_idx * col_blocks + col_start] = t; + } + } else { + const int row_start = blockIdx.y; + const int col_start = blockIdx.x; + + // if (row_start > col_start) return; + + const int row_size = + min(n_boxes - row_start * threadsPerBlock, threadsPerBlock); + const int col_size = + min(n_boxes - col_start * threadsPerBlock, threadsPerBlock); + + // Compared to nms_cuda_kernel, where each box is represented with 4 values + // (x1, y1, x2, y2), each rotated box is represented with 5 values + // (x_center, y_center, width, height, angle_degrees) here. + __shared__ T block_boxes[threadsPerBlock * 5]; + if (threadIdx.x < col_size) { + block_boxes[threadIdx.x * 5 + 0] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 0]; + block_boxes[threadIdx.x * 5 + 1] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 1]; + block_boxes[threadIdx.x * 5 + 2] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 2]; + block_boxes[threadIdx.x * 5 + 3] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 3]; + block_boxes[threadIdx.x * 5 + 4] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 4]; + } + __syncthreads(); + + if (threadIdx.x < row_size) { + const int cur_box_idx = threadsPerBlock * row_start + threadIdx.x; + const T* cur_box = dev_boxes + cur_box_idx * 5; + int i = 0; + unsigned long long t = 0; + int start = 0; + if (row_start == col_start) { + start = threadIdx.x + 1; + } + for (i = start; i < col_size; i++) { + // Instead of devIoU used by original horizontal nms, here + // we use the single_box_iou_rotated function from + // box_iou_rotated_utils.h + if (single_box_iou_rotated(cur_box, block_boxes + i * 5, 0) > + iou_threshold) { + t |= 1ULL << i; + } + } + const int col_blocks = divideUP(n_boxes, threadsPerBlock); + dev_mask[cur_box_idx * col_blocks + col_start] = t; + } + } +} + +#endif diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/roi_align_cuda_kernel.cuh b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/roi_align_cuda_kernel.cuh new file mode 100644 index 000000000..4541462af --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/roi_align_cuda_kernel.cuh @@ -0,0 +1,212 @@ +// Copyright (c) OpenMMLab. All rights reserved +#ifndef ROI_ALIGN_CUDA_KERNEL_CUH +#define ROI_ALIGN_CUDA_KERNEL_CUH + +#include +#ifdef MMCV_WITH_TRT +#include "common_cuda_helper.hpp" +#else // MMCV_WITH_TRT +#ifdef MMCV_USE_PARROTS +#include "parrots_cuda_helper.hpp" +#else // MMCV_USE_PARROTS +#include "pytorch_cuda_helper.hpp" +#endif // MMCV_USE_PARROTS +#endif // MMCV_WITH_TRT + +/*** Forward ***/ +template +__global__ void roi_align_forward_cuda_kernel( + const int nthreads, const T* input, const T* rois, T* output, T* argmax_y, + T* argmax_x, const int pooled_height, const int pooled_width, + const T spatial_scale, const int sampling_ratio, + const int pool_mode, // 0 - max pool, 1 - avg pool + const bool aligned, const int channels, const int height, const int width) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + // (n, c, ph, pw) is an element in the pooled output + int pw = index % pooled_width; + int ph = (index / pooled_width) % pooled_height; + int c = (index / pooled_width / pooled_height) % channels; + int n = index / pooled_width / pooled_height / channels; + + const T* offset_rois = rois + n * 5; + int roi_batch_ind = offset_rois[0]; + + // Do not using rounding; this implementation detail is critical + T offset = aligned ? (T)0.5 : (T)0.0; + T roi_start_w = offset_rois[1] * spatial_scale - offset; + T roi_start_h = offset_rois[2] * spatial_scale - offset; + T roi_end_w = offset_rois[3] * spatial_scale - offset; + T roi_end_h = offset_rois[4] * spatial_scale - offset; + + T roi_width = roi_end_w - roi_start_w; + T roi_height = roi_end_h - roi_start_h; + if (!aligned) { // for backward-compatibility only + roi_width = max(roi_width, (T)1.); + roi_height = max(roi_height, (T)1.); + } + + T bin_size_h = static_cast(roi_height) / static_cast(pooled_height); + T bin_size_w = static_cast(roi_width) / static_cast(pooled_width); + + const T* offset_input = + input + (roi_batch_ind * channels + c) * height * width; + + // We use roi_bin_grid to sample the grid and mimic integral + int roi_bin_grid_h = + (sampling_ratio > 0) + ? sampling_ratio + : static_cast(ceilf(roi_height / pooled_height)); + int roi_bin_grid_w = + (sampling_ratio > 0) + ? sampling_ratio + : static_cast(ceilf(roi_width / pooled_width)); + + if (pool_mode == 0) { + // We do max pooling inside a bin + T maxval = -FLT_MAX; + T maxidx_y = -1.f, maxidx_x = -1.f; + for (int iy = 0; iy < roi_bin_grid_h; iy++) { + const T y = roi_start_h + ph * bin_size_h + + static_cast(iy + .5f) * bin_size_h / + static_cast(roi_bin_grid_h); + for (int ix = 0; ix < roi_bin_grid_w; ix++) { + const T x = roi_start_w + pw * bin_size_w + + static_cast(ix + .5f) * bin_size_w / + static_cast(roi_bin_grid_w); + T val = + bilinear_interpolate(offset_input, height, width, y, x, index); + if (val > maxval) { + maxval = val; + maxidx_y = y; + maxidx_x = x; + } + } + } + output[index] = maxval; + argmax_y[index] = maxidx_y; + argmax_x[index] = maxidx_x; + } else if (pool_mode == 1) { + // We do average pooling inside a bin + const T count = max(roi_bin_grid_h * roi_bin_grid_w, 1); + T output_val = 0.; + for (int iy = 0; iy < roi_bin_grid_h; iy++) { + const T y = roi_start_h + ph * bin_size_h + + static_cast(iy + .5f) * bin_size_h / + static_cast(roi_bin_grid_h); + for (int ix = 0; ix < roi_bin_grid_w; ix++) { + const T x = roi_start_w + pw * bin_size_w + + static_cast(ix + .5f) * bin_size_w / + static_cast(roi_bin_grid_w); + T val = + bilinear_interpolate(offset_input, height, width, y, x, index); + output_val += val; + } + } + output[index] = output_val / count; + } + } +} + +/*** Backward ***/ +template +__global__ void roi_align_backward_cuda_kernel( + const int nthreads, const T* grad_output, const T* rois, const T* argmax_y, + const T* argmax_x, T* grad_input, const int pooled_height, + const int pooled_width, const T spatial_scale, const int sampling_ratio, + const int pool_mode, // 0 - max pool, 1 - avg pool + const bool aligned, const int channels, const int height, const int width) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + // (n, c, ph, pw) is an element in the pooled output + int pw = index % pooled_width; + int ph = (index / pooled_width) % pooled_height; + int c = (index / pooled_width / pooled_height) % channels; + int n = index / pooled_width / pooled_height / channels; + + const T grad_output_this_bin = grad_output[index]; + + const T* offset_rois = rois + n * 5; + int roi_batch_ind = offset_rois[0]; + T* offset_grad_input = + grad_input + ((roi_batch_ind * channels + c) * height * width); + + if (pool_mode == 0) { + T y = argmax_y[index], x = argmax_x[index]; + if (y != -1.f) { + T w1, w2, w3, w4; + int x_low, x_high, y_low, y_high; + bilinear_interpolate_gradient(height, width, y, x, w1, w2, w3, w4, + x_low, x_high, y_low, y_high, index); + + if (x_low >= 0 && x_high >= 0 && y_low >= 0 && y_high >= 0) { + atomicAdd(offset_grad_input + y_low * width + x_low, + grad_output_this_bin * w1); + atomicAdd(offset_grad_input + y_low * width + x_high, + grad_output_this_bin * w2); + atomicAdd(offset_grad_input + y_high * width + x_low, + grad_output_this_bin * w3); + atomicAdd(offset_grad_input + y_high * width + x_high, + grad_output_this_bin * w4); + } + } + } else if (pool_mode == 1) { + // Do not using rounding; this implementation detail is critical + T offset = aligned ? (T)0.5 : (T)0.0; + T roi_start_w = offset_rois[1] * spatial_scale - offset; + T roi_start_h = offset_rois[2] * spatial_scale - offset; + T roi_end_w = offset_rois[3] * spatial_scale - offset; + T roi_end_h = offset_rois[4] * spatial_scale - offset; + + T roi_width = roi_end_w - roi_start_w; + T roi_height = roi_end_h - roi_start_h; + if (!aligned) { // for backward-compatibility only + roi_width = max(roi_width, (T)1.); + roi_height = max(roi_height, (T)1.); + } + + T bin_size_h = static_cast(roi_height) / static_cast(pooled_height); + T bin_size_w = static_cast(roi_width) / static_cast(pooled_width); + + // We use roi_bin_grid to sample the grid and mimic integral + int roi_bin_grid_h = + (sampling_ratio > 0) + ? sampling_ratio + : static_cast(ceilf(roi_height / pooled_height)); + int roi_bin_grid_w = + (sampling_ratio > 0) + ? sampling_ratio + : static_cast(ceilf(roi_width / pooled_width)); + + // We do average (integral) pooling inside a bin + const T count = roi_bin_grid_h * roi_bin_grid_w; // e.g. = 4 + + for (int iy = 0; iy < roi_bin_grid_h; iy++) { + const T y = roi_start_h + ph * bin_size_h + + static_cast(iy + .5f) * bin_size_h / + static_cast(roi_bin_grid_h); + for (int ix = 0; ix < roi_bin_grid_w; ix++) { + const T x = roi_start_w + pw * bin_size_w + + static_cast(ix + .5f) * bin_size_w / + static_cast(roi_bin_grid_w); + + T w1, w2, w3, w4; + int x_low, x_high, y_low, y_high; + bilinear_interpolate_gradient(height, width, y, x, w1, w2, w3, w4, + x_low, x_high, y_low, y_high, index); + + if (x_low >= 0 && x_high >= 0 && y_low >= 0 && y_high >= 0) { + atomicAdd(offset_grad_input + y_low * width + x_low, + grad_output_this_bin * w1 / count); + atomicAdd(offset_grad_input + y_low * width + x_high, + grad_output_this_bin * w2 / count); + atomicAdd(offset_grad_input + y_high * width + x_low, + grad_output_this_bin * w3 / count); + atomicAdd(offset_grad_input + y_high * width + x_high, + grad_output_this_bin * w4 / count); + } + } + } + } + } +} + +#endif // ROI_ALIGN_CUDA_KERNEL_CUH diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/roi_pool_cuda_kernel.cuh b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/roi_pool_cuda_kernel.cuh new file mode 100644 index 000000000..3d7eae66b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/roi_pool_cuda_kernel.cuh @@ -0,0 +1,93 @@ +// Copyright (c) OpenMMLab. All rights reserved +#ifndef ROI_POOL_CUDA_KERNEL_CUH +#define ROI_POOL_CUDA_KERNEL_CUH + +#ifdef MMCV_USE_PARROTS +#include "parrots_cuda_helper.hpp" +#else +#include "pytorch_cuda_helper.hpp" +#endif + +template +__global__ void roi_pool_forward_cuda_kernel( + const int nthreads, const T* input, const T* rois, T* output, int* argmax, + const int pooled_height, const int pooled_width, const T spatial_scale, + const int channels, const int height, const int width) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + // (n, c, ph, pw) is an element in the pooled output + int pw = index % pooled_width; + int ph = (index / pooled_width) % pooled_height; + int c = (index / pooled_width / pooled_height) % channels; + int n = index / pooled_width / pooled_height / channels; + + const T* offset_rois = rois + n * 5; + int roi_batch_ind = offset_rois[0]; + // calculate the roi region on feature maps + T roi_x1 = offset_rois[1] * spatial_scale; + T roi_y1 = offset_rois[2] * spatial_scale; + T roi_x2 = (offset_rois[3] + 1) * spatial_scale; + T roi_y2 = (offset_rois[4] + 1) * spatial_scale; + + // force malformed rois to be 1x1 + T roi_w = roi_x2 - roi_x1; + T roi_h = roi_y2 - roi_y1; + if (roi_w <= 0 || roi_h <= 0) continue; + + T bin_size_w = roi_w / static_cast(pooled_width); + T bin_size_h = roi_h / static_cast(pooled_height); + + // the corresponding bin region + int bin_x1 = floorf(static_cast(pw) * bin_size_w + roi_x1); + int bin_y1 = floorf(static_cast(ph) * bin_size_h + roi_y1); + int bin_x2 = ceilf(static_cast(pw + 1) * bin_size_w + roi_x1); + int bin_y2 = ceilf(static_cast(ph + 1) * bin_size_h + roi_y1); + + // add roi offsets and clip to input boundaries + bin_x1 = min(max(bin_x1, 0), width); + bin_y1 = min(max(bin_y1, 0), height); + bin_x2 = min(max(bin_x2, 0), width); + bin_y2 = min(max(bin_y2, 0), height); + bool is_empty = (bin_y2 <= bin_y1) || (bin_x2 <= bin_x1); + + const T* offset_input = + input + (roi_batch_ind * channels + c) * height * width; + // Define an empty pooling region to be zero + // If nothing is pooled, argmax = -1 causes nothing to be backprop'd + T max_val = is_empty ? 0 : -FLT_MAX; + int max_idx = -1; + for (int h = bin_y1; h < bin_y2; ++h) { + for (int w = bin_x1; w < bin_x2; ++w) { + int offset = h * width + w; + if (offset_input[offset] > max_val) { + max_val = offset_input[offset]; + max_idx = offset; + } + } + } + output[index] = max_val; + if (argmax != NULL) argmax[index] = max_idx; + } +} + +template +__global__ void roi_pool_backward_cuda_kernel( + const int nthreads, const T* grad_output, const T* rois, const int* argmax, + T* grad_input, const int pooled_height, const int pooled_width, + const int channels, const int height, const int width) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + // (n, c) is an element in the pooled output + int c = (index / pooled_width / pooled_height) % channels; + int n = index / pooled_width / pooled_height / channels; + + int roi_batch_ind = rois[n * 5]; + T* grad_input_offset = + grad_input + ((roi_batch_ind * channels + c) * height * width); + int argmax_index = argmax[index]; + + if (argmax_index != -1) { + atomicAdd(grad_input_offset + argmax_index, grad_output[index]); + } + } +} + +#endif // ROI_POOL_CUDA_KERNEL_CUH diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/sigmoid_focal_loss_cuda_kernel.cuh b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/sigmoid_focal_loss_cuda_kernel.cuh new file mode 100644 index 000000000..1eb5f8fcc --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/sigmoid_focal_loss_cuda_kernel.cuh @@ -0,0 +1,71 @@ +// Copyright (c) OpenMMLab. All rights reserved +#ifndef SIGMOID_FOCAL_LOSS_CUDA_KERNEL_CUH +#define SIGMOID_FOCAL_LOSS_CUDA_KERNEL_CUH + +#ifdef MMCV_USE_PARROTS +#include "parrots_cuda_helper.hpp" +#else +#include "pytorch_cuda_helper.hpp" +#endif + +template +__global__ void sigmoid_focal_loss_forward_cuda_kernel( + const int nthreads, const T* input, const int64_t* target, const T* weight, + T* output, const T gamma, const T alpha, const int num_classes) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + int n = index / num_classes; + int c = index % num_classes; + + int64_t t = target[n]; + T flag_p = (t == c); + T flag_n = (t != c); + + // p = sigmoid(x) = 1. / 1. + expf(-x) + T p = (T)1. / ((T)1. + expf(-input[index])); + + // (1 - p)**gamma * log(p) + T term_p = pow(((T)1. - p), gamma) * log(max(p, (T)FLT_MIN)); + // p**gamma * log(1 - p) + T term_n = pow(p, gamma) * log(max((T)1. - p, (T)FLT_MIN)); + + output[index] = (T)0.; + output[index] += -flag_p * alpha * term_p; + output[index] += -flag_n * ((T)1. - alpha) * term_n; + if (weight != NULL) { + output[index] *= weight[t]; + } + } +} + +template +__global__ void sigmoid_focal_loss_backward_cuda_kernel( + const int nthreads, const T* input, const int64_t* target, const T* weight, + T* grad_input, const T gamma, const T alpha, const int num_classes) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + int n = index / num_classes; + int c = index % num_classes; + + int64_t t = target[n]; + T flag_p = (t == c); + T flag_n = (t != c); + + // p = sigmoid(x) = 1. / 1. + expf(-x) + T p = (T)1. / ((T)1. + exp(-input[index])); + + // (1 - p)**gamma * (1 - p - gamma*p*log(p)) + T term_p = pow(((T)1. - p), gamma) * + ((T)1. - p - (gamma * p * log(max(p, (T)FLT_MIN)))); + // p**gamma * (gamma * (1 - p) * log(1 - p) - p) + T term_n = pow(p, gamma) * + (gamma * ((T)1. - p) * log(max((T)1. - p, (T)FLT_MIN)) - p); + + grad_input[index] = (T)0.; + grad_input[index] += -flag_p * alpha * term_p; + grad_input[index] += -flag_n * ((T)1. - alpha) * term_n; + if (weight != NULL) { + grad_input[index] *= weight[t]; + } + } +} + +#endif // SIGMOID_FOCAL_LOSS_CUDA_KERNEL_CUH diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/softmax_focal_loss_cuda_kernel.cuh b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/softmax_focal_loss_cuda_kernel.cuh new file mode 100644 index 000000000..631b2c617 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/softmax_focal_loss_cuda_kernel.cuh @@ -0,0 +1,72 @@ +// Copyright (c) OpenMMLab. All rights reserved +#ifndef SOFTMAX_FOCAL_LOSS_CUDA_KERNEL_CUH +#define SOFTMAX_FOCAL_LOSS_CUDA_KERNEL_CUH + +#ifdef MMCV_USE_PARROTS +#include "parrots_cuda_helper.hpp" +#else +#include "pytorch_cuda_helper.hpp" +#endif + +template +__global__ void softmax_focal_loss_forward_cuda_kernel( + const int nthreads, const T* softmax, const int64_t* target, + const T* weight, T* output, const T gamma, const T alpha, + const int num_classes) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + int64_t label = target[index]; + T pred = softmax[index * num_classes + label]; + + if (label >= 0) { + output[index] = + -alpha * pow((T)1. - pred, gamma) * log(max(pred, (T)FLT_MIN)); + } else { + output[index] = 0; + } + if (weight != NULL) { + output[index] *= weight[label]; + } + } +} + +template +__global__ void softmax_focal_loss_backward_cuda1_kernel( + const int nthreads, const T* softmax, const int64_t* target, + const T* weight, T* buff, const T gamma, const T alpha, + const int num_classes) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + int64_t label = target[index]; + T pred = softmax[index * num_classes + label]; + + if (label >= 0) { + buff[index] = alpha * (-pow((T)1. - pred, gamma) + + gamma * pow((T)1. - pred, gamma - 1) * pred * + log(max(pred, (T)FLT_MIN))); + } else { + buff[index] = 0; + } + if (weight != NULL) { + buff[index] *= weight[label]; + } + } +} + +template +__global__ void softmax_focal_loss_backward_cuda2_kernel( + const int nthreads, const T* softmax, const int64_t* target, const T* buff, + T* grad_input, const int num_classes) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + int n = index / num_classes; + int c = index % num_classes; + int64_t label = target[n]; + + if (label >= 0) { + T flag = (label == c ? (T)1. : (T)0.); + grad_input[index] = buff[n] * (flag - softmax[index]); + } else { + grad_input[index] = 0; + } + } +} + +#endif // SOFTMAX_FOCAL_LOSS_CUDA_KERNEL_CUH diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/sync_bn_cuda_kernel.cuh b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/sync_bn_cuda_kernel.cuh new file mode 100644 index 000000000..4ec6a4668 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/cuda/sync_bn_cuda_kernel.cuh @@ -0,0 +1,331 @@ +// Copyright (c) OpenMMLab. All rights reserved +#ifndef SYNCBN_CUDA_KERNEL_CUH +#define SYNCBN_CUDA_KERNEL_CUH + +#ifdef MMCV_USE_PARROTS +#include "parrots_cuda_helper.hpp" +#else +#include "pytorch_cuda_helper.hpp" +#endif + +template +__global__ void sync_bn_forward_mean_cuda_kernel(const T *input, float *mean, + int num, int channels, + int spatial) { + __shared__ float buffer[THREADS_PER_BLOCK]; + int tid = threadIdx.x; + int c = blockIdx.x; + buffer[tid] = 0; + for (int i = tid; i < num * spatial; i += blockDim.x) { + int index = (i / spatial) * channels * spatial + c * spatial + i % spatial; + buffer[tid] += input[index]; + } + __syncthreads(); + + for (int s = blockDim.x / 2; s > 0; s >>= 1) { + if (tid < s) { + buffer[tid] += buffer[tid + s]; + } + __syncthreads(); + } + int total = num * spatial; + if (tid == 0) { + mean[c] = buffer[0] / total; + } +} + +template <> +__global__ void sync_bn_forward_mean_cuda_kernel(const phalf *input, + float *mean, int num, + int channels, int spatial) { + __shared__ float buffer[THREADS_PER_BLOCK]; + int tid = threadIdx.x; + int c = blockIdx.x; + buffer[tid] = 0; + for (int i = tid; i < num * spatial; i += blockDim.x) { + int index = (i / spatial) * channels * spatial + c * spatial + i % spatial; + buffer[tid] += static_cast(input[index]); + } + __syncthreads(); + + for (int s = blockDim.x / 2; s > 0; s >>= 1) { + if (tid < s) { + buffer[tid] += buffer[tid + s]; + } + __syncthreads(); + } + int total = num * spatial; + if (tid == 0) { + mean[c] = buffer[0] / total; + } +} + +template +__global__ void sync_bn_forward_var_cuda_kernel(const T *input, + const float *mean, float *var, + int num, int channels, + int spatial) { + __shared__ float buffer[THREADS_PER_BLOCK]; + int tid = threadIdx.x; + int c = blockIdx.x; + buffer[tid] = 0; + for (int i = tid; i < num * spatial; i += blockDim.x) { + int index = (i / spatial) * channels * spatial + c * spatial + i % spatial; + float td = input[index] - mean[c]; + buffer[tid] += td * td; + } + __syncthreads(); + for (int s = blockDim.x / 2; s > 0; s >>= 1) { + if (tid < s) { + buffer[tid] += buffer[tid + s]; + } + __syncthreads(); + } + int total = num * spatial; + if (tid == 0) { + var[c] = buffer[0] / total; + } +} + +template <> +__global__ void sync_bn_forward_var_cuda_kernel(const phalf *input, + const float *mean, float *var, + int num, int channels, + int spatial) { + __shared__ float buffer[THREADS_PER_BLOCK]; + int tid = threadIdx.x; + int c = blockIdx.x; + buffer[tid] = 0; + for (int i = tid; i < num * spatial; i += blockDim.x) { + int index = (i / spatial) * channels * spatial + c * spatial + i % spatial; + float td = static_cast(input[index]) - mean[c]; + buffer[tid] += td * td; + } + __syncthreads(); + for (int s = blockDim.x / 2; s > 0; s >>= 1) { + if (tid < s) { + buffer[tid] += buffer[tid + s]; + } + __syncthreads(); + } + int total = num * spatial; + if (tid == 0) { + var[c] = buffer[0] / total; + } +} + +template +__global__ void sync_bn_forward_output_cuda_kernel( + const T *input, const float *mean, const float *var, float *running_mean, + float *running_var, const float *weight, const float *bias, float *norm, + float *std, T *output, int num, int channels, int spatial, float eps, + float momentum, int group_size) { + int tid = threadIdx.x; + int c = blockIdx.x; + float mean_value = mean[c]; + float std_value = sqrt(var[c] + eps); + + if (weight != nullptr) { + float weight_value = weight[c]; + float bias_value = bias[c]; + if (norm != nullptr) { + for (int i = tid; i < num * spatial; i += blockDim.x) { + int index = + (i / spatial) * channels * spatial + c * spatial + i % spatial; + norm[index] = (input[index] - mean_value) / std_value; + output[index] = norm[index] * weight_value + bias_value; + } + } else { + for (int i = tid; i < num * spatial; i += blockDim.x) { + int index = + (i / spatial) * channels * spatial + c * spatial + i % spatial; + output[index] = + (input[index] - mean_value) / std_value * weight_value + bias_value; + } + } + } else { + if (norm != nullptr) { + for (int i = tid; i < num * spatial; i += blockDim.x) { + int index = + (i / spatial) * channels * spatial + c * spatial + i % spatial; + output[index] = norm[index] = (input[index] - mean_value) / std_value; + } + } else { + for (int i = tid; i < num * spatial; i += blockDim.x) { + int index = + (i / spatial) * channels * spatial + c * spatial + i % spatial; + output[index] = (input[index] - mean_value) / std_value; + } + } + } + if (tid == 0) { + if (std != nullptr) std[c] = std_value; + if (running_mean != nullptr) { + running_mean[c] = + momentum * mean_value + (1 - momentum) * running_mean[c]; + int count = num * spatial * group_size; + float var_unbias = count > 1 ? var[c] * count / (count - 1) : var[c]; + running_var[c] = momentum * var_unbias + (1 - momentum) * running_var[c]; + } + } +} + +template <> +__global__ void sync_bn_forward_output_cuda_kernel( + const phalf *input, const float *mean, const float *var, + float *running_mean, float *running_var, const float *weight, + const float *bias, float *norm, float *std, phalf *output, int num, + int channels, int spatial, float eps, float momentum, int group_size) { + int tid = threadIdx.x; + int c = blockIdx.x; + float mean_value = mean[c]; + float std_value = sqrt(var[c] + eps); + if (weight != nullptr) { + float weight_value = weight[c]; + float bias_value = bias[c]; + if (norm != nullptr) { + for (int i = tid; i < num * spatial; i += blockDim.x) { + int index = + (i / spatial) * channels * spatial + c * spatial + i % spatial; + norm[index] = + (static_cast(input[index]) - mean_value) / std_value; + output[index] = + static_cast(norm[index] * weight_value + bias_value); + } + } else { + for (int i = tid; i < num * spatial; i += blockDim.x) { + int index = + (i / spatial) * channels * spatial + c * spatial + i % spatial; + output[index] = + static_cast((static_cast(input[index]) - mean_value) / + std_value * weight_value + + bias_value); + } + } + } else { + if (norm != nullptr) { + for (int i = tid; i < num * spatial; i += blockDim.x) { + int index = + (i / spatial) * channels * spatial + c * spatial + i % spatial; + norm[index] = + (static_cast(input[index]) - mean_value) / std_value; + output[index] = static_cast(norm[index]); + } + } else { + for (int i = tid; i < num * spatial; i += blockDim.x) { + int index = + (i / spatial) * channels * spatial + c * spatial + i % spatial; + output[index] = static_cast( + (static_cast(input[index]) - mean_value) / std_value); + } + } + } + if (tid == 0) { + if (std != nullptr) std[c] = std_value; + if (running_mean != nullptr) { + running_mean[c] = + momentum * mean_value + (1 - momentum) * running_mean[c]; + int count = num * spatial * group_size; + float var_unbias = count > 1 ? var[c] * count / (count - 1) : var[c]; + running_var[c] = momentum * var_unbias + (1 - momentum) * running_var[c]; + } + } +} + +template +__global__ void sync_bn_backward_param_cuda_kernel(const T *grad_output, + const float *norm, + float *grad_weight, + float *grad_bias, int num, + int channels, int spatial) { + __shared__ float buffer1[THREADS_PER_BLOCK]; + __shared__ float buffer2[THREADS_PER_BLOCK]; + + int tid = threadIdx.x; + int c = blockIdx.x; + buffer1[tid] = buffer2[tid] = 0; + for (int i = tid; i < num * spatial; i += blockDim.x) { + int index = (i / spatial) * channels * spatial + c * spatial + i % spatial; + buffer1[tid] += grad_output[index] * norm[index]; + buffer2[tid] += grad_output[index]; + } + __syncthreads(); + + for (int s = blockDim.x / 2; s > 0; s >>= 1) { + if (tid < s) { + buffer1[tid] += buffer1[tid + s]; + buffer2[tid] += buffer2[tid + s]; + } + __syncthreads(); + } + if (tid == 0) { + grad_weight[c] = buffer1[0]; + grad_bias[c] = buffer2[0]; + } +} + +template <> +__global__ void sync_bn_backward_param_cuda_kernel(const phalf *grad_output, + const float *norm, + float *grad_weight, + float *grad_bias, int num, + int channels, int spatial) { + __shared__ float buffer1[THREADS_PER_BLOCK]; + __shared__ float buffer2[THREADS_PER_BLOCK]; + + int tid = threadIdx.x; + int c = blockIdx.x; + buffer1[tid] = buffer2[tid] = 0; + for (int i = tid; i < num * spatial; i += blockDim.x) { + int index = (i / spatial) * channels * spatial + c * spatial + i % spatial; + buffer1[tid] += static_cast(grad_output[index]) * norm[index]; + buffer2[tid] += static_cast(grad_output[index]); + } + __syncthreads(); + + for (int s = blockDim.x / 2; s > 0; s >>= 1) { + if (tid < s) { + buffer1[tid] += buffer1[tid + s]; + buffer2[tid] += buffer2[tid + s]; + } + __syncthreads(); + } + if (tid == 0) { + grad_weight[c] = buffer1[0]; + grad_bias[c] = buffer2[0]; + } +} + +template +__global__ void sync_bn_backward_data_cuda_kernel( + int output_size, const T *grad_output, const float *weight, + const float *grad_weight, const float *grad_bias, const float *norm, + const float *std, T *grad_input, int num, int channels, int spatial) { + int factor = num * spatial; + CUDA_1D_KERNEL_LOOP(index, output_size) { + int c = (index / spatial) % channels; + grad_input[index] = + weight[c] * + (grad_output[index] - + (grad_weight[c] * norm[index] + grad_bias[c]) / factor) / + std[c]; + } +} + +template <> +__global__ void sync_bn_backward_data_cuda_kernel( + int output_size, const phalf *grad_output, const float *weight, + const float *grad_weight, const float *grad_bias, const float *norm, + const float *std, phalf *grad_input, int num, int channels, int spatial) { + int factor = num * spatial; + CUDA_1D_KERNEL_LOOP(index, output_size) { + int c = (index / spatial) % channels; + grad_input[index] = static_cast( + weight[c] * + (static_cast(grad_output[index]) - + (grad_weight[c] * norm[index] + grad_bias[c]) / factor) / + std[c]); + } +} + +#endif // SYNCBN_CUDA_KERNEL_CUH diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/pytorch_cpp_helper.hpp b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/pytorch_cpp_helper.hpp new file mode 100644 index 000000000..c7f9f35b7 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/pytorch_cpp_helper.hpp @@ -0,0 +1,24 @@ +#ifndef PYTORCH_CPP_HELPER +#define PYTORCH_CPP_HELPER +#include + +#include + +using namespace at; + +#define DIVUP(m, n) ((m) / (n) + ((m) % (n) > 0)) + +#define CHECK_CUDA(x) \ + TORCH_CHECK(x.device().is_cuda(), #x " must be a CUDA tensor") +#define CHECK_CPU(x) \ + TORCH_CHECK(!x.device().is_cuda(), #x " must be a CPU tensor") +#define CHECK_CONTIGUOUS(x) \ + TORCH_CHECK(x.is_contiguous(), #x " must be contiguous") +#define CHECK_CUDA_INPUT(x) \ + CHECK_CUDA(x); \ + CHECK_CONTIGUOUS(x) +#define CHECK_CPU_INPUT(x) \ + CHECK_CPU(x); \ + CHECK_CONTIGUOUS(x) + +#endif // PYTORCH_CPP_HELPER diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/pytorch_cuda_helper.hpp b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/pytorch_cuda_helper.hpp new file mode 100644 index 000000000..9869b535f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/common/pytorch_cuda_helper.hpp @@ -0,0 +1,19 @@ +#ifndef PYTORCH_CUDA_HELPER +#define PYTORCH_CUDA_HELPER + +#include +#include +#include + +#include +#include + +#include "common_cuda_helper.hpp" + +using at::Half; +using at::Tensor; +using phalf = at::Half; + +#define __PHALF(x) (x) + +#endif // PYTORCH_CUDA_HELPER diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/focal_loss_cuda.cu b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/focal_loss_cuda.cu new file mode 100644 index 000000000..cb899f954 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/focal_loss_cuda.cu @@ -0,0 +1,111 @@ +// Copyright (c) OpenMMLab. All rights reserved +#include "pytorch_cuda_helper.hpp" +#include "sigmoid_focal_loss_cuda_kernel.cuh" +#include "softmax_focal_loss_cuda_kernel.cuh" + +void SigmoidFocalLossForwardCUDAKernelLauncher(Tensor input, Tensor target, + Tensor weight, Tensor output, + const float gamma, + const float alpha) { + int output_size = output.numel(); + int num_classes = input.size(1); + AT_ASSERTM(target.max().item() <= (int64_t)num_classes, + "target label should smaller or equal than num classes"); + at::cuda::CUDAGuard device_guard(input.device()); + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + input.scalar_type(), "sigmoid_focal_loss_forward_cuda_kernel", [&] { + sigmoid_focal_loss_forward_cuda_kernel + <<>>( + output_size, input.data_ptr(), + target.data_ptr(), weight.data_ptr(), + output.data_ptr(), gamma, alpha, num_classes); + }); + + AT_CUDA_CHECK(cudaGetLastError()); +} + +void SigmoidFocalLossBackwardCUDAKernelLauncher(Tensor input, Tensor target, + Tensor weight, + Tensor grad_input, + const float gamma, + const float alpha) { + int output_size = grad_input.numel(); + int num_classes = input.size(1); + + at::cuda::CUDAGuard device_guard(grad_input.device()); + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + input.scalar_type(), "sigmoid_focal_loss_backward_cuda_kernel", [&] { + sigmoid_focal_loss_backward_cuda_kernel + <<>>( + output_size, input.data_ptr(), + target.data_ptr(), weight.data_ptr(), + grad_input.data_ptr(), gamma, alpha, num_classes); + }); + + AT_CUDA_CHECK(cudaGetLastError()); +} + +void SoftmaxFocalLossForwardCUDAKernelLauncher(Tensor softmax, Tensor target, + Tensor weight, Tensor output, + const float gamma, + const float alpha) { + int output_size = output.numel(); + int num_classes = softmax.size(1); + + AT_ASSERTM(target.max().item() <= (int64_t)num_classes, + "target label should smaller or equal than num classes"); + at::cuda::CUDAGuard device_guard(softmax.device()); + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + softmax.scalar_type(), "softmax_focal_loss_forward_cuda_kernel", [&] { + softmax_focal_loss_forward_cuda_kernel + <<>>( + output_size, softmax.data_ptr(), + target.data_ptr(), weight.data_ptr(), + output.data_ptr(), gamma, alpha, num_classes); + }); + + AT_CUDA_CHECK(cudaGetLastError()); +} + +void SoftmaxFocalLossBackwardCUDAKernelLauncher(Tensor softmax, Tensor target, + Tensor weight, Tensor buff, + Tensor grad_input, + const float gamma, + const float alpha) { + int num_classes = softmax.size(1); + + int output_size = buff.numel(); + at::cuda::CUDAGuard device_guard(grad_input.device()); + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + grad_input.scalar_type(), + "softmax_focal_loss_backward_cuda1_" + "kernel", + [&] { + softmax_focal_loss_backward_cuda1_kernel + <<>>( + output_size, softmax.data_ptr(), + target.data_ptr(), weight.data_ptr(), + buff.data_ptr(), gamma, alpha, num_classes); + }); + + AT_CUDA_CHECK(cudaGetLastError()); + + output_size = grad_input.numel(); + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + grad_input.scalar_type(), + "softmax_focal_loss_backward_cuda2_" + "kernel", + [&] { + softmax_focal_loss_backward_cuda2_kernel + <<>>( + output_size, softmax.data_ptr(), + target.data_ptr(), buff.data_ptr(), + grad_input.data_ptr(), num_classes); + }); + + AT_CUDA_CHECK(cudaGetLastError()); +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/nms_cuda.cu b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/nms_cuda.cu new file mode 100644 index 000000000..16cf64683 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/nms_cuda.cu @@ -0,0 +1,53 @@ +// Copyright (c) OpenMMLab. All rights reserved +#include "nms_cuda_kernel.cuh" +#include "pytorch_cuda_helper.hpp" + +Tensor NMSCUDAKernelLauncher(Tensor boxes, Tensor scores, float iou_threshold, + int offset) { + at::cuda::CUDAGuard device_guard(boxes.device()); + + if (boxes.numel() == 0) { + return at::empty({0}, boxes.options().dtype(at::kLong)); + } + auto order_t = std::get<1>(scores.sort(0, /*descending=*/true)); + auto boxes_sorted = boxes.index_select(0, order_t); + + int boxes_num = boxes.size(0); + const int col_blocks = DIVUP(boxes_num, threadsPerBlock); + Tensor mask = + at::empty({boxes_num, col_blocks}, boxes.options().dtype(at::kLong)); + dim3 blocks(col_blocks, col_blocks); + dim3 threads(threadsPerBlock); + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + nms_cuda<<>>( + boxes_num, iou_threshold, offset, boxes_sorted.data_ptr(), + (unsigned long long*)mask.data_ptr()); + + at::Tensor mask_cpu = mask.to(at::kCPU); + unsigned long long* mask_host = + (unsigned long long*)mask_cpu.data_ptr(); + + std::vector remv(col_blocks); + memset(&remv[0], 0, sizeof(unsigned long long) * col_blocks); + + at::Tensor keep_t = + at::zeros({boxes_num}, boxes.options().dtype(at::kBool).device(at::kCPU)); + bool* keep = keep_t.data_ptr(); + + for (int i = 0; i < boxes_num; i++) { + int nblock = i / threadsPerBlock; + int inblock = i % threadsPerBlock; + + if (!(remv[nblock] & (1ULL << inblock))) { + keep[i] = true; + // set every overlap box with bit 1 in remv + unsigned long long* p = mask_host + i * col_blocks; + for (int j = nblock; j < col_blocks; j++) { + remv[j] |= p[j]; + } + } + } + + AT_CUDA_CHECK(cudaGetLastError()); + return order_t.masked_select(keep_t.to(at::kCUDA)); +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/roi_align_cuda.cu b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/roi_align_cuda.cu new file mode 100644 index 000000000..3d4f7614e --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/roi_align_cuda.cu @@ -0,0 +1,58 @@ +// Copyright (c) OpenMMLab. All rights reserved +#include "pytorch_cuda_helper.hpp" +#include "roi_align_cuda_kernel.cuh" + +void ROIAlignForwardCUDAKernelLauncher(Tensor input, Tensor rois, Tensor output, + Tensor argmax_y, Tensor argmax_x, + int aligned_height, int aligned_width, + float spatial_scale, int sampling_ratio, + int pool_mode, bool aligned) { + int output_size = output.numel(); + int channels = input.size(1); + int height = input.size(2); + int width = input.size(3); + + at::cuda::CUDAGuard device_guard(input.device()); + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + input.scalar_type(), "roi_align_forward_cuda_kernel", [&] { + roi_align_forward_cuda_kernel + <<>>( + output_size, input.data_ptr(), + rois.data_ptr(), output.data_ptr(), + argmax_y.data_ptr(), argmax_x.data_ptr(), + aligned_height, aligned_width, + static_cast(spatial_scale), sampling_ratio, pool_mode, + aligned, channels, height, width); + }); + + AT_CUDA_CHECK(cudaGetLastError()); +} + +void ROIAlignBackwardCUDAKernelLauncher(Tensor grad_output, Tensor rois, + Tensor argmax_y, Tensor argmax_x, + Tensor grad_input, int aligned_height, + int aligned_width, float spatial_scale, + int sampling_ratio, int pool_mode, + bool aligned) { + int output_size = grad_output.numel(); + int channels = grad_input.size(1); + int height = grad_input.size(2); + int width = grad_input.size(3); + + at::cuda::CUDAGuard device_guard(grad_output.device()); + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + grad_output.scalar_type(), "roi_align_backward_cuda_kernel", [&] { + roi_align_backward_cuda_kernel + <<>>( + output_size, grad_output.data_ptr(), + rois.data_ptr(), argmax_y.data_ptr(), + argmax_x.data_ptr(), grad_input.data_ptr(), + aligned_height, aligned_width, + static_cast(spatial_scale), sampling_ratio, pool_mode, + aligned, channels, height, width); + }); + + AT_CUDA_CHECK(cudaGetLastError()); +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/roi_pool_cuda.cu b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/roi_pool_cuda.cu new file mode 100644 index 000000000..d9cdf3050 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/roi_pool_cuda.cu @@ -0,0 +1,50 @@ +// Copyright (c) OpenMMLab. All rights reserved +#include "pytorch_cuda_helper.hpp" +#include "roi_pool_cuda_kernel.cuh" + +void ROIPoolForwardCUDAKernelLauncher(Tensor input, Tensor rois, Tensor output, + Tensor argmax, int pooled_height, + int pooled_width, float spatial_scale) { + int output_size = output.numel(); + int channels = input.size(1); + int height = input.size(2); + int width = input.size(3); + + at::cuda::CUDAGuard device_guard(input.device()); + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + input.scalar_type(), "roi_pool_forward_cuda_kernel", [&] { + roi_pool_forward_cuda_kernel + <<>>( + output_size, input.data_ptr(), + rois.data_ptr(), output.data_ptr(), + argmax.data_ptr(), pooled_height, pooled_width, + static_cast(spatial_scale), channels, height, width); + }); + + AT_CUDA_CHECK(cudaGetLastError()); +} + +void ROIPoolBackwardCUDAKernelLauncher(Tensor grad_output, Tensor rois, + Tensor argmax, Tensor grad_input, + int pooled_height, int pooled_width, + float spatial_scale) { + int output_size = grad_output.numel(); + int channels = grad_input.size(1); + int height = grad_input.size(2); + int width = grad_input.size(3); + + at::cuda::CUDAGuard device_guard(grad_output.device()); + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + grad_output.scalar_type(), "roi_pool_backward_cuda_kernel", [&] { + roi_pool_backward_cuda_kernel + <<>>( + output_size, grad_output.data_ptr(), + rois.data_ptr(), argmax.data_ptr(), + grad_input.data_ptr(), pooled_height, pooled_width, + channels, height, width); + }); + + AT_CUDA_CHECK(cudaGetLastError()); +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/sync_bn_cuda.cu b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/sync_bn_cuda.cu new file mode 100644 index 000000000..657c81701 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/cuda/sync_bn_cuda.cu @@ -0,0 +1,110 @@ +// Copyright (c) OpenMMLab. All rights reserved +#include "pytorch_cuda_helper.hpp" +#include "sync_bn_cuda_kernel.cuh" + +void SyncBNForwardMeanCUDAKernelLauncher(const Tensor input, Tensor mean) { + int num = input.size(0); + int channels = input.size(1); + int spatial = input.size(2); + + at::cuda::CUDAGuard device_guard(input.device()); + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + input.scalar_type(), "sync_bn_forward_mean_cuda_kernel", [&] { + sync_bn_forward_mean_cuda_kernel + <<>>( + input.data_ptr(), mean.data_ptr(), num, + channels, spatial); + }); + AT_CUDA_CHECK(cudaGetLastError()); +} + +void SyncBNForwardVarCUDAKernelLauncher(const Tensor input, const Tensor mean, + Tensor var) { + int num = input.size(0); + int channels = input.size(1); + int spatial = input.size(2); + + at::cuda::CUDAGuard device_guard(input.device()); + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + input.scalar_type(), "sync_bn_forward_mean_cuda_kernel", [&] { + sync_bn_forward_var_cuda_kernel + <<>>( + input.data_ptr(), mean.data_ptr(), + var.data_ptr(), num, channels, spatial); + }); + AT_CUDA_CHECK(cudaGetLastError()); +} + +void SyncBNForwardOutputCUDAKernelLauncher( + const Tensor input, const Tensor mean, const Tensor var, + Tensor running_mean, Tensor running_var, const Tensor weight, + const Tensor bias, Tensor norm, Tensor std, Tensor output, float eps, + float momentum, int group_size) { + int num = input.size(0); + int channels = input.size(1); + int spatial = input.size(2); + + at::cuda::CUDAGuard device_guard(input.device()); + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + input.scalar_type(), "sync_bn_forward_mean_cuda_kernel", [&] { + sync_bn_forward_output_cuda_kernel + <<>>( + input.data_ptr(), mean.data_ptr(), + var.data_ptr(), running_mean.data_ptr(), + running_var.data_ptr(), weight.data_ptr(), + bias.data_ptr(), norm.data_ptr(), + std.data_ptr(), output.data_ptr(), num, + channels, spatial, eps, momentum, group_size); + }); + AT_CUDA_CHECK(cudaGetLastError()); +} + +void SyncBNBackwardParamCUDAKernelLauncher(const Tensor grad_output, + const Tensor norm, + Tensor grad_weight, + Tensor grad_bias) { + int num = grad_output.size(0); + int channels = grad_output.size(1); + int spatial = grad_output.size(2); + + at::cuda::CUDAGuard device_guard(grad_output.device()); + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + grad_output.scalar_type(), "sync_bn_backward_param_cuda_kernel", [&] { + sync_bn_backward_param_cuda_kernel + <<>>( + grad_output.data_ptr(), norm.data_ptr(), + grad_weight.data_ptr(), grad_bias.data_ptr(), num, + channels, spatial); + }); + AT_CUDA_CHECK(cudaGetLastError()); +} + +void SyncBNBackwardDataCUDAKernelLauncher(const Tensor grad_output, + const Tensor weight, + const Tensor grad_weight, + const Tensor grad_bias, + const Tensor norm, const Tensor std, + Tensor grad_input) { + int output_size = grad_input.numel(); + int num = grad_input.size(0); + int channels = grad_input.size(1); + int spatial = grad_input.size(2); + + at::cuda::CUDAGuard device_guard(grad_input.device()); + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + grad_output.scalar_type(), "sync_bn_backward_data_cuda_kernel", [&] { + sync_bn_backward_data_cuda_kernel + <<>>( + output_size, grad_output.data_ptr(), + weight.data_ptr(), grad_weight.data_ptr(), + grad_bias.data_ptr(), norm.data_ptr(), + std.data_ptr(), grad_input.data_ptr(), num, + channels, spatial); + }); + AT_CUDA_CHECK(cudaGetLastError()); +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/focal_loss.cpp b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/focal_loss.cpp new file mode 100644 index 000000000..3e2c92b27 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/focal_loss.cpp @@ -0,0 +1,131 @@ +// Copyright (c) OpenMMLab. All rights reserved +#include "pytorch_cpp_helper.hpp" + +#ifdef MMCV_WITH_CUDA +void SigmoidFocalLossForwardCUDAKernelLauncher(Tensor input, Tensor target, + Tensor weight, Tensor output, + const float gamma, + const float alpha); + +void SigmoidFocalLossBackwardCUDAKernelLauncher(Tensor input, Tensor target, + Tensor weight, + Tensor grad_input, + const float gamma, + const float alpha); + +void SoftmaxFocalLossForwardCUDAKernelLauncher(Tensor input, Tensor target, + Tensor weight, Tensor output, + const float gamma, + const float alpha); + +void SoftmaxFocalLossBackwardCUDAKernelLauncher(Tensor input, Tensor target, + Tensor weight, Tensor buff, + Tensor grad_input, + const float gamma, + const float alpha); + +void sigmoid_focal_loss_forward_cuda(Tensor input, Tensor target, Tensor weight, + Tensor output, float gamma, float alpha) { + SigmoidFocalLossForwardCUDAKernelLauncher(input, target, weight, output, + gamma, alpha); +} + +void sigmoid_focal_loss_backward_cuda(Tensor input, Tensor target, + Tensor weight, Tensor grad_input, + float gamma, float alpha) { + SigmoidFocalLossBackwardCUDAKernelLauncher(input, target, weight, grad_input, + gamma, alpha); +} + +void softmax_focal_loss_forward_cuda(Tensor input, Tensor target, Tensor weight, + Tensor output, float gamma, float alpha) { + SoftmaxFocalLossForwardCUDAKernelLauncher(input, target, weight, output, + gamma, alpha); +} + +void softmax_focal_loss_backward_cuda(Tensor input, Tensor target, + Tensor weight, Tensor buff, + Tensor grad_input, float gamma, + float alpha) { + SoftmaxFocalLossBackwardCUDAKernelLauncher(input, target, weight, buff, + grad_input, gamma, alpha); +} +#endif + +void sigmoid_focal_loss_forward(Tensor input, Tensor target, Tensor weight, + Tensor output, float gamma, float alpha) { + if (input.device().is_cuda()) { +#ifdef MMCV_WITH_CUDA + CHECK_CUDA_INPUT(input); + CHECK_CUDA_INPUT(target); + CHECK_CUDA_INPUT(weight); + CHECK_CUDA_INPUT(output); + + sigmoid_focal_loss_forward_cuda(input, target, weight, output, gamma, + alpha); +#else + AT_ERROR("SigmoidFocalLoss is not compiled with GPU support"); +#endif + } else { + AT_ERROR("SigmoidFocalLoss is not implemented on CPU"); + } +} + +void sigmoid_focal_loss_backward(Tensor input, Tensor target, Tensor weight, + Tensor grad_input, float gamma, float alpha) { + if (input.device().is_cuda()) { +#ifdef MMCV_WITH_CUDA + CHECK_CUDA_INPUT(input); + CHECK_CUDA_INPUT(target); + CHECK_CUDA_INPUT(weight); + CHECK_CUDA_INPUT(grad_input); + + sigmoid_focal_loss_backward_cuda(input, target, weight, grad_input, gamma, + alpha); +#else + AT_ERROR("SigmoidFocalLoss is not compiled with GPU support"); +#endif + } else { + AT_ERROR("SigmoidFocalLoss is not implemented on CPU"); + } +} + +void softmax_focal_loss_forward(Tensor input, Tensor target, Tensor weight, + Tensor output, float gamma, float alpha) { + if (input.device().is_cuda()) { +#ifdef MMCV_WITH_CUDA + CHECK_CUDA_INPUT(input); + CHECK_CUDA_INPUT(target); + CHECK_CUDA_INPUT(weight); + CHECK_CUDA_INPUT(output); + + softmax_focal_loss_forward_cuda(input, target, weight, output, gamma, + alpha); +#else + AT_ERROR("SoftmaxFocalLoss is not compiled with GPU support"); +#endif + } else { + AT_ERROR("SoftmaxFocalLoss is not implemented on CPU"); + } +} + +void softmax_focal_loss_backward(Tensor input, Tensor target, Tensor weight, + Tensor buff, Tensor grad_input, float gamma, + float alpha) { + if (input.device().is_cuda()) { +#ifdef MMCV_WITH_CUDA + CHECK_CUDA_INPUT(input); + CHECK_CUDA_INPUT(target); + CHECK_CUDA_INPUT(weight); + CHECK_CUDA_INPUT(buff); + CHECK_CUDA_INPUT(grad_input); + + softmax_focal_loss_backward_cuda(input, target, weight, buff, grad_input, + gamma, alpha); +#else + AT_ERROR("SoftmaxFocalLoss is not compiled with GPU support"); +#endif + } else { + AT_ERROR("SoftmaxFocalLoss is not implemented on CPU"); + } +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/utils/src/compiling_info.cpp b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/info.cpp similarity index 79% rename from cv/instance_segmentation/SOLO/pytorch/mmdet/ops/utils/src/compiling_info.cpp rename to cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/info.cpp index fd62aabcf..a08d227d4 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/utils/src/compiling_info.cpp +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/info.cpp @@ -1,16 +1,19 @@ +// Copyright (c) OpenMMLab. All rights reserved // modified from // https://github.com/facebookresearch/detectron2/blob/master/detectron2/layers/csrc/vision.cpp -#include -#include +#include "pytorch_cpp_helper.hpp" -#ifdef WITH_CUDA +#ifdef MMCV_WITH_CUDA +#ifndef HIP_DIFF +#include int get_cudart_version() { return CUDART_VERSION; } #endif +#endif std::string get_compiling_cuda_version() { -#ifdef WITH_CUDA +#ifdef MMCV_WITH_CUDA +#ifndef HIP_DIFF std::ostringstream oss; - // copied from // https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/cuda/detail/CUDAHooks.cpp#L231 auto printCudaStyleVersion = [&](int v) { @@ -21,6 +24,9 @@ std::string get_compiling_cuda_version() { }; printCudaStyleVersion(get_cudart_version()); return oss.str(); +#else + return std::string("rocm not available"); +#endif #else return std::string("not available"); #endif @@ -48,9 +54,3 @@ std::string get_compiler_version() { #endif return ss.str(); } - -PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { - m.def("get_compiler_version", &get_compiler_version, "get_compiler_version"); - m.def("get_compiling_cuda_version", &get_compiling_cuda_version, - "get_compiling_cuda_version"); -} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/nms.cpp b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/nms.cpp new file mode 100644 index 000000000..e88208dc9 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/nms.cpp @@ -0,0 +1,261 @@ +// Copyright (c) OpenMMLab. All rights reserved +#include "pytorch_cpp_helper.hpp" + +#ifdef MMCV_WITH_CUDA +Tensor NMSCUDAKernelLauncher(Tensor boxes, Tensor scores, float iou_threshold, + int offset); + +Tensor nms_cuda(Tensor boxes, Tensor scores, float iou_threshold, int offset) { + return NMSCUDAKernelLauncher(boxes, scores, iou_threshold, offset); +} +#endif + +Tensor nms_cpu(Tensor boxes, Tensor scores, float iou_threshold, int offset) { + if (boxes.numel() == 0) { + return at::empty({0}, boxes.options().dtype(at::kLong)); + } + auto x1_t = boxes.select(1, 0).contiguous(); + auto y1_t = boxes.select(1, 1).contiguous(); + auto x2_t = boxes.select(1, 2).contiguous(); + auto y2_t = boxes.select(1, 3).contiguous(); + + Tensor areas_t = (x2_t - x1_t + offset) * (y2_t - y1_t + offset); + + auto order_t = std::get<1>(scores.sort(0, /* descending=*/true)); + + auto nboxes = boxes.size(0); + Tensor select_t = at::ones({nboxes}, boxes.options().dtype(at::kBool)); + + auto select = select_t.data_ptr(); + auto order = order_t.data_ptr(); + auto x1 = x1_t.data_ptr(); + auto y1 = y1_t.data_ptr(); + auto x2 = x2_t.data_ptr(); + auto y2 = y2_t.data_ptr(); + auto areas = areas_t.data_ptr(); + + for (int64_t _i = 0; _i < nboxes; _i++) { + if (select[_i] == false) continue; + auto i = order[_i]; + auto ix1 = x1[i]; + auto iy1 = y1[i]; + auto ix2 = x2[i]; + auto iy2 = y2[i]; + auto iarea = areas[i]; + + for (int64_t _j = _i + 1; _j < nboxes; _j++) { + if (select[_j] == false) continue; + auto j = order[_j]; + auto xx1 = std::max(ix1, x1[j]); + auto yy1 = std::max(iy1, y1[j]); + auto xx2 = std::min(ix2, x2[j]); + auto yy2 = std::min(iy2, y2[j]); + + auto w = std::max(0.f, xx2 - xx1 + offset); + auto h = std::max(0.f, yy2 - yy1 + offset); + auto inter = w * h; + auto ovr = inter / (iarea + areas[j] - inter); + if (ovr > iou_threshold) select[_j] = false; + } + } + return order_t.masked_select(select_t); +} + +Tensor nms(Tensor boxes, Tensor scores, float iou_threshold, int offset) { + if (boxes.device().is_cuda()) { +#ifdef MMCV_WITH_CUDA + CHECK_CUDA_INPUT(boxes); + CHECK_CUDA_INPUT(scores); + return nms_cuda(boxes, scores, iou_threshold, offset); +#else + AT_ERROR("nms is not compiled with GPU support"); +#endif + } else { + CHECK_CPU_INPUT(boxes); + CHECK_CPU_INPUT(scores); + return nms_cpu(boxes, scores, iou_threshold, offset); + } +} + +Tensor softnms_cpu(Tensor boxes, Tensor scores, Tensor dets, + float iou_threshold, float sigma, float min_score, + int method, int offset) { + if (boxes.numel() == 0) { + return at::empty({0}, boxes.options().dtype(at::kLong)); + } + + auto x1_t = boxes.select(1, 0).contiguous(); + auto y1_t = boxes.select(1, 1).contiguous(); + auto x2_t = boxes.select(1, 2).contiguous(); + auto y2_t = boxes.select(1, 3).contiguous(); + auto scores_t = scores.clone(); + + Tensor areas_t = (x2_t - x1_t + offset) * (y2_t - y1_t + offset); + + auto nboxes = boxes.size(0); + auto x1 = x1_t.data_ptr(); + auto y1 = y1_t.data_ptr(); + auto x2 = x2_t.data_ptr(); + auto y2 = y2_t.data_ptr(); + auto sc = scores_t.data_ptr(); + auto areas = areas_t.data_ptr(); + auto de = dets.data_ptr(); + + int64_t pos = 0; + Tensor inds_t = at::arange(nboxes, boxes.options().dtype(at::kLong)); + auto inds = inds_t.data_ptr(); + + for (int64_t i = 0; i < nboxes; i++) { + auto max_score = sc[i]; + auto max_pos = i; + + pos = i + 1; + // get max box + while (pos < nboxes) { + if (max_score < sc[pos]) { + max_score = sc[pos]; + max_pos = pos; + } + pos = pos + 1; + } + // swap + auto ix1 = de[i * 5 + 0] = x1[max_pos]; + auto iy1 = de[i * 5 + 1] = y1[max_pos]; + auto ix2 = de[i * 5 + 2] = x2[max_pos]; + auto iy2 = de[i * 5 + 3] = y2[max_pos]; + auto iscore = de[i * 5 + 4] = sc[max_pos]; + auto iarea = areas[max_pos]; + auto iind = inds[max_pos]; + x1[max_pos] = x1[i]; + y1[max_pos] = y1[i]; + x2[max_pos] = x2[i]; + y2[max_pos] = y2[i]; + sc[max_pos] = sc[i]; + areas[max_pos] = areas[i]; + inds[max_pos] = inds[i]; + x1[i] = ix1; + y1[i] = iy1; + x2[i] = ix2; + y2[i] = iy2; + sc[i] = iscore; + areas[i] = iarea; + inds[i] = iind; + + pos = i + 1; + while (pos < nboxes) { + auto xx1 = std::max(ix1, x1[pos]); + auto yy1 = std::max(iy1, y1[pos]); + auto xx2 = std::min(ix2, x2[pos]); + auto yy2 = std::min(iy2, y2[pos]); + + auto w = std::max(0.f, xx2 - xx1 + offset); + auto h = std::max(0.f, yy2 - yy1 + offset); + auto inter = w * h; + auto ovr = inter / (iarea + areas[pos] - inter); + + float weight = 1.; + if (method == 0) { + if (ovr >= iou_threshold) weight = 0; + } else if (method == 1) { + if (ovr >= iou_threshold) weight = 1 - ovr; + } else if (method == 2) { + weight = std::exp(-(ovr * ovr) / sigma); + } + sc[pos] *= weight; + // if box score falls below threshold, discard the box by + // swapping with last box update N + if (sc[pos] < min_score) { + x1[pos] = x1[nboxes - 1]; + y1[pos] = y1[nboxes - 1]; + x2[pos] = x2[nboxes - 1]; + y2[pos] = y2[nboxes - 1]; + sc[pos] = sc[nboxes - 1]; + areas[pos] = areas[nboxes - 1]; + inds[pos] = inds[nboxes - 1]; + nboxes = nboxes - 1; + pos = pos - 1; + } + pos = pos + 1; + } + } + return inds_t.slice(0, 0, nboxes); +} + +Tensor softnms(Tensor boxes, Tensor scores, Tensor dets, float iou_threshold, + float sigma, float min_score, int method, int offset) { + if (boxes.device().is_cuda()) { + AT_ERROR("softnms is not implemented on GPU"); + } else { + return softnms_cpu(boxes, scores, dets, iou_threshold, sigma, min_score, + method, offset); + } +} + +std::vector > nms_match_cpu(Tensor dets, float iou_threshold) { + auto x1_t = dets.select(1, 0).contiguous(); + auto y1_t = dets.select(1, 1).contiguous(); + auto x2_t = dets.select(1, 2).contiguous(); + auto y2_t = dets.select(1, 3).contiguous(); + auto scores = dets.select(1, 4).contiguous(); + + at::Tensor areas_t = (x2_t - x1_t) * (y2_t - y1_t); + + auto order_t = std::get<1>(scores.sort(0, /* descending=*/true)); + + auto ndets = dets.size(0); + at::Tensor suppressed_t = + at::zeros({ndets}, dets.options().dtype(at::kByte).device(at::kCPU)); + + auto suppressed = suppressed_t.data_ptr(); + auto order = order_t.data_ptr(); + auto x1 = x1_t.data_ptr(); + auto y1 = y1_t.data_ptr(); + auto x2 = x2_t.data_ptr(); + auto y2 = y2_t.data_ptr(); + auto areas = areas_t.data_ptr(); + + std::vector keep; + std::vector > matched; + + for (int64_t _i = 0; _i < ndets; _i++) { + auto i = order[_i]; + if (suppressed[i] == 1) continue; + keep.push_back(i); + std::vector v_i; + auto ix1 = x1[i]; + auto iy1 = y1[i]; + auto ix2 = x2[i]; + auto iy2 = y2[i]; + auto iarea = areas[i]; + + for (int64_t _j = _i + 1; _j < ndets; _j++) { + auto j = order[_j]; + if (suppressed[j] == 1) continue; + auto xx1 = std::max(ix1, x1[j]); + auto yy1 = std::max(iy1, y1[j]); + auto xx2 = std::min(ix2, x2[j]); + auto yy2 = std::min(iy2, y2[j]); + + auto w = std::max(static_cast(0), xx2 - xx1); + auto h = std::max(static_cast(0), yy2 - yy1); + auto inter = w * h; + auto ovr = inter / (iarea + areas[j] - inter); + if (ovr >= iou_threshold) { + suppressed[j] = 1; + v_i.push_back(j); + } + } + matched.push_back(v_i); + } + for (int i = 0; i < keep.size(); i++) + matched[i].insert(matched[i].begin(), keep[i]); + return matched; +} + +std::vector > nms_match(Tensor dets, float iou_threshold) { + if (dets.device().is_cuda()) { + AT_ERROR("nms_match is not implemented on GPU"); + } else { + return nms_match_cpu(dets, iou_threshold); + } +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/pybind.cpp b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/pybind.cpp new file mode 100644 index 000000000..de8e18c97 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/pybind.cpp @@ -0,0 +1,131 @@ +// Copyright (c) OpenMMLab. All rights reserved +#include "pytorch_cpp_helper.hpp" + +std::string get_compiler_version(); +std::string get_compiling_cuda_version(); + +void sigmoid_focal_loss_forward(Tensor input, Tensor target, Tensor weight, + Tensor output, float gamma, float alpha); + +void sigmoid_focal_loss_backward(Tensor input, Tensor target, Tensor weight, + Tensor grad_input, float gamma, float alpha); + +void softmax_focal_loss_forward(Tensor input, Tensor target, Tensor weight, + Tensor output, float gamma, float alpha); + +void softmax_focal_loss_backward(Tensor input, Tensor target, Tensor weight, + Tensor buff, Tensor grad_input, float gamma, + float alpha); + +Tensor nms(Tensor boxes, Tensor scores, float iou_threshold, int offset); + +Tensor softnms(Tensor boxes, Tensor scores, Tensor dets, float iou_threshold, + float sigma, float min_score, int method, int offset); + +std::vector> nms_match(Tensor dets, float iou_threshold); + + + +void roi_align_forward(Tensor input, Tensor rois, Tensor output, + Tensor argmax_y, Tensor argmax_x, int aligned_height, + int aligned_width, float spatial_scale, + int sampling_ratio, int pool_mode, bool aligned); + +void roi_align_backward(Tensor grad_output, Tensor rois, Tensor argmax_y, + Tensor argmax_x, Tensor grad_input, int aligned_height, + int aligned_width, float spatial_scale, + int sampling_ratio, int pool_mode, bool aligned); + +void roi_pool_forward(Tensor input, Tensor rois, Tensor output, Tensor argmax, + int pooled_height, int pooled_width, float spatial_scale); + +void roi_pool_backward(Tensor grad_output, Tensor rois, Tensor argmax, + Tensor grad_input, int pooled_height, int pooled_width, + float spatial_scale); + +void sync_bn_forward_mean(const Tensor input, Tensor mean); + +void sync_bn_forward_var(const Tensor input, const Tensor mean, Tensor var); + +void sync_bn_forward_output(const Tensor input, const Tensor mean, + const Tensor var, const Tensor weight, + const Tensor bias, Tensor running_mean, + Tensor running_var, Tensor norm, Tensor std, + Tensor output, float eps, float momentum, + int group_size); + +void sync_bn_backward_param(const Tensor grad_output, const Tensor norm, + Tensor grad_weight, Tensor grad_bias); + +void sync_bn_backward_data(const Tensor grad_output, const Tensor weight, + const Tensor grad_weight, const Tensor grad_bias, + const Tensor norm, const Tensor std, + Tensor grad_input); + + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + + m.def("get_compiler_version", &get_compiler_version, "get_compiler_version"); + m.def("get_compiling_cuda_version", &get_compiling_cuda_version, + "get_compiling_cuda_version"); + + m.def("sigmoid_focal_loss_forward", &sigmoid_focal_loss_forward, + "sigmoid_focal_loss_forward ", py::arg("input"), py::arg("target"), + py::arg("weight"), py::arg("output"), py::arg("gamma"), + py::arg("alpha")); + m.def("sigmoid_focal_loss_backward", &sigmoid_focal_loss_backward, + "sigmoid_focal_loss_backward", py::arg("input"), py::arg("target"), + py::arg("weight"), py::arg("grad_input"), py::arg("gamma"), + py::arg("alpha")); + m.def("softmax_focal_loss_forward", &softmax_focal_loss_forward, + "softmax_focal_loss_forward", py::arg("input"), py::arg("target"), + py::arg("weight"), py::arg("output"), py::arg("gamma"), + py::arg("alpha")); + m.def("softmax_focal_loss_backward", &softmax_focal_loss_backward, + "softmax_focal_loss_backward", py::arg("input"), py::arg("target"), + py::arg("weight"), py::arg("buff"), py::arg("grad_input"), + py::arg("gamma"), py::arg("alpha")); + m.def("nms", &nms, "nms (CPU/CUDA) ", py::arg("boxes"), py::arg("scores"), + py::arg("iou_threshold"), py::arg("offset")); + m.def("softnms", &softnms, "softnms (CPU) ", py::arg("boxes"), + py::arg("scores"), py::arg("dets"), py::arg("iou_threshold"), + py::arg("sigma"), py::arg("min_score"), py::arg("method"), + py::arg("offset")); + m.def("nms_match", &nms_match, "nms_match (CPU) ", py::arg("dets"), + py::arg("iou_threshold")); + m.def("roi_align_forward", &roi_align_forward, "roi_align forward", + py::arg("input"), py::arg("rois"), py::arg("output"), + py::arg("argmax_y"), py::arg("argmax_x"), py::arg("aligned_height"), + py::arg("aligned_width"), py::arg("spatial_scale"), + py::arg("sampling_ratio"), py::arg("pool_mode"), py::arg("aligned")); + m.def("roi_align_backward", &roi_align_backward, "roi_align backward", + py::arg("grad_output"), py::arg("rois"), py::arg("argmax_y"), + py::arg("argmax_x"), py::arg("grad_input"), py::arg("aligned_height"), + py::arg("aligned_width"), py::arg("spatial_scale"), + py::arg("sampling_ratio"), py::arg("pool_mode"), py::arg("aligned")); + m.def("roi_pool_forward", &roi_pool_forward, "roi_pool forward", + py::arg("input"), py::arg("rois"), py::arg("output"), py::arg("argmax"), + py::arg("pooled_height"), py::arg("pooled_width"), + py::arg("spatial_scale")); + m.def("roi_pool_backward", &roi_pool_backward, "roi_pool backward", + py::arg("grad_output"), py::arg("rois"), py::arg("argmax"), + py::arg("grad_input"), py::arg("pooled_height"), + py::arg("pooled_width"), py::arg("spatial_scale")); + m.def("sync_bn_forward_mean", &sync_bn_forward_mean, "sync_bn forward_mean", + py::arg("input"), py::arg("mean")); + m.def("sync_bn_forward_var", &sync_bn_forward_var, "sync_bn forward_var", + py::arg("input"), py::arg("mean"), py::arg("var")); + m.def("sync_bn_forward_output", &sync_bn_forward_output, + "sync_bn forward_output", py::arg("input"), py::arg("mean"), + py::arg("var"), py::arg("weight"), py::arg("bias"), + py::arg("running_mean"), py::arg("running_var"), py::arg("norm"), + py::arg("std"), py::arg("output"), py::arg("eps"), py::arg("momentum"), + py::arg("group_size")); + m.def("sync_bn_backward_param", &sync_bn_backward_param, + "sync_bn backward_param", py::arg("grad_output"), py::arg("norm"), + py::arg("grad_weight"), py::arg("grad_bias")); + m.def("sync_bn_backward_data", &sync_bn_backward_data, + "sync_bn backward_data", py::arg("grad_output"), py::arg("weight"), + py::arg("grad_weight"), py::arg("grad_bias"), py::arg("norm"), + py::arg("std"), py::arg("grad_input")); +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/roi_align.cpp b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/roi_align.cpp new file mode 100644 index 000000000..b44a742ce --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/roi_align.cpp @@ -0,0 +1,130 @@ +// Copyright (c) OpenMMLab. All rights reserved +#include "pytorch_cpp_helper.hpp" + +#ifdef MMCV_WITH_CUDA +void ROIAlignForwardCUDAKernelLauncher(Tensor input, Tensor rois, Tensor output, + Tensor argmax_y, Tensor argmax_x, + int aligned_height, int aligned_width, + float spatial_scale, int sampling_ratio, + int pool_mode, bool aligned); + +void ROIAlignBackwardCUDAKernelLauncher(Tensor grad_output, Tensor rois, + Tensor argmax_y, Tensor argmax_x, + Tensor grad_input, int aligned_height, + int aligned_width, float spatial_scale, + int sampling_ratio, int pool_mode, + bool aligned); + +void roi_align_forward_cuda(Tensor input, Tensor rois, Tensor output, + Tensor argmax_y, Tensor argmax_x, + int aligned_height, int aligned_width, + float spatial_scale, int sampling_ratio, + int pool_mode, bool aligned) { + ROIAlignForwardCUDAKernelLauncher( + input, rois, output, argmax_y, argmax_x, aligned_height, aligned_width, + spatial_scale, sampling_ratio, pool_mode, aligned); +} + +void roi_align_backward_cuda(Tensor grad_output, Tensor rois, Tensor argmax_y, + Tensor argmax_x, Tensor grad_input, + int aligned_height, int aligned_width, + float spatial_scale, int sampling_ratio, + int pool_mode, bool aligned) { + ROIAlignBackwardCUDAKernelLauncher( + grad_output, rois, argmax_y, argmax_x, grad_input, aligned_height, + aligned_width, spatial_scale, sampling_ratio, pool_mode, aligned); +} +#endif + +void ROIAlignForwardCPULauncher(Tensor input, Tensor rois, Tensor output, + Tensor argmax_y, Tensor argmax_x, + int aligned_height, int aligned_width, + float spatial_scale, int sampling_ratio, + int pool_mode, bool aligned); + +void ROIAlignBackwardCPULauncher(Tensor grad_output, Tensor rois, + Tensor argmax_y, Tensor argmax_x, + Tensor grad_input, int aligned_height, + int aligned_width, float spatial_scale, + int sampling_ratio, int pool_mode, + bool aligned); + +void roi_align_forward_cpu(Tensor input, Tensor rois, Tensor output, + Tensor argmax_y, Tensor argmax_x, int aligned_height, + int aligned_width, float spatial_scale, + int sampling_ratio, int pool_mode, bool aligned) { + ROIAlignForwardCPULauncher(input, rois, output, argmax_y, argmax_x, + aligned_height, aligned_width, spatial_scale, + sampling_ratio, pool_mode, aligned); +} + +void roi_align_backward_cpu(Tensor grad_output, Tensor rois, Tensor argmax_y, + Tensor argmax_x, Tensor grad_input, + int aligned_height, int aligned_width, + float spatial_scale, int sampling_ratio, + int pool_mode, bool aligned) { + ROIAlignBackwardCPULauncher(grad_output, rois, argmax_y, argmax_x, grad_input, + aligned_height, aligned_width, spatial_scale, + sampling_ratio, pool_mode, aligned); +} + +void roi_align_forward(Tensor input, Tensor rois, Tensor output, + Tensor argmax_y, Tensor argmax_x, int aligned_height, + int aligned_width, float spatial_scale, + int sampling_ratio, int pool_mode, bool aligned) { + if (input.device().is_cuda()) { +#ifdef MMCV_WITH_CUDA + CHECK_CUDA_INPUT(input); + CHECK_CUDA_INPUT(rois); + CHECK_CUDA_INPUT(output); + CHECK_CUDA_INPUT(argmax_y); + CHECK_CUDA_INPUT(argmax_x); + + roi_align_forward_cuda(input, rois, output, argmax_y, argmax_x, + aligned_height, aligned_width, spatial_scale, + sampling_ratio, pool_mode, aligned); +#else + AT_ERROR("RoIAlign is not compiled with GPU support"); +#endif + } else { + CHECK_CPU_INPUT(input); + CHECK_CPU_INPUT(rois); + CHECK_CPU_INPUT(output); + CHECK_CPU_INPUT(argmax_y); + CHECK_CPU_INPUT(argmax_x); + roi_align_forward_cpu(input, rois, output, argmax_y, argmax_x, + aligned_height, aligned_width, spatial_scale, + sampling_ratio, pool_mode, aligned); + } +} + +void roi_align_backward(Tensor grad_output, Tensor rois, Tensor argmax_y, + Tensor argmax_x, Tensor grad_input, int aligned_height, + int aligned_width, float spatial_scale, + int sampling_ratio, int pool_mode, bool aligned) { + if (grad_output.device().is_cuda()) { +#ifdef MMCV_WITH_CUDA + CHECK_CUDA_INPUT(grad_output); + CHECK_CUDA_INPUT(rois); + CHECK_CUDA_INPUT(argmax_y); + CHECK_CUDA_INPUT(argmax_x); + CHECK_CUDA_INPUT(grad_input); + + roi_align_backward_cuda(grad_output, rois, argmax_y, argmax_x, grad_input, + aligned_height, aligned_width, spatial_scale, + sampling_ratio, pool_mode, aligned); +#else + AT_ERROR("RoIAlign is not compiled with GPU support"); +#endif + } else { + CHECK_CPU_INPUT(grad_output); + CHECK_CPU_INPUT(rois); + CHECK_CPU_INPUT(argmax_y); + CHECK_CPU_INPUT(argmax_x); + CHECK_CPU_INPUT(grad_input); + + roi_align_backward_cpu(grad_output, rois, argmax_y, argmax_x, grad_input, + aligned_height, aligned_width, spatial_scale, + sampling_ratio, pool_mode, aligned); + } +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/roi_align_cpu.cpp b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/roi_align_cpu.cpp new file mode 100644 index 000000000..3f797cb63 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/roi_align_cpu.cpp @@ -0,0 +1,431 @@ +// Modified from +// https://github.com/facebookresearch/detectron2/tree/master/detectron2/layers/csrc/ROIAlign +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved +#include +#include + +#include "pytorch_cpp_helper.hpp" + +// implementation taken from Caffe2 +template +struct PreCalc { + int pos1; + int pos2; + int pos3; + int pos4; + T w1; + T w2; + T w3; + T w4; +}; + +template +void pre_calc_for_bilinear_interpolate( + const int height, const int width, const int pooled_height, + const int pooled_width, const int iy_upper, const int ix_upper, + T roi_start_h, T roi_start_w, T bin_size_h, T bin_size_w, + int roi_bin_grid_h, int roi_bin_grid_w, std::vector>& pre_calc) { + int pre_calc_index = 0; + for (int ph = 0; ph < pooled_height; ph++) { + for (int pw = 0; pw < pooled_width; pw++) { + for (int iy = 0; iy < iy_upper; iy++) { + const T yy = roi_start_h + ph * bin_size_h + + static_cast(iy + .5f) * bin_size_h / + static_cast(roi_bin_grid_h); // e.g., 0.5, 1.5 + for (int ix = 0; ix < ix_upper; ix++) { + const T xx = roi_start_w + pw * bin_size_w + + static_cast(ix + .5f) * bin_size_w / + static_cast(roi_bin_grid_w); + + T x = xx; + T y = yy; + // deal with: inverse elements are out of feature map boundary + if (y < -1.0 || y > height || x < -1.0 || x > width) { + // empty + PreCalc pc; + pc.pos1 = 0; + pc.pos2 = 0; + pc.pos3 = 0; + pc.pos4 = 0; + pc.w1 = 0; + pc.w2 = 0; + pc.w3 = 0; + pc.w4 = 0; + pre_calc[pre_calc_index] = pc; + pre_calc_index += 1; + continue; + } + + if (y <= 0) { + y = 0; + } + if (x <= 0) { + x = 0; + } + + int y_low = (int)y; + int x_low = (int)x; + int y_high; + int x_high; + + if (y_low >= height - 1) { + y_high = y_low = height - 1; + y = (T)y_low; + } else { + y_high = y_low + 1; + } + + if (x_low >= width - 1) { + x_high = x_low = width - 1; + x = (T)x_low; + } else { + x_high = x_low + 1; + } + + T ly = y - y_low; + T lx = x - x_low; + T hy = 1. - ly, hx = 1. - lx; + T w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; + + // save weights and indices + PreCalc pc; + pc.pos1 = y_low * width + x_low; + pc.pos2 = y_low * width + x_high; + pc.pos3 = y_high * width + x_low; + pc.pos4 = y_high * width + x_high; + pc.w1 = w1; + pc.w2 = w2; + pc.w3 = w3; + pc.w4 = w4; + pre_calc[pre_calc_index] = pc; + + pre_calc_index += 1; + } + } + } + } +} + +template +void ROIAlignForward(const int nthreads, const T* input, const T* rois, + T* output, T* argmax_y, T* argmax_x, + const int pooled_height, const int pooled_width, + const T spatial_scale, const int sampling_ratio, + const int pool_mode, // 0 - max pool, 1 - avg pool + const bool aligned, const int channels, const int height, + const int width) { + int n_rois = nthreads / channels / pooled_width / pooled_height; + // (n, c, ph, pw) is an element in the pooled output + // can be parallelized using omp + // #pragma omp parallel for num_threads(32) + for (int n = 0; n < n_rois; n++) { + int index_n = n * channels * pooled_width * pooled_height; + + const T* offset_rois = rois + n * 5; + int roi_batch_ind = offset_rois[0]; + + // Do not use rounding; this implementation detail is critical + T offset = aligned ? (T)0.5 : (T)0.0; + T roi_start_w = offset_rois[1] * spatial_scale - offset; + T roi_start_h = offset_rois[2] * spatial_scale - offset; + T roi_end_w = offset_rois[3] * spatial_scale - offset; + T roi_end_h = offset_rois[4] * spatial_scale - offset; + + T roi_width = roi_end_w - roi_start_w; + T roi_height = roi_end_h - roi_start_h; + if (aligned) { + AT_ASSERTM(roi_width >= 0 && roi_height >= 0, + "ROIs in ROIAlign cannot have non-negative size!"); + } else { // for backward-compatibility only + roi_width = std::max(roi_width, (T)1.); + roi_height = std::max(roi_height, (T)1.); + } + T bin_size_h = static_cast(roi_height) / static_cast(pooled_height); + T bin_size_w = static_cast(roi_width) / static_cast(pooled_width); + + // We use roi_bin_grid to sample the grid and mimic integral + int roi_bin_grid_h = (sampling_ratio > 0) + ? sampling_ratio + : ceilf(roi_height / pooled_height); // e.g., = 2 + int roi_bin_grid_w = + (sampling_ratio > 0) ? sampling_ratio : ceilf(roi_width / pooled_width); + + // When the grid is empty, output zeros == 0/1, instead of NaN. + const T count = std::max(roi_bin_grid_h * roi_bin_grid_w, 1); // e.g. = 4 + + // we want to precalculate indices and weights shared by all channels, + // this is the key point of optimization + std::vector> pre_calc(roi_bin_grid_h * roi_bin_grid_w * + pooled_width * pooled_height); + pre_calc_for_bilinear_interpolate( + height, width, pooled_height, pooled_width, roi_bin_grid_h, + roi_bin_grid_w, roi_start_h, roi_start_w, bin_size_h, bin_size_w, + roi_bin_grid_h, roi_bin_grid_w, pre_calc); + + for (int c = 0; c < channels; c++) { + int index_n_c = index_n + c * pooled_width * pooled_height; + const T* offset_input = + input + (roi_batch_ind * channels + c) * height * width; + int pre_calc_index = 0; + + for (int ph = 0; ph < pooled_height; ph++) { + for (int pw = 0; pw < pooled_width; pw++) { + int index = index_n_c + ph * pooled_width + pw; + + T output_val = 0.; + T maxval = -10000; + T maxidx_y = -1.f, maxidx_x = -1.f; + for (int iy = 0; iy < roi_bin_grid_h; iy++) { + const T y = roi_start_h + ph * bin_size_h + + static_cast(iy + .5f) * bin_size_h / + static_cast(roi_bin_grid_h); + for (int ix = 0; ix < roi_bin_grid_w; ix++) { + const T x = roi_start_w + pw * bin_size_w + + static_cast(ix + .5f) * bin_size_w / + static_cast(roi_bin_grid_w); + PreCalc pc = pre_calc[pre_calc_index]; + T val = pc.w1 * offset_input[pc.pos1] + + pc.w2 * offset_input[pc.pos2] + + pc.w3 * offset_input[pc.pos3] + + pc.w4 * offset_input[pc.pos4]; + if (val > maxval) { + maxval = val; + maxidx_y = y; + maxidx_x = x; + } + output_val += val; + pre_calc_index += 1; + } + } + if (pool_mode == 0) { + // We do max pooling inside a bin + output[index] = maxval; + argmax_y[index] = maxidx_y; + argmax_x[index] = maxidx_x; + } else if (pool_mode == 1) { + // We do average (integral) pooling inside a bin + output[index] = output_val / count; + } // if + } // for pw + } // for ph + } // for c + } // for n +} + +template +void bilinear_interpolate_gradient(const int height, const int width, T y, T x, + T& w1, T& w2, T& w3, T& w4, int& x_low, + int& x_high, int& y_low, int& y_high, + const int index /* index for debug only*/) { + // deal with cases that inverse elements are out of feature map boundary + if (y < -1.0 || y > height || x < -1.0 || x > width) { + // empty + w1 = w2 = w3 = w4 = 0.; + x_low = x_high = y_low = y_high = -1; + return; + } + + if (y <= 0) y = 0; + if (x <= 0) x = 0; + + y_low = (int)y; + x_low = (int)x; + + if (y_low >= height - 1) { + y_high = y_low = height - 1; + y = (T)y_low; + } else { + y_high = y_low + 1; + } + + if (x_low >= width - 1) { + x_high = x_low = width - 1; + x = (T)x_low; + } else { + x_high = x_low + 1; + } + + T ly = y - y_low; + T lx = x - x_low; + T hy = 1. - ly, hx = 1. - lx; + + // reference in forward + // T v1 = input[y_low * width + x_low]; + // T v2 = input[y_low * width + x_high]; + // T v3 = input[y_high * width + x_low]; + // T v4 = input[y_high * width + x_high]; + // T val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); + + w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; + + return; +} + +template +inline void add(T* address, const T& val) { + *address += val; +} + +template +void ROIAlignBackward(const int nthreads, const T* grad_output, const T* rois, + const T* argmax_y, const T* argmax_x, T* grad_input, + const int pooled_height, const int pooled_width, + const T spatial_scale, const int sampling_ratio, + const int pool_mode, // 0 - max pool, 1 - avg pool + const bool aligned, const int channels, const int height, + const int width, const int n_stride, const int c_stride, + const int h_stride, const int w_stride) { + for (int index = 0; index < nthreads; index++) { + // (n, c, ph, pw) is an element in the pooled output + int pw = index % pooled_width; + int ph = (index / pooled_width) % pooled_height; + int c = (index / pooled_width / pooled_height) % channels; + int n = index / pooled_width / pooled_height / channels; + + const T* offset_rois = rois + n * 5; + int roi_batch_ind = offset_rois[0]; + + // Do not use rounding; this implementation detail is critical + T offset = aligned ? (T)0.5 : (T)0.0; + T roi_start_w = offset_rois[1] * spatial_scale - offset; + T roi_start_h = offset_rois[2] * spatial_scale - offset; + T roi_end_w = offset_rois[3] * spatial_scale - offset; + T roi_end_h = offset_rois[4] * spatial_scale - offset; + + T roi_width = roi_end_w - roi_start_w; + T roi_height = roi_end_h - roi_start_h; + if (aligned) { + AT_ASSERTM(roi_width >= 0 && roi_height >= 0, + "ROIs in ROIAlign do not have non-negative size!"); + } else { // for backward-compatibility only + roi_width = std::max(roi_width, (T)1.); + roi_height = std::max(roi_height, (T)1.); + } + T bin_size_h = static_cast(roi_height) / static_cast(pooled_height); + T bin_size_w = static_cast(roi_width) / static_cast(pooled_width); + + T* offset_grad_input = + grad_input + ((roi_batch_ind * channels + c) * height * width); + + int output_offset = n * n_stride + c * c_stride; + const T* offset_grad_output = grad_output + output_offset; + const T grad_output_this_bin = + offset_grad_output[ph * h_stride + pw * w_stride]; + + if (pool_mode == 0) { + // We do max pooling inside a bin + T y = argmax_y[index], x = argmax_x[index]; + if (y != -1.f) { + T w1, w2, w3, w4; + int x_low, x_high, y_low, y_high; + bilinear_interpolate_gradient(height, width, y, x, w1, w2, w3, w4, + x_low, x_high, y_low, y_high, index); + + T g1 = grad_output_this_bin * w1; + T g2 = grad_output_this_bin * w2; + T g3 = grad_output_this_bin * w3; + T g4 = grad_output_this_bin * w4; + + if (x_low >= 0 && x_high >= 0 && y_low >= 0 && y_high >= 0) { + // atomic add is not needed for now since it is single threaded + add(offset_grad_input + y_low * width + x_low, static_cast(g1)); + add(offset_grad_input + y_low * width + x_high, static_cast(g2)); + add(offset_grad_input + y_high * width + x_low, static_cast(g3)); + add(offset_grad_input + y_high * width + x_high, static_cast(g4)); + } // if + } // mode + } else if (pool_mode == 1) { + // We do average (integral) pooling inside a bin + // We use roi_bin_grid to sample the grid and mimic integral + int roi_bin_grid_h = + (sampling_ratio > 0) + ? sampling_ratio + : ceilf(roi_height / pooled_height); // e.g., = 2 + int roi_bin_grid_w = (sampling_ratio > 0) + ? sampling_ratio + : ceilf(roi_width / pooled_width); + + const T count = roi_bin_grid_h * roi_bin_grid_w; // e.g. = 4 + for (int iy = 0; iy < roi_bin_grid_h; iy++) { + const T y = roi_start_h + ph * bin_size_h + + static_cast(iy + .5f) * bin_size_h / + static_cast(roi_bin_grid_h); // e.g., 0.5, 1.5 + for (int ix = 0; ix < roi_bin_grid_w; ix++) { + const T x = roi_start_w + pw * bin_size_w + + static_cast(ix + .5f) * bin_size_w / + static_cast(roi_bin_grid_w); + + T w1, w2, w3, w4; + int x_low, x_high, y_low, y_high; + + bilinear_interpolate_gradient(height, width, y, x, w1, w2, w3, w4, + x_low, x_high, y_low, y_high, index); + + T g1 = grad_output_this_bin * w1 / count; + T g2 = grad_output_this_bin * w2 / count; + T g3 = grad_output_this_bin * w3 / count; + T g4 = grad_output_this_bin * w4 / count; + + if (x_low >= 0 && x_high >= 0 && y_low >= 0 && y_high >= 0) { + // atomic add is not needed for now since it is single threaded + add(offset_grad_input + y_low * width + x_low, static_cast(g1)); + add(offset_grad_input + y_low * width + x_high, static_cast(g2)); + add(offset_grad_input + y_high * width + x_low, static_cast(g3)); + add(offset_grad_input + y_high * width + x_high, + static_cast(g4)); + } // if + } // ix + } // iy + } // mode + } // for +} // ROIAlignBackward + +void ROIAlignForwardCPULauncher(Tensor input, Tensor rois, Tensor output, + Tensor argmax_y, Tensor argmax_x, + int aligned_height, int aligned_width, + float spatial_scale, int sampling_ratio, + int pool_mode, bool aligned) { + int output_size = output.numel(); + int channels = input.size(1); + int height = input.size(2); + int width = input.size(3); + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + input.scalar_type(), "ROIAlign_forward", [&] { + ROIAlignForward( + output_size, input.data_ptr(), rois.data_ptr(), + output.data_ptr(), argmax_y.data_ptr(), + argmax_x.data_ptr(), aligned_height, aligned_width, + static_cast(spatial_scale), sampling_ratio, pool_mode, + aligned, channels, height, width); + }); +} + +void ROIAlignBackwardCPULauncher(Tensor grad_output, Tensor rois, + Tensor argmax_y, Tensor argmax_x, + Tensor grad_input, int aligned_height, + int aligned_width, float spatial_scale, + int sampling_ratio, int pool_mode, + bool aligned) { + int output_size = grad_output.numel(); + int channels = grad_input.size(1); + int height = grad_input.size(2); + int width = grad_input.size(3); + + // get stride values to ensure indexing into gradients is correct. + int n_stride = grad_output.stride(0); + int c_stride = grad_output.stride(1); + int h_stride = grad_output.stride(2); + int w_stride = grad_output.stride(3); + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + grad_output.scalar_type(), "ROIAlign_backward", [&] { + ROIAlignBackward( + output_size, grad_output.data_ptr(), + rois.data_ptr(), argmax_y.data_ptr(), + argmax_x.data_ptr(), grad_input.data_ptr(), + aligned_height, aligned_width, static_cast(spatial_scale), + sampling_ratio, pool_mode, aligned, channels, height, width, + n_stride, c_stride, h_stride, w_stride); + }); +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/roi_pool.cpp b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/roi_pool.cpp new file mode 100644 index 000000000..34c4b996b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/roi_pool.cpp @@ -0,0 +1,67 @@ +// Copyright (c) OpenMMLab. All rights reserved +#include "pytorch_cpp_helper.hpp" + +#ifdef MMCV_WITH_CUDA +void ROIPoolForwardCUDAKernelLauncher(Tensor input, Tensor rois, Tensor output, + Tensor argmax, int pooled_height, + int pooled_width, float spatial_scale); + +void ROIPoolBackwardCUDAKernelLauncher(Tensor grad_output, Tensor rois, + Tensor argmax, Tensor grad_input, + int pooled_height, int pooled_width, + float spatial_scale); + +void roi_pool_forward_cuda(Tensor input, Tensor rois, Tensor output, + Tensor argmax, int pooled_height, int pooled_width, + float spatial_scale) { + ROIPoolForwardCUDAKernelLauncher(input, rois, output, argmax, pooled_height, + pooled_width, spatial_scale); +} + +void roi_pool_backward_cuda(Tensor grad_output, Tensor rois, Tensor argmax, + Tensor grad_input, int pooled_height, + int pooled_width, float spatial_scale) { + ROIPoolBackwardCUDAKernelLauncher(grad_output, rois, argmax, grad_input, + pooled_height, pooled_width, spatial_scale); +} +#endif + +void roi_pool_forward(Tensor input, Tensor rois, Tensor output, Tensor argmax, + int pooled_height, int pooled_width, + float spatial_scale) { + if (input.device().is_cuda()) { +#ifdef MMCV_WITH_CUDA + CHECK_CUDA_INPUT(input); + CHECK_CUDA_INPUT(rois); + CHECK_CUDA_INPUT(output); + CHECK_CUDA_INPUT(argmax); + + roi_pool_forward_cuda(input, rois, output, argmax, pooled_height, + pooled_width, spatial_scale); +#else + AT_ERROR("RoIPool is not compiled with GPU support"); +#endif + } else { + AT_ERROR("RoIPool is not implemented on CPU"); + } +} + +void roi_pool_backward(Tensor grad_output, Tensor rois, Tensor argmax, + Tensor grad_input, int pooled_height, int pooled_width, + float spatial_scale) { + if (grad_output.device().is_cuda()) { +#ifdef MMCV_WITH_CUDA + CHECK_CUDA_INPUT(grad_output); + CHECK_CUDA_INPUT(rois); + CHECK_CUDA_INPUT(argmax); + CHECK_CUDA_INPUT(grad_input); + + roi_pool_backward_cuda(grad_output, rois, argmax, grad_input, pooled_height, + pooled_width, spatial_scale); +#else + AT_ERROR("RoIPool is not compiled with GPU support"); +#endif + } else { + AT_ERROR("RoIPool is not implemented on CPU"); + } +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/sync_bn.cpp b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/sync_bn.cpp new file mode 100644 index 000000000..2e023a859 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/csrc/pytorch/sync_bn.cpp @@ -0,0 +1,159 @@ +// Copyright (c) OpenMMLab. All rights reserved +#include "pytorch_cpp_helper.hpp" + +#ifdef MMCV_WITH_CUDA +void SyncBNForwardMeanCUDAKernelLauncher(const Tensor input, Tensor mean); + +void SyncBNForwardVarCUDAKernelLauncher(const Tensor input, const Tensor mean, + Tensor var); + +void SyncBNForwardOutputCUDAKernelLauncher( + const Tensor input, const Tensor mean, const Tensor var, + Tensor running_mean, Tensor running_var, const Tensor weight, + const Tensor bias, Tensor norm, Tensor std, Tensor output, float eps, + float momentum, int group_size); + +void SyncBNBackwardParamCUDAKernelLauncher(const Tensor grad_output, + const Tensor norm, + Tensor grad_weight, + Tensor grad_bias); + +void SyncBNBackwardDataCUDAKernelLauncher(const Tensor grad_output, + const Tensor weight, + const Tensor grad_weight, + const Tensor grad_bias, + const Tensor norm, const Tensor std, + Tensor grad_input); + +void sync_bn_forward_mean_cuda(const Tensor input, Tensor mean) { + SyncBNForwardMeanCUDAKernelLauncher(input, mean); +} + +void sync_bn_forward_var_cuda(const Tensor input, const Tensor mean, + Tensor var) { + SyncBNForwardVarCUDAKernelLauncher(input, mean, var); +} + +void sync_bn_forward_output_cuda(const Tensor input, const Tensor mean, + const Tensor var, Tensor running_mean, + Tensor running_var, const Tensor weight, + const Tensor bias, Tensor norm, Tensor std, + Tensor output, float eps, float momentum, + int group_size) { + SyncBNForwardOutputCUDAKernelLauncher(input, mean, var, running_mean, + running_var, weight, bias, norm, std, + output, eps, momentum, group_size); +} + +void sync_bn_backward_param_cuda(const Tensor grad_output, const Tensor norm, + Tensor grad_weight, Tensor grad_bias) { + SyncBNBackwardParamCUDAKernelLauncher(grad_output, norm, grad_weight, + grad_bias); +} + +void sync_bn_backward_data_cuda(const Tensor grad_output, const Tensor weight, + const Tensor grad_weight, + const Tensor grad_bias, const Tensor norm, + const Tensor std, Tensor grad_input) { + SyncBNBackwardDataCUDAKernelLauncher(grad_output, weight, grad_weight, + grad_bias, norm, std, grad_input); +} +#endif + +void sync_bn_forward_mean(const Tensor input, Tensor mean) { + if (input.device().is_cuda()) { +#ifdef MMCV_WITH_CUDA + CHECK_CUDA_INPUT(input); + CHECK_CUDA_INPUT(mean); + sync_bn_forward_mean_cuda(input, mean); +#else + AT_ERROR("SyncBatchNorm is not compiled with GPU support"); +#endif + } else { + AT_ERROR("SyncBatchNorm is not implemented on CPU"); + } +} + +void sync_bn_forward_var(const Tensor input, const Tensor mean, Tensor var) { + if (input.device().is_cuda()) { +#ifdef MMCV_WITH_CUDA + CHECK_CUDA_INPUT(input); + CHECK_CUDA_INPUT(mean); + CHECK_CUDA_INPUT(var); + sync_bn_forward_var_cuda(input, mean, var); +#else + AT_ERROR("SyncBatchNorm is not compiled with GPU support"); +#endif + } else { + AT_ERROR("SyncBatchNorm is not implemented on CPU"); + } +} + +void sync_bn_forward_output(const Tensor input, const Tensor mean, + const Tensor var, const Tensor weight, + const Tensor bias, Tensor running_mean, + Tensor running_var, Tensor norm, Tensor std, + Tensor output, float eps, float momentum, + int group_size) { + if (input.device().is_cuda()) { +#ifdef MMCV_WITH_CUDA + CHECK_CUDA_INPUT(input); + CHECK_CUDA_INPUT(mean); + CHECK_CUDA_INPUT(var); + CHECK_CUDA_INPUT(weight); + CHECK_CUDA_INPUT(bias); + CHECK_CUDA_INPUT(running_mean); + CHECK_CUDA_INPUT(running_var); + CHECK_CUDA_INPUT(norm); + CHECK_CUDA_INPUT(std); + CHECK_CUDA_INPUT(output); + sync_bn_forward_output_cuda(input, mean, var, running_mean, running_var, + weight, bias, norm, std, output, eps, momentum, + group_size); +#else + AT_ERROR("SyncBatchNorm is not compiled with GPU support"); +#endif + } else { + AT_ERROR("SyncBatchNorm is not implemented on CPU"); + } +} + +void sync_bn_backward_param(const Tensor grad_output, const Tensor norm, + Tensor grad_weight, Tensor grad_bias) { + if (grad_output.device().is_cuda()) { +#ifdef MMCV_WITH_CUDA + CHECK_CUDA_INPUT(grad_output); + CHECK_CUDA_INPUT(norm); + CHECK_CUDA_INPUT(grad_weight); + CHECK_CUDA_INPUT(grad_bias); + sync_bn_backward_param_cuda(grad_output, norm, grad_weight, grad_bias); +#else + AT_ERROR("SyncBatchNorm is not compiled with GPU support"); +#endif + } else { + AT_ERROR("SyncBatchNorm is not implemented on CPU"); + } +} + +void sync_bn_backward_data(const Tensor grad_output, const Tensor weight, + const Tensor grad_weight, const Tensor grad_bias, + const Tensor norm, const Tensor std, + Tensor grad_input) { + if (grad_output.device().is_cuda()) { +#ifdef MMCV_WITH_CUDA + CHECK_CUDA_INPUT(grad_output); + CHECK_CUDA_INPUT(weight); + CHECK_CUDA_INPUT(grad_weight); + CHECK_CUDA_INPUT(grad_bias); + CHECK_CUDA_INPUT(norm); + CHECK_CUDA_INPUT(std); + CHECK_CUDA_INPUT(grad_input); + sync_bn_backward_data_cuda(grad_output, weight, grad_weight, grad_bias, + norm, std, grad_input); +#else + AT_ERROR("SyncBatchNorm is not compiled with GPU support"); +#endif + } else { + AT_ERROR("SyncBatchNorm is not implemented on CPU"); + } +} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/deprecated_wrappers.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/deprecated_wrappers.py new file mode 100644 index 000000000..a2e593df9 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/deprecated_wrappers.py @@ -0,0 +1,43 @@ +# Copyright (c) OpenMMLab. All rights reserved. +# This file is for backward compatibility. +# Module wrappers for empty tensor have been moved to mmcv.cnn.bricks. +import warnings + +from ..cnn.bricks.wrappers import Conv2d, ConvTranspose2d, Linear, MaxPool2d + + +class Conv2d_deprecated(Conv2d): + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + warnings.warn( + 'Importing Conv2d wrapper from "mmcv.ops" will be deprecated in' + ' the future. Please import them from "mmcv.cnn" instead') + + +class ConvTranspose2d_deprecated(ConvTranspose2d): + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + warnings.warn( + 'Importing ConvTranspose2d wrapper from "mmcv.ops" will be ' + 'deprecated in the future. Please import them from "mmcv.cnn" ' + 'instead') + + +class MaxPool2d_deprecated(MaxPool2d): + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + warnings.warn( + 'Importing MaxPool2d wrapper from "mmcv.ops" will be deprecated in' + ' the future. Please import them from "mmcv.cnn" instead') + + +class Linear_deprecated(Linear): + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + warnings.warn( + 'Importing Linear wrapper from "mmcv.ops" will be deprecated in' + ' the future. Please import them from "mmcv.cnn" instead') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/focal_loss.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/focal_loss.py new file mode 100644 index 000000000..763bc93bd --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/focal_loss.py @@ -0,0 +1,212 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch +import torch.nn as nn +from torch.autograd import Function +from torch.autograd.function import once_differentiable + +from ..utils import ext_loader + +ext_module = ext_loader.load_ext('_ext', [ + 'sigmoid_focal_loss_forward', 'sigmoid_focal_loss_backward', + 'softmax_focal_loss_forward', 'softmax_focal_loss_backward' +]) + + +class SigmoidFocalLossFunction(Function): + + @staticmethod + def symbolic(g, input, target, gamma, alpha, weight, reduction): + return g.op( + 'mmcv::MMCVSigmoidFocalLoss', + input, + target, + gamma_f=gamma, + alpha_f=alpha, + weight_f=weight, + reduction_s=reduction) + + @staticmethod + def forward(ctx, + input, + target, + gamma=2.0, + alpha=0.25, + weight=None, + reduction='mean'): + + assert isinstance(target, (torch.LongTensor, torch.cuda.LongTensor)) + assert input.dim() == 2 + assert target.dim() == 1 + assert input.size(0) == target.size(0) + if weight is None: + weight = input.new_empty(0) + else: + assert weight.dim() == 1 + assert input.size(1) == weight.size(0) + ctx.reduction_dict = {'none': 0, 'mean': 1, 'sum': 2} + assert reduction in ctx.reduction_dict.keys() + + ctx.gamma = float(gamma) + ctx.alpha = float(alpha) + ctx.reduction = ctx.reduction_dict[reduction] + + output = input.new_zeros(input.size()) + + ext_module.sigmoid_focal_loss_forward( + input, target, weight, output, gamma=ctx.gamma, alpha=ctx.alpha) + if ctx.reduction == ctx.reduction_dict['mean']: + output = output.sum() / input.size(0) + elif ctx.reduction == ctx.reduction_dict['sum']: + output = output.sum() + ctx.save_for_backward(input, target, weight) + return output + + @staticmethod + @once_differentiable + def backward(ctx, grad_output): + input, target, weight = ctx.saved_tensors + + grad_input = input.new_zeros(input.size()) + + ext_module.sigmoid_focal_loss_backward( + input, + target, + weight, + grad_input, + gamma=ctx.gamma, + alpha=ctx.alpha) + + grad_input *= grad_output + if ctx.reduction == ctx.reduction_dict['mean']: + grad_input /= input.size(0) + return grad_input, None, None, None, None, None + + +sigmoid_focal_loss = SigmoidFocalLossFunction.apply + + +class SigmoidFocalLoss(nn.Module): + + def __init__(self, gamma, alpha, weight=None, reduction='mean'): + super(SigmoidFocalLoss, self).__init__() + self.gamma = gamma + self.alpha = alpha + self.register_buffer('weight', weight) + self.reduction = reduction + + def forward(self, input, target): + return sigmoid_focal_loss(input, target, self.gamma, self.alpha, + self.weight, self.reduction) + + def __repr__(self): + s = self.__class__.__name__ + s += f'(gamma={self.gamma}, ' + s += f'alpha={self.alpha}, ' + s += f'reduction={self.reduction})' + return s + + +class SoftmaxFocalLossFunction(Function): + + @staticmethod + def symbolic(g, input, target, gamma, alpha, weight, reduction): + return g.op( + 'mmcv::MMCVSoftmaxFocalLoss', + input, + target, + gamma_f=gamma, + alpha_f=alpha, + weight_f=weight, + reduction_s=reduction) + + @staticmethod + def forward(ctx, + input, + target, + gamma=2.0, + alpha=0.25, + weight=None, + reduction='mean'): + + assert isinstance(target, (torch.LongTensor, torch.cuda.LongTensor)) + assert input.dim() == 2 + assert target.dim() == 1 + assert input.size(0) == target.size(0) + if weight is None: + weight = input.new_empty(0) + else: + assert weight.dim() == 1 + assert input.size(1) == weight.size(0) + ctx.reduction_dict = {'none': 0, 'mean': 1, 'sum': 2} + assert reduction in ctx.reduction_dict.keys() + + ctx.gamma = float(gamma) + ctx.alpha = float(alpha) + ctx.reduction = ctx.reduction_dict[reduction] + + channel_stats, _ = torch.max(input, dim=1) + input_softmax = input - channel_stats.unsqueeze(1).expand_as(input) + input_softmax.exp_() + + channel_stats = input_softmax.sum(dim=1) + input_softmax /= channel_stats.unsqueeze(1).expand_as(input) + + output = input.new_zeros(input.size(0)) + ext_module.softmax_focal_loss_forward( + input_softmax, + target, + weight, + output, + gamma=ctx.gamma, + alpha=ctx.alpha) + + if ctx.reduction == ctx.reduction_dict['mean']: + output = output.sum() / input.size(0) + elif ctx.reduction == ctx.reduction_dict['sum']: + output = output.sum() + ctx.save_for_backward(input_softmax, target, weight) + return output + + @staticmethod + def backward(ctx, grad_output): + input_softmax, target, weight = ctx.saved_tensors + buff = input_softmax.new_zeros(input_softmax.size(0)) + grad_input = input_softmax.new_zeros(input_softmax.size()) + + ext_module.softmax_focal_loss_backward( + input_softmax, + target, + weight, + buff, + grad_input, + gamma=ctx.gamma, + alpha=ctx.alpha) + + grad_input *= grad_output + if ctx.reduction == ctx.reduction_dict['mean']: + grad_input /= input_softmax.size(0) + return grad_input, None, None, None, None, None + + +softmax_focal_loss = SoftmaxFocalLossFunction.apply + + +class SoftmaxFocalLoss(nn.Module): + + def __init__(self, gamma, alpha, weight=None, reduction='mean'): + super(SoftmaxFocalLoss, self).__init__() + self.gamma = gamma + self.alpha = alpha + self.register_buffer('weight', weight) + self.reduction = reduction + + def forward(self, input, target): + return softmax_focal_loss(input, target, self.gamma, self.alpha, + self.weight, self.reduction) + + def __repr__(self): + s = self.__class__.__name__ + s += f'(gamma={self.gamma}, ' + s += f'alpha={self.alpha}, ' + s += f'reduction={self.reduction})' + return s diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/info.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/info.py new file mode 100644 index 000000000..29f2e5598 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/info.py @@ -0,0 +1,36 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import glob +import os + +import torch + +if torch.__version__ == 'parrots': + import parrots + + def get_compiler_version(): + return 'GCC ' + parrots.version.compiler + + def get_compiling_cuda_version(): + return parrots.version.cuda +else: + from ..utils import ext_loader + ext_module = ext_loader.load_ext( + '_ext', ['get_compiler_version', 'get_compiling_cuda_version']) + + def get_compiler_version(): + return ext_module.get_compiler_version() + + def get_compiling_cuda_version(): + return ext_module.get_compiling_cuda_version() + + +def get_onnxruntime_op_path(): + wildcard = os.path.join( + os.path.abspath(os.path.dirname(os.path.dirname(__file__))), + '_ext_ort.*.so') + + paths = glob.glob(wildcard) + if len(paths) > 0: + return paths[0] + else: + return '' diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/nms.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/nms.py new file mode 100644 index 000000000..40ff7bee7 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/nms.py @@ -0,0 +1,417 @@ +import os + +import numpy as np +import torch + +from mmcv.utils import deprecated_api_warning +from ..utils import ext_loader + +ext_module = ext_loader.load_ext( + '_ext', ['nms', 'softnms', 'nms_match']) + + +# This function is modified from: https://github.com/pytorch/vision/ +class NMSop(torch.autograd.Function): + + @staticmethod + def forward(ctx, bboxes, scores, iou_threshold, offset, score_threshold, + max_num): + is_filtering_by_score = score_threshold > 0 + if is_filtering_by_score: + valid_mask = scores > score_threshold + bboxes, scores = bboxes[valid_mask], scores[valid_mask] + valid_inds = torch.nonzero( + valid_mask, as_tuple=False).squeeze(dim=1) + + inds = ext_module.nms( + bboxes, scores, iou_threshold=float(iou_threshold), offset=offset) + + if max_num > 0: + inds = inds[:max_num] + if is_filtering_by_score: + inds = valid_inds[inds] + return inds + + @staticmethod + def symbolic(g, bboxes, scores, iou_threshold, offset, score_threshold, + max_num): + from ..onnx import is_custom_op_loaded + has_custom_op = is_custom_op_loaded() + # TensorRT nms plugin is aligned with original nms in ONNXRuntime + is_trt_backend = os.environ.get('ONNX_BACKEND') == 'MMCVTensorRT' + if has_custom_op and (not is_trt_backend): + return g.op( + 'mmcv::NonMaxSuppression', + bboxes, + scores, + iou_threshold_f=float(iou_threshold), + offset_i=int(offset)) + else: + from torch.onnx.symbolic_opset9 import select, squeeze, unsqueeze + from ..onnx.onnx_utils.symbolic_helper import _size_helper + + boxes = unsqueeze(g, bboxes, 0) + scores = unsqueeze(g, unsqueeze(g, scores, 0), 0) + + if max_num > 0: + max_num = g.op( + 'Constant', + value_t=torch.tensor(max_num, dtype=torch.long)) + else: + dim = g.op('Constant', value_t=torch.tensor(0)) + max_num = _size_helper(g, bboxes, dim) + max_output_per_class = max_num + iou_threshold = g.op( + 'Constant', + value_t=torch.tensor([iou_threshold], dtype=torch.float)) + score_threshold = g.op( + 'Constant', + value_t=torch.tensor([score_threshold], dtype=torch.float)) + nms_out = g.op('NonMaxSuppression', boxes, scores, + max_output_per_class, iou_threshold, + score_threshold) + return squeeze( + g, + select( + g, nms_out, 1, + g.op( + 'Constant', + value_t=torch.tensor([2], dtype=torch.long))), 1) + + +class SoftNMSop(torch.autograd.Function): + + @staticmethod + def forward(ctx, boxes, scores, iou_threshold, sigma, min_score, method, + offset): + dets = boxes.new_empty((boxes.size(0), 5), device='cpu') + inds = ext_module.softnms( + boxes.cpu(), + scores.cpu(), + dets.cpu(), + iou_threshold=float(iou_threshold), + sigma=float(sigma), + min_score=float(min_score), + method=int(method), + offset=int(offset)) + return dets, inds + + @staticmethod + def symbolic(g, boxes, scores, iou_threshold, sigma, min_score, method, + offset): + from packaging import version + assert version.parse(torch.__version__) >= version.parse('1.7.0') + nms_out = g.op( + 'mmcv::SoftNonMaxSuppression', + boxes, + scores, + iou_threshold_f=float(iou_threshold), + sigma_f=float(sigma), + min_score_f=float(min_score), + method_i=int(method), + offset_i=int(offset), + outputs=2) + return nms_out + + +@deprecated_api_warning({'iou_thr': 'iou_threshold'}) +def nms(boxes, scores, iou_threshold, offset=0, score_threshold=0, max_num=-1): + """Dispatch to either CPU or GPU NMS implementations. + + The input can be either torch tensor or numpy array. GPU NMS will be used + if the input is gpu tensor, otherwise CPU NMS + will be used. The returned type will always be the same as inputs. + + Arguments: + boxes (torch.Tensor or np.ndarray): boxes in shape (N, 4). + scores (torch.Tensor or np.ndarray): scores in shape (N, ). + iou_threshold (float): IoU threshold for NMS. + offset (int, 0 or 1): boxes' width or height is (x2 - x1 + offset). + score_threshold (float): score threshold for NMS. + max_num (int): maximum number of boxes after NMS. + + Returns: + tuple: kept dets(boxes and scores) and indice, which is always the \ + same data type as the input. + + Example: + >>> boxes = np.array([[49.1, 32.4, 51.0, 35.9], + >>> [49.3, 32.9, 51.0, 35.3], + >>> [49.2, 31.8, 51.0, 35.4], + >>> [35.1, 11.5, 39.1, 15.7], + >>> [35.6, 11.8, 39.3, 14.2], + >>> [35.3, 11.5, 39.9, 14.5], + >>> [35.2, 11.7, 39.7, 15.7]], dtype=np.float32) + >>> scores = np.array([0.9, 0.9, 0.5, 0.5, 0.5, 0.4, 0.3],\ + dtype=np.float32) + >>> iou_threshold = 0.6 + >>> dets, inds = nms(boxes, scores, iou_threshold) + >>> assert len(inds) == len(dets) == 3 + """ + assert isinstance(boxes, (torch.Tensor, np.ndarray)) + assert isinstance(scores, (torch.Tensor, np.ndarray)) + is_numpy = False + if isinstance(boxes, np.ndarray): + is_numpy = True + boxes = torch.from_numpy(boxes) + if isinstance(scores, np.ndarray): + scores = torch.from_numpy(scores) + assert boxes.size(1) == 4 + assert boxes.size(0) == scores.size(0) + assert offset in (0, 1) + + if torch.__version__ == 'parrots': + indata_list = [boxes, scores] + indata_dict = { + 'iou_threshold': float(iou_threshold), + 'offset': int(offset) + } + inds = ext_module.nms(*indata_list, **indata_dict) + else: + inds = NMSop.apply(boxes, scores, iou_threshold, offset, + score_threshold, max_num) + dets = torch.cat((boxes[inds], scores[inds].reshape(-1, 1)), dim=1) + if is_numpy: + dets = dets.cpu().numpy() + inds = inds.cpu().numpy() + return dets, inds + + +@deprecated_api_warning({'iou_thr': 'iou_threshold'}) +def soft_nms(boxes, + scores, + iou_threshold=0.3, + sigma=0.5, + min_score=1e-3, + method='linear', + offset=0): + """Dispatch to only CPU Soft NMS implementations. + + The input can be either a torch tensor or numpy array. + The returned type will always be the same as inputs. + + Arguments: + boxes (torch.Tensor or np.ndarray): boxes in shape (N, 4). + scores (torch.Tensor or np.ndarray): scores in shape (N, ). + iou_threshold (float): IoU threshold for NMS. + sigma (float): hyperparameter for gaussian method + min_score (float): score filter threshold + method (str): either 'linear' or 'gaussian' + offset (int, 0 or 1): boxes' width or height is (x2 - x1 + offset). + + Returns: + tuple: kept dets(boxes and scores) and indice, which is always the \ + same data type as the input. + + Example: + >>> boxes = np.array([[4., 3., 5., 3.], + >>> [4., 3., 5., 4.], + >>> [3., 1., 3., 1.], + >>> [3., 1., 3., 1.], + >>> [3., 1., 3., 1.], + >>> [3., 1., 3., 1.]], dtype=np.float32) + >>> scores = np.array([0.9, 0.9, 0.5, 0.5, 0.4, 0.0], dtype=np.float32) + >>> iou_threshold = 0.6 + >>> dets, inds = soft_nms(boxes, scores, iou_threshold, sigma=0.5) + >>> assert len(inds) == len(dets) == 5 + """ + + assert isinstance(boxes, (torch.Tensor, np.ndarray)) + assert isinstance(scores, (torch.Tensor, np.ndarray)) + is_numpy = False + if isinstance(boxes, np.ndarray): + is_numpy = True + boxes = torch.from_numpy(boxes) + if isinstance(scores, np.ndarray): + scores = torch.from_numpy(scores) + assert boxes.size(1) == 4 + assert boxes.size(0) == scores.size(0) + assert offset in (0, 1) + method_dict = {'naive': 0, 'linear': 1, 'gaussian': 2} + assert method in method_dict.keys() + + if torch.__version__ == 'parrots': + dets = boxes.new_empty((boxes.size(0), 5), device='cpu') + indata_list = [boxes.cpu(), scores.cpu(), dets.cpu()] + indata_dict = { + 'iou_threshold': float(iou_threshold), + 'sigma': float(sigma), + 'min_score': min_score, + 'method': method_dict[method], + 'offset': int(offset) + } + inds = ext_module.softnms(*indata_list, **indata_dict) + else: + dets, inds = SoftNMSop.apply(boxes.cpu(), scores.cpu(), + float(iou_threshold), float(sigma), + float(min_score), method_dict[method], + int(offset)) + + dets = dets[:inds.size(0)] + + if is_numpy: + dets = dets.cpu().numpy() + inds = inds.cpu().numpy() + return dets, inds + else: + return dets.to(device=boxes.device), inds.to(device=boxes.device) + + +def batched_nms(boxes, scores, idxs, nms_cfg, class_agnostic=False): + """Performs non-maximum suppression in a batched fashion. + + Modified from https://github.com/pytorch/vision/blob + /505cd6957711af790211896d32b40291bea1bc21/torchvision/ops/boxes.py#L39. + In order to perform NMS independently per class, we add an offset to all + the boxes. The offset is dependent only on the class idx, and is large + enough so that boxes from different classes do not overlap. + + Arguments: + boxes (torch.Tensor): boxes in shape (N, 4). + scores (torch.Tensor): scores in shape (N, ). + idxs (torch.Tensor): each index value correspond to a bbox cluster, + and NMS will not be applied between elements of different idxs, + shape (N, ). + nms_cfg (dict): specify nms type and other parameters like iou_thr. + Possible keys includes the following. + + - iou_thr (float): IoU threshold used for NMS. + - split_thr (float): threshold number of boxes. In some cases the + number of boxes is large (e.g., 200k). To avoid OOM during + training, the users could set `split_thr` to a small value. + If the number of boxes is greater than the threshold, it will + perform NMS on each group of boxes separately and sequentially. + Defaults to 10000. + class_agnostic (bool): if true, nms is class agnostic, + i.e. IoU thresholding happens over all boxes, + regardless of the predicted class. + + Returns: + tuple: kept dets and indice. + """ + nms_cfg_ = nms_cfg.copy() + class_agnostic = nms_cfg_.pop('class_agnostic', class_agnostic) + if class_agnostic: + boxes_for_nms = boxes + else: + max_coordinate = boxes.max() + offsets = idxs.to(boxes) * (max_coordinate + torch.tensor(1).to(boxes)) + boxes_for_nms = boxes + offsets[:, None] + + nms_type = nms_cfg_.pop('type', 'nms') + nms_op = eval(nms_type) + + split_thr = nms_cfg_.pop('split_thr', 10000) + # Won't split to multiple nms nodes when exporting to onnx + if boxes_for_nms.shape[0] < split_thr or torch.onnx.is_in_onnx_export(): + dets, keep = nms_op(boxes_for_nms, scores, **nms_cfg_) + boxes = boxes[keep] + # -1 indexing works abnormal in TensorRT + # This assumes `dets` has 5 dimensions where + # the last dimension is score. + # TODO: more elegant way to handle the dimension issue. + # Some type of nms would reweight the score, such as SoftNMS + scores = dets[:, 4] + else: + max_num = nms_cfg_.pop('max_num', -1) + total_mask = scores.new_zeros(scores.size(), dtype=torch.bool) + # Some type of nms would reweight the score, such as SoftNMS + scores_after_nms = scores.new_zeros(scores.size()) + for id in torch.unique(idxs): + mask = (idxs == id).nonzero(as_tuple=False).view(-1) + dets, keep = nms_op(boxes_for_nms[mask], scores[mask], **nms_cfg_) + total_mask[mask[keep]] = True + scores_after_nms[mask[keep]] = dets[:, -1] + keep = total_mask.nonzero(as_tuple=False).view(-1) + + scores, inds = scores_after_nms[keep].sort(descending=True) + keep = keep[inds] + boxes = boxes[keep] + + if max_num > 0: + keep = keep[:max_num] + boxes = boxes[:max_num] + scores = scores[:max_num] + + return torch.cat([boxes, scores[:, None]], -1), keep + + +def nms_match(dets, iou_threshold): + """Matched dets into different groups by NMS. + + NMS match is Similar to NMS but when a bbox is suppressed, nms match will + record the indice of suppressed bbox and form a group with the indice of + kept bbox. In each group, indice is sorted as score order. + + Arguments: + dets (torch.Tensor | np.ndarray): Det boxes with scores, shape (N, 5). + iou_thr (float): IoU thresh for NMS. + + Returns: + List[torch.Tensor | np.ndarray]: The outer list corresponds different + matched group, the inner Tensor corresponds the indices for a group + in score order. + """ + if dets.shape[0] == 0: + matched = [] + else: + assert dets.shape[-1] == 5, 'inputs dets.shape should be (N, 5), ' \ + f'but get {dets.shape}' + if isinstance(dets, torch.Tensor): + dets_t = dets.detach().cpu() + else: + dets_t = torch.from_numpy(dets) + indata_list = [dets_t] + indata_dict = {'iou_threshold': float(iou_threshold)} + matched = ext_module.nms_match(*indata_list, **indata_dict) + if torch.__version__ == 'parrots': + matched = matched.tolist() + + if isinstance(dets, torch.Tensor): + return [dets.new_tensor(m, dtype=torch.long) for m in matched] + else: + return [np.array(m, dtype=np.int) for m in matched] + + +def nms_rotated(dets, scores, iou_threshold, labels=None): + """Performs non-maximum suppression (NMS) on the rotated boxes according to + their intersection-over-union (IoU). + + Rotated NMS iteratively removes lower scoring rotated boxes which have an + IoU greater than iou_threshold with another (higher scoring) rotated box. + + Args: + boxes (Tensor): Rotated boxes in shape (N, 5). They are expected to \ + be in (x_ctr, y_ctr, width, height, angle_radian) format. + scores (Tensor): scores in shape (N, ). + iou_threshold (float): IoU thresh for NMS. + labels (Tensor): boxes' label in shape (N,). + + Returns: + tuple: kept dets(boxes and scores) and indice, which is always the \ + same data type as the input. + """ + if dets.shape[0] == 0: + return dets, None + multi_label = labels is not None + if multi_label: + dets_wl = torch.cat((dets, labels.unsqueeze(1)), 1) + else: + dets_wl = dets + _, order = scores.sort(0, descending=True) + dets_sorted = dets_wl.index_select(0, order) + + if torch.__version__ == 'parrots': + keep_inds = ext_module.nms_rotated( + dets_wl, + scores, + order, + dets_sorted, + iou_threshold=iou_threshold, + multi_label=multi_label) + else: + keep_inds = ext_module.nms_rotated(dets_wl, scores, order, dets_sorted, + iou_threshold, multi_label) + dets = torch.cat((dets[keep_inds], scores[keep_inds].reshape(-1, 1)), + dim=1) + return dets, keep_inds diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/point_sample.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/point_sample.py new file mode 100644 index 000000000..c084a8c22 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/point_sample.py @@ -0,0 +1,336 @@ +# Modified from https://github.com/facebookresearch/detectron2/tree/master/projects/PointRend # noqa + +from os import path as osp + +import torch +import torch.nn as nn +import torch.nn.functional as F +from torch.nn.modules.utils import _pair +from torch.onnx.operators import shape_as_tensor + + +def bilinear_grid_sample(im, grid, align_corners=False): + """Given an input and a flow-field grid, computes the output using input + values and pixel locations from grid. Supported only bilinear interpolation + method to sample the input pixels. + + Args: + im (torch.Tensor): Input feature map, shape (N, C, H, W) + grid (torch.Tensor): Point coordinates, shape (N, Hg, Wg, 2) + align_corners {bool}: If set to True, the extrema (-1 and 1) are + considered as referring to the center points of the input’s + corner pixels. If set to False, they are instead considered as + referring to the corner points of the input’s corner pixels, + making the sampling more resolution agnostic. + Returns: + torch.Tensor: A tensor with sampled points, shape (N, C, Hg, Wg) + """ + n, c, h, w = im.shape + gn, gh, gw, _ = grid.shape + assert n == gn + + x = grid[:, :, :, 0] + y = grid[:, :, :, 1] + + if align_corners: + x = ((x + 1) / 2) * (w - 1) + y = ((y + 1) / 2) * (h - 1) + else: + x = ((x + 1) * w - 1) / 2 + y = ((y + 1) * h - 1) / 2 + + x = x.view(n, -1) + y = y.view(n, -1) + + x0 = torch.floor(x).long() + y0 = torch.floor(y).long() + x1 = x0 + 1 + y1 = y0 + 1 + + wa = ((x1 - x) * (y1 - y)).unsqueeze(1) + wb = ((x1 - x) * (y - y0)).unsqueeze(1) + wc = ((x - x0) * (y1 - y)).unsqueeze(1) + wd = ((x - x0) * (y - y0)).unsqueeze(1) + + # Apply default for grid_sample function zero padding + im_padded = F.pad(im, pad=[1, 1, 1, 1], mode='constant', value=0) + padded_h = h + 2 + padded_w = w + 2 + # save points positions after padding + x0, x1, y0, y1 = x0 + 1, x1 + 1, y0 + 1, y1 + 1 + + # Clip coordinates to padded image size + x0 = torch.where(x0 < 0, torch.tensor(0), x0) + x0 = torch.where(x0 > padded_w - 1, torch.tensor(padded_w - 1), x0) + x1 = torch.where(x1 < 0, torch.tensor(0), x1) + x1 = torch.where(x1 > padded_w - 1, torch.tensor(padded_w - 1), x1) + y0 = torch.where(y0 < 0, torch.tensor(0), y0) + y0 = torch.where(y0 > padded_h - 1, torch.tensor(padded_h - 1), y0) + y1 = torch.where(y1 < 0, torch.tensor(0), y1) + y1 = torch.where(y1 > padded_h - 1, torch.tensor(padded_h - 1), y1) + + im_padded = im_padded.view(n, c, -1) + + x0_y0 = (x0 + y0 * padded_w).unsqueeze(1).expand(-1, c, -1) + x0_y1 = (x0 + y1 * padded_w).unsqueeze(1).expand(-1, c, -1) + x1_y0 = (x1 + y0 * padded_w).unsqueeze(1).expand(-1, c, -1) + x1_y1 = (x1 + y1 * padded_w).unsqueeze(1).expand(-1, c, -1) + + Ia = torch.gather(im_padded, 2, x0_y0) + Ib = torch.gather(im_padded, 2, x0_y1) + Ic = torch.gather(im_padded, 2, x1_y0) + Id = torch.gather(im_padded, 2, x1_y1) + + return (Ia * wa + Ib * wb + Ic * wc + Id * wd).reshape(n, c, gh, gw) + + +def is_in_onnx_export_without_custom_ops(): + from mmcv.ops import get_onnxruntime_op_path + ort_custom_op_path = get_onnxruntime_op_path() + return torch.onnx.is_in_onnx_export( + ) and not osp.exists(ort_custom_op_path) + + +def normalize(grid): + """Normalize input grid from [-1, 1] to [0, 1] + Args: + grid (Tensor): The grid to be normalize, range [-1, 1]. + Returns: + Tensor: Normalized grid, range [0, 1]. + """ + + return (grid + 1.0) / 2.0 + + +def denormalize(grid): + """Denormalize input grid from range [0, 1] to [-1, 1] + Args: + grid (Tensor): The grid to be denormalize, range [0, 1]. + Returns: + Tensor: Denormalized grid, range [-1, 1]. + """ + + return grid * 2.0 - 1.0 + + +def generate_grid(num_grid, size, device): + """Generate regular square grid of points in [0, 1] x [0, 1] coordinate + space. + + Args: + num_grid (int): The number of grids to sample, one for each region. + size (tuple(int, int)): The side size of the regular grid. + device (torch.device): Desired device of returned tensor. + + Returns: + (torch.Tensor): A tensor of shape (num_grid, size[0]*size[1], 2) that + contains coordinates for the regular grids. + """ + + affine_trans = torch.tensor([[[1., 0., 0.], [0., 1., 0.]]], device=device) + grid = F.affine_grid( + affine_trans, torch.Size((1, 1, *size)), align_corners=False) + grid = normalize(grid) + return grid.view(1, -1, 2).expand(num_grid, -1, -1) + + +def rel_roi_point_to_abs_img_point(rois, rel_roi_points): + """Convert roi based relative point coordinates to image based absolute + point coordinates. + + Args: + rois (Tensor): RoIs or BBoxes, shape (N, 4) or (N, 5) + rel_roi_points (Tensor): Point coordinates inside RoI, relative to + RoI, location, range (0, 1), shape (N, P, 2) + Returns: + Tensor: Image based absolute point coordinates, shape (N, P, 2) + """ + + with torch.no_grad(): + assert rel_roi_points.size(0) == rois.size(0) + assert rois.dim() == 2 + assert rel_roi_points.dim() == 3 + assert rel_roi_points.size(2) == 2 + # remove batch idx + if rois.size(1) == 5: + rois = rois[:, 1:] + abs_img_points = rel_roi_points.clone() + # To avoid an error during exporting to onnx use independent + # variables instead inplace computation + xs = abs_img_points[:, :, 0] * (rois[:, None, 2] - rois[:, None, 0]) + ys = abs_img_points[:, :, 1] * (rois[:, None, 3] - rois[:, None, 1]) + xs += rois[:, None, 0] + ys += rois[:, None, 1] + abs_img_points = torch.stack([xs, ys], dim=2) + return abs_img_points + + +def get_shape_from_feature_map(x): + """Get spatial resolution of input feature map considering exporting to + onnx mode. + + Args: + x (torch.Tensor): Input tensor, shape (N, C, H, W) + Returns: + torch.Tensor: Spatial resolution (width, height), shape (1, 1, 2) + """ + if torch.onnx.is_in_onnx_export(): + img_shape = shape_as_tensor(x)[2:].flip(0).view(1, 1, 2).to( + x.device).float() + else: + img_shape = torch.tensor(x.shape[2:]).flip(0).view(1, 1, 2).to( + x.device).float() + return img_shape + + +def abs_img_point_to_rel_img_point(abs_img_points, img, spatial_scale=1.): + """Convert image based absolute point coordinates to image based relative + coordinates for sampling. + + Args: + abs_img_points (Tensor): Image based absolute point coordinates, + shape (N, P, 2) + img (tuple/Tensor): (height, width) of image or feature map. + spatial_scale (float): Scale points by this factor. Default: 1. + + Returns: + Tensor: Image based relative point coordinates for sampling, + shape (N, P, 2) + """ + + assert (isinstance(img, tuple) and len(img) == 2) or \ + (isinstance(img, torch.Tensor) and len(img.shape) == 4) + + if isinstance(img, tuple): + h, w = img + scale = torch.tensor([w, h], + dtype=torch.float, + device=abs_img_points.device) + scale = scale.view(1, 1, 2) + else: + scale = get_shape_from_feature_map(img) + + return abs_img_points / scale * spatial_scale + + +def rel_roi_point_to_rel_img_point(rois, + rel_roi_points, + img, + spatial_scale=1.): + """Convert roi based relative point coordinates to image based absolute + point coordinates. + + Args: + rois (Tensor): RoIs or BBoxes, shape (N, 4) or (N, 5) + rel_roi_points (Tensor): Point coordinates inside RoI, relative to + RoI, location, range (0, 1), shape (N, P, 2) + img (tuple/Tensor): (height, width) of image or feature map. + spatial_scale (float): Scale points by this factor. Default: 1. + + Returns: + Tensor: Image based relative point coordinates for sampling, + shape (N, P, 2) + """ + + abs_img_point = rel_roi_point_to_abs_img_point(rois, rel_roi_points) + rel_img_point = abs_img_point_to_rel_img_point(abs_img_point, img, + spatial_scale) + + return rel_img_point + + +def point_sample(input, points, align_corners=False, **kwargs): + """A wrapper around :func:`grid_sample` to support 3D point_coords tensors + Unlike :func:`torch.nn.functional.grid_sample` it assumes point_coords to + lie inside ``[0, 1] x [0, 1]`` square. + + Args: + input (Tensor): Feature map, shape (N, C, H, W). + points (Tensor): Image based absolute point coordinates (normalized), + range [0, 1] x [0, 1], shape (N, P, 2) or (N, Hgrid, Wgrid, 2). + align_corners (bool): Whether align_corners. Default: False + + Returns: + Tensor: Features of `point` on `input`, shape (N, C, P) or + (N, C, Hgrid, Wgrid). + """ + + add_dim = False + if points.dim() == 3: + add_dim = True + points = points.unsqueeze(2) + if is_in_onnx_export_without_custom_ops(): + # If custom ops for onnx runtime not compiled use python + # implementation of grid_sample function to make onnx graph + # with supported nodes + output = bilinear_grid_sample( + input, denormalize(points), align_corners=align_corners) + else: + output = F.grid_sample( + input, denormalize(points), align_corners=align_corners, **kwargs) + if add_dim: + output = output.squeeze(3) + return output + + +class SimpleRoIAlign(nn.Module): + + def __init__(self, output_size, spatial_scale, aligned=True): + """Simple RoI align in PointRend, faster than standard RoIAlign. + + Args: + output_size (tuple[int]): h, w + spatial_scale (float): scale the input boxes by this number + aligned (bool): if False, use the legacy implementation in + MMDetection, align_corners=True will be used in F.grid_sample. + If True, align the results more perfectly. + """ + + super(SimpleRoIAlign, self).__init__() + self.output_size = _pair(output_size) + self.spatial_scale = float(spatial_scale) + # to be consistent with other RoI ops + self.use_torchvision = False + self.aligned = aligned + + def forward(self, features, rois): + num_imgs = features.size(0) + num_rois = rois.size(0) + rel_roi_points = generate_grid( + num_rois, self.output_size, device=rois.device) + + if torch.onnx.is_in_onnx_export(): + rel_img_points = rel_roi_point_to_rel_img_point( + rois, rel_roi_points, features, self.spatial_scale) + rel_img_points = rel_img_points.reshape(num_imgs, -1, + *rel_img_points.shape[1:]) + point_feats = point_sample( + features, rel_img_points, align_corners=not self.aligned) + point_feats = point_feats.transpose(1, 2) + else: + point_feats = [] + for batch_ind in range(num_imgs): + # unravel batch dim + feat = features[batch_ind].unsqueeze(0) + inds = (rois[:, 0].long() == batch_ind) + if inds.any(): + rel_img_points = rel_roi_point_to_rel_img_point( + rois[inds], rel_roi_points[inds], feat, + self.spatial_scale).unsqueeze(0) + point_feat = point_sample( + feat, rel_img_points, align_corners=not self.aligned) + point_feat = point_feat.squeeze(0).transpose(0, 1) + point_feats.append(point_feat) + + point_feats = torch.cat(point_feats, dim=0) + + channels = features.size(1) + roi_feats = point_feats.reshape(num_rois, channels, *self.output_size) + + return roi_feats + + def __repr__(self): + format_str = self.__class__.__name__ + format_str += '(output_size={}, spatial_scale={}'.format( + self.output_size, self.spatial_scale) + return format_str diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/roi_align.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/roi_align.py new file mode 100644 index 000000000..0755aefc6 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/roi_align.py @@ -0,0 +1,223 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch +import torch.nn as nn +from torch.autograd import Function +from torch.autograd.function import once_differentiable +from torch.nn.modules.utils import _pair + +from ..utils import deprecated_api_warning, ext_loader + +ext_module = ext_loader.load_ext('_ext', + ['roi_align_forward', 'roi_align_backward']) + + +class RoIAlignFunction(Function): + + @staticmethod + def symbolic(g, input, rois, output_size, spatial_scale, sampling_ratio, + pool_mode, aligned): + from ..onnx import is_custom_op_loaded + has_custom_op = is_custom_op_loaded() + if has_custom_op: + return g.op( + 'mmcv::MMCVRoiAlign', + input, + rois, + output_height_i=output_size[0], + output_width_i=output_size[1], + spatial_scale_f=spatial_scale, + sampling_ratio_i=sampling_ratio, + mode_s=pool_mode, + aligned_i=aligned) + else: + from torch.onnx.symbolic_opset9 import sub, squeeze + from torch.onnx.symbolic_helper import _slice_helper + from torch.onnx import TensorProtoDataType + # batch_indices = rois[:, 0].long() + batch_indices = _slice_helper( + g, rois, axes=[1], starts=[0], ends=[1]) + batch_indices = squeeze(g, batch_indices, 1) + batch_indices = g.op( + 'Cast', batch_indices, to_i=TensorProtoDataType.INT64) + # rois = rois[:, 1:] + rois = _slice_helper(g, rois, axes=[1], starts=[1], ends=[5]) + if aligned: + # rois -= 0.5/spatial_scale + aligned_offset = g.op( + 'Constant', + value_t=torch.tensor([0.5 / spatial_scale], + dtype=torch.float32)) + rois = sub(g, rois, aligned_offset) + # roi align + return g.op( + 'RoiAlign', + input, + rois, + batch_indices, + output_height_i=output_size[0], + output_width_i=output_size[1], + spatial_scale_f=spatial_scale, + sampling_ratio_i=max(0, sampling_ratio), + mode_s=pool_mode) + + @staticmethod + def forward(ctx, + input, + rois, + output_size, + spatial_scale=1.0, + sampling_ratio=0, + pool_mode='avg', + aligned=True): + ctx.output_size = _pair(output_size) + ctx.spatial_scale = spatial_scale + ctx.sampling_ratio = sampling_ratio + assert pool_mode in ('max', 'avg') + ctx.pool_mode = 0 if pool_mode == 'max' else 1 + ctx.aligned = aligned + ctx.input_shape = input.size() + + assert rois.size(1) == 5, 'RoI must be (idx, x1, y1, x2, y2)!' + + output_shape = (rois.size(0), input.size(1), ctx.output_size[0], + ctx.output_size[1]) + output = input.new_zeros(output_shape) + if ctx.pool_mode == 0: + argmax_y = input.new_zeros(output_shape) + argmax_x = input.new_zeros(output_shape) + else: + argmax_y = input.new_zeros(0) + argmax_x = input.new_zeros(0) + + ext_module.roi_align_forward( + input, + rois, + output, + argmax_y, + argmax_x, + aligned_height=ctx.output_size[0], + aligned_width=ctx.output_size[1], + spatial_scale=ctx.spatial_scale, + sampling_ratio=ctx.sampling_ratio, + pool_mode=ctx.pool_mode, + aligned=ctx.aligned) + + ctx.save_for_backward(rois, argmax_y, argmax_x) + return output + + @staticmethod + @once_differentiable + def backward(ctx, grad_output): + rois, argmax_y, argmax_x = ctx.saved_tensors + grad_input = grad_output.new_zeros(ctx.input_shape) + # complex head architecture may cause grad_output uncontiguous. + grad_output = grad_output.contiguous() + ext_module.roi_align_backward( + grad_output, + rois, + argmax_y, + argmax_x, + grad_input, + aligned_height=ctx.output_size[0], + aligned_width=ctx.output_size[1], + spatial_scale=ctx.spatial_scale, + sampling_ratio=ctx.sampling_ratio, + pool_mode=ctx.pool_mode, + aligned=ctx.aligned) + return grad_input, None, None, None, None, None, None + + +roi_align = RoIAlignFunction.apply + + +class RoIAlign(nn.Module): + """RoI align pooling layer. + + Args: + output_size (tuple): h, w + spatial_scale (float): scale the input boxes by this number + sampling_ratio (int): number of inputs samples to take for each + output sample. 0 to take samples densely for current models. + pool_mode (str, 'avg' or 'max'): pooling mode in each bin. + aligned (bool): if False, use the legacy implementation in + MMDetection. If True, align the results more perfectly. + use_torchvision (bool): whether to use roi_align from torchvision. + + Note: + The implementation of RoIAlign when aligned=True is modified from + https://github.com/facebookresearch/detectron2/ + + The meaning of aligned=True: + + Given a continuous coordinate c, its two neighboring pixel + indices (in our pixel model) are computed by floor(c - 0.5) and + ceil(c - 0.5). For example, c=1.3 has pixel neighbors with discrete + indices [0] and [1] (which are sampled from the underlying signal + at continuous coordinates 0.5 and 1.5). But the original roi_align + (aligned=False) does not subtract the 0.5 when computing + neighboring pixel indices and therefore it uses pixels with a + slightly incorrect alignment (relative to our pixel model) when + performing bilinear interpolation. + + With `aligned=True`, + we first appropriately scale the ROI and then shift it by -0.5 + prior to calling roi_align. This produces the correct neighbors; + + The difference does not make a difference to the model's + performance if ROIAlign is used together with conv layers. + """ + + @deprecated_api_warning( + { + 'out_size': 'output_size', + 'sample_num': 'sampling_ratio' + }, + cls_name='RoIAlign') + def __init__(self, + output_size, + spatial_scale=1.0, + sampling_ratio=0, + pool_mode='avg', + aligned=True, + use_torchvision=False): + super(RoIAlign, self).__init__() + + self.output_size = _pair(output_size) + self.spatial_scale = float(spatial_scale) + self.sampling_ratio = int(sampling_ratio) + self.pool_mode = pool_mode + self.aligned = aligned + self.use_torchvision = use_torchvision + + def forward(self, input, rois): + """ + Args: + input: NCHW images + rois: Bx5 boxes. First column is the index into N.\ + The other 4 columns are xyxy. + """ + if self.use_torchvision: + from torchvision.ops import roi_align as tv_roi_align + if 'aligned' in tv_roi_align.__code__.co_varnames: + return tv_roi_align(input, rois, self.output_size, + self.spatial_scale, self.sampling_ratio, + self.aligned) + else: + if self.aligned: + rois -= rois.new_tensor([0.] + + [0.5 / self.spatial_scale] * 4) + return tv_roi_align(input, rois, self.output_size, + self.spatial_scale, self.sampling_ratio) + else: + return roi_align(input, rois, self.output_size, self.spatial_scale, + self.sampling_ratio, self.pool_mode, self.aligned) + + def __repr__(self): + s = self.__class__.__name__ + s += f'(output_size={self.output_size}, ' + s += f'spatial_scale={self.spatial_scale}, ' + s += f'sampling_ratio={self.sampling_ratio}, ' + s += f'pool_mode={self.pool_mode}, ' + s += f'aligned={self.aligned}, ' + s += f'use_torchvision={self.use_torchvision})' + return s diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/roi_pool.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/roi_pool.py new file mode 100644 index 000000000..d339d8f29 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/roi_pool.py @@ -0,0 +1,86 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch +import torch.nn as nn +from torch.autograd import Function +from torch.autograd.function import once_differentiable +from torch.nn.modules.utils import _pair + +from ..utils import ext_loader + +ext_module = ext_loader.load_ext('_ext', + ['roi_pool_forward', 'roi_pool_backward']) + + +class RoIPoolFunction(Function): + + @staticmethod + def symbolic(g, input, rois, output_size, spatial_scale): + return g.op( + 'MaxRoiPool', + input, + rois, + pooled_shape_i=output_size, + spatial_scale_f=spatial_scale) + + @staticmethod + def forward(ctx, input, rois, output_size, spatial_scale=1.0): + ctx.output_size = _pair(output_size) + ctx.spatial_scale = spatial_scale + ctx.input_shape = input.size() + + assert rois.size(1) == 5, 'RoI must be (idx, x1, y1, x2, y2)!' + + output_shape = (rois.size(0), input.size(1), ctx.output_size[0], + ctx.output_size[1]) + output = input.new_zeros(output_shape) + argmax = input.new_zeros(output_shape, dtype=torch.int) + + ext_module.roi_pool_forward( + input, + rois, + output, + argmax, + pooled_height=ctx.output_size[0], + pooled_width=ctx.output_size[1], + spatial_scale=ctx.spatial_scale) + + ctx.save_for_backward(rois, argmax) + return output + + @staticmethod + @once_differentiable + def backward(ctx, grad_output): + rois, argmax = ctx.saved_tensors + grad_input = grad_output.new_zeros(ctx.input_shape) + + ext_module.roi_pool_backward( + grad_output, + rois, + argmax, + grad_input, + pooled_height=ctx.output_size[0], + pooled_width=ctx.output_size[1], + spatial_scale=ctx.spatial_scale) + + return grad_input, None, None, None + + +roi_pool = RoIPoolFunction.apply + + +class RoIPool(nn.Module): + + def __init__(self, output_size, spatial_scale=1.0): + super(RoIPool, self).__init__() + + self.output_size = _pair(output_size) + self.spatial_scale = float(spatial_scale) + + def forward(self, input, rois): + return roi_pool(input, rois, self.output_size, self.spatial_scale) + + def __repr__(self): + s = self.__class__.__name__ + s += f'(output_size={self.output_size}, ' + s += f'spatial_scale={self.spatial_scale})' + return s diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/sync_bn.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/sync_bn.py new file mode 100644 index 000000000..04302f031 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/ops/sync_bn.py @@ -0,0 +1,279 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch +import torch.distributed as dist +import torch.nn.functional as F +from torch.autograd import Function +from torch.autograd.function import once_differentiable +from torch.nn.modules.module import Module +from torch.nn.parameter import Parameter + +from mmcv.cnn import NORM_LAYERS +from ..utils import ext_loader + +ext_module = ext_loader.load_ext('_ext', [ + 'sync_bn_forward_mean', 'sync_bn_forward_var', 'sync_bn_forward_output', + 'sync_bn_backward_param', 'sync_bn_backward_data' +]) + + +class SyncBatchNormFunction(Function): + + @staticmethod + def symbolic(g, input, running_mean, running_var, weight, bias, momentum, + eps, group, group_size, stats_mode): + return g.op( + 'mmcv::MMCVSyncBatchNorm', + input, + running_mean, + running_var, + weight, + bias, + momentum_f=momentum, + eps_f=eps, + group_i=group, + group_size_i=group_size, + stats_mode=stats_mode) + + @staticmethod + def forward(self, input, running_mean, running_var, weight, bias, momentum, + eps, group, group_size, stats_mode): + self.momentum = momentum + self.eps = eps + self.group = group + self.group_size = group_size + self.stats_mode = stats_mode + + assert isinstance( + input, (torch.HalfTensor, torch.FloatTensor, + torch.cuda.HalfTensor, torch.cuda.FloatTensor)), \ + f'only support Half or Float Tensor, but {input.type()}' + output = torch.zeros_like(input) + input3d = input.flatten(start_dim=2) + output3d = output.view_as(input3d) + num_channels = input3d.size(1) + + # ensure mean/var/norm/std are initialized as zeros + # ``torch.empty()`` does not guarantee that + mean = torch.zeros( + num_channels, dtype=torch.float, device=input3d.device) + var = torch.zeros( + num_channels, dtype=torch.float, device=input3d.device) + norm = torch.zeros_like( + input3d, dtype=torch.float, device=input3d.device) + std = torch.zeros( + num_channels, dtype=torch.float, device=input3d.device) + + batch_size = input3d.size(0) + if batch_size > 0: + ext_module.sync_bn_forward_mean(input3d, mean) + batch_flag = torch.ones([1], device=mean.device, dtype=mean.dtype) + else: + # skip updating mean and leave it as zeros when the input is empty + batch_flag = torch.zeros([1], device=mean.device, dtype=mean.dtype) + + # synchronize mean and the batch flag + vec = torch.cat([mean, batch_flag]) + if self.stats_mode == 'N': + vec *= batch_size + if self.group_size > 1: + dist.all_reduce(vec, group=self.group) + total_batch = vec[-1].detach() + mean = vec[:num_channels] + + if self.stats_mode == 'default': + mean = mean / self.group_size + elif self.stats_mode == 'N': + mean = mean / total_batch.clamp(min=1) + else: + raise NotImplementedError + + # leave var as zeros when the input is empty + if batch_size > 0: + ext_module.sync_bn_forward_var(input3d, mean, var) + + if self.stats_mode == 'N': + var *= batch_size + if self.group_size > 1: + dist.all_reduce(var, group=self.group) + + if self.stats_mode == 'default': + var /= self.group_size + elif self.stats_mode == 'N': + var /= total_batch.clamp(min=1) + else: + raise NotImplementedError + + # if the total batch size over all the ranks is zero, + # we should not update the statistics in the current batch + update_flag = total_batch.clamp(max=1) + momentum = update_flag * self.momentum + ext_module.sync_bn_forward_output( + input3d, + mean, + var, + weight, + bias, + running_mean, + running_var, + norm, + std, + output3d, + eps=self.eps, + momentum=momentum, + group_size=self.group_size) + self.save_for_backward(norm, std, weight) + return output + + @staticmethod + @once_differentiable + def backward(self, grad_output): + norm, std, weight = self.saved_tensors + grad_weight = torch.zeros_like(weight) + grad_bias = torch.zeros_like(weight) + grad_input = torch.zeros_like(grad_output) + grad_output3d = grad_output.flatten(start_dim=2) + grad_input3d = grad_input.view_as(grad_output3d) + + batch_size = grad_input3d.size(0) + if batch_size > 0: + ext_module.sync_bn_backward_param(grad_output3d, norm, grad_weight, + grad_bias) + + # all reduce + if self.group_size > 1: + dist.all_reduce(grad_weight, group=self.group) + dist.all_reduce(grad_bias, group=self.group) + grad_weight /= self.group_size + grad_bias /= self.group_size + + if batch_size > 0: + ext_module.sync_bn_backward_data(grad_output3d, weight, + grad_weight, grad_bias, norm, std, + grad_input3d) + + return grad_input, None, None, grad_weight, grad_bias, \ + None, None, None, None, None + + +@NORM_LAYERS.register_module(name='MMSyncBN') +class SyncBatchNorm(Module): + """Synchronized Batch Normalization. + + Args: + num_features (int): number of features/chennels in input tensor + eps (float, optional): a value added to the denominator for numerical + stability. Defaults to 1e-5. + momentum (float, optional): the value used for the running_mean and + running_var computation. Defaults to 0.1. + affine (bool, optional): whether to use learnable affine parameters. + Defaults to True. + track_running_stats (bool, optional): whether to track the running + mean and variance during training. When set to False, this + module does not track such statistics, and initializes statistics + buffers ``running_mean`` and ``running_var`` as ``None``. When + these buffers are ``None``, this module always uses batch + statistics in both training and eval modes. Defaults to True. + group (int, optional): synchronization of stats happen within + each process group individually. By default it is synchronization + across the whole world. Defaults to None. + stats_mode (str, optional): The statistical mode. Available options + includes ``'default'`` and ``'N'``. Defaults to 'default'. + When ``stats_mode=='default'``, it computes the overall statistics + using those from each worker with equal weight, i.e., the + statistics are synchronized and simply divied by ``group``. This + mode will produce inaccurate statistics when empty tensors occur. + When ``stats_mode=='N'``, it compute the overall statistics using + the total number of batches in each worker ignoring the number of + group, i.e., the statistics are synchronized and then divied by + the total batch ``N``. This mode is beneficial when empty tensors + occur during training, as it average the total mean by the real + number of batch. + """ + + def __init__(self, + num_features, + eps=1e-5, + momentum=0.1, + affine=True, + track_running_stats=True, + group=None, + stats_mode='default'): + super(SyncBatchNorm, self).__init__() + self.num_features = num_features + self.eps = eps + self.momentum = momentum + self.affine = affine + self.track_running_stats = track_running_stats + group = dist.group.WORLD if group is None else group + self.group = group + self.group_size = dist.get_world_size(group) + assert stats_mode in ['default', 'N'], \ + f'"stats_mode" only accepts "default" and "N", got "{stats_mode}"' + self.stats_mode = stats_mode + if self.affine: + self.weight = Parameter(torch.Tensor(num_features)) + self.bias = Parameter(torch.Tensor(num_features)) + else: + self.register_parameter('weight', None) + self.register_parameter('bias', None) + if self.track_running_stats: + self.register_buffer('running_mean', torch.zeros(num_features)) + self.register_buffer('running_var', torch.ones(num_features)) + self.register_buffer('num_batches_tracked', + torch.tensor(0, dtype=torch.long)) + else: + self.register_buffer('running_mean', None) + self.register_buffer('running_var', None) + self.register_buffer('num_batches_tracked', None) + self.reset_parameters() + + def reset_running_stats(self): + if self.track_running_stats: + self.running_mean.zero_() + self.running_var.fill_(1) + self.num_batches_tracked.zero_() + + def reset_parameters(self): + self.reset_running_stats() + if self.affine: + self.weight.data.uniform_() # pytorch use ones_() + self.bias.data.zero_() + + def forward(self, input): + if input.dim() < 2: + raise ValueError( + f'expected at least 2D input, got {input.dim()}D input') + if self.momentum is None: + exponential_average_factor = 0.0 + else: + exponential_average_factor = self.momentum + + if self.training and self.track_running_stats: + if self.num_batches_tracked is not None: + self.num_batches_tracked += 1 + if self.momentum is None: # use cumulative moving average + exponential_average_factor = 1.0 / float( + self.num_batches_tracked) + else: # use exponential moving average + exponential_average_factor = self.momentum + + if self.training or not self.track_running_stats: + return SyncBatchNormFunction.apply( + input, self.running_mean, self.running_var, self.weight, + self.bias, exponential_average_factor, self.eps, self.group, + self.group_size, self.stats_mode) + else: + return F.batch_norm(input, self.running_mean, self.running_var, + self.weight, self.bias, False, + exponential_average_factor, self.eps) + + def __repr__(self): + s = self.__class__.__name__ + s += f'({self.num_features}, ' + s += f'eps={self.eps}, ' + s += f'momentum={self.momentum}, ' + s += f'affine={self.affine}, ' + s += f'track_running_stats={self.track_running_stats}, ' + s += f'group_size={self.group_size},' + s += f'stats_mode={self.stats_mode})' + return s diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/__init__.py new file mode 100644 index 000000000..2ed2c17ad --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/__init__.py @@ -0,0 +1,13 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .collate import collate +from .data_container import DataContainer +from .data_parallel import MMDataParallel +from .distributed import MMDistributedDataParallel +from .registry import MODULE_WRAPPERS +from .scatter_gather import scatter, scatter_kwargs +from .utils import is_module_wrapper + +__all__ = [ + 'collate', 'DataContainer', 'MMDataParallel', 'MMDistributedDataParallel', + 'scatter', 'scatter_kwargs', 'is_module_wrapper', 'MODULE_WRAPPERS' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/_functions.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/_functions.py new file mode 100644 index 000000000..9b5a8a444 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/_functions.py @@ -0,0 +1,79 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch +from torch.nn.parallel._functions import _get_stream + + +def scatter(input, devices, streams=None): + """Scatters tensor across multiple GPUs.""" + if streams is None: + streams = [None] * len(devices) + + if isinstance(input, list): + chunk_size = (len(input) - 1) // len(devices) + 1 + outputs = [ + scatter(input[i], [devices[i // chunk_size]], + [streams[i // chunk_size]]) for i in range(len(input)) + ] + return outputs + elif isinstance(input, torch.Tensor): + output = input.contiguous() + # TODO: copy to a pinned buffer first (if copying from CPU) + stream = streams[0] if output.numel() > 0 else None + if devices != [-1]: + with torch.cuda.device(devices[0]), torch.cuda.stream(stream): + output = output.cuda(devices[0], non_blocking=True) + else: + # unsqueeze the first dimension thus the tensor's shape is the + # same as those scattered with GPU. + output = output.unsqueeze(0) + return output + else: + raise Exception(f'Unknown type {type(input)}.') + + +def synchronize_stream(output, devices, streams): + if isinstance(output, list): + chunk_size = len(output) // len(devices) + for i in range(len(devices)): + for j in range(chunk_size): + synchronize_stream(output[i * chunk_size + j], [devices[i]], + [streams[i]]) + elif isinstance(output, torch.Tensor): + if output.numel() != 0: + with torch.cuda.device(devices[0]): + main_stream = torch.cuda.current_stream() + main_stream.wait_stream(streams[0]) + output.record_stream(main_stream) + else: + raise Exception(f'Unknown type {type(output)}.') + + +def get_input_device(input): + if isinstance(input, list): + for item in input: + input_device = get_input_device(item) + if input_device != -1: + return input_device + return -1 + elif isinstance(input, torch.Tensor): + return input.get_device() if input.is_cuda else -1 + else: + raise Exception(f'Unknown type {type(input)}.') + + +class Scatter: + + @staticmethod + def forward(target_gpus, input): + input_device = get_input_device(input) + streams = None + if input_device == -1 and target_gpus != [-1]: + # Perform CPU to GPU copies in a background stream + streams = [_get_stream(device) for device in target_gpus] + + outputs = scatter(input, target_gpus, streams) + # Synchronize with the copy stream + if streams is not None: + synchronize_stream(outputs, target_gpus, streams) + + return tuple(outputs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/collate.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/collate.py new file mode 100644 index 000000000..ad749197d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/collate.py @@ -0,0 +1,84 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from collections.abc import Mapping, Sequence + +import torch +import torch.nn.functional as F +from torch.utils.data.dataloader import default_collate + +from .data_container import DataContainer + + +def collate(batch, samples_per_gpu=1): + """Puts each data field into a tensor/DataContainer with outer dimension + batch size. + + Extend default_collate to add support for + :type:`~mmcv.parallel.DataContainer`. There are 3 cases. + + 1. cpu_only = True, e.g., meta data + 2. cpu_only = False, stack = True, e.g., images tensors + 3. cpu_only = False, stack = False, e.g., gt bboxes + """ + + if not isinstance(batch, Sequence): + raise TypeError(f'{batch.dtype} is not supported.') + + if isinstance(batch[0], DataContainer): + stacked = [] + if batch[0].cpu_only: + for i in range(0, len(batch), samples_per_gpu): + stacked.append( + [sample.data for sample in batch[i:i + samples_per_gpu]]) + return DataContainer( + stacked, batch[0].stack, batch[0].padding_value, cpu_only=True) + elif batch[0].stack: + for i in range(0, len(batch), samples_per_gpu): + assert isinstance(batch[i].data, torch.Tensor) + + if batch[i].pad_dims is not None: + ndim = batch[i].dim() + assert ndim > batch[i].pad_dims + max_shape = [0 for _ in range(batch[i].pad_dims)] + for dim in range(1, batch[i].pad_dims + 1): + max_shape[dim - 1] = batch[i].size(-dim) + for sample in batch[i:i + samples_per_gpu]: + for dim in range(0, ndim - batch[i].pad_dims): + assert batch[i].size(dim) == sample.size(dim) + for dim in range(1, batch[i].pad_dims + 1): + max_shape[dim - 1] = max(max_shape[dim - 1], + sample.size(-dim)) + padded_samples = [] + for sample in batch[i:i + samples_per_gpu]: + pad = [0 for _ in range(batch[i].pad_dims * 2)] + for dim in range(1, batch[i].pad_dims + 1): + pad[2 * dim - + 1] = max_shape[dim - 1] - sample.size(-dim) + padded_samples.append( + F.pad( + sample.data, pad, value=sample.padding_value)) + stacked.append(default_collate(padded_samples)) + elif batch[i].pad_dims is None: + stacked.append( + default_collate([ + sample.data + for sample in batch[i:i + samples_per_gpu] + ])) + else: + raise ValueError( + 'pad_dims should be either None or integers (1-3)') + + else: + for i in range(0, len(batch), samples_per_gpu): + stacked.append( + [sample.data for sample in batch[i:i + samples_per_gpu]]) + return DataContainer(stacked, batch[0].stack, batch[0].padding_value) + elif isinstance(batch[0], Sequence): + transposed = zip(*batch) + return [collate(samples, samples_per_gpu) for samples in transposed] + elif isinstance(batch[0], Mapping): + return { + key: collate([d[key] for d in batch], samples_per_gpu) + for key in batch[0] + } + else: + return default_collate(batch) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/data_container.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/data_container.py new file mode 100644 index 000000000..cedb0d32a --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/data_container.py @@ -0,0 +1,89 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import functools + +import torch + + +def assert_tensor_type(func): + + @functools.wraps(func) + def wrapper(*args, **kwargs): + if not isinstance(args[0].data, torch.Tensor): + raise AttributeError( + f'{args[0].__class__.__name__} has no attribute ' + f'{func.__name__} for type {args[0].datatype}') + return func(*args, **kwargs) + + return wrapper + + +class DataContainer: + """A container for any type of objects. + + Typically tensors will be stacked in the collate function and sliced along + some dimension in the scatter function. This behavior has some limitations. + 1. All tensors have to be the same size. + 2. Types are limited (numpy array or Tensor). + + We design `DataContainer` and `MMDataParallel` to overcome these + limitations. The behavior can be either of the following. + + - copy to GPU, pad all tensors to the same size and stack them + - copy to GPU without stacking + - leave the objects as is and pass it to the model + - pad_dims specifies the number of last few dimensions to do padding + """ + + def __init__(self, + data, + stack=False, + padding_value=0, + cpu_only=False, + pad_dims=2): + self._data = data + self._cpu_only = cpu_only + self._stack = stack + self._padding_value = padding_value + assert pad_dims in [None, 1, 2, 3] + self._pad_dims = pad_dims + + def __repr__(self): + return f'{self.__class__.__name__}({repr(self.data)})' + + def __len__(self): + return len(self._data) + + @property + def data(self): + return self._data + + @property + def datatype(self): + if isinstance(self.data, torch.Tensor): + return self.data.type() + else: + return type(self.data) + + @property + def cpu_only(self): + return self._cpu_only + + @property + def stack(self): + return self._stack + + @property + def padding_value(self): + return self._padding_value + + @property + def pad_dims(self): + return self._pad_dims + + @assert_tensor_type + def size(self, *args, **kwargs): + return self.data.size(*args, **kwargs) + + @assert_tensor_type + def dim(self): + return self.data.dim() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/data_parallel.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/data_parallel.py new file mode 100644 index 000000000..79b5f69b6 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/data_parallel.py @@ -0,0 +1,89 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from itertools import chain + +from torch.nn.parallel import DataParallel + +from .scatter_gather import scatter_kwargs + + +class MMDataParallel(DataParallel): + """The DataParallel module that supports DataContainer. + + MMDataParallel has two main differences with PyTorch DataParallel: + + - It supports a custom type :class:`DataContainer` which allows more + flexible control of input data during both GPU and CPU inference. + - It implement two more APIs ``train_step()`` and ``val_step()``. + + Args: + module (:class:`nn.Module`): Module to be encapsulated. + device_ids (list[int]): Device IDS of modules to be scattered to. + Defaults to None when GPU is not available. + output_device (str | int): Device ID for output. Defaults to None. + dim (int): Dimension used to scatter the data. Defaults to 0. + """ + + def __init__(self, *args, dim=0, **kwargs): + super(MMDataParallel, self).__init__(*args, dim=dim, **kwargs) + self.dim = dim + + def forward(self, *inputs, **kwargs): + """Override the original forward function. + + The main difference lies in the CPU inference where the data in + :class:`DataContainers` will still be gathered. + """ + if not self.device_ids: + # We add the following line thus the module could gather and + # convert data containers as those in GPU inference + inputs, kwargs = self.scatter(inputs, kwargs, [-1]) + return self.module(*inputs[0], **kwargs[0]) + else: + return super().forward(*inputs, **kwargs) + + def scatter(self, inputs, kwargs, device_ids): + return scatter_kwargs(inputs, kwargs, device_ids, dim=self.dim) + + def train_step(self, *inputs, **kwargs): + if not self.device_ids: + # We add the following line thus the module could gather and + # convert data containers as those in GPU inference + inputs, kwargs = self.scatter(inputs, kwargs, [-1]) + return self.module.train_step(*inputs[0], **kwargs[0]) + + assert len(self.device_ids) == 1, \ + ('MMDataParallel only supports single GPU training, if you need to' + ' train with multiple GPUs, please use MMDistributedDataParallel' + 'instead.') + + for t in chain(self.module.parameters(), self.module.buffers()): + if t.device != self.src_device_obj: + raise RuntimeError( + 'module must have its parameters and buffers ' + f'on device {self.src_device_obj} (device_ids[0]) but ' + f'found one of them on device: {t.device}') + + inputs, kwargs = self.scatter(inputs, kwargs, self.device_ids) + return self.module.train_step(*inputs[0], **kwargs[0]) + + def val_step(self, *inputs, **kwargs): + if not self.device_ids: + # We add the following line thus the module could gather and + # convert data containers as those in GPU inference + inputs, kwargs = self.scatter(inputs, kwargs, [-1]) + return self.module.val_step(*inputs[0], **kwargs[0]) + + assert len(self.device_ids) == 1, \ + ('MMDataParallel only supports single GPU training, if you need to' + ' train with multiple GPUs, please use MMDistributedDataParallel' + ' instead.') + + for t in chain(self.module.parameters(), self.module.buffers()): + if t.device != self.src_device_obj: + raise RuntimeError( + 'module must have its parameters and buffers ' + f'on device {self.src_device_obj} (device_ids[0]) but ' + f'found one of them on device: {t.device}') + + inputs, kwargs = self.scatter(inputs, kwargs, self.device_ids) + return self.module.val_step(*inputs[0], **kwargs[0]) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/distributed.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/distributed.py new file mode 100644 index 000000000..b799a213d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/distributed.py @@ -0,0 +1,112 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch +from torch.nn.parallel.distributed import (DistributedDataParallel, + _find_tensors) + +from mmcv import print_log +from mmcv.utils import TORCH_VERSION, digit_version +from .scatter_gather import scatter_kwargs + + +class MMDistributedDataParallel(DistributedDataParallel): + """The DDP module that supports DataContainer. + + MMDDP has two main differences with PyTorch DDP: + + - It supports a custom type :class:`DataContainer` which allows more + flexible control of input data. + - It implement two APIs ``train_step()`` and ``val_step()``. + """ + + def to_kwargs(self, inputs, kwargs, device_id): + # Use `self.to_kwargs` instead of `self.scatter` in pytorch1.8 + # to move all tensors to device_id + return scatter_kwargs(inputs, kwargs, [device_id], dim=self.dim) + + def scatter(self, inputs, kwargs, device_ids): + return scatter_kwargs(inputs, kwargs, device_ids, dim=self.dim) + + def train_step(self, *inputs, **kwargs): + """train_step() API for module wrapped by DistributedDataParallel. + + This method is basically the same as + ``DistributedDataParallel.forward()``, while replacing + ``self.module.forward()`` with ``self.module.train_step()``. + It is compatible with PyTorch 1.1 - 1.5. + """ + + # In PyTorch >= 1.7, ``reducer._rebuild_buckets()`` is moved from the + # end of backward to the beginning of forward. + if ('parrots' not in TORCH_VERSION + and digit_version(TORCH_VERSION) >= digit_version('1.7') + and self.reducer._rebuild_buckets()): + print_log( + 'Reducer buckets have been rebuilt in this iteration.', + logger='mmcv') + + if getattr(self, 'require_forward_param_sync', True): + self._sync_params() + if self.device_ids: + inputs, kwargs = self.scatter(inputs, kwargs, self.device_ids) + if len(self.device_ids) == 1: + output = self.module.train_step(*inputs[0], **kwargs[0]) + else: + outputs = self.parallel_apply( + self._module_copies[:len(inputs)], inputs, kwargs) + output = self.gather(outputs, self.output_device) + else: + output = self.module.train_step(*inputs, **kwargs) + + if torch.is_grad_enabled() and getattr( + self, 'require_backward_grad_sync', True): + if self.find_unused_parameters: + self.reducer.prepare_for_backward(list(_find_tensors(output))) + else: + self.reducer.prepare_for_backward([]) + else: + if ('parrots' not in TORCH_VERSION + and digit_version(TORCH_VERSION) > digit_version('1.2')): + self.require_forward_param_sync = False + return output + + def val_step(self, *inputs, **kwargs): + """val_step() API for module wrapped by DistributedDataParallel. + + This method is basically the same as + ``DistributedDataParallel.forward()``, while replacing + ``self.module.forward()`` with ``self.module.val_step()``. + It is compatible with PyTorch 1.1 - 1.5. + """ + # In PyTorch >= 1.7, ``reducer._rebuild_buckets()`` is moved from the + # end of backward to the beginning of forward. + if ('parrots' not in TORCH_VERSION + and digit_version(TORCH_VERSION) >= digit_version('1.7') + and self.reducer._rebuild_buckets()): + print_log( + 'Reducer buckets have been rebuilt in this iteration.', + logger='mmcv') + + if getattr(self, 'require_forward_param_sync', True): + self._sync_params() + if self.device_ids: + inputs, kwargs = self.scatter(inputs, kwargs, self.device_ids) + if len(self.device_ids) == 1: + output = self.module.val_step(*inputs[0], **kwargs[0]) + else: + outputs = self.parallel_apply( + self._module_copies[:len(inputs)], inputs, kwargs) + output = self.gather(outputs, self.output_device) + else: + output = self.module.val_step(*inputs, **kwargs) + + if torch.is_grad_enabled() and getattr( + self, 'require_backward_grad_sync', True): + if self.find_unused_parameters: + self.reducer.prepare_for_backward(list(_find_tensors(output))) + else: + self.reducer.prepare_for_backward([]) + else: + if ('parrots' not in TORCH_VERSION + and digit_version(TORCH_VERSION) > digit_version('1.2')): + self.require_forward_param_sync = False + return output diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/distributed_deprecated.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/distributed_deprecated.py new file mode 100644 index 000000000..b593d4a9e --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/distributed_deprecated.py @@ -0,0 +1,70 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch +import torch.distributed as dist +import torch.nn as nn +from torch._utils import (_flatten_dense_tensors, _take_tensors, + _unflatten_dense_tensors) + +from mmcv.utils import TORCH_VERSION, digit_version +from .registry import MODULE_WRAPPERS +from .scatter_gather import scatter_kwargs + + +@MODULE_WRAPPERS.register_module() +class MMDistributedDataParallel(nn.Module): + + def __init__(self, + module, + dim=0, + broadcast_buffers=True, + bucket_cap_mb=25): + super(MMDistributedDataParallel, self).__init__() + self.module = module + self.dim = dim + self.broadcast_buffers = broadcast_buffers + + self.broadcast_bucket_size = bucket_cap_mb * 1024 * 1024 + self._sync_params() + + def _dist_broadcast_coalesced(self, tensors, buffer_size): + for tensors in _take_tensors(tensors, buffer_size): + flat_tensors = _flatten_dense_tensors(tensors) + dist.broadcast(flat_tensors, 0) + for tensor, synced in zip( + tensors, _unflatten_dense_tensors(flat_tensors, tensors)): + tensor.copy_(synced) + + def _sync_params(self): + module_states = list(self.module.state_dict().values()) + if len(module_states) > 0: + self._dist_broadcast_coalesced(module_states, + self.broadcast_bucket_size) + if self.broadcast_buffers: + if (TORCH_VERSION != 'parrots' + and digit_version(TORCH_VERSION) < digit_version('1.0')): + buffers = [b.data for b in self.module._all_buffers()] + else: + buffers = [b.data for b in self.module.buffers()] + if len(buffers) > 0: + self._dist_broadcast_coalesced(buffers, + self.broadcast_bucket_size) + + def scatter(self, inputs, kwargs, device_ids): + return scatter_kwargs(inputs, kwargs, device_ids, dim=self.dim) + + def forward(self, *inputs, **kwargs): + inputs, kwargs = self.scatter(inputs, kwargs, + [torch.cuda.current_device()]) + return self.module(*inputs[0], **kwargs[0]) + + def train_step(self, *inputs, **kwargs): + inputs, kwargs = self.scatter(inputs, kwargs, + [torch.cuda.current_device()]) + output = self.module.train_step(*inputs[0], **kwargs[0]) + return output + + def val_step(self, *inputs, **kwargs): + inputs, kwargs = self.scatter(inputs, kwargs, + [torch.cuda.current_device()]) + output = self.module.val_step(*inputs[0], **kwargs[0]) + return output diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/registry.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/registry.py new file mode 100644 index 000000000..144f9fb16 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/registry.py @@ -0,0 +1,8 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from torch.nn.parallel import DataParallel, DistributedDataParallel + +from mmcv.utils import Registry + +MODULE_WRAPPERS = Registry('module wrapper') +MODULE_WRAPPERS.register_module(module=DataParallel) +MODULE_WRAPPERS.register_module(module=DistributedDataParallel) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/scatter_gather.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/scatter_gather.py new file mode 100644 index 000000000..900ff8856 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/scatter_gather.py @@ -0,0 +1,59 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch +from torch.nn.parallel._functions import Scatter as OrigScatter + +from ._functions import Scatter +from .data_container import DataContainer + + +def scatter(inputs, target_gpus, dim=0): + """Scatter inputs to target gpus. + + The only difference from original :func:`scatter` is to add support for + :type:`~mmcv.parallel.DataContainer`. + """ + + def scatter_map(obj): + if isinstance(obj, torch.Tensor): + if target_gpus != [-1]: + return OrigScatter.apply(target_gpus, None, dim, obj) + else: + # for CPU inference we use self-implemented scatter + return Scatter.forward(target_gpus, obj) + if isinstance(obj, DataContainer): + if obj.cpu_only: + return obj.data + else: + return Scatter.forward(target_gpus, obj.data) + if isinstance(obj, tuple) and len(obj) > 0: + return list(zip(*map(scatter_map, obj))) + if isinstance(obj, list) and len(obj) > 0: + out = list(map(list, zip(*map(scatter_map, obj)))) + return out + if isinstance(obj, dict) and len(obj) > 0: + out = list(map(type(obj), zip(*map(scatter_map, obj.items())))) + return out + return [obj for targets in target_gpus] + + # After scatter_map is called, a scatter_map cell will exist. This cell + # has a reference to the actual function scatter_map, which has references + # to a closure that has a reference to the scatter_map cell (because the + # fn is recursive). To avoid this reference cycle, we set the function to + # None, clearing the cell + try: + return scatter_map(inputs) + finally: + scatter_map = None + + +def scatter_kwargs(inputs, kwargs, target_gpus, dim=0): + """Scatter with support for kwargs dictionary.""" + inputs = scatter(inputs, target_gpus, dim) if inputs else [] + kwargs = scatter(kwargs, target_gpus, dim) if kwargs else [] + if len(inputs) < len(kwargs): + inputs.extend([() for _ in range(len(kwargs) - len(inputs))]) + elif len(kwargs) < len(inputs): + kwargs.extend([{} for _ in range(len(inputs) - len(kwargs))]) + inputs = tuple(inputs) + kwargs = tuple(kwargs) + return inputs, kwargs diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/utils.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/utils.py new file mode 100644 index 000000000..0f5712cb4 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/parallel/utils.py @@ -0,0 +1,20 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .registry import MODULE_WRAPPERS + + +def is_module_wrapper(module): + """Check if a module is a module wrapper. + + The following 3 modules in MMCV (and their subclasses) are regarded as + module wrappers: DataParallel, DistributedDataParallel, + MMDistributedDataParallel (the deprecated version). You may add you own + module wrapper by registering it to mmcv.parallel.MODULE_WRAPPERS. + + Args: + module (nn.Module): The module to be checked. + + Returns: + bool: True if the input module is a module wrapper. + """ + module_wrappers = tuple(MODULE_WRAPPERS.module_dict.values()) + return isinstance(module, module_wrappers) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/__init__.py new file mode 100644 index 000000000..52e4b48d3 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/__init__.py @@ -0,0 +1,47 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .base_module import BaseModule, ModuleList, Sequential +from .base_runner import BaseRunner +from .builder import RUNNERS, build_runner +from .checkpoint import (CheckpointLoader, _load_checkpoint, + _load_checkpoint_with_prefix, load_checkpoint, + load_state_dict, save_checkpoint, weights_to_cpu) +from .default_constructor import DefaultRunnerConstructor +from .dist_utils import (allreduce_grads, allreduce_params, get_dist_info, + init_dist, master_only) +from .epoch_based_runner import EpochBasedRunner, Runner +from .fp16_utils import LossScaler, auto_fp16, force_fp32, wrap_fp16_model +from .hooks import (HOOKS, CheckpointHook, ClosureHook, DistEvalHook, + DistSamplerSeedHook, DvcliveLoggerHook, EMAHook, EvalHook, + Fp16OptimizerHook, GradientCumulativeFp16OptimizerHook, + GradientCumulativeOptimizerHook, Hook, IterTimerHook, + LoggerHook, LrUpdaterHook, MlflowLoggerHook, + NeptuneLoggerHook, OptimizerHook, PaviLoggerHook, + SyncBuffersHook, TensorboardLoggerHook, TextLoggerHook, + WandbLoggerHook) +from .iter_based_runner import IterBasedRunner, IterLoader +from .log_buffer import LogBuffer +from .optimizer import (OPTIMIZER_BUILDERS, OPTIMIZERS, + DefaultOptimizerConstructor, build_optimizer, + build_optimizer_constructor) +from .priority import Priority, get_priority +from .utils import get_host_info, get_time_str, obj_from_dict, set_random_seed + +__all__ = [ + 'BaseRunner', 'Runner', 'EpochBasedRunner', 'IterBasedRunner', 'LogBuffer', + 'HOOKS', 'Hook', 'CheckpointHook', 'ClosureHook', 'LrUpdaterHook', + 'OptimizerHook', 'IterTimerHook', 'DistSamplerSeedHook', 'LoggerHook', + 'PaviLoggerHook', 'TextLoggerHook', 'TensorboardLoggerHook', + 'NeptuneLoggerHook', 'WandbLoggerHook', 'MlflowLoggerHook', + 'DvcliveLoggerHook', '_load_checkpoint', 'load_state_dict', + 'load_checkpoint', 'weights_to_cpu', 'save_checkpoint', 'Priority', + 'get_priority', 'get_host_info', 'get_time_str', 'obj_from_dict', + 'init_dist', 'get_dist_info', 'master_only', 'OPTIMIZER_BUILDERS', + 'OPTIMIZERS', 'DefaultOptimizerConstructor', 'build_optimizer', + 'build_optimizer_constructor', 'IterLoader', 'set_random_seed', + 'auto_fp16', 'force_fp32', 'wrap_fp16_model', 'Fp16OptimizerHook', + 'SyncBuffersHook', 'EMAHook', 'build_runner', 'RUNNERS', 'allreduce_grads', + 'allreduce_params', 'LossScaler', 'CheckpointLoader', 'BaseModule', + '_load_checkpoint_with_prefix', 'EvalHook', 'DistEvalHook', 'Sequential', + 'ModuleList', 'GradientCumulativeOptimizerHook', + 'GradientCumulativeFp16OptimizerHook', 'DefaultRunnerConstructor' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/base_module.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/base_module.py new file mode 100644 index 000000000..529575b81 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/base_module.py @@ -0,0 +1,195 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import copy +import warnings +from abc import ABCMeta +from collections import defaultdict +from logging import FileHandler + +import torch.nn as nn + +from mmcv.runner.dist_utils import master_only +from mmcv.utils.logging import get_logger, logger_initialized, print_log + + +class BaseModule(nn.Module, metaclass=ABCMeta): + """Base module for all modules in openmmlab. + + ``BaseModule`` is a wrapper of ``torch.nn.Module`` with additional + functionality of parameter initialization. Compared with + ``torch.nn.Module``, ``BaseModule`` mainly adds three attributes. + + - ``init_cfg``: the config to control the initialization. + - ``init_weights``: The function of parameter + initialization and recording initialization + information. + - ``_params_init_info``: Used to track the parameter + initialization information. This attribute only + exists during executing the ``init_weights``. + + Args: + init_cfg (dict, optional): Initialization config dict. + """ + + def __init__(self, init_cfg=None): + """Initialize BaseModule, inherited from `torch.nn.Module`""" + + # NOTE init_cfg can be defined in different levels, but init_cfg + # in low levels has a higher priority. + + super(BaseModule, self).__init__() + # define default value of init_cfg instead of hard code + # in init_weights() function + self._is_init = False + + self.init_cfg = copy.deepcopy(init_cfg) + + # Backward compatibility in derived classes + # if pretrained is not None: + # warnings.warn('DeprecationWarning: pretrained is a deprecated \ + # key, please consider using init_cfg') + # self.init_cfg = dict(type='Pretrained', checkpoint=pretrained) + + @property + def is_init(self): + return self._is_init + + def init_weights(self): + """Initialize the weights.""" + + is_top_level_module = False + # check if it is top-level module + if not hasattr(self, '_params_init_info'): + # The `_params_init_info` is used to record the initialization + # information of the parameters + # the key should be the obj:`nn.Parameter` of model and the value + # should be a dict containing + # - init_info (str): The string that describes the initialization. + # - tmp_mean_value (FloatTensor): The mean of the parameter, + # which indicates whether the parameter has been modified. + # this attribute would be deleted after all parameters + # is initialized. + self._params_init_info = defaultdict(dict) + is_top_level_module = True + + # Initialize the `_params_init_info`, + # When detecting the `tmp_mean_value` of + # the corresponding parameter is changed, update related + # initialization information + for name, param in self.named_parameters(): + self._params_init_info[param][ + 'init_info'] = f'The value is the same before and ' \ + f'after calling `init_weights` ' \ + f'of {self.__class__.__name__} ' + self._params_init_info[param][ + 'tmp_mean_value'] = param.data.mean() + + # pass `params_init_info` to all submodules + # All submodules share the same `params_init_info`, + # so it will be updated when parameters are + # modified at any level of the model. + for sub_module in self.modules(): + sub_module._params_init_info = self._params_init_info + + # Get the initialized logger, if not exist, + # create a logger named `mmcv` + logger_names = list(logger_initialized.keys()) + logger_name = logger_names[0] if logger_names else 'mmcv' + + from ..cnn import initialize + from ..cnn.utils.weight_init import update_init_info + module_name = self.__class__.__name__ + if not self._is_init: + if self.init_cfg: + print_log( + f'initialize {module_name} with init_cfg {self.init_cfg}', + logger=logger_name) + initialize(self, self.init_cfg) + if isinstance(self.init_cfg, dict): + # prevent the parameters of + # the pre-trained model + # from being overwritten by + # the `init_weights` + if self.init_cfg['type'] == 'Pretrained': + return + + for m in self.children(): + if hasattr(m, 'init_weights'): + m.init_weights() + # users may overload the `init_weights` + update_init_info( + m, + init_info=f'Initialized by ' + f'user-defined `init_weights`' + f' in {m.__class__.__name__} ') + + self._is_init = True + else: + warnings.warn(f'init_weights of {self.__class__.__name__} has ' + f'been called more than once.') + + if is_top_level_module: + self._dump_init_info(logger_name) + + for sub_module in self.modules(): + del sub_module._params_init_info + + @master_only + def _dump_init_info(self, logger_name): + """Dump the initialization information to a file named + `initialization.log.json` in workdir. + + Args: + logger_name (str): The name of logger. + """ + + logger = get_logger(logger_name) + + with_file_handler = False + # dump the information to the logger file if there is a `FileHandler` + for handler in logger.handlers: + if isinstance(handler, FileHandler): + handler.stream.write( + 'Name of parameter - Initialization information\n') + for name, param in self.named_parameters(): + handler.stream.write( + f'\n{name} - {param.shape}: ' + f"\n{self._params_init_info[param]['init_info']} \n") + handler.stream.flush() + with_file_handler = True + if not with_file_handler: + for name, param in self.named_parameters(): + print_log( + f'\n{name} - {param.shape}: ' + f"\n{self._params_init_info[param]['init_info']} \n ", + logger=logger_name) + + def __repr__(self): + s = super().__repr__() + if self.init_cfg: + s += f'\ninit_cfg={self.init_cfg}' + return s + + +class Sequential(BaseModule, nn.Sequential): + """Sequential module in openmmlab. + + Args: + init_cfg (dict, optional): Initialization config dict. + """ + + def __init__(self, *args, init_cfg=None): + BaseModule.__init__(self, init_cfg) + nn.Sequential.__init__(self, *args) + + +class ModuleList(BaseModule, nn.ModuleList): + """ModuleList in openmmlab. + + Args: + modules (iterable, optional): an iterable of modules to add. + init_cfg (dict, optional): Initialization config dict. + """ + + def __init__(self, modules=None, init_cfg=None): + BaseModule.__init__(self, init_cfg) + nn.ModuleList.__init__(self, modules) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/base_runner.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/base_runner.py new file mode 100644 index 000000000..25cd98f51 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/base_runner.py @@ -0,0 +1,542 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import copy +import logging +import os.path as osp +import warnings +from abc import ABCMeta, abstractmethod + +import torch +from torch.optim import Optimizer + +import mmcv +from ..parallel import is_module_wrapper +from .checkpoint import load_checkpoint +from .dist_utils import get_dist_info +from .hooks import HOOKS, Hook +from .log_buffer import LogBuffer +from .priority import Priority, get_priority +from .utils import get_time_str + + +class BaseRunner(metaclass=ABCMeta): + """The base class of Runner, a training helper for PyTorch. + + All subclasses should implement the following APIs: + + - ``run()`` + - ``train()`` + - ``val()`` + - ``save_checkpoint()`` + + Args: + model (:obj:`torch.nn.Module`): The model to be run. + batch_processor (callable): A callable method that process a data + batch. The interface of this method should be + `batch_processor(model, data, train_mode) -> dict` + optimizer (dict or :obj:`torch.optim.Optimizer`): It can be either an + optimizer (in most cases) or a dict of optimizers (in models that + requires more than one optimizer, e.g., GAN). + work_dir (str, optional): The working directory to save checkpoints + and logs. Defaults to None. + logger (:obj:`logging.Logger`): Logger used during training. + Defaults to None. (The default value is just for backward + compatibility) + meta (dict | None): A dict records some import information such as + environment info and seed, which will be logged in logger hook. + Defaults to None. + max_epochs (int, optional): Total training epochs. + max_iters (int, optional): Total training iterations. + """ + + def __init__(self, + model, + batch_processor=None, + optimizer=None, + work_dir=None, + logger=None, + meta=None, + max_iters=None, + max_epochs=None): + if batch_processor is not None: + if not callable(batch_processor): + raise TypeError('batch_processor must be callable, ' + f'but got {type(batch_processor)}') + warnings.warn('batch_processor is deprecated, please implement ' + 'train_step() and val_step() in the model instead.') + # raise an error is `batch_processor` is not None and + # `model.train_step()` exists. + if is_module_wrapper(model): + _model = model.module + else: + _model = model + if hasattr(_model, 'train_step') or hasattr(_model, 'val_step'): + raise RuntimeError( + 'batch_processor and model.train_step()/model.val_step() ' + 'cannot be both available.') + else: + assert hasattr(model, 'train_step') + + # check the type of `optimizer` + if isinstance(optimizer, dict): + for name, optim in optimizer.items(): + if not isinstance(optim, Optimizer): + raise TypeError( + f'optimizer must be a dict of torch.optim.Optimizers, ' + f'but optimizer["{name}"] is a {type(optim)}') + elif not isinstance(optimizer, Optimizer) and optimizer is not None: + raise TypeError( + f'optimizer must be a torch.optim.Optimizer object ' + f'or dict or None, but got {type(optimizer)}') + + # check the type of `logger` + if not isinstance(logger, logging.Logger): + raise TypeError(f'logger must be a logging.Logger object, ' + f'but got {type(logger)}') + + # check the type of `meta` + if meta is not None and not isinstance(meta, dict): + raise TypeError( + f'meta must be a dict or None, but got {type(meta)}') + + self.model = model + self.batch_processor = batch_processor + self.optimizer = optimizer + self.logger = logger + self.meta = meta + # create work_dir + if mmcv.is_str(work_dir): + self.work_dir = osp.abspath(work_dir) + mmcv.mkdir_or_exist(self.work_dir) + elif work_dir is None: + self.work_dir = None + else: + raise TypeError('"work_dir" must be a str or None') + + # get model name from the model class + if hasattr(self.model, 'module'): + self._model_name = self.model.module.__class__.__name__ + else: + self._model_name = self.model.__class__.__name__ + + self._rank, self._world_size = get_dist_info() + self.timestamp = get_time_str() + self.mode = None + self._hooks = [] + self._epoch = 0 + self._iter = 0 + self._inner_iter = 0 + + if max_epochs is not None and max_iters is not None: + raise ValueError( + 'Only one of `max_epochs` or `max_iters` can be set.') + + self._max_epochs = max_epochs + self._max_iters = max_iters + # TODO: Redesign LogBuffer, it is not flexible and elegant enough + self.log_buffer = LogBuffer() + + @property + def model_name(self): + """str: Name of the model, usually the module class name.""" + return self._model_name + + @property + def rank(self): + """int: Rank of current process. (distributed training)""" + return self._rank + + @property + def world_size(self): + """int: Number of processes participating in the job. + (distributed training)""" + return self._world_size + + @property + def hooks(self): + """list[:obj:`Hook`]: A list of registered hooks.""" + return self._hooks + + @property + def epoch(self): + """int: Current epoch.""" + return self._epoch + + @property + def iter(self): + """int: Current iteration.""" + return self._iter + + @property + def inner_iter(self): + """int: Iteration in an epoch.""" + return self._inner_iter + + @property + def max_epochs(self): + """int: Maximum training epochs.""" + return self._max_epochs + + @property + def max_iters(self): + """int: Maximum training iterations.""" + return self._max_iters + + @abstractmethod + def train(self): + pass + + @abstractmethod + def val(self): + pass + + @abstractmethod + def run(self, data_loaders, workflow, **kwargs): + pass + + @abstractmethod + def save_checkpoint(self, + out_dir, + filename_tmpl, + save_optimizer=True, + meta=None, + create_symlink=True): + pass + + def current_lr(self): + """Get current learning rates. + + Returns: + list[float] | dict[str, list[float]]: Current learning rates of all + param groups. If the runner has a dict of optimizers, this + method will return a dict. + """ + if isinstance(self.optimizer, torch.optim.Optimizer): + lr = [group['lr'] for group in self.optimizer.param_groups] + elif isinstance(self.optimizer, dict): + lr = dict() + for name, optim in self.optimizer.items(): + lr[name] = [group['lr'] for group in optim.param_groups] + else: + raise RuntimeError( + 'lr is not applicable because optimizer does not exist.') + return lr + + def current_momentum(self): + """Get current momentums. + + Returns: + list[float] | dict[str, list[float]]: Current momentums of all + param groups. If the runner has a dict of optimizers, this + method will return a dict. + """ + + def _get_momentum(optimizer): + momentums = [] + for group in optimizer.param_groups: + if 'momentum' in group.keys(): + momentums.append(group['momentum']) + elif 'betas' in group.keys(): + momentums.append(group['betas'][0]) + else: + momentums.append(0) + return momentums + + if self.optimizer is None: + raise RuntimeError( + 'momentum is not applicable because optimizer does not exist.') + elif isinstance(self.optimizer, torch.optim.Optimizer): + momentums = _get_momentum(self.optimizer) + elif isinstance(self.optimizer, dict): + momentums = dict() + for name, optim in self.optimizer.items(): + momentums[name] = _get_momentum(optim) + return momentums + + def register_hook(self, hook, priority='NORMAL'): + """Register a hook into the hook list. + + The hook will be inserted into a priority queue, with the specified + priority (See :class:`Priority` for details of priorities). + For hooks with the same priority, they will be triggered in the same + order as they are registered. + + Args: + hook (:obj:`Hook`): The hook to be registered. + priority (int or str or :obj:`Priority`): Hook priority. + Lower value means higher priority. + """ + assert isinstance(hook, Hook) + if hasattr(hook, 'priority'): + raise ValueError('"priority" is a reserved attribute for hooks') + priority = get_priority(priority) + hook.priority = priority + # insert the hook to a sorted list + inserted = False + for i in range(len(self._hooks) - 1, -1, -1): + if priority >= self._hooks[i].priority: + self._hooks.insert(i + 1, hook) + inserted = True + break + if not inserted: + self._hooks.insert(0, hook) + + def register_hook_from_cfg(self, hook_cfg): + """Register a hook from its cfg. + + Args: + hook_cfg (dict): Hook config. It should have at least keys 'type' + and 'priority' indicating its type and priority. + + Notes: + The specific hook class to register should not use 'type' and + 'priority' arguments during initialization. + """ + hook_cfg = hook_cfg.copy() + priority = hook_cfg.pop('priority', 'NORMAL') + hook = mmcv.build_from_cfg(hook_cfg, HOOKS) + self.register_hook(hook, priority=priority) + + def call_hook(self, fn_name): + """Call all hooks. + + Args: + fn_name (str): The function name in each hook to be called, such as + "before_train_epoch". + """ + for hook in self._hooks: + getattr(hook, fn_name)(self) + + def get_hook_info(self): + # Get hooks info in each stage + stage_hook_map = {stage: [] for stage in Hook.stages} + for hook in self.hooks: + try: + priority = Priority(hook.priority).name + except ValueError: + priority = hook.priority + classname = hook.__class__.__name__ + hook_info = f'({priority:<12}) {classname:<35}' + for trigger_stage in hook.get_triggered_stages(): + stage_hook_map[trigger_stage].append(hook_info) + + stage_hook_infos = [] + for stage in Hook.stages: + hook_infos = stage_hook_map[stage] + if len(hook_infos) > 0: + info = f'{stage}:\n' + info += '\n'.join(hook_infos) + info += '\n -------------------- ' + stage_hook_infos.append(info) + return '\n'.join(stage_hook_infos) + + def load_checkpoint(self, + filename, + map_location='cpu', + strict=False, + revise_keys=[(r'^module.', '')]): + return load_checkpoint( + self.model, + filename, + map_location, + strict, + self.logger, + revise_keys=revise_keys) + + def resume(self, + checkpoint, + resume_optimizer=True, + map_location='default'): + if map_location == 'default': + if torch.cuda.is_available(): + device_id = torch.cuda.current_device() + checkpoint = self.load_checkpoint( + checkpoint, + map_location=lambda storage, loc: storage.cuda(device_id)) + else: + checkpoint = self.load_checkpoint(checkpoint) + else: + checkpoint = self.load_checkpoint( + checkpoint, map_location=map_location) + + self._epoch = checkpoint['meta']['epoch'] + self._iter = checkpoint['meta']['iter'] + if self.meta is None: + self.meta = {} + self.meta.setdefault('hook_msgs', {}) + # load `last_ckpt`, `best_score`, `best_ckpt`, etc. for hook messages + self.meta['hook_msgs'].update(checkpoint['meta'].get('hook_msgs', {})) + + # Re-calculate the number of iterations when resuming + # models with different number of GPUs + if 'config' in checkpoint['meta']: + config = mmcv.Config.fromstring( + checkpoint['meta']['config'], file_format='.py') + previous_gpu_ids = config.get('gpu_ids', None) + if previous_gpu_ids and len(previous_gpu_ids) > 0 and len( + previous_gpu_ids) != self.world_size: + self._iter = int(self._iter * len(previous_gpu_ids) / + self.world_size) + self.logger.info('the iteration number is changed due to ' + 'change of GPU number') + + # resume meta information meta + self.meta = checkpoint['meta'] + + if 'optimizer' in checkpoint and resume_optimizer: + if isinstance(self.optimizer, Optimizer): + self.optimizer.load_state_dict(checkpoint['optimizer']) + elif isinstance(self.optimizer, dict): + for k in self.optimizer.keys(): + self.optimizer[k].load_state_dict( + checkpoint['optimizer'][k]) + else: + raise TypeError( + 'Optimizer should be dict or torch.optim.Optimizer ' + f'but got {type(self.optimizer)}') + + self.logger.info('resumed epoch %d, iter %d', self.epoch, self.iter) + + def register_lr_hook(self, lr_config): + if lr_config is None: + return + elif isinstance(lr_config, dict): + assert 'policy' in lr_config + policy_type = lr_config.pop('policy') + # If the type of policy is all in lower case, e.g., 'cyclic', + # then its first letter will be capitalized, e.g., to be 'Cyclic'. + # This is for the convenient usage of Lr updater. + # Since this is not applicable for ` + # CosineAnnealingLrUpdater`, + # the string will not be changed if it contains capital letters. + if policy_type == policy_type.lower(): + policy_type = policy_type.title() + hook_type = policy_type + 'LrUpdaterHook' + lr_config['type'] = hook_type + hook = mmcv.build_from_cfg(lr_config, HOOKS) + else: + hook = lr_config + self.register_hook(hook, priority='VERY_HIGH') + + def register_momentum_hook(self, momentum_config): + if momentum_config is None: + return + if isinstance(momentum_config, dict): + assert 'policy' in momentum_config + policy_type = momentum_config.pop('policy') + # If the type of policy is all in lower case, e.g., 'cyclic', + # then its first letter will be capitalized, e.g., to be 'Cyclic'. + # This is for the convenient usage of momentum updater. + # Since this is not applicable for + # `CosineAnnealingMomentumUpdater`, + # the string will not be changed if it contains capital letters. + if policy_type == policy_type.lower(): + policy_type = policy_type.title() + hook_type = policy_type + 'MomentumUpdaterHook' + momentum_config['type'] = hook_type + hook = mmcv.build_from_cfg(momentum_config, HOOKS) + else: + hook = momentum_config + self.register_hook(hook, priority='HIGH') + + def register_optimizer_hook(self, optimizer_config): + if optimizer_config is None: + return + if isinstance(optimizer_config, dict): + optimizer_config.setdefault('type', 'OptimizerHook') + hook = mmcv.build_from_cfg(optimizer_config, HOOKS) + else: + hook = optimizer_config + self.register_hook(hook, priority='ABOVE_NORMAL') + + def register_checkpoint_hook(self, checkpoint_config): + if checkpoint_config is None: + return + if isinstance(checkpoint_config, dict): + checkpoint_config.setdefault('type', 'CheckpointHook') + hook = mmcv.build_from_cfg(checkpoint_config, HOOKS) + else: + hook = checkpoint_config + self.register_hook(hook, priority='NORMAL') + + def register_logger_hooks(self, log_config): + if log_config is None: + return + log_interval = log_config['interval'] + for info in log_config['hooks']: + logger_hook = mmcv.build_from_cfg( + info, HOOKS, default_args=dict(interval=log_interval)) + self.register_hook(logger_hook, priority='VERY_LOW') + + def register_timer_hook(self, timer_config): + if timer_config is None: + return + if isinstance(timer_config, dict): + timer_config_ = copy.deepcopy(timer_config) + hook = mmcv.build_from_cfg(timer_config_, HOOKS) + else: + hook = timer_config + self.register_hook(hook, priority='LOW') + + def register_custom_hooks(self, custom_config): + if custom_config is None: + return + + if not isinstance(custom_config, list): + custom_config = [custom_config] + + for item in custom_config: + if isinstance(item, dict): + self.register_hook_from_cfg(item) + else: + self.register_hook(item, priority='NORMAL') + + def register_profiler_hook(self, profiler_config): + if profiler_config is None: + return + if isinstance(profiler_config, dict): + profiler_config.setdefault('type', 'ProfilerHook') + hook = mmcv.build_from_cfg(profiler_config, HOOKS) + else: + hook = profiler_config + self.register_hook(hook) + + def register_training_hooks(self, + lr_config, + optimizer_config=None, + checkpoint_config=None, + log_config=None, + momentum_config=None, + timer_config=dict(type='IterTimerHook'), + custom_hooks_config=None): + """Register default and custom hooks for training. + + Default and custom hooks include: + + +----------------------+-------------------------+ + | Hooks | Priority | + +======================+=========================+ + | LrUpdaterHook | VERY_HIGH (10) | + +----------------------+-------------------------+ + | MomentumUpdaterHook | HIGH (30) | + +----------------------+-------------------------+ + | OptimizerStepperHook | ABOVE_NORMAL (40) | + +----------------------+-------------------------+ + | CheckpointSaverHook | NORMAL (50) | + +----------------------+-------------------------+ + | IterTimerHook | LOW (70) | + +----------------------+-------------------------+ + | LoggerHook(s) | VERY_LOW (90) | + +----------------------+-------------------------+ + | CustomHook(s) | defaults to NORMAL (50) | + +----------------------+-------------------------+ + + If custom hooks have same priority with default hooks, custom hooks + will be triggered after default hooks. + """ + self.register_lr_hook(lr_config) + self.register_momentum_hook(momentum_config) + self.register_optimizer_hook(optimizer_config) + self.register_checkpoint_hook(checkpoint_config) + self.register_timer_hook(timer_config) + self.register_logger_hooks(log_config) + self.register_custom_hooks(custom_hooks_config) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/builder.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/builder.py new file mode 100644 index 000000000..77c96ba0b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/builder.py @@ -0,0 +1,24 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import copy + +from ..utils import Registry + +RUNNERS = Registry('runner') +RUNNER_BUILDERS = Registry('runner builder') + + +def build_runner_constructor(cfg): + return RUNNER_BUILDERS.build(cfg) + + +def build_runner(cfg, default_args=None): + runner_cfg = copy.deepcopy(cfg) + constructor_type = runner_cfg.pop('constructor', + 'DefaultRunnerConstructor') + runner_constructor = build_runner_constructor( + dict( + type=constructor_type, + runner_cfg=runner_cfg, + default_args=default_args)) + runner = runner_constructor() + return runner diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/checkpoint.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/checkpoint.py new file mode 100644 index 000000000..6ad605b85 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/checkpoint.py @@ -0,0 +1,707 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import io +import os +import os.path as osp +import pkgutil +import re +import time +import warnings +from collections import OrderedDict +from importlib import import_module +from tempfile import TemporaryDirectory + +import torch +import torchvision +from torch.optim import Optimizer +from torch.utils import model_zoo + +import mmcv +from ..fileio import FileClient +from ..fileio import load as load_file +from ..parallel import is_module_wrapper +from ..utils import mkdir_or_exist +from .dist_utils import get_dist_info + +ENV_MMCV_HOME = 'MMCV_HOME' +ENV_XDG_CACHE_HOME = 'XDG_CACHE_HOME' +DEFAULT_CACHE_DIR = '~/.cache' + + +def _get_mmcv_home(): + mmcv_home = os.path.expanduser( + os.getenv( + ENV_MMCV_HOME, + os.path.join( + os.getenv(ENV_XDG_CACHE_HOME, DEFAULT_CACHE_DIR), 'mmcv'))) + + mkdir_or_exist(mmcv_home) + return mmcv_home + + +def load_state_dict(module, state_dict, strict=False, logger=None): + """Load state_dict to a module. + + This method is modified from :meth:`torch.nn.Module.load_state_dict`. + Default value for ``strict`` is set to ``False`` and the message for + param mismatch will be shown even if strict is False. + + Args: + module (Module): Module that receives the state_dict. + state_dict (OrderedDict): Weights. + strict (bool): whether to strictly enforce that the keys + in :attr:`state_dict` match the keys returned by this module's + :meth:`~torch.nn.Module.state_dict` function. Default: ``False``. + logger (:obj:`logging.Logger`, optional): Logger to log the error + message. If not specified, print function will be used. + """ + unexpected_keys = [] + all_missing_keys = [] + err_msg = [] + + metadata = getattr(state_dict, '_metadata', None) + state_dict = state_dict.copy() + if metadata is not None: + state_dict._metadata = metadata + + # use _load_from_state_dict to enable checkpoint version control + def load(module, prefix=''): + # recursively check parallel module in case that the model has a + # complicated structure, e.g., nn.Module(nn.Module(DDP)) + if is_module_wrapper(module): + module = module.module + local_metadata = {} if metadata is None else metadata.get( + prefix[:-1], {}) + module._load_from_state_dict(state_dict, prefix, local_metadata, True, + all_missing_keys, unexpected_keys, + err_msg) + for name, child in module._modules.items(): + if child is not None: + load(child, prefix + name + '.') + + load(module) + load = None # break load->load reference cycle + + # ignore "num_batches_tracked" of BN layers + missing_keys = [ + key for key in all_missing_keys if 'num_batches_tracked' not in key + ] + + if unexpected_keys: + err_msg.append('unexpected key in source ' + f'state_dict: {", ".join(unexpected_keys)}\n') + if missing_keys: + err_msg.append( + f'missing keys in source state_dict: {", ".join(missing_keys)}\n') + + rank, _ = get_dist_info() + if len(err_msg) > 0 and rank == 0: + err_msg.insert( + 0, 'The model and loaded state dict do not match exactly\n') + err_msg = '\n'.join(err_msg) + if strict: + raise RuntimeError(err_msg) + elif logger is not None: + logger.warning(err_msg) + else: + print(err_msg) + + +def get_torchvision_models(): + model_urls = dict() + for _, name, ispkg in pkgutil.walk_packages(torchvision.models.__path__): + if ispkg: + continue + _zoo = import_module(f'torchvision.models.{name}') + if hasattr(_zoo, 'model_urls'): + _urls = getattr(_zoo, 'model_urls') + model_urls.update(_urls) + return model_urls + + +def get_external_models(): + mmcv_home = _get_mmcv_home() + default_json_path = osp.join(mmcv.__path__[0], 'model_zoo/open_mmlab.json') + default_urls = load_file(default_json_path) + assert isinstance(default_urls, dict) + external_json_path = osp.join(mmcv_home, 'open_mmlab.json') + if osp.exists(external_json_path): + external_urls = load_file(external_json_path) + assert isinstance(external_urls, dict) + default_urls.update(external_urls) + + return default_urls + + +def get_mmcls_models(): + mmcls_json_path = osp.join(mmcv.__path__[0], 'model_zoo/mmcls.json') + mmcls_urls = load_file(mmcls_json_path) + + return mmcls_urls + + +def get_deprecated_model_names(): + deprecate_json_path = osp.join(mmcv.__path__[0], + 'model_zoo/deprecated.json') + deprecate_urls = load_file(deprecate_json_path) + assert isinstance(deprecate_urls, dict) + + return deprecate_urls + + +def _process_mmcls_checkpoint(checkpoint): + state_dict = checkpoint['state_dict'] + new_state_dict = OrderedDict() + for k, v in state_dict.items(): + if k.startswith('backbone.'): + new_state_dict[k[9:]] = v + new_checkpoint = dict(state_dict=new_state_dict) + + return new_checkpoint + + +class CheckpointLoader: + """A general checkpoint loader to manage all schemes.""" + + _schemes = {} + + @classmethod + def _register_scheme(cls, prefixes, loader, force=False): + if isinstance(prefixes, str): + prefixes = [prefixes] + else: + assert isinstance(prefixes, (list, tuple)) + for prefix in prefixes: + if (prefix not in cls._schemes) or force: + cls._schemes[prefix] = loader + else: + raise KeyError( + f'{prefix} is already registered as a loader backend, ' + 'add "force=True" if you want to override it') + # sort, longer prefixes take priority + cls._schemes = OrderedDict( + sorted(cls._schemes.items(), key=lambda t: t[0], reverse=True)) + + @classmethod + def register_scheme(cls, prefixes, loader=None, force=False): + """Register a loader to CheckpointLoader. + + This method can be used as a normal class method or a decorator. + + Args: + prefixes (str or list[str] or tuple[str]): + The prefix of the registered loader. + loader (function, optional): The loader function to be registered. + When this method is used as a decorator, loader is None. + Defaults to None. + force (bool, optional): Whether to override the loader + if the prefix has already been registered. Defaults to False. + """ + + if loader is not None: + cls._register_scheme(prefixes, loader, force=force) + return + + def _register(loader_cls): + cls._register_scheme(prefixes, loader_cls, force=force) + return loader_cls + + return _register + + @classmethod + def _get_checkpoint_loader(cls, path): + """Finds a loader that supports the given path. Falls back to the local + loader if no other loader is found. + + Args: + path (str): checkpoint path + + Returns: + loader (function): checkpoint loader + """ + + for p in cls._schemes: + if path.startswith(p): + return cls._schemes[p] + + @classmethod + def load_checkpoint(cls, filename, map_location=None, logger=None): + """load checkpoint through URL scheme path. + + Args: + filename (str): checkpoint file name with given prefix + map_location (str, optional): Same as :func:`torch.load`. + Default: None + logger (:mod:`logging.Logger`, optional): The logger for message. + Default: None + + Returns: + dict or OrderedDict: The loaded checkpoint. + """ + + checkpoint_loader = cls._get_checkpoint_loader(filename) + class_name = checkpoint_loader.__name__ + mmcv.print_log( + f'load checkpoint from {class_name[10:]} path: {filename}', logger) + return checkpoint_loader(filename, map_location) + + +@CheckpointLoader.register_scheme(prefixes='') +def load_from_local(filename, map_location): + """load checkpoint by local file path. + + Args: + filename (str): local checkpoint file path + map_location (str, optional): Same as :func:`torch.load`. + + Returns: + dict or OrderedDict: The loaded checkpoint. + """ + + if not osp.isfile(filename): + raise IOError(f'{filename} is not a checkpoint file') + checkpoint = torch.load(filename, map_location=map_location) + return checkpoint + + +@CheckpointLoader.register_scheme(prefixes=('http://', 'https://')) +def load_from_http(filename, map_location=None, model_dir=None): + """load checkpoint through HTTP or HTTPS scheme path. In distributed + setting, this function only download checkpoint at local rank 0. + + Args: + filename (str): checkpoint file path with modelzoo or + torchvision prefix + map_location (str, optional): Same as :func:`torch.load`. + model_dir (string, optional): directory in which to save the object, + Default: None + + Returns: + dict or OrderedDict: The loaded checkpoint. + """ + rank, world_size = get_dist_info() + rank = int(os.environ.get('LOCAL_RANK', rank)) + if rank == 0: + checkpoint = model_zoo.load_url( + filename, model_dir=model_dir, map_location=map_location) + if world_size > 1: + torch.distributed.barrier() + if rank > 0: + checkpoint = model_zoo.load_url( + filename, model_dir=model_dir, map_location=map_location) + return checkpoint + + +@CheckpointLoader.register_scheme(prefixes='pavi://') +def load_from_pavi(filename, map_location=None): + """load checkpoint through the file path prefixed with pavi. In distributed + setting, this function download ckpt at all ranks to different temporary + directories. + + Args: + filename (str): checkpoint file path with pavi prefix + map_location (str, optional): Same as :func:`torch.load`. + Default: None + + Returns: + dict or OrderedDict: The loaded checkpoint. + """ + assert filename.startswith('pavi://'), \ + f'Expected filename startswith `pavi://`, but get {filename}' + model_path = filename[7:] + + try: + from pavi import modelcloud + except ImportError: + raise ImportError( + 'Please install pavi to load checkpoint from modelcloud.') + + model = modelcloud.get(model_path) + with TemporaryDirectory() as tmp_dir: + downloaded_file = osp.join(tmp_dir, model.name) + model.download(downloaded_file) + checkpoint = torch.load(downloaded_file, map_location=map_location) + return checkpoint + + +@CheckpointLoader.register_scheme(prefixes='s3://') +def load_from_ceph(filename, map_location=None, backend='petrel'): + """load checkpoint through the file path prefixed with s3. In distributed + setting, this function download ckpt at all ranks to different temporary + directories. + + Args: + filename (str): checkpoint file path with s3 prefix + map_location (str, optional): Same as :func:`torch.load`. + backend (str, optional): The storage backend type. Options are 'ceph', + 'petrel'. Default: 'petrel'. + + .. warning:: + :class:`mmcv.fileio.file_client.CephBackend` will be deprecated, + please use :class:`mmcv.fileio.file_client.PetrelBackend` instead. + + Returns: + dict or OrderedDict: The loaded checkpoint. + """ + allowed_backends = ['ceph', 'petrel'] + if backend not in allowed_backends: + raise ValueError(f'Load from Backend {backend} is not supported.') + + if backend == 'ceph': + warnings.warn( + 'CephBackend will be deprecated, please use PetrelBackend instead') + + # CephClient and PetrelBackend have the same prefix 's3://' and the latter + # will be chosen as default. If PetrelBackend can not be instantiated + # successfully, the CephClient will be chosen. + try: + file_client = FileClient(backend=backend) + except ImportError: + allowed_backends.remove(backend) + file_client = FileClient(backend=allowed_backends[0]) + + with io.BytesIO(file_client.get(filename)) as buffer: + checkpoint = torch.load(buffer, map_location=map_location) + return checkpoint + + +@CheckpointLoader.register_scheme(prefixes=('modelzoo://', 'torchvision://')) +def load_from_torchvision(filename, map_location=None): + """load checkpoint through the file path prefixed with modelzoo or + torchvision. + + Args: + filename (str): checkpoint file path with modelzoo or + torchvision prefix + map_location (str, optional): Same as :func:`torch.load`. + + Returns: + dict or OrderedDict: The loaded checkpoint. + """ + model_urls = get_torchvision_models() + if filename.startswith('modelzoo://'): + warnings.warn('The URL scheme of "modelzoo://" is deprecated, please ' + 'use "torchvision://" instead') + model_name = filename[11:] + else: + model_name = filename[14:] + return load_from_http(model_urls[model_name], map_location=map_location) + + +@CheckpointLoader.register_scheme(prefixes=('open-mmlab://', 'openmmlab://')) +def load_from_openmmlab(filename, map_location=None): + """load checkpoint through the file path prefixed with open-mmlab or + openmmlab. + + Args: + filename (str): checkpoint file path with open-mmlab or + openmmlab prefix + map_location (str, optional): Same as :func:`torch.load`. + Default: None + + Returns: + dict or OrderedDict: The loaded checkpoint. + """ + + model_urls = get_external_models() + prefix_str = 'open-mmlab://' + if filename.startswith(prefix_str): + model_name = filename[13:] + else: + model_name = filename[12:] + prefix_str = 'openmmlab://' + + deprecated_urls = get_deprecated_model_names() + if model_name in deprecated_urls: + warnings.warn(f'{prefix_str}{model_name} is deprecated in favor ' + f'of {prefix_str}{deprecated_urls[model_name]}') + model_name = deprecated_urls[model_name] + model_url = model_urls[model_name] + # check if is url + if model_url.startswith(('http://', 'https://')): + checkpoint = load_from_http(model_url, map_location=map_location) + else: + filename = osp.join(_get_mmcv_home(), model_url) + if not osp.isfile(filename): + raise IOError(f'{filename} is not a checkpoint file') + checkpoint = torch.load(filename, map_location=map_location) + return checkpoint + + +@CheckpointLoader.register_scheme(prefixes='mmcls://') +def load_from_mmcls(filename, map_location=None): + """load checkpoint through the file path prefixed with mmcls. + + Args: + filename (str): checkpoint file path with mmcls prefix + map_location (str, optional): Same as :func:`torch.load`. + + Returns: + dict or OrderedDict: The loaded checkpoint. + """ + + model_urls = get_mmcls_models() + model_name = filename[8:] + checkpoint = load_from_http( + model_urls[model_name], map_location=map_location) + checkpoint = _process_mmcls_checkpoint(checkpoint) + return checkpoint + + +def _load_checkpoint(filename, map_location=None, logger=None): + """Load checkpoint from somewhere (modelzoo, file, url). + + Args: + filename (str): Accept local filepath, URL, ``torchvision://xxx``, + ``open-mmlab://xxx``. Please refer to ``docs/model_zoo.md`` for + details. + map_location (str, optional): Same as :func:`torch.load`. + Default: None. + logger (:mod:`logging.Logger`, optional): The logger for error message. + Default: None + + Returns: + dict or OrderedDict: The loaded checkpoint. It can be either an + OrderedDict storing model weights or a dict containing other + information, which depends on the checkpoint. + """ + return CheckpointLoader.load_checkpoint(filename, map_location, logger) + + +def _load_checkpoint_with_prefix(prefix, filename, map_location=None): + """Load partial pretrained model with specific prefix. + + Args: + prefix (str): The prefix of sub-module. + filename (str): Accept local filepath, URL, ``torchvision://xxx``, + ``open-mmlab://xxx``. Please refer to ``docs/model_zoo.md`` for + details. + map_location (str | None): Same as :func:`torch.load`. Default: None. + + Returns: + dict or OrderedDict: The loaded checkpoint. + """ + + checkpoint = _load_checkpoint(filename, map_location=map_location) + + if 'state_dict' in checkpoint: + state_dict = checkpoint['state_dict'] + else: + state_dict = checkpoint + if not prefix.endswith('.'): + prefix += '.' + prefix_len = len(prefix) + + state_dict = { + k[prefix_len:]: v + for k, v in state_dict.items() if k.startswith(prefix) + } + + assert state_dict, f'{prefix} is not in the pretrained model' + return state_dict + + +def load_checkpoint(model, + filename, + map_location=None, + strict=False, + logger=None, + revise_keys=[(r'^module\.', '')]): + """Load checkpoint from a file or URI. + + Args: + model (Module): Module to load checkpoint. + filename (str): Accept local filepath, URL, ``torchvision://xxx``, + ``open-mmlab://xxx``. Please refer to ``docs/model_zoo.md`` for + details. + map_location (str): Same as :func:`torch.load`. + strict (bool): Whether to allow different params for the model and + checkpoint. + logger (:mod:`logging.Logger` or None): The logger for error message. + revise_keys (list): A list of customized keywords to modify the + state_dict in checkpoint. Each item is a (pattern, replacement) + pair of the regular expression operations. Default: strip + the prefix 'module.' by [(r'^module\\.', '')]. + + Returns: + dict or OrderedDict: The loaded checkpoint. + """ + checkpoint = _load_checkpoint(filename, map_location, logger) + # OrderedDict is a subclass of dict + if not isinstance(checkpoint, dict): + raise RuntimeError( + f'No state_dict found in checkpoint file {filename}') + # get state_dict from checkpoint + if 'state_dict' in checkpoint: + state_dict = checkpoint['state_dict'] + else: + state_dict = checkpoint + + # strip prefix of state_dict + metadata = getattr(state_dict, '_metadata', OrderedDict()) + for p, r in revise_keys: + state_dict = OrderedDict( + {re.sub(p, r, k): v + for k, v in state_dict.items()}) + # Keep metadata in state_dict + state_dict._metadata = metadata + + # load state_dict + load_state_dict(model, state_dict, strict, logger) + return checkpoint + + +def weights_to_cpu(state_dict): + """Copy a model state_dict to cpu. + + Args: + state_dict (OrderedDict): Model weights on GPU. + + Returns: + OrderedDict: Model weights on GPU. + """ + state_dict_cpu = OrderedDict() + for key, val in state_dict.items(): + state_dict_cpu[key] = val.cpu() + # Keep metadata in state_dict + state_dict_cpu._metadata = getattr(state_dict, '_metadata', OrderedDict()) + return state_dict_cpu + + +def _save_to_state_dict(module, destination, prefix, keep_vars): + """Saves module state to `destination` dictionary. + + This method is modified from :meth:`torch.nn.Module._save_to_state_dict`. + + Args: + module (nn.Module): The module to generate state_dict. + destination (dict): A dict where state will be stored. + prefix (str): The prefix for parameters and buffers used in this + module. + """ + for name, param in module._parameters.items(): + if param is not None: + destination[prefix + name] = param if keep_vars else param.detach() + for name, buf in module._buffers.items(): + # remove check of _non_persistent_buffers_set to allow nn.BatchNorm2d + if buf is not None: + destination[prefix + name] = buf if keep_vars else buf.detach() + + +def get_state_dict(module, destination=None, prefix='', keep_vars=False): + """Returns a dictionary containing a whole state of the module. + + Both parameters and persistent buffers (e.g. running averages) are + included. Keys are corresponding parameter and buffer names. + + This method is modified from :meth:`torch.nn.Module.state_dict` to + recursively check parallel module in case that the model has a complicated + structure, e.g., nn.Module(nn.Module(DDP)). + + Args: + module (nn.Module): The module to generate state_dict. + destination (OrderedDict): Returned dict for the state of the + module. + prefix (str): Prefix of the key. + keep_vars (bool): Whether to keep the variable property of the + parameters. Default: False. + + Returns: + dict: A dictionary containing a whole state of the module. + """ + # recursively check parallel module in case that the model has a + # complicated structure, e.g., nn.Module(nn.Module(DDP)) + if is_module_wrapper(module): + module = module.module + + # below is the same as torch.nn.Module.state_dict() + if destination is None: + destination = OrderedDict() + destination._metadata = OrderedDict() + destination._metadata[prefix[:-1]] = local_metadata = dict( + version=module._version) + _save_to_state_dict(module, destination, prefix, keep_vars) + for name, child in module._modules.items(): + if child is not None: + get_state_dict( + child, destination, prefix + name + '.', keep_vars=keep_vars) + for hook in module._state_dict_hooks.values(): + hook_result = hook(module, destination, prefix, local_metadata) + if hook_result is not None: + destination = hook_result + return destination + + +def save_checkpoint(model, + filename, + optimizer=None, + meta=None, + file_client_args=None): + """Save checkpoint to file. + + The checkpoint will have 3 fields: ``meta``, ``state_dict`` and + ``optimizer``. By default ``meta`` will contain version and time info. + + Args: + model (Module): Module whose params are to be saved. + filename (str): Checkpoint filename. + optimizer (:obj:`Optimizer`, optional): Optimizer to be saved. + meta (dict, optional): Metadata to be saved in checkpoint. + file_client_args (dict, optional): Arguments to instantiate a + FileClient. See :class:`mmcv.fileio.FileClient` for details. + Default: None. + `New in version 1.3.16.` + """ + if meta is None: + meta = {} + elif not isinstance(meta, dict): + raise TypeError(f'meta must be a dict or None, but got {type(meta)}') + meta.update(mmcv_version=mmcv.__version__, time=time.asctime()) + + if is_module_wrapper(model): + model = model.module + + if hasattr(model, 'CLASSES') and model.CLASSES is not None: + # save class name to the meta + meta.update(CLASSES=model.CLASSES) + + checkpoint = { + 'meta': meta, + 'state_dict': weights_to_cpu(get_state_dict(model)) + } + # save optimizer state dict in the checkpoint + if isinstance(optimizer, Optimizer): + checkpoint['optimizer'] = optimizer.state_dict() + elif isinstance(optimizer, dict): + checkpoint['optimizer'] = {} + for name, optim in optimizer.items(): + checkpoint['optimizer'][name] = optim.state_dict() + + if filename.startswith('pavi://'): + if file_client_args is not None: + raise ValueError( + 'file_client_args should be "None" if filename starts with' + f'"pavi://", but got {file_client_args}') + try: + from pavi import modelcloud + from pavi import exception + except ImportError: + raise ImportError( + 'Please install pavi to load checkpoint from modelcloud.') + model_path = filename[7:] + root = modelcloud.Folder() + model_dir, model_name = osp.split(model_path) + try: + model = modelcloud.get(model_dir) + except exception.NodeNotFoundError: + model = root.create_training_model(model_dir) + with TemporaryDirectory() as tmp_dir: + checkpoint_file = osp.join(tmp_dir, model_name) + with open(checkpoint_file, 'wb') as f: + torch.save(checkpoint, f) + f.flush() + model.create_file(checkpoint_file, name=model_name) + else: + file_client = FileClient.infer_client(file_client_args, filename) + with io.BytesIO() as f: + torch.save(checkpoint, f) + file_client.put(f.getvalue(), filename) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/default_constructor.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/default_constructor.py new file mode 100644 index 000000000..0bad847f2 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/default_constructor.py @@ -0,0 +1,44 @@ +from .builder import RUNNER_BUILDERS, RUNNERS + + +@RUNNER_BUILDERS.register_module() +class DefaultRunnerConstructor: + """Default constructor for runners. + + Custom existing `Runner` like `EpocBasedRunner` though `RunnerConstructor`. + For example, We can inject some new properties and functions for `Runner`. + + Example: + >>> from mmcv.runner import RUNNER_BUILDERS, build_runner + >>> # Define a new RunnerReconstructor + >>> @RUNNER_BUILDERS.register_module() + >>> class MyRunnerConstructor: + ... def __init__(self, runner_cfg, default_args=None): + ... if not isinstance(runner_cfg, dict): + ... raise TypeError('runner_cfg should be a dict', + ... f'but got {type(runner_cfg)}') + ... self.runner_cfg = runner_cfg + ... self.default_args = default_args + ... + ... def __call__(self): + ... runner = RUNNERS.build(self.runner_cfg, + ... default_args=self.default_args) + ... # Add new properties for existing runner + ... runner.my_name = 'my_runner' + ... runner.my_function = lambda self: print(self.my_name) + ... ... + >>> # build your runner + >>> runner_cfg = dict(type='EpochBasedRunner', max_epochs=40, + ... constructor='MyRunnerConstructor') + >>> runner = build_runner(runner_cfg) + """ + + def __init__(self, runner_cfg, default_args=None): + if not isinstance(runner_cfg, dict): + raise TypeError('runner_cfg should be a dict', + f'but got {type(runner_cfg)}') + self.runner_cfg = runner_cfg + self.default_args = default_args + + def __call__(self): + return RUNNERS.build(self.runner_cfg, default_args=self.default_args) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/dist_utils.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/dist_utils.py new file mode 100644 index 000000000..d3a1ef3fd --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/dist_utils.py @@ -0,0 +1,164 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import functools +import os +import subprocess +from collections import OrderedDict + +import torch +import torch.multiprocessing as mp +from torch import distributed as dist +from torch._utils import (_flatten_dense_tensors, _take_tensors, + _unflatten_dense_tensors) + + +def init_dist(launcher, backend='nccl', **kwargs): + if mp.get_start_method(allow_none=True) is None: + mp.set_start_method('spawn') + if launcher == 'pytorch': + _init_dist_pytorch(backend, **kwargs) + elif launcher == 'mpi': + _init_dist_mpi(backend, **kwargs) + elif launcher == 'slurm': + _init_dist_slurm(backend, **kwargs) + else: + raise ValueError(f'Invalid launcher type: {launcher}') + + +def _init_dist_pytorch(backend, **kwargs): + # TODO: use local_rank instead of rank % num_gpus + rank = int(os.environ['RANK']) + num_gpus = torch.cuda.device_count() + torch.cuda.set_device(rank % num_gpus) + dist.init_process_group(backend=backend, **kwargs) + + +def _init_dist_mpi(backend, **kwargs): + # TODO: use local_rank instead of rank % num_gpus + rank = int(os.environ['OMPI_COMM_WORLD_RANK']) + num_gpus = torch.cuda.device_count() + torch.cuda.set_device(rank % num_gpus) + dist.init_process_group(backend=backend, **kwargs) + + +def _init_dist_slurm(backend, port=None): + """Initialize slurm distributed training environment. + + If argument ``port`` is not specified, then the master port will be system + environment variable ``MASTER_PORT``. If ``MASTER_PORT`` is not in system + environment variable, then a default port ``29500`` will be used. + + Args: + backend (str): Backend of torch.distributed. + port (int, optional): Master port. Defaults to None. + """ + proc_id = int(os.environ['SLURM_PROCID']) + ntasks = int(os.environ['SLURM_NTASKS']) + node_list = os.environ['SLURM_NODELIST'] + num_gpus = torch.cuda.device_count() + torch.cuda.set_device(proc_id % num_gpus) + addr = subprocess.getoutput( + f'scontrol show hostname {node_list} | head -n1') + # specify master port + if port is not None: + os.environ['MASTER_PORT'] = str(port) + elif 'MASTER_PORT' in os.environ: + pass # use MASTER_PORT in the environment variable + else: + # 29500 is torch.distributed default port + os.environ['MASTER_PORT'] = '29500' + # use MASTER_ADDR in the environment variable if it already exists + if 'MASTER_ADDR' not in os.environ: + os.environ['MASTER_ADDR'] = addr + os.environ['WORLD_SIZE'] = str(ntasks) + os.environ['LOCAL_RANK'] = str(proc_id % num_gpus) + os.environ['RANK'] = str(proc_id) + dist.init_process_group(backend=backend) + + +def get_dist_info(): + if dist.is_available() and dist.is_initialized(): + rank = dist.get_rank() + world_size = dist.get_world_size() + else: + rank = 0 + world_size = 1 + return rank, world_size + + +def master_only(func): + + @functools.wraps(func) + def wrapper(*args, **kwargs): + rank, _ = get_dist_info() + if rank == 0: + return func(*args, **kwargs) + + return wrapper + + +def allreduce_params(params, coalesce=True, bucket_size_mb=-1): + """Allreduce parameters. + + Args: + params (list[torch.Parameters]): List of parameters or buffers of a + model. + coalesce (bool, optional): Whether allreduce parameters as a whole. + Defaults to True. + bucket_size_mb (int, optional): Size of bucket, the unit is MB. + Defaults to -1. + """ + _, world_size = get_dist_info() + if world_size == 1: + return + params = [param.data for param in params] + if coalesce: + _allreduce_coalesced(params, world_size, bucket_size_mb) + else: + for tensor in params: + dist.all_reduce(tensor.div_(world_size)) + + +def allreduce_grads(params, coalesce=True, bucket_size_mb=-1): + """Allreduce gradients. + + Args: + params (list[torch.Parameters]): List of parameters of a model + coalesce (bool, optional): Whether allreduce parameters as a whole. + Defaults to True. + bucket_size_mb (int, optional): Size of bucket, the unit is MB. + Defaults to -1. + """ + grads = [ + param.grad.data for param in params + if param.requires_grad and param.grad is not None + ] + _, world_size = get_dist_info() + if world_size == 1: + return + if coalesce: + _allreduce_coalesced(grads, world_size, bucket_size_mb) + else: + for tensor in grads: + dist.all_reduce(tensor.div_(world_size)) + + +def _allreduce_coalesced(tensors, world_size, bucket_size_mb=-1): + if bucket_size_mb > 0: + bucket_size_bytes = bucket_size_mb * 1024 * 1024 + buckets = _take_tensors(tensors, bucket_size_bytes) + else: + buckets = OrderedDict() + for tensor in tensors: + tp = tensor.type() + if tp not in buckets: + buckets[tp] = [] + buckets[tp].append(tensor) + buckets = buckets.values() + + for bucket in buckets: + flat_tensors = _flatten_dense_tensors(bucket) + dist.all_reduce(flat_tensors) + flat_tensors.div_(world_size) + for tensor, synced in zip( + bucket, _unflatten_dense_tensors(flat_tensors, bucket)): + tensor.copy_(synced) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/epoch_based_runner.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/epoch_based_runner.py new file mode 100644 index 000000000..2dd29357a --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/epoch_based_runner.py @@ -0,0 +1,187 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import os.path as osp +import platform +import shutil +import time +import warnings + +import torch + +import mmcv +from .base_runner import BaseRunner +from .builder import RUNNERS +from .checkpoint import save_checkpoint +from .utils import get_host_info + + +@RUNNERS.register_module() +class EpochBasedRunner(BaseRunner): + """Epoch-based Runner. + + This runner train models epoch by epoch. + """ + + def run_iter(self, data_batch, train_mode, **kwargs): + if self.batch_processor is not None: + outputs = self.batch_processor( + self.model, data_batch, train_mode=train_mode, **kwargs) + elif train_mode: + outputs = self.model.train_step(data_batch, self.optimizer, + **kwargs) + else: + outputs = self.model.val_step(data_batch, self.optimizer, **kwargs) + if not isinstance(outputs, dict): + raise TypeError('"batch_processor()" or "model.train_step()"' + 'and "model.val_step()" must return a dict') + if 'log_vars' in outputs: + self.log_buffer.update(outputs['log_vars'], outputs['num_samples']) + self.outputs = outputs + + def train(self, data_loader, **kwargs): + self.model.train() + self.mode = 'train' + self.data_loader = data_loader + self._max_iters = self._max_epochs * len(self.data_loader) + self.call_hook('before_train_epoch') + time.sleep(2) # Prevent possible deadlock during epoch transition + for i, data_batch in enumerate(self.data_loader): + self._inner_iter = i + self.call_hook('before_train_iter') + self.run_iter(data_batch, train_mode=True, **kwargs) + self.call_hook('after_train_iter') + self._iter += 1 + + self.call_hook('after_train_epoch') + self._epoch += 1 + + @torch.no_grad() + def val(self, data_loader, **kwargs): + self.model.eval() + self.mode = 'val' + self.data_loader = data_loader + self.call_hook('before_val_epoch') + time.sleep(2) # Prevent possible deadlock during epoch transition + for i, data_batch in enumerate(self.data_loader): + self._inner_iter = i + self.call_hook('before_val_iter') + self.run_iter(data_batch, train_mode=False) + self.call_hook('after_val_iter') + + self.call_hook('after_val_epoch') + + def run(self, data_loaders, workflow, max_epochs=None, **kwargs): + """Start running. + + Args: + data_loaders (list[:obj:`DataLoader`]): Dataloaders for training + and validation. + workflow (list[tuple]): A list of (phase, epochs) to specify the + running order and epochs. E.g, [('train', 2), ('val', 1)] means + running 2 epochs for training and 1 epoch for validation, + iteratively. + """ + assert isinstance(data_loaders, list) + assert mmcv.is_list_of(workflow, tuple) + assert len(data_loaders) == len(workflow) + if max_epochs is not None: + warnings.warn( + 'setting max_epochs in run is deprecated, ' + 'please set max_epochs in runner_config', DeprecationWarning) + self._max_epochs = max_epochs + + assert self._max_epochs is not None, ( + 'max_epochs must be specified during instantiation') + + for i, flow in enumerate(workflow): + mode, epochs = flow + if mode == 'train': + self._max_iters = self._max_epochs * len(data_loaders[i]) + break + + work_dir = self.work_dir if self.work_dir is not None else 'NONE' + self.logger.info('Start running, host: %s, work_dir: %s', + get_host_info(), work_dir) + self.logger.info('Hooks will be executed in the following order:\n%s', + self.get_hook_info()) + self.logger.info('workflow: %s, max: %d epochs', workflow, + self._max_epochs) + self.call_hook('before_run') + + while self.epoch < self._max_epochs: + for i, flow in enumerate(workflow): + mode, epochs = flow + if isinstance(mode, str): # self.train() + if not hasattr(self, mode): + raise ValueError( + f'runner has no method named "{mode}" to run an ' + 'epoch') + epoch_runner = getattr(self, mode) + else: + raise TypeError( + 'mode in workflow must be a str, but got {}'.format( + type(mode))) + + for _ in range(epochs): + if mode == 'train' and self.epoch >= self._max_epochs: + break + epoch_runner(data_loaders[i], **kwargs) + + time.sleep(1) # wait for some hooks like loggers to finish + self.call_hook('after_run') + + def save_checkpoint(self, + out_dir, + filename_tmpl='epoch_{}.pth', + save_optimizer=True, + meta=None, + create_symlink=True): + """Save the checkpoint. + + Args: + out_dir (str): The directory that checkpoints are saved. + filename_tmpl (str, optional): The checkpoint filename template, + which contains a placeholder for the epoch number. + Defaults to 'epoch_{}.pth'. + save_optimizer (bool, optional): Whether to save the optimizer to + the checkpoint. Defaults to True. + meta (dict, optional): The meta information to be saved in the + checkpoint. Defaults to None. + create_symlink (bool, optional): Whether to create a symlink + "latest.pth" to point to the latest checkpoint. + Defaults to True. + """ + if meta is None: + meta = {} + elif not isinstance(meta, dict): + raise TypeError( + f'meta should be a dict or None, but got {type(meta)}') + if self.meta is not None: + meta.update(self.meta) + # Note: meta.update(self.meta) should be done before + # meta.update(epoch=self.epoch + 1, iter=self.iter) otherwise + # there will be problems with resumed checkpoints. + # More details in https://github.com/open-mmlab/mmcv/pull/1108 + meta.update(epoch=self.epoch + 1, iter=self.iter) + + filename = filename_tmpl.format(self.epoch + 1) + filepath = osp.join(out_dir, filename) + optimizer = self.optimizer if save_optimizer else None + save_checkpoint(self.model, filepath, optimizer=optimizer, meta=meta) + # in some environments, `os.symlink` is not supported, you may need to + # set `create_symlink` to False + if create_symlink: + dst_file = osp.join(out_dir, 'latest.pth') + if platform.system() != 'Windows': + mmcv.symlink(filename, dst_file) + else: + shutil.copy(filepath, dst_file) + + +@RUNNERS.register_module() +class Runner(EpochBasedRunner): + """Deprecated name of EpochBasedRunner.""" + + def __init__(self, *args, **kwargs): + warnings.warn( + 'Runner was deprecated, please use EpochBasedRunner instead') + super().__init__(*args, **kwargs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/decorators.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/fp16_utils.py similarity index 33% rename from cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/decorators.py rename to cv/instance_segmentation/SOLO/pytorch/mmcv/runner/fp16_utils.py index 10ffbf898..4baab939a 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/decorators.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/fp16_utils.py @@ -1,9 +1,55 @@ +# Copyright (c) OpenMMLab. All rights reserved. import functools +import warnings +from collections import abc from inspect import getfullargspec +import numpy as np import torch +import torch.nn as nn -from .utils import cast_tensor_type +from mmcv.utils import TORCH_VERSION, digit_version +from .dist_utils import allreduce_grads as _allreduce_grads + +try: + # If PyTorch version >= 1.6.0, torch.cuda.amp.autocast would be imported + # and used; otherwise, auto fp16 will adopt mmcv's implementation. + # Note that when PyTorch >= 1.6.0, we still cast tensor types to fp16 + # manually, so the behavior may not be consistent with real amp. + from torch.cuda.amp import autocast +except ImportError: + pass + + +def cast_tensor_type(inputs, src_type, dst_type): + """Recursively convert Tensor in inputs from src_type to dst_type. + + Args: + inputs: Inputs that to be casted. + src_type (torch.dtype): Source type.. + dst_type (torch.dtype): Destination type. + + Returns: + The same type with inputs, but all contained Tensors have been cast. + """ + if isinstance(inputs, nn.Module): + return inputs + elif isinstance(inputs, torch.Tensor): + return inputs.to(dst_type) + elif isinstance(inputs, str): + return inputs + elif isinstance(inputs, np.ndarray): + return inputs + elif isinstance(inputs, abc.Mapping): + return type(inputs)({ + k: cast_tensor_type(v, src_type, dst_type) + for k, v in inputs.items() + }) + elif isinstance(inputs, abc.Iterable): + return type(inputs)( + cast_tensor_type(item, src_type, dst_type) for item in inputs) + else: + return inputs def auto_fp16(apply_to=None, out_fp32=False): @@ -12,28 +58,31 @@ def auto_fp16(apply_to=None, out_fp32=False): This decorator is useful when you write custom modules and want to support mixed precision training. If inputs arguments are fp32 tensors, they will be converted to fp16 automatically. Arguments other than fp32 tensors are - ignored. + ignored. If you are using PyTorch >= 1.6, torch.cuda.amp is used as the + backend, otherwise, original mmcv implementation will be adopted. Args: apply_to (Iterable, optional): The argument names to be converted. `None` indicates all arguments. out_fp32 (bool): Whether to convert the output back to fp32. - :Example: + Example: - class MyModule1(nn.Module) + >>> import torch.nn as nn + >>> class MyModule1(nn.Module): + >>> + >>> # Convert x and y to fp16 + >>> @auto_fp16() + >>> def forward(self, x, y): + >>> pass - # Convert x and y to fp16 - @auto_fp16() - def forward(self, x, y): - pass - - class MyModule2(nn.Module): - - # convert pred to fp16 - @auto_fp16(apply_to=('pred', )) - def do_something(self, pred, others): - pass + >>> import torch.nn as nn + >>> class MyModule2(nn.Module): + >>> + >>> # convert pred to fp16 + >>> @auto_fp16(apply_to=('pred', )) + >>> def do_something(self, pred, others): + >>> pass """ def auto_fp16_wrapper(old_func): @@ -47,6 +96,7 @@ def auto_fp16(apply_to=None, out_fp32=False): 'method of nn.Module') if not (hasattr(args[0], 'fp16_enabled') and args[0].fp16_enabled): return old_func(*args, **kwargs) + # get the arg spec of the decorated method args_info = getfullargspec(old_func) # get the argument names to be casted @@ -72,7 +122,12 @@ def auto_fp16(apply_to=None, out_fp32=False): else: new_kwargs[arg_name] = arg_value # apply converted arguments to the decorated method - output = old_func(*new_args, **new_kwargs) + if (TORCH_VERSION != 'parrots' and + digit_version(TORCH_VERSION) >= digit_version('1.6.0')): + with autocast(enabled=True): + output = old_func(*new_args, **new_kwargs) + else: + output = old_func(*new_args, **new_kwargs) # cast the results back to fp32 if necessary if out_fp32: output = cast_tensor_type(output, torch.half, torch.float) @@ -90,28 +145,32 @@ def force_fp32(apply_to=None, out_fp16=False): mixed precision training. If there are some inputs that must be processed in fp32 mode, then this decorator can handle it. If inputs arguments are fp16 tensors, they will be converted to fp32 automatically. Arguments other - than fp16 tensors are ignored. + than fp16 tensors are ignored. If you are using PyTorch >= 1.6, + torch.cuda.amp is used as the backend, otherwise, original mmcv + implementation will be adopted. Args: apply_to (Iterable, optional): The argument names to be converted. `None` indicates all arguments. out_fp16 (bool): Whether to convert the output back to fp16. - :Example: + Example: - class MyModule1(nn.Module) + >>> import torch.nn as nn + >>> class MyModule1(nn.Module): + >>> + >>> # Convert x and y to fp32 + >>> @force_fp32() + >>> def loss(self, x, y): + >>> pass - # Convert x and y to fp32 - @force_fp32() - def loss(self, x, y): - pass - - class MyModule2(nn.Module): - - # convert pred to fp32 - @force_fp32(apply_to=('pred', )) - def post_process(self, pred, others): - pass + >>> import torch.nn as nn + >>> class MyModule2(nn.Module): + >>> + >>> # convert pred to fp32 + >>> @force_fp32(apply_to=('pred', )) + >>> def post_process(self, pred, others): + >>> pass """ def force_fp32_wrapper(old_func): @@ -149,7 +208,12 @@ def force_fp32(apply_to=None, out_fp16=False): else: new_kwargs[arg_name] = arg_value # apply converted arguments to the decorated method - output = old_func(*new_args, **new_kwargs) + if (TORCH_VERSION != 'parrots' and + digit_version(TORCH_VERSION) >= digit_version('1.6.0')): + with autocast(enabled=False): + output = old_func(*new_args, **new_kwargs) + else: + output = old_func(*new_args, **new_kwargs) # cast the results back to fp32 if necessary if out_fp16: output = cast_tensor_type(output, torch.float, torch.half) @@ -158,3 +222,189 @@ def force_fp32(apply_to=None, out_fp16=False): return new_func return force_fp32_wrapper + + +def allreduce_grads(params, coalesce=True, bucket_size_mb=-1): + warnings.warning( + '"mmcv.runner.fp16_utils.allreduce_grads" is deprecated, and will be ' + 'removed in v2.8. Please switch to "mmcv.runner.allreduce_grads') + _allreduce_grads(params, coalesce=coalesce, bucket_size_mb=bucket_size_mb) + + +def wrap_fp16_model(model): + """Wrap the FP32 model to FP16. + + If you are using PyTorch >= 1.6, torch.cuda.amp is used as the + backend, otherwise, original mmcv implementation will be adopted. + + For PyTorch >= 1.6, this function will + 1. Set fp16 flag inside the model to True. + + Otherwise: + 1. Convert FP32 model to FP16. + 2. Remain some necessary layers to be FP32, e.g., normalization layers. + 3. Set `fp16_enabled` flag inside the model to True. + + Args: + model (nn.Module): Model in FP32. + """ + if (TORCH_VERSION == 'parrots' + or digit_version(TORCH_VERSION) < digit_version('1.6.0')): + # convert model to fp16 + model.half() + # patch the normalization layers to make it work in fp32 mode + patch_norm_fp32(model) + # set `fp16_enabled` flag + for m in model.modules(): + if hasattr(m, 'fp16_enabled'): + m.fp16_enabled = True + + +def patch_norm_fp32(module): + """Recursively convert normalization layers from FP16 to FP32. + + Args: + module (nn.Module): The modules to be converted in FP16. + + Returns: + nn.Module: The converted module, the normalization layers have been + converted to FP32. + """ + if isinstance(module, (nn.modules.batchnorm._BatchNorm, nn.GroupNorm)): + module.float() + if isinstance(module, nn.GroupNorm) or torch.__version__ < '1.3': + module.forward = patch_forward_method(module.forward, torch.half, + torch.float) + for child in module.children(): + patch_norm_fp32(child) + return module + + +def patch_forward_method(func, src_type, dst_type, convert_output=True): + """Patch the forward method of a module. + + Args: + func (callable): The original forward method. + src_type (torch.dtype): Type of input arguments to be converted from. + dst_type (torch.dtype): Type of input arguments to be converted to. + convert_output (bool): Whether to convert the output back to src_type. + + Returns: + callable: The patched forward method. + """ + + def new_forward(*args, **kwargs): + output = func(*cast_tensor_type(args, src_type, dst_type), + **cast_tensor_type(kwargs, src_type, dst_type)) + if convert_output: + output = cast_tensor_type(output, dst_type, src_type) + return output + + return new_forward + + +class LossScaler: + """Class that manages loss scaling in mixed precision training which + supports both dynamic or static mode. + + The implementation refers to + https://github.com/NVIDIA/apex/blob/master/apex/fp16_utils/loss_scaler.py. + Indirectly, by supplying ``mode='dynamic'`` for dynamic loss scaling. + It's important to understand how :class:`LossScaler` operates. + Loss scaling is designed to combat the problem of underflowing + gradients encountered at long times when training fp16 networks. + Dynamic loss scaling begins by attempting a very high loss + scale. Ironically, this may result in OVERflowing gradients. + If overflowing gradients are encountered, :class:`FP16_Optimizer` then + skips the update step for this particular iteration/minibatch, + and :class:`LossScaler` adjusts the loss scale to a lower value. + If a certain number of iterations occur without overflowing gradients + detected,:class:`LossScaler` increases the loss scale once more. + In this way :class:`LossScaler` attempts to "ride the edge" of always + using the highest loss scale possible without incurring overflow. + + Args: + init_scale (float): Initial loss scale value, default: 2**32. + scale_factor (float): Factor used when adjusting the loss scale. + Default: 2. + mode (str): Loss scaling mode. 'dynamic' or 'static' + scale_window (int): Number of consecutive iterations without an + overflow to wait before increasing the loss scale. Default: 1000. + """ + + def __init__(self, + init_scale=2**32, + mode='dynamic', + scale_factor=2., + scale_window=1000): + self.cur_scale = init_scale + self.cur_iter = 0 + assert mode in ('dynamic', + 'static'), 'mode can only be dynamic or static' + self.mode = mode + self.last_overflow_iter = -1 + self.scale_factor = scale_factor + self.scale_window = scale_window + + def has_overflow(self, params): + """Check if params contain overflow.""" + if self.mode != 'dynamic': + return False + for p in params: + if p.grad is not None and LossScaler._has_inf_or_nan(p.grad.data): + return True + return False + + def _has_inf_or_nan(x): + """Check if params contain NaN.""" + try: + cpu_sum = float(x.float().sum()) + except RuntimeError as instance: + if 'value cannot be converted' not in instance.args[0]: + raise + return True + else: + if cpu_sum == float('inf') or cpu_sum == -float('inf') \ + or cpu_sum != cpu_sum: + return True + return False + + def update_scale(self, overflow): + """update the current loss scale value when overflow happens.""" + if self.mode != 'dynamic': + return + if overflow: + self.cur_scale = max(self.cur_scale / self.scale_factor, 1) + self.last_overflow_iter = self.cur_iter + else: + if (self.cur_iter - self.last_overflow_iter) % \ + self.scale_window == 0: + self.cur_scale *= self.scale_factor + self.cur_iter += 1 + + def state_dict(self): + """Returns the state of the scaler as a :class:`dict`.""" + return dict( + cur_scale=self.cur_scale, + cur_iter=self.cur_iter, + mode=self.mode, + last_overflow_iter=self.last_overflow_iter, + scale_factor=self.scale_factor, + scale_window=self.scale_window) + + def load_state_dict(self, state_dict): + """Loads the loss_scaler state dict. + + Args: + state_dict (dict): scaler state. + """ + self.cur_scale = state_dict['cur_scale'] + self.cur_iter = state_dict['cur_iter'] + self.mode = state_dict['mode'] + self.last_overflow_iter = state_dict['last_overflow_iter'] + self.scale_factor = state_dict['scale_factor'] + self.scale_window = state_dict['scale_window'] + + @property + def loss_scale(self): + return self.cur_scale diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/__init__.py new file mode 100644 index 000000000..915af28ce --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/__init__.py @@ -0,0 +1,29 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .checkpoint import CheckpointHook +from .closure import ClosureHook +from .ema import EMAHook +from .evaluation import DistEvalHook, EvalHook +from .hook import HOOKS, Hook +from .iter_timer import IterTimerHook +from .logger import (DvcliveLoggerHook, LoggerHook, MlflowLoggerHook, + NeptuneLoggerHook, PaviLoggerHook, TensorboardLoggerHook, + TextLoggerHook, WandbLoggerHook) +from .lr_updater import LrUpdaterHook +from .memory import EmptyCacheHook +from .momentum_updater import MomentumUpdaterHook +from .optimizer import (Fp16OptimizerHook, GradientCumulativeFp16OptimizerHook, + GradientCumulativeOptimizerHook, OptimizerHook) +from .profiler import ProfilerHook +from .sampler_seed import DistSamplerSeedHook +from .sync_buffer import SyncBuffersHook + +__all__ = [ + 'HOOKS', 'Hook', 'CheckpointHook', 'ClosureHook', 'LrUpdaterHook', + 'OptimizerHook', 'Fp16OptimizerHook', 'IterTimerHook', + 'DistSamplerSeedHook', 'EmptyCacheHook', 'LoggerHook', 'MlflowLoggerHook', + 'PaviLoggerHook', 'TextLoggerHook', 'TensorboardLoggerHook', + 'NeptuneLoggerHook', 'WandbLoggerHook', 'DvcliveLoggerHook', + 'MomentumUpdaterHook', 'SyncBuffersHook', 'EMAHook', 'EvalHook', + 'DistEvalHook', 'ProfilerHook', 'GradientCumulativeOptimizerHook', + 'GradientCumulativeFp16OptimizerHook' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/checkpoint.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/checkpoint.py new file mode 100644 index 000000000..7bb75f402 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/checkpoint.py @@ -0,0 +1,167 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import os.path as osp +import warnings + +from mmcv.fileio import FileClient +from ..dist_utils import allreduce_params, master_only +from .hook import HOOKS, Hook + + +@HOOKS.register_module() +class CheckpointHook(Hook): + """Save checkpoints periodically. + + Args: + interval (int): The saving period. If ``by_epoch=True``, interval + indicates epochs, otherwise it indicates iterations. + Default: -1, which means "never". + by_epoch (bool): Saving checkpoints by epoch or by iteration. + Default: True. + save_optimizer (bool): Whether to save optimizer state_dict in the + checkpoint. It is usually used for resuming experiments. + Default: True. + out_dir (str, optional): The root directory to save checkpoints. If not + specified, ``runner.work_dir`` will be used by default. If + specified, the ``out_dir`` will be the concatenation of ``out_dir`` + and the last level directory of ``runner.work_dir``. + `Changed in version 1.3.16.` + max_keep_ckpts (int, optional): The maximum checkpoints to keep. + In some cases we want only the latest few checkpoints and would + like to delete old ones to save the disk space. + Default: -1, which means unlimited. + save_last (bool, optional): Whether to force the last checkpoint to be + saved regardless of interval. Default: True. + sync_buffer (bool, optional): Whether to synchronize buffers in + different gpus. Default: False. + file_client_args (dict, optional): Arguments to instantiate a + FileClient. See :class:`mmcv.fileio.FileClient` for details. + Default: None. + `New in version 1.3.16.` + + .. warning:: + Before v1.3.16, the ``out_dir`` argument indicates the path where the + checkpoint is stored. However, since v1.3.16, ``out_dir`` indicates the + root directory and the final path to save checkpoint is the + concatenation of ``out_dir`` and the last level directory of + ``runner.work_dir``. Suppose the value of ``out_dir`` is "/path/of/A" + and the value of ``runner.work_dir`` is "/path/of/B", then the final + path will be "/path/of/A/B". + """ + + def __init__(self, + interval=-1, + by_epoch=True, + save_optimizer=True, + out_dir=None, + max_keep_ckpts=-1, + save_last=True, + sync_buffer=False, + file_client_args=None, + **kwargs): + self.interval = interval + self.by_epoch = by_epoch + self.save_optimizer = save_optimizer + self.out_dir = out_dir + self.max_keep_ckpts = max_keep_ckpts + self.save_last = save_last + self.args = kwargs + self.sync_buffer = sync_buffer + self.file_client_args = file_client_args + + def before_run(self, runner): + if not self.out_dir: + self.out_dir = runner.work_dir + + self.file_client = FileClient.infer_client(self.file_client_args, + self.out_dir) + + # if `self.out_dir` is not equal to `runner.work_dir`, it means that + # `self.out_dir` is set so the final `self.out_dir` is the + # concatenation of `self.out_dir` and the last level directory of + # `runner.work_dir` + if self.out_dir != runner.work_dir: + basename = osp.basename(runner.work_dir.rstrip(osp.sep)) + self.out_dir = self.file_client.join_path(self.out_dir, basename) + + runner.logger.info((f'Checkpoints will be saved to {self.out_dir} by ' + f'{self.file_client.name}.')) + + # disable the create_symlink option because some file backends do not + # allow to create a symlink + if 'create_symlink' in self.args: + if self.args[ + 'create_symlink'] and not self.file_client.allow_symlink: + self.args['create_symlink'] = False + warnings.warn( + ('create_symlink is set as True by the user but is changed' + 'to be False because creating symbolic link is not ' + f'allowed in {self.file_client.name}')) + else: + self.args['create_symlink'] = self.file_client.allow_symlink + + def after_train_epoch(self, runner): + if not self.by_epoch: + return + + # save checkpoint for following cases: + # 1. every ``self.interval`` epochs + # 2. reach the last epoch of training + if self.every_n_epochs( + runner, self.interval) or (self.save_last + and self.is_last_epoch(runner)): + runner.logger.info( + f'Saving checkpoint at {runner.epoch + 1} epochs') + if self.sync_buffer: + allreduce_params(runner.model.buffers()) + self._save_checkpoint(runner) + + @master_only + def _save_checkpoint(self, runner): + """Save the current checkpoint and delete unwanted checkpoint.""" + runner.save_checkpoint( + self.out_dir, save_optimizer=self.save_optimizer, **self.args) + if runner.meta is not None: + if self.by_epoch: + cur_ckpt_filename = self.args.get( + 'filename_tmpl', 'epoch_{}.pth').format(runner.epoch + 1) + else: + cur_ckpt_filename = self.args.get( + 'filename_tmpl', 'iter_{}.pth').format(runner.iter + 1) + runner.meta.setdefault('hook_msgs', dict()) + runner.meta['hook_msgs']['last_ckpt'] = self.file_client.join_path( + self.out_dir, cur_ckpt_filename) + # remove other checkpoints + if self.max_keep_ckpts > 0: + if self.by_epoch: + name = 'epoch_{}.pth' + current_ckpt = runner.epoch + 1 + else: + name = 'iter_{}.pth' + current_ckpt = runner.iter + 1 + redundant_ckpts = range( + current_ckpt - self.max_keep_ckpts * self.interval, 0, + -self.interval) + filename_tmpl = self.args.get('filename_tmpl', name) + for _step in redundant_ckpts: + ckpt_path = self.file_client.join_path( + self.out_dir, filename_tmpl.format(_step)) + if self.file_client.isfile(ckpt_path): + self.file_client.remove(ckpt_path) + else: + break + + def after_train_iter(self, runner): + if self.by_epoch: + return + + # save checkpoint for following cases: + # 1. every ``self.interval`` iterations + # 2. reach the last iteration of training + if self.every_n_iters( + runner, self.interval) or (self.save_last + and self.is_last_iter(runner)): + runner.logger.info( + f'Saving checkpoint at {runner.iter + 1} iterations') + if self.sync_buffer: + allreduce_params(runner.model.buffers()) + self._save_checkpoint(runner) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/closure.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/closure.py new file mode 100644 index 000000000..b955f81f4 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/closure.py @@ -0,0 +1,11 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .hook import HOOKS, Hook + + +@HOOKS.register_module() +class ClosureHook(Hook): + + def __init__(self, fn_name, fn): + assert hasattr(self, fn_name) + assert callable(fn) + setattr(self, fn_name, fn) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/ema.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/ema.py new file mode 100644 index 000000000..15c7e6808 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/ema.py @@ -0,0 +1,89 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from ...parallel import is_module_wrapper +from ..hooks.hook import HOOKS, Hook + + +@HOOKS.register_module() +class EMAHook(Hook): + r"""Exponential Moving Average Hook. + + Use Exponential Moving Average on all parameters of model in training + process. All parameters have a ema backup, which update by the formula + as below. EMAHook takes priority over EvalHook and CheckpointSaverHook. + + .. math:: + + \text{Xema\_{t+1}} = (1 - \text{momentum}) \times + \text{Xema\_{t}} + \text{momentum} \times X_t + + Args: + momentum (float): The momentum used for updating ema parameter. + Defaults to 0.0002. + interval (int): Update ema parameter every interval iteration. + Defaults to 1. + warm_up (int): During first warm_up steps, we may use smaller momentum + to update ema parameters more slowly. Defaults to 100. + resume_from (str): The checkpoint path. Defaults to None. + """ + + def __init__(self, + momentum=0.0002, + interval=1, + warm_up=100, + resume_from=None): + assert isinstance(interval, int) and interval > 0 + self.warm_up = warm_up + self.interval = interval + assert momentum > 0 and momentum < 1 + self.momentum = momentum**interval + self.checkpoint = resume_from + + def before_run(self, runner): + """To resume model with it's ema parameters more friendly. + + Register ema parameter as ``named_buffer`` to model + """ + model = runner.model + if is_module_wrapper(model): + model = model.module + self.param_ema_buffer = {} + self.model_parameters = dict(model.named_parameters(recurse=True)) + for name, value in self.model_parameters.items(): + # "." is not allowed in module's buffer name + buffer_name = f"ema_{name.replace('.', '_')}" + self.param_ema_buffer[name] = buffer_name + model.register_buffer(buffer_name, value.data.clone()) + self.model_buffers = dict(model.named_buffers(recurse=True)) + if self.checkpoint is not None: + runner.resume(self.checkpoint) + + def after_train_iter(self, runner): + """Update ema parameter every self.interval iterations.""" + curr_step = runner.iter + # We warm up the momentum considering the instability at beginning + momentum = min(self.momentum, + (1 + curr_step) / (self.warm_up + curr_step)) + if curr_step % self.interval != 0: + return + for name, parameter in self.model_parameters.items(): + buffer_name = self.param_ema_buffer[name] + buffer_parameter = self.model_buffers[buffer_name] + buffer_parameter.mul_(1 - momentum).add_(momentum, parameter.data) + + def after_train_epoch(self, runner): + """We load parameter values from ema backup to model before the + EvalHook.""" + self._swap_ema_parameters() + + def before_train_epoch(self, runner): + """We recover model's parameter from ema backup after last epoch's + EvalHook.""" + self._swap_ema_parameters() + + def _swap_ema_parameters(self): + """Swap the parameter of model with parameter in ema_buffer.""" + for name, value in self.model_parameters.items(): + temp = value.data.clone() + ema_buffer = self.model_buffers[self.param_ema_buffer[name]] + value.data.copy_(ema_buffer.data) + ema_buffer.data.copy_(temp) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/evaluation.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/evaluation.py new file mode 100644 index 000000000..1eeb44650 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/evaluation.py @@ -0,0 +1,509 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import os.path as osp +import warnings +from math import inf + +import torch.distributed as dist +from torch.nn.modules.batchnorm import _BatchNorm +from torch.utils.data import DataLoader + +from mmcv.fileio import FileClient +from mmcv.utils import is_seq_of +from .hook import Hook +from .logger import LoggerHook + + +class EvalHook(Hook): + """Non-Distributed evaluation hook. + + This hook will regularly perform evaluation in a given interval when + performing in non-distributed environment. + + Args: + dataloader (DataLoader): A PyTorch dataloader, whose dataset has + implemented ``evaluate`` function. + start (int | None, optional): Evaluation starting epoch. It enables + evaluation before the training starts if ``start`` <= the resuming + epoch. If None, whether to evaluate is merely decided by + ``interval``. Default: None. + interval (int): Evaluation interval. Default: 1. + by_epoch (bool): Determine perform evaluation by epoch or by iteration. + If set to True, it will perform by epoch. Otherwise, by iteration. + Default: True. + save_best (str, optional): If a metric is specified, it would measure + the best checkpoint during evaluation. The information about best + checkpoint would be saved in ``runner.meta['hook_msgs']`` to keep + best score value and best checkpoint path, which will be also + loaded when resume checkpoint. Options are the evaluation metrics + on the test dataset. e.g., ``bbox_mAP``, ``segm_mAP`` for bbox + detection and instance segmentation. ``AR@100`` for proposal + recall. If ``save_best`` is ``auto``, the first key of the returned + ``OrderedDict`` result will be used. Default: None. + rule (str | None, optional): Comparison rule for best score. If set to + None, it will infer a reasonable rule. Keys such as 'acc', 'top' + .etc will be inferred by 'greater' rule. Keys contain 'loss' will + be inferred by 'less' rule. Options are 'greater', 'less', None. + Default: None. + test_fn (callable, optional): test a model with samples from a + dataloader, and return the test results. If ``None``, the default + test function ``mmcv.engine.single_gpu_test`` will be used. + (default: ``None``) + greater_keys (List[str] | None, optional): Metric keys that will be + inferred by 'greater' comparison rule. If ``None``, + _default_greater_keys will be used. (default: ``None``) + less_keys (List[str] | None, optional): Metric keys that will be + inferred by 'less' comparison rule. If ``None``, _default_less_keys + will be used. (default: ``None``) + out_dir (str, optional): The root directory to save checkpoints. If not + specified, `runner.work_dir` will be used by default. If specified, + the `out_dir` will be the concatenation of `out_dir` and the last + level directory of `runner.work_dir`. + `New in version 1.3.16.` + file_client_args (dict): Arguments to instantiate a FileClient. + See :class:`mmcv.fileio.FileClient` for details. Default: None. + `New in version 1.3.16.` + **eval_kwargs: Evaluation arguments fed into the evaluate function of + the dataset. + + Notes: + If new arguments are added for EvalHook, tools/test.py, + tools/eval_metric.py may be affected. + """ + + # Since the key for determine greater or less is related to the downstream + # tasks, downstream repos may need to overwrite the following inner + # variable accordingly. + + rule_map = {'greater': lambda x, y: x > y, 'less': lambda x, y: x < y} + init_value_map = {'greater': -inf, 'less': inf} + _default_greater_keys = [ + 'acc', 'top', 'AR@', 'auc', 'precision', 'mAP', 'mDice', 'mIoU', + 'mAcc', 'aAcc' + ] + _default_less_keys = ['loss'] + + def __init__(self, + dataloader, + start=None, + interval=1, + by_epoch=True, + save_best=None, + rule=None, + test_fn=None, + greater_keys=None, + less_keys=None, + out_dir=None, + file_client_args=None, + **eval_kwargs): + if not isinstance(dataloader, DataLoader): + raise TypeError(f'dataloader must be a pytorch DataLoader, ' + f'but got {type(dataloader)}') + + if interval <= 0: + raise ValueError(f'interval must be a positive number, ' + f'but got {interval}') + + assert isinstance(by_epoch, bool), '``by_epoch`` should be a boolean' + + if start is not None and start < 0: + raise ValueError(f'The evaluation start epoch {start} is smaller ' + f'than 0') + + self.dataloader = dataloader + self.interval = interval + self.start = start + self.by_epoch = by_epoch + + assert isinstance(save_best, str) or save_best is None, \ + '""save_best"" should be a str or None ' \ + f'rather than {type(save_best)}' + self.save_best = save_best + self.eval_kwargs = eval_kwargs + self.initial_flag = True + + if test_fn is None: + from mmcv.engine import single_gpu_test + self.test_fn = single_gpu_test + else: + self.test_fn = test_fn + + if greater_keys is None: + self.greater_keys = self._default_greater_keys + else: + if not isinstance(greater_keys, (list, tuple)): + greater_keys = (greater_keys, ) + assert is_seq_of(greater_keys, str) + self.greater_keys = greater_keys + + if less_keys is None: + self.less_keys = self._default_less_keys + else: + if not isinstance(less_keys, (list, tuple)): + less_keys = (less_keys, ) + assert is_seq_of(less_keys, str) + self.less_keys = less_keys + + if self.save_best is not None: + self.best_ckpt_path = None + self._init_rule(rule, self.save_best) + + self.out_dir = out_dir + self.file_client_args = file_client_args + + def _init_rule(self, rule, key_indicator): + """Initialize rule, key_indicator, comparison_func, and best score. + + Here is the rule to determine which rule is used for key indicator + when the rule is not specific (note that the key indicator matching + is case-insensitive): + 1. If the key indicator is in ``self.greater_keys``, the rule will be + specified as 'greater'. + 2. Or if the key indicator is in ``self.less_keys``, the rule will be + specified as 'less'. + 3. Or if the key indicator is equal to the substring in any one item + in ``self.greater_keys``, the rule will be specified as 'greater'. + 4. Or if the key indicator is equal to the substring in any one item + in ``self.less_keys``, the rule will be specified as 'less'. + + Args: + rule (str | None): Comparison rule for best score. + key_indicator (str | None): Key indicator to determine the + comparison rule. + """ + if rule not in self.rule_map and rule is not None: + raise KeyError(f'rule must be greater, less or None, ' + f'but got {rule}.') + + if rule is None: + if key_indicator != 'auto': + # `_lc` here means we use the lower case of keys for + # case-insensitive matching + key_indicator_lc = key_indicator.lower() + greater_keys = [key.lower() for key in self.greater_keys] + less_keys = [key.lower() for key in self.less_keys] + + if key_indicator_lc in greater_keys: + rule = 'greater' + elif key_indicator_lc in less_keys: + rule = 'less' + elif any(key in key_indicator_lc for key in greater_keys): + rule = 'greater' + elif any(key in key_indicator_lc for key in less_keys): + rule = 'less' + else: + raise ValueError(f'Cannot infer the rule for key ' + f'{key_indicator}, thus a specific rule ' + f'must be specified.') + self.rule = rule + self.key_indicator = key_indicator + if self.rule is not None: + self.compare_func = self.rule_map[self.rule] + + def before_run(self, runner): + if not self.out_dir: + self.out_dir = runner.work_dir + + self.file_client = FileClient.infer_client(self.file_client_args, + self.out_dir) + + # if `self.out_dir` is not equal to `runner.work_dir`, it means that + # `self.out_dir` is set so the final `self.out_dir` is the + # concatenation of `self.out_dir` and the last level directory of + # `runner.work_dir` + if self.out_dir != runner.work_dir: + basename = osp.basename(runner.work_dir.rstrip(osp.sep)) + self.out_dir = self.file_client.join_path(self.out_dir, basename) + runner.logger.info( + (f'The best checkpoint will be saved to {self.out_dir} by ' + f'{self.file_client.name}')) + + if self.save_best is not None: + if runner.meta is None: + warnings.warn('runner.meta is None. Creating an empty one.') + runner.meta = dict() + runner.meta.setdefault('hook_msgs', dict()) + self.best_ckpt_path = runner.meta['hook_msgs'].get( + 'best_ckpt', None) + + def before_train_iter(self, runner): + """Evaluate the model only at the start of training by iteration.""" + if self.by_epoch or not self.initial_flag: + return + if self.start is not None and runner.iter >= self.start: + self.after_train_iter(runner) + self.initial_flag = False + + def before_train_epoch(self, runner): + """Evaluate the model only at the start of training by epoch.""" + if not (self.by_epoch and self.initial_flag): + return + if self.start is not None and runner.epoch >= self.start: + self.after_train_epoch(runner) + self.initial_flag = False + + def after_train_iter(self, runner): + """Called after every training iter to evaluate the results.""" + if not self.by_epoch and self._should_evaluate(runner): + # Because the priority of EvalHook is higher than LoggerHook, the + # training log and the evaluating log are mixed. Therefore, + # we need to dump the training log and clear it before evaluating + # log is generated. In addition, this problem will only appear in + # `IterBasedRunner` whose `self.by_epoch` is False, because + # `EpochBasedRunner` whose `self.by_epoch` is True calls + # `_do_evaluate` in `after_train_epoch` stage, and at this stage + # the training log has been printed, so it will not cause any + # problem. more details at + # https://github.com/open-mmlab/mmsegmentation/issues/694 + for hook in runner._hooks: + if isinstance(hook, LoggerHook): + hook.after_train_iter(runner) + runner.log_buffer.clear() + + self._do_evaluate(runner) + + def after_train_epoch(self, runner): + """Called after every training epoch to evaluate the results.""" + if self.by_epoch and self._should_evaluate(runner): + self._do_evaluate(runner) + + def _do_evaluate(self, runner): + """perform evaluation and save ckpt.""" + results = self.test_fn(runner.model, self.dataloader) + runner.log_buffer.output['eval_iter_num'] = len(self.dataloader) + key_score = self.evaluate(runner, results) + # the key_score may be `None` so it needs to skip the action to save + # the best checkpoint + if self.save_best and key_score: + self._save_ckpt(runner, key_score) + + def _should_evaluate(self, runner): + """Judge whether to perform evaluation. + + Here is the rule to judge whether to perform evaluation: + 1. It will not perform evaluation during the epoch/iteration interval, + which is determined by ``self.interval``. + 2. It will not perform evaluation if the start time is larger than + current time. + 3. It will not perform evaluation when current time is larger than + the start time but during epoch/iteration interval. + + Returns: + bool: The flag indicating whether to perform evaluation. + """ + if self.by_epoch: + current = runner.epoch + check_time = self.every_n_epochs + else: + current = runner.iter + check_time = self.every_n_iters + + if self.start is None: + if not check_time(runner, self.interval): + # No evaluation during the interval. + return False + elif (current + 1) < self.start: + # No evaluation if start is larger than the current time. + return False + else: + # Evaluation only at epochs/iters 3, 5, 7... + # if start==3 and interval==2 + if (current + 1 - self.start) % self.interval: + return False + return True + + def _save_ckpt(self, runner, key_score): + """Save the best checkpoint. + + It will compare the score according to the compare function, write + related information (best score, best checkpoint path) and save the + best checkpoint into ``work_dir``. + """ + if self.by_epoch: + current = f'epoch_{runner.epoch + 1}' + cur_type, cur_time = 'epoch', runner.epoch + 1 + else: + current = f'iter_{runner.iter + 1}' + cur_type, cur_time = 'iter', runner.iter + 1 + + best_score = runner.meta['hook_msgs'].get( + 'best_score', self.init_value_map[self.rule]) + if self.compare_func(key_score, best_score): + best_score = key_score + runner.meta['hook_msgs']['best_score'] = best_score + + if self.best_ckpt_path and self.file_client.isfile( + self.best_ckpt_path): + self.file_client.remove(self.best_ckpt_path) + runner.logger.info( + (f'The previous best checkpoint {self.best_ckpt_path} was ' + 'removed')) + + best_ckpt_name = f'best_{self.key_indicator}_{current}.pth' + self.best_ckpt_path = self.file_client.join_path( + self.out_dir, best_ckpt_name) + runner.meta['hook_msgs']['best_ckpt'] = self.best_ckpt_path + + runner.save_checkpoint( + self.out_dir, best_ckpt_name, create_symlink=False) + runner.logger.info( + f'Now best checkpoint is saved as {best_ckpt_name}.') + runner.logger.info( + f'Best {self.key_indicator} is {best_score:0.4f} ' + f'at {cur_time} {cur_type}.') + + def evaluate(self, runner, results): + """Evaluate the results. + + Args: + runner (:obj:`mmcv.Runner`): The underlined training runner. + results (list): Output results. + """ + eval_res = self.dataloader.dataset.evaluate( + results, logger=runner.logger, **self.eval_kwargs) + + for name, val in eval_res.items(): + runner.log_buffer.output[name] = val + runner.log_buffer.ready = True + + if self.save_best is not None: + # If the performance of model is pool, the `eval_res` may be an + # empty dict and it will raise exception when `self.save_best` is + # not None. More details at + # https://github.com/open-mmlab/mmdetection/issues/6265. + if not eval_res: + warnings.warn( + 'Since `eval_res` is an empty dict, the behavior to save ' + 'the best checkpoint will be skipped in this evaluation.') + return None + + if self.key_indicator == 'auto': + # infer from eval_results + self._init_rule(self.rule, list(eval_res.keys())[0]) + return eval_res[self.key_indicator] + + return None + + +class DistEvalHook(EvalHook): + """Distributed evaluation hook. + + This hook will regularly perform evaluation in a given interval when + performing in distributed environment. + + Args: + dataloader (DataLoader): A PyTorch dataloader, whose dataset has + implemented ``evaluate`` function. + start (int | None, optional): Evaluation starting epoch. It enables + evaluation before the training starts if ``start`` <= the resuming + epoch. If None, whether to evaluate is merely decided by + ``interval``. Default: None. + interval (int): Evaluation interval. Default: 1. + by_epoch (bool): Determine perform evaluation by epoch or by iteration. + If set to True, it will perform by epoch. Otherwise, by iteration. + default: True. + save_best (str, optional): If a metric is specified, it would measure + the best checkpoint during evaluation. The information about best + checkpoint would be saved in ``runner.meta['hook_msgs']`` to keep + best score value and best checkpoint path, which will be also + loaded when resume checkpoint. Options are the evaluation metrics + on the test dataset. e.g., ``bbox_mAP``, ``segm_mAP`` for bbox + detection and instance segmentation. ``AR@100`` for proposal + recall. If ``save_best`` is ``auto``, the first key of the returned + ``OrderedDict`` result will be used. Default: None. + rule (str | None, optional): Comparison rule for best score. If set to + None, it will infer a reasonable rule. Keys such as 'acc', 'top' + .etc will be inferred by 'greater' rule. Keys contain 'loss' will + be inferred by 'less' rule. Options are 'greater', 'less', None. + Default: None. + test_fn (callable, optional): test a model with samples from a + dataloader in a multi-gpu manner, and return the test results. If + ``None``, the default test function ``mmcv.engine.multi_gpu_test`` + will be used. (default: ``None``) + tmpdir (str | None): Temporary directory to save the results of all + processes. Default: None. + gpu_collect (bool): Whether to use gpu or cpu to collect results. + Default: False. + broadcast_bn_buffer (bool): Whether to broadcast the + buffer(running_mean and running_var) of rank 0 to other rank + before evaluation. Default: True. + out_dir (str, optional): The root directory to save checkpoints. If not + specified, `runner.work_dir` will be used by default. If specified, + the `out_dir` will be the concatenation of `out_dir` and the last + level directory of `runner.work_dir`. + file_client_args (dict): Arguments to instantiate a FileClient. + See :class:`mmcv.fileio.FileClient` for details. Default: None. + **eval_kwargs: Evaluation arguments fed into the evaluate function of + the dataset. + """ + + def __init__(self, + dataloader, + start=None, + interval=1, + by_epoch=True, + save_best=None, + rule=None, + test_fn=None, + greater_keys=None, + less_keys=None, + broadcast_bn_buffer=True, + tmpdir=None, + gpu_collect=False, + out_dir=None, + file_client_args=None, + **eval_kwargs): + + if test_fn is None: + from mmcv.engine import multi_gpu_test + test_fn = multi_gpu_test + + super().__init__( + dataloader, + start=start, + interval=interval, + by_epoch=by_epoch, + save_best=save_best, + rule=rule, + test_fn=test_fn, + greater_keys=greater_keys, + less_keys=less_keys, + out_dir=out_dir, + file_client_args=file_client_args, + **eval_kwargs) + + self.broadcast_bn_buffer = broadcast_bn_buffer + self.tmpdir = tmpdir + self.gpu_collect = gpu_collect + + def _do_evaluate(self, runner): + """perform evaluation and save ckpt.""" + # Synchronization of BatchNorm's buffer (running_mean + # and running_var) is not supported in the DDP of pytorch, + # which may cause the inconsistent performance of models in + # different ranks, so we broadcast BatchNorm's buffers + # of rank 0 to other ranks to avoid this. + if self.broadcast_bn_buffer: + model = runner.model + for name, module in model.named_modules(): + if isinstance(module, + _BatchNorm) and module.track_running_stats: + dist.broadcast(module.running_var, 0) + dist.broadcast(module.running_mean, 0) + + tmpdir = self.tmpdir + if tmpdir is None: + tmpdir = osp.join(runner.work_dir, '.eval_hook') + + results = self.test_fn( + runner.model, + self.dataloader, + tmpdir=tmpdir, + gpu_collect=self.gpu_collect) + if runner.rank == 0: + print('\n') + runner.log_buffer.output['eval_iter_num'] = len(self.dataloader) + key_score = self.evaluate(runner, results) + # the key_score may be `None` so it needs to skip the action to + # save the best checkpoint + if self.save_best and key_score: + self._save_ckpt(runner, key_score) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/hook.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/hook.py new file mode 100644 index 000000000..f2d1c9865 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/hook.py @@ -0,0 +1,92 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from mmcv.utils import Registry, is_method_overridden + +HOOKS = Registry('hook') + + +class Hook: + stages = ('before_run', 'before_train_epoch', 'before_train_iter', + 'after_train_iter', 'after_train_epoch', 'before_val_epoch', + 'before_val_iter', 'after_val_iter', 'after_val_epoch', + 'after_run') + + def before_run(self, runner): + pass + + def after_run(self, runner): + pass + + def before_epoch(self, runner): + pass + + def after_epoch(self, runner): + pass + + def before_iter(self, runner): + pass + + def after_iter(self, runner): + pass + + def before_train_epoch(self, runner): + self.before_epoch(runner) + + def before_val_epoch(self, runner): + self.before_epoch(runner) + + def after_train_epoch(self, runner): + self.after_epoch(runner) + + def after_val_epoch(self, runner): + self.after_epoch(runner) + + def before_train_iter(self, runner): + self.before_iter(runner) + + def before_val_iter(self, runner): + self.before_iter(runner) + + def after_train_iter(self, runner): + self.after_iter(runner) + + def after_val_iter(self, runner): + self.after_iter(runner) + + def every_n_epochs(self, runner, n): + return (runner.epoch + 1) % n == 0 if n > 0 else False + + def every_n_inner_iters(self, runner, n): + return (runner.inner_iter + 1) % n == 0 if n > 0 else False + + def every_n_iters(self, runner, n): + return (runner.iter + 1) % n == 0 if n > 0 else False + + def end_of_epoch(self, runner): + return runner.inner_iter + 1 == len(runner.data_loader) + + def is_last_epoch(self, runner): + return runner.epoch + 1 == runner._max_epochs + + def is_last_iter(self, runner): + return runner.iter + 1 == runner._max_iters + + def get_triggered_stages(self): + trigger_stages = set() + for stage in Hook.stages: + if is_method_overridden(stage, Hook, self): + trigger_stages.add(stage) + + # some methods will be triggered in multi stages + # use this dict to map method to stages. + method_stages_map = { + 'before_epoch': ['before_train_epoch', 'before_val_epoch'], + 'after_epoch': ['after_train_epoch', 'after_val_epoch'], + 'before_iter': ['before_train_iter', 'before_val_iter'], + 'after_iter': ['after_train_iter', 'after_val_iter'], + } + + for method, map_stages in method_stages_map.items(): + if is_method_overridden(method, Hook, self): + trigger_stages.update(map_stages) + + return [stage for stage in Hook.stages if stage in trigger_stages] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/iter_timer.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/iter_timer.py new file mode 100644 index 000000000..cfd5002fe --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/iter_timer.py @@ -0,0 +1,18 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import time + +from .hook import HOOKS, Hook + + +@HOOKS.register_module() +class IterTimerHook(Hook): + + def before_epoch(self, runner): + self.t = time.time() + + def before_iter(self, runner): + runner.log_buffer.update({'data_time': time.time() - self.t}) + + def after_iter(self, runner): + runner.log_buffer.update({'time': time.time() - self.t}) + self.t = time.time() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/__init__.py new file mode 100644 index 000000000..a0b6b3456 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/__init__.py @@ -0,0 +1,15 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .base import LoggerHook +from .dvclive import DvcliveLoggerHook +from .mlflow import MlflowLoggerHook +from .neptune import NeptuneLoggerHook +from .pavi import PaviLoggerHook +from .tensorboard import TensorboardLoggerHook +from .text import TextLoggerHook +from .wandb import WandbLoggerHook + +__all__ = [ + 'LoggerHook', 'MlflowLoggerHook', 'PaviLoggerHook', + 'TensorboardLoggerHook', 'TextLoggerHook', 'WandbLoggerHook', + 'NeptuneLoggerHook', 'DvcliveLoggerHook' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/base.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/base.py new file mode 100644 index 000000000..f84525672 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/base.py @@ -0,0 +1,166 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import numbers +from abc import ABCMeta, abstractmethod + +import numpy as np +import torch + +from ..hook import Hook + + +class LoggerHook(Hook): + """Base class for logger hooks. + + Args: + interval (int): Logging interval (every k iterations). + ignore_last (bool): Ignore the log of last iterations in each epoch + if less than `interval`. + reset_flag (bool): Whether to clear the output buffer after logging. + by_epoch (bool): Whether EpochBasedRunner is used. + """ + + __metaclass__ = ABCMeta + + def __init__(self, + interval=10, + ignore_last=True, + reset_flag=False, + by_epoch=True): + self.interval = interval + self.ignore_last = ignore_last + self.reset_flag = reset_flag + self.by_epoch = by_epoch + + @abstractmethod + def log(self, runner): + pass + + @staticmethod + def is_scalar(val, include_np=True, include_torch=True): + """Tell the input variable is a scalar or not. + + Args: + val: Input variable. + include_np (bool): Whether include 0-d np.ndarray as a scalar. + include_torch (bool): Whether include 0-d torch.Tensor as a scalar. + + Returns: + bool: True or False. + """ + if isinstance(val, numbers.Number): + return True + elif include_np and isinstance(val, np.ndarray) and val.ndim == 0: + return True + elif include_torch and isinstance(val, torch.Tensor) and len(val) == 1: + return True + else: + return False + + def get_mode(self, runner): + if runner.mode == 'train': + if 'time' in runner.log_buffer.output: + mode = 'train' + else: + mode = 'val' + elif runner.mode == 'val': + mode = 'val' + else: + raise ValueError(f"runner mode should be 'train' or 'val', " + f'but got {runner.mode}') + return mode + + def get_epoch(self, runner): + if runner.mode == 'train': + epoch = runner.epoch + 1 + elif runner.mode == 'val': + # normal val mode + # runner.epoch += 1 has been done before val workflow + epoch = runner.epoch + else: + raise ValueError(f"runner mode should be 'train' or 'val', " + f'but got {runner.mode}') + return epoch + + def get_iter(self, runner, inner_iter=False): + """Get the current training iteration step.""" + if self.by_epoch and inner_iter: + current_iter = runner.inner_iter + 1 + else: + current_iter = runner.iter + 1 + return current_iter + + def get_lr_tags(self, runner): + tags = {} + lrs = runner.current_lr() + if isinstance(lrs, dict): + for name, value in lrs.items(): + tags[f'learning_rate/{name}'] = value[0] + else: + tags['learning_rate'] = lrs[0] + return tags + + def get_momentum_tags(self, runner): + tags = {} + momentums = runner.current_momentum() + if isinstance(momentums, dict): + for name, value in momentums.items(): + tags[f'momentum/{name}'] = value[0] + else: + tags['momentum'] = momentums[0] + return tags + + def get_loggable_tags(self, + runner, + allow_scalar=True, + allow_text=False, + add_mode=True, + tags_to_skip=('time', 'data_time')): + tags = {} + for var, val in runner.log_buffer.output.items(): + if var in tags_to_skip: + continue + if self.is_scalar(val) and not allow_scalar: + continue + if isinstance(val, str) and not allow_text: + continue + if add_mode: + var = f'{self.get_mode(runner)}/{var}' + tags[var] = val + tags.update(self.get_lr_tags(runner)) + tags.update(self.get_momentum_tags(runner)) + return tags + + def before_run(self, runner): + for hook in runner.hooks[::-1]: + if isinstance(hook, LoggerHook): + hook.reset_flag = True + break + + def before_epoch(self, runner): + runner.log_buffer.clear() # clear logs of last epoch + + def after_train_iter(self, runner): + if self.by_epoch and self.every_n_inner_iters(runner, self.interval): + runner.log_buffer.average(self.interval) + elif not self.by_epoch and self.every_n_iters(runner, self.interval): + runner.log_buffer.average(self.interval) + elif self.end_of_epoch(runner) and not self.ignore_last: + # not precise but more stable + runner.log_buffer.average(self.interval) + + if runner.log_buffer.ready: + self.log(runner) + if self.reset_flag: + runner.log_buffer.clear_output() + + def after_train_epoch(self, runner): + if runner.log_buffer.ready: + self.log(runner) + if self.reset_flag: + runner.log_buffer.clear_output() + + def after_val_epoch(self, runner): + runner.log_buffer.average() + self.log(runner) + if self.reset_flag: + runner.log_buffer.clear_output() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/dvclive.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/dvclive.py new file mode 100644 index 000000000..687cdc58c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/dvclive.py @@ -0,0 +1,58 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from ...dist_utils import master_only +from ..hook import HOOKS +from .base import LoggerHook + + +@HOOKS.register_module() +class DvcliveLoggerHook(LoggerHook): + """Class to log metrics with dvclive. + + It requires `dvclive`_ to be installed. + + Args: + path (str): Directory where dvclive will write TSV log files. + interval (int): Logging interval (every k iterations). + Default 10. + ignore_last (bool): Ignore the log of last iterations in each epoch + if less than `interval`. + Default: True. + reset_flag (bool): Whether to clear the output buffer after logging. + Default: True. + by_epoch (bool): Whether EpochBasedRunner is used. + Default: True. + + .. _dvclive: + https://dvc.org/doc/dvclive + """ + + def __init__(self, + path, + interval=10, + ignore_last=True, + reset_flag=True, + by_epoch=True): + + super(DvcliveLoggerHook, self).__init__(interval, ignore_last, + reset_flag, by_epoch) + self.path = path + self.import_dvclive() + + def import_dvclive(self): + try: + import dvclive + except ImportError: + raise ImportError( + 'Please run "pip install dvclive" to install dvclive') + self.dvclive = dvclive + + @master_only + def before_run(self, runner): + self.dvclive.init(self.path) + + @master_only + def log(self, runner): + tags = self.get_loggable_tags(runner) + if tags: + for k, v in tags.items(): + self.dvclive.log(k, v, step=self.get_iter(runner)) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/mlflow.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/mlflow.py new file mode 100644 index 000000000..f9a72592b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/mlflow.py @@ -0,0 +1,78 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from ...dist_utils import master_only +from ..hook import HOOKS +from .base import LoggerHook + + +@HOOKS.register_module() +class MlflowLoggerHook(LoggerHook): + + def __init__(self, + exp_name=None, + tags=None, + log_model=True, + interval=10, + ignore_last=True, + reset_flag=False, + by_epoch=True): + """Class to log metrics and (optionally) a trained model to MLflow. + + It requires `MLflow`_ to be installed. + + Args: + exp_name (str, optional): Name of the experiment to be used. + Default None. + If not None, set the active experiment. + If experiment does not exist, an experiment with provided name + will be created. + tags (dict of str: str, optional): Tags for the current run. + Default None. + If not None, set tags for the current run. + log_model (bool, optional): Whether to log an MLflow artifact. + Default True. + If True, log runner.model as an MLflow artifact + for the current run. + interval (int): Logging interval (every k iterations). + ignore_last (bool): Ignore the log of last iterations in each epoch + if less than `interval`. + reset_flag (bool): Whether to clear the output buffer after logging + by_epoch (bool): Whether EpochBasedRunner is used. + + .. _MLflow: + https://www.mlflow.org/docs/latest/index.html + """ + super(MlflowLoggerHook, self).__init__(interval, ignore_last, + reset_flag, by_epoch) + self.import_mlflow() + self.exp_name = exp_name + self.tags = tags + self.log_model = log_model + + def import_mlflow(self): + try: + import mlflow + import mlflow.pytorch as mlflow_pytorch + except ImportError: + raise ImportError( + 'Please run "pip install mlflow" to install mlflow') + self.mlflow = mlflow + self.mlflow_pytorch = mlflow_pytorch + + @master_only + def before_run(self, runner): + super(MlflowLoggerHook, self).before_run(runner) + if self.exp_name is not None: + self.mlflow.set_experiment(self.exp_name) + if self.tags is not None: + self.mlflow.set_tags(self.tags) + + @master_only + def log(self, runner): + tags = self.get_loggable_tags(runner) + if tags: + self.mlflow.log_metrics(tags, step=self.get_iter(runner)) + + @master_only + def after_run(self, runner): + if self.log_model: + self.mlflow_pytorch.log_model(runner.model, 'models') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/neptune.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/neptune.py new file mode 100644 index 000000000..7a38772b0 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/neptune.py @@ -0,0 +1,82 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from ...dist_utils import master_only +from ..hook import HOOKS +from .base import LoggerHook + + +@HOOKS.register_module() +class NeptuneLoggerHook(LoggerHook): + """Class to log metrics to NeptuneAI. + + It requires `neptune-client` to be installed. + + Args: + init_kwargs (dict): a dict contains the initialization keys as below: + - project (str): Name of a project in a form of + namespace/project_name. If None, the value of + NEPTUNE_PROJECT environment variable will be taken. + - api_token (str): User’s API token. + If None, the value of NEPTUNE_API_TOKEN environment + variable will be taken. Note: It is strongly recommended + to use NEPTUNE_API_TOKEN environment variable rather than + placing your API token in plain text in your source code. + - name (str, optional, default is 'Untitled'): Editable name of + the run. Name is displayed in the run's Details and in + Runs table as a column. + Check https://docs.neptune.ai/api-reference/neptune#init for + more init arguments. + interval (int): Logging interval (every k iterations). + ignore_last (bool): Ignore the log of last iterations in each epoch + if less than `interval`. + reset_flag (bool): Whether to clear the output buffer after logging + by_epoch (bool): Whether EpochBasedRunner is used. + + .. _NeptuneAI: + https://docs.neptune.ai/you-should-know/logging-metadata + """ + + def __init__(self, + init_kwargs=None, + interval=10, + ignore_last=True, + reset_flag=True, + with_step=True, + by_epoch=True): + + super(NeptuneLoggerHook, self).__init__(interval, ignore_last, + reset_flag, by_epoch) + self.import_neptune() + self.init_kwargs = init_kwargs + self.with_step = with_step + + def import_neptune(self): + try: + import neptune.new as neptune + except ImportError: + raise ImportError( + 'Please run "pip install neptune-client" to install neptune') + self.neptune = neptune + self.run = None + + @master_only + def before_run(self, runner): + if self.init_kwargs: + self.run = self.neptune.init(**self.init_kwargs) + else: + self.run = self.neptune.init() + + @master_only + def log(self, runner): + tags = self.get_loggable_tags(runner) + if tags: + for tag_name, tag_value in tags.items(): + if self.with_step: + self.run[tag_name].log( + tag_value, step=self.get_iter(runner)) + else: + tags['global_step'] = self.get_iter(runner) + self.run[tag_name].log(tags) + + @master_only + def after_run(self, runner): + self.run.stop() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/pavi.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/pavi.py new file mode 100644 index 000000000..ba2f6e8df --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/pavi.py @@ -0,0 +1,117 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import json +import os +import os.path as osp + +import torch +import yaml + +import mmcv +from ....parallel.utils import is_module_wrapper +from ...dist_utils import master_only +from ..hook import HOOKS +from .base import LoggerHook + + +@HOOKS.register_module() +class PaviLoggerHook(LoggerHook): + + def __init__(self, + init_kwargs=None, + add_graph=False, + add_last_ckpt=False, + interval=10, + ignore_last=True, + reset_flag=False, + by_epoch=True, + img_key='img_info'): + super(PaviLoggerHook, self).__init__(interval, ignore_last, reset_flag, + by_epoch) + self.init_kwargs = init_kwargs + self.add_graph = add_graph + self.add_last_ckpt = add_last_ckpt + self.img_key = img_key + + @master_only + def before_run(self, runner): + super(PaviLoggerHook, self).before_run(runner) + try: + from pavi import SummaryWriter + except ImportError: + raise ImportError('Please run "pip install pavi" to install pavi.') + + self.run_name = runner.work_dir.split('/')[-1] + + if not self.init_kwargs: + self.init_kwargs = dict() + self.init_kwargs['name'] = self.run_name + self.init_kwargs['model'] = runner._model_name + if runner.meta is not None: + if 'config_dict' in runner.meta: + config_dict = runner.meta['config_dict'] + assert isinstance( + config_dict, + dict), ('meta["config_dict"] has to be of a dict, ' + f'but got {type(config_dict)}') + elif 'config_file' in runner.meta: + config_file = runner.meta['config_file'] + config_dict = dict(mmcv.Config.fromfile(config_file)) + else: + config_dict = None + if config_dict is not None: + # 'max_.*iter' is parsed in pavi sdk as the maximum iterations + # to properly set up the progress bar. + config_dict = config_dict.copy() + config_dict.setdefault('max_iter', runner.max_iters) + # non-serializable values are first converted in + # mmcv.dump to json + config_dict = json.loads( + mmcv.dump(config_dict, file_format='json')) + session_text = yaml.dump(config_dict) + self.init_kwargs['session_text'] = session_text + self.writer = SummaryWriter(**self.init_kwargs) + + def get_step(self, runner): + """Get the total training step/epoch.""" + if self.get_mode(runner) == 'val' and self.by_epoch: + return self.get_epoch(runner) + else: + return self.get_iter(runner) + + @master_only + def log(self, runner): + tags = self.get_loggable_tags(runner, add_mode=False) + if tags: + self.writer.add_scalars( + self.get_mode(runner), tags, self.get_step(runner)) + + @master_only + def after_run(self, runner): + if self.add_last_ckpt: + ckpt_path = osp.join(runner.work_dir, 'latest.pth') + if osp.islink(ckpt_path): + ckpt_path = osp.join(runner.work_dir, os.readlink(ckpt_path)) + + if osp.isfile(ckpt_path): + # runner.epoch += 1 has been done before `after_run`. + iteration = runner.epoch if self.by_epoch else runner.iter + return self.writer.add_snapshot_file( + tag=self.run_name, + snapshot_file_path=ckpt_path, + iteration=iteration) + + # flush the buffer and send a task ending signal to Pavi + self.writer.close() + + @master_only + def before_epoch(self, runner): + if runner.epoch == 0 and self.add_graph: + if is_module_wrapper(runner.model): + _model = runner.model.module + else: + _model = runner.model + device = next(_model.parameters()).device + data = next(iter(runner.data_loader)) + image = data[self.img_key][0:1].to(device) + with torch.no_grad(): + self.writer.add_graph(_model, image) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/tensorboard.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/tensorboard.py new file mode 100644 index 000000000..a8d50366f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/tensorboard.py @@ -0,0 +1,57 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import os.path as osp + +from mmcv.utils import TORCH_VERSION, digit_version +from ...dist_utils import master_only +from ..hook import HOOKS +from .base import LoggerHook + + +@HOOKS.register_module() +class TensorboardLoggerHook(LoggerHook): + + def __init__(self, + log_dir=None, + interval=10, + ignore_last=True, + reset_flag=False, + by_epoch=True): + super(TensorboardLoggerHook, self).__init__(interval, ignore_last, + reset_flag, by_epoch) + self.log_dir = log_dir + + @master_only + def before_run(self, runner): + super(TensorboardLoggerHook, self).before_run(runner) + if (TORCH_VERSION == 'parrots' + or digit_version(TORCH_VERSION) < digit_version('1.1')): + try: + from tensorboardX import SummaryWriter + except ImportError: + raise ImportError('Please install tensorboardX to use ' + 'TensorboardLoggerHook.') + else: + try: + from torch.utils.tensorboard import SummaryWriter + except ImportError: + raise ImportError( + 'Please run "pip install future tensorboard" to install ' + 'the dependencies to use torch.utils.tensorboard ' + '(applicable to PyTorch 1.1 or higher)') + + if self.log_dir is None: + self.log_dir = osp.join(runner.work_dir, 'tf_logs') + self.writer = SummaryWriter(self.log_dir) + + @master_only + def log(self, runner): + tags = self.get_loggable_tags(runner, allow_text=True) + for tag, val in tags.items(): + if isinstance(val, str): + self.writer.add_text(tag, val, self.get_iter(runner)) + else: + self.writer.add_scalar(tag, val, self.get_iter(runner)) + + @master_only + def after_run(self, runner): + self.writer.close() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/text.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/text.py new file mode 100644 index 000000000..043c7bf20 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/text.py @@ -0,0 +1,256 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import datetime +import os +import os.path as osp +from collections import OrderedDict + +import torch +import torch.distributed as dist + +import mmcv +from mmcv.fileio.file_client import FileClient +from mmcv.utils import is_tuple_of, scandir +from ..hook import HOOKS +from .base import LoggerHook + + +@HOOKS.register_module() +class TextLoggerHook(LoggerHook): + """Logger hook in text. + + In this logger hook, the information will be printed on terminal and + saved in json file. + + Args: + by_epoch (bool, optional): Whether EpochBasedRunner is used. + Default: True. + interval (int, optional): Logging interval (every k iterations). + Default: 10. + ignore_last (bool, optional): Ignore the log of last iterations in each + epoch if less than :attr:`interval`. Default: True. + reset_flag (bool, optional): Whether to clear the output buffer after + logging. Default: False. + interval_exp_name (int, optional): Logging interval for experiment + name. This feature is to help users conveniently get the experiment + information from screen or log file. Default: 1000. + out_dir (str, optional): Logs are saved in ``runner.work_dir`` default. + If ``out_dir`` is specified, logs will be copied to a new directory + which is the concatenation of ``out_dir`` and the last level + directory of ``runner.work_dir``. Default: None. + `New in version 1.3.16.` + out_suffix (str or tuple[str], optional): Those filenames ending with + ``out_suffix`` will be copied to ``out_dir``. + Default: ('.log.json', '.log', '.py'). + `New in version 1.3.16.` + keep_local (bool, optional): Whether to keep local log when + :attr:`out_dir` is specified. If False, the local log will be + removed. Default: True. + `New in version 1.3.16.` + file_client_args (dict, optional): Arguments to instantiate a + FileClient. See :class:`mmcv.fileio.FileClient` for details. + Default: None. + `New in version 1.3.16.` + """ + + def __init__(self, + by_epoch=True, + interval=10, + ignore_last=True, + reset_flag=False, + interval_exp_name=1000, + out_dir=None, + out_suffix=('.log.json', '.log', '.py'), + keep_local=True, + file_client_args=None): + super(TextLoggerHook, self).__init__(interval, ignore_last, reset_flag, + by_epoch) + self.by_epoch = by_epoch + self.time_sec_tot = 0 + self.interval_exp_name = interval_exp_name + + if out_dir is None and file_client_args is not None: + raise ValueError( + 'file_client_args should be "None" when `out_dir` is not' + 'specified.') + self.out_dir = out_dir + + if not (out_dir is None or isinstance(out_dir, str) + or is_tuple_of(out_dir, str)): + raise TypeError('out_dir should be "None" or string or tuple of ' + 'string, but got {out_dir}') + self.out_suffix = out_suffix + + self.keep_local = keep_local + self.file_client_args = file_client_args + if self.out_dir is not None: + self.file_client = FileClient.infer_client(file_client_args, + self.out_dir) + + def before_run(self, runner): + super(TextLoggerHook, self).before_run(runner) + + if self.out_dir is not None: + self.file_client = FileClient.infer_client(self.file_client_args, + self.out_dir) + # The final `self.out_dir` is the concatenation of `self.out_dir` + # and the last level directory of `runner.work_dir` + basename = osp.basename(runner.work_dir.rstrip(osp.sep)) + self.out_dir = self.file_client.join_path(self.out_dir, basename) + runner.logger.info( + (f'Text logs will be saved to {self.out_dir} by ' + f'{self.file_client.name} after the training process.')) + + self.start_iter = runner.iter + self.json_log_path = osp.join(runner.work_dir, + f'{runner.timestamp}.log.json') + if runner.meta is not None: + self._dump_log(runner.meta, runner) + + def _get_max_memory(self, runner): + device = getattr(runner.model, 'output_device', None) + mem = torch.cuda.max_memory_allocated(device=device) + mem_mb = torch.tensor([mem / (1024 * 1024)], + dtype=torch.int, + device=device) + if runner.world_size > 1: + dist.reduce(mem_mb, 0, op=dist.ReduceOp.MAX) + return mem_mb.item() + + def _log_info(self, log_dict, runner): + # print exp name for users to distinguish experiments + # at every ``interval_exp_name`` iterations and the end of each epoch + if runner.meta is not None and 'exp_name' in runner.meta: + if (self.every_n_iters(runner, self.interval_exp_name)) or ( + self.by_epoch and self.end_of_epoch(runner)): + exp_info = f'Exp name: {runner.meta["exp_name"]}' + runner.logger.info(exp_info) + + if log_dict['mode'] == 'train': + if isinstance(log_dict['lr'], dict): + lr_str = [] + for k, val in log_dict['lr'].items(): + lr_str.append(f'lr_{k}: {val:.3e}') + lr_str = ' '.join(lr_str) + else: + lr_str = f'lr: {log_dict["lr"]:.3e}' + + # by epoch: Epoch [4][100/1000] + # by iter: Iter [100/100000] + if self.by_epoch: + log_str = f'Epoch [{log_dict["epoch"]}]' \ + f'[{log_dict["iter"]}/{len(runner.data_loader)}]\t' + else: + log_str = f'Iter [{log_dict["iter"]}/{runner.max_iters}]\t' + log_str += f'{lr_str}, ' + + if 'time' in log_dict.keys(): + self.time_sec_tot += (log_dict['time'] * self.interval) + time_sec_avg = self.time_sec_tot / ( + runner.iter - self.start_iter + 1) + eta_sec = time_sec_avg * (runner.max_iters - runner.iter - 1) + eta_str = str(datetime.timedelta(seconds=int(eta_sec))) + log_str += f'eta: {eta_str}, ' + log_str += f'time: {log_dict["time"]:.3f}, ' \ + f'data_time: {log_dict["data_time"]:.3f}, ' + # statistic memory + if torch.cuda.is_available(): + log_str += f'memory: {log_dict["memory"]}, ' + else: + # val/test time + # here 1000 is the length of the val dataloader + # by epoch: Epoch[val] [4][1000] + # by iter: Iter[val] [1000] + if self.by_epoch: + log_str = f'Epoch({log_dict["mode"]}) ' \ + f'[{log_dict["epoch"]}][{log_dict["iter"]}]\t' + else: + log_str = f'Iter({log_dict["mode"]}) [{log_dict["iter"]}]\t' + + log_items = [] + for name, val in log_dict.items(): + # TODO: resolve this hack + # these items have been in log_str + if name in [ + 'mode', 'Epoch', 'iter', 'lr', 'time', 'data_time', + 'memory', 'epoch' + ]: + continue + if isinstance(val, float): + val = f'{val:.4f}' + log_items.append(f'{name}: {val}') + log_str += ', '.join(log_items) + + runner.logger.info(log_str) + + def _dump_log(self, log_dict, runner): + # dump log in json format + json_log = OrderedDict() + for k, v in log_dict.items(): + json_log[k] = self._round_float(v) + # only append log at last line + if runner.rank == 0: + with open(self.json_log_path, 'a+') as f: + mmcv.dump(json_log, f, file_format='json') + f.write('\n') + + def _round_float(self, items): + if isinstance(items, list): + return [self._round_float(item) for item in items] + elif isinstance(items, float): + return round(items, 5) + else: + return items + + def log(self, runner): + if 'eval_iter_num' in runner.log_buffer.output: + # this doesn't modify runner.iter and is regardless of by_epoch + cur_iter = runner.log_buffer.output.pop('eval_iter_num') + else: + cur_iter = self.get_iter(runner, inner_iter=True) + + log_dict = OrderedDict( + mode=self.get_mode(runner), + epoch=self.get_epoch(runner), + iter=cur_iter) + + # only record lr of the first param group + cur_lr = runner.current_lr() + if isinstance(cur_lr, list): + log_dict['lr'] = cur_lr[0] + else: + assert isinstance(cur_lr, dict) + log_dict['lr'] = {} + for k, lr_ in cur_lr.items(): + assert isinstance(lr_, list) + log_dict['lr'].update({k: lr_[0]}) + + if 'time' in runner.log_buffer.output: + # statistic memory + if torch.cuda.is_available(): + log_dict['memory'] = self._get_max_memory(runner) + + log_dict = dict(log_dict, **runner.log_buffer.output) + + self._log_info(log_dict, runner) + self._dump_log(log_dict, runner) + return log_dict + + def after_run(self, runner): + # copy or upload logs to self.out_dir + if self.out_dir is not None: + for filename in scandir(runner.work_dir, self.out_suffix, True): + local_filepath = osp.join(runner.work_dir, filename) + out_filepath = self.file_client.join_path( + self.out_dir, filename) + with open(local_filepath, 'r') as f: + self.file_client.put_text(f.read(), out_filepath) + + runner.logger.info( + (f'The file {local_filepath} has been uploaded to ' + f'{out_filepath}.')) + + if not self.keep_local: + os.remove(local_filepath) + runner.logger.info( + (f'{local_filepath} was removed due to the ' + '`self.keep_local=False`')) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/wandb.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/wandb.py new file mode 100644 index 000000000..9f6808462 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/logger/wandb.py @@ -0,0 +1,56 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from ...dist_utils import master_only +from ..hook import HOOKS +from .base import LoggerHook + + +@HOOKS.register_module() +class WandbLoggerHook(LoggerHook): + + def __init__(self, + init_kwargs=None, + interval=10, + ignore_last=True, + reset_flag=False, + commit=True, + by_epoch=True, + with_step=True): + super(WandbLoggerHook, self).__init__(interval, ignore_last, + reset_flag, by_epoch) + self.import_wandb() + self.init_kwargs = init_kwargs + self.commit = commit + self.with_step = with_step + + def import_wandb(self): + try: + import wandb + except ImportError: + raise ImportError( + 'Please run "pip install wandb" to install wandb') + self.wandb = wandb + + @master_only + def before_run(self, runner): + super(WandbLoggerHook, self).before_run(runner) + if self.wandb is None: + self.import_wandb() + if self.init_kwargs: + self.wandb.init(**self.init_kwargs) + else: + self.wandb.init() + + @master_only + def log(self, runner): + tags = self.get_loggable_tags(runner) + if tags: + if self.with_step: + self.wandb.log( + tags, step=self.get_iter(runner), commit=self.commit) + else: + tags['global_step'] = self.get_iter(runner) + self.wandb.log(tags, commit=self.commit) + + @master_only + def after_run(self, runner): + self.wandb.join() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/lr_updater.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/lr_updater.py new file mode 100644 index 000000000..e5a124157 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/lr_updater.py @@ -0,0 +1,670 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import numbers +from math import cos, pi + +import mmcv +from .hook import HOOKS, Hook + + +class LrUpdaterHook(Hook): + """LR Scheduler in MMCV. + + Args: + by_epoch (bool): LR changes epoch by epoch + warmup (string): Type of warmup used. It can be None(use no warmup), + 'constant', 'linear' or 'exp' + warmup_iters (int): The number of iterations or epochs that warmup + lasts + warmup_ratio (float): LR used at the beginning of warmup equals to + warmup_ratio * initial_lr + warmup_by_epoch (bool): When warmup_by_epoch == True, warmup_iters + means the number of epochs that warmup lasts, otherwise means the + number of iteration that warmup lasts + """ + + def __init__(self, + by_epoch=True, + warmup=None, + warmup_iters=0, + warmup_ratio=0.1, + warmup_by_epoch=False): + # validate the "warmup" argument + if warmup is not None: + if warmup not in ['constant', 'linear', 'exp']: + raise ValueError( + f'"{warmup}" is not a supported type for warming up, valid' + ' types are "constant" and "linear"') + if warmup is not None: + assert warmup_iters > 0, \ + '"warmup_iters" must be a positive integer' + assert 0 < warmup_ratio <= 1.0, \ + '"warmup_ratio" must be in range (0,1]' + + self.by_epoch = by_epoch + self.warmup = warmup + self.warmup_iters = warmup_iters + self.warmup_ratio = warmup_ratio + self.warmup_by_epoch = warmup_by_epoch + + if self.warmup_by_epoch: + self.warmup_epochs = self.warmup_iters + self.warmup_iters = None + else: + self.warmup_epochs = None + + self.base_lr = [] # initial lr for all param groups + self.regular_lr = [] # expected lr if no warming up is performed + + def _set_lr(self, runner, lr_groups): + if isinstance(runner.optimizer, dict): + for k, optim in runner.optimizer.items(): + for param_group, lr in zip(optim.param_groups, lr_groups[k]): + param_group['lr'] = lr + else: + for param_group, lr in zip(runner.optimizer.param_groups, + lr_groups): + param_group['lr'] = lr + + def get_lr(self, runner, base_lr): + raise NotImplementedError + + def get_regular_lr(self, runner): + if isinstance(runner.optimizer, dict): + lr_groups = {} + for k in runner.optimizer.keys(): + _lr_group = [ + self.get_lr(runner, _base_lr) + for _base_lr in self.base_lr[k] + ] + lr_groups.update({k: _lr_group}) + + return lr_groups + else: + return [self.get_lr(runner, _base_lr) for _base_lr in self.base_lr] + + def get_warmup_lr(self, cur_iters): + + def _get_warmup_lr(cur_iters, regular_lr): + if self.warmup == 'constant': + warmup_lr = [_lr * self.warmup_ratio for _lr in regular_lr] + elif self.warmup == 'linear': + k = (1 - cur_iters / self.warmup_iters) * (1 - + self.warmup_ratio) + warmup_lr = [_lr * (1 - k) for _lr in regular_lr] + elif self.warmup == 'exp': + k = self.warmup_ratio**(1 - cur_iters / self.warmup_iters) + warmup_lr = [_lr * k for _lr in regular_lr] + return warmup_lr + + if isinstance(self.regular_lr, dict): + lr_groups = {} + for key, regular_lr in self.regular_lr.items(): + lr_groups[key] = _get_warmup_lr(cur_iters, regular_lr) + return lr_groups + else: + return _get_warmup_lr(cur_iters, self.regular_lr) + + def before_run(self, runner): + # NOTE: when resuming from a checkpoint, if 'initial_lr' is not saved, + # it will be set according to the optimizer params + if isinstance(runner.optimizer, dict): + self.base_lr = {} + for k, optim in runner.optimizer.items(): + for group in optim.param_groups: + group.setdefault('initial_lr', group['lr']) + _base_lr = [ + group['initial_lr'] for group in optim.param_groups + ] + self.base_lr.update({k: _base_lr}) + else: + for group in runner.optimizer.param_groups: + group.setdefault('initial_lr', group['lr']) + self.base_lr = [ + group['initial_lr'] for group in runner.optimizer.param_groups + ] + + def before_train_epoch(self, runner): + if self.warmup_iters is None: + epoch_len = len(runner.data_loader) + self.warmup_iters = self.warmup_epochs * epoch_len + + if not self.by_epoch: + return + + self.regular_lr = self.get_regular_lr(runner) + self._set_lr(runner, self.regular_lr) + + def before_train_iter(self, runner): + cur_iter = runner.iter + if not self.by_epoch: + self.regular_lr = self.get_regular_lr(runner) + if self.warmup is None or cur_iter >= self.warmup_iters: + self._set_lr(runner, self.regular_lr) + else: + warmup_lr = self.get_warmup_lr(cur_iter) + self._set_lr(runner, warmup_lr) + elif self.by_epoch: + if self.warmup is None or cur_iter > self.warmup_iters: + return + elif cur_iter == self.warmup_iters: + self._set_lr(runner, self.regular_lr) + else: + warmup_lr = self.get_warmup_lr(cur_iter) + self._set_lr(runner, warmup_lr) + + +@HOOKS.register_module() +class FixedLrUpdaterHook(LrUpdaterHook): + + def __init__(self, **kwargs): + super(FixedLrUpdaterHook, self).__init__(**kwargs) + + def get_lr(self, runner, base_lr): + return base_lr + + +@HOOKS.register_module() +class StepLrUpdaterHook(LrUpdaterHook): + """Step LR scheduler with min_lr clipping. + + Args: + step (int | list[int]): Step to decay the LR. If an int value is given, + regard it as the decay interval. If a list is given, decay LR at + these steps. + gamma (float, optional): Decay LR ratio. Default: 0.1. + min_lr (float, optional): Minimum LR value to keep. If LR after decay + is lower than `min_lr`, it will be clipped to this value. If None + is given, we don't perform lr clipping. Default: None. + """ + + def __init__(self, step, gamma=0.1, min_lr=None, **kwargs): + if isinstance(step, list): + assert mmcv.is_list_of(step, int) + assert all([s > 0 for s in step]) + elif isinstance(step, int): + assert step > 0 + else: + raise TypeError('"step" must be a list or integer') + self.step = step + self.gamma = gamma + self.min_lr = min_lr + super(StepLrUpdaterHook, self).__init__(**kwargs) + + def get_lr(self, runner, base_lr): + progress = runner.epoch if self.by_epoch else runner.iter + + # calculate exponential term + if isinstance(self.step, int): + exp = progress // self.step + else: + exp = len(self.step) + for i, s in enumerate(self.step): + if progress < s: + exp = i + break + + lr = base_lr * (self.gamma**exp) + if self.min_lr is not None: + # clip to a minimum value + lr = max(lr, self.min_lr) + return lr + + +@HOOKS.register_module() +class ExpLrUpdaterHook(LrUpdaterHook): + + def __init__(self, gamma, **kwargs): + self.gamma = gamma + super(ExpLrUpdaterHook, self).__init__(**kwargs) + + def get_lr(self, runner, base_lr): + progress = runner.epoch if self.by_epoch else runner.iter + return base_lr * self.gamma**progress + + +@HOOKS.register_module() +class PolyLrUpdaterHook(LrUpdaterHook): + + def __init__(self, power=1., min_lr=0., **kwargs): + self.power = power + self.min_lr = min_lr + super(PolyLrUpdaterHook, self).__init__(**kwargs) + + def get_lr(self, runner, base_lr): + if self.by_epoch: + progress = runner.epoch + max_progress = runner.max_epochs + else: + progress = runner.iter + max_progress = runner.max_iters + coeff = (1 - progress / max_progress)**self.power + return (base_lr - self.min_lr) * coeff + self.min_lr + + +@HOOKS.register_module() +class InvLrUpdaterHook(LrUpdaterHook): + + def __init__(self, gamma, power=1., **kwargs): + self.gamma = gamma + self.power = power + super(InvLrUpdaterHook, self).__init__(**kwargs) + + def get_lr(self, runner, base_lr): + progress = runner.epoch if self.by_epoch else runner.iter + return base_lr * (1 + self.gamma * progress)**(-self.power) + + +@HOOKS.register_module() +class CosineAnnealingLrUpdaterHook(LrUpdaterHook): + + def __init__(self, min_lr=None, min_lr_ratio=None, **kwargs): + assert (min_lr is None) ^ (min_lr_ratio is None) + self.min_lr = min_lr + self.min_lr_ratio = min_lr_ratio + super(CosineAnnealingLrUpdaterHook, self).__init__(**kwargs) + + def get_lr(self, runner, base_lr): + if self.by_epoch: + progress = runner.epoch + max_progress = runner.max_epochs + else: + progress = runner.iter + max_progress = runner.max_iters + + if self.min_lr_ratio is not None: + target_lr = base_lr * self.min_lr_ratio + else: + target_lr = self.min_lr + return annealing_cos(base_lr, target_lr, progress / max_progress) + + +@HOOKS.register_module() +class FlatCosineAnnealingLrUpdaterHook(LrUpdaterHook): + """Flat + Cosine lr schedule. + + Modified from https://github.com/fastai/fastai/blob/master/fastai/callback/schedule.py#L128 # noqa: E501 + + Args: + start_percent (float): When to start annealing the learning rate + after the percentage of the total training steps. + The value should be in range [0, 1). + Default: 0.75 + min_lr (float, optional): The minimum lr. Default: None. + min_lr_ratio (float, optional): The ratio of minimum lr to the base lr. + Either `min_lr` or `min_lr_ratio` should be specified. + Default: None. + """ + + def __init__(self, + start_percent=0.75, + min_lr=None, + min_lr_ratio=None, + **kwargs): + assert (min_lr is None) ^ (min_lr_ratio is None) + if start_percent < 0 or start_percent > 1 or not isinstance( + start_percent, float): + raise ValueError( + 'expected float between 0 and 1 start_percent, but ' + f'got {start_percent}') + self.start_percent = start_percent + self.min_lr = min_lr + self.min_lr_ratio = min_lr_ratio + super(FlatCosineAnnealingLrUpdaterHook, self).__init__(**kwargs) + + def get_lr(self, runner, base_lr): + if self.by_epoch: + start = round(runner.max_epochs * self.start_percent) + progress = runner.epoch - start + max_progress = runner.max_epochs - start + else: + start = round(runner.max_iters * self.start_percent) + progress = runner.iter - start + max_progress = runner.max_iters - start + + if self.min_lr_ratio is not None: + target_lr = base_lr * self.min_lr_ratio + else: + target_lr = self.min_lr + + if progress < 0: + return base_lr + else: + return annealing_cos(base_lr, target_lr, progress / max_progress) + + +@HOOKS.register_module() +class CosineRestartLrUpdaterHook(LrUpdaterHook): + """Cosine annealing with restarts learning rate scheme. + + Args: + periods (list[int]): Periods for each cosine anneling cycle. + restart_weights (list[float], optional): Restart weights at each + restart iteration. Default: [1]. + min_lr (float, optional): The minimum lr. Default: None. + min_lr_ratio (float, optional): The ratio of minimum lr to the base lr. + Either `min_lr` or `min_lr_ratio` should be specified. + Default: None. + """ + + def __init__(self, + periods, + restart_weights=[1], + min_lr=None, + min_lr_ratio=None, + **kwargs): + assert (min_lr is None) ^ (min_lr_ratio is None) + self.periods = periods + self.min_lr = min_lr + self.min_lr_ratio = min_lr_ratio + self.restart_weights = restart_weights + assert (len(self.periods) == len(self.restart_weights) + ), 'periods and restart_weights should have the same length.' + super(CosineRestartLrUpdaterHook, self).__init__(**kwargs) + + self.cumulative_periods = [ + sum(self.periods[0:i + 1]) for i in range(0, len(self.periods)) + ] + + def get_lr(self, runner, base_lr): + if self.by_epoch: + progress = runner.epoch + else: + progress = runner.iter + + if self.min_lr_ratio is not None: + target_lr = base_lr * self.min_lr_ratio + else: + target_lr = self.min_lr + + idx = get_position_from_periods(progress, self.cumulative_periods) + current_weight = self.restart_weights[idx] + nearest_restart = 0 if idx == 0 else self.cumulative_periods[idx - 1] + current_periods = self.periods[idx] + + alpha = min((progress - nearest_restart) / current_periods, 1) + return annealing_cos(base_lr, target_lr, alpha, current_weight) + + +def get_position_from_periods(iteration, cumulative_periods): + """Get the position from a period list. + + It will return the index of the right-closest number in the period list. + For example, the cumulative_periods = [100, 200, 300, 400], + if iteration == 50, return 0; + if iteration == 210, return 2; + if iteration == 300, return 3. + + Args: + iteration (int): Current iteration. + cumulative_periods (list[int]): Cumulative period list. + + Returns: + int: The position of the right-closest number in the period list. + """ + for i, period in enumerate(cumulative_periods): + if iteration < period: + return i + raise ValueError(f'Current iteration {iteration} exceeds ' + f'cumulative_periods {cumulative_periods}') + + +@HOOKS.register_module() +class CyclicLrUpdaterHook(LrUpdaterHook): + """Cyclic LR Scheduler. + + Implement the cyclical learning rate policy (CLR) described in + https://arxiv.org/pdf/1506.01186.pdf + + Different from the original paper, we use cosine annealing rather than + triangular policy inside a cycle. This improves the performance in the + 3D detection area. + + Args: + by_epoch (bool): Whether to update LR by epoch. + target_ratio (tuple[float]): Relative ratio of the highest LR and the + lowest LR to the initial LR. + cyclic_times (int): Number of cycles during training + step_ratio_up (float): The ratio of the increasing process of LR in + the total cycle. + anneal_strategy (str): {'cos', 'linear'} + Specifies the annealing strategy: 'cos' for cosine annealing, + 'linear' for linear annealing. Default: 'cos'. + """ + + def __init__(self, + by_epoch=False, + target_ratio=(10, 1e-4), + cyclic_times=1, + step_ratio_up=0.4, + anneal_strategy='cos', + **kwargs): + if isinstance(target_ratio, float): + target_ratio = (target_ratio, target_ratio / 1e5) + elif isinstance(target_ratio, tuple): + target_ratio = (target_ratio[0], target_ratio[0] / 1e5) \ + if len(target_ratio) == 1 else target_ratio + else: + raise ValueError('target_ratio should be either float ' + f'or tuple, got {type(target_ratio)}') + + assert len(target_ratio) == 2, \ + '"target_ratio" must be list or tuple of two floats' + assert 0 <= step_ratio_up < 1.0, \ + '"step_ratio_up" must be in range [0,1)' + + self.target_ratio = target_ratio + self.cyclic_times = cyclic_times + self.step_ratio_up = step_ratio_up + self.lr_phases = [] # init lr_phases + # validate anneal_strategy + if anneal_strategy not in ['cos', 'linear']: + raise ValueError('anneal_strategy must be one of "cos" or ' + f'"linear", instead got {anneal_strategy}') + elif anneal_strategy == 'cos': + self.anneal_func = annealing_cos + elif anneal_strategy == 'linear': + self.anneal_func = annealing_linear + + assert not by_epoch, \ + 'currently only support "by_epoch" = False' + super(CyclicLrUpdaterHook, self).__init__(by_epoch, **kwargs) + + def before_run(self, runner): + super(CyclicLrUpdaterHook, self).before_run(runner) + # initiate lr_phases + # total lr_phases are separated as up and down + max_iter_per_phase = runner.max_iters // self.cyclic_times + iter_up_phase = int(self.step_ratio_up * max_iter_per_phase) + self.lr_phases.append( + [0, iter_up_phase, max_iter_per_phase, 1, self.target_ratio[0]]) + self.lr_phases.append([ + iter_up_phase, max_iter_per_phase, max_iter_per_phase, + self.target_ratio[0], self.target_ratio[1] + ]) + + def get_lr(self, runner, base_lr): + curr_iter = runner.iter + for (start_iter, end_iter, max_iter_per_phase, start_ratio, + end_ratio) in self.lr_phases: + curr_iter %= max_iter_per_phase + if start_iter <= curr_iter < end_iter: + progress = curr_iter - start_iter + return self.anneal_func(base_lr * start_ratio, + base_lr * end_ratio, + progress / (end_iter - start_iter)) + + +@HOOKS.register_module() +class OneCycleLrUpdaterHook(LrUpdaterHook): + """One Cycle LR Scheduler. + + The 1cycle learning rate policy changes the learning rate after every + batch. The one cycle learning rate policy is described in + https://arxiv.org/pdf/1708.07120.pdf + + Args: + max_lr (float or list): Upper learning rate boundaries in the cycle + for each parameter group. + total_steps (int, optional): The total number of steps in the cycle. + Note that if a value is not provided here, it will be the max_iter + of runner. Default: None. + pct_start (float): The percentage of the cycle (in number of steps) + spent increasing the learning rate. + Default: 0.3 + anneal_strategy (str): {'cos', 'linear'} + Specifies the annealing strategy: 'cos' for cosine annealing, + 'linear' for linear annealing. + Default: 'cos' + div_factor (float): Determines the initial learning rate via + initial_lr = max_lr/div_factor + Default: 25 + final_div_factor (float): Determines the minimum learning rate via + min_lr = initial_lr/final_div_factor + Default: 1e4 + three_phase (bool): If three_phase is True, use a third phase of the + schedule to annihilate the learning rate according to + final_div_factor instead of modifying the second phase (the first + two phases will be symmetrical about the step indicated by + pct_start). + Default: False + """ + + def __init__(self, + max_lr, + total_steps=None, + pct_start=0.3, + anneal_strategy='cos', + div_factor=25, + final_div_factor=1e4, + three_phase=False, + **kwargs): + # validate by_epoch, currently only support by_epoch = False + if 'by_epoch' not in kwargs: + kwargs['by_epoch'] = False + else: + assert not kwargs['by_epoch'], \ + 'currently only support "by_epoch" = False' + if not isinstance(max_lr, (numbers.Number, list, dict)): + raise ValueError('the type of max_lr must be the one of list or ' + f'dict, but got {type(max_lr)}') + self._max_lr = max_lr + if total_steps is not None: + if not isinstance(total_steps, int): + raise ValueError('the type of total_steps must be int, but' + f'got {type(total_steps)}') + self.total_steps = total_steps + # validate pct_start + if pct_start < 0 or pct_start > 1 or not isinstance(pct_start, float): + raise ValueError('expected float between 0 and 1 pct_start, but ' + f'got {pct_start}') + self.pct_start = pct_start + # validate anneal_strategy + if anneal_strategy not in ['cos', 'linear']: + raise ValueError('anneal_strategy must be one of "cos" or ' + f'"linear", instead got {anneal_strategy}') + elif anneal_strategy == 'cos': + self.anneal_func = annealing_cos + elif anneal_strategy == 'linear': + self.anneal_func = annealing_linear + self.div_factor = div_factor + self.final_div_factor = final_div_factor + self.three_phase = three_phase + self.lr_phases = [] # init lr_phases + super(OneCycleLrUpdaterHook, self).__init__(**kwargs) + + def before_run(self, runner): + if hasattr(self, 'total_steps'): + total_steps = self.total_steps + else: + total_steps = runner.max_iters + if total_steps < runner.max_iters: + raise ValueError( + 'The total steps must be greater than or equal to max ' + f'iterations {runner.max_iters} of runner, but total steps ' + f'is {total_steps}.') + + if isinstance(runner.optimizer, dict): + self.base_lr = {} + for k, optim in runner.optimizer.items(): + _max_lr = format_param(k, optim, self._max_lr) + self.base_lr[k] = [lr / self.div_factor for lr in _max_lr] + for group, lr in zip(optim.param_groups, self.base_lr[k]): + group.setdefault('initial_lr', lr) + else: + k = type(runner.optimizer).__name__ + _max_lr = format_param(k, runner.optimizer, self._max_lr) + self.base_lr = [lr / self.div_factor for lr in _max_lr] + for group, lr in zip(runner.optimizer.param_groups, self.base_lr): + group.setdefault('initial_lr', lr) + + if self.three_phase: + self.lr_phases.append( + [float(self.pct_start * total_steps) - 1, 1, self.div_factor]) + self.lr_phases.append([ + float(2 * self.pct_start * total_steps) - 2, self.div_factor, 1 + ]) + self.lr_phases.append( + [total_steps - 1, 1, 1 / self.final_div_factor]) + else: + self.lr_phases.append( + [float(self.pct_start * total_steps) - 1, 1, self.div_factor]) + self.lr_phases.append( + [total_steps - 1, self.div_factor, 1 / self.final_div_factor]) + + def get_lr(self, runner, base_lr): + curr_iter = runner.iter + start_iter = 0 + for i, (end_iter, start_lr, end_lr) in enumerate(self.lr_phases): + if curr_iter <= end_iter: + pct = (curr_iter - start_iter) / (end_iter - start_iter) + lr = self.anneal_func(base_lr * start_lr, base_lr * end_lr, + pct) + break + start_iter = end_iter + return lr + + +def annealing_cos(start, end, factor, weight=1): + """Calculate annealing cos learning rate. + + Cosine anneal from `weight * start + (1 - weight) * end` to `end` as + percentage goes from 0.0 to 1.0. + + Args: + start (float): The starting learning rate of the cosine annealing. + end (float): The ending learing rate of the cosine annealing. + factor (float): The coefficient of `pi` when calculating the current + percentage. Range from 0.0 to 1.0. + weight (float, optional): The combination factor of `start` and `end` + when calculating the actual starting learning rate. Default to 1. + """ + cos_out = cos(pi * factor) + 1 + return end + 0.5 * weight * (start - end) * cos_out + + +def annealing_linear(start, end, factor): + """Calculate annealing linear learning rate. + + Linear anneal from `start` to `end` as percentage goes from 0.0 to 1.0. + + Args: + start (float): The starting learning rate of the linear annealing. + end (float): The ending learing rate of the linear annealing. + factor (float): The coefficient of `pi` when calculating the current + percentage. Range from 0.0 to 1.0. + """ + return start + (end - start) * factor + + +def format_param(name, optim, param): + if isinstance(param, numbers.Number): + return [param] * len(optim.param_groups) + elif isinstance(param, (list, tuple)): # multi param groups + if len(param) != len(optim.param_groups): + raise ValueError(f'expected {len(optim.param_groups)} ' + f'values for {name}, got {len(param)}') + return param + else: # multi optimizers + if name not in param: + raise KeyError(f'{name} is not found in {param.keys()}') + return param[name] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/memory.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/memory.py new file mode 100644 index 000000000..70cf9a838 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/memory.py @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch + +from .hook import HOOKS, Hook + + +@HOOKS.register_module() +class EmptyCacheHook(Hook): + + def __init__(self, before_epoch=False, after_epoch=True, after_iter=False): + self._before_epoch = before_epoch + self._after_epoch = after_epoch + self._after_iter = after_iter + + def after_iter(self, runner): + if self._after_iter: + torch.cuda.empty_cache() + + def before_epoch(self, runner): + if self._before_epoch: + torch.cuda.empty_cache() + + def after_epoch(self, runner): + if self._after_epoch: + torch.cuda.empty_cache() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/momentum_updater.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/momentum_updater.py new file mode 100644 index 000000000..13d0e2fab --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/momentum_updater.py @@ -0,0 +1,493 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import mmcv +from .hook import HOOKS, Hook +from .lr_updater import annealing_cos, annealing_linear, format_param + + +class MomentumUpdaterHook(Hook): + + def __init__(self, + by_epoch=True, + warmup=None, + warmup_iters=0, + warmup_ratio=0.9): + # validate the "warmup" argument + if warmup is not None: + if warmup not in ['constant', 'linear', 'exp']: + raise ValueError( + f'"{warmup}" is not a supported type for warming up, valid' + ' types are "constant" and "linear"') + if warmup is not None: + assert warmup_iters > 0, \ + '"warmup_iters" must be a positive integer' + assert 0 < warmup_ratio <= 1.0, \ + '"warmup_momentum" must be in range (0,1]' + + self.by_epoch = by_epoch + self.warmup = warmup + self.warmup_iters = warmup_iters + self.warmup_ratio = warmup_ratio + + self.base_momentum = [] # initial momentum for all param groups + self.regular_momentum = [ + ] # expected momentum if no warming up is performed + + def _set_momentum(self, runner, momentum_groups): + if isinstance(runner.optimizer, dict): + for k, optim in runner.optimizer.items(): + for param_group, mom in zip(optim.param_groups, + momentum_groups[k]): + if 'momentum' in param_group.keys(): + param_group['momentum'] = mom + elif 'betas' in param_group.keys(): + param_group['betas'] = (mom, param_group['betas'][1]) + else: + for param_group, mom in zip(runner.optimizer.param_groups, + momentum_groups): + if 'momentum' in param_group.keys(): + param_group['momentum'] = mom + elif 'betas' in param_group.keys(): + param_group['betas'] = (mom, param_group['betas'][1]) + + def get_momentum(self, runner, base_momentum): + raise NotImplementedError + + def get_regular_momentum(self, runner): + if isinstance(runner.optimizer, dict): + momentum_groups = {} + for k in runner.optimizer.keys(): + _momentum_group = [ + self.get_momentum(runner, _base_momentum) + for _base_momentum in self.base_momentum[k] + ] + momentum_groups.update({k: _momentum_group}) + return momentum_groups + else: + return [ + self.get_momentum(runner, _base_momentum) + for _base_momentum in self.base_momentum + ] + + def get_warmup_momentum(self, cur_iters): + + def _get_warmup_momentum(cur_iters, regular_momentum): + if self.warmup == 'constant': + warmup_momentum = [ + _momentum / self.warmup_ratio + for _momentum in self.regular_momentum + ] + elif self.warmup == 'linear': + k = (1 - cur_iters / self.warmup_iters) * (1 - + self.warmup_ratio) + warmup_momentum = [ + _momentum / (1 - k) for _momentum in self.regular_mom + ] + elif self.warmup == 'exp': + k = self.warmup_ratio**(1 - cur_iters / self.warmup_iters) + warmup_momentum = [ + _momentum / k for _momentum in self.regular_mom + ] + return warmup_momentum + + if isinstance(self.regular_momentum, dict): + momentum_groups = {} + for key, regular_momentum in self.regular_momentum.items(): + momentum_groups[key] = _get_warmup_momentum( + cur_iters, regular_momentum) + return momentum_groups + else: + return _get_warmup_momentum(cur_iters, self.regular_momentum) + + def before_run(self, runner): + # NOTE: when resuming from a checkpoint, + # if 'initial_momentum' is not saved, + # it will be set according to the optimizer params + if isinstance(runner.optimizer, dict): + self.base_momentum = {} + for k, optim in runner.optimizer.items(): + for group in optim.param_groups: + if 'momentum' in group.keys(): + group.setdefault('initial_momentum', group['momentum']) + else: + group.setdefault('initial_momentum', group['betas'][0]) + _base_momentum = [ + group['initial_momentum'] for group in optim.param_groups + ] + self.base_momentum.update({k: _base_momentum}) + else: + for group in runner.optimizer.param_groups: + if 'momentum' in group.keys(): + group.setdefault('initial_momentum', group['momentum']) + else: + group.setdefault('initial_momentum', group['betas'][0]) + self.base_momentum = [ + group['initial_momentum'] + for group in runner.optimizer.param_groups + ] + + def before_train_epoch(self, runner): + if not self.by_epoch: + return + self.regular_mom = self.get_regular_momentum(runner) + self._set_momentum(runner, self.regular_mom) + + def before_train_iter(self, runner): + cur_iter = runner.iter + if not self.by_epoch: + self.regular_mom = self.get_regular_momentum(runner) + if self.warmup is None or cur_iter >= self.warmup_iters: + self._set_momentum(runner, self.regular_mom) + else: + warmup_momentum = self.get_warmup_momentum(cur_iter) + self._set_momentum(runner, warmup_momentum) + elif self.by_epoch: + if self.warmup is None or cur_iter > self.warmup_iters: + return + elif cur_iter == self.warmup_iters: + self._set_momentum(runner, self.regular_mom) + else: + warmup_momentum = self.get_warmup_momentum(cur_iter) + self._set_momentum(runner, warmup_momentum) + + +@HOOKS.register_module() +class StepMomentumUpdaterHook(MomentumUpdaterHook): + """Step momentum scheduler with min value clipping. + + Args: + step (int | list[int]): Step to decay the momentum. If an int value is + given, regard it as the decay interval. If a list is given, decay + momentum at these steps. + gamma (float, optional): Decay momentum ratio. Default: 0.5. + min_momentum (float, optional): Minimum momentum value to keep. If + momentum after decay is lower than this value, it will be clipped + accordingly. If None is given, we don't perform lr clipping. + Default: None. + """ + + def __init__(self, step, gamma=0.5, min_momentum=None, **kwargs): + if isinstance(step, list): + assert mmcv.is_list_of(step, int) + assert all([s > 0 for s in step]) + elif isinstance(step, int): + assert step > 0 + else: + raise TypeError('"step" must be a list or integer') + self.step = step + self.gamma = gamma + self.min_momentum = min_momentum + super(StepMomentumUpdaterHook, self).__init__(**kwargs) + + def get_momentum(self, runner, base_momentum): + progress = runner.epoch if self.by_epoch else runner.iter + + # calculate exponential term + if isinstance(self.step, int): + exp = progress // self.step + else: + exp = len(self.step) + for i, s in enumerate(self.step): + if progress < s: + exp = i + break + + momentum = base_momentum * (self.gamma**exp) + if self.min_momentum is not None: + # clip to a minimum value + momentum = max(momentum, self.min_momentum) + return momentum + + +@HOOKS.register_module() +class CosineAnnealingMomentumUpdaterHook(MomentumUpdaterHook): + + def __init__(self, min_momentum=None, min_momentum_ratio=None, **kwargs): + assert (min_momentum is None) ^ (min_momentum_ratio is None) + self.min_momentum = min_momentum + self.min_momentum_ratio = min_momentum_ratio + super(CosineAnnealingMomentumUpdaterHook, self).__init__(**kwargs) + + def get_momentum(self, runner, base_momentum): + if self.by_epoch: + progress = runner.epoch + max_progress = runner.max_epochs + else: + progress = runner.iter + max_progress = runner.max_iters + if self.min_momentum_ratio is not None: + target_momentum = base_momentum * self.min_momentum_ratio + else: + target_momentum = self.min_momentum + return annealing_cos(base_momentum, target_momentum, + progress / max_progress) + + +@HOOKS.register_module() +class CyclicMomentumUpdaterHook(MomentumUpdaterHook): + """Cyclic momentum Scheduler. + + Implement the cyclical momentum scheduler policy described in + https://arxiv.org/pdf/1708.07120.pdf + + This momentum scheduler usually used together with the CyclicLRUpdater + to improve the performance in the 3D detection area. + + Attributes: + target_ratio (tuple[float]): Relative ratio of the lowest momentum and + the highest momentum to the initial momentum. + cyclic_times (int): Number of cycles during training + step_ratio_up (float): The ratio of the increasing process of momentum + in the total cycle. + by_epoch (bool): Whether to update momentum by epoch. + """ + + def __init__(self, + by_epoch=False, + target_ratio=(0.85 / 0.95, 1), + cyclic_times=1, + step_ratio_up=0.4, + **kwargs): + if isinstance(target_ratio, float): + target_ratio = (target_ratio, target_ratio / 1e5) + elif isinstance(target_ratio, tuple): + target_ratio = (target_ratio[0], target_ratio[0] / 1e5) \ + if len(target_ratio) == 1 else target_ratio + else: + raise ValueError('target_ratio should be either float ' + f'or tuple, got {type(target_ratio)}') + + assert len(target_ratio) == 2, \ + '"target_ratio" must be list or tuple of two floats' + assert 0 <= step_ratio_up < 1.0, \ + '"step_ratio_up" must be in range [0,1)' + + self.target_ratio = target_ratio + self.cyclic_times = cyclic_times + self.step_ratio_up = step_ratio_up + self.momentum_phases = [] # init momentum_phases + # currently only support by_epoch=False + assert not by_epoch, \ + 'currently only support "by_epoch" = False' + super(CyclicMomentumUpdaterHook, self).__init__(by_epoch, **kwargs) + + def before_run(self, runner): + super(CyclicMomentumUpdaterHook, self).before_run(runner) + # initiate momentum_phases + # total momentum_phases are separated as up and down + max_iter_per_phase = runner.max_iters // self.cyclic_times + iter_up_phase = int(self.step_ratio_up * max_iter_per_phase) + self.momentum_phases.append( + [0, iter_up_phase, max_iter_per_phase, 1, self.target_ratio[0]]) + self.momentum_phases.append([ + iter_up_phase, max_iter_per_phase, max_iter_per_phase, + self.target_ratio[0], self.target_ratio[1] + ]) + + def get_momentum(self, runner, base_momentum): + curr_iter = runner.iter + for (start_iter, end_iter, max_iter_per_phase, start_ratio, + end_ratio) in self.momentum_phases: + curr_iter %= max_iter_per_phase + if start_iter <= curr_iter < end_iter: + progress = curr_iter - start_iter + return annealing_cos(base_momentum * start_ratio, + base_momentum * end_ratio, + progress / (end_iter - start_iter)) + + +@HOOKS.register_module() +class OneCycleMomentumUpdaterHook(MomentumUpdaterHook): + """OneCycle momentum Scheduler. + + This momentum scheduler usually used together with the OneCycleLrUpdater + to improve the performance. + + Args: + base_momentum (float or list): Lower momentum boundaries in the cycle + for each parameter group. Note that momentum is cycled inversely + to learning rate; at the peak of a cycle, momentum is + 'base_momentum' and learning rate is 'max_lr'. + Default: 0.85 + max_momentum (float or list): Upper momentum boundaries in the cycle + for each parameter group. Functionally, + it defines the cycle amplitude (max_momentum - base_momentum). + Note that momentum is cycled inversely + to learning rate; at the start of a cycle, momentum is + 'max_momentum' and learning rate is 'base_lr' + Default: 0.95 + pct_start (float): The percentage of the cycle (in number of steps) + spent increasing the learning rate. + Default: 0.3 + anneal_strategy (str): {'cos', 'linear'} + Specifies the annealing strategy: 'cos' for cosine annealing, + 'linear' for linear annealing. + Default: 'cos' + three_phase (bool): If three_phase is True, use a third phase of the + schedule to annihilate the learning rate according to + final_div_factor instead of modifying the second phase (the first + two phases will be symmetrical about the step indicated by + pct_start). + Default: False + """ + + def __init__(self, + base_momentum=0.85, + max_momentum=0.95, + pct_start=0.3, + anneal_strategy='cos', + three_phase=False, + **kwargs): + # validate by_epoch, currently only support by_epoch=False + if 'by_epoch' not in kwargs: + kwargs['by_epoch'] = False + else: + assert not kwargs['by_epoch'], \ + 'currently only support "by_epoch" = False' + if not isinstance(base_momentum, (float, list, dict)): + raise ValueError('base_momentum must be the type among of float,' + 'list or dict.') + self._base_momentum = base_momentum + if not isinstance(max_momentum, (float, list, dict)): + raise ValueError('max_momentum must be the type among of float,' + 'list or dict.') + self._max_momentum = max_momentum + # validate pct_start + if pct_start < 0 or pct_start > 1 or not isinstance(pct_start, float): + raise ValueError('Expected float between 0 and 1 pct_start, but ' + f'got {pct_start}') + self.pct_start = pct_start + # validate anneal_strategy + if anneal_strategy not in ['cos', 'linear']: + raise ValueError('anneal_strategy must by one of "cos" or ' + f'"linear", instead got {anneal_strategy}') + elif anneal_strategy == 'cos': + self.anneal_func = annealing_cos + elif anneal_strategy == 'linear': + self.anneal_func = annealing_linear + self.three_phase = three_phase + self.momentum_phases = [] # init momentum_phases + super(OneCycleMomentumUpdaterHook, self).__init__(**kwargs) + + def before_run(self, runner): + if isinstance(runner.optimizer, dict): + for k, optim in runner.optimizer.items(): + if ('momentum' not in optim.defaults + and 'betas' not in optim.defaults): + raise ValueError('optimizer must support momentum with' + 'option enabled') + self.use_beta1 = 'betas' in optim.defaults + _base_momentum = format_param(k, optim, self._base_momentum) + _max_momentum = format_param(k, optim, self._max_momentum) + for group, b_momentum, m_momentum in zip( + optim.param_groups, _base_momentum, _max_momentum): + if self.use_beta1: + _, beta2 = group['betas'] + group['betas'] = (m_momentum, beta2) + else: + group['momentum'] = m_momentum + group['base_momentum'] = b_momentum + group['max_momentum'] = m_momentum + else: + optim = runner.optimizer + if ('momentum' not in optim.defaults + and 'betas' not in optim.defaults): + raise ValueError('optimizer must support momentum with' + 'option enabled') + self.use_beta1 = 'betas' in optim.defaults + k = type(optim).__name__ + _base_momentum = format_param(k, optim, self._base_momentum) + _max_momentum = format_param(k, optim, self._max_momentum) + for group, b_momentum, m_momentum in zip(optim.param_groups, + _base_momentum, + _max_momentum): + if self.use_beta1: + _, beta2 = group['betas'] + group['betas'] = (m_momentum, beta2) + else: + group['momentum'] = m_momentum + group['base_momentum'] = b_momentum + group['max_momentum'] = m_momentum + + if self.three_phase: + self.momentum_phases.append({ + 'end_iter': + float(self.pct_start * runner.max_iters) - 1, + 'start_momentum': + 'max_momentum', + 'end_momentum': + 'base_momentum' + }) + self.momentum_phases.append({ + 'end_iter': + float(2 * self.pct_start * runner.max_iters) - 2, + 'start_momentum': + 'base_momentum', + 'end_momentum': + 'max_momentum' + }) + self.momentum_phases.append({ + 'end_iter': runner.max_iters - 1, + 'start_momentum': 'max_momentum', + 'end_momentum': 'max_momentum' + }) + else: + self.momentum_phases.append({ + 'end_iter': + float(self.pct_start * runner.max_iters) - 1, + 'start_momentum': + 'max_momentum', + 'end_momentum': + 'base_momentum' + }) + self.momentum_phases.append({ + 'end_iter': runner.max_iters - 1, + 'start_momentum': 'base_momentum', + 'end_momentum': 'max_momentum' + }) + + def _set_momentum(self, runner, momentum_groups): + if isinstance(runner.optimizer, dict): + for k, optim in runner.optimizer.items(): + for param_group, mom in zip(optim.param_groups, + momentum_groups[k]): + if 'momentum' in param_group.keys(): + param_group['momentum'] = mom + elif 'betas' in param_group.keys(): + param_group['betas'] = (mom, param_group['betas'][1]) + else: + for param_group, mom in zip(runner.optimizer.param_groups, + momentum_groups): + if 'momentum' in param_group.keys(): + param_group['momentum'] = mom + elif 'betas' in param_group.keys(): + param_group['betas'] = (mom, param_group['betas'][1]) + + def get_momentum(self, runner, param_group): + curr_iter = runner.iter + start_iter = 0 + for i, phase in enumerate(self.momentum_phases): + end_iter = phase['end_iter'] + if curr_iter <= end_iter or i == len(self.momentum_phases) - 1: + pct = (curr_iter - start_iter) / (end_iter - start_iter) + momentum = self.anneal_func( + param_group[phase['start_momentum']], + param_group[phase['end_momentum']], pct) + break + start_iter = end_iter + return momentum + + def get_regular_momentum(self, runner): + if isinstance(runner.optimizer, dict): + momentum_groups = {} + for k, optim in runner.optimizer.items(): + _momentum_group = [ + self.get_momentum(runner, param_group) + for param_group in optim.param_groups + ] + momentum_groups.update({k: _momentum_group}) + return momentum_groups + else: + momentum_groups = [] + for param_group in runner.optimizer.param_groups: + momentum_groups.append(self.get_momentum(runner, param_group)) + return momentum_groups diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/optimizer.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/optimizer.py new file mode 100644 index 000000000..f575ceda0 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/optimizer.py @@ -0,0 +1,508 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import copy +from collections import defaultdict +from itertools import chain + +from torch.nn.utils import clip_grad + +from mmcv.utils import TORCH_VERSION, _BatchNorm, digit_version +from ..dist_utils import allreduce_grads +from ..fp16_utils import LossScaler, wrap_fp16_model +from .hook import HOOKS, Hook + +try: + # If PyTorch version >= 1.6.0, torch.cuda.amp.GradScaler would be imported + # and used; otherwise, auto fp16 will adopt mmcv's implementation. + from torch.cuda.amp import GradScaler +except ImportError: + pass + + +@HOOKS.register_module() +class OptimizerHook(Hook): + + def __init__(self, grad_clip=None): + self.grad_clip = grad_clip + + def clip_grads(self, params): + params = list( + filter(lambda p: p.requires_grad and p.grad is not None, params)) + if len(params) > 0: + return clip_grad.clip_grad_norm_(params, **self.grad_clip) + + def after_train_iter(self, runner): + runner.optimizer.zero_grad() + runner.outputs['loss'].backward() + if self.grad_clip is not None: + grad_norm = self.clip_grads(runner.model.parameters()) + if grad_norm is not None: + # Add grad norm to the logger + runner.log_buffer.update({'grad_norm': float(grad_norm)}, + runner.outputs['num_samples']) + runner.optimizer.step() + + +@HOOKS.register_module() +class GradientCumulativeOptimizerHook(OptimizerHook): + """Optimizer Hook implements multi-iters gradient cumulating. + + Args: + cumulative_iters (int, optional): Num of gradient cumulative iters. + The optimizer will step every `cumulative_iters` iters. + Defaults to 1. + + Examples: + >>> # Use cumulative_iters to simulate a large batch size + >>> # It is helpful when the hardware cannot handle a large batch size. + >>> loader = DataLoader(data, batch_size=64) + >>> optim_hook = GradientCumulativeOptimizerHook(cumulative_iters=4) + >>> # almost equals to + >>> loader = DataLoader(data, batch_size=256) + >>> optim_hook = OptimizerHook() + """ + + def __init__(self, cumulative_iters=1, **kwargs): + super(GradientCumulativeOptimizerHook, self).__init__(**kwargs) + + assert isinstance(cumulative_iters, int) and cumulative_iters > 0, \ + f'cumulative_iters only accepts positive int, but got ' \ + f'{type(cumulative_iters)} instead.' + + self.cumulative_iters = cumulative_iters + self.divisible_iters = 0 + self.remainder_iters = 0 + self.initialized = False + + def has_batch_norm(self, module): + if isinstance(module, _BatchNorm): + return True + for m in module.children(): + if self.has_batch_norm(m): + return True + return False + + def _init(self, runner): + if runner.iter % self.cumulative_iters != 0: + runner.logger.warning( + 'Resume iter number is not divisible by cumulative_iters in ' + 'GradientCumulativeOptimizerHook, which means the gradient of ' + 'some iters is lost and the result may be influenced slightly.' + ) + + if self.has_batch_norm(runner.model) and self.cumulative_iters > 1: + runner.logger.warning( + 'GradientCumulativeOptimizerHook may slightly decrease ' + 'performance if the model has BatchNorm layers.') + + residual_iters = runner.max_iters - runner.iter + + self.divisible_iters = ( + residual_iters // self.cumulative_iters * self.cumulative_iters) + self.remainder_iters = residual_iters - self.divisible_iters + + self.initialized = True + + def after_train_iter(self, runner): + if not self.initialized: + self._init(runner) + + if runner.iter < self.divisible_iters: + loss_factor = self.cumulative_iters + else: + loss_factor = self.remainder_iters + loss = runner.outputs['loss'] + loss = loss / loss_factor + loss.backward() + + if (self.every_n_iters(runner, self.cumulative_iters) + or self.is_last_iter(runner)): + + if self.grad_clip is not None: + grad_norm = self.clip_grads(runner.model.parameters()) + if grad_norm is not None: + # Add grad norm to the logger + runner.log_buffer.update({'grad_norm': float(grad_norm)}, + runner.outputs['num_samples']) + runner.optimizer.step() + runner.optimizer.zero_grad() + + +if (TORCH_VERSION != 'parrots' + and digit_version(TORCH_VERSION) >= digit_version('1.6.0')): + + @HOOKS.register_module() + class Fp16OptimizerHook(OptimizerHook): + """FP16 optimizer hook (using PyTorch's implementation). + + If you are using PyTorch >= 1.6, torch.cuda.amp is used as the backend, + to take care of the optimization procedure. + + Args: + loss_scale (float | str | dict): Scale factor configuration. + If loss_scale is a float, static loss scaling will be used with + the specified scale. If loss_scale is a string, it must be + 'dynamic', then dynamic loss scaling will be used. + It can also be a dict containing arguments of GradScalar. + Defaults to 512. For Pytorch >= 1.6, mmcv uses official + implementation of GradScaler. If you use a dict version of + loss_scale to create GradScaler, please refer to: + https://pytorch.org/docs/stable/amp.html#torch.cuda.amp.GradScaler + for the parameters. + + Examples: + >>> loss_scale = dict( + ... init_scale=65536.0, + ... growth_factor=2.0, + ... backoff_factor=0.5, + ... growth_interval=2000 + ... ) + >>> optimizer_hook = Fp16OptimizerHook(loss_scale=loss_scale) + """ + + def __init__(self, + grad_clip=None, + coalesce=True, + bucket_size_mb=-1, + loss_scale=512., + distributed=True): + self.grad_clip = grad_clip + self.coalesce = coalesce + self.bucket_size_mb = bucket_size_mb + self.distributed = distributed + self._scale_update_param = None + if loss_scale == 'dynamic': + self.loss_scaler = GradScaler() + elif isinstance(loss_scale, float): + self._scale_update_param = loss_scale + self.loss_scaler = GradScaler(init_scale=loss_scale) + elif isinstance(loss_scale, dict): + self.loss_scaler = GradScaler(**loss_scale) + else: + raise ValueError('loss_scale must be of type float, dict, or ' + f'"dynamic", got {loss_scale}') + + def before_run(self, runner): + """Preparing steps before Mixed Precision Training.""" + # wrap model mode to fp16 + wrap_fp16_model(runner.model) + # resume from state dict + if 'fp16' in runner.meta and 'loss_scaler' in runner.meta['fp16']: + scaler_state_dict = runner.meta['fp16']['loss_scaler'] + self.loss_scaler.load_state_dict(scaler_state_dict) + + def copy_grads_to_fp32(self, fp16_net, fp32_weights): + """Copy gradients from fp16 model to fp32 weight copy.""" + for fp32_param, fp16_param in zip(fp32_weights, + fp16_net.parameters()): + if fp16_param.grad is not None: + if fp32_param.grad is None: + fp32_param.grad = fp32_param.data.new( + fp32_param.size()) + fp32_param.grad.copy_(fp16_param.grad) + + def copy_params_to_fp16(self, fp16_net, fp32_weights): + """Copy updated params from fp32 weight copy to fp16 model.""" + for fp16_param, fp32_param in zip(fp16_net.parameters(), + fp32_weights): + fp16_param.data.copy_(fp32_param.data) + + def after_train_iter(self, runner): + """Backward optimization steps for Mixed Precision Training. For + dynamic loss scaling, please refer to + https://pytorch.org/docs/stable/amp.html#torch.cuda.amp.GradScaler. + + 1. Scale the loss by a scale factor. + 2. Backward the loss to obtain the gradients. + 3. Unscale the optimizer’s gradient tensors. + 4. Call optimizer.step() and update scale factor. + 5. Save loss_scaler state_dict for resume purpose. + """ + # clear grads of last iteration + runner.model.zero_grad() + runner.optimizer.zero_grad() + + self.loss_scaler.scale(runner.outputs['loss']).backward() + self.loss_scaler.unscale_(runner.optimizer) + # grad clip + if self.grad_clip is not None: + grad_norm = self.clip_grads(runner.model.parameters()) + if grad_norm is not None: + # Add grad norm to the logger + runner.log_buffer.update({'grad_norm': float(grad_norm)}, + runner.outputs['num_samples']) + # backward and update scaler + self.loss_scaler.step(runner.optimizer) + self.loss_scaler.update(self._scale_update_param) + + # save state_dict of loss_scaler + runner.meta.setdefault( + 'fp16', {})['loss_scaler'] = self.loss_scaler.state_dict() + + @HOOKS.register_module() + class GradientCumulativeFp16OptimizerHook(GradientCumulativeOptimizerHook, + Fp16OptimizerHook): + """Fp16 optimizer Hook (using PyTorch's implementation) implements + multi-iters gradient cumulating. + + If you are using PyTorch >= 1.6, torch.cuda.amp is used as the backend, + to take care of the optimization procedure. + """ + + def __init__(self, *args, **kwargs): + super(GradientCumulativeFp16OptimizerHook, + self).__init__(*args, **kwargs) + + def after_train_iter(self, runner): + if not self.initialized: + self._init(runner) + + if runner.iter < self.divisible_iters: + loss_factor = self.cumulative_iters + else: + loss_factor = self.remainder_iters + loss = runner.outputs['loss'] + loss = loss / loss_factor + + self.loss_scaler.scale(loss).backward() + + if (self.every_n_iters(runner, self.cumulative_iters) + or self.is_last_iter(runner)): + + # copy fp16 grads in the model to fp32 params in the optimizer + self.loss_scaler.unscale_(runner.optimizer) + + if self.grad_clip is not None: + grad_norm = self.clip_grads(runner.model.parameters()) + if grad_norm is not None: + # Add grad norm to the logger + runner.log_buffer.update( + {'grad_norm': float(grad_norm)}, + runner.outputs['num_samples']) + + # backward and update scaler + self.loss_scaler.step(runner.optimizer) + self.loss_scaler.update(self._scale_update_param) + + # save state_dict of loss_scaler + runner.meta.setdefault( + 'fp16', {})['loss_scaler'] = self.loss_scaler.state_dict() + + # clear grads + runner.model.zero_grad() + runner.optimizer.zero_grad() + +else: + + @HOOKS.register_module() + class Fp16OptimizerHook(OptimizerHook): + """FP16 optimizer hook (mmcv's implementation). + + The steps of fp16 optimizer is as follows. + 1. Scale the loss value. + 2. BP in the fp16 model. + 2. Copy gradients from fp16 model to fp32 weights. + 3. Update fp32 weights. + 4. Copy updated parameters from fp32 weights to fp16 model. + + Refer to https://arxiv.org/abs/1710.03740 for more details. + + Args: + loss_scale (float | str | dict): Scale factor configuration. + If loss_scale is a float, static loss scaling will be used with + the specified scale. If loss_scale is a string, it must be + 'dynamic', then dynamic loss scaling will be used. + It can also be a dict containing arguments of LossScaler. + Defaults to 512. + """ + + def __init__(self, + grad_clip=None, + coalesce=True, + bucket_size_mb=-1, + loss_scale=512., + distributed=True): + self.grad_clip = grad_clip + self.coalesce = coalesce + self.bucket_size_mb = bucket_size_mb + self.distributed = distributed + if loss_scale == 'dynamic': + self.loss_scaler = LossScaler(mode='dynamic') + elif isinstance(loss_scale, float): + self.loss_scaler = LossScaler( + init_scale=loss_scale, mode='static') + elif isinstance(loss_scale, dict): + self.loss_scaler = LossScaler(**loss_scale) + else: + raise ValueError('loss_scale must be of type float, dict, or ' + f'"dynamic", got {loss_scale}') + + def before_run(self, runner): + """Preparing steps before Mixed Precision Training. + + 1. Make a master copy of fp32 weights for optimization. + 2. Convert the main model from fp32 to fp16. + """ + # keep a copy of fp32 weights + old_groups = runner.optimizer.param_groups + runner.optimizer.param_groups = copy.deepcopy( + runner.optimizer.param_groups) + state = defaultdict(dict) + p_map = { + old_p: p + for old_p, p in zip( + chain(*(g['params'] for g in old_groups)), + chain(*(g['params'] + for g in runner.optimizer.param_groups))) + } + for k, v in runner.optimizer.state.items(): + state[p_map[k]] = v + runner.optimizer.state = state + # convert model to fp16 + wrap_fp16_model(runner.model) + # resume from state dict + if 'fp16' in runner.meta and 'loss_scaler' in runner.meta['fp16']: + scaler_state_dict = runner.meta['fp16']['loss_scaler'] + self.loss_scaler.load_state_dict(scaler_state_dict) + + def copy_grads_to_fp32(self, fp16_net, fp32_weights): + """Copy gradients from fp16 model to fp32 weight copy.""" + for fp32_param, fp16_param in zip(fp32_weights, + fp16_net.parameters()): + if fp16_param.grad is not None: + if fp32_param.grad is None: + fp32_param.grad = fp32_param.data.new( + fp32_param.size()) + fp32_param.grad.copy_(fp16_param.grad) + + def copy_params_to_fp16(self, fp16_net, fp32_weights): + """Copy updated params from fp32 weight copy to fp16 model.""" + for fp16_param, fp32_param in zip(fp16_net.parameters(), + fp32_weights): + fp16_param.data.copy_(fp32_param.data) + + def after_train_iter(self, runner): + """Backward optimization steps for Mixed Precision Training. For + dynamic loss scaling, please refer `loss_scalar.py` + + 1. Scale the loss by a scale factor. + 2. Backward the loss to obtain the gradients (fp16). + 3. Copy gradients from the model to the fp32 weight copy. + 4. Scale the gradients back and update the fp32 weight copy. + 5. Copy back the params from fp32 weight copy to the fp16 model. + 6. Save loss_scaler state_dict for resume purpose. + """ + # clear grads of last iteration + runner.model.zero_grad() + runner.optimizer.zero_grad() + # scale the loss value + scaled_loss = runner.outputs['loss'] * self.loss_scaler.loss_scale + scaled_loss.backward() + # copy fp16 grads in the model to fp32 params in the optimizer + + fp32_weights = [] + for param_group in runner.optimizer.param_groups: + fp32_weights += param_group['params'] + self.copy_grads_to_fp32(runner.model, fp32_weights) + # allreduce grads + if self.distributed: + allreduce_grads(fp32_weights, self.coalesce, + self.bucket_size_mb) + + has_overflow = self.loss_scaler.has_overflow(fp32_weights) + # if has overflow, skip this iteration + if not has_overflow: + # scale the gradients back + for param in fp32_weights: + if param.grad is not None: + param.grad.div_(self.loss_scaler.loss_scale) + if self.grad_clip is not None: + grad_norm = self.clip_grads(fp32_weights) + if grad_norm is not None: + # Add grad norm to the logger + runner.log_buffer.update( + {'grad_norm': float(grad_norm)}, + runner.outputs['num_samples']) + # update fp32 params + runner.optimizer.step() + # copy fp32 params to the fp16 model + self.copy_params_to_fp16(runner.model, fp32_weights) + self.loss_scaler.update_scale(has_overflow) + if has_overflow: + runner.logger.warning('Check overflow, downscale loss scale ' + f'to {self.loss_scaler.cur_scale}') + + # save state_dict of loss_scaler + runner.meta.setdefault( + 'fp16', {})['loss_scaler'] = self.loss_scaler.state_dict() + + @HOOKS.register_module() + class GradientCumulativeFp16OptimizerHook(GradientCumulativeOptimizerHook, + Fp16OptimizerHook): + """Fp16 optimizer Hook (using mmcv implementation) implements multi- + iters gradient cumulating.""" + + def __init__(self, *args, **kwargs): + super(GradientCumulativeFp16OptimizerHook, + self).__init__(*args, **kwargs) + + def after_train_iter(self, runner): + if not self.initialized: + self._init(runner) + + if runner.iter < self.divisible_iters: + loss_factor = self.cumulative_iters + else: + loss_factor = self.remainder_iters + + loss = runner.outputs['loss'] + loss = loss / loss_factor + + # scale the loss value + scaled_loss = loss * self.loss_scaler.loss_scale + scaled_loss.backward() + + if (self.every_n_iters(runner, self.cumulative_iters) + or self.is_last_iter(runner)): + + # copy fp16 grads in the model to fp32 params in the optimizer + fp32_weights = [] + for param_group in runner.optimizer.param_groups: + fp32_weights += param_group['params'] + self.copy_grads_to_fp32(runner.model, fp32_weights) + # allreduce grads + if self.distributed: + allreduce_grads(fp32_weights, self.coalesce, + self.bucket_size_mb) + + has_overflow = self.loss_scaler.has_overflow(fp32_weights) + # if has overflow, skip this iteration + if not has_overflow: + # scale the gradients back + for param in fp32_weights: + if param.grad is not None: + param.grad.div_(self.loss_scaler.loss_scale) + if self.grad_clip is not None: + grad_norm = self.clip_grads(fp32_weights) + if grad_norm is not None: + # Add grad norm to the logger + runner.log_buffer.update( + {'grad_norm': float(grad_norm)}, + runner.outputs['num_samples']) + # update fp32 params + runner.optimizer.step() + # copy fp32 params to the fp16 model + self.copy_params_to_fp16(runner.model, fp32_weights) + else: + runner.logger.warning( + 'Check overflow, downscale loss scale ' + f'to {self.loss_scaler.cur_scale}') + + self.loss_scaler.update_scale(has_overflow) + + # save state_dict of loss_scaler + runner.meta.setdefault( + 'fp16', {})['loss_scaler'] = self.loss_scaler.state_dict() + + # clear grads + runner.model.zero_grad() + runner.optimizer.zero_grad() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/profiler.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/profiler.py new file mode 100644 index 000000000..b70236997 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/profiler.py @@ -0,0 +1,180 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import warnings +from typing import Callable, List, Optional, Union + +import torch + +from ..dist_utils import master_only +from .hook import HOOKS, Hook + + +@HOOKS.register_module() +class ProfilerHook(Hook): + """Profiler to analyze performance during training. + + PyTorch Profiler is a tool that allows the collection of the performance + metrics during the training. More details on Profiler can be found at + https://pytorch.org/docs/1.8.1/profiler.html#torch.profiler.profile + + Args: + by_epoch (bool): Profile performance by epoch or by iteration. + Default: True. + profile_iters (int): Number of iterations for profiling. + If ``by_epoch=True``, profile_iters indicates that they are the + first profile_iters epochs at the beginning of the + training, otherwise it indicates the first profile_iters + iterations. Default: 1. + activities (list[str]): List of activity groups (CPU, CUDA) to use in + profiling. Default: ['cpu', 'cuda']. + schedule (dict, optional): Config of generating the callable schedule. + if schedule is None, profiler will not add step markers into the + trace and table view. Default: None. + on_trace_ready (callable, dict): Either a handler or a dict of generate + handler. Default: None. + record_shapes (bool): Save information about operator's input shapes. + Default: False. + profile_memory (bool): Track tensor memory allocation/deallocation. + Default: False. + with_stack (bool): Record source information (file and line number) + for the ops. Default: False. + with_flops (bool): Use formula to estimate the FLOPS of specific + operators (matrix multiplication and 2D convolution). + Default: False. + json_trace_path (str, optional): Exports the collected trace in Chrome + JSON format. Default: None. + + Example: + >>> runner = ... # instantiate a Runner + >>> # tensorboard trace + >>> trace_config = dict(type='tb_trace', dir_name='work_dir') + >>> profiler_config = dict(on_trace_ready=trace_config) + >>> runner.register_profiler_hook(profiler_config) + >>> runner.run(data_loaders=[trainloader], workflow=[('train', 1)]) + """ + + def __init__(self, + by_epoch: bool = True, + profile_iters: int = 1, + activities: List[str] = ['cpu', 'cuda'], + schedule: Optional[dict] = None, + on_trace_ready: Optional[Union[Callable, dict]] = None, + record_shapes: bool = False, + profile_memory: bool = False, + with_stack: bool = False, + with_flops: bool = False, + json_trace_path: Optional[str] = None) -> None: + try: + from torch import profiler # torch version >= 1.8.1 + except ImportError: + raise ImportError('profiler is the new feature of torch1.8.1, ' + f'but your version is {torch.__version__}') + + assert isinstance(by_epoch, bool), '``by_epoch`` should be a boolean.' + self.by_epoch = by_epoch + + if profile_iters < 1: + raise ValueError('profile_iters should be greater than 0, but got ' + f'{profile_iters}') + self.profile_iters = profile_iters + + if not isinstance(activities, list): + raise ValueError( + f'activities should be list, but got {type(activities)}') + self.activities = [] + for activity in activities: + activity = activity.lower() + if activity == 'cpu': + self.activities.append(profiler.ProfilerActivity.CPU) + elif activity == 'cuda': + self.activities.append(profiler.ProfilerActivity.CUDA) + else: + raise ValueError( + f'activity should be "cpu" or "cuda", but got {activity}') + + if schedule is not None: + self.schedule = profiler.schedule(**schedule) + else: + self.schedule = None + + self.on_trace_ready = on_trace_ready + self.record_shapes = record_shapes + self.profile_memory = profile_memory + self.with_stack = with_stack + self.with_flops = with_flops + self.json_trace_path = json_trace_path + + @master_only + def before_run(self, runner): + if self.by_epoch and runner.max_epochs < self.profile_iters: + raise ValueError('self.profile_iters should not be greater than ' + f'{runner.max_epochs}') + + if not self.by_epoch and runner.max_iters < self.profile_iters: + raise ValueError('self.profile_iters should not be greater than ' + f'{runner.max_iters}') + + if callable(self.on_trace_ready): # handler + _on_trace_ready = self.on_trace_ready + elif isinstance(self.on_trace_ready, dict): # config of handler + trace_cfg = self.on_trace_ready.copy() + trace_type = trace_cfg.pop('type') # log_trace handler + if trace_type == 'log_trace': + + def _log_handler(prof): + print(prof.key_averages().table(**trace_cfg)) + + _on_trace_ready = _log_handler + elif trace_type == 'tb_trace': # tensorboard_trace handler + try: + import torch_tb_profiler # noqa: F401 + except ImportError: + raise ImportError('please run "pip install ' + 'torch-tb-profiler" to install ' + 'torch_tb_profiler') + _on_trace_ready = torch.profiler.tensorboard_trace_handler( + **trace_cfg) + else: + raise ValueError('trace_type should be "log_trace" or ' + f'"tb_trace", but got {trace_type}') + elif self.on_trace_ready is None: + _on_trace_ready = None # type: ignore + else: + raise ValueError('on_trace_ready should be handler, dict or None, ' + f'but got {type(self.on_trace_ready)}') + + if runner.max_epochs > 1: + warnings.warn(f'profiler will profile {runner.max_epochs} epochs ' + 'instead of 1 epoch. Since profiler will slow down ' + 'the training, it is recommended to train 1 epoch ' + 'with ProfilerHook and adjust your setting according' + ' to the profiler summary. During normal training ' + '(epoch > 1), you may disable the ProfilerHook.') + + self.profiler = torch.profiler.profile( + activities=self.activities, + schedule=self.schedule, + on_trace_ready=_on_trace_ready, + record_shapes=self.record_shapes, + profile_memory=self.profile_memory, + with_stack=self.with_stack, + with_flops=self.with_flops) + + self.profiler.__enter__() + runner.logger.info('profiler is profiling...') + + @master_only + def after_train_epoch(self, runner): + if self.by_epoch and runner.epoch == self.profile_iters - 1: + runner.logger.info('profiler may take a few minutes...') + self.profiler.__exit__(None, None, None) + if self.json_trace_path is not None: + self.profiler.export_chrome_trace(self.json_trace_path) + + @master_only + def after_train_iter(self, runner): + self.profiler.step() + if not self.by_epoch and runner.iter == self.profile_iters - 1: + runner.logger.info('profiler may take a few minutes...') + self.profiler.__exit__(None, None, None) + if self.json_trace_path is not None: + self.profiler.export_chrome_trace(self.json_trace_path) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/sampler_seed.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/sampler_seed.py new file mode 100644 index 000000000..ee0dc6bdd --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/sampler_seed.py @@ -0,0 +1,20 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .hook import HOOKS, Hook + + +@HOOKS.register_module() +class DistSamplerSeedHook(Hook): + """Data-loading sampler for distributed training. + + When distributed training, it is only useful in conjunction with + :obj:`EpochBasedRunner`, while :obj:`IterBasedRunner` achieves the same + purpose with :obj:`IterLoader`. + """ + + def before_epoch(self, runner): + if hasattr(runner.data_loader.sampler, 'set_epoch'): + # in case the data loader uses `SequentialSampler` in Pytorch + runner.data_loader.sampler.set_epoch(runner.epoch) + elif hasattr(runner.data_loader.batch_sampler.sampler, 'set_epoch'): + # batch sampler in pytorch warps the sampler as its attributes. + runner.data_loader.batch_sampler.sampler.set_epoch(runner.epoch) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/sync_buffer.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/sync_buffer.py new file mode 100644 index 000000000..6376b7ff8 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/hooks/sync_buffer.py @@ -0,0 +1,22 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from ..dist_utils import allreduce_params +from .hook import HOOKS, Hook + + +@HOOKS.register_module() +class SyncBuffersHook(Hook): + """Synchronize model buffers such as running_mean and running_var in BN at + the end of each epoch. + + Args: + distributed (bool): Whether distributed training is used. It is + effective only for distributed training. Defaults to True. + """ + + def __init__(self, distributed=True): + self.distributed = distributed + + def after_epoch(self, runner): + """All-reduce model buffers at the end of each epoch.""" + if self.distributed: + allreduce_params(runner.model.buffers()) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/iter_based_runner.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/iter_based_runner.py new file mode 100644 index 000000000..9892b07a4 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/iter_based_runner.py @@ -0,0 +1,273 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import os.path as osp +import platform +import shutil +import time +import warnings + +import torch +from torch.optim import Optimizer + +import mmcv +from .base_runner import BaseRunner +from .builder import RUNNERS +from .checkpoint import save_checkpoint +from .hooks import IterTimerHook +from .utils import get_host_info + + +class IterLoader: + + def __init__(self, dataloader): + self._dataloader = dataloader + self.iter_loader = iter(self._dataloader) + self._epoch = 0 + + @property + def epoch(self): + return self._epoch + + def __next__(self): + try: + data = next(self.iter_loader) + except StopIteration: + self._epoch += 1 + if hasattr(self._dataloader.sampler, 'set_epoch'): + self._dataloader.sampler.set_epoch(self._epoch) + time.sleep(2) # Prevent possible deadlock during epoch transition + self.iter_loader = iter(self._dataloader) + data = next(self.iter_loader) + + return data + + def __len__(self): + return len(self._dataloader) + + +@RUNNERS.register_module() +class IterBasedRunner(BaseRunner): + """Iteration-based Runner. + + This runner train models iteration by iteration. + """ + + def train(self, data_loader, **kwargs): + self.model.train() + self.mode = 'train' + self.data_loader = data_loader + self._epoch = data_loader.epoch + data_batch = next(data_loader) + self.call_hook('before_train_iter') + outputs = self.model.train_step(data_batch, self.optimizer, **kwargs) + if not isinstance(outputs, dict): + raise TypeError('model.train_step() must return a dict') + if 'log_vars' in outputs: + self.log_buffer.update(outputs['log_vars'], outputs['num_samples']) + self.outputs = outputs + self.call_hook('after_train_iter') + self._inner_iter += 1 + self._iter += 1 + + @torch.no_grad() + def val(self, data_loader, **kwargs): + self.model.eval() + self.mode = 'val' + self.data_loader = data_loader + data_batch = next(data_loader) + self.call_hook('before_val_iter') + outputs = self.model.val_step(data_batch, **kwargs) + if not isinstance(outputs, dict): + raise TypeError('model.val_step() must return a dict') + if 'log_vars' in outputs: + self.log_buffer.update(outputs['log_vars'], outputs['num_samples']) + self.outputs = outputs + self.call_hook('after_val_iter') + self._inner_iter += 1 + + def run(self, data_loaders, workflow, max_iters=None, **kwargs): + """Start running. + + Args: + data_loaders (list[:obj:`DataLoader`]): Dataloaders for training + and validation. + workflow (list[tuple]): A list of (phase, iters) to specify the + running order and iterations. E.g, [('train', 10000), + ('val', 1000)] means running 10000 iterations for training and + 1000 iterations for validation, iteratively. + """ + assert isinstance(data_loaders, list) + assert mmcv.is_list_of(workflow, tuple) + assert len(data_loaders) == len(workflow) + if max_iters is not None: + warnings.warn( + 'setting max_iters in run is deprecated, ' + 'please set max_iters in runner_config', DeprecationWarning) + self._max_iters = max_iters + assert self._max_iters is not None, ( + 'max_iters must be specified during instantiation') + + work_dir = self.work_dir if self.work_dir is not None else 'NONE' + self.logger.info('Start running, host: %s, work_dir: %s', + get_host_info(), work_dir) + self.logger.info('Hooks will be executed in the following order:\n%s', + self.get_hook_info()) + self.logger.info('workflow: %s, max: %d iters', workflow, + self._max_iters) + self.call_hook('before_run') + + iter_loaders = [IterLoader(x) for x in data_loaders] + + self.call_hook('before_epoch') + + while self.iter < self._max_iters: + for i, flow in enumerate(workflow): + self._inner_iter = 0 + mode, iters = flow + if not isinstance(mode, str) or not hasattr(self, mode): + raise ValueError( + 'runner has no method named "{}" to run a workflow'. + format(mode)) + iter_runner = getattr(self, mode) + for _ in range(iters): + if mode == 'train' and self.iter >= self._max_iters: + break + iter_runner(iter_loaders[i], **kwargs) + + time.sleep(1) # wait for some hooks like loggers to finish + self.call_hook('after_epoch') + self.call_hook('after_run') + + def resume(self, + checkpoint, + resume_optimizer=True, + map_location='default'): + """Resume model from checkpoint. + + Args: + checkpoint (str): Checkpoint to resume from. + resume_optimizer (bool, optional): Whether resume the optimizer(s) + if the checkpoint file includes optimizer(s). Default to True. + map_location (str, optional): Same as :func:`torch.load`. + Default to 'default'. + """ + if map_location == 'default': + device_id = torch.cuda.current_device() + checkpoint = self.load_checkpoint( + checkpoint, + map_location=lambda storage, loc: storage.cuda(device_id)) + else: + checkpoint = self.load_checkpoint( + checkpoint, map_location=map_location) + + self._epoch = checkpoint['meta']['epoch'] + self._iter = checkpoint['meta']['iter'] + self._inner_iter = checkpoint['meta']['iter'] + if 'optimizer' in checkpoint and resume_optimizer: + if isinstance(self.optimizer, Optimizer): + self.optimizer.load_state_dict(checkpoint['optimizer']) + elif isinstance(self.optimizer, dict): + for k in self.optimizer.keys(): + self.optimizer[k].load_state_dict( + checkpoint['optimizer'][k]) + else: + raise TypeError( + 'Optimizer should be dict or torch.optim.Optimizer ' + f'but got {type(self.optimizer)}') + + self.logger.info(f'resumed from epoch: {self.epoch}, iter {self.iter}') + + def save_checkpoint(self, + out_dir, + filename_tmpl='iter_{}.pth', + meta=None, + save_optimizer=True, + create_symlink=True): + """Save checkpoint to file. + + Args: + out_dir (str): Directory to save checkpoint files. + filename_tmpl (str, optional): Checkpoint file template. + Defaults to 'iter_{}.pth'. + meta (dict, optional): Metadata to be saved in checkpoint. + Defaults to None. + save_optimizer (bool, optional): Whether save optimizer. + Defaults to True. + create_symlink (bool, optional): Whether create symlink to the + latest checkpoint file. Defaults to True. + """ + if meta is None: + meta = {} + elif not isinstance(meta, dict): + raise TypeError( + f'meta should be a dict or None, but got {type(meta)}') + if self.meta is not None: + meta.update(self.meta) + # Note: meta.update(self.meta) should be done before + # meta.update(epoch=self.epoch + 1, iter=self.iter) otherwise + # there will be problems with resumed checkpoints. + # More details in https://github.com/open-mmlab/mmcv/pull/1108 + meta.update(epoch=self.epoch + 1, iter=self.iter) + + filename = filename_tmpl.format(self.iter + 1) + filepath = osp.join(out_dir, filename) + optimizer = self.optimizer if save_optimizer else None + save_checkpoint(self.model, filepath, optimizer=optimizer, meta=meta) + # in some environments, `os.symlink` is not supported, you may need to + # set `create_symlink` to False + if create_symlink: + dst_file = osp.join(out_dir, 'latest.pth') + if platform.system() != 'Windows': + mmcv.symlink(filename, dst_file) + else: + shutil.copy(filepath, dst_file) + + def register_training_hooks(self, + lr_config, + optimizer_config=None, + checkpoint_config=None, + log_config=None, + momentum_config=None, + custom_hooks_config=None): + """Register default hooks for iter-based training. + + Checkpoint hook, optimizer stepper hook and logger hooks will be set to + `by_epoch=False` by default. + + Default hooks include: + + +----------------------+-------------------------+ + | Hooks | Priority | + +======================+=========================+ + | LrUpdaterHook | VERY_HIGH (10) | + +----------------------+-------------------------+ + | MomentumUpdaterHook | HIGH (30) | + +----------------------+-------------------------+ + | OptimizerStepperHook | ABOVE_NORMAL (40) | + +----------------------+-------------------------+ + | CheckpointSaverHook | NORMAL (50) | + +----------------------+-------------------------+ + | IterTimerHook | LOW (70) | + +----------------------+-------------------------+ + | LoggerHook(s) | VERY_LOW (90) | + +----------------------+-------------------------+ + | CustomHook(s) | defaults to NORMAL (50) | + +----------------------+-------------------------+ + + If custom hooks have same priority with default hooks, custom hooks + will be triggered after default hooks. + """ + if checkpoint_config is not None: + checkpoint_config.setdefault('by_epoch', False) + if lr_config is not None: + lr_config.setdefault('by_epoch', False) + if log_config is not None: + for info in log_config['hooks']: + info.setdefault('by_epoch', False) + super(IterBasedRunner, self).register_training_hooks( + lr_config=lr_config, + momentum_config=momentum_config, + optimizer_config=optimizer_config, + checkpoint_config=checkpoint_config, + log_config=log_config, + timer_config=IterTimerHook(), + custom_hooks_config=custom_hooks_config) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/log_buffer.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/log_buffer.py new file mode 100644 index 000000000..d949e2941 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/log_buffer.py @@ -0,0 +1,41 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from collections import OrderedDict + +import numpy as np + + +class LogBuffer: + + def __init__(self): + self.val_history = OrderedDict() + self.n_history = OrderedDict() + self.output = OrderedDict() + self.ready = False + + def clear(self): + self.val_history.clear() + self.n_history.clear() + self.clear_output() + + def clear_output(self): + self.output.clear() + self.ready = False + + def update(self, vars, count=1): + assert isinstance(vars, dict) + for key, var in vars.items(): + if key not in self.val_history: + self.val_history[key] = [] + self.n_history[key] = [] + self.val_history[key].append(var) + self.n_history[key].append(count) + + def average(self, n=0): + """Average latest n values or all values.""" + assert n >= 0 + for key in self.val_history: + values = np.array(self.val_history[key][-n:]) + nums = np.array(self.n_history[key][-n:]) + avg = np.sum(values * nums) / np.sum(nums) + self.output[key] = avg + self.ready = True diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/optimizer/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/optimizer/__init__.py new file mode 100644 index 000000000..53c34d047 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/optimizer/__init__.py @@ -0,0 +1,9 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .builder import (OPTIMIZER_BUILDERS, OPTIMIZERS, build_optimizer, + build_optimizer_constructor) +from .default_constructor import DefaultOptimizerConstructor + +__all__ = [ + 'OPTIMIZER_BUILDERS', 'OPTIMIZERS', 'DefaultOptimizerConstructor', + 'build_optimizer', 'build_optimizer_constructor' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/optimizer/builder.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/optimizer/builder.py new file mode 100644 index 000000000..f9234eed8 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/optimizer/builder.py @@ -0,0 +1,44 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import copy +import inspect + +import torch + +from ...utils import Registry, build_from_cfg + +OPTIMIZERS = Registry('optimizer') +OPTIMIZER_BUILDERS = Registry('optimizer builder') + + +def register_torch_optimizers(): + torch_optimizers = [] + for module_name in dir(torch.optim): + if module_name.startswith('__'): + continue + _optim = getattr(torch.optim, module_name) + if inspect.isclass(_optim) and issubclass(_optim, + torch.optim.Optimizer): + OPTIMIZERS.register_module()(_optim) + torch_optimizers.append(module_name) + return torch_optimizers + + +TORCH_OPTIMIZERS = register_torch_optimizers() + + +def build_optimizer_constructor(cfg): + return build_from_cfg(cfg, OPTIMIZER_BUILDERS) + + +def build_optimizer(model, cfg): + optimizer_cfg = copy.deepcopy(cfg) + constructor_type = optimizer_cfg.pop('constructor', + 'DefaultOptimizerConstructor') + paramwise_cfg = optimizer_cfg.pop('paramwise_cfg', None) + optim_constructor = build_optimizer_constructor( + dict( + type=constructor_type, + optimizer_cfg=optimizer_cfg, + paramwise_cfg=paramwise_cfg)) + optimizer = optim_constructor(model) + return optimizer diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/optimizer/default_constructor.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/optimizer/default_constructor.py new file mode 100644 index 000000000..e5f5db271 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/optimizer/default_constructor.py @@ -0,0 +1,247 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import warnings + +import torch +from torch.nn import GroupNorm, LayerNorm + +from mmcv.utils import _BatchNorm, _InstanceNorm, build_from_cfg, is_list_of +from mmcv.utils.ext_loader import check_ops_exist +from .builder import OPTIMIZER_BUILDERS, OPTIMIZERS + + +@OPTIMIZER_BUILDERS.register_module() +class DefaultOptimizerConstructor: + """Default constructor for optimizers. + + By default each parameter share the same optimizer settings, and we + provide an argument ``paramwise_cfg`` to specify parameter-wise settings. + It is a dict and may contain the following fields: + + - ``custom_keys`` (dict): Specified parameters-wise settings by keys. If + one of the keys in ``custom_keys`` is a substring of the name of one + parameter, then the setting of the parameter will be specified by + ``custom_keys[key]`` and other setting like ``bias_lr_mult`` etc. will + be ignored. It should be noted that the aforementioned ``key`` is the + longest key that is a substring of the name of the parameter. If there + are multiple matched keys with the same length, then the key with lower + alphabet order will be chosen. + ``custom_keys[key]`` should be a dict and may contain fields ``lr_mult`` + and ``decay_mult``. See Example 2 below. + - ``bias_lr_mult`` (float): It will be multiplied to the learning + rate for all bias parameters (except for those in normalization + layers and offset layers of DCN). + - ``bias_decay_mult`` (float): It will be multiplied to the weight + decay for all bias parameters (except for those in + normalization layers, depthwise conv layers, offset layers of DCN). + - ``norm_decay_mult`` (float): It will be multiplied to the weight + decay for all weight and bias parameters of normalization + layers. + - ``dwconv_decay_mult`` (float): It will be multiplied to the weight + decay for all weight and bias parameters of depthwise conv + layers. + - ``dcn_offset_lr_mult`` (float): It will be multiplied to the learning + rate for parameters of offset layer in the deformable convs + of a model. + - ``bypass_duplicate`` (bool): If true, the duplicate parameters + would not be added into optimizer. Default: False. + + Note: + 1. If the option ``dcn_offset_lr_mult`` is used, the constructor will + override the effect of ``bias_lr_mult`` in the bias of offset + layer. So be careful when using both ``bias_lr_mult`` and + ``dcn_offset_lr_mult``. If you wish to apply both of them to the + offset layer in deformable convs, set ``dcn_offset_lr_mult`` + to the original ``dcn_offset_lr_mult`` * ``bias_lr_mult``. + 2. If the option ``dcn_offset_lr_mult`` is used, the constructor will + apply it to all the DCN layers in the model. So be careful when + the model contains multiple DCN layers in places other than + backbone. + + Args: + model (:obj:`nn.Module`): The model with parameters to be optimized. + optimizer_cfg (dict): The config dict of the optimizer. + Positional fields are + + - `type`: class name of the optimizer. + + Optional fields are + + - any arguments of the corresponding optimizer type, e.g., + lr, weight_decay, momentum, etc. + paramwise_cfg (dict, optional): Parameter-wise options. + + Example 1: + >>> model = torch.nn.modules.Conv1d(1, 1, 1) + >>> optimizer_cfg = dict(type='SGD', lr=0.01, momentum=0.9, + >>> weight_decay=0.0001) + >>> paramwise_cfg = dict(norm_decay_mult=0.) + >>> optim_builder = DefaultOptimizerConstructor( + >>> optimizer_cfg, paramwise_cfg) + >>> optimizer = optim_builder(model) + + Example 2: + >>> # assume model have attribute model.backbone and model.cls_head + >>> optimizer_cfg = dict(type='SGD', lr=0.01, weight_decay=0.95) + >>> paramwise_cfg = dict(custom_keys={ + '.backbone': dict(lr_mult=0.1, decay_mult=0.9)}) + >>> optim_builder = DefaultOptimizerConstructor( + >>> optimizer_cfg, paramwise_cfg) + >>> optimizer = optim_builder(model) + >>> # Then the `lr` and `weight_decay` for model.backbone is + >>> # (0.01 * 0.1, 0.95 * 0.9). `lr` and `weight_decay` for + >>> # model.cls_head is (0.01, 0.95). + """ + + def __init__(self, optimizer_cfg, paramwise_cfg=None): + if not isinstance(optimizer_cfg, dict): + raise TypeError('optimizer_cfg should be a dict', + f'but got {type(optimizer_cfg)}') + self.optimizer_cfg = optimizer_cfg + self.paramwise_cfg = {} if paramwise_cfg is None else paramwise_cfg + self.base_lr = optimizer_cfg.get('lr', None) + self.base_wd = optimizer_cfg.get('weight_decay', None) + self._validate_cfg() + + def _validate_cfg(self): + if not isinstance(self.paramwise_cfg, dict): + raise TypeError('paramwise_cfg should be None or a dict, ' + f'but got {type(self.paramwise_cfg)}') + + if 'custom_keys' in self.paramwise_cfg: + if not isinstance(self.paramwise_cfg['custom_keys'], dict): + raise TypeError( + 'If specified, custom_keys must be a dict, ' + f'but got {type(self.paramwise_cfg["custom_keys"])}') + if self.base_wd is None: + for key in self.paramwise_cfg['custom_keys']: + if 'decay_mult' in self.paramwise_cfg['custom_keys'][key]: + raise ValueError('base_wd should not be None') + + # get base lr and weight decay + # weight_decay must be explicitly specified if mult is specified + if ('bias_decay_mult' in self.paramwise_cfg + or 'norm_decay_mult' in self.paramwise_cfg + or 'dwconv_decay_mult' in self.paramwise_cfg): + if self.base_wd is None: + raise ValueError('base_wd should not be None') + + def _is_in(self, param_group, param_group_list): + assert is_list_of(param_group_list, dict) + param = set(param_group['params']) + param_set = set() + for group in param_group_list: + param_set.update(set(group['params'])) + + return not param.isdisjoint(param_set) + + def add_params(self, params, module, prefix='', is_dcn_module=None): + """Add all parameters of module to the params list. + + The parameters of the given module will be added to the list of param + groups, with specific rules defined by paramwise_cfg. + + Args: + params (list[dict]): A list of param groups, it will be modified + in place. + module (nn.Module): The module to be added. + prefix (str): The prefix of the module + is_dcn_module (int|float|None): If the current module is a + submodule of DCN, `is_dcn_module` will be passed to + control conv_offset layer's learning rate. Defaults to None. + """ + # get param-wise options + custom_keys = self.paramwise_cfg.get('custom_keys', {}) + # first sort with alphabet order and then sort with reversed len of str + sorted_keys = sorted(sorted(custom_keys.keys()), key=len, reverse=True) + + bias_lr_mult = self.paramwise_cfg.get('bias_lr_mult', 1.) + bias_decay_mult = self.paramwise_cfg.get('bias_decay_mult', 1.) + norm_decay_mult = self.paramwise_cfg.get('norm_decay_mult', 1.) + dwconv_decay_mult = self.paramwise_cfg.get('dwconv_decay_mult', 1.) + bypass_duplicate = self.paramwise_cfg.get('bypass_duplicate', False) + dcn_offset_lr_mult = self.paramwise_cfg.get('dcn_offset_lr_mult', 1.) + + # special rules for norm layers and depth-wise conv layers + is_norm = isinstance(module, + (_BatchNorm, _InstanceNorm, GroupNorm, LayerNorm)) + is_dwconv = ( + isinstance(module, torch.nn.Conv2d) + and module.in_channels == module.groups) + + for name, param in module.named_parameters(recurse=False): + param_group = {'params': [param]} + if not param.requires_grad: + params.append(param_group) + continue + if bypass_duplicate and self._is_in(param_group, params): + warnings.warn(f'{prefix} is duplicate. It is skipped since ' + f'bypass_duplicate={bypass_duplicate}') + continue + # if the parameter match one of the custom keys, ignore other rules + is_custom = False + for key in sorted_keys: + if key in f'{prefix}.{name}': + is_custom = True + lr_mult = custom_keys[key].get('lr_mult', 1.) + param_group['lr'] = self.base_lr * lr_mult + if self.base_wd is not None: + decay_mult = custom_keys[key].get('decay_mult', 1.) + param_group['weight_decay'] = self.base_wd * decay_mult + break + + if not is_custom: + # bias_lr_mult affects all bias parameters + # except for norm.bias dcn.conv_offset.bias + if name == 'bias' and not (is_norm or is_dcn_module): + param_group['lr'] = self.base_lr * bias_lr_mult + + if (prefix.find('conv_offset') != -1 and is_dcn_module + and isinstance(module, torch.nn.Conv2d)): + # deal with both dcn_offset's bias & weight + param_group['lr'] = self.base_lr * dcn_offset_lr_mult + + # apply weight decay policies + if self.base_wd is not None: + # norm decay + if is_norm: + param_group[ + 'weight_decay'] = self.base_wd * norm_decay_mult + # depth-wise conv + elif is_dwconv: + param_group[ + 'weight_decay'] = self.base_wd * dwconv_decay_mult + # bias lr and decay + elif name == 'bias' and not is_dcn_module: + # TODO: current bias_decay_mult will have affect on DCN + param_group[ + 'weight_decay'] = self.base_wd * bias_decay_mult + params.append(param_group) + + if check_ops_exist(): + is_dcn_module = False + else: + is_dcn_module = False + for child_name, child_mod in module.named_children(): + child_prefix = f'{prefix}.{child_name}' if prefix else child_name + self.add_params( + params, + child_mod, + prefix=child_prefix, + is_dcn_module=is_dcn_module) + + def __call__(self, model): + if hasattr(model, 'module'): + model = model.module + + optimizer_cfg = self.optimizer_cfg.copy() + # if no paramwise option is specified, just use the global setting + if not self.paramwise_cfg: + optimizer_cfg['params'] = model.parameters() + return build_from_cfg(optimizer_cfg, OPTIMIZERS) + + # set param-wise lr and weight decay recursively + params = [] + self.add_params(params, model) + optimizer_cfg['params'] = params + + return build_from_cfg(optimizer_cfg, OPTIMIZERS) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/priority.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/priority.py new file mode 100644 index 000000000..64cc4e3a0 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/priority.py @@ -0,0 +1,60 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from enum import Enum + + +class Priority(Enum): + """Hook priority levels. + + +--------------+------------+ + | Level | Value | + +==============+============+ + | HIGHEST | 0 | + +--------------+------------+ + | VERY_HIGH | 10 | + +--------------+------------+ + | HIGH | 30 | + +--------------+------------+ + | ABOVE_NORMAL | 40 | + +--------------+------------+ + | NORMAL | 50 | + +--------------+------------+ + | BELOW_NORMAL | 60 | + +--------------+------------+ + | LOW | 70 | + +--------------+------------+ + | VERY_LOW | 90 | + +--------------+------------+ + | LOWEST | 100 | + +--------------+------------+ + """ + + HIGHEST = 0 + VERY_HIGH = 10 + HIGH = 30 + ABOVE_NORMAL = 40 + NORMAL = 50 + BELOW_NORMAL = 60 + LOW = 70 + VERY_LOW = 90 + LOWEST = 100 + + +def get_priority(priority): + """Get priority value. + + Args: + priority (int or str or :obj:`Priority`): Priority. + + Returns: + int: The priority value. + """ + if isinstance(priority, int): + if priority < 0 or priority > 100: + raise ValueError('priority must be between 0 and 100') + return priority + elif isinstance(priority, Priority): + return priority.value + elif isinstance(priority, str): + return Priority[priority.upper()].value + else: + raise TypeError('priority must be an integer or Priority enum value') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/utils.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/utils.py new file mode 100644 index 000000000..144d11e1a --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/runner/utils.py @@ -0,0 +1,93 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import os +import random +import sys +import time +import warnings +from getpass import getuser +from socket import gethostname + +import numpy as np +import torch + +import mmcv + + +def get_host_info(): + """Get hostname and username. + + Return empty string if exception raised, e.g. ``getpass.getuser()`` will + lead to error in docker container + """ + host = '' + try: + host = f'{getuser()}@{gethostname()}' + except Exception as e: + warnings.warn(f'Host or user not found: {str(e)}') + finally: + return host + + +def get_time_str(): + return time.strftime('%Y%m%d_%H%M%S', time.localtime()) + + +def obj_from_dict(info, parent=None, default_args=None): + """Initialize an object from dict. + + The dict must contain the key "type", which indicates the object type, it + can be either a string or type, such as "list" or ``list``. Remaining + fields are treated as the arguments for constructing the object. + + Args: + info (dict): Object types and arguments. + parent (:class:`module`): Module which may containing expected object + classes. + default_args (dict, optional): Default arguments for initializing the + object. + + Returns: + any type: Object built from the dict. + """ + assert isinstance(info, dict) and 'type' in info + assert isinstance(default_args, dict) or default_args is None + args = info.copy() + obj_type = args.pop('type') + if mmcv.is_str(obj_type): + if parent is not None: + obj_type = getattr(parent, obj_type) + else: + obj_type = sys.modules[obj_type] + elif not isinstance(obj_type, type): + raise TypeError('type must be a str or valid type, but ' + f'got {type(obj_type)}') + if default_args is not None: + for name, value in default_args.items(): + args.setdefault(name, value) + return obj_type(**args) + + +def set_random_seed(seed, deterministic=False, use_rank_shift=False): + """Set random seed. + + Args: + seed (int): Seed to be used. + deterministic (bool): Whether to set the deterministic option for + CUDNN backend, i.e., set `torch.backends.cudnn.deterministic` + to True and `torch.backends.cudnn.benchmark` to False. + Default: False. + rank_shift (bool): Whether to add rank number to the random seed to + have different random seed in different threads. Default: False. + """ + if use_rank_shift: + rank, _ = mmcv.runner.get_dist_info() + seed += rank + random.seed(seed) + np.random.seed(seed) + torch.manual_seed(seed) + torch.cuda.manual_seed(seed) + torch.cuda.manual_seed_all(seed) + os.environ['PYTHONHASHSEED'] = str(seed) + if deterministic: + torch.backends.cudnn.deterministic = True + torch.backends.cudnn.benchmark = False diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/__init__.py new file mode 100644 index 000000000..378a00684 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/__init__.py @@ -0,0 +1,69 @@ +# flake8: noqa +# Copyright (c) OpenMMLab. All rights reserved. +from .config import Config, ConfigDict, DictAction +from .misc import (check_prerequisites, concat_list, deprecated_api_warning, + has_method, import_modules_from_strings, is_list_of, + is_method_overridden, is_seq_of, is_str, is_tuple_of, + iter_cast, list_cast, requires_executable, requires_package, + slice_list, to_1tuple, to_2tuple, to_3tuple, to_4tuple, + to_ntuple, tuple_cast) +from .path import (check_file_exist, fopen, is_filepath, mkdir_or_exist, + scandir, symlink) +from .progressbar import (ProgressBar, track_iter_progress, + track_parallel_progress, track_progress) +from .testing import (assert_attrs_equal, assert_dict_contains_subset, + assert_dict_has_keys, assert_is_norm_layer, + assert_keys_equal, assert_params_all_zeros, + check_python_script) +from .timer import Timer, TimerError, check_time +from .version_utils import digit_version, get_git_hash + +try: + import torch +except ImportError: + __all__ = [ + 'Config', 'ConfigDict', 'DictAction', 'is_str', 'iter_cast', + 'list_cast', 'tuple_cast', 'is_seq_of', 'is_list_of', 'is_tuple_of', + 'slice_list', 'concat_list', 'check_prerequisites', 'requires_package', + 'requires_executable', 'is_filepath', 'fopen', 'check_file_exist', + 'mkdir_or_exist', 'symlink', 'scandir', 'ProgressBar', + 'track_progress', 'track_iter_progress', 'track_parallel_progress', + 'Timer', 'TimerError', 'check_time', 'deprecated_api_warning', + 'digit_version', 'get_git_hash', 'import_modules_from_strings', + 'assert_dict_contains_subset', 'assert_attrs_equal', + 'assert_dict_has_keys', 'assert_keys_equal', 'check_python_script', + 'to_1tuple', 'to_2tuple', 'to_3tuple', 'to_4tuple', 'to_ntuple', + 'is_method_overridden', 'has_method' + ] +else: + from .env import collect_env + from .logging import get_logger, print_log + from .parrots_jit import jit, skip_no_elena + from .parrots_wrapper import ( + TORCH_VERSION, BuildExtension, CppExtension, CUDAExtension, DataLoader, + PoolDataLoader, SyncBatchNorm, _AdaptiveAvgPoolNd, _AdaptiveMaxPoolNd, + _AvgPoolNd, _BatchNorm, _ConvNd, _ConvTransposeMixin, _InstanceNorm, + _MaxPoolNd, get_build_config, is_rocm_pytorch, _get_cuda_home) + from .registry import Registry, build_from_cfg + from .trace import is_jit_tracing + __all__ = [ + 'Config', 'ConfigDict', 'DictAction', 'collect_env', 'get_logger', + 'print_log', 'is_str', 'iter_cast', 'list_cast', 'tuple_cast', + 'is_seq_of', 'is_list_of', 'is_tuple_of', 'slice_list', 'concat_list', + 'check_prerequisites', 'requires_package', 'requires_executable', + 'is_filepath', 'fopen', 'check_file_exist', 'mkdir_or_exist', + 'symlink', 'scandir', 'ProgressBar', 'track_progress', + 'track_iter_progress', 'track_parallel_progress', 'Registry', + 'build_from_cfg', 'Timer', 'TimerError', 'check_time', 'SyncBatchNorm', + '_AdaptiveAvgPoolNd', '_AdaptiveMaxPoolNd', '_AvgPoolNd', '_BatchNorm', + '_ConvNd', '_ConvTransposeMixin', '_InstanceNorm', '_MaxPoolNd', + 'get_build_config', 'BuildExtension', 'CppExtension', 'CUDAExtension', + 'DataLoader', 'PoolDataLoader', 'TORCH_VERSION', + 'deprecated_api_warning', 'digit_version', 'get_git_hash', + 'import_modules_from_strings', 'jit', 'skip_no_elena', + 'assert_dict_contains_subset', 'assert_attrs_equal', + 'assert_dict_has_keys', 'assert_keys_equal', 'assert_is_norm_layer', + 'assert_params_all_zeros', 'check_python_script', + 'is_method_overridden', 'is_jit_tracing', 'is_rocm_pytorch', + '_get_cuda_home', 'has_method' + ] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/config.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/config.py new file mode 100644 index 000000000..c71377c07 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/config.py @@ -0,0 +1,688 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import ast +import copy +import os +import os.path as osp +import platform +import shutil +import sys +import tempfile +import uuid +import warnings +from argparse import Action, ArgumentParser +from collections import abc +from importlib import import_module + +from addict import Dict +from yapf.yapflib.yapf_api import FormatCode + +from .misc import import_modules_from_strings +from .path import check_file_exist + +if platform.system() == 'Windows': + import regex as re +else: + import re + +BASE_KEY = '_base_' +DELETE_KEY = '_delete_' +DEPRECATION_KEY = '_deprecation_' +RESERVED_KEYS = ['filename', 'text', 'pretty_text'] + + +class ConfigDict(Dict): + + def __missing__(self, name): + raise KeyError(name) + + def __getattr__(self, name): + try: + value = super(ConfigDict, self).__getattr__(name) + except KeyError: + ex = AttributeError(f"'{self.__class__.__name__}' object has no " + f"attribute '{name}'") + except Exception as e: + ex = e + else: + return value + raise ex + + +def add_args(parser, cfg, prefix=''): + for k, v in cfg.items(): + if isinstance(v, str): + parser.add_argument('--' + prefix + k) + elif isinstance(v, int): + parser.add_argument('--' + prefix + k, type=int) + elif isinstance(v, float): + parser.add_argument('--' + prefix + k, type=float) + elif isinstance(v, bool): + parser.add_argument('--' + prefix + k, action='store_true') + elif isinstance(v, dict): + add_args(parser, v, prefix + k + '.') + elif isinstance(v, abc.Iterable): + parser.add_argument('--' + prefix + k, type=type(v[0]), nargs='+') + else: + print(f'cannot parse key {prefix + k} of type {type(v)}') + return parser + + +class Config: + """A facility for config and config files. + + It supports common file formats as configs: python/json/yaml. The interface + is the same as a dict object and also allows access config values as + attributes. + + Example: + >>> cfg = Config(dict(a=1, b=dict(b1=[0, 1]))) + >>> cfg.a + 1 + >>> cfg.b + {'b1': [0, 1]} + >>> cfg.b.b1 + [0, 1] + >>> cfg = Config.fromfile('tests/data/config/a.py') + >>> cfg.filename + "/home/kchen/projects/mmcv/tests/data/config/a.py" + >>> cfg.item4 + 'test' + >>> cfg + "Config [path: /home/kchen/projects/mmcv/tests/data/config/a.py]: " + "{'item1': [1, 2], 'item2': {'a': 0}, 'item3': True, 'item4': 'test'}" + """ + + @staticmethod + def _validate_py_syntax(filename): + with open(filename, 'r', encoding='utf-8') as f: + # Setting encoding explicitly to resolve coding issue on windows + content = f.read() + try: + ast.parse(content) + except SyntaxError as e: + raise SyntaxError('There are syntax errors in config ' + f'file {filename}: {e}') + + @staticmethod + def _substitute_predefined_vars(filename, temp_config_name): + file_dirname = osp.dirname(filename) + file_basename = osp.basename(filename) + file_basename_no_extension = osp.splitext(file_basename)[0] + file_extname = osp.splitext(filename)[1] + support_templates = dict( + fileDirname=file_dirname, + fileBasename=file_basename, + fileBasenameNoExtension=file_basename_no_extension, + fileExtname=file_extname) + with open(filename, 'r', encoding='utf-8') as f: + # Setting encoding explicitly to resolve coding issue on windows + config_file = f.read() + for key, value in support_templates.items(): + regexp = r'\{\{\s*' + str(key) + r'\s*\}\}' + value = value.replace('\\', '/') + config_file = re.sub(regexp, value, config_file) + with open(temp_config_name, 'w', encoding='utf-8') as tmp_config_file: + tmp_config_file.write(config_file) + + @staticmethod + def _pre_substitute_base_vars(filename, temp_config_name): + """Substitute base variable placehoders to string, so that parsing + would work.""" + with open(filename, 'r', encoding='utf-8') as f: + # Setting encoding explicitly to resolve coding issue on windows + config_file = f.read() + base_var_dict = {} + regexp = r'\{\{\s*' + BASE_KEY + r'\.([\w\.]+)\s*\}\}' + base_vars = set(re.findall(regexp, config_file)) + for base_var in base_vars: + randstr = f'_{base_var}_{uuid.uuid4().hex.lower()[:6]}' + base_var_dict[randstr] = base_var + regexp = r'\{\{\s*' + BASE_KEY + r'\.' + base_var + r'\s*\}\}' + config_file = re.sub(regexp, f'"{randstr}"', config_file) + with open(temp_config_name, 'w', encoding='utf-8') as tmp_config_file: + tmp_config_file.write(config_file) + return base_var_dict + + @staticmethod + def _substitute_base_vars(cfg, base_var_dict, base_cfg): + """Substitute variable strings to their actual values.""" + cfg = copy.deepcopy(cfg) + + if isinstance(cfg, dict): + for k, v in cfg.items(): + if isinstance(v, str) and v in base_var_dict: + new_v = base_cfg + for new_k in base_var_dict[v].split('.'): + new_v = new_v[new_k] + cfg[k] = new_v + elif isinstance(v, (list, tuple, dict)): + cfg[k] = Config._substitute_base_vars( + v, base_var_dict, base_cfg) + elif isinstance(cfg, tuple): + cfg = tuple( + Config._substitute_base_vars(c, base_var_dict, base_cfg) + for c in cfg) + elif isinstance(cfg, list): + cfg = [ + Config._substitute_base_vars(c, base_var_dict, base_cfg) + for c in cfg + ] + elif isinstance(cfg, str) and cfg in base_var_dict: + new_v = base_cfg + for new_k in base_var_dict[cfg].split('.'): + new_v = new_v[new_k] + cfg = new_v + + return cfg + + @staticmethod + def _file2dict(filename, use_predefined_variables=True): + filename = osp.abspath(osp.expanduser(filename)) + check_file_exist(filename) + fileExtname = osp.splitext(filename)[1] + if fileExtname not in ['.py', '.json', '.yaml', '.yml']: + raise IOError('Only py/yml/yaml/json type are supported now!') + + with tempfile.TemporaryDirectory() as temp_config_dir: + temp_config_file = tempfile.NamedTemporaryFile( + dir=temp_config_dir, suffix=fileExtname) + if platform.system() == 'Windows': + temp_config_file.close() + temp_config_name = osp.basename(temp_config_file.name) + # Substitute predefined variables + if use_predefined_variables: + Config._substitute_predefined_vars(filename, + temp_config_file.name) + else: + shutil.copyfile(filename, temp_config_file.name) + # Substitute base variables from placeholders to strings + base_var_dict = Config._pre_substitute_base_vars( + temp_config_file.name, temp_config_file.name) + + if filename.endswith('.py'): + temp_module_name = osp.splitext(temp_config_name)[0] + sys.path.insert(0, temp_config_dir) + Config._validate_py_syntax(filename) + mod = import_module(temp_module_name) + sys.path.pop(0) + cfg_dict = { + name: value + for name, value in mod.__dict__.items() + if not name.startswith('__') + } + # delete imported module + del sys.modules[temp_module_name] + elif filename.endswith(('.yml', '.yaml', '.json')): + import mmcv + cfg_dict = mmcv.load(temp_config_file.name) + # close temp file + temp_config_file.close() + + # check deprecation information + if DEPRECATION_KEY in cfg_dict: + deprecation_info = cfg_dict.pop(DEPRECATION_KEY) + warning_msg = f'The config file {filename} will be deprecated ' \ + 'in the future.' + if 'expected' in deprecation_info: + warning_msg += f' Please use {deprecation_info["expected"]} ' \ + 'instead.' + if 'reference' in deprecation_info: + warning_msg += ' More information can be found at ' \ + f'{deprecation_info["reference"]}' + warnings.warn(warning_msg) + + cfg_text = filename + '\n' + with open(filename, 'r', encoding='utf-8') as f: + # Setting encoding explicitly to resolve coding issue on windows + cfg_text += f.read() + + if BASE_KEY in cfg_dict: + cfg_dir = osp.dirname(filename) + base_filename = cfg_dict.pop(BASE_KEY) + base_filename = base_filename if isinstance( + base_filename, list) else [base_filename] + + cfg_dict_list = list() + cfg_text_list = list() + for f in base_filename: + _cfg_dict, _cfg_text = Config._file2dict(osp.join(cfg_dir, f)) + cfg_dict_list.append(_cfg_dict) + cfg_text_list.append(_cfg_text) + + base_cfg_dict = dict() + for c in cfg_dict_list: + duplicate_keys = base_cfg_dict.keys() & c.keys() + if len(duplicate_keys) > 0: + raise KeyError('Duplicate key is not allowed among bases. ' + f'Duplicate keys: {duplicate_keys}') + base_cfg_dict.update(c) + + # Substitute base variables from strings to their actual values + cfg_dict = Config._substitute_base_vars(cfg_dict, base_var_dict, + base_cfg_dict) + + base_cfg_dict = Config._merge_a_into_b(cfg_dict, base_cfg_dict) + cfg_dict = base_cfg_dict + + # merge cfg_text + cfg_text_list.append(cfg_text) + cfg_text = '\n'.join(cfg_text_list) + + return cfg_dict, cfg_text + + @staticmethod + def _merge_a_into_b(a, b, allow_list_keys=False): + """merge dict ``a`` into dict ``b`` (non-inplace). + + Values in ``a`` will overwrite ``b``. ``b`` is copied first to avoid + in-place modifications. + + Args: + a (dict): The source dict to be merged into ``b``. + b (dict): The origin dict to be fetch keys from ``a``. + allow_list_keys (bool): If True, int string keys (e.g. '0', '1') + are allowed in source ``a`` and will replace the element of the + corresponding index in b if b is a list. Default: False. + + Returns: + dict: The modified dict of ``b`` using ``a``. + + Examples: + # Normally merge a into b. + >>> Config._merge_a_into_b( + ... dict(obj=dict(a=2)), dict(obj=dict(a=1))) + {'obj': {'a': 2}} + + # Delete b first and merge a into b. + >>> Config._merge_a_into_b( + ... dict(obj=dict(_delete_=True, a=2)), dict(obj=dict(a=1))) + {'obj': {'a': 2}} + + # b is a list + >>> Config._merge_a_into_b( + ... {'0': dict(a=2)}, [dict(a=1), dict(b=2)], True) + [{'a': 2}, {'b': 2}] + """ + b = b.copy() + for k, v in a.items(): + if allow_list_keys and k.isdigit() and isinstance(b, list): + k = int(k) + if len(b) <= k: + raise KeyError(f'Index {k} exceeds the length of list {b}') + b[k] = Config._merge_a_into_b(v, b[k], allow_list_keys) + elif isinstance(v, + dict) and k in b and not v.pop(DELETE_KEY, False): + allowed_types = (dict, list) if allow_list_keys else dict + if not isinstance(b[k], allowed_types): + raise TypeError( + f'{k}={v} in child config cannot inherit from base ' + f'because {k} is a dict in the child config but is of ' + f'type {type(b[k])} in base config. You may set ' + f'`{DELETE_KEY}=True` to ignore the base config') + b[k] = Config._merge_a_into_b(v, b[k], allow_list_keys) + else: + b[k] = v + return b + + @staticmethod + def fromfile(filename, + use_predefined_variables=True, + import_custom_modules=True): + cfg_dict, cfg_text = Config._file2dict(filename, + use_predefined_variables) + if import_custom_modules and cfg_dict.get('custom_imports', None): + import_modules_from_strings(**cfg_dict['custom_imports']) + return Config(cfg_dict, cfg_text=cfg_text, filename=filename) + + @staticmethod + def fromstring(cfg_str, file_format): + """Generate config from config str. + + Args: + cfg_str (str): Config str. + file_format (str): Config file format corresponding to the + config str. Only py/yml/yaml/json type are supported now! + + Returns: + obj:`Config`: Config obj. + """ + if file_format not in ['.py', '.json', '.yaml', '.yml']: + raise IOError('Only py/yml/yaml/json type are supported now!') + if file_format != '.py' and 'dict(' in cfg_str: + # check if users specify a wrong suffix for python + warnings.warn( + 'Please check "file_format", the file format may be .py') + with tempfile.NamedTemporaryFile( + 'w', encoding='utf-8', suffix=file_format, + delete=False) as temp_file: + temp_file.write(cfg_str) + # on windows, previous implementation cause error + # see PR 1077 for details + cfg = Config.fromfile(temp_file.name) + os.remove(temp_file.name) + return cfg + + @staticmethod + def auto_argparser(description=None): + """Generate argparser from config file automatically (experimental)""" + partial_parser = ArgumentParser(description=description) + partial_parser.add_argument('config', help='config file path') + cfg_file = partial_parser.parse_known_args()[0].config + cfg = Config.fromfile(cfg_file) + parser = ArgumentParser(description=description) + parser.add_argument('config', help='config file path') + add_args(parser, cfg) + return parser, cfg + + def __init__(self, cfg_dict=None, cfg_text=None, filename=None): + if cfg_dict is None: + cfg_dict = dict() + elif not isinstance(cfg_dict, dict): + raise TypeError('cfg_dict must be a dict, but ' + f'got {type(cfg_dict)}') + for key in cfg_dict: + if key in RESERVED_KEYS: + raise KeyError(f'{key} is reserved for config file') + + super(Config, self).__setattr__('_cfg_dict', ConfigDict(cfg_dict)) + super(Config, self).__setattr__('_filename', filename) + if cfg_text: + text = cfg_text + elif filename: + with open(filename, 'r') as f: + text = f.read() + else: + text = '' + super(Config, self).__setattr__('_text', text) + + @property + def filename(self): + return self._filename + + @property + def text(self): + return self._text + + @property + def pretty_text(self): + + indent = 4 + + def _indent(s_, num_spaces): + s = s_.split('\n') + if len(s) == 1: + return s_ + first = s.pop(0) + s = [(num_spaces * ' ') + line for line in s] + s = '\n'.join(s) + s = first + '\n' + s + return s + + def _format_basic_types(k, v, use_mapping=False): + if isinstance(v, str): + v_str = f"'{v}'" + else: + v_str = str(v) + + if use_mapping: + k_str = f"'{k}'" if isinstance(k, str) else str(k) + attr_str = f'{k_str}: {v_str}' + else: + attr_str = f'{str(k)}={v_str}' + attr_str = _indent(attr_str, indent) + + return attr_str + + def _format_list(k, v, use_mapping=False): + # check if all items in the list are dict + if all(isinstance(_, dict) for _ in v): + v_str = '[\n' + v_str += '\n'.join( + f'dict({_indent(_format_dict(v_), indent)}),' + for v_ in v).rstrip(',') + if use_mapping: + k_str = f"'{k}'" if isinstance(k, str) else str(k) + attr_str = f'{k_str}: {v_str}' + else: + attr_str = f'{str(k)}={v_str}' + attr_str = _indent(attr_str, indent) + ']' + else: + attr_str = _format_basic_types(k, v, use_mapping) + return attr_str + + def _contain_invalid_identifier(dict_str): + contain_invalid_identifier = False + for key_name in dict_str: + contain_invalid_identifier |= \ + (not str(key_name).isidentifier()) + return contain_invalid_identifier + + def _format_dict(input_dict, outest_level=False): + r = '' + s = [] + + use_mapping = _contain_invalid_identifier(input_dict) + if use_mapping: + r += '{' + for idx, (k, v) in enumerate(input_dict.items()): + is_last = idx >= len(input_dict) - 1 + end = '' if outest_level or is_last else ',' + if isinstance(v, dict): + v_str = '\n' + _format_dict(v) + if use_mapping: + k_str = f"'{k}'" if isinstance(k, str) else str(k) + attr_str = f'{k_str}: dict({v_str}' + else: + attr_str = f'{str(k)}=dict({v_str}' + attr_str = _indent(attr_str, indent) + ')' + end + elif isinstance(v, list): + attr_str = _format_list(k, v, use_mapping) + end + else: + attr_str = _format_basic_types(k, v, use_mapping) + end + + s.append(attr_str) + r += '\n'.join(s) + if use_mapping: + r += '}' + return r + + cfg_dict = self._cfg_dict.to_dict() + text = _format_dict(cfg_dict, outest_level=True) + # copied from setup.cfg + yapf_style = dict( + based_on_style='pep8', + blank_line_before_nested_class_or_def=True, + split_before_expression_after_opening_paren=True) + text, _ = FormatCode(text, style_config=yapf_style, verify=True) + + return text + + def __repr__(self): + return f'Config (path: {self.filename}): {self._cfg_dict.__repr__()}' + + def __len__(self): + return len(self._cfg_dict) + + def __getattr__(self, name): + return getattr(self._cfg_dict, name) + + def __getitem__(self, name): + return self._cfg_dict.__getitem__(name) + + def __setattr__(self, name, value): + if isinstance(value, dict): + value = ConfigDict(value) + self._cfg_dict.__setattr__(name, value) + + def __setitem__(self, name, value): + if isinstance(value, dict): + value = ConfigDict(value) + self._cfg_dict.__setitem__(name, value) + + def __iter__(self): + return iter(self._cfg_dict) + + def __getstate__(self): + return (self._cfg_dict, self._filename, self._text) + + def __setstate__(self, state): + _cfg_dict, _filename, _text = state + super(Config, self).__setattr__('_cfg_dict', _cfg_dict) + super(Config, self).__setattr__('_filename', _filename) + super(Config, self).__setattr__('_text', _text) + + def dump(self, file=None): + cfg_dict = super(Config, self).__getattribute__('_cfg_dict').to_dict() + if self.filename.endswith('.py'): + if file is None: + return self.pretty_text + else: + with open(file, 'w', encoding='utf-8') as f: + f.write(self.pretty_text) + else: + import mmcv + if file is None: + file_format = self.filename.split('.')[-1] + return mmcv.dump(cfg_dict, file_format=file_format) + else: + mmcv.dump(cfg_dict, file) + + def merge_from_dict(self, options, allow_list_keys=True): + """Merge list into cfg_dict. + + Merge the dict parsed by MultipleKVAction into this cfg. + + Examples: + >>> options = {'model.backbone.depth': 50, + ... 'model.backbone.with_cp':True} + >>> cfg = Config(dict(model=dict(backbone=dict(type='ResNet')))) + >>> cfg.merge_from_dict(options) + >>> cfg_dict = super(Config, self).__getattribute__('_cfg_dict') + >>> assert cfg_dict == dict( + ... model=dict(backbone=dict(depth=50, with_cp=True))) + + # Merge list element + >>> cfg = Config(dict(pipeline=[ + ... dict(type='LoadImage'), dict(type='LoadAnnotations')])) + >>> options = dict(pipeline={'0': dict(type='SelfLoadImage')}) + >>> cfg.merge_from_dict(options, allow_list_keys=True) + >>> cfg_dict = super(Config, self).__getattribute__('_cfg_dict') + >>> assert cfg_dict == dict(pipeline=[ + ... dict(type='SelfLoadImage'), dict(type='LoadAnnotations')]) + + Args: + options (dict): dict of configs to merge from. + allow_list_keys (bool): If True, int string keys (e.g. '0', '1') + are allowed in ``options`` and will replace the element of the + corresponding index in the config if the config is a list. + Default: True. + """ + option_cfg_dict = {} + for full_key, v in options.items(): + d = option_cfg_dict + key_list = full_key.split('.') + for subkey in key_list[:-1]: + d.setdefault(subkey, ConfigDict()) + d = d[subkey] + subkey = key_list[-1] + d[subkey] = v + + cfg_dict = super(Config, self).__getattribute__('_cfg_dict') + super(Config, self).__setattr__( + '_cfg_dict', + Config._merge_a_into_b( + option_cfg_dict, cfg_dict, allow_list_keys=allow_list_keys)) + + +class DictAction(Action): + """ + argparse action to split an argument into KEY=VALUE form + on the first = and append to a dictionary. List options can + be passed as comma separated values, i.e 'KEY=V1,V2,V3', or with explicit + brackets, i.e. 'KEY=[V1,V2,V3]'. It also support nested brackets to build + list/tuple values. e.g. 'KEY=[(V1,V2),(V3,V4)]' + """ + + @staticmethod + def _parse_int_float_bool(val): + try: + return int(val) + except ValueError: + pass + try: + return float(val) + except ValueError: + pass + if val.lower() in ['true', 'false']: + return True if val.lower() == 'true' else False + return val + + @staticmethod + def _parse_iterable(val): + """Parse iterable values in the string. + + All elements inside '()' or '[]' are treated as iterable values. + + Args: + val (str): Value string. + + Returns: + list | tuple: The expanded list or tuple from the string. + + Examples: + >>> DictAction._parse_iterable('1,2,3') + [1, 2, 3] + >>> DictAction._parse_iterable('[a, b, c]') + ['a', 'b', 'c'] + >>> DictAction._parse_iterable('[(1, 2, 3), [a, b], c]') + [(1, 2, 3), ['a', 'b'], 'c'] + """ + + def find_next_comma(string): + """Find the position of next comma in the string. + + If no ',' is found in the string, return the string length. All + chars inside '()' and '[]' are treated as one element and thus ',' + inside these brackets are ignored. + """ + assert (string.count('(') == string.count(')')) and ( + string.count('[') == string.count(']')), \ + f'Imbalanced brackets exist in {string}' + end = len(string) + for idx, char in enumerate(string): + pre = string[:idx] + # The string before this ',' is balanced + if ((char == ',') and (pre.count('(') == pre.count(')')) + and (pre.count('[') == pre.count(']'))): + end = idx + break + return end + + # Strip ' and " characters and replace whitespace. + val = val.strip('\'\"').replace(' ', '') + is_tuple = False + if val.startswith('(') and val.endswith(')'): + is_tuple = True + val = val[1:-1] + elif val.startswith('[') and val.endswith(']'): + val = val[1:-1] + elif ',' not in val: + # val is a single value + return DictAction._parse_int_float_bool(val) + + values = [] + while len(val) > 0: + comma_idx = find_next_comma(val) + element = DictAction._parse_iterable(val[:comma_idx]) + values.append(element) + val = val[comma_idx + 1:] + if is_tuple: + values = tuple(values) + return values + + def __call__(self, parser, namespace, values, option_string=None): + options = {} + for kv in values: + key, val = kv.split('=', maxsplit=1) + options[key] = self._parse_iterable(val) + setattr(namespace, self.dest, options) diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/collect_env.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/env.py similarity index 32% rename from cv/instance_segmentation/SOLO/pytorch/tools/collect_env.py rename to cv/instance_segmentation/SOLO/pytorch/mmcv/utils/env.py index 81d6c7aaa..e46a1094f 100644 --- a/cv/instance_segmentation/SOLO/pytorch/tools/collect_env.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/env.py @@ -1,18 +1,40 @@ +# Copyright (c) OpenMMLab. All rights reserved. +"""This file holding some environment constant for sharing by other files.""" + import os.path as osp import subprocess import sys from collections import defaultdict import cv2 -import mmcv import torch -import torchvision -import mmdet -from mmdet.ops import get_compiler_version, get_compiling_cuda_version +import mmcv +from .parrots_wrapper import get_build_config def collect_env(): + """Collect the information of the running environments. + + Returns: + dict: The environment information. The following fields are contained. + + - sys.platform: The variable of ``sys.platform``. + - Python: Python version. + - CUDA available: Bool, indicating if CUDA is available. + - GPU devices: Device type of each GPU. + - CUDA_HOME (optional): The env var ``CUDA_HOME``. + - NVCC (optional): NVCC version. + - GCC: GCC version, "n/a" if GCC is not installed. + - PyTorch: PyTorch version. + - PyTorch compiling details: The output of \ + ``torch.__config__.show()``. + - TorchVision (optional): TorchVision version. + - OpenCV: OpenCV version. + - MMCV: MMCV version. + - MMCV Compiler: The GCC version for compiling MMCV ops. + - MMCV CUDA Compiler: The CUDA version for compiling MMCV ops. + """ env_info = {} env_info['sys.platform'] = sys.platform env_info['Python'] = sys.version.replace('\n', '') @@ -21,44 +43,53 @@ def collect_env(): env_info['CUDA available'] = cuda_available if cuda_available: - from torch.utils.cpp_extension import CUDA_HOME + devices = defaultdict(list) + for k in range(torch.cuda.device_count()): + devices[torch.cuda.get_device_name(k)].append(str(k)) + for name, device_ids in devices.items(): + env_info['GPU ' + ','.join(device_ids)] = name + + from mmcv.utils.parrots_wrapper import _get_cuda_home + CUDA_HOME = _get_cuda_home() env_info['CUDA_HOME'] = CUDA_HOME if CUDA_HOME is not None and osp.isdir(CUDA_HOME): try: nvcc = osp.join(CUDA_HOME, 'bin/nvcc') nvcc = subprocess.check_output( - '"{}" -V | tail -n1'.format(nvcc), shell=True) + f'"{nvcc}" -V | tail -n1', shell=True) nvcc = nvcc.decode('utf-8').strip() except subprocess.SubprocessError: nvcc = 'Not Available' env_info['NVCC'] = nvcc - devices = defaultdict(list) - for k in range(torch.cuda.device_count()): - devices[torch.cuda.get_device_name(k)].append(str(k)) - for name, devids in devices.items(): - env_info['GPU ' + ','.join(devids)] = name - - gcc = subprocess.check_output('gcc --version | head -n1', shell=True) - gcc = gcc.decode('utf-8').strip() - env_info['GCC'] = gcc + try: + gcc = subprocess.check_output('gcc --version | head -n1', shell=True) + gcc = gcc.decode('utf-8').strip() + env_info['GCC'] = gcc + except subprocess.CalledProcessError: # gcc is unavailable + env_info['GCC'] = 'n/a' env_info['PyTorch'] = torch.__version__ - env_info['PyTorch compiling details'] = torch.__config__.show() + env_info['PyTorch compiling details'] = get_build_config() - env_info['TorchVision'] = torchvision.__version__ + try: + import torchvision + env_info['TorchVision'] = torchvision.__version__ + except ModuleNotFoundError: + pass env_info['OpenCV'] = cv2.__version__ env_info['MMCV'] = mmcv.__version__ - env_info['MMDetection'] = mmdet.__version__ - env_info['MMDetection Compiler'] = get_compiler_version() - env_info['MMDetection CUDA Compiler'] = get_compiling_cuda_version() - - for name, val in env_info.items(): - print('{}: {}'.format(name, val)) + try: + from mmcv.ops import get_compiler_version, get_compiling_cuda_version + except ModuleNotFoundError: + env_info['MMCV Compiler'] = 'n/a' + env_info['MMCV CUDA Compiler'] = 'n/a' + else: + env_info['MMCV Compiler'] = get_compiler_version() + env_info['MMCV CUDA Compiler'] = get_compiling_cuda_version() -if __name__ == "__main__": - collect_env() + return env_info diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/ext_loader.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/ext_loader.py new file mode 100644 index 000000000..08132d2c1 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/ext_loader.py @@ -0,0 +1,71 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import importlib +import os +import pkgutil +import warnings +from collections import namedtuple + +import torch + +if torch.__version__ != 'parrots': + + def load_ext(name, funcs): + ext = importlib.import_module('mmcv.' + name) + for fun in funcs: + assert hasattr(ext, fun), f'{fun} miss in module {name}' + return ext +else: + from parrots import extension + from parrots.base import ParrotsException + + has_return_value_ops = [ + 'nms', + 'softnms', + 'nms_match', + 'nms_rotated', + 'top_pool_forward', + 'top_pool_backward', + 'bottom_pool_forward', + 'bottom_pool_backward', + 'left_pool_forward', + 'left_pool_backward', + 'right_pool_forward', + 'right_pool_backward', + 'fused_bias_leakyrelu', + 'upfirdn2d', + 'ms_deform_attn_forward', + 'pixel_group', + 'contour_expand', + ] + + def get_fake_func(name, e): + + def fake_func(*args, **kwargs): + warnings.warn(f'{name} is not supported in parrots now') + raise e + + return fake_func + + def load_ext(name, funcs): + ExtModule = namedtuple('ExtModule', funcs) + ext_list = [] + lib_root = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + for fun in funcs: + try: + ext_fun = extension.load(fun, name, lib_dir=lib_root) + except ParrotsException as e: + if 'No element registered' not in e.message: + warnings.warn(e.message) + ext_fun = get_fake_func(fun, e) + ext_list.append(ext_fun) + else: + if fun in has_return_value_ops: + ext_list.append(ext_fun.op) + else: + ext_list.append(ext_fun.op_) + return ExtModule(*ext_list) + + +def check_ops_exist(): + ext_loader = pkgutil.find_loader('mmcv._ext') + return ext_loader is not None diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/logging.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/logging.py new file mode 100644 index 000000000..4aa0e04bb --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/logging.py @@ -0,0 +1,110 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import logging + +import torch.distributed as dist + +logger_initialized = {} + + +def get_logger(name, log_file=None, log_level=logging.INFO, file_mode='w'): + """Initialize and get a logger by name. + + If the logger has not been initialized, this method will initialize the + logger by adding one or two handlers, otherwise the initialized logger will + be directly returned. During initialization, a StreamHandler will always be + added. If `log_file` is specified and the process rank is 0, a FileHandler + will also be added. + + Args: + name (str): Logger name. + log_file (str | None): The log filename. If specified, a FileHandler + will be added to the logger. + log_level (int): The logger level. Note that only the process of + rank 0 is affected, and other processes will set the level to + "Error" thus be silent most of the time. + file_mode (str): The file mode used in opening log file. + Defaults to 'w'. + + Returns: + logging.Logger: The expected logger. + """ + logger = logging.getLogger(name) + if name in logger_initialized: + return logger + # handle hierarchical names + # e.g., logger "a" is initialized, then logger "a.b" will skip the + # initialization since it is a child of "a". + for logger_name in logger_initialized: + if name.startswith(logger_name): + return logger + + # handle duplicate logs to the console + # Starting in 1.8.0, PyTorch DDP attaches a StreamHandler (NOTSET) + # to the root logger. As logger.propagate is True by default, this root + # level handler causes logging messages from rank>0 processes to + # unexpectedly show up on the console, creating much unwanted clutter. + # To fix this issue, we set the root logger's StreamHandler, if any, to log + # at the ERROR level. + for handler in logger.root.handlers: + if type(handler) is logging.StreamHandler: + handler.setLevel(logging.ERROR) + + stream_handler = logging.StreamHandler() + handlers = [stream_handler] + + if dist.is_available() and dist.is_initialized(): + rank = dist.get_rank() + else: + rank = 0 + + # only rank 0 will add a FileHandler + if rank == 0 and log_file is not None: + # Here, the default behaviour of the official logger is 'a'. Thus, we + # provide an interface to change the file mode to the default + # behaviour. + file_handler = logging.FileHandler(log_file, file_mode) + handlers.append(file_handler) + + formatter = logging.Formatter( + '%(asctime)s - %(name)s - %(levelname)s - %(message)s') + for handler in handlers: + handler.setFormatter(formatter) + handler.setLevel(log_level) + logger.addHandler(handler) + + if rank == 0: + logger.setLevel(log_level) + else: + logger.setLevel(logging.ERROR) + + logger_initialized[name] = True + + return logger + + +def print_log(msg, logger=None, level=logging.INFO): + """Print a log message. + + Args: + msg (str): The message to be logged. + logger (logging.Logger | str | None): The logger to be used. + Some special loggers are: + - "silent": no message will be printed. + - other str: the logger obtained with `get_root_logger(logger)`. + - None: The `print()` method will be used to print log messages. + level (int): Logging level. Only available when `logger` is a Logger + object or "root". + """ + if logger is None: + print(msg) + elif isinstance(logger, logging.Logger): + logger.log(level, msg) + elif logger == 'silent': + pass + elif isinstance(logger, str): + _logger = get_logger(logger) + _logger.log(level, msg) + else: + raise TypeError( + 'logger should be either a logging.Logger object, str, ' + f'"silent" or None, but got {type(logger)}') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/misc.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/misc.py new file mode 100644 index 000000000..2c58d0d7f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/misc.py @@ -0,0 +1,377 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import collections.abc +import functools +import itertools +import subprocess +import warnings +from collections import abc +from importlib import import_module +from inspect import getfullargspec +from itertools import repeat + + +# From PyTorch internals +def _ntuple(n): + + def parse(x): + if isinstance(x, collections.abc.Iterable): + return x + return tuple(repeat(x, n)) + + return parse + + +to_1tuple = _ntuple(1) +to_2tuple = _ntuple(2) +to_3tuple = _ntuple(3) +to_4tuple = _ntuple(4) +to_ntuple = _ntuple + + +def is_str(x): + """Whether the input is an string instance. + + Note: This method is deprecated since python 2 is no longer supported. + """ + return isinstance(x, str) + + +def import_modules_from_strings(imports, allow_failed_imports=False): + """Import modules from the given list of strings. + + Args: + imports (list | str | None): The given module names to be imported. + allow_failed_imports (bool): If True, the failed imports will return + None. Otherwise, an ImportError is raise. Default: False. + + Returns: + list[module] | module | None: The imported modules. + + Examples: + >>> osp, sys = import_modules_from_strings( + ... ['os.path', 'sys']) + >>> import os.path as osp_ + >>> import sys as sys_ + >>> assert osp == osp_ + >>> assert sys == sys_ + """ + if not imports: + return + single_import = False + if isinstance(imports, str): + single_import = True + imports = [imports] + if not isinstance(imports, list): + raise TypeError( + f'custom_imports must be a list but got type {type(imports)}') + imported = [] + for imp in imports: + if not isinstance(imp, str): + raise TypeError( + f'{imp} is of type {type(imp)} and cannot be imported.') + try: + imported_tmp = import_module(imp) + except ImportError: + if allow_failed_imports: + warnings.warn(f'{imp} failed to import and is ignored.', + UserWarning) + imported_tmp = None + else: + raise ImportError + imported.append(imported_tmp) + if single_import: + imported = imported[0] + return imported + + +def iter_cast(inputs, dst_type, return_type=None): + """Cast elements of an iterable object into some type. + + Args: + inputs (Iterable): The input object. + dst_type (type): Destination type. + return_type (type, optional): If specified, the output object will be + converted to this type, otherwise an iterator. + + Returns: + iterator or specified type: The converted object. + """ + if not isinstance(inputs, abc.Iterable): + raise TypeError('inputs must be an iterable object') + if not isinstance(dst_type, type): + raise TypeError('"dst_type" must be a valid type') + + out_iterable = map(dst_type, inputs) + + if return_type is None: + return out_iterable + else: + return return_type(out_iterable) + + +def list_cast(inputs, dst_type): + """Cast elements of an iterable object into a list of some type. + + A partial method of :func:`iter_cast`. + """ + return iter_cast(inputs, dst_type, return_type=list) + + +def tuple_cast(inputs, dst_type): + """Cast elements of an iterable object into a tuple of some type. + + A partial method of :func:`iter_cast`. + """ + return iter_cast(inputs, dst_type, return_type=tuple) + + +def is_seq_of(seq, expected_type, seq_type=None): + """Check whether it is a sequence of some type. + + Args: + seq (Sequence): The sequence to be checked. + expected_type (type): Expected type of sequence items. + seq_type (type, optional): Expected sequence type. + + Returns: + bool: Whether the sequence is valid. + """ + if seq_type is None: + exp_seq_type = abc.Sequence + else: + assert isinstance(seq_type, type) + exp_seq_type = seq_type + if not isinstance(seq, exp_seq_type): + return False + for item in seq: + if not isinstance(item, expected_type): + return False + return True + + +def is_list_of(seq, expected_type): + """Check whether it is a list of some type. + + A partial method of :func:`is_seq_of`. + """ + return is_seq_of(seq, expected_type, seq_type=list) + + +def is_tuple_of(seq, expected_type): + """Check whether it is a tuple of some type. + + A partial method of :func:`is_seq_of`. + """ + return is_seq_of(seq, expected_type, seq_type=tuple) + + +def slice_list(in_list, lens): + """Slice a list into several sub lists by a list of given length. + + Args: + in_list (list): The list to be sliced. + lens(int or list): The expected length of each out list. + + Returns: + list: A list of sliced list. + """ + if isinstance(lens, int): + assert len(in_list) % lens == 0 + lens = [lens] * int(len(in_list) / lens) + if not isinstance(lens, list): + raise TypeError('"indices" must be an integer or a list of integers') + elif sum(lens) != len(in_list): + raise ValueError('sum of lens and list length does not ' + f'match: {sum(lens)} != {len(in_list)}') + out_list = [] + idx = 0 + for i in range(len(lens)): + out_list.append(in_list[idx:idx + lens[i]]) + idx += lens[i] + return out_list + + +def concat_list(in_list): + """Concatenate a list of list into a single list. + + Args: + in_list (list): The list of list to be merged. + + Returns: + list: The concatenated flat list. + """ + return list(itertools.chain(*in_list)) + + +def check_prerequisites( + prerequisites, + checker, + msg_tmpl='Prerequisites "{}" are required in method "{}" but not ' + 'found, please install them first.'): # yapf: disable + """A decorator factory to check if prerequisites are satisfied. + + Args: + prerequisites (str of list[str]): Prerequisites to be checked. + checker (callable): The checker method that returns True if a + prerequisite is meet, False otherwise. + msg_tmpl (str): The message template with two variables. + + Returns: + decorator: A specific decorator. + """ + + def wrap(func): + + @functools.wraps(func) + def wrapped_func(*args, **kwargs): + requirements = [prerequisites] if isinstance( + prerequisites, str) else prerequisites + missing = [] + for item in requirements: + if not checker(item): + missing.append(item) + if missing: + print(msg_tmpl.format(', '.join(missing), func.__name__)) + raise RuntimeError('Prerequisites not meet.') + else: + return func(*args, **kwargs) + + return wrapped_func + + return wrap + + +def _check_py_package(package): + try: + import_module(package) + except ImportError: + return False + else: + return True + + +def _check_executable(cmd): + if subprocess.call(f'which {cmd}', shell=True) != 0: + return False + else: + return True + + +def requires_package(prerequisites): + """A decorator to check if some python packages are installed. + + Example: + >>> @requires_package('numpy') + >>> func(arg1, args): + >>> return numpy.zeros(1) + array([0.]) + >>> @requires_package(['numpy', 'non_package']) + >>> func(arg1, args): + >>> return numpy.zeros(1) + ImportError + """ + return check_prerequisites(prerequisites, checker=_check_py_package) + + +def requires_executable(prerequisites): + """A decorator to check if some executable files are installed. + + Example: + >>> @requires_executable('ffmpeg') + >>> func(arg1, args): + >>> print(1) + 1 + """ + return check_prerequisites(prerequisites, checker=_check_executable) + + +def deprecated_api_warning(name_dict, cls_name=None): + """A decorator to check if some arguments are deprecate and try to replace + deprecate src_arg_name to dst_arg_name. + + Args: + name_dict(dict): + key (str): Deprecate argument names. + val (str): Expected argument names. + + Returns: + func: New function. + """ + + def api_warning_wrapper(old_func): + + @functools.wraps(old_func) + def new_func(*args, **kwargs): + # get the arg spec of the decorated method + args_info = getfullargspec(old_func) + # get name of the function + func_name = old_func.__name__ + if cls_name is not None: + func_name = f'{cls_name}.{func_name}' + if args: + arg_names = args_info.args[:len(args)] + for src_arg_name, dst_arg_name in name_dict.items(): + if src_arg_name in arg_names: + warnings.warn( + f'"{src_arg_name}" is deprecated in ' + f'`{func_name}`, please use "{dst_arg_name}" ' + 'instead') + arg_names[arg_names.index(src_arg_name)] = dst_arg_name + if kwargs: + for src_arg_name, dst_arg_name in name_dict.items(): + if src_arg_name in kwargs: + + assert dst_arg_name not in kwargs, ( + f'The expected behavior is to replace ' + f'the deprecated key `{src_arg_name}` to ' + f'new key `{dst_arg_name}`, but got them ' + f'in the arguments at the same time, which ' + f'is confusing. `{src_arg_name} will be ' + f'deprecated in the future, please ' + f'use `{dst_arg_name}` instead.') + + warnings.warn( + f'"{src_arg_name}" is deprecated in ' + f'`{func_name}`, please use "{dst_arg_name}" ' + 'instead') + kwargs[dst_arg_name] = kwargs.pop(src_arg_name) + + # apply converted arguments to the decorated method + output = old_func(*args, **kwargs) + return output + + return new_func + + return api_warning_wrapper + + +def is_method_overridden(method, base_class, derived_class): + """Check if a method of base class is overridden in derived class. + + Args: + method (str): the method name to check. + base_class (type): the class of the base class. + derived_class (type | Any): the class or instance of the derived class. + """ + assert isinstance(base_class, type), \ + "base_class doesn't accept instance, Please pass class instead." + + if not isinstance(derived_class, type): + derived_class = derived_class.__class__ + + base_method = getattr(base_class, method) + derived_method = getattr(derived_class, method) + return derived_method != base_method + + +def has_method(obj: object, method: str) -> bool: + """Check whether the object has a method. + + Args: + method (str): The method name to check. + obj (object): The object to check. + + Returns: + bool: True if the object has the method else False. + """ + return hasattr(obj, method) and callable(getattr(obj, method)) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/parrots_jit.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/parrots_jit.py new file mode 100644 index 000000000..61873f6db --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/parrots_jit.py @@ -0,0 +1,41 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import os + +from .parrots_wrapper import TORCH_VERSION + +parrots_jit_option = os.getenv('PARROTS_JIT_OPTION') + +if TORCH_VERSION == 'parrots' and parrots_jit_option == 'ON': + from parrots.jit import pat as jit +else: + + def jit(func=None, + check_input=None, + full_shape=True, + derivate=False, + coderize=False, + optimize=False): + + def wrapper(func): + + def wrapper_inner(*args, **kargs): + return func(*args, **kargs) + + return wrapper_inner + + if func is None: + return wrapper + else: + return func + + +if TORCH_VERSION == 'parrots': + from parrots.utils.tester import skip_no_elena +else: + + def skip_no_elena(func): + + def wrapper(*args, **kargs): + return func(*args, **kargs) + + return wrapper diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/parrots_wrapper.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/parrots_wrapper.py new file mode 100644 index 000000000..93c97640d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/parrots_wrapper.py @@ -0,0 +1,107 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from functools import partial + +import torch + +TORCH_VERSION = torch.__version__ + + +def is_rocm_pytorch() -> bool: + is_rocm = False + if TORCH_VERSION != 'parrots': + try: + from torch.utils.cpp_extension import ROCM_HOME + is_rocm = True if ((torch.version.hip is not None) and + (ROCM_HOME is not None)) else False + except ImportError: + pass + return is_rocm + + +def _get_cuda_home(): + if TORCH_VERSION == 'parrots': + from parrots.utils.build_extension import CUDA_HOME + else: + if is_rocm_pytorch(): + from torch.utils.cpp_extension import ROCM_HOME + CUDA_HOME = ROCM_HOME + else: + from torch.utils.cpp_extension import CUDA_HOME + return CUDA_HOME + + +def get_build_config(): + if TORCH_VERSION == 'parrots': + from parrots.config import get_build_info + return get_build_info() + else: + return torch.__config__.show() + + +def _get_conv(): + if TORCH_VERSION == 'parrots': + from parrots.nn.modules.conv import _ConvNd, _ConvTransposeMixin + else: + from torch.nn.modules.conv import _ConvNd, _ConvTransposeMixin + return _ConvNd, _ConvTransposeMixin + + +def _get_dataloader(): + if TORCH_VERSION == 'parrots': + from torch.utils.data import DataLoader, PoolDataLoader + else: + from torch.utils.data import DataLoader + PoolDataLoader = DataLoader + return DataLoader, PoolDataLoader + + +def _get_extension(): + if TORCH_VERSION == 'parrots': + from parrots.utils.build_extension import BuildExtension, Extension + CppExtension = partial(Extension, cuda=False) + CUDAExtension = partial(Extension, cuda=True) + else: + from torch.utils.cpp_extension import (BuildExtension, CppExtension, + CUDAExtension) + return BuildExtension, CppExtension, CUDAExtension + + +def _get_pool(): + if TORCH_VERSION == 'parrots': + from parrots.nn.modules.pool import (_AdaptiveAvgPoolNd, + _AdaptiveMaxPoolNd, _AvgPoolNd, + _MaxPoolNd) + else: + from torch.nn.modules.pooling import (_AdaptiveAvgPoolNd, + _AdaptiveMaxPoolNd, _AvgPoolNd, + _MaxPoolNd) + return _AdaptiveAvgPoolNd, _AdaptiveMaxPoolNd, _AvgPoolNd, _MaxPoolNd + + +def _get_norm(): + if TORCH_VERSION == 'parrots': + from parrots.nn.modules.batchnorm import _BatchNorm, _InstanceNorm + SyncBatchNorm_ = torch.nn.SyncBatchNorm2d + else: + from torch.nn.modules.instancenorm import _InstanceNorm + from torch.nn.modules.batchnorm import _BatchNorm + SyncBatchNorm_ = torch.nn.SyncBatchNorm + return _BatchNorm, _InstanceNorm, SyncBatchNorm_ + + +_ConvNd, _ConvTransposeMixin = _get_conv() +DataLoader, PoolDataLoader = _get_dataloader() +BuildExtension, CppExtension, CUDAExtension = _get_extension() +_BatchNorm, _InstanceNorm, SyncBatchNorm_ = _get_norm() +_AdaptiveAvgPoolNd, _AdaptiveMaxPoolNd, _AvgPoolNd, _MaxPoolNd = _get_pool() + + +class SyncBatchNorm(SyncBatchNorm_): + + def _check_input_dim(self, input): + if TORCH_VERSION == 'parrots': + if input.dim() < 2: + raise ValueError( + f'expected at least 2D input (got {input.dim()}D input)') + else: + super()._check_input_dim(input) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/path.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/path.py new file mode 100644 index 000000000..7dab4b304 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/path.py @@ -0,0 +1,101 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import os +import os.path as osp +from pathlib import Path + +from .misc import is_str + + +def is_filepath(x): + return is_str(x) or isinstance(x, Path) + + +def fopen(filepath, *args, **kwargs): + if is_str(filepath): + return open(filepath, *args, **kwargs) + elif isinstance(filepath, Path): + return filepath.open(*args, **kwargs) + raise ValueError('`filepath` should be a string or a Path') + + +def check_file_exist(filename, msg_tmpl='file "{}" does not exist'): + if not osp.isfile(filename): + raise FileNotFoundError(msg_tmpl.format(filename)) + + +def mkdir_or_exist(dir_name, mode=0o777): + if dir_name == '': + return + dir_name = osp.expanduser(dir_name) + os.makedirs(dir_name, mode=mode, exist_ok=True) + + +def symlink(src, dst, overwrite=True, **kwargs): + if os.path.lexists(dst) and overwrite: + os.remove(dst) + os.symlink(src, dst, **kwargs) + + +def scandir(dir_path, suffix=None, recursive=False, case_sensitive=True): + """Scan a directory to find the interested files. + + Args: + dir_path (str | obj:`Path`): Path of the directory. + suffix (str | tuple(str), optional): File suffix that we are + interested in. Default: None. + recursive (bool, optional): If set to True, recursively scan the + directory. Default: False. + case_sensitive (bool, optional) : If set to False, ignore the case of + suffix. Default: True. + + Returns: + A generator for all the interested files with relative paths. + """ + if isinstance(dir_path, (str, Path)): + dir_path = str(dir_path) + else: + raise TypeError('"dir_path" must be a string or Path object') + + if (suffix is not None) and not isinstance(suffix, (str, tuple)): + raise TypeError('"suffix" must be a string or tuple of strings') + + if suffix is not None and not case_sensitive: + suffix = suffix.lower() if isinstance(suffix, str) else tuple( + item.lower() for item in suffix) + + root = dir_path + + def _scandir(dir_path, suffix, recursive, case_sensitive): + for entry in os.scandir(dir_path): + if not entry.name.startswith('.') and entry.is_file(): + rel_path = osp.relpath(entry.path, root) + _rel_path = rel_path if case_sensitive else rel_path.lower() + if suffix is None or _rel_path.endswith(suffix): + yield rel_path + elif recursive and os.path.isdir(entry.path): + # scan recursively if entry.path is a directory + yield from _scandir(entry.path, suffix, recursive, + case_sensitive) + + return _scandir(dir_path, suffix, recursive, case_sensitive) + + +def find_vcs_root(path, markers=('.git', )): + """Finds the root directory (including itself) of specified markers. + + Args: + path (str): Path of directory or file. + markers (list[str], optional): List of file or directory names. + + Returns: + The directory contained one of the markers or None if not found. + """ + if osp.isfile(path): + path = osp.dirname(path) + + prev, cur = None, osp.abspath(osp.expanduser(path)) + while cur != prev: + if any(osp.exists(osp.join(cur, marker)) for marker in markers): + return cur + prev, cur = cur, osp.split(cur)[0] + return None diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/progressbar.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/progressbar.py new file mode 100644 index 000000000..0062f670d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/progressbar.py @@ -0,0 +1,208 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import sys +from collections.abc import Iterable +from multiprocessing import Pool +from shutil import get_terminal_size + +from .timer import Timer + + +class ProgressBar: + """A progress bar which can print the progress.""" + + def __init__(self, task_num=0, bar_width=50, start=True, file=sys.stdout): + self.task_num = task_num + self.bar_width = bar_width + self.completed = 0 + self.file = file + if start: + self.start() + + @property + def terminal_width(self): + width, _ = get_terminal_size() + return width + + def start(self): + if self.task_num > 0: + self.file.write(f'[{" " * self.bar_width}] 0/{self.task_num}, ' + 'elapsed: 0s, ETA:') + else: + self.file.write('completed: 0, elapsed: 0s') + self.file.flush() + self.timer = Timer() + + def update(self, num_tasks=1): + assert num_tasks > 0 + self.completed += num_tasks + elapsed = self.timer.since_start() + if elapsed > 0: + fps = self.completed / elapsed + else: + fps = float('inf') + if self.task_num > 0: + percentage = self.completed / float(self.task_num) + eta = int(elapsed * (1 - percentage) / percentage + 0.5) + msg = f'\r[{{}}] {self.completed}/{self.task_num}, ' \ + f'{fps:.1f} task/s, elapsed: {int(elapsed + 0.5)}s, ' \ + f'ETA: {eta:5}s' + + bar_width = min(self.bar_width, + int(self.terminal_width - len(msg)) + 2, + int(self.terminal_width * 0.6)) + bar_width = max(2, bar_width) + mark_width = int(bar_width * percentage) + bar_chars = '>' * mark_width + ' ' * (bar_width - mark_width) + self.file.write(msg.format(bar_chars)) + else: + self.file.write( + f'completed: {self.completed}, elapsed: {int(elapsed + 0.5)}s,' + f' {fps:.1f} tasks/s') + self.file.flush() + + +def track_progress(func, tasks, bar_width=50, file=sys.stdout, **kwargs): + """Track the progress of tasks execution with a progress bar. + + Tasks are done with a simple for-loop. + + Args: + func (callable): The function to be applied to each task. + tasks (list or tuple[Iterable, int]): A list of tasks or + (tasks, total num). + bar_width (int): Width of progress bar. + + Returns: + list: The task results. + """ + if isinstance(tasks, tuple): + assert len(tasks) == 2 + assert isinstance(tasks[0], Iterable) + assert isinstance(tasks[1], int) + task_num = tasks[1] + tasks = tasks[0] + elif isinstance(tasks, Iterable): + task_num = len(tasks) + else: + raise TypeError( + '"tasks" must be an iterable object or a (iterator, int) tuple') + prog_bar = ProgressBar(task_num, bar_width, file=file) + results = [] + for task in tasks: + results.append(func(task, **kwargs)) + prog_bar.update() + prog_bar.file.write('\n') + return results + + +def init_pool(process_num, initializer=None, initargs=None): + if initializer is None: + return Pool(process_num) + elif initargs is None: + return Pool(process_num, initializer) + else: + if not isinstance(initargs, tuple): + raise TypeError('"initargs" must be a tuple') + return Pool(process_num, initializer, initargs) + + +def track_parallel_progress(func, + tasks, + nproc, + initializer=None, + initargs=None, + bar_width=50, + chunksize=1, + skip_first=False, + keep_order=True, + file=sys.stdout): + """Track the progress of parallel task execution with a progress bar. + + The built-in :mod:`multiprocessing` module is used for process pools and + tasks are done with :func:`Pool.map` or :func:`Pool.imap_unordered`. + + Args: + func (callable): The function to be applied to each task. + tasks (list or tuple[Iterable, int]): A list of tasks or + (tasks, total num). + nproc (int): Process (worker) number. + initializer (None or callable): Refer to :class:`multiprocessing.Pool` + for details. + initargs (None or tuple): Refer to :class:`multiprocessing.Pool` for + details. + chunksize (int): Refer to :class:`multiprocessing.Pool` for details. + bar_width (int): Width of progress bar. + skip_first (bool): Whether to skip the first sample for each worker + when estimating fps, since the initialization step may takes + longer. + keep_order (bool): If True, :func:`Pool.imap` is used, otherwise + :func:`Pool.imap_unordered` is used. + + Returns: + list: The task results. + """ + if isinstance(tasks, tuple): + assert len(tasks) == 2 + assert isinstance(tasks[0], Iterable) + assert isinstance(tasks[1], int) + task_num = tasks[1] + tasks = tasks[0] + elif isinstance(tasks, Iterable): + task_num = len(tasks) + else: + raise TypeError( + '"tasks" must be an iterable object or a (iterator, int) tuple') + pool = init_pool(nproc, initializer, initargs) + start = not skip_first + task_num -= nproc * chunksize * int(skip_first) + prog_bar = ProgressBar(task_num, bar_width, start, file=file) + results = [] + if keep_order: + gen = pool.imap(func, tasks, chunksize) + else: + gen = pool.imap_unordered(func, tasks, chunksize) + for result in gen: + results.append(result) + if skip_first: + if len(results) < nproc * chunksize: + continue + elif len(results) == nproc * chunksize: + prog_bar.start() + continue + prog_bar.update() + prog_bar.file.write('\n') + pool.close() + pool.join() + return results + + +def track_iter_progress(tasks, bar_width=50, file=sys.stdout): + """Track the progress of tasks iteration or enumeration with a progress + bar. + + Tasks are yielded with a simple for-loop. + + Args: + tasks (list or tuple[Iterable, int]): A list of tasks or + (tasks, total num). + bar_width (int): Width of progress bar. + + Yields: + list: The task results. + """ + if isinstance(tasks, tuple): + assert len(tasks) == 2 + assert isinstance(tasks[0], Iterable) + assert isinstance(tasks[1], int) + task_num = tasks[1] + tasks = tasks[0] + elif isinstance(tasks, Iterable): + task_num = len(tasks) + else: + raise TypeError( + '"tasks" must be an iterable object or a (iterator, int) tuple') + prog_bar = ProgressBar(task_num, bar_width, file=file) + for task in tasks: + yield task + prog_bar.update() + prog_bar.file.write('\n') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/registry.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/registry.py new file mode 100644 index 000000000..fa9df39bc --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/registry.py @@ -0,0 +1,315 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import inspect +import warnings +from functools import partial + +from .misc import is_seq_of + + +def build_from_cfg(cfg, registry, default_args=None): + """Build a module from config dict. + + Args: + cfg (dict): Config dict. It should at least contain the key "type". + registry (:obj:`Registry`): The registry to search the type from. + default_args (dict, optional): Default initialization arguments. + + Returns: + object: The constructed object. + """ + if not isinstance(cfg, dict): + raise TypeError(f'cfg must be a dict, but got {type(cfg)}') + if 'type' not in cfg: + if default_args is None or 'type' not in default_args: + raise KeyError( + '`cfg` or `default_args` must contain the key "type", ' + f'but got {cfg}\n{default_args}') + if not isinstance(registry, Registry): + raise TypeError('registry must be an mmcv.Registry object, ' + f'but got {type(registry)}') + if not (isinstance(default_args, dict) or default_args is None): + raise TypeError('default_args must be a dict or None, ' + f'but got {type(default_args)}') + + args = cfg.copy() + + if default_args is not None: + for name, value in default_args.items(): + args.setdefault(name, value) + + obj_type = args.pop('type') + if isinstance(obj_type, str): + obj_cls = registry.get(obj_type) + if obj_cls is None: + raise KeyError( + f'{obj_type} is not in the {registry.name} registry') + elif inspect.isclass(obj_type): + obj_cls = obj_type + else: + raise TypeError( + f'type must be a str or valid type, but got {type(obj_type)}') + try: + return obj_cls(**args) + except Exception as e: + # Normal TypeError does not print class name. + raise type(e)(f'{obj_cls.__name__}: {e}') + + +class Registry: + """A registry to map strings to classes. + + Registered object could be built from registry. + Example: + >>> MODELS = Registry('models') + >>> @MODELS.register_module() + >>> class ResNet: + >>> pass + >>> resnet = MODELS.build(dict(type='ResNet')) + + Please refer to + https://mmcv.readthedocs.io/en/latest/understand_mmcv/registry.html for + advanced usage. + + Args: + name (str): Registry name. + build_func(func, optional): Build function to construct instance from + Registry, func:`build_from_cfg` is used if neither ``parent`` or + ``build_func`` is specified. If ``parent`` is specified and + ``build_func`` is not given, ``build_func`` will be inherited + from ``parent``. Default: None. + parent (Registry, optional): Parent registry. The class registered in + children registry could be built from parent. Default: None. + scope (str, optional): The scope of registry. It is the key to search + for children registry. If not specified, scope will be the name of + the package where class is defined, e.g. mmdet, mmcls, mmseg. + Default: None. + """ + + def __init__(self, name, build_func=None, parent=None, scope=None): + self._name = name + self._module_dict = dict() + self._children = dict() + self._scope = self.infer_scope() if scope is None else scope + + # self.build_func will be set with the following priority: + # 1. build_func + # 2. parent.build_func + # 3. build_from_cfg + if build_func is None: + if parent is not None: + self.build_func = parent.build_func + else: + self.build_func = build_from_cfg + else: + self.build_func = build_func + if parent is not None: + assert isinstance(parent, Registry) + parent._add_children(self) + self.parent = parent + else: + self.parent = None + + def __len__(self): + return len(self._module_dict) + + def __contains__(self, key): + return self.get(key) is not None + + def __repr__(self): + format_str = self.__class__.__name__ + \ + f'(name={self._name}, ' \ + f'items={self._module_dict})' + return format_str + + @staticmethod + def infer_scope(): + """Infer the scope of registry. + + The name of the package where registry is defined will be returned. + + Example: + # in mmdet/models/backbone/resnet.py + >>> MODELS = Registry('models') + >>> @MODELS.register_module() + >>> class ResNet: + >>> pass + The scope of ``ResNet`` will be ``mmdet``. + + + Returns: + scope (str): The inferred scope name. + """ + # inspect.stack() trace where this function is called, the index-2 + # indicates the frame where `infer_scope()` is called + filename = inspect.getmodule(inspect.stack()[2][0]).__name__ + split_filename = filename.split('.') + return split_filename[0] + + @staticmethod + def split_scope_key(key): + """Split scope and key. + + The first scope will be split from key. + + Examples: + >>> Registry.split_scope_key('mmdet.ResNet') + 'mmdet', 'ResNet' + >>> Registry.split_scope_key('ResNet') + None, 'ResNet' + + Return: + scope (str, None): The first scope. + key (str): The remaining key. + """ + split_index = key.find('.') + if split_index != -1: + return key[:split_index], key[split_index + 1:] + else: + return None, key + + @property + def name(self): + return self._name + + @property + def scope(self): + return self._scope + + @property + def module_dict(self): + return self._module_dict + + @property + def children(self): + return self._children + + def get(self, key): + """Get the registry record. + + Args: + key (str): The class name in string format. + + Returns: + class: The corresponding class. + """ + scope, real_key = self.split_scope_key(key) + if scope is None or scope == self._scope: + # get from self + if real_key in self._module_dict: + return self._module_dict[real_key] + else: + # get from self._children + if scope in self._children: + return self._children[scope].get(real_key) + else: + # goto root + parent = self.parent + while parent.parent is not None: + parent = parent.parent + return parent.get(key) + + def build(self, *args, **kwargs): + return self.build_func(*args, **kwargs, registry=self) + + def _add_children(self, registry): + """Add children for a registry. + + The ``registry`` will be added as children based on its scope. + The parent registry could build objects from children registry. + + Example: + >>> models = Registry('models') + >>> mmdet_models = Registry('models', parent=models) + >>> @mmdet_models.register_module() + >>> class ResNet: + >>> pass + >>> resnet = models.build(dict(type='mmdet.ResNet')) + """ + + assert isinstance(registry, Registry) + assert registry.scope is not None + assert registry.scope not in self.children, \ + f'scope {registry.scope} exists in {self.name} registry' + self.children[registry.scope] = registry + + def _register_module(self, module_class, module_name=None, force=False): + if not inspect.isclass(module_class): + raise TypeError('module must be a class, ' + f'but got {type(module_class)}') + + if module_name is None: + module_name = module_class.__name__ + if isinstance(module_name, str): + module_name = [module_name] + for name in module_name: + if not force and name in self._module_dict: + raise KeyError(f'{name} is already registered ' + f'in {self.name}') + self._module_dict[name] = module_class + + def deprecated_register_module(self, cls=None, force=False): + warnings.warn( + 'The old API of register_module(module, force=False) ' + 'is deprecated and will be removed, please use the new API ' + 'register_module(name=None, force=False, module=None) instead.') + if cls is None: + return partial(self.deprecated_register_module, force=force) + self._register_module(cls, force=force) + return cls + + def register_module(self, name=None, force=False, module=None): + """Register a module. + + A record will be added to `self._module_dict`, whose key is the class + name or the specified name, and value is the class itself. + It can be used as a decorator or a normal function. + + Example: + >>> backbones = Registry('backbone') + >>> @backbones.register_module() + >>> class ResNet: + >>> pass + + >>> backbones = Registry('backbone') + >>> @backbones.register_module(name='mnet') + >>> class MobileNet: + >>> pass + + >>> backbones = Registry('backbone') + >>> class ResNet: + >>> pass + >>> backbones.register_module(ResNet) + + Args: + name (str | None): The module name to be registered. If not + specified, the class name will be used. + force (bool, optional): Whether to override an existing class with + the same name. Default: False. + module (type): Module class to be registered. + """ + if not isinstance(force, bool): + raise TypeError(f'force must be a boolean, but got {type(force)}') + # NOTE: This is a walkaround to be compatible with the old api, + # while it may introduce unexpected bugs. + if isinstance(name, type): + return self.deprecated_register_module(name, force=force) + + # raise the error ahead of time + if not (name is None or isinstance(name, str) or is_seq_of(name, str)): + raise TypeError( + 'name must be either of None, an instance of str or a sequence' + f' of str, but got {type(name)}') + + # use it as a normal method: x.register_module(module=SomeClass) + if module is not None: + self._register_module( + module_class=module, module_name=name, force=force) + return module + + # use it as a decorator: @x.register_module() + def _register(cls): + self._register_module( + module_class=cls, module_name=name, force=force) + return cls + + return _register diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/testing.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/testing.py new file mode 100644 index 000000000..a27f936da --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/testing.py @@ -0,0 +1,140 @@ +# Copyright (c) Open-MMLab. +import sys +from collections.abc import Iterable +from runpy import run_path +from shlex import split +from typing import Any, Dict, List +from unittest.mock import patch + + +def check_python_script(cmd): + """Run the python cmd script with `__main__`. The difference between + `os.system` is that, this function exectues code in the current process, so + that it can be tracked by coverage tools. Currently it supports two forms: + + - ./tests/data/scripts/hello.py zz + - python tests/data/scripts/hello.py zz + """ + args = split(cmd) + if args[0] == 'python': + args = args[1:] + with patch.object(sys, 'argv', args): + run_path(args[0], run_name='__main__') + + +def _any(judge_result): + """Since built-in ``any`` works only when the element of iterable is not + iterable, implement the function.""" + if not isinstance(judge_result, Iterable): + return judge_result + + try: + for element in judge_result: + if _any(element): + return True + except TypeError: + # Maybe encounter the case: torch.tensor(True) | torch.tensor(False) + if judge_result: + return True + return False + + +def assert_dict_contains_subset(dict_obj: Dict[Any, Any], + expected_subset: Dict[Any, Any]) -> bool: + """Check if the dict_obj contains the expected_subset. + + Args: + dict_obj (Dict[Any, Any]): Dict object to be checked. + expected_subset (Dict[Any, Any]): Subset expected to be contained in + dict_obj. + + Returns: + bool: Whether the dict_obj contains the expected_subset. + """ + + for key, value in expected_subset.items(): + if key not in dict_obj.keys() or _any(dict_obj[key] != value): + return False + return True + + +def assert_attrs_equal(obj: Any, expected_attrs: Dict[str, Any]) -> bool: + """Check if attribute of class object is correct. + + Args: + obj (object): Class object to be checked. + expected_attrs (Dict[str, Any]): Dict of the expected attrs. + + Returns: + bool: Whether the attribute of class object is correct. + """ + for attr, value in expected_attrs.items(): + if not hasattr(obj, attr) or _any(getattr(obj, attr) != value): + return False + return True + + +def assert_dict_has_keys(obj: Dict[str, Any], + expected_keys: List[str]) -> bool: + """Check if the obj has all the expected_keys. + + Args: + obj (Dict[str, Any]): Object to be checked. + expected_keys (List[str]): Keys expected to contained in the keys of + the obj. + + Returns: + bool: Whether the obj has the expected keys. + """ + return set(expected_keys).issubset(set(obj.keys())) + + +def assert_keys_equal(result_keys: List[str], target_keys: List[str]) -> bool: + """Check if target_keys is equal to result_keys. + + Args: + result_keys (List[str]): Result keys to be checked. + target_keys (List[str]): Target keys to be checked. + + Returns: + bool: Whether target_keys is equal to result_keys. + """ + return set(result_keys) == set(target_keys) + + +def assert_is_norm_layer(module) -> bool: + """Check if the module is a norm layer. + + Args: + module (nn.Module): The module to be checked. + + Returns: + bool: Whether the module is a norm layer. + """ + from .parrots_wrapper import _BatchNorm, _InstanceNorm + from torch.nn import GroupNorm, LayerNorm + norm_layer_candidates = (_BatchNorm, _InstanceNorm, GroupNorm, LayerNorm) + return isinstance(module, norm_layer_candidates) + + +def assert_params_all_zeros(module) -> bool: + """Check if the parameters of the module is all zeros. + + Args: + module (nn.Module): The module to be checked. + + Returns: + bool: Whether the parameters of the module is all zeros. + """ + weight_data = module.weight.data + is_weight_zero = weight_data.allclose( + weight_data.new_zeros(weight_data.size())) + + if hasattr(module, 'bias') and module.bias is not None: + bias_data = module.bias.data + is_bias_zero = bias_data.allclose( + bias_data.new_zeros(bias_data.size())) + else: + is_bias_zero = True + + return is_weight_zero and is_bias_zero diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/timer.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/timer.py new file mode 100644 index 000000000..66d4a78a8 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/timer.py @@ -0,0 +1,118 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from time import time + + +class TimerError(Exception): + + def __init__(self, message): + self.message = message + super(TimerError, self).__init__(message) + + +class Timer: + """A flexible Timer class. + + :Example: + + >>> import time + >>> import mmcv + >>> with mmcv.Timer(): + >>> # simulate a code block that will run for 1s + >>> time.sleep(1) + 1.000 + >>> with mmcv.Timer(print_tmpl='it takes {:.1f} seconds'): + >>> # simulate a code block that will run for 1s + >>> time.sleep(1) + it takes 1.0 seconds + >>> timer = mmcv.Timer() + >>> time.sleep(0.5) + >>> print(timer.since_start()) + 0.500 + >>> time.sleep(0.5) + >>> print(timer.since_last_check()) + 0.500 + >>> print(timer.since_start()) + 1.000 + """ + + def __init__(self, start=True, print_tmpl=None): + self._is_running = False + self.print_tmpl = print_tmpl if print_tmpl else '{:.3f}' + if start: + self.start() + + @property + def is_running(self): + """bool: indicate whether the timer is running""" + return self._is_running + + def __enter__(self): + self.start() + return self + + def __exit__(self, type, value, traceback): + print(self.print_tmpl.format(self.since_last_check())) + self._is_running = False + + def start(self): + """Start the timer.""" + if not self._is_running: + self._t_start = time() + self._is_running = True + self._t_last = time() + + def since_start(self): + """Total time since the timer is started. + + Returns (float): Time in seconds. + """ + if not self._is_running: + raise TimerError('timer is not running') + self._t_last = time() + return self._t_last - self._t_start + + def since_last_check(self): + """Time since the last checking. + + Either :func:`since_start` or :func:`since_last_check` is a checking + operation. + + Returns (float): Time in seconds. + """ + if not self._is_running: + raise TimerError('timer is not running') + dur = time() - self._t_last + self._t_last = time() + return dur + + +_g_timers = {} # global timers + + +def check_time(timer_id): + """Add check points in a single line. + + This method is suitable for running a task on a list of items. A timer will + be registered when the method is called for the first time. + + :Example: + + >>> import time + >>> import mmcv + >>> for i in range(1, 6): + >>> # simulate a code block + >>> time.sleep(i) + >>> mmcv.check_time('task1') + 2.000 + 3.000 + 4.000 + 5.000 + + Args: + timer_id (str): Timer identifier. + """ + if timer_id not in _g_timers: + _g_timers[timer_id] = Timer() + return 0 + else: + return _g_timers[timer_id].since_last_check() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/trace.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/trace.py new file mode 100644 index 000000000..8e49bfd38 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/trace.py @@ -0,0 +1,23 @@ +import warnings + +import torch + +from mmcv.utils import digit_version + + +def is_jit_tracing() -> bool: + if (torch.__version__ != 'parrots' + and digit_version(torch.__version__) >= digit_version('1.6.0')): + on_trace = torch.jit.is_tracing() + # In PyTorch 1.6, torch.jit.is_tracing has a bug. + # Refers to https://github.com/pytorch/pytorch/issues/42448 + if isinstance(on_trace, bool): + return on_trace + else: + return torch._C._is_tracing() + else: + warnings.warn( + 'torch.jit.is_tracing is only supported after v1.6.0. ' + 'Therefore is_tracing returns False automatically. Please ' + 'set on_trace manually if you are using trace.', UserWarning) + return False diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/version_utils.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/version_utils.py new file mode 100644 index 000000000..963c45a2e --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/utils/version_utils.py @@ -0,0 +1,90 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import os +import subprocess +import warnings + +from packaging.version import parse + + +def digit_version(version_str: str, length: int = 4): + """Convert a version string into a tuple of integers. + + This method is usually used for comparing two versions. For pre-release + versions: alpha < beta < rc. + + Args: + version_str (str): The version string. + length (int): The maximum number of version levels. Default: 4. + + Returns: + tuple[int]: The version info in digits (integers). + """ + assert 'parrots' not in version_str + version = parse(version_str) + assert version.release, f'failed to parse version {version_str}' + release = list(version.release) + release = release[:length] + if len(release) < length: + release = release + [0] * (length - len(release)) + if version.is_prerelease: + mapping = {'a': -3, 'b': -2, 'rc': -1} + val = -4 + # version.pre can be None + if version.pre: + if version.pre[0] not in mapping: + warnings.warn(f'unknown prerelease version {version.pre[0]}, ' + 'version checking may go wrong') + else: + val = mapping[version.pre[0]] + release.extend([val, version.pre[-1]]) + else: + release.extend([val, 0]) + + elif version.is_postrelease: + release.extend([1, version.post]) + else: + release.extend([0, 0]) + return tuple(release) + + +def _minimal_ext_cmd(cmd): + # construct minimal environment + env = {} + for k in ['SYSTEMROOT', 'PATH', 'HOME']: + v = os.environ.get(k) + if v is not None: + env[k] = v + # LANGUAGE is used on win32 + env['LANGUAGE'] = 'C' + env['LANG'] = 'C' + env['LC_ALL'] = 'C' + out = subprocess.Popen( + cmd, stdout=subprocess.PIPE, env=env).communicate()[0] + return out + + +def get_git_hash(fallback='unknown', digits=None): + """Get the git hash of the current repo. + + Args: + fallback (str, optional): The fallback string when git hash is + unavailable. Defaults to 'unknown'. + digits (int, optional): kept digits of the hash. Defaults to None, + meaning all digits are kept. + + Returns: + str: Git commit hash. + """ + + if digits is not None and not isinstance(digits, int): + raise TypeError('digits must be None or an integer') + + try: + out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD']) + sha = out.strip().decode('ascii') + if digits is not None: + sha = sha[:digits] + except OSError: + sha = fallback + + return sha diff --git a/cv/instance_segmentation/SOLO/pytorch/mmcv/version.py b/cv/instance_segmentation/SOLO/pytorch/mmcv/version.py new file mode 100644 index 000000000..1cce4e50b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmcv/version.py @@ -0,0 +1,35 @@ +# Copyright (c) OpenMMLab. All rights reserved. +__version__ = '1.3.17' + + +def parse_version_info(version_str: str, length: int = 4) -> tuple: + """Parse a version string into a tuple. + + Args: + version_str (str): The version string. + length (int): The maximum number of version levels. Default: 4. + + Returns: + tuple[int | str]: The version info, e.g., "1.3.0" is parsed into + (1, 3, 0, 0, 0, 0), and "2.0.0rc1" is parsed into + (2, 0, 0, 0, 'rc', 1) (when length is set to 4). + """ + from packaging.version import parse + version = parse(version_str) + assert version.release, f'failed to parse version {version_str}' + release = list(version.release) + release = release[:length] + if len(release) < length: + release = release + [0] * (length - len(release)) + if version.is_prerelease: + release.extend(list(version.pre)) + elif version.is_postrelease: + release.extend(list(version.post)) + else: + release.extend([0, 0]) + return tuple(release) + + +version_info = tuple(int(x) for x in __version__.split('.')[:3]) + +__all__ = ['__version__', 'version_info', 'parse_version_info'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/__init__.py index 1c4f7e8fc..1f8ee169b 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/__init__.py @@ -1,3 +1,29 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import mmcv + from .version import __version__, short_version + +def digit_version(version_str): + digit_version = [] + for x in version_str.split('.'): + if x.isdigit(): + digit_version.append(int(x)) + elif x.find('rc') != -1: + patch_version = x.split('rc') + digit_version.append(int(patch_version[0]) - 1) + digit_version.append(int(patch_version[1])) + return digit_version + + +mmcv_minimum_version = '1.3.17' +mmcv_maximum_version = '1.6.0' +mmcv_version = digit_version(mmcv.__version__) + + +assert (mmcv_version >= digit_version(mmcv_minimum_version) + and mmcv_version <= digit_version(mmcv_maximum_version)), \ + f'MMCV=={mmcv.__version__} is used but incompatible. ' \ + f'Please install mmcv>={mmcv_minimum_version}, <={mmcv_maximum_version}.' + __all__ = ['__version__', 'short_version'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/__init__.py index 164594445..a865e942a 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/__init__.py @@ -1,9 +1,12 @@ +# Copyright (c) OpenMMLab. All rights reserved. from .inference import (async_inference_detector, inference_detector, - init_detector, show_result, show_result_pyplot, show_result_ins) -from .train import get_root_logger, set_random_seed, train_detector + init_detector, show_result_pyplot) +from .test import multi_gpu_test, single_gpu_test +from .train import (get_root_logger, init_random_seed, set_random_seed, + train_detector) __all__ = [ 'get_root_logger', 'set_random_seed', 'train_detector', 'init_detector', - 'async_inference_detector', 'inference_detector', 'show_result', - 'show_result_pyplot', 'show_result_ins' + 'async_inference_detector', 'inference_detector', 'show_result_pyplot', + 'multi_gpu_test', 'single_gpu_test', 'init_random_seed' ] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/inference.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/inference.py index 9470b6e2a..795fce518 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/inference.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/inference.py @@ -1,44 +1,53 @@ +# Copyright (c) OpenMMLab. All rights reserved. import warnings +from pathlib import Path -import matplotlib.pyplot as plt import mmcv import numpy as np -import pycocotools.mask as maskUtils import torch +from mmcv.ops import RoIPool from mmcv.parallel import collate, scatter from mmcv.runner import load_checkpoint from mmdet.core import get_classes +from mmdet.datasets import replace_ImageToTensor from mmdet.datasets.pipelines import Compose from mmdet.models import build_detector -import cv2 -from scipy import ndimage -def init_detector(config, checkpoint=None, device='cuda:0'): +def init_detector(config, checkpoint=None, device='cuda:0', cfg_options=None): """Initialize a detector from config file. Args: - config (str or :obj:`mmcv.Config`): Config file path or the config - object. + config (str, :obj:`Path`, or :obj:`mmcv.Config`): Config file path, + :obj:`Path`, or the config object. checkpoint (str, optional): Checkpoint path. If left as None, the model will not load any weights. + cfg_options (dict): Options to override some settings in the used + config. Returns: nn.Module: The constructed detector. """ - if isinstance(config, str): + if isinstance(config, (str, Path)): config = mmcv.Config.fromfile(config) elif not isinstance(config, mmcv.Config): raise TypeError('config must be a filename or Config object, ' - 'but got {}'.format(type(config))) - config.model.pretrained = None - model = build_detector(config.model, test_cfg=config.test_cfg) + f'but got {type(config)}') + if cfg_options is not None: + config.merge_from_dict(cfg_options) + if 'pretrained' in config.model: + config.model.pretrained = None + elif 'init_cfg' in config.model.backbone: + config.model.backbone.init_cfg = None + config.model.train_cfg = None + model = build_detector(config.model, test_cfg=config.get('test_cfg')) if checkpoint is not None: - checkpoint = load_checkpoint(model, checkpoint) - if 'CLASSES' in checkpoint['meta']: + checkpoint = load_checkpoint(model, checkpoint, map_location='cpu') + if 'CLASSES' in checkpoint.get('meta', {}): model.CLASSES = checkpoint['meta']['CLASSES'] else: + warnings.simplefilter('once') warnings.warn('Class names are not saved in the checkpoint\'s ' 'meta data, use COCO classes by default.') model.CLASSES = get_classes('coco') @@ -48,243 +57,195 @@ def init_detector(config, checkpoint=None, device='cuda:0'): return model -class LoadImage(object): +class LoadImage: + """Deprecated. + + A simple pipeline to load image. + """ def __call__(self, results): + """Call function to load images into results. + + Args: + results (dict): A result dict contains the file name + of the image to be read. + Returns: + dict: ``results`` will be returned containing loaded image. + """ + warnings.simplefilter('once') + warnings.warn('`LoadImage` is deprecated and will be removed in ' + 'future releases. You may use `LoadImageFromWebcam` ' + 'from `mmdet.datasets.pipelines.` instead.') if isinstance(results['img'], str): results['filename'] = results['img'] + results['ori_filename'] = results['img'] else: results['filename'] = None + results['ori_filename'] = None img = mmcv.imread(results['img']) results['img'] = img + results['img_fields'] = ['img'] results['img_shape'] = img.shape results['ori_shape'] = img.shape return results -def inference_detector(model, img): +def inference_detector(model, imgs): """Inference image(s) with the detector. Args: model (nn.Module): The loaded detector. - imgs (str/ndarray or list[str/ndarray]): Either image files or loaded - images. + imgs (str/ndarray or list[str/ndarray] or tuple[str/ndarray]): + Either image files or loaded images. Returns: - If imgs is a str, a generator will be returned, otherwise return the - detection results directly. + If imgs is a list or tuple, the same length list type results + will be returned, otherwise return the detection results directly. """ + + if isinstance(imgs, (list, tuple)): + is_batch = True + else: + imgs = [imgs] + is_batch = False + cfg = model.cfg device = next(model.parameters()).device # model device - # build the data pipeline - test_pipeline = [LoadImage()] + cfg.data.test.pipeline[1:] - test_pipeline = Compose(test_pipeline) - # prepare data - data = dict(img=img) - data = test_pipeline(data) - data = scatter(collate([data], samples_per_gpu=1), [device])[0] + + if isinstance(imgs[0], np.ndarray): + cfg = cfg.copy() + # set loading pipeline type + cfg.data.test.pipeline[0].type = 'LoadImageFromWebcam' + + cfg.data.test.pipeline = replace_ImageToTensor(cfg.data.test.pipeline) + test_pipeline = Compose(cfg.data.test.pipeline) + + datas = [] + for img in imgs: + # prepare data + if isinstance(img, np.ndarray): + # directly add img + data = dict(img=img) + else: + # add information into dict + data = dict(img_info=dict(filename=img), img_prefix=None) + # build the data pipeline + data = test_pipeline(data) + datas.append(data) + + data = collate(datas, samples_per_gpu=len(imgs)) + # just get the actual data from DataContainer + data['img_metas'] = [img_metas.data[0] for img_metas in data['img_metas']] + data['img'] = [img.data[0] for img in data['img']] + if next(model.parameters()).is_cuda: + # scatter to specified GPU + data = scatter(data, [device])[0] + else: + for m in model.modules(): + assert not isinstance( + m, RoIPool + ), 'CPU inference with RoIPool is not supported currently.' + # forward the model with torch.no_grad(): - result = model(return_loss=False, rescale=True, **data) - return result + results = model(return_loss=False, rescale=True, **data) + if not is_batch: + return results[0] + else: + return results -async def async_inference_detector(model, img): + +async def async_inference_detector(model, imgs): """Async inference image(s) with the detector. Args: model (nn.Module): The loaded detector. - imgs (str/ndarray or list[str/ndarray]): Either image files or loaded - images. + img (str | ndarray): Either image files or loaded images. Returns: Awaitable detection results. """ + if not isinstance(imgs, (list, tuple)): + imgs = [imgs] + cfg = model.cfg device = next(model.parameters()).device # model device - # build the data pipeline - test_pipeline = [LoadImage()] + cfg.data.test.pipeline[1:] - test_pipeline = Compose(test_pipeline) - # prepare data - data = dict(img=img) - data = test_pipeline(data) - data = scatter(collate([data], samples_per_gpu=1), [device])[0] - # We don't restore `torch.is_grad_enabled()` value during concurrent - # inference since execution can overlap - torch.set_grad_enabled(False) - result = await model.aforward_test(rescale=True, **data) - return result - - -# TODO: merge this method with the one in BaseDetector -def show_result(img, - result, - class_names, - score_thr=0.3, - wait_time=0, - show=True, - out_file=None): - """Visualize the detection results on the image. + if isinstance(imgs[0], np.ndarray): + cfg = cfg.copy() + # set loading pipeline type + cfg.data.test.pipeline[0].type = 'LoadImageFromWebcam' - Args: - img (str or np.ndarray): Image filename or loaded image. - result (tuple[list] or list): The detection result, can be either - (bbox, segm) or just bbox. - class_names (list[str] or tuple[str]): A list of class names. - score_thr (float): The threshold to visualize the bboxes and masks. - wait_time (int): Value of waitKey param. - show (bool, optional): Whether to show the image with opencv or not. - out_file (str, optional): If specified, the visualization result will - be written to the out file instead of shown in a window. + cfg.data.test.pipeline = replace_ImageToTensor(cfg.data.test.pipeline) + test_pipeline = Compose(cfg.data.test.pipeline) - Returns: - np.ndarray or None: If neither `show` nor `out_file` is specified, the - visualized image is returned, otherwise None is returned. - """ - assert isinstance(class_names, (tuple, list)) - img = mmcv.imread(img) - img = img.copy() - if isinstance(result, tuple): - bbox_result, segm_result = result + datas = [] + for img in imgs: + # prepare data + if isinstance(img, np.ndarray): + # directly add img + data = dict(img=img) + else: + # add information into dict + data = dict(img_info=dict(filename=img), img_prefix=None) + # build the data pipeline + data = test_pipeline(data) + datas.append(data) + + data = collate(datas, samples_per_gpu=len(imgs)) + # just get the actual data from DataContainer + data['img_metas'] = [img_metas.data[0] for img_metas in data['img_metas']] + data['img'] = [img.data[0] for img in data['img']] + if next(model.parameters()).is_cuda: + # scatter to specified GPU + data = scatter(data, [device])[0] else: - bbox_result, segm_result = result, None - bboxes = np.vstack(bbox_result) - labels = [ - np.full(bbox.shape[0], i, dtype=np.int32) - for i, bbox in enumerate(bbox_result) - ] - labels = np.concatenate(labels) - # draw segmentation masks - if segm_result is not None: - segms = mmcv.concat_list(segm_result) - inds = np.where(bboxes[:, -1] > score_thr)[0] - np.random.seed(42) - color_masks = [ - np.random.randint(0, 256, (1, 3), dtype=np.uint8) - for _ in range(max(labels) + 1) - ] - for i in inds: - i = int(i) - color_mask = color_masks[labels[i]] - mask = maskUtils.decode(segms[i]).astype(np.bool) - img[mask] = img[mask] * 0.5 + color_mask * 0.5 - # draw bounding boxes - mmcv.imshow_det_bboxes( - img, - bboxes, - labels, - class_names=class_names, - score_thr=score_thr, - show=show, - wait_time=wait_time, - out_file=out_file) - if not (show or out_file): - return img + for m in model.modules(): + assert not isinstance( + m, RoIPool + ), 'CPU inference with RoIPool is not supported currently.' + + # We don't restore `torch.is_grad_enabled()` value during concurrent + # inference since execution can overlap + torch.set_grad_enabled(False) + results = await model.aforward_test(rescale=True, **data) + return results -def show_result_pyplot(img, +def show_result_pyplot(model, + img, result, - class_names, score_thr=0.3, - fig_size=(15, 10)): + title='result', + wait_time=0, + palette=None, + out_file=None): """Visualize the detection results on the image. Args: + model (nn.Module): The loaded detector. img (str or np.ndarray): Image filename or loaded image. result (tuple[list] or list): The detection result, can be either (bbox, segm) or just bbox. - class_names (list[str] or tuple[str]): A list of class names. score_thr (float): The threshold to visualize the bboxes and masks. - fig_size (tuple): Figure size of the pyplot figure. - out_file (str, optional): If specified, the visualization result will - be written to the out file instead of shown in a window. + title (str): Title of the pyplot figure. + wait_time (float): Value of waitKey param. Default: 0. + palette (str or tuple(int) or :obj:`Color`): Color. + The tuple of color should be in BGR order. + out_file (str or None): The path to write the image. + Default: None. """ - img = show_result( - img, result, class_names, score_thr=score_thr, show=False) - plt.figure(figsize=fig_size) - plt.imshow(mmcv.bgr2rgb(img)) - - -def show_result_ins(img, - result, - class_names, - score_thr=0.3, - sort_by_density=False, - out_file=None): - """Visualize the instance segmentation results on the image. - - Args: - img (str or np.ndarray): Image filename or loaded image. - result (tuple[list] or list): The instance segmentation result. - class_names (list[str] or tuple[str]): A list of class names. - score_thr (float): The threshold to visualize the masks. - sort_by_density (bool): sort the masks by their density. - out_file (str, optional): If specified, the visualization result will - be written to the out file instead of shown in a window. - - Returns: - np.ndarray or None: If neither `show` nor `out_file` is specified, the - visualized image is returned, otherwise None is returned. - """ - - assert isinstance(class_names, (tuple, list)) - img = mmcv.imread(img) - img_show = img.copy() - h, w, _ = img.shape - - if not result or result == [None]: - return img_show - cur_result = result[0] - seg_label = cur_result[0] - seg_label = seg_label.cpu().numpy().astype(np.uint8) - cate_label = cur_result[1] - cate_label = cate_label.cpu().numpy() - score = cur_result[2].cpu().numpy() - - vis_inds = score > score_thr - seg_label = seg_label[vis_inds] - num_mask = seg_label.shape[0] - cate_label = cate_label[vis_inds] - cate_score = score[vis_inds] - - if sort_by_density: - mask_density = [] - for idx in range(num_mask): - cur_mask = seg_label[idx, :, :] - cur_mask = mmcv.imresize(cur_mask, (w, h)) - cur_mask = (cur_mask > 0.5).astype(np.int32) - mask_density.append(cur_mask.sum()) - orders = np.argsort(mask_density) - seg_label = seg_label[orders] - cate_label = cate_label[orders] - cate_score = cate_score[orders] - - np.random.seed(42) - color_masks = [ - np.random.randint(0, 256, (1, 3), dtype=np.uint8) - for _ in range(num_mask) - ] - for idx in range(num_mask): - idx = -(idx+1) - cur_mask = seg_label[idx, :, :] - cur_mask = mmcv.imresize(cur_mask, (w, h)) - cur_mask = (cur_mask > 0.5).astype(np.uint8) - if cur_mask.sum() == 0: - continue - color_mask = color_masks[idx] - cur_mask_bool = cur_mask.astype(np.bool) - img_show[cur_mask_bool] = img[cur_mask_bool] * 0.5 + color_mask * 0.5 - - cur_cate = cate_label[idx] - cur_score = cate_score[idx] - label_text = class_names[cur_cate] - #label_text += '|{:.02f}'.format(cur_score) - center_y, center_x = ndimage.measurements.center_of_mass(cur_mask) - vis_pos = (max(int(center_x) - 10, 0), int(center_y)) - cv2.putText(img_show, label_text, vis_pos, - cv2.FONT_HERSHEY_COMPLEX, 0.3, (255, 255, 255)) # green - if out_file is None: - return img_show - else: - mmcv.imwrite(img_show, out_file) + if hasattr(model, 'module'): + model = model.module + model.show_result( + img, + result, + score_thr=score_thr, + show=True, + wait_time=wait_time, + win_name=title, + bbox_color=palette, + text_color=(200, 200, 200), + mask_color=palette, + out_file=out_file) diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/test.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/test.py similarity index 44% rename from cv/instance_segmentation/SOLO/pytorch/tools/test.py rename to cv/instance_segmentation/SOLO/pytorch/mmdet/apis/test.py index b39cf13ab..973d3623d 100644 --- a/cv/instance_segmentation/SOLO/pytorch/tools/test.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/test.py @@ -1,35 +1,78 @@ -import argparse -import os +# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import pickle import shutil import tempfile +import time import mmcv import torch import torch.distributed as dist -from mmcv.parallel import MMDataParallel, MMDistributedDataParallel -from mmcv.runner import get_dist_info, init_dist, load_checkpoint +from mmcv.image import tensor2imgs +from mmcv.runner import get_dist_info -from mmdet.core import coco_eval, results2json, wrap_fp16_model -from mmdet.datasets import build_dataloader, build_dataset -from mmdet.models import build_detector +from mmdet.core import encode_mask_results -def single_gpu_test(model, data_loader, show=False): +def single_gpu_test(model, + data_loader, + show=False, + out_dir=None, + show_score_thr=0.3): model.eval() results = [] dataset = data_loader.dataset + PALETTE = getattr(dataset, 'PALETTE', None) prog_bar = mmcv.ProgressBar(len(dataset)) for i, data in enumerate(data_loader): with torch.no_grad(): - result = model(return_loss=False, rescale=not show, **data) - results.append(result) + result = model(return_loss=False, rescale=True, **data) + + batch_size = len(result) + if show or out_dir: + if batch_size == 1 and isinstance(data['img'][0], torch.Tensor): + img_tensor = data['img'][0] + else: + img_tensor = data['img'][0].data[0] + img_metas = data['img_metas'][0].data[0] + imgs = tensor2imgs(img_tensor, **img_metas[0]['img_norm_cfg']) + assert len(imgs) == len(img_metas) + + for i, (img, img_meta) in enumerate(zip(imgs, img_metas)): + h, w, _ = img_meta['img_shape'] + img_show = img[:h, :w, :] - if show: - model.module.show_result(data, result) + ori_h, ori_w = img_meta['ori_shape'][:-1] + img_show = mmcv.imresize(img_show, (ori_w, ori_h)) + + if out_dir: + out_file = osp.join(out_dir, img_meta['ori_filename']) + else: + out_file = None + + model.module.show_result( + img_show, + result[i], + bbox_color=PALETTE, + text_color=PALETTE, + mask_color=PALETTE, + show=show, + out_file=out_file, + score_thr=show_score_thr) + + # encode mask results + if isinstance(result[0], tuple): + result = [(bbox_results, encode_mask_results(mask_results)) + for bbox_results, mask_results in result] + # This logic is only used in panoptic segmentation test. + elif isinstance(result[0], dict) and 'ins_results' in result[0]: + for j in range(len(result)): + bbox_results, mask_results = result[j]['ins_results'] + result[j]['ins_results'] = (bbox_results, + encode_mask_results(mask_results)) + + results.extend(result) - batch_size = data['img'][0].size(0) for _ in range(batch_size): prog_bar.update() return results @@ -60,13 +103,25 @@ def multi_gpu_test(model, data_loader, tmpdir=None, gpu_collect=False): rank, world_size = get_dist_info() if rank == 0: prog_bar = mmcv.ProgressBar(len(dataset)) + time.sleep(2) # This line can prevent deadlock problem in some cases. for i, data in enumerate(data_loader): with torch.no_grad(): result = model(return_loss=False, rescale=True, **data) - results.append(result) + # encode mask results + if isinstance(result[0], tuple): + result = [(bbox_results, encode_mask_results(mask_results)) + for bbox_results, mask_results in result] + # This logic is only used in panoptic segmentation test. + elif isinstance(result[0], dict) and 'ins_results' in result[0]: + for j in range(len(result)): + bbox_results, mask_results = result[j]['ins_results'] + result[j]['ins_results'] = ( + bbox_results, encode_mask_results(mask_results)) + + results.extend(result) if rank == 0: - batch_size = data['img'][0].size(0) + batch_size = len(result) for _ in range(batch_size * world_size): prog_bar.update() @@ -89,7 +144,8 @@ def collect_results_cpu(result_part, size, tmpdir=None): dtype=torch.uint8, device='cuda') if rank == 0: - tmpdir = tempfile.mkdtemp() + mmcv.mkdir_or_exist('.dist_test') + tmpdir = tempfile.mkdtemp(dir='.dist_test') tmpdir = torch.tensor( bytearray(tmpdir.encode()), dtype=torch.uint8, device='cuda') dir_tensor[:len(tmpdir)] = tmpdir @@ -98,7 +154,7 @@ def collect_results_cpu(result_part, size, tmpdir=None): else: mmcv.mkdir_or_exist(tmpdir) # dump the part result to the dir - mmcv.dump(result_part, osp.join(tmpdir, 'part_{}.pkl'.format(rank))) + mmcv.dump(result_part, osp.join(tmpdir, f'part_{rank}.pkl')) dist.barrier() # collect all parts if rank != 0: @@ -107,7 +163,7 @@ def collect_results_cpu(result_part, size, tmpdir=None): # load results of all parts from tmp dir part_list = [] for i in range(world_size): - part_file = osp.join(tmpdir, 'part_{}.pkl'.format(i)) + part_file = osp.join(tmpdir, f'part_{i}.pkl') part_list.append(mmcv.load(part_file)) # sort the results ordered_results = [] @@ -151,132 +207,3 @@ def collect_results_gpu(result_part, size): # the dataloader may pad some samples ordered_results = ordered_results[:size] return ordered_results - - -def parse_args(): - parser = argparse.ArgumentParser(description='MMDet test detector') - parser.add_argument('config', help='test config file path') - parser.add_argument('checkpoint', help='checkpoint file') - parser.add_argument('--out', help='output result file') - parser.add_argument( - '--json_out', - help='output result file name without extension', - type=str) - parser.add_argument( - '--eval', - type=str, - nargs='+', - choices=['proposal', 'proposal_fast', 'bbox', 'segm', 'keypoints'], - help='eval types') - parser.add_argument('--show', action='store_true', help='show results') - parser.add_argument( - '--gpu_collect', - action='store_true', - help='whether to use gpu to collect results') - parser.add_argument('--tmpdir', help='tmp dir for writing some results') - parser.add_argument( - '--launcher', - choices=['none', 'pytorch', 'slurm', 'mpi'], - default='none', - help='job launcher') - parser.add_argument('--local_rank', type=int, default=0) - args = parser.parse_args() - if 'LOCAL_RANK' not in os.environ: - os.environ['LOCAL_RANK'] = str(args.local_rank) - return args - - -def main(): - args = parse_args() - - assert args.out or args.show or args.json_out, \ - ('Please specify at least one operation (save or show the results) ' - 'with the argument "--out" or "--show" or "--json_out"') - - if args.out is not None and not args.out.endswith(('.pkl', '.pickle')): - raise ValueError('The output file must be a pkl file.') - - if args.json_out is not None and args.json_out.endswith('.json'): - args.json_out = args.json_out[:-5] - - cfg = mmcv.Config.fromfile(args.config) - # set cudnn_benchmark - if cfg.get('cudnn_benchmark', False): - torch.backends.cudnn.benchmark = True - cfg.model.pretrained = None - cfg.data.test.test_mode = True - - # init distributed env first, since logger depends on the dist info. - if args.launcher == 'none': - distributed = False - else: - distributed = True - init_dist(args.launcher, **cfg.dist_params) - - # build the dataloader - # TODO: support multiple images per gpu (only minor changes are needed) - dataset = build_dataset(cfg.data.test) - data_loader = build_dataloader( - dataset, - imgs_per_gpu=1, - workers_per_gpu=cfg.data.workers_per_gpu, - dist=distributed, - shuffle=False) - - # build the model and load checkpoint - model = build_detector(cfg.model, train_cfg=None, test_cfg=cfg.test_cfg) - fp16_cfg = cfg.get('fp16', None) - if fp16_cfg is not None: - wrap_fp16_model(model) - checkpoint = load_checkpoint(model, args.checkpoint, map_location='cpu') - # old versions did not save class info in checkpoints, this walkaround is - # for backward compatibility - if 'CLASSES' in checkpoint['meta']: - model.CLASSES = checkpoint['meta']['CLASSES'] - else: - model.CLASSES = dataset.CLASSES - - if not distributed: - model = MMDataParallel(model, device_ids=[0]) - outputs = single_gpu_test(model, data_loader, args.show) - else: - model = MMDistributedDataParallel(model.cuda()) - outputs = multi_gpu_test(model, data_loader, args.tmpdir, - args.gpu_collect) - - rank, _ = get_dist_info() - if args.out and rank == 0: - print('\nwriting results to {}'.format(args.out)) - mmcv.dump(outputs, args.out) - eval_types = args.eval - if eval_types: - print('Starting evaluate {}'.format(' and '.join(eval_types))) - if eval_types == ['proposal_fast']: - result_file = args.out - coco_eval(result_file, eval_types, dataset.coco) - else: - if not isinstance(outputs[0], dict): - result_files = results2json(dataset, outputs, args.out) - coco_eval(result_files, eval_types, dataset.coco) - else: - for name in outputs[0]: - print('\nEvaluating {}'.format(name)) - outputs_ = [out[name] for out in outputs] - result_file = args.out + '.{}'.format(name) - result_files = results2json(dataset, outputs_, - result_file) - coco_eval(result_files, eval_types, dataset.coco) - - # Save predictions in the COCO json format - if args.json_out and rank == 0: - if not isinstance(outputs[0], dict): - results2json(dataset, outputs, args.json_out) - else: - for name in outputs[0]: - outputs_ = [out[name] for out in outputs] - result_file = args.json_out + '.{}'.format(name) - results2json(dataset, outputs_, result_file) - - -if __name__ == '__main__': - main() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/train.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/train.py index 97c0dc69e..ca7633180 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/train.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/apis/train.py @@ -1,19 +1,52 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import os import random -import re -from collections import OrderedDict import numpy as np import torch import torch.distributed as dist -from mmcv.parallel import MMDataParallel, MMDistributedDataParallel -from mmcv.runner import DistSamplerSeedHook, Runner, obj_from_dict +from mmcv.runner import (DistSamplerSeedHook, EpochBasedRunner, + Fp16OptimizerHook, OptimizerHook, build_runner, + get_dist_info) -from mmdet import datasets -from mmdet.core import (CocoDistEvalmAPHook, CocoDistEvalRecallHook, - DistEvalmAPHook, DistOptimizerHook, Fp16OptimizerHook) -from mmdet.datasets import DATASETS, build_dataloader -from mmdet.models import RPN -from mmdet.utils import get_root_logger +from mmdet.core import DistEvalHook, EvalHook, build_optimizer +from mmdet.datasets import (build_dataloader, build_dataset, + replace_ImageToTensor) +from mmdet.utils import (build_ddp, build_dp, compat_cfg, + find_latest_checkpoint, get_root_logger) + + +def init_random_seed(seed=None, device='cuda'): + """Initialize random seed. + + If the seed is not set, the seed will be automatically randomized, + and then broadcast to all processes to prevent some potential bugs. + + Args: + seed (int, Optional): The seed. Default to None. + device (str): The device where the seed will be put on. + Default to 'cuda'. + + Returns: + int: Seed to be used. + """ + if seed is not None: + return seed + + # Make sure all ranks share the same random seed to prevent + # some potential bugs. Please refer to + # https://github.com/open-mmlab/mmdetection/issues/6339 + rank, world_size = get_dist_info() + seed = np.random.randint(2**31) + if world_size == 1: + return seed + + if rank == 0: + random_num = torch.tensor(seed, dtype=torch.int32, device=device) + else: + random_num = torch.tensor(0, dtype=torch.int32, device=device) + dist.broadcast(random_num, src=0) + return random_num.item() def set_random_seed(seed, deterministic=False): @@ -35,53 +68,50 @@ def set_random_seed(seed, deterministic=False): torch.backends.cudnn.benchmark = False -def parse_losses(losses): - log_vars = OrderedDict() - for loss_name, loss_value in losses.items(): - if isinstance(loss_value, torch.Tensor): - log_vars[loss_name] = loss_value.mean() - elif isinstance(loss_value, list): - log_vars[loss_name] = sum(_loss.mean() for _loss in loss_value) - else: - raise TypeError( - '{} is not a tensor or list of tensors'.format(loss_name)) - - loss = sum(_value for _key, _value in log_vars.items() if 'loss' in _key) - - log_vars['loss'] = loss - for loss_name, loss_value in log_vars.items(): - # reduce loss when distributed training - if dist.is_available() and dist.is_initialized(): - loss_value = loss_value.data.clone() - dist.all_reduce(loss_value.div_(dist.get_world_size())) - log_vars[loss_name] = loss_value.item() - - return loss, log_vars - - -def batch_processor(model, data, train_mode): - """Process a data batch. - - This method is required as an argument of Runner, which defines how to - process a data batch and obtain proper outputs. The first 3 arguments of - batch_processor are fixed. +def auto_scale_lr(cfg, distributed, logger): + """Automatically scaling LR according to GPU number and sample per GPU. Args: - model (nn.Module): A PyTorch model. - data (dict): The data batch in a dict. - train_mode (bool): Training mode or not. It may be useless for some - models. - - Returns: - dict: A dict containing losses and log vars. + cfg (config): Training config. + distributed (bool): Using distributed or not. + logger (logging.Logger): Logger. """ - losses = model(**data) - loss, log_vars = parse_losses(losses) - - outputs = dict( - loss=loss, log_vars=log_vars, num_samples=len(data['img'].data)) - - return outputs + # Get flag from config + if ('auto_scale_lr' not in cfg) or \ + (not cfg.auto_scale_lr.get('enable', False)): + logger.info('Automatic scaling of learning rate (LR)' + ' has been disabled.') + return + + # Get base batch size from config + base_batch_size = cfg.auto_scale_lr.get('base_batch_size', None) + if base_batch_size is None: + return + + # Get gpu number + if distributed: + _, world_size = get_dist_info() + num_gpus = len(range(world_size)) + else: + num_gpus = len(cfg.gpu_ids) + + # calculate the batch size + samples_per_gpu = cfg.data.train_dataloader.samples_per_gpu + batch_size = num_gpus * samples_per_gpu + logger.info(f'Training with {num_gpus} GPU(s) with {samples_per_gpu} ' + f'samples per GPU. The total batch size is {batch_size}.') + + if batch_size != base_batch_size: + # scale LR with + # [linear scaling rule](https://arxiv.org/abs/1706.02677) + scaled_lr = (batch_size / base_batch_size) * cfg.optimizer.lr + logger.info('LR has been automatically scaled ' + f'from {cfg.optimizer.lr} to {scaled_lr}') + cfg.optimizer.lr = scaled_lr + else: + logger.info('The batch size match the ' + f'base batch size: {base_batch_size}, ' + f'will not scaling the LR ({cfg.optimizer.lr}).') def train_detector(model, @@ -89,209 +119,126 @@ def train_detector(model, cfg, distributed=False, validate=False, - timestamp=None): - logger = get_root_logger(cfg.log_level) + timestamp=None, + meta=None): - # start training - if distributed: - _dist_train( - model, - dataset, - cfg, - validate=validate, - logger=logger, - timestamp=timestamp) - else: - _non_dist_train( - model, - dataset, - cfg, - validate=validate, - logger=logger, - timestamp=timestamp) + cfg = compat_cfg(cfg) + logger = get_root_logger(log_level=cfg.log_level) + # prepare data loaders + dataset = dataset if isinstance(dataset, (list, tuple)) else [dataset] -def build_optimizer(model, optimizer_cfg): - """Build optimizer from configs. + runner_type = 'EpochBasedRunner' if 'runner' not in cfg else cfg.runner[ + 'type'] - Args: - model (:obj:`nn.Module`): The model with parameters to be optimized. - optimizer_cfg (dict): The config dict of the optimizer. - Positional fields are: - - type: class name of the optimizer. - - lr: base learning rate. - Optional fields are: - - any arguments of the corresponding optimizer type, e.g., - weight_decay, momentum, etc. - - paramwise_options: a dict with 3 accepted fileds - (bias_lr_mult, bias_decay_mult, norm_decay_mult). - `bias_lr_mult` and `bias_decay_mult` will be multiplied to - the lr and weight decay respectively for all bias parameters - (except for the normalization layers), and - `norm_decay_mult` will be multiplied to the weight decay - for all weight and bias parameters of normalization layers. + train_dataloader_default_args = dict( + samples_per_gpu=2, + workers_per_gpu=2, + # `num_gpus` will be ignored if distributed + num_gpus=len(cfg.gpu_ids), + dist=distributed, + seed=cfg.seed, + runner_type=runner_type, + persistent_workers=False) - Returns: - torch.optim.Optimizer: The initialized optimizer. + train_loader_cfg = { + **train_dataloader_default_args, + **cfg.data.get('train_dataloader', {}) + } + + data_loaders = [build_dataloader(ds, **train_loader_cfg) for ds in dataset] - Example: - >>> model = torch.nn.modules.Conv1d(1, 1, 1) - >>> optimizer_cfg = dict(type='SGD', lr=0.01, momentum=0.9, - >>> weight_decay=0.0001) - >>> optimizer = build_optimizer(model, optimizer_cfg) - """ - if hasattr(model, 'module'): - model = model.module - - optimizer_cfg = optimizer_cfg.copy() - paramwise_options = optimizer_cfg.pop('paramwise_options', None) - # if no paramwise option is specified, just use the global setting - if paramwise_options is None: - return obj_from_dict(optimizer_cfg, torch.optim, - dict(params=model.parameters())) - else: - assert isinstance(paramwise_options, dict) - # get base lr and weight decay - base_lr = optimizer_cfg['lr'] - base_wd = optimizer_cfg.get('weight_decay', None) - # weight_decay must be explicitly specified if mult is specified - if ('bias_decay_mult' in paramwise_options - or 'norm_decay_mult' in paramwise_options): - assert base_wd is not None - # get param-wise options - bias_lr_mult = paramwise_options.get('bias_lr_mult', 1.) - bias_decay_mult = paramwise_options.get('bias_decay_mult', 1.) - norm_decay_mult = paramwise_options.get('norm_decay_mult', 1.) - # set param-wise lr and weight decay - params = [] - for name, param in model.named_parameters(): - param_group = {'params': [param]} - if not param.requires_grad: - # FP16 training needs to copy gradient/weight between master - # weight copy and model weight, it is convenient to keep all - # parameters here to align with model.parameters() - params.append(param_group) - continue - - # for norm layers, overwrite the weight decay of weight and bias - # TODO: obtain the norm layer prefixes dynamically - if re.search(r'(bn|gn)(\d+)?.(weight|bias)', name): - if base_wd is not None: - param_group['weight_decay'] = base_wd * norm_decay_mult - # for other layers, overwrite both lr and weight decay of bias - elif name.endswith('.bias'): - param_group['lr'] = base_lr * bias_lr_mult - if base_wd is not None: - param_group['weight_decay'] = base_wd * bias_decay_mult - # otherwise use the global settings - - params.append(param_group) - - optimizer_cls = getattr(torch.optim, optimizer_cfg.pop('type')) - return optimizer_cls(params, **optimizer_cfg) - - -def _dist_train(model, - dataset, - cfg, - validate=False, - logger=None, - timestamp=None): - # prepare data loaders - dataset = dataset if isinstance(dataset, (list, tuple)) else [dataset] - data_loaders = [ - build_dataloader( - ds, cfg.data.imgs_per_gpu, cfg.data.workers_per_gpu, dist=True) - for ds in dataset - ] # put model on gpus - model = MMDistributedDataParallel(model.cuda()) + if distributed: + find_unused_parameters = cfg.get('find_unused_parameters', False) + # Sets the `find_unused_parameters` parameter in + # torch.nn.parallel.DistributedDataParallel + model = build_ddp( + model, + cfg.device, + device_ids=[int(os.environ['LOCAL_RANK'])], + broadcast_buffers=False, + find_unused_parameters=find_unused_parameters) + else: + model = build_dp(model, cfg.device, device_ids=cfg.gpu_ids) - # build runner + # build optimizer + auto_scale_lr(cfg, distributed, logger) optimizer = build_optimizer(model, cfg.optimizer) - runner = Runner( - model, batch_processor, optimizer, cfg.work_dir, logger=logger) - # an ugly walkaround to make the .log and .log.json filenames the same + + runner = build_runner( + cfg.runner, + default_args=dict( + model=model, + optimizer=optimizer, + work_dir=cfg.work_dir, + logger=logger, + meta=meta)) + + # an ugly workaround to make .log and .log.json filenames the same runner.timestamp = timestamp # fp16 setting fp16_cfg = cfg.get('fp16', None) if fp16_cfg is not None: - optimizer_config = Fp16OptimizerHook(**cfg.optimizer_config, - **fp16_cfg) + optimizer_config = Fp16OptimizerHook( + **cfg.optimizer_config, **fp16_cfg, distributed=distributed) + elif distributed and 'type' not in cfg.optimizer_config: + optimizer_config = OptimizerHook(**cfg.optimizer_config) else: - optimizer_config = DistOptimizerHook(**cfg.optimizer_config) + optimizer_config = cfg.optimizer_config # register hooks - runner.register_training_hooks(cfg.lr_config, optimizer_config, - cfg.checkpoint_config, cfg.log_config) - runner.register_hook(DistSamplerSeedHook()) - # register eval hooks - if validate: - val_dataset_cfg = cfg.data.val - eval_cfg = cfg.get('evaluation', {}) - if isinstance(model.module, RPN): - # TODO: implement recall hooks for other datasets - runner.register_hook( - CocoDistEvalRecallHook(val_dataset_cfg, **eval_cfg)) - else: - dataset_type = DATASETS.get(val_dataset_cfg.type) - if issubclass(dataset_type, datasets.CocoDataset): - runner.register_hook( - CocoDistEvalmAPHook(val_dataset_cfg, **eval_cfg)) - else: - runner.register_hook( - DistEvalmAPHook(val_dataset_cfg, **eval_cfg)) - - if cfg.resume_from: - runner.resume(cfg.resume_from) - elif cfg.load_from: - runner.load_checkpoint(cfg.load_from) - runner.run(data_loaders, cfg.workflow, cfg.total_epochs) + runner.register_training_hooks( + cfg.lr_config, + optimizer_config, + cfg.checkpoint_config, + cfg.log_config, + cfg.get('momentum_config', None), + custom_hooks_config=cfg.get('custom_hooks', None)) + if distributed: + if isinstance(runner, EpochBasedRunner): + runner.register_hook(DistSamplerSeedHook()) -def _non_dist_train(model, - dataset, - cfg, - validate=False, - logger=None, - timestamp=None): + # register eval hooks if validate: - raise NotImplementedError('Built-in validation is not implemented ' - 'yet in not-distributed training. Use ' - 'distributed training or test.py and ' - '*eval.py scripts instead.') - # prepare data loaders - dataset = dataset if isinstance(dataset, (list, tuple)) else [dataset] - data_loaders = [ - build_dataloader( - ds, - cfg.data.imgs_per_gpu, - cfg.data.workers_per_gpu, - cfg.gpus, - dist=False) for ds in dataset - ] - # put model on gpus - model = MMDataParallel(model, device_ids=range(cfg.gpus)).cuda() - - # build runner - optimizer = build_optimizer(model, cfg.optimizer) - runner = Runner( - model, batch_processor, optimizer, cfg.work_dir, logger=logger) - # an ugly walkaround to make the .log and .log.json filenames the same - runner.timestamp = timestamp - # fp16 setting - fp16_cfg = cfg.get('fp16', None) - if fp16_cfg is not None: - optimizer_config = Fp16OptimizerHook( - **cfg.optimizer_config, **fp16_cfg, distributed=False) - else: - optimizer_config = cfg.optimizer_config - runner.register_training_hooks(cfg.lr_config, optimizer_config, - cfg.checkpoint_config, cfg.log_config) + val_dataloader_default_args = dict( + samples_per_gpu=1, + workers_per_gpu=2, + dist=distributed, + shuffle=False, + persistent_workers=False) + + val_dataloader_args = { + **val_dataloader_default_args, + **cfg.data.get('val_dataloader', {}) + } + # Support batch_size > 1 in validation + + if val_dataloader_args['samples_per_gpu'] > 1: + # Replace 'ImageToTensor' to 'DefaultFormatBundle' + cfg.data.val.pipeline = replace_ImageToTensor( + cfg.data.val.pipeline) + val_dataset = build_dataset(cfg.data.val, dict(test_mode=True)) + + val_dataloader = build_dataloader(val_dataset, **val_dataloader_args) + eval_cfg = cfg.get('evaluation', {}) + eval_cfg['by_epoch'] = cfg.runner['type'] != 'IterBasedRunner' + eval_hook = DistEvalHook if distributed else EvalHook + # In this PR (https://github.com/open-mmlab/mmcv/pull/1193), the + # priority of IterTimerHook has been modified from 'NORMAL' to 'LOW'. + runner.register_hook( + eval_hook(val_dataloader, **eval_cfg), priority='LOW') + + resume_from = None + if cfg.resume_from is None and cfg.get('auto_resume'): + resume_from = find_latest_checkpoint(cfg.work_dir) + if resume_from is not None: + cfg.resume_from = resume_from if cfg.resume_from: runner.resume(cfg.resume_from) elif cfg.load_from: runner.load_checkpoint(cfg.load_from) - runner.run(data_loaders, cfg.workflow, cfg.total_epochs) + runner.run(data_loaders, cfg.workflow) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/__init__.py index f8eb6cba5..2a6203879 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/__init__.py @@ -1,7 +1,10 @@ +# Copyright (c) OpenMMLab. All rights reserved. from .anchor import * # noqa: F401, F403 from .bbox import * # noqa: F401, F403 +from .data_structures import * # noqa: F401, F403 from .evaluation import * # noqa: F401, F403 -from .fp16 import * # noqa: F401, F403 +from .hook import * # noqa: F401, F403 from .mask import * # noqa: F401, F403 +from .optimizers import * # noqa: F401, F403 from .post_processing import * # noqa: F401, F403 from .utils import * # noqa: F401, F403 diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/__init__.py index 06e2d1232..fcc7e4af3 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/__init__.py @@ -1,12 +1,14 @@ -from .anchor_generator import AnchorGenerator -from .anchor_target import (anchor_inside_flags, anchor_target, - images_to_levels, unmap) -from .guided_anchor_target import ga_loc_target, ga_shape_target -from .point_generator import PointGenerator -from .point_target import point_target +# Copyright (c) OpenMMLab. All rights reserved. +from .anchor_generator import (AnchorGenerator, LegacyAnchorGenerator, + YOLOAnchorGenerator) +from .builder import (ANCHOR_GENERATORS, PRIOR_GENERATORS, + build_anchor_generator, build_prior_generator) +from .point_generator import MlvlPointGenerator, PointGenerator +from .utils import anchor_inside_flags, calc_region, images_to_levels __all__ = [ - 'AnchorGenerator', 'anchor_target', 'anchor_inside_flags', 'ga_loc_target', - 'ga_shape_target', 'PointGenerator', 'point_target', 'images_to_levels', - 'unmap' + 'AnchorGenerator', 'LegacyAnchorGenerator', 'anchor_inside_flags', + 'PointGenerator', 'images_to_levels', 'calc_region', + 'build_anchor_generator', 'ANCHOR_GENERATORS', 'YOLOAnchorGenerator', + 'build_prior_generator', 'PRIOR_GENERATORS', 'MlvlPointGenerator' ] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/anchor_generator.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/anchor_generator.py index cd227ad06..20886fbda 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/anchor_generator.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/anchor_generator.py @@ -1,74 +1,381 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import warnings + +import mmcv +import numpy as np import torch +from torch.nn.modules.utils import _pair +from .builder import PRIOR_GENERATORS + + +@PRIOR_GENERATORS.register_module() +class AnchorGenerator: + """Standard anchor generator for 2D anchor-based detectors. + + Args: + strides (list[int] | list[tuple[int, int]]): Strides of anchors + in multiple feature levels in order (w, h). + ratios (list[float]): The list of ratios between the height and width + of anchors in a single level. + scales (list[int] | None): Anchor scales for anchors in a single level. + It cannot be set at the same time if `octave_base_scale` and + `scales_per_octave` are set. + base_sizes (list[int] | None): The basic sizes + of anchors in multiple levels. + If None is given, strides will be used as base_sizes. + (If strides are non square, the shortest stride is taken.) + scale_major (bool): Whether to multiply scales first when generating + base anchors. If true, the anchors in the same row will have the + same scales. By default it is True in V2.0 + octave_base_scale (int): The base scale of octave. + scales_per_octave (int): Number of scales for each octave. + `octave_base_scale` and `scales_per_octave` are usually used in + retinanet and the `scales` should be None when they are set. + centers (list[tuple[float, float]] | None): The centers of the anchor + relative to the feature grid center in multiple feature levels. + By default it is set to be None and not used. If a list of tuple of + float is given, they will be used to shift the centers of anchors. + center_offset (float): The offset of center in proportion to anchors' + width and height. By default it is 0 in V2.0. -class AnchorGenerator(object): - """ Examples: >>> from mmdet.core import AnchorGenerator - >>> self = AnchorGenerator(9, [1.], [1.]) - >>> all_anchors = self.grid_anchors((2, 2), device='cpu') + >>> self = AnchorGenerator([16], [1.], [1.], [9]) + >>> all_anchors = self.grid_priors([(2, 2)], device='cpu') >>> print(all_anchors) - tensor([[ 0., 0., 8., 8.], - [16., 0., 24., 8.], - [ 0., 16., 8., 24.], - [16., 16., 24., 24.]]) + [tensor([[-4.5000, -4.5000, 4.5000, 4.5000], + [11.5000, -4.5000, 20.5000, 4.5000], + [-4.5000, 11.5000, 4.5000, 20.5000], + [11.5000, 11.5000, 20.5000, 20.5000]])] + >>> self = AnchorGenerator([16, 32], [1.], [1.], [9, 18]) + >>> all_anchors = self.grid_priors([(2, 2), (1, 1)], device='cpu') + >>> print(all_anchors) + [tensor([[-4.5000, -4.5000, 4.5000, 4.5000], + [11.5000, -4.5000, 20.5000, 4.5000], + [-4.5000, 11.5000, 4.5000, 20.5000], + [11.5000, 11.5000, 20.5000, 20.5000]]), \ + tensor([[-9., -9., 9., 9.]])] """ - def __init__(self, base_size, scales, ratios, scale_major=True, ctr=None): - self.base_size = base_size - self.scales = torch.Tensor(scales) + def __init__(self, + strides, + ratios, + scales=None, + base_sizes=None, + scale_major=True, + octave_base_scale=None, + scales_per_octave=None, + centers=None, + center_offset=0.): + # check center and center_offset + if center_offset != 0: + assert centers is None, 'center cannot be set when center_offset' \ + f'!=0, {centers} is given.' + if not (0 <= center_offset <= 1): + raise ValueError('center_offset should be in range [0, 1], ' + f'{center_offset} is given.') + if centers is not None: + assert len(centers) == len(strides), \ + 'The number of strides should be the same as centers, got ' \ + f'{strides} and {centers}' + + # calculate base sizes of anchors + self.strides = [_pair(stride) for stride in strides] + self.base_sizes = [min(stride) for stride in self.strides + ] if base_sizes is None else base_sizes + assert len(self.base_sizes) == len(self.strides), \ + 'The number of strides should be the same as base sizes, got ' \ + f'{self.strides} and {self.base_sizes}' + + # calculate scales of anchors + assert ((octave_base_scale is not None + and scales_per_octave is not None) ^ (scales is not None)), \ + 'scales and octave_base_scale with scales_per_octave cannot' \ + ' be set at the same time' + if scales is not None: + self.scales = torch.Tensor(scales) + elif octave_base_scale is not None and scales_per_octave is not None: + octave_scales = np.array( + [2**(i / scales_per_octave) for i in range(scales_per_octave)]) + scales = octave_scales * octave_base_scale + self.scales = torch.Tensor(scales) + else: + raise ValueError('Either scales or octave_base_scale with ' + 'scales_per_octave should be set') + + self.octave_base_scale = octave_base_scale + self.scales_per_octave = scales_per_octave self.ratios = torch.Tensor(ratios) self.scale_major = scale_major - self.ctr = ctr + self.centers = centers + self.center_offset = center_offset self.base_anchors = self.gen_base_anchors() @property def num_base_anchors(self): - return self.base_anchors.size(0) + """list[int]: total number of base anchors in a feature grid""" + return self.num_base_priors + + @property + def num_base_priors(self): + """list[int]: The number of priors (anchors) at a point + on the feature grid""" + return [base_anchors.size(0) for base_anchors in self.base_anchors] + + @property + def num_levels(self): + """int: number of feature levels that the generator will be applied""" + return len(self.strides) def gen_base_anchors(self): - w = self.base_size - h = self.base_size - if self.ctr is None: - x_ctr = 0.5 * (w - 1) - y_ctr = 0.5 * (h - 1) + """Generate base anchors. + + Returns: + list(torch.Tensor): Base anchors of a feature grid in multiple \ + feature levels. + """ + multi_level_base_anchors = [] + for i, base_size in enumerate(self.base_sizes): + center = None + if self.centers is not None: + center = self.centers[i] + multi_level_base_anchors.append( + self.gen_single_level_base_anchors( + base_size, + scales=self.scales, + ratios=self.ratios, + center=center)) + return multi_level_base_anchors + + def gen_single_level_base_anchors(self, + base_size, + scales, + ratios, + center=None): + """Generate base anchors of a single level. + + Args: + base_size (int | float): Basic size of an anchor. + scales (torch.Tensor): Scales of the anchor. + ratios (torch.Tensor): The ratio between between the height + and width of anchors in a single level. + center (tuple[float], optional): The center of the base anchor + related to a single feature grid. Defaults to None. + + Returns: + torch.Tensor: Anchors in a single-level feature maps. + """ + w = base_size + h = base_size + if center is None: + x_center = self.center_offset * w + y_center = self.center_offset * h else: - x_ctr, y_ctr = self.ctr + x_center, y_center = center - h_ratios = torch.sqrt(self.ratios) + h_ratios = torch.sqrt(ratios) w_ratios = 1 / h_ratios if self.scale_major: - ws = (w * w_ratios[:, None] * self.scales[None, :]).view(-1) - hs = (h * h_ratios[:, None] * self.scales[None, :]).view(-1) + ws = (w * w_ratios[:, None] * scales[None, :]).view(-1) + hs = (h * h_ratios[:, None] * scales[None, :]).view(-1) else: - ws = (w * self.scales[:, None] * w_ratios[None, :]).view(-1) - hs = (h * self.scales[:, None] * h_ratios[None, :]).view(-1) - - # yapf: disable - base_anchors = torch.stack( - [ - x_ctr - 0.5 * (ws - 1), y_ctr - 0.5 * (hs - 1), - x_ctr + 0.5 * (ws - 1), y_ctr + 0.5 * (hs - 1) - ], - dim=-1).round() - # yapf: enable + ws = (w * scales[:, None] * w_ratios[None, :]).view(-1) + hs = (h * scales[:, None] * h_ratios[None, :]).view(-1) + + # use float anchor and the anchor's center is aligned with the + # pixel center + base_anchors = [ + x_center - 0.5 * ws, y_center - 0.5 * hs, x_center + 0.5 * ws, + y_center + 0.5 * hs + ] + base_anchors = torch.stack(base_anchors, dim=-1) return base_anchors def _meshgrid(self, x, y, row_major=True): - xx = x.repeat(len(y)) - yy = y.view(-1, 1).repeat(1, len(x)).view(-1) + """Generate mesh grid of x and y. + + Args: + x (torch.Tensor): Grids of x dimension. + y (torch.Tensor): Grids of y dimension. + row_major (bool, optional): Whether to return y grids first. + Defaults to True. + + Returns: + tuple[torch.Tensor]: The mesh grids of x and y. + """ + # use shape instead of len to keep tracing while exporting to onnx + xx = x.repeat(y.shape[0]) + yy = y.view(-1, 1).repeat(1, x.shape[0]).view(-1) if row_major: return xx, yy else: return yy, xx - def grid_anchors(self, featmap_size, stride=16, device='cuda'): - base_anchors = self.base_anchors.to(device) + def grid_priors(self, featmap_sizes, dtype=torch.float32, device='cuda'): + """Generate grid anchors in multiple feature levels. + + Args: + featmap_sizes (list[tuple]): List of feature map sizes in + multiple feature levels. + dtype (:obj:`torch.dtype`): Dtype of priors. + Default: torch.float32. + device (str): The device where the anchors will be put on. + + Return: + list[torch.Tensor]: Anchors in multiple feature levels. \ + The sizes of each tensor should be [N, 4], where \ + N = width * height * num_base_anchors, width and height \ + are the sizes of the corresponding feature level, \ + num_base_anchors is the number of anchors for that level. + """ + assert self.num_levels == len(featmap_sizes) + multi_level_anchors = [] + for i in range(self.num_levels): + anchors = self.single_level_grid_priors( + featmap_sizes[i], level_idx=i, dtype=dtype, device=device) + multi_level_anchors.append(anchors) + return multi_level_anchors + + def single_level_grid_priors(self, + featmap_size, + level_idx, + dtype=torch.float32, + device='cuda'): + """Generate grid anchors of a single level. + Note: + This function is usually called by method ``self.grid_priors``. + + Args: + featmap_size (tuple[int]): Size of the feature maps. + level_idx (int): The index of corresponding feature map level. + dtype (obj:`torch.dtype`): Date type of points.Defaults to + ``torch.float32``. + device (str, optional): The device the tensor will be put on. + Defaults to 'cuda'. + + Returns: + torch.Tensor: Anchors in the overall feature maps. + """ + + base_anchors = self.base_anchors[level_idx].to(device).to(dtype) feat_h, feat_w = featmap_size - shift_x = torch.arange(0, feat_w, device=device) * stride - shift_y = torch.arange(0, feat_h, device=device) * stride + stride_w, stride_h = self.strides[level_idx] + # First create Range with the default dtype, than convert to + # target `dtype` for onnx exporting. + shift_x = torch.arange(0, feat_w, device=device).to(dtype) * stride_w + shift_y = torch.arange(0, feat_h, device=device).to(dtype) * stride_h + + shift_xx, shift_yy = self._meshgrid(shift_x, shift_y) + shifts = torch.stack([shift_xx, shift_yy, shift_xx, shift_yy], dim=-1) + # first feat_w elements correspond to the first row of shifts + # add A anchors (1, A, 4) to K shifts (K, 1, 4) to get + # shifted anchors (K, A, 4), reshape to (K*A, 4) + + all_anchors = base_anchors[None, :, :] + shifts[:, None, :] + all_anchors = all_anchors.view(-1, 4) + # first A rows correspond to A anchors of (0, 0) in feature map, + # then (0, 1), (0, 2), ... + return all_anchors + + def sparse_priors(self, + prior_idxs, + featmap_size, + level_idx, + dtype=torch.float32, + device='cuda'): + """Generate sparse anchors according to the ``prior_idxs``. + + Args: + prior_idxs (Tensor): The index of corresponding anchors + in the feature map. + featmap_size (tuple[int]): feature map size arrange as (h, w). + level_idx (int): The level index of corresponding feature + map. + dtype (obj:`torch.dtype`): Date type of points.Defaults to + ``torch.float32``. + device (obj:`torch.device`): The device where the points is + located. + Returns: + Tensor: Anchor with shape (N, 4), N should be equal to + the length of ``prior_idxs``. + """ + + height, width = featmap_size + num_base_anchors = self.num_base_anchors[level_idx] + base_anchor_id = prior_idxs % num_base_anchors + x = (prior_idxs // + num_base_anchors) % width * self.strides[level_idx][0] + y = (prior_idxs // width // + num_base_anchors) % height * self.strides[level_idx][1] + priors = torch.stack([x, y, x, y], 1).to(dtype).to(device) + \ + self.base_anchors[level_idx][base_anchor_id, :].to(device) + + return priors + + def grid_anchors(self, featmap_sizes, device='cuda'): + """Generate grid anchors in multiple feature levels. + + Args: + featmap_sizes (list[tuple]): List of feature map sizes in + multiple feature levels. + device (str): Device where the anchors will be put on. + + Return: + list[torch.Tensor]: Anchors in multiple feature levels. \ + The sizes of each tensor should be [N, 4], where \ + N = width * height * num_base_anchors, width and height \ + are the sizes of the corresponding feature level, \ + num_base_anchors is the number of anchors for that level. + """ + warnings.warn('``grid_anchors`` would be deprecated soon. ' + 'Please use ``grid_priors`` ') + + assert self.num_levels == len(featmap_sizes) + multi_level_anchors = [] + for i in range(self.num_levels): + anchors = self.single_level_grid_anchors( + self.base_anchors[i].to(device), + featmap_sizes[i], + self.strides[i], + device=device) + multi_level_anchors.append(anchors) + return multi_level_anchors + + def single_level_grid_anchors(self, + base_anchors, + featmap_size, + stride=(16, 16), + device='cuda'): + """Generate grid anchors of a single level. + + Note: + This function is usually called by method ``self.grid_anchors``. + + Args: + base_anchors (torch.Tensor): The base anchors of a feature grid. + featmap_size (tuple[int]): Size of the feature maps. + stride (tuple[int], optional): Stride of the feature map in order + (w, h). Defaults to (16, 16). + device (str, optional): Device the tensor will be put on. + Defaults to 'cuda'. + + Returns: + torch.Tensor: Anchors in the overall feature maps. + """ + + warnings.warn( + '``single_level_grid_anchors`` would be deprecated soon. ' + 'Please use ``single_level_grid_priors`` ') + + # keep featmap_size as Tensor instead of int, so that we + # can convert to ONNX correctly + feat_h, feat_w = featmap_size + shift_x = torch.arange(0, feat_w, device=device) * stride[0] + shift_y = torch.arange(0, feat_h, device=device) * stride[1] + shift_xx, shift_yy = self._meshgrid(shift_x, shift_y) shifts = torch.stack([shift_xx, shift_yy, shift_xx, shift_yy], dim=-1) shifts = shifts.type_as(base_anchors) @@ -82,17 +389,478 @@ class AnchorGenerator(object): # then (0, 1), (0, 2), ... return all_anchors - def valid_flags(self, featmap_size, valid_size, device='cuda'): + def valid_flags(self, featmap_sizes, pad_shape, device='cuda'): + """Generate valid flags of anchors in multiple feature levels. + + Args: + featmap_sizes (list(tuple)): List of feature map sizes in + multiple feature levels. + pad_shape (tuple): The padded shape of the image. + device (str): Device where the anchors will be put on. + + Return: + list(torch.Tensor): Valid flags of anchors in multiple levels. + """ + assert self.num_levels == len(featmap_sizes) + multi_level_flags = [] + for i in range(self.num_levels): + anchor_stride = self.strides[i] + feat_h, feat_w = featmap_sizes[i] + h, w = pad_shape[:2] + valid_feat_h = min(int(np.ceil(h / anchor_stride[1])), feat_h) + valid_feat_w = min(int(np.ceil(w / anchor_stride[0])), feat_w) + flags = self.single_level_valid_flags((feat_h, feat_w), + (valid_feat_h, valid_feat_w), + self.num_base_anchors[i], + device=device) + multi_level_flags.append(flags) + return multi_level_flags + + def single_level_valid_flags(self, + featmap_size, + valid_size, + num_base_anchors, + device='cuda'): + """Generate the valid flags of anchor in a single feature map. + + Args: + featmap_size (tuple[int]): The size of feature maps, arrange + as (h, w). + valid_size (tuple[int]): The valid size of the feature maps. + num_base_anchors (int): The number of base anchors. + device (str, optional): Device where the flags will be put on. + Defaults to 'cuda'. + + Returns: + torch.Tensor: The valid flags of each anchor in a single level \ + feature map. + """ feat_h, feat_w = featmap_size valid_h, valid_w = valid_size assert valid_h <= feat_h and valid_w <= feat_w - valid_x = torch.zeros(feat_w, dtype=torch.uint8, device=device) - valid_y = torch.zeros(feat_h, dtype=torch.uint8, device=device) + valid_x = torch.zeros(feat_w, dtype=torch.bool, device=device) + valid_y = torch.zeros(feat_h, dtype=torch.bool, device=device) valid_x[:valid_w] = 1 valid_y[:valid_h] = 1 valid_xx, valid_yy = self._meshgrid(valid_x, valid_y) valid = valid_xx & valid_yy - valid = valid[:, - None].expand(valid.size(0), - self.num_base_anchors).contiguous().view(-1) + valid = valid[:, None].expand(valid.size(0), + num_base_anchors).contiguous().view(-1) return valid + + def __repr__(self): + """str: a string that describes the module""" + indent_str = ' ' + repr_str = self.__class__.__name__ + '(\n' + repr_str += f'{indent_str}strides={self.strides},\n' + repr_str += f'{indent_str}ratios={self.ratios},\n' + repr_str += f'{indent_str}scales={self.scales},\n' + repr_str += f'{indent_str}base_sizes={self.base_sizes},\n' + repr_str += f'{indent_str}scale_major={self.scale_major},\n' + repr_str += f'{indent_str}octave_base_scale=' + repr_str += f'{self.octave_base_scale},\n' + repr_str += f'{indent_str}scales_per_octave=' + repr_str += f'{self.scales_per_octave},\n' + repr_str += f'{indent_str}num_levels={self.num_levels}\n' + repr_str += f'{indent_str}centers={self.centers},\n' + repr_str += f'{indent_str}center_offset={self.center_offset})' + return repr_str + + +@PRIOR_GENERATORS.register_module() +class SSDAnchorGenerator(AnchorGenerator): + """Anchor generator for SSD. + + Args: + strides (list[int] | list[tuple[int, int]]): Strides of anchors + in multiple feature levels. + ratios (list[float]): The list of ratios between the height and width + of anchors in a single level. + min_sizes (list[float]): The list of minimum anchor sizes on each + level. + max_sizes (list[float]): The list of maximum anchor sizes on each + level. + basesize_ratio_range (tuple(float)): Ratio range of anchors. Being + used when not setting min_sizes and max_sizes. + input_size (int): Size of feature map, 300 for SSD300, 512 for + SSD512. Being used when not setting min_sizes and max_sizes. + scale_major (bool): Whether to multiply scales first when generating + base anchors. If true, the anchors in the same row will have the + same scales. It is always set to be False in SSD. + """ + + def __init__(self, + strides, + ratios, + min_sizes=None, + max_sizes=None, + basesize_ratio_range=(0.15, 0.9), + input_size=300, + scale_major=True): + assert len(strides) == len(ratios) + assert not (min_sizes is None) ^ (max_sizes is None) + self.strides = [_pair(stride) for stride in strides] + self.centers = [(stride[0] / 2., stride[1] / 2.) + for stride in self.strides] + + if min_sizes is None and max_sizes is None: + # use hard code to generate SSD anchors + self.input_size = input_size + assert mmcv.is_tuple_of(basesize_ratio_range, float) + self.basesize_ratio_range = basesize_ratio_range + # calculate anchor ratios and sizes + min_ratio, max_ratio = basesize_ratio_range + min_ratio = int(min_ratio * 100) + max_ratio = int(max_ratio * 100) + step = int(np.floor(max_ratio - min_ratio) / (self.num_levels - 2)) + min_sizes = [] + max_sizes = [] + for ratio in range(int(min_ratio), int(max_ratio) + 1, step): + min_sizes.append(int(self.input_size * ratio / 100)) + max_sizes.append(int(self.input_size * (ratio + step) / 100)) + if self.input_size == 300: + if basesize_ratio_range[0] == 0.15: # SSD300 COCO + min_sizes.insert(0, int(self.input_size * 7 / 100)) + max_sizes.insert(0, int(self.input_size * 15 / 100)) + elif basesize_ratio_range[0] == 0.2: # SSD300 VOC + min_sizes.insert(0, int(self.input_size * 10 / 100)) + max_sizes.insert(0, int(self.input_size * 20 / 100)) + else: + raise ValueError( + 'basesize_ratio_range[0] should be either 0.15' + 'or 0.2 when input_size is 300, got ' + f'{basesize_ratio_range[0]}.') + elif self.input_size == 512: + if basesize_ratio_range[0] == 0.1: # SSD512 COCO + min_sizes.insert(0, int(self.input_size * 4 / 100)) + max_sizes.insert(0, int(self.input_size * 10 / 100)) + elif basesize_ratio_range[0] == 0.15: # SSD512 VOC + min_sizes.insert(0, int(self.input_size * 7 / 100)) + max_sizes.insert(0, int(self.input_size * 15 / 100)) + else: + raise ValueError( + 'When not setting min_sizes and max_sizes,' + 'basesize_ratio_range[0] should be either 0.1' + 'or 0.15 when input_size is 512, got' + f' {basesize_ratio_range[0]}.') + else: + raise ValueError( + 'Only support 300 or 512 in SSDAnchorGenerator when ' + 'not setting min_sizes and max_sizes, ' + f'got {self.input_size}.') + + assert len(min_sizes) == len(max_sizes) == len(strides) + + anchor_ratios = [] + anchor_scales = [] + for k in range(len(self.strides)): + scales = [1., np.sqrt(max_sizes[k] / min_sizes[k])] + anchor_ratio = [1.] + for r in ratios[k]: + anchor_ratio += [1 / r, r] # 4 or 6 ratio + anchor_ratios.append(torch.Tensor(anchor_ratio)) + anchor_scales.append(torch.Tensor(scales)) + + self.base_sizes = min_sizes + self.scales = anchor_scales + self.ratios = anchor_ratios + self.scale_major = scale_major + self.center_offset = 0 + self.base_anchors = self.gen_base_anchors() + + def gen_base_anchors(self): + """Generate base anchors. + + Returns: + list(torch.Tensor): Base anchors of a feature grid in multiple \ + feature levels. + """ + multi_level_base_anchors = [] + for i, base_size in enumerate(self.base_sizes): + base_anchors = self.gen_single_level_base_anchors( + base_size, + scales=self.scales[i], + ratios=self.ratios[i], + center=self.centers[i]) + indices = list(range(len(self.ratios[i]))) + indices.insert(1, len(indices)) + base_anchors = torch.index_select(base_anchors, 0, + torch.LongTensor(indices)) + multi_level_base_anchors.append(base_anchors) + return multi_level_base_anchors + + def __repr__(self): + """str: a string that describes the module""" + indent_str = ' ' + repr_str = self.__class__.__name__ + '(\n' + repr_str += f'{indent_str}strides={self.strides},\n' + repr_str += f'{indent_str}scales={self.scales},\n' + repr_str += f'{indent_str}scale_major={self.scale_major},\n' + repr_str += f'{indent_str}input_size={self.input_size},\n' + repr_str += f'{indent_str}scales={self.scales},\n' + repr_str += f'{indent_str}ratios={self.ratios},\n' + repr_str += f'{indent_str}num_levels={self.num_levels},\n' + repr_str += f'{indent_str}base_sizes={self.base_sizes},\n' + repr_str += f'{indent_str}basesize_ratio_range=' + repr_str += f'{self.basesize_ratio_range})' + return repr_str + + +@PRIOR_GENERATORS.register_module() +class LegacyAnchorGenerator(AnchorGenerator): + """Legacy anchor generator used in MMDetection V1.x. + + Note: + Difference to the V2.0 anchor generator: + + 1. The center offset of V1.x anchors are set to be 0.5 rather than 0. + 2. The width/height are minused by 1 when calculating the anchors' \ + centers and corners to meet the V1.x coordinate system. + 3. The anchors' corners are quantized. + + Args: + strides (list[int] | list[tuple[int]]): Strides of anchors + in multiple feature levels. + ratios (list[float]): The list of ratios between the height and width + of anchors in a single level. + scales (list[int] | None): Anchor scales for anchors in a single level. + It cannot be set at the same time if `octave_base_scale` and + `scales_per_octave` are set. + base_sizes (list[int]): The basic sizes of anchors in multiple levels. + If None is given, strides will be used to generate base_sizes. + scale_major (bool): Whether to multiply scales first when generating + base anchors. If true, the anchors in the same row will have the + same scales. By default it is True in V2.0 + octave_base_scale (int): The base scale of octave. + scales_per_octave (int): Number of scales for each octave. + `octave_base_scale` and `scales_per_octave` are usually used in + retinanet and the `scales` should be None when they are set. + centers (list[tuple[float, float]] | None): The centers of the anchor + relative to the feature grid center in multiple feature levels. + By default it is set to be None and not used. It a list of float + is given, this list will be used to shift the centers of anchors. + center_offset (float): The offset of center in proportion to anchors' + width and height. By default it is 0.5 in V2.0 but it should be 0.5 + in v1.x models. + + Examples: + >>> from mmdet.core import LegacyAnchorGenerator + >>> self = LegacyAnchorGenerator( + >>> [16], [1.], [1.], [9], center_offset=0.5) + >>> all_anchors = self.grid_anchors(((2, 2),), device='cpu') + >>> print(all_anchors) + [tensor([[ 0., 0., 8., 8.], + [16., 0., 24., 8.], + [ 0., 16., 8., 24.], + [16., 16., 24., 24.]])] + """ + + def gen_single_level_base_anchors(self, + base_size, + scales, + ratios, + center=None): + """Generate base anchors of a single level. + + Note: + The width/height of anchors are minused by 1 when calculating \ + the centers and corners to meet the V1.x coordinate system. + + Args: + base_size (int | float): Basic size of an anchor. + scales (torch.Tensor): Scales of the anchor. + ratios (torch.Tensor): The ratio between between the height. + and width of anchors in a single level. + center (tuple[float], optional): The center of the base anchor + related to a single feature grid. Defaults to None. + + Returns: + torch.Tensor: Anchors in a single-level feature map. + """ + w = base_size + h = base_size + if center is None: + x_center = self.center_offset * (w - 1) + y_center = self.center_offset * (h - 1) + else: + x_center, y_center = center + + h_ratios = torch.sqrt(ratios) + w_ratios = 1 / h_ratios + if self.scale_major: + ws = (w * w_ratios[:, None] * scales[None, :]).view(-1) + hs = (h * h_ratios[:, None] * scales[None, :]).view(-1) + else: + ws = (w * scales[:, None] * w_ratios[None, :]).view(-1) + hs = (h * scales[:, None] * h_ratios[None, :]).view(-1) + + # use float anchor and the anchor's center is aligned with the + # pixel center + base_anchors = [ + x_center - 0.5 * (ws - 1), y_center - 0.5 * (hs - 1), + x_center + 0.5 * (ws - 1), y_center + 0.5 * (hs - 1) + ] + base_anchors = torch.stack(base_anchors, dim=-1).round() + + return base_anchors + + +@PRIOR_GENERATORS.register_module() +class LegacySSDAnchorGenerator(SSDAnchorGenerator, LegacyAnchorGenerator): + """Legacy anchor generator used in MMDetection V1.x. + + The difference between `LegacySSDAnchorGenerator` and `SSDAnchorGenerator` + can be found in `LegacyAnchorGenerator`. + """ + + def __init__(self, + strides, + ratios, + basesize_ratio_range, + input_size=300, + scale_major=True): + super(LegacySSDAnchorGenerator, self).__init__( + strides=strides, + ratios=ratios, + basesize_ratio_range=basesize_ratio_range, + input_size=input_size, + scale_major=scale_major) + self.centers = [((stride - 1) / 2., (stride - 1) / 2.) + for stride in strides] + self.base_anchors = self.gen_base_anchors() + + +@PRIOR_GENERATORS.register_module() +class YOLOAnchorGenerator(AnchorGenerator): + """Anchor generator for YOLO. + + Args: + strides (list[int] | list[tuple[int, int]]): Strides of anchors + in multiple feature levels. + base_sizes (list[list[tuple[int, int]]]): The basic sizes + of anchors in multiple levels. + """ + + def __init__(self, strides, base_sizes): + self.strides = [_pair(stride) for stride in strides] + self.centers = [(stride[0] / 2., stride[1] / 2.) + for stride in self.strides] + self.base_sizes = [] + num_anchor_per_level = len(base_sizes[0]) + for base_sizes_per_level in base_sizes: + assert num_anchor_per_level == len(base_sizes_per_level) + self.base_sizes.append( + [_pair(base_size) for base_size in base_sizes_per_level]) + self.base_anchors = self.gen_base_anchors() + + @property + def num_levels(self): + """int: number of feature levels that the generator will be applied""" + return len(self.base_sizes) + + def gen_base_anchors(self): + """Generate base anchors. + + Returns: + list(torch.Tensor): Base anchors of a feature grid in multiple \ + feature levels. + """ + multi_level_base_anchors = [] + for i, base_sizes_per_level in enumerate(self.base_sizes): + center = None + if self.centers is not None: + center = self.centers[i] + multi_level_base_anchors.append( + self.gen_single_level_base_anchors(base_sizes_per_level, + center)) + return multi_level_base_anchors + + def gen_single_level_base_anchors(self, base_sizes_per_level, center=None): + """Generate base anchors of a single level. + + Args: + base_sizes_per_level (list[tuple[int, int]]): Basic sizes of + anchors. + center (tuple[float], optional): The center of the base anchor + related to a single feature grid. Defaults to None. + + Returns: + torch.Tensor: Anchors in a single-level feature maps. + """ + x_center, y_center = center + base_anchors = [] + for base_size in base_sizes_per_level: + w, h = base_size + + # use float anchor and the anchor's center is aligned with the + # pixel center + base_anchor = torch.Tensor([ + x_center - 0.5 * w, y_center - 0.5 * h, x_center + 0.5 * w, + y_center + 0.5 * h + ]) + base_anchors.append(base_anchor) + base_anchors = torch.stack(base_anchors, dim=0) + + return base_anchors + + def responsible_flags(self, featmap_sizes, gt_bboxes, device='cuda'): + """Generate responsible anchor flags of grid cells in multiple scales. + + Args: + featmap_sizes (list(tuple)): List of feature map sizes in multiple + feature levels. + gt_bboxes (Tensor): Ground truth boxes, shape (n, 4). + device (str): Device where the anchors will be put on. + + Return: + list(torch.Tensor): responsible flags of anchors in multiple level + """ + assert self.num_levels == len(featmap_sizes) + multi_level_responsible_flags = [] + for i in range(self.num_levels): + anchor_stride = self.strides[i] + flags = self.single_level_responsible_flags( + featmap_sizes[i], + gt_bboxes, + anchor_stride, + self.num_base_anchors[i], + device=device) + multi_level_responsible_flags.append(flags) + return multi_level_responsible_flags + + def single_level_responsible_flags(self, + featmap_size, + gt_bboxes, + stride, + num_base_anchors, + device='cuda'): + """Generate the responsible flags of anchor in a single feature map. + + Args: + featmap_size (tuple[int]): The size of feature maps. + gt_bboxes (Tensor): Ground truth boxes, shape (n, 4). + stride (tuple(int)): stride of current level + num_base_anchors (int): The number of base anchors. + device (str, optional): Device where the flags will be put on. + Defaults to 'cuda'. + + Returns: + torch.Tensor: The valid flags of each anchor in a single level \ + feature map. + """ + feat_h, feat_w = featmap_size + gt_bboxes_cx = ((gt_bboxes[:, 0] + gt_bboxes[:, 2]) * 0.5).to(device) + gt_bboxes_cy = ((gt_bboxes[:, 1] + gt_bboxes[:, 3]) * 0.5).to(device) + gt_bboxes_grid_x = torch.floor(gt_bboxes_cx / stride[0]).long() + gt_bboxes_grid_y = torch.floor(gt_bboxes_cy / stride[1]).long() + + # row major indexing + gt_bboxes_grid_idx = gt_bboxes_grid_y * feat_w + gt_bboxes_grid_x + + responsible_grid = torch.zeros( + feat_h * feat_w, dtype=torch.uint8, device=device) + responsible_grid[gt_bboxes_grid_idx] = 1 + + responsible_grid = responsible_grid[:, None].expand( + responsible_grid.size(0), num_base_anchors).contiguous().view(-1) + return responsible_grid diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/anchor_target.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/anchor_target.py deleted file mode 100644 index daf43c45e..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/anchor_target.py +++ /dev/null @@ -1,188 +0,0 @@ -import torch - -from ..bbox import PseudoSampler, assign_and_sample, bbox2delta, build_assigner -from ..utils import multi_apply - - -def anchor_target(anchor_list, - valid_flag_list, - gt_bboxes_list, - img_metas, - target_means, - target_stds, - cfg, - gt_bboxes_ignore_list=None, - gt_labels_list=None, - label_channels=1, - sampling=True, - unmap_outputs=True): - """Compute regression and classification targets for anchors. - - Args: - anchor_list (list[list]): Multi level anchors of each image. - valid_flag_list (list[list]): Multi level valid flags of each image. - gt_bboxes_list (list[Tensor]): Ground truth bboxes of each image. - img_metas (list[dict]): Meta info of each image. - target_means (Iterable): Mean value of regression targets. - target_stds (Iterable): Std value of regression targets. - cfg (dict): RPN train configs. - - Returns: - tuple - """ - num_imgs = len(img_metas) - assert len(anchor_list) == len(valid_flag_list) == num_imgs - - # anchor number of multi levels - num_level_anchors = [anchors.size(0) for anchors in anchor_list[0]] - # concat all level anchors and flags to a single tensor - for i in range(num_imgs): - assert len(anchor_list[i]) == len(valid_flag_list[i]) - anchor_list[i] = torch.cat(anchor_list[i]) - valid_flag_list[i] = torch.cat(valid_flag_list[i]) - - # compute targets for each image - if gt_bboxes_ignore_list is None: - gt_bboxes_ignore_list = [None for _ in range(num_imgs)] - if gt_labels_list is None: - gt_labels_list = [None for _ in range(num_imgs)] - (all_labels, all_label_weights, all_bbox_targets, all_bbox_weights, - pos_inds_list, neg_inds_list) = multi_apply( - anchor_target_single, - anchor_list, - valid_flag_list, - gt_bboxes_list, - gt_bboxes_ignore_list, - gt_labels_list, - img_metas, - target_means=target_means, - target_stds=target_stds, - cfg=cfg, - label_channels=label_channels, - sampling=sampling, - unmap_outputs=unmap_outputs) - # no valid anchors - if any([labels is None for labels in all_labels]): - return None - # sampled anchors of all images - num_total_pos = sum([max(inds.numel(), 1) for inds in pos_inds_list]) - num_total_neg = sum([max(inds.numel(), 1) for inds in neg_inds_list]) - # split targets to a list w.r.t. multiple levels - labels_list = images_to_levels(all_labels, num_level_anchors) - label_weights_list = images_to_levels(all_label_weights, num_level_anchors) - bbox_targets_list = images_to_levels(all_bbox_targets, num_level_anchors) - bbox_weights_list = images_to_levels(all_bbox_weights, num_level_anchors) - return (labels_list, label_weights_list, bbox_targets_list, - bbox_weights_list, num_total_pos, num_total_neg) - - -def images_to_levels(target, num_level_anchors): - """Convert targets by image to targets by feature level. - - [target_img0, target_img1] -> [target_level0, target_level1, ...] - """ - target = torch.stack(target, 0) - level_targets = [] - start = 0 - for n in num_level_anchors: - end = start + n - level_targets.append(target[:, start:end].squeeze(0)) - start = end - return level_targets - - -def anchor_target_single(flat_anchors, - valid_flags, - gt_bboxes, - gt_bboxes_ignore, - gt_labels, - img_meta, - target_means, - target_stds, - cfg, - label_channels=1, - sampling=True, - unmap_outputs=True): - inside_flags = anchor_inside_flags(flat_anchors, valid_flags, - img_meta['img_shape'][:2], - cfg.allowed_border) - if not inside_flags.any(): - return (None, ) * 6 - # assign gt and sample anchors - anchors = flat_anchors[inside_flags, :] - - if sampling: - assign_result, sampling_result = assign_and_sample( - anchors, gt_bboxes, gt_bboxes_ignore, None, cfg) - else: - bbox_assigner = build_assigner(cfg.assigner) - assign_result = bbox_assigner.assign(anchors, gt_bboxes, - gt_bboxes_ignore, gt_labels) - bbox_sampler = PseudoSampler() - sampling_result = bbox_sampler.sample(assign_result, anchors, - gt_bboxes) - - num_valid_anchors = anchors.shape[0] - bbox_targets = torch.zeros_like(anchors) - bbox_weights = torch.zeros_like(anchors) - labels = anchors.new_zeros(num_valid_anchors, dtype=torch.long) - label_weights = anchors.new_zeros(num_valid_anchors, dtype=torch.float) - - pos_inds = sampling_result.pos_inds - neg_inds = sampling_result.neg_inds - if len(pos_inds) > 0: - pos_bbox_targets = bbox2delta(sampling_result.pos_bboxes, - sampling_result.pos_gt_bboxes, - target_means, target_stds) - bbox_targets[pos_inds, :] = pos_bbox_targets - bbox_weights[pos_inds, :] = 1.0 - if gt_labels is None: - labels[pos_inds] = 1 - else: - labels[pos_inds] = gt_labels[sampling_result.pos_assigned_gt_inds] - if cfg.pos_weight <= 0: - label_weights[pos_inds] = 1.0 - else: - label_weights[pos_inds] = cfg.pos_weight - if len(neg_inds) > 0: - label_weights[neg_inds] = 1.0 - - # map up to original set of anchors - if unmap_outputs: - num_total_anchors = flat_anchors.size(0) - labels = unmap(labels, num_total_anchors, inside_flags) - label_weights = unmap(label_weights, num_total_anchors, inside_flags) - bbox_targets = unmap(bbox_targets, num_total_anchors, inside_flags) - bbox_weights = unmap(bbox_weights, num_total_anchors, inside_flags) - - return (labels, label_weights, bbox_targets, bbox_weights, pos_inds, - neg_inds) - - -def anchor_inside_flags(flat_anchors, - valid_flags, - img_shape, - allowed_border=0): - img_h, img_w = img_shape[:2] - if allowed_border >= 0: - inside_flags = valid_flags & \ - (flat_anchors[:, 0] >= -allowed_border).type(torch.uint8) & \ - (flat_anchors[:, 1] >= -allowed_border).type(torch.uint8) & \ - (flat_anchors[:, 2] < img_w + allowed_border).type(torch.uint8) & \ - (flat_anchors[:, 3] < img_h + allowed_border).type(torch.uint8) - else: - inside_flags = valid_flags - return inside_flags - - -def unmap(data, count, inds, fill=0): - """ Unmap a subset of item (data) back to the original set of items (of - size count) """ - if data.dim() == 1: - ret = data.new_full((count, ), fill) - ret[inds] = data - else: - new_size = (count, ) + data.size()[1:] - ret = data.new_full(new_size, fill) - ret[inds, :] = data - return ret diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/builder.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/builder.py new file mode 100644 index 000000000..ddb25ad37 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/builder.py @@ -0,0 +1,19 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import warnings + +from mmcv.utils import Registry, build_from_cfg + +PRIOR_GENERATORS = Registry('Generator for anchors and points') + +ANCHOR_GENERATORS = PRIOR_GENERATORS + + +def build_prior_generator(cfg, default_args=None): + return build_from_cfg(cfg, PRIOR_GENERATORS, default_args) + + +def build_anchor_generator(cfg, default_args=None): + warnings.warn( + '``build_anchor_generator`` would be deprecated soon, please use ' + '``build_prior_generator`` ') + return build_prior_generator(cfg, default_args=default_args) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/guided_anchor_target.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/guided_anchor_target.py deleted file mode 100644 index 21162eb9e..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/guided_anchor_target.py +++ /dev/null @@ -1,287 +0,0 @@ -import torch - -from ..bbox import PseudoSampler, build_assigner, build_sampler -from ..utils import multi_apply, unmap - - -def calc_region(bbox, ratio, featmap_size=None): - """Calculate a proportional bbox region. - - The bbox center are fixed and the new h' and w' is h * ratio and w * ratio. - - Args: - bbox (Tensor): Bboxes to calculate regions, shape (n, 4) - ratio (float): Ratio of the output region. - featmap_size (tuple): Feature map size used for clipping the boundary. - - Returns: - tuple: x1, y1, x2, y2 - """ - x1 = torch.round((1 - ratio) * bbox[0] + ratio * bbox[2]).long() - y1 = torch.round((1 - ratio) * bbox[1] + ratio * bbox[3]).long() - x2 = torch.round(ratio * bbox[0] + (1 - ratio) * bbox[2]).long() - y2 = torch.round(ratio * bbox[1] + (1 - ratio) * bbox[3]).long() - if featmap_size is not None: - x1 = x1.clamp(min=0, max=featmap_size[1] - 1) - y1 = y1.clamp(min=0, max=featmap_size[0] - 1) - x2 = x2.clamp(min=0, max=featmap_size[1] - 1) - y2 = y2.clamp(min=0, max=featmap_size[0] - 1) - return (x1, y1, x2, y2) - - -def ga_loc_target(gt_bboxes_list, - featmap_sizes, - anchor_scale, - anchor_strides, - center_ratio=0.2, - ignore_ratio=0.5): - """Compute location targets for guided anchoring. - - Each feature map is divided into positive, negative and ignore regions. - - positive regions: target 1, weight 1 - - ignore regions: target 0, weight 0 - - negative regions: target 0, weight 0.1 - - Args: - gt_bboxes_list (list[Tensor]): Gt bboxes of each image. - featmap_sizes (list[tuple]): Multi level sizes of each feature maps. - anchor_scale (int): Anchor scale. - anchor_strides ([list[int]]): Multi level anchor strides. - center_ratio (float): Ratio of center region. - ignore_ratio (float): Ratio of ignore region. - - Returns: - tuple - """ - img_per_gpu = len(gt_bboxes_list) - num_lvls = len(featmap_sizes) - r1 = (1 - center_ratio) / 2 - r2 = (1 - ignore_ratio) / 2 - all_loc_targets = [] - all_loc_weights = [] - all_ignore_map = [] - for lvl_id in range(num_lvls): - h, w = featmap_sizes[lvl_id] - loc_targets = torch.zeros( - img_per_gpu, - 1, - h, - w, - device=gt_bboxes_list[0].device, - dtype=torch.float32) - loc_weights = torch.full_like(loc_targets, -1) - ignore_map = torch.zeros_like(loc_targets) - all_loc_targets.append(loc_targets) - all_loc_weights.append(loc_weights) - all_ignore_map.append(ignore_map) - for img_id in range(img_per_gpu): - gt_bboxes = gt_bboxes_list[img_id] - scale = torch.sqrt((gt_bboxes[:, 2] - gt_bboxes[:, 0] + 1) * - (gt_bboxes[:, 3] - gt_bboxes[:, 1] + 1)) - min_anchor_size = scale.new_full( - (1, ), float(anchor_scale * anchor_strides[0])) - # assign gt bboxes to different feature levels w.r.t. their scales - target_lvls = torch.floor( - torch.log2(scale) - torch.log2(min_anchor_size) + 0.5) - target_lvls = target_lvls.clamp(min=0, max=num_lvls - 1).long() - for gt_id in range(gt_bboxes.size(0)): - lvl = target_lvls[gt_id].item() - # rescaled to corresponding feature map - gt_ = gt_bboxes[gt_id, :4] / anchor_strides[lvl] - # calculate ignore regions - ignore_x1, ignore_y1, ignore_x2, ignore_y2 = calc_region( - gt_, r2, featmap_sizes[lvl]) - # calculate positive (center) regions - ctr_x1, ctr_y1, ctr_x2, ctr_y2 = calc_region( - gt_, r1, featmap_sizes[lvl]) - all_loc_targets[lvl][img_id, 0, ctr_y1:ctr_y2 + 1, - ctr_x1:ctr_x2 + 1] = 1 - all_loc_weights[lvl][img_id, 0, ignore_y1:ignore_y2 + 1, - ignore_x1:ignore_x2 + 1] = 0 - all_loc_weights[lvl][img_id, 0, ctr_y1:ctr_y2 + 1, - ctr_x1:ctr_x2 + 1] = 1 - # calculate ignore map on nearby low level feature - if lvl > 0: - d_lvl = lvl - 1 - # rescaled to corresponding feature map - gt_ = gt_bboxes[gt_id, :4] / anchor_strides[d_lvl] - ignore_x1, ignore_y1, ignore_x2, ignore_y2 = calc_region( - gt_, r2, featmap_sizes[d_lvl]) - all_ignore_map[d_lvl][img_id, 0, ignore_y1:ignore_y2 + 1, - ignore_x1:ignore_x2 + 1] = 1 - # calculate ignore map on nearby high level feature - if lvl < num_lvls - 1: - u_lvl = lvl + 1 - # rescaled to corresponding feature map - gt_ = gt_bboxes[gt_id, :4] / anchor_strides[u_lvl] - ignore_x1, ignore_y1, ignore_x2, ignore_y2 = calc_region( - gt_, r2, featmap_sizes[u_lvl]) - all_ignore_map[u_lvl][img_id, 0, ignore_y1:ignore_y2 + 1, - ignore_x1:ignore_x2 + 1] = 1 - for lvl_id in range(num_lvls): - # ignore negative regions w.r.t. ignore map - all_loc_weights[lvl_id][(all_loc_weights[lvl_id] < 0) - & (all_ignore_map[lvl_id] > 0)] = 0 - # set negative regions with weight 0.1 - all_loc_weights[lvl_id][all_loc_weights[lvl_id] < 0] = 0.1 - # loc average factor to balance loss - loc_avg_factor = sum( - [t.size(0) * t.size(-1) * t.size(-2) for t in all_loc_targets]) / 200 - return all_loc_targets, all_loc_weights, loc_avg_factor - - -def ga_shape_target(approx_list, - inside_flag_list, - square_list, - gt_bboxes_list, - img_metas, - approxs_per_octave, - cfg, - gt_bboxes_ignore_list=None, - sampling=True, - unmap_outputs=True): - """Compute guided anchoring targets. - - Args: - approx_list (list[list]): Multi level approxs of each image. - inside_flag_list (list[list]): Multi level inside flags of each image. - square_list (list[list]): Multi level squares of each image. - gt_bboxes_list (list[Tensor]): Ground truth bboxes of each image. - img_metas (list[dict]): Meta info of each image. - approxs_per_octave (int): number of approxs per octave - cfg (dict): RPN train configs. - gt_bboxes_ignore_list (list[Tensor]): ignore list of gt bboxes. - sampling (bool): sampling or not. - unmap_outputs (bool): unmap outputs or not. - - Returns: - tuple - """ - num_imgs = len(img_metas) - assert len(approx_list) == len(inside_flag_list) == len( - square_list) == num_imgs - # anchor number of multi levels - num_level_squares = [squares.size(0) for squares in square_list[0]] - # concat all level anchors and flags to a single tensor - inside_flag_flat_list = [] - approx_flat_list = [] - square_flat_list = [] - for i in range(num_imgs): - assert len(square_list[i]) == len(inside_flag_list[i]) - inside_flag_flat_list.append(torch.cat(inside_flag_list[i])) - approx_flat_list.append(torch.cat(approx_list[i])) - square_flat_list.append(torch.cat(square_list[i])) - - # compute targets for each image - if gt_bboxes_ignore_list is None: - gt_bboxes_ignore_list = [None for _ in range(num_imgs)] - (all_bbox_anchors, all_bbox_gts, all_bbox_weights, pos_inds_list, - neg_inds_list) = multi_apply( - ga_shape_target_single, - approx_flat_list, - inside_flag_flat_list, - square_flat_list, - gt_bboxes_list, - gt_bboxes_ignore_list, - img_metas, - approxs_per_octave=approxs_per_octave, - cfg=cfg, - sampling=sampling, - unmap_outputs=unmap_outputs) - # no valid anchors - if any([bbox_anchors is None for bbox_anchors in all_bbox_anchors]): - return None - # sampled anchors of all images - num_total_pos = sum([max(inds.numel(), 1) for inds in pos_inds_list]) - num_total_neg = sum([max(inds.numel(), 1) for inds in neg_inds_list]) - # split targets to a list w.r.t. multiple levels - bbox_anchors_list = images_to_levels(all_bbox_anchors, num_level_squares) - bbox_gts_list = images_to_levels(all_bbox_gts, num_level_squares) - bbox_weights_list = images_to_levels(all_bbox_weights, num_level_squares) - return (bbox_anchors_list, bbox_gts_list, bbox_weights_list, num_total_pos, - num_total_neg) - - -def images_to_levels(target, num_level_anchors): - """Convert targets by image to targets by feature level. - - [target_img0, target_img1] -> [target_level0, target_level1, ...] - """ - target = torch.stack(target, 0) - level_targets = [] - start = 0 - for n in num_level_anchors: - end = start + n - level_targets.append(target[:, start:end].squeeze(0)) - start = end - return level_targets - - -def ga_shape_target_single(flat_approxs, - inside_flags, - flat_squares, - gt_bboxes, - gt_bboxes_ignore, - img_meta, - approxs_per_octave, - cfg, - sampling=True, - unmap_outputs=True): - """Compute guided anchoring targets. - - This function returns sampled anchors and gt bboxes directly - rather than calculates regression targets. - - Args: - flat_approxs (Tensor): flat approxs of a single image, - shape (n, 4) - inside_flags (Tensor): inside flags of a single image, - shape (n, ). - flat_squares (Tensor): flat squares of a single image, - shape (approxs_per_octave * n, 4) - gt_bboxes (Tensor): Ground truth bboxes of a single image. - img_meta (dict): Meta info of a single image. - approxs_per_octave (int): number of approxs per octave - cfg (dict): RPN train configs. - sampling (bool): sampling or not. - unmap_outputs (bool): unmap outputs or not. - - Returns: - tuple - """ - if not inside_flags.any(): - return (None, ) * 5 - # assign gt and sample anchors - expand_inside_flags = inside_flags[:, None].expand( - -1, approxs_per_octave).reshape(-1) - approxs = flat_approxs[expand_inside_flags, :] - squares = flat_squares[inside_flags, :] - - bbox_assigner = build_assigner(cfg.ga_assigner) - assign_result = bbox_assigner.assign(approxs, squares, approxs_per_octave, - gt_bboxes, gt_bboxes_ignore) - if sampling: - bbox_sampler = build_sampler(cfg.ga_sampler) - else: - bbox_sampler = PseudoSampler() - sampling_result = bbox_sampler.sample(assign_result, squares, gt_bboxes) - - bbox_anchors = torch.zeros_like(squares) - bbox_gts = torch.zeros_like(squares) - bbox_weights = torch.zeros_like(squares) - - pos_inds = sampling_result.pos_inds - neg_inds = sampling_result.neg_inds - if len(pos_inds) > 0: - bbox_anchors[pos_inds, :] = sampling_result.pos_bboxes - bbox_gts[pos_inds, :] = sampling_result.pos_gt_bboxes - bbox_weights[pos_inds, :] = 1.0 - - # map up to original set of anchors - if unmap_outputs: - num_total_anchors = flat_squares.size(0) - bbox_anchors = unmap(bbox_anchors, num_total_anchors, inside_flags) - bbox_gts = unmap(bbox_gts, num_total_anchors, inside_flags) - bbox_weights = unmap(bbox_weights, num_total_anchors, inside_flags) - - return (bbox_anchors, bbox_gts, bbox_weights, pos_inds, neg_inds) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/point_generator.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/point_generator.py index c1a34dddd..cc9c3887d 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/point_generator.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/point_generator.py @@ -1,7 +1,13 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import numpy as np import torch +from torch.nn.modules.utils import _pair +from .builder import PRIOR_GENERATORS -class PointGenerator(object): + +@PRIOR_GENERATORS.register_module() +class PointGenerator: def _meshgrid(self, x, y, row_major=True): xx = x.repeat(len(y)) @@ -25,10 +31,233 @@ class PointGenerator(object): feat_h, feat_w = featmap_size valid_h, valid_w = valid_size assert valid_h <= feat_h and valid_w <= feat_w - valid_x = torch.zeros(feat_w, dtype=torch.uint8, device=device) - valid_y = torch.zeros(feat_h, dtype=torch.uint8, device=device) + valid_x = torch.zeros(feat_w, dtype=torch.bool, device=device) + valid_y = torch.zeros(feat_h, dtype=torch.bool, device=device) + valid_x[:valid_w] = 1 + valid_y[:valid_h] = 1 + valid_xx, valid_yy = self._meshgrid(valid_x, valid_y) + valid = valid_xx & valid_yy + return valid + + +@PRIOR_GENERATORS.register_module() +class MlvlPointGenerator: + """Standard points generator for multi-level (Mlvl) feature maps in 2D + points-based detectors. + + Args: + strides (list[int] | list[tuple[int, int]]): Strides of anchors + in multiple feature levels in order (w, h). + offset (float): The offset of points, the value is normalized with + corresponding stride. Defaults to 0.5. + """ + + def __init__(self, strides, offset=0.5): + self.strides = [_pair(stride) for stride in strides] + self.offset = offset + + @property + def num_levels(self): + """int: number of feature levels that the generator will be applied""" + return len(self.strides) + + @property + def num_base_priors(self): + """list[int]: The number of priors (points) at a point + on the feature grid""" + return [1 for _ in range(len(self.strides))] + + def _meshgrid(self, x, y, row_major=True): + yy, xx = torch.meshgrid(y, x) + if row_major: + # warning .flatten() would cause error in ONNX exporting + # have to use reshape here + return xx.reshape(-1), yy.reshape(-1) + + else: + return yy.reshape(-1), xx.reshape(-1) + + def grid_priors(self, + featmap_sizes, + dtype=torch.float32, + device='cuda', + with_stride=False): + """Generate grid points of multiple feature levels. + + Args: + featmap_sizes (list[tuple]): List of feature map sizes in + multiple feature levels, each size arrange as + as (h, w). + dtype (:obj:`dtype`): Dtype of priors. Default: torch.float32. + device (str): The device where the anchors will be put on. + with_stride (bool): Whether to concatenate the stride to + the last dimension of points. + + Return: + list[torch.Tensor]: Points of multiple feature levels. + The sizes of each tensor should be (N, 2) when with stride is + ``False``, where N = width * height, width and height + are the sizes of the corresponding feature level, + and the last dimension 2 represent (coord_x, coord_y), + otherwise the shape should be (N, 4), + and the last dimension 4 represent + (coord_x, coord_y, stride_w, stride_h). + """ + + assert self.num_levels == len(featmap_sizes) + multi_level_priors = [] + for i in range(self.num_levels): + priors = self.single_level_grid_priors( + featmap_sizes[i], + level_idx=i, + dtype=dtype, + device=device, + with_stride=with_stride) + multi_level_priors.append(priors) + return multi_level_priors + + def single_level_grid_priors(self, + featmap_size, + level_idx, + dtype=torch.float32, + device='cuda', + with_stride=False): + """Generate grid Points of a single level. + + Note: + This function is usually called by method ``self.grid_priors``. + + Args: + featmap_size (tuple[int]): Size of the feature maps, arrange as + (h, w). + level_idx (int): The index of corresponding feature map level. + dtype (:obj:`dtype`): Dtype of priors. Default: torch.float32. + device (str, optional): The device the tensor will be put on. + Defaults to 'cuda'. + with_stride (bool): Concatenate the stride to the last dimension + of points. + + Return: + Tensor: Points of single feature levels. + The shape of tensor should be (N, 2) when with stride is + ``False``, where N = width * height, width and height + are the sizes of the corresponding feature level, + and the last dimension 2 represent (coord_x, coord_y), + otherwise the shape should be (N, 4), + and the last dimension 4 represent + (coord_x, coord_y, stride_w, stride_h). + """ + feat_h, feat_w = featmap_size + stride_w, stride_h = self.strides[level_idx] + shift_x = (torch.arange(0, feat_w, device=device) + + self.offset) * stride_w + # keep featmap_size as Tensor instead of int, so that we + # can convert to ONNX correctly + shift_x = shift_x.to(dtype) + + shift_y = (torch.arange(0, feat_h, device=device) + + self.offset) * stride_h + # keep featmap_size as Tensor instead of int, so that we + # can convert to ONNX correctly + shift_y = shift_y.to(dtype) + shift_xx, shift_yy = self._meshgrid(shift_x, shift_y) + if not with_stride: + shifts = torch.stack([shift_xx, shift_yy], dim=-1) + else: + # use `shape[0]` instead of `len(shift_xx)` for ONNX export + stride_w = shift_xx.new_full((shift_xx.shape[0], ), + stride_w).to(dtype) + stride_h = shift_xx.new_full((shift_yy.shape[0], ), + stride_h).to(dtype) + shifts = torch.stack([shift_xx, shift_yy, stride_w, stride_h], + dim=-1) + all_points = shifts.to(device) + return all_points + + def valid_flags(self, featmap_sizes, pad_shape, device='cuda'): + """Generate valid flags of points of multiple feature levels. + + Args: + featmap_sizes (list(tuple)): List of feature map sizes in + multiple feature levels, each size arrange as + as (h, w). + pad_shape (tuple(int)): The padded shape of the image, + arrange as (h, w). + device (str): The device where the anchors will be put on. + + Return: + list(torch.Tensor): Valid flags of points of multiple levels. + """ + assert self.num_levels == len(featmap_sizes) + multi_level_flags = [] + for i in range(self.num_levels): + point_stride = self.strides[i] + feat_h, feat_w = featmap_sizes[i] + h, w = pad_shape[:2] + valid_feat_h = min(int(np.ceil(h / point_stride[1])), feat_h) + valid_feat_w = min(int(np.ceil(w / point_stride[0])), feat_w) + flags = self.single_level_valid_flags((feat_h, feat_w), + (valid_feat_h, valid_feat_w), + device=device) + multi_level_flags.append(flags) + return multi_level_flags + + def single_level_valid_flags(self, + featmap_size, + valid_size, + device='cuda'): + """Generate the valid flags of points of a single feature map. + + Args: + featmap_size (tuple[int]): The size of feature maps, arrange as + as (h, w). + valid_size (tuple[int]): The valid size of the feature maps. + The size arrange as as (h, w). + device (str, optional): The device where the flags will be put on. + Defaults to 'cuda'. + + Returns: + torch.Tensor: The valid flags of each points in a single level \ + feature map. + """ + feat_h, feat_w = featmap_size + valid_h, valid_w = valid_size + assert valid_h <= feat_h and valid_w <= feat_w + valid_x = torch.zeros(feat_w, dtype=torch.bool, device=device) + valid_y = torch.zeros(feat_h, dtype=torch.bool, device=device) valid_x[:valid_w] = 1 valid_y[:valid_h] = 1 valid_xx, valid_yy = self._meshgrid(valid_x, valid_y) valid = valid_xx & valid_yy return valid + + def sparse_priors(self, + prior_idxs, + featmap_size, + level_idx, + dtype=torch.float32, + device='cuda'): + """Generate sparse points according to the ``prior_idxs``. + + Args: + prior_idxs (Tensor): The index of corresponding anchors + in the feature map. + featmap_size (tuple[int]): feature map size arrange as (w, h). + level_idx (int): The level index of corresponding feature + map. + dtype (obj:`torch.dtype`): Date type of points. Defaults to + ``torch.float32``. + device (obj:`torch.device`): The device where the points is + located. + Returns: + Tensor: Anchor with shape (N, 2), N should be equal to + the length of ``prior_idxs``. And last dimension + 2 represent (coord_x, coord_y). + """ + height, width = featmap_size + x = (prior_idxs % width + self.offset) * self.strides[level_idx][0] + y = ((prior_idxs // width) % height + + self.offset) * self.strides[level_idx][1] + prioris = torch.stack([x, y], 1).to(dtype) + prioris = prioris.to(device) + return prioris diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/point_target.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/point_target.py deleted file mode 100644 index 1ab8d0260..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/point_target.py +++ /dev/null @@ -1,165 +0,0 @@ -import torch - -from ..bbox import PseudoSampler, assign_and_sample, build_assigner -from ..utils import multi_apply - - -def point_target(proposals_list, - valid_flag_list, - gt_bboxes_list, - img_metas, - cfg, - gt_bboxes_ignore_list=None, - gt_labels_list=None, - label_channels=1, - sampling=True, - unmap_outputs=True): - """Compute corresponding GT box and classification targets for proposals. - - Args: - points_list (list[list]): Multi level points of each image. - valid_flag_list (list[list]): Multi level valid flags of each image. - gt_bboxes_list (list[Tensor]): Ground truth bboxes of each image. - img_metas (list[dict]): Meta info of each image. - cfg (dict): train sample configs. - - Returns: - tuple - """ - num_imgs = len(img_metas) - assert len(proposals_list) == len(valid_flag_list) == num_imgs - - # points number of multi levels - num_level_proposals = [points.size(0) for points in proposals_list[0]] - - # concat all level points and flags to a single tensor - for i in range(num_imgs): - assert len(proposals_list[i]) == len(valid_flag_list[i]) - proposals_list[i] = torch.cat(proposals_list[i]) - valid_flag_list[i] = torch.cat(valid_flag_list[i]) - - # compute targets for each image - if gt_bboxes_ignore_list is None: - gt_bboxes_ignore_list = [None for _ in range(num_imgs)] - if gt_labels_list is None: - gt_labels_list = [None for _ in range(num_imgs)] - (all_labels, all_label_weights, all_bbox_gt, all_proposals, - all_proposal_weights, pos_inds_list, neg_inds_list) = multi_apply( - point_target_single, - proposals_list, - valid_flag_list, - gt_bboxes_list, - gt_bboxes_ignore_list, - gt_labels_list, - cfg=cfg, - label_channels=label_channels, - sampling=sampling, - unmap_outputs=unmap_outputs) - # no valid points - if any([labels is None for labels in all_labels]): - return None - # sampled points of all images - num_total_pos = sum([max(inds.numel(), 1) for inds in pos_inds_list]) - num_total_neg = sum([max(inds.numel(), 1) for inds in neg_inds_list]) - labels_list = images_to_levels(all_labels, num_level_proposals) - label_weights_list = images_to_levels(all_label_weights, - num_level_proposals) - bbox_gt_list = images_to_levels(all_bbox_gt, num_level_proposals) - proposals_list = images_to_levels(all_proposals, num_level_proposals) - proposal_weights_list = images_to_levels(all_proposal_weights, - num_level_proposals) - return (labels_list, label_weights_list, bbox_gt_list, proposals_list, - proposal_weights_list, num_total_pos, num_total_neg) - - -def images_to_levels(target, num_level_grids): - """Convert targets by image to targets by feature level. - - [target_img0, target_img1] -> [target_level0, target_level1, ...] - """ - target = torch.stack(target, 0) - level_targets = [] - start = 0 - for n in num_level_grids: - end = start + n - level_targets.append(target[:, start:end].squeeze(0)) - start = end - return level_targets - - -def point_target_single(flat_proposals, - valid_flags, - gt_bboxes, - gt_bboxes_ignore, - gt_labels, - cfg, - label_channels=1, - sampling=True, - unmap_outputs=True): - inside_flags = valid_flags - if not inside_flags.any(): - return (None, ) * 7 - # assign gt and sample proposals - proposals = flat_proposals[inside_flags, :] - - if sampling: - assign_result, sampling_result = assign_and_sample( - proposals, gt_bboxes, gt_bboxes_ignore, None, cfg) - else: - bbox_assigner = build_assigner(cfg.assigner) - assign_result = bbox_assigner.assign(proposals, gt_bboxes, - gt_bboxes_ignore, gt_labels) - bbox_sampler = PseudoSampler() - sampling_result = bbox_sampler.sample(assign_result, proposals, - gt_bboxes) - - num_valid_proposals = proposals.shape[0] - bbox_gt = proposals.new_zeros([num_valid_proposals, 4]) - pos_proposals = torch.zeros_like(proposals) - proposals_weights = proposals.new_zeros([num_valid_proposals, 4]) - labels = proposals.new_zeros(num_valid_proposals, dtype=torch.long) - label_weights = proposals.new_zeros(num_valid_proposals, dtype=torch.float) - - pos_inds = sampling_result.pos_inds - neg_inds = sampling_result.neg_inds - if len(pos_inds) > 0: - pos_gt_bboxes = sampling_result.pos_gt_bboxes - bbox_gt[pos_inds, :] = pos_gt_bboxes - pos_proposals[pos_inds, :] = proposals[pos_inds, :] - proposals_weights[pos_inds, :] = 1.0 - if gt_labels is None: - labels[pos_inds] = 1 - else: - labels[pos_inds] = gt_labels[sampling_result.pos_assigned_gt_inds] - if cfg.pos_weight <= 0: - label_weights[pos_inds] = 1.0 - else: - label_weights[pos_inds] = cfg.pos_weight - if len(neg_inds) > 0: - label_weights[neg_inds] = 1.0 - - # map up to original set of proposals - if unmap_outputs: - num_total_proposals = flat_proposals.size(0) - labels = unmap(labels, num_total_proposals, inside_flags) - label_weights = unmap(label_weights, num_total_proposals, inside_flags) - bbox_gt = unmap(bbox_gt, num_total_proposals, inside_flags) - pos_proposals = unmap(pos_proposals, num_total_proposals, inside_flags) - proposals_weights = unmap(proposals_weights, num_total_proposals, - inside_flags) - - return (labels, label_weights, bbox_gt, pos_proposals, proposals_weights, - pos_inds, neg_inds) - - -def unmap(data, count, inds, fill=0): - """ Unmap a subset of item (data) back to the original set of items (of - size count) """ - if data.dim() == 1: - ret = data.new_full((count, ), fill) - ret[inds] = data - else: - new_size = (count, ) + data.size()[1:] - ret = data.new_full(new_size, fill) - ret[inds, :] = data - return ret diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/utils.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/utils.py new file mode 100644 index 000000000..c2f202476 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/anchor/utils.py @@ -0,0 +1,72 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch + + +def images_to_levels(target, num_levels): + """Convert targets by image to targets by feature level. + + [target_img0, target_img1] -> [target_level0, target_level1, ...] + """ + target = torch.stack(target, 0) + level_targets = [] + start = 0 + for n in num_levels: + end = start + n + # level_targets.append(target[:, start:end].squeeze(0)) + level_targets.append(target[:, start:end]) + start = end + return level_targets + + +def anchor_inside_flags(flat_anchors, + valid_flags, + img_shape, + allowed_border=0): + """Check whether the anchors are inside the border. + + Args: + flat_anchors (torch.Tensor): Flatten anchors, shape (n, 4). + valid_flags (torch.Tensor): An existing valid flags of anchors. + img_shape (tuple(int)): Shape of current image. + allowed_border (int, optional): The border to allow the valid anchor. + Defaults to 0. + + Returns: + torch.Tensor: Flags indicating whether the anchors are inside a \ + valid range. + """ + img_h, img_w = img_shape[:2] + if allowed_border >= 0: + inside_flags = valid_flags & \ + (flat_anchors[:, 0] >= -allowed_border) & \ + (flat_anchors[:, 1] >= -allowed_border) & \ + (flat_anchors[:, 2] < img_w + allowed_border) & \ + (flat_anchors[:, 3] < img_h + allowed_border) + else: + inside_flags = valid_flags + return inside_flags + + +def calc_region(bbox, ratio, featmap_size=None): + """Calculate a proportional bbox region. + + The bbox center are fixed and the new h' and w' is h * ratio and w * ratio. + + Args: + bbox (Tensor): Bboxes to calculate regions, shape (n, 4). + ratio (float): Ratio of the output region. + featmap_size (tuple): Feature map size used for clipping the boundary. + + Returns: + tuple: x1, y1, x2, y2 + """ + x1 = torch.round((1 - ratio) * bbox[0] + ratio * bbox[2]).long() + y1 = torch.round((1 - ratio) * bbox[1] + ratio * bbox[3]).long() + x2 = torch.round(ratio * bbox[0] + (1 - ratio) * bbox[2]).long() + y2 = torch.round(ratio * bbox[1] + (1 - ratio) * bbox[3]).long() + if featmap_size is not None: + x1 = x1.clamp(min=0, max=featmap_size[1]) + y1 = y1.clamp(min=0, max=featmap_size[0]) + x2 = x2.clamp(min=0, max=featmap_size[1]) + y2 = y2.clamp(min=0, max=featmap_size[0]) + return (x1, y1, x2, y2) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/__init__.py index a0de91724..371eba198 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/__init__.py @@ -1,22 +1,28 @@ -from .assigners import AssignResult, BaseAssigner, MaxIoUAssigner -from .bbox_target import bbox_target -from .geometry import bbox_overlaps +# Copyright (c) OpenMMLab. All rights reserved. +from .assigners import (AssignResult, BaseAssigner, CenterRegionAssigner, + MaxIoUAssigner, RegionAssigner) +from .builder import build_assigner, build_bbox_coder, build_sampler +from .coder import (BaseBBoxCoder, DeltaXYWHBBoxCoder, DistancePointBBoxCoder, + PseudoBBoxCoder, TBLRBBoxCoder) +from .iou_calculators import BboxOverlaps2D, bbox_overlaps from .samplers import (BaseSampler, CombinedSampler, InstanceBalancedPosSampler, IoUBalancedNegSampler, - PseudoSampler, RandomSampler, SamplingResult) -from .transforms import (bbox2delta, bbox2result, bbox2roi, bbox_flip, - bbox_mapping, bbox_mapping_back, delta2bbox, - distance2bbox, roi2bbox) - -from .assign_sampling import ( # isort:skip, avoid recursive imports - assign_and_sample, build_assigner, build_sampler) + OHEMSampler, PseudoSampler, RandomSampler, + SamplingResult, ScoreHLRSampler) +from .transforms import (bbox2distance, bbox2result, bbox2roi, + bbox_cxcywh_to_xyxy, bbox_flip, bbox_mapping, + bbox_mapping_back, bbox_rescale, bbox_xyxy_to_cxcywh, + distance2bbox, find_inside_bboxes, roi2bbox) __all__ = [ - 'bbox_overlaps', 'BaseAssigner', 'MaxIoUAssigner', 'AssignResult', - 'BaseSampler', 'PseudoSampler', 'RandomSampler', + 'bbox_overlaps', 'BboxOverlaps2D', 'BaseAssigner', 'MaxIoUAssigner', + 'AssignResult', 'BaseSampler', 'PseudoSampler', 'RandomSampler', 'InstanceBalancedPosSampler', 'IoUBalancedNegSampler', 'CombinedSampler', - 'SamplingResult', 'build_assigner', 'build_sampler', 'assign_and_sample', - 'bbox2delta', 'delta2bbox', 'bbox_flip', 'bbox_mapping', - 'bbox_mapping_back', 'bbox2roi', 'roi2bbox', 'bbox2result', - 'distance2bbox', 'bbox_target' + 'OHEMSampler', 'SamplingResult', 'ScoreHLRSampler', 'build_assigner', + 'build_sampler', 'bbox_flip', 'bbox_mapping', 'bbox_mapping_back', + 'bbox2roi', 'roi2bbox', 'bbox2result', 'distance2bbox', 'bbox2distance', + 'build_bbox_coder', 'BaseBBoxCoder', 'PseudoBBoxCoder', + 'DeltaXYWHBBoxCoder', 'TBLRBBoxCoder', 'DistancePointBBoxCoder', + 'CenterRegionAssigner', 'bbox_rescale', 'bbox_cxcywh_to_xyxy', + 'bbox_xyxy_to_cxcywh', 'RegionAssigner', 'find_inside_bboxes' ] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assign_sampling.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assign_sampling.py deleted file mode 100644 index 4267174bb..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assign_sampling.py +++ /dev/null @@ -1,33 +0,0 @@ -import mmcv - -from . import assigners, samplers - - -def build_assigner(cfg, **kwargs): - if isinstance(cfg, assigners.BaseAssigner): - return cfg - elif isinstance(cfg, dict): - return mmcv.runner.obj_from_dict(cfg, assigners, default_args=kwargs) - else: - raise TypeError('Invalid type {} for building a sampler'.format( - type(cfg))) - - -def build_sampler(cfg, **kwargs): - if isinstance(cfg, samplers.BaseSampler): - return cfg - elif isinstance(cfg, dict): - return mmcv.runner.obj_from_dict(cfg, samplers, default_args=kwargs) - else: - raise TypeError('Invalid type {} for building a sampler'.format( - type(cfg))) - - -def assign_and_sample(bboxes, gt_bboxes, gt_bboxes_ignore, gt_labels, cfg): - bbox_assigner = build_assigner(cfg.assigner) - bbox_sampler = build_sampler(cfg.sampler) - assign_result = bbox_assigner.assign(bboxes, gt_bboxes, gt_bboxes_ignore, - gt_labels) - sampling_result = bbox_sampler.sample(assign_result, bboxes, gt_bboxes, - gt_labels) - return assign_result, sampling_result diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/__init__.py index 4ed1d5643..5eaf7fa3a 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/__init__.py @@ -1,11 +1,22 @@ +# Copyright (c) OpenMMLab. All rights reserved. from .approx_max_iou_assigner import ApproxMaxIoUAssigner from .assign_result import AssignResult from .atss_assigner import ATSSAssigner from .base_assigner import BaseAssigner +from .center_region_assigner import CenterRegionAssigner +from .grid_assigner import GridAssigner +from .hungarian_assigner import HungarianAssigner +from .mask_hungarian_assigner import MaskHungarianAssigner from .max_iou_assigner import MaxIoUAssigner from .point_assigner import PointAssigner +from .region_assigner import RegionAssigner +from .sim_ota_assigner import SimOTAAssigner +from .task_aligned_assigner import TaskAlignedAssigner +from .uniform_assigner import UniformAssigner __all__ = [ 'BaseAssigner', 'MaxIoUAssigner', 'ApproxMaxIoUAssigner', 'AssignResult', - 'PointAssigner', 'ATSSAssigner' + 'PointAssigner', 'ATSSAssigner', 'CenterRegionAssigner', 'GridAssigner', + 'HungarianAssigner', 'RegionAssigner', 'UniformAssigner', 'SimOTAAssigner', + 'TaskAlignedAssigner', 'MaskHungarianAssigner' ] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/approx_max_iou_assigner.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/approx_max_iou_assigner.py index e7d3510a0..304d09c3f 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/approx_max_iou_assigner.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/approx_max_iou_assigner.py @@ -1,18 +1,20 @@ +# Copyright (c) OpenMMLab. All rights reserved. import torch -from ..geometry import bbox_overlaps +from ..builder import BBOX_ASSIGNERS +from ..iou_calculators import build_iou_calculator from .max_iou_assigner import MaxIoUAssigner +@BBOX_ASSIGNERS.register_module() class ApproxMaxIoUAssigner(MaxIoUAssigner): """Assign a corresponding gt bbox or background to each bbox. - Each proposals will be assigned with `-1`, `0`, or a positive integer - indicating the ground truth index. + Each proposals will be assigned with an integer indicating the ground truth + index. (semi-positive index: gt label (0-based), -1: background) - - -1: don't care - - 0: negative sample, no assigned gt - - positive integer: positive sample, index (1-based) of assigned gt + - -1: negative sample, no assigned gt + - semi-positive integer: positive sample, index (0-based) of assigned gt Args: pos_iou_thr (float): IoU threshold for positive bboxes. @@ -27,6 +29,9 @@ class ApproxMaxIoUAssigner(MaxIoUAssigner): ignoring any bboxes. ignore_wrt_candidates (bool): Whether to compute the iof between `bboxes` and `gt_bboxes_ignore`, or the contrary. + match_low_quality (bool): Whether to allow quality matches. This is + usually allowed for RPN and single stage detectors, but not allowed + in the second stage. gpu_assign_thr (int): The upper bound of the number of GT for GPU assign. When the number of gt is above this threshold, will assign on CPU device. Negative values mean not assign on CPU. @@ -39,7 +44,9 @@ class ApproxMaxIoUAssigner(MaxIoUAssigner): gt_max_assign_all=True, ignore_iof_thr=-1, ignore_wrt_candidates=True, - gpu_assign_thr=-1): + match_low_quality=True, + gpu_assign_thr=-1, + iou_calculator=dict(type='BboxOverlaps2D')): self.pos_iou_thr = pos_iou_thr self.neg_iou_thr = neg_iou_thr self.min_pos_iou = min_pos_iou @@ -47,6 +54,8 @@ class ApproxMaxIoUAssigner(MaxIoUAssigner): self.ignore_iof_thr = ignore_iof_thr self.ignore_wrt_candidates = ignore_wrt_candidates self.gpu_assign_thr = gpu_assign_thr + self.match_low_quality = match_low_quality + self.iou_calculator = build_iou_calculator(iou_calculator) def assign(self, approxs, @@ -59,14 +68,14 @@ class ApproxMaxIoUAssigner(MaxIoUAssigner): This method assign a gt bbox to each group of approxs (bboxes), each group of approxs is represent by a base approx (bbox) and - will be assigned with -1, 0, or a positive number. - -1 means don't care, 0 means negative sample, - positive number is the index (1-based) of assigned gt. + will be assigned with -1, or a semi-positive number. + background_label (-1) means negative sample, + semi-positive number is the index (0-based) of assigned gt. The assignment is done in following steps, the order matters. - 1. assign every bbox to -1 + 1. assign every bbox to background_label (-1) 2. use the max IoU of each group of approxs to assign - 2. assign proposals whose iou with all gts < neg_iou_thr to 0 + 2. assign proposals whose iou with all gts < neg_iou_thr to background 3. for each bbox, if the iou with its nearest gt >= pos_iou_thr, assign it to that bbox 4. for each gt bbox, assign its nearest proposals (may be more than @@ -110,23 +119,21 @@ class ApproxMaxIoUAssigner(MaxIoUAssigner): gt_bboxes_ignore = gt_bboxes_ignore.cpu() if gt_labels is not None: gt_labels = gt_labels.cpu() - all_overlaps = bbox_overlaps(approxs, gt_bboxes) + all_overlaps = self.iou_calculator(approxs, gt_bboxes) overlaps, _ = all_overlaps.view(approxs_per_octave, num_squares, num_gts).max(dim=0) overlaps = torch.transpose(overlaps, 0, 1) - bboxes = squares[:, :4] - - if (self.ignore_iof_thr > 0) and (gt_bboxes_ignore is not None) and ( - gt_bboxes_ignore.numel() > 0): + if (self.ignore_iof_thr > 0 and gt_bboxes_ignore is not None + and gt_bboxes_ignore.numel() > 0 and squares.numel() > 0): if self.ignore_wrt_candidates: - ignore_overlaps = bbox_overlaps( - bboxes, gt_bboxes_ignore, mode='iof') + ignore_overlaps = self.iou_calculator( + squares, gt_bboxes_ignore, mode='iof') ignore_max_overlaps, _ = ignore_overlaps.max(dim=1) else: - ignore_overlaps = bbox_overlaps( - gt_bboxes_ignore, bboxes, mode='iof') + ignore_overlaps = self.iou_calculator( + gt_bboxes_ignore, squares, mode='iof') ignore_max_overlaps, _ = ignore_overlaps.max(dim=0) overlaps[:, ignore_max_overlaps > self.ignore_iof_thr] = -1 diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/assign_result.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/assign_result.py index 5e81c8978..488010b5d 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/assign_result.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/assign_result.py @@ -1,11 +1,11 @@ +# Copyright (c) OpenMMLab. All rights reserved. import torch from mmdet.utils import util_mixins class AssignResult(util_mixins.NiceRepr): - """ - Stores assignments between predicted and truth boxes. + """Stores assignments between predicted and truth boxes. Attributes: num_gts (int): the number of truth boxes considered when computing this @@ -45,58 +45,63 @@ class AssignResult(util_mixins.NiceRepr): self.gt_inds = gt_inds self.max_overlaps = max_overlaps self.labels = labels + # Interface for possible user-defined properties + self._extra_properties = {} @property def num_preds(self): - """ - Return the number of predictions in this assignment - """ + """int: the number of predictions in this assignment""" return len(self.gt_inds) + def set_extra_property(self, key, value): + """Set user-defined new property.""" + assert key not in self.info + self._extra_properties[key] = value + + def get_extra_property(self, key): + """Get user-defined property.""" + return self._extra_properties.get(key, None) + @property def info(self): - """ - Returns a dictionary of info about the object - """ - return { + """dict: a dictionary of info about the object""" + basic_info = { 'num_gts': self.num_gts, 'num_preds': self.num_preds, 'gt_inds': self.gt_inds, 'max_overlaps': self.max_overlaps, 'labels': self.labels, } + basic_info.update(self._extra_properties) + return basic_info def __nice__(self): - """ - Create a "nice" summary string describing this assign result - """ + """str: a "nice" summary string describing this assign result""" parts = [] - parts.append('num_gts={!r}'.format(self.num_gts)) + parts.append(f'num_gts={self.num_gts!r}') if self.gt_inds is None: - parts.append('gt_inds={!r}'.format(self.gt_inds)) + parts.append(f'gt_inds={self.gt_inds!r}') else: - parts.append('gt_inds.shape={!r}'.format( - tuple(self.gt_inds.shape))) + parts.append(f'gt_inds.shape={tuple(self.gt_inds.shape)!r}') if self.max_overlaps is None: - parts.append('max_overlaps={!r}'.format(self.max_overlaps)) + parts.append(f'max_overlaps={self.max_overlaps!r}') else: - parts.append('max_overlaps.shape={!r}'.format( - tuple(self.max_overlaps.shape))) + parts.append('max_overlaps.shape=' + f'{tuple(self.max_overlaps.shape)!r}') if self.labels is None: - parts.append('labels={!r}'.format(self.labels)) + parts.append(f'labels={self.labels!r}') else: - parts.append('labels.shape={!r}'.format(tuple(self.labels.shape))) + parts.append(f'labels.shape={tuple(self.labels.shape)!r}') return ', '.join(parts) @classmethod def random(cls, **kwargs): - """ - Create random AssignResult for tests or debugging. + """Create random AssignResult for tests or debugging. - Kwargs: + Args: num_preds: number of predicted boxes num_gts: number of true boxes - p_ignore (float): probability of a predicted box assinged to an + p_ignore (float): probability of a predicted box assigned to an ignored truth p_assigned (float): probability of a predicted box not being assigned @@ -104,7 +109,7 @@ class AssignResult(util_mixins.NiceRepr): rng (None | int | numpy.random.RandomState): seed or state Returns: - AssignResult : + :obj:`AssignResult`: Randomly generated assign results. Example: >>> from mmdet.core.bbox.assigners.assign_result import * # NOQA @@ -135,6 +140,7 @@ class AssignResult(util_mixins.NiceRepr): labels = None else: import numpy as np + # Create an overlap for each predicted box max_overlaps = torch.from_numpy(rng.rand(num_preds)) @@ -159,7 +165,7 @@ class AssignResult(util_mixins.NiceRepr): true_idxs = np.arange(num_gts) rng.shuffle(true_idxs) true_idxs = torch.from_numpy(true_idxs) - gt_inds[is_assigned] = true_idxs[:n_assigned] + gt_inds[is_assigned] = true_idxs[:n_assigned].long() gt_inds = torch.from_numpy( rng.randint(1, num_gts + 1, size=num_preds)) @@ -172,7 +178,10 @@ class AssignResult(util_mixins.NiceRepr): labels = torch.zeros(num_preds, dtype=torch.int64) else: labels = torch.from_numpy( - rng.randint(1, num_classes + 1, size=num_preds)) + # remind that we set FG labels to [0, num_class-1] + # since mmdet v2.0 + # BG cat_id: num_class + rng.randint(0, num_classes, size=num_preds)) labels[~is_assigned] = 0 else: labels = None @@ -181,6 +190,11 @@ class AssignResult(util_mixins.NiceRepr): return self def add_gt_(self, gt_labels): + """Add ground truth as assigned results. + + Args: + gt_labels (torch.Tensor): Labels of gt boxes + """ self_inds = torch.arange( 1, len(gt_labels) + 1, dtype=torch.long, device=gt_labels.device) self.gt_inds = torch.cat([self_inds, self.gt_inds]) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/atss_assigner.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/atss_assigner.py index e442ac709..79c8281e5 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/atss_assigner.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/atss_assigner.py @@ -1,10 +1,15 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import warnings + import torch -from ..geometry import bbox_overlaps +from ..builder import BBOX_ASSIGNERS +from ..iou_calculators import build_iou_calculator from .assign_result import AssignResult from .base_assigner import BaseAssigner +@BBOX_ASSIGNERS.register_module() class ATSSAssigner(BaseAssigner): """Assign a corresponding gt bbox or background to each bbox. @@ -14,21 +19,44 @@ class ATSSAssigner(BaseAssigner): - 0: negative sample, no assigned gt - positive integer: positive sample, index (1-based) of assigned gt + If ``alpha`` is not None, it means that the dynamic cost + ATSSAssigner is adopted, which is currently only used in the DDOD. + Args: topk (float): number of bbox selected in each level """ - def __init__(self, topk): + def __init__(self, + topk, + alpha=None, + iou_calculator=dict(type='BboxOverlaps2D'), + ignore_iof_thr=-1): self.topk = topk + self.alpha = alpha + self.iou_calculator = build_iou_calculator(iou_calculator) + self.ignore_iof_thr = ignore_iof_thr - # https://github.com/sfzhang15/ATSS/blob/master/atss_core/modeling/rpn/atss/loss.py + """Assign a corresponding gt bbox or background to each bbox. + Args: + topk (int): number of bbox selected in each level. + alpha (float): param of cost rate for each proposal only in DDOD. + Default None. + iou_calculator (dict): builder of IoU calculator. + Default dict(type='BboxOverlaps2D'). + ignore_iof_thr (int): whether ignore max overlaps or not. + Default -1 (1 or -1). + """ + + # https://github.com/sfzhang15/ATSS/blob/master/atss_core/modeling/rpn/atss/loss.py def assign(self, bboxes, num_level_bboxes, gt_bboxes, gt_bboxes_ignore=None, - gt_labels=None): + gt_labels=None, + cls_scores=None, + bbox_preds=None): """Assign gt to bboxes. The assignment is done in following steps @@ -41,17 +69,27 @@ class ATSSAssigner(BaseAssigner): 4. get corresponding iou for the these candidates, and compute the mean and std, set mean + std as the iou threshold 5. select these candidates whose iou are greater than or equal to - the threshold as postive + the threshold as positive 6. limit the positive sample's center in gt + If ``alpha`` is not None, and ``cls_scores`` and `bbox_preds` + are not None, the overlaps calculation in the first step + will also include dynamic cost, which is currently only used in + the DDOD. Args: bboxes (Tensor): Bounding boxes to be assigned, shape(n, 4). num_level_bboxes (List): num of bboxes in each level gt_bboxes (Tensor): Groundtruth boxes, shape (k, 4). gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are - labelled as `ignored`, e.g., crowd boxes in COCO. + labelled as `ignored`, e.g., crowd boxes in COCO. Default None. gt_labels (Tensor, optional): Label of gt_bboxes, shape (k, ). + cls_scores (list[Tensor]): Classification scores for all scale + levels, each is a 4D-tensor, the channels number is + num_base_priors * num_classes. Default None. + bbox_preds (list[Tensor]): Box energies / deltas for all scale + levels, each is a 4D-tensor, the channels number is + num_base_priors * 4. Default None. Returns: :obj:`AssignResult`: The assign result. @@ -60,8 +98,31 @@ class ATSSAssigner(BaseAssigner): bboxes = bboxes[:, :4] num_gt, num_bboxes = gt_bboxes.size(0), bboxes.size(0) - # compute iou between all bbox and gt - overlaps = bbox_overlaps(bboxes, gt_bboxes) + message = 'Invalid alpha parameter because cls_scores or ' \ + 'bbox_preds are None. If you want to use the ' \ + 'cost-based ATSSAssigner, please set cls_scores, ' \ + 'bbox_preds and self.alpha at the same time. ' + + if self.alpha is None: + # ATSSAssigner + overlaps = self.iou_calculator(bboxes, gt_bboxes) + if cls_scores is not None or bbox_preds is not None: + warnings.warn(message) + else: + # Dynamic cost ATSSAssigner in DDOD + assert cls_scores is not None and bbox_preds is not None, message + + # compute cls cost for bbox and GT + cls_cost = torch.sigmoid(cls_scores[:, gt_labels]) + + # compute iou between all bbox and gt + overlaps = self.iou_calculator(bbox_preds, gt_bboxes) + + # make sure that we are in element-wise multiplication + assert cls_cost.shape == overlaps.shape + + # overlaps is actually a cost matrix + overlaps = cls_cost**(1 - self.alpha) * overlaps**self.alpha # assign 0 by default assigned_gt_inds = overlaps.new_full((num_bboxes, ), @@ -77,8 +138,9 @@ class ATSSAssigner(BaseAssigner): if gt_labels is None: assigned_labels = None else: - assigned_labels = overlaps.new_zeros((num_bboxes, ), - dtype=torch.long) + assigned_labels = overlaps.new_full((num_bboxes, ), + -1, + dtype=torch.long) return AssignResult( num_gt, assigned_gt_inds, max_overlaps, labels=assigned_labels) @@ -94,6 +156,15 @@ class ATSSAssigner(BaseAssigner): distances = (bboxes_points[:, None, :] - gt_points[None, :, :]).pow(2).sum(-1).sqrt() + if (self.ignore_iof_thr > 0 and gt_bboxes_ignore is not None + and gt_bboxes_ignore.numel() > 0 and bboxes.numel() > 0): + ignore_overlaps = self.iou_calculator( + bboxes, gt_bboxes_ignore, mode='iof') + ignore_max_overlaps, _ = ignore_overlaps.max(dim=1) + ignore_idxs = ignore_max_overlaps > self.ignore_iof_thr + distances[ignore_idxs, :] = INF + assigned_gt_inds[ignore_idxs] = -1 + # Selecting candidates based on the center distance candidate_idxs = [] start_idx = 0 @@ -102,8 +173,10 @@ class ATSSAssigner(BaseAssigner): # select k bbox whose center are closest to the gt center end_idx = start_idx + bboxes_per_level distances_per_level = distances[start_idx:end_idx, :] + selectable_k = min(self.topk, bboxes_per_level) + _, topk_idxs_per_level = distances_per_level.topk( - self.topk, dim=0, largest=False) + selectable_k, dim=0, largest=False) candidate_idxs.append(topk_idxs_per_level + start_idx) start_idx = end_idx candidate_idxs = torch.cat(candidate_idxs, dim=0) @@ -133,6 +206,7 @@ class ATSSAssigner(BaseAssigner): r_ = gt_bboxes[:, 2] - ep_bboxes_cx[candidate_idxs].view(-1, num_gt) b_ = gt_bboxes[:, 3] - ep_bboxes_cy[candidate_idxs].view(-1, num_gt) is_in_gts = torch.stack([l_, t_, r_, b_], dim=1).min(dim=1)[0] > 0.01 + is_pos = is_pos & is_in_gts # if an anchor box is assigned to multiple gts, @@ -148,8 +222,9 @@ class ATSSAssigner(BaseAssigner): max_overlaps != -INF] = argmax_overlaps[max_overlaps != -INF] + 1 if gt_labels is not None: - assigned_labels = assigned_gt_inds.new_zeros((num_bboxes, )) - pos_inds = torch.nonzero(assigned_gt_inds > 0).squeeze() + assigned_labels = assigned_gt_inds.new_full((num_bboxes, ), -1) + pos_inds = torch.nonzero( + assigned_gt_inds > 0, as_tuple=False).squeeze() if pos_inds.numel() > 0: assigned_labels[pos_inds] = gt_labels[ assigned_gt_inds[pos_inds] - 1] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/base_assigner.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/base_assigner.py index 7bd02dce1..3c2d597a5 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/base_assigner.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/base_assigner.py @@ -1,8 +1,10 @@ +# Copyright (c) OpenMMLab. All rights reserved. from abc import ABCMeta, abstractmethod class BaseAssigner(metaclass=ABCMeta): + """Base assigner that assigns boxes to ground truth boxes.""" @abstractmethod def assign(self, bboxes, gt_bboxes, gt_bboxes_ignore=None, gt_labels=None): - pass + """Assign boxes to either a ground truth boxes or a negative boxes.""" diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/center_region_assigner.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/center_region_assigner.py new file mode 100644 index 000000000..86e78597d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/center_region_assigner.py @@ -0,0 +1,336 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch + +from ..builder import BBOX_ASSIGNERS +from ..iou_calculators import build_iou_calculator +from .assign_result import AssignResult +from .base_assigner import BaseAssigner + + +def scale_boxes(bboxes, scale): + """Expand an array of boxes by a given scale. + + Args: + bboxes (Tensor): Shape (m, 4) + scale (float): The scale factor of bboxes + + Returns: + (Tensor): Shape (m, 4). Scaled bboxes + """ + assert bboxes.size(1) == 4 + w_half = (bboxes[:, 2] - bboxes[:, 0]) * .5 + h_half = (bboxes[:, 3] - bboxes[:, 1]) * .5 + x_c = (bboxes[:, 2] + bboxes[:, 0]) * .5 + y_c = (bboxes[:, 3] + bboxes[:, 1]) * .5 + + w_half *= scale + h_half *= scale + + boxes_scaled = torch.zeros_like(bboxes) + boxes_scaled[:, 0] = x_c - w_half + boxes_scaled[:, 2] = x_c + w_half + boxes_scaled[:, 1] = y_c - h_half + boxes_scaled[:, 3] = y_c + h_half + return boxes_scaled + + +def is_located_in(points, bboxes): + """Are points located in bboxes. + + Args: + points (Tensor): Points, shape: (m, 2). + bboxes (Tensor): Bounding boxes, shape: (n, 4). + + Return: + Tensor: Flags indicating if points are located in bboxes, shape: (m, n). + """ + assert points.size(1) == 2 + assert bboxes.size(1) == 4 + return (points[:, 0].unsqueeze(1) > bboxes[:, 0].unsqueeze(0)) & \ + (points[:, 0].unsqueeze(1) < bboxes[:, 2].unsqueeze(0)) & \ + (points[:, 1].unsqueeze(1) > bboxes[:, 1].unsqueeze(0)) & \ + (points[:, 1].unsqueeze(1) < bboxes[:, 3].unsqueeze(0)) + + +def bboxes_area(bboxes): + """Compute the area of an array of bboxes. + + Args: + bboxes (Tensor): The coordinates ox bboxes. Shape: (m, 4) + + Returns: + Tensor: Area of the bboxes. Shape: (m, ) + """ + assert bboxes.size(1) == 4 + w = (bboxes[:, 2] - bboxes[:, 0]) + h = (bboxes[:, 3] - bboxes[:, 1]) + areas = w * h + return areas + + +@BBOX_ASSIGNERS.register_module() +class CenterRegionAssigner(BaseAssigner): + """Assign pixels at the center region of a bbox as positive. + + Each proposals will be assigned with `-1`, `0`, or a positive integer + indicating the ground truth index. + - -1: negative samples + - semi-positive numbers: positive sample, index (0-based) of assigned gt + + Args: + pos_scale (float): Threshold within which pixels are + labelled as positive. + neg_scale (float): Threshold above which pixels are + labelled as positive. + min_pos_iof (float): Minimum iof of a pixel with a gt to be + labelled as positive. Default: 1e-2 + ignore_gt_scale (float): Threshold within which the pixels + are ignored when the gt is labelled as shadowed. Default: 0.5 + foreground_dominate (bool): If True, the bbox will be assigned as + positive when a gt's kernel region overlaps with another's shadowed + (ignored) region, otherwise it is set as ignored. Default to False. + """ + + def __init__(self, + pos_scale, + neg_scale, + min_pos_iof=1e-2, + ignore_gt_scale=0.5, + foreground_dominate=False, + iou_calculator=dict(type='BboxOverlaps2D')): + self.pos_scale = pos_scale + self.neg_scale = neg_scale + self.min_pos_iof = min_pos_iof + self.ignore_gt_scale = ignore_gt_scale + self.foreground_dominate = foreground_dominate + self.iou_calculator = build_iou_calculator(iou_calculator) + + def get_gt_priorities(self, gt_bboxes): + """Get gt priorities according to their areas. + + Smaller gt has higher priority. + + Args: + gt_bboxes (Tensor): Ground truth boxes, shape (k, 4). + + Returns: + Tensor: The priority of gts so that gts with larger priority is \ + more likely to be assigned. Shape (k, ) + """ + gt_areas = bboxes_area(gt_bboxes) + # Rank all gt bbox areas. Smaller objects has larger priority + _, sort_idx = gt_areas.sort(descending=True) + sort_idx = sort_idx.argsort() + return sort_idx + + def assign(self, bboxes, gt_bboxes, gt_bboxes_ignore=None, gt_labels=None): + """Assign gt to bboxes. + + This method assigns gts to every bbox (proposal/anchor), each bbox \ + will be assigned with -1, or a semi-positive number. -1 means \ + negative sample, semi-positive number is the index (0-based) of \ + assigned gt. + + Args: + bboxes (Tensor): Bounding boxes to be assigned, shape(n, 4). + gt_bboxes (Tensor): Groundtruth boxes, shape (k, 4). + gt_bboxes_ignore (tensor, optional): Ground truth bboxes that are + labelled as `ignored`, e.g., crowd boxes in COCO. + gt_labels (tensor, optional): Label of gt_bboxes, shape (num_gts,). + + Returns: + :obj:`AssignResult`: The assigned result. Note that \ + shadowed_labels of shape (N, 2) is also added as an \ + `assign_result` attribute. `shadowed_labels` is a tensor \ + composed of N pairs of anchor_ind, class_label], where N \ + is the number of anchors that lie in the outer region of a \ + gt, anchor_ind is the shadowed anchor index and class_label \ + is the shadowed class label. + + Example: + >>> self = CenterRegionAssigner(0.2, 0.2) + >>> bboxes = torch.Tensor([[0, 0, 10, 10], [10, 10, 20, 20]]) + >>> gt_bboxes = torch.Tensor([[0, 0, 10, 10]]) + >>> assign_result = self.assign(bboxes, gt_bboxes) + >>> expected_gt_inds = torch.LongTensor([1, 0]) + >>> assert torch.all(assign_result.gt_inds == expected_gt_inds) + """ + # There are in total 5 steps in the pixel assignment + # 1. Find core (the center region, say inner 0.2) + # and shadow (the relatively ourter part, say inner 0.2-0.5) + # regions of every gt. + # 2. Find all prior bboxes that lie in gt_core and gt_shadow regions + # 3. Assign prior bboxes in gt_core with a one-hot id of the gt in + # the image. + # 3.1. For overlapping objects, the prior bboxes in gt_core is + # assigned with the object with smallest area + # 4. Assign prior bboxes with class label according to its gt id. + # 4.1. Assign -1 to prior bboxes lying in shadowed gts + # 4.2. Assign positive prior boxes with the corresponding label + # 5. Find pixels lying in the shadow of an object and assign them with + # background label, but set the loss weight of its corresponding + # gt to zero. + assert bboxes.size(1) == 4, 'bboxes must have size of 4' + # 1. Find core positive and shadow region of every gt + gt_core = scale_boxes(gt_bboxes, self.pos_scale) + gt_shadow = scale_boxes(gt_bboxes, self.neg_scale) + + # 2. Find prior bboxes that lie in gt_core and gt_shadow regions + bbox_centers = (bboxes[:, 2:4] + bboxes[:, 0:2]) / 2 + # The center points lie within the gt boxes + is_bbox_in_gt = is_located_in(bbox_centers, gt_bboxes) + # Only calculate bbox and gt_core IoF. This enables small prior bboxes + # to match large gts + bbox_and_gt_core_overlaps = self.iou_calculator( + bboxes, gt_core, mode='iof') + # The center point of effective priors should be within the gt box + is_bbox_in_gt_core = is_bbox_in_gt & ( + bbox_and_gt_core_overlaps > self.min_pos_iof) # shape (n, k) + + is_bbox_in_gt_shadow = ( + self.iou_calculator(bboxes, gt_shadow, mode='iof') > + self.min_pos_iof) + # Rule out center effective positive pixels + is_bbox_in_gt_shadow &= (~is_bbox_in_gt_core) + + num_gts, num_bboxes = gt_bboxes.size(0), bboxes.size(0) + if num_gts == 0 or num_bboxes == 0: + # If no gts exist, assign all pixels to negative + assigned_gt_ids = \ + is_bbox_in_gt_core.new_zeros((num_bboxes,), + dtype=torch.long) + pixels_in_gt_shadow = assigned_gt_ids.new_empty((0, 2)) + else: + # Step 3: assign a one-hot gt id to each pixel, and smaller objects + # have high priority to assign the pixel. + sort_idx = self.get_gt_priorities(gt_bboxes) + assigned_gt_ids, pixels_in_gt_shadow = \ + self.assign_one_hot_gt_indices(is_bbox_in_gt_core, + is_bbox_in_gt_shadow, + gt_priority=sort_idx) + + if gt_bboxes_ignore is not None and gt_bboxes_ignore.numel() > 0: + # No ground truth or boxes, return empty assignment + gt_bboxes_ignore = scale_boxes( + gt_bboxes_ignore, scale=self.ignore_gt_scale) + is_bbox_in_ignored_gts = is_located_in(bbox_centers, + gt_bboxes_ignore) + is_bbox_in_ignored_gts = is_bbox_in_ignored_gts.any(dim=1) + assigned_gt_ids[is_bbox_in_ignored_gts] = -1 + + # 4. Assign prior bboxes with class label according to its gt id. + assigned_labels = None + shadowed_pixel_labels = None + if gt_labels is not None: + # Default assigned label is the background (-1) + assigned_labels = assigned_gt_ids.new_full((num_bboxes, ), -1) + pos_inds = torch.nonzero( + assigned_gt_ids > 0, as_tuple=False).squeeze() + if pos_inds.numel() > 0: + assigned_labels[pos_inds] = gt_labels[assigned_gt_ids[pos_inds] + - 1] + # 5. Find pixels lying in the shadow of an object + shadowed_pixel_labels = pixels_in_gt_shadow.clone() + if pixels_in_gt_shadow.numel() > 0: + pixel_idx, gt_idx =\ + pixels_in_gt_shadow[:, 0], pixels_in_gt_shadow[:, 1] + assert (assigned_gt_ids[pixel_idx] != gt_idx).all(), \ + 'Some pixels are dually assigned to ignore and gt!' + shadowed_pixel_labels[:, 1] = gt_labels[gt_idx - 1] + override = ( + assigned_labels[pixel_idx] == shadowed_pixel_labels[:, 1]) + if self.foreground_dominate: + # When a pixel is both positive and shadowed, set it as pos + shadowed_pixel_labels = shadowed_pixel_labels[~override] + else: + # When a pixel is both pos and shadowed, set it as shadowed + assigned_labels[pixel_idx[override]] = -1 + assigned_gt_ids[pixel_idx[override]] = 0 + + assign_result = AssignResult( + num_gts, assigned_gt_ids, None, labels=assigned_labels) + # Add shadowed_labels as assign_result property. Shape: (num_shadow, 2) + assign_result.set_extra_property('shadowed_labels', + shadowed_pixel_labels) + return assign_result + + def assign_one_hot_gt_indices(self, + is_bbox_in_gt_core, + is_bbox_in_gt_shadow, + gt_priority=None): + """Assign only one gt index to each prior box. + + Gts with large gt_priority are more likely to be assigned. + + Args: + is_bbox_in_gt_core (Tensor): Bool tensor indicating the bbox center + is in the core area of a gt (e.g. 0-0.2). + Shape: (num_prior, num_gt). + is_bbox_in_gt_shadow (Tensor): Bool tensor indicating the bbox + center is in the shadowed area of a gt (e.g. 0.2-0.5). + Shape: (num_prior, num_gt). + gt_priority (Tensor): Priorities of gts. The gt with a higher + priority is more likely to be assigned to the bbox when the bbox + match with multiple gts. Shape: (num_gt, ). + + Returns: + tuple: Returns (assigned_gt_inds, shadowed_gt_inds). + + - assigned_gt_inds: The assigned gt index of each prior bbox \ + (i.e. index from 1 to num_gts). Shape: (num_prior, ). + - shadowed_gt_inds: shadowed gt indices. It is a tensor of \ + shape (num_ignore, 2) with first column being the \ + shadowed prior bbox indices and the second column the \ + shadowed gt indices (1-based). + """ + num_bboxes, num_gts = is_bbox_in_gt_core.shape + + if gt_priority is None: + gt_priority = torch.arange( + num_gts, device=is_bbox_in_gt_core.device) + assert gt_priority.size(0) == num_gts + # The bigger gt_priority, the more preferable to be assigned + # The assigned inds are by default 0 (background) + assigned_gt_inds = is_bbox_in_gt_core.new_zeros((num_bboxes, ), + dtype=torch.long) + # Shadowed bboxes are assigned to be background. But the corresponding + # label is ignored during loss calculation, which is done through + # shadowed_gt_inds + shadowed_gt_inds = torch.nonzero(is_bbox_in_gt_shadow, as_tuple=False) + if is_bbox_in_gt_core.sum() == 0: # No gt match + shadowed_gt_inds[:, 1] += 1 # 1-based. For consistency issue + return assigned_gt_inds, shadowed_gt_inds + + # The priority of each prior box and gt pair. If one prior box is + # matched bo multiple gts. Only the pair with the highest priority + # is saved + pair_priority = is_bbox_in_gt_core.new_full((num_bboxes, num_gts), + -1, + dtype=torch.long) + + # Each bbox could match with multiple gts. + # The following codes deal with this situation + # Matched bboxes (to any gt). Shape: (num_pos_anchor, ) + inds_of_match = torch.any(is_bbox_in_gt_core, dim=1) + # The matched gt index of each positive bbox. Length >= num_pos_anchor + # , since one bbox could match multiple gts + matched_bbox_gt_inds = torch.nonzero( + is_bbox_in_gt_core, as_tuple=False)[:, 1] + # Assign priority to each bbox-gt pair. + pair_priority[is_bbox_in_gt_core] = gt_priority[matched_bbox_gt_inds] + _, argmax_priority = pair_priority[inds_of_match].max(dim=1) + assigned_gt_inds[inds_of_match] = argmax_priority + 1 # 1-based + # Zero-out the assigned anchor box to filter the shadowed gt indices + is_bbox_in_gt_core[inds_of_match, argmax_priority] = 0 + # Concat the shadowed indices due to overlapping with that out side of + # effective scale. shape: (total_num_ignore, 2) + shadowed_gt_inds = torch.cat( + (shadowed_gt_inds, torch.nonzero( + is_bbox_in_gt_core, as_tuple=False)), + dim=0) + # `is_bbox_in_gt_core` should be changed back to keep arguments intact. + is_bbox_in_gt_core[inds_of_match, argmax_priority] = 1 + # 1-based shadowed gt indices, to be consistent with `assigned_gt_inds` + if shadowed_gt_inds.numel() > 0: + shadowed_gt_inds[:, 1] += 1 + return assigned_gt_inds, shadowed_gt_inds diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/grid_assigner.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/grid_assigner.py new file mode 100644 index 000000000..a0c814e78 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/grid_assigner.py @@ -0,0 +1,156 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch + +from ..builder import BBOX_ASSIGNERS +from ..iou_calculators import build_iou_calculator +from .assign_result import AssignResult +from .base_assigner import BaseAssigner + + +@BBOX_ASSIGNERS.register_module() +class GridAssigner(BaseAssigner): + """Assign a corresponding gt bbox or background to each bbox. + + Each proposals will be assigned with `-1`, `0`, or a positive integer + indicating the ground truth index. + + - -1: don't care + - 0: negative sample, no assigned gt + - positive integer: positive sample, index (1-based) of assigned gt + + Args: + pos_iou_thr (float): IoU threshold for positive bboxes. + neg_iou_thr (float or tuple): IoU threshold for negative bboxes. + min_pos_iou (float): Minimum iou for a bbox to be considered as a + positive bbox. Positive samples can have smaller IoU than + pos_iou_thr due to the 4th step (assign max IoU sample to each gt). + gt_max_assign_all (bool): Whether to assign all bboxes with the same + highest overlap with some gt to that gt. + """ + + def __init__(self, + pos_iou_thr, + neg_iou_thr, + min_pos_iou=.0, + gt_max_assign_all=True, + iou_calculator=dict(type='BboxOverlaps2D')): + self.pos_iou_thr = pos_iou_thr + self.neg_iou_thr = neg_iou_thr + self.min_pos_iou = min_pos_iou + self.gt_max_assign_all = gt_max_assign_all + self.iou_calculator = build_iou_calculator(iou_calculator) + + def assign(self, bboxes, box_responsible_flags, gt_bboxes, gt_labels=None): + """Assign gt to bboxes. The process is very much like the max iou + assigner, except that positive samples are constrained within the cell + that the gt boxes fell in. + + This method assign a gt bbox to every bbox (proposal/anchor), each bbox + will be assigned with -1, 0, or a positive number. -1 means don't care, + 0 means negative sample, positive number is the index (1-based) of + assigned gt. + The assignment is done in following steps, the order matters. + + 1. assign every bbox to -1 + 2. assign proposals whose iou with all gts <= neg_iou_thr to 0 + 3. for each bbox within a cell, if the iou with its nearest gt > + pos_iou_thr and the center of that gt falls inside the cell, + assign it to that bbox + 4. for each gt bbox, assign its nearest proposals within the cell the + gt bbox falls in to itself. + + Args: + bboxes (Tensor): Bounding boxes to be assigned, shape(n, 4). + box_responsible_flags (Tensor): flag to indicate whether box is + responsible for prediction, shape(n, ) + gt_bboxes (Tensor): Groundtruth boxes, shape (k, 4). + gt_labels (Tensor, optional): Label of gt_bboxes, shape (k, ). + + Returns: + :obj:`AssignResult`: The assign result. + """ + num_gts, num_bboxes = gt_bboxes.size(0), bboxes.size(0) + + # compute iou between all gt and bboxes + overlaps = self.iou_calculator(gt_bboxes, bboxes) + + # 1. assign -1 by default + assigned_gt_inds = overlaps.new_full((num_bboxes, ), + -1, + dtype=torch.long) + + if num_gts == 0 or num_bboxes == 0: + # No ground truth or boxes, return empty assignment + max_overlaps = overlaps.new_zeros((num_bboxes, )) + if num_gts == 0: + # No truth, assign everything to background + assigned_gt_inds[:] = 0 + if gt_labels is None: + assigned_labels = None + else: + assigned_labels = overlaps.new_full((num_bboxes, ), + -1, + dtype=torch.long) + return AssignResult( + num_gts, + assigned_gt_inds, + max_overlaps, + labels=assigned_labels) + + # 2. assign negative: below + # for each anchor, which gt best overlaps with it + # for each anchor, the max iou of all gts + # shape of max_overlaps == argmax_overlaps == num_bboxes + max_overlaps, argmax_overlaps = overlaps.max(dim=0) + + if isinstance(self.neg_iou_thr, float): + assigned_gt_inds[(max_overlaps >= 0) + & (max_overlaps <= self.neg_iou_thr)] = 0 + elif isinstance(self.neg_iou_thr, (tuple, list)): + assert len(self.neg_iou_thr) == 2 + assigned_gt_inds[(max_overlaps > self.neg_iou_thr[0]) + & (max_overlaps <= self.neg_iou_thr[1])] = 0 + + # 3. assign positive: falls into responsible cell and above + # positive IOU threshold, the order matters. + # the prior condition of comparison is to filter out all + # unrelated anchors, i.e. not box_responsible_flags + overlaps[:, ~box_responsible_flags.type(torch.bool)] = -1. + + # calculate max_overlaps again, but this time we only consider IOUs + # for anchors responsible for prediction + max_overlaps, argmax_overlaps = overlaps.max(dim=0) + + # for each gt, which anchor best overlaps with it + # for each gt, the max iou of all proposals + # shape of gt_max_overlaps == gt_argmax_overlaps == num_gts + gt_max_overlaps, gt_argmax_overlaps = overlaps.max(dim=1) + + pos_inds = (max_overlaps > + self.pos_iou_thr) & box_responsible_flags.type(torch.bool) + assigned_gt_inds[pos_inds] = argmax_overlaps[pos_inds] + 1 + + # 4. assign positive to max overlapped anchors within responsible cell + for i in range(num_gts): + if gt_max_overlaps[i] > self.min_pos_iou: + if self.gt_max_assign_all: + max_iou_inds = (overlaps[i, :] == gt_max_overlaps[i]) & \ + box_responsible_flags.type(torch.bool) + assigned_gt_inds[max_iou_inds] = i + 1 + elif box_responsible_flags[gt_argmax_overlaps[i]]: + assigned_gt_inds[gt_argmax_overlaps[i]] = i + 1 + + # assign labels of positive anchors + if gt_labels is not None: + assigned_labels = assigned_gt_inds.new_full((num_bboxes, ), -1) + pos_inds = torch.nonzero( + assigned_gt_inds > 0, as_tuple=False).squeeze() + if pos_inds.numel() > 0: + assigned_labels[pos_inds] = gt_labels[ + assigned_gt_inds[pos_inds] - 1] + + else: + assigned_labels = None + + return AssignResult( + num_gts, assigned_gt_inds, max_overlaps, labels=assigned_labels) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/hungarian_assigner.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/hungarian_assigner.py new file mode 100644 index 000000000..4105fb5c4 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/hungarian_assigner.py @@ -0,0 +1,146 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch + +from ..builder import BBOX_ASSIGNERS +from ..match_costs import build_match_cost +from ..transforms import bbox_cxcywh_to_xyxy +from .assign_result import AssignResult +from .base_assigner import BaseAssigner + +try: + from scipy.optimize import linear_sum_assignment +except ImportError: + linear_sum_assignment = None + + +@BBOX_ASSIGNERS.register_module() +class HungarianAssigner(BaseAssigner): + """Computes one-to-one matching between predictions and ground truth. + + This class computes an assignment between the targets and the predictions + based on the costs. The costs are weighted sum of three components: + classification cost, regression L1 cost and regression iou cost. The + targets don't include the no_object, so generally there are more + predictions than targets. After the one-to-one matching, the un-matched + are treated as backgrounds. Thus each query prediction will be assigned + with `0` or a positive integer indicating the ground truth index: + + - 0: negative sample, no assigned gt + - positive integer: positive sample, index (1-based) of assigned gt + + Args: + cls_weight (int | float, optional): The scale factor for classification + cost. Default 1.0. + bbox_weight (int | float, optional): The scale factor for regression + L1 cost. Default 1.0. + iou_weight (int | float, optional): The scale factor for regression + iou cost. Default 1.0. + iou_calculator (dict | optional): The config for the iou calculation. + Default type `BboxOverlaps2D`. + iou_mode (str | optional): "iou" (intersection over union), "iof" + (intersection over foreground), or "giou" (generalized + intersection over union). Default "giou". + """ + + def __init__(self, + cls_cost=dict(type='ClassificationCost', weight=1.), + reg_cost=dict(type='BBoxL1Cost', weight=1.0), + iou_cost=dict(type='IoUCost', iou_mode='giou', weight=1.0)): + self.cls_cost = build_match_cost(cls_cost) + self.reg_cost = build_match_cost(reg_cost) + self.iou_cost = build_match_cost(iou_cost) + + def assign(self, + bbox_pred, + cls_pred, + gt_bboxes, + gt_labels, + img_meta, + gt_bboxes_ignore=None, + eps=1e-7): + """Computes one-to-one matching based on the weighted costs. + + This method assign each query prediction to a ground truth or + background. The `assigned_gt_inds` with -1 means don't care, + 0 means negative sample, and positive number is the index (1-based) + of assigned gt. + The assignment is done in the following steps, the order matters. + + 1. assign every prediction to -1 + 2. compute the weighted costs + 3. do Hungarian matching on CPU based on the costs + 4. assign all to 0 (background) first, then for each matched pair + between predictions and gts, treat this prediction as foreground + and assign the corresponding gt index (plus 1) to it. + + Args: + bbox_pred (Tensor): Predicted boxes with normalized coordinates + (cx, cy, w, h), which are all in range [0, 1]. Shape + [num_query, 4]. + cls_pred (Tensor): Predicted classification logits, shape + [num_query, num_class]. + gt_bboxes (Tensor): Ground truth boxes with unnormalized + coordinates (x1, y1, x2, y2). Shape [num_gt, 4]. + gt_labels (Tensor): Label of `gt_bboxes`, shape (num_gt,). + img_meta (dict): Meta information for current image. + gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are + labelled as `ignored`. Default None. + eps (int | float, optional): A value added to the denominator for + numerical stability. Default 1e-7. + + Returns: + :obj:`AssignResult`: The assigned result. + """ + assert gt_bboxes_ignore is None, \ + 'Only case when gt_bboxes_ignore is None is supported.' + num_gts, num_bboxes = gt_bboxes.size(0), bbox_pred.size(0) + + # 1. assign -1 by default + assigned_gt_inds = bbox_pred.new_full((num_bboxes, ), + -1, + dtype=torch.long) + assigned_labels = bbox_pred.new_full((num_bboxes, ), + -1, + dtype=torch.long) + if num_gts == 0 or num_bboxes == 0: + # No ground truth or boxes, return empty assignment + if num_gts == 0: + # No ground truth, assign all to background + assigned_gt_inds[:] = 0 + return AssignResult( + num_gts, assigned_gt_inds, None, labels=assigned_labels) + img_h, img_w, _ = img_meta['img_shape'] + factor = gt_bboxes.new_tensor([img_w, img_h, img_w, + img_h]).unsqueeze(0) + + # 2. compute the weighted costs + # classification and bboxcost. + cls_cost = self.cls_cost(cls_pred, gt_labels) + # regression L1 cost + normalize_gt_bboxes = gt_bboxes / factor + reg_cost = self.reg_cost(bbox_pred, normalize_gt_bboxes) + # regression iou cost, defaultly giou is used in official DETR. + bboxes = bbox_cxcywh_to_xyxy(bbox_pred) * factor + iou_cost = self.iou_cost(bboxes, gt_bboxes) + # weighted sum of above three costs + cost = cls_cost + reg_cost + iou_cost + + # 3. do Hungarian matching on CPU using linear_sum_assignment + cost = cost.detach().cpu() + if linear_sum_assignment is None: + raise ImportError('Please run "pip install scipy" ' + 'to install scipy first.') + matched_row_inds, matched_col_inds = linear_sum_assignment(cost) + matched_row_inds = torch.from_numpy(matched_row_inds).to( + bbox_pred.device) + matched_col_inds = torch.from_numpy(matched_col_inds).to( + bbox_pred.device) + + # 4. assign backgrounds and foregrounds + # assign all indices to backgrounds first + assigned_gt_inds[:] = 0 + # assign foregrounds based on matching results + assigned_gt_inds[matched_row_inds] = matched_col_inds + 1 + assigned_labels[matched_row_inds] = gt_labels[matched_col_inds] + return AssignResult( + num_gts, assigned_gt_inds, None, labels=assigned_labels) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/mask_hungarian_assigner.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/mask_hungarian_assigner.py new file mode 100644 index 000000000..f5f27f3f5 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/mask_hungarian_assigner.py @@ -0,0 +1,132 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch + +from mmdet.core.bbox.builder import BBOX_ASSIGNERS +from mmdet.core.bbox.match_costs.builder import build_match_cost +from .assign_result import AssignResult +from .base_assigner import BaseAssigner + +try: + from scipy.optimize import linear_sum_assignment +except ImportError: + linear_sum_assignment = None + + +@BBOX_ASSIGNERS.register_module() +class MaskHungarianAssigner(BaseAssigner): + """Computes one-to-one matching between predictions and ground truth for + mask. + + This class computes an assignment between the targets and the predictions + based on the costs. The costs are weighted sum of three components: + classification cost, mask focal cost and mask dice cost. The + targets don't include the no_object, so generally there are more + predictions than targets. After the one-to-one matching, the un-matched + are treated as backgrounds. Thus each query prediction will be assigned + with `0` or a positive integer indicating the ground truth index: + + - 0: negative sample, no assigned gt + - positive integer: positive sample, index (1-based) of assigned gt + + Args: + cls_cost (:obj:`mmcv.ConfigDict` | dict): Classification cost config. + mask_cost (:obj:`mmcv.ConfigDict` | dict): Mask cost config. + dice_cost (:obj:`mmcv.ConfigDict` | dict): Dice cost config. + """ + + def __init__(self, + cls_cost=dict(type='ClassificationCost', weight=1.0), + mask_cost=dict( + type='FocalLossCost', weight=1.0, binary_input=True), + dice_cost=dict(type='DiceCost', weight=1.0)): + self.cls_cost = build_match_cost(cls_cost) + self.mask_cost = build_match_cost(mask_cost) + self.dice_cost = build_match_cost(dice_cost) + + def assign(self, + cls_pred, + mask_pred, + gt_labels, + gt_mask, + img_meta, + gt_bboxes_ignore=None, + eps=1e-7): + """Computes one-to-one matching based on the weighted costs. + + Args: + cls_pred (Tensor | None): Class prediction in shape + (num_query, cls_out_channels). + mask_pred (Tensor): Mask prediction in shape (num_query, H, W). + gt_labels (Tensor): Label of 'gt_mask'in shape = (num_gt, ). + gt_mask (Tensor): Ground truth mask in shape = (num_gt, H, W). + img_meta (dict): Meta information for current image. + gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are + labelled as `ignored`. Default None. + eps (int | float, optional): A value added to the denominator for + numerical stability. Default 1e-7. + + Returns: + :obj:`AssignResult`: The assigned result. + """ + assert gt_bboxes_ignore is None, \ + 'Only case when gt_bboxes_ignore is None is supported.' + # K-Net sometimes passes cls_pred=None to this assigner. + # So we should use the shape of mask_pred + num_gt, num_query = gt_labels.shape[0], mask_pred.shape[0] + + # 1. assign -1 by default + assigned_gt_inds = mask_pred.new_full((num_query, ), + -1, + dtype=torch.long) + assigned_labels = mask_pred.new_full((num_query, ), + -1, + dtype=torch.long) + if num_gt == 0 or num_query == 0: + # No ground truth or boxes, return empty assignment + if num_gt == 0: + # No ground truth, assign all to background + assigned_gt_inds[:] = 0 + return AssignResult( + num_gt, assigned_gt_inds, None, labels=assigned_labels) + + # 2. compute the weighted costs + # classification and maskcost. + if self.cls_cost.weight != 0 and cls_pred is not None: + cls_cost = self.cls_cost(cls_pred, gt_labels) + else: + cls_cost = 0 + + if self.mask_cost.weight != 0: + # mask_pred shape = [num_query, h, w] + # gt_mask shape = [num_gt, h, w] + # mask_cost shape = [num_query, num_gt] + mask_cost = self.mask_cost(mask_pred, gt_mask) + else: + mask_cost = 0 + + if self.dice_cost.weight != 0: + dice_cost = self.dice_cost(mask_pred, gt_mask) + else: + dice_cost = 0 + cost = cls_cost + mask_cost + dice_cost + + # 3. do Hungarian matching on CPU using linear_sum_assignment + cost = cost.detach().cpu() + if linear_sum_assignment is None: + raise ImportError('Please run "pip install scipy" ' + 'to install scipy first.') + + matched_row_inds, matched_col_inds = linear_sum_assignment(cost) + matched_row_inds = torch.from_numpy(matched_row_inds).to( + mask_pred.device) + matched_col_inds = torch.from_numpy(matched_col_inds).to( + mask_pred.device) + + # 4. assign backgrounds and foregrounds + # assign all indices to backgrounds first + assigned_gt_inds[:] = 0 + # assign foregrounds based on matching results + assigned_gt_inds[matched_row_inds] = matched_col_inds + 1 + assigned_labels[matched_row_inds] = gt_labels[matched_col_inds] + return AssignResult( + num_gt, assigned_gt_inds, None, labels=assigned_labels) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/max_iou_assigner.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/max_iou_assigner.py index 93ffc42ca..676421f76 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/max_iou_assigner.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/max_iou_assigner.py @@ -1,19 +1,21 @@ +# Copyright (c) OpenMMLab. All rights reserved. import torch -from ..geometry import bbox_overlaps +from ..builder import BBOX_ASSIGNERS +from ..iou_calculators import build_iou_calculator from .assign_result import AssignResult from .base_assigner import BaseAssigner +@BBOX_ASSIGNERS.register_module() class MaxIoUAssigner(BaseAssigner): """Assign a corresponding gt bbox or background to each bbox. - Each proposals will be assigned with `-1`, `0`, or a positive integer + Each proposals will be assigned with `-1`, or a semi-positive integer indicating the ground truth index. - - -1: don't care - - 0: negative sample, no assigned gt - - positive integer: positive sample, index (1-based) of assigned gt + - -1: negative sample, no assigned gt + - semi-positive integer: positive sample, index (0-based) of assigned gt Args: pos_iou_thr (float): IoU threshold for positive bboxes. @@ -21,6 +23,11 @@ class MaxIoUAssigner(BaseAssigner): min_pos_iou (float): Minimum iou for a bbox to be considered as a positive bbox. Positive samples can have smaller IoU than pos_iou_thr due to the 4th step (assign max IoU sample to each gt). + `min_pos_iou` is set to avoid assigning bboxes that have extremely + small iou with GT as positive samples. It brings about 0.3 mAP + improvements in 1x schedule but does not affect the performance of + 3x schedule. More comparisons can be found in + `PR #7464 `_. gt_max_assign_all (bool): Whether to assign all bboxes with the same highest overlap with some gt to that gt. ignore_iof_thr (float): IoF threshold for ignoring bboxes (if @@ -28,6 +35,9 @@ class MaxIoUAssigner(BaseAssigner): ignoring any bboxes. ignore_wrt_candidates (bool): Whether to compute the iof between `bboxes` and `gt_bboxes_ignore`, or the contrary. + match_low_quality (bool): Whether to allow low quality matches. This is + usually allowed for RPN and single stage detectors, but not allowed + in the second stage. Details are demonstrated in Step 4. gpu_assign_thr (int): The upper bound of the number of GT for GPU assign. When the number of gt is above this threshold, will assign on CPU device. Negative values mean not assign on CPU. @@ -40,7 +50,9 @@ class MaxIoUAssigner(BaseAssigner): gt_max_assign_all=True, ignore_iof_thr=-1, ignore_wrt_candidates=True, - gpu_assign_thr=-1): + match_low_quality=True, + gpu_assign_thr=-1, + iou_calculator=dict(type='BboxOverlaps2D')): self.pos_iou_thr = pos_iou_thr self.neg_iou_thr = neg_iou_thr self.min_pos_iou = min_pos_iou @@ -48,17 +60,18 @@ class MaxIoUAssigner(BaseAssigner): self.ignore_iof_thr = ignore_iof_thr self.ignore_wrt_candidates = ignore_wrt_candidates self.gpu_assign_thr = gpu_assign_thr + self.match_low_quality = match_low_quality + self.iou_calculator = build_iou_calculator(iou_calculator) def assign(self, bboxes, gt_bboxes, gt_bboxes_ignore=None, gt_labels=None): """Assign gt to bboxes. This method assign a gt bbox to every bbox (proposal/anchor), each bbox - will be assigned with -1, 0, or a positive number. -1 means don't care, - 0 means negative sample, positive number is the index (1-based) of - assigned gt. + will be assigned with -1, or a semi-positive number. -1 means negative + sample, semi-positive number is the index (0-based) of assigned gt. The assignment is done in following steps, the order matters. - 1. assign every bbox to -1 + 1. assign every bbox to the background 2. assign proposals whose iou with all gts < neg_iou_thr to 0 3. for each bbox, if the iou with its nearest gt >= pos_iou_thr, assign it to that bbox @@ -95,17 +108,16 @@ class MaxIoUAssigner(BaseAssigner): if gt_labels is not None: gt_labels = gt_labels.cpu() - bboxes = bboxes[:, :4] - overlaps = bbox_overlaps(gt_bboxes, bboxes) + overlaps = self.iou_calculator(gt_bboxes, bboxes) - if (self.ignore_iof_thr > 0) and (gt_bboxes_ignore is not None) and ( - gt_bboxes_ignore.numel() > 0): + if (self.ignore_iof_thr > 0 and gt_bboxes_ignore is not None + and gt_bboxes_ignore.numel() > 0 and bboxes.numel() > 0): if self.ignore_wrt_candidates: - ignore_overlaps = bbox_overlaps( + ignore_overlaps = self.iou_calculator( bboxes, gt_bboxes_ignore, mode='iof') ignore_max_overlaps, _ = ignore_overlaps.max(dim=1) else: - ignore_overlaps = bbox_overlaps( + ignore_overlaps = self.iou_calculator( gt_bboxes_ignore, bboxes, mode='iof') ignore_max_overlaps, _ = ignore_overlaps.max(dim=0) overlaps[:, ignore_max_overlaps > self.ignore_iof_thr] = -1 @@ -145,8 +157,9 @@ class MaxIoUAssigner(BaseAssigner): if gt_labels is None: assigned_labels = None else: - assigned_labels = overlaps.new_zeros((num_bboxes, ), - dtype=torch.long) + assigned_labels = overlaps.new_full((num_bboxes, ), + -1, + dtype=torch.long) return AssignResult( num_gts, assigned_gt_inds, @@ -161,6 +174,7 @@ class MaxIoUAssigner(BaseAssigner): gt_max_overlaps, gt_argmax_overlaps = overlaps.max(dim=1) # 2. assign negative: below + # the negative inds are set to be 0 if isinstance(self.neg_iou_thr, float): assigned_gt_inds[(max_overlaps >= 0) & (max_overlaps < self.neg_iou_thr)] = 0 @@ -173,18 +187,27 @@ class MaxIoUAssigner(BaseAssigner): pos_inds = max_overlaps >= self.pos_iou_thr assigned_gt_inds[pos_inds] = argmax_overlaps[pos_inds] + 1 - # 4. assign fg: for each gt, proposals with highest IoU - for i in range(num_gts): - if gt_max_overlaps[i] >= self.min_pos_iou: - if self.gt_max_assign_all: - max_iou_inds = overlaps[i, :] == gt_max_overlaps[i] - assigned_gt_inds[max_iou_inds] = i + 1 - else: - assigned_gt_inds[gt_argmax_overlaps[i]] = i + 1 + if self.match_low_quality: + # Low-quality matching will overwrite the assigned_gt_inds assigned + # in Step 3. Thus, the assigned gt might not be the best one for + # prediction. + # For example, if bbox A has 0.9 and 0.8 iou with GT bbox 1 & 2, + # bbox 1 will be assigned as the best target for bbox A in step 3. + # However, if GT bbox 2's gt_argmax_overlaps = A, bbox A's + # assigned_gt_inds will be overwritten to be bbox 2. + # This might be the reason that it is not used in ROI Heads. + for i in range(num_gts): + if gt_max_overlaps[i] >= self.min_pos_iou: + if self.gt_max_assign_all: + max_iou_inds = overlaps[i, :] == gt_max_overlaps[i] + assigned_gt_inds[max_iou_inds] = i + 1 + else: + assigned_gt_inds[gt_argmax_overlaps[i]] = i + 1 if gt_labels is not None: - assigned_labels = assigned_gt_inds.new_zeros((num_bboxes, )) - pos_inds = torch.nonzero(assigned_gt_inds > 0).squeeze() + assigned_labels = assigned_gt_inds.new_full((num_bboxes, ), -1) + pos_inds = torch.nonzero( + assigned_gt_inds > 0, as_tuple=False).squeeze() if pos_inds.numel() > 0: assigned_labels[pos_inds] = gt_labels[ assigned_gt_inds[pos_inds] - 1] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/point_assigner.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/point_assigner.py index 263b3096c..b0dc22463 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/point_assigner.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/point_assigner.py @@ -1,9 +1,12 @@ +# Copyright (c) OpenMMLab. All rights reserved. import torch +from ..builder import BBOX_ASSIGNERS from .assign_result import AssignResult from .base_assigner import BaseAssigner +@BBOX_ASSIGNERS.register_module() class PointAssigner(BaseAssigner): """Assign a corresponding gt bbox or background to each point. @@ -12,7 +15,6 @@ class PointAssigner(BaseAssigner): - 0: negative sample, no assigned gt - positive integer: positive sample, index (1-based) of assigned gt - """ def __init__(self, scale=4, pos_num=3): @@ -23,12 +25,12 @@ class PointAssigner(BaseAssigner): """Assign gt to points. This method assign a gt bbox to every points set, each points set - will be assigned with 0, or a positive number. - 0 means negative sample, positive number is the index (1-based) of + will be assigned with the background_label (-1), or a label number. + -1 is background, and semi-positive number is the index (0-based) of assigned gt. The assignment is done in following steps, the order matters. - 1. assign every points to 0 + 1. assign every points to the background_label (-1) 2. A point is assigned to some gt bbox if (i) the point is within the k closest points to the gt bbox (ii) the distance between this point and the gt is smaller than @@ -57,8 +59,9 @@ class PointAssigner(BaseAssigner): if gt_labels is None: assigned_labels = None else: - assigned_labels = points.new_zeros((num_points, ), - dtype=torch.long) + assigned_labels = points.new_full((num_points, ), + -1, + dtype=torch.long) return AssignResult( num_gts, assigned_gt_inds, None, labels=assigned_labels) @@ -118,8 +121,9 @@ class PointAssigner(BaseAssigner): less_than_recorded_index] if gt_labels is not None: - assigned_labels = assigned_gt_inds.new_zeros((num_points, )) - pos_inds = torch.nonzero(assigned_gt_inds > 0).squeeze() + assigned_labels = assigned_gt_inds.new_full((num_points, ), -1) + pos_inds = torch.nonzero( + assigned_gt_inds > 0, as_tuple=False).squeeze() if pos_inds.numel() > 0: assigned_labels[pos_inds] = gt_labels[ assigned_gt_inds[pos_inds] - 1] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/region_assigner.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/region_assigner.py new file mode 100644 index 000000000..1833b8941 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/region_assigner.py @@ -0,0 +1,222 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch + +from mmdet.core import anchor_inside_flags +from ..builder import BBOX_ASSIGNERS +from .assign_result import AssignResult +from .base_assigner import BaseAssigner + + +def calc_region(bbox, ratio, stride, featmap_size=None): + """Calculate region of the box defined by the ratio, the ratio is from the + center of the box to every edge.""" + # project bbox on the feature + f_bbox = bbox / stride + x1 = torch.round((1 - ratio) * f_bbox[0] + ratio * f_bbox[2]) + y1 = torch.round((1 - ratio) * f_bbox[1] + ratio * f_bbox[3]) + x2 = torch.round(ratio * f_bbox[0] + (1 - ratio) * f_bbox[2]) + y2 = torch.round(ratio * f_bbox[1] + (1 - ratio) * f_bbox[3]) + if featmap_size is not None: + x1 = x1.clamp(min=0, max=featmap_size[1]) + y1 = y1.clamp(min=0, max=featmap_size[0]) + x2 = x2.clamp(min=0, max=featmap_size[1]) + y2 = y2.clamp(min=0, max=featmap_size[0]) + return (x1, y1, x2, y2) + + +def anchor_ctr_inside_region_flags(anchors, stride, region): + """Get the flag indicate whether anchor centers are inside regions.""" + x1, y1, x2, y2 = region + f_anchors = anchors / stride + x = (f_anchors[:, 0] + f_anchors[:, 2]) * 0.5 + y = (f_anchors[:, 1] + f_anchors[:, 3]) * 0.5 + flags = (x >= x1) & (x <= x2) & (y >= y1) & (y <= y2) + return flags + + +@BBOX_ASSIGNERS.register_module() +class RegionAssigner(BaseAssigner): + """Assign a corresponding gt bbox or background to each bbox. + + Each proposals will be assigned with `-1`, `0`, or a positive integer + indicating the ground truth index. + + - -1: don't care + - 0: negative sample, no assigned gt + - positive integer: positive sample, index (1-based) of assigned gt + + Args: + center_ratio: ratio of the region in the center of the bbox to + define positive sample. + ignore_ratio: ratio of the region to define ignore samples. + """ + + def __init__(self, center_ratio=0.2, ignore_ratio=0.5): + self.center_ratio = center_ratio + self.ignore_ratio = ignore_ratio + + def assign(self, + mlvl_anchors, + mlvl_valid_flags, + gt_bboxes, + img_meta, + featmap_sizes, + anchor_scale, + anchor_strides, + gt_bboxes_ignore=None, + gt_labels=None, + allowed_border=0): + """Assign gt to anchors. + + This method assign a gt bbox to every bbox (proposal/anchor), each bbox + will be assigned with -1, 0, or a positive number. -1 means don't care, + 0 means negative sample, positive number is the index (1-based) of + assigned gt. + + The assignment is done in following steps, and the order matters. + + 1. Assign every anchor to 0 (negative) + 2. (For each gt_bboxes) Compute ignore flags based on ignore_region + then assign -1 to anchors w.r.t. ignore flags + 3. (For each gt_bboxes) Compute pos flags based on center_region then + assign gt_bboxes to anchors w.r.t. pos flags + 4. (For each gt_bboxes) Compute ignore flags based on adjacent anchor + level then assign -1 to anchors w.r.t. ignore flags + 5. Assign anchor outside of image to -1 + + Args: + mlvl_anchors (list[Tensor]): Multi level anchors. + mlvl_valid_flags (list[Tensor]): Multi level valid flags. + gt_bboxes (Tensor): Ground truth bboxes of image + img_meta (dict): Meta info of image. + featmap_sizes (list[Tensor]): Feature mapsize each level + anchor_scale (int): Scale of the anchor. + anchor_strides (list[int]): Stride of the anchor. + gt_bboxes (Tensor): Groundtruth boxes, shape (k, 4). + gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are + labelled as `ignored`, e.g., crowd boxes in COCO. + gt_labels (Tensor, optional): Label of gt_bboxes, shape (k, ). + allowed_border (int, optional): The border to allow the valid + anchor. Defaults to 0. + + Returns: + :obj:`AssignResult`: The assign result. + """ + if gt_bboxes_ignore is not None: + raise NotImplementedError + + num_gts = gt_bboxes.shape[0] + num_bboxes = sum(x.shape[0] for x in mlvl_anchors) + + if num_gts == 0 or num_bboxes == 0: + # No ground truth or boxes, return empty assignment + max_overlaps = gt_bboxes.new_zeros((num_bboxes, )) + assigned_gt_inds = gt_bboxes.new_zeros((num_bboxes, ), + dtype=torch.long) + if gt_labels is None: + assigned_labels = None + else: + assigned_labels = gt_bboxes.new_full((num_bboxes, ), + -1, + dtype=torch.long) + return AssignResult( + num_gts, + assigned_gt_inds, + max_overlaps, + labels=assigned_labels) + + num_lvls = len(mlvl_anchors) + r1 = (1 - self.center_ratio) / 2 + r2 = (1 - self.ignore_ratio) / 2 + + scale = torch.sqrt((gt_bboxes[:, 2] - gt_bboxes[:, 0]) * + (gt_bboxes[:, 3] - gt_bboxes[:, 1])) + min_anchor_size = scale.new_full( + (1, ), float(anchor_scale * anchor_strides[0])) + target_lvls = torch.floor( + torch.log2(scale) - torch.log2(min_anchor_size) + 0.5) + target_lvls = target_lvls.clamp(min=0, max=num_lvls - 1).long() + + # 1. assign 0 (negative) by default + mlvl_assigned_gt_inds = [] + mlvl_ignore_flags = [] + for lvl in range(num_lvls): + h, w = featmap_sizes[lvl] + assert h * w == mlvl_anchors[lvl].shape[0] + assigned_gt_inds = gt_bboxes.new_full((h * w, ), + 0, + dtype=torch.long) + ignore_flags = torch.zeros_like(assigned_gt_inds) + mlvl_assigned_gt_inds.append(assigned_gt_inds) + mlvl_ignore_flags.append(ignore_flags) + + for gt_id in range(num_gts): + lvl = target_lvls[gt_id].item() + featmap_size = featmap_sizes[lvl] + stride = anchor_strides[lvl] + anchors = mlvl_anchors[lvl] + gt_bbox = gt_bboxes[gt_id, :4] + + # Compute regions + ignore_region = calc_region(gt_bbox, r2, stride, featmap_size) + ctr_region = calc_region(gt_bbox, r1, stride, featmap_size) + + # 2. Assign -1 to ignore flags + ignore_flags = anchor_ctr_inside_region_flags( + anchors, stride, ignore_region) + mlvl_assigned_gt_inds[lvl][ignore_flags] = -1 + + # 3. Assign gt_bboxes to pos flags + pos_flags = anchor_ctr_inside_region_flags(anchors, stride, + ctr_region) + mlvl_assigned_gt_inds[lvl][pos_flags] = gt_id + 1 + + # 4. Assign -1 to ignore adjacent lvl + if lvl > 0: + d_lvl = lvl - 1 + d_anchors = mlvl_anchors[d_lvl] + d_featmap_size = featmap_sizes[d_lvl] + d_stride = anchor_strides[d_lvl] + d_ignore_region = calc_region(gt_bbox, r2, d_stride, + d_featmap_size) + ignore_flags = anchor_ctr_inside_region_flags( + d_anchors, d_stride, d_ignore_region) + mlvl_ignore_flags[d_lvl][ignore_flags] = 1 + if lvl < num_lvls - 1: + u_lvl = lvl + 1 + u_anchors = mlvl_anchors[u_lvl] + u_featmap_size = featmap_sizes[u_lvl] + u_stride = anchor_strides[u_lvl] + u_ignore_region = calc_region(gt_bbox, r2, u_stride, + u_featmap_size) + ignore_flags = anchor_ctr_inside_region_flags( + u_anchors, u_stride, u_ignore_region) + mlvl_ignore_flags[u_lvl][ignore_flags] = 1 + + # 4. (cont.) Assign -1 to ignore adjacent lvl + for lvl in range(num_lvls): + ignore_flags = mlvl_ignore_flags[lvl] + mlvl_assigned_gt_inds[lvl][ignore_flags] = -1 + + # 5. Assign -1 to anchor outside of image + flat_assigned_gt_inds = torch.cat(mlvl_assigned_gt_inds) + flat_anchors = torch.cat(mlvl_anchors) + flat_valid_flags = torch.cat(mlvl_valid_flags) + assert (flat_assigned_gt_inds.shape[0] == flat_anchors.shape[0] == + flat_valid_flags.shape[0]) + inside_flags = anchor_inside_flags(flat_anchors, flat_valid_flags, + img_meta['img_shape'], + allowed_border) + outside_flags = ~inside_flags + flat_assigned_gt_inds[outside_flags] = -1 + + if gt_labels is not None: + assigned_labels = torch.zeros_like(flat_assigned_gt_inds) + pos_flags = assigned_gt_inds > 0 + assigned_labels[pos_flags] = gt_labels[ + flat_assigned_gt_inds[pos_flags] - 1] + else: + assigned_labels = None + + return AssignResult( + num_gts, flat_assigned_gt_inds, None, labels=assigned_labels) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/sim_ota_assigner.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/sim_ota_assigner.py new file mode 100644 index 000000000..58bfef433 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/sim_ota_assigner.py @@ -0,0 +1,257 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import warnings + +import torch +import torch.nn.functional as F + +from ..builder import BBOX_ASSIGNERS +from ..iou_calculators import bbox_overlaps +from .assign_result import AssignResult +from .base_assigner import BaseAssigner + + +@BBOX_ASSIGNERS.register_module() +class SimOTAAssigner(BaseAssigner): + """Computes matching between predictions and ground truth. + + Args: + center_radius (int | float, optional): Ground truth center size + to judge whether a prior is in center. Default 2.5. + candidate_topk (int, optional): The candidate top-k which used to + get top-k ious to calculate dynamic-k. Default 10. + iou_weight (int | float, optional): The scale factor for regression + iou cost. Default 3.0. + cls_weight (int | float, optional): The scale factor for classification + cost. Default 1.0. + """ + + def __init__(self, + center_radius=2.5, + candidate_topk=10, + iou_weight=3.0, + cls_weight=1.0): + self.center_radius = center_radius + self.candidate_topk = candidate_topk + self.iou_weight = iou_weight + self.cls_weight = cls_weight + + def assign(self, + pred_scores, + priors, + decoded_bboxes, + gt_bboxes, + gt_labels, + gt_bboxes_ignore=None, + eps=1e-7): + """Assign gt to priors using SimOTA. It will switch to CPU mode when + GPU is out of memory. + Args: + pred_scores (Tensor): Classification scores of one image, + a 2D-Tensor with shape [num_priors, num_classes] + priors (Tensor): All priors of one image, a 2D-Tensor with shape + [num_priors, 4] in [cx, xy, stride_w, stride_y] format. + decoded_bboxes (Tensor): Predicted bboxes, a 2D-Tensor with shape + [num_priors, 4] in [tl_x, tl_y, br_x, br_y] format. + gt_bboxes (Tensor): Ground truth bboxes of one image, a 2D-Tensor + with shape [num_gts, 4] in [tl_x, tl_y, br_x, br_y] format. + gt_labels (Tensor): Ground truth labels of one image, a Tensor + with shape [num_gts]. + gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are + labelled as `ignored`, e.g., crowd boxes in COCO. + eps (float): A value added to the denominator for numerical + stability. Default 1e-7. + Returns: + assign_result (obj:`AssignResult`): The assigned result. + """ + try: + assign_result = self._assign(pred_scores, priors, decoded_bboxes, + gt_bboxes, gt_labels, + gt_bboxes_ignore, eps) + return assign_result + except RuntimeError: + origin_device = pred_scores.device + warnings.warn('OOM RuntimeError is raised due to the huge memory ' + 'cost during label assignment. CPU mode is applied ' + 'in this batch. If you want to avoid this issue, ' + 'try to reduce the batch size or image size.') + torch.cuda.empty_cache() + + pred_scores = pred_scores.cpu() + priors = priors.cpu() + decoded_bboxes = decoded_bboxes.cpu() + gt_bboxes = gt_bboxes.cpu().float() + gt_labels = gt_labels.cpu() + + assign_result = self._assign(pred_scores, priors, decoded_bboxes, + gt_bboxes, gt_labels, + gt_bboxes_ignore, eps) + assign_result.gt_inds = assign_result.gt_inds.to(origin_device) + assign_result.max_overlaps = assign_result.max_overlaps.to( + origin_device) + assign_result.labels = assign_result.labels.to(origin_device) + + return assign_result + + def _assign(self, + pred_scores, + priors, + decoded_bboxes, + gt_bboxes, + gt_labels, + gt_bboxes_ignore=None, + eps=1e-7): + """Assign gt to priors using SimOTA. + Args: + pred_scores (Tensor): Classification scores of one image, + a 2D-Tensor with shape [num_priors, num_classes] + priors (Tensor): All priors of one image, a 2D-Tensor with shape + [num_priors, 4] in [cx, xy, stride_w, stride_y] format. + decoded_bboxes (Tensor): Predicted bboxes, a 2D-Tensor with shape + [num_priors, 4] in [tl_x, tl_y, br_x, br_y] format. + gt_bboxes (Tensor): Ground truth bboxes of one image, a 2D-Tensor + with shape [num_gts, 4] in [tl_x, tl_y, br_x, br_y] format. + gt_labels (Tensor): Ground truth labels of one image, a Tensor + with shape [num_gts]. + gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are + labelled as `ignored`, e.g., crowd boxes in COCO. + eps (float): A value added to the denominator for numerical + stability. Default 1e-7. + Returns: + :obj:`AssignResult`: The assigned result. + """ + INF = 100000.0 + num_gt = gt_bboxes.size(0) + num_bboxes = decoded_bboxes.size(0) + + # assign 0 by default + assigned_gt_inds = decoded_bboxes.new_full((num_bboxes, ), + 0, + dtype=torch.long) + valid_mask, is_in_boxes_and_center = self.get_in_gt_and_in_center_info( + priors, gt_bboxes) + valid_decoded_bbox = decoded_bboxes[valid_mask] + valid_pred_scores = pred_scores[valid_mask] + num_valid = valid_decoded_bbox.size(0) + + if num_gt == 0 or num_bboxes == 0 or num_valid == 0: + # No ground truth or boxes, return empty assignment + max_overlaps = decoded_bboxes.new_zeros((num_bboxes, )) + if num_gt == 0: + # No truth, assign everything to background + assigned_gt_inds[:] = 0 + if gt_labels is None: + assigned_labels = None + else: + assigned_labels = decoded_bboxes.new_full((num_bboxes, ), + -1, + dtype=torch.long) + return AssignResult( + num_gt, assigned_gt_inds, max_overlaps, labels=assigned_labels) + + pairwise_ious = bbox_overlaps(valid_decoded_bbox, gt_bboxes) + iou_cost = -torch.log(pairwise_ious + eps) + + gt_onehot_label = ( + F.one_hot(gt_labels.to(torch.int64), + pred_scores.shape[-1]).float().unsqueeze(0).repeat( + num_valid, 1, 1)) + + valid_pred_scores = valid_pred_scores.unsqueeze(1).repeat(1, num_gt, 1) + cls_cost = ( + F.binary_cross_entropy( + valid_pred_scores.to(dtype=torch.float32).sqrt_(), + gt_onehot_label, + reduction='none', + ).sum(-1).to(dtype=valid_pred_scores.dtype)) + + cost_matrix = ( + cls_cost * self.cls_weight + iou_cost * self.iou_weight + + (~is_in_boxes_and_center) * INF) + + matched_pred_ious, matched_gt_inds = \ + self.dynamic_k_matching( + cost_matrix, pairwise_ious, num_gt, valid_mask) + + # convert to AssignResult format + assigned_gt_inds[valid_mask] = matched_gt_inds + 1 + assigned_labels = assigned_gt_inds.new_full((num_bboxes, ), -1) + assigned_labels[valid_mask] = gt_labels[matched_gt_inds].long() + max_overlaps = assigned_gt_inds.new_full((num_bboxes, ), + -INF, + dtype=torch.float32) + max_overlaps[valid_mask] = matched_pred_ious + return AssignResult( + num_gt, assigned_gt_inds, max_overlaps, labels=assigned_labels) + + def get_in_gt_and_in_center_info(self, priors, gt_bboxes): + num_gt = gt_bboxes.size(0) + + repeated_x = priors[:, 0].unsqueeze(1).repeat(1, num_gt) + repeated_y = priors[:, 1].unsqueeze(1).repeat(1, num_gt) + repeated_stride_x = priors[:, 2].unsqueeze(1).repeat(1, num_gt) + repeated_stride_y = priors[:, 3].unsqueeze(1).repeat(1, num_gt) + + # is prior centers in gt bboxes, shape: [n_prior, n_gt] + l_ = repeated_x - gt_bboxes[:, 0] + t_ = repeated_y - gt_bboxes[:, 1] + r_ = gt_bboxes[:, 2] - repeated_x + b_ = gt_bboxes[:, 3] - repeated_y + + deltas = torch.stack([l_, t_, r_, b_], dim=1) + is_in_gts = deltas.min(dim=1).values > 0 + is_in_gts_all = is_in_gts.sum(dim=1) > 0 + + # is prior centers in gt centers + gt_cxs = (gt_bboxes[:, 0] + gt_bboxes[:, 2]) / 2.0 + gt_cys = (gt_bboxes[:, 1] + gt_bboxes[:, 3]) / 2.0 + ct_box_l = gt_cxs - self.center_radius * repeated_stride_x + ct_box_t = gt_cys - self.center_radius * repeated_stride_y + ct_box_r = gt_cxs + self.center_radius * repeated_stride_x + ct_box_b = gt_cys + self.center_radius * repeated_stride_y + + cl_ = repeated_x - ct_box_l + ct_ = repeated_y - ct_box_t + cr_ = ct_box_r - repeated_x + cb_ = ct_box_b - repeated_y + + ct_deltas = torch.stack([cl_, ct_, cr_, cb_], dim=1) + is_in_cts = ct_deltas.min(dim=1).values > 0 + is_in_cts_all = is_in_cts.sum(dim=1) > 0 + + # in boxes or in centers, shape: [num_priors] + is_in_gts_or_centers = is_in_gts_all | is_in_cts_all + + # both in boxes and centers, shape: [num_fg, num_gt] + is_in_boxes_and_centers = ( + is_in_gts[is_in_gts_or_centers, :] + & is_in_cts[is_in_gts_or_centers, :]) + return is_in_gts_or_centers, is_in_boxes_and_centers + + def dynamic_k_matching(self, cost, pairwise_ious, num_gt, valid_mask): + matching_matrix = torch.zeros_like(cost, dtype=torch.uint8) + # select candidate topk ious for dynamic-k calculation + candidate_topk = min(self.candidate_topk, pairwise_ious.size(0)) + topk_ious, _ = torch.topk(pairwise_ious, candidate_topk, dim=0) + # calculate dynamic k for each gt + dynamic_ks = torch.clamp(topk_ious.sum(0).int(), min=1) + for gt_idx in range(num_gt): + _, pos_idx = torch.topk( + cost[:, gt_idx], k=dynamic_ks[gt_idx], largest=False) + matching_matrix[:, gt_idx][pos_idx] = 1 + + del topk_ious, dynamic_ks, pos_idx + + prior_match_gt_mask = matching_matrix.sum(1) > 1 + if prior_match_gt_mask.sum() > 0: + cost_min, cost_argmin = torch.min( + cost[prior_match_gt_mask, :], dim=1) + matching_matrix[prior_match_gt_mask, :] *= 0 + matching_matrix[prior_match_gt_mask, cost_argmin] = 1 + # get foreground mask inside box and center prior + fg_mask_inboxes = matching_matrix.sum(1) > 0 + valid_mask[valid_mask.clone()] = fg_mask_inboxes + + matched_gt_inds = matching_matrix[fg_mask_inboxes, :].argmax(1) + matched_pred_ious = (matching_matrix * + pairwise_ious).sum(1)[fg_mask_inboxes] + return matched_pred_ious, matched_gt_inds diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/task_aligned_assigner.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/task_aligned_assigner.py new file mode 100644 index 000000000..1872de4a7 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/task_aligned_assigner.py @@ -0,0 +1,151 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch + +from ..builder import BBOX_ASSIGNERS +from ..iou_calculators import build_iou_calculator +from .assign_result import AssignResult +from .base_assigner import BaseAssigner + +INF = 100000000 + + +@BBOX_ASSIGNERS.register_module() +class TaskAlignedAssigner(BaseAssigner): + """Task aligned assigner used in the paper: + `TOOD: Task-aligned One-stage Object Detection. + `_. + + Assign a corresponding gt bbox or background to each predicted bbox. + Each bbox will be assigned with `0` or a positive integer + indicating the ground truth index. + + - 0: negative sample, no assigned gt + - positive integer: positive sample, index (1-based) of assigned gt + + Args: + topk (int): number of bbox selected in each level + iou_calculator (dict): Config dict for iou calculator. + Default: dict(type='BboxOverlaps2D') + """ + + def __init__(self, topk, iou_calculator=dict(type='BboxOverlaps2D')): + assert topk >= 1 + self.topk = topk + self.iou_calculator = build_iou_calculator(iou_calculator) + + def assign(self, + pred_scores, + decode_bboxes, + anchors, + gt_bboxes, + gt_bboxes_ignore=None, + gt_labels=None, + alpha=1, + beta=6): + """Assign gt to bboxes. + + The assignment is done in following steps + + 1. compute alignment metric between all bbox (bbox of all pyramid + levels) and gt + 2. select top-k bbox as candidates for each gt + 3. limit the positive sample's center in gt (because the anchor-free + detector only can predict positive distance) + + + Args: + pred_scores (Tensor): predicted class probability, + shape(n, num_classes) + decode_bboxes (Tensor): predicted bounding boxes, shape(n, 4) + anchors (Tensor): pre-defined anchors, shape(n, 4). + gt_bboxes (Tensor): Groundtruth boxes, shape (k, 4). + gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are + labelled as `ignored`, e.g., crowd boxes in COCO. + gt_labels (Tensor, optional): Label of gt_bboxes, shape (k, ). + + Returns: + :obj:`TaskAlignedAssignResult`: The assign result. + """ + anchors = anchors[:, :4] + num_gt, num_bboxes = gt_bboxes.size(0), anchors.size(0) + # compute alignment metric between all bbox and gt + overlaps = self.iou_calculator(decode_bboxes, gt_bboxes).detach() + bbox_scores = pred_scores[:, gt_labels].detach() + # assign 0 by default + assigned_gt_inds = anchors.new_full((num_bboxes, ), + 0, + dtype=torch.long) + assign_metrics = anchors.new_zeros((num_bboxes, )) + + if num_gt == 0 or num_bboxes == 0: + # No ground truth or boxes, return empty assignment + max_overlaps = anchors.new_zeros((num_bboxes, )) + if num_gt == 0: + # No gt boxes, assign everything to background + assigned_gt_inds[:] = 0 + if gt_labels is None: + assigned_labels = None + else: + assigned_labels = anchors.new_full((num_bboxes, ), + -1, + dtype=torch.long) + assign_result = AssignResult( + num_gt, assigned_gt_inds, max_overlaps, labels=assigned_labels) + assign_result.assign_metrics = assign_metrics + return assign_result + + # select top-k bboxes as candidates for each gt + alignment_metrics = bbox_scores**alpha * overlaps**beta + topk = min(self.topk, alignment_metrics.size(0)) + _, candidate_idxs = alignment_metrics.topk(topk, dim=0, largest=True) + candidate_metrics = alignment_metrics[candidate_idxs, + torch.arange(num_gt)] + is_pos = candidate_metrics > 0 + + # limit the positive sample's center in gt + anchors_cx = (anchors[:, 0] + anchors[:, 2]) / 2.0 + anchors_cy = (anchors[:, 1] + anchors[:, 3]) / 2.0 + for gt_idx in range(num_gt): + candidate_idxs[:, gt_idx] += gt_idx * num_bboxes + ep_anchors_cx = anchors_cx.view(1, -1).expand( + num_gt, num_bboxes).contiguous().view(-1) + ep_anchors_cy = anchors_cy.view(1, -1).expand( + num_gt, num_bboxes).contiguous().view(-1) + candidate_idxs = candidate_idxs.view(-1) + + # calculate the left, top, right, bottom distance between positive + # bbox center and gt side + l_ = ep_anchors_cx[candidate_idxs].view(-1, num_gt) - gt_bboxes[:, 0] + t_ = ep_anchors_cy[candidate_idxs].view(-1, num_gt) - gt_bboxes[:, 1] + r_ = gt_bboxes[:, 2] - ep_anchors_cx[candidate_idxs].view(-1, num_gt) + b_ = gt_bboxes[:, 3] - ep_anchors_cy[candidate_idxs].view(-1, num_gt) + is_in_gts = torch.stack([l_, t_, r_, b_], dim=1).min(dim=1)[0] > 0.01 + is_pos = is_pos & is_in_gts + + # if an anchor box is assigned to multiple gts, + # the one with the highest iou will be selected. + overlaps_inf = torch.full_like(overlaps, + -INF).t().contiguous().view(-1) + index = candidate_idxs.view(-1)[is_pos.view(-1)] + overlaps_inf[index] = overlaps.t().contiguous().view(-1)[index] + overlaps_inf = overlaps_inf.view(num_gt, -1).t() + + max_overlaps, argmax_overlaps = overlaps_inf.max(dim=1) + assigned_gt_inds[ + max_overlaps != -INF] = argmax_overlaps[max_overlaps != -INF] + 1 + assign_metrics[max_overlaps != -INF] = alignment_metrics[ + max_overlaps != -INF, argmax_overlaps[max_overlaps != -INF]] + + if gt_labels is not None: + assigned_labels = assigned_gt_inds.new_full((num_bboxes, ), -1) + pos_inds = torch.nonzero( + assigned_gt_inds > 0, as_tuple=False).squeeze() + if pos_inds.numel() > 0: + assigned_labels[pos_inds] = gt_labels[ + assigned_gt_inds[pos_inds] - 1] + else: + assigned_labels = None + assign_result = AssignResult( + num_gt, assigned_gt_inds, max_overlaps, labels=assigned_labels) + assign_result.assign_metrics = assign_metrics + return assign_result diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/uniform_assigner.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/uniform_assigner.py new file mode 100644 index 000000000..70294fc45 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/assigners/uniform_assigner.py @@ -0,0 +1,135 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch + +from ..builder import BBOX_ASSIGNERS +from ..iou_calculators import build_iou_calculator +from ..transforms import bbox_xyxy_to_cxcywh +from .assign_result import AssignResult +from .base_assigner import BaseAssigner + + +@BBOX_ASSIGNERS.register_module() +class UniformAssigner(BaseAssigner): + """Uniform Matching between the anchors and gt boxes, which can achieve + balance in positive anchors, and gt_bboxes_ignore was not considered for + now. + + Args: + pos_ignore_thr (float): the threshold to ignore positive anchors + neg_ignore_thr (float): the threshold to ignore negative anchors + match_times(int): Number of positive anchors for each gt box. + Default 4. + iou_calculator (dict): iou_calculator config + """ + + def __init__(self, + pos_ignore_thr, + neg_ignore_thr, + match_times=4, + iou_calculator=dict(type='BboxOverlaps2D')): + self.match_times = match_times + self.pos_ignore_thr = pos_ignore_thr + self.neg_ignore_thr = neg_ignore_thr + self.iou_calculator = build_iou_calculator(iou_calculator) + + def assign(self, + bbox_pred, + anchor, + gt_bboxes, + gt_bboxes_ignore=None, + gt_labels=None): + num_gts, num_bboxes = gt_bboxes.size(0), bbox_pred.size(0) + + # 1. assign -1 by default + assigned_gt_inds = bbox_pred.new_full((num_bboxes, ), + 0, + dtype=torch.long) + assigned_labels = bbox_pred.new_full((num_bboxes, ), + -1, + dtype=torch.long) + if num_gts == 0 or num_bboxes == 0: + # No ground truth or boxes, return empty assignment + if num_gts == 0: + # No ground truth, assign all to background + assigned_gt_inds[:] = 0 + assign_result = AssignResult( + num_gts, assigned_gt_inds, None, labels=assigned_labels) + assign_result.set_extra_property( + 'pos_idx', bbox_pred.new_empty(0, dtype=torch.bool)) + assign_result.set_extra_property('pos_predicted_boxes', + bbox_pred.new_empty((0, 4))) + assign_result.set_extra_property('target_boxes', + bbox_pred.new_empty((0, 4))) + return assign_result + + # 2. Compute the L1 cost between boxes + # Note that we use anchors and predict boxes both + cost_bbox = torch.cdist( + bbox_xyxy_to_cxcywh(bbox_pred), + bbox_xyxy_to_cxcywh(gt_bboxes), + p=1) + cost_bbox_anchors = torch.cdist( + bbox_xyxy_to_cxcywh(anchor), bbox_xyxy_to_cxcywh(gt_bboxes), p=1) + + # We found that topk function has different results in cpu and + # cuda mode. In order to ensure consistency with the source code, + # we also use cpu mode. + # TODO: Check whether the performance of cpu and cuda are the same. + C = cost_bbox.cpu() + C1 = cost_bbox_anchors.cpu() + + # self.match_times x n + index = torch.topk( + C, # c=b,n,x c[i]=n,x + k=self.match_times, + dim=0, + largest=False)[1] + + # self.match_times x n + index1 = torch.topk(C1, k=self.match_times, dim=0, largest=False)[1] + # (self.match_times*2) x n + indexes = torch.cat((index, index1), + dim=1).reshape(-1).to(bbox_pred.device) + + pred_overlaps = self.iou_calculator(bbox_pred, gt_bboxes) + anchor_overlaps = self.iou_calculator(anchor, gt_bboxes) + pred_max_overlaps, _ = pred_overlaps.max(dim=1) + anchor_max_overlaps, _ = anchor_overlaps.max(dim=0) + + # 3. Compute the ignore indexes use gt_bboxes and predict boxes + ignore_idx = pred_max_overlaps > self.neg_ignore_thr + assigned_gt_inds[ignore_idx] = -1 + + # 4. Compute the ignore indexes of positive sample use anchors + # and predict boxes + pos_gt_index = torch.arange( + 0, C1.size(1), + device=bbox_pred.device).repeat(self.match_times * 2) + pos_ious = anchor_overlaps[indexes, pos_gt_index] + pos_ignore_idx = pos_ious < self.pos_ignore_thr + + pos_gt_index_with_ignore = pos_gt_index + 1 + pos_gt_index_with_ignore[pos_ignore_idx] = -1 + assigned_gt_inds[indexes] = pos_gt_index_with_ignore + + if gt_labels is not None: + assigned_labels = assigned_gt_inds.new_full((num_bboxes, ), -1) + pos_inds = torch.nonzero( + assigned_gt_inds > 0, as_tuple=False).squeeze() + if pos_inds.numel() > 0: + assigned_labels[pos_inds] = gt_labels[ + assigned_gt_inds[pos_inds] - 1] + else: + assigned_labels = None + + assign_result = AssignResult( + num_gts, + assigned_gt_inds, + anchor_max_overlaps, + labels=assigned_labels) + assign_result.set_extra_property('pos_idx', ~pos_ignore_idx) + assign_result.set_extra_property('pos_predicted_boxes', + bbox_pred[indexes]) + assign_result.set_extra_property('target_boxes', + gt_bboxes[pos_gt_index]) + return assign_result diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/bbox_target.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/bbox_target.py deleted file mode 100644 index 2a918bf87..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/bbox_target.py +++ /dev/null @@ -1,73 +0,0 @@ -import torch - -from ..utils import multi_apply -from .transforms import bbox2delta - - -def bbox_target(pos_bboxes_list, - neg_bboxes_list, - pos_gt_bboxes_list, - pos_gt_labels_list, - cfg, - reg_classes=1, - target_means=[.0, .0, .0, .0], - target_stds=[1.0, 1.0, 1.0, 1.0], - concat=True): - labels, label_weights, bbox_targets, bbox_weights = multi_apply( - bbox_target_single, - pos_bboxes_list, - neg_bboxes_list, - pos_gt_bboxes_list, - pos_gt_labels_list, - cfg=cfg, - reg_classes=reg_classes, - target_means=target_means, - target_stds=target_stds) - - if concat: - labels = torch.cat(labels, 0) - label_weights = torch.cat(label_weights, 0) - bbox_targets = torch.cat(bbox_targets, 0) - bbox_weights = torch.cat(bbox_weights, 0) - return labels, label_weights, bbox_targets, bbox_weights - - -def bbox_target_single(pos_bboxes, - neg_bboxes, - pos_gt_bboxes, - pos_gt_labels, - cfg, - reg_classes=1, - target_means=[.0, .0, .0, .0], - target_stds=[1.0, 1.0, 1.0, 1.0]): - num_pos = pos_bboxes.size(0) - num_neg = neg_bboxes.size(0) - num_samples = num_pos + num_neg - labels = pos_bboxes.new_zeros(num_samples, dtype=torch.long) - label_weights = pos_bboxes.new_zeros(num_samples) - bbox_targets = pos_bboxes.new_zeros(num_samples, 4) - bbox_weights = pos_bboxes.new_zeros(num_samples, 4) - if num_pos > 0: - labels[:num_pos] = pos_gt_labels - pos_weight = 1.0 if cfg.pos_weight <= 0 else cfg.pos_weight - label_weights[:num_pos] = pos_weight - pos_bbox_targets = bbox2delta(pos_bboxes, pos_gt_bboxes, target_means, - target_stds) - bbox_targets[:num_pos, :] = pos_bbox_targets - bbox_weights[:num_pos, :] = 1 - if num_neg > 0: - label_weights[-num_neg:] = 1.0 - - return labels, label_weights, bbox_targets, bbox_weights - - -def expand_target(bbox_targets, bbox_weights, labels, num_classes): - bbox_targets_expand = bbox_targets.new_zeros( - (bbox_targets.size(0), 4 * num_classes)) - bbox_weights_expand = bbox_weights.new_zeros( - (bbox_weights.size(0), 4 * num_classes)) - for i in torch.nonzero(labels > 0).squeeze(-1): - start, end = labels[i] * 4, (labels[i] + 1) * 4 - bbox_targets_expand[i, start:end] = bbox_targets[i, :] - bbox_weights_expand[i, start:end] = bbox_weights[i, :] - return bbox_targets_expand, bbox_weights_expand diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/builder.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/builder.py new file mode 100644 index 000000000..9cfa055b5 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/builder.py @@ -0,0 +1,21 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from mmcv.utils import Registry, build_from_cfg + +BBOX_ASSIGNERS = Registry('bbox_assigner') +BBOX_SAMPLERS = Registry('bbox_sampler') +BBOX_CODERS = Registry('bbox_coder') + + +def build_assigner(cfg, **default_args): + """Builder of box assigner.""" + return build_from_cfg(cfg, BBOX_ASSIGNERS, default_args) + + +def build_sampler(cfg, **default_args): + """Builder of box sampler.""" + return build_from_cfg(cfg, BBOX_SAMPLERS, default_args) + + +def build_bbox_coder(cfg, **default_args): + """Builder of box coder.""" + return build_from_cfg(cfg, BBOX_CODERS, default_args) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/__init__.py new file mode 100644 index 000000000..e12fd64e1 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/__init__.py @@ -0,0 +1,15 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .base_bbox_coder import BaseBBoxCoder +from .bucketing_bbox_coder import BucketingBBoxCoder +from .delta_xywh_bbox_coder import DeltaXYWHBBoxCoder +from .distance_point_bbox_coder import DistancePointBBoxCoder +from .legacy_delta_xywh_bbox_coder import LegacyDeltaXYWHBBoxCoder +from .pseudo_bbox_coder import PseudoBBoxCoder +from .tblr_bbox_coder import TBLRBBoxCoder +from .yolo_bbox_coder import YOLOBBoxCoder + +__all__ = [ + 'BaseBBoxCoder', 'PseudoBBoxCoder', 'DeltaXYWHBBoxCoder', + 'LegacyDeltaXYWHBBoxCoder', 'TBLRBBoxCoder', 'YOLOBBoxCoder', + 'BucketingBBoxCoder', 'DistancePointBBoxCoder' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/base_bbox_coder.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/base_bbox_coder.py new file mode 100644 index 000000000..a7ed041a4 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/base_bbox_coder.py @@ -0,0 +1,18 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from abc import ABCMeta, abstractmethod + + +class BaseBBoxCoder(metaclass=ABCMeta): + """Base bounding box coder.""" + + def __init__(self, **kwargs): + pass + + @abstractmethod + def encode(self, bboxes, gt_bboxes): + """Encode deltas between bboxes and ground truth boxes.""" + + @abstractmethod + def decode(self, bboxes, bboxes_pred): + """Decode the predicted bboxes according to prediction and base + boxes.""" diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/bucketing_bbox_coder.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/bucketing_bbox_coder.py new file mode 100644 index 000000000..4be0ada04 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/bucketing_bbox_coder.py @@ -0,0 +1,351 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import mmcv +import numpy as np +import torch +import torch.nn.functional as F + +from ..builder import BBOX_CODERS +from ..transforms import bbox_rescale +from .base_bbox_coder import BaseBBoxCoder + + +@BBOX_CODERS.register_module() +class BucketingBBoxCoder(BaseBBoxCoder): + """Bucketing BBox Coder for Side-Aware Boundary Localization (SABL). + + Boundary Localization with Bucketing and Bucketing Guided Rescoring + are implemented here. + + Please refer to https://arxiv.org/abs/1912.04260 for more details. + + Args: + num_buckets (int): Number of buckets. + scale_factor (int): Scale factor of proposals to generate buckets. + offset_topk (int): Topk buckets are used to generate + bucket fine regression targets. Defaults to 2. + offset_upperbound (float): Offset upperbound to generate + bucket fine regression targets. + To avoid too large offset displacements. Defaults to 1.0. + cls_ignore_neighbor (bool): Ignore second nearest bucket or Not. + Defaults to True. + clip_border (bool, optional): Whether clip the objects outside the + border of the image. Defaults to True. + """ + + def __init__(self, + num_buckets, + scale_factor, + offset_topk=2, + offset_upperbound=1.0, + cls_ignore_neighbor=True, + clip_border=True): + super(BucketingBBoxCoder, self).__init__() + self.num_buckets = num_buckets + self.scale_factor = scale_factor + self.offset_topk = offset_topk + self.offset_upperbound = offset_upperbound + self.cls_ignore_neighbor = cls_ignore_neighbor + self.clip_border = clip_border + + def encode(self, bboxes, gt_bboxes): + """Get bucketing estimation and fine regression targets during + training. + + Args: + bboxes (torch.Tensor): source boxes, e.g., object proposals. + gt_bboxes (torch.Tensor): target of the transformation, e.g., + ground truth boxes. + + Returns: + encoded_bboxes(tuple[Tensor]): bucketing estimation + and fine regression targets and weights + """ + + assert bboxes.size(0) == gt_bboxes.size(0) + assert bboxes.size(-1) == gt_bboxes.size(-1) == 4 + encoded_bboxes = bbox2bucket(bboxes, gt_bboxes, self.num_buckets, + self.scale_factor, self.offset_topk, + self.offset_upperbound, + self.cls_ignore_neighbor) + return encoded_bboxes + + def decode(self, bboxes, pred_bboxes, max_shape=None): + """Apply transformation `pred_bboxes` to `boxes`. + Args: + boxes (torch.Tensor): Basic boxes. + pred_bboxes (torch.Tensor): Predictions for bucketing estimation + and fine regression + max_shape (tuple[int], optional): Maximum shape of boxes. + Defaults to None. + + Returns: + torch.Tensor: Decoded boxes. + """ + assert len(pred_bboxes) == 2 + cls_preds, offset_preds = pred_bboxes + assert cls_preds.size(0) == bboxes.size(0) and offset_preds.size( + 0) == bboxes.size(0) + decoded_bboxes = bucket2bbox(bboxes, cls_preds, offset_preds, + self.num_buckets, self.scale_factor, + max_shape, self.clip_border) + + return decoded_bboxes + + +@mmcv.jit(coderize=True) +def generat_buckets(proposals, num_buckets, scale_factor=1.0): + """Generate buckets w.r.t bucket number and scale factor of proposals. + + Args: + proposals (Tensor): Shape (n, 4) + num_buckets (int): Number of buckets. + scale_factor (float): Scale factor to rescale proposals. + + Returns: + tuple[Tensor]: (bucket_w, bucket_h, l_buckets, r_buckets, + t_buckets, d_buckets) + + - bucket_w: Width of buckets on x-axis. Shape (n, ). + - bucket_h: Height of buckets on y-axis. Shape (n, ). + - l_buckets: Left buckets. Shape (n, ceil(side_num/2)). + - r_buckets: Right buckets. Shape (n, ceil(side_num/2)). + - t_buckets: Top buckets. Shape (n, ceil(side_num/2)). + - d_buckets: Down buckets. Shape (n, ceil(side_num/2)). + """ + proposals = bbox_rescale(proposals, scale_factor) + + # number of buckets in each side + side_num = int(np.ceil(num_buckets / 2.0)) + pw = proposals[..., 2] - proposals[..., 0] + ph = proposals[..., 3] - proposals[..., 1] + px1 = proposals[..., 0] + py1 = proposals[..., 1] + px2 = proposals[..., 2] + py2 = proposals[..., 3] + + bucket_w = pw / num_buckets + bucket_h = ph / num_buckets + + # left buckets + l_buckets = px1[:, None] + (0.5 + torch.arange( + 0, side_num).to(proposals).float())[None, :] * bucket_w[:, None] + # right buckets + r_buckets = px2[:, None] - (0.5 + torch.arange( + 0, side_num).to(proposals).float())[None, :] * bucket_w[:, None] + # top buckets + t_buckets = py1[:, None] + (0.5 + torch.arange( + 0, side_num).to(proposals).float())[None, :] * bucket_h[:, None] + # down buckets + d_buckets = py2[:, None] - (0.5 + torch.arange( + 0, side_num).to(proposals).float())[None, :] * bucket_h[:, None] + return bucket_w, bucket_h, l_buckets, r_buckets, t_buckets, d_buckets + + +@mmcv.jit(coderize=True) +def bbox2bucket(proposals, + gt, + num_buckets, + scale_factor, + offset_topk=2, + offset_upperbound=1.0, + cls_ignore_neighbor=True): + """Generate buckets estimation and fine regression targets. + + Args: + proposals (Tensor): Shape (n, 4) + gt (Tensor): Shape (n, 4) + num_buckets (int): Number of buckets. + scale_factor (float): Scale factor to rescale proposals. + offset_topk (int): Topk buckets are used to generate + bucket fine regression targets. Defaults to 2. + offset_upperbound (float): Offset allowance to generate + bucket fine regression targets. + To avoid too large offset displacements. Defaults to 1.0. + cls_ignore_neighbor (bool): Ignore second nearest bucket or Not. + Defaults to True. + + Returns: + tuple[Tensor]: (offsets, offsets_weights, bucket_labels, cls_weights). + + - offsets: Fine regression targets. \ + Shape (n, num_buckets*2). + - offsets_weights: Fine regression weights. \ + Shape (n, num_buckets*2). + - bucket_labels: Bucketing estimation labels. \ + Shape (n, num_buckets*2). + - cls_weights: Bucketing estimation weights. \ + Shape (n, num_buckets*2). + """ + assert proposals.size() == gt.size() + + # generate buckets + proposals = proposals.float() + gt = gt.float() + (bucket_w, bucket_h, l_buckets, r_buckets, t_buckets, + d_buckets) = generat_buckets(proposals, num_buckets, scale_factor) + + gx1 = gt[..., 0] + gy1 = gt[..., 1] + gx2 = gt[..., 2] + gy2 = gt[..., 3] + + # generate offset targets and weights + # offsets from buckets to gts + l_offsets = (l_buckets - gx1[:, None]) / bucket_w[:, None] + r_offsets = (r_buckets - gx2[:, None]) / bucket_w[:, None] + t_offsets = (t_buckets - gy1[:, None]) / bucket_h[:, None] + d_offsets = (d_buckets - gy2[:, None]) / bucket_h[:, None] + + # select top-k nearest buckets + l_topk, l_label = l_offsets.abs().topk( + offset_topk, dim=1, largest=False, sorted=True) + r_topk, r_label = r_offsets.abs().topk( + offset_topk, dim=1, largest=False, sorted=True) + t_topk, t_label = t_offsets.abs().topk( + offset_topk, dim=1, largest=False, sorted=True) + d_topk, d_label = d_offsets.abs().topk( + offset_topk, dim=1, largest=False, sorted=True) + + offset_l_weights = l_offsets.new_zeros(l_offsets.size()) + offset_r_weights = r_offsets.new_zeros(r_offsets.size()) + offset_t_weights = t_offsets.new_zeros(t_offsets.size()) + offset_d_weights = d_offsets.new_zeros(d_offsets.size()) + inds = torch.arange(0, proposals.size(0)).to(proposals).long() + + # generate offset weights of top-k nearest buckets + for k in range(offset_topk): + if k >= 1: + offset_l_weights[inds, l_label[:, + k]] = (l_topk[:, k] < + offset_upperbound).float() + offset_r_weights[inds, r_label[:, + k]] = (r_topk[:, k] < + offset_upperbound).float() + offset_t_weights[inds, t_label[:, + k]] = (t_topk[:, k] < + offset_upperbound).float() + offset_d_weights[inds, d_label[:, + k]] = (d_topk[:, k] < + offset_upperbound).float() + else: + offset_l_weights[inds, l_label[:, k]] = 1.0 + offset_r_weights[inds, r_label[:, k]] = 1.0 + offset_t_weights[inds, t_label[:, k]] = 1.0 + offset_d_weights[inds, d_label[:, k]] = 1.0 + + offsets = torch.cat([l_offsets, r_offsets, t_offsets, d_offsets], dim=-1) + offsets_weights = torch.cat([ + offset_l_weights, offset_r_weights, offset_t_weights, offset_d_weights + ], + dim=-1) + + # generate bucket labels and weight + side_num = int(np.ceil(num_buckets / 2.0)) + labels = torch.stack( + [l_label[:, 0], r_label[:, 0], t_label[:, 0], d_label[:, 0]], dim=-1) + + batch_size = labels.size(0) + bucket_labels = F.one_hot(labels.view(-1), side_num).view(batch_size, + -1).float() + bucket_cls_l_weights = (l_offsets.abs() < 1).float() + bucket_cls_r_weights = (r_offsets.abs() < 1).float() + bucket_cls_t_weights = (t_offsets.abs() < 1).float() + bucket_cls_d_weights = (d_offsets.abs() < 1).float() + bucket_cls_weights = torch.cat([ + bucket_cls_l_weights, bucket_cls_r_weights, bucket_cls_t_weights, + bucket_cls_d_weights + ], + dim=-1) + # ignore second nearest buckets for cls if necessary + if cls_ignore_neighbor: + bucket_cls_weights = (~((bucket_cls_weights == 1) & + (bucket_labels == 0))).float() + else: + bucket_cls_weights[:] = 1.0 + return offsets, offsets_weights, bucket_labels, bucket_cls_weights + + +@mmcv.jit(coderize=True) +def bucket2bbox(proposals, + cls_preds, + offset_preds, + num_buckets, + scale_factor=1.0, + max_shape=None, + clip_border=True): + """Apply bucketing estimation (cls preds) and fine regression (offset + preds) to generate det bboxes. + + Args: + proposals (Tensor): Boxes to be transformed. Shape (n, 4) + cls_preds (Tensor): bucketing estimation. Shape (n, num_buckets*2). + offset_preds (Tensor): fine regression. Shape (n, num_buckets*2). + num_buckets (int): Number of buckets. + scale_factor (float): Scale factor to rescale proposals. + max_shape (tuple[int, int]): Maximum bounds for boxes. specifies (H, W) + clip_border (bool, optional): Whether clip the objects outside the + border of the image. Defaults to True. + + Returns: + tuple[Tensor]: (bboxes, loc_confidence). + + - bboxes: predicted bboxes. Shape (n, 4) + - loc_confidence: localization confidence of predicted bboxes. + Shape (n,). + """ + + side_num = int(np.ceil(num_buckets / 2.0)) + cls_preds = cls_preds.view(-1, side_num) + offset_preds = offset_preds.view(-1, side_num) + + scores = F.softmax(cls_preds, dim=1) + score_topk, score_label = scores.topk(2, dim=1, largest=True, sorted=True) + + rescaled_proposals = bbox_rescale(proposals, scale_factor) + + pw = rescaled_proposals[..., 2] - rescaled_proposals[..., 0] + ph = rescaled_proposals[..., 3] - rescaled_proposals[..., 1] + px1 = rescaled_proposals[..., 0] + py1 = rescaled_proposals[..., 1] + px2 = rescaled_proposals[..., 2] + py2 = rescaled_proposals[..., 3] + + bucket_w = pw / num_buckets + bucket_h = ph / num_buckets + + score_inds_l = score_label[0::4, 0] + score_inds_r = score_label[1::4, 0] + score_inds_t = score_label[2::4, 0] + score_inds_d = score_label[3::4, 0] + l_buckets = px1 + (0.5 + score_inds_l.float()) * bucket_w + r_buckets = px2 - (0.5 + score_inds_r.float()) * bucket_w + t_buckets = py1 + (0.5 + score_inds_t.float()) * bucket_h + d_buckets = py2 - (0.5 + score_inds_d.float()) * bucket_h + + offsets = offset_preds.view(-1, 4, side_num) + inds = torch.arange(proposals.size(0)).to(proposals).long() + l_offsets = offsets[:, 0, :][inds, score_inds_l] + r_offsets = offsets[:, 1, :][inds, score_inds_r] + t_offsets = offsets[:, 2, :][inds, score_inds_t] + d_offsets = offsets[:, 3, :][inds, score_inds_d] + + x1 = l_buckets - l_offsets * bucket_w + x2 = r_buckets - r_offsets * bucket_w + y1 = t_buckets - t_offsets * bucket_h + y2 = d_buckets - d_offsets * bucket_h + + if clip_border and max_shape is not None: + x1 = x1.clamp(min=0, max=max_shape[1] - 1) + y1 = y1.clamp(min=0, max=max_shape[0] - 1) + x2 = x2.clamp(min=0, max=max_shape[1] - 1) + y2 = y2.clamp(min=0, max=max_shape[0] - 1) + bboxes = torch.cat([x1[:, None], y1[:, None], x2[:, None], y2[:, None]], + dim=-1) + + # bucketing guided rescoring + loc_confidence = score_topk[:, 0] + top2_neighbor_inds = (score_label[:, 0] - score_label[:, 1]).abs() == 1 + loc_confidence += score_topk[:, 1] * top2_neighbor_inds.float() + loc_confidence = loc_confidence.view(-1, 4).mean(dim=1) + + return bboxes, loc_confidence diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/delta_xywh_bbox_coder.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/delta_xywh_bbox_coder.py new file mode 100644 index 000000000..a7f1c62fa --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/delta_xywh_bbox_coder.py @@ -0,0 +1,392 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import warnings + +import mmcv +import numpy as np +import torch + +from ..builder import BBOX_CODERS +from .base_bbox_coder import BaseBBoxCoder + + +@BBOX_CODERS.register_module() +class DeltaXYWHBBoxCoder(BaseBBoxCoder): + """Delta XYWH BBox coder. + + Following the practice in `R-CNN `_, + this coder encodes bbox (x1, y1, x2, y2) into delta (dx, dy, dw, dh) and + decodes delta (dx, dy, dw, dh) back to original bbox (x1, y1, x2, y2). + + Args: + target_means (Sequence[float]): Denormalizing means of target for + delta coordinates + target_stds (Sequence[float]): Denormalizing standard deviation of + target for delta coordinates + clip_border (bool, optional): Whether clip the objects outside the + border of the image. Defaults to True. + add_ctr_clamp (bool): Whether to add center clamp, when added, the + predicted box is clamped is its center is too far away from + the original anchor's center. Only used by YOLOF. Default False. + ctr_clamp (int): the maximum pixel shift to clamp. Only used by YOLOF. + Default 32. + """ + + def __init__(self, + target_means=(0., 0., 0., 0.), + target_stds=(1., 1., 1., 1.), + clip_border=True, + add_ctr_clamp=False, + ctr_clamp=32): + super(BaseBBoxCoder, self).__init__() + self.means = target_means + self.stds = target_stds + self.clip_border = clip_border + self.add_ctr_clamp = add_ctr_clamp + self.ctr_clamp = ctr_clamp + + def encode(self, bboxes, gt_bboxes): + """Get box regression transformation deltas that can be used to + transform the ``bboxes`` into the ``gt_bboxes``. + + Args: + bboxes (torch.Tensor): Source boxes, e.g., object proposals. + gt_bboxes (torch.Tensor): Target of the transformation, e.g., + ground-truth boxes. + + Returns: + torch.Tensor: Box transformation deltas + """ + + assert bboxes.size(0) == gt_bboxes.size(0) + assert bboxes.size(-1) == gt_bboxes.size(-1) == 4 + encoded_bboxes = bbox2delta(bboxes, gt_bboxes, self.means, self.stds) + return encoded_bboxes + + def decode(self, + bboxes, + pred_bboxes, + max_shape=None, + wh_ratio_clip=16 / 1000): + """Apply transformation `pred_bboxes` to `boxes`. + + Args: + bboxes (torch.Tensor): Basic boxes. Shape (B, N, 4) or (N, 4) + pred_bboxes (Tensor): Encoded offsets with respect to each roi. + Has shape (B, N, num_classes * 4) or (B, N, 4) or + (N, num_classes * 4) or (N, 4). Note N = num_anchors * W * H + when rois is a grid of anchors.Offset encoding follows [1]_. + max_shape (Sequence[int] or torch.Tensor or Sequence[ + Sequence[int]],optional): Maximum bounds for boxes, specifies + (H, W, C) or (H, W). If bboxes shape is (B, N, 4), then + the max_shape should be a Sequence[Sequence[int]] + and the length of max_shape should also be B. + wh_ratio_clip (float, optional): The allowed ratio between + width and height. + + Returns: + torch.Tensor: Decoded boxes. + """ + + assert pred_bboxes.size(0) == bboxes.size(0) + if pred_bboxes.ndim == 3: + assert pred_bboxes.size(1) == bboxes.size(1) + + if pred_bboxes.ndim == 2 and not torch.onnx.is_in_onnx_export(): + # single image decode + decoded_bboxes = delta2bbox(bboxes, pred_bboxes, self.means, + self.stds, max_shape, wh_ratio_clip, + self.clip_border, self.add_ctr_clamp, + self.ctr_clamp) + else: + if pred_bboxes.ndim == 3 and not torch.onnx.is_in_onnx_export(): + warnings.warn( + 'DeprecationWarning: onnx_delta2bbox is deprecated ' + 'in the case of batch decoding and non-ONNX, ' + 'please use “delta2bbox” instead. In order to improve ' + 'the decoding speed, the batch function will no ' + 'longer be supported. ') + decoded_bboxes = onnx_delta2bbox(bboxes, pred_bboxes, self.means, + self.stds, max_shape, + wh_ratio_clip, self.clip_border, + self.add_ctr_clamp, + self.ctr_clamp) + + return decoded_bboxes + + +@mmcv.jit(coderize=True) +def bbox2delta(proposals, gt, means=(0., 0., 0., 0.), stds=(1., 1., 1., 1.)): + """Compute deltas of proposals w.r.t. gt. + + We usually compute the deltas of x, y, w, h of proposals w.r.t ground + truth bboxes to get regression target. + This is the inverse function of :func:`delta2bbox`. + + Args: + proposals (Tensor): Boxes to be transformed, shape (N, ..., 4) + gt (Tensor): Gt bboxes to be used as base, shape (N, ..., 4) + means (Sequence[float]): Denormalizing means for delta coordinates + stds (Sequence[float]): Denormalizing standard deviation for delta + coordinates + + Returns: + Tensor: deltas with shape (N, 4), where columns represent dx, dy, + dw, dh. + """ + assert proposals.size() == gt.size() + + proposals = proposals.float() + gt = gt.float() + px = (proposals[..., 0] + proposals[..., 2]) * 0.5 + py = (proposals[..., 1] + proposals[..., 3]) * 0.5 + pw = proposals[..., 2] - proposals[..., 0] + ph = proposals[..., 3] - proposals[..., 1] + + gx = (gt[..., 0] + gt[..., 2]) * 0.5 + gy = (gt[..., 1] + gt[..., 3]) * 0.5 + gw = gt[..., 2] - gt[..., 0] + gh = gt[..., 3] - gt[..., 1] + + dx = (gx - px) / pw + dy = (gy - py) / ph + dw = torch.log(gw / pw) + dh = torch.log(gh / ph) + deltas = torch.stack([dx, dy, dw, dh], dim=-1) + + means = deltas.new_tensor(means).unsqueeze(0) + stds = deltas.new_tensor(stds).unsqueeze(0) + deltas = deltas.sub_(means).div_(stds) + + return deltas + + +@mmcv.jit(coderize=True) +def delta2bbox(rois, + deltas, + means=(0., 0., 0., 0.), + stds=(1., 1., 1., 1.), + max_shape=None, + wh_ratio_clip=16 / 1000, + clip_border=True, + add_ctr_clamp=False, + ctr_clamp=32): + """Apply deltas to shift/scale base boxes. + + Typically the rois are anchor or proposed bounding boxes and the deltas are + network outputs used to shift/scale those boxes. + This is the inverse function of :func:`bbox2delta`. + + Args: + rois (Tensor): Boxes to be transformed. Has shape (N, 4). + deltas (Tensor): Encoded offsets relative to each roi. + Has shape (N, num_classes * 4) or (N, 4). Note + N = num_base_anchors * W * H, when rois is a grid of + anchors. Offset encoding follows [1]_. + means (Sequence[float]): Denormalizing means for delta coordinates. + Default (0., 0., 0., 0.). + stds (Sequence[float]): Denormalizing standard deviation for delta + coordinates. Default (1., 1., 1., 1.). + max_shape (tuple[int, int]): Maximum bounds for boxes, specifies + (H, W). Default None. + wh_ratio_clip (float): Maximum aspect ratio for boxes. Default + 16 / 1000. + clip_border (bool, optional): Whether clip the objects outside the + border of the image. Default True. + add_ctr_clamp (bool): Whether to add center clamp. When set to True, + the center of the prediction bounding box will be clamped to + avoid being too far away from the center of the anchor. + Only used by YOLOF. Default False. + ctr_clamp (int): the maximum pixel shift to clamp. Only used by YOLOF. + Default 32. + + Returns: + Tensor: Boxes with shape (N, num_classes * 4) or (N, 4), where 4 + represent tl_x, tl_y, br_x, br_y. + + References: + .. [1] https://arxiv.org/abs/1311.2524 + + Example: + >>> rois = torch.Tensor([[ 0., 0., 1., 1.], + >>> [ 0., 0., 1., 1.], + >>> [ 0., 0., 1., 1.], + >>> [ 5., 5., 5., 5.]]) + >>> deltas = torch.Tensor([[ 0., 0., 0., 0.], + >>> [ 1., 1., 1., 1.], + >>> [ 0., 0., 2., -1.], + >>> [ 0.7, -1.9, -0.5, 0.3]]) + >>> delta2bbox(rois, deltas, max_shape=(32, 32, 3)) + tensor([[0.0000, 0.0000, 1.0000, 1.0000], + [0.1409, 0.1409, 2.8591, 2.8591], + [0.0000, 0.3161, 4.1945, 0.6839], + [5.0000, 5.0000, 5.0000, 5.0000]]) + """ + num_bboxes, num_classes = deltas.size(0), deltas.size(1) // 4 + if num_bboxes == 0: + return deltas + + deltas = deltas.reshape(-1, 4) + + means = deltas.new_tensor(means).view(1, -1) + stds = deltas.new_tensor(stds).view(1, -1) + denorm_deltas = deltas * stds + means + + dxy = denorm_deltas[:, :2] + dwh = denorm_deltas[:, 2:] + + # Compute width/height of each roi + rois_ = rois.repeat(1, num_classes).reshape(-1, 4) + pxy = ((rois_[:, :2] + rois_[:, 2:]) * 0.5) + pwh = (rois_[:, 2:] - rois_[:, :2]) + + dxy_wh = pwh * dxy + + max_ratio = np.abs(np.log(wh_ratio_clip)) + if add_ctr_clamp: + dxy_wh = torch.clamp(dxy_wh, max=ctr_clamp, min=-ctr_clamp) + dwh = torch.clamp(dwh, max=max_ratio) + else: + dwh = dwh.clamp(min=-max_ratio, max=max_ratio) + + gxy = pxy + dxy_wh + gwh = pwh * dwh.exp() + x1y1 = gxy - (gwh * 0.5) + x2y2 = gxy + (gwh * 0.5) + bboxes = torch.cat([x1y1, x2y2], dim=-1) + if clip_border and max_shape is not None: + bboxes[..., 0::2].clamp_(min=0, max=max_shape[1]) + bboxes[..., 1::2].clamp_(min=0, max=max_shape[0]) + bboxes = bboxes.reshape(num_bboxes, -1) + return bboxes + + +def onnx_delta2bbox(rois, + deltas, + means=(0., 0., 0., 0.), + stds=(1., 1., 1., 1.), + max_shape=None, + wh_ratio_clip=16 / 1000, + clip_border=True, + add_ctr_clamp=False, + ctr_clamp=32): + """Apply deltas to shift/scale base boxes. + + Typically the rois are anchor or proposed bounding boxes and the deltas are + network outputs used to shift/scale those boxes. + This is the inverse function of :func:`bbox2delta`. + + Args: + rois (Tensor): Boxes to be transformed. Has shape (N, 4) or (B, N, 4) + deltas (Tensor): Encoded offsets with respect to each roi. + Has shape (B, N, num_classes * 4) or (B, N, 4) or + (N, num_classes * 4) or (N, 4). Note N = num_anchors * W * H + when rois is a grid of anchors.Offset encoding follows [1]_. + means (Sequence[float]): Denormalizing means for delta coordinates. + Default (0., 0., 0., 0.). + stds (Sequence[float]): Denormalizing standard deviation for delta + coordinates. Default (1., 1., 1., 1.). + max_shape (Sequence[int] or torch.Tensor or Sequence[ + Sequence[int]],optional): Maximum bounds for boxes, specifies + (H, W, C) or (H, W). If rois shape is (B, N, 4), then + the max_shape should be a Sequence[Sequence[int]] + and the length of max_shape should also be B. Default None. + wh_ratio_clip (float): Maximum aspect ratio for boxes. + Default 16 / 1000. + clip_border (bool, optional): Whether clip the objects outside the + border of the image. Default True. + add_ctr_clamp (bool): Whether to add center clamp, when added, the + predicted box is clamped is its center is too far away from + the original anchor's center. Only used by YOLOF. Default False. + ctr_clamp (int): the maximum pixel shift to clamp. Only used by YOLOF. + Default 32. + + Returns: + Tensor: Boxes with shape (B, N, num_classes * 4) or (B, N, 4) or + (N, num_classes * 4) or (N, 4), where 4 represent + tl_x, tl_y, br_x, br_y. + + References: + .. [1] https://arxiv.org/abs/1311.2524 + + Example: + >>> rois = torch.Tensor([[ 0., 0., 1., 1.], + >>> [ 0., 0., 1., 1.], + >>> [ 0., 0., 1., 1.], + >>> [ 5., 5., 5., 5.]]) + >>> deltas = torch.Tensor([[ 0., 0., 0., 0.], + >>> [ 1., 1., 1., 1.], + >>> [ 0., 0., 2., -1.], + >>> [ 0.7, -1.9, -0.5, 0.3]]) + >>> delta2bbox(rois, deltas, max_shape=(32, 32, 3)) + tensor([[0.0000, 0.0000, 1.0000, 1.0000], + [0.1409, 0.1409, 2.8591, 2.8591], + [0.0000, 0.3161, 4.1945, 0.6839], + [5.0000, 5.0000, 5.0000, 5.0000]]) + """ + means = deltas.new_tensor(means).view(1, + -1).repeat(1, + deltas.size(-1) // 4) + stds = deltas.new_tensor(stds).view(1, -1).repeat(1, deltas.size(-1) // 4) + denorm_deltas = deltas * stds + means + dx = denorm_deltas[..., 0::4] + dy = denorm_deltas[..., 1::4] + dw = denorm_deltas[..., 2::4] + dh = denorm_deltas[..., 3::4] + + x1, y1 = rois[..., 0], rois[..., 1] + x2, y2 = rois[..., 2], rois[..., 3] + # Compute center of each roi + px = ((x1 + x2) * 0.5).unsqueeze(-1).expand_as(dx) + py = ((y1 + y2) * 0.5).unsqueeze(-1).expand_as(dy) + # Compute width/height of each roi + pw = (x2 - x1).unsqueeze(-1).expand_as(dw) + ph = (y2 - y1).unsqueeze(-1).expand_as(dh) + + dx_width = pw * dx + dy_height = ph * dy + + max_ratio = np.abs(np.log(wh_ratio_clip)) + if add_ctr_clamp: + dx_width = torch.clamp(dx_width, max=ctr_clamp, min=-ctr_clamp) + dy_height = torch.clamp(dy_height, max=ctr_clamp, min=-ctr_clamp) + dw = torch.clamp(dw, max=max_ratio) + dh = torch.clamp(dh, max=max_ratio) + else: + dw = dw.clamp(min=-max_ratio, max=max_ratio) + dh = dh.clamp(min=-max_ratio, max=max_ratio) + # Use exp(network energy) to enlarge/shrink each roi + gw = pw * dw.exp() + gh = ph * dh.exp() + # Use network energy to shift the center of each roi + gx = px + dx_width + gy = py + dy_height + # Convert center-xy/width/height to top-left, bottom-right + x1 = gx - gw * 0.5 + y1 = gy - gh * 0.5 + x2 = gx + gw * 0.5 + y2 = gy + gh * 0.5 + + bboxes = torch.stack([x1, y1, x2, y2], dim=-1).view(deltas.size()) + + if clip_border and max_shape is not None: + # clip bboxes with dynamic `min` and `max` for onnx + if torch.onnx.is_in_onnx_export(): + from mmdet.core.export import dynamic_clip_for_onnx + x1, y1, x2, y2 = dynamic_clip_for_onnx(x1, y1, x2, y2, max_shape) + bboxes = torch.stack([x1, y1, x2, y2], dim=-1).view(deltas.size()) + return bboxes + if not isinstance(max_shape, torch.Tensor): + max_shape = x1.new_tensor(max_shape) + max_shape = max_shape[..., :2].type_as(x1) + if max_shape.ndim == 2: + assert bboxes.ndim == 3 + assert max_shape.size(0) == bboxes.size(0) + + min_xy = x1.new_tensor(0) + max_xy = torch.cat( + [max_shape] * (deltas.size(-1) // 2), + dim=-1).flip(-1).unsqueeze(-2) + bboxes = torch.where(bboxes < min_xy, min_xy, bboxes) + bboxes = torch.where(bboxes > max_xy, max_xy, bboxes) + + return bboxes diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/distance_point_bbox_coder.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/distance_point_bbox_coder.py new file mode 100644 index 000000000..9f308a841 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/distance_point_bbox_coder.py @@ -0,0 +1,63 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from ..builder import BBOX_CODERS +from ..transforms import bbox2distance, distance2bbox +from .base_bbox_coder import BaseBBoxCoder + + +@BBOX_CODERS.register_module() +class DistancePointBBoxCoder(BaseBBoxCoder): + """Distance Point BBox coder. + + This coder encodes gt bboxes (x1, y1, x2, y2) into (top, bottom, left, + right) and decode it back to the original. + + Args: + clip_border (bool, optional): Whether clip the objects outside the + border of the image. Defaults to True. + """ + + def __init__(self, clip_border=True): + super(BaseBBoxCoder, self).__init__() + self.clip_border = clip_border + + def encode(self, points, gt_bboxes, max_dis=None, eps=0.1): + """Encode bounding box to distances. + + Args: + points (Tensor): Shape (N, 2), The format is [x, y]. + gt_bboxes (Tensor): Shape (N, 4), The format is "xyxy" + max_dis (float): Upper bound of the distance. Default None. + eps (float): a small value to ensure target < max_dis, instead <=. + Default 0.1. + + Returns: + Tensor: Box transformation deltas. The shape is (N, 4). + """ + assert points.size(0) == gt_bboxes.size(0) + assert points.size(-1) == 2 + assert gt_bboxes.size(-1) == 4 + return bbox2distance(points, gt_bboxes, max_dis, eps) + + def decode(self, points, pred_bboxes, max_shape=None): + """Decode distance prediction to bounding box. + + Args: + points (Tensor): Shape (B, N, 2) or (N, 2). + pred_bboxes (Tensor): Distance from the given point to 4 + boundaries (left, top, right, bottom). Shape (B, N, 4) + or (N, 4) + max_shape (Sequence[int] or torch.Tensor or Sequence[ + Sequence[int]],optional): Maximum bounds for boxes, specifies + (H, W, C) or (H, W). If priors shape is (B, N, 4), then + the max_shape should be a Sequence[Sequence[int]], + and the length of max_shape should also be B. + Default None. + Returns: + Tensor: Boxes with shape (N, 4) or (B, N, 4) + """ + assert points.size(0) == pred_bboxes.size(0) + assert points.size(-1) == 2 + assert pred_bboxes.size(-1) == 4 + if self.clip_border is False: + max_shape = None + return distance2bbox(points, pred_bboxes, max_shape) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/legacy_delta_xywh_bbox_coder.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/legacy_delta_xywh_bbox_coder.py new file mode 100644 index 000000000..7fa348b2d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/legacy_delta_xywh_bbox_coder.py @@ -0,0 +1,216 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import mmcv +import numpy as np +import torch + +from ..builder import BBOX_CODERS +from .base_bbox_coder import BaseBBoxCoder + + +@BBOX_CODERS.register_module() +class LegacyDeltaXYWHBBoxCoder(BaseBBoxCoder): + """Legacy Delta XYWH BBox coder used in MMDet V1.x. + + Following the practice in R-CNN [1]_, this coder encodes bbox (x1, y1, x2, + y2) into delta (dx, dy, dw, dh) and decodes delta (dx, dy, dw, dh) + back to original bbox (x1, y1, x2, y2). + + Note: + The main difference between :class`LegacyDeltaXYWHBBoxCoder` and + :class:`DeltaXYWHBBoxCoder` is whether ``+ 1`` is used during width and + height calculation. We suggest to only use this coder when testing with + MMDet V1.x models. + + References: + .. [1] https://arxiv.org/abs/1311.2524 + + Args: + target_means (Sequence[float]): denormalizing means of target for + delta coordinates + target_stds (Sequence[float]): denormalizing standard deviation of + target for delta coordinates + """ + + def __init__(self, + target_means=(0., 0., 0., 0.), + target_stds=(1., 1., 1., 1.)): + super(BaseBBoxCoder, self).__init__() + self.means = target_means + self.stds = target_stds + + def encode(self, bboxes, gt_bboxes): + """Get box regression transformation deltas that can be used to + transform the ``bboxes`` into the ``gt_bboxes``. + + Args: + bboxes (torch.Tensor): source boxes, e.g., object proposals. + gt_bboxes (torch.Tensor): target of the transformation, e.g., + ground-truth boxes. + + Returns: + torch.Tensor: Box transformation deltas + """ + assert bboxes.size(0) == gt_bboxes.size(0) + assert bboxes.size(-1) == gt_bboxes.size(-1) == 4 + encoded_bboxes = legacy_bbox2delta(bboxes, gt_bboxes, self.means, + self.stds) + return encoded_bboxes + + def decode(self, + bboxes, + pred_bboxes, + max_shape=None, + wh_ratio_clip=16 / 1000): + """Apply transformation `pred_bboxes` to `boxes`. + + Args: + boxes (torch.Tensor): Basic boxes. + pred_bboxes (torch.Tensor): Encoded boxes with shape + max_shape (tuple[int], optional): Maximum shape of boxes. + Defaults to None. + wh_ratio_clip (float, optional): The allowed ratio between + width and height. + + Returns: + torch.Tensor: Decoded boxes. + """ + assert pred_bboxes.size(0) == bboxes.size(0) + decoded_bboxes = legacy_delta2bbox(bboxes, pred_bboxes, self.means, + self.stds, max_shape, wh_ratio_clip) + + return decoded_bboxes + + +@mmcv.jit(coderize=True) +def legacy_bbox2delta(proposals, + gt, + means=(0., 0., 0., 0.), + stds=(1., 1., 1., 1.)): + """Compute deltas of proposals w.r.t. gt in the MMDet V1.x manner. + + We usually compute the deltas of x, y, w, h of proposals w.r.t ground + truth bboxes to get regression target. + This is the inverse function of `delta2bbox()` + + Args: + proposals (Tensor): Boxes to be transformed, shape (N, ..., 4) + gt (Tensor): Gt bboxes to be used as base, shape (N, ..., 4) + means (Sequence[float]): Denormalizing means for delta coordinates + stds (Sequence[float]): Denormalizing standard deviation for delta + coordinates + + Returns: + Tensor: deltas with shape (N, 4), where columns represent dx, dy, + dw, dh. + """ + assert proposals.size() == gt.size() + + proposals = proposals.float() + gt = gt.float() + px = (proposals[..., 0] + proposals[..., 2]) * 0.5 + py = (proposals[..., 1] + proposals[..., 3]) * 0.5 + pw = proposals[..., 2] - proposals[..., 0] + 1.0 + ph = proposals[..., 3] - proposals[..., 1] + 1.0 + + gx = (gt[..., 0] + gt[..., 2]) * 0.5 + gy = (gt[..., 1] + gt[..., 3]) * 0.5 + gw = gt[..., 2] - gt[..., 0] + 1.0 + gh = gt[..., 3] - gt[..., 1] + 1.0 + + dx = (gx - px) / pw + dy = (gy - py) / ph + dw = torch.log(gw / pw) + dh = torch.log(gh / ph) + deltas = torch.stack([dx, dy, dw, dh], dim=-1) + + means = deltas.new_tensor(means).unsqueeze(0) + stds = deltas.new_tensor(stds).unsqueeze(0) + deltas = deltas.sub_(means).div_(stds) + + return deltas + + +@mmcv.jit(coderize=True) +def legacy_delta2bbox(rois, + deltas, + means=(0., 0., 0., 0.), + stds=(1., 1., 1., 1.), + max_shape=None, + wh_ratio_clip=16 / 1000): + """Apply deltas to shift/scale base boxes in the MMDet V1.x manner. + + Typically the rois are anchor or proposed bounding boxes and the deltas are + network outputs used to shift/scale those boxes. + This is the inverse function of `bbox2delta()` + + Args: + rois (Tensor): Boxes to be transformed. Has shape (N, 4) + deltas (Tensor): Encoded offsets with respect to each roi. + Has shape (N, 4 * num_classes). Note N = num_anchors * W * H when + rois is a grid of anchors. Offset encoding follows [1]_. + means (Sequence[float]): Denormalizing means for delta coordinates + stds (Sequence[float]): Denormalizing standard deviation for delta + coordinates + max_shape (tuple[int, int]): Maximum bounds for boxes. specifies (H, W) + wh_ratio_clip (float): Maximum aspect ratio for boxes. + + Returns: + Tensor: Boxes with shape (N, 4), where columns represent + tl_x, tl_y, br_x, br_y. + + References: + .. [1] https://arxiv.org/abs/1311.2524 + + Example: + >>> rois = torch.Tensor([[ 0., 0., 1., 1.], + >>> [ 0., 0., 1., 1.], + >>> [ 0., 0., 1., 1.], + >>> [ 5., 5., 5., 5.]]) + >>> deltas = torch.Tensor([[ 0., 0., 0., 0.], + >>> [ 1., 1., 1., 1.], + >>> [ 0., 0., 2., -1.], + >>> [ 0.7, -1.9, -0.5, 0.3]]) + >>> legacy_delta2bbox(rois, deltas, max_shape=(32, 32)) + tensor([[0.0000, 0.0000, 1.5000, 1.5000], + [0.0000, 0.0000, 5.2183, 5.2183], + [0.0000, 0.1321, 7.8891, 0.8679], + [5.3967, 2.4251, 6.0033, 3.7749]]) + """ + means = deltas.new_tensor(means).repeat(1, deltas.size(1) // 4) + stds = deltas.new_tensor(stds).repeat(1, deltas.size(1) // 4) + denorm_deltas = deltas * stds + means + dx = denorm_deltas[:, 0::4] + dy = denorm_deltas[:, 1::4] + dw = denorm_deltas[:, 2::4] + dh = denorm_deltas[:, 3::4] + max_ratio = np.abs(np.log(wh_ratio_clip)) + dw = dw.clamp(min=-max_ratio, max=max_ratio) + dh = dh.clamp(min=-max_ratio, max=max_ratio) + # Compute center of each roi + px = ((rois[:, 0] + rois[:, 2]) * 0.5).unsqueeze(1).expand_as(dx) + py = ((rois[:, 1] + rois[:, 3]) * 0.5).unsqueeze(1).expand_as(dy) + # Compute width/height of each roi + pw = (rois[:, 2] - rois[:, 0] + 1.0).unsqueeze(1).expand_as(dw) + ph = (rois[:, 3] - rois[:, 1] + 1.0).unsqueeze(1).expand_as(dh) + # Use exp(network energy) to enlarge/shrink each roi + gw = pw * dw.exp() + gh = ph * dh.exp() + # Use network energy to shift the center of each roi + gx = px + pw * dx + gy = py + ph * dy + # Convert center-xy/width/height to top-left, bottom-right + + # The true legacy box coder should +- 0.5 here. + # However, current implementation improves the performance when testing + # the models trained in MMDetection 1.X (~0.5 bbox AP, 0.2 mask AP) + x1 = gx - gw * 0.5 + y1 = gy - gh * 0.5 + x2 = gx + gw * 0.5 + y2 = gy + gh * 0.5 + if max_shape is not None: + x1 = x1.clamp(min=0, max=max_shape[1] - 1) + y1 = y1.clamp(min=0, max=max_shape[0] - 1) + x2 = x2.clamp(min=0, max=max_shape[1] - 1) + y2 = y2.clamp(min=0, max=max_shape[0] - 1) + bboxes = torch.stack([x1, y1, x2, y2], dim=-1).view_as(deltas) + return bboxes diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/pseudo_bbox_coder.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/pseudo_bbox_coder.py new file mode 100644 index 000000000..fe71f369c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/pseudo_bbox_coder.py @@ -0,0 +1,19 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from ..builder import BBOX_CODERS +from .base_bbox_coder import BaseBBoxCoder + + +@BBOX_CODERS.register_module() +class PseudoBBoxCoder(BaseBBoxCoder): + """Pseudo bounding box coder.""" + + def __init__(self, **kwargs): + super(BaseBBoxCoder, self).__init__(**kwargs) + + def encode(self, bboxes, gt_bboxes): + """torch.Tensor: return the given ``bboxes``""" + return gt_bboxes + + def decode(self, bboxes, pred_bboxes): + """torch.Tensor: return the given ``pred_bboxes``""" + return pred_bboxes diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/tblr_bbox_coder.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/tblr_bbox_coder.py new file mode 100644 index 000000000..cb4206636 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/tblr_bbox_coder.py @@ -0,0 +1,206 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import mmcv +import torch + +from ..builder import BBOX_CODERS +from .base_bbox_coder import BaseBBoxCoder + + +@BBOX_CODERS.register_module() +class TBLRBBoxCoder(BaseBBoxCoder): + """TBLR BBox coder. + + Following the practice in `FSAF `_, + this coder encodes gt bboxes (x1, y1, x2, y2) into (top, bottom, left, + right) and decode it back to the original. + + Args: + normalizer (list | float): Normalization factor to be + divided with when coding the coordinates. If it is a list, it should + have length of 4 indicating normalization factor in tblr dims. + Otherwise it is a unified float factor for all dims. Default: 4.0 + clip_border (bool, optional): Whether clip the objects outside the + border of the image. Defaults to True. + """ + + def __init__(self, normalizer=4.0, clip_border=True): + super(BaseBBoxCoder, self).__init__() + self.normalizer = normalizer + self.clip_border = clip_border + + def encode(self, bboxes, gt_bboxes): + """Get box regression transformation deltas that can be used to + transform the ``bboxes`` into the ``gt_bboxes`` in the (top, left, + bottom, right) order. + + Args: + bboxes (torch.Tensor): source boxes, e.g., object proposals. + gt_bboxes (torch.Tensor): target of the transformation, e.g., + ground truth boxes. + + Returns: + torch.Tensor: Box transformation deltas + """ + assert bboxes.size(0) == gt_bboxes.size(0) + assert bboxes.size(-1) == gt_bboxes.size(-1) == 4 + encoded_bboxes = bboxes2tblr( + bboxes, gt_bboxes, normalizer=self.normalizer) + return encoded_bboxes + + def decode(self, bboxes, pred_bboxes, max_shape=None): + """Apply transformation `pred_bboxes` to `boxes`. + + Args: + bboxes (torch.Tensor): Basic boxes.Shape (B, N, 4) or (N, 4) + pred_bboxes (torch.Tensor): Encoded boxes with shape + (B, N, 4) or (N, 4) + max_shape (Sequence[int] or torch.Tensor or Sequence[ + Sequence[int]],optional): Maximum bounds for boxes, specifies + (H, W, C) or (H, W). If bboxes shape is (B, N, 4), then + the max_shape should be a Sequence[Sequence[int]] + and the length of max_shape should also be B. + + Returns: + torch.Tensor: Decoded boxes. + """ + decoded_bboxes = tblr2bboxes( + bboxes, + pred_bboxes, + normalizer=self.normalizer, + max_shape=max_shape, + clip_border=self.clip_border) + + return decoded_bboxes + + +@mmcv.jit(coderize=True) +def bboxes2tblr(priors, gts, normalizer=4.0, normalize_by_wh=True): + """Encode ground truth boxes to tblr coordinate. + + It first convert the gt coordinate to tblr format, + (top, bottom, left, right), relative to prior box centers. + The tblr coordinate may be normalized by the side length of prior bboxes + if `normalize_by_wh` is specified as True, and it is then normalized by + the `normalizer` factor. + + Args: + priors (Tensor): Prior boxes in point form + Shape: (num_proposals,4). + gts (Tensor): Coords of ground truth for each prior in point-form + Shape: (num_proposals, 4). + normalizer (Sequence[float] | float): normalization parameter of + encoded boxes. If it is a list, it has to have length = 4. + Default: 4.0 + normalize_by_wh (bool): Whether to normalize tblr coordinate by the + side length (wh) of prior bboxes. + + Return: + encoded boxes (Tensor), Shape: (num_proposals, 4) + """ + + # dist b/t match center and prior's center + if not isinstance(normalizer, float): + normalizer = torch.tensor(normalizer, device=priors.device) + assert len(normalizer) == 4, 'Normalizer must have length = 4' + assert priors.size(0) == gts.size(0) + prior_centers = (priors[:, 0:2] + priors[:, 2:4]) / 2 + xmin, ymin, xmax, ymax = gts.split(1, dim=1) + top = prior_centers[:, 1].unsqueeze(1) - ymin + bottom = ymax - prior_centers[:, 1].unsqueeze(1) + left = prior_centers[:, 0].unsqueeze(1) - xmin + right = xmax - prior_centers[:, 0].unsqueeze(1) + loc = torch.cat((top, bottom, left, right), dim=1) + if normalize_by_wh: + # Normalize tblr by anchor width and height + wh = priors[:, 2:4] - priors[:, 0:2] + w, h = torch.split(wh, 1, dim=1) + loc[:, :2] /= h # tb is normalized by h + loc[:, 2:] /= w # lr is normalized by w + # Normalize tblr by the given normalization factor + return loc / normalizer + + +@mmcv.jit(coderize=True) +def tblr2bboxes(priors, + tblr, + normalizer=4.0, + normalize_by_wh=True, + max_shape=None, + clip_border=True): + """Decode tblr outputs to prediction boxes. + + The process includes 3 steps: 1) De-normalize tblr coordinates by + multiplying it with `normalizer`; 2) De-normalize tblr coordinates by the + prior bbox width and height if `normalize_by_wh` is `True`; 3) Convert + tblr (top, bottom, left, right) pair relative to the center of priors back + to (xmin, ymin, xmax, ymax) coordinate. + + Args: + priors (Tensor): Prior boxes in point form (x0, y0, x1, y1) + Shape: (N,4) or (B, N, 4). + tblr (Tensor): Coords of network output in tblr form + Shape: (N, 4) or (B, N, 4). + normalizer (Sequence[float] | float): Normalization parameter of + encoded boxes. By list, it represents the normalization factors at + tblr dims. By float, it is the unified normalization factor at all + dims. Default: 4.0 + normalize_by_wh (bool): Whether the tblr coordinates have been + normalized by the side length (wh) of prior bboxes. + max_shape (Sequence[int] or torch.Tensor or Sequence[ + Sequence[int]],optional): Maximum bounds for boxes, specifies + (H, W, C) or (H, W). If priors shape is (B, N, 4), then + the max_shape should be a Sequence[Sequence[int]] + and the length of max_shape should also be B. + clip_border (bool, optional): Whether clip the objects outside the + border of the image. Defaults to True. + + Return: + encoded boxes (Tensor): Boxes with shape (N, 4) or (B, N, 4) + """ + if not isinstance(normalizer, float): + normalizer = torch.tensor(normalizer, device=priors.device) + assert len(normalizer) == 4, 'Normalizer must have length = 4' + assert priors.size(0) == tblr.size(0) + if priors.ndim == 3: + assert priors.size(1) == tblr.size(1) + + loc_decode = tblr * normalizer + prior_centers = (priors[..., 0:2] + priors[..., 2:4]) / 2 + if normalize_by_wh: + wh = priors[..., 2:4] - priors[..., 0:2] + w, h = torch.split(wh, 1, dim=-1) + # Inplace operation with slice would failed for exporting to ONNX + th = h * loc_decode[..., :2] # tb + tw = w * loc_decode[..., 2:] # lr + loc_decode = torch.cat([th, tw], dim=-1) + # Cannot be exported using onnx when loc_decode.split(1, dim=-1) + top, bottom, left, right = loc_decode.split((1, 1, 1, 1), dim=-1) + xmin = prior_centers[..., 0].unsqueeze(-1) - left + xmax = prior_centers[..., 0].unsqueeze(-1) + right + ymin = prior_centers[..., 1].unsqueeze(-1) - top + ymax = prior_centers[..., 1].unsqueeze(-1) + bottom + + bboxes = torch.cat((xmin, ymin, xmax, ymax), dim=-1) + + if clip_border and max_shape is not None: + # clip bboxes with dynamic `min` and `max` for onnx + if torch.onnx.is_in_onnx_export(): + from mmdet.core.export import dynamic_clip_for_onnx + xmin, ymin, xmax, ymax = dynamic_clip_for_onnx( + xmin, ymin, xmax, ymax, max_shape) + bboxes = torch.cat([xmin, ymin, xmax, ymax], dim=-1) + return bboxes + if not isinstance(max_shape, torch.Tensor): + max_shape = priors.new_tensor(max_shape) + max_shape = max_shape[..., :2].type_as(priors) + if max_shape.ndim == 2: + assert bboxes.ndim == 3 + assert max_shape.size(0) == bboxes.size(0) + + min_xy = priors.new_tensor(0) + max_xy = torch.cat([max_shape, max_shape], + dim=-1).flip(-1).unsqueeze(-2) + bboxes = torch.where(bboxes < min_xy, min_xy, bboxes) + bboxes = torch.where(bboxes > max_xy, max_xy, bboxes) + + return bboxes diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/yolo_bbox_coder.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/yolo_bbox_coder.py new file mode 100644 index 000000000..2852eca75 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/coder/yolo_bbox_coder.py @@ -0,0 +1,83 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import mmcv +import torch + +from ..builder import BBOX_CODERS +from .base_bbox_coder import BaseBBoxCoder + + +@BBOX_CODERS.register_module() +class YOLOBBoxCoder(BaseBBoxCoder): + """YOLO BBox coder. + + Following `YOLO `_, this coder divide + image into grids, and encode bbox (x1, y1, x2, y2) into (cx, cy, dw, dh). + cx, cy in [0., 1.], denotes relative center position w.r.t the center of + bboxes. dw, dh are the same as :obj:`DeltaXYWHBBoxCoder`. + + Args: + eps (float): Min value of cx, cy when encoding. + """ + + def __init__(self, eps=1e-6): + super(BaseBBoxCoder, self).__init__() + self.eps = eps + + @mmcv.jit(coderize=True) + def encode(self, bboxes, gt_bboxes, stride): + """Get box regression transformation deltas that can be used to + transform the ``bboxes`` into the ``gt_bboxes``. + + Args: + bboxes (torch.Tensor): Source boxes, e.g., anchors. + gt_bboxes (torch.Tensor): Target of the transformation, e.g., + ground-truth boxes. + stride (torch.Tensor | int): Stride of bboxes. + + Returns: + torch.Tensor: Box transformation deltas + """ + + assert bboxes.size(0) == gt_bboxes.size(0) + assert bboxes.size(-1) == gt_bboxes.size(-1) == 4 + x_center_gt = (gt_bboxes[..., 0] + gt_bboxes[..., 2]) * 0.5 + y_center_gt = (gt_bboxes[..., 1] + gt_bboxes[..., 3]) * 0.5 + w_gt = gt_bboxes[..., 2] - gt_bboxes[..., 0] + h_gt = gt_bboxes[..., 3] - gt_bboxes[..., 1] + x_center = (bboxes[..., 0] + bboxes[..., 2]) * 0.5 + y_center = (bboxes[..., 1] + bboxes[..., 3]) * 0.5 + w = bboxes[..., 2] - bboxes[..., 0] + h = bboxes[..., 3] - bboxes[..., 1] + w_target = torch.log((w_gt / w).clamp(min=self.eps)) + h_target = torch.log((h_gt / h).clamp(min=self.eps)) + x_center_target = ((x_center_gt - x_center) / stride + 0.5).clamp( + self.eps, 1 - self.eps) + y_center_target = ((y_center_gt - y_center) / stride + 0.5).clamp( + self.eps, 1 - self.eps) + encoded_bboxes = torch.stack( + [x_center_target, y_center_target, w_target, h_target], dim=-1) + return encoded_bboxes + + @mmcv.jit(coderize=True) + def decode(self, bboxes, pred_bboxes, stride): + """Apply transformation `pred_bboxes` to `boxes`. + + Args: + boxes (torch.Tensor): Basic boxes, e.g. anchors. + pred_bboxes (torch.Tensor): Encoded boxes with shape + stride (torch.Tensor | int): Strides of bboxes. + + Returns: + torch.Tensor: Decoded boxes. + """ + assert pred_bboxes.size(-1) == bboxes.size(-1) == 4 + xy_centers = (bboxes[..., :2] + bboxes[..., 2:]) * 0.5 + ( + pred_bboxes[..., :2] - 0.5) * stride + whs = (bboxes[..., 2:] - + bboxes[..., :2]) * 0.5 * pred_bboxes[..., 2:].exp() + decoded_bboxes = torch.stack( + (xy_centers[..., 0] - whs[..., 0], xy_centers[..., 1] - + whs[..., 1], xy_centers[..., 0] + whs[..., 0], + xy_centers[..., 1] + whs[..., 1]), + dim=-1) + return decoded_bboxes diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/demodata.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/demodata.py index d59d65427..eb24b34b6 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/demodata.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/demodata.py @@ -1,35 +1,12 @@ +# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import torch - -def ensure_rng(rng=None): - """ - Simple version of the ``kwarray.ensure_rng`` - - Args: - rng (int | numpy.random.RandomState | None): - if None, then defaults to the global rng. Otherwise this can be an - integer or a RandomState class - Returns: - (numpy.random.RandomState) : rng - - a numpy random number generator - - References: - https://gitlab.kitware.com/computer-vision/kwarray/blob/master/kwarray/util_random.py#L270 - """ - - if rng is None: - rng = np.random.mtrand._rand - elif isinstance(rng, int): - rng = np.random.RandomState(rng) - else: - rng = rng - return rng +from mmdet.utils.util_random import ensure_rng def random_boxes(num=1, scale=1, rng=None): - """ - Simple version of ``kwimage.Boxes.random`` + """Simple version of ``kwimage.Boxes.random`` Returns: Tensor: shape (n, 4) in x1, y1, x2, y2 format. diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/geometry.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/geometry.py deleted file mode 100644 index ff7c5d4fa..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/geometry.py +++ /dev/null @@ -1,88 +0,0 @@ -import torch - - -def bbox_overlaps(bboxes1, bboxes2, mode='iou', is_aligned=False): - """Calculate overlap between two set of bboxes. - - If ``is_aligned`` is ``False``, then calculate the ious between each bbox - of bboxes1 and bboxes2, otherwise the ious between each aligned pair of - bboxes1 and bboxes2. - - Args: - bboxes1 (Tensor): shape (m, 4) in format. - bboxes2 (Tensor): shape (n, 4) in format. - If is_aligned is ``True``, then m and n must be equal. - mode (str): "iou" (intersection over union) or iof (intersection over - foreground). - - Returns: - ious(Tensor): shape (m, n) if is_aligned == False else shape (m, 1) - - Example: - >>> bboxes1 = torch.FloatTensor([ - >>> [0, 0, 10, 10], - >>> [10, 10, 20, 20], - >>> [32, 32, 38, 42], - >>> ]) - >>> bboxes2 = torch.FloatTensor([ - >>> [0, 0, 10, 20], - >>> [0, 10, 10, 19], - >>> [10, 10, 20, 20], - >>> ]) - >>> bbox_overlaps(bboxes1, bboxes2) - tensor([[0.5238, 0.0500, 0.0041], - [0.0323, 0.0452, 1.0000], - [0.0000, 0.0000, 0.0000]]) - - Example: - >>> empty = torch.FloatTensor([]) - >>> nonempty = torch.FloatTensor([ - >>> [0, 0, 10, 9], - >>> ]) - >>> assert tuple(bbox_overlaps(empty, nonempty).shape) == (0, 1) - >>> assert tuple(bbox_overlaps(nonempty, empty).shape) == (1, 0) - >>> assert tuple(bbox_overlaps(empty, empty).shape) == (0, 0) - """ - - assert mode in ['iou', 'iof'] - - rows = bboxes1.size(0) - cols = bboxes2.size(0) - if is_aligned: - assert rows == cols - - if rows * cols == 0: - return bboxes1.new(rows, 1) if is_aligned else bboxes1.new(rows, cols) - - if is_aligned: - lt = torch.max(bboxes1[:, :2], bboxes2[:, :2]) # [rows, 2] - rb = torch.min(bboxes1[:, 2:], bboxes2[:, 2:]) # [rows, 2] - - wh = (rb - lt + 1).clamp(min=0) # [rows, 2] - overlap = wh[:, 0] * wh[:, 1] - area1 = (bboxes1[:, 2] - bboxes1[:, 0] + 1) * ( - bboxes1[:, 3] - bboxes1[:, 1] + 1) - - if mode == 'iou': - area2 = (bboxes2[:, 2] - bboxes2[:, 0] + 1) * ( - bboxes2[:, 3] - bboxes2[:, 1] + 1) - ious = overlap / (area1 + area2 - overlap) - else: - ious = overlap / area1 - else: - lt = torch.max(bboxes1[:, None, :2], bboxes2[:, :2]) # [rows, cols, 2] - rb = torch.min(bboxes1[:, None, 2:], bboxes2[:, 2:]) # [rows, cols, 2] - - wh = (rb - lt + 1).clamp(min=0) # [rows, cols, 2] - overlap = wh[:, :, 0] * wh[:, :, 1] - area1 = (bboxes1[:, 2] - bboxes1[:, 0] + 1) * ( - bboxes1[:, 3] - bboxes1[:, 1] + 1) - - if mode == 'iou': - area2 = (bboxes2[:, 2] - bboxes2[:, 0] + 1) * ( - bboxes2[:, 3] - bboxes2[:, 1] + 1) - ious = overlap / (area1[:, None] + area2 - overlap) - else: - ious = overlap / (area1[:, None]) - - return ious diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/iou_calculators/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/iou_calculators/__init__.py new file mode 100644 index 000000000..04ba925b4 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/iou_calculators/__init__.py @@ -0,0 +1,5 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .builder import build_iou_calculator +from .iou2d_calculator import BboxOverlaps2D, bbox_overlaps + +__all__ = ['build_iou_calculator', 'BboxOverlaps2D', 'bbox_overlaps'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/iou_calculators/builder.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/iou_calculators/builder.py new file mode 100644 index 000000000..378ee269f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/iou_calculators/builder.py @@ -0,0 +1,9 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from mmcv.utils import Registry, build_from_cfg + +IOU_CALCULATORS = Registry('IoU calculator') + + +def build_iou_calculator(cfg, default_args=None): + """Builder of IoU calculator.""" + return build_from_cfg(cfg, IOU_CALCULATORS, default_args) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/iou_calculators/iou2d_calculator.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/iou_calculators/iou2d_calculator.py new file mode 100644 index 000000000..4656d6198 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/iou_calculators/iou2d_calculator.py @@ -0,0 +1,261 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch + +from .builder import IOU_CALCULATORS + + +def cast_tensor_type(x, scale=1., dtype=None): + if dtype == 'fp16': + # scale is for preventing overflows + x = (x / scale).half() + return x + + +def fp16_clamp(x, min=None, max=None): + if not x.is_cuda and x.dtype == torch.float16: + # clamp for cpu float16, tensor fp16 has no clamp implementation + return x.float().clamp(min, max).half() + + return x.clamp(min, max) + + +@IOU_CALCULATORS.register_module() +class BboxOverlaps2D: + """2D Overlaps (e.g. IoUs, GIoUs) Calculator.""" + + def __init__(self, scale=1., dtype=None): + self.scale = scale + self.dtype = dtype + + def __call__(self, bboxes1, bboxes2, mode='iou', is_aligned=False): + """Calculate IoU between 2D bboxes. + + Args: + bboxes1 (Tensor): bboxes have shape (m, 4) in + format, or shape (m, 5) in format. + bboxes2 (Tensor): bboxes have shape (m, 4) in + format, shape (m, 5) in format, or be + empty. If ``is_aligned `` is ``True``, then m and n must be + equal. + mode (str): "iou" (intersection over union), "iof" (intersection + over foreground), or "giou" (generalized intersection over + union). + is_aligned (bool, optional): If True, then m and n must be equal. + Default False. + + Returns: + Tensor: shape (m, n) if ``is_aligned `` is False else shape (m,) + """ + assert bboxes1.size(-1) in [0, 4, 5] + assert bboxes2.size(-1) in [0, 4, 5] + if bboxes2.size(-1) == 5: + bboxes2 = bboxes2[..., :4] + if bboxes1.size(-1) == 5: + bboxes1 = bboxes1[..., :4] + + if self.dtype == 'fp16': + # change tensor type to save cpu and cuda memory and keep speed + bboxes1 = cast_tensor_type(bboxes1, self.scale, self.dtype) + bboxes2 = cast_tensor_type(bboxes2, self.scale, self.dtype) + overlaps = bbox_overlaps(bboxes1, bboxes2, mode, is_aligned) + if not overlaps.is_cuda and overlaps.dtype == torch.float16: + # resume cpu float32 + overlaps = overlaps.float() + return overlaps + + return bbox_overlaps(bboxes1, bboxes2, mode, is_aligned) + + def __repr__(self): + """str: a string describing the module""" + repr_str = self.__class__.__name__ + f'(' \ + f'scale={self.scale}, dtype={self.dtype})' + return repr_str + + +def bbox_overlaps(bboxes1, bboxes2, mode='iou', is_aligned=False, eps=1e-6): + """Calculate overlap between two set of bboxes. + + FP16 Contributed by https://github.com/open-mmlab/mmdetection/pull/4889 + Note: + Assume bboxes1 is M x 4, bboxes2 is N x 4, when mode is 'iou', + there are some new generated variable when calculating IOU + using bbox_overlaps function: + + 1) is_aligned is False + area1: M x 1 + area2: N x 1 + lt: M x N x 2 + rb: M x N x 2 + wh: M x N x 2 + overlap: M x N x 1 + union: M x N x 1 + ious: M x N x 1 + + Total memory: + S = (9 x N x M + N + M) * 4 Byte, + + When using FP16, we can reduce: + R = (9 x N x M + N + M) * 4 / 2 Byte + R large than (N + M) * 4 * 2 is always true when N and M >= 1. + Obviously, N + M <= N * M < 3 * N * M, when N >=2 and M >=2, + N + 1 < 3 * N, when N or M is 1. + + Given M = 40 (ground truth), N = 400000 (three anchor boxes + in per grid, FPN, R-CNNs), + R = 275 MB (one times) + + A special case (dense detection), M = 512 (ground truth), + R = 3516 MB = 3.43 GB + + When the batch size is B, reduce: + B x R + + Therefore, CUDA memory runs out frequently. + + Experiments on GeForce RTX 2080Ti (11019 MiB): + + | dtype | M | N | Use | Real | Ideal | + |:----:|:----:|:----:|:----:|:----:|:----:| + | FP32 | 512 | 400000 | 8020 MiB | -- | -- | + | FP16 | 512 | 400000 | 4504 MiB | 3516 MiB | 3516 MiB | + | FP32 | 40 | 400000 | 1540 MiB | -- | -- | + | FP16 | 40 | 400000 | 1264 MiB | 276MiB | 275 MiB | + + 2) is_aligned is True + area1: N x 1 + area2: N x 1 + lt: N x 2 + rb: N x 2 + wh: N x 2 + overlap: N x 1 + union: N x 1 + ious: N x 1 + + Total memory: + S = 11 x N * 4 Byte + + When using FP16, we can reduce: + R = 11 x N * 4 / 2 Byte + + So do the 'giou' (large than 'iou'). + + Time-wise, FP16 is generally faster than FP32. + + When gpu_assign_thr is not -1, it takes more time on cpu + but not reduce memory. + There, we can reduce half the memory and keep the speed. + + If ``is_aligned`` is ``False``, then calculate the overlaps between each + bbox of bboxes1 and bboxes2, otherwise the overlaps between each aligned + pair of bboxes1 and bboxes2. + + Args: + bboxes1 (Tensor): shape (B, m, 4) in format or empty. + bboxes2 (Tensor): shape (B, n, 4) in format or empty. + B indicates the batch dim, in shape (B1, B2, ..., Bn). + If ``is_aligned`` is ``True``, then m and n must be equal. + mode (str): "iou" (intersection over union), "iof" (intersection over + foreground) or "giou" (generalized intersection over union). + Default "iou". + is_aligned (bool, optional): If True, then m and n must be equal. + Default False. + eps (float, optional): A value added to the denominator for numerical + stability. Default 1e-6. + + Returns: + Tensor: shape (m, n) if ``is_aligned`` is False else shape (m,) + + Example: + >>> bboxes1 = torch.FloatTensor([ + >>> [0, 0, 10, 10], + >>> [10, 10, 20, 20], + >>> [32, 32, 38, 42], + >>> ]) + >>> bboxes2 = torch.FloatTensor([ + >>> [0, 0, 10, 20], + >>> [0, 10, 10, 19], + >>> [10, 10, 20, 20], + >>> ]) + >>> overlaps = bbox_overlaps(bboxes1, bboxes2) + >>> assert overlaps.shape == (3, 3) + >>> overlaps = bbox_overlaps(bboxes1, bboxes2, is_aligned=True) + >>> assert overlaps.shape == (3, ) + + Example: + >>> empty = torch.empty(0, 4) + >>> nonempty = torch.FloatTensor([[0, 0, 10, 9]]) + >>> assert tuple(bbox_overlaps(empty, nonempty).shape) == (0, 1) + >>> assert tuple(bbox_overlaps(nonempty, empty).shape) == (1, 0) + >>> assert tuple(bbox_overlaps(empty, empty).shape) == (0, 0) + """ + + assert mode in ['iou', 'iof', 'giou'], f'Unsupported mode {mode}' + # Either the boxes are empty or the length of boxes' last dimension is 4 + assert (bboxes1.size(-1) == 4 or bboxes1.size(0) == 0) + assert (bboxes2.size(-1) == 4 or bboxes2.size(0) == 0) + + # Batch dim must be the same + # Batch dim: (B1, B2, ... Bn) + assert bboxes1.shape[:-2] == bboxes2.shape[:-2] + batch_shape = bboxes1.shape[:-2] + + rows = bboxes1.size(-2) + cols = bboxes2.size(-2) + if is_aligned: + assert rows == cols + + if rows * cols == 0: + if is_aligned: + return bboxes1.new(batch_shape + (rows, )) + else: + return bboxes1.new(batch_shape + (rows, cols)) + + area1 = (bboxes1[..., 2] - bboxes1[..., 0]) * ( + bboxes1[..., 3] - bboxes1[..., 1]) + area2 = (bboxes2[..., 2] - bboxes2[..., 0]) * ( + bboxes2[..., 3] - bboxes2[..., 1]) + + if is_aligned: + lt = torch.max(bboxes1[..., :2], bboxes2[..., :2]) # [B, rows, 2] + rb = torch.min(bboxes1[..., 2:], bboxes2[..., 2:]) # [B, rows, 2] + + wh = fp16_clamp(rb - lt, min=0) + overlap = wh[..., 0] * wh[..., 1] + + if mode in ['iou', 'giou']: + union = area1 + area2 - overlap + else: + union = area1 + if mode == 'giou': + enclosed_lt = torch.min(bboxes1[..., :2], bboxes2[..., :2]) + enclosed_rb = torch.max(bboxes1[..., 2:], bboxes2[..., 2:]) + else: + lt = torch.max(bboxes1[..., :, None, :2], + bboxes2[..., None, :, :2]) # [B, rows, cols, 2] + rb = torch.min(bboxes1[..., :, None, 2:], + bboxes2[..., None, :, 2:]) # [B, rows, cols, 2] + + wh = fp16_clamp(rb - lt, min=0) + overlap = wh[..., 0] * wh[..., 1] + + if mode in ['iou', 'giou']: + union = area1[..., None] + area2[..., None, :] - overlap + else: + union = area1[..., None] + if mode == 'giou': + enclosed_lt = torch.min(bboxes1[..., :, None, :2], + bboxes2[..., None, :, :2]) + enclosed_rb = torch.max(bboxes1[..., :, None, 2:], + bboxes2[..., None, :, 2:]) + + eps = union.new_tensor([eps]) + union = torch.max(union, eps) + ious = overlap / union + if mode in ['iou', 'iof']: + return ious + # calculate gious + enclose_wh = fp16_clamp(enclosed_rb - enclosed_lt, min=0) + enclose_area = enclose_wh[..., 0] * enclose_wh[..., 1] + enclose_area = torch.max(enclose_area, eps) + gious = ious - (enclose_area - union) / enclose_area + return gious diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/match_costs/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/match_costs/__init__.py new file mode 100644 index 000000000..1b6367950 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/match_costs/__init__.py @@ -0,0 +1,9 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .builder import build_match_cost +from .match_cost import (BBoxL1Cost, ClassificationCost, CrossEntropyLossCost, + DiceCost, FocalLossCost, IoUCost) + +__all__ = [ + 'build_match_cost', 'ClassificationCost', 'BBoxL1Cost', 'IoUCost', + 'FocalLossCost', 'DiceCost', 'CrossEntropyLossCost' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/match_costs/builder.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/match_costs/builder.py new file mode 100644 index 000000000..ea086adff --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/match_costs/builder.py @@ -0,0 +1,9 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from mmcv.utils import Registry, build_from_cfg + +MATCH_COST = Registry('Match Cost') + + +def build_match_cost(cfg, default_args=None): + """Builder of IoU calculator.""" + return build_from_cfg(cfg, MATCH_COST, default_args) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/match_costs/match_cost.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/match_costs/match_cost.py new file mode 100644 index 000000000..4342b0245 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/match_costs/match_cost.py @@ -0,0 +1,359 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch +import torch.nn.functional as F + +from mmdet.core.bbox.iou_calculators import bbox_overlaps +from mmdet.core.bbox.transforms import bbox_cxcywh_to_xyxy, bbox_xyxy_to_cxcywh +from .builder import MATCH_COST + + +@MATCH_COST.register_module() +class BBoxL1Cost: + """BBoxL1Cost. + + Args: + weight (int | float, optional): loss_weight + box_format (str, optional): 'xyxy' for DETR, 'xywh' for Sparse_RCNN + + Examples: + >>> from mmdet.core.bbox.match_costs.match_cost import BBoxL1Cost + >>> import torch + >>> self = BBoxL1Cost() + >>> bbox_pred = torch.rand(1, 4) + >>> gt_bboxes= torch.FloatTensor([[0, 0, 2, 4], [1, 2, 3, 4]]) + >>> factor = torch.tensor([10, 8, 10, 8]) + >>> self(bbox_pred, gt_bboxes, factor) + tensor([[1.6172, 1.6422]]) + """ + + def __init__(self, weight=1., box_format='xyxy'): + self.weight = weight + assert box_format in ['xyxy', 'xywh'] + self.box_format = box_format + + def __call__(self, bbox_pred, gt_bboxes): + """ + Args: + bbox_pred (Tensor): Predicted boxes with normalized coordinates + (cx, cy, w, h), which are all in range [0, 1]. Shape + (num_query, 4). + gt_bboxes (Tensor): Ground truth boxes with normalized + coordinates (x1, y1, x2, y2). Shape (num_gt, 4). + + Returns: + torch.Tensor: bbox_cost value with weight + """ + if self.box_format == 'xywh': + gt_bboxes = bbox_xyxy_to_cxcywh(gt_bboxes) + elif self.box_format == 'xyxy': + bbox_pred = bbox_cxcywh_to_xyxy(bbox_pred) + bbox_cost = torch.cdist(bbox_pred, gt_bboxes, p=1) + return bbox_cost * self.weight + + +@MATCH_COST.register_module() +class FocalLossCost: + """FocalLossCost. + + Args: + weight (int | float, optional): loss_weight + alpha (int | float, optional): focal_loss alpha + gamma (int | float, optional): focal_loss gamma + eps (float, optional): default 1e-12 + binary_input (bool, optional): Whether the input is binary, + default False. + + Examples: + >>> from mmdet.core.bbox.match_costs.match_cost import FocalLossCost + >>> import torch + >>> self = FocalLossCost() + >>> cls_pred = torch.rand(4, 3) + >>> gt_labels = torch.tensor([0, 1, 2]) + >>> factor = torch.tensor([10, 8, 10, 8]) + >>> self(cls_pred, gt_labels) + tensor([[-0.3236, -0.3364, -0.2699], + [-0.3439, -0.3209, -0.4807], + [-0.4099, -0.3795, -0.2929], + [-0.1950, -0.1207, -0.2626]]) + """ + + def __init__(self, + weight=1., + alpha=0.25, + gamma=2, + eps=1e-12, + binary_input=False): + self.weight = weight + self.alpha = alpha + self.gamma = gamma + self.eps = eps + self.binary_input = binary_input + + def _focal_loss_cost(self, cls_pred, gt_labels): + """ + Args: + cls_pred (Tensor): Predicted classification logits, shape + (num_query, num_class). + gt_labels (Tensor): Label of `gt_bboxes`, shape (num_gt,). + + Returns: + torch.Tensor: cls_cost value with weight + """ + cls_pred = cls_pred.sigmoid() + neg_cost = -(1 - cls_pred + self.eps).log() * ( + 1 - self.alpha) * cls_pred.pow(self.gamma) + pos_cost = -(cls_pred + self.eps).log() * self.alpha * ( + 1 - cls_pred).pow(self.gamma) + + cls_cost = pos_cost[:, gt_labels] - neg_cost[:, gt_labels] + return cls_cost * self.weight + + def _mask_focal_loss_cost(self, cls_pred, gt_labels): + """ + Args: + cls_pred (Tensor): Predicted classfication logits + in shape (num_query, d1, ..., dn), dtype=torch.float32. + gt_labels (Tensor): Ground truth in shape (num_gt, d1, ..., dn), + dtype=torch.long. Labels should be binary. + + Returns: + Tensor: Focal cost matrix with weight in shape\ + (num_query, num_gt). + """ + cls_pred = cls_pred.flatten(1) + gt_labels = gt_labels.flatten(1).float() + n = cls_pred.shape[1] + cls_pred = cls_pred.sigmoid() + neg_cost = -(1 - cls_pred + self.eps).log() * ( + 1 - self.alpha) * cls_pred.pow(self.gamma) + pos_cost = -(cls_pred + self.eps).log() * self.alpha * ( + 1 - cls_pred).pow(self.gamma) + + cls_cost = torch.einsum('nc,mc->nm', pos_cost, gt_labels) + \ + torch.einsum('nc,mc->nm', neg_cost, (1 - gt_labels)) + return cls_cost / n * self.weight + + def __call__(self, cls_pred, gt_labels): + """ + Args: + cls_pred (Tensor): Predicted classfication logits. + gt_labels (Tensor)): Labels. + + Returns: + Tensor: Focal cost matrix with weight in shape\ + (num_query, num_gt). + """ + if self.binary_input: + return self._mask_focal_loss_cost(cls_pred, gt_labels) + else: + return self._focal_loss_cost(cls_pred, gt_labels) + + +@MATCH_COST.register_module() +class ClassificationCost: + """ClsSoftmaxCost. + + Args: + weight (int | float, optional): loss_weight + + Examples: + >>> from mmdet.core.bbox.match_costs.match_cost import \ + ... ClassificationCost + >>> import torch + >>> self = ClassificationCost() + >>> cls_pred = torch.rand(4, 3) + >>> gt_labels = torch.tensor([0, 1, 2]) + >>> factor = torch.tensor([10, 8, 10, 8]) + >>> self(cls_pred, gt_labels) + tensor([[-0.3430, -0.3525, -0.3045], + [-0.3077, -0.2931, -0.3992], + [-0.3664, -0.3455, -0.2881], + [-0.3343, -0.2701, -0.3956]]) + """ + + def __init__(self, weight=1.): + self.weight = weight + + def __call__(self, cls_pred, gt_labels): + """ + Args: + cls_pred (Tensor): Predicted classification logits, shape + (num_query, num_class). + gt_labels (Tensor): Label of `gt_bboxes`, shape (num_gt,). + + Returns: + torch.Tensor: cls_cost value with weight + """ + # Following the official DETR repo, contrary to the loss that + # NLL is used, we approximate it in 1 - cls_score[gt_label]. + # The 1 is a constant that doesn't change the matching, + # so it can be omitted. + cls_score = cls_pred.softmax(-1) + cls_cost = -cls_score[:, gt_labels] + return cls_cost * self.weight + + +@MATCH_COST.register_module() +class IoUCost: + """IoUCost. + + Args: + iou_mode (str, optional): iou mode such as 'iou' | 'giou' + weight (int | float, optional): loss weight + + Examples: + >>> from mmdet.core.bbox.match_costs.match_cost import IoUCost + >>> import torch + >>> self = IoUCost() + >>> bboxes = torch.FloatTensor([[1,1, 2, 2], [2, 2, 3, 4]]) + >>> gt_bboxes = torch.FloatTensor([[0, 0, 2, 4], [1, 2, 3, 4]]) + >>> self(bboxes, gt_bboxes) + tensor([[-0.1250, 0.1667], + [ 0.1667, -0.5000]]) + """ + + def __init__(self, iou_mode='giou', weight=1.): + self.weight = weight + self.iou_mode = iou_mode + + def __call__(self, bboxes, gt_bboxes): + """ + Args: + bboxes (Tensor): Predicted boxes with unnormalized coordinates + (x1, y1, x2, y2). Shape (num_query, 4). + gt_bboxes (Tensor): Ground truth boxes with unnormalized + coordinates (x1, y1, x2, y2). Shape (num_gt, 4). + + Returns: + torch.Tensor: iou_cost value with weight + """ + # overlaps: [num_bboxes, num_gt] + overlaps = bbox_overlaps( + bboxes, gt_bboxes, mode=self.iou_mode, is_aligned=False) + # The 1 is a constant that doesn't change the matching, so omitted. + iou_cost = -overlaps + return iou_cost * self.weight + + +@MATCH_COST.register_module() +class DiceCost: + """Cost of mask assignments based on dice losses. + + Args: + weight (int | float, optional): loss_weight. Defaults to 1. + pred_act (bool, optional): Whether to apply sigmoid to mask_pred. + Defaults to False. + eps (float, optional): default 1e-12. + naive_dice (bool, optional): If True, use the naive dice loss + in which the power of the number in the denominator is + the first power. If Flase, use the second power that + is adopted by K-Net and SOLO. + Defaults to True. + """ + + def __init__(self, weight=1., pred_act=False, eps=1e-3, naive_dice=True): + self.weight = weight + self.pred_act = pred_act + self.eps = eps + self.naive_dice = naive_dice + + def binary_mask_dice_loss(self, mask_preds, gt_masks): + """ + Args: + mask_preds (Tensor): Mask prediction in shape (num_query, *). + gt_masks (Tensor): Ground truth in shape (num_gt, *) + store 0 or 1, 0 for negative class and 1 for + positive class. + + Returns: + Tensor: Dice cost matrix in shape (num_query, num_gt). + """ + mask_preds = mask_preds.flatten(1) + gt_masks = gt_masks.flatten(1).float() + numerator = 2 * torch.einsum('nc,mc->nm', mask_preds, gt_masks) + if self.naive_dice: + denominator = mask_preds.sum(-1)[:, None] + \ + gt_masks.sum(-1)[None, :] + else: + denominator = mask_preds.pow(2).sum(1)[:, None] + \ + gt_masks.pow(2).sum(1)[None, :] + loss = 1 - (numerator + self.eps) / (denominator + self.eps) + return loss + + def __call__(self, mask_preds, gt_masks): + """ + Args: + mask_preds (Tensor): Mask prediction logits in shape (num_query, *) + gt_masks (Tensor): Ground truth in shape (num_gt, *) + + Returns: + Tensor: Dice cost matrix with weight in shape (num_query, num_gt). + """ + if self.pred_act: + mask_preds = mask_preds.sigmoid() + dice_cost = self.binary_mask_dice_loss(mask_preds, gt_masks) + return dice_cost * self.weight + + +@MATCH_COST.register_module() +class CrossEntropyLossCost: + """CrossEntropyLossCost. + + Args: + weight (int | float, optional): loss weight. Defaults to 1. + use_sigmoid (bool, optional): Whether the prediction uses sigmoid + of softmax. Defaults to True. + Examples: + >>> from mmdet.core.bbox.match_costs import CrossEntropyLossCost + >>> import torch + >>> bce = CrossEntropyLossCost(use_sigmoid=True) + >>> cls_pred = torch.tensor([[7.6, 1.2], [-1.3, 10]]) + >>> gt_labels = torch.tensor([[1, 1], [1, 0]]) + >>> print(bce(cls_pred, gt_labels)) + """ + + def __init__(self, weight=1., use_sigmoid=True): + assert use_sigmoid, 'use_sigmoid = False is not supported yet.' + self.weight = weight + self.use_sigmoid = use_sigmoid + + def _binary_cross_entropy(self, cls_pred, gt_labels): + """ + Args: + cls_pred (Tensor): The prediction with shape (num_query, 1, *) or + (num_query, *). + gt_labels (Tensor): The learning label of prediction with + shape (num_gt, *). + + Returns: + Tensor: Cross entropy cost matrix in shape (num_query, num_gt). + """ + cls_pred = cls_pred.flatten(1).float() + gt_labels = gt_labels.flatten(1).float() + n = cls_pred.shape[1] + pos = F.binary_cross_entropy_with_logits( + cls_pred, torch.ones_like(cls_pred), reduction='none') + neg = F.binary_cross_entropy_with_logits( + cls_pred, torch.zeros_like(cls_pred), reduction='none') + cls_cost = torch.einsum('nc,mc->nm', pos, gt_labels) + \ + torch.einsum('nc,mc->nm', neg, 1 - gt_labels) + cls_cost = cls_cost / n + + return cls_cost + + def __call__(self, cls_pred, gt_labels): + """ + Args: + cls_pred (Tensor): Predicted classification logits. + gt_labels (Tensor): Labels. + + Returns: + Tensor: Cross entropy cost matrix with weight in + shape (num_query, num_gt). + """ + if self.use_sigmoid: + cls_cost = self._binary_cross_entropy(cls_pred, gt_labels) + else: + raise NotImplementedError + + return cls_cost * self.weight diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/__init__.py index d709d8ecb..f58505b59 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/__init__.py @@ -1,14 +1,19 @@ +# Copyright (c) OpenMMLab. All rights reserved. from .base_sampler import BaseSampler from .combined_sampler import CombinedSampler from .instance_balanced_pos_sampler import InstanceBalancedPosSampler from .iou_balanced_neg_sampler import IoUBalancedNegSampler +from .mask_pseudo_sampler import MaskPseudoSampler +from .mask_sampling_result import MaskSamplingResult from .ohem_sampler import OHEMSampler from .pseudo_sampler import PseudoSampler from .random_sampler import RandomSampler from .sampling_result import SamplingResult +from .score_hlr_sampler import ScoreHLRSampler __all__ = [ 'BaseSampler', 'PseudoSampler', 'RandomSampler', 'InstanceBalancedPosSampler', 'IoUBalancedNegSampler', 'CombinedSampler', - 'OHEMSampler', 'SamplingResult' + 'OHEMSampler', 'SamplingResult', 'ScoreHLRSampler', 'MaskPseudoSampler', + 'MaskSamplingResult' ] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/base_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/base_sampler.py index f437195f6..bd15c7c64 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/base_sampler.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/base_sampler.py @@ -1,3 +1,4 @@ +# Copyright (c) OpenMMLab. All rights reserved. from abc import ABCMeta, abstractmethod import torch @@ -6,6 +7,7 @@ from .sampling_result import SamplingResult class BaseSampler(metaclass=ABCMeta): + """Base class of samplers.""" def __init__(self, num, @@ -22,10 +24,12 @@ class BaseSampler(metaclass=ABCMeta): @abstractmethod def _sample_pos(self, assign_result, num_expected, **kwargs): + """Sample positive samples.""" pass @abstractmethod def _sample_neg(self, assign_result, num_expected, **kwargs): + """Sample negative samples.""" pass def sample(self, diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/combined_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/combined_sampler.py index 351a097f6..4f6d86ff2 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/combined_sampler.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/combined_sampler.py @@ -1,8 +1,11 @@ -from ..assign_sampling import build_sampler +# Copyright (c) OpenMMLab. All rights reserved. +from ..builder import BBOX_SAMPLERS, build_sampler from .base_sampler import BaseSampler +@BBOX_SAMPLERS.register_module() class CombinedSampler(BaseSampler): + """A sampler that combines positive sampler and negative sampler.""" def __init__(self, pos_sampler, neg_sampler, **kwargs): super(CombinedSampler, self).__init__(**kwargs) @@ -10,7 +13,9 @@ class CombinedSampler(BaseSampler): self.neg_sampler = build_sampler(neg_sampler, **kwargs) def _sample_pos(self, **kwargs): + """Sample positive samples.""" raise NotImplementedError def _sample_neg(self, **kwargs): + """Sample negative samples.""" raise NotImplementedError diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/instance_balanced_pos_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/instance_balanced_pos_sampler.py index bc829a236..5e0d9cc0e 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/instance_balanced_pos_sampler.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/instance_balanced_pos_sampler.py @@ -1,13 +1,27 @@ +# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import torch +from ..builder import BBOX_SAMPLERS from .random_sampler import RandomSampler +@BBOX_SAMPLERS.register_module() class InstanceBalancedPosSampler(RandomSampler): + """Instance balanced sampler that samples equal number of positive samples + for each instance.""" def _sample_pos(self, assign_result, num_expected, **kwargs): - pos_inds = torch.nonzero(assign_result.gt_inds > 0) + """Sample positive boxes. + + Args: + assign_result (:obj:`AssignResult`): The assigned results of boxes. + num_expected (int): The number of expected positive samples + + Returns: + Tensor or ndarray: sampled indices. + """ + pos_inds = torch.nonzero(assign_result.gt_inds > 0, as_tuple=False) if pos_inds.numel() != 0: pos_inds = pos_inds.squeeze(1) if pos_inds.numel() <= num_expected: @@ -18,7 +32,8 @@ class InstanceBalancedPosSampler(RandomSampler): num_per_gt = int(round(num_expected / float(num_gts)) + 1) sampled_inds = [] for i in unique_gt_inds: - inds = torch.nonzero(assign_result.gt_inds == i.item()) + inds = torch.nonzero( + assign_result.gt_inds == i.item(), as_tuple=False) if inds.numel() != 0: inds = inds.squeeze(1) else: diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/iou_balanced_neg_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/iou_balanced_neg_sampler.py index d9239e070..56e2874a4 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/iou_balanced_neg_sampler.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/iou_balanced_neg_sampler.py @@ -1,11 +1,14 @@ +# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import torch +from ..builder import BBOX_SAMPLERS from .random_sampler import RandomSampler +@BBOX_SAMPLERS.register_module() class IoUBalancedNegSampler(RandomSampler): - """IoU Balanced Sampling + """IoU Balanced Sampling. arXiv: https://arxiv.org/pdf/1904.02701.pdf (CVPR 2019) @@ -42,6 +45,17 @@ class IoUBalancedNegSampler(RandomSampler): self.num_bins = num_bins def sample_via_interval(self, max_overlaps, full_set, num_expected): + """Sample according to the iou interval. + + Args: + max_overlaps (torch.Tensor): IoU between bounding boxes and ground + truth boxes. + full_set (set(int)): A full set of indices of boxes。 + num_expected (int): Number of expected samples。 + + Returns: + np.ndarray: Indices of samples + """ max_iou = max_overlaps.max() iou_interval = (max_iou - self.floor_thr) / self.num_bins per_num_expected = int(num_expected / self.num_bins) @@ -73,7 +87,16 @@ class IoUBalancedNegSampler(RandomSampler): return sampled_inds def _sample_neg(self, assign_result, num_expected, **kwargs): - neg_inds = torch.nonzero(assign_result.gt_inds == 0) + """Sample negative boxes. + + Args: + assign_result (:obj:`AssignResult`): The assigned results of boxes. + num_expected (int): The number of expected negative samples + + Returns: + Tensor or ndarray: sampled indices. + """ + neg_inds = torch.nonzero(assign_result.gt_inds == 0, as_tuple=False) if neg_inds.numel() != 0: neg_inds = neg_inds.squeeze(1) if len(neg_inds) <= num_expected: diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/mask_pseudo_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/mask_pseudo_sampler.py new file mode 100644 index 000000000..b5f69658d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/mask_pseudo_sampler.py @@ -0,0 +1,44 @@ +# Copyright (c) OpenMMLab. All rights reserved. +"""copy from +https://github.com/ZwwWayne/K-Net/blob/main/knet/det/mask_pseudo_sampler.py.""" + +import torch + +from mmdet.core.bbox.builder import BBOX_SAMPLERS +from .base_sampler import BaseSampler +from .mask_sampling_result import MaskSamplingResult + + +@BBOX_SAMPLERS.register_module() +class MaskPseudoSampler(BaseSampler): + """A pseudo sampler that does not do sampling actually.""" + + def __init__(self, **kwargs): + pass + + def _sample_pos(self, **kwargs): + """Sample positive samples.""" + raise NotImplementedError + + def _sample_neg(self, **kwargs): + """Sample negative samples.""" + raise NotImplementedError + + def sample(self, assign_result, masks, gt_masks, **kwargs): + """Directly returns the positive and negative indices of samples. + + Args: + assign_result (:obj:`AssignResult`): Assigned results + masks (torch.Tensor): Bounding boxes + gt_masks (torch.Tensor): Ground truth boxes + Returns: + :obj:`SamplingResult`: sampler results + """ + pos_inds = torch.nonzero( + assign_result.gt_inds > 0, as_tuple=False).squeeze(-1).unique() + neg_inds = torch.nonzero( + assign_result.gt_inds == 0, as_tuple=False).squeeze(-1).unique() + gt_flags = masks.new_zeros(masks.shape[0], dtype=torch.uint8) + sampling_result = MaskSamplingResult(pos_inds, neg_inds, masks, + gt_masks, assign_result, gt_flags) + return sampling_result diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/mask_sampling_result.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/mask_sampling_result.py new file mode 100644 index 000000000..3d1094322 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/mask_sampling_result.py @@ -0,0 +1,60 @@ +# Copyright (c) OpenMMLab. All rights reserved. +"""copy from +https://github.com/ZwwWayne/K-Net/blob/main/knet/det/mask_pseudo_sampler.py.""" + +import torch + +from .sampling_result import SamplingResult + + +class MaskSamplingResult(SamplingResult): + """Mask sampling result.""" + + def __init__(self, pos_inds, neg_inds, masks, gt_masks, assign_result, + gt_flags): + self.pos_inds = pos_inds + self.neg_inds = neg_inds + self.pos_masks = masks[pos_inds] + self.neg_masks = masks[neg_inds] + self.pos_is_gt = gt_flags[pos_inds] + + self.num_gts = gt_masks.shape[0] + self.pos_assigned_gt_inds = assign_result.gt_inds[pos_inds] - 1 + + if gt_masks.numel() == 0: + # hack for index error case + assert self.pos_assigned_gt_inds.numel() == 0 + self.pos_gt_masks = torch.empty_like(gt_masks) + else: + self.pos_gt_masks = gt_masks[self.pos_assigned_gt_inds, :] + + if assign_result.labels is not None: + self.pos_gt_labels = assign_result.labels[pos_inds] + else: + self.pos_gt_labels = None + + @property + def masks(self): + """torch.Tensor: concatenated positive and negative boxes""" + return torch.cat([self.pos_masks, self.neg_masks]) + + def __nice__(self): + data = self.info.copy() + data['pos_masks'] = data.pop('pos_masks').shape + data['neg_masks'] = data.pop('neg_masks').shape + parts = [f"'{k}': {v!r}" for k, v in sorted(data.items())] + body = ' ' + ',\n '.join(parts) + return '{\n' + body + '\n}' + + @property + def info(self): + """Returns a dictionary of info about the object.""" + return { + 'pos_inds': self.pos_inds, + 'neg_inds': self.neg_inds, + 'pos_masks': self.pos_masks, + 'neg_masks': self.neg_masks, + 'pos_is_gt': self.pos_is_gt, + 'num_gts': self.num_gts, + 'pos_assigned_gt_inds': self.pos_assigned_gt_inds, + } diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/ohem_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/ohem_sampler.py index 3701d83ac..7eb066633 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/ohem_sampler.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/ohem_sampler.py @@ -1,15 +1,16 @@ +# Copyright (c) OpenMMLab. All rights reserved. import torch +from ..builder import BBOX_SAMPLERS from ..transforms import bbox2roi from .base_sampler import BaseSampler +@BBOX_SAMPLERS.register_module() class OHEMSampler(BaseSampler): - """ - Online Hard Example Mining Sampler described in [1]_. - - References: - .. [1] https://arxiv.org/pdf/1604.03540.pdf + r"""Online Hard Example Mining Sampler described in `Training Region-based + Object Detectors with Online Hard Example Mining + `_. """ def __init__(self, @@ -18,31 +19,36 @@ class OHEMSampler(BaseSampler): context, neg_pos_ub=-1, add_gt_as_proposals=True, + loss_key='loss_cls', **kwargs): super(OHEMSampler, self).__init__(num, pos_fraction, neg_pos_ub, add_gt_as_proposals) - if not hasattr(context, 'num_stages'): - self.bbox_roi_extractor = context.bbox_roi_extractor - self.bbox_head = context.bbox_head + self.context = context + if not hasattr(self.context, 'num_stages'): + self.bbox_head = self.context.bbox_head else: - self.bbox_roi_extractor = context.bbox_roi_extractor[ - context.current_stage] - self.bbox_head = context.bbox_head[context.current_stage] + self.bbox_head = self.context.bbox_head[self.context.current_stage] + + self.loss_key = loss_key def hard_mining(self, inds, num_expected, bboxes, labels, feats): with torch.no_grad(): rois = bbox2roi([bboxes]) - bbox_feats = self.bbox_roi_extractor( - feats[:self.bbox_roi_extractor.num_inputs], rois) - cls_score, _ = self.bbox_head(bbox_feats) + if not hasattr(self.context, 'num_stages'): + bbox_results = self.context._bbox_forward(feats, rois) + else: + bbox_results = self.context._bbox_forward( + self.context.current_stage, feats, rois) + cls_score = bbox_results['cls_score'] loss = self.bbox_head.loss( cls_score=cls_score, bbox_pred=None, + rois=rois, labels=labels, label_weights=cls_score.new_ones(cls_score.size(0)), bbox_targets=None, bbox_weights=None, - reduction_override='none')['loss_cls'] + reduction_override='none')[self.loss_key] _, topk_loss_inds = loss.topk(num_expected) return inds[topk_loss_inds] @@ -52,8 +58,20 @@ class OHEMSampler(BaseSampler): bboxes=None, feats=None, **kwargs): + """Sample positive boxes. + + Args: + assign_result (:obj:`AssignResult`): Assigned results + num_expected (int): Number of expected positive samples + bboxes (torch.Tensor, optional): Boxes. Defaults to None. + feats (list[torch.Tensor], optional): Multi-level features. + Defaults to None. + + Returns: + torch.Tensor: Indices of positive samples + """ # Sample some hard positive samples - pos_inds = torch.nonzero(assign_result.gt_inds > 0) + pos_inds = torch.nonzero(assign_result.gt_inds > 0, as_tuple=False) if pos_inds.numel() != 0: pos_inds = pos_inds.squeeze(1) if pos_inds.numel() <= num_expected: @@ -68,12 +86,26 @@ class OHEMSampler(BaseSampler): bboxes=None, feats=None, **kwargs): + """Sample negative boxes. + + Args: + assign_result (:obj:`AssignResult`): Assigned results + num_expected (int): Number of expected negative samples + bboxes (torch.Tensor, optional): Boxes. Defaults to None. + feats (list[torch.Tensor], optional): Multi-level features. + Defaults to None. + + Returns: + torch.Tensor: Indices of negative samples + """ # Sample some hard negative samples - neg_inds = torch.nonzero(assign_result.gt_inds == 0) + neg_inds = torch.nonzero(assign_result.gt_inds == 0, as_tuple=False) if neg_inds.numel() != 0: neg_inds = neg_inds.squeeze(1) if len(neg_inds) <= num_expected: return neg_inds else: + neg_labels = assign_result.labels.new_empty( + neg_inds.size(0)).fill_(self.bbox_head.num_classes) return self.hard_mining(neg_inds, num_expected, bboxes[neg_inds], - assign_result.labels[neg_inds], feats) + neg_labels, feats) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/pseudo_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/pseudo_sampler.py index b4c2ea09b..b5ce298ed 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/pseudo_sampler.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/pseudo_sampler.py @@ -1,25 +1,41 @@ +# Copyright (c) OpenMMLab. All rights reserved. import torch +from ..builder import BBOX_SAMPLERS from .base_sampler import BaseSampler from .sampling_result import SamplingResult +@BBOX_SAMPLERS.register_module() class PseudoSampler(BaseSampler): + """A pseudo sampler that does not do sampling actually.""" def __init__(self, **kwargs): pass def _sample_pos(self, **kwargs): + """Sample positive samples.""" raise NotImplementedError def _sample_neg(self, **kwargs): + """Sample negative samples.""" raise NotImplementedError - def sample(self, assign_result, bboxes, gt_bboxes, **kwargs): + def sample(self, assign_result, bboxes, gt_bboxes, *args, **kwargs): + """Directly returns the positive and negative indices of samples. + + Args: + assign_result (:obj:`AssignResult`): Assigned results + bboxes (torch.Tensor): Bounding boxes + gt_bboxes (torch.Tensor): Ground truth boxes + + Returns: + :obj:`SamplingResult`: sampler results + """ pos_inds = torch.nonzero( - assign_result.gt_inds > 0).squeeze(-1).unique() + assign_result.gt_inds > 0, as_tuple=False).squeeze(-1).unique() neg_inds = torch.nonzero( - assign_result.gt_inds == 0).squeeze(-1).unique() + assign_result.gt_inds == 0, as_tuple=False).squeeze(-1).unique() gt_flags = bboxes.new_zeros(bboxes.shape[0], dtype=torch.uint8) sampling_result = SamplingResult(pos_inds, neg_inds, bboxes, gt_bboxes, assign_result, gt_flags) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/random_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/random_sampler.py index 3db00bab0..d09207e7f 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/random_sampler.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/random_sampler.py @@ -1,10 +1,22 @@ -import numpy as np +# Copyright (c) OpenMMLab. All rights reserved. import torch +from ..builder import BBOX_SAMPLERS from .base_sampler import BaseSampler +@BBOX_SAMPLERS.register_module() class RandomSampler(BaseSampler): + """Random sampler. + + Args: + num (int): Number of samples + pos_fraction (float): Fraction of positive samples + neg_pos_up (int, optional): Upper bound number of negative and + positive samples. Defaults to -1. + add_gt_as_proposals (bool, optional): Whether to add ground truth + boxes as proposals. Defaults to True. + """ def __init__(self, num, @@ -20,22 +32,38 @@ class RandomSampler(BaseSampler): def random_choice(self, gallery, num): """Random select some elements from the gallery. - It seems that Pytorch's implementation is slower than numpy so we use - numpy to randperm the indices. + If `gallery` is a Tensor, the returned indices will be a Tensor; + If `gallery` is a ndarray or list, the returned indices will be a + ndarray. + + Args: + gallery (Tensor | ndarray | list): indices pool. + num (int): expected sample num. + + Returns: + Tensor or ndarray: sampled indices. """ assert len(gallery) >= num - if isinstance(gallery, list): - gallery = np.array(gallery) - cands = np.arange(len(gallery)) - self.rng.shuffle(cands) - rand_inds = cands[:num] - if not isinstance(gallery, np.ndarray): - rand_inds = torch.from_numpy(rand_inds).long().to(gallery.device) - return gallery[rand_inds] + + is_tensor = isinstance(gallery, torch.Tensor) + if not is_tensor: + if torch.cuda.is_available(): + device = torch.cuda.current_device() + else: + device = 'cpu' + gallery = torch.tensor(gallery, dtype=torch.long, device=device) + # This is a temporary fix. We can revert the following code + # when PyTorch fixes the abnormal return of torch.randperm. + # See: https://github.com/open-mmlab/mmdetection/pull/5014 + perm = torch.randperm(gallery.numel())[:num].to(device=gallery.device) + rand_inds = gallery[perm] + if not is_tensor: + rand_inds = rand_inds.cpu().numpy() + return rand_inds def _sample_pos(self, assign_result, num_expected, **kwargs): """Randomly sample some positive samples.""" - pos_inds = torch.nonzero(assign_result.gt_inds > 0) + pos_inds = torch.nonzero(assign_result.gt_inds > 0, as_tuple=False) if pos_inds.numel() != 0: pos_inds = pos_inds.squeeze(1) if pos_inds.numel() <= num_expected: @@ -45,7 +73,7 @@ class RandomSampler(BaseSampler): def _sample_neg(self, assign_result, num_expected, **kwargs): """Randomly sample some negative samples.""" - neg_inds = torch.nonzero(assign_result.gt_inds == 0) + neg_inds = torch.nonzero(assign_result.gt_inds == 0, as_tuple=False) if neg_inds.numel() != 0: neg_inds = neg_inds.squeeze(1) if len(neg_inds) <= num_expected: diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/sampling_result.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/sampling_result.py index dcf25eecd..50676d041 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/sampling_result.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/sampling_result.py @@ -1,15 +1,17 @@ +# Copyright (c) OpenMMLab. All rights reserved. import torch from mmdet.utils import util_mixins class SamplingResult(util_mixins.NiceRepr): - """ + """Bbox sampling result. + Example: >>> # xdoctest: +IGNORE_WANT >>> from mmdet.core.bbox.samplers.sampling_result import * # NOQA >>> self = SamplingResult.random(rng=10) - >>> print('self = {}'.format(self)) + >>> print(f'self = {self}') self = >> self = SamplingResult.random() - >>> print('self = {}'.format(self.to(None))) + >>> print(f'self = {self.to(None)}') >>> # xdoctest: +REQUIRES(--gpu) - >>> print('self = {}'.format(self.to(0))) + >>> print(f'self = {self.to(0)}') """ _dict = self.__dict__ for key, value in _dict.items(): @@ -71,15 +73,13 @@ class SamplingResult(util_mixins.NiceRepr): data = self.info.copy() data['pos_bboxes'] = data.pop('pos_bboxes').shape data['neg_bboxes'] = data.pop('neg_bboxes').shape - parts = ['\'{}\': {!r}'.format(k, v) for k, v in sorted(data.items())] + parts = [f"'{k}': {v!r}" for k, v in sorted(data.items())] body = ' ' + ',\n '.join(parts) return '{\n' + body + '\n}' @property def info(self): - """ - Returns a dictionary of info about the object - """ + """Returns a dictionary of info about the object.""" return { 'pos_inds': self.pos_inds, 'neg_inds': self.neg_inds, @@ -94,28 +94,27 @@ class SamplingResult(util_mixins.NiceRepr): def random(cls, rng=None, **kwargs): """ Args: - rng (None | int | numpy.random.RandomState): seed or state - - Kwargs: - num_preds: number of predicted boxes - num_gts: number of true boxes - p_ignore (float): probability of a predicted box assinged to an - ignored truth - p_assigned (float): probability of a predicted box not being - assigned - p_use_label (float | bool): with labels or not + rng (None | int | numpy.random.RandomState): seed or state. + kwargs (keyword arguments): + - num_preds: number of predicted boxes + - num_gts: number of true boxes + - p_ignore (float): probability of a predicted box assigned to \ + an ignored truth. + - p_assigned (float): probability of a predicted box not being \ + assigned. + - p_use_label (float | bool): with labels or not. Returns: - AssignResult : + :obj:`SamplingResult`: Randomly generated sampling result. Example: >>> from mmdet.core.bbox.samplers.sampling_result import * # NOQA >>> self = SamplingResult.random() >>> print(self.__dict__) """ - from mmdet.core.bbox.samplers.random_sampler import RandomSampler - from mmdet.core.bbox.assigners.assign_result import AssignResult from mmdet.core.bbox import demodata + from mmdet.core.bbox.assigners.assign_result import AssignResult + from mmdet.core.bbox.samplers.random_sampler import RandomSampler rng = demodata.ensure_rng(rng) # make probabalistic? @@ -147,7 +146,7 @@ class SamplingResult(util_mixins.NiceRepr): sampler = RandomSampler( num, pos_fraction, - neg_pos_ubo=neg_pos_ub, + neg_pos_ub=neg_pos_ub, add_gt_as_proposals=add_gt_as_proposals, rng=rng) self = sampler.sample(assign_result, bboxes, gt_bboxes, gt_labels) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/score_hlr_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/score_hlr_sampler.py new file mode 100644 index 000000000..f4be9b8cf --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/samplers/score_hlr_sampler.py @@ -0,0 +1,265 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch +from mmcv.ops import nms_match + +from ..builder import BBOX_SAMPLERS +from ..transforms import bbox2roi +from .base_sampler import BaseSampler +from .sampling_result import SamplingResult + + +@BBOX_SAMPLERS.register_module() +class ScoreHLRSampler(BaseSampler): + r"""Importance-based Sample Reweighting (ISR_N), described in `Prime Sample + Attention in Object Detection `_. + + Score hierarchical local rank (HLR) differentiates with RandomSampler in + negative part. It firstly computes Score-HLR in a two-step way, + then linearly maps score hlr to the loss weights. + + Args: + num (int): Total number of sampled RoIs. + pos_fraction (float): Fraction of positive samples. + context (:class:`BaseRoIHead`): RoI head that the sampler belongs to. + neg_pos_ub (int): Upper bound of the ratio of num negative to num + positive, -1 means no upper bound. + add_gt_as_proposals (bool): Whether to add ground truth as proposals. + k (float): Power of the non-linear mapping. + bias (float): Shift of the non-linear mapping. + score_thr (float): Minimum score that a negative sample is to be + considered as valid bbox. + """ + + def __init__(self, + num, + pos_fraction, + context, + neg_pos_ub=-1, + add_gt_as_proposals=True, + k=0.5, + bias=0, + score_thr=0.05, + iou_thr=0.5, + **kwargs): + super().__init__(num, pos_fraction, neg_pos_ub, add_gt_as_proposals) + self.k = k + self.bias = bias + self.score_thr = score_thr + self.iou_thr = iou_thr + self.context = context + # context of cascade detectors is a list, so distinguish them here. + if not hasattr(context, 'num_stages'): + self.bbox_roi_extractor = context.bbox_roi_extractor + self.bbox_head = context.bbox_head + self.with_shared_head = context.with_shared_head + if self.with_shared_head: + self.shared_head = context.shared_head + else: + self.bbox_roi_extractor = context.bbox_roi_extractor[ + context.current_stage] + self.bbox_head = context.bbox_head[context.current_stage] + + @staticmethod + def random_choice(gallery, num): + """Randomly select some elements from the gallery. + + If `gallery` is a Tensor, the returned indices will be a Tensor; + If `gallery` is a ndarray or list, the returned indices will be a + ndarray. + + Args: + gallery (Tensor | ndarray | list): indices pool. + num (int): expected sample num. + + Returns: + Tensor or ndarray: sampled indices. + """ + assert len(gallery) >= num + + is_tensor = isinstance(gallery, torch.Tensor) + if not is_tensor: + if torch.cuda.is_available(): + device = torch.cuda.current_device() + else: + device = 'cpu' + gallery = torch.tensor(gallery, dtype=torch.long, device=device) + perm = torch.randperm(gallery.numel(), device=gallery.device)[:num] + rand_inds = gallery[perm] + if not is_tensor: + rand_inds = rand_inds.cpu().numpy() + return rand_inds + + def _sample_pos(self, assign_result, num_expected, **kwargs): + """Randomly sample some positive samples.""" + pos_inds = torch.nonzero(assign_result.gt_inds > 0).flatten() + if pos_inds.numel() <= num_expected: + return pos_inds + else: + return self.random_choice(pos_inds, num_expected) + + def _sample_neg(self, + assign_result, + num_expected, + bboxes, + feats=None, + img_meta=None, + **kwargs): + """Sample negative samples. + + Score-HLR sampler is done in the following steps: + 1. Take the maximum positive score prediction of each negative samples + as s_i. + 2. Filter out negative samples whose s_i <= score_thr, the left samples + are called valid samples. + 3. Use NMS-Match to divide valid samples into different groups, + samples in the same group will greatly overlap with each other + 4. Rank the matched samples in two-steps to get Score-HLR. + (1) In the same group, rank samples with their scores. + (2) In the same score rank across different groups, + rank samples with their scores again. + 5. Linearly map Score-HLR to the final label weights. + + Args: + assign_result (:obj:`AssignResult`): result of assigner. + num_expected (int): Expected number of samples. + bboxes (Tensor): bbox to be sampled. + feats (Tensor): Features come from FPN. + img_meta (dict): Meta information dictionary. + """ + neg_inds = torch.nonzero(assign_result.gt_inds == 0).flatten() + num_neg = neg_inds.size(0) + if num_neg == 0: + return neg_inds, None + with torch.no_grad(): + neg_bboxes = bboxes[neg_inds] + neg_rois = bbox2roi([neg_bboxes]) + bbox_result = self.context._bbox_forward(feats, neg_rois) + cls_score, bbox_pred = bbox_result['cls_score'], bbox_result[ + 'bbox_pred'] + + ori_loss = self.bbox_head.loss( + cls_score=cls_score, + bbox_pred=None, + rois=None, + labels=neg_inds.new_full((num_neg, ), + self.bbox_head.num_classes), + label_weights=cls_score.new_ones(num_neg), + bbox_targets=None, + bbox_weights=None, + reduction_override='none')['loss_cls'] + + # filter out samples with the max score lower than score_thr + max_score, argmax_score = cls_score.softmax(-1)[:, :-1].max(-1) + valid_inds = (max_score > self.score_thr).nonzero().view(-1) + invalid_inds = (max_score <= self.score_thr).nonzero().view(-1) + num_valid = valid_inds.size(0) + num_invalid = invalid_inds.size(0) + + num_expected = min(num_neg, num_expected) + num_hlr = min(num_valid, num_expected) + num_rand = num_expected - num_hlr + if num_valid > 0: + valid_rois = neg_rois[valid_inds] + valid_max_score = max_score[valid_inds] + valid_argmax_score = argmax_score[valid_inds] + valid_bbox_pred = bbox_pred[valid_inds] + + # valid_bbox_pred shape: [num_valid, #num_classes, 4] + valid_bbox_pred = valid_bbox_pred.view( + valid_bbox_pred.size(0), -1, 4) + selected_bbox_pred = valid_bbox_pred[range(num_valid), + valid_argmax_score] + pred_bboxes = self.bbox_head.bbox_coder.decode( + valid_rois[:, 1:], selected_bbox_pred) + pred_bboxes_with_score = torch.cat( + [pred_bboxes, valid_max_score[:, None]], -1) + group = nms_match(pred_bboxes_with_score, self.iou_thr) + + # imp: importance + imp = cls_score.new_zeros(num_valid) + for g in group: + g_score = valid_max_score[g] + # g_score has already sorted + rank = g_score.new_tensor(range(g_score.size(0))) + imp[g] = num_valid - rank + g_score + _, imp_rank_inds = imp.sort(descending=True) + _, imp_rank = imp_rank_inds.sort() + hlr_inds = imp_rank_inds[:num_expected] + + if num_rand > 0: + rand_inds = torch.randperm(num_invalid)[:num_rand] + select_inds = torch.cat( + [valid_inds[hlr_inds], invalid_inds[rand_inds]]) + else: + select_inds = valid_inds[hlr_inds] + + neg_label_weights = cls_score.new_ones(num_expected) + + up_bound = max(num_expected, num_valid) + imp_weights = (up_bound - + imp_rank[hlr_inds].float()) / up_bound + neg_label_weights[:num_hlr] = imp_weights + neg_label_weights[num_hlr:] = imp_weights.min() + neg_label_weights = (self.bias + + (1 - self.bias) * neg_label_weights).pow( + self.k) + ori_selected_loss = ori_loss[select_inds] + new_loss = ori_selected_loss * neg_label_weights + norm_ratio = ori_selected_loss.sum() / new_loss.sum() + neg_label_weights *= norm_ratio + else: + neg_label_weights = cls_score.new_ones(num_expected) + select_inds = torch.randperm(num_neg)[:num_expected] + + return neg_inds[select_inds], neg_label_weights + + def sample(self, + assign_result, + bboxes, + gt_bboxes, + gt_labels=None, + img_meta=None, + **kwargs): + """Sample positive and negative bboxes. + + This is a simple implementation of bbox sampling given candidates, + assigning results and ground truth bboxes. + + Args: + assign_result (:obj:`AssignResult`): Bbox assigning results. + bboxes (Tensor): Boxes to be sampled from. + gt_bboxes (Tensor): Ground truth bboxes. + gt_labels (Tensor, optional): Class labels of ground truth bboxes. + + Returns: + tuple[:obj:`SamplingResult`, Tensor]: Sampling result and negative + label weights. + """ + bboxes = bboxes[:, :4] + + gt_flags = bboxes.new_zeros((bboxes.shape[0], ), dtype=torch.uint8) + if self.add_gt_as_proposals: + bboxes = torch.cat([gt_bboxes, bboxes], dim=0) + assign_result.add_gt_(gt_labels) + gt_ones = bboxes.new_ones(gt_bboxes.shape[0], dtype=torch.uint8) + gt_flags = torch.cat([gt_ones, gt_flags]) + + num_expected_pos = int(self.num * self.pos_fraction) + pos_inds = self.pos_sampler._sample_pos( + assign_result, num_expected_pos, bboxes=bboxes, **kwargs) + num_sampled_pos = pos_inds.numel() + num_expected_neg = self.num - num_sampled_pos + if self.neg_pos_ub >= 0: + _pos = max(1, num_sampled_pos) + neg_upper_bound = int(self.neg_pos_ub * _pos) + if num_expected_neg > neg_upper_bound: + num_expected_neg = neg_upper_bound + neg_inds, neg_label_weights = self.neg_sampler._sample_neg( + assign_result, + num_expected_neg, + bboxes, + img_meta=img_meta, + **kwargs) + + return SamplingResult(pos_inds, neg_inds, bboxes, gt_bboxes, + assign_result, gt_flags), neg_label_weights diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/transforms.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/transforms.py index b9d1e6605..6d72076a5 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/transforms.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/bbox/transforms.py @@ -1,149 +1,75 @@ -import mmcv +# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import torch -def bbox2delta(proposals, gt, means=[0, 0, 0, 0], stds=[1, 1, 1, 1]): - assert proposals.size() == gt.size() - - proposals = proposals.float() - gt = gt.float() - px = (proposals[..., 0] + proposals[..., 2]) * 0.5 - py = (proposals[..., 1] + proposals[..., 3]) * 0.5 - pw = proposals[..., 2] - proposals[..., 0] + 1.0 - ph = proposals[..., 3] - proposals[..., 1] + 1.0 - - gx = (gt[..., 0] + gt[..., 2]) * 0.5 - gy = (gt[..., 1] + gt[..., 3]) * 0.5 - gw = gt[..., 2] - gt[..., 0] + 1.0 - gh = gt[..., 3] - gt[..., 1] + 1.0 - - dx = (gx - px) / pw - dy = (gy - py) / ph - dw = torch.log(gw / pw) - dh = torch.log(gh / ph) - deltas = torch.stack([dx, dy, dw, dh], dim=-1) - - means = deltas.new_tensor(means).unsqueeze(0) - stds = deltas.new_tensor(stds).unsqueeze(0) - deltas = deltas.sub_(means).div_(stds) - - return deltas - - -def delta2bbox(rois, - deltas, - means=[0, 0, 0, 0], - stds=[1, 1, 1, 1], - max_shape=None, - wh_ratio_clip=16 / 1000): - """ - Apply deltas to shift/scale base boxes. - - Typically the rois are anchor or proposed bounding boxes and the deltas are - network outputs used to shift/scale those boxes. +def find_inside_bboxes(bboxes, img_h, img_w): + """Find bboxes as long as a part of bboxes is inside the image. Args: - rois (Tensor): boxes to be transformed. Has shape (N, 4) - deltas (Tensor): encoded offsets with respect to each roi. - Has shape (N, 4). Note N = num_anchors * W * H when rois is a grid - of anchors. Offset encoding follows [1]_. - means (list): denormalizing means for delta coordinates - stds (list): denormalizing standard deviation for delta coordinates - max_shape (tuple[int, int]): maximum bounds for boxes. specifies (H, W) - wh_ratio_clip (float): maximum aspect ratio for boxes. + bboxes (Tensor): Shape (N, 4). + img_h (int): Image height. + img_w (int): Image width. Returns: - Tensor: boxes with shape (N, 4), where columns represent - tl_x, tl_y, br_x, br_y. - - References: - .. [1] https://arxiv.org/abs/1311.2524 - - Example: - >>> rois = torch.Tensor([[ 0., 0., 1., 1.], - >>> [ 0., 0., 1., 1.], - >>> [ 0., 0., 1., 1.], - >>> [ 5., 5., 5., 5.]]) - >>> deltas = torch.Tensor([[ 0., 0., 0., 0.], - >>> [ 1., 1., 1., 1.], - >>> [ 0., 0., 2., -1.], - >>> [ 0.7, -1.9, -0.5, 0.3]]) - >>> delta2bbox(rois, deltas, max_shape=(32, 32)) - tensor([[0.0000, 0.0000, 1.0000, 1.0000], - [0.2817, 0.2817, 4.7183, 4.7183], - [0.0000, 0.6321, 7.3891, 0.3679], - [5.8967, 2.9251, 5.5033, 3.2749]]) + Tensor: Index of the remaining bboxes. """ - means = deltas.new_tensor(means).repeat(1, deltas.size(1) // 4) - stds = deltas.new_tensor(stds).repeat(1, deltas.size(1) // 4) - denorm_deltas = deltas * stds + means - dx = denorm_deltas[:, 0::4] - dy = denorm_deltas[:, 1::4] - dw = denorm_deltas[:, 2::4] - dh = denorm_deltas[:, 3::4] - max_ratio = np.abs(np.log(wh_ratio_clip)) - dw = dw.clamp(min=-max_ratio, max=max_ratio) - dh = dh.clamp(min=-max_ratio, max=max_ratio) - # Compute center of each roi - px = ((rois[:, 0] + rois[:, 2]) * 0.5).unsqueeze(1).expand_as(dx) - py = ((rois[:, 1] + rois[:, 3]) * 0.5).unsqueeze(1).expand_as(dy) - # Compute width/height of each roi - pw = (rois[:, 2] - rois[:, 0] + 1.0).unsqueeze(1).expand_as(dw) - ph = (rois[:, 3] - rois[:, 1] + 1.0).unsqueeze(1).expand_as(dh) - # Use exp(network energy) to enlarge/shrink each roi - gw = pw * dw.exp() - gh = ph * dh.exp() - # Use network energy to shift the center of each roi - gx = torch.addcmul(px, 1, pw, dx) # gx = px + pw * dx - gy = torch.addcmul(py, 1, ph, dy) # gy = py + ph * dy - # Convert center-xy/width/height to top-left, bottom-right - x1 = gx - gw * 0.5 + 0.5 - y1 = gy - gh * 0.5 + 0.5 - x2 = gx + gw * 0.5 - 0.5 - y2 = gy + gh * 0.5 - 0.5 - if max_shape is not None: - x1 = x1.clamp(min=0, max=max_shape[1] - 1) - y1 = y1.clamp(min=0, max=max_shape[0] - 1) - x2 = x2.clamp(min=0, max=max_shape[1] - 1) - y2 = y2.clamp(min=0, max=max_shape[0] - 1) - bboxes = torch.stack([x1, y1, x2, y2], dim=-1).view_as(deltas) - return bboxes + inside_inds = (bboxes[:, 0] < img_w) & (bboxes[:, 2] > 0) \ + & (bboxes[:, 1] < img_h) & (bboxes[:, 3] > 0) + return inside_inds -def bbox_flip(bboxes, img_shape): - """Flip bboxes horizontally. +def bbox_flip(bboxes, img_shape, direction='horizontal'): + """Flip bboxes horizontally or vertically. Args: - bboxes(Tensor or ndarray): Shape (..., 4*k) - img_shape(tuple): Image shape. + bboxes (Tensor): Shape (..., 4*k) + img_shape (tuple): Image shape. + direction (str): Flip direction, options are "horizontal", "vertical", + "diagonal". Default: "horizontal" Returns: - Same type as `bboxes`: Flipped bboxes. + Tensor: Flipped bboxes. """ - if isinstance(bboxes, torch.Tensor): - assert bboxes.shape[-1] % 4 == 0 - flipped = bboxes.clone() - flipped[:, 0::4] = img_shape[1] - bboxes[:, 2::4] - 1 - flipped[:, 2::4] = img_shape[1] - bboxes[:, 0::4] - 1 - return flipped - elif isinstance(bboxes, np.ndarray): - return mmcv.bbox_flip(bboxes, img_shape) - - -def bbox_mapping(bboxes, img_shape, scale_factor, flip): - """Map bboxes from the original image scale to testing scale""" - new_bboxes = bboxes * scale_factor + assert bboxes.shape[-1] % 4 == 0 + assert direction in ['horizontal', 'vertical', 'diagonal'] + flipped = bboxes.clone() + if direction == 'horizontal': + flipped[..., 0::4] = img_shape[1] - bboxes[..., 2::4] + flipped[..., 2::4] = img_shape[1] - bboxes[..., 0::4] + elif direction == 'vertical': + flipped[..., 1::4] = img_shape[0] - bboxes[..., 3::4] + flipped[..., 3::4] = img_shape[0] - bboxes[..., 1::4] + else: + flipped[..., 0::4] = img_shape[1] - bboxes[..., 2::4] + flipped[..., 1::4] = img_shape[0] - bboxes[..., 3::4] + flipped[..., 2::4] = img_shape[1] - bboxes[..., 0::4] + flipped[..., 3::4] = img_shape[0] - bboxes[..., 1::4] + return flipped + + +def bbox_mapping(bboxes, + img_shape, + scale_factor, + flip, + flip_direction='horizontal'): + """Map bboxes from the original image scale to testing scale.""" + new_bboxes = bboxes * bboxes.new_tensor(scale_factor) if flip: - new_bboxes = bbox_flip(new_bboxes, img_shape) + new_bboxes = bbox_flip(new_bboxes, img_shape, flip_direction) return new_bboxes -def bbox_mapping_back(bboxes, img_shape, scale_factor, flip): - """Map bboxes from testing scale to original image scale""" - new_bboxes = bbox_flip(bboxes, img_shape) if flip else bboxes - new_bboxes = new_bboxes / scale_factor - return new_bboxes +def bbox_mapping_back(bboxes, + img_shape, + scale_factor, + flip, + flip_direction='horizontal'): + """Map bboxes from testing scale to original image scale.""" + new_bboxes = bbox_flip(bboxes, img_shape, + flip_direction) if flip else bboxes + new_bboxes = new_bboxes.view(-1, 4) / new_bboxes.new_tensor(scale_factor) + return new_bboxes.view(bboxes.shape) def bbox2roi(bbox_list): @@ -169,6 +95,15 @@ def bbox2roi(bbox_list): def roi2bbox(rois): + """Convert rois to bounding box format. + + Args: + rois (torch.Tensor): RoIs with the shape (n, 5) where the first + column indicates batch id of each RoI. + + Returns: + list[torch.Tensor]: Converted boxes of corresponding rois. + """ bbox_list = [] img_ids = torch.unique(rois[:, 0].cpu(), sorted=True) for img_id in img_ids: @@ -182,42 +117,154 @@ def bbox2result(bboxes, labels, num_classes): """Convert detection results to a list of numpy arrays. Args: - bboxes (Tensor): shape (n, 5) - labels (Tensor): shape (n, ) + bboxes (torch.Tensor | np.ndarray): shape (n, 5) + labels (torch.Tensor | np.ndarray): shape (n, ) num_classes (int): class number, including background class Returns: list(ndarray): bbox results of each class """ if bboxes.shape[0] == 0: - return [ - np.zeros((0, 5), dtype=np.float32) for i in range(num_classes - 1) - ] + return [np.zeros((0, 5), dtype=np.float32) for i in range(num_classes)] else: - bboxes = bboxes.cpu().numpy() - labels = labels.cpu().numpy() - return [bboxes[labels == i, :] for i in range(num_classes - 1)] + if isinstance(bboxes, torch.Tensor): + bboxes = bboxes.detach().cpu().numpy() + labels = labels.detach().cpu().numpy() + return [bboxes[labels == i, :] for i in range(num_classes)] def distance2bbox(points, distance, max_shape=None): """Decode distance prediction to bounding box. Args: - points (Tensor): Shape (n, 2), [x, y]. + points (Tensor): Shape (B, N, 2) or (N, 2). distance (Tensor): Distance from the given point to 4 - boundaries (left, top, right, bottom). - max_shape (tuple): Shape of the image. + boundaries (left, top, right, bottom). Shape (B, N, 4) or (N, 4) + max_shape (Sequence[int] or torch.Tensor or Sequence[ + Sequence[int]],optional): Maximum bounds for boxes, specifies + (H, W, C) or (H, W). If priors shape is (B, N, 4), then + the max_shape should be a Sequence[Sequence[int]] + and the length of max_shape should also be B. Returns: - Tensor: Decoded bboxes. + Tensor: Boxes with shape (N, 4) or (B, N, 4) """ - x1 = points[:, 0] - distance[:, 0] - y1 = points[:, 1] - distance[:, 1] - x2 = points[:, 0] + distance[:, 2] - y2 = points[:, 1] + distance[:, 3] + + x1 = points[..., 0] - distance[..., 0] + y1 = points[..., 1] - distance[..., 1] + x2 = points[..., 0] + distance[..., 2] + y2 = points[..., 1] + distance[..., 3] + + bboxes = torch.stack([x1, y1, x2, y2], -1) + if max_shape is not None: - x1 = x1.clamp(min=0, max=max_shape[1] - 1) - y1 = y1.clamp(min=0, max=max_shape[0] - 1) - x2 = x2.clamp(min=0, max=max_shape[1] - 1) - y2 = y2.clamp(min=0, max=max_shape[0] - 1) - return torch.stack([x1, y1, x2, y2], -1) + if bboxes.dim() == 2 and not torch.onnx.is_in_onnx_export(): + # speed up + bboxes[:, 0::2].clamp_(min=0, max=max_shape[1]) + bboxes[:, 1::2].clamp_(min=0, max=max_shape[0]) + return bboxes + + # clip bboxes with dynamic `min` and `max` for onnx + if torch.onnx.is_in_onnx_export(): + from mmdet.core.export import dynamic_clip_for_onnx + x1, y1, x2, y2 = dynamic_clip_for_onnx(x1, y1, x2, y2, max_shape) + bboxes = torch.stack([x1, y1, x2, y2], dim=-1) + return bboxes + if not isinstance(max_shape, torch.Tensor): + max_shape = x1.new_tensor(max_shape) + max_shape = max_shape[..., :2].type_as(x1) + if max_shape.ndim == 2: + assert bboxes.ndim == 3 + assert max_shape.size(0) == bboxes.size(0) + + min_xy = x1.new_tensor(0) + max_xy = torch.cat([max_shape, max_shape], + dim=-1).flip(-1).unsqueeze(-2) + bboxes = torch.where(bboxes < min_xy, min_xy, bboxes) + bboxes = torch.where(bboxes > max_xy, max_xy, bboxes) + + return bboxes + + +def bbox2distance(points, bbox, max_dis=None, eps=0.1): + """Decode bounding box based on distances. + + Args: + points (Tensor): Shape (n, 2), [x, y]. + bbox (Tensor): Shape (n, 4), "xyxy" format + max_dis (float): Upper bound of the distance. + eps (float): a small value to ensure target < max_dis, instead <= + + Returns: + Tensor: Decoded distances. + """ + left = points[:, 0] - bbox[:, 0] + top = points[:, 1] - bbox[:, 1] + right = bbox[:, 2] - points[:, 0] + bottom = bbox[:, 3] - points[:, 1] + if max_dis is not None: + left = left.clamp(min=0, max=max_dis - eps) + top = top.clamp(min=0, max=max_dis - eps) + right = right.clamp(min=0, max=max_dis - eps) + bottom = bottom.clamp(min=0, max=max_dis - eps) + return torch.stack([left, top, right, bottom], -1) + + +def bbox_rescale(bboxes, scale_factor=1.0): + """Rescale bounding box w.r.t. scale_factor. + + Args: + bboxes (Tensor): Shape (n, 4) for bboxes or (n, 5) for rois + scale_factor (float): rescale factor + + Returns: + Tensor: Rescaled bboxes. + """ + if bboxes.size(1) == 5: + bboxes_ = bboxes[:, 1:] + inds_ = bboxes[:, 0] + else: + bboxes_ = bboxes + cx = (bboxes_[:, 0] + bboxes_[:, 2]) * 0.5 + cy = (bboxes_[:, 1] + bboxes_[:, 3]) * 0.5 + w = bboxes_[:, 2] - bboxes_[:, 0] + h = bboxes_[:, 3] - bboxes_[:, 1] + w = w * scale_factor + h = h * scale_factor + x1 = cx - 0.5 * w + x2 = cx + 0.5 * w + y1 = cy - 0.5 * h + y2 = cy + 0.5 * h + if bboxes.size(1) == 5: + rescaled_bboxes = torch.stack([inds_, x1, y1, x2, y2], dim=-1) + else: + rescaled_bboxes = torch.stack([x1, y1, x2, y2], dim=-1) + return rescaled_bboxes + + +def bbox_cxcywh_to_xyxy(bbox): + """Convert bbox coordinates from (cx, cy, w, h) to (x1, y1, x2, y2). + + Args: + bbox (Tensor): Shape (n, 4) for bboxes. + + Returns: + Tensor: Converted bboxes. + """ + cx, cy, w, h = bbox.split((1, 1, 1, 1), dim=-1) + bbox_new = [(cx - 0.5 * w), (cy - 0.5 * h), (cx + 0.5 * w), (cy + 0.5 * h)] + return torch.cat(bbox_new, dim=-1) + + +def bbox_xyxy_to_cxcywh(bbox): + """Convert bbox coordinates from (x1, y1, x2, y2) to (cx, cy, w, h). + + Args: + bbox (Tensor): Shape (n, 4) for bboxes. + + Returns: + Tensor: Converted bboxes. + """ + x1, y1, x2, y2 = bbox.split((1, 1, 1, 1), dim=-1) + bbox_new = [(x1 + x2) / 2, (y1 + y2) / 2, (x2 - x1), (y2 - y1)] + return torch.cat(bbox_new, dim=-1) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/data_structures/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/data_structures/__init__.py new file mode 100644 index 000000000..11ab96c56 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/data_structures/__init__.py @@ -0,0 +1,5 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .general_data import GeneralData +from .instance_data import InstanceData + +__all__ = ['GeneralData', 'InstanceData'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/data_structures/general_data.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/data_structures/general_data.py new file mode 100644 index 000000000..99316e41b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/data_structures/general_data.py @@ -0,0 +1,326 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import copy + +import numpy as np +import torch + +from mmdet.utils.util_mixins import NiceRepr + + +class GeneralData(NiceRepr): + """A general data structure of OpenMMlab. + + A data structure that stores the meta information, + the annotations of the images or the model predictions, + which can be used in communication between components. + + The attributes in `GeneralData` are divided into two parts, + the `meta_info_fields` and the `data_fields` respectively. + + - `meta_info_fields`: Usually contains the + information about the image such as filename, + image_shape, pad_shape, etc. All attributes in + it are immutable once set, + but the user can add new meta information with + `set_meta_info` function, all information can be accessed + with methods `meta_info_keys`, `meta_info_values`, + `meta_info_items`. + + - `data_fields`: Annotations or model predictions are + stored. The attributes can be accessed or modified by + dict-like or object-like operations, such as + `.` , `[]`, `in`, `del`, `pop(str)` `get(str)`, `keys()`, + `values()`, `items()`. Users can also apply tensor-like methods + to all obj:`torch.Tensor` in the `data_fileds`, + such as `.cuda()`, `.cpu()`, `.numpy()`, `device`, `.to()` + `.detach()`, `.numpy()` + + Args: + meta_info (dict, optional): A dict contains the meta information + of single image. such as `img_shape`, `scale_factor`, etc. + Default: None. + data (dict, optional): A dict contains annotations of single image or + model predictions. Default: None. + + Examples: + >>> from mmdet.core import GeneralData + >>> img_meta = dict(img_shape=(800, 1196, 3), pad_shape=(800, 1216, 3)) + >>> instance_data = GeneralData(meta_info=img_meta) + >>> img_shape in instance_data + True + >>> instance_data.det_labels = torch.LongTensor([0, 1, 2, 3]) + >>> instance_data["det_scores"] = torch.Tensor([0.01, 0.1, 0.2, 0.3]) + >>> print(results) + + >>> instance_data.det_scores + tensor([0.0100, 0.1000, 0.2000, 0.3000]) + >>> instance_data.det_labels + tensor([0, 1, 2, 3]) + >>> instance_data['det_labels'] + tensor([0, 1, 2, 3]) + >>> 'det_labels' in instance_data + True + >>> instance_data.img_shape + (800, 1196, 3) + >>> 'det_scores' in instance_data + True + >>> del instance_data.det_scores + >>> 'det_scores' in instance_data + False + >>> det_labels = instance_data.pop('det_labels', None) + >>> det_labels + tensor([0, 1, 2, 3]) + >>> 'det_labels' in instance_data + >>> False + """ + + def __init__(self, meta_info=None, data=None): + + self._meta_info_fields = set() + self._data_fields = set() + + if meta_info is not None: + self.set_meta_info(meta_info=meta_info) + if data is not None: + self.set_data(data) + + def set_meta_info(self, meta_info): + """Add meta information. + + Args: + meta_info (dict): A dict contains the meta information + of image. such as `img_shape`, `scale_factor`, etc. + Default: None. + """ + assert isinstance(meta_info, + dict), f'meta should be a `dict` but get {meta_info}' + meta = copy.deepcopy(meta_info) + for k, v in meta.items(): + # should be consistent with original meta_info + if k in self._meta_info_fields: + ori_value = getattr(self, k) + if isinstance(ori_value, (torch.Tensor, np.ndarray)): + if (ori_value == v).all(): + continue + else: + raise KeyError( + f'img_meta_info {k} has been set as ' + f'{getattr(self, k)} before, which is immutable ') + elif ori_value == v: + continue + else: + raise KeyError( + f'img_meta_info {k} has been set as ' + f'{getattr(self, k)} before, which is immutable ') + else: + self._meta_info_fields.add(k) + self.__dict__[k] = v + + def set_data(self, data): + """Update a dict to `data_fields`. + + Args: + data (dict): A dict contains annotations of image or + model predictions. Default: None. + """ + assert isinstance(data, + dict), f'meta should be a `dict` but get {data}' + for k, v in data.items(): + self.__setattr__(k, v) + + def new(self, meta_info=None, data=None): + """Return a new results with same image meta information. + + Args: + meta_info (dict, optional): A dict contains the meta information + of image. such as `img_shape`, `scale_factor`, etc. + Default: None. + data (dict, optional): A dict contains annotations of image or + model predictions. Default: None. + """ + new_data = self.__class__() + new_data.set_meta_info(dict(self.meta_info_items())) + if meta_info is not None: + new_data.set_meta_info(meta_info) + if data is not None: + new_data.set_data(data) + return new_data + + def keys(self): + """ + Returns: + list: Contains all keys in data_fields. + """ + return [key for key in self._data_fields] + + def meta_info_keys(self): + """ + Returns: + list: Contains all keys in meta_info_fields. + """ + return [key for key in self._meta_info_fields] + + def values(self): + """ + Returns: + list: Contains all values in data_fields. + """ + return [getattr(self, k) for k in self.keys()] + + def meta_info_values(self): + """ + Returns: + list: Contains all values in meta_info_fields. + """ + return [getattr(self, k) for k in self.meta_info_keys()] + + def items(self): + for k in self.keys(): + yield (k, getattr(self, k)) + + def meta_info_items(self): + for k in self.meta_info_keys(): + yield (k, getattr(self, k)) + + def __setattr__(self, name, val): + if name in ('_meta_info_fields', '_data_fields'): + if not hasattr(self, name): + super().__setattr__(name, val) + else: + raise AttributeError( + f'{name} has been used as a ' + f'private attribute, which is immutable. ') + else: + if name in self._meta_info_fields: + raise AttributeError(f'`{name}` is used in meta information,' + f'which is immutable') + + self._data_fields.add(name) + super().__setattr__(name, val) + + def __delattr__(self, item): + + if item in ('_meta_info_fields', '_data_fields'): + raise AttributeError(f'{item} has been used as a ' + f'private attribute, which is immutable. ') + + if item in self._meta_info_fields: + raise KeyError(f'{item} is used in meta information, ' + f'which is immutable.') + super().__delattr__(item) + if item in self._data_fields: + self._data_fields.remove(item) + + # dict-like methods + __setitem__ = __setattr__ + __delitem__ = __delattr__ + + def __getitem__(self, name): + return getattr(self, name) + + def get(self, *args): + assert len(args) < 3, '`get` get more than 2 arguments' + return self.__dict__.get(*args) + + def pop(self, *args): + assert len(args) < 3, '`pop` get more than 2 arguments' + name = args[0] + if name in self._meta_info_fields: + raise KeyError(f'{name} is a key in meta information, ' + f'which is immutable') + + if args[0] in self._data_fields: + self._data_fields.remove(args[0]) + return self.__dict__.pop(*args) + + # with default value + elif len(args) == 2: + return args[1] + else: + raise KeyError(f'{args[0]}') + + def __contains__(self, item): + return item in self._data_fields or \ + item in self._meta_info_fields + + # Tensor-like methods + def to(self, *args, **kwargs): + """Apply same name function to all tensors in data_fields.""" + new_data = self.new() + for k, v in self.items(): + if hasattr(v, 'to'): + v = v.to(*args, **kwargs) + new_data[k] = v + return new_data + + # Tensor-like methods + def cpu(self): + """Apply same name function to all tensors in data_fields.""" + new_data = self.new() + for k, v in self.items(): + if isinstance(v, torch.Tensor): + v = v.cpu() + new_data[k] = v + return new_data + + # Tensor-like methods + def mlu(self): + """Apply same name function to all tensors in data_fields.""" + new_data = self.new() + for k, v in self.items(): + if isinstance(v, torch.Tensor): + v = v.mlu() + new_data[k] = v + return new_data + + # Tensor-like methods + def cuda(self): + """Apply same name function to all tensors in data_fields.""" + new_data = self.new() + for k, v in self.items(): + if isinstance(v, torch.Tensor): + v = v.cuda() + new_data[k] = v + return new_data + + # Tensor-like methods + def detach(self): + """Apply same name function to all tensors in data_fields.""" + new_data = self.new() + for k, v in self.items(): + if isinstance(v, torch.Tensor): + v = v.detach() + new_data[k] = v + return new_data + + # Tensor-like methods + def numpy(self): + """Apply same name function to all tensors in data_fields.""" + new_data = self.new() + for k, v in self.items(): + if isinstance(v, torch.Tensor): + v = v.detach().cpu().numpy() + new_data[k] = v + return new_data + + def __nice__(self): + repr = '\n \n META INFORMATION \n' + for k, v in self.meta_info_items(): + repr += f'{k}: {v} \n' + repr += '\n DATA FIELDS \n' + for k, v in self.items(): + if isinstance(v, (torch.Tensor, np.ndarray)): + repr += f'shape of {k}: {v.shape} \n' + else: + repr += f'{k}: {v} \n' + return repr + '\n' diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/data_structures/instance_data.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/data_structures/instance_data.py new file mode 100644 index 000000000..eef2065c8 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/data_structures/instance_data.py @@ -0,0 +1,188 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import itertools + +import numpy as np +import torch + +from .general_data import GeneralData + + +class InstanceData(GeneralData): + """Data structure for instance-level annnotations or predictions. + + Subclass of :class:`GeneralData`. All value in `data_fields` + should have the same length. This design refer to + https://github.com/facebookresearch/detectron2/blob/master/detectron2/structures/instances.py # noqa E501 + + Examples: + >>> from mmdet.core import InstanceData + >>> import numpy as np + >>> img_meta = dict(img_shape=(800, 1196, 3), pad_shape=(800, 1216, 3)) + >>> results = InstanceData(img_meta) + >>> img_shape in results + True + >>> results.det_labels = torch.LongTensor([0, 1, 2, 3]) + >>> results["det_scores"] = torch.Tensor([0.01, 0.7, 0.6, 0.3]) + >>> results["det_masks"] = np.ndarray(4, 2, 2) + >>> len(results) + 4 + >>> print(resutls) + + >>> sorted_results = results[results.det_scores.sort().indices] + >>> sorted_results.det_scores + tensor([0.0100, 0.3000, 0.6000, 0.7000]) + >>> sorted_results.det_labels + tensor([0, 3, 2, 1]) + >>> print(results[results.scores > 0.5]) + + >>> results[results.det_scores > 0.5].det_labels + tensor([1, 2]) + >>> results[results.det_scores > 0.5].det_scores + tensor([0.7000, 0.6000]) + """ + + def __setattr__(self, name, value): + + if name in ('_meta_info_fields', '_data_fields'): + if not hasattr(self, name): + super().__setattr__(name, value) + else: + raise AttributeError( + f'{name} has been used as a ' + f'private attribute, which is immutable. ') + + else: + assert isinstance(value, (torch.Tensor, np.ndarray, list)), \ + f'Can set {type(value)}, only support' \ + f' {(torch.Tensor, np.ndarray, list)}' + + if self._data_fields: + assert len(value) == len(self), f'the length of ' \ + f'values {len(value)} is ' \ + f'not consistent with' \ + f' the length ' \ + f'of this :obj:`InstanceData` ' \ + f'{len(self)} ' + super().__setattr__(name, value) + + def __getitem__(self, item): + """ + Args: + item (str, obj:`slice`, + obj`torch.LongTensor`, obj:`torch.BoolTensor`): + get the corresponding values according to item. + + Returns: + obj:`InstanceData`: Corresponding values. + """ + assert len(self), ' This is a empty instance' + + assert isinstance( + item, (str, slice, int, torch.LongTensor, torch.BoolTensor)) + + if isinstance(item, str): + return getattr(self, item) + + if type(item) == int: + if item >= len(self) or item < -len(self): + raise IndexError(f'Index {item} out of range!') + else: + # keep the dimension + item = slice(item, None, len(self)) + + new_data = self.new() + if isinstance(item, (torch.Tensor)): + assert item.dim() == 1, 'Only support to get the' \ + ' values along the first dimension.' + if isinstance(item, torch.BoolTensor): + assert len(item) == len(self), f'The shape of the' \ + f' input(BoolTensor)) ' \ + f'{len(item)} ' \ + f' does not match the shape ' \ + f'of the indexed tensor ' \ + f'in results_filed ' \ + f'{len(self)} at ' \ + f'first dimension. ' + + for k, v in self.items(): + if isinstance(v, torch.Tensor): + new_data[k] = v[item] + elif isinstance(v, np.ndarray): + new_data[k] = v[item.cpu().numpy()] + elif isinstance(v, list): + r_list = [] + # convert to indexes from boolTensor + if isinstance(item, torch.BoolTensor): + indexes = torch.nonzero(item).view(-1) + else: + indexes = item + for index in indexes: + r_list.append(v[index]) + new_data[k] = r_list + else: + # item is a slice + for k, v in self.items(): + new_data[k] = v[item] + return new_data + + @staticmethod + def cat(instances_list): + """Concat the predictions of all :obj:`InstanceData` in the list. + + Args: + instances_list (list[:obj:`InstanceData`]): A list + of :obj:`InstanceData`. + + Returns: + obj:`InstanceData` + """ + assert all( + isinstance(results, InstanceData) for results in instances_list) + assert len(instances_list) > 0 + if len(instances_list) == 1: + return instances_list[0] + + new_data = instances_list[0].new() + for k in instances_list[0]._data_fields: + values = [results[k] for results in instances_list] + v0 = values[0] + if isinstance(v0, torch.Tensor): + values = torch.cat(values, dim=0) + elif isinstance(v0, np.ndarray): + values = np.concatenate(values, axis=0) + elif isinstance(v0, list): + values = list(itertools.chain(*values)) + else: + raise ValueError( + f'Can not concat the {k} which is a {type(v0)}') + new_data[k] = values + return new_data + + def __len__(self): + if len(self._data_fields): + for v in self.values(): + return len(v) + else: + raise AssertionError('This is an empty `InstanceData`.') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/__init__.py index 2e59f020c..67e7c55b3 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/__init__.py @@ -1,18 +1,19 @@ -from .class_names import (coco_classes, dataset_aliases, get_classes, - imagenet_det_classes, imagenet_vid_classes, - voc_classes) -from .coco_utils import coco_eval, fast_eval_recall, results2json, results2json_segm -from .eval_hooks import (CocoDistEvalmAPHook, CocoDistEvalRecallHook, - DistEvalHook, DistEvalmAPHook) +# Copyright (c) OpenMMLab. All rights reserved. +from .class_names import (cityscapes_classes, coco_classes, dataset_aliases, + get_classes, imagenet_det_classes, + imagenet_vid_classes, oid_challenge_classes, + oid_v6_classes, voc_classes) +from .eval_hooks import DistEvalHook, EvalHook from .mean_ap import average_precision, eval_map, print_map_summary +from .panoptic_utils import INSTANCE_OFFSET from .recall import (eval_recalls, plot_iou_recall, plot_num_recall, print_recall_summary) __all__ = [ 'voc_classes', 'imagenet_det_classes', 'imagenet_vid_classes', - 'coco_classes', 'dataset_aliases', 'get_classes', 'coco_eval', - 'fast_eval_recall', 'results2json', 'DistEvalHook', 'DistEvalmAPHook', - 'CocoDistEvalRecallHook', 'CocoDistEvalmAPHook', 'average_precision', - 'eval_map', 'print_map_summary', 'eval_recalls', 'print_recall_summary', - 'plot_num_recall', 'plot_iou_recall', 'results2json_segm' + 'coco_classes', 'cityscapes_classes', 'dataset_aliases', 'get_classes', + 'DistEvalHook', 'EvalHook', 'average_precision', 'eval_map', + 'print_map_summary', 'eval_recalls', 'print_recall_summary', + 'plot_num_recall', 'plot_iou_recall', 'oid_v6_classes', + 'oid_challenge_classes', 'INSTANCE_OFFSET' ] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/bbox_overlaps.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/bbox_overlaps.py index ad4c70523..5d6eb82fc 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/bbox_overlaps.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/bbox_overlaps.py @@ -1,21 +1,36 @@ +# Copyright (c) OpenMMLab. All rights reserved. import numpy as np -def bbox_overlaps(bboxes1, bboxes2, mode='iou'): +def bbox_overlaps(bboxes1, + bboxes2, + mode='iou', + eps=1e-6, + use_legacy_coordinate=False): """Calculate the ious between each bbox of bboxes1 and bboxes2. Args: - bboxes1(ndarray): shape (n, 4) - bboxes2(ndarray): shape (k, 4) - mode(str): iou (intersection over union) or iof (intersection + bboxes1 (ndarray): Shape (n, 4) + bboxes2 (ndarray): Shape (k, 4) + mode (str): IOU (intersection over union) or IOF (intersection over foreground) + use_legacy_coordinate (bool): Whether to use coordinate system in + mmdet v1.x. which means width, height should be + calculated as 'x2 - x1 + 1` and 'y2 - y1 + 1' respectively. + Note when function is used in `VOCDataset`, it should be + True to align with the official implementation + `http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCdevkit_18-May-2011.tar` + Default: False. Returns: - ious(ndarray): shape (n, k) + ious (ndarray): Shape (n, k) """ assert mode in ['iou', 'iof'] - + if not use_legacy_coordinate: + extra_length = 0. + else: + extra_length = 1. bboxes1 = bboxes1.astype(np.float32) bboxes2 = bboxes2.astype(np.float32) rows = bboxes1.shape[0] @@ -28,21 +43,22 @@ def bbox_overlaps(bboxes1, bboxes2, mode='iou'): bboxes1, bboxes2 = bboxes2, bboxes1 ious = np.zeros((cols, rows), dtype=np.float32) exchange = True - area1 = (bboxes1[:, 2] - bboxes1[:, 0] + 1) * ( - bboxes1[:, 3] - bboxes1[:, 1] + 1) - area2 = (bboxes2[:, 2] - bboxes2[:, 0] + 1) * ( - bboxes2[:, 3] - bboxes2[:, 1] + 1) + area1 = (bboxes1[:, 2] - bboxes1[:, 0] + extra_length) * ( + bboxes1[:, 3] - bboxes1[:, 1] + extra_length) + area2 = (bboxes2[:, 2] - bboxes2[:, 0] + extra_length) * ( + bboxes2[:, 3] - bboxes2[:, 1] + extra_length) for i in range(bboxes1.shape[0]): x_start = np.maximum(bboxes1[i, 0], bboxes2[:, 0]) y_start = np.maximum(bboxes1[i, 1], bboxes2[:, 1]) x_end = np.minimum(bboxes1[i, 2], bboxes2[:, 2]) y_end = np.minimum(bboxes1[i, 3], bboxes2[:, 3]) - overlap = np.maximum(x_end - x_start + 1, 0) * np.maximum( - y_end - y_start + 1, 0) + overlap = np.maximum(x_end - x_start + extra_length, 0) * np.maximum( + y_end - y_start + extra_length, 0) if mode == 'iou': union = area1[i] + area2 - overlap else: union = area1[i] if not exchange else area2 + union = np.maximum(union, eps) ious[i, :] = overlap / union if exchange: ious = ious.T diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/class_names.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/class_names.py index 784277345..737971182 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/class_names.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/class_names.py @@ -1,3 +1,4 @@ +# Copyright (c) OpenMMLab. All rights reserved. import mmcv @@ -89,13 +90,228 @@ def cityscapes_classes(): ] +def oid_challenge_classes(): + return [ + 'Footwear', 'Jeans', 'House', 'Tree', 'Woman', 'Man', 'Land vehicle', + 'Person', 'Wheel', 'Bus', 'Human face', 'Bird', 'Dress', 'Girl', + 'Vehicle', 'Building', 'Cat', 'Car', 'Belt', 'Elephant', 'Dessert', + 'Butterfly', 'Train', 'Guitar', 'Poster', 'Book', 'Boy', 'Bee', + 'Flower', 'Window', 'Hat', 'Human head', 'Dog', 'Human arm', 'Drink', + 'Human mouth', 'Human hair', 'Human nose', 'Human hand', 'Table', + 'Marine invertebrates', 'Fish', 'Sculpture', 'Rose', 'Street light', + 'Glasses', 'Fountain', 'Skyscraper', 'Swimwear', 'Brassiere', 'Drum', + 'Duck', 'Countertop', 'Furniture', 'Ball', 'Human leg', 'Boat', + 'Balloon', 'Bicycle helmet', 'Goggles', 'Door', 'Human eye', 'Shirt', + 'Toy', 'Teddy bear', 'Pasta', 'Tomato', 'Human ear', + 'Vehicle registration plate', 'Microphone', 'Musical keyboard', + 'Tower', 'Houseplant', 'Flowerpot', 'Fruit', 'Vegetable', + 'Musical instrument', 'Suit', 'Motorcycle', 'Bagel', 'French fries', + 'Hamburger', 'Chair', 'Salt and pepper shakers', 'Snail', 'Airplane', + 'Horse', 'Laptop', 'Computer keyboard', 'Football helmet', 'Cocktail', + 'Juice', 'Tie', 'Computer monitor', 'Human beard', 'Bottle', + 'Saxophone', 'Lemon', 'Mouse', 'Sock', 'Cowboy hat', 'Sun hat', + 'Football', 'Porch', 'Sunglasses', 'Lobster', 'Crab', 'Picture frame', + 'Van', 'Crocodile', 'Surfboard', 'Shorts', 'Helicopter', 'Helmet', + 'Sports uniform', 'Taxi', 'Swan', 'Goose', 'Coat', 'Jacket', 'Handbag', + 'Flag', 'Skateboard', 'Television', 'Tire', 'Spoon', 'Palm tree', + 'Stairs', 'Salad', 'Castle', 'Oven', 'Microwave oven', 'Wine', + 'Ceiling fan', 'Mechanical fan', 'Cattle', 'Truck', 'Box', 'Ambulance', + 'Desk', 'Wine glass', 'Reptile', 'Tank', 'Traffic light', 'Billboard', + 'Tent', 'Insect', 'Spider', 'Treadmill', 'Cupboard', 'Shelf', + 'Seat belt', 'Human foot', 'Bicycle', 'Bicycle wheel', 'Couch', + 'Bookcase', 'Fedora', 'Backpack', 'Bench', 'Oyster', + 'Moths and butterflies', 'Lavender', 'Waffle', 'Fork', 'Animal', + 'Accordion', 'Mobile phone', 'Plate', 'Coffee cup', 'Saucer', + 'Platter', 'Dagger', 'Knife', 'Bull', 'Tortoise', 'Sea turtle', 'Deer', + 'Weapon', 'Apple', 'Ski', 'Taco', 'Traffic sign', 'Beer', 'Necklace', + 'Sunflower', 'Piano', 'Organ', 'Harpsichord', 'Bed', 'Cabinetry', + 'Nightstand', 'Curtain', 'Chest of drawers', 'Drawer', 'Parrot', + 'Sandal', 'High heels', 'Tableware', 'Cart', 'Mushroom', 'Kite', + 'Missile', 'Seafood', 'Camera', 'Paper towel', 'Toilet paper', + 'Sombrero', 'Radish', 'Lighthouse', 'Segway', 'Pig', 'Watercraft', + 'Golf cart', 'studio couch', 'Dolphin', 'Whale', 'Earrings', 'Otter', + 'Sea lion', 'Whiteboard', 'Monkey', 'Gondola', 'Zebra', + 'Baseball glove', 'Scarf', 'Adhesive tape', 'Trousers', 'Scoreboard', + 'Lily', 'Carnivore', 'Power plugs and sockets', 'Office building', + 'Sandwich', 'Swimming pool', 'Headphones', 'Tin can', 'Crown', 'Doll', + 'Cake', 'Frog', 'Beetle', 'Ant', 'Gas stove', 'Canoe', 'Falcon', + 'Blue jay', 'Egg', 'Fire hydrant', 'Raccoon', 'Muffin', 'Wall clock', + 'Coffee', 'Mug', 'Tea', 'Bear', 'Waste container', 'Home appliance', + 'Candle', 'Lion', 'Mirror', 'Starfish', 'Marine mammal', 'Wheelchair', + 'Umbrella', 'Alpaca', 'Violin', 'Cello', 'Brown bear', 'Canary', 'Bat', + 'Ruler', 'Plastic bag', 'Penguin', 'Watermelon', 'Harbor seal', 'Pen', + 'Pumpkin', 'Harp', 'Kitchen appliance', 'Roller skates', 'Bust', + 'Coffee table', 'Tennis ball', 'Tennis racket', 'Ladder', 'Boot', + 'Bowl', 'Stop sign', 'Volleyball', 'Eagle', 'Paddle', 'Chicken', + 'Skull', 'Lamp', 'Beehive', 'Maple', 'Sink', 'Goldfish', 'Tripod', + 'Coconut', 'Bidet', 'Tap', 'Bathroom cabinet', 'Toilet', + 'Filing cabinet', 'Pretzel', 'Table tennis racket', 'Bronze sculpture', + 'Rocket', 'Mouse', 'Hamster', 'Lizard', 'Lifejacket', 'Goat', + 'Washing machine', 'Trumpet', 'Horn', 'Trombone', 'Sheep', + 'Tablet computer', 'Pillow', 'Kitchen & dining room table', + 'Parachute', 'Raven', 'Glove', 'Loveseat', 'Christmas tree', + 'Shellfish', 'Rifle', 'Shotgun', 'Sushi', 'Sparrow', 'Bread', + 'Toaster', 'Watch', 'Asparagus', 'Artichoke', 'Suitcase', 'Antelope', + 'Broccoli', 'Ice cream', 'Racket', 'Banana', 'Cookie', 'Cucumber', + 'Dragonfly', 'Lynx', 'Caterpillar', 'Light bulb', 'Office supplies', + 'Miniskirt', 'Skirt', 'Fireplace', 'Potato', 'Light switch', + 'Croissant', 'Cabbage', 'Ladybug', 'Handgun', 'Luggage and bags', + 'Window blind', 'Snowboard', 'Baseball bat', 'Digital clock', + 'Serving tray', 'Infant bed', 'Sofa bed', 'Guacamole', 'Fox', 'Pizza', + 'Snowplow', 'Jet ski', 'Refrigerator', 'Lantern', 'Convenience store', + 'Sword', 'Rugby ball', 'Owl', 'Ostrich', 'Pancake', 'Strawberry', + 'Carrot', 'Tart', 'Dice', 'Turkey', 'Rabbit', 'Invertebrate', 'Vase', + 'Stool', 'Swim cap', 'Shower', 'Clock', 'Jellyfish', 'Aircraft', + 'Chopsticks', 'Orange', 'Snake', 'Sewing machine', 'Kangaroo', 'Mixer', + 'Food processor', 'Shrimp', 'Towel', 'Porcupine', 'Jaguar', 'Cannon', + 'Limousine', 'Mule', 'Squirrel', 'Kitchen knife', 'Tiara', 'Tiger', + 'Bow and arrow', 'Candy', 'Rhinoceros', 'Shark', 'Cricket ball', + 'Doughnut', 'Plumbing fixture', 'Camel', 'Polar bear', 'Coin', + 'Printer', 'Blender', 'Giraffe', 'Billiard table', 'Kettle', + 'Dinosaur', 'Pineapple', 'Zucchini', 'Jug', 'Barge', 'Teapot', + 'Golf ball', 'Binoculars', 'Scissors', 'Hot dog', 'Door handle', + 'Seahorse', 'Bathtub', 'Leopard', 'Centipede', 'Grapefruit', 'Snowman', + 'Cheetah', 'Alarm clock', 'Grape', 'Wrench', 'Wok', 'Bell pepper', + 'Cake stand', 'Barrel', 'Woodpecker', 'Flute', 'Corded phone', + 'Willow', 'Punching bag', 'Pomegranate', 'Telephone', 'Pear', + 'Common fig', 'Bench', 'Wood-burning stove', 'Burrito', 'Nail', + 'Turtle', 'Submarine sandwich', 'Drinking straw', 'Peach', 'Popcorn', + 'Frying pan', 'Picnic basket', 'Honeycomb', 'Envelope', 'Mango', + 'Cutting board', 'Pitcher', 'Stationary bicycle', 'Dumbbell', + 'Personal care', 'Dog bed', 'Snowmobile', 'Oboe', 'Briefcase', + 'Squash', 'Tick', 'Slow cooker', 'Coffeemaker', 'Measuring cup', + 'Crutch', 'Stretcher', 'Screwdriver', 'Flashlight', 'Spatula', + 'Pressure cooker', 'Ring binder', 'Beaker', 'Torch', 'Winter melon' + ] + + +def oid_v6_classes(): + return [ + 'Tortoise', 'Container', 'Magpie', 'Sea turtle', 'Football', + 'Ambulance', 'Ladder', 'Toothbrush', 'Syringe', 'Sink', 'Toy', + 'Organ (Musical Instrument)', 'Cassette deck', 'Apple', 'Human eye', + 'Cosmetics', 'Paddle', 'Snowman', 'Beer', 'Chopsticks', 'Human beard', + 'Bird', 'Parking meter', 'Traffic light', 'Croissant', 'Cucumber', + 'Radish', 'Towel', 'Doll', 'Skull', 'Washing machine', 'Glove', 'Tick', + 'Belt', 'Sunglasses', 'Banjo', 'Cart', 'Ball', 'Backpack', 'Bicycle', + 'Home appliance', 'Centipede', 'Boat', 'Surfboard', 'Boot', + 'Headphones', 'Hot dog', 'Shorts', 'Fast food', 'Bus', 'Boy', + 'Screwdriver', 'Bicycle wheel', 'Barge', 'Laptop', 'Miniskirt', + 'Drill (Tool)', 'Dress', 'Bear', 'Waffle', 'Pancake', 'Brown bear', + 'Woodpecker', 'Blue jay', 'Pretzel', 'Bagel', 'Tower', 'Teapot', + 'Person', 'Bow and arrow', 'Swimwear', 'Beehive', 'Brassiere', 'Bee', + 'Bat (Animal)', 'Starfish', 'Popcorn', 'Burrito', 'Chainsaw', + 'Balloon', 'Wrench', 'Tent', 'Vehicle registration plate', 'Lantern', + 'Toaster', 'Flashlight', 'Billboard', 'Tiara', 'Limousine', 'Necklace', + 'Carnivore', 'Scissors', 'Stairs', 'Computer keyboard', 'Printer', + 'Traffic sign', 'Chair', 'Shirt', 'Poster', 'Cheese', 'Sock', + 'Fire hydrant', 'Land vehicle', 'Earrings', 'Tie', 'Watercraft', + 'Cabinetry', 'Suitcase', 'Muffin', 'Bidet', 'Snack', 'Snowmobile', + 'Clock', 'Medical equipment', 'Cattle', 'Cello', 'Jet ski', 'Camel', + 'Coat', 'Suit', 'Desk', 'Cat', 'Bronze sculpture', 'Juice', 'Gondola', + 'Beetle', 'Cannon', 'Computer mouse', 'Cookie', 'Office building', + 'Fountain', 'Coin', 'Calculator', 'Cocktail', 'Computer monitor', + 'Box', 'Stapler', 'Christmas tree', 'Cowboy hat', 'Hiking equipment', + 'Studio couch', 'Drum', 'Dessert', 'Wine rack', 'Drink', 'Zucchini', + 'Ladle', 'Human mouth', 'Dairy Product', 'Dice', 'Oven', 'Dinosaur', + 'Ratchet (Device)', 'Couch', 'Cricket ball', 'Winter melon', 'Spatula', + 'Whiteboard', 'Pencil sharpener', 'Door', 'Hat', 'Shower', 'Eraser', + 'Fedora', 'Guacamole', 'Dagger', 'Scarf', 'Dolphin', 'Sombrero', + 'Tin can', 'Mug', 'Tap', 'Harbor seal', 'Stretcher', 'Can opener', + 'Goggles', 'Human body', 'Roller skates', 'Coffee cup', + 'Cutting board', 'Blender', 'Plumbing fixture', 'Stop sign', + 'Office supplies', 'Volleyball (Ball)', 'Vase', 'Slow cooker', + 'Wardrobe', 'Coffee', 'Whisk', 'Paper towel', 'Personal care', 'Food', + 'Sun hat', 'Tree house', 'Flying disc', 'Skirt', 'Gas stove', + 'Salt and pepper shakers', 'Mechanical fan', 'Face powder', 'Fax', + 'Fruit', 'French fries', 'Nightstand', 'Barrel', 'Kite', 'Tart', + 'Treadmill', 'Fox', 'Flag', 'French horn', 'Window blind', + 'Human foot', 'Golf cart', 'Jacket', 'Egg (Food)', 'Street light', + 'Guitar', 'Pillow', 'Human leg', 'Isopod', 'Grape', 'Human ear', + 'Power plugs and sockets', 'Panda', 'Giraffe', 'Woman', 'Door handle', + 'Rhinoceros', 'Bathtub', 'Goldfish', 'Houseplant', 'Goat', + 'Baseball bat', 'Baseball glove', 'Mixing bowl', + 'Marine invertebrates', 'Kitchen utensil', 'Light switch', 'House', + 'Horse', 'Stationary bicycle', 'Hammer', 'Ceiling fan', 'Sofa bed', + 'Adhesive tape', 'Harp', 'Sandal', 'Bicycle helmet', 'Saucer', + 'Harpsichord', 'Human hair', 'Heater', 'Harmonica', 'Hamster', + 'Curtain', 'Bed', 'Kettle', 'Fireplace', 'Scale', 'Drinking straw', + 'Insect', 'Hair dryer', 'Kitchenware', 'Indoor rower', 'Invertebrate', + 'Food processor', 'Bookcase', 'Refrigerator', 'Wood-burning stove', + 'Punching bag', 'Common fig', 'Cocktail shaker', 'Jaguar (Animal)', + 'Golf ball', 'Fashion accessory', 'Alarm clock', 'Filing cabinet', + 'Artichoke', 'Table', 'Tableware', 'Kangaroo', 'Koala', 'Knife', + 'Bottle', 'Bottle opener', 'Lynx', 'Lavender (Plant)', 'Lighthouse', + 'Dumbbell', 'Human head', 'Bowl', 'Humidifier', 'Porch', 'Lizard', + 'Billiard table', 'Mammal', 'Mouse', 'Motorcycle', + 'Musical instrument', 'Swim cap', 'Frying pan', 'Snowplow', + 'Bathroom cabinet', 'Missile', 'Bust', 'Man', 'Waffle iron', 'Milk', + 'Ring binder', 'Plate', 'Mobile phone', 'Baked goods', 'Mushroom', + 'Crutch', 'Pitcher (Container)', 'Mirror', 'Personal flotation device', + 'Table tennis racket', 'Pencil case', 'Musical keyboard', 'Scoreboard', + 'Briefcase', 'Kitchen knife', 'Nail (Construction)', 'Tennis ball', + 'Plastic bag', 'Oboe', 'Chest of drawers', 'Ostrich', 'Piano', 'Girl', + 'Plant', 'Potato', 'Hair spray', 'Sports equipment', 'Pasta', + 'Penguin', 'Pumpkin', 'Pear', 'Infant bed', 'Polar bear', 'Mixer', + 'Cupboard', 'Jacuzzi', 'Pizza', 'Digital clock', 'Pig', 'Reptile', + 'Rifle', 'Lipstick', 'Skateboard', 'Raven', 'High heels', 'Red panda', + 'Rose', 'Rabbit', 'Sculpture', 'Saxophone', 'Shotgun', 'Seafood', + 'Submarine sandwich', 'Snowboard', 'Sword', 'Picture frame', 'Sushi', + 'Loveseat', 'Ski', 'Squirrel', 'Tripod', 'Stethoscope', 'Submarine', + 'Scorpion', 'Segway', 'Training bench', 'Snake', 'Coffee table', + 'Skyscraper', 'Sheep', 'Television', 'Trombone', 'Tea', 'Tank', 'Taco', + 'Telephone', 'Torch', 'Tiger', 'Strawberry', 'Trumpet', 'Tree', + 'Tomato', 'Train', 'Tool', 'Picnic basket', 'Cooking spray', + 'Trousers', 'Bowling equipment', 'Football helmet', 'Truck', + 'Measuring cup', 'Coffeemaker', 'Violin', 'Vehicle', 'Handbag', + 'Paper cutter', 'Wine', 'Weapon', 'Wheel', 'Worm', 'Wok', 'Whale', + 'Zebra', 'Auto part', 'Jug', 'Pizza cutter', 'Cream', 'Monkey', 'Lion', + 'Bread', 'Platter', 'Chicken', 'Eagle', 'Helicopter', 'Owl', 'Duck', + 'Turtle', 'Hippopotamus', 'Crocodile', 'Toilet', 'Toilet paper', + 'Squid', 'Clothing', 'Footwear', 'Lemon', 'Spider', 'Deer', 'Frog', + 'Banana', 'Rocket', 'Wine glass', 'Countertop', 'Tablet computer', + 'Waste container', 'Swimming pool', 'Dog', 'Book', 'Elephant', 'Shark', + 'Candle', 'Leopard', 'Axe', 'Hand dryer', 'Soap dispenser', + 'Porcupine', 'Flower', 'Canary', 'Cheetah', 'Palm tree', 'Hamburger', + 'Maple', 'Building', 'Fish', 'Lobster', 'Garden Asparagus', + 'Furniture', 'Hedgehog', 'Airplane', 'Spoon', 'Otter', 'Bull', + 'Oyster', 'Horizontal bar', 'Convenience store', 'Bomb', 'Bench', + 'Ice cream', 'Caterpillar', 'Butterfly', 'Parachute', 'Orange', + 'Antelope', 'Beaker', 'Moths and butterflies', 'Window', 'Closet', + 'Castle', 'Jellyfish', 'Goose', 'Mule', 'Swan', 'Peach', 'Coconut', + 'Seat belt', 'Raccoon', 'Chisel', 'Fork', 'Lamp', 'Camera', + 'Squash (Plant)', 'Racket', 'Human face', 'Human arm', 'Vegetable', + 'Diaper', 'Unicycle', 'Falcon', 'Chime', 'Snail', 'Shellfish', + 'Cabbage', 'Carrot', 'Mango', 'Jeans', 'Flowerpot', 'Pineapple', + 'Drawer', 'Stool', 'Envelope', 'Cake', 'Dragonfly', 'Common sunflower', + 'Microwave oven', 'Honeycomb', 'Marine mammal', 'Sea lion', 'Ladybug', + 'Shelf', 'Watch', 'Candy', 'Salad', 'Parrot', 'Handgun', 'Sparrow', + 'Van', 'Grinder', 'Spice rack', 'Light bulb', 'Corded phone', + 'Sports uniform', 'Tennis racket', 'Wall clock', 'Serving tray', + 'Kitchen & dining room table', 'Dog bed', 'Cake stand', + 'Cat furniture', 'Bathroom accessory', 'Facial tissue holder', + 'Pressure cooker', 'Kitchen appliance', 'Tire', 'Ruler', + 'Luggage and bags', 'Microphone', 'Broccoli', 'Umbrella', 'Pastry', + 'Grapefruit', 'Band-aid', 'Animal', 'Bell pepper', 'Turkey', 'Lily', + 'Pomegranate', 'Doughnut', 'Glasses', 'Human nose', 'Pen', 'Ant', + 'Car', 'Aircraft', 'Human hand', 'Skunk', 'Teddy bear', 'Watermelon', + 'Cantaloupe', 'Dishwasher', 'Flute', 'Balance beam', 'Sandwich', + 'Shrimp', 'Sewing machine', 'Binoculars', 'Rays and skates', 'Ipod', + 'Accordion', 'Willow', 'Crab', 'Crown', 'Seahorse', 'Perfume', + 'Alpaca', 'Taxi', 'Canoe', 'Remote control', 'Wheelchair', + 'Rugby ball', 'Armadillo', 'Maracas', 'Helmet' + ] + + dataset_aliases = { 'voc': ['voc', 'pascal_voc', 'voc07', 'voc12'], 'imagenet_det': ['det', 'imagenet_det', 'ilsvrc_det'], 'imagenet_vid': ['vid', 'imagenet_vid', 'ilsvrc_vid'], 'coco': ['coco', 'mscoco', 'ms_coco'], - 'wider_face': ['WIDERFaceDataset', 'wider_face', 'WDIERFace'], - 'cityscapes': ['cityscapes'] + 'wider_face': ['WIDERFaceDataset', 'wider_face', 'WIDERFace'], + 'cityscapes': ['cityscapes'], + 'oid_challenge': ['oid_challenge', 'openimages_challenge'], + 'oid_v6': ['oid_v6', 'openimages_v6'] } @@ -110,7 +326,7 @@ def get_classes(dataset): if dataset in alias2name: labels = eval(alias2name[dataset] + '_classes()') else: - raise ValueError('Unrecognized dataset: {}'.format(dataset)) + raise ValueError(f'Unrecognized dataset: {dataset}') else: - raise TypeError('dataset must a str, but got {}'.format(type(dataset))) + raise TypeError(f'dataset must a str, but got {type(dataset)}') return labels diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/coco_utils.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/coco_utils.py deleted file mode 100644 index d57ca4d19..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/coco_utils.py +++ /dev/null @@ -1,250 +0,0 @@ -import itertools - -import mmcv -import numpy as np -from pycocotools.coco import COCO -from pycocotools.cocoeval import COCOeval -from terminaltables import AsciiTable - -from .recall import eval_recalls - - -def coco_eval(result_files, - result_types, - coco, - max_dets=(100, 300, 1000), - classwise=False): - for res_type in result_types: - assert res_type in [ - 'proposal', 'proposal_fast', 'bbox', 'segm', 'keypoints' - ] - - if mmcv.is_str(coco): - coco = COCO(coco) - assert isinstance(coco, COCO) - - if result_types == ['proposal_fast']: - ar = fast_eval_recall(result_files, coco, np.array(max_dets)) - for i, num in enumerate(max_dets): - print('AR@{}\t= {:.4f}'.format(num, ar[i])) - return - - for res_type in result_types: - if isinstance(result_files, str): - result_file = result_files - elif isinstance(result_files, dict): - result_file = result_files[res_type] - else: - assert TypeError('result_files must be a str or dict') - assert result_file.endswith('.json') - - coco_dets = coco.loadRes(result_file) - img_ids = coco.getImgIds() - iou_type = 'bbox' if res_type == 'proposal' else res_type - cocoEval = COCOeval(coco, coco_dets, iou_type) - cocoEval.params.imgIds = img_ids - if res_type == 'proposal': - cocoEval.params.useCats = 0 - cocoEval.params.maxDets = list(max_dets) - cocoEval.evaluate() - cocoEval.accumulate() - cocoEval.summarize() - - if classwise: - # Compute per-category AP - # from https://github.com/facebookresearch/detectron2/blob/03064eb5bafe4a3e5750cc7a16672daf5afe8435/detectron2/evaluation/coco_evaluation.py#L259-L283 # noqa - precisions = cocoEval.eval['precision'] - catIds = coco.getCatIds() - # precision has dims (iou, recall, cls, area range, max dets) - assert len(catIds) == precisions.shape[2] - - results_per_category = [] - for idx, catId in enumerate(catIds): - # area range index 0: all area ranges - # max dets index -1: typically 100 per image - nm = coco.loadCats(catId)[0] - precision = precisions[:, :, idx, 0, -1] - precision = precision[precision > -1] - ap = np.mean(precision) if precision.size else float('nan') - results_per_category.append( - ('{}'.format(nm['name']), - '{:0.3f}'.format(float(ap * 100)))) - - N_COLS = min(6, len(results_per_category) * 2) - results_flatten = list(itertools.chain(*results_per_category)) - headers = ['category', 'AP'] * (N_COLS // 2) - results_2d = itertools.zip_longest( - *[results_flatten[i::N_COLS] for i in range(N_COLS)]) - table_data = [headers] - table_data += [result for result in results_2d] - table = AsciiTable(table_data) - print(table.table) - - -def fast_eval_recall(results, - coco, - max_dets, - iou_thrs=np.arange(0.5, 0.96, 0.05)): - if mmcv.is_str(results): - assert results.endswith('.pkl') - results = mmcv.load(results) - elif not isinstance(results, list): - raise TypeError( - 'results must be a list of numpy arrays or a filename, not {}'. - format(type(results))) - - gt_bboxes = [] - img_ids = coco.getImgIds() - for i in range(len(img_ids)): - ann_ids = coco.getAnnIds(imgIds=img_ids[i]) - ann_info = coco.loadAnns(ann_ids) - if len(ann_info) == 0: - gt_bboxes.append(np.zeros((0, 4))) - continue - bboxes = [] - for ann in ann_info: - if ann.get('ignore', False) or ann['iscrowd']: - continue - x1, y1, w, h = ann['bbox'] - bboxes.append([x1, y1, x1 + w - 1, y1 + h - 1]) - bboxes = np.array(bboxes, dtype=np.float32) - if bboxes.shape[0] == 0: - bboxes = np.zeros((0, 4)) - gt_bboxes.append(bboxes) - - recalls = eval_recalls( - gt_bboxes, results, max_dets, iou_thrs, print_summary=False) - ar = recalls.mean(axis=1) - return ar - - -def xyxy2xywh(bbox): - _bbox = bbox.tolist() - return [ - _bbox[0], - _bbox[1], - _bbox[2] - _bbox[0] + 1, - _bbox[3] - _bbox[1] + 1, - ] - - -def proposal2json(dataset, results): - json_results = [] - for idx in range(len(dataset)): - img_id = dataset.img_ids[idx] - bboxes = results[idx] - for i in range(bboxes.shape[0]): - data = dict() - data['image_id'] = img_id - data['bbox'] = xyxy2xywh(bboxes[i]) - data['score'] = float(bboxes[i][4]) - data['category_id'] = 1 - json_results.append(data) - return json_results - - -def det2json(dataset, results): - json_results = [] - for idx in range(len(dataset)): - img_id = dataset.img_ids[idx] - result = results[idx] - for label in range(len(result)): - bboxes = result[label] - for i in range(bboxes.shape[0]): - data = dict() - data['image_id'] = img_id - data['bbox'] = xyxy2xywh(bboxes[i]) - data['score'] = float(bboxes[i][4]) - data['category_id'] = dataset.cat_ids[label] - json_results.append(data) - return json_results - - -def segm2json(dataset, results): - bbox_json_results = [] - segm_json_results = [] - for idx in range(len(dataset)): - img_id = dataset.img_ids[idx] - det, seg = results[idx] - for label in range(len(det)): - # bbox results - bboxes = det[label] - for i in range(bboxes.shape[0]): - data = dict() - data['image_id'] = img_id - data['bbox'] = xyxy2xywh(bboxes[i]) - data['score'] = float(bboxes[i][4]) - data['category_id'] = dataset.cat_ids[label] - bbox_json_results.append(data) - - # segm results - # some detectors use different score for det and segm - if isinstance(seg, tuple): - segms = seg[0][label] - mask_score = seg[1][label] - else: - segms = seg[label] - mask_score = [bbox[4] for bbox in bboxes] - for i in range(bboxes.shape[0]): - data = dict() - data['image_id'] = img_id - data['bbox'] = xyxy2xywh(bboxes[i]) - data['score'] = float(mask_score[i]) - data['category_id'] = dataset.cat_ids[label] - if isinstance(segms[i]['counts'], bytes): - segms[i]['counts'] = segms[i]['counts'].decode() - data['segmentation'] = segms[i] - segm_json_results.append(data) - return bbox_json_results, segm_json_results - - -def segm2json_segm(dataset, results): - segm_json_results = [] - for idx in range(len(dataset)): - img_id = dataset.img_ids[idx] - seg = results[idx] - for label in range(len(seg)): - masks = seg[label] - for i in range(len(masks)): - mask_score = masks[i][1] - segm = masks[i][0] - data = dict() - data['image_id'] = img_id - data['score'] = float(mask_score) - data['category_id'] = dataset.cat_ids[label] - segm['counts'] = segm['counts'].decode() - data['segmentation'] = segm - segm_json_results.append(data) - return segm_json_results - - -def results2json(dataset, results, out_file): - result_files = dict() - if isinstance(results[0], list): - json_results = det2json(dataset, results) - result_files['bbox'] = '{}.{}.json'.format(out_file, 'bbox') - result_files['proposal'] = '{}.{}.json'.format(out_file, 'bbox') - mmcv.dump(json_results, result_files['bbox']) - elif isinstance(results[0], tuple): - json_results = segm2json(dataset, results) - result_files['bbox'] = '{}.{}.json'.format(out_file, 'bbox') - result_files['proposal'] = '{}.{}.json'.format(out_file, 'bbox') - result_files['segm'] = '{}.{}.json'.format(out_file, 'segm') - mmcv.dump(json_results[0], result_files['bbox']) - mmcv.dump(json_results[1], result_files['segm']) - elif isinstance(results[0], np.ndarray): - json_results = proposal2json(dataset, results) - result_files['proposal'] = '{}.{}.json'.format(out_file, 'proposal') - mmcv.dump(json_results, result_files['proposal']) - else: - raise TypeError('invalid type of results') - return result_files - - -def results2json_segm(dataset, results, out_file): - result_files = dict() - json_results = segm2json_segm(dataset, results) - result_files['segm'] = '{}.{}.json'.format(out_file, 'segm') - mmcv.dump(json_results, result_files['segm']) - - return result_files diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/eval_hooks.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/eval_hooks.py index 1a074eec1..98856c18c 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/eval_hooks.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/eval_hooks.py @@ -1,152 +1,140 @@ -import os +# Copyright (c) OpenMMLab. All rights reserved. +import bisect import os.path as osp import mmcv -import numpy as np -import torch import torch.distributed as dist -from mmcv.parallel import collate, scatter -from mmcv.runner import Hook -from pycocotools.cocoeval import COCOeval -from torch.utils.data import Dataset - -from mmdet import datasets -from .coco_utils import fast_eval_recall, results2json -from .mean_ap import eval_map - - -class DistEvalHook(Hook): - - def __init__(self, dataset, interval=1): - if isinstance(dataset, Dataset): - self.dataset = dataset - elif isinstance(dataset, dict): - self.dataset = datasets.build_dataset(dataset, {'test_mode': True}) - else: - raise TypeError( - 'dataset must be a Dataset object or a dict, not {}'.format( - type(dataset))) - self.interval = interval - - def after_train_epoch(self, runner): - if not self.every_n_epochs(runner, self.interval): +from mmcv.runner import DistEvalHook as BaseDistEvalHook +from mmcv.runner import EvalHook as BaseEvalHook +from torch.nn.modules.batchnorm import _BatchNorm + + +def _calc_dynamic_intervals(start_interval, dynamic_interval_list): + assert mmcv.is_list_of(dynamic_interval_list, tuple) + + dynamic_milestones = [0] + dynamic_milestones.extend( + [dynamic_interval[0] for dynamic_interval in dynamic_interval_list]) + dynamic_intervals = [start_interval] + dynamic_intervals.extend( + [dynamic_interval[1] for dynamic_interval in dynamic_interval_list]) + return dynamic_milestones, dynamic_intervals + + +class EvalHook(BaseEvalHook): + + def __init__(self, *args, dynamic_intervals=None, **kwargs): + super(EvalHook, self).__init__(*args, **kwargs) + self.latest_results = None + + self.use_dynamic_intervals = dynamic_intervals is not None + if self.use_dynamic_intervals: + self.dynamic_milestones, self.dynamic_intervals = \ + _calc_dynamic_intervals(self.interval, dynamic_intervals) + + def _decide_interval(self, runner): + if self.use_dynamic_intervals: + progress = runner.epoch if self.by_epoch else runner.iter + step = bisect.bisect(self.dynamic_milestones, (progress + 1)) + # Dynamically modify the evaluation interval + self.interval = self.dynamic_intervals[step - 1] + + def before_train_epoch(self, runner): + """Evaluate the model only at the start of training by epoch.""" + self._decide_interval(runner) + super().before_train_epoch(runner) + + def before_train_iter(self, runner): + self._decide_interval(runner) + super().before_train_iter(runner) + + def _do_evaluate(self, runner): + """perform evaluation and save ckpt.""" + if not self._should_evaluate(runner): return - runner.model.eval() - results = [None for _ in range(len(self.dataset))] - if runner.rank == 0: - prog_bar = mmcv.ProgressBar(len(self.dataset)) - for idx in range(runner.rank, len(self.dataset), runner.world_size): - data = self.dataset[idx] - data_gpu = scatter( - collate([data], samples_per_gpu=1), - [torch.cuda.current_device()])[0] - - # compute output - with torch.no_grad(): - result = runner.model( - return_loss=False, rescale=True, **data_gpu) - results[idx] = result - - batch_size = runner.world_size - if runner.rank == 0: - for _ in range(batch_size): - prog_bar.update() + from mmdet.apis import single_gpu_test + + # Changed results to self.results so that MMDetWandbHook can access + # the evaluation results and log them to wandb. + results = single_gpu_test(runner.model, self.dataloader, show=False) + self.latest_results = results + runner.log_buffer.output['eval_iter_num'] = len(self.dataloader) + key_score = self.evaluate(runner, results) + # the key_score may be `None` so it needs to skip the action to save + # the best checkpoint + if self.save_best and key_score: + self._save_ckpt(runner, key_score) + + +# Note: Considering that MMCV's EvalHook updated its interface in V1.3.16, +# in order to avoid strong version dependency, we did not directly +# inherit EvalHook but BaseDistEvalHook. +class DistEvalHook(BaseDistEvalHook): + + def __init__(self, *args, dynamic_intervals=None, **kwargs): + super(DistEvalHook, self).__init__(*args, **kwargs) + self.latest_results = None + + self.use_dynamic_intervals = dynamic_intervals is not None + if self.use_dynamic_intervals: + self.dynamic_milestones, self.dynamic_intervals = \ + _calc_dynamic_intervals(self.interval, dynamic_intervals) + + def _decide_interval(self, runner): + if self.use_dynamic_intervals: + progress = runner.epoch if self.by_epoch else runner.iter + step = bisect.bisect(self.dynamic_milestones, (progress + 1)) + # Dynamically modify the evaluation interval + self.interval = self.dynamic_intervals[step - 1] + + def before_train_epoch(self, runner): + """Evaluate the model only at the start of training by epoch.""" + self._decide_interval(runner) + super().before_train_epoch(runner) + + def before_train_iter(self, runner): + self._decide_interval(runner) + super().before_train_iter(runner) + + def _do_evaluate(self, runner): + """perform evaluation and save ckpt.""" + # Synchronization of BatchNorm's buffer (running_mean + # and running_var) is not supported in the DDP of pytorch, + # which may cause the inconsistent performance of models in + # different ranks, so we broadcast BatchNorm's buffers + # of rank 0 to other ranks to avoid this. + if self.broadcast_bn_buffer: + model = runner.model + for name, module in model.named_modules(): + if isinstance(module, + _BatchNorm) and module.track_running_stats: + dist.broadcast(module.running_var, 0) + dist.broadcast(module.running_mean, 0) + + if not self._should_evaluate(runner): + return + + tmpdir = self.tmpdir + if tmpdir is None: + tmpdir = osp.join(runner.work_dir, '.eval_hook') + + from mmdet.apis import multi_gpu_test + + # Changed results to self.results so that MMDetWandbHook can access + # the evaluation results and log them to wandb. + results = multi_gpu_test( + runner.model, + self.dataloader, + tmpdir=tmpdir, + gpu_collect=self.gpu_collect) + self.latest_results = results if runner.rank == 0: print('\n') - dist.barrier() - for i in range(1, runner.world_size): - tmp_file = osp.join(runner.work_dir, 'temp_{}.pkl'.format(i)) - tmp_results = mmcv.load(tmp_file) - for idx in range(i, len(results), runner.world_size): - results[idx] = tmp_results[idx] - os.remove(tmp_file) - self.evaluate(runner, results) - else: - tmp_file = osp.join(runner.work_dir, - 'temp_{}.pkl'.format(runner.rank)) - mmcv.dump(results, tmp_file) - dist.barrier() - dist.barrier() - - def evaluate(self): - raise NotImplementedError - - -class DistEvalmAPHook(DistEvalHook): - - def evaluate(self, runner, results): - annotations = [ - self.dataset.get_ann_info(i) for i in range(len(self.dataset)) - ] - # If the dataset is VOC2007, then use 11 points mAP evaluation. - if hasattr(self.dataset, 'year') and self.dataset.year == 2007: - ds_name = 'voc07' - else: - ds_name = self.dataset.CLASSES - mean_ap, eval_results = eval_map( - results, - annotations, - scale_ranges=None, - iou_thr=0.5, - dataset=ds_name, - logger=runner.logger) - runner.log_buffer.output['mAP'] = mean_ap - runner.log_buffer.ready = True - - -class CocoDistEvalRecallHook(DistEvalHook): - - def __init__(self, - dataset, - interval=1, - proposal_nums=(100, 300, 1000), - iou_thrs=np.arange(0.5, 0.96, 0.05)): - super(CocoDistEvalRecallHook, self).__init__( - dataset, interval=interval) - self.proposal_nums = np.array(proposal_nums, dtype=np.int32) - self.iou_thrs = np.array(iou_thrs, dtype=np.float32) - - def evaluate(self, runner, results): - # the official coco evaluation is too slow, here we use our own - # implementation instead, which may get slightly different results - ar = fast_eval_recall(results, self.dataset.coco, self.proposal_nums, - self.iou_thrs) - for i, num in enumerate(self.proposal_nums): - runner.log_buffer.output['AR@{}'.format(num)] = ar[i] - runner.log_buffer.ready = True - - -class CocoDistEvalmAPHook(DistEvalHook): - - def evaluate(self, runner, results): - tmp_file = osp.join(runner.work_dir, 'temp_0') - result_files = results2json(self.dataset, results, tmp_file) - - res_types = ['bbox', 'segm' - ] if runner.model.module.with_mask else ['bbox'] - cocoGt = self.dataset.coco - imgIds = cocoGt.getImgIds() - for res_type in res_types: - try: - cocoDt = cocoGt.loadRes(result_files[res_type]) - except IndexError: - print('No prediction found.') - break - iou_type = res_type - cocoEval = COCOeval(cocoGt, cocoDt, iou_type) - cocoEval.params.imgIds = imgIds - cocoEval.evaluate() - cocoEval.accumulate() - cocoEval.summarize() - metrics = ['mAP', 'mAP_50', 'mAP_75', 'mAP_s', 'mAP_m', 'mAP_l'] - for i in range(len(metrics)): - key = '{}_{}'.format(res_type, metrics[i]) - val = float('{:.3f}'.format(cocoEval.stats[i])) - runner.log_buffer.output[key] = val - runner.log_buffer.output['{}_mAP_copypaste'.format(res_type)] = ( - '{ap[0]:.3f} {ap[1]:.3f} {ap[2]:.3f} {ap[3]:.3f} ' - '{ap[4]:.3f} {ap[5]:.3f}').format(ap=cocoEval.stats[:6]) - runner.log_buffer.ready = True - for res_type in res_types: - os.remove(result_files[res_type]) + runner.log_buffer.output['eval_iter_num'] = len(self.dataloader) + key_score = self.evaluate(runner, results) + + # the key_score may be `None` so it needs to skip + # the action to save the best checkpoint + if self.save_best and key_score: + self._save_ckpt(runner, key_score) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/mean_ap.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/mean_ap.py index 4e3cd5d07..a293b80f0 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/mean_ap.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/mean_ap.py @@ -1,10 +1,11 @@ +# Copyright (c) OpenMMLab. All rights reserved. from multiprocessing import Pool import mmcv import numpy as np +from mmcv.utils import print_log from terminaltables import AsciiTable -from mmdet.utils import print_log from .bbox_overlaps import bbox_overlaps from .class_names import get_classes @@ -47,7 +48,7 @@ def average_precision(recalls, precisions, mode='area'): precs = precisions[i, recalls[i, :] >= thr] prec = precs.max() if precs.size > 0 else 0 ap[i] += prec - ap /= 11 + ap /= 11 else: raise ValueError( 'Unrecognized mode, only "area" and "11points" are supported') @@ -60,7 +61,9 @@ def tpfp_imagenet(det_bboxes, gt_bboxes, gt_bboxes_ignore=None, default_iou_thr=0.5, - area_ranges=None): + area_ranges=None, + use_legacy_coordinate=False, + **kwargs): """Check if detected bboxes are true positive or false positive. Args: @@ -73,11 +76,21 @@ def tpfp_imagenet(det_bboxes, Default: 0.5. area_ranges (list[tuple] | None): Range of bbox areas to be evaluated, in the format [(min1, max1), (min2, max2), ...]. Default: None. + use_legacy_coordinate (bool): Whether to use coordinate system in + mmdet v1.x. which means width, height should be + calculated as 'x2 - x1 + 1` and 'y2 - y1 + 1' respectively. + Default: False. Returns: tuple[np.ndarray]: (tp, fp) whose elements are 0 and 1. The shape of - each array is (num_scales, m). + each array is (num_scales, m). """ + + if not use_legacy_coordinate: + extra_length = 0. + else: + extra_length = 1. + # an indicator of ignored gts gt_ignore_inds = np.concatenate( (np.zeros(gt_bboxes.shape[0], dtype=np.bool), @@ -98,14 +111,16 @@ def tpfp_imagenet(det_bboxes, if area_ranges == [(None, None)]: fp[...] = 1 else: - det_areas = (det_bboxes[:, 2] - det_bboxes[:, 0] + 1) * ( - det_bboxes[:, 3] - det_bboxes[:, 1] + 1) + det_areas = ( + det_bboxes[:, 2] - det_bboxes[:, 0] + extra_length) * ( + det_bboxes[:, 3] - det_bboxes[:, 1] + extra_length) for i, (min_area, max_area) in enumerate(area_ranges): fp[i, (det_areas >= min_area) & (det_areas < max_area)] = 1 return tp, fp - ious = bbox_overlaps(det_bboxes, gt_bboxes - 1) - gt_w = gt_bboxes[:, 2] - gt_bboxes[:, 0] + 1 - gt_h = gt_bboxes[:, 3] - gt_bboxes[:, 1] + 1 + ious = bbox_overlaps( + det_bboxes, gt_bboxes - 1, use_legacy_coordinate=use_legacy_coordinate) + gt_w = gt_bboxes[:, 2] - gt_bboxes[:, 0] + extra_length + gt_h = gt_bboxes[:, 3] - gt_bboxes[:, 1] + extra_length iou_thrs = np.minimum((gt_w * gt_h) / ((gt_w + 10.0) * (gt_h + 10.0)), default_iou_thr) # sort all detections by scores in descending order @@ -124,7 +139,7 @@ def tpfp_imagenet(det_bboxes, # find best overlapped available gt for j in range(num_gts): # different from PASCAL VOC: allow finding other gts if the - # best overlaped ones are already matched by other det bboxes + # best overlapped ones are already matched by other det bboxes if gt_covered[j]: continue elif ious[i, j] >= iou_thrs[j] and ious[i, j] > max_iou: @@ -144,7 +159,8 @@ def tpfp_imagenet(det_bboxes, fp[k, i] = 1 else: bbox = det_bboxes[i, :4] - area = (bbox[2] - bbox[0] + 1) * (bbox[3] - bbox[1] + 1) + area = (bbox[2] - bbox[0] + extra_length) * ( + bbox[3] - bbox[1] + extra_length) if area >= min_area and area < max_area: fp[k, i] = 1 return tp, fp @@ -154,7 +170,9 @@ def tpfp_default(det_bboxes, gt_bboxes, gt_bboxes_ignore=None, iou_thr=0.5, - area_ranges=None): + area_ranges=None, + use_legacy_coordinate=False, + **kwargs): """Check if detected bboxes are true positive or false positive. Args: @@ -164,13 +182,24 @@ def tpfp_default(det_bboxes, of shape (k, 4). Default: None iou_thr (float): IoU threshold to be considered as matched. Default: 0.5. - area_ranges (list[tuple] | None): Range of bbox areas to be evaluated, - in the format [(min1, max1), (min2, max2), ...]. Default: None. + area_ranges (list[tuple] | None): Range of bbox areas to be + evaluated, in the format [(min1, max1), (min2, max2), ...]. + Default: None. + use_legacy_coordinate (bool): Whether to use coordinate system in + mmdet v1.x. which means width, height should be + calculated as 'x2 - x1 + 1` and 'y2 - y1 + 1' respectively. + Default: False. Returns: tuple[np.ndarray]: (tp, fp) whose elements are 0 and 1. The shape of - each array is (num_scales, m). + each array is (num_scales, m). """ + + if not use_legacy_coordinate: + extra_length = 0. + else: + extra_length = 1. + # an indicator of ignored gts gt_ignore_inds = np.concatenate( (np.zeros(gt_bboxes.shape[0], dtype=np.bool), @@ -194,13 +223,15 @@ def tpfp_default(det_bboxes, if area_ranges == [(None, None)]: fp[...] = 1 else: - det_areas = (det_bboxes[:, 2] - det_bboxes[:, 0] + 1) * ( - det_bboxes[:, 3] - det_bboxes[:, 1] + 1) + det_areas = ( + det_bboxes[:, 2] - det_bboxes[:, 0] + extra_length) * ( + det_bboxes[:, 3] - det_bboxes[:, 1] + extra_length) for i, (min_area, max_area) in enumerate(area_ranges): fp[i, (det_areas >= min_area) & (det_areas < max_area)] = 1 return tp, fp - ious = bbox_overlaps(det_bboxes, gt_bboxes) + ious = bbox_overlaps( + det_bboxes, gt_bboxes, use_legacy_coordinate=use_legacy_coordinate) # for each det, the max iou with all gts ious_max = ious.max(axis=1) # for each det, which gt overlaps most with it @@ -213,8 +244,8 @@ def tpfp_default(det_bboxes, if min_area is None: gt_area_ignore = np.zeros_like(gt_ignore_inds, dtype=bool) else: - gt_areas = (gt_bboxes[:, 2] - gt_bboxes[:, 0] + 1) * ( - gt_bboxes[:, 3] - gt_bboxes[:, 1] + 1) + gt_areas = (gt_bboxes[:, 2] - gt_bboxes[:, 0] + extra_length) * ( + gt_bboxes[:, 3] - gt_bboxes[:, 1] + extra_length) gt_area_ignore = (gt_areas < min_area) | (gt_areas >= max_area) for i in sort_inds: if ious_max[i] >= iou_thr: @@ -231,18 +262,225 @@ def tpfp_default(det_bboxes, fp[k, i] = 1 else: bbox = det_bboxes[i, :4] - area = (bbox[2] - bbox[0] + 1) * (bbox[3] - bbox[1] + 1) + area = (bbox[2] - bbox[0] + extra_length) * ( + bbox[3] - bbox[1] + extra_length) if area >= min_area and area < max_area: fp[k, i] = 1 return tp, fp +def tpfp_openimages(det_bboxes, + gt_bboxes, + gt_bboxes_ignore=None, + iou_thr=0.5, + area_ranges=None, + use_legacy_coordinate=False, + gt_bboxes_group_of=None, + use_group_of=True, + ioa_thr=0.5, + **kwargs): + """Check if detected bboxes are true positive or false positive. + + Args: + det_bbox (ndarray): Detected bboxes of this image, of shape (m, 5). + gt_bboxes (ndarray): GT bboxes of this image, of shape (n, 4). + gt_bboxes_ignore (ndarray): Ignored gt bboxes of this image, + of shape (k, 4). Default: None + iou_thr (float): IoU threshold to be considered as matched. + Default: 0.5. + area_ranges (list[tuple] | None): Range of bbox areas to be + evaluated, in the format [(min1, max1), (min2, max2), ...]. + Default: None. + use_legacy_coordinate (bool): Whether to use coordinate system in + mmdet v1.x. which means width, height should be + calculated as 'x2 - x1 + 1` and 'y2 - y1 + 1' respectively. + Default: False. + gt_bboxes_group_of (ndarray): GT group_of of this image, of shape + (k, 1). Default: None + use_group_of (bool): Whether to use group of when calculate TP and FP, + which only used in OpenImages evaluation. Default: True. + ioa_thr (float | None): IoA threshold to be considered as matched, + which only used in OpenImages evaluation. Default: 0.5. + + Returns: + tuple[np.ndarray]: Returns a tuple (tp, fp, det_bboxes), where + (tp, fp) whose elements are 0 and 1. The shape of each array is + (num_scales, m). (det_bboxes) whose will filter those are not + matched by group of gts when processing Open Images evaluation. + The shape is (num_scales, m). + """ + + if not use_legacy_coordinate: + extra_length = 0. + else: + extra_length = 1. + + # an indicator of ignored gts + gt_ignore_inds = np.concatenate( + (np.zeros(gt_bboxes.shape[0], dtype=np.bool), + np.ones(gt_bboxes_ignore.shape[0], dtype=np.bool))) + # stack gt_bboxes and gt_bboxes_ignore for convenience + gt_bboxes = np.vstack((gt_bboxes, gt_bboxes_ignore)) + + num_dets = det_bboxes.shape[0] + num_gts = gt_bboxes.shape[0] + if area_ranges is None: + area_ranges = [(None, None)] + num_scales = len(area_ranges) + # tp and fp are of shape (num_scales, num_gts), each row is tp or fp of + # a certain scale + tp = np.zeros((num_scales, num_dets), dtype=np.float32) + fp = np.zeros((num_scales, num_dets), dtype=np.float32) + + # if there is no gt bboxes in this image, then all det bboxes + # within area range are false positives + if gt_bboxes.shape[0] == 0: + if area_ranges == [(None, None)]: + fp[...] = 1 + else: + det_areas = ( + det_bboxes[:, 2] - det_bboxes[:, 0] + extra_length) * ( + det_bboxes[:, 3] - det_bboxes[:, 1] + extra_length) + for i, (min_area, max_area) in enumerate(area_ranges): + fp[i, (det_areas >= min_area) & (det_areas < max_area)] = 1 + return tp, fp, det_bboxes + + if gt_bboxes_group_of is not None and use_group_of: + # if handle group-of boxes, divided gt boxes into two parts: + # non-group-of and group-of.Then calculate ious and ioas through + # non-group-of group-of gts respectively. This only used in + # OpenImages evaluation. + assert gt_bboxes_group_of.shape[0] == gt_bboxes.shape[0] + non_group_gt_bboxes = gt_bboxes[~gt_bboxes_group_of] + group_gt_bboxes = gt_bboxes[gt_bboxes_group_of] + num_gts_group = group_gt_bboxes.shape[0] + ious = bbox_overlaps(det_bboxes, non_group_gt_bboxes) + ioas = bbox_overlaps(det_bboxes, group_gt_bboxes, mode='iof') + else: + # if not consider group-of boxes, only calculate ious through gt boxes + ious = bbox_overlaps( + det_bboxes, gt_bboxes, use_legacy_coordinate=use_legacy_coordinate) + ioas = None + + if ious.shape[1] > 0: + # for each det, the max iou with all gts + ious_max = ious.max(axis=1) + # for each det, which gt overlaps most with it + ious_argmax = ious.argmax(axis=1) + # sort all dets in descending order by scores + sort_inds = np.argsort(-det_bboxes[:, -1]) + for k, (min_area, max_area) in enumerate(area_ranges): + gt_covered = np.zeros(num_gts, dtype=bool) + # if no area range is specified, gt_area_ignore is all False + if min_area is None: + gt_area_ignore = np.zeros_like(gt_ignore_inds, dtype=bool) + else: + gt_areas = ( + gt_bboxes[:, 2] - gt_bboxes[:, 0] + extra_length) * ( + gt_bboxes[:, 3] - gt_bboxes[:, 1] + extra_length) + gt_area_ignore = (gt_areas < min_area) | (gt_areas >= max_area) + for i in sort_inds: + if ious_max[i] >= iou_thr: + matched_gt = ious_argmax[i] + if not (gt_ignore_inds[matched_gt] + or gt_area_ignore[matched_gt]): + if not gt_covered[matched_gt]: + gt_covered[matched_gt] = True + tp[k, i] = 1 + else: + fp[k, i] = 1 + # otherwise ignore this detected bbox, tp = 0, fp = 0 + elif min_area is None: + fp[k, i] = 1 + else: + bbox = det_bboxes[i, :4] + area = (bbox[2] - bbox[0] + extra_length) * ( + bbox[3] - bbox[1] + extra_length) + if area >= min_area and area < max_area: + fp[k, i] = 1 + else: + # if there is no no-group-of gt bboxes in this image, + # then all det bboxes within area range are false positives. + # Only used in OpenImages evaluation. + if area_ranges == [(None, None)]: + fp[...] = 1 + else: + det_areas = ( + det_bboxes[:, 2] - det_bboxes[:, 0] + extra_length) * ( + det_bboxes[:, 3] - det_bboxes[:, 1] + extra_length) + for i, (min_area, max_area) in enumerate(area_ranges): + fp[i, (det_areas >= min_area) & (det_areas < max_area)] = 1 + + if ioas is None or ioas.shape[1] <= 0: + return tp, fp, det_bboxes + else: + # The evaluation of group-of TP and FP are done in two stages: + # 1. All detections are first matched to non group-of boxes; true + # positives are determined. + # 2. Detections that are determined as false positives are matched + # against group-of boxes and calculated group-of TP and FP. + # Only used in OpenImages evaluation. + det_bboxes_group = np.zeros( + (num_scales, ioas.shape[1], det_bboxes.shape[1]), dtype=float) + match_group_of = np.zeros((num_scales, num_dets), dtype=bool) + tp_group = np.zeros((num_scales, num_gts_group), dtype=np.float32) + ioas_max = ioas.max(axis=1) + # for each det, which gt overlaps most with it + ioas_argmax = ioas.argmax(axis=1) + # sort all dets in descending order by scores + sort_inds = np.argsort(-det_bboxes[:, -1]) + for k, (min_area, max_area) in enumerate(area_ranges): + box_is_covered = tp[k] + # if no area range is specified, gt_area_ignore is all False + if min_area is None: + gt_area_ignore = np.zeros_like(gt_ignore_inds, dtype=bool) + else: + gt_areas = (gt_bboxes[:, 2] - gt_bboxes[:, 0]) * ( + gt_bboxes[:, 3] - gt_bboxes[:, 1]) + gt_area_ignore = (gt_areas < min_area) | (gt_areas >= max_area) + for i in sort_inds: + matched_gt = ioas_argmax[i] + if not box_is_covered[i]: + if ioas_max[i] >= ioa_thr: + if not (gt_ignore_inds[matched_gt] + or gt_area_ignore[matched_gt]): + if not tp_group[k, matched_gt]: + tp_group[k, matched_gt] = 1 + match_group_of[k, i] = True + else: + match_group_of[k, i] = True + + if det_bboxes_group[k, matched_gt, -1] < \ + det_bboxes[i, -1]: + det_bboxes_group[k, matched_gt] = \ + det_bboxes[i] + + fp_group = (tp_group <= 0).astype(float) + tps = [] + fps = [] + # concatenate tp, fp, and det-boxes which not matched group of + # gt boxes and tp_group, fp_group, and det_bboxes_group which + # matched group of boxes respectively. + for i in range(num_scales): + tps.append( + np.concatenate((tp[i][~match_group_of[i]], tp_group[i]))) + fps.append( + np.concatenate((fp[i][~match_group_of[i]], fp_group[i]))) + det_bboxes = np.concatenate( + (det_bboxes[~match_group_of[i]], det_bboxes_group[i])) + + tp = np.vstack(tps) + fp = np.vstack(fps) + return tp, fp, det_bboxes + + def get_cls_results(det_results, annotations, class_id): """Get det results and gt information of a certain class. Args: det_results (list[list]): Same as `eval_map()`. annotations (list[dict]): Same as `eval_map()`. + class_id (int): ID of a specific class. Returns: tuple[list[np.ndarray]]: detected bboxes, gt bboxes, ignored gt bboxes @@ -251,25 +489,50 @@ def get_cls_results(det_results, annotations, class_id): cls_gts = [] cls_gts_ignore = [] for ann in annotations: - gt_inds = ann['labels'] == (class_id + 1) + gt_inds = ann['labels'] == class_id cls_gts.append(ann['bboxes'][gt_inds, :]) if ann.get('labels_ignore', None) is not None: - ignore_inds = ann['labels_ignore'] == (class_id + 1) + ignore_inds = ann['labels_ignore'] == class_id cls_gts_ignore.append(ann['bboxes_ignore'][ignore_inds, :]) else: - cls_gts_ignore.append(np.array((0, 4), dtype=np.float32)) + cls_gts_ignore.append(np.empty((0, 4), dtype=np.float32)) return cls_dets, cls_gts, cls_gts_ignore +def get_cls_group_ofs(annotations, class_id): + """Get `gt_group_of` of a certain class, which is used in Open Images. + + Args: + annotations (list[dict]): Same as `eval_map()`. + class_id (int): ID of a specific class. + + Returns: + list[np.ndarray]: `gt_group_of` of a certain class. + """ + gt_group_ofs = [] + for ann in annotations: + gt_inds = ann['labels'] == class_id + if ann.get('gt_is_group_ofs', None) is not None: + gt_group_ofs.append(ann['gt_is_group_ofs'][gt_inds]) + else: + gt_group_ofs.append(np.empty((0, 1), dtype=np.bool)) + + return gt_group_ofs + + def eval_map(det_results, annotations, scale_ranges=None, iou_thr=0.5, + ioa_thr=None, dataset=None, logger=None, - nproc=4): + tpfp_fn=None, + nproc=4, + use_legacy_coordinate=False, + use_group_of=False): """Evaluate mAP of a dataset. Args: @@ -278,28 +541,46 @@ def eval_map(det_results, per-class detected bboxes. annotations (list[dict]): Ground truth annotations where each item of the list indicates an image. Keys of annotations are: - - "bboxes": numpy array of shape (n, 4) - - "labels": numpy array of shape (n, ) - - "bboxes_ignore" (optional): numpy array of shape (k, 4) - - "labels_ignore" (optional): numpy array of shape (k, ) + + - `bboxes`: numpy array of shape (n, 4) + - `labels`: numpy array of shape (n, ) + - `bboxes_ignore` (optional): numpy array of shape (k, 4) + - `labels_ignore` (optional): numpy array of shape (k, ) scale_ranges (list[tuple] | None): Range of scales to be evaluated, in the format [(min1, max1), (min2, max2), ...]. A range of (32, 64) means the area range between (32**2, 64**2). Default: None. iou_thr (float): IoU threshold to be considered as matched. Default: 0.5. + ioa_thr (float | None): IoA threshold to be considered as matched, + which only used in OpenImages evaluation. Default: None. dataset (list[str] | str | None): Dataset name or dataset classes, - there are minor differences in metrics for different datsets, e.g. + there are minor differences in metrics for different datasets, e.g. "voc07", "imagenet_det", etc. Default: None. logger (logging.Logger | str | None): The way to print the mAP - summary. See `mmdet.utils.print_log()` for details. Default: None. + summary. See `mmcv.utils.print_log()` for details. Default: None. + tpfp_fn (callable | None): The function used to determine true/ + false positives. If None, :func:`tpfp_default` is used as default + unless dataset is 'det' or 'vid' (:func:`tpfp_imagenet` in this + case). If it is given as a function, then this function is used + to evaluate tp & fp. Default None. nproc (int): Processes used for computing TP and FP. Default: 4. + use_legacy_coordinate (bool): Whether to use coordinate system in + mmdet v1.x. which means width, height should be + calculated as 'x2 - x1 + 1` and 'y2 - y1 + 1' respectively. + Default: False. + use_group_of (bool): Whether to use group of when calculate TP and FP, + which only used in OpenImages evaluation. Default: False. Returns: tuple: (mAP, [dict, dict, ...]) """ assert len(det_results) == len(annotations) + if not use_legacy_coordinate: + extra_length = 0. + else: + extra_length = 1. num_imgs = len(det_results) num_scales = len(scale_ranges) if scale_ranges is not None else 1 @@ -307,24 +588,66 @@ def eval_map(det_results, area_ranges = ([(rg[0]**2, rg[1]**2) for rg in scale_ranges] if scale_ranges is not None else None) - pool = Pool(nproc) + # There is no need to use multi processes to process + # when num_imgs = 1 . + if num_imgs > 1: + assert nproc > 0, 'nproc must be at least one.' + nproc = min(nproc, num_imgs) + pool = Pool(nproc) + eval_results = [] for i in range(num_classes): # get gt and det bboxes of this class cls_dets, cls_gts, cls_gts_ignore = get_cls_results( det_results, annotations, i) # choose proper function according to datasets to compute tp and fp - if dataset in ['det', 'vid']: - tpfp_func = tpfp_imagenet + if tpfp_fn is None: + if dataset in ['det', 'vid']: + tpfp_fn = tpfp_imagenet + elif dataset in ['oid_challenge', 'oid_v6'] \ + or use_group_of is True: + tpfp_fn = tpfp_openimages + else: + tpfp_fn = tpfp_default + if not callable(tpfp_fn): + raise ValueError( + f'tpfp_fn has to be a function or None, but got {tpfp_fn}') + + if num_imgs > 1: + # compute tp and fp for each image with multiple processes + args = [] + if use_group_of: + # used in Open Images Dataset evaluation + gt_group_ofs = get_cls_group_ofs(annotations, i) + args.append(gt_group_ofs) + args.append([use_group_of for _ in range(num_imgs)]) + if ioa_thr is not None: + args.append([ioa_thr for _ in range(num_imgs)]) + + tpfp = pool.starmap( + tpfp_fn, + zip(cls_dets, cls_gts, cls_gts_ignore, + [iou_thr for _ in range(num_imgs)], + [area_ranges for _ in range(num_imgs)], + [use_legacy_coordinate for _ in range(num_imgs)], *args)) + else: + tpfp = tpfp_fn( + cls_dets[0], + cls_gts[0], + cls_gts_ignore[0], + iou_thr, + area_ranges, + use_legacy_coordinate, + gt_bboxes_group_of=(get_cls_group_ofs(annotations, i)[0] + if use_group_of else None), + use_group_of=use_group_of, + ioa_thr=ioa_thr) + tpfp = [tpfp] + + if use_group_of: + tp, fp, cls_dets = tuple(zip(*tpfp)) else: - tpfp_func = tpfp_default - # compute tp and fp for each image with multiple processes - tpfp = pool.starmap( - tpfp_func, - zip(cls_dets, cls_gts, cls_gts_ignore, - [iou_thr for _ in range(num_imgs)], - [area_ranges for _ in range(num_imgs)])) - tp, fp = tuple(zip(*tpfp)) + tp, fp = tuple(zip(*tpfp)) # calculate gt number of each scale # ignored gts or gts beyond the specific scale are not counted num_gts = np.zeros(num_scales, dtype=int) @@ -332,8 +655,8 @@ def eval_map(det_results, if area_ranges is None: num_gts[0] += bbox.shape[0] else: - gt_areas = (bbox[:, 2] - bbox[:, 0] + 1) * ( - bbox[:, 3] - bbox[:, 1] + 1) + gt_areas = (bbox[:, 2] - bbox[:, 0] + extra_length) * ( + bbox[:, 3] - bbox[:, 1] + extra_length) for k, (min_area, max_area) in enumerate(area_ranges): num_gts[k] += np.sum((gt_areas >= min_area) & (gt_areas < max_area)) @@ -363,6 +686,10 @@ def eval_map(det_results, 'precision': precisions, 'ap': ap }) + + if num_imgs > 1: + pool.close() + if scale_ranges is not None: # shape (num_classes, num_scales) all_ap = np.vstack([cls_result['ap'] for cls_result in eval_results]) @@ -403,7 +730,7 @@ def print_map_summary(mean_ap, dataset (list[str] | str | None): Dataset name or dataset classes. scale_ranges (list[tuple] | None): Range of scales to be evaluated. logger (logging.Logger | str | None): The way to print the mAP - summary. See `mmdet.utils.print_log()` for details. Default: None. + summary. See `mmcv.utils.print_log()` for details. Default: None. """ if logger == 'silent': @@ -429,7 +756,7 @@ def print_map_summary(mean_ap, num_gts[:, i] = cls_result['num_gts'] if dataset is None: - label_names = [str(i) for i in range(1, num_classes + 1)] + label_names = [str(i) for i in range(num_classes)] elif mmcv.is_str(dataset): label_names = get_classes(dataset) else: @@ -441,15 +768,15 @@ def print_map_summary(mean_ap, header = ['class', 'gts', 'dets', 'recall', 'ap'] for i in range(num_scales): if scale_ranges is not None: - print_log('Scale range {}'.format(scale_ranges[i]), logger=logger) + print_log(f'Scale range {scale_ranges[i]}', logger=logger) table_data = [header] for j in range(num_classes): row_data = [ label_names[j], num_gts[i, j], results[j]['num_dets'], - '{:.3f}'.format(recalls[i, j]), '{:.3f}'.format(aps[i, j]) + f'{recalls[i, j]:.3f}', f'{aps[i, j]:.3f}' ] table_data.append(row_data) - table_data.append(['mAP', '', '', '', '{:.3f}'.format(mean_ap[i])]) + table_data.append(['mAP', '', '', '', f'{mean_ap[i]:.3f}']) table = AsciiTable(table_data) table.inner_footing_row_border = True print_log('\n' + table.table, logger=logger) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/panoptic_utils.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/panoptic_utils.py new file mode 100644 index 000000000..10c9ad934 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/panoptic_utils.py @@ -0,0 +1,6 @@ +# Copyright (c) OpenMMLab. All rights reserved. +# A custom value to distinguish instance ID and category ID; need to +# be greater than the number of categories. +# For a pixel in the panoptic result map: +# pan_id = ins_id * INSTANCE_OFFSET + cat_id +INSTANCE_OFFSET = 1000 diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/recall.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/recall.py index 2a56f42fd..82b3c909b 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/recall.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/evaluation/recall.py @@ -1,4 +1,8 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from collections.abc import Sequence + import numpy as np +from mmcv.utils import print_log from terminaltables import AsciiTable from .bbox_overlaps import bbox_overlaps @@ -38,9 +42,8 @@ def _recalls(all_ious, proposal_nums, thrs): def set_recall_param(proposal_nums, iou_thrs): - """Check proposal_nums and iou_thrs and set correct format. - """ - if isinstance(proposal_nums, list): + """Check proposal_nums and iou_thrs and set correct format.""" + if isinstance(proposal_nums, Sequence): _proposal_nums = np.array(proposal_nums) elif isinstance(proposal_nums, int): _proposal_nums = np.array([proposal_nums]) @@ -49,7 +52,7 @@ def set_recall_param(proposal_nums, iou_thrs): if iou_thrs is None: _iou_thrs = np.array([0.5]) - elif isinstance(iou_thrs, list): + elif isinstance(iou_thrs, Sequence): _iou_thrs = np.array(iou_thrs) elif isinstance(iou_thrs, float): _iou_thrs = np.array([iou_thrs]) @@ -62,15 +65,23 @@ def set_recall_param(proposal_nums, iou_thrs): def eval_recalls(gts, proposals, proposal_nums=None, - iou_thrs=None, - print_summary=True): + iou_thrs=0.5, + logger=None, + use_legacy_coordinate=False): """Calculate recalls. Args: - gts(list or ndarray): a list of arrays of shape (n, 4) - proposals(list or ndarray): a list of arrays of shape (k, 4) or (k, 5) - proposal_nums(int or list of int or ndarray): top N proposals - thrs(float or list or ndarray): iou thresholds + gts (list[ndarray]): a list of arrays of shape (n, 4) + proposals (list[ndarray]): a list of arrays of shape (k, 4) or (k, 5) + proposal_nums (int | Sequence[int]): Top N proposals to be evaluated. + iou_thrs (float | Sequence[float]): IoU thresholds. Default: 0.5. + logger (logging.Logger | str | None): The way to print the recall + summary. See `mmcv.utils.print_log()` for details. Default: None. + use_legacy_coordinate (bool): Whether use coordinate system + in mmdet v1.x. "1" was added to both height and width + which means w, h should be + computed as 'x2 - x1 + 1` and 'y2 - y1 + 1'. Default: False. + Returns: ndarray: recalls of different ious and proposal nums @@ -78,9 +89,7 @@ def eval_recalls(gts, img_num = len(gts) assert img_num == len(proposals) - proposal_nums, iou_thrs = set_recall_param(proposal_nums, iou_thrs) - all_ious = [] for i in range(img_num): if proposals[i].ndim == 2 and proposals[i].shape[1] == 5: @@ -93,12 +102,15 @@ def eval_recalls(gts, if gts[i] is None or gts[i].shape[0] == 0: ious = np.zeros((0, img_proposal.shape[0]), dtype=np.float32) else: - ious = bbox_overlaps(gts[i], img_proposal[:prop_num, :4]) + ious = bbox_overlaps( + gts[i], + img_proposal[:prop_num, :4], + use_legacy_coordinate=use_legacy_coordinate) all_ious.append(ious) all_ious = np.array(all_ious) recalls = _recalls(all_ious, proposal_nums, iou_thrs) - if print_summary: - print_recall_summary(recalls, proposal_nums, iou_thrs) + + print_recall_summary(recalls, proposal_nums, iou_thrs, logger=logger) return recalls @@ -106,15 +118,18 @@ def print_recall_summary(recalls, proposal_nums, iou_thrs, row_idxs=None, - col_idxs=None): + col_idxs=None, + logger=None): """Print recalls in a table. Args: - recalls(ndarray): calculated from `bbox_recalls` - proposal_nums(ndarray or list): top N proposals - iou_thrs(ndarray or list): iou thresholds - row_idxs(ndarray): which rows(proposal nums) to print - col_idxs(ndarray): which cols(iou thresholds) to print + recalls (ndarray): calculated from `bbox_recalls` + proposal_nums (ndarray or list): top N proposals + iou_thrs (ndarray or list): iou thresholds + row_idxs (ndarray): which rows(proposal nums) to print + col_idxs (ndarray): which cols(iou thresholds) to print + logger (logging.Logger | str | None): The way to print the recall + summary. See `mmcv.utils.print_log()` for details. Default: None. """ proposal_nums = np.array(proposal_nums, dtype=np.int32) iou_thrs = np.array(iou_thrs) @@ -125,14 +140,11 @@ def print_recall_summary(recalls, row_header = [''] + iou_thrs[col_idxs].tolist() table_data = [row_header] for i, num in enumerate(proposal_nums[row_idxs]): - row = [ - '{:.3f}'.format(val) - for val in recalls[row_idxs[i], col_idxs].tolist() - ] + row = [f'{val:.3f}' for val in recalls[row_idxs[i], col_idxs].tolist()] row.insert(0, num) table_data.append(row) table = AsciiTable(table_data) - print(table.table) + print_log('\n' + table.table, logger=logger) def plot_num_recall(recalls, proposal_nums): diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/export/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/export/__init__.py new file mode 100644 index 000000000..a8179c936 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/export/__init__.py @@ -0,0 +1,12 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .onnx_helper import (add_dummy_nms_for_onnx, dynamic_clip_for_onnx, + get_k_for_topk) +from .pytorch2onnx import (build_model_from_cfg, + generate_inputs_and_wrap_model, + preprocess_example_input) + +__all__ = [ + 'build_model_from_cfg', 'generate_inputs_and_wrap_model', + 'preprocess_example_input', 'get_k_for_topk', 'add_dummy_nms_for_onnx', + 'dynamic_clip_for_onnx' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/export/model_wrappers.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/export/model_wrappers.py new file mode 100644 index 000000000..2f62bb031 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/export/model_wrappers.py @@ -0,0 +1,183 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import os.path as osp +import warnings + +import numpy as np +import torch + +from mmdet.core import bbox2result +from mmdet.models import BaseDetector + + +class DeployBaseDetector(BaseDetector): + """DeployBaseDetector.""" + + def __init__(self, class_names, device_id): + super(DeployBaseDetector, self).__init__() + self.CLASSES = class_names + self.device_id = device_id + + def simple_test(self, img, img_metas, **kwargs): + raise NotImplementedError('This method is not implemented.') + + def aug_test(self, imgs, img_metas, **kwargs): + raise NotImplementedError('This method is not implemented.') + + def extract_feat(self, imgs): + raise NotImplementedError('This method is not implemented.') + + def forward_train(self, imgs, img_metas, **kwargs): + raise NotImplementedError('This method is not implemented.') + + def val_step(self, data, optimizer): + raise NotImplementedError('This method is not implemented.') + + def train_step(self, data, optimizer): + raise NotImplementedError('This method is not implemented.') + + def forward_test(self, *, img, img_metas, **kwargs): + raise NotImplementedError('This method is not implemented.') + + def async_simple_test(self, img, img_metas, **kwargs): + raise NotImplementedError('This method is not implemented.') + + def forward(self, img, img_metas, return_loss=True, **kwargs): + outputs = self.forward_test(img, img_metas, **kwargs) + batch_dets, batch_labels = outputs[:2] + batch_masks = outputs[2] if len(outputs) == 3 else None + batch_size = img[0].shape[0] + img_metas = img_metas[0] + results = [] + rescale = kwargs.get('rescale', True) + for i in range(batch_size): + dets, labels = batch_dets[i], batch_labels[i] + if rescale: + scale_factor = img_metas[i]['scale_factor'] + + if isinstance(scale_factor, (list, tuple, np.ndarray)): + assert len(scale_factor) == 4 + scale_factor = np.array(scale_factor)[None, :] # [1,4] + dets[:, :4] /= scale_factor + + if 'border' in img_metas[i]: + # offset pixel of the top-left corners between original image + # and padded/enlarged image, 'border' is used when exporting + # CornerNet and CentripetalNet to onnx + x_off = img_metas[i]['border'][2] + y_off = img_metas[i]['border'][0] + dets[:, [0, 2]] -= x_off + dets[:, [1, 3]] -= y_off + dets[:, :4] *= (dets[:, :4] > 0).astype(dets.dtype) + + dets_results = bbox2result(dets, labels, len(self.CLASSES)) + + if batch_masks is not None: + masks = batch_masks[i] + img_h, img_w = img_metas[i]['img_shape'][:2] + ori_h, ori_w = img_metas[i]['ori_shape'][:2] + masks = masks[:, :img_h, :img_w] + if rescale: + masks = masks.astype(np.float32) + masks = torch.from_numpy(masks) + masks = torch.nn.functional.interpolate( + masks.unsqueeze(0), size=(ori_h, ori_w)) + masks = masks.squeeze(0).detach().numpy() + if masks.dtype != np.bool: + masks = masks >= 0.5 + segms_results = [[] for _ in range(len(self.CLASSES))] + for j in range(len(dets)): + segms_results[labels[j]].append(masks[j]) + results.append((dets_results, segms_results)) + else: + results.append(dets_results) + return results + + +class ONNXRuntimeDetector(DeployBaseDetector): + """Wrapper for detector's inference with ONNXRuntime.""" + + def __init__(self, onnx_file, class_names, device_id): + super(ONNXRuntimeDetector, self).__init__(class_names, device_id) + import onnxruntime as ort + + # get the custom op path + ort_custom_op_path = '' + try: + from mmcv.ops import get_onnxruntime_op_path + ort_custom_op_path = get_onnxruntime_op_path() + except (ImportError, ModuleNotFoundError): + warnings.warn('If input model has custom op from mmcv, \ + you may have to build mmcv with ONNXRuntime from source.') + session_options = ort.SessionOptions() + # register custom op for onnxruntime + if osp.exists(ort_custom_op_path): + session_options.register_custom_ops_library(ort_custom_op_path) + sess = ort.InferenceSession(onnx_file, session_options) + providers = ['CPUExecutionProvider'] + options = [{}] + is_cuda_available = ort.get_device() == 'GPU' + if is_cuda_available: + providers.insert(0, 'CUDAExecutionProvider') + options.insert(0, {'device_id': device_id}) + + sess.set_providers(providers, options) + + self.sess = sess + self.io_binding = sess.io_binding() + self.output_names = [_.name for _ in sess.get_outputs()] + self.is_cuda_available = is_cuda_available + + def forward_test(self, imgs, img_metas, **kwargs): + input_data = imgs[0] + # set io binding for inputs/outputs + device_type = 'cuda' if self.is_cuda_available else 'cpu' + if not self.is_cuda_available: + input_data = input_data.cpu() + self.io_binding.bind_input( + name='input', + device_type=device_type, + device_id=self.device_id, + element_type=np.float32, + shape=input_data.shape, + buffer_ptr=input_data.data_ptr()) + + for name in self.output_names: + self.io_binding.bind_output(name) + # run session to get outputs + self.sess.run_with_iobinding(self.io_binding) + ort_outputs = self.io_binding.copy_outputs_to_cpu() + return ort_outputs + + +class TensorRTDetector(DeployBaseDetector): + """Wrapper for detector's inference with TensorRT.""" + + def __init__(self, engine_file, class_names, device_id, output_names=None): + super(TensorRTDetector, self).__init__(class_names, device_id) + warnings.warn('`output_names` is deprecated and will be removed in ' + 'future releases.') + from mmcv.tensorrt import TRTWraper, load_tensorrt_plugin + try: + load_tensorrt_plugin() + except (ImportError, ModuleNotFoundError): + warnings.warn('If input model has custom op from mmcv, \ + you may have to build mmcv with TensorRT from source.') + + output_names = ['dets', 'labels'] + model = TRTWraper(engine_file, ['input'], output_names) + with_masks = False + # if TensorRT has totally 4 inputs/outputs, then + # the detector should have `mask` output. + if len(model.engine) == 4: + model.output_names = output_names + ['masks'] + with_masks = True + self.model = model + self.with_masks = with_masks + + def forward_test(self, imgs, img_metas, **kwargs): + input_data = imgs[0].contiguous() + with torch.cuda.device(self.device_id), torch.no_grad(): + outputs = self.model({'input': input_data}) + outputs = [outputs[name] for name in self.model.output_names] + outputs = [out.detach().cpu().numpy() for out in outputs] + return outputs diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/export/onnx_helper.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/export/onnx_helper.py new file mode 100644 index 000000000..9f6b9a012 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/export/onnx_helper.py @@ -0,0 +1,223 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import os + +import torch + + +def dynamic_clip_for_onnx(x1, y1, x2, y2, max_shape): + """Clip boxes dynamically for onnx. + + Since torch.clamp cannot have dynamic `min` and `max`, we scale the + boxes by 1/max_shape and clamp in the range [0, 1]. + + Args: + x1 (Tensor): The x1 for bounding boxes. + y1 (Tensor): The y1 for bounding boxes. + x2 (Tensor): The x2 for bounding boxes. + y2 (Tensor): The y2 for bounding boxes. + max_shape (Tensor or torch.Size): The (H,W) of original image. + Returns: + tuple(Tensor): The clipped x1, y1, x2, y2. + """ + assert isinstance( + max_shape, + torch.Tensor), '`max_shape` should be tensor of (h,w) for onnx' + + # scale by 1/max_shape + x1 = x1 / max_shape[1] + y1 = y1 / max_shape[0] + x2 = x2 / max_shape[1] + y2 = y2 / max_shape[0] + + # clamp [0, 1] + x1 = torch.clamp(x1, 0, 1) + y1 = torch.clamp(y1, 0, 1) + x2 = torch.clamp(x2, 0, 1) + y2 = torch.clamp(y2, 0, 1) + + # scale back + x1 = x1 * max_shape[1] + y1 = y1 * max_shape[0] + x2 = x2 * max_shape[1] + y2 = y2 * max_shape[0] + return x1, y1, x2, y2 + + +def get_k_for_topk(k, size): + """Get k of TopK for onnx exporting. + + The K of TopK in TensorRT should not be a Tensor, while in ONNX Runtime + it could be a Tensor.Due to dynamic shape feature, we have to decide + whether to do TopK and what K it should be while exporting to ONNX. + If returned K is less than zero, it means we do not have to do + TopK operation. + + Args: + k (int or Tensor): The set k value for nms from config file. + size (Tensor or torch.Size): The number of elements of \ + TopK's input tensor + Returns: + tuple: (int or Tensor): The final K for TopK. + """ + ret_k = -1 + if k <= 0 or size <= 0: + return ret_k + if torch.onnx.is_in_onnx_export(): + is_trt_backend = os.environ.get('ONNX_BACKEND') == 'MMCVTensorRT' + if is_trt_backend: + # TensorRT does not support dynamic K with TopK op + if 0 < k < size: + ret_k = k + else: + # Always keep topk op for dynamic input in onnx for ONNX Runtime + ret_k = torch.where(k < size, k, size) + elif k < size: + ret_k = k + else: + # ret_k is -1 + pass + return ret_k + + +def add_dummy_nms_for_onnx(boxes, + scores, + max_output_boxes_per_class=1000, + iou_threshold=0.5, + score_threshold=0.05, + pre_top_k=-1, + after_top_k=-1, + labels=None): + """Create a dummy onnx::NonMaxSuppression op while exporting to ONNX. + + This function helps exporting to onnx with batch and multiclass NMS op. + It only supports class-agnostic detection results. That is, the scores + is of shape (N, num_bboxes, num_classes) and the boxes is of shape + (N, num_boxes, 4). + + Args: + boxes (Tensor): The bounding boxes of shape [N, num_boxes, 4] + scores (Tensor): The detection scores of shape + [N, num_boxes, num_classes] + max_output_boxes_per_class (int): Maximum number of output + boxes per class of nms. Defaults to 1000. + iou_threshold (float): IOU threshold of nms. Defaults to 0.5 + score_threshold (float): score threshold of nms. + Defaults to 0.05. + pre_top_k (bool): Number of top K boxes to keep before nms. + Defaults to -1. + after_top_k (int): Number of top K boxes to keep after nms. + Defaults to -1. + labels (Tensor, optional): It not None, explicit labels would be used. + Otherwise, labels would be automatically generated using + num_classed. Defaults to None. + + Returns: + tuple[Tensor, Tensor]: dets of shape [N, num_det, 5] + and class labels of shape [N, num_det]. + """ + max_output_boxes_per_class = torch.LongTensor([max_output_boxes_per_class]) + iou_threshold = torch.tensor([iou_threshold], dtype=torch.float32) + score_threshold = torch.tensor([score_threshold], dtype=torch.float32) + batch_size = scores.shape[0] + num_class = scores.shape[2] + + nms_pre = torch.tensor(pre_top_k, device=scores.device, dtype=torch.long) + nms_pre = get_k_for_topk(nms_pre, boxes.shape[1]) + + if nms_pre > 0: + max_scores, _ = scores.max(-1) + _, topk_inds = max_scores.topk(nms_pre) + batch_inds = torch.arange(batch_size).view( + -1, 1).expand_as(topk_inds).long() + # Avoid onnx2tensorrt issue in https://github.com/NVIDIA/TensorRT/issues/1134 # noqa: E501 + transformed_inds = boxes.shape[1] * batch_inds + topk_inds + boxes = boxes.reshape(-1, 4)[transformed_inds, :].reshape( + batch_size, -1, 4) + scores = scores.reshape(-1, num_class)[transformed_inds, :].reshape( + batch_size, -1, num_class) + if labels is not None: + labels = labels.reshape(-1, 1)[transformed_inds].reshape( + batch_size, -1) + + scores = scores.permute(0, 2, 1) + num_box = boxes.shape[1] + # turn off tracing to create a dummy output of nms + state = torch._C._get_tracing_state() + # dummy indices of nms's output + num_fake_det = 2 + batch_inds = torch.randint(batch_size, (num_fake_det, 1)) + cls_inds = torch.randint(num_class, (num_fake_det, 1)) + box_inds = torch.randint(num_box, (num_fake_det, 1)) + indices = torch.cat([batch_inds, cls_inds, box_inds], dim=1) + output = indices + setattr(DummyONNXNMSop, 'output', output) + + # open tracing + torch._C._set_tracing_state(state) + selected_indices = DummyONNXNMSop.apply(boxes, scores, + max_output_boxes_per_class, + iou_threshold, score_threshold) + + batch_inds, cls_inds = selected_indices[:, 0], selected_indices[:, 1] + box_inds = selected_indices[:, 2] + if labels is None: + labels = torch.arange(num_class, dtype=torch.long).to(scores.device) + labels = labels.view(1, num_class, 1).expand_as(scores) + scores = scores.reshape(-1, 1) + boxes = boxes.reshape(batch_size, -1).repeat(1, num_class).reshape(-1, 4) + pos_inds = (num_class * batch_inds + cls_inds) * num_box + box_inds + mask = scores.new_zeros(scores.shape) + # Avoid onnx2tensorrt issue in https://github.com/NVIDIA/TensorRT/issues/1134 # noqa: E501 + # PyTorch style code: mask[batch_inds, box_inds] += 1 + mask[pos_inds, :] += 1 + scores = scores * mask + boxes = boxes * mask + + scores = scores.reshape(batch_size, -1) + boxes = boxes.reshape(batch_size, -1, 4) + labels = labels.reshape(batch_size, -1) + + nms_after = torch.tensor( + after_top_k, device=scores.device, dtype=torch.long) + nms_after = get_k_for_topk(nms_after, num_box * num_class) + + if nms_after > 0: + _, topk_inds = scores.topk(nms_after) + batch_inds = torch.arange(batch_size).view(-1, 1).expand_as(topk_inds) + # Avoid onnx2tensorrt issue in https://github.com/NVIDIA/TensorRT/issues/1134 # noqa: E501 + transformed_inds = scores.shape[1] * batch_inds + topk_inds + scores = scores.reshape(-1, 1)[transformed_inds, :].reshape( + batch_size, -1) + boxes = boxes.reshape(-1, 4)[transformed_inds, :].reshape( + batch_size, -1, 4) + labels = labels.reshape(-1, 1)[transformed_inds, :].reshape( + batch_size, -1) + + scores = scores.unsqueeze(2) + dets = torch.cat([boxes, scores], dim=2) + return dets, labels + + +class DummyONNXNMSop(torch.autograd.Function): + """DummyONNXNMSop. + + This class is only for creating onnx::NonMaxSuppression. + """ + + @staticmethod + def forward(ctx, boxes, scores, max_output_boxes_per_class, iou_threshold, + score_threshold): + + return DummyONNXNMSop.output + + @staticmethod + def symbolic(g, boxes, scores, max_output_boxes_per_class, iou_threshold, + score_threshold): + return g.op( + 'NonMaxSuppression', + boxes, + scores, + max_output_boxes_per_class, + iou_threshold, + score_threshold, + outputs=1) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/export/pytorch2onnx.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/export/pytorch2onnx.py new file mode 100644 index 000000000..b8261eed9 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/export/pytorch2onnx.py @@ -0,0 +1,159 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from functools import partial + +import mmcv +import numpy as np +import torch +from mmcv.runner import load_checkpoint + + +def generate_inputs_and_wrap_model(config_path, + checkpoint_path, + input_config, + cfg_options=None): + """Prepare sample input and wrap model for ONNX export. + + The ONNX export API only accept args, and all inputs should be + torch.Tensor or corresponding types (such as tuple of tensor). + So we should call this function before exporting. This function will: + + 1. generate corresponding inputs which are used to execute the model. + 2. Wrap the model's forward function. + + For example, the MMDet models' forward function has a parameter + ``return_loss:bool``. As we want to set it as False while export API + supports neither bool type or kwargs. So we have to replace the forward + method like ``model.forward = partial(model.forward, return_loss=False)``. + + Args: + config_path (str): the OpenMMLab config for the model we want to + export to ONNX + checkpoint_path (str): Path to the corresponding checkpoint + input_config (dict): the exactly data in this dict depends on the + framework. For MMSeg, we can just declare the input shape, + and generate the dummy data accordingly. However, for MMDet, + we may pass the real img path, or the NMS will return None + as there is no legal bbox. + + Returns: + tuple: (model, tensor_data) wrapped model which can be called by + ``model(*tensor_data)`` and a list of inputs which are used to + execute the model while exporting. + """ + + model = build_model_from_cfg( + config_path, checkpoint_path, cfg_options=cfg_options) + one_img, one_meta = preprocess_example_input(input_config) + tensor_data = [one_img] + model.forward = partial( + model.forward, img_metas=[[one_meta]], return_loss=False) + + # pytorch has some bug in pytorch1.3, we have to fix it + # by replacing these existing op + opset_version = 11 + # put the import within the function thus it will not cause import error + # when not using this function + try: + from mmcv.onnx.symbolic import register_extra_symbolics + except ModuleNotFoundError: + raise NotImplementedError('please update mmcv to version>=v1.0.4') + register_extra_symbolics(opset_version) + + return model, tensor_data + + +def build_model_from_cfg(config_path, checkpoint_path, cfg_options=None): + """Build a model from config and load the given checkpoint. + + Args: + config_path (str): the OpenMMLab config for the model we want to + export to ONNX + checkpoint_path (str): Path to the corresponding checkpoint + + Returns: + torch.nn.Module: the built model + """ + from mmdet.models import build_detector + + cfg = mmcv.Config.fromfile(config_path) + if cfg_options is not None: + cfg.merge_from_dict(cfg_options) + # set cudnn_benchmark + if cfg.get('cudnn_benchmark', False): + torch.backends.cudnn.benchmark = True + cfg.model.pretrained = None + cfg.data.test.test_mode = True + + # build the model + cfg.model.train_cfg = None + model = build_detector(cfg.model, test_cfg=cfg.get('test_cfg')) + checkpoint = load_checkpoint(model, checkpoint_path, map_location='cpu') + if 'CLASSES' in checkpoint.get('meta', {}): + model.CLASSES = checkpoint['meta']['CLASSES'] + else: + from mmdet.datasets import DATASETS + dataset = DATASETS.get(cfg.data.test['type']) + assert (dataset is not None) + model.CLASSES = dataset.CLASSES + model.cpu().eval() + return model + + +def preprocess_example_input(input_config): + """Prepare an example input image for ``generate_inputs_and_wrap_model``. + + Args: + input_config (dict): customized config describing the example input. + + Returns: + tuple: (one_img, one_meta), tensor of the example input image and \ + meta information for the example input image. + + Examples: + >>> from mmdet.core.export import preprocess_example_input + >>> input_config = { + >>> 'input_shape': (1,3,224,224), + >>> 'input_path': 'demo/demo.jpg', + >>> 'normalize_cfg': { + >>> 'mean': (123.675, 116.28, 103.53), + >>> 'std': (58.395, 57.12, 57.375) + >>> } + >>> } + >>> one_img, one_meta = preprocess_example_input(input_config) + >>> print(one_img.shape) + torch.Size([1, 3, 224, 224]) + >>> print(one_meta) + {'img_shape': (224, 224, 3), + 'ori_shape': (224, 224, 3), + 'pad_shape': (224, 224, 3), + 'filename': '.png', + 'scale_factor': 1.0, + 'flip': False} + """ + input_path = input_config['input_path'] + input_shape = input_config['input_shape'] + one_img = mmcv.imread(input_path) + one_img = mmcv.imresize(one_img, input_shape[2:][::-1]) + show_img = one_img.copy() + if 'normalize_cfg' in input_config.keys(): + normalize_cfg = input_config['normalize_cfg'] + mean = np.array(normalize_cfg['mean'], dtype=np.float32) + std = np.array(normalize_cfg['std'], dtype=np.float32) + to_rgb = normalize_cfg.get('to_rgb', True) + one_img = mmcv.imnormalize(one_img, mean, std, to_rgb=to_rgb) + one_img = one_img.transpose(2, 0, 1) + one_img = torch.from_numpy(one_img).unsqueeze(0).float().requires_grad_( + True) + (_, C, H, W) = input_shape + one_meta = { + 'img_shape': (H, W, C), + 'ori_shape': (H, W, C), + 'pad_shape': (H, W, C), + 'filename': '.png', + 'scale_factor': np.ones(4, dtype=np.float32), + 'flip': False, + 'show_img': show_img, + 'flip_direction': None + } + + return one_img, one_meta diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/__init__.py deleted file mode 100644 index cc655b7c3..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from .decorators import auto_fp16, force_fp32 -from .hooks import Fp16OptimizerHook, wrap_fp16_model - -__all__ = ['auto_fp16', 'force_fp32', 'Fp16OptimizerHook', 'wrap_fp16_model'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/hooks.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/hooks.py deleted file mode 100644 index 6b4dacb1c..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/hooks.py +++ /dev/null @@ -1,127 +0,0 @@ -import copy - -import torch -import torch.nn as nn -from mmcv.runner import OptimizerHook - -from ..utils.dist_utils import allreduce_grads -from .utils import cast_tensor_type - - -class Fp16OptimizerHook(OptimizerHook): - """FP16 optimizer hook. - - The steps of fp16 optimizer is as follows. - 1. Scale the loss value. - 2. BP in the fp16 model. - 2. Copy gradients from fp16 model to fp32 weights. - 3. Update fp32 weights. - 4. Copy updated parameters from fp32 weights to fp16 model. - - Refer to https://arxiv.org/abs/1710.03740 for more details. - - Args: - loss_scale (float): Scale factor multiplied with loss. - """ - - def __init__(self, - grad_clip=None, - coalesce=True, - bucket_size_mb=-1, - loss_scale=512., - distributed=True): - self.grad_clip = grad_clip - self.coalesce = coalesce - self.bucket_size_mb = bucket_size_mb - self.loss_scale = loss_scale - self.distributed = distributed - - def before_run(self, runner): - # keep a copy of fp32 weights - runner.optimizer.param_groups = copy.deepcopy( - runner.optimizer.param_groups) - # convert model to fp16 - wrap_fp16_model(runner.model) - - def copy_grads_to_fp32(self, fp16_net, fp32_weights): - """Copy gradients from fp16 model to fp32 weight copy.""" - for fp32_param, fp16_param in zip(fp32_weights, fp16_net.parameters()): - if fp16_param.grad is not None: - if fp32_param.grad is None: - fp32_param.grad = fp32_param.data.new(fp32_param.size()) - fp32_param.grad.copy_(fp16_param.grad) - - def copy_params_to_fp16(self, fp16_net, fp32_weights): - """Copy updated params from fp32 weight copy to fp16 model.""" - for fp16_param, fp32_param in zip(fp16_net.parameters(), fp32_weights): - fp16_param.data.copy_(fp32_param.data) - - def after_train_iter(self, runner): - # clear grads of last iteration - runner.model.zero_grad() - runner.optimizer.zero_grad() - # scale the loss value - scaled_loss = runner.outputs['loss'] * self.loss_scale - scaled_loss.backward() - # copy fp16 grads in the model to fp32 params in the optimizer - fp32_weights = [] - for param_group in runner.optimizer.param_groups: - fp32_weights += param_group['params'] - self.copy_grads_to_fp32(runner.model, fp32_weights) - # allreduce grads - if self.distributed: - allreduce_grads(fp32_weights, self.coalesce, self.bucket_size_mb) - # scale the gradients back - for param in fp32_weights: - if param.grad is not None: - param.grad.div_(self.loss_scale) - if self.grad_clip is not None: - self.clip_grads(fp32_weights) - # update fp32 params - runner.optimizer.step() - # copy fp32 params to the fp16 model - self.copy_params_to_fp16(runner.model, fp32_weights) - - -def wrap_fp16_model(model): - # convert model to fp16 - model.half() - # patch the normalization layers to make it work in fp32 mode - patch_norm_fp32(model) - # set `fp16_enabled` flag - for m in model.modules(): - if hasattr(m, 'fp16_enabled'): - m.fp16_enabled = True - - -def patch_norm_fp32(module): - if isinstance(module, (nn.modules.batchnorm._BatchNorm, nn.GroupNorm)): - module.float() - module.forward = patch_forward_method(module.forward, torch.half, - torch.float) - for child in module.children(): - patch_norm_fp32(child) - return module - - -def patch_forward_method(func, src_type, dst_type, convert_output=True): - """Patch the forward method of a module. - - Args: - func (callable): The original forward method. - src_type (torch.dtype): Type of input arguments to be converted from. - dst_type (torch.dtype): Type of input arguments to be converted to. - convert_output (bool): Whether to convert the output back to src_type. - - Returns: - callable: The patched forward method. - """ - - def new_forward(*args, **kwargs): - output = func(*cast_tensor_type(args, src_type, dst_type), - **cast_tensor_type(kwargs, src_type, dst_type)) - if convert_output: - output = cast_tensor_type(output, dst_type, src_type) - return output - - return new_forward diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/utils.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/utils.py deleted file mode 100644 index ce691c799..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/fp16/utils.py +++ /dev/null @@ -1,23 +0,0 @@ -from collections import abc - -import numpy as np -import torch - - -def cast_tensor_type(inputs, src_type, dst_type): - if isinstance(inputs, torch.Tensor): - return inputs.to(dst_type) - elif isinstance(inputs, str): - return inputs - elif isinstance(inputs, np.ndarray): - return inputs - elif isinstance(inputs, abc.Mapping): - return type(inputs)({ - k: cast_tensor_type(v, src_type, dst_type) - for k, v in inputs.items() - }) - elif isinstance(inputs, abc.Iterable): - return type(inputs)( - cast_tensor_type(item, src_type, dst_type) for item in inputs) - else: - return inputs diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/__init__.py new file mode 100644 index 000000000..7b9ac9ff3 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/__init__.py @@ -0,0 +1,17 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .checkloss_hook import CheckInvalidLossHook +from .ema import ExpMomentumEMAHook, LinearMomentumEMAHook +from .memory_profiler_hook import MemoryProfilerHook +from .set_epoch_info_hook import SetEpochInfoHook +from .sync_norm_hook import SyncNormHook +from .sync_random_size_hook import SyncRandomSizeHook +from .wandblogger_hook import MMDetWandbHook +from .yolox_lrupdater_hook import YOLOXLrUpdaterHook +from .yolox_mode_switch_hook import YOLOXModeSwitchHook + +__all__ = [ + 'SyncRandomSizeHook', 'YOLOXModeSwitchHook', 'SyncNormHook', + 'ExpMomentumEMAHook', 'LinearMomentumEMAHook', 'YOLOXLrUpdaterHook', + 'CheckInvalidLossHook', 'SetEpochInfoHook', 'MemoryProfilerHook', + 'MMDetWandbHook' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/checkloss_hook.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/checkloss_hook.py new file mode 100644 index 000000000..754e61bef --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/checkloss_hook.py @@ -0,0 +1,24 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch +from mmcv.runner.hooks import HOOKS, Hook + + +@HOOKS.register_module() +class CheckInvalidLossHook(Hook): + """Check invalid loss hook. + + This hook will regularly check whether the loss is valid + during training. + + Args: + interval (int): Checking interval (every k iterations). + Default: 50. + """ + + def __init__(self, interval=50): + self.interval = interval + + def after_train_iter(self, runner): + if self.every_n_iters(runner, self.interval): + assert torch.isfinite(runner.outputs['loss']), \ + runner.logger.info('loss become infinite or NaN!') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/ema.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/ema.py new file mode 100644 index 000000000..ff7bfbabe --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/ema.py @@ -0,0 +1,130 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import math + +from mmcv.parallel import is_module_wrapper +from mmcv.runner.hooks import HOOKS, Hook + + +class BaseEMAHook(Hook): + """Exponential Moving Average Hook. + + Use Exponential Moving Average on all parameters of model in training + process. All parameters have a ema backup, which update by the formula + as below. EMAHook takes priority over EvalHook and CheckpointHook. Note, + the original model parameters are actually saved in ema field after train. + + Args: + momentum (float): The momentum used for updating ema parameter. + Ema's parameter are updated with the formula: + `ema_param = (1-momentum) * ema_param + momentum * cur_param`. + Defaults to 0.0002. + skip_buffers (bool): Whether to skip the model buffers, such as + batchnorm running stats (running_mean, running_var), it does not + perform the ema operation. Default to False. + interval (int): Update ema parameter every interval iteration. + Defaults to 1. + resume_from (str, optional): The checkpoint path. Defaults to None. + momentum_fun (func, optional): The function to change momentum + during early iteration (also warmup) to help early training. + It uses `momentum` as a constant. Defaults to None. + """ + + def __init__(self, + momentum=0.0002, + interval=1, + skip_buffers=False, + resume_from=None, + momentum_fun=None): + assert 0 < momentum < 1 + self.momentum = momentum + self.skip_buffers = skip_buffers + self.interval = interval + self.checkpoint = resume_from + self.momentum_fun = momentum_fun + + def before_run(self, runner): + """To resume model with it's ema parameters more friendly. + + Register ema parameter as ``named_buffer`` to model. + """ + model = runner.model + if is_module_wrapper(model): + model = model.module + self.param_ema_buffer = {} + if self.skip_buffers: + self.model_parameters = dict(model.named_parameters()) + else: + self.model_parameters = model.state_dict() + for name, value in self.model_parameters.items(): + # "." is not allowed in module's buffer name + buffer_name = f"ema_{name.replace('.', '_')}" + self.param_ema_buffer[name] = buffer_name + model.register_buffer(buffer_name, value.data.clone()) + self.model_buffers = dict(model.named_buffers()) + if self.checkpoint is not None: + runner.resume(self.checkpoint) + + def get_momentum(self, runner): + return self.momentum_fun(runner.iter) if self.momentum_fun else \ + self.momentum + + def after_train_iter(self, runner): + """Update ema parameter every self.interval iterations.""" + if (runner.iter + 1) % self.interval != 0: + return + momentum = self.get_momentum(runner) + for name, parameter in self.model_parameters.items(): + # exclude num_tracking + if parameter.dtype.is_floating_point: + buffer_name = self.param_ema_buffer[name] + buffer_parameter = self.model_buffers[buffer_name] + buffer_parameter.mul_(1 - momentum).add_( + parameter.data, alpha=momentum) + + def after_train_epoch(self, runner): + """We load parameter values from ema backup to model before the + EvalHook.""" + self._swap_ema_parameters() + + def before_train_epoch(self, runner): + """We recover model's parameter from ema backup after last epoch's + EvalHook.""" + self._swap_ema_parameters() + + def _swap_ema_parameters(self): + """Swap the parameter of model with parameter in ema_buffer.""" + for name, value in self.model_parameters.items(): + temp = value.data.clone() + ema_buffer = self.model_buffers[self.param_ema_buffer[name]] + value.data.copy_(ema_buffer.data) + ema_buffer.data.copy_(temp) + + +@HOOKS.register_module() +class ExpMomentumEMAHook(BaseEMAHook): + """EMAHook using exponential momentum strategy. + + Args: + total_iter (int): The total number of iterations of EMA momentum. + Defaults to 2000. + """ + + def __init__(self, total_iter=2000, **kwargs): + super(ExpMomentumEMAHook, self).__init__(**kwargs) + self.momentum_fun = lambda x: (1 - self.momentum) * math.exp(-( + 1 + x) / total_iter) + self.momentum + + +@HOOKS.register_module() +class LinearMomentumEMAHook(BaseEMAHook): + """EMAHook using linear momentum strategy. + + Args: + warm_up (int): During first warm_up steps, we may use smaller decay + to update ema parameters more slowly. Defaults to 100. + """ + + def __init__(self, warm_up=100, **kwargs): + super(LinearMomentumEMAHook, self).__init__(**kwargs) + self.momentum_fun = lambda x: min(self.momentum**self.interval, + (1 + x) / (warm_up + x)) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/memory_profiler_hook.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/memory_profiler_hook.py new file mode 100644 index 000000000..a473061b5 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/memory_profiler_hook.py @@ -0,0 +1,55 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from mmcv.runner.hooks import HOOKS, Hook + + +@HOOKS.register_module() +class MemoryProfilerHook(Hook): + """Memory profiler hook recording memory information including virtual + memory, swap memory, and the memory of the current process. + + Args: + interval (int): Checking interval (every k iterations). + Default: 50. + """ + + def __init__(self, interval=50): + try: + from psutil import swap_memory, virtual_memory + self._swap_memory = swap_memory + self._virtual_memory = virtual_memory + except ImportError: + raise ImportError('psutil is not installed, please install it by: ' + 'pip install psutil') + + try: + from memory_profiler import memory_usage + self._memory_usage = memory_usage + except ImportError: + raise ImportError( + 'memory_profiler is not installed, please install it by: ' + 'pip install memory_profiler') + + self.interval = interval + + def after_iter(self, runner): + if self.every_n_iters(runner, self.interval): + # in Byte + virtual_memory = self._virtual_memory() + swap_memory = self._swap_memory() + # in MB + process_memory = self._memory_usage()[0] + factor = 1024 * 1024 + runner.logger.info( + 'Memory information ' + 'available_memory: ' + f'{round(virtual_memory.available / factor)} MB, ' + 'used_memory: ' + f'{round(virtual_memory.used / factor)} MB, ' + f'memory_utilization: {virtual_memory.percent} %, ' + 'available_swap_memory: ' + f'{round((swap_memory.total - swap_memory.used) / factor)}' + ' MB, ' + f'used_swap_memory: {round(swap_memory.used / factor)} MB, ' + f'swap_memory_utilization: {swap_memory.percent} %, ' + 'current_process_memory: ' + f'{round(process_memory)} MB') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/set_epoch_info_hook.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/set_epoch_info_hook.py new file mode 100644 index 000000000..c2b134ceb --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/set_epoch_info_hook.py @@ -0,0 +1,15 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from mmcv.parallel import is_module_wrapper +from mmcv.runner import HOOKS, Hook + + +@HOOKS.register_module() +class SetEpochInfoHook(Hook): + """Set runner's epoch information to the model.""" + + def before_train_epoch(self, runner): + epoch = runner.epoch + model = runner.model + if is_module_wrapper(model): + model = model.module + model.set_epoch(epoch) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/sync_norm_hook.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/sync_norm_hook.py new file mode 100644 index 000000000..82931cef3 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/sync_norm_hook.py @@ -0,0 +1,52 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from collections import OrderedDict + +from mmcv.runner import get_dist_info +from mmcv.runner.hooks import HOOKS, Hook +from torch import nn + +from ..utils.dist_utils import all_reduce_dict + + +def get_norm_states(module): + async_norm_states = OrderedDict() + for name, child in module.named_modules(): + if isinstance(child, nn.modules.batchnorm._NormBase): + for k, v in child.state_dict().items(): + async_norm_states['.'.join([name, k])] = v + return async_norm_states + + +@HOOKS.register_module() +class SyncNormHook(Hook): + """Synchronize Norm states after training epoch, currently used in YOLOX. + + Args: + num_last_epochs (int): The number of latter epochs in the end of the + training to switch to synchronizing norm interval. Default: 15. + interval (int): Synchronizing norm interval. Default: 1. + """ + + def __init__(self, num_last_epochs=15, interval=1): + self.interval = interval + self.num_last_epochs = num_last_epochs + + def before_train_epoch(self, runner): + epoch = runner.epoch + if (epoch + 1) == runner.max_epochs - self.num_last_epochs: + # Synchronize norm every epoch. + self.interval = 1 + + def after_train_epoch(self, runner): + """Synchronizing norm.""" + epoch = runner.epoch + module = runner.model + if (epoch + 1) % self.interval == 0: + _, world_size = get_dist_info() + if world_size == 1: + return + norm_states = get_norm_states(module) + if len(norm_states) == 0: + return + norm_states = all_reduce_dict(norm_states, op='mean') + module.load_state_dict(norm_states, strict=False) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/sync_random_size_hook.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/sync_random_size_hook.py new file mode 100644 index 000000000..6d7e96c6a --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/sync_random_size_hook.py @@ -0,0 +1,72 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import random +import warnings + +import torch +from mmcv.runner import get_dist_info +from mmcv.runner.hooks import HOOKS, Hook +from torch import distributed as dist + + +@HOOKS.register_module() +class SyncRandomSizeHook(Hook): + """Change and synchronize the random image size across ranks. + SyncRandomSizeHook is deprecated, please use Resize pipeline to achieve + similar functions. Such as `dict(type='Resize', img_scale=[(448, 448), + (832, 832)], multiscale_mode='range', keep_ratio=True)`. + + Note: Due to the multi-process dataloader, its behavior is different + from YOLOX's official implementation, the official is to change the + size every fixed iteration interval and what we achieved is a fixed + epoch interval. + + Args: + ratio_range (tuple[int]): Random ratio range. It will be multiplied + by 32, and then change the dataset output image size. + Default: (14, 26). + img_scale (tuple[int]): Size of input image. Default: (640, 640). + interval (int): The epoch interval of change image size. Default: 1. + device (torch.device | str): device for returned tensors. + Default: 'cuda'. + """ + + def __init__(self, + ratio_range=(14, 26), + img_scale=(640, 640), + interval=1, + device='cuda'): + warnings.warn('DeprecationWarning: SyncRandomSizeHook is deprecated. ' + 'Please use Resize pipeline to achieve similar ' + 'functions. Due to the multi-process dataloader, ' + 'its behavior is different from YOLOX\'s official ' + 'implementation, the official is to change the size ' + 'every fixed iteration interval and what we achieved ' + 'is a fixed epoch interval.') + self.rank, world_size = get_dist_info() + self.is_distributed = world_size > 1 + self.ratio_range = ratio_range + self.img_scale = img_scale + self.interval = interval + self.device = device + + def after_train_epoch(self, runner): + """Change the dataset output image size.""" + if self.ratio_range is not None and (runner.epoch + + 1) % self.interval == 0: + # Due to DDP and DP get the device behavior inconsistent, + # so we did not get the device from runner.model. + tensor = torch.LongTensor(2).to(self.device) + + if self.rank == 0: + size_factor = self.img_scale[1] * 1. / self.img_scale[0] + size = random.randint(*self.ratio_range) + size = (int(32 * size), 32 * int(size * size_factor)) + tensor[0] = size[0] + tensor[1] = size[1] + + if self.is_distributed: + dist.barrier() + dist.broadcast(tensor, 0) + + runner.data_loader.dataset.update_dynamic_scale( + (tensor[0].item(), tensor[1].item())) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/wandblogger_hook.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/wandblogger_hook.py new file mode 100644 index 000000000..01c22bf50 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/wandblogger_hook.py @@ -0,0 +1,587 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import importlib +import os.path as osp +import sys +import warnings + +import mmcv +import numpy as np +import pycocotools.mask as mask_util +from mmcv.runner import HOOKS +from mmcv.runner.dist_utils import master_only +from mmcv.runner.hooks.checkpoint import CheckpointHook +from mmcv.runner.hooks.logger.wandb import WandbLoggerHook +from mmcv.utils import digit_version + +from mmdet.core import DistEvalHook, EvalHook +from mmdet.core.mask.structures import polygon_to_bitmap + + +@HOOKS.register_module() +class MMDetWandbHook(WandbLoggerHook): + """Enhanced Wandb logger hook for MMDetection. + + Comparing with the :cls:`mmcv.runner.WandbLoggerHook`, this hook can not + only automatically log all the metrics but also log the following extra + information - saves model checkpoints as W&B Artifact, and + logs model prediction as interactive W&B Tables. + + - Metrics: The MMDetWandbHook will automatically log training + and validation metrics along with system metrics (CPU/GPU). + + - Checkpointing: If `log_checkpoint` is True, the checkpoint saved at + every checkpoint interval will be saved as W&B Artifacts. + This depends on the : class:`mmcv.runner.CheckpointHook` whose priority + is higher than this hook. Please refer to + https://docs.wandb.ai/guides/artifacts/model-versioning + to learn more about model versioning with W&B Artifacts. + + - Checkpoint Metadata: If evaluation results are available for a given + checkpoint artifact, it will have a metadata associated with it. + The metadata contains the evaluation metrics computed on validation + data with that checkpoint along with the current epoch. It depends + on `EvalHook` whose priority is more than MMDetWandbHook. + + - Evaluation: At every evaluation interval, the `MMDetWandbHook` logs the + model prediction as interactive W&B Tables. The number of samples + logged is given by `num_eval_images`. Currently, the `MMDetWandbHook` + logs the predicted bounding boxes along with the ground truth at every + evaluation interval. This depends on the `EvalHook` whose priority is + more than `MMDetWandbHook`. Also note that the data is just logged once + and subsequent evaluation tables uses reference to the logged data + to save memory usage. Please refer to + https://docs.wandb.ai/guides/data-vis to learn more about W&B Tables. + + For more details check out W&B's MMDetection docs: + https://docs.wandb.ai/guides/integrations/mmdetection + + ``` + Example: + log_config = dict( + ... + hooks=[ + ..., + dict(type='MMDetWandbHook', + init_kwargs={ + 'entity': "YOUR_ENTITY", + 'project': "YOUR_PROJECT_NAME" + }, + interval=50, + log_checkpoint=True, + log_checkpoint_metadata=True, + num_eval_images=100, + bbox_score_thr=0.3) + ]) + ``` + + Args: + init_kwargs (dict): A dict passed to wandb.init to initialize + a W&B run. Please refer to https://docs.wandb.ai/ref/python/init + for possible key-value pairs. + interval (int): Logging interval (every k iterations). Defaults to 50. + log_checkpoint (bool): Save the checkpoint at every checkpoint interval + as W&B Artifacts. Use this for model versioning where each version + is a checkpoint. Defaults to False. + log_checkpoint_metadata (bool): Log the evaluation metrics computed + on the validation data with the checkpoint, along with current + epoch as a metadata to that checkpoint. + Defaults to True. + num_eval_images (int): The number of validation images to be logged. + If zero, the evaluation won't be logged. Defaults to 100. + bbox_score_thr (float): Threshold for bounding box scores. + Defaults to 0.3. + """ + + def __init__(self, + init_kwargs=None, + interval=50, + log_checkpoint=False, + log_checkpoint_metadata=False, + num_eval_images=100, + bbox_score_thr=0.3, + **kwargs): + super(MMDetWandbHook, self).__init__(init_kwargs, interval, **kwargs) + + self.log_checkpoint = log_checkpoint + self.log_checkpoint_metadata = ( + log_checkpoint and log_checkpoint_metadata) + self.num_eval_images = num_eval_images + self.bbox_score_thr = bbox_score_thr + self.log_evaluation = (num_eval_images > 0) + self.ckpt_hook: CheckpointHook = None + self.eval_hook: EvalHook = None + + def import_wandb(self): + try: + import wandb + from wandb import init # noqa + + # Fix ResourceWarning when calling wandb.log in wandb v0.12.10. + # https://github.com/wandb/client/issues/2837 + if digit_version(wandb.__version__) < digit_version('0.12.10'): + warnings.warn( + f'The current wandb {wandb.__version__} is ' + f'lower than v0.12.10 will cause ResourceWarning ' + f'when calling wandb.log, Please run ' + f'"pip install --upgrade wandb"') + + except ImportError: + raise ImportError( + 'Please run "pip install "wandb>=0.12.10"" to install wandb') + self.wandb = wandb + + @master_only + def before_run(self, runner): + super(MMDetWandbHook, self).before_run(runner) + + # Save and Log config. + if runner.meta is not None and runner.meta.get('exp_name', + None) is not None: + src_cfg_path = osp.join(runner.work_dir, + runner.meta.get('exp_name', None)) + if osp.exists(src_cfg_path): + self.wandb.save(src_cfg_path, base_path=runner.work_dir) + self._update_wandb_config(runner) + else: + runner.logger.warning('No meta information found in the runner. ') + + # Inspect CheckpointHook and EvalHook + for hook in runner.hooks: + if isinstance(hook, CheckpointHook): + self.ckpt_hook = hook + if isinstance(hook, (EvalHook, DistEvalHook)): + self.eval_hook = hook + + # Check conditions to log checkpoint + if self.log_checkpoint: + if self.ckpt_hook is None: + self.log_checkpoint = False + self.log_checkpoint_metadata = False + runner.logger.warning( + 'To log checkpoint in MMDetWandbHook, `CheckpointHook` is' + 'required, please check hooks in the runner.') + else: + self.ckpt_interval = self.ckpt_hook.interval + + # Check conditions to log evaluation + if self.log_evaluation or self.log_checkpoint_metadata: + if self.eval_hook is None: + self.log_evaluation = False + self.log_checkpoint_metadata = False + runner.logger.warning( + 'To log evaluation or checkpoint metadata in ' + 'MMDetWandbHook, `EvalHook` or `DistEvalHook` in mmdet ' + 'is required, please check whether the validation ' + 'is enabled.') + else: + self.eval_interval = self.eval_hook.interval + self.val_dataset = self.eval_hook.dataloader.dataset + # Determine the number of samples to be logged. + if self.num_eval_images > len(self.val_dataset): + self.num_eval_images = len(self.val_dataset) + runner.logger.warning( + f'The num_eval_images ({self.num_eval_images}) is ' + 'greater than the total number of validation samples ' + f'({len(self.val_dataset)}). The complete validation ' + 'dataset will be logged.') + + # Check conditions to log checkpoint metadata + if self.log_checkpoint_metadata: + assert self.ckpt_interval % self.eval_interval == 0, \ + 'To log checkpoint metadata in MMDetWandbHook, the interval ' \ + f'of checkpoint saving ({self.ckpt_interval}) should be ' \ + 'divisible by the interval of evaluation ' \ + f'({self.eval_interval}).' + + # Initialize evaluation table + if self.log_evaluation: + # Initialize data table + self._init_data_table() + # Add data to the data table + self._add_ground_truth(runner) + # Log ground truth data + self._log_data_table() + + @master_only + def after_train_epoch(self, runner): + super(MMDetWandbHook, self).after_train_epoch(runner) + + if not self.by_epoch: + return + + # Log checkpoint and metadata. + if (self.log_checkpoint + and self.every_n_epochs(runner, self.ckpt_interval) + or (self.ckpt_hook.save_last and self.is_last_epoch(runner))): + if self.log_checkpoint_metadata and self.eval_hook: + metadata = { + 'epoch': runner.epoch + 1, + **self._get_eval_results() + } + else: + metadata = None + aliases = [f'epoch_{runner.epoch + 1}', 'latest'] + model_path = osp.join(self.ckpt_hook.out_dir, + f'epoch_{runner.epoch + 1}.pth') + self._log_ckpt_as_artifact(model_path, aliases, metadata) + + # Save prediction table + if self.log_evaluation and self.eval_hook._should_evaluate(runner): + results = self.eval_hook.latest_results + # Initialize evaluation table + self._init_pred_table() + # Log predictions + self._log_predictions(results) + # Log the table + self._log_eval_table(runner.epoch + 1) + + @master_only + def after_train_iter(self, runner): + if self.get_mode(runner) == 'train': + # An ugly patch. The iter-based eval hook will call the + # `after_train_iter` method of all logger hooks before evaluation. + # Use this trick to skip that call. + # Don't call super method at first, it will clear the log_buffer + return super(MMDetWandbHook, self).after_train_iter(runner) + else: + super(MMDetWandbHook, self).after_train_iter(runner) + + if self.by_epoch: + return + + # Save checkpoint and metadata + if (self.log_checkpoint + and self.every_n_iters(runner, self.ckpt_interval) + or (self.ckpt_hook.save_last and self.is_last_iter(runner))): + if self.log_checkpoint_metadata and self.eval_hook: + metadata = { + 'iter': runner.iter + 1, + **self._get_eval_results() + } + else: + metadata = None + aliases = [f'iter_{runner.iter + 1}', 'latest'] + model_path = osp.join(self.ckpt_hook.out_dir, + f'iter_{runner.iter + 1}.pth') + self._log_ckpt_as_artifact(model_path, aliases, metadata) + + # Save prediction table + if self.log_evaluation and self.eval_hook._should_evaluate(runner): + results = self.eval_hook.latest_results + # Initialize evaluation table + self._init_pred_table() + # Log predictions + self._log_predictions(results) + # Log the table + self._log_eval_table(runner.iter + 1) + + @master_only + def after_run(self, runner): + self.wandb.finish() + + def _update_wandb_config(self, runner): + """Update wandb config.""" + # Import the config file. + sys.path.append(runner.work_dir) + config_filename = runner.meta['exp_name'][:-3] + configs = importlib.import_module(config_filename) + # Prepare a nested dict of config variables. + config_keys = [key for key in dir(configs) if not key.startswith('__')] + config_dict = {key: getattr(configs, key) for key in config_keys} + # Update the W&B config. + self.wandb.config.update(config_dict) + + def _log_ckpt_as_artifact(self, model_path, aliases, metadata=None): + """Log model checkpoint as W&B Artifact. + + Args: + model_path (str): Path of the checkpoint to log. + aliases (list): List of the aliases associated with this artifact. + metadata (dict, optional): Metadata associated with this artifact. + """ + model_artifact = self.wandb.Artifact( + f'run_{self.wandb.run.id}_model', type='model', metadata=metadata) + model_artifact.add_file(model_path) + self.wandb.log_artifact(model_artifact, aliases=aliases) + + def _get_eval_results(self): + """Get model evaluation results.""" + results = self.eval_hook.latest_results + eval_results = self.val_dataset.evaluate( + results, logger='silent', **self.eval_hook.eval_kwargs) + return eval_results + + def _init_data_table(self): + """Initialize the W&B Tables for validation data.""" + columns = ['image_name', 'image'] + self.data_table = self.wandb.Table(columns=columns) + + def _init_pred_table(self): + """Initialize the W&B Tables for model evaluation.""" + columns = ['image_name', 'ground_truth', 'prediction'] + self.eval_table = self.wandb.Table(columns=columns) + + def _add_ground_truth(self, runner): + # Get image loading pipeline + from mmdet.datasets.pipelines import LoadImageFromFile + img_loader = None + for t in self.val_dataset.pipeline.transforms: + if isinstance(t, LoadImageFromFile): + img_loader = t + + if img_loader is None: + self.log_evaluation = False + runner.logger.warning( + 'LoadImageFromFile is required to add images ' + 'to W&B Tables.') + return + + # Select the images to be logged. + self.eval_image_indexs = np.arange(len(self.val_dataset)) + # Set seed so that same validation set is logged each time. + np.random.seed(42) + np.random.shuffle(self.eval_image_indexs) + self.eval_image_indexs = self.eval_image_indexs[:self.num_eval_images] + + CLASSES = self.val_dataset.CLASSES + self.class_id_to_label = { + id + 1: name + for id, name in enumerate(CLASSES) + } + self.class_set = self.wandb.Classes([{ + 'id': id, + 'name': name + } for id, name in self.class_id_to_label.items()]) + + img_prefix = self.val_dataset.img_prefix + + for idx in self.eval_image_indexs: + img_info = self.val_dataset.data_infos[idx] + image_name = img_info.get('filename', f'img_{idx}') + img_height, img_width = img_info['height'], img_info['width'] + + img_meta = img_loader( + dict(img_info=img_info, img_prefix=img_prefix)) + + # Get image and convert from BGR to RGB + image = mmcv.bgr2rgb(img_meta['img']) + + data_ann = self.val_dataset.get_ann_info(idx) + bboxes = data_ann['bboxes'] + labels = data_ann['labels'] + masks = data_ann.get('masks', None) + + # Get dict of bounding boxes to be logged. + assert len(bboxes) == len(labels) + wandb_boxes = self._get_wandb_bboxes(bboxes, labels) + + # Get dict of masks to be logged. + if masks is not None: + wandb_masks = self._get_wandb_masks( + masks, + labels, + is_poly_mask=True, + height=img_height, + width=img_width) + else: + wandb_masks = None + # TODO: Panoramic segmentation visualization. + + # Log a row to the data table. + self.data_table.add_data( + image_name, + self.wandb.Image( + image, + boxes=wandb_boxes, + masks=wandb_masks, + classes=self.class_set)) + + def _log_predictions(self, results): + table_idxs = self.data_table_ref.get_index() + assert len(table_idxs) == len(self.eval_image_indexs) + + for ndx, eval_image_index in enumerate(self.eval_image_indexs): + # Get the result + result = results[eval_image_index] + if isinstance(result, tuple): + bbox_result, segm_result = result + if isinstance(segm_result, tuple): + segm_result = segm_result[0] # ms rcnn + else: + bbox_result, segm_result = result, None + assert len(bbox_result) == len(self.class_id_to_label) + + # Get labels + bboxes = np.vstack(bbox_result) + labels = [ + np.full(bbox.shape[0], i, dtype=np.int32) + for i, bbox in enumerate(bbox_result) + ] + labels = np.concatenate(labels) + + # Get segmentation mask if available. + segms = None + if segm_result is not None and len(labels) > 0: + segms = mmcv.concat_list(segm_result) + segms = mask_util.decode(segms) + segms = segms.transpose(2, 0, 1) + assert len(segms) == len(labels) + # TODO: Panoramic segmentation visualization. + + # Remove bounding boxes and masks with score lower than threshold. + if self.bbox_score_thr > 0: + assert bboxes is not None and bboxes.shape[1] == 5 + scores = bboxes[:, -1] + inds = scores > self.bbox_score_thr + bboxes = bboxes[inds, :] + labels = labels[inds] + if segms is not None: + segms = segms[inds, ...] + + # Get dict of bounding boxes to be logged. + wandb_boxes = self._get_wandb_bboxes(bboxes, labels, log_gt=False) + # Get dict of masks to be logged. + if segms is not None: + wandb_masks = self._get_wandb_masks(segms, labels) + else: + wandb_masks = None + + # Log a row to the eval table. + self.eval_table.add_data( + self.data_table_ref.data[ndx][0], + self.data_table_ref.data[ndx][1], + self.wandb.Image( + self.data_table_ref.data[ndx][1], + boxes=wandb_boxes, + masks=wandb_masks, + classes=self.class_set)) + + def _get_wandb_bboxes(self, bboxes, labels, log_gt=True): + """Get list of structured dict for logging bounding boxes to W&B. + + Args: + bboxes (list): List of bounding box coordinates in + (minX, minY, maxX, maxY) format. + labels (int): List of label ids. + log_gt (bool): Whether to log ground truth or prediction boxes. + + Returns: + Dictionary of bounding boxes to be logged. + """ + wandb_boxes = {} + + box_data = [] + for bbox, label in zip(bboxes, labels): + if not isinstance(label, int): + label = int(label) + label = label + 1 + + if len(bbox) == 5: + confidence = float(bbox[4]) + class_name = self.class_id_to_label[label] + box_caption = f'{class_name} {confidence:.2f}' + else: + box_caption = str(self.class_id_to_label[label]) + + position = dict( + minX=int(bbox[0]), + minY=int(bbox[1]), + maxX=int(bbox[2]), + maxY=int(bbox[3])) + + box_data.append({ + 'position': position, + 'class_id': label, + 'box_caption': box_caption, + 'domain': 'pixel' + }) + + wandb_bbox_dict = { + 'box_data': box_data, + 'class_labels': self.class_id_to_label + } + + if log_gt: + wandb_boxes['ground_truth'] = wandb_bbox_dict + else: + wandb_boxes['predictions'] = wandb_bbox_dict + + return wandb_boxes + + def _get_wandb_masks(self, + masks, + labels, + is_poly_mask=False, + height=None, + width=None): + """Get list of structured dict for logging masks to W&B. + + Args: + masks (list): List of masks. + labels (int): List of label ids. + is_poly_mask (bool): Whether the mask is polygonal or not. + This is true for CocoDataset. + height (int): Height of the image. + width (int): Width of the image. + + Returns: + Dictionary of masks to be logged. + """ + mask_label_dict = dict() + for mask, label in zip(masks, labels): + label = label + 1 + # Get bitmap mask from polygon. + if is_poly_mask: + if height is not None and width is not None: + mask = polygon_to_bitmap(mask, height, width) + # Create composite masks for each class. + if label not in mask_label_dict.keys(): + mask_label_dict[label] = mask + else: + mask_label_dict[label] = np.logical_or(mask_label_dict[label], + mask) + + wandb_masks = dict() + for key, value in mask_label_dict.items(): + # Create mask for that class. + value = value.astype(np.uint8) + value[value > 0] = key + + # Create dict of masks for logging. + class_name = self.class_id_to_label[key] + wandb_masks[class_name] = { + 'mask_data': value, + 'class_labels': self.class_id_to_label + } + + return wandb_masks + + def _log_data_table(self): + """Log the W&B Tables for validation data as artifact and calls + `use_artifact` on it so that the evaluation table can use the reference + of already uploaded images. + + This allows the data to be uploaded just once. + """ + data_artifact = self.wandb.Artifact('val', type='dataset') + data_artifact.add(self.data_table, 'val_data') + + self.wandb.run.use_artifact(data_artifact) + data_artifact.wait() + + self.data_table_ref = data_artifact.get('val_data') + + def _log_eval_table(self, idx): + """Log the W&B Tables for model evaluation. + + The table will be logged multiple times creating new version. Use this + to compare models at different intervals interactively. + """ + pred_artifact = self.wandb.Artifact( + f'run_{self.wandb.run.id}_pred', type='evaluation') + pred_artifact.add(self.eval_table, 'eval_data') + if self.by_epoch: + aliases = ['latest', f'epoch_{idx}'] + else: + aliases = ['latest', f'iter_{idx}'] + self.wandb.run.log_artifact(pred_artifact, aliases=aliases) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/yolox_lrupdater_hook.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/yolox_lrupdater_hook.py new file mode 100644 index 000000000..ecb028ed2 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/yolox_lrupdater_hook.py @@ -0,0 +1,67 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from mmcv.runner.hooks import HOOKS +from mmcv.runner.hooks.lr_updater import (CosineAnnealingLrUpdaterHook, + annealing_cos) + + +@HOOKS.register_module() +class YOLOXLrUpdaterHook(CosineAnnealingLrUpdaterHook): + """YOLOX learning rate scheme. + + There are two main differences between YOLOXLrUpdaterHook + and CosineAnnealingLrUpdaterHook. + + 1. When the current running epoch is greater than + `max_epoch-last_epoch`, a fixed learning rate will be used + 2. The exp warmup scheme is different with LrUpdaterHook in MMCV + + Args: + num_last_epochs (int): The number of epochs with a fixed learning rate + before the end of the training. + """ + + def __init__(self, num_last_epochs, **kwargs): + self.num_last_epochs = num_last_epochs + super(YOLOXLrUpdaterHook, self).__init__(**kwargs) + + def get_warmup_lr(self, cur_iters): + + def _get_warmup_lr(cur_iters, regular_lr): + # exp warmup scheme + k = self.warmup_ratio * pow( + (cur_iters + 1) / float(self.warmup_iters), 2) + warmup_lr = [_lr * k for _lr in regular_lr] + return warmup_lr + + if isinstance(self.base_lr, dict): + lr_groups = {} + for key, base_lr in self.base_lr.items(): + lr_groups[key] = _get_warmup_lr(cur_iters, base_lr) + return lr_groups + else: + return _get_warmup_lr(cur_iters, self.base_lr) + + def get_lr(self, runner, base_lr): + last_iter = len(runner.data_loader) * self.num_last_epochs + + if self.by_epoch: + progress = runner.epoch + max_progress = runner.max_epochs + else: + progress = runner.iter + max_progress = runner.max_iters + + progress += 1 + + if self.min_lr_ratio is not None: + target_lr = base_lr * self.min_lr_ratio + else: + target_lr = self.min_lr + + if progress >= max_progress - last_iter: + # fixed learning rate + return target_lr + else: + return annealing_cos( + base_lr, target_lr, (progress - self.warmup_iters) / + (max_progress - self.warmup_iters - last_iter)) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/yolox_mode_switch_hook.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/yolox_mode_switch_hook.py new file mode 100644 index 000000000..10834e686 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/hook/yolox_mode_switch_hook.py @@ -0,0 +1,52 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from mmcv.parallel import is_module_wrapper +from mmcv.runner.hooks import HOOKS, Hook + + +@HOOKS.register_module() +class YOLOXModeSwitchHook(Hook): + """Switch the mode of YOLOX during training. + + This hook turns off the mosaic and mixup data augmentation and switches + to use L1 loss in bbox_head. + + Args: + num_last_epochs (int): The number of latter epochs in the end of the + training to close the data augmentation and switch to L1 loss. + Default: 15. + skip_type_keys (list[str], optional): Sequence of type string to be + skip pipeline. Default: ('Mosaic', 'RandomAffine', 'MixUp') + """ + + def __init__(self, + num_last_epochs=15, + skip_type_keys=('Mosaic', 'RandomAffine', 'MixUp')): + self.num_last_epochs = num_last_epochs + self.skip_type_keys = skip_type_keys + self._restart_dataloader = False + + def before_train_epoch(self, runner): + """Close mosaic and mixup augmentation and switches to use L1 loss.""" + epoch = runner.epoch + train_loader = runner.data_loader + model = runner.model + if is_module_wrapper(model): + model = model.module + if (epoch + 1) == runner.max_epochs - self.num_last_epochs: + runner.logger.info('No mosaic and mixup aug now!') + # The dataset pipeline cannot be updated when persistent_workers + # is True, so we need to force the dataloader's multi-process + # restart. This is a very hacky approach. + train_loader.dataset.update_skip_type_keys(self.skip_type_keys) + if hasattr(train_loader, 'persistent_workers' + ) and train_loader.persistent_workers is True: + train_loader._DataLoader__initialized = False + train_loader._iterator = None + self._restart_dataloader = True + runner.logger.info('Add additional L1 loss now!') + model.bbox_head.use_l1 = True + else: + # Once the restart is complete, we need to restore + # the initialization flag. + if self._restart_dataloader: + train_loader._DataLoader__initialized = True diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/__init__.py index 845e7180e..644a9b1d9 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/__init__.py @@ -1,4 +1,9 @@ +# Copyright (c) OpenMMLab. All rights reserved. from .mask_target import mask_target -from .utils import split_combined_polys +from .structures import BaseInstanceMasks, BitmapMasks, PolygonMasks +from .utils import encode_mask_results, mask2bbox, split_combined_polys -__all__ = ['split_combined_polys', 'mask_target'] +__all__ = [ + 'split_combined_polys', 'mask_target', 'BaseInstanceMasks', 'BitmapMasks', + 'PolygonMasks', 'encode_mask_results', 'mask2bbox' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/mask_target.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/mask_target.py index 6603f11a4..273e7678f 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/mask_target.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/mask_target.py @@ -1,4 +1,4 @@ -import mmcv +# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import torch from torch.nn.modules.utils import _pair @@ -6,36 +6,122 @@ from torch.nn.modules.utils import _pair def mask_target(pos_proposals_list, pos_assigned_gt_inds_list, gt_masks_list, cfg): + """Compute mask target for positive proposals in multiple images. + + Args: + pos_proposals_list (list[Tensor]): Positive proposals in multiple + images. + pos_assigned_gt_inds_list (list[Tensor]): Assigned GT indices for each + positive proposals. + gt_masks_list (list[:obj:`BaseInstanceMasks`]): Ground truth masks of + each image. + cfg (dict): Config dict that specifies the mask size. + + Returns: + list[Tensor]: Mask target of each image. + + Example: + >>> import mmcv + >>> import mmdet + >>> from mmdet.core.mask import BitmapMasks + >>> from mmdet.core.mask.mask_target import * + >>> H, W = 17, 18 + >>> cfg = mmcv.Config({'mask_size': (13, 14)}) + >>> rng = np.random.RandomState(0) + >>> # Positive proposals (tl_x, tl_y, br_x, br_y) for each image + >>> pos_proposals_list = [ + >>> torch.Tensor([ + >>> [ 7.2425, 5.5929, 13.9414, 14.9541], + >>> [ 7.3241, 3.6170, 16.3850, 15.3102], + >>> ]), + >>> torch.Tensor([ + >>> [ 4.8448, 6.4010, 7.0314, 9.7681], + >>> [ 5.9790, 2.6989, 7.4416, 4.8580], + >>> [ 0.0000, 0.0000, 0.1398, 9.8232], + >>> ]), + >>> ] + >>> # Corresponding class index for each proposal for each image + >>> pos_assigned_gt_inds_list = [ + >>> torch.LongTensor([7, 0]), + >>> torch.LongTensor([5, 4, 1]), + >>> ] + >>> # Ground truth mask for each true object for each image + >>> gt_masks_list = [ + >>> BitmapMasks(rng.rand(8, H, W), height=H, width=W), + >>> BitmapMasks(rng.rand(6, H, W), height=H, width=W), + >>> ] + >>> mask_targets = mask_target( + >>> pos_proposals_list, pos_assigned_gt_inds_list, + >>> gt_masks_list, cfg) + >>> assert mask_targets.shape == (5,) + cfg['mask_size'] + """ cfg_list = [cfg for _ in range(len(pos_proposals_list))] mask_targets = map(mask_target_single, pos_proposals_list, pos_assigned_gt_inds_list, gt_masks_list, cfg_list) - mask_targets = torch.cat(list(mask_targets)) + mask_targets = list(mask_targets) + if len(mask_targets) > 0: + mask_targets = torch.cat(mask_targets) return mask_targets def mask_target_single(pos_proposals, pos_assigned_gt_inds, gt_masks, cfg): + """Compute mask target for each positive proposal in the image. + + Args: + pos_proposals (Tensor): Positive proposals. + pos_assigned_gt_inds (Tensor): Assigned GT inds of positive proposals. + gt_masks (:obj:`BaseInstanceMasks`): GT masks in the format of Bitmap + or Polygon. + cfg (dict): Config dict that indicate the mask size. + + Returns: + Tensor: Mask target of each positive proposals in the image. + + Example: + >>> import mmcv + >>> import mmdet + >>> from mmdet.core.mask import BitmapMasks + >>> from mmdet.core.mask.mask_target import * # NOQA + >>> H, W = 32, 32 + >>> cfg = mmcv.Config({'mask_size': (7, 11)}) + >>> rng = np.random.RandomState(0) + >>> # Masks for each ground truth box (relative to the image) + >>> gt_masks_data = rng.rand(3, H, W) + >>> gt_masks = BitmapMasks(gt_masks_data, height=H, width=W) + >>> # Predicted positive boxes in one image + >>> pos_proposals = torch.FloatTensor([ + >>> [ 16.2, 5.5, 19.9, 20.9], + >>> [ 17.3, 13.6, 19.3, 19.3], + >>> [ 14.8, 16.4, 17.0, 23.7], + >>> [ 0.0, 0.0, 16.0, 16.0], + >>> [ 4.0, 0.0, 20.0, 16.0], + >>> ]) + >>> # For each predicted proposal, its assignment to a gt mask + >>> pos_assigned_gt_inds = torch.LongTensor([0, 1, 2, 1, 1]) + >>> mask_targets = mask_target_single( + >>> pos_proposals, pos_assigned_gt_inds, gt_masks, cfg) + >>> assert mask_targets.shape == (5,) + cfg['mask_size'] + """ + device = pos_proposals.device mask_size = _pair(cfg.mask_size) + binarize = not cfg.get('soft_mask_target', False) num_pos = pos_proposals.size(0) - mask_targets = [] if num_pos > 0: proposals_np = pos_proposals.cpu().numpy() - _, maxh, maxw = gt_masks.shape - proposals_np[:, [0, 2]] = np.clip(proposals_np[:, [0, 2]], 0, maxw - 1) - proposals_np[:, [1, 3]] = np.clip(proposals_np[:, [1, 3]], 0, maxh - 1) + maxh, maxw = gt_masks.height, gt_masks.width + proposals_np[:, [0, 2]] = np.clip(proposals_np[:, [0, 2]], 0, maxw) + proposals_np[:, [1, 3]] = np.clip(proposals_np[:, [1, 3]], 0, maxh) pos_assigned_gt_inds = pos_assigned_gt_inds.cpu().numpy() - for i in range(num_pos): - gt_mask = gt_masks[pos_assigned_gt_inds[i]] - bbox = proposals_np[i, :].astype(np.int32) - x1, y1, x2, y2 = bbox - w = np.maximum(x2 - x1 + 1, 1) - h = np.maximum(y2 - y1 + 1, 1) - # mask is uint8 both before and after resizing - # mask_size (h, w) to (w, h) - target = mmcv.imresize(gt_mask[y1:y1 + h, x1:x1 + w], - mask_size[::-1]) - mask_targets.append(target) - mask_targets = torch.from_numpy(np.stack(mask_targets)).float().to( - pos_proposals.device) + + mask_targets = gt_masks.crop_and_resize( + proposals_np, + mask_size, + device=device, + inds=pos_assigned_gt_inds, + binarize=binarize).to_ndarray() + + mask_targets = torch.from_numpy(mask_targets).float().to(device) else: mask_targets = pos_proposals.new_zeros((0, ) + mask_size) + return mask_targets diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/structures.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/structures.py new file mode 100644 index 000000000..a9d0ebb4b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/structures.py @@ -0,0 +1,1102 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from abc import ABCMeta, abstractmethod + +import cv2 +import mmcv +import numpy as np +import pycocotools.mask as maskUtils +import torch +from mmcv.ops.roi_align import roi_align + + +class BaseInstanceMasks(metaclass=ABCMeta): + """Base class for instance masks.""" + + @abstractmethod + def rescale(self, scale, interpolation='nearest'): + """Rescale masks as large as possible while keeping the aspect ratio. + For details can refer to `mmcv.imrescale`. + + Args: + scale (tuple[int]): The maximum size (h, w) of rescaled mask. + interpolation (str): Same as :func:`mmcv.imrescale`. + + Returns: + BaseInstanceMasks: The rescaled masks. + """ + + @abstractmethod + def resize(self, out_shape, interpolation='nearest'): + """Resize masks to the given out_shape. + + Args: + out_shape: Target (h, w) of resized mask. + interpolation (str): See :func:`mmcv.imresize`. + + Returns: + BaseInstanceMasks: The resized masks. + """ + + @abstractmethod + def flip(self, flip_direction='horizontal'): + """Flip masks alone the given direction. + + Args: + flip_direction (str): Either 'horizontal' or 'vertical'. + + Returns: + BaseInstanceMasks: The flipped masks. + """ + + @abstractmethod + def pad(self, out_shape, pad_val): + """Pad masks to the given size of (h, w). + + Args: + out_shape (tuple[int]): Target (h, w) of padded mask. + pad_val (int): The padded value. + + Returns: + BaseInstanceMasks: The padded masks. + """ + + @abstractmethod + def crop(self, bbox): + """Crop each mask by the given bbox. + + Args: + bbox (ndarray): Bbox in format [x1, y1, x2, y2], shape (4, ). + + Return: + BaseInstanceMasks: The cropped masks. + """ + + @abstractmethod + def crop_and_resize(self, + bboxes, + out_shape, + inds, + device, + interpolation='bilinear', + binarize=True): + """Crop and resize masks by the given bboxes. + + This function is mainly used in mask targets computation. + It firstly align mask to bboxes by assigned_inds, then crop mask by the + assigned bbox and resize to the size of (mask_h, mask_w) + + Args: + bboxes (Tensor): Bboxes in format [x1, y1, x2, y2], shape (N, 4) + out_shape (tuple[int]): Target (h, w) of resized mask + inds (ndarray): Indexes to assign masks to each bbox, + shape (N,) and values should be between [0, num_masks - 1]. + device (str): Device of bboxes + interpolation (str): See `mmcv.imresize` + binarize (bool): if True fractional values are rounded to 0 or 1 + after the resize operation. if False and unsupported an error + will be raised. Defaults to True. + + Return: + BaseInstanceMasks: the cropped and resized masks. + """ + + @abstractmethod + def expand(self, expanded_h, expanded_w, top, left): + """see :class:`Expand`.""" + + @property + @abstractmethod + def areas(self): + """ndarray: areas of each instance.""" + + @abstractmethod + def to_ndarray(self): + """Convert masks to the format of ndarray. + + Return: + ndarray: Converted masks in the format of ndarray. + """ + + @abstractmethod + def to_tensor(self, dtype, device): + """Convert masks to the format of Tensor. + + Args: + dtype (str): Dtype of converted mask. + device (torch.device): Device of converted masks. + + Returns: + Tensor: Converted masks in the format of Tensor. + """ + + @abstractmethod + def translate(self, + out_shape, + offset, + direction='horizontal', + fill_val=0, + interpolation='bilinear'): + """Translate the masks. + + Args: + out_shape (tuple[int]): Shape for output mask, format (h, w). + offset (int | float): The offset for translate. + direction (str): The translate direction, either "horizontal" + or "vertical". + fill_val (int | float): Border value. Default 0. + interpolation (str): Same as :func:`mmcv.imtranslate`. + + Returns: + Translated masks. + """ + + def shear(self, + out_shape, + magnitude, + direction='horizontal', + border_value=0, + interpolation='bilinear'): + """Shear the masks. + + Args: + out_shape (tuple[int]): Shape for output mask, format (h, w). + magnitude (int | float): The magnitude used for shear. + direction (str): The shear direction, either "horizontal" + or "vertical". + border_value (int | tuple[int]): Value used in case of a + constant border. Default 0. + interpolation (str): Same as in :func:`mmcv.imshear`. + + Returns: + ndarray: Sheared masks. + """ + + @abstractmethod + def rotate(self, out_shape, angle, center=None, scale=1.0, fill_val=0): + """Rotate the masks. + + Args: + out_shape (tuple[int]): Shape for output mask, format (h, w). + angle (int | float): Rotation angle in degrees. Positive values + mean counter-clockwise rotation. + center (tuple[float], optional): Center point (w, h) of the + rotation in source image. If not specified, the center of + the image will be used. + scale (int | float): Isotropic scale factor. + fill_val (int | float): Border value. Default 0 for masks. + + Returns: + Rotated masks. + """ + + +class BitmapMasks(BaseInstanceMasks): + """This class represents masks in the form of bitmaps. + + Args: + masks (ndarray): ndarray of masks in shape (N, H, W), where N is + the number of objects. + height (int): height of masks + width (int): width of masks + + Example: + >>> from mmdet.core.mask.structures import * # NOQA + >>> num_masks, H, W = 3, 32, 32 + >>> rng = np.random.RandomState(0) + >>> masks = (rng.rand(num_masks, H, W) > 0.1).astype(np.int) + >>> self = BitmapMasks(masks, height=H, width=W) + + >>> # demo crop_and_resize + >>> num_boxes = 5 + >>> bboxes = np.array([[0, 0, 30, 10.0]] * num_boxes) + >>> out_shape = (14, 14) + >>> inds = torch.randint(0, len(self), size=(num_boxes,)) + >>> device = 'cpu' + >>> interpolation = 'bilinear' + >>> new = self.crop_and_resize( + ... bboxes, out_shape, inds, device, interpolation) + >>> assert len(new) == num_boxes + >>> assert new.height, new.width == out_shape + """ + + def __init__(self, masks, height, width): + self.height = height + self.width = width + if len(masks) == 0: + self.masks = np.empty((0, self.height, self.width), dtype=np.uint8) + else: + assert isinstance(masks, (list, np.ndarray)) + if isinstance(masks, list): + assert isinstance(masks[0], np.ndarray) + assert masks[0].ndim == 2 # (H, W) + else: + assert masks.ndim == 3 # (N, H, W) + + self.masks = np.stack(masks).reshape(-1, height, width) + assert self.masks.shape[1] == self.height + assert self.masks.shape[2] == self.width + + def __getitem__(self, index): + """Index the BitmapMask. + + Args: + index (int | ndarray): Indices in the format of integer or ndarray. + + Returns: + :obj:`BitmapMasks`: Indexed bitmap masks. + """ + masks = self.masks[index].reshape(-1, self.height, self.width) + return BitmapMasks(masks, self.height, self.width) + + def __iter__(self): + return iter(self.masks) + + def __repr__(self): + s = self.__class__.__name__ + '(' + s += f'num_masks={len(self.masks)}, ' + s += f'height={self.height}, ' + s += f'width={self.width})' + return s + + def __len__(self): + """Number of masks.""" + return len(self.masks) + + def rescale(self, scale, interpolation='nearest'): + """See :func:`BaseInstanceMasks.rescale`.""" + if len(self.masks) == 0: + new_w, new_h = mmcv.rescale_size((self.width, self.height), scale) + rescaled_masks = np.empty((0, new_h, new_w), dtype=np.uint8) + else: + rescaled_masks = np.stack([ + mmcv.imrescale(mask, scale, interpolation=interpolation) + for mask in self.masks + ]) + height, width = rescaled_masks.shape[1:] + return BitmapMasks(rescaled_masks, height, width) + + def resize(self, out_shape, interpolation='nearest'): + """See :func:`BaseInstanceMasks.resize`.""" + if len(self.masks) == 0: + resized_masks = np.empty((0, *out_shape), dtype=np.uint8) + else: + resized_masks = np.stack([ + mmcv.imresize( + mask, out_shape[::-1], interpolation=interpolation) + for mask in self.masks + ]) + return BitmapMasks(resized_masks, *out_shape) + + def flip(self, flip_direction='horizontal'): + """See :func:`BaseInstanceMasks.flip`.""" + assert flip_direction in ('horizontal', 'vertical', 'diagonal') + + if len(self.masks) == 0: + flipped_masks = self.masks + else: + flipped_masks = np.stack([ + mmcv.imflip(mask, direction=flip_direction) + for mask in self.masks + ]) + return BitmapMasks(flipped_masks, self.height, self.width) + + def pad(self, out_shape, pad_val=0): + """See :func:`BaseInstanceMasks.pad`.""" + if len(self.masks) == 0: + padded_masks = np.empty((0, *out_shape), dtype=np.uint8) + else: + padded_masks = np.stack([ + mmcv.impad(mask, shape=out_shape, pad_val=pad_val) + for mask in self.masks + ]) + return BitmapMasks(padded_masks, *out_shape) + + def crop(self, bbox): + """See :func:`BaseInstanceMasks.crop`.""" + assert isinstance(bbox, np.ndarray) + assert bbox.ndim == 1 + + # clip the boundary + bbox = bbox.copy() + bbox[0::2] = np.clip(bbox[0::2], 0, self.width) + bbox[1::2] = np.clip(bbox[1::2], 0, self.height) + x1, y1, x2, y2 = bbox + w = np.maximum(x2 - x1, 1) + h = np.maximum(y2 - y1, 1) + + if len(self.masks) == 0: + cropped_masks = np.empty((0, h, w), dtype=np.uint8) + else: + cropped_masks = self.masks[:, y1:y1 + h, x1:x1 + w] + return BitmapMasks(cropped_masks, h, w) + + def crop_and_resize(self, + bboxes, + out_shape, + inds, + device='cpu', + interpolation='bilinear', + binarize=True): + """See :func:`BaseInstanceMasks.crop_and_resize`.""" + if len(self.masks) == 0: + empty_masks = np.empty((0, *out_shape), dtype=np.uint8) + return BitmapMasks(empty_masks, *out_shape) + + # convert bboxes to tensor + if isinstance(bboxes, np.ndarray): + bboxes = torch.from_numpy(bboxes).to(device=device) + if isinstance(inds, np.ndarray): + inds = torch.from_numpy(inds).to(device=device) + + num_bbox = bboxes.shape[0] + fake_inds = torch.arange( + num_bbox, device=device).to(dtype=bboxes.dtype)[:, None] + rois = torch.cat([fake_inds, bboxes], dim=1) # Nx5 + rois = rois.to(device=device) + if num_bbox > 0: + gt_masks_th = torch.from_numpy(self.masks).to(device).index_select( + 0, inds).to(dtype=rois.dtype) + targets = roi_align(gt_masks_th[:, None, :, :], rois, out_shape, + 1.0, 0, 'avg', True).squeeze(1) + if binarize: + resized_masks = (targets >= 0.5).cpu().numpy() + else: + resized_masks = targets.cpu().numpy() + else: + resized_masks = [] + return BitmapMasks(resized_masks, *out_shape) + + def expand(self, expanded_h, expanded_w, top, left): + """See :func:`BaseInstanceMasks.expand`.""" + if len(self.masks) == 0: + expanded_mask = np.empty((0, expanded_h, expanded_w), + dtype=np.uint8) + else: + expanded_mask = np.zeros((len(self), expanded_h, expanded_w), + dtype=np.uint8) + expanded_mask[:, top:top + self.height, + left:left + self.width] = self.masks + return BitmapMasks(expanded_mask, expanded_h, expanded_w) + + def translate(self, + out_shape, + offset, + direction='horizontal', + fill_val=0, + interpolation='bilinear'): + """Translate the BitmapMasks. + + Args: + out_shape (tuple[int]): Shape for output mask, format (h, w). + offset (int | float): The offset for translate. + direction (str): The translate direction, either "horizontal" + or "vertical". + fill_val (int | float): Border value. Default 0 for masks. + interpolation (str): Same as :func:`mmcv.imtranslate`. + + Returns: + BitmapMasks: Translated BitmapMasks. + + Example: + >>> from mmdet.core.mask.structures import BitmapMasks + >>> self = BitmapMasks.random(dtype=np.uint8) + >>> out_shape = (32, 32) + >>> offset = 4 + >>> direction = 'horizontal' + >>> fill_val = 0 + >>> interpolation = 'bilinear' + >>> # Note, There seem to be issues when: + >>> # * out_shape is different than self's shape + >>> # * the mask dtype is not supported by cv2.AffineWarp + >>> new = self.translate(out_shape, offset, direction, fill_val, + >>> interpolation) + >>> assert len(new) == len(self) + >>> assert new.height, new.width == out_shape + """ + if len(self.masks) == 0: + translated_masks = np.empty((0, *out_shape), dtype=np.uint8) + else: + translated_masks = mmcv.imtranslate( + self.masks.transpose((1, 2, 0)), + offset, + direction, + border_value=fill_val, + interpolation=interpolation) + if translated_masks.ndim == 2: + translated_masks = translated_masks[:, :, None] + translated_masks = translated_masks.transpose( + (2, 0, 1)).astype(self.masks.dtype) + return BitmapMasks(translated_masks, *out_shape) + + def shear(self, + out_shape, + magnitude, + direction='horizontal', + border_value=0, + interpolation='bilinear'): + """Shear the BitmapMasks. + + Args: + out_shape (tuple[int]): Shape for output mask, format (h, w). + magnitude (int | float): The magnitude used for shear. + direction (str): The shear direction, either "horizontal" + or "vertical". + border_value (int | tuple[int]): Value used in case of a + constant border. + interpolation (str): Same as in :func:`mmcv.imshear`. + + Returns: + BitmapMasks: The sheared masks. + """ + if len(self.masks) == 0: + sheared_masks = np.empty((0, *out_shape), dtype=np.uint8) + else: + sheared_masks = mmcv.imshear( + self.masks.transpose((1, 2, 0)), + magnitude, + direction, + border_value=border_value, + interpolation=interpolation) + if sheared_masks.ndim == 2: + sheared_masks = sheared_masks[:, :, None] + sheared_masks = sheared_masks.transpose( + (2, 0, 1)).astype(self.masks.dtype) + return BitmapMasks(sheared_masks, *out_shape) + + def rotate(self, out_shape, angle, center=None, scale=1.0, fill_val=0): + """Rotate the BitmapMasks. + + Args: + out_shape (tuple[int]): Shape for output mask, format (h, w). + angle (int | float): Rotation angle in degrees. Positive values + mean counter-clockwise rotation. + center (tuple[float], optional): Center point (w, h) of the + rotation in source image. If not specified, the center of + the image will be used. + scale (int | float): Isotropic scale factor. + fill_val (int | float): Border value. Default 0 for masks. + + Returns: + BitmapMasks: Rotated BitmapMasks. + """ + if len(self.masks) == 0: + rotated_masks = np.empty((0, *out_shape), dtype=self.masks.dtype) + else: + rotated_masks = mmcv.imrotate( + self.masks.transpose((1, 2, 0)), + angle, + center=center, + scale=scale, + border_value=fill_val) + if rotated_masks.ndim == 2: + # case when only one mask, (h, w) + rotated_masks = rotated_masks[:, :, None] # (h, w, 1) + rotated_masks = rotated_masks.transpose( + (2, 0, 1)).astype(self.masks.dtype) + return BitmapMasks(rotated_masks, *out_shape) + + @property + def areas(self): + """See :py:attr:`BaseInstanceMasks.areas`.""" + return self.masks.sum((1, 2)) + + def to_ndarray(self): + """See :func:`BaseInstanceMasks.to_ndarray`.""" + return self.masks + + def to_tensor(self, dtype, device): + """See :func:`BaseInstanceMasks.to_tensor`.""" + return torch.tensor(self.masks, dtype=dtype, device=device) + + @classmethod + def random(cls, + num_masks=3, + height=32, + width=32, + dtype=np.uint8, + rng=None): + """Generate random bitmap masks for demo / testing purposes. + + Example: + >>> from mmdet.core.mask.structures import BitmapMasks + >>> self = BitmapMasks.random() + >>> print('self = {}'.format(self)) + self = BitmapMasks(num_masks=3, height=32, width=32) + """ + from mmdet.utils.util_random import ensure_rng + rng = ensure_rng(rng) + masks = (rng.rand(num_masks, height, width) > 0.1).astype(dtype) + self = cls(masks, height=height, width=width) + return self + + def get_bboxes(self): + num_masks = len(self) + boxes = np.zeros((num_masks, 4), dtype=np.float32) + x_any = self.masks.any(axis=1) + y_any = self.masks.any(axis=2) + for idx in range(num_masks): + x = np.where(x_any[idx, :])[0] + y = np.where(y_any[idx, :])[0] + if len(x) > 0 and len(y) > 0: + # use +1 for x_max and y_max so that the right and bottom + # boundary of instance masks are fully included by the box + boxes[idx, :] = np.array([x[0], y[0], x[-1] + 1, y[-1] + 1], + dtype=np.float32) + return boxes + + +class PolygonMasks(BaseInstanceMasks): + """This class represents masks in the form of polygons. + + Polygons is a list of three levels. The first level of the list + corresponds to objects, the second level to the polys that compose the + object, the third level to the poly coordinates + + Args: + masks (list[list[ndarray]]): The first level of the list + corresponds to objects, the second level to the polys that + compose the object, the third level to the poly coordinates + height (int): height of masks + width (int): width of masks + + Example: + >>> from mmdet.core.mask.structures import * # NOQA + >>> masks = [ + >>> [ np.array([0, 0, 10, 0, 10, 10., 0, 10, 0, 0]) ] + >>> ] + >>> height, width = 16, 16 + >>> self = PolygonMasks(masks, height, width) + + >>> # demo translate + >>> new = self.translate((16, 16), 4., direction='horizontal') + >>> assert np.all(new.masks[0][0][1::2] == masks[0][0][1::2]) + >>> assert np.all(new.masks[0][0][0::2] == masks[0][0][0::2] + 4) + + >>> # demo crop_and_resize + >>> num_boxes = 3 + >>> bboxes = np.array([[0, 0, 30, 10.0]] * num_boxes) + >>> out_shape = (16, 16) + >>> inds = torch.randint(0, len(self), size=(num_boxes,)) + >>> device = 'cpu' + >>> interpolation = 'bilinear' + >>> new = self.crop_and_resize( + ... bboxes, out_shape, inds, device, interpolation) + >>> assert len(new) == num_boxes + >>> assert new.height, new.width == out_shape + """ + + def __init__(self, masks, height, width): + assert isinstance(masks, list) + if len(masks) > 0: + assert isinstance(masks[0], list) + assert isinstance(masks[0][0], np.ndarray) + + self.height = height + self.width = width + self.masks = masks + + def __getitem__(self, index): + """Index the polygon masks. + + Args: + index (ndarray | List): The indices. + + Returns: + :obj:`PolygonMasks`: The indexed polygon masks. + """ + if isinstance(index, np.ndarray): + index = index.tolist() + if isinstance(index, list): + masks = [self.masks[i] for i in index] + else: + try: + masks = self.masks[index] + except Exception: + raise ValueError( + f'Unsupported input of type {type(index)} for indexing!') + if len(masks) and isinstance(masks[0], np.ndarray): + masks = [masks] # ensure a list of three levels + return PolygonMasks(masks, self.height, self.width) + + def __iter__(self): + return iter(self.masks) + + def __repr__(self): + s = self.__class__.__name__ + '(' + s += f'num_masks={len(self.masks)}, ' + s += f'height={self.height}, ' + s += f'width={self.width})' + return s + + def __len__(self): + """Number of masks.""" + return len(self.masks) + + def rescale(self, scale, interpolation=None): + """see :func:`BaseInstanceMasks.rescale`""" + new_w, new_h = mmcv.rescale_size((self.width, self.height), scale) + if len(self.masks) == 0: + rescaled_masks = PolygonMasks([], new_h, new_w) + else: + rescaled_masks = self.resize((new_h, new_w)) + return rescaled_masks + + def resize(self, out_shape, interpolation=None): + """see :func:`BaseInstanceMasks.resize`""" + if len(self.masks) == 0: + resized_masks = PolygonMasks([], *out_shape) + else: + h_scale = out_shape[0] / self.height + w_scale = out_shape[1] / self.width + resized_masks = [] + for poly_per_obj in self.masks: + resized_poly = [] + for p in poly_per_obj: + p = p.copy() + p[0::2] = p[0::2] * w_scale + p[1::2] = p[1::2] * h_scale + resized_poly.append(p) + resized_masks.append(resized_poly) + resized_masks = PolygonMasks(resized_masks, *out_shape) + return resized_masks + + def flip(self, flip_direction='horizontal'): + """see :func:`BaseInstanceMasks.flip`""" + assert flip_direction in ('horizontal', 'vertical', 'diagonal') + if len(self.masks) == 0: + flipped_masks = PolygonMasks([], self.height, self.width) + else: + flipped_masks = [] + for poly_per_obj in self.masks: + flipped_poly_per_obj = [] + for p in poly_per_obj: + p = p.copy() + if flip_direction == 'horizontal': + p[0::2] = self.width - p[0::2] + elif flip_direction == 'vertical': + p[1::2] = self.height - p[1::2] + else: + p[0::2] = self.width - p[0::2] + p[1::2] = self.height - p[1::2] + flipped_poly_per_obj.append(p) + flipped_masks.append(flipped_poly_per_obj) + flipped_masks = PolygonMasks(flipped_masks, self.height, + self.width) + return flipped_masks + + def crop(self, bbox): + """see :func:`BaseInstanceMasks.crop`""" + assert isinstance(bbox, np.ndarray) + assert bbox.ndim == 1 + + # clip the boundary + bbox = bbox.copy() + bbox[0::2] = np.clip(bbox[0::2], 0, self.width) + bbox[1::2] = np.clip(bbox[1::2], 0, self.height) + x1, y1, x2, y2 = bbox + w = np.maximum(x2 - x1, 1) + h = np.maximum(y2 - y1, 1) + + if len(self.masks) == 0: + cropped_masks = PolygonMasks([], h, w) + else: + cropped_masks = [] + for poly_per_obj in self.masks: + cropped_poly_per_obj = [] + for p in poly_per_obj: + # pycocotools will clip the boundary + p = p.copy() + p[0::2] = p[0::2] - bbox[0] + p[1::2] = p[1::2] - bbox[1] + cropped_poly_per_obj.append(p) + cropped_masks.append(cropped_poly_per_obj) + cropped_masks = PolygonMasks(cropped_masks, h, w) + return cropped_masks + + def pad(self, out_shape, pad_val=0): + """padding has no effect on polygons`""" + return PolygonMasks(self.masks, *out_shape) + + def expand(self, *args, **kwargs): + """TODO: Add expand for polygon""" + raise NotImplementedError + + def crop_and_resize(self, + bboxes, + out_shape, + inds, + device='cpu', + interpolation='bilinear', + binarize=True): + """see :func:`BaseInstanceMasks.crop_and_resize`""" + out_h, out_w = out_shape + if len(self.masks) == 0: + return PolygonMasks([], out_h, out_w) + + if not binarize: + raise ValueError('Polygons are always binary, ' + 'setting binarize=False is unsupported') + + resized_masks = [] + for i in range(len(bboxes)): + mask = self.masks[inds[i]] + bbox = bboxes[i, :] + x1, y1, x2, y2 = bbox + w = np.maximum(x2 - x1, 1) + h = np.maximum(y2 - y1, 1) + h_scale = out_h / max(h, 0.1) # avoid too large scale + w_scale = out_w / max(w, 0.1) + + resized_mask = [] + for p in mask: + p = p.copy() + # crop + # pycocotools will clip the boundary + p[0::2] = p[0::2] - bbox[0] + p[1::2] = p[1::2] - bbox[1] + + # resize + p[0::2] = p[0::2] * w_scale + p[1::2] = p[1::2] * h_scale + resized_mask.append(p) + resized_masks.append(resized_mask) + return PolygonMasks(resized_masks, *out_shape) + + def translate(self, + out_shape, + offset, + direction='horizontal', + fill_val=None, + interpolation=None): + """Translate the PolygonMasks. + + Example: + >>> self = PolygonMasks.random(dtype=np.int) + >>> out_shape = (self.height, self.width) + >>> new = self.translate(out_shape, 4., direction='horizontal') + >>> assert np.all(new.masks[0][0][1::2] == self.masks[0][0][1::2]) + >>> assert np.all(new.masks[0][0][0::2] == self.masks[0][0][0::2] + 4) # noqa: E501 + """ + assert fill_val is None or fill_val == 0, 'Here fill_val is not '\ + f'used, and defaultly should be None or 0. got {fill_val}.' + if len(self.masks) == 0: + translated_masks = PolygonMasks([], *out_shape) + else: + translated_masks = [] + for poly_per_obj in self.masks: + translated_poly_per_obj = [] + for p in poly_per_obj: + p = p.copy() + if direction == 'horizontal': + p[0::2] = np.clip(p[0::2] + offset, 0, out_shape[1]) + elif direction == 'vertical': + p[1::2] = np.clip(p[1::2] + offset, 0, out_shape[0]) + translated_poly_per_obj.append(p) + translated_masks.append(translated_poly_per_obj) + translated_masks = PolygonMasks(translated_masks, *out_shape) + return translated_masks + + def shear(self, + out_shape, + magnitude, + direction='horizontal', + border_value=0, + interpolation='bilinear'): + """See :func:`BaseInstanceMasks.shear`.""" + if len(self.masks) == 0: + sheared_masks = PolygonMasks([], *out_shape) + else: + sheared_masks = [] + if direction == 'horizontal': + shear_matrix = np.stack([[1, magnitude], + [0, 1]]).astype(np.float32) + elif direction == 'vertical': + shear_matrix = np.stack([[1, 0], [magnitude, + 1]]).astype(np.float32) + for poly_per_obj in self.masks: + sheared_poly = [] + for p in poly_per_obj: + p = np.stack([p[0::2], p[1::2]], axis=0) # [2, n] + new_coords = np.matmul(shear_matrix, p) # [2, n] + new_coords[0, :] = np.clip(new_coords[0, :], 0, + out_shape[1]) + new_coords[1, :] = np.clip(new_coords[1, :], 0, + out_shape[0]) + sheared_poly.append( + new_coords.transpose((1, 0)).reshape(-1)) + sheared_masks.append(sheared_poly) + sheared_masks = PolygonMasks(sheared_masks, *out_shape) + return sheared_masks + + def rotate(self, out_shape, angle, center=None, scale=1.0, fill_val=0): + """See :func:`BaseInstanceMasks.rotate`.""" + if len(self.masks) == 0: + rotated_masks = PolygonMasks([], *out_shape) + else: + rotated_masks = [] + rotate_matrix = cv2.getRotationMatrix2D(center, -angle, scale) + for poly_per_obj in self.masks: + rotated_poly = [] + for p in poly_per_obj: + p = p.copy() + coords = np.stack([p[0::2], p[1::2]], axis=1) # [n, 2] + # pad 1 to convert from format [x, y] to homogeneous + # coordinates format [x, y, 1] + coords = np.concatenate( + (coords, np.ones((coords.shape[0], 1), coords.dtype)), + axis=1) # [n, 3] + rotated_coords = np.matmul( + rotate_matrix[None, :, :], + coords[:, :, None])[..., 0] # [n, 2, 1] -> [n, 2] + rotated_coords[:, 0] = np.clip(rotated_coords[:, 0], 0, + out_shape[1]) + rotated_coords[:, 1] = np.clip(rotated_coords[:, 1], 0, + out_shape[0]) + rotated_poly.append(rotated_coords.reshape(-1)) + rotated_masks.append(rotated_poly) + rotated_masks = PolygonMasks(rotated_masks, *out_shape) + return rotated_masks + + def to_bitmap(self): + """convert polygon masks to bitmap masks.""" + bitmap_masks = self.to_ndarray() + return BitmapMasks(bitmap_masks, self.height, self.width) + + @property + def areas(self): + """Compute areas of masks. + + This func is modified from `detectron2 + `_. + The function only works with Polygons using the shoelace formula. + + Return: + ndarray: areas of each instance + """ # noqa: W501 + area = [] + for polygons_per_obj in self.masks: + area_per_obj = 0 + for p in polygons_per_obj: + area_per_obj += self._polygon_area(p[0::2], p[1::2]) + area.append(area_per_obj) + return np.asarray(area) + + def _polygon_area(self, x, y): + """Compute the area of a component of a polygon. + + Using the shoelace formula: + https://stackoverflow.com/questions/24467972/calculate-area-of-polygon-given-x-y-coordinates + + Args: + x (ndarray): x coordinates of the component + y (ndarray): y coordinates of the component + + Return: + float: the are of the component + """ # noqa: 501 + return 0.5 * np.abs( + np.dot(x, np.roll(y, 1)) - np.dot(y, np.roll(x, 1))) + + def to_ndarray(self): + """Convert masks to the format of ndarray.""" + if len(self.masks) == 0: + return np.empty((0, self.height, self.width), dtype=np.uint8) + bitmap_masks = [] + for poly_per_obj in self.masks: + bitmap_masks.append( + polygon_to_bitmap(poly_per_obj, self.height, self.width)) + return np.stack(bitmap_masks) + + def to_tensor(self, dtype, device): + """See :func:`BaseInstanceMasks.to_tensor`.""" + if len(self.masks) == 0: + return torch.empty((0, self.height, self.width), + dtype=dtype, + device=device) + ndarray_masks = self.to_ndarray() + return torch.tensor(ndarray_masks, dtype=dtype, device=device) + + @classmethod + def random(cls, + num_masks=3, + height=32, + width=32, + n_verts=5, + dtype=np.float32, + rng=None): + """Generate random polygon masks for demo / testing purposes. + + Adapted from [1]_ + + References: + .. [1] https://gitlab.kitware.com/computer-vision/kwimage/-/blob/928cae35ca8/kwimage/structs/polygon.py#L379 # noqa: E501 + + Example: + >>> from mmdet.core.mask.structures import PolygonMasks + >>> self = PolygonMasks.random() + >>> print('self = {}'.format(self)) + """ + from mmdet.utils.util_random import ensure_rng + rng = ensure_rng(rng) + + def _gen_polygon(n, irregularity, spikeyness): + """Creates the polygon by sampling points on a circle around the + centre. Random noise is added by varying the angular spacing + between sequential points, and by varying the radial distance of + each point from the centre. + + Based on original code by Mike Ounsworth + + Args: + n (int): number of vertices + irregularity (float): [0,1] indicating how much variance there + is in the angular spacing of vertices. [0,1] will map to + [0, 2pi/numberOfVerts] + spikeyness (float): [0,1] indicating how much variance there is + in each vertex from the circle of radius aveRadius. [0,1] + will map to [0, aveRadius] + + Returns: + a list of vertices, in CCW order. + """ + from scipy.stats import truncnorm + + # Generate around the unit circle + cx, cy = (0.0, 0.0) + radius = 1 + + tau = np.pi * 2 + + irregularity = np.clip(irregularity, 0, 1) * 2 * np.pi / n + spikeyness = np.clip(spikeyness, 1e-9, 1) + + # generate n angle steps + lower = (tau / n) - irregularity + upper = (tau / n) + irregularity + angle_steps = rng.uniform(lower, upper, n) + + # normalize the steps so that point 0 and point n+1 are the same + k = angle_steps.sum() / (2 * np.pi) + angles = (angle_steps / k).cumsum() + rng.uniform(0, tau) + + # Convert high and low values to be wrt the standard normal range + # https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.truncnorm.html + low = 0 + high = 2 * radius + mean = radius + std = spikeyness + a = (low - mean) / std + b = (high - mean) / std + tnorm = truncnorm(a=a, b=b, loc=mean, scale=std) + + # now generate the points + radii = tnorm.rvs(n, random_state=rng) + x_pts = cx + radii * np.cos(angles) + y_pts = cy + radii * np.sin(angles) + + points = np.hstack([x_pts[:, None], y_pts[:, None]]) + + # Scale to 0-1 space + points = points - points.min(axis=0) + points = points / points.max(axis=0) + + # Randomly place within 0-1 space + points = points * (rng.rand() * .8 + .2) + min_pt = points.min(axis=0) + max_pt = points.max(axis=0) + + high = (1 - max_pt) + low = (0 - min_pt) + offset = (rng.rand(2) * (high - low)) + low + points = points + offset + return points + + def _order_vertices(verts): + """ + References: + https://stackoverflow.com/questions/1709283/how-can-i-sort-a-coordinate-list-for-a-rectangle-counterclockwise + """ + mlat = verts.T[0].sum() / len(verts) + mlng = verts.T[1].sum() / len(verts) + + tau = np.pi * 2 + angle = (np.arctan2(mlat - verts.T[0], verts.T[1] - mlng) + + tau) % tau + sortx = angle.argsort() + verts = verts.take(sortx, axis=0) + return verts + + # Generate a random exterior for each requested mask + masks = [] + for _ in range(num_masks): + exterior = _order_vertices(_gen_polygon(n_verts, 0.9, 0.9)) + exterior = (exterior * [(width, height)]).astype(dtype) + masks.append([exterior.ravel()]) + + self = cls(masks, height, width) + return self + + def get_bboxes(self): + num_masks = len(self) + boxes = np.zeros((num_masks, 4), dtype=np.float32) + for idx, poly_per_obj in enumerate(self.masks): + # simply use a number that is big enough for comparison with + # coordinates + xy_min = np.array([self.width * 2, self.height * 2], + dtype=np.float32) + xy_max = np.zeros(2, dtype=np.float32) + for p in poly_per_obj: + xy = np.array(p).reshape(-1, 2).astype(np.float32) + xy_min = np.minimum(xy_min, np.min(xy, axis=0)) + xy_max = np.maximum(xy_max, np.max(xy, axis=0)) + boxes[idx, :2] = xy_min + boxes[idx, 2:] = xy_max + + return boxes + + +def polygon_to_bitmap(polygons, height, width): + """Convert masks from the form of polygons to bitmaps. + + Args: + polygons (list[ndarray]): masks in polygon representation + height (int): mask height + width (int): mask width + + Return: + ndarray: the converted masks in bitmap representation + """ + rles = maskUtils.frPyObjects(polygons, height, width) + rle = maskUtils.merge(rles) + bitmap_mask = maskUtils.decode(rle).astype(np.bool) + return bitmap_mask + + +def bitmap_to_polygon(bitmap): + """Convert masks from the form of bitmaps to polygons. + + Args: + bitmap (ndarray): masks in bitmap representation. + + Return: + list[ndarray]: the converted mask in polygon representation. + bool: whether the mask has holes. + """ + bitmap = np.ascontiguousarray(bitmap).astype(np.uint8) + # cv2.RETR_CCOMP: retrieves all of the contours and organizes them + # into a two-level hierarchy. At the top level, there are external + # boundaries of the components. At the second level, there are + # boundaries of the holes. If there is another contour inside a hole + # of a connected component, it is still put at the top level. + # cv2.CHAIN_APPROX_NONE: stores absolutely all the contour points. + outs = cv2.findContours(bitmap, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE) + contours = outs[-2] + hierarchy = outs[-1] + if hierarchy is None: + return [], False + # hierarchy[i]: 4 elements, for the indexes of next, previous, + # parent, or nested contours. If there is no corresponding contour, + # it will be -1. + with_hole = (hierarchy.reshape(-1, 4)[:, 3] >= 0).any() + contours = [c.reshape(-1, 2) for c in contours] + return contours, with_hole diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/utils.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/utils.py index a68312b17..90544b34f 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/utils.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/mask/utils.py @@ -1,4 +1,8 @@ +# Copyright (c) OpenMMLab. All rights reserved. import mmcv +import numpy as np +import pycocotools.mask as mask_util +import torch def split_combined_polys(polys, poly_lens, polys_per_mask): @@ -15,8 +19,8 @@ def split_combined_polys(polys, poly_lens, polys_per_mask): of each mask Returns: - list: a list (length = image num) of list (length = mask num) of - list (length = poly num) of numpy array + list: a list (length = image num) of list (length = mask num) of \ + list (length = poly num) of numpy array. """ mask_polys_list = [] for img_id in range(len(polys)): @@ -28,3 +32,58 @@ def split_combined_polys(polys, poly_lens, polys_per_mask): mask_polys = mmcv.slice_list(split_polys, polys_per_mask_single) mask_polys_list.append(mask_polys) return mask_polys_list + + +# TODO: move this function to more proper place +def encode_mask_results(mask_results): + """Encode bitmap mask to RLE code. + + Args: + mask_results (list | tuple[list]): bitmap mask results. + In mask scoring rcnn, mask_results is a tuple of (segm_results, + segm_cls_score). + + Returns: + list | tuple: RLE encoded mask. + """ + if isinstance(mask_results, tuple): # mask scoring + cls_segms, cls_mask_scores = mask_results + else: + cls_segms = mask_results + num_classes = len(cls_segms) + encoded_mask_results = [[] for _ in range(num_classes)] + for i in range(len(cls_segms)): + for cls_segm in cls_segms[i]: + encoded_mask_results[i].append( + mask_util.encode( + np.array( + cls_segm[:, :, np.newaxis], order='F', + dtype='uint8'))[0]) # encoded with RLE + if isinstance(mask_results, tuple): + return encoded_mask_results, cls_mask_scores + else: + return encoded_mask_results + + +def mask2bbox(masks): + """Obtain tight bounding boxes of binary masks. + + Args: + masks (Tensor): Binary mask of shape (n, h, w). + + Returns: + Tensor: Bboxe with shape (n, 4) of \ + positive region in binary mask. + """ + N = masks.shape[0] + bboxes = masks.new_zeros((N, 4), dtype=torch.float32) + x_any = torch.any(masks, dim=1) + y_any = torch.any(masks, dim=2) + for i in range(N): + x = torch.where(x_any[i, :])[0] + y = torch.where(y_any[i, :])[0] + if len(x) > 0 and len(y) > 0: + bboxes[i, :] = bboxes.new_tensor( + [x[0], y[0], x[-1] + 1, y[-1] + 1]) + + return bboxes diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/optimizers/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/optimizers/__init__.py new file mode 100644 index 000000000..e867d0761 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/optimizers/__init__.py @@ -0,0 +1,9 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .builder import OPTIMIZER_BUILDERS, build_optimizer +from .layer_decay_optimizer_constructor import \ + LearningRateDecayOptimizerConstructor + +__all__ = [ + 'LearningRateDecayOptimizerConstructor', 'OPTIMIZER_BUILDERS', + 'build_optimizer' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/optimizers/builder.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/optimizers/builder.py new file mode 100644 index 000000000..406dd9b4b --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/optimizers/builder.py @@ -0,0 +1,33 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import copy + +from mmcv.runner.optimizer import OPTIMIZER_BUILDERS as MMCV_OPTIMIZER_BUILDERS +from mmcv.utils import Registry, build_from_cfg + +OPTIMIZER_BUILDERS = Registry( + 'optimizer builder', parent=MMCV_OPTIMIZER_BUILDERS) + + +def build_optimizer_constructor(cfg): + constructor_type = cfg.get('type') + if constructor_type in OPTIMIZER_BUILDERS: + return build_from_cfg(cfg, OPTIMIZER_BUILDERS) + elif constructor_type in MMCV_OPTIMIZER_BUILDERS: + return build_from_cfg(cfg, MMCV_OPTIMIZER_BUILDERS) + else: + raise KeyError(f'{constructor_type} is not registered ' + 'in the optimizer builder registry.') + + +def build_optimizer(model, cfg): + optimizer_cfg = copy.deepcopy(cfg) + constructor_type = optimizer_cfg.pop('constructor', + 'DefaultOptimizerConstructor') + paramwise_cfg = optimizer_cfg.pop('paramwise_cfg', None) + optim_constructor = build_optimizer_constructor( + dict( + type=constructor_type, + optimizer_cfg=optimizer_cfg, + paramwise_cfg=paramwise_cfg)) + optimizer = optim_constructor(model) + return optimizer diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/optimizers/layer_decay_optimizer_constructor.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/optimizers/layer_decay_optimizer_constructor.py new file mode 100644 index 000000000..1bc3469e8 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/optimizers/layer_decay_optimizer_constructor.py @@ -0,0 +1,154 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import json + +from mmcv.runner import DefaultOptimizerConstructor, get_dist_info + +from mmdet.utils import get_root_logger +from .builder import OPTIMIZER_BUILDERS + + +def get_layer_id_for_convnext(var_name, max_layer_id): + """Get the layer id to set the different learning rates in ``layer_wise`` + decay_type. + + Args: + var_name (str): The key of the model. + max_layer_id (int): Maximum layer id. + + Returns: + int: The id number corresponding to different learning rate in + ``LearningRateDecayOptimizerConstructor``. + """ + + if var_name in ('backbone.cls_token', 'backbone.mask_token', + 'backbone.pos_embed'): + return 0 + elif var_name.startswith('backbone.downsample_layers'): + stage_id = int(var_name.split('.')[2]) + if stage_id == 0: + layer_id = 0 + elif stage_id == 1: + layer_id = 2 + elif stage_id == 2: + layer_id = 3 + elif stage_id == 3: + layer_id = max_layer_id + return layer_id + elif var_name.startswith('backbone.stages'): + stage_id = int(var_name.split('.')[2]) + block_id = int(var_name.split('.')[3]) + if stage_id == 0: + layer_id = 1 + elif stage_id == 1: + layer_id = 2 + elif stage_id == 2: + layer_id = 3 + block_id // 3 + elif stage_id == 3: + layer_id = max_layer_id + return layer_id + else: + return max_layer_id + 1 + + +def get_stage_id_for_convnext(var_name, max_stage_id): + """Get the stage id to set the different learning rates in ``stage_wise`` + decay_type. + + Args: + var_name (str): The key of the model. + max_stage_id (int): Maximum stage id. + + Returns: + int: The id number corresponding to different learning rate in + ``LearningRateDecayOptimizerConstructor``. + """ + + if var_name in ('backbone.cls_token', 'backbone.mask_token', + 'backbone.pos_embed'): + return 0 + elif var_name.startswith('backbone.downsample_layers'): + return 0 + elif var_name.startswith('backbone.stages'): + stage_id = int(var_name.split('.')[2]) + return stage_id + 1 + else: + return max_stage_id - 1 + + +@OPTIMIZER_BUILDERS.register_module() +class LearningRateDecayOptimizerConstructor(DefaultOptimizerConstructor): + # Different learning rates are set for different layers of backbone. + # Note: Currently, this optimizer constructor is built for ConvNeXt. + + def add_params(self, params, module, **kwargs): + """Add all parameters of module to the params list. + + The parameters of the given module will be added to the list of param + groups, with specific rules defined by paramwise_cfg. + + Args: + params (list[dict]): A list of param groups, it will be modified + in place. + module (nn.Module): The module to be added. + """ + logger = get_root_logger() + + parameter_groups = {} + logger.info(f'self.paramwise_cfg is {self.paramwise_cfg}') + num_layers = self.paramwise_cfg.get('num_layers') + 2 + decay_rate = self.paramwise_cfg.get('decay_rate') + decay_type = self.paramwise_cfg.get('decay_type', 'layer_wise') + logger.info('Build LearningRateDecayOptimizerConstructor ' + f'{decay_type} {decay_rate} - {num_layers}') + weight_decay = self.base_wd + for name, param in module.named_parameters(): + if not param.requires_grad: + continue # frozen weights + if len(param.shape) == 1 or name.endswith('.bias') or name in ( + 'pos_embed', 'cls_token'): + group_name = 'no_decay' + this_weight_decay = 0. + else: + group_name = 'decay' + this_weight_decay = weight_decay + if 'layer_wise' in decay_type: + if 'ConvNeXt' in module.backbone.__class__.__name__: + layer_id = get_layer_id_for_convnext( + name, self.paramwise_cfg.get('num_layers')) + logger.info(f'set param {name} as id {layer_id}') + else: + raise NotImplementedError() + elif decay_type == 'stage_wise': + if 'ConvNeXt' in module.backbone.__class__.__name__: + layer_id = get_stage_id_for_convnext(name, num_layers) + logger.info(f'set param {name} as id {layer_id}') + else: + raise NotImplementedError() + group_name = f'layer_{layer_id}_{group_name}' + + if group_name not in parameter_groups: + scale = decay_rate**(num_layers - layer_id - 1) + + parameter_groups[group_name] = { + 'weight_decay': this_weight_decay, + 'params': [], + 'param_names': [], + 'lr_scale': scale, + 'group_name': group_name, + 'lr': scale * self.base_lr, + } + + parameter_groups[group_name]['params'].append(param) + parameter_groups[group_name]['param_names'].append(name) + rank, _ = get_dist_info() + if rank == 0: + to_display = {} + for key in parameter_groups: + to_display[key] = { + 'param_names': parameter_groups[key]['param_names'], + 'lr_scale': parameter_groups[key]['lr_scale'], + 'lr': parameter_groups[key]['lr'], + 'weight_decay': parameter_groups[key]['weight_decay'], + } + logger.info(f'Param groups = {json.dumps(to_display, indent=2)}') + params.extend(parameter_groups.values()) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/__init__.py index 73fb1990c..00376bd49 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/__init__.py @@ -1,9 +1,10 @@ -from .bbox_nms import multiclass_nms -from .matrix_nms import matrix_nms +# Copyright (c) OpenMMLab. All rights reserved. +from .bbox_nms import fast_nms, multiclass_nms +from .matrix_nms import mask_matrix_nms from .merge_augs import (merge_aug_bboxes, merge_aug_masks, merge_aug_proposals, merge_aug_scores) __all__ = [ 'multiclass_nms', 'merge_aug_proposals', 'merge_aug_bboxes', - 'merge_aug_scores', 'merge_aug_masks', 'matrix_nms' + 'merge_aug_scores', 'merge_aug_masks', 'mask_matrix_nms', 'fast_nms' ] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/bbox_nms.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/bbox_nms.py index ce3794c64..4fcf57bb5 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/bbox_nms.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/bbox_nms.py @@ -1,6 +1,8 @@ +# Copyright (c) OpenMMLab. All rights reserved. import torch +from mmcv.ops.nms import batched_nms -from mmdet.ops.nms import nms_wrapper +from mmdet.core.bbox.iou_calculators import bbox_overlaps def multiclass_nms(multi_bboxes, @@ -8,59 +10,162 @@ def multiclass_nms(multi_bboxes, score_thr, nms_cfg, max_num=-1, - score_factors=None): + score_factors=None, + return_inds=False): """NMS for multi-class bboxes. Args: multi_bboxes (Tensor): shape (n, #class*4) or (n, 4) - multi_scores (Tensor): shape (n, #class), where the 0th column + multi_scores (Tensor): shape (n, #class), where the last column contains scores of the background class, but this will be ignored. score_thr (float): bbox threshold, bboxes with scores lower than it will not be considered. - nms_thr (float): NMS IoU threshold - max_num (int): if there are more than max_num bboxes after NMS, - only top max_num will be kept. - score_factors (Tensor): The factors multiplied to scores before - applying NMS + nms_cfg (dict): a dict that contains the arguments of nms operations + max_num (int, optional): if there are more than max_num bboxes after + NMS, only top max_num will be kept. Default to -1. + score_factors (Tensor, optional): The factors multiplied to scores + before applying NMS. Default to None. + return_inds (bool, optional): Whether return the indices of kept + bboxes. Default to False. Returns: - tuple: (bboxes, labels), tensors of shape (k, 5) and (k, 1). Labels - are 0-based. + tuple: (dets, labels, indices (optional)), tensors of shape (k, 5), + (k), and (k). Dets are boxes with scores. Labels are 0-based. """ - num_classes = multi_scores.shape[1] - bboxes, labels = [], [] - nms_cfg_ = nms_cfg.copy() - nms_type = nms_cfg_.pop('type', 'nms') - nms_op = getattr(nms_wrapper, nms_type) - for i in range(1, num_classes): - cls_inds = multi_scores[:, i] > score_thr - if not cls_inds.any(): - continue - # get bboxes and scores of this class - if multi_bboxes.shape[1] == 4: - _bboxes = multi_bboxes[cls_inds, :] + num_classes = multi_scores.size(1) - 1 + # exclude background category + if multi_bboxes.shape[1] > 4: + bboxes = multi_bboxes.view(multi_scores.size(0), -1, 4) + else: + bboxes = multi_bboxes[:, None].expand( + multi_scores.size(0), num_classes, 4) + + scores = multi_scores[:, :-1] + + labels = torch.arange(num_classes, dtype=torch.long, device=scores.device) + labels = labels.view(1, -1).expand_as(scores) + + bboxes = bboxes.reshape(-1, 4) + scores = scores.reshape(-1) + labels = labels.reshape(-1) + + if not torch.onnx.is_in_onnx_export(): + # NonZero not supported in TensorRT + # remove low scoring boxes + valid_mask = scores > score_thr + # multiply score_factor after threshold to preserve more bboxes, improve + # mAP by 1% for YOLOv3 + if score_factors is not None: + # expand the shape to match original shape of score + score_factors = score_factors.view(-1, 1).expand( + multi_scores.size(0), num_classes) + score_factors = score_factors.reshape(-1) + scores = scores * score_factors + + if not torch.onnx.is_in_onnx_export(): + # NonZero not supported in TensorRT + inds = valid_mask.nonzero(as_tuple=False).squeeze(1) + bboxes, scores, labels = bboxes[inds], scores[inds], labels[inds] + else: + # TensorRT NMS plugin has invalid output filled with -1 + # add dummy data to make detection output correct. + bboxes = torch.cat([bboxes, bboxes.new_zeros(1, 4)], dim=0) + scores = torch.cat([scores, scores.new_zeros(1)], dim=0) + labels = torch.cat([labels, labels.new_zeros(1)], dim=0) + + if bboxes.numel() == 0: + if torch.onnx.is_in_onnx_export(): + raise RuntimeError('[ONNX Error] Can not record NMS ' + 'as it has not been executed this time') + dets = torch.cat([bboxes, scores[:, None]], -1) + if return_inds: + return dets, labels, inds else: - _bboxes = multi_bboxes[cls_inds, i * 4:(i + 1) * 4] - _scores = multi_scores[cls_inds, i] - if score_factors is not None: - _scores *= score_factors[cls_inds] - cls_dets = torch.cat([_bboxes, _scores[:, None]], dim=1) - cls_dets, _ = nms_op(cls_dets, **nms_cfg_) - cls_labels = multi_bboxes.new_full((cls_dets.shape[0], ), - i - 1, - dtype=torch.long) - bboxes.append(cls_dets) - labels.append(cls_labels) - if bboxes: - bboxes = torch.cat(bboxes) - labels = torch.cat(labels) - if bboxes.shape[0] > max_num: - _, inds = bboxes[:, -1].sort(descending=True) - inds = inds[:max_num] - bboxes = bboxes[inds] - labels = labels[inds] + return dets, labels + + dets, keep = batched_nms(bboxes, scores, labels, nms_cfg) + + if max_num > 0: + dets = dets[:max_num] + keep = keep[:max_num] + + if return_inds: + return dets, labels[keep], inds[keep] else: - bboxes = multi_bboxes.new_zeros((0, 5)) - labels = multi_bboxes.new_zeros((0, ), dtype=torch.long) + return dets, labels[keep] + + +def fast_nms(multi_bboxes, + multi_scores, + multi_coeffs, + score_thr, + iou_thr, + top_k, + max_num=-1): + """Fast NMS in `YOLACT `_. + + Fast NMS allows already-removed detections to suppress other detections so + that every instance can be decided to be kept or discarded in parallel, + which is not possible in traditional NMS. This relaxation allows us to + implement Fast NMS entirely in standard GPU-accelerated matrix operations. + + Args: + multi_bboxes (Tensor): shape (n, #class*4) or (n, 4) + multi_scores (Tensor): shape (n, #class+1), where the last column + contains scores of the background class, but this will be ignored. + multi_coeffs (Tensor): shape (n, #class*coeffs_dim). + score_thr (float): bbox threshold, bboxes with scores lower than it + will not be considered. + iou_thr (float): IoU threshold to be considered as conflicted. + top_k (int): if there are more than top_k bboxes before NMS, + only top top_k will be kept. + max_num (int): if there are more than max_num bboxes after NMS, + only top max_num will be kept. If -1, keep all the bboxes. + Default: -1. + + Returns: + tuple: (dets, labels, coefficients), tensors of shape (k, 5), (k, 1), + and (k, coeffs_dim). Dets are boxes with scores. + Labels are 0-based. + """ + + scores = multi_scores[:, :-1].t() # [#class, n] + scores, idx = scores.sort(1, descending=True) + + idx = idx[:, :top_k].contiguous() + scores = scores[:, :top_k] # [#class, topk] + num_classes, num_dets = idx.size() + boxes = multi_bboxes[idx.view(-1), :].view(num_classes, num_dets, 4) + coeffs = multi_coeffs[idx.view(-1), :].view(num_classes, num_dets, -1) + + iou = bbox_overlaps(boxes, boxes) # [#class, topk, topk] + iou.triu_(diagonal=1) + iou_max, _ = iou.max(dim=1) + + # Now just filter out the ones higher than the threshold + keep = iou_max <= iou_thr + + # Second thresholding introduces 0.2 mAP gain at negligible time cost + keep *= scores > score_thr + + # Assign each kept detection to its corresponding class + classes = torch.arange( + num_classes, device=boxes.device)[:, None].expand_as(keep) + classes = classes[keep] + + boxes = boxes[keep] + coeffs = coeffs[keep] + scores = scores[keep] + + # Only keep the top max_num highest scores across all classes + scores, idx = scores.sort(0, descending=True) + if max_num > 0: + idx = idx[:max_num] + scores = scores[:max_num] + + classes = classes[idx] + boxes = boxes[idx] + coeffs = coeffs[idx] - return bboxes, labels + cls_dets = torch.cat([boxes, scores[:, None]], dim=1) + return cls_dets, classes, coeffs diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/matrix_nms.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/matrix_nms.py index cbbe4209f..9dc8c4f74 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/matrix_nms.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/matrix_nms.py @@ -1,117 +1,121 @@ +# Copyright (c) OpenMMLab. All rights reserved. import torch -def matrix_nms(seg_masks, cate_labels, cate_scores, kernel='gaussian', sigma=2.0, sum_masks=None): +def mask_matrix_nms(masks, + labels, + scores, + filter_thr=-1, + nms_pre=-1, + max_num=-1, + kernel='gaussian', + sigma=2.0, + mask_area=None): """Matrix NMS for multi-class masks. Args: - seg_masks (Tensor): shape (n, h, w) - cate_labels (Tensor): shape (n), mask labels in descending order - cate_scores (Tensor): shape (n), mask scores in descending order - kernel (str): 'linear' or 'gauss' - sigma (float): std in gaussian method - sum_masks (Tensor): The sum of seg_masks + masks (Tensor): Has shape (num_instances, h, w) + labels (Tensor): Labels of corresponding masks, + has shape (num_instances,). + scores (Tensor): Mask scores of corresponding masks, + has shape (num_instances). + filter_thr (float): Score threshold to filter the masks + after matrix nms. Default: -1, which means do not + use filter_thr. + nms_pre (int): The max number of instances to do the matrix nms. + Default: -1, which means do not use nms_pre. + max_num (int, optional): If there are more than max_num masks after + matrix, only top max_num will be kept. Default: -1, which means + do not use max_num. + kernel (str): 'linear' or 'gaussian'. + sigma (float): std in gaussian method. + mask_area (Tensor): The sum of seg_masks. Returns: - Tensor: cate_scores_update, tensors of shape (n) + tuple(Tensor): Processed mask results. + + - scores (Tensor): Updated scores, has shape (n,). + - labels (Tensor): Remained labels, has shape (n,). + - masks (Tensor): Remained masks, has shape (n, w, h). + - keep_inds (Tensor): The indices number of + the remaining mask in the input mask, has shape (n,). """ - n_samples = len(cate_labels) - if n_samples == 0: - return [] - if sum_masks is None: - sum_masks = seg_masks.sum((1, 2)).float() - seg_masks = seg_masks.reshape(n_samples, -1).float() + assert len(labels) == len(masks) == len(scores) + if len(labels) == 0: + return scores.new_zeros(0), labels.new_zeros(0), masks.new_zeros( + 0, *masks.shape[-2:]), labels.new_zeros(0) + if mask_area is None: + mask_area = masks.sum((1, 2)).float() + else: + assert len(masks) == len(mask_area) + + # sort and keep top nms_pre + scores, sort_inds = torch.sort(scores, descending=True) + + keep_inds = sort_inds + if nms_pre > 0 and len(sort_inds) > nms_pre: + sort_inds = sort_inds[:nms_pre] + keep_inds = keep_inds[:nms_pre] + scores = scores[:nms_pre] + masks = masks[sort_inds] + mask_area = mask_area[sort_inds] + labels = labels[sort_inds] + + num_masks = len(labels) + flatten_masks = masks.reshape(num_masks, -1).float() # inter. - inter_matrix = torch.mm(seg_masks, seg_masks.transpose(1, 0)) - # union. - sum_masks_x = sum_masks.expand(n_samples, n_samples) - # iou. - iou_matrix = (inter_matrix / (sum_masks_x + sum_masks_x.transpose(1, 0) - inter_matrix)).triu(diagonal=1) + inter_matrix = torch.mm(flatten_masks, flatten_masks.transpose(1, 0)) + expanded_mask_area = mask_area.expand(num_masks, num_masks) + # Upper triangle iou matrix. + iou_matrix = (inter_matrix / + (expanded_mask_area + expanded_mask_area.transpose(1, 0) - + inter_matrix)).triu(diagonal=1) # label_specific matrix. - cate_labels_x = cate_labels.expand(n_samples, n_samples) - label_matrix = (cate_labels_x == cate_labels_x.transpose(1, 0)).float().triu(diagonal=1) + expanded_labels = labels.expand(num_masks, num_masks) + # Upper triangle label matrix. + label_matrix = (expanded_labels == expanded_labels.transpose( + 1, 0)).triu(diagonal=1) # IoU compensation compensate_iou, _ = (iou_matrix * label_matrix).max(0) - compensate_iou = compensate_iou.expand(n_samples, n_samples).transpose(1, 0) + compensate_iou = compensate_iou.expand(num_masks, + num_masks).transpose(1, 0) - # IoU decay + # IoU decay decay_iou = iou_matrix * label_matrix - # matrix nms + # Calculate the decay_coefficient if kernel == 'gaussian': - decay_matrix = torch.exp(-1 * sigma * (decay_iou ** 2)) - compensate_matrix = torch.exp(-1 * sigma * (compensate_iou ** 2)) + decay_matrix = torch.exp(-1 * sigma * (decay_iou**2)) + compensate_matrix = torch.exp(-1 * sigma * (compensate_iou**2)) decay_coefficient, _ = (decay_matrix / compensate_matrix).min(0) elif kernel == 'linear': - decay_matrix = (1-decay_iou)/(1-compensate_iou) + decay_matrix = (1 - decay_iou) / (1 - compensate_iou) decay_coefficient, _ = decay_matrix.min(0) else: - raise NotImplementedError - + raise NotImplementedError( + f'{kernel} kernel is not supported in matrix nms!') # update the score. - cate_scores_update = cate_scores * decay_coefficient - return cate_scores_update + scores = scores * decay_coefficient + if filter_thr > 0: + keep = scores >= filter_thr + keep_inds = keep_inds[keep] + if not keep.any(): + return scores.new_zeros(0), labels.new_zeros(0), masks.new_zeros( + 0, *masks.shape[-2:]), labels.new_zeros(0) + masks = masks[keep] + scores = scores[keep] + labels = labels[keep] -def multiclass_nms(multi_bboxes, - multi_scores, - score_thr, - nms_cfg, - max_num=-1, - score_factors=None): - """NMS for multi-class bboxes. - - Args: - multi_bboxes (Tensor): shape (n, #class*4) or (n, 4) - multi_scores (Tensor): shape (n, #class), where the 0th column - contains scores of the background class, but this will be ignored. - score_thr (float): bbox threshold, bboxes with scores lower than it - will not be considered. - nms_thr (float): NMS IoU threshold - max_num (int): if there are more than max_num bboxes after NMS, - only top max_num will be kept. - score_factors (Tensor): The factors multiplied to scores before - applying NMS - - Returns: - tuple: (bboxes, labels), tensors of shape (k, 5) and (k, 1). Labels - are 0-based. - """ - num_classes = multi_scores.shape[1] - bboxes, labels = [], [] - nms_cfg_ = nms_cfg.copy() - nms_type = nms_cfg_.pop('type', 'nms') - nms_op = getattr(nms_wrapper, nms_type) - for i in range(1, num_classes): - cls_inds = multi_scores[:, i] > score_thr - if not cls_inds.any(): - continue - # get bboxes and scores of this class - if multi_bboxes.shape[1] == 4: - _bboxes = multi_bboxes[cls_inds, :] - else: - _bboxes = multi_bboxes[cls_inds, i * 4:(i + 1) * 4] - _scores = multi_scores[cls_inds, i] - if score_factors is not None: - _scores *= score_factors[cls_inds] - cls_dets = torch.cat([_bboxes, _scores[:, None]], dim=1) - cls_dets, _ = nms_op(cls_dets, **nms_cfg_) - cls_labels = multi_bboxes.new_full((cls_dets.shape[0], ), - i - 1, - dtype=torch.long) - bboxes.append(cls_dets) - labels.append(cls_labels) - if bboxes: - bboxes = torch.cat(bboxes) - labels = torch.cat(labels) - if bboxes.shape[0] > max_num: - _, inds = bboxes[:, -1].sort(descending=True) - inds = inds[:max_num] - bboxes = bboxes[inds] - labels = labels[inds] - else: - bboxes = multi_bboxes.new_zeros((0, 5)) - labels = multi_bboxes.new_zeros((0, ), dtype=torch.long) + # sort and keep top max_num + scores, sort_inds = torch.sort(scores, descending=True) + keep_inds = keep_inds[sort_inds] + if max_num > 0 and len(sort_inds) > max_num: + sort_inds = sort_inds[:max_num] + keep_inds = keep_inds[:max_num] + scores = scores[:max_num] + masks = masks[sort_inds] + labels = labels[sort_inds] - return bboxes, labels + return scores, labels, masks, keep_inds diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/merge_augs.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/merge_augs.py index a0214d63f..2ac4603a1 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/merge_augs.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/post_processing/merge_augs.py @@ -1,11 +1,16 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import copy +import warnings + import numpy as np import torch +from mmcv import ConfigDict +from mmcv.ops import nms -from mmdet.ops import nms from ..bbox import bbox_mapping_back -def merge_aug_proposals(aug_proposals, img_metas, rpn_test_cfg): +def merge_aug_proposals(aug_proposals, img_metas, cfg): """Merge augmented proposals (multiscale, flip, etc.) Args: @@ -14,30 +19,63 @@ def merge_aug_proposals(aug_proposals, img_metas, rpn_test_cfg): original image size. img_metas (list[dict]): list of image info dict where each dict has: - 'img_shape', 'scale_factor', 'flip', and my also contain + 'img_shape', 'scale_factor', 'flip', and may also contain 'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'. For details on the values of these keys see `mmdet/datasets/pipelines/formatting.py:Collect`. - rpn_test_cfg (dict): rpn test config. + cfg (dict): rpn test config. Returns: Tensor: shape (n, 4), proposals corresponding to original image scale. """ + + cfg = copy.deepcopy(cfg) + + # deprecate arguments warning + if 'nms' not in cfg or 'max_num' in cfg or 'nms_thr' in cfg: + warnings.warn( + 'In rpn_proposal or test_cfg, ' + 'nms_thr has been moved to a dict named nms as ' + 'iou_threshold, max_num has been renamed as max_per_img, ' + 'name of original arguments and the way to specify ' + 'iou_threshold of NMS will be deprecated.') + if 'nms' not in cfg: + cfg.nms = ConfigDict(dict(type='nms', iou_threshold=cfg.nms_thr)) + if 'max_num' in cfg: + if 'max_per_img' in cfg: + assert cfg.max_num == cfg.max_per_img, f'You set max_num and ' \ + f'max_per_img at the same time, but get {cfg.max_num} ' \ + f'and {cfg.max_per_img} respectively' \ + f'Please delete max_num which will be deprecated.' + else: + cfg.max_per_img = cfg.max_num + if 'nms_thr' in cfg: + assert cfg.nms.iou_threshold == cfg.nms_thr, f'You set ' \ + f'iou_threshold in nms and ' \ + f'nms_thr at the same time, but get ' \ + f'{cfg.nms.iou_threshold} and {cfg.nms_thr}' \ + f' respectively. Please delete the nms_thr ' \ + f'which will be deprecated.' + recovered_proposals = [] for proposals, img_info in zip(aug_proposals, img_metas): img_shape = img_info['img_shape'] scale_factor = img_info['scale_factor'] flip = img_info['flip'] + flip_direction = img_info['flip_direction'] _proposals = proposals.clone() _proposals[:, :4] = bbox_mapping_back(_proposals[:, :4], img_shape, - scale_factor, flip) + scale_factor, flip, + flip_direction) recovered_proposals.append(_proposals) aug_proposals = torch.cat(recovered_proposals, dim=0) - merged_proposals, _ = nms(aug_proposals, rpn_test_cfg.nms_thr) + merged_proposals, _ = nms(aug_proposals[:, :4].contiguous(), + aug_proposals[:, -1].contiguous(), + cfg.nms.iou_threshold) scores = merged_proposals[:, 4] _, order = scores.sort(0, descending=True) - num = min(rpn_test_cfg.max_num, merged_proposals.shape[0]) + num = min(cfg.max_per_img, merged_proposals.shape[0]) order = order[:num] merged_proposals = merged_proposals[order, :] return merged_proposals @@ -60,7 +98,9 @@ def merge_aug_bboxes(aug_bboxes, aug_scores, img_metas, rcnn_test_cfg): img_shape = img_info[0]['img_shape'] scale_factor = img_info[0]['scale_factor'] flip = img_info[0]['flip'] - bboxes = bbox_mapping_back(bboxes, img_shape, scale_factor, flip) + flip_direction = img_info[0]['flip_direction'] + bboxes = bbox_mapping_back(bboxes, img_shape, scale_factor, flip, + flip_direction) recovered_bboxes.append(bboxes) bboxes = torch.stack(recovered_bboxes).mean(dim=0) if aug_scores is None: @@ -89,10 +129,23 @@ def merge_aug_masks(aug_masks, img_metas, rcnn_test_cfg, weights=None): Returns: tuple: (bboxes, scores) """ - recovered_masks = [ - mask if not img_info[0]['flip'] else mask[..., ::-1] - for mask, img_info in zip(aug_masks, img_metas) - ] + recovered_masks = [] + for mask, img_info in zip(aug_masks, img_metas): + flip = img_info[0]['flip'] + if flip: + flip_direction = img_info[0]['flip_direction'] + if flip_direction == 'horizontal': + mask = mask[:, :, :, ::-1] + elif flip_direction == 'vertical': + mask = mask[:, :, ::-1, :] + elif flip_direction == 'diagonal': + mask = mask[:, :, :, ::-1] + mask = mask[:, :, ::-1, :] + else: + raise ValueError( + f"Invalid flipping direction '{flip_direction}'") + recovered_masks.append(mask) + if weights is None: merged_masks = np.mean(recovered_masks, axis=0) else: diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/__init__.py index cc999ea10..3f0d07081 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/__init__.py @@ -1,7 +1,13 @@ -from .dist_utils import DistOptimizerHook, allreduce_grads -from .misc import multi_apply, tensor2imgs, unmap +# Copyright (c) OpenMMLab. All rights reserved. +from .dist_utils import (DistOptimizerHook, all_reduce_dict, allreduce_grads, + reduce_mean, sync_random_seed) +from .misc import (center_of_mass, filter_scores_and_topk, flip_tensor, + generate_coordinate, mask2ndarray, multi_apply, + select_single_mlvl, unmap) __all__ = [ - 'allreduce_grads', 'DistOptimizerHook', 'tensor2imgs', 'unmap', - 'multi_apply' + 'allreduce_grads', 'DistOptimizerHook', 'reduce_mean', 'multi_apply', + 'unmap', 'mask2ndarray', 'flip_tensor', 'all_reduce_dict', + 'center_of_mass', 'generate_coordinate', 'select_single_mlvl', + 'filter_scores_and_topk', 'sync_random_seed' ] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/dist_utils.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/dist_utils.py index be830b6a2..8760774fd 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/dist_utils.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/dist_utils.py @@ -1,7 +1,13 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import functools +import pickle +import warnings from collections import OrderedDict +import numpy as np +import torch import torch.distributed as dist -from mmcv.runner import OptimizerHook +from mmcv.runner import OptimizerHook, get_dist_info from torch._utils import (_flatten_dense_tensors, _take_tensors, _unflatten_dense_tensors) @@ -29,6 +35,15 @@ def _allreduce_coalesced(tensors, world_size, bucket_size_mb=-1): def allreduce_grads(params, coalesce=True, bucket_size_mb=-1): + """Allreduce gradients. + + Args: + params (list[torch.Parameters]): List of parameters of a model + coalesce (bool, optional): Whether allreduce parameters as a whole. + Defaults to True. + bucket_size_mb (int, optional): Size of bucket, the unit is MB. + Defaults to -1. + """ grads = [ param.grad.data for param in params if param.requires_grad and param.grad is not None @@ -42,17 +57,137 @@ def allreduce_grads(params, coalesce=True, bucket_size_mb=-1): class DistOptimizerHook(OptimizerHook): + """Deprecated optimizer hook for distributed training.""" + + def __init__(self, *args, **kwargs): + warnings.warn('"DistOptimizerHook" is deprecated, please switch to' + '"mmcv.runner.OptimizerHook".') + super().__init__(*args, **kwargs) + + +def reduce_mean(tensor): + """"Obtain the mean of tensor on different GPUs.""" + if not (dist.is_available() and dist.is_initialized()): + return tensor + tensor = tensor.clone() + dist.all_reduce(tensor.div_(dist.get_world_size()), op=dist.ReduceOp.SUM) + return tensor + + +def obj2tensor(pyobj, device='cuda'): + """Serialize picklable python object to tensor.""" + storage = torch.ByteStorage.from_buffer(pickle.dumps(pyobj)) + return torch.ByteTensor(storage).to(device=device) + + +def tensor2obj(tensor): + """Deserialize tensor to picklable python object.""" + return pickle.loads(tensor.cpu().numpy().tobytes()) + + +@functools.lru_cache() +def _get_global_gloo_group(): + """Return a process group based on gloo backend, containing all the ranks + The result is cached.""" + if dist.get_backend() == 'nccl': + return dist.new_group(backend='gloo') + else: + return dist.group.WORLD + + +def all_reduce_dict(py_dict, op='sum', group=None, to_float=True): + """Apply all reduce function for python dict object. + + The code is modified from https://github.com/Megvii- + BaseDetection/YOLOX/blob/main/yolox/utils/allreduce_norm.py. + + NOTE: make sure that py_dict in different ranks has the same keys and + the values should be in the same shape. Currently only supports + nccl backend. + + Args: + py_dict (dict): Dict to be applied all reduce op. + op (str): Operator, could be 'sum' or 'mean'. Default: 'sum' + group (:obj:`torch.distributed.group`, optional): Distributed group, + Default: None. + to_float (bool): Whether to convert all values of dict to float. + Default: True. + + Returns: + OrderedDict: reduced python dict object. + """ + warnings.warn( + 'group` is deprecated. Currently only supports NCCL backend.') + _, world_size = get_dist_info() + if world_size == 1: + return py_dict - def __init__(self, grad_clip=None, coalesce=True, bucket_size_mb=-1): - self.grad_clip = grad_clip - self.coalesce = coalesce - self.bucket_size_mb = bucket_size_mb - - def after_train_iter(self, runner): - runner.optimizer.zero_grad() - runner.outputs['loss'].backward() - allreduce_grads(runner.model.parameters(), self.coalesce, - self.bucket_size_mb) - if self.grad_clip is not None: - self.clip_grads(runner.model.parameters()) - runner.optimizer.step() + # all reduce logic across different devices. + py_key = list(py_dict.keys()) + if not isinstance(py_dict, OrderedDict): + py_key_tensor = obj2tensor(py_key) + dist.broadcast(py_key_tensor, src=0) + py_key = tensor2obj(py_key_tensor) + + tensor_shapes = [py_dict[k].shape for k in py_key] + tensor_numels = [py_dict[k].numel() for k in py_key] + + if to_float: + warnings.warn('Note: the "to_float" is True, you need to ' + 'ensure that the behavior is reasonable.') + flatten_tensor = torch.cat( + [py_dict[k].flatten().float() for k in py_key]) + else: + flatten_tensor = torch.cat([py_dict[k].flatten() for k in py_key]) + + dist.all_reduce(flatten_tensor, op=dist.ReduceOp.SUM) + if op == 'mean': + flatten_tensor /= world_size + + split_tensors = [ + x.reshape(shape) for x, shape in zip( + torch.split(flatten_tensor, tensor_numels), tensor_shapes) + ] + out_dict = {k: v for k, v in zip(py_key, split_tensors)} + if isinstance(py_dict, OrderedDict): + out_dict = OrderedDict(out_dict) + return out_dict + + +def sync_random_seed(seed=None, device='cuda'): + """Make sure different ranks share the same seed. + + All workers must call this function, otherwise it will deadlock. + This method is generally used in `DistributedSampler`, + because the seed should be identical across all processes + in the distributed group. + + In distributed sampling, different ranks should sample non-overlapped + data in the dataset. Therefore, this function is used to make sure that + each rank shuffles the data indices in the same order based + on the same seed. Then different ranks could use different indices + to select non-overlapped data from the same data list. + + Args: + seed (int, Optional): The seed. Default to None. + device (str): The device where the seed will be put on. + Default to 'cuda'. + + Returns: + int: Seed to be used. + """ + if seed is None: + seed = np.random.randint(2**31) + assert isinstance(seed, int) + + rank, world_size = get_dist_info() + + if world_size == 1: + return seed + + if rank == 0: + random_num = torch.tensor(seed, dtype=torch.int32, device=device) + else: + random_num = torch.tensor(0, dtype=torch.int32, device=device) + dist.broadcast(random_num, src=0) + return random_num.item() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/misc.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/misc.py index 262f168e6..14cb745e3 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/misc.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/utils/misc.py @@ -1,37 +1,208 @@ +# Copyright (c) OpenMMLab. All rights reserved. from functools import partial -import mmcv import numpy as np +import torch from six.moves import map, zip - -def tensor2imgs(tensor, mean=(0, 0, 0), std=(1, 1, 1), to_rgb=True): - num_imgs = tensor.size(0) - mean = np.array(mean, dtype=np.float32) - std = np.array(std, dtype=np.float32) - imgs = [] - for img_id in range(num_imgs): - img = tensor[img_id, ...].cpu().numpy().transpose(1, 2, 0) - img = mmcv.imdenormalize( - img, mean, std, to_bgr=to_rgb).astype(np.uint8) - imgs.append(np.ascontiguousarray(img)) - return imgs +from ..mask.structures import BitmapMasks, PolygonMasks def multi_apply(func, *args, **kwargs): + """Apply function to a list of arguments. + + Note: + This function applies the ``func`` to multiple inputs and + map the multiple outputs of the ``func`` into different + list. Each list contains the same type of outputs corresponding + to different inputs. + + Args: + func (Function): A function that will be applied to a list of + arguments + + Returns: + tuple(list): A tuple containing multiple list, each list contains \ + a kind of returned results by the function + """ pfunc = partial(func, **kwargs) if kwargs else func map_results = map(pfunc, *args) return tuple(map(list, zip(*map_results))) def unmap(data, count, inds, fill=0): - """ Unmap a subset of item (data) back to the original set of items (of - size count) """ + """Unmap a subset of item (data) back to the original set of items (of size + count)""" if data.dim() == 1: ret = data.new_full((count, ), fill) - ret[inds] = data + ret[inds.type(torch.bool)] = data else: new_size = (count, ) + data.size()[1:] ret = data.new_full(new_size, fill) - ret[inds, :] = data + ret[inds.type(torch.bool), :] = data return ret + + +def mask2ndarray(mask): + """Convert Mask to ndarray.. + + Args: + mask (:obj:`BitmapMasks` or :obj:`PolygonMasks` or + torch.Tensor or np.ndarray): The mask to be converted. + + Returns: + np.ndarray: Ndarray mask of shape (n, h, w) that has been converted + """ + if isinstance(mask, (BitmapMasks, PolygonMasks)): + mask = mask.to_ndarray() + elif isinstance(mask, torch.Tensor): + mask = mask.detach().cpu().numpy() + elif not isinstance(mask, np.ndarray): + raise TypeError(f'Unsupported {type(mask)} data type') + return mask + + +def flip_tensor(src_tensor, flip_direction): + """flip tensor base on flip_direction. + + Args: + src_tensor (Tensor): input feature map, shape (B, C, H, W). + flip_direction (str): The flipping direction. Options are + 'horizontal', 'vertical', 'diagonal'. + + Returns: + out_tensor (Tensor): Flipped tensor. + """ + assert src_tensor.ndim == 4 + valid_directions = ['horizontal', 'vertical', 'diagonal'] + assert flip_direction in valid_directions + if flip_direction == 'horizontal': + out_tensor = torch.flip(src_tensor, [3]) + elif flip_direction == 'vertical': + out_tensor = torch.flip(src_tensor, [2]) + else: + out_tensor = torch.flip(src_tensor, [2, 3]) + return out_tensor + + +def select_single_mlvl(mlvl_tensors, batch_id, detach=True): + """Extract a multi-scale single image tensor from a multi-scale batch + tensor based on batch index. + + Note: The default value of detach is True, because the proposal gradient + needs to be detached during the training of the two-stage model. E.g + Cascade Mask R-CNN. + + Args: + mlvl_tensors (list[Tensor]): Batch tensor for all scale levels, + each is a 4D-tensor. + batch_id (int): Batch index. + detach (bool): Whether detach gradient. Default True. + + Returns: + list[Tensor]: Multi-scale single image tensor. + """ + assert isinstance(mlvl_tensors, (list, tuple)) + num_levels = len(mlvl_tensors) + + if detach: + mlvl_tensor_list = [ + mlvl_tensors[i][batch_id].detach() for i in range(num_levels) + ] + else: + mlvl_tensor_list = [ + mlvl_tensors[i][batch_id] for i in range(num_levels) + ] + return mlvl_tensor_list + + +def filter_scores_and_topk(scores, score_thr, topk, results=None): + """Filter results using score threshold and topk candidates. + + Args: + scores (Tensor): The scores, shape (num_bboxes, K). + score_thr (float): The score filter threshold. + topk (int): The number of topk candidates. + results (dict or list or Tensor, Optional): The results to + which the filtering rule is to be applied. The shape + of each item is (num_bboxes, N). + + Returns: + tuple: Filtered results + + - scores (Tensor): The scores after being filtered, \ + shape (num_bboxes_filtered, ). + - labels (Tensor): The class labels, shape \ + (num_bboxes_filtered, ). + - anchor_idxs (Tensor): The anchor indexes, shape \ + (num_bboxes_filtered, ). + - filtered_results (dict or list or Tensor, Optional): \ + The filtered results. The shape of each item is \ + (num_bboxes_filtered, N). + """ + valid_mask = scores > score_thr + scores = scores[valid_mask] + valid_idxs = torch.nonzero(valid_mask) + + num_topk = min(topk, valid_idxs.size(0)) + # torch.sort is actually faster than .topk (at least on GPUs) + scores, idxs = scores.sort(descending=True) + scores = scores[:num_topk] + topk_idxs = valid_idxs[idxs[:num_topk]] + keep_idxs, labels = topk_idxs.unbind(dim=1) + + filtered_results = None + if results is not None: + if isinstance(results, dict): + filtered_results = {k: v[keep_idxs] for k, v in results.items()} + elif isinstance(results, list): + filtered_results = [result[keep_idxs] for result in results] + elif isinstance(results, torch.Tensor): + filtered_results = results[keep_idxs] + else: + raise NotImplementedError(f'Only supports dict or list or Tensor, ' + f'but get {type(results)}.') + return scores, labels, keep_idxs, filtered_results + + +def center_of_mass(mask, esp=1e-6): + """Calculate the centroid coordinates of the mask. + + Args: + mask (Tensor): The mask to be calculated, shape (h, w). + esp (float): Avoid dividing by zero. Default: 1e-6. + + Returns: + tuple[Tensor]: the coordinates of the center point of the mask. + + - center_h (Tensor): the center point of the height. + - center_w (Tensor): the center point of the width. + """ + h, w = mask.shape + grid_h = torch.arange(h, device=mask.device)[:, None] + grid_w = torch.arange(w, device=mask.device) + normalizer = mask.sum().float().clamp(min=esp) + center_h = (mask * grid_h).sum() / normalizer + center_w = (mask * grid_w).sum() / normalizer + return center_h, center_w + + +def generate_coordinate(featmap_sizes, device='cuda'): + """Generate the coordinate. + + Args: + featmap_sizes (tuple): The feature to be calculated, + of shape (N, C, W, H). + device (str): The device where the feature will be put on. + Returns: + coord_feat (Tensor): The coordinate feature, of shape (N, 2, W, H). + """ + + x_range = torch.linspace(-1, 1, featmap_sizes[-1], device=device) + y_range = torch.linspace(-1, 1, featmap_sizes[-2], device=device) + y, x = torch.meshgrid(y_range, x_range) + y = y.expand([featmap_sizes[0], 1, -1, -1]) + x = x.expand([featmap_sizes[0], 1, -1, -1]) + coord_feat = torch.cat([x, y], 1) + + return coord_feat diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/visualization/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/visualization/__init__.py new file mode 100644 index 000000000..2eb17c4b3 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/visualization/__init__.py @@ -0,0 +1,9 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .image import (color_val_matplotlib, imshow_det_bboxes, + imshow_gt_det_bboxes) +from .palette import get_palette, palette_val + +__all__ = [ + 'imshow_det_bboxes', 'imshow_gt_det_bboxes', 'color_val_matplotlib', + 'palette_val', 'get_palette' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/visualization/image.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/visualization/image.py new file mode 100644 index 000000000..43bebf97f --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/visualization/image.py @@ -0,0 +1,559 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import cv2 +import matplotlib.pyplot as plt +import mmcv +import numpy as np +import pycocotools.mask as mask_util +from matplotlib.collections import PatchCollection +from matplotlib.patches import Polygon + +from mmdet.core.evaluation.panoptic_utils import INSTANCE_OFFSET +from ..mask.structures import bitmap_to_polygon +from ..utils import mask2ndarray +from .palette import get_palette, palette_val + +__all__ = [ + 'color_val_matplotlib', 'draw_masks', 'draw_bboxes', 'draw_labels', + 'imshow_det_bboxes', 'imshow_gt_det_bboxes' +] + +EPS = 1e-2 + + +def color_val_matplotlib(color): + """Convert various input in BGR order to normalized RGB matplotlib color + tuples. + + Args: + color (:obj`Color` | str | tuple | int | ndarray): Color inputs. + + Returns: + tuple[float]: A tuple of 3 normalized floats indicating RGB channels. + """ + color = mmcv.color_val(color) + color = [color / 255 for color in color[::-1]] + return tuple(color) + + +def _get_adaptive_scales(areas, min_area=800, max_area=30000): + """Get adaptive scales according to areas. + + The scale range is [0.5, 1.0]. When the area is less than + ``'min_area'``, the scale is 0.5 while the area is larger than + ``'max_area'``, the scale is 1.0. + + Args: + areas (ndarray): The areas of bboxes or masks with the + shape of (n, ). + min_area (int): Lower bound areas for adaptive scales. + Default: 800. + max_area (int): Upper bound areas for adaptive scales. + Default: 30000. + + Returns: + ndarray: The adaotive scales with the shape of (n, ). + """ + scales = 0.5 + (areas - min_area) / (max_area - min_area) + scales = np.clip(scales, 0.5, 1.0) + return scales + + +def _get_bias_color(base, max_dist=30): + """Get different colors for each masks. + + Get different colors for each masks by adding a bias + color to the base category color. + Args: + base (ndarray): The base category color with the shape + of (3, ). + max_dist (int): The max distance of bias. Default: 30. + + Returns: + ndarray: The new color for a mask with the shape of (3, ). + """ + new_color = base + np.random.randint( + low=-max_dist, high=max_dist + 1, size=3) + return np.clip(new_color, 0, 255, new_color) + + +def draw_bboxes(ax, bboxes, color='g', alpha=0.8, thickness=2): + """Draw bounding boxes on the axes. + + Args: + ax (matplotlib.Axes): The input axes. + bboxes (ndarray): The input bounding boxes with the shape + of (n, 4). + color (list[tuple] | matplotlib.color): the colors for each + bounding boxes. + alpha (float): Transparency of bounding boxes. Default: 0.8. + thickness (int): Thickness of lines. Default: 2. + + Returns: + matplotlib.Axes: The result axes. + """ + polygons = [] + for i, bbox in enumerate(bboxes): + bbox_int = bbox.astype(np.int32) + poly = [[bbox_int[0], bbox_int[1]], [bbox_int[0], bbox_int[3]], + [bbox_int[2], bbox_int[3]], [bbox_int[2], bbox_int[1]]] + np_poly = np.array(poly).reshape((4, 2)) + polygons.append(Polygon(np_poly)) + p = PatchCollection( + polygons, + facecolor='none', + edgecolors=color, + linewidths=thickness, + alpha=alpha) + ax.add_collection(p) + + return ax + + +def draw_labels(ax, + labels, + positions, + scores=None, + class_names=None, + color='w', + font_size=8, + scales=None, + horizontal_alignment='left'): + """Draw labels on the axes. + + Args: + ax (matplotlib.Axes): The input axes. + labels (ndarray): The labels with the shape of (n, ). + positions (ndarray): The positions to draw each labels. + scores (ndarray): The scores for each labels. + class_names (list[str]): The class names. + color (list[tuple] | matplotlib.color): The colors for labels. + font_size (int): Font size of texts. Default: 8. + scales (list[float]): Scales of texts. Default: None. + horizontal_alignment (str): The horizontal alignment method of + texts. Default: 'left'. + + Returns: + matplotlib.Axes: The result axes. + """ + for i, (pos, label) in enumerate(zip(positions, labels)): + label_text = class_names[ + label] if class_names is not None else f'class {label}' + if scores is not None: + label_text += f'|{scores[i]:.02f}' + text_color = color[i] if isinstance(color, list) else color + + font_size_mask = font_size if scales is None else font_size * scales[i] + ax.text( + pos[0], + pos[1], + f'{label_text}', + bbox={ + 'facecolor': 'black', + 'alpha': 0.8, + 'pad': 0.7, + 'edgecolor': 'none' + }, + color=text_color, + fontsize=font_size_mask, + verticalalignment='top', + horizontalalignment=horizontal_alignment) + + return ax + + +def draw_masks(ax, img, masks, color=None, with_edge=True, alpha=0.8): + """Draw masks on the image and their edges on the axes. + + Args: + ax (matplotlib.Axes): The input axes. + img (ndarray): The image with the shape of (3, h, w). + masks (ndarray): The masks with the shape of (n, h, w). + color (ndarray): The colors for each masks with the shape + of (n, 3). + with_edge (bool): Whether to draw edges. Default: True. + alpha (float): Transparency of bounding boxes. Default: 0.8. + + Returns: + matplotlib.Axes: The result axes. + ndarray: The result image. + """ + taken_colors = set([0, 0, 0]) + if color is None: + random_colors = np.random.randint(0, 255, (masks.size(0), 3)) + color = [tuple(c) for c in random_colors] + color = np.array(color, dtype=np.uint8) + polygons = [] + for i, mask in enumerate(masks): + if with_edge: + contours, _ = bitmap_to_polygon(mask) + polygons += [Polygon(c) for c in contours] + + color_mask = color[i] + while tuple(color_mask) in taken_colors: + color_mask = _get_bias_color(color_mask) + taken_colors.add(tuple(color_mask)) + + mask = mask.astype(bool) + img[mask] = img[mask] * (1 - alpha) + color_mask * alpha + + p = PatchCollection( + polygons, facecolor='none', edgecolors='w', linewidths=1, alpha=0.8) + ax.add_collection(p) + + return ax, img + + +def imshow_det_bboxes(img, + bboxes=None, + labels=None, + segms=None, + class_names=None, + score_thr=0, + bbox_color='green', + text_color='green', + mask_color=None, + thickness=2, + font_size=8, + win_name='', + show=True, + wait_time=0, + out_file=None): + """Draw bboxes and class labels (with scores) on an image. + + Args: + img (str | ndarray): The image to be displayed. + bboxes (ndarray): Bounding boxes (with scores), shaped (n, 4) or + (n, 5). + labels (ndarray): Labels of bboxes. + segms (ndarray | None): Masks, shaped (n,h,w) or None. + class_names (list[str]): Names of each classes. + score_thr (float): Minimum score of bboxes to be shown. Default: 0. + bbox_color (list[tuple] | tuple | str | None): Colors of bbox lines. + If a single color is given, it will be applied to all classes. + The tuple of color should be in RGB order. Default: 'green'. + text_color (list[tuple] | tuple | str | None): Colors of texts. + If a single color is given, it will be applied to all classes. + The tuple of color should be in RGB order. Default: 'green'. + mask_color (list[tuple] | tuple | str | None, optional): Colors of + masks. If a single color is given, it will be applied to all + classes. The tuple of color should be in RGB order. + Default: None. + thickness (int): Thickness of lines. Default: 2. + font_size (int): Font size of texts. Default: 13. + show (bool): Whether to show the image. Default: True. + win_name (str): The window name. Default: ''. + wait_time (float): Value of waitKey param. Default: 0. + out_file (str, optional): The filename to write the image. + Default: None. + + Returns: + ndarray: The image with bboxes drawn on it. + """ + assert bboxes is None or bboxes.ndim == 2, \ + f' bboxes ndim should be 2, but its ndim is {bboxes.ndim}.' + assert labels.ndim == 1, \ + f' labels ndim should be 1, but its ndim is {labels.ndim}.' + assert bboxes is None or bboxes.shape[1] == 4 or bboxes.shape[1] == 5, \ + f' bboxes.shape[1] should be 4 or 5, but its {bboxes.shape[1]}.' + assert bboxes is None or bboxes.shape[0] <= labels.shape[0], \ + 'labels.shape[0] should not be less than bboxes.shape[0].' + assert segms is None or segms.shape[0] == labels.shape[0], \ + 'segms.shape[0] and labels.shape[0] should have the same length.' + assert segms is not None or bboxes is not None, \ + 'segms and bboxes should not be None at the same time.' + + img = mmcv.imread(img).astype(np.uint8) + + if score_thr > 0: + assert bboxes is not None and bboxes.shape[1] == 5 + scores = bboxes[:, -1] + inds = scores > score_thr + bboxes = bboxes[inds, :] + labels = labels[inds] + if segms is not None: + segms = segms[inds, ...] + + img = mmcv.bgr2rgb(img) + width, height = img.shape[1], img.shape[0] + img = np.ascontiguousarray(img) + + fig = plt.figure(win_name, frameon=False) + plt.title(win_name) + canvas = fig.canvas + dpi = fig.get_dpi() + # add a small EPS to avoid precision lost due to matplotlib's truncation + # (https://github.com/matplotlib/matplotlib/issues/15363) + fig.set_size_inches((width + EPS) / dpi, (height + EPS) / dpi) + + # remove white edges by set subplot margin + plt.subplots_adjust(left=0, right=1, bottom=0, top=1) + ax = plt.gca() + ax.axis('off') + + max_label = int(max(labels) if len(labels) > 0 else 0) + text_palette = palette_val(get_palette(text_color, max_label + 1)) + text_colors = [text_palette[label] for label in labels] + + num_bboxes = 0 + if bboxes is not None: + num_bboxes = bboxes.shape[0] + bbox_palette = palette_val(get_palette(bbox_color, max_label + 1)) + colors = [bbox_palette[label] for label in labels[:num_bboxes]] + draw_bboxes(ax, bboxes, colors, alpha=0.8, thickness=thickness) + + horizontal_alignment = 'left' + positions = bboxes[:, :2].astype(np.int32) + thickness + areas = (bboxes[:, 3] - bboxes[:, 1]) * (bboxes[:, 2] - bboxes[:, 0]) + scales = _get_adaptive_scales(areas) + scores = bboxes[:, 4] if bboxes.shape[1] == 5 else None + draw_labels( + ax, + labels[:num_bboxes], + positions, + scores=scores, + class_names=class_names, + color=text_colors, + font_size=font_size, + scales=scales, + horizontal_alignment=horizontal_alignment) + + if segms is not None: + mask_palette = get_palette(mask_color, max_label + 1) + colors = [mask_palette[label] for label in labels] + colors = np.array(colors, dtype=np.uint8) + draw_masks(ax, img, segms, colors, with_edge=True) + + if num_bboxes < segms.shape[0]: + segms = segms[num_bboxes:] + horizontal_alignment = 'center' + areas = [] + positions = [] + for mask in segms: + _, _, stats, centroids = cv2.connectedComponentsWithStats( + mask.astype(np.uint8), connectivity=8) + largest_id = np.argmax(stats[1:, -1]) + 1 + positions.append(centroids[largest_id]) + areas.append(stats[largest_id, -1]) + areas = np.stack(areas, axis=0) + scales = _get_adaptive_scales(areas) + draw_labels( + ax, + labels[num_bboxes:], + positions, + class_names=class_names, + color=text_colors, + font_size=font_size, + scales=scales, + horizontal_alignment=horizontal_alignment) + + plt.imshow(img) + + stream, _ = canvas.print_to_buffer() + buffer = np.frombuffer(stream, dtype='uint8') + img_rgba = buffer.reshape(height, width, 4) + rgb, alpha = np.split(img_rgba, [3], axis=2) + img = rgb.astype('uint8') + img = mmcv.rgb2bgr(img) + + if show: + # We do not use cv2 for display because in some cases, opencv will + # conflict with Qt, it will output a warning: Current thread + # is not the object's thread. You can refer to + # https://github.com/opencv/opencv-python/issues/46 for details + if wait_time == 0: + plt.show() + else: + plt.show(block=False) + plt.pause(wait_time) + if out_file is not None: + mmcv.imwrite(img, out_file) + + plt.close() + + return img + + +def imshow_gt_det_bboxes(img, + annotation, + result, + class_names=None, + score_thr=0, + gt_bbox_color=(61, 102, 255), + gt_text_color=(200, 200, 200), + gt_mask_color=(61, 102, 255), + det_bbox_color=(241, 101, 72), + det_text_color=(200, 200, 200), + det_mask_color=(241, 101, 72), + thickness=2, + font_size=13, + win_name='', + show=True, + wait_time=0, + out_file=None, + overlay_gt_pred=True): + """General visualization GT and result function. + + Args: + img (str | ndarray): The image to be displayed. + annotation (dict): Ground truth annotations where contain keys of + 'gt_bboxes' and 'gt_labels' or 'gt_masks'. + result (tuple[list] | list): The detection result, can be either + (bbox, segm) or just bbox. + class_names (list[str]): Names of each classes. + score_thr (float): Minimum score of bboxes to be shown. Default: 0. + gt_bbox_color (list[tuple] | tuple | str | None): Colors of bbox lines. + If a single color is given, it will be applied to all classes. + The tuple of color should be in RGB order. Default: (61, 102, 255). + gt_text_color (list[tuple] | tuple | str | None): Colors of texts. + If a single color is given, it will be applied to all classes. + The tuple of color should be in RGB order. Default: (200, 200, 200). + gt_mask_color (list[tuple] | tuple | str | None, optional): Colors of + masks. If a single color is given, it will be applied to all classes. + The tuple of color should be in RGB order. Default: (61, 102, 255). + det_bbox_color (list[tuple] | tuple | str | None):Colors of bbox lines. + If a single color is given, it will be applied to all classes. + The tuple of color should be in RGB order. Default: (241, 101, 72). + det_text_color (list[tuple] | tuple | str | None):Colors of texts. + If a single color is given, it will be applied to all classes. + The tuple of color should be in RGB order. Default: (200, 200, 200). + det_mask_color (list[tuple] | tuple | str | None, optional): Color of + masks. If a single color is given, it will be applied to all classes. + The tuple of color should be in RGB order. Default: (241, 101, 72). + thickness (int): Thickness of lines. Default: 2. + font_size (int): Font size of texts. Default: 13. + win_name (str): The window name. Default: ''. + show (bool): Whether to show the image. Default: True. + wait_time (float): Value of waitKey param. Default: 0. + out_file (str, optional): The filename to write the image. + Default: None. + overlay_gt_pred (bool): Whether to plot gts and predictions on the + same image. If False, predictions and gts will be plotted on two same + image which will be concatenated in vertical direction. The image + above is drawn with gt, and the image below is drawn with the + prediction result. Default: True. + + Returns: + ndarray: The image with bboxes or masks drawn on it. + """ + assert 'gt_bboxes' in annotation + assert 'gt_labels' in annotation + assert isinstance(result, (tuple, list, dict)), 'Expected ' \ + f'tuple or list or dict, but get {type(result)}' + + gt_bboxes = annotation['gt_bboxes'] + gt_labels = annotation['gt_labels'] + gt_masks = annotation.get('gt_masks', None) + if gt_masks is not None: + gt_masks = mask2ndarray(gt_masks) + + gt_seg = annotation.get('gt_semantic_seg', None) + if gt_seg is not None: + pad_value = 255 # the padding value of gt_seg + sem_labels = np.unique(gt_seg) + all_labels = np.concatenate((gt_labels, sem_labels), axis=0) + all_labels, counts = np.unique(all_labels, return_counts=True) + stuff_labels = all_labels[np.logical_and(counts < 2, + all_labels != pad_value)] + stuff_masks = gt_seg[None] == stuff_labels[:, None, None] + gt_labels = np.concatenate((gt_labels, stuff_labels), axis=0) + gt_masks = np.concatenate((gt_masks, stuff_masks.astype(np.uint8)), + axis=0) + # If you need to show the bounding boxes, + # please comment the following line + # gt_bboxes = None + + img = mmcv.imread(img) + + img_with_gt = imshow_det_bboxes( + img, + gt_bboxes, + gt_labels, + gt_masks, + class_names=class_names, + bbox_color=gt_bbox_color, + text_color=gt_text_color, + mask_color=gt_mask_color, + thickness=thickness, + font_size=font_size, + win_name=win_name, + show=False) + + if not isinstance(result, dict): + if isinstance(result, tuple): + bbox_result, segm_result = result + if isinstance(segm_result, tuple): + segm_result = segm_result[0] # ms rcnn + else: + bbox_result, segm_result = result, None + + bboxes = np.vstack(bbox_result) + labels = [ + np.full(bbox.shape[0], i, dtype=np.int32) + for i, bbox in enumerate(bbox_result) + ] + labels = np.concatenate(labels) + + segms = None + if segm_result is not None and len(labels) > 0: # non empty + segms = mmcv.concat_list(segm_result) + segms = mask_util.decode(segms) + segms = segms.transpose(2, 0, 1) + else: + assert class_names is not None, 'We need to know the number ' \ + 'of classes.' + VOID = len(class_names) + bboxes = None + pan_results = result['pan_results'] + # keep objects ahead + ids = np.unique(pan_results)[::-1] + legal_indices = ids != VOID + ids = ids[legal_indices] + labels = np.array([id % INSTANCE_OFFSET for id in ids], dtype=np.int64) + segms = (pan_results[None] == ids[:, None, None]) + + if overlay_gt_pred: + img = imshow_det_bboxes( + img_with_gt, + bboxes, + labels, + segms=segms, + class_names=class_names, + score_thr=score_thr, + bbox_color=det_bbox_color, + text_color=det_text_color, + mask_color=det_mask_color, + thickness=thickness, + font_size=font_size, + win_name=win_name, + show=show, + wait_time=wait_time, + out_file=out_file) + else: + img_with_det = imshow_det_bboxes( + img, + bboxes, + labels, + segms=segms, + class_names=class_names, + score_thr=score_thr, + bbox_color=det_bbox_color, + text_color=det_text_color, + mask_color=det_mask_color, + thickness=thickness, + font_size=font_size, + win_name=win_name, + show=False) + img = np.concatenate([img_with_gt, img_with_det], axis=0) + + plt.imshow(img) + if show: + if wait_time == 0: + plt.show() + else: + plt.show(block=False) + plt.pause(wait_time) + if out_file is not None: + mmcv.imwrite(img, out_file) + plt.close() + + return img diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/core/visualization/palette.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/visualization/palette.py new file mode 100644 index 000000000..11692cdd0 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/core/visualization/palette.py @@ -0,0 +1,63 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import mmcv +import numpy as np + + +def palette_val(palette): + """Convert palette to matplotlib palette. + + Args: + palette List[tuple]: A list of color tuples. + + Returns: + List[tuple[float]]: A list of RGB matplotlib color tuples. + """ + new_palette = [] + for color in palette: + color = [c / 255 for c in color] + new_palette.append(tuple(color)) + return new_palette + + +def get_palette(palette, num_classes): + """Get palette from various inputs. + + Args: + palette (list[tuple] | str | tuple | :obj:`Color`): palette inputs. + num_classes (int): the number of classes. + + Returns: + list[tuple[int]]: A list of color tuples. + """ + assert isinstance(num_classes, int) + + if isinstance(palette, list): + dataset_palette = palette + elif isinstance(palette, tuple): + dataset_palette = [palette] * num_classes + elif palette == 'random' or palette is None: + state = np.random.get_state() + # random color + np.random.seed(42) + palette = np.random.randint(0, 256, size=(num_classes, 3)) + np.random.set_state(state) + dataset_palette = [tuple(c) for c in palette] + elif palette == 'coco': + from mmdet.datasets import CocoDataset, CocoPanopticDataset + dataset_palette = CocoDataset.PALETTE + if len(dataset_palette) < num_classes: + dataset_palette = CocoPanopticDataset.PALETTE + elif palette == 'citys': + from mmdet.datasets import CityscapesDataset + dataset_palette = CityscapesDataset.PALETTE + elif palette == 'voc': + from mmdet.datasets import VOCDataset + dataset_palette = VOCDataset.PALETTE + elif mmcv.is_str(palette): + dataset_palette = [mmcv.color_val(palette)[::-1]] * num_classes + else: + raise TypeError(f'Invalid type for palette: {type(palette)}') + + assert len(dataset_palette) >= num_classes, \ + 'The length of palette should not be less than `num_classes`.' + return dataset_palette diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/__init__.py index 7ad926d4c..7e5120b13 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/__init__.py @@ -1,17 +1,10 @@ -from .builder import build_dataset -from .cityscapes import CityscapesDataset +# Copyright (c) 2022, Shanghai Iluvatar CoreX Semiconductor Co., Ltd. +# Copyright (c) OpenMMLab. All rights reserved. +from .builder import DATASETS, PIPELINES, build_dataloader, build_dataset from .coco import CocoDataset from .custom import CustomDataset -from .dataset_wrappers import ConcatDataset, RepeatDataset -from .loader import DistributedGroupSampler, GroupSampler, build_dataloader -from .registry import DATASETS -from .voc import VOCDataset -from .wider_face import WIDERFaceDataset -from .xml_style import XMLDataset - -__all__ = [ - 'CustomDataset', 'XMLDataset', 'CocoDataset', 'VOCDataset', - 'CityscapesDataset', 'GroupSampler', 'DistributedGroupSampler', - 'build_dataloader', 'ConcatDataset', 'RepeatDataset', 'WIDERFaceDataset', - 'DATASETS', 'build_dataset' -] +from .dataset_wrappers import (ClassBalancedDataset, ConcatDataset, + MultiImageMixDataset, RepeatDataset) +from .samplers import DistributedGroupSampler, DistributedSampler, GroupSampler +from .utils import (NumClassCheckHook, get_loading_pipeline, + replace_ImageToTensor) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/api_wrappers/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/api_wrappers/__init__.py new file mode 100644 index 000000000..af8557593 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/api_wrappers/__init__.py @@ -0,0 +1,7 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .coco_api import COCO, COCOeval +from .panoptic_evaluation import pq_compute_multi_core, pq_compute_single_core + +__all__ = [ + 'COCO', 'COCOeval', 'pq_compute_multi_core', 'pq_compute_single_core' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/api_wrappers/coco_api.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/api_wrappers/coco_api.py new file mode 100644 index 000000000..eef6341eb --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/api_wrappers/coco_api.py @@ -0,0 +1,47 @@ +# Copyright (c) OpenMMLab. All rights reserved. +# This file add snake case alias for coco api + +import warnings + +import pycocotools +from pycocotools.coco import COCO as _COCO +from pycocotools.cocoeval import COCOeval as _COCOeval + + +class COCO(_COCO): + """This class is almost the same as official pycocotools package. + + It implements some snake case function aliases. So that the COCO class has + the same interface as LVIS class. + """ + + def __init__(self, annotation_file=None): + if getattr(pycocotools, '__version__', '0') >= '12.0.2': + warnings.warn( + 'mmpycocotools is deprecated. Please install official pycocotools by "pip install pycocotools"', # noqa: E501 + UserWarning) + super().__init__(annotation_file=annotation_file) + self.img_ann_map = self.imgToAnns + self.cat_img_map = self.catToImgs + + def get_ann_ids(self, img_ids=[], cat_ids=[], area_rng=[], iscrowd=None): + return self.getAnnIds(img_ids, cat_ids, area_rng, iscrowd) + + def get_cat_ids(self, cat_names=[], sup_names=[], cat_ids=[]): + return self.getCatIds(cat_names, sup_names, cat_ids) + + def get_img_ids(self, img_ids=[], cat_ids=[]): + return self.getImgIds(img_ids, cat_ids) + + def load_anns(self, ids): + return self.loadAnns(ids) + + def load_cats(self, ids): + return self.loadCats(ids) + + def load_imgs(self, ids): + return self.loadImgs(ids) + + +# just for the ease of import +COCOeval = _COCOeval diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/api_wrappers/panoptic_evaluation.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/api_wrappers/panoptic_evaluation.py new file mode 100644 index 000000000..55f57bf4a --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/api_wrappers/panoptic_evaluation.py @@ -0,0 +1,228 @@ +# Copyright (c) OpenMMLab. All rights reserved. + +# Copyright (c) 2018, Alexander Kirillov +# This file supports `file_client` for `panopticapi`, +# the source code is copied from `panopticapi`, +# only the way to load the gt images is modified. +import multiprocessing +import os + +import mmcv +import numpy as np + +try: + from panopticapi.evaluation import OFFSET, VOID, PQStat + from panopticapi.utils import rgb2id +except ImportError: + PQStat = None + rgb2id = None + VOID = 0 + OFFSET = 256 * 256 * 256 + + +def pq_compute_single_core(proc_id, + annotation_set, + gt_folder, + pred_folder, + categories, + file_client=None, + print_log=False): + """The single core function to evaluate the metric of Panoptic + Segmentation. + + Same as the function with the same name in `panopticapi`. Only the function + to load the images is changed to use the file client. + + Args: + proc_id (int): The id of the mini process. + gt_folder (str): The path of the ground truth images. + pred_folder (str): The path of the prediction images. + categories (str): The categories of the dataset. + file_client (object): The file client of the dataset. If None, + the backend will be set to `disk`. + print_log (bool): Whether to print the log. Defaults to False. + """ + if PQStat is None: + raise RuntimeError( + 'panopticapi is not installed, please install it by: ' + 'pip install git+https://github.com/cocodataset/' + 'panopticapi.git.') + + if file_client is None: + file_client_args = dict(backend='disk') + file_client = mmcv.FileClient(**file_client_args) + + pq_stat = PQStat() + + idx = 0 + for gt_ann, pred_ann in annotation_set: + if print_log and idx % 100 == 0: + print('Core: {}, {} from {} images processed'.format( + proc_id, idx, len(annotation_set))) + idx += 1 + # The gt images can be on the local disk or `ceph`, so we use + # file_client here. + img_bytes = file_client.get( + os.path.join(gt_folder, gt_ann['file_name'])) + pan_gt = mmcv.imfrombytes(img_bytes, flag='color', channel_order='rgb') + pan_gt = rgb2id(pan_gt) + + # The predictions can only be on the local dist now. + pan_pred = mmcv.imread( + os.path.join(pred_folder, pred_ann['file_name']), + flag='color', + channel_order='rgb') + pan_pred = rgb2id(pan_pred) + + gt_segms = {el['id']: el for el in gt_ann['segments_info']} + pred_segms = {el['id']: el for el in pred_ann['segments_info']} + + # predicted segments area calculation + prediction sanity checks + pred_labels_set = set(el['id'] for el in pred_ann['segments_info']) + labels, labels_cnt = np.unique(pan_pred, return_counts=True) + for label, label_cnt in zip(labels, labels_cnt): + if label not in pred_segms: + if label == VOID: + continue + raise KeyError( + 'In the image with ID {} segment with ID {} is ' + 'presented in PNG and not presented in JSON.'.format( + gt_ann['image_id'], label)) + pred_segms[label]['area'] = label_cnt + pred_labels_set.remove(label) + if pred_segms[label]['category_id'] not in categories: + raise KeyError( + 'In the image with ID {} segment with ID {} has ' + 'unknown category_id {}.'.format( + gt_ann['image_id'], label, + pred_segms[label]['category_id'])) + if len(pred_labels_set) != 0: + raise KeyError( + 'In the image with ID {} the following segment IDs {} ' + 'are presented in JSON and not presented in PNG.'.format( + gt_ann['image_id'], list(pred_labels_set))) + + # confusion matrix calculation + pan_gt_pred = pan_gt.astype(np.uint64) * OFFSET + pan_pred.astype( + np.uint64) + gt_pred_map = {} + labels, labels_cnt = np.unique(pan_gt_pred, return_counts=True) + for label, intersection in zip(labels, labels_cnt): + gt_id = label // OFFSET + pred_id = label % OFFSET + gt_pred_map[(gt_id, pred_id)] = intersection + + # count all matched pairs + gt_matched = set() + pred_matched = set() + for label_tuple, intersection in gt_pred_map.items(): + gt_label, pred_label = label_tuple + if gt_label not in gt_segms: + continue + if pred_label not in pred_segms: + continue + if gt_segms[gt_label]['iscrowd'] == 1: + continue + if gt_segms[gt_label]['category_id'] != pred_segms[pred_label][ + 'category_id']: + continue + + union = pred_segms[pred_label]['area'] + gt_segms[gt_label][ + 'area'] - intersection - gt_pred_map.get((VOID, pred_label), 0) + iou = intersection / union + if iou > 0.5: + pq_stat[gt_segms[gt_label]['category_id']].tp += 1 + pq_stat[gt_segms[gt_label]['category_id']].iou += iou + gt_matched.add(gt_label) + pred_matched.add(pred_label) + + # count false positives + crowd_labels_dict = {} + for gt_label, gt_info in gt_segms.items(): + if gt_label in gt_matched: + continue + # crowd segments are ignored + if gt_info['iscrowd'] == 1: + crowd_labels_dict[gt_info['category_id']] = gt_label + continue + pq_stat[gt_info['category_id']].fn += 1 + + # count false positives + for pred_label, pred_info in pred_segms.items(): + if pred_label in pred_matched: + continue + # intersection of the segment with VOID + intersection = gt_pred_map.get((VOID, pred_label), 0) + # plus intersection with corresponding CROWD region if it exists + if pred_info['category_id'] in crowd_labels_dict: + intersection += gt_pred_map.get( + (crowd_labels_dict[pred_info['category_id']], pred_label), + 0) + # predicted segment is ignored if more than half of + # the segment correspond to VOID and CROWD regions + if intersection / pred_info['area'] > 0.5: + continue + pq_stat[pred_info['category_id']].fp += 1 + + if print_log: + print('Core: {}, all {} images processed'.format( + proc_id, len(annotation_set))) + return pq_stat + + +def pq_compute_multi_core(matched_annotations_list, + gt_folder, + pred_folder, + categories, + file_client=None, + nproc=32): + """Evaluate the metrics of Panoptic Segmentation with multithreading. + + Same as the function with the same name in `panopticapi`. + + Args: + matched_annotations_list (list): The matched annotation list. Each + element is a tuple of annotations of the same image with the + format (gt_anns, pred_anns). + gt_folder (str): The path of the ground truth images. + pred_folder (str): The path of the prediction images. + categories (str): The categories of the dataset. + file_client (object): The file client of the dataset. If None, + the backend will be set to `disk`. + nproc (int): Number of processes for panoptic quality computing. + Defaults to 32. When `nproc` exceeds the number of cpu cores, + the number of cpu cores is used. + """ + if PQStat is None: + raise RuntimeError( + 'panopticapi is not installed, please install it by: ' + 'pip install git+https://github.com/cocodataset/' + 'panopticapi.git.') + + if file_client is None: + file_client_args = dict(backend='disk') + file_client = mmcv.FileClient(**file_client_args) + + cpu_num = min(nproc, multiprocessing.cpu_count()) + + annotations_split = np.array_split(matched_annotations_list, cpu_num) + print('Number of cores: {}, images per core: {}'.format( + cpu_num, len(annotations_split[0]))) + workers = multiprocessing.Pool(processes=cpu_num) + processes = [] + for proc_id, annotation_set in enumerate(annotations_split): + p = workers.apply_async(pq_compute_single_core, + (proc_id, annotation_set, gt_folder, + pred_folder, categories, file_client)) + processes.append(p) + + # Close the process pool, otherwise it will lead to memory + # leaking problems. + workers.close() + workers.join() + + pq_stat = PQStat() + for p in processes: + pq_stat += p.get() + + return pq_stat diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/builder.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/builder.py index 6e707b190..1936296a5 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/builder.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/builder.py @@ -1,20 +1,49 @@ +# Copyright (c) OpenMMLab. All rights reserved. import copy +import platform +import random +import warnings +from functools import partial -from mmdet.utils import build_from_cfg -from .dataset_wrappers import ConcatDataset, RepeatDataset -from .registry import DATASETS +import numpy as np +import torch +from mmcv.parallel import collate +from mmcv.runner import get_dist_info +from mmcv.utils import TORCH_VERSION, Registry, build_from_cfg, digit_version +from torch.utils.data import DataLoader + +from .samplers import (ClassAwareSampler, DistributedGroupSampler, + DistributedSampler, GroupSampler, InfiniteBatchSampler, + InfiniteGroupBatchSampler) + +if platform.system() != 'Windows': + # https://github.com/pytorch/pytorch/issues/973 + import resource + rlimit = resource.getrlimit(resource.RLIMIT_NOFILE) + base_soft_limit = rlimit[0] + hard_limit = rlimit[1] + soft_limit = min(max(4096, base_soft_limit), hard_limit) + resource.setrlimit(resource.RLIMIT_NOFILE, (soft_limit, hard_limit)) + +DATASETS = Registry('dataset') +PIPELINES = Registry('pipeline') def _concat_dataset(cfg, default_args=None): + from .dataset_wrappers import ConcatDataset ann_files = cfg['ann_file'] img_prefixes = cfg.get('img_prefix', None) seg_prefixes = cfg.get('seg_prefix', None) proposal_files = cfg.get('proposal_file', None) + separate_eval = cfg.get('separate_eval', True) datasets = [] num_dset = len(ann_files) for i in range(num_dset): data_cfg = copy.deepcopy(cfg) + # pop 'separate_eval' since it is not a valid key for common datasets. + if 'separate_eval' in data_cfg: + data_cfg.pop('separate_eval') data_cfg['ann_file'] = ann_files[i] if isinstance(img_prefixes, (list, tuple)): data_cfg['img_prefix'] = img_prefixes[i] @@ -24,18 +53,163 @@ def _concat_dataset(cfg, default_args=None): data_cfg['proposal_file'] = proposal_files[i] datasets.append(build_dataset(data_cfg, default_args)) - return ConcatDataset(datasets) + return ConcatDataset(datasets, separate_eval) def build_dataset(cfg, default_args=None): + from .dataset_wrappers import (ClassBalancedDataset, ConcatDataset, + MultiImageMixDataset, RepeatDataset) if isinstance(cfg, (list, tuple)): dataset = ConcatDataset([build_dataset(c, default_args) for c in cfg]) + elif cfg['type'] == 'ConcatDataset': + dataset = ConcatDataset( + [build_dataset(c, default_args) for c in cfg['datasets']], + cfg.get('separate_eval', True)) elif cfg['type'] == 'RepeatDataset': dataset = RepeatDataset( build_dataset(cfg['dataset'], default_args), cfg['times']) - elif isinstance(cfg['ann_file'], (list, tuple)): + elif cfg['type'] == 'ClassBalancedDataset': + dataset = ClassBalancedDataset( + build_dataset(cfg['dataset'], default_args), cfg['oversample_thr']) + elif cfg['type'] == 'MultiImageMixDataset': + cp_cfg = copy.deepcopy(cfg) + cp_cfg['dataset'] = build_dataset(cp_cfg['dataset']) + cp_cfg.pop('type') + dataset = MultiImageMixDataset(**cp_cfg) + elif isinstance(cfg.get('ann_file'), (list, tuple)): dataset = _concat_dataset(cfg, default_args) else: dataset = build_from_cfg(cfg, DATASETS, default_args) return dataset + + +def build_dataloader(dataset, + samples_per_gpu, + workers_per_gpu, + num_gpus=1, + dist=True, + shuffle=True, + seed=None, + runner_type='EpochBasedRunner', + persistent_workers=False, + class_aware_sampler=None, + **kwargs): + """Build PyTorch DataLoader. + + In distributed training, each GPU/process has a dataloader. + In non-distributed training, there is only one dataloader for all GPUs. + + Args: + dataset (Dataset): A PyTorch dataset. + samples_per_gpu (int): Number of training samples on each GPU, i.e., + batch size of each GPU. + workers_per_gpu (int): How many subprocesses to use for data loading + for each GPU. + num_gpus (int): Number of GPUs. Only used in non-distributed training. + dist (bool): Distributed training/test or not. Default: True. + shuffle (bool): Whether to shuffle the data at every epoch. + Default: True. + seed (int, Optional): Seed to be used. Default: None. + runner_type (str): Type of runner. Default: `EpochBasedRunner` + persistent_workers (bool): If True, the data loader will not shutdown + the worker processes after a dataset has been consumed once. + This allows to maintain the workers `Dataset` instances alive. + This argument is only valid when PyTorch>=1.7.0. Default: False. + class_aware_sampler (dict): Whether to use `ClassAwareSampler` + during training. Default: None. + kwargs: any keyword argument to be used to initialize DataLoader + + Returns: + DataLoader: A PyTorch dataloader. + """ + rank, world_size = get_dist_info() + + if dist: + # When model is :obj:`DistributedDataParallel`, + # `batch_size` of :obj:`dataloader` is the + # number of training samples on each GPU. + batch_size = samples_per_gpu + num_workers = workers_per_gpu + else: + # When model is obj:`DataParallel` + # the batch size is samples on all the GPUS + batch_size = num_gpus * samples_per_gpu + num_workers = num_gpus * workers_per_gpu + + if runner_type == 'IterBasedRunner': + # this is a batch sampler, which can yield + # a mini-batch indices each time. + # it can be used in both `DataParallel` and + # `DistributedDataParallel` + if shuffle: + batch_sampler = InfiniteGroupBatchSampler( + dataset, batch_size, world_size, rank, seed=seed) + else: + batch_sampler = InfiniteBatchSampler( + dataset, + batch_size, + world_size, + rank, + seed=seed, + shuffle=False) + batch_size = 1 + sampler = None + else: + if class_aware_sampler is not None: + # ClassAwareSampler can be used in both distributed and + # non-distributed training. + num_sample_class = class_aware_sampler.get('num_sample_class', 1) + sampler = ClassAwareSampler( + dataset, + samples_per_gpu, + world_size, + rank, + seed=seed, + num_sample_class=num_sample_class) + elif dist: + # DistributedGroupSampler will definitely shuffle the data to + # satisfy that images on each GPU are in the same group + if shuffle: + sampler = DistributedGroupSampler( + dataset, samples_per_gpu, world_size, rank, seed=seed) + else: + sampler = DistributedSampler( + dataset, world_size, rank, shuffle=False, seed=seed) + else: + sampler = GroupSampler(dataset, + samples_per_gpu) if shuffle else None + batch_sampler = None + + init_fn = partial( + worker_init_fn, num_workers=num_workers, rank=rank, + seed=seed) if seed is not None else None + + if (TORCH_VERSION != 'parrots' + and digit_version(TORCH_VERSION) >= digit_version('1.7.0')): + kwargs['persistent_workers'] = persistent_workers + elif persistent_workers is True: + warnings.warn('persistent_workers is invalid because your pytorch ' + 'version is lower than 1.7.0') + + data_loader = DataLoader( + dataset, + batch_size=batch_size, + sampler=sampler, + num_workers=num_workers, + batch_sampler=batch_sampler, + collate_fn=partial(collate, samples_per_gpu=samples_per_gpu), + pin_memory=kwargs.pop('pin_memory', False), + worker_init_fn=init_fn, + **kwargs) + + return data_loader + + +def worker_init_fn(worker_id, num_workers, rank, seed): + # The seed of each worker equals to + # num_worker * rank + worker_id + user_seed + worker_seed = num_workers * rank + worker_id + seed + np.random.seed(worker_seed) + random.seed(worker_seed) + torch.manual_seed(worker_seed) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/cityscapes.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/cityscapes.py deleted file mode 100644 index 51ca04987..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/cityscapes.py +++ /dev/null @@ -1,9 +0,0 @@ -from .coco import CocoDataset -from .registry import DATASETS - - -@DATASETS.register_module -class CityscapesDataset(CocoDataset): - - CLASSES = ('person', 'rider', 'car', 'truck', 'bus', 'train', 'motorcycle', - 'bicycle') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/coco.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/coco.py index d041532ab..bcdd4df39 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/coco.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/coco.py @@ -1,58 +1,145 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import contextlib +import io +import itertools +import logging +import os.path as osp +import tempfile +import warnings +from collections import OrderedDict + +import mmcv import numpy as np -from pycocotools.coco import COCO +from mmcv.utils import print_log +from terminaltables import AsciiTable +from mmdet.core import eval_recalls +from .api_wrappers import COCO, COCOeval +from .builder import DATASETS from .custom import CustomDataset -from .registry import DATASETS -@DATASETS.register_module +@DATASETS.register_module() class CocoDataset(CustomDataset): CLASSES = ('person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', - 'train', 'truck', 'boat', 'traffic_light', 'fire_hydrant', - 'stop_sign', 'parking_meter', 'bench', 'bird', 'cat', 'dog', + 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', + 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', - 'skis', 'snowboard', 'sports_ball', 'kite', 'baseball_bat', - 'baseball_glove', 'skateboard', 'surfboard', 'tennis_racket', - 'bottle', 'wine_glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', + 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', + 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', + 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', - 'hot_dog', 'pizza', 'donut', 'cake', 'chair', 'couch', - 'potted_plant', 'bed', 'dining_table', 'toilet', 'tv', 'laptop', - 'mouse', 'remote', 'keyboard', 'cell_phone', 'microwave', + 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', + 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', + 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', - 'vase', 'scissors', 'teddy_bear', 'hair_drier', 'toothbrush') + 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush') + + PALETTE = [(220, 20, 60), (119, 11, 32), (0, 0, 142), (0, 0, 230), + (106, 0, 228), (0, 60, 100), (0, 80, 100), (0, 0, 70), + (0, 0, 192), (250, 170, 30), (100, 170, 30), (220, 220, 0), + (175, 116, 175), (250, 0, 30), (165, 42, 42), (255, 77, 255), + (0, 226, 252), (182, 182, 255), (0, 82, 0), (120, 166, 157), + (110, 76, 0), (174, 57, 255), (199, 100, 0), (72, 0, 118), + (255, 179, 240), (0, 125, 92), (209, 0, 151), (188, 208, 182), + (0, 220, 176), (255, 99, 164), (92, 0, 73), (133, 129, 255), + (78, 180, 255), (0, 228, 0), (174, 255, 243), (45, 89, 255), + (134, 134, 103), (145, 148, 174), (255, 208, 186), + (197, 226, 255), (171, 134, 1), (109, 63, 54), (207, 138, 255), + (151, 0, 95), (9, 80, 61), (84, 105, 51), (74, 65, 105), + (166, 196, 102), (208, 195, 210), (255, 109, 65), (0, 143, 149), + (179, 0, 194), (209, 99, 106), (5, 121, 0), (227, 255, 205), + (147, 186, 208), (153, 69, 1), (3, 95, 161), (163, 255, 0), + (119, 0, 170), (0, 182, 199), (0, 165, 120), (183, 130, 88), + (95, 32, 0), (130, 114, 135), (110, 129, 133), (166, 74, 118), + (219, 142, 185), (79, 210, 114), (178, 90, 62), (65, 70, 15), + (127, 167, 115), (59, 105, 106), (142, 108, 45), (196, 172, 0), + (95, 54, 80), (128, 76, 255), (201, 57, 1), (246, 0, 122), + (191, 162, 208)] def load_annotations(self, ann_file): + """Load annotation from COCO style annotation file. + + Args: + ann_file (str): Path of annotation file. + + Returns: + list[dict]: Annotation info from COCO api. + """ + self.coco = COCO(ann_file) - self.cat_ids = self.coco.getCatIds() - self.cat2label = { - cat_id: i + 1 - for i, cat_id in enumerate(self.cat_ids) - } - self.img_ids = self.coco.getImgIds() - img_infos = [] + # The order of returned `cat_ids` will not + # change with the order of the CLASSES + self.cat_ids = self.coco.get_cat_ids(cat_names=self.CLASSES) + + self.cat2label = {cat_id: i for i, cat_id in enumerate(self.cat_ids)} + self.img_ids = self.coco.get_img_ids() + data_infos = [] + total_ann_ids = [] for i in self.img_ids: - info = self.coco.loadImgs([i])[0] + info = self.coco.load_imgs([i])[0] info['filename'] = info['file_name'] - img_infos.append(info) - return img_infos + data_infos.append(info) + ann_ids = self.coco.get_ann_ids(img_ids=[i]) + total_ann_ids.extend(ann_ids) + assert len(set(total_ann_ids)) == len( + total_ann_ids), f"Annotation ids in '{ann_file}' are not unique!" + return data_infos def get_ann_info(self, idx): - img_id = self.img_infos[idx]['id'] - ann_ids = self.coco.getAnnIds(imgIds=[img_id]) - ann_info = self.coco.loadAnns(ann_ids) - return self._parse_ann_info(self.img_infos[idx], ann_info) + """Get COCO annotation by index. + + Args: + idx (int): Index of data. + + Returns: + dict: Annotation info of specified index. + """ + + img_id = self.data_infos[idx]['id'] + ann_ids = self.coco.get_ann_ids(img_ids=[img_id]) + ann_info = self.coco.load_anns(ann_ids) + return self._parse_ann_info(self.data_infos[idx], ann_info) + + def get_cat_ids(self, idx): + """Get COCO category ids by index. + + Args: + idx (int): Index of data. + + Returns: + list[int]: All categories in the image of specified index. + """ + + img_id = self.data_infos[idx]['id'] + ann_ids = self.coco.get_ann_ids(img_ids=[img_id]) + ann_info = self.coco.load_anns(ann_ids) + return [ann['category_id'] for ann in ann_info] def _filter_imgs(self, min_size=32): """Filter images too small or without ground truths.""" valid_inds = [] + # obtain images that contain annotation ids_with_ann = set(_['image_id'] for _ in self.coco.anns.values()) - for i, img_info in enumerate(self.img_infos): - if self.filter_empty_gt and self.img_ids[i] not in ids_with_ann: + # obtain images that contain annotations of the required categories + ids_in_cat = set() + for i, class_id in enumerate(self.cat_ids): + ids_in_cat |= set(self.coco.cat_img_map[class_id]) + # merge the image id sets of the two conditions and use the merged set + # to filter out images if self.filter_empty_gt=True + ids_in_cat &= ids_with_ann + + valid_img_ids = [] + for i, img_info in enumerate(self.data_infos): + img_id = self.img_ids[i] + if self.filter_empty_gt and img_id not in ids_in_cat: continue if min(img_info['width'], img_info['height']) >= min_size: valid_inds.append(i) + valid_img_ids.append(img_id) + self.img_ids = valid_img_ids return valid_inds def _parse_ann_info(self, img_info, ann_info): @@ -63,28 +150,33 @@ class CocoDataset(CustomDataset): with_mask (bool): Whether to parse mask annotations. Returns: - dict: A dict containing the following keys: bboxes, bboxes_ignore, - labels, masks, seg_map. "masks" are raw annotations and not + dict: A dict containing the following keys: bboxes, bboxes_ignore,\ + labels, masks, seg_map. "masks" are raw annotations and not \ decoded into binary masks. """ gt_bboxes = [] gt_labels = [] gt_bboxes_ignore = [] gt_masks_ann = [] - for i, ann in enumerate(ann_info): if ann.get('ignore', False): continue x1, y1, w, h = ann['bbox'] + inter_w = max(0, min(x1 + w, img_info['width']) - max(x1, 0)) + inter_h = max(0, min(y1 + h, img_info['height']) - max(y1, 0)) + if inter_w * inter_h == 0: + continue if ann['area'] <= 0 or w < 1 or h < 1: continue - bbox = [x1, y1, x1 + w - 1, y1 + h - 1] + if ann['category_id'] not in self.cat_ids: + continue + bbox = [x1, y1, x1 + w, y1 + h] if ann.get('iscrowd', False): gt_bboxes_ignore.append(bbox) else: gt_bboxes.append(bbox) gt_labels.append(self.cat2label[ann['category_id']]) - gt_masks_ann.append(ann['segmentation']) + gt_masks_ann.append(ann.get('segmentation', None)) if gt_bboxes: gt_bboxes = np.array(gt_bboxes, dtype=np.float32) @@ -108,3 +200,450 @@ class CocoDataset(CustomDataset): seg_map=seg_map) return ann + + def xyxy2xywh(self, bbox): + """Convert ``xyxy`` style bounding boxes to ``xywh`` style for COCO + evaluation. + + Args: + bbox (numpy.ndarray): The bounding boxes, shape (4, ), in + ``xyxy`` order. + + Returns: + list[float]: The converted bounding boxes, in ``xywh`` order. + """ + + _bbox = bbox.tolist() + return [ + _bbox[0], + _bbox[1], + _bbox[2] - _bbox[0], + _bbox[3] - _bbox[1], + ] + + def _proposal2json(self, results): + """Convert proposal results to COCO json style.""" + json_results = [] + for idx in range(len(self)): + img_id = self.img_ids[idx] + bboxes = results[idx] + for i in range(bboxes.shape[0]): + data = dict() + data['image_id'] = img_id + data['bbox'] = self.xyxy2xywh(bboxes[i]) + data['score'] = float(bboxes[i][4]) + data['category_id'] = 1 + json_results.append(data) + return json_results + + def _det2json(self, results): + """Convert detection results to COCO json style.""" + json_results = [] + for idx in range(len(self)): + img_id = self.img_ids[idx] + result = results[idx] + for label in range(len(result)): + bboxes = result[label] + for i in range(bboxes.shape[0]): + data = dict() + data['image_id'] = img_id + data['bbox'] = self.xyxy2xywh(bboxes[i]) + data['score'] = float(bboxes[i][4]) + data['category_id'] = self.cat_ids[label] + json_results.append(data) + return json_results + + def _segm2json(self, results): + """Convert instance segmentation results to COCO json style.""" + bbox_json_results = [] + segm_json_results = [] + for idx in range(len(self)): + img_id = self.img_ids[idx] + det, seg = results[idx] + for label in range(len(det)): + # bbox results + bboxes = det[label] + for i in range(bboxes.shape[0]): + data = dict() + data['image_id'] = img_id + data['bbox'] = self.xyxy2xywh(bboxes[i]) + data['score'] = float(bboxes[i][4]) + data['category_id'] = self.cat_ids[label] + bbox_json_results.append(data) + + # segm results + # some detectors use different scores for bbox and mask + if isinstance(seg, tuple): + segms = seg[0][label] + mask_score = seg[1][label] + else: + segms = seg[label] + mask_score = [bbox[4] for bbox in bboxes] + for i in range(bboxes.shape[0]): + data = dict() + data['image_id'] = img_id + data['bbox'] = self.xyxy2xywh(bboxes[i]) + data['score'] = float(mask_score[i]) + data['category_id'] = self.cat_ids[label] + if isinstance(segms[i]['counts'], bytes): + segms[i]['counts'] = segms[i]['counts'].decode() + data['segmentation'] = segms[i] + segm_json_results.append(data) + return bbox_json_results, segm_json_results + + def results2json(self, results, outfile_prefix): + """Dump the detection results to a COCO style json file. + + There are 3 types of results: proposals, bbox predictions, mask + predictions, and they have different data types. This method will + automatically recognize the type, and dump them to json files. + + Args: + results (list[list | tuple | ndarray]): Testing results of the + dataset. + outfile_prefix (str): The filename prefix of the json files. If the + prefix is "somepath/xxx", the json files will be named + "somepath/xxx.bbox.json", "somepath/xxx.segm.json", + "somepath/xxx.proposal.json". + + Returns: + dict[str: str]: Possible keys are "bbox", "segm", "proposal", and \ + values are corresponding filenames. + """ + result_files = dict() + if isinstance(results[0], list): + json_results = self._det2json(results) + result_files['bbox'] = f'{outfile_prefix}.bbox.json' + result_files['proposal'] = f'{outfile_prefix}.bbox.json' + mmcv.dump(json_results, result_files['bbox']) + elif isinstance(results[0], tuple): + json_results = self._segm2json(results) + result_files['bbox'] = f'{outfile_prefix}.bbox.json' + result_files['proposal'] = f'{outfile_prefix}.bbox.json' + result_files['segm'] = f'{outfile_prefix}.segm.json' + mmcv.dump(json_results[0], result_files['bbox']) + mmcv.dump(json_results[1], result_files['segm']) + elif isinstance(results[0], np.ndarray): + json_results = self._proposal2json(results) + result_files['proposal'] = f'{outfile_prefix}.proposal.json' + mmcv.dump(json_results, result_files['proposal']) + else: + raise TypeError('invalid type of results') + return result_files + + def fast_eval_recall(self, results, proposal_nums, iou_thrs, logger=None): + gt_bboxes = [] + for i in range(len(self.img_ids)): + ann_ids = self.coco.get_ann_ids(img_ids=self.img_ids[i]) + ann_info = self.coco.load_anns(ann_ids) + if len(ann_info) == 0: + gt_bboxes.append(np.zeros((0, 4))) + continue + bboxes = [] + for ann in ann_info: + if ann.get('ignore', False) or ann['iscrowd']: + continue + x1, y1, w, h = ann['bbox'] + bboxes.append([x1, y1, x1 + w, y1 + h]) + bboxes = np.array(bboxes, dtype=np.float32) + if bboxes.shape[0] == 0: + bboxes = np.zeros((0, 4)) + gt_bboxes.append(bboxes) + + recalls = eval_recalls( + gt_bboxes, results, proposal_nums, iou_thrs, logger=logger) + ar = recalls.mean(axis=1) + return ar + + def format_results(self, results, jsonfile_prefix=None, **kwargs): + """Format the results to json (standard format for COCO evaluation). + + Args: + results (list[tuple | numpy.ndarray]): Testing results of the + dataset. + jsonfile_prefix (str | None): The prefix of json files. It includes + the file path and the prefix of filename, e.g., "a/b/prefix". + If not specified, a temp file will be created. Default: None. + + Returns: + tuple: (result_files, tmp_dir), result_files is a dict containing \ + the json filepaths, tmp_dir is the temporal directory created \ + for saving json files when jsonfile_prefix is not specified. + """ + assert isinstance(results, list), 'results must be a list' + assert len(results) == len(self), ( + 'The length of results is not equal to the dataset len: {} != {}'. + format(len(results), len(self))) + + if jsonfile_prefix is None: + tmp_dir = tempfile.TemporaryDirectory() + jsonfile_prefix = osp.join(tmp_dir.name, 'results') + else: + tmp_dir = None + result_files = self.results2json(results, jsonfile_prefix) + return result_files, tmp_dir + + def evaluate_det_segm(self, + results, + result_files, + coco_gt, + metrics, + logger=None, + classwise=False, + proposal_nums=(100, 300, 1000), + iou_thrs=None, + metric_items=None): + """Instance segmentation and object detection evaluation in COCO + protocol. + + Args: + results (list[list | tuple | dict]): Testing results of the + dataset. + result_files (dict[str, str]): a dict contains json file path. + coco_gt (COCO): COCO API object with ground truth annotation. + metric (str | list[str]): Metrics to be evaluated. Options are + 'bbox', 'segm', 'proposal', 'proposal_fast'. + logger (logging.Logger | str | None): Logger used for printing + related information during evaluation. Default: None. + classwise (bool): Whether to evaluating the AP for each class. + proposal_nums (Sequence[int]): Proposal number used for evaluating + recalls, such as recall@100, recall@1000. + Default: (100, 300, 1000). + iou_thrs (Sequence[float], optional): IoU threshold used for + evaluating recalls/mAPs. If set to a list, the average of all + IoUs will also be computed. If not specified, [0.50, 0.55, + 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95] will be used. + Default: None. + metric_items (list[str] | str, optional): Metric items that will + be returned. If not specified, ``['AR@100', 'AR@300', + 'AR@1000', 'AR_s@1000', 'AR_m@1000', 'AR_l@1000' ]`` will be + used when ``metric=='proposal'``, ``['mAP', 'mAP_50', 'mAP_75', + 'mAP_s', 'mAP_m', 'mAP_l']`` will be used when + ``metric=='bbox' or metric=='segm'``. + + Returns: + dict[str, float]: COCO style evaluation metric. + """ + if iou_thrs is None: + iou_thrs = np.linspace( + .5, 0.95, int(np.round((0.95 - .5) / .05)) + 1, endpoint=True) + if metric_items is not None: + if not isinstance(metric_items, list): + metric_items = [metric_items] + + eval_results = OrderedDict() + for metric in metrics: + msg = f'Evaluating {metric}...' + if logger is None: + msg = '\n' + msg + print_log(msg, logger=logger) + + if metric == 'proposal_fast': + if isinstance(results[0], tuple): + raise KeyError('proposal_fast is not supported for ' + 'instance segmentation result.') + ar = self.fast_eval_recall( + results, proposal_nums, iou_thrs, logger='silent') + log_msg = [] + for i, num in enumerate(proposal_nums): + eval_results[f'AR@{num}'] = ar[i] + log_msg.append(f'\nAR@{num}\t{ar[i]:.4f}') + log_msg = ''.join(log_msg) + print_log(log_msg, logger=logger) + continue + + iou_type = 'bbox' if metric == 'proposal' else metric + if metric not in result_files: + raise KeyError(f'{metric} is not in results') + try: + predictions = mmcv.load(result_files[metric]) + if iou_type == 'segm': + # Refer to https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocotools/coco.py#L331 # noqa + # When evaluating mask AP, if the results contain bbox, + # cocoapi will use the box area instead of the mask area + # for calculating the instance area. Though the overall AP + # is not affected, this leads to different + # small/medium/large mask AP results. + for x in predictions: + x.pop('bbox') + warnings.simplefilter('once') + warnings.warn( + 'The key "bbox" is deleted for more accurate mask AP ' + 'of small/medium/large instances since v2.12.0. This ' + 'does not change the overall mAP calculation.', + UserWarning) + coco_det = coco_gt.loadRes(predictions) + except IndexError: + print_log( + 'The testing results of the whole dataset is empty.', + logger=logger, + level=logging.ERROR) + break + + cocoEval = COCOeval(coco_gt, coco_det, iou_type) + cocoEval.params.catIds = self.cat_ids + cocoEval.params.imgIds = self.img_ids + cocoEval.params.maxDets = list(proposal_nums) + cocoEval.params.iouThrs = iou_thrs + # mapping of cocoEval.stats + coco_metric_names = { + 'mAP': 0, + 'mAP_50': 1, + 'mAP_75': 2, + 'mAP_s': 3, + 'mAP_m': 4, + 'mAP_l': 5, + 'AR@100': 6, + 'AR@300': 7, + 'AR@1000': 8, + 'AR_s@1000': 9, + 'AR_m@1000': 10, + 'AR_l@1000': 11 + } + if metric_items is not None: + for metric_item in metric_items: + if metric_item not in coco_metric_names: + raise KeyError( + f'metric item {metric_item} is not supported') + + if metric == 'proposal': + cocoEval.params.useCats = 0 + cocoEval.evaluate() + cocoEval.accumulate() + + # Save coco summarize print information to logger + redirect_string = io.StringIO() + with contextlib.redirect_stdout(redirect_string): + cocoEval.summarize() + print_log('\n' + redirect_string.getvalue(), logger=logger) + + if metric_items is None: + metric_items = [ + 'AR@100', 'AR@300', 'AR@1000', 'AR_s@1000', + 'AR_m@1000', 'AR_l@1000' + ] + + for item in metric_items: + val = float( + f'{cocoEval.stats[coco_metric_names[item]]:.3f}') + eval_results[item] = val + else: + cocoEval.evaluate() + cocoEval.accumulate() + + # Save coco summarize print information to logger + redirect_string = io.StringIO() + with contextlib.redirect_stdout(redirect_string): + cocoEval.summarize() + print_log('\n' + redirect_string.getvalue(), logger=logger) + + if classwise: # Compute per-category AP + # Compute per-category AP + # from https://github.com/facebookresearch/detectron2/ + precisions = cocoEval.eval['precision'] + # precision: (iou, recall, cls, area range, max dets) + assert len(self.cat_ids) == precisions.shape[2] + + results_per_category = [] + for idx, catId in enumerate(self.cat_ids): + # area range index 0: all area ranges + # max dets index -1: typically 100 per image + nm = self.coco.loadCats(catId)[0] + precision = precisions[:, :, idx, 0, -1] + precision = precision[precision > -1] + if precision.size: + ap = np.mean(precision) + else: + ap = float('nan') + results_per_category.append( + (f'{nm["name"]}', f'{float(ap):0.3f}')) + + num_columns = min(6, len(results_per_category) * 2) + results_flatten = list( + itertools.chain(*results_per_category)) + headers = ['category', 'AP'] * (num_columns // 2) + results_2d = itertools.zip_longest(*[ + results_flatten[i::num_columns] + for i in range(num_columns) + ]) + table_data = [headers] + table_data += [result for result in results_2d] + table = AsciiTable(table_data) + print_log('\n' + table.table, logger=logger) + + if metric_items is None: + metric_items = [ + 'mAP', 'mAP_50', 'mAP_75', 'mAP_s', 'mAP_m', 'mAP_l' + ] + + for metric_item in metric_items: + key = f'{metric}_{metric_item}' + val = float( + f'{cocoEval.stats[coco_metric_names[metric_item]]:.3f}' + ) + eval_results[key] = val + ap = cocoEval.stats[:6] + eval_results[f'{metric}_mAP_copypaste'] = ( + f'{ap[0]:.3f} {ap[1]:.3f} {ap[2]:.3f} {ap[3]:.3f} ' + f'{ap[4]:.3f} {ap[5]:.3f}') + + return eval_results + + def evaluate(self, + results, + metric='bbox', + logger=None, + jsonfile_prefix=None, + classwise=False, + proposal_nums=(100, 300, 1000), + iou_thrs=None, + metric_items=None): + """Evaluation in COCO protocol. + + Args: + results (list[list | tuple]): Testing results of the dataset. + metric (str | list[str]): Metrics to be evaluated. Options are + 'bbox', 'segm', 'proposal', 'proposal_fast'. + logger (logging.Logger | str | None): Logger used for printing + related information during evaluation. Default: None. + jsonfile_prefix (str | None): The prefix of json files. It includes + the file path and the prefix of filename, e.g., "a/b/prefix". + If not specified, a temp file will be created. Default: None. + classwise (bool): Whether to evaluating the AP for each class. + proposal_nums (Sequence[int]): Proposal number used for evaluating + recalls, such as recall@100, recall@1000. + Default: (100, 300, 1000). + iou_thrs (Sequence[float], optional): IoU threshold used for + evaluating recalls/mAPs. If set to a list, the average of all + IoUs will also be computed. If not specified, [0.50, 0.55, + 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95] will be used. + Default: None. + metric_items (list[str] | str, optional): Metric items that will + be returned. If not specified, ``['AR@100', 'AR@300', + 'AR@1000', 'AR_s@1000', 'AR_m@1000', 'AR_l@1000' ]`` will be + used when ``metric=='proposal'``, ``['mAP', 'mAP_50', 'mAP_75', + 'mAP_s', 'mAP_m', 'mAP_l']`` will be used when + ``metric=='bbox' or metric=='segm'``. + + Returns: + dict[str, float]: COCO style evaluation metric. + """ + + metrics = metric if isinstance(metric, list) else [metric] + allowed_metrics = ['bbox', 'segm', 'proposal', 'proposal_fast'] + for metric in metrics: + if metric not in allowed_metrics: + raise KeyError(f'metric {metric} is not supported') + + coco_gt = self.coco + self.cat_ids = coco_gt.get_cat_ids(cat_names=self.CLASSES) + + result_files, tmp_dir = self.format_results(results, jsonfile_prefix) + eval_results = self.evaluate_det_segm(results, result_files, coco_gt, + metrics, logger, classwise, + proposal_nums, iou_thrs, + metric_items) + + if tmp_dir is not None: + tmp_dir.cleanup() + return eval_results diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/custom.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/custom.py index 935b39d2c..a4d825898 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/custom.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/custom.py @@ -1,47 +1,72 @@ +# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp +import warnings +from collections import OrderedDict import mmcv import numpy as np +from mmcv.utils import print_log +from terminaltables import AsciiTable from torch.utils.data import Dataset +from mmdet.core import eval_map, eval_recalls +from .builder import DATASETS from .pipelines import Compose -from .registry import DATASETS -@DATASETS.register_module +@DATASETS.register_module() class CustomDataset(Dataset): """Custom dataset for detection. - Annotation format: - [ - { - 'filename': 'a.jpg', - 'width': 1280, - 'height': 720, - 'ann': { - 'bboxes': (n, 4), - 'labels': (n, ), - 'bboxes_ignore': (k, 4), (optional field) - 'labels_ignore': (k, 4) (optional field) - } - }, - ... - ] - - The `ann` field is optional for testing. + The annotation format is shown as follows. The `ann` field is optional for + testing. + + .. code-block:: none + + [ + { + 'filename': 'a.jpg', + 'width': 1280, + 'height': 720, + 'ann': { + 'bboxes': (n, 4) in (x1, y1, x2, y2) order. + 'labels': (n, ), + 'bboxes_ignore': (k, 4), (optional field) + 'labels_ignore': (k, 4) (optional field) + } + }, + ... + ] + + Args: + ann_file (str): Annotation file path. + pipeline (list[dict]): Processing pipeline. + classes (str | Sequence[str], optional): Specify classes to load. + If is None, ``cls.CLASSES`` will be used. Default: None. + data_root (str, optional): Data root for ``ann_file``, + ``img_prefix``, ``seg_prefix``, ``proposal_file`` if specified. + test_mode (bool, optional): If set True, annotation will not be loaded. + filter_empty_gt (bool, optional): If set true, images without bounding + boxes of the dataset's classes will be filtered out. This option + only works when `test_mode=False`, i.e., we never filter images + during tests. """ CLASSES = None + PALETTE = None + def __init__(self, ann_file, pipeline, + classes=None, data_root=None, img_prefix='', seg_prefix=None, proposal_file=None, test_mode=False, - filter_empty_gt=True): + filter_empty_gt=True, + file_client_args=dict(backend='disk')): self.ann_file = ann_file self.data_root = data_root self.img_prefix = img_prefix @@ -49,6 +74,8 @@ class CustomDataset(Dataset): self.proposal_file = proposal_file self.test_mode = test_mode self.filter_empty_gt = filter_empty_gt + self.file_client = mmcv.FileClient(**file_client_args) + self.CLASSES = self.get_classes(classes) # join paths if data_root is specified if self.data_root is not None: @@ -63,36 +90,82 @@ class CustomDataset(Dataset): self.proposal_file = osp.join(self.data_root, self.proposal_file) # load annotations (and proposals) - self.img_infos = self.load_annotations(self.ann_file) + if hasattr(self.file_client, 'get_local_path'): + with self.file_client.get_local_path(self.ann_file) as local_path: + self.data_infos = self.load_annotations(local_path) + else: + warnings.warn( + 'The used MMCV version does not have get_local_path. ' + f'We treat the {self.ann_file} as local paths and it ' + 'might cause errors if the path is not a local path. ' + 'Please use MMCV>= 1.3.16 if you meet errors.') + self.data_infos = self.load_annotations(self.ann_file) + if self.proposal_file is not None: - self.proposals = self.load_proposals(self.proposal_file) + if hasattr(self.file_client, 'get_local_path'): + with self.file_client.get_local_path( + self.proposal_file) as local_path: + self.proposals = self.load_proposals(local_path) + else: + warnings.warn( + 'The used MMCV version does not have get_local_path. ' + f'We treat the {self.ann_file} as local paths and it ' + 'might cause errors if the path is not a local path. ' + 'Please use MMCV>= 1.3.16 if you meet errors.') + self.proposals = self.load_proposals(self.proposal_file) else: self.proposals = None - # filter images too small + + # filter images too small and containing no annotations if not test_mode: valid_inds = self._filter_imgs() - self.img_infos = [self.img_infos[i] for i in valid_inds] + self.data_infos = [self.data_infos[i] for i in valid_inds] if self.proposals is not None: self.proposals = [self.proposals[i] for i in valid_inds] - # set group flag for the sampler - if not self.test_mode: + # set group flag for the sampler self._set_group_flag() + # processing pipeline self.pipeline = Compose(pipeline) def __len__(self): - return len(self.img_infos) + """Total number of samples of data.""" + return len(self.data_infos) def load_annotations(self, ann_file): + """Load annotation from annotation file.""" return mmcv.load(ann_file) def load_proposals(self, proposal_file): + """Load proposal from proposal file.""" return mmcv.load(proposal_file) def get_ann_info(self, idx): - return self.img_infos[idx]['ann'] + """Get annotation by index. + + Args: + idx (int): Index of data. + + Returns: + dict: Annotation info of specified index. + """ + + return self.data_infos[idx]['ann'] + + def get_cat_ids(self, idx): + """Get category ids by index. + + Args: + idx (int): Index of data. + + Returns: + list[int]: All categories in the image of specified index. + """ + + return self.data_infos[idx]['ann']['labels'].astype(np.int).tolist() def pre_pipeline(self, results): + """Prepare results dict for pipeline.""" results['img_prefix'] = self.img_prefix results['seg_prefix'] = self.seg_prefix results['proposal_file'] = self.proposal_file @@ -102,8 +175,11 @@ class CustomDataset(Dataset): def _filter_imgs(self, min_size=32): """Filter images too small.""" + if self.filter_empty_gt: + warnings.warn( + 'CustomDataset does not support filtering empty gt images.') valid_inds = [] - for i, img_info in enumerate(self.img_infos): + for i, img_info in enumerate(self.data_infos): if min(img_info['width'], img_info['height']) >= min_size: valid_inds.append(i) return valid_inds @@ -116,15 +192,26 @@ class CustomDataset(Dataset): """ self.flag = np.zeros(len(self), dtype=np.uint8) for i in range(len(self)): - img_info = self.img_infos[i] + img_info = self.data_infos[i] if img_info['width'] / img_info['height'] > 1: self.flag[i] = 1 def _rand_another(self, idx): + """Get another random index from the same group as the given index.""" pool = np.where(self.flag == self.flag[idx])[0] return np.random.choice(pool) def __getitem__(self, idx): + """Get training/test data after pipeline. + + Args: + idx (int): Index of data. + + Returns: + dict: Training/test data (with annotation if `test_mode` is set \ + True). + """ + if self.test_mode: return self.prepare_test_img(idx) while True: @@ -135,7 +222,17 @@ class CustomDataset(Dataset): return data def prepare_train_img(self, idx): - img_info = self.img_infos[idx] + """Get training data and annotations after pipeline. + + Args: + idx (int): Index of data. + + Returns: + dict: Training data and annotation after pipeline with new keys \ + introduced by pipeline. + """ + + img_info = self.data_infos[idx] ann_info = self.get_ann_info(idx) results = dict(img_info=img_info, ann_info=ann_info) if self.proposals is not None: @@ -144,9 +241,170 @@ class CustomDataset(Dataset): return self.pipeline(results) def prepare_test_img(self, idx): - img_info = self.img_infos[idx] + """Get testing data after pipeline. + + Args: + idx (int): Index of data. + + Returns: + dict: Testing data after pipeline with new keys introduced by \ + pipeline. + """ + + img_info = self.data_infos[idx] results = dict(img_info=img_info) if self.proposals is not None: results['proposals'] = self.proposals[idx] self.pre_pipeline(results) return self.pipeline(results) + + @classmethod + def get_classes(cls, classes=None): + """Get class names of current dataset. + + Args: + classes (Sequence[str] | str | None): If classes is None, use + default CLASSES defined by builtin dataset. If classes is a + string, take it as a file name. The file contains the name of + classes where each line contains one class name. If classes is + a tuple or list, override the CLASSES defined by the dataset. + + Returns: + tuple[str] or list[str]: Names of categories of the dataset. + """ + if classes is None: + return cls.CLASSES + + if isinstance(classes, str): + # take it as a file path + class_names = mmcv.list_from_file(classes) + elif isinstance(classes, (tuple, list)): + class_names = classes + else: + raise ValueError(f'Unsupported type {type(classes)} of classes.') + + return class_names + + def get_cat2imgs(self): + """Get a dict with class as key and img_ids as values, which will be + used in :class:`ClassAwareSampler`. + + Returns: + dict[list]: A dict of per-label image list, + the item of the dict indicates a label index, + corresponds to the image index that contains the label. + """ + if self.CLASSES is None: + raise ValueError('self.CLASSES can not be None') + # sort the label index + cat2imgs = {i: [] for i in range(len(self.CLASSES))} + for i in range(len(self)): + cat_ids = set(self.get_cat_ids(i)) + for cat in cat_ids: + cat2imgs[cat].append(i) + return cat2imgs + + def format_results(self, results, **kwargs): + """Place holder to format result to dataset specific output.""" + + def evaluate(self, + results, + metric='mAP', + logger=None, + proposal_nums=(100, 300, 1000), + iou_thr=0.5, + scale_ranges=None): + """Evaluate the dataset. + + Args: + results (list): Testing results of the dataset. + metric (str | list[str]): Metrics to be evaluated. + logger (logging.Logger | None | str): Logger used for printing + related information during evaluation. Default: None. + proposal_nums (Sequence[int]): Proposal number used for evaluating + recalls, such as recall@100, recall@1000. + Default: (100, 300, 1000). + iou_thr (float | list[float]): IoU threshold. Default: 0.5. + scale_ranges (list[tuple] | None): Scale ranges for evaluating mAP. + Default: None. + """ + + if not isinstance(metric, str): + assert len(metric) == 1 + metric = metric[0] + allowed_metrics = ['mAP', 'recall'] + if metric not in allowed_metrics: + raise KeyError(f'metric {metric} is not supported') + annotations = [self.get_ann_info(i) for i in range(len(self))] + eval_results = OrderedDict() + iou_thrs = [iou_thr] if isinstance(iou_thr, float) else iou_thr + if metric == 'mAP': + assert isinstance(iou_thrs, list) + mean_aps = [] + for iou_thr in iou_thrs: + print_log(f'\n{"-" * 15}iou_thr: {iou_thr}{"-" * 15}') + mean_ap, _ = eval_map( + results, + annotations, + scale_ranges=scale_ranges, + iou_thr=iou_thr, + dataset=self.CLASSES, + logger=logger) + mean_aps.append(mean_ap) + eval_results[f'AP{int(iou_thr * 100):02d}'] = round(mean_ap, 3) + eval_results['mAP'] = sum(mean_aps) / len(mean_aps) + elif metric == 'recall': + gt_bboxes = [ann['bboxes'] for ann in annotations] + recalls = eval_recalls( + gt_bboxes, results, proposal_nums, iou_thr, logger=logger) + for i, num in enumerate(proposal_nums): + for j, iou in enumerate(iou_thrs): + eval_results[f'recall@{num}@{iou}'] = recalls[i, j] + if recalls.shape[1] > 1: + ar = recalls.mean(axis=1) + for i, num in enumerate(proposal_nums): + eval_results[f'AR@{num}'] = ar[i] + return eval_results + + def __repr__(self): + """Print the number of instance number.""" + dataset_type = 'Test' if self.test_mode else 'Train' + result = (f'\n{self.__class__.__name__} {dataset_type} dataset ' + f'with number of images {len(self)}, ' + f'and instance counts: \n') + if self.CLASSES is None: + result += 'Category names are not provided. \n' + return result + instance_count = np.zeros(len(self.CLASSES) + 1).astype(int) + # count the instance number in each image + for idx in range(len(self)): + label = self.get_ann_info(idx)['labels'] + unique, counts = np.unique(label, return_counts=True) + if len(unique) > 0: + # add the occurrence number to each class + instance_count[unique] += counts + else: + # background is the last index + instance_count[-1] += 1 + # create a table with category count + table_data = [['category', 'count'] * 5] + row_data = [] + for cls, count in enumerate(instance_count): + if cls < len(self.CLASSES): + row_data += [f'{cls} [{self.CLASSES[cls]}]', f'{count}'] + else: + # add the background number + row_data += ['-1 background', f'{count}'] + if len(row_data) == 10: + table_data.append(row_data) + row_data = [] + if len(row_data) >= 2: + if row_data[-1] == '0': + row_data = row_data[:-2] + if len(row_data) >= 2: + table_data.append([]) + table_data.append(row_data) + + table = AsciiTable(table_data) + result += table.table + return result diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/dataset_wrappers.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/dataset_wrappers.py index e749cb076..e62b88eb6 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/dataset_wrappers.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/dataset_wrappers.py @@ -1,10 +1,19 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import bisect +import collections +import copy +import math +from collections import defaultdict + import numpy as np +from mmcv.utils import build_from_cfg, print_log from torch.utils.data.dataset import ConcatDataset as _ConcatDataset -from .registry import DATASETS +from .builder import DATASETS, PIPELINES +from .coco import CocoDataset -@DATASETS.register_module +@DATASETS.register_module() class ConcatDataset(_ConcatDataset): """A wrapper of concatenated dataset. @@ -13,20 +22,136 @@ class ConcatDataset(_ConcatDataset): Args: datasets (list[:obj:`Dataset`]): A list of datasets. + separate_eval (bool): Whether to evaluate the results + separately if it is used as validation dataset. + Defaults to True. """ - def __init__(self, datasets): + def __init__(self, datasets, separate_eval=True): super(ConcatDataset, self).__init__(datasets) self.CLASSES = datasets[0].CLASSES + self.PALETTE = getattr(datasets[0], 'PALETTE', None) + self.separate_eval = separate_eval + if not separate_eval: + if any([isinstance(ds, CocoDataset) for ds in datasets]): + raise NotImplementedError( + 'Evaluating concatenated CocoDataset as a whole is not' + ' supported! Please set "separate_eval=True"') + elif len(set([type(ds) for ds in datasets])) != 1: + raise NotImplementedError( + 'All the datasets should have same types') + if hasattr(datasets[0], 'flag'): flags = [] for i in range(0, len(datasets)): flags.append(datasets[i].flag) self.flag = np.concatenate(flags) + def get_cat_ids(self, idx): + """Get category ids of concatenated dataset by index. + + Args: + idx (int): Index of data. + + Returns: + list[int]: All categories in the image of specified index. + """ + + if idx < 0: + if -idx > len(self): + raise ValueError( + 'absolute value of index should not exceed dataset length') + idx = len(self) + idx + dataset_idx = bisect.bisect_right(self.cumulative_sizes, idx) + if dataset_idx == 0: + sample_idx = idx + else: + sample_idx = idx - self.cumulative_sizes[dataset_idx - 1] + return self.datasets[dataset_idx].get_cat_ids(sample_idx) + + def get_ann_info(self, idx): + """Get annotation of concatenated dataset by index. + + Args: + idx (int): Index of data. + + Returns: + dict: Annotation info of specified index. + """ + + if idx < 0: + if -idx > len(self): + raise ValueError( + 'absolute value of index should not exceed dataset length') + idx = len(self) + idx + dataset_idx = bisect.bisect_right(self.cumulative_sizes, idx) + if dataset_idx == 0: + sample_idx = idx + else: + sample_idx = idx - self.cumulative_sizes[dataset_idx - 1] + return self.datasets[dataset_idx].get_ann_info(sample_idx) + + def evaluate(self, results, logger=None, **kwargs): + """Evaluate the results. -@DATASETS.register_module -class RepeatDataset(object): + Args: + results (list[list | tuple]): Testing results of the dataset. + logger (logging.Logger | str | None): Logger used for printing + related information during evaluation. Default: None. + + Returns: + dict[str: float]: AP results of the total dataset or each separate + dataset if `self.separate_eval=True`. + """ + assert len(results) == self.cumulative_sizes[-1], \ + ('Dataset and results have different sizes: ' + f'{self.cumulative_sizes[-1]} v.s. {len(results)}') + + # Check whether all the datasets support evaluation + for dataset in self.datasets: + assert hasattr(dataset, 'evaluate'), \ + f'{type(dataset)} does not implement evaluate function' + + if self.separate_eval: + dataset_idx = -1 + total_eval_results = dict() + for size, dataset in zip(self.cumulative_sizes, self.datasets): + start_idx = 0 if dataset_idx == -1 else \ + self.cumulative_sizes[dataset_idx] + end_idx = self.cumulative_sizes[dataset_idx + 1] + + results_per_dataset = results[start_idx:end_idx] + print_log( + f'\nEvaluateing {dataset.ann_file} with ' + f'{len(results_per_dataset)} images now', + logger=logger) + + eval_results_per_dataset = dataset.evaluate( + results_per_dataset, logger=logger, **kwargs) + dataset_idx += 1 + for k, v in eval_results_per_dataset.items(): + total_eval_results.update({f'{dataset_idx}_{k}': v}) + + return total_eval_results + elif any([isinstance(ds, CocoDataset) for ds in self.datasets]): + raise NotImplementedError( + 'Evaluating concatenated CocoDataset as a whole is not' + ' supported! Please set "separate_eval=True"') + elif len(set([type(ds) for ds in self.datasets])) != 1: + raise NotImplementedError( + 'All the datasets should have same types') + else: + original_data_infos = self.datasets[0].data_infos + self.datasets[0].data_infos = sum( + [dataset.data_infos for dataset in self.datasets], []) + eval_results = self.datasets[0].evaluate( + results, logger=logger, **kwargs) + self.datasets[0].data_infos = original_data_infos + return eval_results + + +@DATASETS.register_module() +class RepeatDataset: """A wrapper of repeated dataset. The length of repeated dataset will be `times` larger than the original @@ -43,6 +168,7 @@ class RepeatDataset(object): self.dataset = dataset self.times = times self.CLASSES = dataset.CLASSES + self.PALETTE = getattr(dataset, 'PALETTE', None) if hasattr(self.dataset, 'flag'): self.flag = np.tile(self.dataset.flag, times) @@ -51,5 +177,280 @@ class RepeatDataset(object): def __getitem__(self, idx): return self.dataset[idx % self._ori_len] + def get_cat_ids(self, idx): + """Get category ids of repeat dataset by index. + + Args: + idx (int): Index of data. + + Returns: + list[int]: All categories in the image of specified index. + """ + + return self.dataset.get_cat_ids(idx % self._ori_len) + + def get_ann_info(self, idx): + """Get annotation of repeat dataset by index. + + Args: + idx (int): Index of data. + + Returns: + dict: Annotation info of specified index. + """ + + return self.dataset.get_ann_info(idx % self._ori_len) + def __len__(self): + """Length after repetition.""" return self.times * self._ori_len + + +# Modified from https://github.com/facebookresearch/detectron2/blob/41d475b75a230221e21d9cac5d69655e3415e3a4/detectron2/data/samplers/distributed_sampler.py#L57 # noqa +@DATASETS.register_module() +class ClassBalancedDataset: + """A wrapper of repeated dataset with repeat factor. + + Suitable for training on class imbalanced datasets like LVIS. Following + the sampling strategy in the `paper `_, + in each epoch, an image may appear multiple times based on its + "repeat factor". + The repeat factor for an image is a function of the frequency the rarest + category labeled in that image. The "frequency of category c" in [0, 1] + is defined by the fraction of images in the training set (without repeats) + in which category c appears. + The dataset needs to instantiate :func:`self.get_cat_ids` to support + ClassBalancedDataset. + + The repeat factor is computed as followed. + + 1. For each category c, compute the fraction # of images + that contain it: :math:`f(c)` + 2. For each category c, compute the category-level repeat factor: + :math:`r(c) = max(1, sqrt(t/f(c)))` + 3. For each image I, compute the image-level repeat factor: + :math:`r(I) = max_{c in I} r(c)` + + Args: + dataset (:obj:`CustomDataset`): The dataset to be repeated. + oversample_thr (float): frequency threshold below which data is + repeated. For categories with ``f_c >= oversample_thr``, there is + no oversampling. For categories with ``f_c < oversample_thr``, the + degree of oversampling following the square-root inverse frequency + heuristic above. + filter_empty_gt (bool, optional): If set true, images without bounding + boxes will not be oversampled. Otherwise, they will be categorized + as the pure background class and involved into the oversampling. + Default: True. + """ + + def __init__(self, dataset, oversample_thr, filter_empty_gt=True): + self.dataset = dataset + self.oversample_thr = oversample_thr + self.filter_empty_gt = filter_empty_gt + self.CLASSES = dataset.CLASSES + self.PALETTE = getattr(dataset, 'PALETTE', None) + + repeat_factors = self._get_repeat_factors(dataset, oversample_thr) + repeat_indices = [] + for dataset_idx, repeat_factor in enumerate(repeat_factors): + repeat_indices.extend([dataset_idx] * math.ceil(repeat_factor)) + self.repeat_indices = repeat_indices + + flags = [] + if hasattr(self.dataset, 'flag'): + for flag, repeat_factor in zip(self.dataset.flag, repeat_factors): + flags.extend([flag] * int(math.ceil(repeat_factor))) + assert len(flags) == len(repeat_indices) + self.flag = np.asarray(flags, dtype=np.uint8) + + def _get_repeat_factors(self, dataset, repeat_thr): + """Get repeat factor for each images in the dataset. + + Args: + dataset (:obj:`CustomDataset`): The dataset + repeat_thr (float): The threshold of frequency. If an image + contains the categories whose frequency below the threshold, + it would be repeated. + + Returns: + list[float]: The repeat factors for each images in the dataset. + """ + + # 1. For each category c, compute the fraction # of images + # that contain it: f(c) + category_freq = defaultdict(int) + num_images = len(dataset) + for idx in range(num_images): + cat_ids = set(self.dataset.get_cat_ids(idx)) + if len(cat_ids) == 0 and not self.filter_empty_gt: + cat_ids = set([len(self.CLASSES)]) + for cat_id in cat_ids: + category_freq[cat_id] += 1 + for k, v in category_freq.items(): + category_freq[k] = v / num_images + + # 2. For each category c, compute the category-level repeat factor: + # r(c) = max(1, sqrt(t/f(c))) + category_repeat = { + cat_id: max(1.0, math.sqrt(repeat_thr / cat_freq)) + for cat_id, cat_freq in category_freq.items() + } + + # 3. For each image I, compute the image-level repeat factor: + # r(I) = max_{c in I} r(c) + repeat_factors = [] + for idx in range(num_images): + cat_ids = set(self.dataset.get_cat_ids(idx)) + if len(cat_ids) == 0 and not self.filter_empty_gt: + cat_ids = set([len(self.CLASSES)]) + repeat_factor = 1 + if len(cat_ids) > 0: + repeat_factor = max( + {category_repeat[cat_id] + for cat_id in cat_ids}) + repeat_factors.append(repeat_factor) + + return repeat_factors + + def __getitem__(self, idx): + ori_index = self.repeat_indices[idx] + return self.dataset[ori_index] + + def get_ann_info(self, idx): + """Get annotation of dataset by index. + + Args: + idx (int): Index of data. + + Returns: + dict: Annotation info of specified index. + """ + ori_index = self.repeat_indices[idx] + return self.dataset.get_ann_info(ori_index) + + def __len__(self): + """Length after repetition.""" + return len(self.repeat_indices) + + +@DATASETS.register_module() +class MultiImageMixDataset: + """A wrapper of multiple images mixed dataset. + + Suitable for training on multiple images mixed data augmentation like + mosaic and mixup. For the augmentation pipeline of mixed image data, + the `get_indexes` method needs to be provided to obtain the image + indexes, and you can set `skip_flags` to change the pipeline running + process. At the same time, we provide the `dynamic_scale` parameter + to dynamically change the output image size. + + Args: + dataset (:obj:`CustomDataset`): The dataset to be mixed. + pipeline (Sequence[dict]): Sequence of transform object or + config dict to be composed. + dynamic_scale (tuple[int], optional): The image scale can be changed + dynamically. Default to None. It is deprecated. + skip_type_keys (list[str], optional): Sequence of type string to + be skip pipeline. Default to None. + max_refetch (int): The maximum number of retry iterations for getting + valid results from the pipeline. If the number of iterations is + greater than `max_refetch`, but results is still None, then the + iteration is terminated and raise the error. Default: 15. + """ + + def __init__(self, + dataset, + pipeline, + dynamic_scale=None, + skip_type_keys=None, + max_refetch=15): + if dynamic_scale is not None: + raise RuntimeError( + 'dynamic_scale is deprecated. Please use Resize pipeline ' + 'to achieve similar functions') + assert isinstance(pipeline, collections.abc.Sequence) + if skip_type_keys is not None: + assert all([ + isinstance(skip_type_key, str) + for skip_type_key in skip_type_keys + ]) + self._skip_type_keys = skip_type_keys + + self.pipeline = [] + self.pipeline_types = [] + for transform in pipeline: + if isinstance(transform, dict): + self.pipeline_types.append(transform['type']) + transform = build_from_cfg(transform, PIPELINES) + self.pipeline.append(transform) + else: + raise TypeError('pipeline must be a dict') + + self.dataset = dataset + self.CLASSES = dataset.CLASSES + self.PALETTE = getattr(dataset, 'PALETTE', None) + if hasattr(self.dataset, 'flag'): + self.flag = dataset.flag + self.num_samples = len(dataset) + self.max_refetch = max_refetch + + def __len__(self): + return self.num_samples + + def __getitem__(self, idx): + results = copy.deepcopy(self.dataset[idx]) + for (transform, transform_type) in zip(self.pipeline, + self.pipeline_types): + if self._skip_type_keys is not None and \ + transform_type in self._skip_type_keys: + continue + + if hasattr(transform, 'get_indexes'): + for i in range(self.max_refetch): + # Make sure the results passed the loading pipeline + # of the original dataset is not None. + indexes = transform.get_indexes(self.dataset) + if not isinstance(indexes, collections.abc.Sequence): + indexes = [indexes] + mix_results = [ + copy.deepcopy(self.dataset[index]) for index in indexes + ] + if None not in mix_results: + results['mix_results'] = mix_results + break + else: + raise RuntimeError( + 'The loading pipeline of the original dataset' + ' always return None. Please check the correctness ' + 'of the dataset and its pipeline.') + + for i in range(self.max_refetch): + # To confirm the results passed the training pipeline + # of the wrapper is not None. + updated_results = transform(copy.deepcopy(results)) + if updated_results is not None: + results = updated_results + break + else: + raise RuntimeError( + 'The training pipeline of the dataset wrapper' + ' always return None.Please check the correctness ' + 'of the dataset and its pipeline.') + + if 'mix_results' in results: + results.pop('mix_results') + + return results + + def update_skip_type_keys(self, skip_type_keys): + """Update skip_type_keys. It is called by an external hook. + + Args: + skip_type_keys (list[str], optional): Sequence of type + string to be skip pipeline. + """ + assert all([ + isinstance(skip_type_key, str) for skip_type_key in skip_type_keys + ]) + self._skip_type_keys = skip_type_keys diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/__init__.py deleted file mode 100644 index 4404615be..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from .build_loader import build_dataloader -from .sampler import DistributedGroupSampler, GroupSampler - -__all__ = ['GroupSampler', 'DistributedGroupSampler', 'build_dataloader'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/build_loader.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/build_loader.py deleted file mode 100644 index e9431d7ba..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/build_loader.py +++ /dev/null @@ -1,70 +0,0 @@ -import platform -from functools import partial - -from mmcv.parallel import collate -from mmcv.runner import get_dist_info -from torch.utils.data import DataLoader - -from .sampler import DistributedGroupSampler, DistributedSampler, GroupSampler - -if platform.system() != 'Windows': - # https://github.com/pytorch/pytorch/issues/973 - import resource - rlimit = resource.getrlimit(resource.RLIMIT_NOFILE) - resource.setrlimit(resource.RLIMIT_NOFILE, (4096, rlimit[1])) - - -def build_dataloader(dataset, - imgs_per_gpu, - workers_per_gpu, - num_gpus=1, - dist=True, - shuffle=True, - **kwargs): - """Build PyTorch DataLoader. - - In distributed training, each GPU/process has a dataloader. - In non-distributed training, there is only one dataloader for all GPUs. - - Args: - dataset (Dataset): A PyTorch dataset. - imgs_per_gpu (int): Number of images on each GPU, i.e., batch size of - each GPU. - workers_per_gpu (int): How many subprocesses to use for data loading - for each GPU. - num_gpus (int): Number of GPUs. Only used in non-distributed training. - dist (bool): Distributed training/test or not. Default: True. - shuffle (bool): Whether to shuffle the data at every epoch. - Default: True. - kwargs: any keyword argument to be used to initialize DataLoader - - Returns: - DataLoader: A PyTorch dataloader. - """ - if dist: - rank, world_size = get_dist_info() - # DistributedGroupSampler will definitely shuffle the data to satisfy - # that images on each GPU are in the same group - if shuffle: - sampler = DistributedGroupSampler(dataset, imgs_per_gpu, - world_size, rank) - else: - sampler = DistributedSampler( - dataset, world_size, rank, shuffle=False) - batch_size = imgs_per_gpu - num_workers = workers_per_gpu - else: - sampler = GroupSampler(dataset, imgs_per_gpu) if shuffle else None - batch_size = num_gpus * imgs_per_gpu - num_workers = num_gpus * workers_per_gpu - - data_loader = DataLoader( - dataset, - batch_size=batch_size, - sampler=sampler, - num_workers=num_workers, - collate_fn=partial(collate, samples_per_gpu=imgs_per_gpu), - pin_memory=False, - **kwargs) - - return data_loader diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/__init__.py index fca8d984c..e722b3697 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/__init__.py @@ -1,17 +1,15 @@ +# Copyright (c) 2022, Shanghai Iluvatar CoreX Semiconductor Co., Ltd. +# Copyright (c) OpenMMLab. All rights reserved. from .compose import Compose -from .formating import (Collect, ImageToTensor, ToDataContainer, ToTensor, - Transpose, to_tensor) -from .instaboost import InstaBoost -from .loading import LoadAnnotations, LoadImageFromFile, LoadProposals -from .test_aug import MultiScaleFlipAug -from .transforms import (Albu, Expand, MinIoURandomCrop, Normalize, Pad, - PhotoMetricDistortion, RandomCrop, RandomFlip, Resize, - SegRescale) +from .formatting import (Collect, DefaultFormatBundle, ImageToTensor, + ToDataContainer, ToTensor, Transpose, to_tensor) +from .loading import (FilterAnnotations, LoadAnnotations, LoadImageFromFile, + LoadImageFromWebcam, LoadMultiChannelImageFromFiles, + LoadPanopticAnnotations, LoadProposals) +from .test_time_aug import MultiScaleFlipAug +from .transforms import (Albu, CopyPaste, CutOut, Expand, MinIoURandomCrop, + MixUp, Mosaic, Normalize, Pad, PhotoMetricDistortion, + RandomAffine, RandomCenterCropPad, RandomCrop, + RandomFlip, RandomShift, Resize, SegRescale, + YOLOXHSVRandomAug) -__all__ = [ - 'Compose', 'to_tensor', 'ToTensor', 'ImageToTensor', 'ToDataContainer', - 'Transpose', 'Collect', 'LoadAnnotations', 'LoadImageFromFile', - 'LoadProposals', 'MultiScaleFlipAug', 'Resize', 'RandomFlip', 'Pad', - 'RandomCrop', 'Normalize', 'SegRescale', 'MinIoURandomCrop', 'Expand', - 'PhotoMetricDistortion', 'Albu', 'InstaBoost' -] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/compose.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/compose.py index f160eed97..d75922009 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/compose.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/compose.py @@ -1,11 +1,19 @@ +# Copyright (c) OpenMMLab. All rights reserved. import collections -from mmdet.utils import build_from_cfg -from ..registry import PIPELINES +from mmcv.utils import build_from_cfg +from ..builder import PIPELINES -@PIPELINES.register_module -class Compose(object): + +@PIPELINES.register_module() +class Compose: + """Compose multiple transforms sequentially. + + Args: + transforms (Sequence[dict | callable]): Sequence of transform object or + config dict to be composed. + """ def __init__(self, transforms): assert isinstance(transforms, collections.abc.Sequence) @@ -20,6 +28,15 @@ class Compose(object): raise TypeError('transform must be callable or a dict') def __call__(self, data): + """Call function to apply transforms sequentially. + + Args: + data (dict): A result dict contains the data to transform. + + Returns: + dict: Transformed data. + """ + for t in self.transforms: data = t(data) if data is None: @@ -29,7 +46,10 @@ class Compose(object): def __repr__(self): format_string = self.__class__.__name__ + '(' for t in self.transforms: + str_ = t.__repr__() + if 'Compose(' in str_: + str_ = str_.replace('\n', '\n ') format_string += '\n' - format_string += ' {0}'.format(t) + format_string += f' {str_}' format_string += '\n)' return format_string diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/formating.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/formating.py index e14dd0a97..3b3e45abb 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/formating.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/formating.py @@ -1,192 +1,9 @@ -from collections.abc import Sequence +# Copyright (c) OpenMMLab. All rights reserved. +# flake8: noqa +import warnings -import mmcv -import numpy as np -import torch -from mmcv.parallel import DataContainer as DC +from .formatting import * -from ..registry import PIPELINES - - -def to_tensor(data): - """Convert objects of various python types to :obj:`torch.Tensor`. - - Supported types are: :class:`numpy.ndarray`, :class:`torch.Tensor`, - :class:`Sequence`, :class:`int` and :class:`float`. - """ - if isinstance(data, torch.Tensor): - return data - elif isinstance(data, np.ndarray): - return torch.from_numpy(data) - elif isinstance(data, Sequence) and not mmcv.is_str(data): - return torch.tensor(data) - elif isinstance(data, int): - return torch.LongTensor([data]) - elif isinstance(data, float): - return torch.FloatTensor([data]) - else: - raise TypeError('type {} cannot be converted to tensor.'.format( - type(data))) - - -@PIPELINES.register_module -class ToTensor(object): - - def __init__(self, keys): - self.keys = keys - - def __call__(self, results): - for key in self.keys: - results[key] = to_tensor(results[key]) - return results - - def __repr__(self): - return self.__class__.__name__ + '(keys={})'.format(self.keys) - - -@PIPELINES.register_module -class ImageToTensor(object): - - def __init__(self, keys): - self.keys = keys - - def __call__(self, results): - for key in self.keys: - img = results[key] - if len(img.shape) < 3: - img = np.expand_dims(img, -1) - results[key] = to_tensor(img.transpose(2, 0, 1)) - return results - - def __repr__(self): - return self.__class__.__name__ + '(keys={})'.format(self.keys) - - -@PIPELINES.register_module -class Transpose(object): - - def __init__(self, keys, order): - self.keys = keys - self.order = order - - def __call__(self, results): - for key in self.keys: - results[key] = results[key].transpose(self.order) - return results - - def __repr__(self): - return self.__class__.__name__ + '(keys={}, order={})'.format( - self.keys, self.order) - - -@PIPELINES.register_module -class ToDataContainer(object): - - def __init__(self, - fields=(dict(key='img', stack=True), dict(key='gt_bboxes'), - dict(key='gt_labels'))): - self.fields = fields - - def __call__(self, results): - for field in self.fields: - field = field.copy() - key = field.pop('key') - results[key] = DC(results[key], **field) - return results - - def __repr__(self): - return self.__class__.__name__ + '(fields={})'.format(self.fields) - - -@PIPELINES.register_module -class DefaultFormatBundle(object): - """Default formatting bundle. - - It simplifies the pipeline of formatting common fields, including "img", - "proposals", "gt_bboxes", "gt_labels", "gt_masks" and "gt_semantic_seg". - These fields are formatted as follows. - - - img: (1)transpose, (2)to tensor, (3)to DataContainer (stack=True) - - proposals: (1)to tensor, (2)to DataContainer - - gt_bboxes: (1)to tensor, (2)to DataContainer - - gt_bboxes_ignore: (1)to tensor, (2)to DataContainer - - gt_labels: (1)to tensor, (2)to DataContainer - - gt_masks: (1)to tensor, (2)to DataContainer (cpu_only=True) - - gt_semantic_seg: (1)unsqueeze dim-0 (2)to tensor, - (3)to DataContainer (stack=True) - """ - - def __call__(self, results): - if 'img' in results: - img = results['img'] - if len(img.shape) < 3: - img = np.expand_dims(img, -1) - img = np.ascontiguousarray(img.transpose(2, 0, 1)) - results['img'] = DC(to_tensor(img), stack=True) - for key in ['proposals', 'gt_bboxes', 'gt_bboxes_ignore', 'gt_labels']: - if key not in results: - continue - results[key] = DC(to_tensor(results[key])) - if 'gt_masks' in results: - results['gt_masks'] = DC(results['gt_masks'], cpu_only=True) - if 'gt_semantic_seg' in results: - results['gt_semantic_seg'] = DC( - to_tensor(results['gt_semantic_seg'][None, ...]), stack=True) - return results - - def __repr__(self): - return self.__class__.__name__ - - -@PIPELINES.register_module -class Collect(object): - """ - Collect data from the loader relevant to the specific task. - - This is usually the last stage of the data loader pipeline. Typically keys - is set to some subset of "img", "proposals", "gt_bboxes", - "gt_bboxes_ignore", "gt_labels", and/or "gt_masks". - - The "img_meta" item is always populated. The contents of the "img_meta" - dictionary depends on "meta_keys". By default this includes: - - - "img_shape": shape of the image input to the network as a tuple - (h, w, c). Note that images may be zero padded on the bottom/right - if the batch tensor is larger than this shape. - - - "scale_factor": a float indicating the preprocessing scale - - - "flip": a boolean indicating if image flip transform was used - - - "filename": path to the image file - - - "ori_shape": original shape of the image as a tuple (h, w, c) - - - "pad_shape": image shape after padding - - - "img_norm_cfg": a dict of normalization information: - - mean - per channel mean subtraction - - std - per channel std divisor - - to_rgb - bool indicating if bgr was converted to rgb - """ - - def __init__(self, - keys, - meta_keys=('filename', 'ori_shape', 'img_shape', 'pad_shape', - 'scale_factor', 'flip', 'img_norm_cfg')): - self.keys = keys - self.meta_keys = meta_keys - - def __call__(self, results): - data = {} - img_meta = {} - for key in self.meta_keys: - img_meta[key] = results[key] - data['img_meta'] = DC(img_meta, cpu_only=True) - for key in self.keys: - data[key] = results[key] - return data - - def __repr__(self): - return self.__class__.__name__ + '(keys={}, meta_keys={})'.format( - self.keys, self.meta_keys) +warnings.warn('DeprecationWarning: mmdet.datasets.pipelines.formating will be ' + 'deprecated, please replace it with ' + 'mmdet.datasets.pipelines.formatting.') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/formatting.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/formatting.py new file mode 100644 index 000000000..45ca69cfc --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/formatting.py @@ -0,0 +1,392 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from collections.abc import Sequence + +import mmcv +import numpy as np +import torch +from mmcv.parallel import DataContainer as DC + +from ..builder import PIPELINES + + +def to_tensor(data): + """Convert objects of various python types to :obj:`torch.Tensor`. + + Supported types are: :class:`numpy.ndarray`, :class:`torch.Tensor`, + :class:`Sequence`, :class:`int` and :class:`float`. + + Args: + data (torch.Tensor | numpy.ndarray | Sequence | int | float): Data to + be converted. + """ + + if isinstance(data, torch.Tensor): + return data + elif isinstance(data, np.ndarray): + return torch.from_numpy(data) + elif isinstance(data, Sequence) and not mmcv.is_str(data): + return torch.tensor(data) + elif isinstance(data, int): + return torch.LongTensor([data]) + elif isinstance(data, float): + return torch.FloatTensor([data]) + else: + raise TypeError(f'type {type(data)} cannot be converted to tensor.') + + +@PIPELINES.register_module() +class ToTensor: + """Convert some results to :obj:`torch.Tensor` by given keys. + + Args: + keys (Sequence[str]): Keys that need to be converted to Tensor. + """ + + def __init__(self, keys): + self.keys = keys + + def __call__(self, results): + """Call function to convert data in results to :obj:`torch.Tensor`. + + Args: + results (dict): Result dict contains the data to convert. + + Returns: + dict: The result dict contains the data converted + to :obj:`torch.Tensor`. + """ + for key in self.keys: + results[key] = to_tensor(results[key]) + return results + + def __repr__(self): + return self.__class__.__name__ + f'(keys={self.keys})' + + +@PIPELINES.register_module() +class ImageToTensor: + """Convert image to :obj:`torch.Tensor` by given keys. + + The dimension order of input image is (H, W, C). The pipeline will convert + it to (C, H, W). If only 2 dimension (H, W) is given, the output would be + (1, H, W). + + Args: + keys (Sequence[str]): Key of images to be converted to Tensor. + """ + + def __init__(self, keys): + self.keys = keys + + def __call__(self, results): + """Call function to convert image in results to :obj:`torch.Tensor` and + transpose the channel order. + + Args: + results (dict): Result dict contains the image data to convert. + + Returns: + dict: The result dict contains the image converted + to :obj:`torch.Tensor` and transposed to (C, H, W) order. + """ + for key in self.keys: + img = results[key] + if len(img.shape) < 3: + img = np.expand_dims(img, -1) + results[key] = (to_tensor(img.transpose(2, 0, 1))).contiguous() + return results + + def __repr__(self): + return self.__class__.__name__ + f'(keys={self.keys})' + + +@PIPELINES.register_module() +class Transpose: + """Transpose some results by given keys. + + Args: + keys (Sequence[str]): Keys of results to be transposed. + order (Sequence[int]): Order of transpose. + """ + + def __init__(self, keys, order): + self.keys = keys + self.order = order + + def __call__(self, results): + """Call function to transpose the channel order of data in results. + + Args: + results (dict): Result dict contains the data to transpose. + + Returns: + dict: The result dict contains the data transposed to \ + ``self.order``. + """ + for key in self.keys: + results[key] = results[key].transpose(self.order) + return results + + def __repr__(self): + return self.__class__.__name__ + \ + f'(keys={self.keys}, order={self.order})' + + +@PIPELINES.register_module() +class ToDataContainer: + """Convert results to :obj:`mmcv.DataContainer` by given fields. + + Args: + fields (Sequence[dict]): Each field is a dict like + ``dict(key='xxx', **kwargs)``. The ``key`` in result will + be converted to :obj:`mmcv.DataContainer` with ``**kwargs``. + Default: ``(dict(key='img', stack=True), dict(key='gt_bboxes'), + dict(key='gt_labels'))``. + """ + + def __init__(self, + fields=(dict(key='img', stack=True), dict(key='gt_bboxes'), + dict(key='gt_labels'))): + self.fields = fields + + def __call__(self, results): + """Call function to convert data in results to + :obj:`mmcv.DataContainer`. + + Args: + results (dict): Result dict contains the data to convert. + + Returns: + dict: The result dict contains the data converted to \ + :obj:`mmcv.DataContainer`. + """ + + for field in self.fields: + field = field.copy() + key = field.pop('key') + results[key] = DC(results[key], **field) + return results + + def __repr__(self): + return self.__class__.__name__ + f'(fields={self.fields})' + + +@PIPELINES.register_module() +class DefaultFormatBundle: + """Default formatting bundle. + + It simplifies the pipeline of formatting common fields, including "img", + "proposals", "gt_bboxes", "gt_labels", "gt_masks" and "gt_semantic_seg". + These fields are formatted as follows. + + - img: (1)transpose, (2)to tensor, (3)to DataContainer (stack=True) + - proposals: (1)to tensor, (2)to DataContainer + - gt_bboxes: (1)to tensor, (2)to DataContainer + - gt_bboxes_ignore: (1)to tensor, (2)to DataContainer + - gt_labels: (1)to tensor, (2)to DataContainer + - gt_masks: (1)to tensor, (2)to DataContainer (cpu_only=True) + - gt_semantic_seg: (1)unsqueeze dim-0 (2)to tensor, \ + (3)to DataContainer (stack=True) + + Args: + img_to_float (bool): Whether to force the image to be converted to + float type. Default: True. + pad_val (dict): A dict for padding value in batch collating, + the default value is `dict(img=0, masks=0, seg=255)`. + Without this argument, the padding value of "gt_semantic_seg" + will be set to 0 by default, which should be 255. + """ + + def __init__(self, + img_to_float=True, + pad_val=dict(img=0, masks=0, seg=255)): + self.img_to_float = img_to_float + self.pad_val = pad_val + + def __call__(self, results): + """Call function to transform and format common fields in results. + + Args: + results (dict): Result dict contains the data to convert. + + Returns: + dict: The result dict contains the data that is formatted with \ + default bundle. + """ + + if 'img' in results: + img = results['img'] + if self.img_to_float is True and img.dtype == np.uint8: + # Normally, image is of uint8 type without normalization. + # At this time, it needs to be forced to be converted to + # flot32, otherwise the model training and inference + # will be wrong. Only used for YOLOX currently . + img = img.astype(np.float32) + # add default meta keys + results = self._add_default_meta_keys(results) + if len(img.shape) < 3: + img = np.expand_dims(img, -1) + img = np.ascontiguousarray(img.transpose(2, 0, 1)) + results['img'] = DC( + to_tensor(img), padding_value=self.pad_val['img'], stack=True) + for key in ['proposals', 'gt_bboxes', 'gt_bboxes_ignore', 'gt_labels']: + if key not in results: + continue + results[key] = DC(to_tensor(results[key])) + if 'gt_masks' in results: + results['gt_masks'] = DC( + results['gt_masks'], + padding_value=self.pad_val['masks'], + cpu_only=True) + if 'gt_semantic_seg' in results: + results['gt_semantic_seg'] = DC( + to_tensor(results['gt_semantic_seg'][None, ...]), + padding_value=self.pad_val['seg'], + stack=True) + return results + + def _add_default_meta_keys(self, results): + """Add default meta keys. + + We set default meta keys including `pad_shape`, `scale_factor` and + `img_norm_cfg` to avoid the case where no `Resize`, `Normalize` and + `Pad` are implemented during the whole pipeline. + + Args: + results (dict): Result dict contains the data to convert. + + Returns: + results (dict): Updated result dict contains the data to convert. + """ + img = results['img'] + results.setdefault('pad_shape', img.shape) + results.setdefault('scale_factor', 1.0) + num_channels = 1 if len(img.shape) < 3 else img.shape[2] + results.setdefault( + 'img_norm_cfg', + dict( + mean=np.zeros(num_channels, dtype=np.float32), + std=np.ones(num_channels, dtype=np.float32), + to_rgb=False)) + return results + + def __repr__(self): + return self.__class__.__name__ + \ + f'(img_to_float={self.img_to_float})' + + +@PIPELINES.register_module() +class Collect: + """Collect data from the loader relevant to the specific task. + + This is usually the last stage of the data loader pipeline. Typically keys + is set to some subset of "img", "proposals", "gt_bboxes", + "gt_bboxes_ignore", "gt_labels", and/or "gt_masks". + + The "img_meta" item is always populated. The contents of the "img_meta" + dictionary depends on "meta_keys". By default this includes: + + - "img_shape": shape of the image input to the network as a tuple \ + (h, w, c). Note that images may be zero padded on the \ + bottom/right if the batch tensor is larger than this shape. + + - "scale_factor": a float indicating the preprocessing scale + + - "flip": a boolean indicating if image flip transform was used + + - "filename": path to the image file + + - "ori_shape": original shape of the image as a tuple (h, w, c) + + - "pad_shape": image shape after padding + + - "img_norm_cfg": a dict of normalization information: + + - mean - per channel mean subtraction + - std - per channel std divisor + - to_rgb - bool indicating if bgr was converted to rgb + + Args: + keys (Sequence[str]): Keys of results to be collected in ``data``. + meta_keys (Sequence[str], optional): Meta keys to be converted to + ``mmcv.DataContainer`` and collected in ``data[img_metas]``. + Default: ``('filename', 'ori_filename', 'ori_shape', 'img_shape', + 'pad_shape', 'scale_factor', 'flip', 'flip_direction', + 'img_norm_cfg')`` + """ + + def __init__(self, + keys, + meta_keys=('filename', 'ori_filename', 'ori_shape', + 'img_shape', 'pad_shape', 'scale_factor', 'flip', + 'flip_direction', 'img_norm_cfg')): + self.keys = keys + self.meta_keys = meta_keys + + def __call__(self, results): + """Call function to collect keys in results. The keys in ``meta_keys`` + will be converted to :obj:mmcv.DataContainer. + + Args: + results (dict): Result dict contains the data to collect. + + Returns: + dict: The result dict contains the following keys + + - keys in``self.keys`` + - ``img_metas`` + """ + + data = {} + img_meta = {} + for key in self.meta_keys: + img_meta[key] = results[key] + data['img_metas'] = DC(img_meta, cpu_only=True) + for key in self.keys: + data[key] = results[key] + return data + + def __repr__(self): + return self.__class__.__name__ + \ + f'(keys={self.keys}, meta_keys={self.meta_keys})' + + +@PIPELINES.register_module() +class WrapFieldsToLists: + """Wrap fields of the data dictionary into lists for evaluation. + + This class can be used as a last step of a test or validation + pipeline for single image evaluation or inference. + + Example: + >>> test_pipeline = [ + >>> dict(type='LoadImageFromFile'), + >>> dict(type='Normalize', + mean=[123.675, 116.28, 103.53], + std=[58.395, 57.12, 57.375], + to_rgb=True), + >>> dict(type='Pad', size_divisor=32), + >>> dict(type='ImageToTensor', keys=['img']), + >>> dict(type='Collect', keys=['img']), + >>> dict(type='WrapFieldsToLists') + >>> ] + """ + + def __call__(self, results): + """Call function to wrap fields into lists. + + Args: + results (dict): Result dict contains the data to wrap. + + Returns: + dict: The result dict where value of ``self.keys`` are wrapped \ + into list. + """ + + # Wrap dict fields into lists + for key, val in results.items(): + results[key] = [val] + return results + + def __repr__(self): + return f'{self.__class__.__name__}()' diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/instaboost.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/instaboost.py deleted file mode 100644 index 6777d4425..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/instaboost.py +++ /dev/null @@ -1,91 +0,0 @@ -import numpy as np - -from ..registry import PIPELINES - - -@PIPELINES.register_module -class InstaBoost(object): - """ - Data augmentation method in paper "InstaBoost: Boosting Instance - Segmentation Via Probability Map Guided Copy-Pasting" - Implementation details can refer to https://github.com/GothicAi/Instaboost. - """ - - def __init__(self, - action_candidate=('normal', 'horizontal', 'skip'), - action_prob=(1, 0, 0), - scale=(0.8, 1.2), - dx=15, - dy=15, - theta=(-1, 1), - color_prob=0.5, - hflag=False, - aug_ratio=0.5): - try: - import instaboostfast as instaboost - except ImportError: - raise ImportError( - 'Please run "pip install instaboostfast" ' - 'to install instaboostfast first for instaboost augmentation.') - self.cfg = instaboost.InstaBoostConfig(action_candidate, action_prob, - scale, dx, dy, theta, - color_prob, hflag) - self.aug_ratio = aug_ratio - - def _load_anns(self, results): - labels = results['ann_info']['labels'] - masks = results['ann_info']['masks'] - bboxes = results['ann_info']['bboxes'] - n = len(labels) - - anns = [] - for i in range(n): - label = labels[i] - bbox = bboxes[i] - mask = masks[i] - x1, y1, x2, y2 = bbox - bbox = [x1, y1, x2 - x1 + 1, y2 - y1 + 1] - anns.append({ - 'category_id': label, - 'segmentation': mask, - 'bbox': bbox - }) - - return anns - - def _parse_anns(self, results, anns, img): - gt_bboxes = [] - gt_labels = [] - gt_masks_ann = [] - for ann in anns: - x1, y1, w, h = ann['bbox'] - bbox = [x1, y1, x1 + w - 1, y1 + h - 1] - gt_bboxes.append(bbox) - gt_labels.append(ann['category_id']) - gt_masks_ann.append(ann['segmentation']) - gt_bboxes = np.array(gt_bboxes, dtype=np.float32) - gt_labels = np.array(gt_labels, dtype=np.int64) - results['ann_info']['labels'] = gt_labels - results['ann_info']['bboxes'] = gt_bboxes - results['ann_info']['masks'] = gt_masks_ann - results['img'] = img - return results - - def __call__(self, results): - img = results['img'] - anns = self._load_anns(results) - if np.random.choice([0, 1], p=[1 - self.aug_ratio, self.aug_ratio]): - try: - import instaboostfast as instaboost - except ImportError: - raise ImportError('Please run "pip install instaboostfast" ' - 'to install instaboostfast first.') - anns, img = instaboost.get_new_data( - anns, img, self.cfg, background=None) - results = self._parse_anns(results, anns, img) - return results - - def __repr__(self): - repr_str = self.__class__.__name__ - repr_str += ('(cfg={}, aug_ratio={})').format(self.cfg, self.aug_ratio) - return repr_str diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/loading.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/loading.py index 190773b15..79bbf8099 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/loading.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/loading.py @@ -1,70 +1,305 @@ +# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import mmcv import numpy as np import pycocotools.mask as maskUtils -from ..registry import PIPELINES +from mmdet.core import BitmapMasks, PolygonMasks +from ..builder import PIPELINES +try: + from panopticapi.utils import rgb2id +except ImportError: + rgb2id = None -@PIPELINES.register_module -class LoadImageFromFile(object): - def __init__(self, to_float32=False, color_type='color'): +@PIPELINES.register_module() +class LoadImageFromFile: + """Load an image from file. + + Required keys are "img_prefix" and "img_info" (a dict that must contain the + key "filename"). Added or updated keys are "filename", "img", "img_shape", + "ori_shape" (same as `img_shape`), "pad_shape" (same as `img_shape`), + "scale_factor" (1.0) and "img_norm_cfg" (means=0 and stds=1). + + Args: + to_float32 (bool): Whether to convert the loaded image to a float32 + numpy array. If set to False, the loaded image is an uint8 array. + Defaults to False. + color_type (str): The flag argument for :func:`mmcv.imfrombytes`. + Defaults to 'color'. + file_client_args (dict): Arguments to instantiate a FileClient. + See :class:`mmcv.fileio.FileClient` for details. + Defaults to ``dict(backend='disk')``. + """ + + def __init__(self, + to_float32=False, + color_type='color', + channel_order='bgr', + file_client_args=dict(backend='disk')): self.to_float32 = to_float32 self.color_type = color_type + self.channel_order = channel_order + self.file_client_args = file_client_args.copy() + self.file_client = None def __call__(self, results): + """Call functions to load image and get image meta information. + + Args: + results (dict): Result dict from :obj:`mmdet.CustomDataset`. + + Returns: + dict: The dict contains loaded image and meta information. + """ + + if self.file_client is None: + self.file_client = mmcv.FileClient(**self.file_client_args) + if results['img_prefix'] is not None: filename = osp.join(results['img_prefix'], results['img_info']['filename']) else: filename = results['img_info']['filename'] - img = mmcv.imread(filename, self.color_type) + + img_bytes = self.file_client.get(filename) + img = mmcv.imfrombytes( + img_bytes, flag=self.color_type, channel_order=self.channel_order) if self.to_float32: img = img.astype(np.float32) + results['filename'] = filename + results['ori_filename'] = results['img_info']['filename'] results['img'] = img results['img_shape'] = img.shape results['ori_shape'] = img.shape + results['img_fields'] = ['img'] return results def __repr__(self): - return '{} (to_float32={}, color_type={})'.format( - self.__class__.__name__, self.to_float32, self.color_type) + repr_str = (f'{self.__class__.__name__}(' + f'to_float32={self.to_float32}, ' + f"color_type='{self.color_type}', " + f"channel_order='{self.channel_order}', " + f'file_client_args={self.file_client_args})') + return repr_str + +@PIPELINES.register_module() +class LoadImageFromWebcam(LoadImageFromFile): + """Load an image from webcam. -@PIPELINES.register_module -class LoadAnnotations(object): + Similar with :obj:`LoadImageFromFile`, but the image read from webcam is in + ``results['img']``. + """ + + def __call__(self, results): + """Call functions to add image meta information. + + Args: + results (dict): Result dict with Webcam read image in + ``results['img']``. + + Returns: + dict: The dict contains loaded image and meta information. + """ + + img = results['img'] + if self.to_float32: + img = img.astype(np.float32) + + results['filename'] = None + results['ori_filename'] = None + results['img'] = img + results['img_shape'] = img.shape + results['ori_shape'] = img.shape + results['img_fields'] = ['img'] + return results + + +@PIPELINES.register_module() +class LoadMultiChannelImageFromFiles: + """Load multi-channel images from a list of separate channel files. + + Required keys are "img_prefix" and "img_info" (a dict that must contain the + key "filename", which is expected to be a list of filenames). + Added or updated keys are "filename", "img", "img_shape", + "ori_shape" (same as `img_shape`), "pad_shape" (same as `img_shape`), + "scale_factor" (1.0) and "img_norm_cfg" (means=0 and stds=1). + + Args: + to_float32 (bool): Whether to convert the loaded image to a float32 + numpy array. If set to False, the loaded image is an uint8 array. + Defaults to False. + color_type (str): The flag argument for :func:`mmcv.imfrombytes`. + Defaults to 'color'. + file_client_args (dict): Arguments to instantiate a FileClient. + See :class:`mmcv.fileio.FileClient` for details. + Defaults to ``dict(backend='disk')``. + """ + + def __init__(self, + to_float32=False, + color_type='unchanged', + file_client_args=dict(backend='disk')): + self.to_float32 = to_float32 + self.color_type = color_type + self.file_client_args = file_client_args.copy() + self.file_client = None + + def __call__(self, results): + """Call functions to load multiple images and get images meta + information. + + Args: + results (dict): Result dict from :obj:`mmdet.CustomDataset`. + + Returns: + dict: The dict contains loaded images and meta information. + """ + + if self.file_client is None: + self.file_client = mmcv.FileClient(**self.file_client_args) + + if results['img_prefix'] is not None: + filename = [ + osp.join(results['img_prefix'], fname) + for fname in results['img_info']['filename'] + ] + else: + filename = results['img_info']['filename'] + + img = [] + for name in filename: + img_bytes = self.file_client.get(name) + img.append(mmcv.imfrombytes(img_bytes, flag=self.color_type)) + img = np.stack(img, axis=-1) + if self.to_float32: + img = img.astype(np.float32) + + results['filename'] = filename + results['ori_filename'] = results['img_info']['filename'] + results['img'] = img + results['img_shape'] = img.shape + results['ori_shape'] = img.shape + # Set initial values for default meta_keys + results['pad_shape'] = img.shape + results['scale_factor'] = 1.0 + num_channels = 1 if len(img.shape) < 3 else img.shape[2] + results['img_norm_cfg'] = dict( + mean=np.zeros(num_channels, dtype=np.float32), + std=np.ones(num_channels, dtype=np.float32), + to_rgb=False) + return results + + def __repr__(self): + repr_str = (f'{self.__class__.__name__}(' + f'to_float32={self.to_float32}, ' + f"color_type='{self.color_type}', " + f'file_client_args={self.file_client_args})') + return repr_str + + +@PIPELINES.register_module() +class LoadAnnotations: + """Load multiple types of annotations. + + Args: + with_bbox (bool): Whether to parse and load the bbox annotation. + Default: True. + with_label (bool): Whether to parse and load the label annotation. + Default: True. + with_mask (bool): Whether to parse and load the mask annotation. + Default: False. + with_seg (bool): Whether to parse and load the semantic segmentation + annotation. Default: False. + poly2mask (bool): Whether to convert the instance masks from polygons + to bitmaps. Default: True. + denorm_bbox (bool): Whether to convert bbox from relative value to + absolute value. Only used in OpenImage Dataset. + Default: False. + file_client_args (dict): Arguments to instantiate a FileClient. + See :class:`mmcv.fileio.FileClient` for details. + Defaults to ``dict(backend='disk')``. + """ def __init__(self, with_bbox=True, with_label=True, with_mask=False, with_seg=False, - poly2mask=True): + poly2mask=True, + denorm_bbox=False, + file_client_args=dict(backend='disk')): self.with_bbox = with_bbox self.with_label = with_label self.with_mask = with_mask self.with_seg = with_seg self.poly2mask = poly2mask + self.denorm_bbox = denorm_bbox + self.file_client_args = file_client_args.copy() + self.file_client = None def _load_bboxes(self, results): + """Private function to load bounding box annotations. + + Args: + results (dict): Result dict from :obj:`mmdet.CustomDataset`. + + Returns: + dict: The dict contains loaded bounding box annotations. + """ + ann_info = results['ann_info'] - results['gt_bboxes'] = ann_info['bboxes'] + results['gt_bboxes'] = ann_info['bboxes'].copy() + + if self.denorm_bbox: + bbox_num = results['gt_bboxes'].shape[0] + if bbox_num != 0: + h, w = results['img_shape'][:2] + results['gt_bboxes'][:, 0::2] *= w + results['gt_bboxes'][:, 1::2] *= h gt_bboxes_ignore = ann_info.get('bboxes_ignore', None) if gt_bboxes_ignore is not None: - results['gt_bboxes_ignore'] = gt_bboxes_ignore + results['gt_bboxes_ignore'] = gt_bboxes_ignore.copy() results['bbox_fields'].append('gt_bboxes_ignore') results['bbox_fields'].append('gt_bboxes') + + gt_is_group_ofs = ann_info.get('gt_is_group_ofs', None) + if gt_is_group_ofs is not None: + results['gt_is_group_ofs'] = gt_is_group_ofs.copy() + return results def _load_labels(self, results): - results['gt_labels'] = results['ann_info']['labels'] + """Private function to load label annotations. + + Args: + results (dict): Result dict from :obj:`mmdet.CustomDataset`. + + Returns: + dict: The dict contains loaded label annotations. + """ + + results['gt_labels'] = results['ann_info']['labels'].copy() return results def _poly2mask(self, mask_ann, img_h, img_w): + """Private function to convert masks represented with polygon to + bitmaps. + + Args: + mask_ann (list | dict): Polygon mask annotation input. + img_h (int): The height of output mask. + img_w (int): The width of output mask. + + Returns: + numpy.ndarray: The decode bitmap mask of shape (img_h, img_w). + """ + if isinstance(mask_ann, list): # polygon -- a single object might consist of multiple parts # we merge all parts into one mask rle code @@ -79,23 +314,80 @@ class LoadAnnotations(object): mask = maskUtils.decode(rle) return mask + def process_polygons(self, polygons): + """Convert polygons to list of ndarray and filter invalid polygons. + + Args: + polygons (list[list]): Polygons of one instance. + + Returns: + list[numpy.ndarray]: Processed polygons. + """ + + polygons = [np.array(p) for p in polygons] + valid_polygons = [] + for polygon in polygons: + if len(polygon) % 2 == 0 and len(polygon) >= 6: + valid_polygons.append(polygon) + return valid_polygons + def _load_masks(self, results): + """Private function to load mask annotations. + + Args: + results (dict): Result dict from :obj:`mmdet.CustomDataset`. + + Returns: + dict: The dict contains loaded mask annotations. + If ``self.poly2mask`` is set ``True``, `gt_mask` will contain + :obj:`PolygonMasks`. Otherwise, :obj:`BitmapMasks` is used. + """ + h, w = results['img_info']['height'], results['img_info']['width'] gt_masks = results['ann_info']['masks'] if self.poly2mask: - gt_masks = [self._poly2mask(mask, h, w) for mask in gt_masks] + gt_masks = BitmapMasks( + [self._poly2mask(mask, h, w) for mask in gt_masks], h, w) + else: + gt_masks = PolygonMasks( + [self.process_polygons(polygons) for polygons in gt_masks], h, + w) results['gt_masks'] = gt_masks results['mask_fields'].append('gt_masks') return results def _load_semantic_seg(self, results): - results['gt_semantic_seg'] = mmcv.imread( - osp.join(results['seg_prefix'], results['ann_info']['seg_map']), - flag='unchanged').squeeze() + """Private function to load semantic segmentation annotations. + + Args: + results (dict): Result dict from :obj:`dataset`. + + Returns: + dict: The dict contains loaded semantic segmentation annotations. + """ + + if self.file_client is None: + self.file_client = mmcv.FileClient(**self.file_client_args) + + filename = osp.join(results['seg_prefix'], + results['ann_info']['seg_map']) + img_bytes = self.file_client.get(filename) + results['gt_semantic_seg'] = mmcv.imfrombytes( + img_bytes, flag='unchanged').squeeze() results['seg_fields'].append('gt_semantic_seg') return results def __call__(self, results): + """Call function to load multiple types annotations. + + Args: + results (dict): Result dict from :obj:`mmdet.CustomDataset`. + + Returns: + dict: The dict contains loaded bounding box, label, mask and + semantic segmentation annotations. + """ + if self.with_bbox: results = self._load_bboxes(results) if results is None: @@ -110,24 +402,155 @@ class LoadAnnotations(object): def __repr__(self): repr_str = self.__class__.__name__ - repr_str += ('(with_bbox={}, with_label={}, with_mask={},' - ' with_seg={})').format(self.with_bbox, self.with_label, - self.with_mask, self.with_seg) + repr_str += f'(with_bbox={self.with_bbox}, ' + repr_str += f'with_label={self.with_label}, ' + repr_str += f'with_mask={self.with_mask}, ' + repr_str += f'with_seg={self.with_seg}, ' + repr_str += f'poly2mask={self.poly2mask}, ' + repr_str += f'poly2mask={self.file_client_args})' return repr_str -@PIPELINES.register_module -class LoadProposals(object): +@PIPELINES.register_module() +class LoadPanopticAnnotations(LoadAnnotations): + """Load multiple types of panoptic annotations. + + Args: + with_bbox (bool): Whether to parse and load the bbox annotation. + Default: True. + with_label (bool): Whether to parse and load the label annotation. + Default: True. + with_mask (bool): Whether to parse and load the mask annotation. + Default: True. + with_seg (bool): Whether to parse and load the semantic segmentation + annotation. Default: True. + file_client_args (dict): Arguments to instantiate a FileClient. + See :class:`mmcv.fileio.FileClient` for details. + Defaults to ``dict(backend='disk')``. + """ + + def __init__(self, + with_bbox=True, + with_label=True, + with_mask=True, + with_seg=True, + file_client_args=dict(backend='disk')): + if rgb2id is None: + raise RuntimeError( + 'panopticapi is not installed, please install it by: ' + 'pip install git+https://github.com/cocodataset/' + 'panopticapi.git.') + + super(LoadPanopticAnnotations, self).__init__( + with_bbox=with_bbox, + with_label=with_label, + with_mask=with_mask, + with_seg=with_seg, + poly2mask=True, + denorm_bbox=False, + file_client_args=file_client_args) + + def _load_masks_and_semantic_segs(self, results): + """Private function to load mask and semantic segmentation annotations. + + In gt_semantic_seg, the foreground label is from `0` to + `num_things - 1`, the background label is from `num_things` to + `num_things + num_stuff - 1`, 255 means the ignored label (`VOID`). + + Args: + results (dict): Result dict from :obj:`mmdet.CustomDataset`. + + Returns: + dict: The dict contains loaded mask and semantic segmentation + annotations. `BitmapMasks` is used for mask annotations. + """ + + if self.file_client is None: + self.file_client = mmcv.FileClient(**self.file_client_args) + + filename = osp.join(results['seg_prefix'], + results['ann_info']['seg_map']) + img_bytes = self.file_client.get(filename) + pan_png = mmcv.imfrombytes( + img_bytes, flag='color', channel_order='rgb').squeeze() + pan_png = rgb2id(pan_png) + + gt_masks = [] + gt_seg = np.zeros_like(pan_png) + 255 # 255 as ignore + + for mask_info in results['ann_info']['masks']: + mask = (pan_png == mask_info['id']) + gt_seg = np.where(mask, mask_info['category'], gt_seg) + + # The legal thing masks + if mask_info.get('is_thing'): + gt_masks.append(mask.astype(np.uint8)) + + if self.with_mask: + h, w = results['img_info']['height'], results['img_info']['width'] + gt_masks = BitmapMasks(gt_masks, h, w) + results['gt_masks'] = gt_masks + results['mask_fields'].append('gt_masks') + + if self.with_seg: + results['gt_semantic_seg'] = gt_seg + results['seg_fields'].append('gt_semantic_seg') + return results + + def __call__(self, results): + """Call function to load multiple types panoptic annotations. + + Args: + results (dict): Result dict from :obj:`mmdet.CustomDataset`. + + Returns: + dict: The dict contains loaded bounding box, label, mask and + semantic segmentation annotations. + """ + + if self.with_bbox: + results = self._load_bboxes(results) + if results is None: + return None + if self.with_label: + results = self._load_labels(results) + if self.with_mask or self.with_seg: + # The tasks completed by '_load_masks' and '_load_semantic_segs' + # in LoadAnnotations are merged to one function. + results = self._load_masks_and_semantic_segs(results) + + return results + + +@PIPELINES.register_module() +class LoadProposals: + """Load proposal pipeline. + + Required key is "proposals". Updated keys are "proposals", "bbox_fields". + + Args: + num_max_proposals (int, optional): Maximum number of proposals to load. + If not specified, all proposals will be loaded. + """ def __init__(self, num_max_proposals=None): self.num_max_proposals = num_max_proposals def __call__(self, results): + """Call function to load proposals from file. + + Args: + results (dict): Result dict from :obj:`mmdet.CustomDataset`. + + Returns: + dict: The dict contains loaded proposal annotations. + """ + proposals = results['proposals'] if proposals.shape[1] not in (4, 5): raise AssertionError( 'proposals should have shapes (n, 4) or (n, 5), ' - 'but found {}'.format(proposals.shape)) + f'but found {proposals.shape}') proposals = proposals[:, :4] if self.num_max_proposals is not None: @@ -140,5 +563,81 @@ class LoadProposals(object): return results def __repr__(self): - return self.__class__.__name__ + '(num_max_proposals={})'.format( - self.num_max_proposals) + return self.__class__.__name__ + \ + f'(num_max_proposals={self.num_max_proposals})' + + +@PIPELINES.register_module() +class FilterAnnotations: + """Filter invalid annotations. + + Args: + min_gt_bbox_wh (tuple[float]): Minimum width and height of ground truth + boxes. Default: (1., 1.) + min_gt_mask_area (int): Minimum foreground area of ground truth masks. + Default: 1 + by_box (bool): Filter instances with bounding boxes not meeting the + min_gt_bbox_wh threshold. Default: True + by_mask (bool): Filter instances with masks not meeting + min_gt_mask_area threshold. Default: False + keep_empty (bool): Whether to return None when it + becomes an empty bbox after filtering. Default: True + """ + + def __init__(self, + min_gt_bbox_wh=(1., 1.), + min_gt_mask_area=1, + by_box=True, + by_mask=False, + keep_empty=True): + # TODO: add more filter options + assert by_box or by_mask + self.min_gt_bbox_wh = min_gt_bbox_wh + self.min_gt_mask_area = min_gt_mask_area + self.by_box = by_box + self.by_mask = by_mask + self.keep_empty = keep_empty + + def __call__(self, results): + if self.by_box: + assert 'gt_bboxes' in results + gt_bboxes = results['gt_bboxes'] + instance_num = gt_bboxes.shape[0] + if self.by_mask: + assert 'gt_masks' in results + gt_masks = results['gt_masks'] + instance_num = len(gt_masks) + + if instance_num == 0: + return results + + tests = [] + if self.by_box: + w = gt_bboxes[:, 2] - gt_bboxes[:, 0] + h = gt_bboxes[:, 3] - gt_bboxes[:, 1] + tests.append((w > self.min_gt_bbox_wh[0]) + & (h > self.min_gt_bbox_wh[1])) + if self.by_mask: + gt_masks = results['gt_masks'] + tests.append(gt_masks.areas >= self.min_gt_mask_area) + + keep = tests[0] + for t in tests[1:]: + keep = keep & t + + keys = ('gt_bboxes', 'gt_labels', 'gt_masks') + for key in keys: + if key in results: + results[key] = results[key][keep] + if not keep.any(): + if self.keep_empty: + return None + return results + + def __repr__(self): + return self.__class__.__name__ + \ + f'(min_gt_bbox_wh={self.min_gt_bbox_wh},' \ + f'(min_gt_mask_area={self.min_gt_mask_area},' \ + f'(by_box={self.by_box},' \ + f'(by_mask={self.by_mask},' \ + f'always_keep={self.always_keep})' diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/test_aug.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/test_aug.py deleted file mode 100644 index b5d218075..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/test_aug.py +++ /dev/null @@ -1,38 +0,0 @@ -import mmcv - -from ..registry import PIPELINES -from .compose import Compose - - -@PIPELINES.register_module -class MultiScaleFlipAug(object): - - def __init__(self, transforms, img_scale, flip=False): - self.transforms = Compose(transforms) - self.img_scale = img_scale if isinstance(img_scale, - list) else [img_scale] - assert mmcv.is_list_of(self.img_scale, tuple) - self.flip = flip - - def __call__(self, results): - aug_data = [] - flip_aug = [False, True] if self.flip else [False] - for scale in self.img_scale: - for flip in flip_aug: - _results = results.copy() - _results['scale'] = scale - _results['flip'] = flip - data = self.transforms(_results) - aug_data.append(data) - # list of dict to dict of list - aug_data_dict = {key: [] for key in aug_data[0]} - for data in aug_data: - for key, val in data.items(): - aug_data_dict[key].append(val) - return aug_data_dict - - def __repr__(self): - repr_str = self.__class__.__name__ - repr_str += '(transforms={}, img_scale={}, flip={})'.format( - self.transforms, self.img_scale, self.flip) - return repr_str diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/test_time_aug.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/test_time_aug.py new file mode 100644 index 000000000..5f1ab7b7c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/test_time_aug.py @@ -0,0 +1,121 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import warnings + +import mmcv + +from ..builder import PIPELINES +from .compose import Compose + + +@PIPELINES.register_module() +class MultiScaleFlipAug: + """Test-time augmentation with multiple scales and flipping. + + An example configuration is as followed: + + .. code-block:: + + img_scale=[(1333, 400), (1333, 800)], + flip=True, + transforms=[ + dict(type='Resize', keep_ratio=True), + dict(type='RandomFlip'), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='ImageToTensor', keys=['img']), + dict(type='Collect', keys=['img']), + ] + + After MultiScaleFLipAug with above configuration, the results are wrapped + into lists of the same length as followed: + + .. code-block:: + + dict( + img=[...], + img_shape=[...], + scale=[(1333, 400), (1333, 400), (1333, 800), (1333, 800)] + flip=[False, True, False, True] + ... + ) + + Args: + transforms (list[dict]): Transforms to apply in each augmentation. + img_scale (tuple | list[tuple] | None): Images scales for resizing. + scale_factor (float | list[float] | None): Scale factors for resizing. + flip (bool): Whether apply flip augmentation. Default: False. + flip_direction (str | list[str]): Flip augmentation directions, + options are "horizontal", "vertical" and "diagonal". If + flip_direction is a list, multiple flip augmentations will be + applied. It has no effect when flip == False. Default: + "horizontal". + """ + + def __init__(self, + transforms, + img_scale=None, + scale_factor=None, + flip=False, + flip_direction='horizontal'): + self.transforms = Compose(transforms) + assert (img_scale is None) ^ (scale_factor is None), ( + 'Must have but only one variable can be set') + if img_scale is not None: + self.img_scale = img_scale if isinstance(img_scale, + list) else [img_scale] + self.scale_key = 'scale' + assert mmcv.is_list_of(self.img_scale, tuple) + else: + self.img_scale = scale_factor if isinstance( + scale_factor, list) else [scale_factor] + self.scale_key = 'scale_factor' + + self.flip = flip + self.flip_direction = flip_direction if isinstance( + flip_direction, list) else [flip_direction] + assert mmcv.is_list_of(self.flip_direction, str) + if not self.flip and self.flip_direction != ['horizontal']: + warnings.warn( + 'flip_direction has no effect when flip is set to False') + if (self.flip + and not any([t['type'] == 'RandomFlip' for t in transforms])): + warnings.warn( + 'flip has no effect when RandomFlip is not in transforms') + + def __call__(self, results): + """Call function to apply test time augment transforms on results. + + Args: + results (dict): Result dict contains the data to transform. + + Returns: + dict[str: list]: The augmented data, where each value is wrapped + into a list. + """ + + aug_data = [] + flip_args = [(False, None)] + if self.flip: + flip_args += [(True, direction) + for direction in self.flip_direction] + for scale in self.img_scale: + for flip, direction in flip_args: + _results = results.copy() + _results[self.scale_key] = scale + _results['flip'] = flip + _results['flip_direction'] = direction + data = self.transforms(_results) + aug_data.append(data) + # list of dict to dict of list + aug_data_dict = {key: [] for key in aug_data[0]} + for data in aug_data: + for key, val in data.items(): + aug_data_dict[key].append(val) + return aug_data_dict + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += f'(transforms={self.transforms}, ' + repr_str += f'img_scale={self.img_scale}, flip={self.flip}, ' + repr_str += f'flip_direction={self.flip_direction})' + return repr_str diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/transforms.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/transforms.py index 58c1c2131..0a1b38911 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/transforms.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/pipelines/transforms.py @@ -1,11 +1,18 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import copy import inspect +import math +import warnings +import cv2 import mmcv import numpy as np from numpy import random +from mmdet.core import BitmapMasks, PolygonMasks, find_inside_bboxes from mmdet.core.evaluation.bbox_overlaps import bbox_overlaps -from ..registry import PIPELINES +from mmdet.utils import log_img_scale +from ..builder import PIPELINES try: from imagecorruptions import corrupt @@ -20,23 +27,27 @@ except ImportError: Compose = None -@PIPELINES.register_module -class Resize(object): +@PIPELINES.register_module() +class Resize: """Resize images & bbox & mask. This transform resizes the input image to some scale. Bboxes and masks are then resized with the same scale factor. If the input dict contains the key "scale", then the scale in the input dict is used, otherwise the specified - scale in the init method is used. + scale in the init method is used. If the input dict contains the key + "scale_factor" (if MultiScaleFlipAug does not give img_scale but + scale_factor), the actual scale will be computed by image shape and + scale_factor. `img_scale` can either be a tuple (single-scale) or a list of tuple (multi-scale). There are 3 multiscale modes: - - `ratio_range` is not None: randomly sample a ratio from the ratio range - and multiply it with the image scale. - - `ratio_range` is None and `multiscale_mode` == "range": randomly sample a - scale from the a range. - - `ratio_range` is None and `multiscale_mode` == "value": randomly sample a - scale from multiple scales. + + - ``ratio_range is not None``: randomly sample a ratio from the ratio \ + range and multiply it with the image scale. + - ``ratio_range is None`` and ``multiscale_mode == "range"``: randomly \ + sample a scale from the multiscale range. + - ``ratio_range is None`` and ``multiscale_mode == "value"``: randomly \ + sample a scale from multiple scales. Args: img_scale (tuple or list[tuple]): Images scales for resizing. @@ -44,13 +55,33 @@ class Resize(object): ratio_range (tuple[float]): (min_ratio, max_ratio) keep_ratio (bool): Whether to keep the aspect ratio when resizing the image. + bbox_clip_border (bool, optional): Whether to clip the objects outside + the border of the image. In some dataset like MOT17, the gt bboxes + are allowed to cross the border of images. Therefore, we don't + need to clip the gt bboxes in these cases. Defaults to True. + backend (str): Image resize backend, choices are 'cv2' and 'pillow'. + These two backends generates slightly different results. Defaults + to 'cv2'. + interpolation (str): Interpolation method, accepted values are + "nearest", "bilinear", "bicubic", "area", "lanczos" for 'cv2' + backend, "nearest", "bilinear" for 'pillow' backend. + override (bool, optional): Whether to override `scale` and + `scale_factor` so as to call resize twice. Default False. If True, + after the first resizing, the existed `scale` and `scale_factor` + will be ignored so the second resizing can be allowed. + This option is a work-around for multiple times of resize in DETR. + Defaults to False. """ def __init__(self, img_scale=None, multiscale_mode='range', ratio_range=None, - keep_ratio=True): + keep_ratio=True, + bbox_clip_border=True, + backend='cv2', + interpolation='bilinear', + override=False): if img_scale is None: self.img_scale = None else: @@ -67,12 +98,28 @@ class Resize(object): # mode 2: given multiple scales or a range of scales assert multiscale_mode in ['value', 'range'] + self.backend = backend self.multiscale_mode = multiscale_mode self.ratio_range = ratio_range self.keep_ratio = keep_ratio + # TODO: refactor the override option in Resize + self.interpolation = interpolation + self.override = override + self.bbox_clip_border = bbox_clip_border @staticmethod def random_select(img_scales): + """Randomly select an img_scale from given candidates. + + Args: + img_scales (list[tuple]): Images scales for selection. + + Returns: + (tuple, int): Returns a tuple ``(img_scale, scale_dix)``, \ + where ``img_scale`` is the selected image scale and \ + ``scale_idx`` is the selected index in the given candidates. + """ + assert mmcv.is_list_of(img_scales, tuple) scale_idx = np.random.randint(len(img_scales)) img_scale = img_scales[scale_idx] @@ -80,6 +127,19 @@ class Resize(object): @staticmethod def random_sample(img_scales): + """Randomly sample an img_scale when ``multiscale_mode=='range'``. + + Args: + img_scales (list[tuple]): Images scale range for sampling. + There must be two tuples in img_scales, which specify the lower + and upper bound of image scales. + + Returns: + (tuple, None): Returns a tuple ``(img_scale, None)``, where \ + ``img_scale`` is sampled scale and None is just a placeholder \ + to be consistent with :func:`random_select`. + """ + assert mmcv.is_list_of(img_scales, tuple) and len(img_scales) == 2 img_scale_long = [max(s) for s in img_scales] img_scale_short = [min(s) for s in img_scales] @@ -94,6 +154,24 @@ class Resize(object): @staticmethod def random_sample_ratio(img_scale, ratio_range): + """Randomly sample an img_scale when ``ratio_range`` is specified. + + A ratio will be randomly sampled from the range specified by + ``ratio_range``. Then it would be multiplied with ``img_scale`` to + generate sampled scale. + + Args: + img_scale (tuple): Images scale base to multiply with ratio. + ratio_range (tuple[float]): The minimum and maximum ratio to scale + the ``img_scale``. + + Returns: + (tuple, None): Returns a tuple ``(scale, None)``, where \ + ``scale`` is sampled ratio multiplied with ``img_scale`` and \ + None is just a placeholder to be consistent with \ + :func:`random_select`. + """ + assert isinstance(img_scale, tuple) and len(img_scale) == 2 min_ratio, max_ratio = ratio_range assert min_ratio <= max_ratio @@ -102,6 +180,23 @@ class Resize(object): return scale, None def _random_scale(self, results): + """Randomly sample an img_scale according to ``ratio_range`` and + ``multiscale_mode``. + + If ``ratio_range`` is specified, a ratio will be sampled and be + multiplied with ``img_scale``. + If multiple scales are specified by ``img_scale``, a scale will be + sampled according to ``multiscale_mode``. + Otherwise, single scale will be used. + + Args: + results (dict): Result dict from :obj:`dataset`. + + Returns: + dict: Two new keys 'scale` and 'scale_idx` are added into \ + ``results``, which would be used by subsequent pipelines. + """ + if self.ratio_range is not None: scale, scale_idx = self.random_sample_ratio( self.img_scale[0], self.ratio_range) @@ -118,59 +213,106 @@ class Resize(object): results['scale_idx'] = scale_idx def _resize_img(self, results): - if self.keep_ratio: - img, scale_factor = mmcv.imrescale( - results['img'], results['scale'], return_scale=True) - else: - img, w_scale, h_scale = mmcv.imresize( - results['img'], results['scale'], return_scale=True) + """Resize images with ``results['scale']``.""" + for key in results.get('img_fields', ['img']): + if self.keep_ratio: + img, scale_factor = mmcv.imrescale( + results[key], + results['scale'], + return_scale=True, + interpolation=self.interpolation, + backend=self.backend) + # the w_scale and h_scale has minor difference + # a real fix should be done in the mmcv.imrescale in the future + new_h, new_w = img.shape[:2] + h, w = results[key].shape[:2] + w_scale = new_w / w + h_scale = new_h / h + else: + img, w_scale, h_scale = mmcv.imresize( + results[key], + results['scale'], + return_scale=True, + interpolation=self.interpolation, + backend=self.backend) + results[key] = img + scale_factor = np.array([w_scale, h_scale, w_scale, h_scale], dtype=np.float32) - results['img'] = img - results['img_shape'] = img.shape - results['pad_shape'] = img.shape # in case that there is no padding - results['scale_factor'] = scale_factor - results['keep_ratio'] = self.keep_ratio + results['img_shape'] = img.shape + # in case that there is no padding + results['pad_shape'] = img.shape + results['scale_factor'] = scale_factor + results['keep_ratio'] = self.keep_ratio def _resize_bboxes(self, results): - img_shape = results['img_shape'] + """Resize bounding boxes with ``results['scale_factor']``.""" for key in results.get('bbox_fields', []): bboxes = results[key] * results['scale_factor'] - bboxes[:, 0::2] = np.clip(bboxes[:, 0::2], 0, img_shape[1] - 1) - bboxes[:, 1::2] = np.clip(bboxes[:, 1::2], 0, img_shape[0] - 1) + if self.bbox_clip_border: + img_shape = results['img_shape'] + bboxes[:, 0::2] = np.clip(bboxes[:, 0::2], 0, img_shape[1]) + bboxes[:, 1::2] = np.clip(bboxes[:, 1::2], 0, img_shape[0]) results[key] = bboxes def _resize_masks(self, results): + """Resize masks with ``results['scale']``""" for key in results.get('mask_fields', []): if results[key] is None: continue if self.keep_ratio: - masks = [ - mmcv.imrescale( - mask, results['scale_factor'], interpolation='nearest') - for mask in results[key] - ] + results[key] = results[key].rescale(results['scale']) else: - mask_size = (results['img_shape'][1], results['img_shape'][0]) - masks = [ - mmcv.imresize(mask, mask_size, interpolation='nearest') - for mask in results[key] - ] - results[key] = np.stack(masks) + results[key] = results[key].resize(results['img_shape'][:2]) def _resize_seg(self, results): + """Resize semantic segmentation map with ``results['scale']``.""" for key in results.get('seg_fields', []): if self.keep_ratio: gt_seg = mmcv.imrescale( - results[key], results['scale'], interpolation='nearest') + results[key], + results['scale'], + interpolation='nearest', + backend=self.backend) else: gt_seg = mmcv.imresize( - results[key], results['scale'], interpolation='nearest') - results['gt_semantic_seg'] = gt_seg + results[key], + results['scale'], + interpolation='nearest', + backend=self.backend) + results[key] = gt_seg def __call__(self, results): + """Call function to resize images, bounding boxes, masks, semantic + segmentation map. + + Args: + results (dict): Result dict from loading pipeline. + + Returns: + dict: Resized results, 'img_shape', 'pad_shape', 'scale_factor', \ + 'keep_ratio' keys are added into result dict. + """ + if 'scale' not in results: - self._random_scale(results) + if 'scale_factor' in results: + img_shape = results['img'].shape[:2] + scale_factor = results['scale_factor'] + assert isinstance(scale_factor, float) + results['scale'] = tuple( + [int(x * scale_factor) for x in img_shape][::-1]) + else: + self._random_scale(results) + else: + if not self.override: + assert 'scale_factor' not in results, ( + 'scale and scale_factor cannot be both set.') + else: + results.pop('scale') + if 'scale_factor' in results: + results.pop('scale_factor') + self._random_scale(results) + self._resize_img(results) self._resize_bboxes(results) self._resize_masks(results) @@ -179,65 +321,152 @@ class Resize(object): def __repr__(self): repr_str = self.__class__.__name__ - repr_str += ('(img_scale={}, multiscale_mode={}, ratio_range={}, ' - 'keep_ratio={})').format(self.img_scale, - self.multiscale_mode, - self.ratio_range, - self.keep_ratio) + repr_str += f'(img_scale={self.img_scale}, ' + repr_str += f'multiscale_mode={self.multiscale_mode}, ' + repr_str += f'ratio_range={self.ratio_range}, ' + repr_str += f'keep_ratio={self.keep_ratio}, ' + repr_str += f'bbox_clip_border={self.bbox_clip_border})' return repr_str -@PIPELINES.register_module -class RandomFlip(object): +@PIPELINES.register_module() +class RandomFlip: """Flip the image & bbox & mask. If the input dict contains the key "flip", then the flag will be used, otherwise it will be randomly decided by a ratio specified in the init method. + When random flip is enabled, ``flip_ratio``/``direction`` can either be a + float/string or tuple of float/string. There are 3 flip modes: + + - ``flip_ratio`` is float, ``direction`` is string: the image will be + ``direction``ly flipped with probability of ``flip_ratio`` . + E.g., ``flip_ratio=0.5``, ``direction='horizontal'``, + then image will be horizontally flipped with probability of 0.5. + - ``flip_ratio`` is float, ``direction`` is list of string: the image will + be ``direction[i]``ly flipped with probability of + ``flip_ratio/len(direction)``. + E.g., ``flip_ratio=0.5``, ``direction=['horizontal', 'vertical']``, + then image will be horizontally flipped with probability of 0.25, + vertically with probability of 0.25. + - ``flip_ratio`` is list of float, ``direction`` is list of string: + given ``len(flip_ratio) == len(direction)``, the image will + be ``direction[i]``ly flipped with probability of ``flip_ratio[i]``. + E.g., ``flip_ratio=[0.3, 0.5]``, ``direction=['horizontal', + 'vertical']``, then image will be horizontally flipped with probability + of 0.3, vertically with probability of 0.5. + Args: - flip_ratio (float, optional): The flipping probability. + flip_ratio (float | list[float], optional): The flipping probability. + Default: None. + direction(str | list[str], optional): The flipping direction. Options + are 'horizontal', 'vertical', 'diagonal'. Default: 'horizontal'. + If input is a list, the length must equal ``flip_ratio``. Each + element in ``flip_ratio`` indicates the flip probability of + corresponding direction. """ def __init__(self, flip_ratio=None, direction='horizontal'): + if isinstance(flip_ratio, list): + assert mmcv.is_list_of(flip_ratio, float) + assert 0 <= sum(flip_ratio) <= 1 + elif isinstance(flip_ratio, float): + assert 0 <= flip_ratio <= 1 + elif flip_ratio is None: + pass + else: + raise ValueError('flip_ratios must be None, float, ' + 'or list of float') self.flip_ratio = flip_ratio + + valid_directions = ['horizontal', 'vertical', 'diagonal'] + if isinstance(direction, str): + assert direction in valid_directions + elif isinstance(direction, list): + assert mmcv.is_list_of(direction, str) + assert set(direction).issubset(set(valid_directions)) + else: + raise ValueError('direction must be either str or list of str') self.direction = direction - if flip_ratio is not None: - assert flip_ratio >= 0 and flip_ratio <= 1 - assert direction in ['horizontal', 'vertical'] + + if isinstance(flip_ratio, list): + assert len(self.flip_ratio) == len(self.direction) def bbox_flip(self, bboxes, img_shape, direction): """Flip bboxes horizontally. Args: - bboxes(ndarray): shape (..., 4*k) - img_shape(tuple): (height, width) + bboxes (numpy.ndarray): Bounding boxes, shape (..., 4*k) + img_shape (tuple[int]): Image shape (height, width) + direction (str): Flip direction. Options are 'horizontal', + 'vertical'. + + Returns: + numpy.ndarray: Flipped bounding boxes. """ + assert bboxes.shape[-1] % 4 == 0 flipped = bboxes.copy() if direction == 'horizontal': w = img_shape[1] - flipped[..., 0::4] = w - bboxes[..., 2::4] - 1 - flipped[..., 2::4] = w - bboxes[..., 0::4] - 1 + flipped[..., 0::4] = w - bboxes[..., 2::4] + flipped[..., 2::4] = w - bboxes[..., 0::4] elif direction == 'vertical': h = img_shape[0] - flipped[..., 1::4] = h - bboxes[..., 3::4] - 1 - flipped[..., 3::4] = h - bboxes[..., 1::4] - 1 + flipped[..., 1::4] = h - bboxes[..., 3::4] + flipped[..., 3::4] = h - bboxes[..., 1::4] + elif direction == 'diagonal': + w = img_shape[1] + h = img_shape[0] + flipped[..., 0::4] = w - bboxes[..., 2::4] + flipped[..., 1::4] = h - bboxes[..., 3::4] + flipped[..., 2::4] = w - bboxes[..., 0::4] + flipped[..., 3::4] = h - bboxes[..., 1::4] else: - raise ValueError( - 'Invalid flipping direction "{}"'.format(direction)) + raise ValueError(f"Invalid flipping direction '{direction}'") return flipped def __call__(self, results): + """Call function to flip bounding boxes, masks, semantic segmentation + maps. + + Args: + results (dict): Result dict from loading pipeline. + + Returns: + dict: Flipped results, 'flip', 'flip_direction' keys are added \ + into result dict. + """ + if 'flip' not in results: - flip = True if np.random.rand() < self.flip_ratio else False - results['flip'] = flip + if isinstance(self.direction, list): + # None means non-flip + direction_list = self.direction + [None] + else: + # None means non-flip + direction_list = [self.direction, None] + + if isinstance(self.flip_ratio, list): + non_flip_ratio = 1 - sum(self.flip_ratio) + flip_ratio_list = self.flip_ratio + [non_flip_ratio] + else: + non_flip_ratio = 1 - self.flip_ratio + # exclude non-flip + single_ratio = self.flip_ratio / (len(direction_list) - 1) + flip_ratio_list = [single_ratio] * (len(direction_list) - + 1) + [non_flip_ratio] + + cur_dir = np.random.choice(direction_list, p=flip_ratio_list) + + results['flip'] = cur_dir is not None if 'flip_direction' not in results: - results['flip_direction'] = self.direction + results['flip_direction'] = cur_dir if results['flip']: # flip image - results['img'] = mmcv.imflip( - results['img'], direction=results['flip_direction']) + for key in results.get('img_fields', ['img']): + results[key] = mmcv.imflip( + results[key], direction=results['flip_direction']) # flip bboxes for key in results.get('bbox_fields', []): results[key] = self.bbox_flip(results[key], @@ -245,10 +474,7 @@ class RandomFlip(object): results['flip_direction']) # flip masks for key in results.get('mask_fields', []): - results[key] = np.stack([ - mmcv.imflip(mask, direction=results['flip_direction']) - for mask in results[key] - ]) + results[key] = results[key].flip(results['flip_direction']) # flip segs for key in results.get('seg_fields', []): @@ -257,59 +483,184 @@ class RandomFlip(object): return results def __repr__(self): - return self.__class__.__name__ + '(flip_ratio={})'.format( - self.flip_ratio) + return self.__class__.__name__ + f'(flip_ratio={self.flip_ratio})' + + +@PIPELINES.register_module() +class RandomShift: + """Shift the image and box given shift pixels and probability. + + Args: + shift_ratio (float): Probability of shifts. Default 0.5. + max_shift_px (int): The max pixels for shifting. Default 32. + filter_thr_px (int): The width and height threshold for filtering. + The bbox and the rest of the targets below the width and + height threshold will be filtered. Default 1. + """ + + def __init__(self, shift_ratio=0.5, max_shift_px=32, filter_thr_px=1): + assert 0 <= shift_ratio <= 1 + assert max_shift_px >= 0 + self.shift_ratio = shift_ratio + self.max_shift_px = max_shift_px + self.filter_thr_px = int(filter_thr_px) + # The key correspondence from bboxes to labels. + self.bbox2label = { + 'gt_bboxes': 'gt_labels', + 'gt_bboxes_ignore': 'gt_labels_ignore' + } + + def __call__(self, results): + """Call function to random shift images, bounding boxes. + + Args: + results (dict): Result dict from loading pipeline. + + Returns: + dict: Shift results. + """ + if random.random() < self.shift_ratio: + img_shape = results['img'].shape[:2] + + random_shift_x = random.randint(-self.max_shift_px, + self.max_shift_px) + random_shift_y = random.randint(-self.max_shift_px, + self.max_shift_px) + new_x = max(0, random_shift_x) + ori_x = max(0, -random_shift_x) + new_y = max(0, random_shift_y) + ori_y = max(0, -random_shift_y) + + # TODO: support mask and semantic segmentation maps. + for key in results.get('bbox_fields', []): + bboxes = results[key].copy() + bboxes[..., 0::2] += random_shift_x + bboxes[..., 1::2] += random_shift_y + + # clip border + bboxes[..., 0::2] = np.clip(bboxes[..., 0::2], 0, img_shape[1]) + bboxes[..., 1::2] = np.clip(bboxes[..., 1::2], 0, img_shape[0]) + + # remove invalid bboxes + bbox_w = bboxes[..., 2] - bboxes[..., 0] + bbox_h = bboxes[..., 3] - bboxes[..., 1] + valid_inds = (bbox_w > self.filter_thr_px) & ( + bbox_h > self.filter_thr_px) + # If the shift does not contain any gt-bbox area, skip this + # image. + if key == 'gt_bboxes' and not valid_inds.any(): + return results + bboxes = bboxes[valid_inds] + results[key] = bboxes + + # label fields. e.g. gt_labels and gt_labels_ignore + label_key = self.bbox2label.get(key) + if label_key in results: + results[label_key] = results[label_key][valid_inds] + + for key in results.get('img_fields', ['img']): + img = results[key] + new_img = np.zeros_like(img) + img_h, img_w = img.shape[:2] + new_h = img_h - np.abs(random_shift_y) + new_w = img_w - np.abs(random_shift_x) + new_img[new_y:new_y + new_h, new_x:new_x + new_w] \ + = img[ori_y:ori_y + new_h, ori_x:ori_x + new_w] + results[key] = new_img + + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += f'(max_shift_px={self.max_shift_px}, ' + return repr_str -@PIPELINES.register_module -class Pad(object): - """Pad the image & mask. +@PIPELINES.register_module() +class Pad: + """Pad the image & masks & segmentation map. There are two padding modes: (1) pad to a fixed size and (2) pad to the minimum size that is divisible by some number. + Added keys are "pad_shape", "pad_fixed_size", "pad_size_divisor", Args: size (tuple, optional): Fixed padding size. size_divisor (int, optional): The divisor of padded size. - pad_val (float, optional): Padding value, 0 by default. + pad_to_square (bool): Whether to pad the image into a square. + Currently only used for YOLOX. Default: False. + pad_val (dict, optional): A dict for padding value, the default + value is `dict(img=0, masks=0, seg=255)`. """ - def __init__(self, size=None, size_divisor=None, pad_val=0): + def __init__(self, + size=None, + size_divisor=None, + pad_to_square=False, + pad_val=dict(img=0, masks=0, seg=255)): self.size = size self.size_divisor = size_divisor + if isinstance(pad_val, float) or isinstance(pad_val, int): + warnings.warn( + 'pad_val of float type is deprecated now, ' + f'please use pad_val=dict(img={pad_val}, ' + f'masks={pad_val}, seg=255) instead.', DeprecationWarning) + pad_val = dict(img=pad_val, masks=pad_val, seg=255) + assert isinstance(pad_val, dict) self.pad_val = pad_val - # only one of size and size_divisor should be valid - assert size is not None or size_divisor is not None - assert size is None or size_divisor is None + self.pad_to_square = pad_to_square + + if pad_to_square: + assert size is None and size_divisor is None, \ + 'The size and size_divisor must be None ' \ + 'when pad2square is True' + else: + assert size is not None or size_divisor is not None, \ + 'only one of size and size_divisor should be valid' + assert size is None or size_divisor is None def _pad_img(self, results): - if self.size is not None: - padded_img = mmcv.impad(results['img'], self.size) - elif self.size_divisor is not None: - padded_img = mmcv.impad_to_multiple( - results['img'], self.size_divisor, pad_val=self.pad_val) - results['img'] = padded_img + """Pad images according to ``self.size``.""" + pad_val = self.pad_val.get('img', 0) + for key in results.get('img_fields', ['img']): + if self.pad_to_square: + max_size = max(results[key].shape[:2]) + self.size = (max_size, max_size) + if self.size is not None: + padded_img = mmcv.impad( + results[key], shape=self.size, pad_val=pad_val) + elif self.size_divisor is not None: + padded_img = mmcv.impad_to_multiple( + results[key], self.size_divisor, pad_val=pad_val) + results[key] = padded_img results['pad_shape'] = padded_img.shape results['pad_fixed_size'] = self.size results['pad_size_divisor'] = self.size_divisor def _pad_masks(self, results): + """Pad masks according to ``results['pad_shape']``.""" pad_shape = results['pad_shape'][:2] + pad_val = self.pad_val.get('masks', 0) for key in results.get('mask_fields', []): - padded_masks = [ - mmcv.impad(mask, pad_shape, pad_val=self.pad_val) - for mask in results[key] - ] - if padded_masks: - results[key] = np.stack(padded_masks, axis=0) - else: - results[key] = np.empty((0, ) + pad_shape, dtype=np.uint8) + results[key] = results[key].pad(pad_shape, pad_val=pad_val) def _pad_seg(self, results): + """Pad semantic segmentation map according to + ``results['pad_shape']``.""" + pad_val = self.pad_val.get('seg', 255) for key in results.get('seg_fields', []): - results[key] = mmcv.impad(results[key], results['pad_shape'][:2]) + results[key] = mmcv.impad( + results[key], shape=results['pad_shape'][:2], pad_val=pad_val) def __call__(self, results): + """Call function to pad images, masks, semantic segmentation maps. + + Args: + results (dict): Result dict from loading pipeline. + + Returns: + dict: Updated result dict. + """ self._pad_img(results) self._pad_masks(results) self._pad_seg(results) @@ -317,15 +668,19 @@ class Pad(object): def __repr__(self): repr_str = self.__class__.__name__ - repr_str += '(size={}, size_divisor={}, pad_val={})'.format( - self.size, self.size_divisor, self.pad_val) + repr_str += f'(size={self.size}, ' + repr_str += f'size_divisor={self.size_divisor}, ' + repr_str += f'pad_to_square={self.pad_to_square}, ' + repr_str += f'pad_val={self.pad_val})' return repr_str -@PIPELINES.register_module -class Normalize(object): +@PIPELINES.register_module() +class Normalize: """Normalize the image. + Added key is "img_norm_cfg". + Args: mean (sequence): Mean values of 3 channels. std (sequence): Std values of 3 channels. @@ -339,111 +694,258 @@ class Normalize(object): self.to_rgb = to_rgb def __call__(self, results): - results['img'] = mmcv.imnormalize(results['img'], self.mean, self.std, - self.to_rgb) + """Call function to normalize images. + + Args: + results (dict): Result dict from loading pipeline. + + Returns: + dict: Normalized results, 'img_norm_cfg' key is added into + result dict. + """ + for key in results.get('img_fields', ['img']): + results[key] = mmcv.imnormalize(results[key], self.mean, self.std, + self.to_rgb) results['img_norm_cfg'] = dict( mean=self.mean, std=self.std, to_rgb=self.to_rgb) return results def __repr__(self): repr_str = self.__class__.__name__ - repr_str += '(mean={}, std={}, to_rgb={})'.format( - self.mean, self.std, self.to_rgb) + repr_str += f'(mean={self.mean}, std={self.std}, to_rgb={self.to_rgb})' return repr_str -@PIPELINES.register_module -class RandomCrop(object): +@PIPELINES.register_module() +class RandomCrop: """Random crop the image & bboxes & masks. + The absolute `crop_size` is sampled based on `crop_type` and `image_size`, + then the cropped results are generated. + Args: - crop_size (tuple): Expected size after cropping, (h, w). + crop_size (tuple): The relative ratio or absolute pixels of + height and width. + crop_type (str, optional): one of "relative_range", "relative", + "absolute", "absolute_range". "relative" randomly crops + (h * crop_size[0], w * crop_size[1]) part from an input of size + (h, w). "relative_range" uniformly samples relative crop size from + range [crop_size[0], 1] and [crop_size[1], 1] for height and width + respectively. "absolute" crops from an input with absolute size + (crop_size[0], crop_size[1]). "absolute_range" uniformly samples + crop_h in range [crop_size[0], min(h, crop_size[1])] and crop_w + in range [crop_size[0], min(w, crop_size[1])]. Default "absolute". + allow_negative_crop (bool, optional): Whether to allow a crop that does + not contain any bbox area. Default False. + recompute_bbox (bool, optional): Whether to re-compute the boxes based + on cropped instance masks. Default False. + bbox_clip_border (bool, optional): Whether clip the objects outside + the border of the image. Defaults to True. + + Note: + - If the image is smaller than the absolute crop size, return the + original image. + - The keys for bboxes, labels and masks must be aligned. That is, + `gt_bboxes` corresponds to `gt_labels` and `gt_masks`, and + `gt_bboxes_ignore` corresponds to `gt_labels_ignore` and + `gt_masks_ignore`. + - If the crop does not contain any gt-bbox region and + `allow_negative_crop` is set to False, skip this image. """ - def __init__(self, crop_size): + def __init__(self, + crop_size, + crop_type='absolute', + allow_negative_crop=False, + recompute_bbox=False, + bbox_clip_border=True): + if crop_type not in [ + 'relative_range', 'relative', 'absolute', 'absolute_range' + ]: + raise ValueError(f'Invalid crop_type {crop_type}.') + if crop_type in ['absolute', 'absolute_range']: + assert crop_size[0] > 0 and crop_size[1] > 0 + assert isinstance(crop_size[0], int) and isinstance( + crop_size[1], int) + else: + assert 0 < crop_size[0] <= 1 and 0 < crop_size[1] <= 1 self.crop_size = crop_size + self.crop_type = crop_type + self.allow_negative_crop = allow_negative_crop + self.bbox_clip_border = bbox_clip_border + self.recompute_bbox = recompute_bbox + # The key correspondence from bboxes to labels and masks. + self.bbox2label = { + 'gt_bboxes': 'gt_labels', + 'gt_bboxes_ignore': 'gt_labels_ignore' + } + self.bbox2mask = { + 'gt_bboxes': 'gt_masks', + 'gt_bboxes_ignore': 'gt_masks_ignore' + } + + def _crop_data(self, results, crop_size, allow_negative_crop): + """Function to randomly crop images, bounding boxes, masks, semantic + segmentation maps. - def __call__(self, results): - img = results['img'] - margin_h = max(img.shape[0] - self.crop_size[0], 0) - margin_w = max(img.shape[1] - self.crop_size[1], 0) - offset_h = np.random.randint(0, margin_h + 1) - offset_w = np.random.randint(0, margin_w + 1) - crop_y1, crop_y2 = offset_h, offset_h + self.crop_size[0] - crop_x1, crop_x2 = offset_w, offset_w + self.crop_size[1] - - # crop the image - img = img[crop_y1:crop_y2, crop_x1:crop_x2, ...] - img_shape = img.shape - results['img'] = img + Args: + results (dict): Result dict from loading pipeline. + crop_size (tuple): Expected absolute size after cropping, (h, w). + allow_negative_crop (bool): Whether to allow a crop that does not + contain any bbox area. Default to False. + + Returns: + dict: Randomly cropped results, 'img_shape' key in result dict is + updated according to crop size. + """ + assert crop_size[0] > 0 and crop_size[1] > 0 + for key in results.get('img_fields', ['img']): + img = results[key] + margin_h = max(img.shape[0] - crop_size[0], 0) + margin_w = max(img.shape[1] - crop_size[1], 0) + offset_h = np.random.randint(0, margin_h + 1) + offset_w = np.random.randint(0, margin_w + 1) + crop_y1, crop_y2 = offset_h, offset_h + crop_size[0] + crop_x1, crop_x2 = offset_w, offset_w + crop_size[1] + + # crop the image + img = img[crop_y1:crop_y2, crop_x1:crop_x2, ...] + img_shape = img.shape + results[key] = img results['img_shape'] = img_shape # crop bboxes accordingly and clip to the image boundary for key in results.get('bbox_fields', []): + # e.g. gt_bboxes and gt_bboxes_ignore bbox_offset = np.array([offset_w, offset_h, offset_w, offset_h], dtype=np.float32) bboxes = results[key] - bbox_offset - bboxes[:, 0::2] = np.clip(bboxes[:, 0::2], 0, img_shape[1] - 1) - bboxes[:, 1::2] = np.clip(bboxes[:, 1::2], 0, img_shape[0] - 1) - results[key] = bboxes + if self.bbox_clip_border: + bboxes[:, 0::2] = np.clip(bboxes[:, 0::2], 0, img_shape[1]) + bboxes[:, 1::2] = np.clip(bboxes[:, 1::2], 0, img_shape[0]) + valid_inds = (bboxes[:, 2] > bboxes[:, 0]) & ( + bboxes[:, 3] > bboxes[:, 1]) + # If the crop does not contain any gt-bbox area and + # allow_negative_crop is False, skip this image. + if (key == 'gt_bboxes' and not valid_inds.any() + and not allow_negative_crop): + return None + results[key] = bboxes[valid_inds, :] + # label fields. e.g. gt_labels and gt_labels_ignore + label_key = self.bbox2label.get(key) + if label_key in results: + results[label_key] = results[label_key][valid_inds] + + # mask fields, e.g. gt_masks and gt_masks_ignore + mask_key = self.bbox2mask.get(key) + if mask_key in results: + results[mask_key] = results[mask_key][ + valid_inds.nonzero()[0]].crop( + np.asarray([crop_x1, crop_y1, crop_x2, crop_y2])) + if self.recompute_bbox: + results[key] = results[mask_key].get_bboxes() # crop semantic seg for key in results.get('seg_fields', []): results[key] = results[key][crop_y1:crop_y2, crop_x1:crop_x2] - # filter out the gt bboxes that are completely cropped - if 'gt_bboxes' in results: - gt_bboxes = results['gt_bboxes'] - valid_inds = (gt_bboxes[:, 2] > gt_bboxes[:, 0]) & ( - gt_bboxes[:, 3] > gt_bboxes[:, 1]) - # if no gt bbox remains after cropping, just skip this image - if not np.any(valid_inds): - return None - results['gt_bboxes'] = gt_bboxes[valid_inds, :] - if 'gt_labels' in results: - results['gt_labels'] = results['gt_labels'][valid_inds] - - # filter and crop the masks - if 'gt_masks' in results: - valid_gt_masks = [] - for i in np.where(valid_inds)[0]: - gt_mask = results['gt_masks'][i][crop_y1:crop_y2, - crop_x1:crop_x2] - valid_gt_masks.append(gt_mask) - results['gt_masks'] = np.stack(valid_gt_masks) + return results + def _get_crop_size(self, image_size): + """Randomly generates the absolute crop size based on `crop_type` and + `image_size`. + + Args: + image_size (tuple): (h, w). + + Returns: + crop_size (tuple): (crop_h, crop_w) in absolute pixels. + """ + h, w = image_size + if self.crop_type == 'absolute': + return (min(self.crop_size[0], h), min(self.crop_size[1], w)) + elif self.crop_type == 'absolute_range': + assert self.crop_size[0] <= self.crop_size[1] + crop_h = np.random.randint( + min(h, self.crop_size[0]), + min(h, self.crop_size[1]) + 1) + crop_w = np.random.randint( + min(w, self.crop_size[0]), + min(w, self.crop_size[1]) + 1) + return crop_h, crop_w + elif self.crop_type == 'relative': + crop_h, crop_w = self.crop_size + return int(h * crop_h + 0.5), int(w * crop_w + 0.5) + elif self.crop_type == 'relative_range': + crop_size = np.asarray(self.crop_size, dtype=np.float32) + crop_h, crop_w = crop_size + np.random.rand(2) * (1 - crop_size) + return int(h * crop_h + 0.5), int(w * crop_w + 0.5) + + def __call__(self, results): + """Call function to randomly crop images, bounding boxes, masks, + semantic segmentation maps. + + Args: + results (dict): Result dict from loading pipeline. + + Returns: + dict: Randomly cropped results, 'img_shape' key in result dict is + updated according to crop size. + """ + image_size = results['img'].shape[:2] + crop_size = self._get_crop_size(image_size) + results = self._crop_data(results, crop_size, self.allow_negative_crop) return results def __repr__(self): - return self.__class__.__name__ + '(crop_size={})'.format( - self.crop_size) + repr_str = self.__class__.__name__ + repr_str += f'(crop_size={self.crop_size}, ' + repr_str += f'crop_type={self.crop_type}, ' + repr_str += f'allow_negative_crop={self.allow_negative_crop}, ' + repr_str += f'bbox_clip_border={self.bbox_clip_border})' + return repr_str -@PIPELINES.register_module -class SegRescale(object): +@PIPELINES.register_module() +class SegRescale: """Rescale semantic segmentation maps. Args: scale_factor (float): The scale factor of the final output. + backend (str): Image rescale backend, choices are 'cv2' and 'pillow'. + These two backends generates slightly different results. Defaults + to 'cv2'. """ - def __init__(self, scale_factor=1): + def __init__(self, scale_factor=1, backend='cv2'): self.scale_factor = scale_factor + self.backend = backend def __call__(self, results): + """Call function to scale the semantic segmentation map. + + Args: + results (dict): Result dict from loading pipeline. + + Returns: + dict: Result dict with semantic segmentation map scaled. + """ + for key in results.get('seg_fields', []): if self.scale_factor != 1: results[key] = mmcv.imrescale( - results[key], self.scale_factor, interpolation='nearest') + results[key], + self.scale_factor, + interpolation='nearest', + backend=self.backend) return results def __repr__(self): - return self.__class__.__name__ + '(scale_factor={})'.format( - self.scale_factor) + return self.__class__.__name__ + f'(scale_factor={self.scale_factor})' -@PIPELINES.register_module -class PhotoMetricDistortion(object): +@PIPELINES.register_module() +class PhotoMetricDistortion: """Apply photometric distortion to image sequentially, every transformation is applied with a probability of 0.5. The position of random contrast is in second or second to last. @@ -475,7 +977,20 @@ class PhotoMetricDistortion(object): self.hue_delta = hue_delta def __call__(self, results): + """Call function to perform photometric distortion on images. + + Args: + results (dict): Result dict from loading pipeline. + + Returns: + dict: Result dict with images distorted. + """ + + if 'img_fields' in results: + assert results['img_fields'] == ['img'], \ + 'Only single img_fields is allowed' img = results['img'] + img = img.astype(np.float32) # random brightness if random.randint(2): delta = random.uniform(-self.brightness_delta, @@ -524,15 +1039,17 @@ class PhotoMetricDistortion(object): def __repr__(self): repr_str = self.__class__.__name__ - repr_str += ('(brightness_delta={}, contrast_range={}, ' - 'saturation_range={}, hue_delta={})').format( - self.brightness_delta, self.contrast_range, - self.saturation_range, self.hue_delta) + repr_str += f'(\nbrightness_delta={self.brightness_delta},\n' + repr_str += 'contrast_range=' + repr_str += f'{(self.contrast_lower, self.contrast_upper)},\n' + repr_str += 'saturation_range=' + repr_str += f'{(self.saturation_lower, self.saturation_upper)},\n' + repr_str += f'hue_delta={self.hue_delta})' return repr_str -@PIPELINES.register_module -class Expand(object): +@PIPELINES.register_module() +class Expand: """Random expand the image & bboxes. Randomly place the original image on a canvas of 'ratio' x original image @@ -562,53 +1079,69 @@ class Expand(object): self.prob = prob def __call__(self, results): + """Call function to expand images, bounding boxes. + + Args: + results (dict): Result dict from loading pipeline. + + Returns: + dict: Result dict with images, bounding boxes expanded + """ + if random.uniform(0, 1) > self.prob: return results - img, boxes = [results[k] for k in ('img', 'gt_bboxes')] + if 'img_fields' in results: + assert results['img_fields'] == ['img'], \ + 'Only single img_fields is allowed' + img = results['img'] h, w, c = img.shape ratio = random.uniform(self.min_ratio, self.max_ratio) - expand_img = np.full((int(h * ratio), int(w * ratio), c), - self.mean).astype(img.dtype) + # speedup expand when meets large image + if np.all(self.mean == self.mean[0]): + expand_img = np.empty((int(h * ratio), int(w * ratio), c), + img.dtype) + expand_img.fill(self.mean[0]) + else: + expand_img = np.full((int(h * ratio), int(w * ratio), c), + self.mean, + dtype=img.dtype) left = int(random.uniform(0, w * ratio - w)) top = int(random.uniform(0, h * ratio - h)) expand_img[top:top + h, left:left + w] = img - boxes = boxes + np.tile((left, top), 2).astype(boxes.dtype) results['img'] = expand_img - results['gt_bboxes'] = boxes - - if 'gt_masks' in results: - expand_gt_masks = [] - for mask in results['gt_masks']: - expand_mask = np.full((int(h * ratio), int(w * ratio)), - 0).astype(mask.dtype) - expand_mask[top:top + h, left:left + w] = mask - expand_gt_masks.append(expand_mask) - results['gt_masks'] = np.stack(expand_gt_masks) - - # not tested - if 'gt_semantic_seg' in results: - assert self.seg_ignore_label is not None - gt_seg = results['gt_semantic_seg'] + # expand bboxes + for key in results.get('bbox_fields', []): + results[key] = results[key] + np.tile( + (left, top), 2).astype(results[key].dtype) + + # expand masks + for key in results.get('mask_fields', []): + results[key] = results[key].expand( + int(h * ratio), int(w * ratio), top, left) + + # expand segs + for key in results.get('seg_fields', []): + gt_seg = results[key] expand_gt_seg = np.full((int(h * ratio), int(w * ratio)), - self.seg_ignore_label).astype(gt_seg.dtype) + self.seg_ignore_label, + dtype=gt_seg.dtype) expand_gt_seg[top:top + h, left:left + w] = gt_seg - results['gt_semantic_seg'] = expand_gt_seg + results[key] = expand_gt_seg return results def __repr__(self): repr_str = self.__class__.__name__ - repr_str += '(mean={}, to_rgb={}, ratio_range={}, ' \ - 'seg_ignore_label={})'.format( - self.mean, self.to_rgb, self.ratio_range, - self.seg_ignore_label) + repr_str += f'(mean={self.mean}, to_rgb={self.to_rgb}, ' + repr_str += f'ratio_range={self.ratio_range}, ' + repr_str += f'seg_ignore_label={self.seg_ignore_label})' return repr_str -@PIPELINES.register_module -class MinIoURandomCrop(object): +@PIPELINES.register_module() +class MinIoURandomCrop: """Random crop the image & bboxes, the cropped patches have minimum IoU requirement with original image & bboxes, the IoU threshold is randomly selected from min_ious. @@ -618,20 +1151,56 @@ class MinIoURandomCrop(object): bounding boxes min_crop_size (float): minimum crop's size (i.e. h,w := a*h, a*w, where a >= min_crop_size). + bbox_clip_border (bool, optional): Whether clip the objects outside + the border of the image. Defaults to True. + + Note: + The keys for bboxes, labels and masks should be paired. That is, \ + `gt_bboxes` corresponds to `gt_labels` and `gt_masks`, and \ + `gt_bboxes_ignore` to `gt_labels_ignore` and `gt_masks_ignore`. """ - def __init__(self, min_ious=(0.1, 0.3, 0.5, 0.7, 0.9), min_crop_size=0.3): + def __init__(self, + min_ious=(0.1, 0.3, 0.5, 0.7, 0.9), + min_crop_size=0.3, + bbox_clip_border=True): # 1: return ori img + self.min_ious = min_ious self.sample_mode = (1, *min_ious, 0) self.min_crop_size = min_crop_size + self.bbox_clip_border = bbox_clip_border + self.bbox2label = { + 'gt_bboxes': 'gt_labels', + 'gt_bboxes_ignore': 'gt_labels_ignore' + } + self.bbox2mask = { + 'gt_bboxes': 'gt_masks', + 'gt_bboxes_ignore': 'gt_masks_ignore' + } def __call__(self, results): - img, boxes, labels = [ - results[k] for k in ('img', 'gt_bboxes', 'gt_labels') - ] + """Call function to crop images and bounding boxes with minimum IoU + constraint. + + Args: + results (dict): Result dict from loading pipeline. + + Returns: + dict: Result dict with images and bounding boxes cropped, \ + 'img_shape' key is updated. + """ + + if 'img_fields' in results: + assert results['img_fields'] == ['img'], \ + 'Only single img_fields is allowed' + img = results['img'] + assert 'bbox_fields' in results + boxes = [results[key] for key in results['bbox_fields']] + boxes = np.concatenate(boxes, 0) h, w, c = img.shape while True: mode = random.choice(self.sample_mode) + self.mode = mode if mode == 1: return results @@ -649,63 +1218,99 @@ class MinIoURandomCrop(object): patch = np.array( (int(left), int(top), int(left + new_w), int(top + new_h))) + # Line or point crop is not allowed + if patch[2] == patch[0] or patch[3] == patch[1]: + continue overlaps = bbox_overlaps( patch.reshape(-1, 4), boxes.reshape(-1, 4)).reshape(-1) - if overlaps.min() < min_iou: + if len(overlaps) > 0 and overlaps.min() < min_iou: continue # center of boxes should inside the crop img - center = (boxes[:, :2] + boxes[:, 2:]) / 2 - mask = ((center[:, 0] > patch[0]) * (center[:, 1] > patch[1]) * - (center[:, 0] < patch[2]) * (center[:, 1] < patch[3])) - if not mask.any(): - continue - boxes = boxes[mask] - labels = labels[mask] - - # adjust boxes + # only adjust boxes and instance masks when the gt is not empty + if len(overlaps) > 0: + # adjust boxes + def is_center_of_bboxes_in_patch(boxes, patch): + center = (boxes[:, :2] + boxes[:, 2:]) / 2 + mask = ((center[:, 0] > patch[0]) * + (center[:, 1] > patch[1]) * + (center[:, 0] < patch[2]) * + (center[:, 1] < patch[3])) + return mask + + mask = is_center_of_bboxes_in_patch(boxes, patch) + if not mask.any(): + continue + for key in results.get('bbox_fields', []): + boxes = results[key].copy() + mask = is_center_of_bboxes_in_patch(boxes, patch) + boxes = boxes[mask] + if self.bbox_clip_border: + boxes[:, 2:] = boxes[:, 2:].clip(max=patch[2:]) + boxes[:, :2] = boxes[:, :2].clip(min=patch[:2]) + boxes -= np.tile(patch[:2], 2) + + results[key] = boxes + # labels + label_key = self.bbox2label.get(key) + if label_key in results: + results[label_key] = results[label_key][mask] + + # mask fields + mask_key = self.bbox2mask.get(key) + if mask_key in results: + results[mask_key] = results[mask_key][ + mask.nonzero()[0]].crop(patch) + # adjust the img no matter whether the gt is empty before crop img = img[patch[1]:patch[3], patch[0]:patch[2]] - boxes[:, 2:] = boxes[:, 2:].clip(max=patch[2:]) - boxes[:, :2] = boxes[:, :2].clip(min=patch[:2]) - boxes -= np.tile(patch[:2], 2) - results['img'] = img - results['gt_bboxes'] = boxes - results['gt_labels'] = labels + results['img_shape'] = img.shape - if 'gt_masks' in results: - valid_masks = [ - results['gt_masks'][i] for i in range(len(mask)) - if mask[i] - ] - results['gt_masks'] = np.stack([ - gt_mask[patch[1]:patch[3], patch[0]:patch[2]] - for gt_mask in valid_masks - ]) - - # not tested - if 'gt_semantic_seg' in results: - results['gt_semantic_seg'] = results['gt_semantic_seg'][ - patch[1]:patch[3], patch[0]:patch[2]] + # seg fields + for key in results.get('seg_fields', []): + results[key] = results[key][patch[1]:patch[3], + patch[0]:patch[2]] return results def __repr__(self): repr_str = self.__class__.__name__ - repr_str += '(min_ious={}, min_crop_size={})'.format( - self.min_ious, self.min_crop_size) + repr_str += f'(min_ious={self.min_ious}, ' + repr_str += f'min_crop_size={self.min_crop_size}, ' + repr_str += f'bbox_clip_border={self.bbox_clip_border})' return repr_str -@PIPELINES.register_module -class Corrupt(object): +@PIPELINES.register_module() +class Corrupt: + """Corruption augmentation. + + Corruption transforms implemented based on + `imagecorruptions `_. + + Args: + corruption (str): Corruption name. + severity (int, optional): The severity of corruption. Default: 1. + """ def __init__(self, corruption, severity=1): self.corruption = corruption self.severity = severity def __call__(self, results): + """Call function to corrupt image. + + Args: + results (dict): Result dict from loading pipeline. + + Returns: + dict: Result dict with images corrupted. + """ + if corrupt is None: raise RuntimeError('imagecorruptions is not installed') + if 'img_fields' in results: + assert results['img_fields'] == ['img'], \ + 'Only single img_fields is allowed' results['img'] = corrupt( results['img'].astype(np.uint8), corruption_name=self.corruption, @@ -714,13 +1319,53 @@ class Corrupt(object): def __repr__(self): repr_str = self.__class__.__name__ - repr_str += '(corruption={}, severity={})'.format( - self.corruption, self.severity) + repr_str += f'(corruption={self.corruption}, ' + repr_str += f'severity={self.severity})' return repr_str -@PIPELINES.register_module -class Albu(object): +@PIPELINES.register_module() +class Albu: + """Albumentation augmentation. + + Adds custom transformations from Albumentations library. + Please, visit `https://albumentations.readthedocs.io` + to get more information. + + An example of ``transforms`` is as followed: + + .. code-block:: + + [ + dict( + type='ShiftScaleRotate', + shift_limit=0.0625, + scale_limit=0.0, + rotate_limit=0, + interpolation=1, + p=0.5), + dict( + type='RandomBrightnessContrast', + brightness_limit=[0.1, 0.3], + contrast_limit=[0.1, 0.3], + p=0.2), + dict(type='ChannelShuffle', p=0.1), + dict( + type='OneOf', + transforms=[ + dict(type='Blur', blur_limit=3, p=1.0), + dict(type='MedianBlur', blur_limit=3, p=1.0) + ], + p=0.1), + ] + + Args: + transforms (list[dict]): A list of albu transformations + bbox_params (dict): Bbox_params for albumentation `Compose` + keymap (dict): Contains {'input key':'albumentation-style key'} + skip_img_without_anno (bool): Whether to skip the image if no ann left + after aug + """ def __init__(self, transforms, @@ -728,20 +1373,15 @@ class Albu(object): keymap=None, update_pad_shape=False, skip_img_without_anno=False): - """ - Adds custom transformations from Albumentations lib. - Please, visit `https://albumentations.readthedocs.io` - to get more information. - - transforms (list): list of albu transformations - bbox_params (dict): bbox_params for albumentation `Compose` - keymap (dict): contains {'input key':'albumentation-style key'} - skip_img_without_anno (bool): whether to skip the image - if no ann left after aug - """ if Compose is None: raise RuntimeError('albumentations is not installed') + # Args will be modified later, copying it will be safer + transforms = copy.deepcopy(transforms) + if bbox_params is not None: + bbox_params = copy.deepcopy(bbox_params) + if keymap is not None: + keymap = copy.deepcopy(keymap) self.transforms = transforms self.filter_lost_elements = False self.update_pad_shape = update_pad_shape @@ -772,17 +1412,20 @@ class Albu(object): def albu_builder(self, cfg): """Import a module from albumentations. - Inherits some of `build_from_cfg` logic. + + It inherits some of :func:`build_from_cfg` logic. Args: cfg (dict): Config dict. It should at least contain the key "type". + Returns: obj: The constructed object. """ - assert isinstance(cfg, dict) and "type" in cfg + + assert isinstance(cfg, dict) and 'type' in cfg args = cfg.copy() - obj_type = args.pop("type") + obj_type = args.pop('type') if mmcv.is_str(obj_type): if albumentations is None: raise RuntimeError('albumentations is not installed') @@ -791,8 +1434,7 @@ class Albu(object): obj_cls = obj_type else: raise TypeError( - 'type must be a str or valid type, but got {}'.format( - type(obj_type))) + f'type must be a str or valid type, but got {type(obj_type)}') if 'transforms' in args: args['transforms'] = [ @@ -804,9 +1446,7 @@ class Albu(object): @staticmethod def mapper(d, keymap): - """ - Dictionary mapper. - Renames keys according to keymap provided. + """Dictionary mapper. Renames keys according to keymap provided. Args: d (dict): old dict @@ -814,6 +1454,7 @@ class Albu(object): Returns: dict: new dict. """ + updated_dict = {} for k, v in zip(d.keys(), d.values()): new_k = keymap.get(k, k) @@ -823,7 +1464,7 @@ class Albu(object): def __call__(self, results): # dict to albumentations format results = self.mapper(results, self.keymap_to_albu) - + # TODO: add bbox_fields if 'bboxes' in results: # to list of boxes if isinstance(results['bboxes'], np.ndarray): @@ -832,6 +1473,17 @@ class Albu(object): if self.filter_lost_elements: results['idx_mapper'] = np.arange(len(results['bboxes'])) + # TODO: Support mask structure in albu + if 'masks' in results: + if isinstance(results['masks'], PolygonMasks): + raise NotImplementedError( + 'Albu only supports BitMap masks now') + ori_masks = results['masks'] + if albumentations.__version__ < '0.5': + results['masks'] = results['masks'].masks + else: + results['masks'] = [mask for mask in results['masks'].masks] + results = self.aug(**results) if 'bboxes' in results: @@ -843,14 +1495,15 @@ class Albu(object): # filter label_fields if self.filter_lost_elements: - results['idx_mapper'] = np.arange(len(results['bboxes'])) - for label in self.origin_label_fields: results[label] = np.array( [results[label][i] for i in results['idx_mapper']]) if 'masks' in results: results['masks'] = np.array( [results['masks'][i] for i in results['idx_mapper']]) + results['masks'] = ori_masks.__class__( + results['masks'], results['image'].shape[0], + results['image'].shape[1]) if (not len(results['idx_mapper']) and self.skip_img_without_anno): @@ -870,7 +1523,1397 @@ class Albu(object): return results + def __repr__(self): + repr_str = self.__class__.__name__ + f'(transforms={self.transforms})' + return repr_str + + +@PIPELINES.register_module() +class RandomCenterCropPad: + """Random center crop and random around padding for CornerNet. + + This operation generates randomly cropped image from the original image and + pads it simultaneously. Different from :class:`RandomCrop`, the output + shape may not equal to ``crop_size`` strictly. We choose a random value + from ``ratios`` and the output shape could be larger or smaller than + ``crop_size``. The padding operation is also different from :class:`Pad`, + here we use around padding instead of right-bottom padding. + + The relation between output image (padding image) and original image: + + .. code:: text + + output image + + +----------------------------+ + | padded area | + +------|----------------------------|----------+ + | | cropped area | | + | | +---------------+ | | + | | | . center | | | original image + | | | range | | | + | | +---------------+ | | + +------|----------------------------|----------+ + | padded area | + +----------------------------+ + + There are 5 main areas in the figure: + + - output image: output image of this operation, also called padding + image in following instruction. + - original image: input image of this operation. + - padded area: non-intersect area of output image and original image. + - cropped area: the overlap of output image and original image. + - center range: a smaller area where random center chosen from. + center range is computed by ``border`` and original image's shape + to avoid our random center is too close to original image's border. + + Also this operation act differently in train and test mode, the summary + pipeline is listed below. + + Train pipeline: + + 1. Choose a ``random_ratio`` from ``ratios``, the shape of padding image + will be ``random_ratio * crop_size``. + 2. Choose a ``random_center`` in center range. + 3. Generate padding image with center matches the ``random_center``. + 4. Initialize the padding image with pixel value equals to ``mean``. + 5. Copy the cropped area to padding image. + 6. Refine annotations. + + Test pipeline: + + 1. Compute output shape according to ``test_pad_mode``. + 2. Generate padding image with center matches the original image + center. + 3. Initialize the padding image with pixel value equals to ``mean``. + 4. Copy the ``cropped area`` to padding image. + + Args: + crop_size (tuple | None): expected size after crop, final size will + computed according to ratio. Requires (h, w) in train mode, and + None in test mode. + ratios (tuple): random select a ratio from tuple and crop image to + (crop_size[0] * ratio) * (crop_size[1] * ratio). + Only available in train mode. + border (int): max distance from center select area to image border. + Only available in train mode. + mean (sequence): Mean values of 3 channels. + std (sequence): Std values of 3 channels. + to_rgb (bool): Whether to convert the image from BGR to RGB. + test_mode (bool): whether involve random variables in transform. + In train mode, crop_size is fixed, center coords and ratio is + random selected from predefined lists. In test mode, crop_size + is image's original shape, center coords and ratio is fixed. + test_pad_mode (tuple): padding method and padding shape value, only + available in test mode. Default is using 'logical_or' with + 127 as padding shape value. + + - 'logical_or': final_shape = input_shape | padding_shape_value + - 'size_divisor': final_shape = int( + ceil(input_shape / padding_shape_value) * padding_shape_value) + test_pad_add_pix (int): Extra padding pixel in test mode. Default 0. + bbox_clip_border (bool, optional): Whether clip the objects outside + the border of the image. Defaults to True. + """ + + def __init__(self, + crop_size=None, + ratios=(0.9, 1.0, 1.1), + border=128, + mean=None, + std=None, + to_rgb=None, + test_mode=False, + test_pad_mode=('logical_or', 127), + test_pad_add_pix=0, + bbox_clip_border=True): + if test_mode: + assert crop_size is None, 'crop_size must be None in test mode' + assert ratios is None, 'ratios must be None in test mode' + assert border is None, 'border must be None in test mode' + assert isinstance(test_pad_mode, (list, tuple)) + assert test_pad_mode[0] in ['logical_or', 'size_divisor'] + else: + assert isinstance(crop_size, (list, tuple)) + assert crop_size[0] > 0 and crop_size[1] > 0, ( + 'crop_size must > 0 in train mode') + assert isinstance(ratios, (list, tuple)) + assert test_pad_mode is None, ( + 'test_pad_mode must be None in train mode') + + self.crop_size = crop_size + self.ratios = ratios + self.border = border + # We do not set default value to mean, std and to_rgb because these + # hyper-parameters are easy to forget but could affect the performance. + # Please use the same setting as Normalize for performance assurance. + assert mean is not None and std is not None and to_rgb is not None + self.to_rgb = to_rgb + self.input_mean = mean + self.input_std = std + if to_rgb: + self.mean = mean[::-1] + self.std = std[::-1] + else: + self.mean = mean + self.std = std + self.test_mode = test_mode + self.test_pad_mode = test_pad_mode + self.test_pad_add_pix = test_pad_add_pix + self.bbox_clip_border = bbox_clip_border + + def _get_border(self, border, size): + """Get final border for the target size. + + This function generates a ``final_border`` according to image's shape. + The area between ``final_border`` and ``size - final_border`` is the + ``center range``. We randomly choose center from the ``center range`` + to avoid our random center is too close to original image's border. + Also ``center range`` should be larger than 0. + + Args: + border (int): The initial border, default is 128. + size (int): The width or height of original image. + Returns: + int: The final border. + """ + k = 2 * border / size + i = pow(2, np.ceil(np.log2(np.ceil(k))) + (k == int(k))) + return border // i + + def _filter_boxes(self, patch, boxes): + """Check whether the center of each box is in the patch. + + Args: + patch (list[int]): The cropped area, [left, top, right, bottom]. + boxes (numpy array, (N x 4)): Ground truth boxes. + + Returns: + mask (numpy array, (N,)): Each box is inside or outside the patch. + """ + center = (boxes[:, :2] + boxes[:, 2:]) / 2 + mask = (center[:, 0] > patch[0]) * (center[:, 1] > patch[1]) * ( + center[:, 0] < patch[2]) * ( + center[:, 1] < patch[3]) + return mask + + def _crop_image_and_paste(self, image, center, size): + """Crop image with a given center and size, then paste the cropped + image to a blank image with two centers align. + + This function is equivalent to generating a blank image with ``size`` + as its shape. Then cover it on the original image with two centers ( + the center of blank image and the random center of original image) + aligned. The overlap area is paste from the original image and the + outside area is filled with ``mean pixel``. + + Args: + image (np array, H x W x C): Original image. + center (list[int]): Target crop center coord. + size (list[int]): Target crop size. [target_h, target_w] + + Returns: + cropped_img (np array, target_h x target_w x C): Cropped image. + border (np array, 4): The distance of four border of + ``cropped_img`` to the original image area, [top, bottom, + left, right] + patch (list[int]): The cropped area, [left, top, right, bottom]. + """ + center_y, center_x = center + target_h, target_w = size + img_h, img_w, img_c = image.shape + + x0 = max(0, center_x - target_w // 2) + x1 = min(center_x + target_w // 2, img_w) + y0 = max(0, center_y - target_h // 2) + y1 = min(center_y + target_h // 2, img_h) + patch = np.array((int(x0), int(y0), int(x1), int(y1))) + + left, right = center_x - x0, x1 - center_x + top, bottom = center_y - y0, y1 - center_y + + cropped_center_y, cropped_center_x = target_h // 2, target_w // 2 + cropped_img = np.zeros((target_h, target_w, img_c), dtype=image.dtype) + for i in range(img_c): + cropped_img[:, :, i] += self.mean[i] + y_slice = slice(cropped_center_y - top, cropped_center_y + bottom) + x_slice = slice(cropped_center_x - left, cropped_center_x + right) + cropped_img[y_slice, x_slice, :] = image[y0:y1, x0:x1, :] + + border = np.array([ + cropped_center_y - top, cropped_center_y + bottom, + cropped_center_x - left, cropped_center_x + right + ], + dtype=np.float32) + + return cropped_img, border, patch + + def _train_aug(self, results): + """Random crop and around padding the original image. + + Args: + results (dict): Image infomations in the augment pipeline. + + Returns: + results (dict): The updated dict. + """ + img = results['img'] + h, w, c = img.shape + boxes = results['gt_bboxes'] + while True: + scale = random.choice(self.ratios) + new_h = int(self.crop_size[0] * scale) + new_w = int(self.crop_size[1] * scale) + h_border = self._get_border(self.border, h) + w_border = self._get_border(self.border, w) + + for i in range(50): + center_x = random.randint(low=w_border, high=w - w_border) + center_y = random.randint(low=h_border, high=h - h_border) + + cropped_img, border, patch = self._crop_image_and_paste( + img, [center_y, center_x], [new_h, new_w]) + + mask = self._filter_boxes(patch, boxes) + # if image do not have valid bbox, any crop patch is valid. + if not mask.any() and len(boxes) > 0: + continue + + results['img'] = cropped_img + results['img_shape'] = cropped_img.shape + results['pad_shape'] = cropped_img.shape + + x0, y0, x1, y1 = patch + + left_w, top_h = center_x - x0, center_y - y0 + cropped_center_x, cropped_center_y = new_w // 2, new_h // 2 + + # crop bboxes accordingly and clip to the image boundary + for key in results.get('bbox_fields', []): + mask = self._filter_boxes(patch, results[key]) + bboxes = results[key][mask] + bboxes[:, 0:4:2] += cropped_center_x - left_w - x0 + bboxes[:, 1:4:2] += cropped_center_y - top_h - y0 + if self.bbox_clip_border: + bboxes[:, 0:4:2] = np.clip(bboxes[:, 0:4:2], 0, new_w) + bboxes[:, 1:4:2] = np.clip(bboxes[:, 1:4:2], 0, new_h) + keep = (bboxes[:, 2] > bboxes[:, 0]) & ( + bboxes[:, 3] > bboxes[:, 1]) + bboxes = bboxes[keep] + results[key] = bboxes + if key in ['gt_bboxes']: + if 'gt_labels' in results: + labels = results['gt_labels'][mask] + labels = labels[keep] + results['gt_labels'] = labels + if 'gt_masks' in results: + raise NotImplementedError( + 'RandomCenterCropPad only supports bbox.') + + # crop semantic seg + for key in results.get('seg_fields', []): + raise NotImplementedError( + 'RandomCenterCropPad only supports bbox.') + return results + + def _test_aug(self, results): + """Around padding the original image without cropping. + + The padding mode and value are from ``test_pad_mode``. + + Args: + results (dict): Image infomations in the augment pipeline. + + Returns: + results (dict): The updated dict. + """ + img = results['img'] + h, w, c = img.shape + results['img_shape'] = img.shape + if self.test_pad_mode[0] in ['logical_or']: + # self.test_pad_add_pix is only used for centernet + target_h = (h | self.test_pad_mode[1]) + self.test_pad_add_pix + target_w = (w | self.test_pad_mode[1]) + self.test_pad_add_pix + elif self.test_pad_mode[0] in ['size_divisor']: + divisor = self.test_pad_mode[1] + target_h = int(np.ceil(h / divisor)) * divisor + target_w = int(np.ceil(w / divisor)) * divisor + else: + raise NotImplementedError( + 'RandomCenterCropPad only support two testing pad mode:' + 'logical-or and size_divisor.') + + cropped_img, border, _ = self._crop_image_and_paste( + img, [h // 2, w // 2], [target_h, target_w]) + results['img'] = cropped_img + results['pad_shape'] = cropped_img.shape + results['border'] = border + return results + + def __call__(self, results): + img = results['img'] + assert img.dtype == np.float32, ( + 'RandomCenterCropPad needs the input image of dtype np.float32,' + ' please set "to_float32=True" in "LoadImageFromFile" pipeline') + h, w, c = img.shape + assert c == len(self.mean) + if self.test_mode: + return self._test_aug(results) + else: + return self._train_aug(results) + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += f'(crop_size={self.crop_size}, ' + repr_str += f'ratios={self.ratios}, ' + repr_str += f'border={self.border}, ' + repr_str += f'mean={self.input_mean}, ' + repr_str += f'std={self.input_std}, ' + repr_str += f'to_rgb={self.to_rgb}, ' + repr_str += f'test_mode={self.test_mode}, ' + repr_str += f'test_pad_mode={self.test_pad_mode}, ' + repr_str += f'bbox_clip_border={self.bbox_clip_border})' + return repr_str + + +@PIPELINES.register_module() +class CutOut: + """CutOut operation. + + Randomly drop some regions of image used in + `Cutout `_. + + Args: + n_holes (int | tuple[int, int]): Number of regions to be dropped. + If it is given as a list, number of holes will be randomly + selected from the closed interval [`n_holes[0]`, `n_holes[1]`]. + cutout_shape (tuple[int, int] | list[tuple[int, int]]): The candidate + shape of dropped regions. It can be `tuple[int, int]` to use a + fixed cutout shape, or `list[tuple[int, int]]` to randomly choose + shape from the list. + cutout_ratio (tuple[float, float] | list[tuple[float, float]]): The + candidate ratio of dropped regions. It can be `tuple[float, float]` + to use a fixed ratio or `list[tuple[float, float]]` to randomly + choose ratio from the list. Please note that `cutout_shape` + and `cutout_ratio` cannot be both given at the same time. + fill_in (tuple[float, float, float] | tuple[int, int, int]): The value + of pixel to fill in the dropped regions. Default: (0, 0, 0). + """ + + def __init__(self, + n_holes, + cutout_shape=None, + cutout_ratio=None, + fill_in=(0, 0, 0)): + + assert (cutout_shape is None) ^ (cutout_ratio is None), \ + 'Either cutout_shape or cutout_ratio should be specified.' + assert (isinstance(cutout_shape, (list, tuple)) + or isinstance(cutout_ratio, (list, tuple))) + if isinstance(n_holes, tuple): + assert len(n_holes) == 2 and 0 <= n_holes[0] < n_holes[1] + else: + n_holes = (n_holes, n_holes) + self.n_holes = n_holes + self.fill_in = fill_in + self.with_ratio = cutout_ratio is not None + self.candidates = cutout_ratio if self.with_ratio else cutout_shape + if not isinstance(self.candidates, list): + self.candidates = [self.candidates] + + def __call__(self, results): + """Call function to drop some regions of image.""" + h, w, c = results['img'].shape + n_holes = np.random.randint(self.n_holes[0], self.n_holes[1] + 1) + for _ in range(n_holes): + x1 = np.random.randint(0, w) + y1 = np.random.randint(0, h) + index = np.random.randint(0, len(self.candidates)) + if not self.with_ratio: + cutout_w, cutout_h = self.candidates[index] + else: + cutout_w = int(self.candidates[index][0] * w) + cutout_h = int(self.candidates[index][1] * h) + + x2 = np.clip(x1 + cutout_w, 0, w) + y2 = np.clip(y1 + cutout_h, 0, h) + results['img'][y1:y2, x1:x2, :] = self.fill_in + + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += f'(n_holes={self.n_holes}, ' + repr_str += (f'cutout_ratio={self.candidates}, ' if self.with_ratio + else f'cutout_shape={self.candidates}, ') + repr_str += f'fill_in={self.fill_in})' + return repr_str + + +@PIPELINES.register_module() +class Mosaic: + """Mosaic augmentation. + + Given 4 images, mosaic transform combines them into + one output image. The output image is composed of the parts from each sub- + image. + + .. code:: text + + mosaic transform + center_x + +------------------------------+ + | pad | pad | + | +-----------+ | + | | | | + | | image1 |--------+ | + | | | | | + | | | image2 | | + center_y |----+-------------+-----------| + | | cropped | | + |pad | image3 | image4 | + | | | | + +----|-------------+-----------+ + | | + +-------------+ + + The mosaic transform steps are as follows: + + 1. Choose the mosaic center as the intersections of 4 images + 2. Get the left top image according to the index, and randomly + sample another 3 images from the custom dataset. + 3. Sub image will be cropped if image is larger than mosaic patch + + Args: + img_scale (Sequence[int]): Image size after mosaic pipeline of single + image. The shape order should be (height, width). + Default to (640, 640). + center_ratio_range (Sequence[float]): Center ratio range of mosaic + output. Default to (0.5, 1.5). + min_bbox_size (int | float): The minimum pixel for filtering + invalid bboxes after the mosaic pipeline. Default to 0. + bbox_clip_border (bool, optional): Whether to clip the objects outside + the border of the image. In some dataset like MOT17, the gt bboxes + are allowed to cross the border of images. Therefore, we don't + need to clip the gt bboxes in these cases. Defaults to True. + skip_filter (bool): Whether to skip filtering rules. If it + is True, the filter rule will not be applied, and the + `min_bbox_size` is invalid. Default to True. + pad_val (int): Pad value. Default to 114. + prob (float): Probability of applying this transformation. + Default to 1.0. + """ + + def __init__(self, + img_scale=(640, 640), + center_ratio_range=(0.5, 1.5), + min_bbox_size=0, + bbox_clip_border=True, + skip_filter=True, + pad_val=114, + prob=1.0): + assert isinstance(img_scale, tuple) + assert 0 <= prob <= 1.0, 'The probability should be in range [0,1]. '\ + f'got {prob}.' + + log_img_scale(img_scale, skip_square=True) + self.img_scale = img_scale + self.center_ratio_range = center_ratio_range + self.min_bbox_size = min_bbox_size + self.bbox_clip_border = bbox_clip_border + self.skip_filter = skip_filter + self.pad_val = pad_val + self.prob = prob + + def __call__(self, results): + """Call function to make a mosaic of image. + + Args: + results (dict): Result dict. + + Returns: + dict: Result dict with mosaic transformed. + """ + + if random.uniform(0, 1) > self.prob: + return results + + results = self._mosaic_transform(results) + return results + + def get_indexes(self, dataset): + """Call function to collect indexes. + + Args: + dataset (:obj:`MultiImageMixDataset`): The dataset. + + Returns: + list: indexes. + """ + + indexes = [random.randint(0, len(dataset)) for _ in range(3)] + return indexes + + def _mosaic_transform(self, results): + """Mosaic transform function. + + Args: + results (dict): Result dict. + + Returns: + dict: Updated result dict. + """ + + assert 'mix_results' in results + mosaic_labels = [] + mosaic_bboxes = [] + if len(results['img'].shape) == 3: + mosaic_img = np.full( + (int(self.img_scale[0] * 2), int(self.img_scale[1] * 2), 3), + self.pad_val, + dtype=results['img'].dtype) + else: + mosaic_img = np.full( + (int(self.img_scale[0] * 2), int(self.img_scale[1] * 2)), + self.pad_val, + dtype=results['img'].dtype) + + # mosaic center x, y + center_x = int( + random.uniform(*self.center_ratio_range) * self.img_scale[1]) + center_y = int( + random.uniform(*self.center_ratio_range) * self.img_scale[0]) + center_position = (center_x, center_y) + + loc_strs = ('top_left', 'top_right', 'bottom_left', 'bottom_right') + for i, loc in enumerate(loc_strs): + if loc == 'top_left': + results_patch = copy.deepcopy(results) + else: + results_patch = copy.deepcopy(results['mix_results'][i - 1]) + + img_i = results_patch['img'] + h_i, w_i = img_i.shape[:2] + # keep_ratio resize + scale_ratio_i = min(self.img_scale[0] / h_i, + self.img_scale[1] / w_i) + img_i = mmcv.imresize( + img_i, (int(w_i * scale_ratio_i), int(h_i * scale_ratio_i))) + + # compute the combine parameters + paste_coord, crop_coord = self._mosaic_combine( + loc, center_position, img_i.shape[:2][::-1]) + x1_p, y1_p, x2_p, y2_p = paste_coord + x1_c, y1_c, x2_c, y2_c = crop_coord + + # crop and paste image + mosaic_img[y1_p:y2_p, x1_p:x2_p] = img_i[y1_c:y2_c, x1_c:x2_c] + + # adjust coordinate + gt_bboxes_i = results_patch['gt_bboxes'] + gt_labels_i = results_patch['gt_labels'] + + if gt_bboxes_i.shape[0] > 0: + padw = x1_p - x1_c + padh = y1_p - y1_c + gt_bboxes_i[:, 0::2] = \ + scale_ratio_i * gt_bboxes_i[:, 0::2] + padw + gt_bboxes_i[:, 1::2] = \ + scale_ratio_i * gt_bboxes_i[:, 1::2] + padh + + mosaic_bboxes.append(gt_bboxes_i) + mosaic_labels.append(gt_labels_i) + + if len(mosaic_labels) > 0: + mosaic_bboxes = np.concatenate(mosaic_bboxes, 0) + mosaic_labels = np.concatenate(mosaic_labels, 0) + + if self.bbox_clip_border: + mosaic_bboxes[:, 0::2] = np.clip(mosaic_bboxes[:, 0::2], 0, + 2 * self.img_scale[1]) + mosaic_bboxes[:, 1::2] = np.clip(mosaic_bboxes[:, 1::2], 0, + 2 * self.img_scale[0]) + + if not self.skip_filter: + mosaic_bboxes, mosaic_labels = \ + self._filter_box_candidates(mosaic_bboxes, mosaic_labels) + + # remove outside bboxes + inside_inds = find_inside_bboxes(mosaic_bboxes, 2 * self.img_scale[0], + 2 * self.img_scale[1]) + mosaic_bboxes = mosaic_bboxes[inside_inds] + mosaic_labels = mosaic_labels[inside_inds] + + results['img'] = mosaic_img + results['img_shape'] = mosaic_img.shape + results['gt_bboxes'] = mosaic_bboxes + results['gt_labels'] = mosaic_labels + + return results + + def _mosaic_combine(self, loc, center_position_xy, img_shape_wh): + """Calculate global coordinate of mosaic image and local coordinate of + cropped sub-image. + + Args: + loc (str): Index for the sub-image, loc in ('top_left', + 'top_right', 'bottom_left', 'bottom_right'). + center_position_xy (Sequence[float]): Mixing center for 4 images, + (x, y). + img_shape_wh (Sequence[int]): Width and height of sub-image + + Returns: + tuple[tuple[float]]: Corresponding coordinate of pasting and + cropping + - paste_coord (tuple): paste corner coordinate in mosaic image. + - crop_coord (tuple): crop corner coordinate in mosaic image. + """ + assert loc in ('top_left', 'top_right', 'bottom_left', 'bottom_right') + if loc == 'top_left': + # index0 to top left part of image + x1, y1, x2, y2 = max(center_position_xy[0] - img_shape_wh[0], 0), \ + max(center_position_xy[1] - img_shape_wh[1], 0), \ + center_position_xy[0], \ + center_position_xy[1] + crop_coord = img_shape_wh[0] - (x2 - x1), img_shape_wh[1] - ( + y2 - y1), img_shape_wh[0], img_shape_wh[1] + + elif loc == 'top_right': + # index1 to top right part of image + x1, y1, x2, y2 = center_position_xy[0], \ + max(center_position_xy[1] - img_shape_wh[1], 0), \ + min(center_position_xy[0] + img_shape_wh[0], + self.img_scale[1] * 2), \ + center_position_xy[1] + crop_coord = 0, img_shape_wh[1] - (y2 - y1), min( + img_shape_wh[0], x2 - x1), img_shape_wh[1] + + elif loc == 'bottom_left': + # index2 to bottom left part of image + x1, y1, x2, y2 = max(center_position_xy[0] - img_shape_wh[0], 0), \ + center_position_xy[1], \ + center_position_xy[0], \ + min(self.img_scale[0] * 2, center_position_xy[1] + + img_shape_wh[1]) + crop_coord = img_shape_wh[0] - (x2 - x1), 0, img_shape_wh[0], min( + y2 - y1, img_shape_wh[1]) + + else: + # index3 to bottom right part of image + x1, y1, x2, y2 = center_position_xy[0], \ + center_position_xy[1], \ + min(center_position_xy[0] + img_shape_wh[0], + self.img_scale[1] * 2), \ + min(self.img_scale[0] * 2, center_position_xy[1] + + img_shape_wh[1]) + crop_coord = 0, 0, min(img_shape_wh[0], + x2 - x1), min(y2 - y1, img_shape_wh[1]) + + paste_coord = x1, y1, x2, y2 + return paste_coord, crop_coord + + def _filter_box_candidates(self, bboxes, labels): + """Filter out bboxes too small after Mosaic.""" + bbox_w = bboxes[:, 2] - bboxes[:, 0] + bbox_h = bboxes[:, 3] - bboxes[:, 1] + valid_inds = (bbox_w > self.min_bbox_size) & \ + (bbox_h > self.min_bbox_size) + valid_inds = np.nonzero(valid_inds)[0] + return bboxes[valid_inds], labels[valid_inds] + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += f'img_scale={self.img_scale}, ' + repr_str += f'center_ratio_range={self.center_ratio_range}, ' + repr_str += f'pad_val={self.pad_val}, ' + repr_str += f'min_bbox_size={self.min_bbox_size}, ' + repr_str += f'skip_filter={self.skip_filter})' + return repr_str + + +@PIPELINES.register_module() +class MixUp: + """MixUp data augmentation. + + .. code:: text + + mixup transform + +------------------------------+ + | mixup image | | + | +--------|--------+ | + | | | | | + |---------------+ | | + | | | | + | | image | | + | | | | + | | | | + | |-----------------+ | + | pad | + +------------------------------+ + + The mixup transform steps are as follows: + + 1. Another random image is picked by dataset and embedded in + the top left patch(after padding and resizing) + 2. The target of mixup transform is the weighted average of mixup + image and origin image. + + Args: + img_scale (Sequence[int]): Image output size after mixup pipeline. + The shape order should be (height, width). Default: (640, 640). + ratio_range (Sequence[float]): Scale ratio of mixup image. + Default: (0.5, 1.5). + flip_ratio (float): Horizontal flip ratio of mixup image. + Default: 0.5. + pad_val (int): Pad value. Default: 114. + max_iters (int): The maximum number of iterations. If the number of + iterations is greater than `max_iters`, but gt_bbox is still + empty, then the iteration is terminated. Default: 15. + min_bbox_size (float): Width and height threshold to filter bboxes. + If the height or width of a box is smaller than this value, it + will be removed. Default: 5. + min_area_ratio (float): Threshold of area ratio between + original bboxes and wrapped bboxes. If smaller than this value, + the box will be removed. Default: 0.2. + max_aspect_ratio (float): Aspect ratio of width and height + threshold to filter bboxes. If max(h/w, w/h) larger than this + value, the box will be removed. Default: 20. + bbox_clip_border (bool, optional): Whether to clip the objects outside + the border of the image. In some dataset like MOT17, the gt bboxes + are allowed to cross the border of images. Therefore, we don't + need to clip the gt bboxes in these cases. Defaults to True. + skip_filter (bool): Whether to skip filtering rules. If it + is True, the filter rule will not be applied, and the + `min_bbox_size` and `min_area_ratio` and `max_aspect_ratio` + is invalid. Default to True. + """ + + def __init__(self, + img_scale=(640, 640), + ratio_range=(0.5, 1.5), + flip_ratio=0.5, + pad_val=114, + max_iters=15, + min_bbox_size=5, + min_area_ratio=0.2, + max_aspect_ratio=20, + bbox_clip_border=True, + skip_filter=True): + assert isinstance(img_scale, tuple) + log_img_scale(img_scale, skip_square=True) + self.dynamic_scale = img_scale + self.ratio_range = ratio_range + self.flip_ratio = flip_ratio + self.pad_val = pad_val + self.max_iters = max_iters + self.min_bbox_size = min_bbox_size + self.min_area_ratio = min_area_ratio + self.max_aspect_ratio = max_aspect_ratio + self.bbox_clip_border = bbox_clip_border + self.skip_filter = skip_filter + + def __call__(self, results): + """Call function to make a mixup of image. + + Args: + results (dict): Result dict. + + Returns: + dict: Result dict with mixup transformed. + """ + + results = self._mixup_transform(results) + return results + + def get_indexes(self, dataset): + """Call function to collect indexes. + + Args: + dataset (:obj:`MultiImageMixDataset`): The dataset. + + Returns: + list: indexes. + """ + + for i in range(self.max_iters): + index = random.randint(0, len(dataset)) + gt_bboxes_i = dataset.get_ann_info(index)['bboxes'] + if len(gt_bboxes_i) != 0: + break + + return index + + def _mixup_transform(self, results): + """MixUp transform function. + + Args: + results (dict): Result dict. + + Returns: + dict: Updated result dict. + """ + + assert 'mix_results' in results + assert len( + results['mix_results']) == 1, 'MixUp only support 2 images now !' + + if results['mix_results'][0]['gt_bboxes'].shape[0] == 0: + # empty bbox + return results + + retrieve_results = results['mix_results'][0] + retrieve_img = retrieve_results['img'] + + jit_factor = random.uniform(*self.ratio_range) + is_filp = random.uniform(0, 1) > self.flip_ratio + + if len(retrieve_img.shape) == 3: + out_img = np.ones( + (self.dynamic_scale[0], self.dynamic_scale[1], 3), + dtype=retrieve_img.dtype) * self.pad_val + else: + out_img = np.ones( + self.dynamic_scale, dtype=retrieve_img.dtype) * self.pad_val + + # 1. keep_ratio resize + scale_ratio = min(self.dynamic_scale[0] / retrieve_img.shape[0], + self.dynamic_scale[1] / retrieve_img.shape[1]) + retrieve_img = mmcv.imresize( + retrieve_img, (int(retrieve_img.shape[1] * scale_ratio), + int(retrieve_img.shape[0] * scale_ratio))) + + # 2. paste + out_img[:retrieve_img.shape[0], :retrieve_img.shape[1]] = retrieve_img + + # 3. scale jit + scale_ratio *= jit_factor + out_img = mmcv.imresize(out_img, (int(out_img.shape[1] * jit_factor), + int(out_img.shape[0] * jit_factor))) + + # 4. flip + if is_filp: + out_img = out_img[:, ::-1, :] + + # 5. random crop + ori_img = results['img'] + origin_h, origin_w = out_img.shape[:2] + target_h, target_w = ori_img.shape[:2] + padded_img = np.zeros( + (max(origin_h, target_h), max(origin_w, + target_w), 3)).astype(np.uint8) + padded_img[:origin_h, :origin_w] = out_img + + x_offset, y_offset = 0, 0 + if padded_img.shape[0] > target_h: + y_offset = random.randint(0, padded_img.shape[0] - target_h) + if padded_img.shape[1] > target_w: + x_offset = random.randint(0, padded_img.shape[1] - target_w) + padded_cropped_img = padded_img[y_offset:y_offset + target_h, + x_offset:x_offset + target_w] + + # 6. adjust bbox + retrieve_gt_bboxes = retrieve_results['gt_bboxes'] + retrieve_gt_bboxes[:, 0::2] = retrieve_gt_bboxes[:, 0::2] * scale_ratio + retrieve_gt_bboxes[:, 1::2] = retrieve_gt_bboxes[:, 1::2] * scale_ratio + if self.bbox_clip_border: + retrieve_gt_bboxes[:, 0::2] = np.clip(retrieve_gt_bboxes[:, 0::2], + 0, origin_w) + retrieve_gt_bboxes[:, 1::2] = np.clip(retrieve_gt_bboxes[:, 1::2], + 0, origin_h) + + if is_filp: + retrieve_gt_bboxes[:, 0::2] = ( + origin_w - retrieve_gt_bboxes[:, 0::2][:, ::-1]) + + # 7. filter + cp_retrieve_gt_bboxes = retrieve_gt_bboxes.copy() + cp_retrieve_gt_bboxes[:, 0::2] = \ + cp_retrieve_gt_bboxes[:, 0::2] - x_offset + cp_retrieve_gt_bboxes[:, 1::2] = \ + cp_retrieve_gt_bboxes[:, 1::2] - y_offset + if self.bbox_clip_border: + cp_retrieve_gt_bboxes[:, 0::2] = np.clip( + cp_retrieve_gt_bboxes[:, 0::2], 0, target_w) + cp_retrieve_gt_bboxes[:, 1::2] = np.clip( + cp_retrieve_gt_bboxes[:, 1::2], 0, target_h) + + # 8. mix up + ori_img = ori_img.astype(np.float32) + mixup_img = 0.5 * ori_img + 0.5 * padded_cropped_img.astype(np.float32) + + retrieve_gt_labels = retrieve_results['gt_labels'] + if not self.skip_filter: + keep_list = self._filter_box_candidates(retrieve_gt_bboxes.T, + cp_retrieve_gt_bboxes.T) + + retrieve_gt_labels = retrieve_gt_labels[keep_list] + cp_retrieve_gt_bboxes = cp_retrieve_gt_bboxes[keep_list] + + mixup_gt_bboxes = np.concatenate( + (results['gt_bboxes'], cp_retrieve_gt_bboxes), axis=0) + mixup_gt_labels = np.concatenate( + (results['gt_labels'], retrieve_gt_labels), axis=0) + + # remove outside bbox + inside_inds = find_inside_bboxes(mixup_gt_bboxes, target_h, target_w) + mixup_gt_bboxes = mixup_gt_bboxes[inside_inds] + mixup_gt_labels = mixup_gt_labels[inside_inds] + + results['img'] = mixup_img.astype(np.uint8) + results['img_shape'] = mixup_img.shape + results['gt_bboxes'] = mixup_gt_bboxes + results['gt_labels'] = mixup_gt_labels + + return results + + def _filter_box_candidates(self, bbox1, bbox2): + """Compute candidate boxes which include following 5 things: + + bbox1 before augment, bbox2 after augment, min_bbox_size (pixels), + min_area_ratio, max_aspect_ratio. + """ + + w1, h1 = bbox1[2] - bbox1[0], bbox1[3] - bbox1[1] + w2, h2 = bbox2[2] - bbox2[0], bbox2[3] - bbox2[1] + ar = np.maximum(w2 / (h2 + 1e-16), h2 / (w2 + 1e-16)) + return ((w2 > self.min_bbox_size) + & (h2 > self.min_bbox_size) + & (w2 * h2 / (w1 * h1 + 1e-16) > self.min_area_ratio) + & (ar < self.max_aspect_ratio)) + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += f'dynamic_scale={self.dynamic_scale}, ' + repr_str += f'ratio_range={self.ratio_range}, ' + repr_str += f'flip_ratio={self.flip_ratio}, ' + repr_str += f'pad_val={self.pad_val}, ' + repr_str += f'max_iters={self.max_iters}, ' + repr_str += f'min_bbox_size={self.min_bbox_size}, ' + repr_str += f'min_area_ratio={self.min_area_ratio}, ' + repr_str += f'max_aspect_ratio={self.max_aspect_ratio}, ' + repr_str += f'skip_filter={self.skip_filter})' + return repr_str + + +@PIPELINES.register_module() +class RandomAffine: + """Random affine transform data augmentation. + + This operation randomly generates affine transform matrix which including + rotation, translation, shear and scaling transforms. + + Args: + max_rotate_degree (float): Maximum degrees of rotation transform. + Default: 10. + max_translate_ratio (float): Maximum ratio of translation. + Default: 0.1. + scaling_ratio_range (tuple[float]): Min and max ratio of + scaling transform. Default: (0.5, 1.5). + max_shear_degree (float): Maximum degrees of shear + transform. Default: 2. + border (tuple[int]): Distance from height and width sides of input + image to adjust output shape. Only used in mosaic dataset. + Default: (0, 0). + border_val (tuple[int]): Border padding values of 3 channels. + Default: (114, 114, 114). + min_bbox_size (float): Width and height threshold to filter bboxes. + If the height or width of a box is smaller than this value, it + will be removed. Default: 2. + min_area_ratio (float): Threshold of area ratio between + original bboxes and wrapped bboxes. If smaller than this value, + the box will be removed. Default: 0.2. + max_aspect_ratio (float): Aspect ratio of width and height + threshold to filter bboxes. If max(h/w, w/h) larger than this + value, the box will be removed. + bbox_clip_border (bool, optional): Whether to clip the objects outside + the border of the image. In some dataset like MOT17, the gt bboxes + are allowed to cross the border of images. Therefore, we don't + need to clip the gt bboxes in these cases. Defaults to True. + skip_filter (bool): Whether to skip filtering rules. If it + is True, the filter rule will not be applied, and the + `min_bbox_size` and `min_area_ratio` and `max_aspect_ratio` + is invalid. Default to True. + """ + + def __init__(self, + max_rotate_degree=10.0, + max_translate_ratio=0.1, + scaling_ratio_range=(0.5, 1.5), + max_shear_degree=2.0, + border=(0, 0), + border_val=(114, 114, 114), + min_bbox_size=2, + min_area_ratio=0.2, + max_aspect_ratio=20, + bbox_clip_border=True, + skip_filter=True): + assert 0 <= max_translate_ratio <= 1 + assert scaling_ratio_range[0] <= scaling_ratio_range[1] + assert scaling_ratio_range[0] > 0 + self.max_rotate_degree = max_rotate_degree + self.max_translate_ratio = max_translate_ratio + self.scaling_ratio_range = scaling_ratio_range + self.max_shear_degree = max_shear_degree + self.border = border + self.border_val = border_val + self.min_bbox_size = min_bbox_size + self.min_area_ratio = min_area_ratio + self.max_aspect_ratio = max_aspect_ratio + self.bbox_clip_border = bbox_clip_border + self.skip_filter = skip_filter + + def __call__(self, results): + img = results['img'] + height = img.shape[0] + self.border[0] * 2 + width = img.shape[1] + self.border[1] * 2 + + # Rotation + rotation_degree = random.uniform(-self.max_rotate_degree, + self.max_rotate_degree) + rotation_matrix = self._get_rotation_matrix(rotation_degree) + + # Scaling + scaling_ratio = random.uniform(self.scaling_ratio_range[0], + self.scaling_ratio_range[1]) + scaling_matrix = self._get_scaling_matrix(scaling_ratio) + + # Shear + x_degree = random.uniform(-self.max_shear_degree, + self.max_shear_degree) + y_degree = random.uniform(-self.max_shear_degree, + self.max_shear_degree) + shear_matrix = self._get_shear_matrix(x_degree, y_degree) + + # Translation + trans_x = random.uniform(-self.max_translate_ratio, + self.max_translate_ratio) * width + trans_y = random.uniform(-self.max_translate_ratio, + self.max_translate_ratio) * height + translate_matrix = self._get_translation_matrix(trans_x, trans_y) + + warp_matrix = ( + translate_matrix @ shear_matrix @ rotation_matrix @ scaling_matrix) + + img = cv2.warpPerspective( + img, + warp_matrix, + dsize=(width, height), + borderValue=self.border_val) + results['img'] = img + results['img_shape'] = img.shape + + for key in results.get('bbox_fields', []): + bboxes = results[key] + num_bboxes = len(bboxes) + if num_bboxes: + # homogeneous coordinates + xs = bboxes[:, [0, 0, 2, 2]].reshape(num_bboxes * 4) + ys = bboxes[:, [1, 3, 3, 1]].reshape(num_bboxes * 4) + ones = np.ones_like(xs) + points = np.vstack([xs, ys, ones]) + + warp_points = warp_matrix @ points + warp_points = warp_points[:2] / warp_points[2] + xs = warp_points[0].reshape(num_bboxes, 4) + ys = warp_points[1].reshape(num_bboxes, 4) + + warp_bboxes = np.vstack( + (xs.min(1), ys.min(1), xs.max(1), ys.max(1))).T + + if self.bbox_clip_border: + warp_bboxes[:, [0, 2]] = \ + warp_bboxes[:, [0, 2]].clip(0, width) + warp_bboxes[:, [1, 3]] = \ + warp_bboxes[:, [1, 3]].clip(0, height) + + # remove outside bbox + valid_index = find_inside_bboxes(warp_bboxes, height, width) + if not self.skip_filter: + # filter bboxes + filter_index = self.filter_gt_bboxes( + bboxes * scaling_ratio, warp_bboxes) + valid_index = valid_index & filter_index + + results[key] = warp_bboxes[valid_index] + if key in ['gt_bboxes']: + if 'gt_labels' in results: + results['gt_labels'] = results['gt_labels'][ + valid_index] + + if 'gt_masks' in results: + raise NotImplementedError( + 'RandomAffine only supports bbox.') + return results + + def filter_gt_bboxes(self, origin_bboxes, wrapped_bboxes): + origin_w = origin_bboxes[:, 2] - origin_bboxes[:, 0] + origin_h = origin_bboxes[:, 3] - origin_bboxes[:, 1] + wrapped_w = wrapped_bboxes[:, 2] - wrapped_bboxes[:, 0] + wrapped_h = wrapped_bboxes[:, 3] - wrapped_bboxes[:, 1] + aspect_ratio = np.maximum(wrapped_w / (wrapped_h + 1e-16), + wrapped_h / (wrapped_w + 1e-16)) + + wh_valid_idx = (wrapped_w > self.min_bbox_size) & \ + (wrapped_h > self.min_bbox_size) + area_valid_idx = wrapped_w * wrapped_h / (origin_w * origin_h + + 1e-16) > self.min_area_ratio + aspect_ratio_valid_idx = aspect_ratio < self.max_aspect_ratio + return wh_valid_idx & area_valid_idx & aspect_ratio_valid_idx + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += f'(max_rotate_degree={self.max_rotate_degree}, ' + repr_str += f'max_translate_ratio={self.max_translate_ratio}, ' + repr_str += f'scaling_ratio={self.scaling_ratio_range}, ' + repr_str += f'max_shear_degree={self.max_shear_degree}, ' + repr_str += f'border={self.border}, ' + repr_str += f'border_val={self.border_val}, ' + repr_str += f'min_bbox_size={self.min_bbox_size}, ' + repr_str += f'min_area_ratio={self.min_area_ratio}, ' + repr_str += f'max_aspect_ratio={self.max_aspect_ratio}, ' + repr_str += f'skip_filter={self.skip_filter})' + return repr_str + + @staticmethod + def _get_rotation_matrix(rotate_degrees): + radian = math.radians(rotate_degrees) + rotation_matrix = np.array( + [[np.cos(radian), -np.sin(radian), 0.], + [np.sin(radian), np.cos(radian), 0.], [0., 0., 1.]], + dtype=np.float32) + return rotation_matrix + + @staticmethod + def _get_scaling_matrix(scale_ratio): + scaling_matrix = np.array( + [[scale_ratio, 0., 0.], [0., scale_ratio, 0.], [0., 0., 1.]], + dtype=np.float32) + return scaling_matrix + + @staticmethod + def _get_share_matrix(scale_ratio): + scaling_matrix = np.array( + [[scale_ratio, 0., 0.], [0., scale_ratio, 0.], [0., 0., 1.]], + dtype=np.float32) + return scaling_matrix + + @staticmethod + def _get_shear_matrix(x_shear_degrees, y_shear_degrees): + x_radian = math.radians(x_shear_degrees) + y_radian = math.radians(y_shear_degrees) + shear_matrix = np.array([[1, np.tan(x_radian), 0.], + [np.tan(y_radian), 1, 0.], [0., 0., 1.]], + dtype=np.float32) + return shear_matrix + + @staticmethod + def _get_translation_matrix(x, y): + translation_matrix = np.array([[1, 0., x], [0., 1, y], [0., 0., 1.]], + dtype=np.float32) + return translation_matrix + + +@PIPELINES.register_module() +class YOLOXHSVRandomAug: + """Apply HSV augmentation to image sequentially. It is referenced from + https://github.com/Megvii- + BaseDetection/YOLOX/blob/main/yolox/data/data_augment.py#L21. + + Args: + hue_delta (int): delta of hue. Default: 5. + saturation_delta (int): delta of saturation. Default: 30. + value_delta (int): delat of value. Default: 30. + """ + + def __init__(self, hue_delta=5, saturation_delta=30, value_delta=30): + self.hue_delta = hue_delta + self.saturation_delta = saturation_delta + self.value_delta = value_delta + + def __call__(self, results): + img = results['img'] + hsv_gains = np.random.uniform(-1, 1, 3) * [ + self.hue_delta, self.saturation_delta, self.value_delta + ] + # random selection of h, s, v + hsv_gains *= np.random.randint(0, 2, 3) + # prevent overflow + hsv_gains = hsv_gains.astype(np.int16) + img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV).astype(np.int16) + + img_hsv[..., 0] = (img_hsv[..., 0] + hsv_gains[0]) % 180 + img_hsv[..., 1] = np.clip(img_hsv[..., 1] + hsv_gains[1], 0, 255) + img_hsv[..., 2] = np.clip(img_hsv[..., 2] + hsv_gains[2], 0, 255) + cv2.cvtColor(img_hsv.astype(img.dtype), cv2.COLOR_HSV2BGR, dst=img) + + results['img'] = img + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += f'(hue_delta={self.hue_delta}, ' + repr_str += f'saturation_delta={self.saturation_delta}, ' + repr_str += f'value_delta={self.value_delta})' + return repr_str + + +@PIPELINES.register_module() +class CopyPaste: + """Simple Copy-Paste is a Strong Data Augmentation Method for Instance + Segmentation The simple copy-paste transform steps are as follows: + + 1. The destination image is already resized with aspect ratio kept, + cropped and padded. + 2. Randomly select a source image, which is also already resized + with aspect ratio kept, cropped and padded in a similar way + as the destination image. + 3. Randomly select some objects from the source image. + 4. Paste these source objects to the destination image directly, + due to the source and destination image have the same size. + 5. Update object masks of the destination image, for some origin objects + may be occluded. + 6. Generate bboxes from the updated destination masks and + filter some objects which are totally occluded, and adjust bboxes + which are partly occluded. + 7. Append selected source bboxes, masks, and labels. + + Args: + max_num_pasted (int): The maximum number of pasted objects. + Default: 100. + bbox_occluded_thr (int): The threshold of occluded bbox. + Default: 10. + mask_occluded_thr (int): The threshold of occluded mask. + Default: 300. + selected (bool): Whether select objects or not. If select is False, + all objects of the source image will be pasted to the + destination image. + Default: True. + """ + + def __init__( + self, + max_num_pasted=100, + bbox_occluded_thr=10, + mask_occluded_thr=300, + selected=True, + ): + self.max_num_pasted = max_num_pasted + self.bbox_occluded_thr = bbox_occluded_thr + self.mask_occluded_thr = mask_occluded_thr + self.selected = selected + + def get_indexes(self, dataset): + """Call function to collect indexes.s. + + Args: + dataset (:obj:`MultiImageMixDataset`): The dataset. + Returns: + list: Indexes. + """ + return random.randint(0, len(dataset)) + + def __call__(self, results): + """Call function to make a copy-paste of image. + + Args: + results (dict): Result dict. + Returns: + dict: Result dict with copy-paste transformed. + """ + + assert 'mix_results' in results + num_images = len(results['mix_results']) + assert num_images == 1, \ + f'CopyPaste only supports processing 2 images, got {num_images}' + if self.selected: + selected_results = self._select_object(results['mix_results'][0]) + else: + selected_results = results['mix_results'][0] + return self._copy_paste(results, selected_results) + + def _select_object(self, results): + """Select some objects from the source results.""" + bboxes = results['gt_bboxes'] + labels = results['gt_labels'] + masks = results['gt_masks'] + max_num_pasted = min(bboxes.shape[0] + 1, self.max_num_pasted) + num_pasted = np.random.randint(0, max_num_pasted) + selected_inds = np.random.choice( + bboxes.shape[0], size=num_pasted, replace=False) + + selected_bboxes = bboxes[selected_inds] + selected_labels = labels[selected_inds] + selected_masks = masks[selected_inds] + + results['gt_bboxes'] = selected_bboxes + results['gt_labels'] = selected_labels + results['gt_masks'] = selected_masks + return results + + def _copy_paste(self, dst_results, src_results): + """CopyPaste transform function. + + Args: + dst_results (dict): Result dict of the destination image. + src_results (dict): Result dict of the source image. + Returns: + dict: Updated result dict. + """ + dst_img = dst_results['img'] + dst_bboxes = dst_results['gt_bboxes'] + dst_labels = dst_results['gt_labels'] + dst_masks = dst_results['gt_masks'] + + src_img = src_results['img'] + src_bboxes = src_results['gt_bboxes'] + src_labels = src_results['gt_labels'] + src_masks = src_results['gt_masks'] + + if len(src_bboxes) == 0: + return dst_results + + # update masks and generate bboxes from updated masks + composed_mask = np.where(np.any(src_masks.masks, axis=0), 1, 0) + updated_dst_masks = self.get_updated_masks(dst_masks, composed_mask) + updated_dst_bboxes = updated_dst_masks.get_bboxes() + assert len(updated_dst_bboxes) == len(updated_dst_masks) + + # filter totally occluded objects + bboxes_inds = np.all( + np.abs( + (updated_dst_bboxes - dst_bboxes)) <= self.bbox_occluded_thr, + axis=-1) + masks_inds = updated_dst_masks.masks.sum( + axis=(1, 2)) > self.mask_occluded_thr + valid_inds = bboxes_inds | masks_inds + + # Paste source objects to destination image directly + img = dst_img * (1 - composed_mask[..., np.newaxis] + ) + src_img * composed_mask[..., np.newaxis] + bboxes = np.concatenate([updated_dst_bboxes[valid_inds], src_bboxes]) + labels = np.concatenate([dst_labels[valid_inds], src_labels]) + masks = np.concatenate( + [updated_dst_masks.masks[valid_inds], src_masks.masks]) + + dst_results['img'] = img + dst_results['gt_bboxes'] = bboxes + dst_results['gt_labels'] = labels + dst_results['gt_masks'] = BitmapMasks(masks, masks.shape[1], + masks.shape[2]) + + return dst_results + + def get_updated_masks(self, masks, composed_mask): + assert masks.masks.shape[-2:] == composed_mask.shape[-2:], \ + 'Cannot compare two arrays of different size' + masks.masks = np.where(composed_mask, 0, masks.masks) + return masks + def __repr__(self): repr_str = self.__class__.__name__ - repr_str += '(transformations={})'.format(self.transformations) + repr_str += f'max_num_pasted={self.max_num_pasted}, ' + repr_str += f'bbox_occluded_thr={self.bbox_occluded_thr}, ' + repr_str += f'mask_occluded_thr={self.mask_occluded_thr}, ' + repr_str += f'selected={self.selected}, ' return repr_str diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/registry.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/registry.py deleted file mode 100644 index 974a4fbb7..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/registry.py +++ /dev/null @@ -1,4 +0,0 @@ -from mmdet.utils import Registry - -DATASETS = Registry('dataset') -PIPELINES = Registry('pipeline') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/__init__.py new file mode 100644 index 000000000..a4c7ea135 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/__init__.py @@ -0,0 +1,10 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from .class_aware_sampler import ClassAwareSampler +from .distributed_sampler import DistributedSampler +from .group_sampler import DistributedGroupSampler, GroupSampler +from .infinite_sampler import InfiniteBatchSampler, InfiniteGroupBatchSampler + +__all__ = [ + 'DistributedSampler', 'DistributedGroupSampler', 'GroupSampler', + 'InfiniteGroupBatchSampler', 'InfiniteBatchSampler', 'ClassAwareSampler' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/class_aware_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/class_aware_sampler.py new file mode 100644 index 000000000..c52708eb8 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/class_aware_sampler.py @@ -0,0 +1,176 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import math + +import torch +from mmcv.runner import get_dist_info +from torch.utils.data import Sampler + +from mmdet.core.utils import sync_random_seed + + +class ClassAwareSampler(Sampler): + r"""Sampler that restricts data loading to the label of the dataset. + + A class-aware sampling strategy to effectively tackle the + non-uniform class distribution. The length of the training data is + consistent with source data. Simple improvements based on `Relay + Backpropagation for Effective Learning of Deep Convolutional + Neural Networks `_ + + The implementation logic is referred to + https://github.com/Sense-X/TSD/blob/master/mmdet/datasets/samplers/distributed_classaware_sampler.py + + Args: + dataset: Dataset used for sampling. + samples_per_gpu (int): When model is :obj:`DistributedDataParallel`, + it is the number of training samples on each GPU. + When model is :obj:`DataParallel`, it is + `num_gpus * samples_per_gpu`. + Default : 1. + num_replicas (optional): Number of processes participating in + distributed training. + rank (optional): Rank of the current process within num_replicas. + seed (int, optional): random seed used to shuffle the sampler if + ``shuffle=True``. This number should be identical across all + processes in the distributed group. Default: 0. + num_sample_class (int): The number of samples taken from each + per-label list. Default: 1 + """ + + def __init__(self, + dataset, + samples_per_gpu=1, + num_replicas=None, + rank=None, + seed=0, + num_sample_class=1): + _rank, _num_replicas = get_dist_info() + if num_replicas is None: + num_replicas = _num_replicas + if rank is None: + rank = _rank + + self.dataset = dataset + self.num_replicas = num_replicas + self.samples_per_gpu = samples_per_gpu + self.rank = rank + self.epoch = 0 + # Must be the same across all workers. If None, will use a + # random seed shared among workers + # (require synchronization among all workers) + self.seed = sync_random_seed(seed) + + # The number of samples taken from each per-label list + assert num_sample_class > 0 and isinstance(num_sample_class, int) + self.num_sample_class = num_sample_class + # Get per-label image list from dataset + assert hasattr(dataset, 'get_cat2imgs'), \ + 'dataset must have `get_cat2imgs` function' + self.cat_dict = dataset.get_cat2imgs() + + self.num_samples = int( + math.ceil( + len(self.dataset) * 1.0 / self.num_replicas / + self.samples_per_gpu)) * self.samples_per_gpu + self.total_size = self.num_samples * self.num_replicas + + # get number of images containing each category + self.num_cat_imgs = [len(x) for x in self.cat_dict.values()] + # filter labels without images + self.valid_cat_inds = [ + i for i, length in enumerate(self.num_cat_imgs) if length != 0 + ] + self.num_classes = len(self.valid_cat_inds) + + def __iter__(self): + # deterministically shuffle based on epoch + g = torch.Generator() + g.manual_seed(self.epoch + self.seed) + + # initialize label list + label_iter_list = RandomCycleIter(self.valid_cat_inds, generator=g) + # initialize each per-label image list + data_iter_dict = dict() + for i in self.valid_cat_inds: + data_iter_dict[i] = RandomCycleIter(self.cat_dict[i], generator=g) + + def gen_cat_img_inds(cls_list, data_dict, num_sample_cls): + """Traverse the categories and extract `num_sample_cls` image + indexes of the corresponding categories one by one.""" + id_indices = [] + for _ in range(len(cls_list)): + cls_idx = next(cls_list) + for _ in range(num_sample_cls): + id = next(data_dict[cls_idx]) + id_indices.append(id) + return id_indices + + # deterministically shuffle based on epoch + num_bins = int( + math.ceil(self.total_size * 1.0 / self.num_classes / + self.num_sample_class)) + indices = [] + for i in range(num_bins): + indices += gen_cat_img_inds(label_iter_list, data_iter_dict, + self.num_sample_class) + + # fix extra samples to make it evenly divisible + if len(indices) >= self.total_size: + indices = indices[:self.total_size] + else: + indices += indices[:(self.total_size - len(indices))] + assert len(indices) == self.total_size + + # subsample + offset = self.num_samples * self.rank + indices = indices[offset:offset + self.num_samples] + assert len(indices) == self.num_samples + + return iter(indices) + + def __len__(self): + return self.num_samples + + def set_epoch(self, epoch): + self.epoch = epoch + + +class RandomCycleIter: + """Shuffle the list and do it again after the list have traversed. + + The implementation logic is referred to + https://github.com/wutong16/DistributionBalancedLoss/blob/master/mllt/datasets/loader/sampler.py + + Example: + >>> label_list = [0, 1, 2, 4, 5] + >>> g = torch.Generator() + >>> g.manual_seed(0) + >>> label_iter_list = RandomCycleIter(label_list, generator=g) + >>> index = next(label_iter_list) + Args: + data (list or ndarray): The data that needs to be shuffled. + generator: An torch.Generator object, which is used in setting the seed + for generating random numbers. + """ # noqa: W605 + + def __init__(self, data, generator=None): + self.data = data + self.length = len(data) + self.index = torch.randperm(self.length, generator=generator).numpy() + self.i = 0 + self.generator = generator + + def __iter__(self): + return self + + def __len__(self): + return len(self.data) + + def __next__(self): + if self.i == self.length: + self.index = torch.randperm( + self.length, generator=self.generator).numpy() + self.i = 0 + idx = self.data[self.index[self.i]] + self.i += 1 + return idx diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/distributed_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/distributed_sampler.py new file mode 100644 index 000000000..1bc8b7c36 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/distributed_sampler.py @@ -0,0 +1,54 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import math + +import torch +from torch.utils.data import DistributedSampler as _DistributedSampler + +from mmdet.core.utils import sync_random_seed +from mmdet.utils import get_device + + +class DistributedSampler(_DistributedSampler): + + def __init__(self, + dataset, + num_replicas=None, + rank=None, + shuffle=True, + seed=0): + super().__init__( + dataset, num_replicas=num_replicas, rank=rank, shuffle=shuffle) + + # In distributed sampling, different ranks should sample + # non-overlapped data in the dataset. Therefore, this function + # is used to make sure that each rank shuffles the data indices + # in the same order based on the same seed. Then different ranks + # could use different indices to select non-overlapped data from the + # same data list. + device = get_device() + self.seed = sync_random_seed(seed, device) + + def __iter__(self): + # deterministically shuffle based on epoch + if self.shuffle: + g = torch.Generator() + # When :attr:`shuffle=True`, this ensures all replicas + # use a different random ordering for each epoch. + # Otherwise, the next iteration of this sampler will + # yield the same ordering. + g.manual_seed(self.epoch + self.seed) + indices = torch.randperm(len(self.dataset), generator=g).tolist() + else: + indices = torch.arange(len(self.dataset)).tolist() + + # add extra samples to make it evenly divisible + # in case that indices is shorter than half of total_size + indices = (indices * + math.ceil(self.total_size / len(indices)))[:self.total_size] + assert len(indices) == self.total_size + + # subsample + indices = indices[self.rank:self.total_size:self.num_replicas] + assert len(indices) == self.num_samples + + return iter(indices) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/group_sampler.py similarity index 79% rename from cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/sampler.py rename to cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/group_sampler.py index f3dd99620..783d2b21c 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/loader/sampler.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/group_sampler.py @@ -1,39 +1,12 @@ -from __future__ import division +# Copyright (c) OpenMMLab. All rights reserved. import math import numpy as np import torch from mmcv.runner import get_dist_info -from torch.utils.data import DistributedSampler as _DistributedSampler from torch.utils.data import Sampler -class DistributedSampler(_DistributedSampler): - - def __init__(self, dataset, num_replicas=None, rank=None, shuffle=True): - super().__init__(dataset, num_replicas=num_replicas, rank=rank) - self.shuffle = shuffle - - def __iter__(self): - # deterministically shuffle based on epoch - if self.shuffle: - g = torch.Generator() - g.manual_seed(self.epoch) - indices = torch.randperm(len(self.dataset), generator=g).tolist() - else: - indices = torch.arange(len(self.dataset)).tolist() - - # add extra samples to make it evenly divisible - indices += indices[:(self.total_size - len(indices))] - assert len(indices) == self.total_size - - # subsample - indices = indices[self.rank:self.total_size:self.num_replicas] - assert len(indices) == self.num_samples - - return iter(indices) - - class GroupSampler(Sampler): def __init__(self, dataset, samples_per_gpu=1): @@ -77,24 +50,31 @@ class GroupSampler(Sampler): class DistributedGroupSampler(Sampler): """Sampler that restricts data loading to a subset of the dataset. + It is especially useful in conjunction with :class:`torch.nn.parallel.DistributedDataParallel`. In such case, each process can pass a DistributedSampler instance as a DataLoader sampler, and load a subset of the original dataset that is exclusive to it. + .. note:: Dataset is assumed to be of constant size. + Arguments: dataset: Dataset used for sampling. num_replicas (optional): Number of processes participating in distributed training. rank (optional): Rank of the current process within num_replicas. + seed (int, optional): random seed used to shuffle the sampler if + ``shuffle=True``. This number should be identical across all + processes in the distributed group. Default: 0. """ def __init__(self, dataset, samples_per_gpu=1, num_replicas=None, - rank=None): + rank=None, + seed=0): _rank, _num_replicas = get_dist_info() if num_replicas is None: num_replicas = _num_replicas @@ -105,6 +85,7 @@ class DistributedGroupSampler(Sampler): self.num_replicas = num_replicas self.rank = rank self.epoch = 0 + self.seed = seed if seed is not None else 0 assert hasattr(self.dataset, 'flag') self.flag = self.dataset.flag @@ -120,15 +101,18 @@ class DistributedGroupSampler(Sampler): def __iter__(self): # deterministically shuffle based on epoch g = torch.Generator() - g.manual_seed(self.epoch) + g.manual_seed(self.epoch + self.seed) indices = [] for i, size in enumerate(self.group_sizes): if size > 0: indice = np.where(self.flag == i)[0] assert len(indice) == size - indice = indice[list(torch.randperm(int(size), - generator=g))].tolist() + # add .numpy() to avoid bug when selecting indice in parrots. + # TODO: check whether torch.randperm() can be replaced by + # numpy.random.permutation(). + indice = indice[list( + torch.randperm(int(size), generator=g).numpy())].tolist() extra = int( math.ceil( size * 1.0 / self.samples_per_gpu / self.num_replicas) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/infinite_sampler.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/infinite_sampler.py new file mode 100644 index 000000000..d42487e6a --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/samplers/infinite_sampler.py @@ -0,0 +1,186 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import itertools + +import numpy as np +import torch +from mmcv.runner import get_dist_info +from torch.utils.data.sampler import Sampler + +from mmdet.core.utils import sync_random_seed + + +class InfiniteGroupBatchSampler(Sampler): + """Similar to `BatchSampler` warping a `GroupSampler. It is designed for + iteration-based runners like `IterBasedRunner` and yields a mini-batch + indices each time, all indices in a batch should be in the same group. + + The implementation logic is referred to + https://github.com/facebookresearch/detectron2/blob/main/detectron2/data/samplers/grouped_batch_sampler.py + + Args: + dataset (object): The dataset. + batch_size (int): When model is :obj:`DistributedDataParallel`, + it is the number of training samples on each GPU. + When model is :obj:`DataParallel`, it is + `num_gpus * samples_per_gpu`. + Default : 1. + world_size (int, optional): Number of processes participating in + distributed training. Default: None. + rank (int, optional): Rank of current process. Default: None. + seed (int): Random seed. Default: 0. + shuffle (bool): Whether shuffle the indices of a dummy `epoch`, it + should be noted that `shuffle` can not guarantee that you can + generate sequential indices because it need to ensure + that all indices in a batch is in a group. Default: True. + """ # noqa: W605 + + def __init__(self, + dataset, + batch_size=1, + world_size=None, + rank=None, + seed=0, + shuffle=True): + _rank, _world_size = get_dist_info() + if world_size is None: + world_size = _world_size + if rank is None: + rank = _rank + self.rank = rank + self.world_size = world_size + self.dataset = dataset + self.batch_size = batch_size + # In distributed sampling, different ranks should sample + # non-overlapped data in the dataset. Therefore, this function + # is used to make sure that each rank shuffles the data indices + # in the same order based on the same seed. Then different ranks + # could use different indices to select non-overlapped data from the + # same data list. + self.seed = sync_random_seed(seed) + self.shuffle = shuffle + + assert hasattr(self.dataset, 'flag') + self.flag = self.dataset.flag + self.group_sizes = np.bincount(self.flag) + # buffer used to save indices of each group + self.buffer_per_group = {k: [] for k in range(len(self.group_sizes))} + + self.size = len(dataset) + self.indices = self._indices_of_rank() + + def _infinite_indices(self): + """Infinitely yield a sequence of indices.""" + g = torch.Generator() + g.manual_seed(self.seed) + while True: + if self.shuffle: + yield from torch.randperm(self.size, generator=g).tolist() + + else: + yield from torch.arange(self.size).tolist() + + def _indices_of_rank(self): + """Slice the infinite indices by rank.""" + yield from itertools.islice(self._infinite_indices(), self.rank, None, + self.world_size) + + def __iter__(self): + # once batch size is reached, yield the indices + for idx in self.indices: + flag = self.flag[idx] + group_buffer = self.buffer_per_group[flag] + group_buffer.append(idx) + if len(group_buffer) == self.batch_size: + yield group_buffer[:] + del group_buffer[:] + + def __len__(self): + """Length of base dataset.""" + return self.size + + def set_epoch(self, epoch): + """Not supported in `IterationBased` runner.""" + raise NotImplementedError + + +class InfiniteBatchSampler(Sampler): + """Similar to `BatchSampler` warping a `DistributedSampler. It is designed + iteration-based runners like `IterBasedRunner` and yields a mini-batch + indices each time. + + The implementation logic is referred to + https://github.com/facebookresearch/detectron2/blob/main/detectron2/data/samplers/grouped_batch_sampler.py + + Args: + dataset (object): The dataset. + batch_size (int): When model is :obj:`DistributedDataParallel`, + it is the number of training samples on each GPU, + When model is :obj:`DataParallel`, it is + `num_gpus * samples_per_gpu`. + Default : 1. + world_size (int, optional): Number of processes participating in + distributed training. Default: None. + rank (int, optional): Rank of current process. Default: None. + seed (int): Random seed. Default: 0. + shuffle (bool): Whether shuffle the dataset or not. Default: True. + """ # noqa: W605 + + def __init__(self, + dataset, + batch_size=1, + world_size=None, + rank=None, + seed=0, + shuffle=True): + _rank, _world_size = get_dist_info() + if world_size is None: + world_size = _world_size + if rank is None: + rank = _rank + self.rank = rank + self.world_size = world_size + self.dataset = dataset + self.batch_size = batch_size + # In distributed sampling, different ranks should sample + # non-overlapped data in the dataset. Therefore, this function + # is used to make sure that each rank shuffles the data indices + # in the same order based on the same seed. Then different ranks + # could use different indices to select non-overlapped data from the + # same data list. + self.seed = sync_random_seed(seed) + self.shuffle = shuffle + self.size = len(dataset) + self.indices = self._indices_of_rank() + + def _infinite_indices(self): + """Infinitely yield a sequence of indices.""" + g = torch.Generator() + g.manual_seed(self.seed) + while True: + if self.shuffle: + yield from torch.randperm(self.size, generator=g).tolist() + + else: + yield from torch.arange(self.size).tolist() + + def _indices_of_rank(self): + """Slice the infinite indices by rank.""" + yield from itertools.islice(self._infinite_indices(), self.rank, None, + self.world_size) + + def __iter__(self): + # once batch size is reached, yield the indices + batch_buffer = [] + for idx in self.indices: + batch_buffer.append(idx) + if len(batch_buffer) == self.batch_size: + yield batch_buffer + batch_buffer = [] + + def __len__(self): + """Length of base dataset.""" + return self.size + + def set_epoch(self, epoch): + """Not supported in `IterationBased` runner.""" + raise NotImplementedError diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/utils.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/utils.py new file mode 100644 index 000000000..be911b57c --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/utils.py @@ -0,0 +1,164 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import copy +import warnings + +from mmcv.cnn import VGG +from mmcv.runner.hooks import HOOKS, Hook + +from mmdet.datasets.builder import PIPELINES +from mmdet.datasets.pipelines import (LoadAnnotations, LoadImageFromFile, + LoadPanopticAnnotations) + + +def replace_ImageToTensor(pipelines): + """Replace the ImageToTensor transform in a data pipeline to + DefaultFormatBundle, which is normally useful in batch inference. + + Args: + pipelines (list[dict]): Data pipeline configs. + + Returns: + list: The new pipeline list with all ImageToTensor replaced by + DefaultFormatBundle. + + Examples: + >>> pipelines = [ + ... dict(type='LoadImageFromFile'), + ... dict( + ... type='MultiScaleFlipAug', + ... img_scale=(1333, 800), + ... flip=False, + ... transforms=[ + ... dict(type='Resize', keep_ratio=True), + ... dict(type='RandomFlip'), + ... dict(type='Normalize', mean=[0, 0, 0], std=[1, 1, 1]), + ... dict(type='Pad', size_divisor=32), + ... dict(type='ImageToTensor', keys=['img']), + ... dict(type='Collect', keys=['img']), + ... ]) + ... ] + >>> expected_pipelines = [ + ... dict(type='LoadImageFromFile'), + ... dict( + ... type='MultiScaleFlipAug', + ... img_scale=(1333, 800), + ... flip=False, + ... transforms=[ + ... dict(type='Resize', keep_ratio=True), + ... dict(type='RandomFlip'), + ... dict(type='Normalize', mean=[0, 0, 0], std=[1, 1, 1]), + ... dict(type='Pad', size_divisor=32), + ... dict(type='DefaultFormatBundle'), + ... dict(type='Collect', keys=['img']), + ... ]) + ... ] + >>> assert expected_pipelines == replace_ImageToTensor(pipelines) + """ + pipelines = copy.deepcopy(pipelines) + for i, pipeline in enumerate(pipelines): + if pipeline['type'] == 'MultiScaleFlipAug': + assert 'transforms' in pipeline + pipeline['transforms'] = replace_ImageToTensor( + pipeline['transforms']) + elif pipeline['type'] == 'ImageToTensor': + warnings.warn( + '"ImageToTensor" pipeline is replaced by ' + '"DefaultFormatBundle" for batch inference. It is ' + 'recommended to manually replace it in the test ' + 'data pipeline in your config file.', UserWarning) + pipelines[i] = {'type': 'DefaultFormatBundle'} + return pipelines + + +def get_loading_pipeline(pipeline): + """Only keep loading image and annotations related configuration. + + Args: + pipeline (list[dict]): Data pipeline configs. + + Returns: + list[dict]: The new pipeline list with only keep + loading image and annotations related configuration. + + Examples: + >>> pipelines = [ + ... dict(type='LoadImageFromFile'), + ... dict(type='LoadAnnotations', with_bbox=True), + ... dict(type='Resize', img_scale=(1333, 800), keep_ratio=True), + ... dict(type='RandomFlip', flip_ratio=0.5), + ... dict(type='Normalize', **img_norm_cfg), + ... dict(type='Pad', size_divisor=32), + ... dict(type='DefaultFormatBundle'), + ... dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']) + ... ] + >>> expected_pipelines = [ + ... dict(type='LoadImageFromFile'), + ... dict(type='LoadAnnotations', with_bbox=True) + ... ] + >>> assert expected_pipelines ==\ + ... get_loading_pipeline(pipelines) + """ + loading_pipeline_cfg = [] + for cfg in pipeline: + obj_cls = PIPELINES.get(cfg['type']) + # TODO:use more elegant way to distinguish loading modules + if obj_cls is not None and obj_cls in (LoadImageFromFile, + LoadAnnotations, + LoadPanopticAnnotations): + loading_pipeline_cfg.append(cfg) + assert len(loading_pipeline_cfg) == 2, \ + 'The data pipeline in your config file must include ' \ + 'loading image and annotations related pipeline.' + return loading_pipeline_cfg + + +@HOOKS.register_module() +class NumClassCheckHook(Hook): + + def _check_head(self, runner): + """Check whether the `num_classes` in head matches the length of + `CLASSES` in `dataset`. + + Args: + runner (obj:`EpochBasedRunner`): Epoch based Runner. + """ + model = runner.model + dataset = runner.data_loader.dataset + if dataset.CLASSES is None: + runner.logger.warning( + f'Please set `CLASSES` ' + f'in the {dataset.__class__.__name__} and' + f'check if it is consistent with the `num_classes` ' + f'of head') + else: + assert type(dataset.CLASSES) is not str, \ + (f'`CLASSES` in {dataset.__class__.__name__}' + f'should be a tuple of str.' + f'Add comma if number of classes is 1 as ' + f'CLASSES = ({dataset.CLASSES},)') + for name, module in model.named_modules(): + if hasattr(module, 'num_classes') and not isinstance( + module, VGG): + assert module.num_classes == len(dataset.CLASSES), \ + (f'The `num_classes` ({module.num_classes}) in ' + f'{module.__class__.__name__} of ' + f'{model.__class__.__name__} does not matches ' + f'the length of `CLASSES` ' + f'{len(dataset.CLASSES)}) in ' + f'{dataset.__class__.__name__}') + + def before_train_epoch(self, runner): + """Check whether the training dataset is compatible with head. + + Args: + runner (obj:`EpochBasedRunner`): Epoch based Runner. + """ + self._check_head(runner) + + def before_val_epoch(self, runner): + """Check whether the dataset in val epoch is compatible with head. + + Args: + runner (obj:`EpochBasedRunner`): Epoch based Runner. + """ + self._check_head(runner) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/voc.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/voc.py deleted file mode 100644 index 77bffe355..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/voc.py +++ /dev/null @@ -1,20 +0,0 @@ -from .registry import DATASETS -from .xml_style import XMLDataset - - -@DATASETS.register_module -class VOCDataset(XMLDataset): - - CLASSES = ('aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', - 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', - 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', - 'tvmonitor') - - def __init__(self, **kwargs): - super(VOCDataset, self).__init__(**kwargs) - if 'VOC2007' in self.img_prefix: - self.year = 2007 - elif 'VOC2012' in self.img_prefix: - self.year = 2012 - else: - raise ValueError('Cannot infer dataset year from img_prefix') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/wider_face.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/wider_face.py deleted file mode 100644 index b83e3d664..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/wider_face.py +++ /dev/null @@ -1,42 +0,0 @@ -import os.path as osp -import xml.etree.ElementTree as ET - -import mmcv - -from .registry import DATASETS -from .xml_style import XMLDataset - - -@DATASETS.register_module -class WIDERFaceDataset(XMLDataset): - """ - Reader for the WIDER Face dataset in PASCAL VOC format. - Conversion scripts can be found in - https://github.com/sovrasov/wider-face-pascal-voc-annotations - """ - CLASSES = ('face', ) - - def __init__(self, **kwargs): - super(WIDERFaceDataset, self).__init__(**kwargs) - - def load_annotations(self, ann_file): - img_infos = [] - img_ids = mmcv.list_from_file(ann_file) - for img_id in img_ids: - filename = '{}.jpg'.format(img_id) - xml_path = osp.join(self.img_prefix, 'Annotations', - '{}.xml'.format(img_id)) - tree = ET.parse(xml_path) - root = tree.getroot() - size = root.find('size') - width = int(size.find('width').text) - height = int(size.find('height').text) - folder = root.find('folder').text - img_infos.append( - dict( - id=img_id, - filename=osp.join(folder, filename), - width=width, - height=height)) - - return img_infos diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/xml_style.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/xml_style.py deleted file mode 100644 index 39d57042e..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/datasets/xml_style.py +++ /dev/null @@ -1,86 +0,0 @@ -import os.path as osp -import xml.etree.ElementTree as ET - -import mmcv -import numpy as np - -from .custom import CustomDataset -from .registry import DATASETS - - -@DATASETS.register_module -class XMLDataset(CustomDataset): - - def __init__(self, min_size=None, **kwargs): - super(XMLDataset, self).__init__(**kwargs) - self.cat2label = {cat: i + 1 for i, cat in enumerate(self.CLASSES)} - self.min_size = min_size - - def load_annotations(self, ann_file): - img_infos = [] - img_ids = mmcv.list_from_file(ann_file) - for img_id in img_ids: - filename = 'JPEGImages/{}.jpg'.format(img_id) - xml_path = osp.join(self.img_prefix, 'Annotations', - '{}.xml'.format(img_id)) - tree = ET.parse(xml_path) - root = tree.getroot() - size = root.find('size') - width = int(size.find('width').text) - height = int(size.find('height').text) - img_infos.append( - dict(id=img_id, filename=filename, width=width, height=height)) - return img_infos - - def get_ann_info(self, idx): - img_id = self.img_infos[idx]['id'] - xml_path = osp.join(self.img_prefix, 'Annotations', - '{}.xml'.format(img_id)) - tree = ET.parse(xml_path) - root = tree.getroot() - bboxes = [] - labels = [] - bboxes_ignore = [] - labels_ignore = [] - for obj in root.findall('object'): - name = obj.find('name').text - label = self.cat2label[name] - difficult = int(obj.find('difficult').text) - bnd_box = obj.find('bndbox') - bbox = [ - int(bnd_box.find('xmin').text), - int(bnd_box.find('ymin').text), - int(bnd_box.find('xmax').text), - int(bnd_box.find('ymax').text) - ] - ignore = False - if self.min_size: - assert not self.test_mode - w = bbox[2] - bbox[0] - h = bbox[3] - bbox[1] - if w < self.min_size or h < self.min_size: - ignore = True - if difficult or ignore: - bboxes_ignore.append(bbox) - labels_ignore.append(label) - else: - bboxes.append(bbox) - labels.append(label) - if not bboxes: - bboxes = np.zeros((0, 4)) - labels = np.zeros((0, )) - else: - bboxes = np.array(bboxes, ndmin=2) - 1 - labels = np.array(labels) - if not bboxes_ignore: - bboxes_ignore = np.zeros((0, 4)) - labels_ignore = np.zeros((0, )) - else: - bboxes_ignore = np.array(bboxes_ignore, ndmin=2) - 1 - labels_ignore = np.array(labels_ignore) - ann = dict( - bboxes=bboxes.astype(np.float32), - labels=labels.astype(np.int64), - bboxes_ignore=bboxes_ignore.astype(np.float32), - labels_ignore=labels_ignore.astype(np.int64)) - return ann diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/__init__.py index 35f0a09e3..eb114dde7 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/__init__.py @@ -1,16 +1,13 @@ -from .anchor_heads import * # noqa: F401,F403 +# Copyright (c) OpenMMLab. All rights reserved. from .backbones import * # noqa: F401,F403 -from .bbox_heads import * # noqa: F401,F403 -from .builder import (build_backbone, build_detector, build_head, build_loss, - build_neck, build_roi_extractor, build_shared_head) +from .builder import (BACKBONES, DETECTORS, HEADS, LOSSES, NECKS, + ROI_EXTRACTORS, SHARED_HEADS, build_backbone, + build_detector, build_head, build_loss, build_neck, + build_roi_extractor, build_shared_head) +from .dense_heads import * # noqa: F401,F403 from .detectors import * # noqa: F401,F403 from .losses import * # noqa: F401,F403 -from .mask_heads import * # noqa: F401,F403 from .necks import * # noqa: F401,F403 -from .registry import (BACKBONES, DETECTORS, HEADS, LOSSES, NECKS, - ROI_EXTRACTORS, SHARED_HEADS) -from .roi_extractors import * # noqa: F401,F403 -from .shared_heads import * # noqa: F401,F403 __all__ = [ 'BACKBONES', 'NECKS', 'ROI_EXTRACTORS', 'SHARED_HEADS', 'HEADS', 'LOSSES', diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/__init__.py deleted file mode 100644 index de1d7ef01..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -from .anchor_head import AnchorHead -from .atss_head import ATSSHead -from .fcos_head import FCOSHead -from .fovea_head import FoveaHead -from .free_anchor_retina_head import FreeAnchorRetinaHead -from .ga_retina_head import GARetinaHead -from .ga_rpn_head import GARPNHead -from .guided_anchor_head import FeatureAdaption, GuidedAnchorHead -from .reppoints_head import RepPointsHead -from .retina_head import RetinaHead -from .retina_sepbn_head import RetinaSepBNHead -from .rpn_head import RPNHead -from .ssd_head import SSDHead -from .solo_head import SOLOHead -from .solov2_head import SOLOv2Head -from .solov2_light_head import SOLOv2LightHead -from .decoupled_solo_head import DecoupledSOLOHead -from .decoupled_solo_light_head import DecoupledSOLOLightHead - -__all__ = [ - 'AnchorHead', 'GuidedAnchorHead', 'FeatureAdaption', 'RPNHead', - 'GARPNHead', 'RetinaHead', 'RetinaSepBNHead', 'GARetinaHead', 'SSDHead', - 'FCOSHead', 'RepPointsHead', 'FoveaHead', 'FreeAnchorRetinaHead', - 'ATSSHead', 'SOLOHead', 'SOLOv2Head', 'SOLOv2LightHead', 'DecoupledSOLOHead', 'DecoupledSOLOLightHead' -] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/anchor_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/anchor_head.py deleted file mode 100644 index 0fdc0aade..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/anchor_head.py +++ /dev/null @@ -1,330 +0,0 @@ -from __future__ import division - -import numpy as np -import torch -import torch.nn as nn -from mmcv.cnn import normal_init - -from mmdet.core import (AnchorGenerator, anchor_target, delta2bbox, force_fp32, - multi_apply, multiclass_nms) -from ..builder import build_loss -from ..registry import HEADS - - -@HEADS.register_module -class AnchorHead(nn.Module): - """Anchor-based head (RPN, RetinaNet, SSD, etc.). - - Args: - num_classes (int): Number of categories including the background - category. - in_channels (int): Number of channels in the input feature map. - feat_channels (int): Number of hidden channels. Used in child classes. - anchor_scales (Iterable): Anchor scales. - anchor_ratios (Iterable): Anchor aspect ratios. - anchor_strides (Iterable): Anchor strides. - anchor_base_sizes (Iterable): Anchor base sizes. - target_means (Iterable): Mean values of regression targets. - target_stds (Iterable): Std values of regression targets. - loss_cls (dict): Config of classification loss. - loss_bbox (dict): Config of localization loss. - """ # noqa: W605 - - def __init__(self, - num_classes, - in_channels, - feat_channels=256, - anchor_scales=[8, 16, 32], - anchor_ratios=[0.5, 1.0, 2.0], - anchor_strides=[4, 8, 16, 32, 64], - anchor_base_sizes=None, - target_means=(.0, .0, .0, .0), - target_stds=(1.0, 1.0, 1.0, 1.0), - loss_cls=dict( - type='CrossEntropyLoss', - use_sigmoid=True, - loss_weight=1.0), - loss_bbox=dict( - type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0)): - super(AnchorHead, self).__init__() - self.in_channels = in_channels - self.num_classes = num_classes - self.feat_channels = feat_channels - self.anchor_scales = anchor_scales - self.anchor_ratios = anchor_ratios - self.anchor_strides = anchor_strides - self.anchor_base_sizes = list( - anchor_strides) if anchor_base_sizes is None else anchor_base_sizes - self.target_means = target_means - self.target_stds = target_stds - - self.use_sigmoid_cls = loss_cls.get('use_sigmoid', False) - self.sampling = loss_cls['type'] not in ['FocalLoss', 'GHMC'] - if self.use_sigmoid_cls: - self.cls_out_channels = num_classes - 1 - else: - self.cls_out_channels = num_classes - - if self.cls_out_channels <= 0: - raise ValueError('num_classes={} is too small'.format(num_classes)) - - self.loss_cls = build_loss(loss_cls) - self.loss_bbox = build_loss(loss_bbox) - self.fp16_enabled = False - - self.anchor_generators = [] - for anchor_base in self.anchor_base_sizes: - self.anchor_generators.append( - AnchorGenerator(anchor_base, anchor_scales, anchor_ratios)) - - self.num_anchors = len(self.anchor_ratios) * len(self.anchor_scales) - self._init_layers() - - def _init_layers(self): - self.conv_cls = nn.Conv2d(self.in_channels, - self.num_anchors * self.cls_out_channels, 1) - self.conv_reg = nn.Conv2d(self.in_channels, self.num_anchors * 4, 1) - - def init_weights(self): - normal_init(self.conv_cls, std=0.01) - normal_init(self.conv_reg, std=0.01) - - def forward_single(self, x): - cls_score = self.conv_cls(x) - bbox_pred = self.conv_reg(x) - return cls_score, bbox_pred - - def forward(self, feats): - return multi_apply(self.forward_single, feats) - - def get_anchors(self, featmap_sizes, img_metas, device='cuda'): - """Get anchors according to feature map sizes. - - Args: - featmap_sizes (list[tuple]): Multi-level feature map sizes. - img_metas (list[dict]): Image meta info. - device (torch.device | str): device for returned tensors - - Returns: - tuple: anchors of each image, valid flags of each image - """ - num_imgs = len(img_metas) - num_levels = len(featmap_sizes) - - # since feature map sizes of all images are the same, we only compute - # anchors for one time - multi_level_anchors = [] - for i in range(num_levels): - anchors = self.anchor_generators[i].grid_anchors( - featmap_sizes[i], self.anchor_strides[i], device=device) - multi_level_anchors.append(anchors) - anchor_list = [multi_level_anchors for _ in range(num_imgs)] - - # for each image, we compute valid flags of multi level anchors - valid_flag_list = [] - for img_id, img_meta in enumerate(img_metas): - multi_level_flags = [] - for i in range(num_levels): - anchor_stride = self.anchor_strides[i] - feat_h, feat_w = featmap_sizes[i] - h, w = img_meta['pad_shape'][:2] - valid_feat_h = min(int(np.ceil(h / anchor_stride)), feat_h) - valid_feat_w = min(int(np.ceil(w / anchor_stride)), feat_w) - flags = self.anchor_generators[i].valid_flags( - (feat_h, feat_w), (valid_feat_h, valid_feat_w), - device=device) - multi_level_flags.append(flags) - valid_flag_list.append(multi_level_flags) - - return anchor_list, valid_flag_list - - def loss_single(self, cls_score, bbox_pred, labels, label_weights, - bbox_targets, bbox_weights, num_total_samples, cfg): - # classification loss - labels = labels.reshape(-1) - label_weights = label_weights.reshape(-1) - cls_score = cls_score.permute(0, 2, 3, - 1).reshape(-1, self.cls_out_channels) - loss_cls = self.loss_cls( - cls_score, labels, label_weights, avg_factor=num_total_samples) - # regression loss - bbox_targets = bbox_targets.reshape(-1, 4) - bbox_weights = bbox_weights.reshape(-1, 4) - bbox_pred = bbox_pred.permute(0, 2, 3, 1).reshape(-1, 4) - loss_bbox = self.loss_bbox( - bbox_pred, - bbox_targets, - bbox_weights, - avg_factor=num_total_samples) - return loss_cls, loss_bbox - - @force_fp32(apply_to=('cls_scores', 'bbox_preds')) - def loss(self, - cls_scores, - bbox_preds, - gt_bboxes, - gt_labels, - img_metas, - cfg, - gt_bboxes_ignore=None): - featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] - assert len(featmap_sizes) == len(self.anchor_generators) - - device = cls_scores[0].device - - anchor_list, valid_flag_list = self.get_anchors( - featmap_sizes, img_metas, device=device) - label_channels = self.cls_out_channels if self.use_sigmoid_cls else 1 - cls_reg_targets = anchor_target( - anchor_list, - valid_flag_list, - gt_bboxes, - img_metas, - self.target_means, - self.target_stds, - cfg, - gt_bboxes_ignore_list=gt_bboxes_ignore, - gt_labels_list=gt_labels, - label_channels=label_channels, - sampling=self.sampling) - if cls_reg_targets is None: - return None - (labels_list, label_weights_list, bbox_targets_list, bbox_weights_list, - num_total_pos, num_total_neg) = cls_reg_targets - num_total_samples = ( - num_total_pos + num_total_neg if self.sampling else num_total_pos) - losses_cls, losses_bbox = multi_apply( - self.loss_single, - cls_scores, - bbox_preds, - labels_list, - label_weights_list, - bbox_targets_list, - bbox_weights_list, - num_total_samples=num_total_samples, - cfg=cfg) - return dict(loss_cls=losses_cls, loss_bbox=losses_bbox) - - @force_fp32(apply_to=('cls_scores', 'bbox_preds')) - def get_bboxes(self, - cls_scores, - bbox_preds, - img_metas, - cfg, - rescale=False): - """ - Transform network output for a batch into labeled boxes. - - Args: - cls_scores (list[Tensor]): Box scores for each scale level - Has shape (N, num_anchors * num_classes, H, W) - bbox_preds (list[Tensor]): Box energies / deltas for each scale - level with shape (N, num_anchors * 4, H, W) - img_metas (list[dict]): size / scale info for each image - cfg (mmcv.Config): test / postprocessing configuration - rescale (bool): if True, return boxes in original image space - - Returns: - list[tuple[Tensor, Tensor]]: each item in result_list is 2-tuple. - The first item is an (n, 5) tensor, where the first 4 columns - are bounding box positions (tl_x, tl_y, br_x, br_y) and the - 5-th column is a score between 0 and 1. The second item is a - (n,) tensor where each item is the class index of the - corresponding box. - - Example: - >>> import mmcv - >>> self = AnchorHead(num_classes=9, in_channels=1) - >>> img_metas = [{'img_shape': (32, 32, 3), 'scale_factor': 1}] - >>> cfg = mmcv.Config(dict( - >>> score_thr=0.00, - >>> nms=dict(type='nms', iou_thr=1.0), - >>> max_per_img=10)) - >>> feat = torch.rand(1, 1, 3, 3) - >>> cls_score, bbox_pred = self.forward_single(feat) - >>> # note the input lists are over different levels, not images - >>> cls_scores, bbox_preds = [cls_score], [bbox_pred] - >>> result_list = self.get_bboxes(cls_scores, bbox_preds, - >>> img_metas, cfg) - >>> det_bboxes, det_labels = result_list[0] - >>> assert len(result_list) == 1 - >>> assert det_bboxes.shape[1] == 5 - >>> assert len(det_bboxes) == len(det_labels) == cfg.max_per_img - """ - assert len(cls_scores) == len(bbox_preds) - num_levels = len(cls_scores) - - device = cls_scores[0].device - mlvl_anchors = [ - self.anchor_generators[i].grid_anchors( - cls_scores[i].size()[-2:], - self.anchor_strides[i], - device=device) for i in range(num_levels) - ] - result_list = [] - for img_id in range(len(img_metas)): - cls_score_list = [ - cls_scores[i][img_id].detach() for i in range(num_levels) - ] - bbox_pred_list = [ - bbox_preds[i][img_id].detach() for i in range(num_levels) - ] - img_shape = img_metas[img_id]['img_shape'] - scale_factor = img_metas[img_id]['scale_factor'] - proposals = self.get_bboxes_single(cls_score_list, bbox_pred_list, - mlvl_anchors, img_shape, - scale_factor, cfg, rescale) - result_list.append(proposals) - return result_list - - def get_bboxes_single(self, - cls_score_list, - bbox_pred_list, - mlvl_anchors, - img_shape, - scale_factor, - cfg, - rescale=False): - """ - Transform outputs for a single batch item into labeled boxes. - """ - assert len(cls_score_list) == len(bbox_pred_list) == len(mlvl_anchors) - mlvl_bboxes = [] - mlvl_scores = [] - for cls_score, bbox_pred, anchors in zip(cls_score_list, - bbox_pred_list, mlvl_anchors): - assert cls_score.size()[-2:] == bbox_pred.size()[-2:] - cls_score = cls_score.permute(1, 2, - 0).reshape(-1, self.cls_out_channels) - if self.use_sigmoid_cls: - scores = cls_score.sigmoid() - else: - scores = cls_score.softmax(-1) - bbox_pred = bbox_pred.permute(1, 2, 0).reshape(-1, 4) - nms_pre = cfg.get('nms_pre', -1) - if nms_pre > 0 and scores.shape[0] > nms_pre: - # Get maximum scores for foreground classes. - if self.use_sigmoid_cls: - max_scores, _ = scores.max(dim=1) - else: - max_scores, _ = scores[:, 1:].max(dim=1) - _, topk_inds = max_scores.topk(nms_pre) - anchors = anchors[topk_inds, :] - bbox_pred = bbox_pred[topk_inds, :] - scores = scores[topk_inds, :] - bboxes = delta2bbox(anchors, bbox_pred, self.target_means, - self.target_stds, img_shape) - mlvl_bboxes.append(bboxes) - mlvl_scores.append(scores) - mlvl_bboxes = torch.cat(mlvl_bboxes) - if rescale: - mlvl_bboxes /= mlvl_bboxes.new_tensor(scale_factor) - mlvl_scores = torch.cat(mlvl_scores) - if self.use_sigmoid_cls: - # Add a dummy background class to the front when using sigmoid - padding = mlvl_scores.new_zeros(mlvl_scores.shape[0], 1) - mlvl_scores = torch.cat([padding, mlvl_scores], dim=1) - det_bboxes, det_labels = multiclass_nms(mlvl_bboxes, mlvl_scores, - cfg.score_thr, cfg.nms, - cfg.max_per_img) - return det_bboxes, det_labels diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/atss_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/atss_head.py deleted file mode 100644 index e0f2e0abc..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/atss_head.py +++ /dev/null @@ -1,487 +0,0 @@ -import numpy as np -import torch -import torch.distributed as dist -import torch.nn as nn -from mmcv.cnn import normal_init - -from mmdet.core import (PseudoSampler, anchor_inside_flags, bbox2delta, - build_assigner, delta2bbox, force_fp32, - images_to_levels, multi_apply, multiclass_nms, unmap) -from ..builder import build_loss -from ..registry import HEADS -from ..utils import ConvModule, Scale, bias_init_with_prob -from .anchor_head import AnchorHead - - -def reduce_mean(tensor): - if not (dist.is_available() and dist.is_initialized()): - return tensor - tensor = tensor.clone() - dist.all_reduce(tensor.div_(dist.get_world_size()), op=dist.reduce_op.SUM) - return tensor - - -@HEADS.register_module -class ATSSHead(AnchorHead): - """ - Bridging the Gap Between Anchor-based and Anchor-free Detection via - Adaptive Training Sample Selection - - ATSS head structure is similar with FCOS, however ATSS use anchor boxes - and assign label by Adaptive Training Sample Selection instead max-iou. - - https://arxiv.org/abs/1912.02424 - """ - - def __init__(self, - num_classes, - in_channels, - stacked_convs=4, - octave_base_scale=4, - scales_per_octave=1, - conv_cfg=None, - norm_cfg=dict(type='GN', num_groups=32, requires_grad=True), - loss_centerness=dict( - type='CrossEntropyLoss', - use_sigmoid=True, - loss_weight=1.0), - **kwargs): - self.stacked_convs = stacked_convs - self.octave_base_scale = octave_base_scale - self.scales_per_octave = scales_per_octave - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - - octave_scales = np.array( - [2**(i / scales_per_octave) for i in range(scales_per_octave)]) - anchor_scales = octave_scales * octave_base_scale - super(ATSSHead, self).__init__( - num_classes, in_channels, anchor_scales=anchor_scales, **kwargs) - - self.loss_centerness = build_loss(loss_centerness) - - def _init_layers(self): - self.relu = nn.ReLU(inplace=True) - self.cls_convs = nn.ModuleList() - self.reg_convs = nn.ModuleList() - for i in range(self.stacked_convs): - chn = self.in_channels if i == 0 else self.feat_channels - self.cls_convs.append( - ConvModule( - chn, - self.feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg)) - self.reg_convs.append( - ConvModule( - chn, - self.feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg)) - self.atss_cls = nn.Conv2d( - self.feat_channels, - self.num_anchors * self.cls_out_channels, - 3, - padding=1) - self.atss_reg = nn.Conv2d( - self.feat_channels, self.num_anchors * 4, 3, padding=1) - self.atss_centerness = nn.Conv2d( - self.feat_channels, self.num_anchors * 1, 3, padding=1) - self.scales = nn.ModuleList([Scale(1.0) for _ in self.anchor_strides]) - - def init_weights(self): - for m in self.cls_convs: - normal_init(m.conv, std=0.01) - for m in self.reg_convs: - normal_init(m.conv, std=0.01) - bias_cls = bias_init_with_prob(0.01) - normal_init(self.atss_cls, std=0.01, bias=bias_cls) - normal_init(self.atss_reg, std=0.01) - normal_init(self.atss_centerness, std=0.01) - - def forward(self, feats): - return multi_apply(self.forward_single, feats, self.scales) - - def forward_single(self, x, scale): - cls_feat = x - reg_feat = x - for cls_conv in self.cls_convs: - cls_feat = cls_conv(cls_feat) - for reg_conv in self.reg_convs: - reg_feat = reg_conv(reg_feat) - cls_score = self.atss_cls(cls_feat) - # we just follow atss, not apply exp in bbox_pred - bbox_pred = scale(self.atss_reg(reg_feat)).float() - centerness = self.atss_centerness(reg_feat) - return cls_score, bbox_pred, centerness - - def loss_single(self, anchors, cls_score, bbox_pred, centerness, labels, - label_weights, bbox_targets, num_total_samples, cfg): - - anchors = anchors.reshape(-1, 4) - cls_score = cls_score.permute(0, 2, 3, - 1).reshape(-1, self.cls_out_channels) - bbox_pred = bbox_pred.permute(0, 2, 3, 1).reshape(-1, 4) - centerness = centerness.permute(0, 2, 3, 1).reshape(-1) - bbox_targets = bbox_targets.reshape(-1, 4) - labels = labels.reshape(-1) - label_weights = label_weights.reshape(-1) - - # classification loss - loss_cls = self.loss_cls( - cls_score, labels, label_weights, avg_factor=num_total_samples) - - pos_inds = torch.nonzero(labels).squeeze(1) - - if len(pos_inds) > 0: - pos_bbox_targets = bbox_targets[pos_inds] - pos_bbox_pred = bbox_pred[pos_inds] - pos_anchors = anchors[pos_inds] - pos_centerness = centerness[pos_inds] - - centerness_targets = self.centerness_target( - pos_anchors, pos_bbox_targets) - pos_decode_bbox_pred = delta2bbox(pos_anchors, pos_bbox_pred, - self.target_means, - self.target_stds) - pos_decode_bbox_targets = delta2bbox(pos_anchors, pos_bbox_targets, - self.target_means, - self.target_stds) - - # regression loss - loss_bbox = self.loss_bbox( - pos_decode_bbox_pred, - pos_decode_bbox_targets, - weight=centerness_targets, - avg_factor=1.0) - - # centerness loss - loss_centerness = self.loss_centerness( - pos_centerness, - centerness_targets, - avg_factor=num_total_samples) - - else: - loss_bbox = loss_cls * 0 - loss_centerness = loss_bbox * 0 - centerness_targets = torch.tensor(0).cuda() - - return loss_cls, loss_bbox, loss_centerness, centerness_targets.sum() - - @force_fp32(apply_to=('cls_scores', 'bbox_preds', 'centernesses')) - def loss(self, - cls_scores, - bbox_preds, - centernesses, - gt_bboxes, - gt_labels, - img_metas, - cfg, - gt_bboxes_ignore=None): - - featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] - assert len(featmap_sizes) == len(self.anchor_generators) - - device = cls_scores[0].device - anchor_list, valid_flag_list = self.get_anchors( - featmap_sizes, img_metas, device=device) - label_channels = self.cls_out_channels if self.use_sigmoid_cls else 1 - - cls_reg_targets = self.atss_target( - anchor_list, - valid_flag_list, - gt_bboxes, - img_metas, - cfg, - gt_bboxes_ignore_list=gt_bboxes_ignore, - gt_labels_list=gt_labels, - label_channels=label_channels) - if cls_reg_targets is None: - return None - - (anchor_list, labels_list, label_weights_list, bbox_targets_list, - bbox_weights_list, num_total_pos, num_total_neg) = cls_reg_targets - - num_total_samples = reduce_mean( - torch.tensor(num_total_pos).cuda()).item() - num_total_samples = max(num_total_samples, 1.0) - - losses_cls, losses_bbox, loss_centerness,\ - bbox_avg_factor = multi_apply( - self.loss_single, - anchor_list, - cls_scores, - bbox_preds, - centernesses, - labels_list, - label_weights_list, - bbox_targets_list, - num_total_samples=num_total_samples, - cfg=cfg) - - bbox_avg_factor = sum(bbox_avg_factor) - bbox_avg_factor = reduce_mean(bbox_avg_factor).item() - losses_bbox = list(map(lambda x: x / bbox_avg_factor, losses_bbox)) - return dict( - loss_cls=losses_cls, - loss_bbox=losses_bbox, - loss_centerness=loss_centerness) - - def centerness_target(self, anchors, bbox_targets): - # only calculate pos centerness targets, otherwise there may be nan - gts = delta2bbox(anchors, bbox_targets, self.target_means, - self.target_stds) - anchors_cx = (anchors[:, 2] + anchors[:, 0]) / 2 - anchors_cy = (anchors[:, 3] + anchors[:, 1]) / 2 - l_ = anchors_cx - gts[:, 0] - t_ = anchors_cy - gts[:, 1] - r_ = gts[:, 2] - anchors_cx - b_ = gts[:, 3] - anchors_cy - - left_right = torch.stack([l_, r_], dim=1) - top_bottom = torch.stack([t_, b_], dim=1) - centerness = torch.sqrt( - (left_right.min(dim=-1)[0] / left_right.max(dim=-1)[0]) * - (top_bottom.min(dim=-1)[0] / top_bottom.max(dim=-1)[0])) - assert not torch.isnan(centerness).any() - return centerness - - @force_fp32(apply_to=('cls_scores', 'bbox_preds', 'centernesses')) - def get_bboxes(self, - cls_scores, - bbox_preds, - centernesses, - img_metas, - cfg, - rescale=False): - - assert len(cls_scores) == len(bbox_preds) - num_levels = len(cls_scores) - device = cls_scores[0].device - mlvl_anchors = [ - self.anchor_generators[i].grid_anchors( - cls_scores[i].size()[-2:], - self.anchor_strides[i], - device=device) for i in range(num_levels) - ] - - result_list = [] - for img_id in range(len(img_metas)): - cls_score_list = [ - cls_scores[i][img_id].detach() for i in range(num_levels) - ] - bbox_pred_list = [ - bbox_preds[i][img_id].detach() for i in range(num_levels) - ] - centerness_pred_list = [ - centernesses[i][img_id].detach() for i in range(num_levels) - ] - img_shape = img_metas[img_id]['img_shape'] - scale_factor = img_metas[img_id]['scale_factor'] - proposals = self.get_bboxes_single(cls_score_list, bbox_pred_list, - centerness_pred_list, - mlvl_anchors, img_shape, - scale_factor, cfg, rescale) - result_list.append(proposals) - return result_list - - def get_bboxes_single(self, - cls_scores, - bbox_preds, - centernesses, - mlvl_anchors, - img_shape, - scale_factor, - cfg, - rescale=False): - assert len(cls_scores) == len(bbox_preds) == len(mlvl_anchors) - mlvl_bboxes = [] - mlvl_scores = [] - mlvl_centerness = [] - for cls_score, bbox_pred, centerness, anchors in zip( - cls_scores, bbox_preds, centernesses, mlvl_anchors): - assert cls_score.size()[-2:] == bbox_pred.size()[-2:] - - scores = cls_score.permute(1, 2, 0).reshape( - -1, self.cls_out_channels).sigmoid() - bbox_pred = bbox_pred.permute(1, 2, 0).reshape(-1, 4) - centerness = centerness.permute(1, 2, 0).reshape(-1).sigmoid() - - nms_pre = cfg.get('nms_pre', -1) - if nms_pre > 0 and scores.shape[0] > nms_pre: - max_scores, _ = (scores * centerness[:, None]).max(dim=1) - _, topk_inds = max_scores.topk(nms_pre) - anchors = anchors[topk_inds, :] - bbox_pred = bbox_pred[topk_inds, :] - scores = scores[topk_inds, :] - centerness = centerness[topk_inds] - - bboxes = delta2bbox(anchors, bbox_pred, self.target_means, - self.target_stds, img_shape) - mlvl_bboxes.append(bboxes) - mlvl_scores.append(scores) - mlvl_centerness.append(centerness) - - mlvl_bboxes = torch.cat(mlvl_bboxes) - if rescale: - mlvl_bboxes /= mlvl_bboxes.new_tensor(scale_factor) - - mlvl_scores = torch.cat(mlvl_scores) - padding = mlvl_scores.new_zeros(mlvl_scores.shape[0], 1) - mlvl_scores = torch.cat([padding, mlvl_scores], dim=1) - mlvl_centerness = torch.cat(mlvl_centerness) - - det_bboxes, det_labels = multiclass_nms( - mlvl_bboxes, - mlvl_scores, - cfg.score_thr, - cfg.nms, - cfg.max_per_img, - score_factors=mlvl_centerness) - return det_bboxes, det_labels - - def atss_target(self, - anchor_list, - valid_flag_list, - gt_bboxes_list, - img_metas, - cfg, - gt_bboxes_ignore_list=None, - gt_labels_list=None, - label_channels=1, - unmap_outputs=True): - """ - almost the same with anchor_target, with a little modification, - here we need return the anchor - """ - num_imgs = len(img_metas) - assert len(anchor_list) == len(valid_flag_list) == num_imgs - - # anchor number of multi levels - num_level_anchors = [anchors.size(0) for anchors in anchor_list[0]] - num_level_anchors_list = [num_level_anchors] * num_imgs - - # concat all level anchors and flags to a single tensor - for i in range(num_imgs): - assert len(anchor_list[i]) == len(valid_flag_list[i]) - anchor_list[i] = torch.cat(anchor_list[i]) - valid_flag_list[i] = torch.cat(valid_flag_list[i]) - - # compute targets for each image - if gt_bboxes_ignore_list is None: - gt_bboxes_ignore_list = [None for _ in range(num_imgs)] - if gt_labels_list is None: - gt_labels_list = [None for _ in range(num_imgs)] - (all_anchors, all_labels, all_label_weights, all_bbox_targets, - all_bbox_weights, pos_inds_list, neg_inds_list) = multi_apply( - self.atss_target_single, - anchor_list, - valid_flag_list, - num_level_anchors_list, - gt_bboxes_list, - gt_bboxes_ignore_list, - gt_labels_list, - img_metas, - cfg=cfg, - label_channels=label_channels, - unmap_outputs=unmap_outputs) - # no valid anchors - if any([labels is None for labels in all_labels]): - return None - # sampled anchors of all images - num_total_pos = sum([max(inds.numel(), 1) for inds in pos_inds_list]) - num_total_neg = sum([max(inds.numel(), 1) for inds in neg_inds_list]) - # split targets to a list w.r.t. multiple levels - anchors_list = images_to_levels(all_anchors, num_level_anchors) - labels_list = images_to_levels(all_labels, num_level_anchors) - label_weights_list = images_to_levels(all_label_weights, - num_level_anchors) - bbox_targets_list = images_to_levels(all_bbox_targets, - num_level_anchors) - bbox_weights_list = images_to_levels(all_bbox_weights, - num_level_anchors) - return (anchors_list, labels_list, label_weights_list, - bbox_targets_list, bbox_weights_list, num_total_pos, - num_total_neg) - - def atss_target_single(self, - flat_anchors, - valid_flags, - num_level_anchors, - gt_bboxes, - gt_bboxes_ignore, - gt_labels, - img_meta, - cfg, - label_channels=1, - unmap_outputs=True): - inside_flags = anchor_inside_flags(flat_anchors, valid_flags, - img_meta['img_shape'][:2], - cfg.allowed_border) - if not inside_flags.any(): - return (None, ) * 6 - # assign gt and sample anchors - anchors = flat_anchors[inside_flags, :] - - num_level_anchors_inside = self.get_num_level_anchors_inside( - num_level_anchors, inside_flags) - bbox_assigner = build_assigner(cfg.assigner) - assign_result = bbox_assigner.assign(anchors, num_level_anchors_inside, - gt_bboxes, gt_bboxes_ignore, - gt_labels) - - bbox_sampler = PseudoSampler() - sampling_result = bbox_sampler.sample(assign_result, anchors, - gt_bboxes) - - num_valid_anchors = anchors.shape[0] - bbox_targets = torch.zeros_like(anchors) - bbox_weights = torch.zeros_like(anchors) - labels = anchors.new_zeros(num_valid_anchors, dtype=torch.long) - label_weights = anchors.new_zeros(num_valid_anchors, dtype=torch.float) - - pos_inds = sampling_result.pos_inds - neg_inds = sampling_result.neg_inds - if len(pos_inds) > 0: - pos_bbox_targets = bbox2delta(sampling_result.pos_bboxes, - sampling_result.pos_gt_bboxes, - self.target_means, self.target_stds) - bbox_targets[pos_inds, :] = pos_bbox_targets - bbox_weights[pos_inds, :] = 1.0 - if gt_labels is None: - labels[pos_inds] = 1 - else: - labels[pos_inds] = gt_labels[ - sampling_result.pos_assigned_gt_inds] - if cfg.pos_weight <= 0: - label_weights[pos_inds] = 1.0 - else: - label_weights[pos_inds] = cfg.pos_weight - if len(neg_inds) > 0: - label_weights[neg_inds] = 1.0 - - # map up to original set of anchors - if unmap_outputs: - num_total_anchors = flat_anchors.size(0) - anchors = unmap(anchors, num_total_anchors, inside_flags) - labels = unmap(labels, num_total_anchors, inside_flags) - label_weights = unmap(label_weights, num_total_anchors, - inside_flags) - bbox_targets = unmap(bbox_targets, num_total_anchors, inside_flags) - bbox_weights = unmap(bbox_weights, num_total_anchors, inside_flags) - - return (anchors, labels, label_weights, bbox_targets, bbox_weights, - pos_inds, neg_inds) - - def get_num_level_anchors_inside(self, num_level_anchors, inside_flags): - split_inside_flags = torch.split(inside_flags, num_level_anchors) - num_level_anchors_inside = [ - int(flags.sum()) for flags in split_inside_flags - ] - return num_level_anchors_inside diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/decoupled_solo_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/decoupled_solo_head.py deleted file mode 100644 index 1b6001142..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/decoupled_solo_head.py +++ /dev/null @@ -1,484 +0,0 @@ -import mmcv -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import normal_init -from mmdet.ops import DeformConv, roi_align -from mmdet.core import multi_apply, bbox2roi, matrix_nms -from ..builder import build_loss -from ..registry import HEADS -from ..utils import bias_init_with_prob, ConvModule - -INF = 1e8 - -def center_of_mass(bitmasks): - _, h, w = bitmasks.size() - ys = torch.arange(0, h, dtype=torch.float32, device=bitmasks.device) - xs = torch.arange(0, w, dtype=torch.float32, device=bitmasks.device) - - m00 = bitmasks.sum(dim=-1).sum(dim=-1).clamp(min=1e-6) - m10 = (bitmasks * xs).sum(dim=-1).sum(dim=-1) - m01 = (bitmasks * ys[:, None]).sum(dim=-1).sum(dim=-1) - center_x = m10 / m00 - center_y = m01 / m00 - return center_x, center_y - -def points_nms(heat, kernel=2): - # kernel must be 2 - hmax = nn.functional.max_pool2d( - heat, (kernel, kernel), stride=1, padding=1) - keep = (hmax[:, :, :-1, :-1] == heat).float() - return heat * keep - -def dice_loss(input, target): - input = input.contiguous().view(input.size()[0], -1) - target = target.contiguous().view(target.size()[0], -1).float() - - a = torch.sum(input * target, 1) - b = torch.sum(input * input, 1) + 0.001 - c = torch.sum(target * target, 1) + 0.001 - d = (2 * a) / (b + c) - return 1-d - -@HEADS.register_module -class DecoupledSOLOHead(nn.Module): - def __init__(self, - num_classes, - in_channels, - seg_feat_channels=256, - stacked_convs=4, - strides=(4, 8, 16, 32, 64), - base_edge_list=(16, 32, 64, 128, 256), - scale_ranges=((8, 32), (16, 64), (32, 128), (64, 256), (128, 512)), - sigma=0.4, - num_grids=None, - cate_down_pos=0, - with_deform=False, - loss_ins=None, - loss_cate=None, - conv_cfg=None, - norm_cfg=None): - super(DecoupledSOLOHead, self).__init__() - self.num_classes = num_classes - self.seg_num_grids = num_grids - self.cate_out_channels = self.num_classes - 1 - self.in_channels = in_channels - self.seg_feat_channels = seg_feat_channels - self.stacked_convs = stacked_convs - self.strides = strides - self.sigma = sigma - self.cate_down_pos = cate_down_pos - self.base_edge_list = base_edge_list - self.scale_ranges = scale_ranges - self.with_deform = with_deform - self.loss_cate = build_loss(loss_cate) - self.ins_loss_weight = loss_ins['loss_weight'] - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - self._init_layers() - - def _init_layers(self): - norm_cfg = dict(type='GN', num_groups=32, requires_grad=True) - self.ins_convs_x = nn.ModuleList() - self.ins_convs_y = nn.ModuleList() - self.cate_convs = nn.ModuleList() - - for i in range(self.stacked_convs): - chn = self.in_channels + 1 if i == 0 else self.seg_feat_channels - self.ins_convs_x.append( - ConvModule( - chn, - self.seg_feat_channels, - 3, - stride=1, - padding=1, - norm_cfg=norm_cfg, - bias=norm_cfg is None)) - self.ins_convs_y.append( - ConvModule( - chn, - self.seg_feat_channels, - 3, - stride=1, - padding=1, - norm_cfg=norm_cfg, - bias=norm_cfg is None)) - - chn = self.in_channels if i == 0 else self.seg_feat_channels - self.cate_convs.append( - ConvModule( - chn, - self.seg_feat_channels, - 3, - stride=1, - padding=1, - norm_cfg=norm_cfg, - bias=norm_cfg is None)) - - self.dsolo_ins_list_x = nn.ModuleList() - self.dsolo_ins_list_y = nn.ModuleList() - for seg_num_grid in self.seg_num_grids: - self.dsolo_ins_list_x.append( - nn.Conv2d( - self.seg_feat_channels, seg_num_grid, 3, padding=1)) - self.dsolo_ins_list_y.append( - nn.Conv2d( - self.seg_feat_channels, seg_num_grid, 3, padding=1)) - self.dsolo_cate = nn.Conv2d( - self.seg_feat_channels, self.cate_out_channels, 3, padding=1) - - def init_weights(self): - for m in self.ins_convs_x: - normal_init(m.conv, std=0.01) - for m in self.ins_convs_y: - normal_init(m.conv, std=0.01) - for m in self.cate_convs: - normal_init(m.conv, std=0.01) - bias_ins = bias_init_with_prob(0.01) - for m in self.dsolo_ins_list_x: - normal_init(m, std=0.01, bias=bias_ins) - for m in self.dsolo_ins_list_y: - normal_init(m, std=0.01, bias=bias_ins) - bias_cate = bias_init_with_prob(0.01) - normal_init(self.dsolo_cate, std=0.01, bias=bias_cate) - - def forward(self, feats, eval=False): - new_feats = self.split_feats(feats) - featmap_sizes = [featmap.size()[-2:] for featmap in new_feats] - upsampled_size = (featmap_sizes[0][0] * 2, featmap_sizes[0][1] * 2) - ins_pred_x, ins_pred_y, cate_pred = multi_apply(self.forward_single, new_feats, - list(range(len(self.seg_num_grids))), - eval=eval, upsampled_size=upsampled_size) - return ins_pred_x, ins_pred_y, cate_pred - - def split_feats(self, feats): - return (F.interpolate(feats[0], scale_factor=0.5, mode='bilinear'), - feats[1], - feats[2], - feats[3], - F.interpolate(feats[4], size=feats[3].shape[-2:], mode='bilinear')) - - def forward_single(self, x, idx, eval=False, upsampled_size=None): - ins_feat = x - cate_feat = x - # ins branch - # concat coord - x_range = torch.linspace(-1, 1, ins_feat.shape[-1], device=ins_feat.device) - y_range = torch.linspace(-1, 1, ins_feat.shape[-2], device=ins_feat.device) - y, x = torch.meshgrid(y_range, x_range) - y = y.expand([ins_feat.shape[0], 1, -1, -1]) - x = x.expand([ins_feat.shape[0], 1, -1, -1]) - ins_feat_x = torch.cat([ins_feat, x], 1) - ins_feat_y = torch.cat([ins_feat, y], 1) - - for ins_layer_x, ins_layer_y in zip(self.ins_convs_x, self.ins_convs_y): - ins_feat_x = ins_layer_x(ins_feat_x) - ins_feat_y = ins_layer_y(ins_feat_y) - - ins_feat_x = F.interpolate(ins_feat_x, scale_factor=2, mode='bilinear') - ins_feat_y = F.interpolate(ins_feat_y, scale_factor=2, mode='bilinear') - - ins_pred_x = self.dsolo_ins_list_x[idx](ins_feat_x) - ins_pred_y = self.dsolo_ins_list_y[idx](ins_feat_y) - - # cate branch - for i, cate_layer in enumerate(self.cate_convs): - if i == self.cate_down_pos: - seg_num_grid = self.seg_num_grids[idx] - cate_feat = F.interpolate(cate_feat, size=seg_num_grid, mode='bilinear') - cate_feat = cate_layer(cate_feat) - - cate_pred = self.dsolo_cate(cate_feat) - - if eval: - ins_pred_x = F.interpolate(ins_pred_x.sigmoid(), size=upsampled_size, mode='bilinear') - ins_pred_y = F.interpolate(ins_pred_y.sigmoid(), size=upsampled_size, mode='bilinear') - cate_pred = points_nms(cate_pred.sigmoid(), kernel=2).permute(0, 2, 3, 1) - return ins_pred_x, ins_pred_y, cate_pred - - def loss(self, - ins_preds_x, - ins_preds_y, - cate_preds, - gt_bbox_list, - gt_label_list, - gt_mask_list, - img_metas, - cfg, - gt_bboxes_ignore=None): - featmap_sizes = [featmap.size()[-2:] for featmap in - ins_preds_x] - ins_label_list, cate_label_list, ins_ind_label_list, ins_ind_label_list_xy = multi_apply( - self.solo_target_single, - gt_bbox_list, - gt_label_list, - gt_mask_list, - featmap_sizes=featmap_sizes) - - # ins - ins_labels = [torch.cat([ins_labels_level_img[ins_ind_labels_level_img, ...] - for ins_labels_level_img, ins_ind_labels_level_img in - zip(ins_labels_level, ins_ind_labels_level)], 0) - for ins_labels_level, ins_ind_labels_level in zip(zip(*ins_label_list), zip(*ins_ind_label_list))] - - ins_preds_x_final = [torch.cat([ins_preds_level_img_x[ins_ind_labels_level_img[:, 1], ...] - for ins_preds_level_img_x, ins_ind_labels_level_img in - zip(ins_preds_level_x, ins_ind_labels_level)], 0) - for ins_preds_level_x, ins_ind_labels_level in - zip(ins_preds_x, zip(*ins_ind_label_list_xy))] - - ins_preds_y_final = [torch.cat([ins_preds_level_img_y[ins_ind_labels_level_img[:, 0], ...] - for ins_preds_level_img_y, ins_ind_labels_level_img in - zip(ins_preds_level_y, ins_ind_labels_level)], 0) - for ins_preds_level_y, ins_ind_labels_level in - zip(ins_preds_y, zip(*ins_ind_label_list_xy))] - - num_ins = 0. - # dice loss - loss_ins = [] - for input_x, input_y, target in zip(ins_preds_x_final, ins_preds_y_final, ins_labels): - mask_n = input_x.size(0) - if mask_n == 0: - continue - num_ins += mask_n - input = (input_x.sigmoid())*(input_y.sigmoid()) - loss_ins.append(dice_loss(input, target)) - - loss_ins = torch.cat(loss_ins).mean() * self.ins_loss_weight - - # cate - cate_labels = [ - torch.cat([cate_labels_level_img.flatten() - for cate_labels_level_img in cate_labels_level]) - for cate_labels_level in zip(*cate_label_list) - ] - flatten_cate_labels = torch.cat(cate_labels) - - cate_preds = [ - cate_pred.permute(0, 2, 3, 1).reshape(-1, self.cate_out_channels) - for cate_pred in cate_preds - ] - flatten_cate_preds = torch.cat(cate_preds) - - loss_cate = self.loss_cate(flatten_cate_preds, flatten_cate_labels, avg_factor=num_ins + 1) - return dict( - loss_ins=loss_ins, - loss_cate=loss_cate) - - def solo_target_single(self, - gt_bboxes_raw, - gt_labels_raw, - gt_masks_raw, - featmap_sizes=None): - - device = gt_labels_raw[0].device - # ins - gt_areas = torch.sqrt((gt_bboxes_raw[:, 2] - gt_bboxes_raw[:, 0]) * ( - gt_bboxes_raw[:, 3] - gt_bboxes_raw[:, 1])) - ins_label_list = [] - cate_label_list = [] - ins_ind_label_list = [] - ins_ind_label_list_xy = [] - for (lower_bound, upper_bound), stride, featmap_size, num_grid \ - in zip(self.scale_ranges, self.strides, featmap_sizes, self.seg_num_grids): - - ins_label = torch.zeros([num_grid**2, featmap_size[0], featmap_size[1]], dtype=torch.uint8, device=device) - cate_label = torch.zeros([num_grid, num_grid], dtype=torch.int64, device=device) - ins_ind_label = torch.zeros([num_grid**2], dtype=torch.bool, device=device) - - hit_indices = ((gt_areas >= lower_bound) & (gt_areas <= upper_bound)).nonzero().flatten() - - if len(hit_indices) == 0: - ins_label = torch.zeros([1, featmap_size[0], featmap_size[1]], dtype=torch.uint8, - device=device) - ins_label_list.append(ins_label) - cate_label_list.append(cate_label) - ins_ind_label = torch.zeros([1], dtype=torch.bool, device=device) - ins_ind_label_list.append(ins_ind_label) - ins_ind_label_list_xy.append(cate_label.nonzero()) - continue - gt_bboxes = gt_bboxes_raw[hit_indices] - gt_labels = gt_labels_raw[hit_indices] - gt_masks = gt_masks_raw[hit_indices.cpu().numpy(), ...] - - half_ws = 0.5 * (gt_bboxes[:, 2] - gt_bboxes[:, 0]) * self.sigma - half_hs = 0.5 * (gt_bboxes[:, 3] - gt_bboxes[:, 1]) * self.sigma - - # mass center - gt_masks_pt = torch.from_numpy(gt_masks).to(device=device) - center_ws, center_hs = center_of_mass(gt_masks_pt) - valid_mask_flags = gt_masks_pt.sum(dim=-1).sum(dim=-1) > 0 - - output_stride = stride / 2 - for seg_mask, gt_label, half_h, half_w, center_h, center_w, valid_mask_flag in zip(gt_masks, gt_labels, half_hs, half_ws, center_hs, center_ws, valid_mask_flags): - if not valid_mask_flag: - continue - upsampled_size = (featmap_sizes[0][0] * 4, featmap_sizes[0][1] * 4) - coord_w = int((center_w / upsampled_size[1]) // (1. / num_grid)) - coord_h = int((center_h / upsampled_size[0]) // (1. / num_grid)) - - # left, top, right, down - top_box = max(0, int(((center_h - half_h) / upsampled_size[0]) // (1. / num_grid))) - down_box = min(num_grid - 1, int(((center_h + half_h) / upsampled_size[0]) // (1. / num_grid))) - left_box = max(0, int(((center_w - half_w) / upsampled_size[1]) // (1. / num_grid))) - right_box = min(num_grid - 1, int(((center_w + half_w) / upsampled_size[1]) // (1. / num_grid))) - - top = max(top_box, coord_h-1) - down = min(down_box, coord_h+1) - left = max(coord_w-1, left_box) - right = min(right_box, coord_w+1) - - # squared - cate_label[top:(down+1), left:(right+1)] = gt_label - # ins - seg_mask = mmcv.imrescale(seg_mask, scale=1. / output_stride) - seg_mask = torch.from_numpy(seg_mask).to(device=device) - for i in range(top, down+1): - for j in range(left, right+1): - label = int(i * num_grid + j) - ins_label[label, :seg_mask.shape[0], :seg_mask.shape[1]] = seg_mask - ins_ind_label[label] = True - - ins_label = ins_label[ins_ind_label] - ins_label_list.append(ins_label) - - cate_label_list.append(cate_label) - - ins_ind_label = ins_ind_label[ins_ind_label] - ins_ind_label_list.append(ins_ind_label) - - ins_ind_label_list_xy.append(cate_label.nonzero()) - return ins_label_list, cate_label_list, ins_ind_label_list, ins_ind_label_list_xy - - def get_seg(self, seg_preds_x, seg_preds_y, cate_preds, img_metas, cfg, rescale=None): - assert len(seg_preds_x) == len(cate_preds) - num_levels = len(cate_preds) - featmap_size = seg_preds_x[0].size()[-2:] - - result_list = [] - for img_id in range(len(img_metas)): - cate_pred_list = [ - cate_preds[i][img_id].view(-1, self.cate_out_channels).detach() for i in range(num_levels) - ] - seg_pred_list_x = [ - seg_preds_x[i][img_id].detach() for i in range(num_levels) - ] - seg_pred_list_y = [ - seg_preds_y[i][img_id].detach() for i in range(num_levels) - ] - img_shape = img_metas[img_id]['img_shape'] - scale_factor = img_metas[img_id]['scale_factor'] - ori_shape = img_metas[img_id]['ori_shape'] - - cate_pred_list = torch.cat(cate_pred_list, dim=0) - seg_pred_list_x = torch.cat(seg_pred_list_x, dim=0) - seg_pred_list_y = torch.cat(seg_pred_list_y, dim=0) - - result = self.get_seg_single(cate_pred_list, seg_pred_list_x, seg_pred_list_y, - featmap_size, img_shape, ori_shape, scale_factor, cfg, rescale) - result_list.append(result) - return result_list - - def get_seg_single(self, - cate_preds, - seg_preds_x, - seg_preds_y, - featmap_size, - img_shape, - ori_shape, - scale_factor, - cfg, - rescale=False, debug=False): - - - # overall info. - h, w, _ = img_shape - upsampled_size_out = (featmap_size[0] * 4, featmap_size[1] * 4) - - # trans trans_diff. - trans_size = torch.Tensor(self.seg_num_grids).pow(2).cumsum(0).long() - trans_diff = torch.ones(trans_size[-1].item(), device=cate_preds.device).long() - num_grids = torch.ones(trans_size[-1].item(), device=cate_preds.device).long() - seg_size = torch.Tensor(self.seg_num_grids).cumsum(0).long() - seg_diff = torch.ones(trans_size[-1].item(), device=cate_preds.device).long() - strides = torch.ones(trans_size[-1].item(), device=cate_preds.device) - - n_stage = len(self.seg_num_grids) - trans_diff[:trans_size[0]] *= 0 - seg_diff[:trans_size[0]] *= 0 - num_grids[:trans_size[0]] *= self.seg_num_grids[0] - strides[:trans_size[0]] *= self.strides[0] - - for ind_ in range(1, n_stage): - trans_diff[trans_size[ind_ - 1]:trans_size[ind_]] *= trans_size[ind_ - 1] - seg_diff[trans_size[ind_ - 1]:trans_size[ind_]] *= seg_size[ind_ - 1] - num_grids[trans_size[ind_ - 1]:trans_size[ind_]] *= self.seg_num_grids[ind_] - strides[trans_size[ind_ - 1]:trans_size[ind_]] *= self.strides[ind_] - - # process. - inds = (cate_preds > cfg.score_thr) - cate_scores = cate_preds[inds] - - inds = inds.nonzero() - trans_diff = torch.index_select(trans_diff, dim=0, index=inds[:, 0]) - seg_diff = torch.index_select(seg_diff, dim=0, index=inds[:, 0]) - num_grids = torch.index_select(num_grids, dim=0, index=inds[:, 0]) - strides = torch.index_select(strides, dim=0, index=inds[:, 0]) - - y_inds = (inds[:, 0] - trans_diff) // num_grids - x_inds = (inds[:, 0] - trans_diff) % num_grids - y_inds += seg_diff - x_inds += seg_diff - - cate_labels = inds[:, 1] - seg_masks_soft = seg_preds_x[x_inds, ...] * seg_preds_y[y_inds, ...] - seg_masks = seg_masks_soft > cfg.mask_thr - sum_masks = seg_masks.sum((1, 2)).float() - keep = sum_masks > strides - - seg_masks_soft = seg_masks_soft[keep, ...] - seg_masks = seg_masks[keep, ...] - cate_scores = cate_scores[keep] - sum_masks = sum_masks[keep] - cate_labels = cate_labels[keep] - # maskness - seg_score = (seg_masks_soft * seg_masks.float()).sum((1, 2)) / sum_masks - cate_scores *= seg_score - - if len(cate_scores) == 0: - return None - - # sort and keep top nms_pre - sort_inds = torch.argsort(cate_scores, descending=True) - if len(sort_inds) > cfg.nms_pre: - sort_inds = sort_inds[:cfg.nms_pre] - seg_masks_soft = seg_masks_soft[sort_inds, :, :] - seg_masks = seg_masks[sort_inds, :, :] - cate_scores = cate_scores[sort_inds] - sum_masks = sum_masks[sort_inds] - cate_labels = cate_labels[sort_inds] - - # Matrix NMS - cate_scores = matrix_nms(seg_masks, cate_labels, cate_scores, - kernel=cfg.kernel, sigma=cfg.sigma, sum_masks=sum_masks) - - keep = cate_scores >= cfg.update_thr - seg_masks_soft = seg_masks_soft[keep, :, :] - cate_scores = cate_scores[keep] - cate_labels = cate_labels[keep] - # sort and keep top_k - sort_inds = torch.argsort(cate_scores, descending=True) - if len(sort_inds) > cfg.max_per_img: - sort_inds = sort_inds[:cfg.max_per_img] - seg_masks_soft = seg_masks_soft[sort_inds, :, :] - cate_scores = cate_scores[sort_inds] - cate_labels = cate_labels[sort_inds] - - seg_masks_soft = F.interpolate(seg_masks_soft.unsqueeze(0), - size=upsampled_size_out, - mode='bilinear')[:, :, :h, :w] - seg_masks = F.interpolate(seg_masks_soft, - size=ori_shape[:2], - mode='bilinear').squeeze(0) - seg_masks = seg_masks > cfg.mask_thr - return seg_masks, cate_labels, cate_scores diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/decoupled_solo_light_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/decoupled_solo_light_head.py deleted file mode 100644 index 5b52802b2..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/decoupled_solo_light_head.py +++ /dev/null @@ -1,479 +0,0 @@ -import mmcv -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import normal_init -from mmdet.ops import DeformConv, roi_align -from mmdet.core import multi_apply, bbox2roi, matrix_nms -from ..builder import build_loss -from ..registry import HEADS -from ..utils import bias_init_with_prob, ConvModule - -INF = 1e8 - -def center_of_mass(bitmasks): - _, h, w = bitmasks.size() - ys = torch.arange(0, h, dtype=torch.float32, device=bitmasks.device) - xs = torch.arange(0, w, dtype=torch.float32, device=bitmasks.device) - - m00 = bitmasks.sum(dim=-1).sum(dim=-1).clamp(min=1e-6) - m10 = (bitmasks * xs).sum(dim=-1).sum(dim=-1) - m01 = (bitmasks * ys[:, None]).sum(dim=-1).sum(dim=-1) - center_x = m10 / m00 - center_y = m01 / m00 - return center_x, center_y - -def points_nms(heat, kernel=2): - # kernel must be 2 - hmax = nn.functional.max_pool2d( - heat, (kernel, kernel), stride=1, padding=1) - keep = (hmax[:, :, :-1, :-1] == heat).float() - return heat * keep - -def dice_loss(input, target): - input = input.contiguous().view(input.size()[0], -1) - target = target.contiguous().view(target.size()[0], -1).float() - - a = torch.sum(input * target, 1) - b = torch.sum(input * input, 1) + 0.001 - c = torch.sum(target * target, 1) + 0.001 - d = (2 * a) / (b + c) - return 1-d - -@HEADS.register_module -class DecoupledSOLOLightHead(nn.Module): - def __init__(self, - num_classes, - in_channels, - seg_feat_channels=256, - stacked_convs=4, - strides=(4, 8, 16, 32, 64), - base_edge_list=(16, 32, 64, 128, 256), - scale_ranges=((8, 32), (16, 64), (32, 128), (64, 256), (128, 512)), - sigma=0.4, - num_grids=None, - cate_down_pos=0, - loss_ins=None, - loss_cate=None, - conv_cfg=None, - norm_cfg=None, - use_dcn_in_tower=False, - type_dcn=None): - super(DecoupledSOLOLightHead, self).__init__() - self.num_classes = num_classes - self.seg_num_grids = num_grids - self.cate_out_channels = self.num_classes - 1 - self.in_channels = in_channels - self.seg_feat_channels = seg_feat_channels - self.stacked_convs = stacked_convs - self.strides = strides - self.sigma = sigma - self.cate_down_pos = cate_down_pos - self.base_edge_list = base_edge_list - self.scale_ranges = scale_ranges - self.loss_cate = build_loss(loss_cate) - self.ins_loss_weight = loss_ins['loss_weight'] - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - self.use_dcn_in_tower = use_dcn_in_tower - self.type_dcn = type_dcn - self._init_layers() - - def _init_layers(self): - norm_cfg = dict(type='GN', num_groups=32, requires_grad=True) - self.ins_convs = nn.ModuleList() - self.cate_convs = nn.ModuleList() - - for i in range(self.stacked_convs): - if self.use_dcn_in_tower and i == self.stacked_convs - 1: - cfg_conv = dict(type=self.type_dcn) - else: - cfg_conv = self.conv_cfg - - chn = self.in_channels + 2 if i == 0 else self.seg_feat_channels - self.ins_convs.append( - ConvModule( - chn, - self.seg_feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=cfg_conv, - norm_cfg=norm_cfg, - bias=norm_cfg is None)) - - chn = self.in_channels if i == 0 else self.seg_feat_channels - self.cate_convs.append( - ConvModule( - chn, - self.seg_feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=cfg_conv, - norm_cfg=norm_cfg, - bias=norm_cfg is None)) - - self.dsolo_ins_list_x = nn.ModuleList() - self.dsolo_ins_list_y = nn.ModuleList() - for seg_num_grid in self.seg_num_grids: - self.dsolo_ins_list_x.append( - nn.Conv2d( - self.seg_feat_channels, seg_num_grid, 3, padding=1)) - self.dsolo_ins_list_y.append( - nn.Conv2d( - self.seg_feat_channels, seg_num_grid, 3, padding=1)) - self.dsolo_cate = nn.Conv2d( - self.seg_feat_channels, self.cate_out_channels, 3, padding=1) - - def init_weights(self): - for m in self.ins_convs: - normal_init(m.conv, std=0.01) - for m in self.cate_convs: - normal_init(m.conv, std=0.01) - bias_ins = bias_init_with_prob(0.01) - for m in self.dsolo_ins_list_x: - normal_init(m, std=0.01, bias=bias_ins) - for m in self.dsolo_ins_list_y: - normal_init(m, std=0.01, bias=bias_ins) - bias_cate = bias_init_with_prob(0.01) - normal_init(self.dsolo_cate, std=0.01, bias=bias_cate) - - def forward(self, feats, eval=False): - new_feats = self.split_feats(feats) - featmap_sizes = [featmap.size()[-2:] for featmap in new_feats] - upsampled_size = (featmap_sizes[0][0] * 2, featmap_sizes[0][1] * 2) - ins_pred_x, ins_pred_y, cate_pred = multi_apply(self.forward_single, new_feats, - list(range(len(self.seg_num_grids))), - eval=eval, upsampled_size=upsampled_size) - return ins_pred_x, ins_pred_y, cate_pred - - def split_feats(self, feats): - return (F.interpolate(feats[0], scale_factor=0.5, mode='bilinear'), - feats[1], - feats[2], - feats[3], - F.interpolate(feats[4], size=feats[3].shape[-2:], mode='bilinear')) - - def forward_single(self, x, idx, eval=False, upsampled_size=None): - ins_feat = x - cate_feat = x - # ins branch - # concat coord - x_range = torch.linspace(-1, 1, ins_feat.shape[-1], device=ins_feat.device) - y_range = torch.linspace(-1, 1, ins_feat.shape[-2], device=ins_feat.device) - y, x = torch.meshgrid(y_range, x_range) - y = y.expand([ins_feat.shape[0], 1, -1, -1]) - x = x.expand([ins_feat.shape[0], 1, -1, -1]) - coord_feat = torch.cat([x, y], 1) - ins_feat = torch.cat([ins_feat, coord_feat], 1) - - for ins_layer in self.ins_convs: - ins_feat = ins_layer(ins_feat) - - ins_feat = F.interpolate(ins_feat, scale_factor=2, mode='bilinear') - - ins_pred_x = self.dsolo_ins_list_x[idx](ins_feat) - ins_pred_y = self.dsolo_ins_list_y[idx](ins_feat) - - # cate branch - for i, cate_layer in enumerate(self.cate_convs): - if i == self.cate_down_pos: - seg_num_grid = self.seg_num_grids[idx] - cate_feat = F.interpolate(cate_feat, size=seg_num_grid, mode='bilinear') - cate_feat = cate_layer(cate_feat) - - cate_pred = self.dsolo_cate(cate_feat) - - if eval: - ins_pred_x = F.interpolate(ins_pred_x.sigmoid(), size=upsampled_size, mode='bilinear') - ins_pred_y = F.interpolate(ins_pred_y.sigmoid(), size=upsampled_size, mode='bilinear') - cate_pred = points_nms(cate_pred.sigmoid(), kernel=2).permute(0, 2, 3, 1) - return ins_pred_x, ins_pred_y, cate_pred - - def loss(self, - ins_preds_x, - ins_preds_y, - cate_preds, - gt_bbox_list, - gt_label_list, - gt_mask_list, - img_metas, - cfg, - gt_bboxes_ignore=None): - featmap_sizes = [featmap.size()[-2:] for featmap in - ins_preds_x] - ins_label_list, cate_label_list, ins_ind_label_list, ins_ind_label_list_xy = multi_apply( - self.solo_target_single, - gt_bbox_list, - gt_label_list, - gt_mask_list, - featmap_sizes=featmap_sizes) - - # ins - ins_labels = [torch.cat([ins_labels_level_img[ins_ind_labels_level_img, ...] - for ins_labels_level_img, ins_ind_labels_level_img in - zip(ins_labels_level, ins_ind_labels_level)], 0) - for ins_labels_level, ins_ind_labels_level in zip(zip(*ins_label_list), zip(*ins_ind_label_list))] - - ins_preds_x_final = [torch.cat([ins_preds_level_img_x[ins_ind_labels_level_img[:, 1], ...] - for ins_preds_level_img_x, ins_ind_labels_level_img in - zip(ins_preds_level_x, ins_ind_labels_level)], 0) - for ins_preds_level_x, ins_ind_labels_level in - zip(ins_preds_x, zip(*ins_ind_label_list_xy))] - - ins_preds_y_final = [torch.cat([ins_preds_level_img_y[ins_ind_labels_level_img[:, 0], ...] - for ins_preds_level_img_y, ins_ind_labels_level_img in - zip(ins_preds_level_y, ins_ind_labels_level)], 0) - for ins_preds_level_y, ins_ind_labels_level in - zip(ins_preds_y, zip(*ins_ind_label_list_xy))] - - num_ins = 0. - # dice loss - loss_ins = [] - for input_x, input_y, target in zip(ins_preds_x_final, ins_preds_y_final, ins_labels): - mask_n = input_x.size(0) - if mask_n == 0: - continue - num_ins += mask_n - input = (input_x.sigmoid())*(input_y.sigmoid()) - loss_ins.append(dice_loss(input, target)) - - loss_ins = torch.cat(loss_ins).mean() * self.ins_loss_weight - - # cate - cate_labels = [ - torch.cat([cate_labels_level_img.flatten() - for cate_labels_level_img in cate_labels_level]) - for cate_labels_level in zip(*cate_label_list) - ] - flatten_cate_labels = torch.cat(cate_labels) - - cate_preds = [ - cate_pred.permute(0, 2, 3, 1).reshape(-1, self.cate_out_channels) - for cate_pred in cate_preds - ] - flatten_cate_preds = torch.cat(cate_preds) - - loss_cate = self.loss_cate(flatten_cate_preds, flatten_cate_labels, avg_factor=num_ins + 1) - return dict( - loss_ins=loss_ins, - loss_cate=loss_cate) - - def solo_target_single(self, - gt_bboxes_raw, - gt_labels_raw, - gt_masks_raw, - featmap_sizes=None): - - device = gt_labels_raw[0].device - # ins - gt_areas = torch.sqrt((gt_bboxes_raw[:, 2] - gt_bboxes_raw[:, 0]) * ( - gt_bboxes_raw[:, 3] - gt_bboxes_raw[:, 1])) - ins_label_list = [] - cate_label_list = [] - ins_ind_label_list = [] - ins_ind_label_list_xy = [] - for (lower_bound, upper_bound), stride, featmap_size, num_grid \ - in zip(self.scale_ranges, self.strides, featmap_sizes, self.seg_num_grids): - - ins_label = torch.zeros([num_grid**2, featmap_size[0], featmap_size[1]], dtype=torch.uint8, device=device) - cate_label = torch.zeros([num_grid, num_grid], dtype=torch.int64, device=device) - ins_ind_label = torch.zeros([num_grid**2], dtype=torch.bool, device=device) - - hit_indices = ((gt_areas >= lower_bound) & (gt_areas <= upper_bound)).nonzero().flatten() - - if len(hit_indices) == 0: - ins_label = torch.zeros([1, featmap_size[0], featmap_size[1]], dtype=torch.uint8, - device=device) - ins_label_list.append(ins_label) - cate_label_list.append(cate_label) - ins_ind_label = torch.zeros([1], dtype=torch.bool, device=device) - ins_ind_label_list.append(ins_ind_label) - ins_ind_label_list_xy.append(cate_label.nonzero()) - continue - gt_bboxes = gt_bboxes_raw[hit_indices] - gt_labels = gt_labels_raw[hit_indices] - gt_masks = gt_masks_raw[hit_indices.cpu().numpy(), ...] - - half_ws = 0.5 * (gt_bboxes[:, 2] - gt_bboxes[:, 0]) * self.sigma - half_hs = 0.5 * (gt_bboxes[:, 3] - gt_bboxes[:, 1]) * self.sigma - - # mass center - gt_masks_pt = torch.from_numpy(gt_masks).to(device=device) - center_ws, center_hs = center_of_mass(gt_masks_pt) - valid_mask_flags = gt_masks_pt.sum(dim=-1).sum(dim=-1) > 0 - - output_stride = stride / 2 - for seg_mask, gt_label, half_h, half_w, center_h, center_w, valid_mask_flag in zip(gt_masks, gt_labels, half_hs, half_ws, center_hs, center_ws, valid_mask_flags): - if not valid_mask_flag: - continue - upsampled_size = (featmap_sizes[0][0] * 4, featmap_sizes[0][1] * 4) - coord_w = int((center_w / upsampled_size[1]) // (1. / num_grid)) - coord_h = int((center_h / upsampled_size[0]) // (1. / num_grid)) - - # left, top, right, down - top_box = max(0, int(((center_h - half_h) / upsampled_size[0]) // (1. / num_grid))) - down_box = min(num_grid - 1, int(((center_h + half_h) / upsampled_size[0]) // (1. / num_grid))) - left_box = max(0, int(((center_w - half_w) / upsampled_size[1]) // (1. / num_grid))) - right_box = min(num_grid - 1, int(((center_w + half_w) / upsampled_size[1]) // (1. / num_grid))) - - top = max(top_box, coord_h-1) - down = min(down_box, coord_h+1) - left = max(coord_w-1, left_box) - right = min(right_box, coord_w+1) - - # squared - cate_label[top:(down+1), left:(right+1)] = gt_label - # ins - seg_mask = mmcv.imrescale(seg_mask, scale=1. / output_stride) - seg_mask = torch.from_numpy(seg_mask).to(device=device) - for i in range(top, down+1): - for j in range(left, right+1): - label = int(i * num_grid + j) - ins_label[label, :seg_mask.shape[0], :seg_mask.shape[1]] = seg_mask - ins_ind_label[label] = True - - ins_label = ins_label[ins_ind_label] - ins_label_list.append(ins_label) - - cate_label_list.append(cate_label) - - ins_ind_label = ins_ind_label[ins_ind_label] - ins_ind_label_list.append(ins_ind_label) - - ins_ind_label_list_xy.append(cate_label.nonzero()) - return ins_label_list, cate_label_list, ins_ind_label_list, ins_ind_label_list_xy - - def get_seg(self, seg_preds_x, seg_preds_y, cate_preds, img_metas, cfg, rescale=None): - assert len(seg_preds_x) == len(cate_preds) - num_levels = len(cate_preds) - featmap_size = seg_preds_x[0].size()[-2:] - - result_list = [] - for img_id in range(len(img_metas)): - cate_pred_list = [ - cate_preds[i][img_id].view(-1, self.cate_out_channels).detach() for i in range(num_levels) - ] - seg_pred_list_x = [ - seg_preds_x[i][img_id].detach() for i in range(num_levels) - ] - seg_pred_list_y = [ - seg_preds_y[i][img_id].detach() for i in range(num_levels) - ] - img_shape = img_metas[img_id]['img_shape'] - scale_factor = img_metas[img_id]['scale_factor'] - ori_shape = img_metas[img_id]['ori_shape'] - - cate_pred_list = torch.cat(cate_pred_list, dim=0) - seg_pred_list_x = torch.cat(seg_pred_list_x, dim=0) - seg_pred_list_y = torch.cat(seg_pred_list_y, dim=0) - - result = self.get_seg_single(cate_pred_list, seg_pred_list_x, seg_pred_list_y, - featmap_size, img_shape, ori_shape, scale_factor, cfg, rescale) - result_list.append(result) - return result_list - - def get_seg_single(self, - cate_preds, - seg_preds_x, - seg_preds_y, - featmap_size, - img_shape, - ori_shape, - scale_factor, - cfg, - rescale=False, debug=False): - - - # overall info. - h, w, _ = img_shape - upsampled_size_out = (featmap_size[0] * 4, featmap_size[1] * 4) - - # trans trans_diff. - trans_size = torch.Tensor(self.seg_num_grids).pow(2).cumsum(0).long() - trans_diff = torch.ones(trans_size[-1].item(), device=cate_preds.device).long() - num_grids = torch.ones(trans_size[-1].item(), device=cate_preds.device).long() - seg_size = torch.Tensor(self.seg_num_grids).cumsum(0).long() - seg_diff = torch.ones(trans_size[-1].item(), device=cate_preds.device).long() - strides = torch.ones(trans_size[-1].item(), device=cate_preds.device) - - n_stage = len(self.seg_num_grids) - trans_diff[:trans_size[0]] *= 0 - seg_diff[:trans_size[0]] *= 0 - num_grids[:trans_size[0]] *= self.seg_num_grids[0] - strides[:trans_size[0]] *= self.strides[0] - - for ind_ in range(1, n_stage): - trans_diff[trans_size[ind_ - 1]:trans_size[ind_]] *= trans_size[ind_ - 1] - seg_diff[trans_size[ind_ - 1]:trans_size[ind_]] *= seg_size[ind_ - 1] - num_grids[trans_size[ind_ - 1]:trans_size[ind_]] *= self.seg_num_grids[ind_] - strides[trans_size[ind_ - 1]:trans_size[ind_]] *= self.strides[ind_] - - # process. - inds = (cate_preds > cfg.score_thr) - cate_scores = cate_preds[inds] - - inds = inds.nonzero() - trans_diff = torch.index_select(trans_diff, dim=0, index=inds[:, 0]) - seg_diff = torch.index_select(seg_diff, dim=0, index=inds[:, 0]) - num_grids = torch.index_select(num_grids, dim=0, index=inds[:, 0]) - strides = torch.index_select(strides, dim=0, index=inds[:, 0]) - - y_inds = (inds[:, 0] - trans_diff) // num_grids - x_inds = (inds[:, 0] - trans_diff) % num_grids - y_inds += seg_diff - x_inds += seg_diff - - cate_labels = inds[:, 1] - seg_masks_soft = seg_preds_x[x_inds, ...] * seg_preds_y[y_inds, ...] - seg_masks = seg_masks_soft > cfg.mask_thr - sum_masks = seg_masks.sum((1, 2)).float() - keep = sum_masks > strides - - seg_masks_soft = seg_masks_soft[keep, ...] - seg_masks = seg_masks[keep, ...] - cate_scores = cate_scores[keep] - sum_masks = sum_masks[keep] - cate_labels = cate_labels[keep] - # maskness - seg_score = (seg_masks_soft * seg_masks.float()).sum((1, 2)) / sum_masks - cate_scores *= seg_score - - if len(cate_scores) == 0: - return None - - # sort and keep top nms_pre - sort_inds = torch.argsort(cate_scores, descending=True) - if len(sort_inds) > cfg.nms_pre: - sort_inds = sort_inds[:cfg.nms_pre] - seg_masks_soft = seg_masks_soft[sort_inds, :, :] - seg_masks = seg_masks[sort_inds, :, :] - cate_scores = cate_scores[sort_inds] - sum_masks = sum_masks[sort_inds] - cate_labels = cate_labels[sort_inds] - - # Matrix NMS - cate_scores = matrix_nms(seg_masks, cate_labels, cate_scores, - kernel=cfg.kernel, sigma=cfg.sigma, sum_masks=sum_masks) - - keep = cate_scores >= cfg.update_thr - seg_masks_soft = seg_masks_soft[keep, :, :] - cate_scores = cate_scores[keep] - cate_labels = cate_labels[keep] - # sort and keep top_k - sort_inds = torch.argsort(cate_scores, descending=True) - if len(sort_inds) > cfg.max_per_img: - sort_inds = sort_inds[:cfg.max_per_img] - seg_masks_soft = seg_masks_soft[sort_inds, :, :] - cate_scores = cate_scores[sort_inds] - cate_labels = cate_labels[sort_inds] - - seg_masks_soft = F.interpolate(seg_masks_soft.unsqueeze(0), - size=upsampled_size_out, - mode='bilinear')[:, :, :h, :w] - seg_masks = F.interpolate(seg_masks_soft, - size=ori_shape[:2], - mode='bilinear').squeeze(0) - seg_masks = seg_masks > cfg.mask_thr - return seg_masks, cate_labels, cate_scores diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/fcos_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/fcos_head.py deleted file mode 100644 index a8c2cd411..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/fcos_head.py +++ /dev/null @@ -1,408 +0,0 @@ -import torch -import torch.nn as nn -from mmcv.cnn import normal_init - -from mmdet.core import distance2bbox, force_fp32, multi_apply, multiclass_nms -from ..builder import build_loss -from ..registry import HEADS -from ..utils import ConvModule, Scale, bias_init_with_prob - -INF = 1e8 - - -@HEADS.register_module -class FCOSHead(nn.Module): - """ - Fully Convolutional One-Stage Object Detection head from [1]_. - - The FCOS head does not use anchor boxes. Instead bounding boxes are - predicted at each pixel and a centerness measure is used to supress - low-quality predictions. - - References: - .. [1] https://arxiv.org/abs/1904.01355 - - Example: - >>> self = FCOSHead(11, 7) - >>> feats = [torch.rand(1, 7, s, s) for s in [4, 8, 16, 32, 64]] - >>> cls_score, bbox_pred, centerness = self.forward(feats) - >>> assert len(cls_score) == len(self.scales) - """ - - def __init__(self, - num_classes, - in_channels, - feat_channels=256, - stacked_convs=4, - strides=(4, 8, 16, 32, 64), - regress_ranges=((-1, 64), (64, 128), (128, 256), (256, 512), - (512, INF)), - loss_cls=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=1.0), - loss_bbox=dict(type='IoULoss', loss_weight=1.0), - loss_centerness=dict( - type='CrossEntropyLoss', - use_sigmoid=True, - loss_weight=1.0), - conv_cfg=None, - norm_cfg=dict(type='GN', num_groups=32, requires_grad=True)): - super(FCOSHead, self).__init__() - - self.num_classes = num_classes - self.cls_out_channels = num_classes - 1 - self.in_channels = in_channels - self.feat_channels = feat_channels - self.stacked_convs = stacked_convs - self.strides = strides - self.regress_ranges = regress_ranges - self.loss_cls = build_loss(loss_cls) - self.loss_bbox = build_loss(loss_bbox) - self.loss_centerness = build_loss(loss_centerness) - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - self.fp16_enabled = False - - self._init_layers() - - def _init_layers(self): - self.cls_convs = nn.ModuleList() - self.reg_convs = nn.ModuleList() - for i in range(self.stacked_convs): - chn = self.in_channels if i == 0 else self.feat_channels - self.cls_convs.append( - ConvModule( - chn, - self.feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg, - bias=self.norm_cfg is None)) - self.reg_convs.append( - ConvModule( - chn, - self.feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg, - bias=self.norm_cfg is None)) - self.fcos_cls = nn.Conv2d( - self.feat_channels, self.cls_out_channels, 3, padding=1) - self.fcos_reg = nn.Conv2d(self.feat_channels, 4, 3, padding=1) - self.fcos_centerness = nn.Conv2d(self.feat_channels, 1, 3, padding=1) - - self.scales = nn.ModuleList([Scale(1.0) for _ in self.strides]) - - def init_weights(self): - for m in self.cls_convs: - normal_init(m.conv, std=0.01) - for m in self.reg_convs: - normal_init(m.conv, std=0.01) - bias_cls = bias_init_with_prob(0.01) - normal_init(self.fcos_cls, std=0.01, bias=bias_cls) - normal_init(self.fcos_reg, std=0.01) - normal_init(self.fcos_centerness, std=0.01) - - def forward(self, feats): - return multi_apply(self.forward_single, feats, self.scales) - - def forward_single(self, x, scale): - cls_feat = x - reg_feat = x - - for cls_layer in self.cls_convs: - cls_feat = cls_layer(cls_feat) - cls_score = self.fcos_cls(cls_feat) - centerness = self.fcos_centerness(cls_feat) - - for reg_layer in self.reg_convs: - reg_feat = reg_layer(reg_feat) - # scale the bbox_pred of different level - # float to avoid overflow when enabling FP16 - bbox_pred = scale(self.fcos_reg(reg_feat)).float().exp() - return cls_score, bbox_pred, centerness - - @force_fp32(apply_to=('cls_scores', 'bbox_preds', 'centernesses')) - def loss(self, - cls_scores, - bbox_preds, - centernesses, - gt_bboxes, - gt_labels, - img_metas, - cfg, - gt_bboxes_ignore=None): - assert len(cls_scores) == len(bbox_preds) == len(centernesses) - featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] - all_level_points = self.get_points(featmap_sizes, bbox_preds[0].dtype, - bbox_preds[0].device) - labels, bbox_targets = self.fcos_target(all_level_points, gt_bboxes, - gt_labels) - - num_imgs = cls_scores[0].size(0) - # flatten cls_scores, bbox_preds and centerness - flatten_cls_scores = [ - cls_score.permute(0, 2, 3, 1).reshape(-1, self.cls_out_channels) - for cls_score in cls_scores - ] - flatten_bbox_preds = [ - bbox_pred.permute(0, 2, 3, 1).reshape(-1, 4) - for bbox_pred in bbox_preds - ] - flatten_centerness = [ - centerness.permute(0, 2, 3, 1).reshape(-1) - for centerness in centernesses - ] - flatten_cls_scores = torch.cat(flatten_cls_scores) - flatten_bbox_preds = torch.cat(flatten_bbox_preds) - flatten_centerness = torch.cat(flatten_centerness) - flatten_labels = torch.cat(labels) - flatten_bbox_targets = torch.cat(bbox_targets) - # repeat points to align with bbox_preds - flatten_points = torch.cat( - [points.repeat(num_imgs, 1) for points in all_level_points]) - - pos_inds = flatten_labels.nonzero().reshape(-1) - num_pos = len(pos_inds) - loss_cls = self.loss_cls( - flatten_cls_scores, flatten_labels, - avg_factor=num_pos + num_imgs) # avoid num_pos is 0 - - pos_bbox_preds = flatten_bbox_preds[pos_inds] - pos_centerness = flatten_centerness[pos_inds] - - if num_pos > 0: - pos_bbox_targets = flatten_bbox_targets[pos_inds] - pos_centerness_targets = self.centerness_target(pos_bbox_targets) - pos_points = flatten_points[pos_inds] - pos_decoded_bbox_preds = distance2bbox(pos_points, pos_bbox_preds) - pos_decoded_target_preds = distance2bbox(pos_points, - pos_bbox_targets) - # centerness weighted iou loss - loss_bbox = self.loss_bbox( - pos_decoded_bbox_preds, - pos_decoded_target_preds, - weight=pos_centerness_targets, - avg_factor=pos_centerness_targets.sum()) - loss_centerness = self.loss_centerness(pos_centerness, - pos_centerness_targets) - else: - loss_bbox = pos_bbox_preds.sum() - loss_centerness = pos_centerness.sum() - - return dict( - loss_cls=loss_cls, - loss_bbox=loss_bbox, - loss_centerness=loss_centerness) - - @force_fp32(apply_to=('cls_scores', 'bbox_preds', 'centernesses')) - def get_bboxes(self, - cls_scores, - bbox_preds, - centernesses, - img_metas, - cfg, - rescale=None): - assert len(cls_scores) == len(bbox_preds) - num_levels = len(cls_scores) - - featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] - mlvl_points = self.get_points(featmap_sizes, bbox_preds[0].dtype, - bbox_preds[0].device) - result_list = [] - for img_id in range(len(img_metas)): - cls_score_list = [ - cls_scores[i][img_id].detach() for i in range(num_levels) - ] - bbox_pred_list = [ - bbox_preds[i][img_id].detach() for i in range(num_levels) - ] - centerness_pred_list = [ - centernesses[i][img_id].detach() for i in range(num_levels) - ] - img_shape = img_metas[img_id]['img_shape'] - scale_factor = img_metas[img_id]['scale_factor'] - det_bboxes = self.get_bboxes_single(cls_score_list, bbox_pred_list, - centerness_pred_list, - mlvl_points, img_shape, - scale_factor, cfg, rescale) - result_list.append(det_bboxes) - return result_list - - def get_bboxes_single(self, - cls_scores, - bbox_preds, - centernesses, - mlvl_points, - img_shape, - scale_factor, - cfg, - rescale=False): - assert len(cls_scores) == len(bbox_preds) == len(mlvl_points) - mlvl_bboxes = [] - mlvl_scores = [] - mlvl_centerness = [] - for cls_score, bbox_pred, centerness, points in zip( - cls_scores, bbox_preds, centernesses, mlvl_points): - assert cls_score.size()[-2:] == bbox_pred.size()[-2:] - scores = cls_score.permute(1, 2, 0).reshape( - -1, self.cls_out_channels).sigmoid() - centerness = centerness.permute(1, 2, 0).reshape(-1).sigmoid() - - bbox_pred = bbox_pred.permute(1, 2, 0).reshape(-1, 4) - nms_pre = cfg.get('nms_pre', -1) - if nms_pre > 0 and scores.shape[0] > nms_pre: - max_scores, _ = (scores * centerness[:, None]).max(dim=1) - _, topk_inds = max_scores.topk(nms_pre) - points = points[topk_inds, :] - bbox_pred = bbox_pred[topk_inds, :] - scores = scores[topk_inds, :] - centerness = centerness[topk_inds] - bboxes = distance2bbox(points, bbox_pred, max_shape=img_shape) - mlvl_bboxes.append(bboxes) - mlvl_scores.append(scores) - mlvl_centerness.append(centerness) - mlvl_bboxes = torch.cat(mlvl_bboxes) - if rescale: - mlvl_bboxes /= mlvl_bboxes.new_tensor(scale_factor) - mlvl_scores = torch.cat(mlvl_scores) - padding = mlvl_scores.new_zeros(mlvl_scores.shape[0], 1) - mlvl_scores = torch.cat([padding, mlvl_scores], dim=1) - mlvl_centerness = torch.cat(mlvl_centerness) - det_bboxes, det_labels = multiclass_nms( - mlvl_bboxes, - mlvl_scores, - cfg.score_thr, - cfg.nms, - cfg.max_per_img, - score_factors=mlvl_centerness) - return det_bboxes, det_labels - - def get_points(self, featmap_sizes, dtype, device): - """Get points according to feature map sizes. - - Args: - featmap_sizes (list[tuple]): Multi-level feature map sizes. - dtype (torch.dtype): Type of points. - device (torch.device): Device of points. - - Returns: - tuple: points of each image. - """ - mlvl_points = [] - for i in range(len(featmap_sizes)): - mlvl_points.append( - self.get_points_single(featmap_sizes[i], self.strides[i], - dtype, device)) - return mlvl_points - - def get_points_single(self, featmap_size, stride, dtype, device): - h, w = featmap_size - x_range = torch.arange( - 0, w * stride, stride, dtype=dtype, device=device) - y_range = torch.arange( - 0, h * stride, stride, dtype=dtype, device=device) - y, x = torch.meshgrid(y_range, x_range) - points = torch.stack( - (x.reshape(-1), y.reshape(-1)), dim=-1) + stride // 2 - return points - - def fcos_target(self, points, gt_bboxes_list, gt_labels_list): - assert len(points) == len(self.regress_ranges) - num_levels = len(points) - # expand regress ranges to align with points - expanded_regress_ranges = [ - points[i].new_tensor(self.regress_ranges[i])[None].expand_as( - points[i]) for i in range(num_levels) - ] - # concat all levels points and regress ranges - concat_regress_ranges = torch.cat(expanded_regress_ranges, dim=0) - concat_points = torch.cat(points, dim=0) - # get labels and bbox_targets of each image - labels_list, bbox_targets_list = multi_apply( - self.fcos_target_single, - gt_bboxes_list, - gt_labels_list, - points=concat_points, - regress_ranges=concat_regress_ranges) - - # split to per img, per level - num_points = [center.size(0) for center in points] - labels_list = [labels.split(num_points, 0) for labels in labels_list] - bbox_targets_list = [ - bbox_targets.split(num_points, 0) - for bbox_targets in bbox_targets_list - ] - - # concat per level image - concat_lvl_labels = [] - concat_lvl_bbox_targets = [] - for i in range(num_levels): - concat_lvl_labels.append( - torch.cat([labels[i] for labels in labels_list])) - concat_lvl_bbox_targets.append( - torch.cat( - [bbox_targets[i] for bbox_targets in bbox_targets_list])) - return concat_lvl_labels, concat_lvl_bbox_targets - - def fcos_target_single(self, gt_bboxes, gt_labels, points, regress_ranges): - num_points = points.size(0) - num_gts = gt_labels.size(0) - if num_gts == 0: - return gt_labels.new_zeros(num_points), \ - gt_bboxes.new_zeros((num_points, 4)) - - areas = (gt_bboxes[:, 2] - gt_bboxes[:, 0] + 1) * ( - gt_bboxes[:, 3] - gt_bboxes[:, 1] + 1) - # TODO: figure out why these two are different - # areas = areas[None].expand(num_points, num_gts) - areas = areas[None].repeat(num_points, 1) - regress_ranges = regress_ranges[:, None, :].expand( - num_points, num_gts, 2) - gt_bboxes = gt_bboxes[None].expand(num_points, num_gts, 4) - xs, ys = points[:, 0], points[:, 1] - xs = xs[:, None].expand(num_points, num_gts) - ys = ys[:, None].expand(num_points, num_gts) - - left = xs - gt_bboxes[..., 0] - right = gt_bboxes[..., 2] - xs - top = ys - gt_bboxes[..., 1] - bottom = gt_bboxes[..., 3] - ys - bbox_targets = torch.stack((left, top, right, bottom), -1) - - # condition1: inside a gt bbox - inside_gt_bbox_mask = bbox_targets.min(-1)[0] > 0 - - # condition2: limit the regression range for each location - max_regress_distance = bbox_targets.max(-1)[0] - inside_regress_range = ( - max_regress_distance >= regress_ranges[..., 0]) & ( - max_regress_distance <= regress_ranges[..., 1]) - - # if there are still more than one objects for a location, - # we choose the one with minimal area - areas[inside_gt_bbox_mask == 0] = INF - areas[inside_regress_range == 0] = INF - min_area, min_area_inds = areas.min(dim=1) - - labels = gt_labels[min_area_inds] - labels[min_area == INF] = 0 - bbox_targets = bbox_targets[range(num_points), min_area_inds] - - return labels, bbox_targets - - def centerness_target(self, pos_bbox_targets): - # only calculate pos centerness targets, otherwise there may be nan - left_right = pos_bbox_targets[:, [0, 2]] - top_bottom = pos_bbox_targets[:, [1, 3]] - centerness_targets = ( - left_right.min(dim=-1)[0] / left_right.max(dim=-1)[0]) * ( - top_bottom.min(dim=-1)[0] / top_bottom.max(dim=-1)[0]) - return torch.sqrt(centerness_targets) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/fovea_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/fovea_head.py deleted file mode 100644 index a17e0b127..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/fovea_head.py +++ /dev/null @@ -1,387 +0,0 @@ -import torch -import torch.nn as nn -from mmcv.cnn import normal_init - -from mmdet.core import multi_apply, multiclass_nms -from mmdet.ops import DeformConv -from ..builder import build_loss -from ..registry import HEADS -from ..utils import ConvModule, bias_init_with_prob - -INF = 1e8 - - -class FeatureAlign(nn.Module): - - def __init__(self, - in_channels, - out_channels, - kernel_size=3, - deformable_groups=4): - super(FeatureAlign, self).__init__() - offset_channels = kernel_size * kernel_size * 2 - self.conv_offset = nn.Conv2d( - 4, deformable_groups * offset_channels, 1, bias=False) - self.conv_adaption = DeformConv( - in_channels, - out_channels, - kernel_size=kernel_size, - padding=(kernel_size - 1) // 2, - deformable_groups=deformable_groups) - self.relu = nn.ReLU(inplace=True) - - def init_weights(self): - normal_init(self.conv_offset, std=0.1) - normal_init(self.conv_adaption, std=0.01) - - def forward(self, x, shape): - offset = self.conv_offset(shape) - x = self.relu(self.conv_adaption(x, offset)) - return x - - -@HEADS.register_module -class FoveaHead(nn.Module): - """FoveaBox: Beyond Anchor-based Object Detector - https://arxiv.org/abs/1904.03797 - """ - - def __init__(self, - num_classes, - in_channels, - feat_channels=256, - stacked_convs=4, - strides=(4, 8, 16, 32, 64), - base_edge_list=(16, 32, 64, 128, 256), - scale_ranges=((8, 32), (16, 64), (32, 128), (64, 256), (128, - 512)), - sigma=0.4, - with_deform=False, - deformable_groups=4, - loss_cls=None, - loss_bbox=None, - conv_cfg=None, - norm_cfg=None): - super(FoveaHead, self).__init__() - self.num_classes = num_classes - self.cls_out_channels = num_classes - 1 - self.in_channels = in_channels - self.feat_channels = feat_channels - self.stacked_convs = stacked_convs - self.strides = strides - self.base_edge_list = base_edge_list - self.scale_ranges = scale_ranges - self.sigma = sigma - self.with_deform = with_deform - self.deformable_groups = deformable_groups - self.loss_cls = build_loss(loss_cls) - self.loss_bbox = build_loss(loss_bbox) - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - self._init_layers() - - def _init_layers(self): - self.cls_convs = nn.ModuleList() - self.reg_convs = nn.ModuleList() - # box branch - for i in range(self.stacked_convs): - chn = self.in_channels if i == 0 else self.feat_channels - self.reg_convs.append( - ConvModule( - chn, - self.feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg, - bias=self.norm_cfg is None)) - self.fovea_reg = nn.Conv2d(self.feat_channels, 4, 3, padding=1) - # cls branch - if not self.with_deform: - for i in range(self.stacked_convs): - chn = self.in_channels if i == 0 else self.feat_channels - self.cls_convs.append( - ConvModule( - chn, - self.feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg, - bias=self.norm_cfg is None)) - self.fovea_cls = nn.Conv2d( - self.feat_channels, self.cls_out_channels, 3, padding=1) - else: - self.cls_convs.append( - ConvModule( - self.feat_channels, (self.feat_channels * 4), - 3, - stride=1, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg, - bias=self.norm_cfg is None)) - self.cls_convs.append( - ConvModule((self.feat_channels * 4), (self.feat_channels * 4), - 1, - stride=1, - padding=0, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg, - bias=self.norm_cfg is None)) - self.feature_adaption = FeatureAlign( - self.feat_channels, - self.feat_channels, - kernel_size=3, - deformable_groups=self.deformable_groups) - self.fovea_cls = nn.Conv2d( - int(self.feat_channels * 4), - self.cls_out_channels, - 3, - padding=1) - - def init_weights(self): - for m in self.cls_convs: - normal_init(m.conv, std=0.01) - for m in self.reg_convs: - normal_init(m.conv, std=0.01) - bias_cls = bias_init_with_prob(0.01) - normal_init(self.fovea_cls, std=0.01, bias=bias_cls) - normal_init(self.fovea_reg, std=0.01) - if self.with_deform: - self.feature_adaption.init_weights() - - def forward(self, feats): - return multi_apply(self.forward_single, feats) - - def forward_single(self, x): - cls_feat = x - reg_feat = x - for reg_layer in self.reg_convs: - reg_feat = reg_layer(reg_feat) - bbox_pred = self.fovea_reg(reg_feat) - if self.with_deform: - cls_feat = self.feature_adaption(cls_feat, bbox_pred.exp()) - for cls_layer in self.cls_convs: - cls_feat = cls_layer(cls_feat) - cls_score = self.fovea_cls(cls_feat) - return cls_score, bbox_pred - - def get_points(self, featmap_sizes, dtype, device, flatten=False): - points = [] - for featmap_size in featmap_sizes: - x_range = torch.arange( - featmap_size[1], dtype=dtype, device=device) + 0.5 - y_range = torch.arange( - featmap_size[0], dtype=dtype, device=device) + 0.5 - y, x = torch.meshgrid(y_range, x_range) - if flatten: - points.append((y.flatten(), x.flatten())) - else: - points.append((y, x)) - return points - - def loss(self, - cls_scores, - bbox_preds, - gt_bbox_list, - gt_label_list, - img_metas, - cfg, - gt_bboxes_ignore=None): - assert len(cls_scores) == len(bbox_preds) - - featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] - points = self.get_points(featmap_sizes, bbox_preds[0].dtype, - bbox_preds[0].device) - num_imgs = cls_scores[0].size(0) - flatten_cls_scores = [ - cls_score.permute(0, 2, 3, 1).reshape(-1, self.cls_out_channels) - for cls_score in cls_scores - ] - flatten_bbox_preds = [ - bbox_pred.permute(0, 2, 3, 1).reshape(-1, 4) - for bbox_pred in bbox_preds - ] - flatten_cls_scores = torch.cat(flatten_cls_scores) - flatten_bbox_preds = torch.cat(flatten_bbox_preds) - flatten_labels, flatten_bbox_targets = self.fovea_target( - gt_bbox_list, gt_label_list, featmap_sizes, points) - pos_inds = (flatten_labels > 0).nonzero().view(-1) - num_pos = len(pos_inds) - loss_cls = self.loss_cls( - flatten_cls_scores, flatten_labels, avg_factor=num_pos + num_imgs) - if num_pos > 0: - pos_bbox_preds = flatten_bbox_preds[pos_inds] - pos_bbox_targets = flatten_bbox_targets[pos_inds] - pos_weights = pos_bbox_targets.new_zeros( - pos_bbox_targets.size()) + 1.0 - loss_bbox = self.loss_bbox( - pos_bbox_preds, - pos_bbox_targets, - pos_weights, - avg_factor=num_pos) - else: - loss_bbox = torch.tensor([0], - dtype=flatten_bbox_preds.dtype, - device=flatten_bbox_preds.device) - return dict(loss_cls=loss_cls, loss_bbox=loss_bbox) - - def fovea_target(self, gt_bbox_list, gt_label_list, featmap_sizes, points): - label_list, bbox_target_list = multi_apply( - self.fovea_target_single, - gt_bbox_list, - gt_label_list, - featmap_size_list=featmap_sizes, - point_list=points) - flatten_labels = [ - torch.cat([ - labels_level_img.flatten() for labels_level_img in labels_level - ]) for labels_level in zip(*label_list) - ] - flatten_bbox_targets = [ - torch.cat([ - bbox_targets_level_img.reshape(-1, 4) - for bbox_targets_level_img in bbox_targets_level - ]) for bbox_targets_level in zip(*bbox_target_list) - ] - flatten_labels = torch.cat(flatten_labels) - flatten_bbox_targets = torch.cat(flatten_bbox_targets) - return flatten_labels, flatten_bbox_targets - - def fovea_target_single(self, - gt_bboxes_raw, - gt_labels_raw, - featmap_size_list=None, - point_list=None): - - gt_areas = torch.sqrt((gt_bboxes_raw[:, 2] - gt_bboxes_raw[:, 0]) * - (gt_bboxes_raw[:, 3] - gt_bboxes_raw[:, 1])) - label_list = [] - bbox_target_list = [] - # for each pyramid, find the cls and box target - for base_len, (lower_bound, upper_bound), stride, featmap_size, \ - (y, x) in zip(self.base_edge_list, self.scale_ranges, - self.strides, featmap_size_list, point_list): - labels = gt_labels_raw.new_zeros(featmap_size) - bbox_targets = gt_bboxes_raw.new(featmap_size[0], featmap_size[1], - 4) + 1 - # scale assignment - hit_indices = ((gt_areas >= lower_bound) & - (gt_areas <= upper_bound)).nonzero().flatten() - if len(hit_indices) == 0: - label_list.append(labels) - bbox_target_list.append(torch.log(bbox_targets)) - continue - _, hit_index_order = torch.sort(-gt_areas[hit_indices]) - hit_indices = hit_indices[hit_index_order] - gt_bboxes = gt_bboxes_raw[hit_indices, :] / stride - gt_labels = gt_labels_raw[hit_indices] - half_w = 0.5 * (gt_bboxes[:, 2] - gt_bboxes[:, 0]) - half_h = 0.5 * (gt_bboxes[:, 3] - gt_bboxes[:, 1]) - # valid fovea area: left, right, top, down - pos_left = torch.ceil( - gt_bboxes[:, 0] + (1 - self.sigma) * half_w - 0.5).long().\ - clamp(0, featmap_size[1] - 1) - pos_right = torch.floor( - gt_bboxes[:, 0] + (1 + self.sigma) * half_w - 0.5).long().\ - clamp(0, featmap_size[1] - 1) - pos_top = torch.ceil( - gt_bboxes[:, 1] + (1 - self.sigma) * half_h - 0.5).long().\ - clamp(0, featmap_size[0] - 1) - pos_down = torch.floor( - gt_bboxes[:, 1] + (1 + self.sigma) * half_h - 0.5).long().\ - clamp(0, featmap_size[0] - 1) - for px1, py1, px2, py2, label, (gt_x1, gt_y1, gt_x2, gt_y2) in \ - zip(pos_left, pos_top, pos_right, pos_down, gt_labels, - gt_bboxes_raw[hit_indices, :]): - labels[py1:py2 + 1, px1:px2 + 1] = label - bbox_targets[py1:py2 + 1, px1:px2 + 1, 0] = \ - (stride * x[py1:py2 + 1, px1:px2 + 1] - gt_x1) / base_len - bbox_targets[py1:py2 + 1, px1:px2 + 1, 1] = \ - (stride * y[py1:py2 + 1, px1:px2 + 1] - gt_y1) / base_len - bbox_targets[py1:py2 + 1, px1:px2 + 1, 2] = \ - (gt_x2 - stride * x[py1:py2 + 1, px1:px2 + 1]) / base_len - bbox_targets[py1:py2 + 1, px1:px2 + 1, 3] = \ - (gt_y2 - stride * y[py1:py2 + 1, px1:px2 + 1]) / base_len - bbox_targets = bbox_targets.clamp(min=1. / 16, max=16.) - label_list.append(labels) - bbox_target_list.append(torch.log(bbox_targets)) - return label_list, bbox_target_list - - def get_bboxes(self, cls_scores, bbox_preds, img_metas, cfg, rescale=None): - assert len(cls_scores) == len(bbox_preds) - num_levels = len(cls_scores) - featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] - points = self.get_points( - featmap_sizes, - bbox_preds[0].dtype, - bbox_preds[0].device, - flatten=True) - result_list = [] - for img_id in range(len(img_metas)): - cls_score_list = [ - cls_scores[i][img_id].detach() for i in range(num_levels) - ] - bbox_pred_list = [ - bbox_preds[i][img_id].detach() for i in range(num_levels) - ] - img_shape = img_metas[img_id]['img_shape'] - scale_factor = img_metas[img_id]['scale_factor'] - det_bboxes = self.get_bboxes_single(cls_score_list, bbox_pred_list, - featmap_sizes, points, - img_shape, scale_factor, cfg, - rescale) - result_list.append(det_bboxes) - return result_list - - def get_bboxes_single(self, - cls_scores, - bbox_preds, - featmap_sizes, - point_list, - img_shape, - scale_factor, - cfg, - rescale=False): - assert len(cls_scores) == len(bbox_preds) == len(point_list) - det_bboxes = [] - det_scores = [] - for cls_score, bbox_pred, featmap_size, stride, base_len, (y, x) \ - in zip(cls_scores, bbox_preds, featmap_sizes, self.strides, - self.base_edge_list, point_list): - assert cls_score.size()[-2:] == bbox_pred.size()[-2:] - scores = cls_score.permute(1, 2, 0).reshape( - -1, self.cls_out_channels).sigmoid() - bbox_pred = bbox_pred.permute(1, 2, 0).reshape(-1, 4).exp() - nms_pre = cfg.get('nms_pre', -1) - if (nms_pre > 0) and (scores.shape[0] > nms_pre): - max_scores, _ = scores.max(dim=1) - _, topk_inds = max_scores.topk(nms_pre) - bbox_pred = bbox_pred[topk_inds, :] - scores = scores[topk_inds, :] - y = y[topk_inds] - x = x[topk_inds] - x1 = (stride * x - base_len * bbox_pred[:, 0]).\ - clamp(min=0, max=img_shape[1] - 1) - y1 = (stride * y - base_len * bbox_pred[:, 1]).\ - clamp(min=0, max=img_shape[0] - 1) - x2 = (stride * x + base_len * bbox_pred[:, 2]).\ - clamp(min=0, max=img_shape[1] - 1) - y2 = (stride * y + base_len * bbox_pred[:, 3]).\ - clamp(min=0, max=img_shape[0] - 1) - bboxes = torch.stack([x1, y1, x2, y2], -1) - det_bboxes.append(bboxes) - det_scores.append(scores) - det_bboxes = torch.cat(det_bboxes) - if rescale: - det_bboxes /= det_bboxes.new_tensor(scale_factor) - det_scores = torch.cat(det_scores) - padding = det_scores.new_zeros(det_scores.shape[0], 1) - det_scores = torch.cat([padding, det_scores], dim=1) - det_bboxes, det_labels = multiclass_nms(det_bboxes, det_scores, - cfg.score_thr, cfg.nms, - cfg.max_per_img) - return det_bboxes, det_labels diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/free_anchor_retina_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/free_anchor_retina_head.py deleted file mode 100644 index 3179aad20..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/free_anchor_retina_head.py +++ /dev/null @@ -1,188 +0,0 @@ -import torch -import torch.nn.functional as F - -from mmdet.core import bbox2delta, bbox_overlaps, delta2bbox -from ..registry import HEADS -from .retina_head import RetinaHead - - -@HEADS.register_module -class FreeAnchorRetinaHead(RetinaHead): - - def __init__(self, - num_classes, - in_channels, - stacked_convs=4, - octave_base_scale=4, - scales_per_octave=3, - conv_cfg=None, - norm_cfg=None, - pre_anchor_topk=50, - bbox_thr=0.6, - gamma=2.0, - alpha=0.5, - **kwargs): - super(FreeAnchorRetinaHead, - self).__init__(num_classes, in_channels, stacked_convs, - octave_base_scale, scales_per_octave, conv_cfg, - norm_cfg, **kwargs) - - self.pre_anchor_topk = pre_anchor_topk - self.bbox_thr = bbox_thr - self.gamma = gamma - self.alpha = alpha - - def loss(self, - cls_scores, - bbox_preds, - gt_bboxes, - gt_labels, - img_metas, - cfg, - gt_bboxes_ignore=None): - featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] - assert len(featmap_sizes) == len(self.anchor_generators) - - anchor_list, _ = self.get_anchors(featmap_sizes, img_metas) - anchors = [torch.cat(anchor) for anchor in anchor_list] - - # concatenate each level - cls_scores = [ - cls.permute(0, 2, 3, - 1).reshape(cls.size(0), -1, self.cls_out_channels) - for cls in cls_scores - ] - bbox_preds = [ - bbox_pred.permute(0, 2, 3, 1).reshape(bbox_pred.size(0), -1, 4) - for bbox_pred in bbox_preds - ] - cls_scores = torch.cat(cls_scores, dim=1) - bbox_preds = torch.cat(bbox_preds, dim=1) - - cls_prob = torch.sigmoid(cls_scores) - box_prob = [] - num_pos = 0 - positive_losses = [] - for _, (anchors_, gt_labels_, gt_bboxes_, cls_prob_, - bbox_preds_) in enumerate( - zip(anchors, gt_labels, gt_bboxes, cls_prob, bbox_preds)): - gt_labels_ -= 1 - - with torch.no_grad(): - # box_localization: a_{j}^{loc}, shape: [j, 4] - pred_boxes = delta2bbox(anchors_, bbox_preds_, - self.target_means, self.target_stds) - - # object_box_iou: IoU_{ij}^{loc}, shape: [i, j] - object_box_iou = bbox_overlaps(gt_bboxes_, pred_boxes) - - # object_box_prob: P{a_{j} -> b_{i}}, shape: [i, j] - t1 = self.bbox_thr - t2 = object_box_iou.max( - dim=1, keepdim=True).values.clamp(min=t1 + 1e-12) - object_box_prob = ((object_box_iou - t1) / (t2 - t1)).clamp( - min=0, max=1) - - # object_cls_box_prob: P{a_{j} -> b_{i}}, shape: [i, c, j] - num_obj = gt_labels_.size(0) - indices = torch.stack( - [torch.arange(num_obj).type_as(gt_labels_), gt_labels_], - dim=0) - object_cls_box_prob = torch.sparse_coo_tensor( - indices, object_box_prob) - - # image_box_iou: P{a_{j} \in A_{+}}, shape: [c, j] - """ - from "start" to "end" implement: - image_box_iou = torch.sparse.max(object_cls_box_prob, - dim=0).t() - - """ - # start - box_cls_prob = torch.sparse.sum( - object_cls_box_prob, dim=0).to_dense() - - indices = torch.nonzero(box_cls_prob).t_() - if indices.numel() == 0: - image_box_prob = torch.zeros( - anchors_.size(0), - self.cls_out_channels).type_as(object_box_prob) - else: - nonzero_box_prob = torch.where( - (gt_labels_.unsqueeze(dim=-1) == indices[0]), - object_box_prob[:, indices[1]], - torch.tensor( - [0]).type_as(object_box_prob)).max(dim=0).values - - # upmap to shape [j, c] - image_box_prob = torch.sparse_coo_tensor( - indices.flip([0]), - nonzero_box_prob, - size=(anchors_.size(0), - self.cls_out_channels)).to_dense() - # end - - box_prob.append(image_box_prob) - - # construct bags for objects - match_quality_matrix = bbox_overlaps(gt_bboxes_, anchors_) - _, matched = torch.topk( - match_quality_matrix, - self.pre_anchor_topk, - dim=1, - sorted=False) - del match_quality_matrix - - # matched_cls_prob: P_{ij}^{cls} - matched_cls_prob = torch.gather( - cls_prob_[matched], 2, - gt_labels_.view(-1, 1, 1).repeat(1, self.pre_anchor_topk, - 1)).squeeze(2) - - # matched_box_prob: P_{ij}^{loc} - matched_anchors = anchors_[matched] - matched_object_targets = bbox2delta( - matched_anchors, - gt_bboxes_.unsqueeze(dim=1).expand_as(matched_anchors), - self.target_means, self.target_stds) - loss_bbox = self.loss_bbox( - bbox_preds_[matched], - matched_object_targets, - reduction_override='none').sum(-1) - matched_box_prob = torch.exp(-loss_bbox) - - # positive_losses: {-log( Mean-max(P_{ij}^{cls} * P_{ij}^{loc}) )} - num_pos += len(gt_bboxes_) - positive_losses.append( - self.positive_bag_loss(matched_cls_prob, matched_box_prob)) - positive_loss = torch.cat(positive_losses).sum() / max(1, num_pos) - - # box_prob: P{a_{j} \in A_{+}} - box_prob = torch.stack(box_prob, dim=0) - - # negative_loss: - # \sum_{j}{ FL((1 - P{a_{j} \in A_{+}}) * (1 - P_{j}^{bg})) } / n||B|| - negative_loss = self.negative_bag_loss(cls_prob, box_prob).sum() / max( - 1, num_pos * self.pre_anchor_topk) - - losses = { - 'positive_bag_loss': positive_loss, - 'negative_bag_loss': negative_loss - } - return losses - - def positive_bag_loss(self, matched_cls_prob, matched_box_prob): - # bag_prob = Mean-max(matched_prob) - matched_prob = matched_cls_prob * matched_box_prob - weight = 1 / torch.clamp(1 - matched_prob, 1e-12, None) - weight /= weight.sum(dim=1).unsqueeze(dim=-1) - bag_prob = (weight * matched_prob).sum(dim=1) - # positive_bag_loss = -self.alpha * log(bag_prob) - return self.alpha * F.binary_cross_entropy( - bag_prob, torch.ones_like(bag_prob), reduction='none') - - def negative_bag_loss(self, cls_prob, box_prob): - prob = cls_prob * (1 - box_prob) - negative_bag_loss = prob**self.gamma * F.binary_cross_entropy( - prob, torch.zeros_like(prob), reduction='none') - return (1 - self.alpha) * negative_bag_loss diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ga_retina_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ga_retina_head.py deleted file mode 100644 index 73f89d725..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ga_retina_head.py +++ /dev/null @@ -1,107 +0,0 @@ -import torch.nn as nn -from mmcv.cnn import normal_init - -from mmdet.ops import MaskedConv2d -from ..registry import HEADS -from ..utils import ConvModule, bias_init_with_prob -from .guided_anchor_head import FeatureAdaption, GuidedAnchorHead - - -@HEADS.register_module -class GARetinaHead(GuidedAnchorHead): - """Guided-Anchor-based RetinaNet head.""" - - def __init__(self, - num_classes, - in_channels, - stacked_convs=4, - conv_cfg=None, - norm_cfg=None, - **kwargs): - self.stacked_convs = stacked_convs - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - super(GARetinaHead, self).__init__(num_classes, in_channels, **kwargs) - - def _init_layers(self): - self.relu = nn.ReLU(inplace=True) - self.cls_convs = nn.ModuleList() - self.reg_convs = nn.ModuleList() - for i in range(self.stacked_convs): - chn = self.in_channels if i == 0 else self.feat_channels - self.cls_convs.append( - ConvModule( - chn, - self.feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg)) - self.reg_convs.append( - ConvModule( - chn, - self.feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg)) - - self.conv_loc = nn.Conv2d(self.feat_channels, 1, 1) - self.conv_shape = nn.Conv2d(self.feat_channels, self.num_anchors * 2, - 1) - self.feature_adaption_cls = FeatureAdaption( - self.feat_channels, - self.feat_channels, - kernel_size=3, - deformable_groups=self.deformable_groups) - self.feature_adaption_reg = FeatureAdaption( - self.feat_channels, - self.feat_channels, - kernel_size=3, - deformable_groups=self.deformable_groups) - self.retina_cls = MaskedConv2d( - self.feat_channels, - self.num_anchors * self.cls_out_channels, - 3, - padding=1) - self.retina_reg = MaskedConv2d( - self.feat_channels, self.num_anchors * 4, 3, padding=1) - - def init_weights(self): - for m in self.cls_convs: - normal_init(m.conv, std=0.01) - for m in self.reg_convs: - normal_init(m.conv, std=0.01) - - self.feature_adaption_cls.init_weights() - self.feature_adaption_reg.init_weights() - - bias_cls = bias_init_with_prob(0.01) - normal_init(self.conv_loc, std=0.01, bias=bias_cls) - normal_init(self.conv_shape, std=0.01) - normal_init(self.retina_cls, std=0.01, bias=bias_cls) - normal_init(self.retina_reg, std=0.01) - - def forward_single(self, x): - cls_feat = x - reg_feat = x - for cls_conv in self.cls_convs: - cls_feat = cls_conv(cls_feat) - for reg_conv in self.reg_convs: - reg_feat = reg_conv(reg_feat) - - loc_pred = self.conv_loc(cls_feat) - shape_pred = self.conv_shape(reg_feat) - - cls_feat = self.feature_adaption_cls(cls_feat, shape_pred) - reg_feat = self.feature_adaption_reg(reg_feat, shape_pred) - - if not self.training: - mask = loc_pred.sigmoid()[0] >= self.loc_filter_thr - else: - mask = None - cls_score = self.retina_cls(cls_feat, mask) - bbox_pred = self.retina_reg(reg_feat, mask) - return cls_score, bbox_pred, shape_pred, loc_pred diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ga_rpn_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ga_rpn_head.py deleted file mode 100644 index 11512ffc5..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ga_rpn_head.py +++ /dev/null @@ -1,127 +0,0 @@ -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import normal_init - -from mmdet.core import delta2bbox -from mmdet.ops import nms -from ..registry import HEADS -from .guided_anchor_head import GuidedAnchorHead - - -@HEADS.register_module -class GARPNHead(GuidedAnchorHead): - """Guided-Anchor-based RPN head.""" - - def __init__(self, in_channels, **kwargs): - super(GARPNHead, self).__init__(2, in_channels, **kwargs) - - def _init_layers(self): - self.rpn_conv = nn.Conv2d( - self.in_channels, self.feat_channels, 3, padding=1) - super(GARPNHead, self)._init_layers() - - def init_weights(self): - normal_init(self.rpn_conv, std=0.01) - super(GARPNHead, self).init_weights() - - def forward_single(self, x): - x = self.rpn_conv(x) - x = F.relu(x, inplace=True) - (cls_score, bbox_pred, shape_pred, - loc_pred) = super(GARPNHead, self).forward_single(x) - return cls_score, bbox_pred, shape_pred, loc_pred - - def loss(self, - cls_scores, - bbox_preds, - shape_preds, - loc_preds, - gt_bboxes, - img_metas, - cfg, - gt_bboxes_ignore=None): - losses = super(GARPNHead, self).loss( - cls_scores, - bbox_preds, - shape_preds, - loc_preds, - gt_bboxes, - None, - img_metas, - cfg, - gt_bboxes_ignore=gt_bboxes_ignore) - return dict( - loss_rpn_cls=losses['loss_cls'], - loss_rpn_bbox=losses['loss_bbox'], - loss_anchor_shape=losses['loss_shape'], - loss_anchor_loc=losses['loss_loc']) - - def get_bboxes_single(self, - cls_scores, - bbox_preds, - mlvl_anchors, - mlvl_masks, - img_shape, - scale_factor, - cfg, - rescale=False): - mlvl_proposals = [] - for idx in range(len(cls_scores)): - rpn_cls_score = cls_scores[idx] - rpn_bbox_pred = bbox_preds[idx] - anchors = mlvl_anchors[idx] - mask = mlvl_masks[idx] - assert rpn_cls_score.size()[-2:] == rpn_bbox_pred.size()[-2:] - # if no location is kept, end. - if mask.sum() == 0: - continue - rpn_cls_score = rpn_cls_score.permute(1, 2, 0) - if self.use_sigmoid_cls: - rpn_cls_score = rpn_cls_score.reshape(-1) - scores = rpn_cls_score.sigmoid() - else: - rpn_cls_score = rpn_cls_score.reshape(-1, 2) - scores = rpn_cls_score.softmax(dim=1)[:, 1] - # filter scores, bbox_pred w.r.t. mask. - # anchors are filtered in get_anchors() beforehand. - scores = scores[mask] - rpn_bbox_pred = rpn_bbox_pred.permute(1, 2, 0).reshape(-1, - 4)[mask, :] - if scores.dim() == 0: - rpn_bbox_pred = rpn_bbox_pred.unsqueeze(0) - anchors = anchors.unsqueeze(0) - scores = scores.unsqueeze(0) - # filter anchors, bbox_pred, scores w.r.t. scores - if cfg.nms_pre > 0 and scores.shape[0] > cfg.nms_pre: - _, topk_inds = scores.topk(cfg.nms_pre) - rpn_bbox_pred = rpn_bbox_pred[topk_inds, :] - anchors = anchors[topk_inds, :] - scores = scores[topk_inds] - # get proposals w.r.t. anchors and rpn_bbox_pred - proposals = delta2bbox(anchors, rpn_bbox_pred, self.target_means, - self.target_stds, img_shape) - # filter out too small bboxes - if cfg.min_bbox_size > 0: - w = proposals[:, 2] - proposals[:, 0] + 1 - h = proposals[:, 3] - proposals[:, 1] + 1 - valid_inds = torch.nonzero((w >= cfg.min_bbox_size) & - (h >= cfg.min_bbox_size)).squeeze() - proposals = proposals[valid_inds, :] - scores = scores[valid_inds] - proposals = torch.cat([proposals, scores.unsqueeze(-1)], dim=-1) - # NMS in current level - proposals, _ = nms(proposals, cfg.nms_thr) - proposals = proposals[:cfg.nms_post, :] - mlvl_proposals.append(proposals) - proposals = torch.cat(mlvl_proposals, 0) - if cfg.nms_across_levels: - # NMS across multi levels - proposals, _ = nms(proposals, cfg.nms_thr) - proposals = proposals[:cfg.max_num, :] - else: - scores = proposals[:, 4] - num = min(cfg.max_num, proposals.shape[0]) - _, topk_inds = scores.topk(num) - proposals = proposals[topk_inds, :] - return proposals diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/guided_anchor_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/guided_anchor_head.py deleted file mode 100644 index 9fdf4f664..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/guided_anchor_head.py +++ /dev/null @@ -1,621 +0,0 @@ -from __future__ import division - -import numpy as np -import torch -import torch.nn as nn -from mmcv.cnn import normal_init - -from mmdet.core import (AnchorGenerator, anchor_inside_flags, anchor_target, - delta2bbox, force_fp32, ga_loc_target, ga_shape_target, - multi_apply, multiclass_nms) -from mmdet.ops import DeformConv, MaskedConv2d -from ..builder import build_loss -from ..registry import HEADS -from ..utils import bias_init_with_prob -from .anchor_head import AnchorHead - - -class FeatureAdaption(nn.Module): - """Feature Adaption Module. - - Feature Adaption Module is implemented based on DCN v1. - It uses anchor shape prediction rather than feature map to - predict offsets of deformable conv layer. - - Args: - in_channels (int): Number of channels in the input feature map. - out_channels (int): Number of channels in the output feature map. - kernel_size (int): Deformable conv kernel size. - deformable_groups (int): Deformable conv group size. - """ - - def __init__(self, - in_channels, - out_channels, - kernel_size=3, - deformable_groups=4): - super(FeatureAdaption, self).__init__() - offset_channels = kernel_size * kernel_size * 2 - self.conv_offset = nn.Conv2d( - 2, deformable_groups * offset_channels, 1, bias=False) - self.conv_adaption = DeformConv( - in_channels, - out_channels, - kernel_size=kernel_size, - padding=(kernel_size - 1) // 2, - deformable_groups=deformable_groups) - self.relu = nn.ReLU(inplace=True) - - def init_weights(self): - normal_init(self.conv_offset, std=0.1) - normal_init(self.conv_adaption, std=0.01) - - def forward(self, x, shape): - offset = self.conv_offset(shape.detach()) - x = self.relu(self.conv_adaption(x, offset)) - return x - - -@HEADS.register_module -class GuidedAnchorHead(AnchorHead): - """Guided-Anchor-based head (GA-RPN, GA-RetinaNet, etc.). - - This GuidedAnchorHead will predict high-quality feature guided - anchors and locations where anchors will be kept in inference. - There are mainly 3 categories of bounding-boxes. - - Sampled (9) pairs for target assignment. (approxes) - - The square boxes where the predicted anchors are based on. - (squares) - - Guided anchors. - Please refer to https://arxiv.org/abs/1901.03278 for more details. - - Args: - num_classes (int): Number of classes. - in_channels (int): Number of channels in the input feature map. - feat_channels (int): Number of hidden channels. - octave_base_scale (int): Base octave scale of each level of - feature map. - scales_per_octave (int): Number of octave scales in each level of - feature map - octave_ratios (Iterable): octave aspect ratios. - anchor_strides (Iterable): Anchor strides. - anchor_base_sizes (Iterable): Anchor base sizes. - anchoring_means (Iterable): Mean values of anchoring targets. - anchoring_stds (Iterable): Std values of anchoring targets. - target_means (Iterable): Mean values of regression targets. - target_stds (Iterable): Std values of regression targets. - deformable_groups: (int): Group number of DCN in - FeatureAdaption module. - loc_filter_thr (float): Threshold to filter out unconcerned regions. - loss_loc (dict): Config of location loss. - loss_shape (dict): Config of anchor shape loss. - loss_cls (dict): Config of classification loss. - loss_bbox (dict): Config of bbox regression loss. - """ - - def __init__( - self, - num_classes, - in_channels, - feat_channels=256, - octave_base_scale=8, - scales_per_octave=3, - octave_ratios=[0.5, 1.0, 2.0], - anchor_strides=[4, 8, 16, 32, 64], - anchor_base_sizes=None, - anchoring_means=(.0, .0, .0, .0), - anchoring_stds=(1.0, 1.0, 1.0, 1.0), - target_means=(.0, .0, .0, .0), - target_stds=(1.0, 1.0, 1.0, 1.0), - deformable_groups=4, - loc_filter_thr=0.01, - loss_loc=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=1.0), - loss_shape=dict(type='BoundedIoULoss', beta=0.2, loss_weight=1.0), - loss_cls=dict( - type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0), - loss_bbox=dict(type='SmoothL1Loss', beta=1.0, - loss_weight=1.0)): # yapf: disable - super(AnchorHead, self).__init__() - self.in_channels = in_channels - self.num_classes = num_classes - self.feat_channels = feat_channels - self.octave_base_scale = octave_base_scale - self.scales_per_octave = scales_per_octave - self.octave_scales = octave_base_scale * np.array( - [2**(i / scales_per_octave) for i in range(scales_per_octave)]) - self.approxs_per_octave = len(self.octave_scales) * len(octave_ratios) - self.octave_ratios = octave_ratios - self.anchor_strides = anchor_strides - self.anchor_base_sizes = list( - anchor_strides) if anchor_base_sizes is None else anchor_base_sizes - self.anchoring_means = anchoring_means - self.anchoring_stds = anchoring_stds - self.target_means = target_means - self.target_stds = target_stds - self.deformable_groups = deformable_groups - self.loc_filter_thr = loc_filter_thr - self.approx_generators = [] - self.square_generators = [] - for anchor_base in self.anchor_base_sizes: - # Generators for approxs - self.approx_generators.append( - AnchorGenerator(anchor_base, self.octave_scales, - self.octave_ratios)) - # Generators for squares - self.square_generators.append( - AnchorGenerator(anchor_base, [self.octave_base_scale], [1.0])) - # one anchor per location - self.num_anchors = 1 - self.use_sigmoid_cls = loss_cls.get('use_sigmoid', False) - self.cls_focal_loss = loss_cls['type'] in ['FocalLoss'] - self.loc_focal_loss = loss_loc['type'] in ['FocalLoss'] - if self.use_sigmoid_cls: - self.cls_out_channels = self.num_classes - 1 - else: - self.cls_out_channels = self.num_classes - - # build losses - self.loss_loc = build_loss(loss_loc) - self.loss_shape = build_loss(loss_shape) - self.loss_cls = build_loss(loss_cls) - self.loss_bbox = build_loss(loss_bbox) - - self.fp16_enabled = False - - self._init_layers() - - def _init_layers(self): - self.relu = nn.ReLU(inplace=True) - self.conv_loc = nn.Conv2d(self.in_channels, 1, 1) - self.conv_shape = nn.Conv2d(self.in_channels, self.num_anchors * 2, 1) - self.feature_adaption = FeatureAdaption( - self.in_channels, - self.feat_channels, - kernel_size=3, - deformable_groups=self.deformable_groups) - self.conv_cls = MaskedConv2d(self.feat_channels, - self.num_anchors * self.cls_out_channels, - 1) - self.conv_reg = MaskedConv2d(self.feat_channels, self.num_anchors * 4, - 1) - - def init_weights(self): - normal_init(self.conv_cls, std=0.01) - normal_init(self.conv_reg, std=0.01) - - bias_cls = bias_init_with_prob(0.01) - normal_init(self.conv_loc, std=0.01, bias=bias_cls) - normal_init(self.conv_shape, std=0.01) - - self.feature_adaption.init_weights() - - def forward_single(self, x): - loc_pred = self.conv_loc(x) - shape_pred = self.conv_shape(x) - x = self.feature_adaption(x, shape_pred) - # masked conv is only used during inference for speed-up - if not self.training: - mask = loc_pred.sigmoid()[0] >= self.loc_filter_thr - else: - mask = None - cls_score = self.conv_cls(x, mask) - bbox_pred = self.conv_reg(x, mask) - return cls_score, bbox_pred, shape_pred, loc_pred - - def forward(self, feats): - return multi_apply(self.forward_single, feats) - - def get_sampled_approxs(self, - featmap_sizes, - img_metas, - cfg, - device='cuda'): - """Get sampled approxs and inside flags according to feature map sizes. - - Args: - featmap_sizes (list[tuple]): Multi-level feature map sizes. - img_metas (list[dict]): Image meta info. - device (torch.device | str): device for returned tensors - - Returns: - tuple: approxes of each image, inside flags of each image - """ - num_imgs = len(img_metas) - num_levels = len(featmap_sizes) - - # since feature map sizes of all images are the same, we only compute - # approxes for one time - multi_level_approxs = [] - for i in range(num_levels): - approxs = self.approx_generators[i].grid_anchors( - featmap_sizes[i], self.anchor_strides[i], device=device) - multi_level_approxs.append(approxs) - approxs_list = [multi_level_approxs for _ in range(num_imgs)] - - # for each image, we compute inside flags of multi level approxes - inside_flag_list = [] - for img_id, img_meta in enumerate(img_metas): - multi_level_flags = [] - multi_level_approxs = approxs_list[img_id] - for i in range(num_levels): - approxs = multi_level_approxs[i] - anchor_stride = self.anchor_strides[i] - feat_h, feat_w = featmap_sizes[i] - h, w = img_meta['pad_shape'][:2] - valid_feat_h = min(int(np.ceil(h / anchor_stride)), feat_h) - valid_feat_w = min(int(np.ceil(w / anchor_stride)), feat_w) - flags = self.approx_generators[i].valid_flags( - (feat_h, feat_w), (valid_feat_h, valid_feat_w), - device=device) - inside_flags_list = [] - for i in range(self.approxs_per_octave): - split_valid_flags = flags[i::self.approxs_per_octave] - split_approxs = approxs[i::self.approxs_per_octave, :] - inside_flags = anchor_inside_flags( - split_approxs, split_valid_flags, - img_meta['img_shape'][:2], cfg.allowed_border) - inside_flags_list.append(inside_flags) - # inside_flag for a position is true if any anchor in this - # position is true - inside_flags = ( - torch.stack(inside_flags_list, 0).sum(dim=0) > 0) - multi_level_flags.append(inside_flags) - inside_flag_list.append(multi_level_flags) - return approxs_list, inside_flag_list - - def get_anchors(self, - featmap_sizes, - shape_preds, - loc_preds, - img_metas, - use_loc_filter=False, - device='cuda'): - """Get squares according to feature map sizes and guided - anchors. - - Args: - featmap_sizes (list[tuple]): Multi-level feature map sizes. - shape_preds (list[tensor]): Multi-level shape predictions. - loc_preds (list[tensor]): Multi-level location predictions. - img_metas (list[dict]): Image meta info. - use_loc_filter (bool): Use loc filter or not. - device (torch.device | str): device for returned tensors - - Returns: - tuple: square approxs of each image, guided anchors of each image, - loc masks of each image - """ - num_imgs = len(img_metas) - num_levels = len(featmap_sizes) - - # since feature map sizes of all images are the same, we only compute - # squares for one time - multi_level_squares = [] - for i in range(num_levels): - squares = self.square_generators[i].grid_anchors( - featmap_sizes[i], self.anchor_strides[i], device=device) - multi_level_squares.append(squares) - squares_list = [multi_level_squares for _ in range(num_imgs)] - - # for each image, we compute multi level guided anchors - guided_anchors_list = [] - loc_mask_list = [] - for img_id, img_meta in enumerate(img_metas): - multi_level_guided_anchors = [] - multi_level_loc_mask = [] - for i in range(num_levels): - squares = squares_list[img_id][i] - shape_pred = shape_preds[i][img_id] - loc_pred = loc_preds[i][img_id] - guided_anchors, loc_mask = self.get_guided_anchors_single( - squares, - shape_pred, - loc_pred, - use_loc_filter=use_loc_filter) - multi_level_guided_anchors.append(guided_anchors) - multi_level_loc_mask.append(loc_mask) - guided_anchors_list.append(multi_level_guided_anchors) - loc_mask_list.append(multi_level_loc_mask) - return squares_list, guided_anchors_list, loc_mask_list - - def get_guided_anchors_single(self, - squares, - shape_pred, - loc_pred, - use_loc_filter=False): - """Get guided anchors and loc masks for a single level. - - Args: - square (tensor): Squares of a single level. - shape_pred (tensor): Shape predections of a single level. - loc_pred (tensor): Loc predections of a single level. - use_loc_filter (list[tensor]): Use loc filter or not. - - Returns: - tuple: guided anchors, location masks - """ - # calculate location filtering mask - loc_pred = loc_pred.sigmoid().detach() - if use_loc_filter: - loc_mask = loc_pred >= self.loc_filter_thr - else: - loc_mask = loc_pred >= 0.0 - mask = loc_mask.permute(1, 2, 0).expand(-1, -1, self.num_anchors) - mask = mask.contiguous().view(-1) - # calculate guided anchors - squares = squares[mask] - anchor_deltas = shape_pred.permute(1, 2, 0).contiguous().view( - -1, 2).detach()[mask] - bbox_deltas = anchor_deltas.new_full(squares.size(), 0) - bbox_deltas[:, 2:] = anchor_deltas - guided_anchors = delta2bbox( - squares, - bbox_deltas, - self.anchoring_means, - self.anchoring_stds, - wh_ratio_clip=1e-6) - return guided_anchors, mask - - def loss_shape_single(self, shape_pred, bbox_anchors, bbox_gts, - anchor_weights, anchor_total_num): - shape_pred = shape_pred.permute(0, 2, 3, 1).contiguous().view(-1, 2) - bbox_anchors = bbox_anchors.contiguous().view(-1, 4) - bbox_gts = bbox_gts.contiguous().view(-1, 4) - anchor_weights = anchor_weights.contiguous().view(-1, 4) - bbox_deltas = bbox_anchors.new_full(bbox_anchors.size(), 0) - bbox_deltas[:, 2:] += shape_pred - # filter out negative samples to speed-up weighted_bounded_iou_loss - inds = torch.nonzero(anchor_weights[:, 0] > 0).squeeze(1) - bbox_deltas_ = bbox_deltas[inds] - bbox_anchors_ = bbox_anchors[inds] - bbox_gts_ = bbox_gts[inds] - anchor_weights_ = anchor_weights[inds] - pred_anchors_ = delta2bbox( - bbox_anchors_, - bbox_deltas_, - self.anchoring_means, - self.anchoring_stds, - wh_ratio_clip=1e-6) - loss_shape = self.loss_shape( - pred_anchors_, - bbox_gts_, - anchor_weights_, - avg_factor=anchor_total_num) - return loss_shape - - def loss_loc_single(self, loc_pred, loc_target, loc_weight, loc_avg_factor, - cfg): - loss_loc = self.loss_loc( - loc_pred.reshape(-1, 1), - loc_target.reshape(-1, 1).long(), - loc_weight.reshape(-1, 1), - avg_factor=loc_avg_factor) - return loss_loc - - @force_fp32( - apply_to=('cls_scores', 'bbox_preds', 'shape_preds', 'loc_preds')) - def loss(self, - cls_scores, - bbox_preds, - shape_preds, - loc_preds, - gt_bboxes, - gt_labels, - img_metas, - cfg, - gt_bboxes_ignore=None): - featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] - assert len(featmap_sizes) == len(self.approx_generators) - - device = cls_scores[0].device - - # get loc targets - loc_targets, loc_weights, loc_avg_factor = ga_loc_target( - gt_bboxes, - featmap_sizes, - self.octave_base_scale, - self.anchor_strides, - center_ratio=cfg.center_ratio, - ignore_ratio=cfg.ignore_ratio) - - # get sampled approxes - approxs_list, inside_flag_list = self.get_sampled_approxs( - featmap_sizes, img_metas, cfg, device=device) - # get squares and guided anchors - squares_list, guided_anchors_list, _ = self.get_anchors( - featmap_sizes, shape_preds, loc_preds, img_metas, device=device) - - # get shape targets - sampling = False if not hasattr(cfg, 'ga_sampler') else True - shape_targets = ga_shape_target( - approxs_list, - inside_flag_list, - squares_list, - gt_bboxes, - img_metas, - self.approxs_per_octave, - cfg, - sampling=sampling) - if shape_targets is None: - return None - (bbox_anchors_list, bbox_gts_list, anchor_weights_list, anchor_fg_num, - anchor_bg_num) = shape_targets - anchor_total_num = ( - anchor_fg_num if not sampling else anchor_fg_num + anchor_bg_num) - - # get anchor targets - sampling = False if self.cls_focal_loss else True - label_channels = self.cls_out_channels if self.use_sigmoid_cls else 1 - cls_reg_targets = anchor_target( - guided_anchors_list, - inside_flag_list, - gt_bboxes, - img_metas, - self.target_means, - self.target_stds, - cfg, - gt_bboxes_ignore_list=gt_bboxes_ignore, - gt_labels_list=gt_labels, - label_channels=label_channels, - sampling=sampling) - if cls_reg_targets is None: - return None - (labels_list, label_weights_list, bbox_targets_list, bbox_weights_list, - num_total_pos, num_total_neg) = cls_reg_targets - num_total_samples = ( - num_total_pos if self.cls_focal_loss else num_total_pos + - num_total_neg) - - # get classification and bbox regression losses - losses_cls, losses_bbox = multi_apply( - self.loss_single, - cls_scores, - bbox_preds, - labels_list, - label_weights_list, - bbox_targets_list, - bbox_weights_list, - num_total_samples=num_total_samples, - cfg=cfg) - - # get anchor location loss - losses_loc = [] - for i in range(len(loc_preds)): - loss_loc = self.loss_loc_single( - loc_preds[i], - loc_targets[i], - loc_weights[i], - loc_avg_factor=loc_avg_factor, - cfg=cfg) - losses_loc.append(loss_loc) - - # get anchor shape loss - losses_shape = [] - for i in range(len(shape_preds)): - loss_shape = self.loss_shape_single( - shape_preds[i], - bbox_anchors_list[i], - bbox_gts_list[i], - anchor_weights_list[i], - anchor_total_num=anchor_total_num) - losses_shape.append(loss_shape) - - return dict( - loss_cls=losses_cls, - loss_bbox=losses_bbox, - loss_shape=losses_shape, - loss_loc=losses_loc) - - @force_fp32( - apply_to=('cls_scores', 'bbox_preds', 'shape_preds', 'loc_preds')) - def get_bboxes(self, - cls_scores, - bbox_preds, - shape_preds, - loc_preds, - img_metas, - cfg, - rescale=False): - assert len(cls_scores) == len(bbox_preds) == len(shape_preds) == len( - loc_preds) - num_levels = len(cls_scores) - featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] - device = cls_scores[0].device - # get guided anchors - _, guided_anchors, loc_masks = self.get_anchors( - featmap_sizes, - shape_preds, - loc_preds, - img_metas, - use_loc_filter=not self.training, - device=device) - result_list = [] - for img_id in range(len(img_metas)): - cls_score_list = [ - cls_scores[i][img_id].detach() for i in range(num_levels) - ] - bbox_pred_list = [ - bbox_preds[i][img_id].detach() for i in range(num_levels) - ] - guided_anchor_list = [ - guided_anchors[img_id][i].detach() for i in range(num_levels) - ] - loc_mask_list = [ - loc_masks[img_id][i].detach() for i in range(num_levels) - ] - img_shape = img_metas[img_id]['img_shape'] - scale_factor = img_metas[img_id]['scale_factor'] - proposals = self.get_bboxes_single(cls_score_list, bbox_pred_list, - guided_anchor_list, - loc_mask_list, img_shape, - scale_factor, cfg, rescale) - result_list.append(proposals) - return result_list - - def get_bboxes_single(self, - cls_scores, - bbox_preds, - mlvl_anchors, - mlvl_masks, - img_shape, - scale_factor, - cfg, - rescale=False): - assert len(cls_scores) == len(bbox_preds) == len(mlvl_anchors) - mlvl_bboxes = [] - mlvl_scores = [] - for cls_score, bbox_pred, anchors, mask in zip(cls_scores, bbox_preds, - mlvl_anchors, - mlvl_masks): - assert cls_score.size()[-2:] == bbox_pred.size()[-2:] - # if no location is kept, end. - if mask.sum() == 0: - continue - # reshape scores and bbox_pred - cls_score = cls_score.permute(1, 2, - 0).reshape(-1, self.cls_out_channels) - if self.use_sigmoid_cls: - scores = cls_score.sigmoid() - else: - scores = cls_score.softmax(-1) - bbox_pred = bbox_pred.permute(1, 2, 0).reshape(-1, 4) - # filter scores, bbox_pred w.r.t. mask. - # anchors are filtered in get_anchors() beforehand. - scores = scores[mask, :] - bbox_pred = bbox_pred[mask, :] - if scores.dim() == 0: - anchors = anchors.unsqueeze(0) - scores = scores.unsqueeze(0) - bbox_pred = bbox_pred.unsqueeze(0) - # filter anchors, bbox_pred, scores w.r.t. scores - nms_pre = cfg.get('nms_pre', -1) - if nms_pre > 0 and scores.shape[0] > nms_pre: - if self.use_sigmoid_cls: - max_scores, _ = scores.max(dim=1) - else: - max_scores, _ = scores[:, 1:].max(dim=1) - _, topk_inds = max_scores.topk(nms_pre) - anchors = anchors[topk_inds, :] - bbox_pred = bbox_pred[topk_inds, :] - scores = scores[topk_inds, :] - bboxes = delta2bbox(anchors, bbox_pred, self.target_means, - self.target_stds, img_shape) - mlvl_bboxes.append(bboxes) - mlvl_scores.append(scores) - mlvl_bboxes = torch.cat(mlvl_bboxes) - if rescale: - mlvl_bboxes /= mlvl_bboxes.new_tensor(scale_factor) - mlvl_scores = torch.cat(mlvl_scores) - if self.use_sigmoid_cls: - padding = mlvl_scores.new_zeros(mlvl_scores.shape[0], 1) - mlvl_scores = torch.cat([padding, mlvl_scores], dim=1) - # multi class NMS - det_bboxes, det_labels = multiclass_nms(mlvl_bboxes, mlvl_scores, - cfg.score_thr, cfg.nms, - cfg.max_per_img) - return det_bboxes, det_labels diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/reppoints_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/reppoints_head.py deleted file mode 100644 index b3214f357..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/reppoints_head.py +++ /dev/null @@ -1,596 +0,0 @@ -from __future__ import division - -import numpy as np -import torch -import torch.nn as nn -from mmcv.cnn import normal_init - -from mmdet.core import (PointGenerator, multi_apply, multiclass_nms, - point_target) -from mmdet.ops import DeformConv -from ..builder import build_loss -from ..registry import HEADS -from ..utils import ConvModule, bias_init_with_prob - - -@HEADS.register_module -class RepPointsHead(nn.Module): - """RepPoint head. - - Args: - in_channels (int): Number of channels in the input feature map. - feat_channels (int): Number of channels of the feature map. - point_feat_channels (int): Number of channels of points features. - stacked_convs (int): How many conv layers are used. - gradient_mul (float): The multiplier to gradients from - points refinement and recognition. - point_strides (Iterable): points strides. - point_base_scale (int): bbox scale for assigning labels. - loss_cls (dict): Config of classification loss. - loss_bbox_init (dict): Config of initial points loss. - loss_bbox_refine (dict): Config of points loss in refinement. - use_grid_points (bool): If we use bounding box representation, the - reppoints is represented as grid points on the bounding box. - center_init (bool): Whether to use center point assignment. - transform_method (str): The methods to transform RepPoints to bbox. - """ # noqa: W605 - - def __init__(self, - num_classes, - in_channels, - feat_channels=256, - point_feat_channels=256, - stacked_convs=3, - num_points=9, - gradient_mul=0.1, - point_strides=[8, 16, 32, 64, 128], - point_base_scale=4, - conv_cfg=None, - norm_cfg=None, - loss_cls=dict( - type='FocalLoss', - use_sigmoid=True, - gamma=2.0, - alpha=0.25, - loss_weight=1.0), - loss_bbox_init=dict( - type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=0.5), - loss_bbox_refine=dict( - type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0), - use_grid_points=False, - center_init=True, - transform_method='moment', - moment_mul=0.01): - super(RepPointsHead, self).__init__() - self.in_channels = in_channels - self.num_classes = num_classes - self.feat_channels = feat_channels - self.point_feat_channels = point_feat_channels - self.stacked_convs = stacked_convs - self.num_points = num_points - self.gradient_mul = gradient_mul - self.point_base_scale = point_base_scale - self.point_strides = point_strides - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - self.use_sigmoid_cls = loss_cls.get('use_sigmoid', False) - self.sampling = loss_cls['type'] not in ['FocalLoss'] - self.loss_cls = build_loss(loss_cls) - self.loss_bbox_init = build_loss(loss_bbox_init) - self.loss_bbox_refine = build_loss(loss_bbox_refine) - self.use_grid_points = use_grid_points - self.center_init = center_init - self.transform_method = transform_method - if self.transform_method == 'moment': - self.moment_transfer = nn.Parameter( - data=torch.zeros(2), requires_grad=True) - self.moment_mul = moment_mul - if self.use_sigmoid_cls: - self.cls_out_channels = self.num_classes - 1 - else: - self.cls_out_channels = self.num_classes - self.point_generators = [PointGenerator() for _ in self.point_strides] - # we use deformable conv to extract points features - self.dcn_kernel = int(np.sqrt(num_points)) - self.dcn_pad = int((self.dcn_kernel - 1) / 2) - assert self.dcn_kernel * self.dcn_kernel == num_points, \ - "The points number should be a square number." - assert self.dcn_kernel % 2 == 1, \ - "The points number should be an odd square number." - dcn_base = np.arange(-self.dcn_pad, - self.dcn_pad + 1).astype(np.float64) - dcn_base_y = np.repeat(dcn_base, self.dcn_kernel) - dcn_base_x = np.tile(dcn_base, self.dcn_kernel) - dcn_base_offset = np.stack([dcn_base_y, dcn_base_x], axis=1).reshape( - (-1)) - self.dcn_base_offset = torch.tensor(dcn_base_offset).view(1, -1, 1, 1) - self._init_layers() - - def _init_layers(self): - self.relu = nn.ReLU(inplace=True) - self.cls_convs = nn.ModuleList() - self.reg_convs = nn.ModuleList() - for i in range(self.stacked_convs): - chn = self.in_channels if i == 0 else self.feat_channels - self.cls_convs.append( - ConvModule( - chn, - self.feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg)) - self.reg_convs.append( - ConvModule( - chn, - self.feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg)) - pts_out_dim = 4 if self.use_grid_points else 2 * self.num_points - self.reppoints_cls_conv = DeformConv(self.feat_channels, - self.point_feat_channels, - self.dcn_kernel, 1, self.dcn_pad) - self.reppoints_cls_out = nn.Conv2d(self.point_feat_channels, - self.cls_out_channels, 1, 1, 0) - self.reppoints_pts_init_conv = nn.Conv2d(self.feat_channels, - self.point_feat_channels, 3, - 1, 1) - self.reppoints_pts_init_out = nn.Conv2d(self.point_feat_channels, - pts_out_dim, 1, 1, 0) - self.reppoints_pts_refine_conv = DeformConv(self.feat_channels, - self.point_feat_channels, - self.dcn_kernel, 1, - self.dcn_pad) - self.reppoints_pts_refine_out = nn.Conv2d(self.point_feat_channels, - pts_out_dim, 1, 1, 0) - - def init_weights(self): - for m in self.cls_convs: - normal_init(m.conv, std=0.01) - for m in self.reg_convs: - normal_init(m.conv, std=0.01) - bias_cls = bias_init_with_prob(0.01) - normal_init(self.reppoints_cls_conv, std=0.01) - normal_init(self.reppoints_cls_out, std=0.01, bias=bias_cls) - normal_init(self.reppoints_pts_init_conv, std=0.01) - normal_init(self.reppoints_pts_init_out, std=0.01) - normal_init(self.reppoints_pts_refine_conv, std=0.01) - normal_init(self.reppoints_pts_refine_out, std=0.01) - - def points2bbox(self, pts, y_first=True): - """ - Converting the points set into bounding box. - :param pts: the input points sets (fields), each points - set (fields) is represented as 2n scalar. - :param y_first: if y_fisrt=True, the point set is represented as - [y1, x1, y2, x2 ... yn, xn], otherwise the point set is - represented as [x1, y1, x2, y2 ... xn, yn]. - :return: each points set is converting to a bbox [x1, y1, x2, y2]. - """ - pts_reshape = pts.view(pts.shape[0], -1, 2, *pts.shape[2:]) - pts_y = pts_reshape[:, :, 0, ...] if y_first else pts_reshape[:, :, 1, - ...] - pts_x = pts_reshape[:, :, 1, ...] if y_first else pts_reshape[:, :, 0, - ...] - if self.transform_method == 'minmax': - bbox_left = pts_x.min(dim=1, keepdim=True)[0] - bbox_right = pts_x.max(dim=1, keepdim=True)[0] - bbox_up = pts_y.min(dim=1, keepdim=True)[0] - bbox_bottom = pts_y.max(dim=1, keepdim=True)[0] - bbox = torch.cat([bbox_left, bbox_up, bbox_right, bbox_bottom], - dim=1) - elif self.transform_method == 'partial_minmax': - pts_y = pts_y[:, :4, ...] - pts_x = pts_x[:, :4, ...] - bbox_left = pts_x.min(dim=1, keepdim=True)[0] - bbox_right = pts_x.max(dim=1, keepdim=True)[0] - bbox_up = pts_y.min(dim=1, keepdim=True)[0] - bbox_bottom = pts_y.max(dim=1, keepdim=True)[0] - bbox = torch.cat([bbox_left, bbox_up, bbox_right, bbox_bottom], - dim=1) - elif self.transform_method == 'moment': - pts_y_mean = pts_y.mean(dim=1, keepdim=True) - pts_x_mean = pts_x.mean(dim=1, keepdim=True) - pts_y_std = torch.std(pts_y - pts_y_mean, dim=1, keepdim=True) - pts_x_std = torch.std(pts_x - pts_x_mean, dim=1, keepdim=True) - moment_transfer = (self.moment_transfer * self.moment_mul) + ( - self.moment_transfer.detach() * (1 - self.moment_mul)) - moment_width_transfer = moment_transfer[0] - moment_height_transfer = moment_transfer[1] - half_width = pts_x_std * torch.exp(moment_width_transfer) - half_height = pts_y_std * torch.exp(moment_height_transfer) - bbox = torch.cat([ - pts_x_mean - half_width, pts_y_mean - half_height, - pts_x_mean + half_width, pts_y_mean + half_height - ], - dim=1) - else: - raise NotImplementedError - return bbox - - def gen_grid_from_reg(self, reg, previous_boxes): - """ - Base on the previous bboxes and regression values, we compute the - regressed bboxes and generate the grids on the bboxes. - :param reg: the regression value to previous bboxes. - :param previous_boxes: previous bboxes. - :return: generate grids on the regressed bboxes. - """ - b, _, h, w = reg.shape - bxy = (previous_boxes[:, :2, ...] + previous_boxes[:, 2:, ...]) / 2. - bwh = (previous_boxes[:, 2:, ...] - - previous_boxes[:, :2, ...]).clamp(min=1e-6) - grid_topleft = bxy + bwh * reg[:, :2, ...] - 0.5 * bwh * torch.exp( - reg[:, 2:, ...]) - grid_wh = bwh * torch.exp(reg[:, 2:, ...]) - grid_left = grid_topleft[:, [0], ...] - grid_top = grid_topleft[:, [1], ...] - grid_width = grid_wh[:, [0], ...] - grid_height = grid_wh[:, [1], ...] - intervel = torch.linspace(0., 1., self.dcn_kernel).view( - 1, self.dcn_kernel, 1, 1).type_as(reg) - grid_x = grid_left + grid_width * intervel - grid_x = grid_x.unsqueeze(1).repeat(1, self.dcn_kernel, 1, 1, 1) - grid_x = grid_x.view(b, -1, h, w) - grid_y = grid_top + grid_height * intervel - grid_y = grid_y.unsqueeze(2).repeat(1, 1, self.dcn_kernel, 1, 1) - grid_y = grid_y.view(b, -1, h, w) - grid_yx = torch.stack([grid_y, grid_x], dim=2) - grid_yx = grid_yx.view(b, -1, h, w) - regressed_bbox = torch.cat([ - grid_left, grid_top, grid_left + grid_width, grid_top + grid_height - ], 1) - return grid_yx, regressed_bbox - - def forward_single(self, x): - dcn_base_offset = self.dcn_base_offset.type_as(x) - # If we use center_init, the initial reppoints is from center points. - # If we use bounding bbox representation, the initial reppoints is - # from regular grid placed on a pre-defined bbox. - if self.use_grid_points or not self.center_init: - scale = self.point_base_scale / 2 - points_init = dcn_base_offset / dcn_base_offset.max() * scale - bbox_init = x.new_tensor([-scale, -scale, scale, - scale]).view(1, 4, 1, 1) - else: - points_init = 0 - cls_feat = x - pts_feat = x - for cls_conv in self.cls_convs: - cls_feat = cls_conv(cls_feat) - for reg_conv in self.reg_convs: - pts_feat = reg_conv(pts_feat) - # initialize reppoints - pts_out_init = self.reppoints_pts_init_out( - self.relu(self.reppoints_pts_init_conv(pts_feat))) - if self.use_grid_points: - pts_out_init, bbox_out_init = self.gen_grid_from_reg( - pts_out_init, bbox_init.detach()) - else: - pts_out_init = pts_out_init + points_init - # refine and classify reppoints - pts_out_init_grad_mul = (1 - self.gradient_mul) * pts_out_init.detach( - ) + self.gradient_mul * pts_out_init - dcn_offset = pts_out_init_grad_mul - dcn_base_offset - cls_out = self.reppoints_cls_out( - self.relu(self.reppoints_cls_conv(cls_feat, dcn_offset))) - pts_out_refine = self.reppoints_pts_refine_out( - self.relu(self.reppoints_pts_refine_conv(pts_feat, dcn_offset))) - if self.use_grid_points: - pts_out_refine, bbox_out_refine = self.gen_grid_from_reg( - pts_out_refine, bbox_out_init.detach()) - else: - pts_out_refine = pts_out_refine + pts_out_init.detach() - return cls_out, pts_out_init, pts_out_refine - - def forward(self, feats): - return multi_apply(self.forward_single, feats) - - def get_points(self, featmap_sizes, img_metas): - """Get points according to feature map sizes. - - Args: - featmap_sizes (list[tuple]): Multi-level feature map sizes. - img_metas (list[dict]): Image meta info. - - Returns: - tuple: points of each image, valid flags of each image - """ - num_imgs = len(img_metas) - num_levels = len(featmap_sizes) - - # since feature map sizes of all images are the same, we only compute - # points center for one time - multi_level_points = [] - for i in range(num_levels): - points = self.point_generators[i].grid_points( - featmap_sizes[i], self.point_strides[i]) - multi_level_points.append(points) - points_list = [[point.clone() for point in multi_level_points] - for _ in range(num_imgs)] - - # for each image, we compute valid flags of multi level grids - valid_flag_list = [] - for img_id, img_meta in enumerate(img_metas): - multi_level_flags = [] - for i in range(num_levels): - point_stride = self.point_strides[i] - feat_h, feat_w = featmap_sizes[i] - h, w = img_meta['pad_shape'][:2] - valid_feat_h = min(int(np.ceil(h / point_stride)), feat_h) - valid_feat_w = min(int(np.ceil(w / point_stride)), feat_w) - flags = self.point_generators[i].valid_flags( - (feat_h, feat_w), (valid_feat_h, valid_feat_w)) - multi_level_flags.append(flags) - valid_flag_list.append(multi_level_flags) - - return points_list, valid_flag_list - - def centers_to_bboxes(self, point_list): - """Get bboxes according to center points. Only used in MaxIOUAssigner. - """ - bbox_list = [] - for i_img, point in enumerate(point_list): - bbox = [] - for i_lvl in range(len(self.point_strides)): - scale = self.point_base_scale * self.point_strides[i_lvl] * 0.5 - bbox_shift = torch.Tensor([-scale, -scale, scale, - scale]).view(1, 4).type_as(point[0]) - bbox_center = torch.cat( - [point[i_lvl][:, :2], point[i_lvl][:, :2]], dim=1) - bbox.append(bbox_center + bbox_shift) - bbox_list.append(bbox) - return bbox_list - - def offset_to_pts(self, center_list, pred_list): - """Change from point offset to point coordinate. - """ - pts_list = [] - for i_lvl in range(len(self.point_strides)): - pts_lvl = [] - for i_img in range(len(center_list)): - pts_center = center_list[i_img][i_lvl][:, :2].repeat( - 1, self.num_points) - pts_shift = pred_list[i_lvl][i_img] - yx_pts_shift = pts_shift.permute(1, 2, 0).view( - -1, 2 * self.num_points) - y_pts_shift = yx_pts_shift[..., 0::2] - x_pts_shift = yx_pts_shift[..., 1::2] - xy_pts_shift = torch.stack([x_pts_shift, y_pts_shift], -1) - xy_pts_shift = xy_pts_shift.view(*yx_pts_shift.shape[:-1], -1) - pts = xy_pts_shift * self.point_strides[i_lvl] + pts_center - pts_lvl.append(pts) - pts_lvl = torch.stack(pts_lvl, 0) - pts_list.append(pts_lvl) - return pts_list - - def loss_single(self, cls_score, pts_pred_init, pts_pred_refine, labels, - label_weights, bbox_gt_init, bbox_weights_init, - bbox_gt_refine, bbox_weights_refine, stride, - num_total_samples_init, num_total_samples_refine): - # classification loss - labels = labels.reshape(-1) - label_weights = label_weights.reshape(-1) - cls_score = cls_score.permute(0, 2, 3, - 1).reshape(-1, self.cls_out_channels) - loss_cls = self.loss_cls( - cls_score, - labels, - label_weights, - avg_factor=num_total_samples_refine) - - # points loss - bbox_gt_init = bbox_gt_init.reshape(-1, 4) - bbox_weights_init = bbox_weights_init.reshape(-1, 4) - bbox_pred_init = self.points2bbox( - pts_pred_init.reshape(-1, 2 * self.num_points), y_first=False) - bbox_gt_refine = bbox_gt_refine.reshape(-1, 4) - bbox_weights_refine = bbox_weights_refine.reshape(-1, 4) - bbox_pred_refine = self.points2bbox( - pts_pred_refine.reshape(-1, 2 * self.num_points), y_first=False) - normalize_term = self.point_base_scale * stride - loss_pts_init = self.loss_bbox_init( - bbox_pred_init / normalize_term, - bbox_gt_init / normalize_term, - bbox_weights_init, - avg_factor=num_total_samples_init) - loss_pts_refine = self.loss_bbox_refine( - bbox_pred_refine / normalize_term, - bbox_gt_refine / normalize_term, - bbox_weights_refine, - avg_factor=num_total_samples_refine) - return loss_cls, loss_pts_init, loss_pts_refine - - def loss(self, - cls_scores, - pts_preds_init, - pts_preds_refine, - gt_bboxes, - gt_labels, - img_metas, - cfg, - gt_bboxes_ignore=None): - featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] - assert len(featmap_sizes) == len(self.point_generators) - label_channels = self.cls_out_channels if self.use_sigmoid_cls else 1 - - # target for initial stage - center_list, valid_flag_list = self.get_points(featmap_sizes, - img_metas) - pts_coordinate_preds_init = self.offset_to_pts(center_list, - pts_preds_init) - if cfg.init.assigner['type'] == 'PointAssigner': - # Assign target for center list - candidate_list = center_list - else: - # transform center list to bbox list and - # assign target for bbox list - bbox_list = self.centers_to_bboxes(center_list) - candidate_list = bbox_list - cls_reg_targets_init = point_target( - candidate_list, - valid_flag_list, - gt_bboxes, - img_metas, - cfg.init, - gt_bboxes_ignore_list=gt_bboxes_ignore, - gt_labels_list=gt_labels, - label_channels=label_channels, - sampling=self.sampling) - (*_, bbox_gt_list_init, candidate_list_init, bbox_weights_list_init, - num_total_pos_init, num_total_neg_init) = cls_reg_targets_init - num_total_samples_init = ( - num_total_pos_init + - num_total_neg_init if self.sampling else num_total_pos_init) - - # target for refinement stage - center_list, valid_flag_list = self.get_points(featmap_sizes, - img_metas) - pts_coordinate_preds_refine = self.offset_to_pts( - center_list, pts_preds_refine) - bbox_list = [] - for i_img, center in enumerate(center_list): - bbox = [] - for i_lvl in range(len(pts_preds_refine)): - bbox_preds_init = self.points2bbox( - pts_preds_init[i_lvl].detach()) - bbox_shift = bbox_preds_init * self.point_strides[i_lvl] - bbox_center = torch.cat( - [center[i_lvl][:, :2], center[i_lvl][:, :2]], dim=1) - bbox.append(bbox_center + - bbox_shift[i_img].permute(1, 2, 0).reshape(-1, 4)) - bbox_list.append(bbox) - cls_reg_targets_refine = point_target( - bbox_list, - valid_flag_list, - gt_bboxes, - img_metas, - cfg.refine, - gt_bboxes_ignore_list=gt_bboxes_ignore, - gt_labels_list=gt_labels, - label_channels=label_channels, - sampling=self.sampling) - (labels_list, label_weights_list, bbox_gt_list_refine, - candidate_list_refine, bbox_weights_list_refine, num_total_pos_refine, - num_total_neg_refine) = cls_reg_targets_refine - num_total_samples_refine = ( - num_total_pos_refine + - num_total_neg_refine if self.sampling else num_total_pos_refine) - - # compute loss - losses_cls, losses_pts_init, losses_pts_refine = multi_apply( - self.loss_single, - cls_scores, - pts_coordinate_preds_init, - pts_coordinate_preds_refine, - labels_list, - label_weights_list, - bbox_gt_list_init, - bbox_weights_list_init, - bbox_gt_list_refine, - bbox_weights_list_refine, - self.point_strides, - num_total_samples_init=num_total_samples_init, - num_total_samples_refine=num_total_samples_refine) - loss_dict_all = { - 'loss_cls': losses_cls, - 'loss_pts_init': losses_pts_init, - 'loss_pts_refine': losses_pts_refine - } - return loss_dict_all - - def get_bboxes(self, - cls_scores, - pts_preds_init, - pts_preds_refine, - img_metas, - cfg, - rescale=False, - nms=True): - assert len(cls_scores) == len(pts_preds_refine) - bbox_preds_refine = [ - self.points2bbox(pts_pred_refine) - for pts_pred_refine in pts_preds_refine - ] - num_levels = len(cls_scores) - mlvl_points = [ - self.point_generators[i].grid_points(cls_scores[i].size()[-2:], - self.point_strides[i]) - for i in range(num_levels) - ] - result_list = [] - for img_id in range(len(img_metas)): - cls_score_list = [ - cls_scores[i][img_id].detach() for i in range(num_levels) - ] - bbox_pred_list = [ - bbox_preds_refine[i][img_id].detach() - for i in range(num_levels) - ] - img_shape = img_metas[img_id]['img_shape'] - scale_factor = img_metas[img_id]['scale_factor'] - proposals = self.get_bboxes_single(cls_score_list, bbox_pred_list, - mlvl_points, img_shape, - scale_factor, cfg, rescale, nms) - result_list.append(proposals) - return result_list - - def get_bboxes_single(self, - cls_scores, - bbox_preds, - mlvl_points, - img_shape, - scale_factor, - cfg, - rescale=False, - nms=True): - assert len(cls_scores) == len(bbox_preds) == len(mlvl_points) - mlvl_bboxes = [] - mlvl_scores = [] - for i_lvl, (cls_score, bbox_pred, points) in enumerate( - zip(cls_scores, bbox_preds, mlvl_points)): - assert cls_score.size()[-2:] == bbox_pred.size()[-2:] - cls_score = cls_score.permute(1, 2, - 0).reshape(-1, self.cls_out_channels) - if self.use_sigmoid_cls: - scores = cls_score.sigmoid() - else: - scores = cls_score.softmax(-1) - bbox_pred = bbox_pred.permute(1, 2, 0).reshape(-1, 4) - nms_pre = cfg.get('nms_pre', -1) - if nms_pre > 0 and scores.shape[0] > nms_pre: - if self.use_sigmoid_cls: - max_scores, _ = scores.max(dim=1) - else: - max_scores, _ = scores[:, 1:].max(dim=1) - _, topk_inds = max_scores.topk(nms_pre) - points = points[topk_inds, :] - bbox_pred = bbox_pred[topk_inds, :] - scores = scores[topk_inds, :] - bbox_pos_center = torch.cat([points[:, :2], points[:, :2]], dim=1) - bboxes = bbox_pred * self.point_strides[i_lvl] + bbox_pos_center - x1 = bboxes[:, 0].clamp(min=0, max=img_shape[1]) - y1 = bboxes[:, 1].clamp(min=0, max=img_shape[0]) - x2 = bboxes[:, 2].clamp(min=0, max=img_shape[1]) - y2 = bboxes[:, 3].clamp(min=0, max=img_shape[0]) - bboxes = torch.stack([x1, y1, x2, y2], dim=-1) - mlvl_bboxes.append(bboxes) - mlvl_scores.append(scores) - mlvl_bboxes = torch.cat(mlvl_bboxes) - if rescale: - mlvl_bboxes /= mlvl_bboxes.new_tensor(scale_factor) - mlvl_scores = torch.cat(mlvl_scores) - if self.use_sigmoid_cls: - padding = mlvl_scores.new_zeros(mlvl_scores.shape[0], 1) - mlvl_scores = torch.cat([padding, mlvl_scores], dim=1) - if nms: - det_bboxes, det_labels = multiclass_nms(mlvl_bboxes, mlvl_scores, - cfg.score_thr, cfg.nms, - cfg.max_per_img) - return det_bboxes, det_labels - else: - return mlvl_bboxes, mlvl_scores diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/retina_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/retina_head.py deleted file mode 100644 index e3b8143ad..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/retina_head.py +++ /dev/null @@ -1,103 +0,0 @@ -import numpy as np -import torch.nn as nn -from mmcv.cnn import normal_init - -from ..registry import HEADS -from ..utils import ConvModule, bias_init_with_prob -from .anchor_head import AnchorHead - - -@HEADS.register_module -class RetinaHead(AnchorHead): - """ - An anchor-based head used in [1]_. - - The head contains two subnetworks. The first classifies anchor boxes and - the second regresses deltas for the anchors. - - References: - .. [1] https://arxiv.org/pdf/1708.02002.pdf - - Example: - >>> import torch - >>> self = RetinaHead(11, 7) - >>> x = torch.rand(1, 7, 32, 32) - >>> cls_score, bbox_pred = self.forward_single(x) - >>> # Each anchor predicts a score for each class except background - >>> cls_per_anchor = cls_score.shape[1] / self.num_anchors - >>> box_per_anchor = bbox_pred.shape[1] / self.num_anchors - >>> assert cls_per_anchor == (self.num_classes - 1) - >>> assert box_per_anchor == 4 - """ - - def __init__(self, - num_classes, - in_channels, - stacked_convs=4, - octave_base_scale=4, - scales_per_octave=3, - conv_cfg=None, - norm_cfg=None, - **kwargs): - self.stacked_convs = stacked_convs - self.octave_base_scale = octave_base_scale - self.scales_per_octave = scales_per_octave - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - octave_scales = np.array( - [2**(i / scales_per_octave) for i in range(scales_per_octave)]) - anchor_scales = octave_scales * octave_base_scale - super(RetinaHead, self).__init__( - num_classes, in_channels, anchor_scales=anchor_scales, **kwargs) - - def _init_layers(self): - self.relu = nn.ReLU(inplace=True) - self.cls_convs = nn.ModuleList() - self.reg_convs = nn.ModuleList() - for i in range(self.stacked_convs): - chn = self.in_channels if i == 0 else self.feat_channels - self.cls_convs.append( - ConvModule( - chn, - self.feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg)) - self.reg_convs.append( - ConvModule( - chn, - self.feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg)) - self.retina_cls = nn.Conv2d( - self.feat_channels, - self.num_anchors * self.cls_out_channels, - 3, - padding=1) - self.retina_reg = nn.Conv2d( - self.feat_channels, self.num_anchors * 4, 3, padding=1) - - def init_weights(self): - for m in self.cls_convs: - normal_init(m.conv, std=0.01) - for m in self.reg_convs: - normal_init(m.conv, std=0.01) - bias_cls = bias_init_with_prob(0.01) - normal_init(self.retina_cls, std=0.01, bias=bias_cls) - normal_init(self.retina_reg, std=0.01) - - def forward_single(self, x): - cls_feat = x - reg_feat = x - for cls_conv in self.cls_convs: - cls_feat = cls_conv(cls_feat) - for reg_conv in self.reg_convs: - reg_feat = reg_conv(reg_feat) - cls_score = self.retina_cls(cls_feat) - bbox_pred = self.retina_reg(reg_feat) - return cls_score, bbox_pred diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/retina_sepbn_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/retina_sepbn_head.py deleted file mode 100644 index 0f0766179..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/retina_sepbn_head.py +++ /dev/null @@ -1,105 +0,0 @@ -import numpy as np -import torch.nn as nn -from mmcv.cnn import normal_init - -from ..registry import HEADS -from ..utils import ConvModule, bias_init_with_prob -from .anchor_head import AnchorHead - - -@HEADS.register_module -class RetinaSepBNHead(AnchorHead): - """"RetinaHead with separate BN. - - In RetinaHead, conv/norm layers are shared across different FPN levels, - while in RetinaSepBNHead, conv layers are shared across different FPN - levels, but BN layers are separated. - """ - - def __init__(self, - num_classes, - num_ins, - in_channels, - stacked_convs=4, - octave_base_scale=4, - scales_per_octave=3, - conv_cfg=None, - norm_cfg=None, - **kwargs): - self.stacked_convs = stacked_convs - self.octave_base_scale = octave_base_scale - self.scales_per_octave = scales_per_octave - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - self.num_ins = num_ins - octave_scales = np.array( - [2**(i / scales_per_octave) for i in range(scales_per_octave)]) - anchor_scales = octave_scales * octave_base_scale - super(RetinaSepBNHead, self).__init__( - num_classes, in_channels, anchor_scales=anchor_scales, **kwargs) - - def _init_layers(self): - self.relu = nn.ReLU(inplace=True) - self.cls_convs = nn.ModuleList() - self.reg_convs = nn.ModuleList() - for i in range(self.num_ins): - cls_convs = nn.ModuleList() - reg_convs = nn.ModuleList() - for i in range(self.stacked_convs): - chn = self.in_channels if i == 0 else self.feat_channels - cls_convs.append( - ConvModule( - chn, - self.feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg)) - reg_convs.append( - ConvModule( - chn, - self.feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg)) - self.cls_convs.append(cls_convs) - self.reg_convs.append(reg_convs) - for i in range(self.stacked_convs): - for j in range(1, self.num_ins): - self.cls_convs[j][i].conv = self.cls_convs[0][i].conv - self.reg_convs[j][i].conv = self.reg_convs[0][i].conv - self.retina_cls = nn.Conv2d( - self.feat_channels, - self.num_anchors * self.cls_out_channels, - 3, - padding=1) - self.retina_reg = nn.Conv2d( - self.feat_channels, self.num_anchors * 4, 3, padding=1) - - def init_weights(self): - for m in self.cls_convs[0]: - normal_init(m.conv, std=0.01) - for m in self.reg_convs[0]: - normal_init(m.conv, std=0.01) - bias_cls = bias_init_with_prob(0.01) - normal_init(self.retina_cls, std=0.01, bias=bias_cls) - normal_init(self.retina_reg, std=0.01) - - def forward(self, feats): - cls_scores = [] - bbox_preds = [] - for i, x in enumerate(feats): - cls_feat = feats[i] - reg_feat = feats[i] - for cls_conv in self.cls_convs[i]: - cls_feat = cls_conv(cls_feat) - for reg_conv in self.reg_convs[i]: - reg_feat = reg_conv(reg_feat) - cls_score = self.retina_cls(cls_feat) - bbox_pred = self.retina_reg(reg_feat) - cls_scores.append(cls_score) - bbox_preds.append(bbox_pred) - return cls_scores, bbox_preds diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/rpn_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/rpn_head.py deleted file mode 100644 index f88b949cf..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/rpn_head.py +++ /dev/null @@ -1,104 +0,0 @@ -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import normal_init - -from mmdet.core import delta2bbox -from mmdet.ops import nms -from ..registry import HEADS -from .anchor_head import AnchorHead - - -@HEADS.register_module -class RPNHead(AnchorHead): - - def __init__(self, in_channels, **kwargs): - super(RPNHead, self).__init__(2, in_channels, **kwargs) - - def _init_layers(self): - self.rpn_conv = nn.Conv2d( - self.in_channels, self.feat_channels, 3, padding=1) - self.rpn_cls = nn.Conv2d(self.feat_channels, - self.num_anchors * self.cls_out_channels, 1) - self.rpn_reg = nn.Conv2d(self.feat_channels, self.num_anchors * 4, 1) - - def init_weights(self): - normal_init(self.rpn_conv, std=0.01) - normal_init(self.rpn_cls, std=0.01) - normal_init(self.rpn_reg, std=0.01) - - def forward_single(self, x): - x = self.rpn_conv(x) - x = F.relu(x, inplace=True) - rpn_cls_score = self.rpn_cls(x) - rpn_bbox_pred = self.rpn_reg(x) - return rpn_cls_score, rpn_bbox_pred - - def loss(self, - cls_scores, - bbox_preds, - gt_bboxes, - img_metas, - cfg, - gt_bboxes_ignore=None): - losses = super(RPNHead, self).loss( - cls_scores, - bbox_preds, - gt_bboxes, - None, - img_metas, - cfg, - gt_bboxes_ignore=gt_bboxes_ignore) - return dict( - loss_rpn_cls=losses['loss_cls'], loss_rpn_bbox=losses['loss_bbox']) - - def get_bboxes_single(self, - cls_scores, - bbox_preds, - mlvl_anchors, - img_shape, - scale_factor, - cfg, - rescale=False): - mlvl_proposals = [] - for idx in range(len(cls_scores)): - rpn_cls_score = cls_scores[idx] - rpn_bbox_pred = bbox_preds[idx] - assert rpn_cls_score.size()[-2:] == rpn_bbox_pred.size()[-2:] - rpn_cls_score = rpn_cls_score.permute(1, 2, 0) - if self.use_sigmoid_cls: - rpn_cls_score = rpn_cls_score.reshape(-1) - scores = rpn_cls_score.sigmoid() - else: - rpn_cls_score = rpn_cls_score.reshape(-1, 2) - scores = rpn_cls_score.softmax(dim=1)[:, 1] - rpn_bbox_pred = rpn_bbox_pred.permute(1, 2, 0).reshape(-1, 4) - anchors = mlvl_anchors[idx] - if cfg.nms_pre > 0 and scores.shape[0] > cfg.nms_pre: - _, topk_inds = scores.topk(cfg.nms_pre) - rpn_bbox_pred = rpn_bbox_pred[topk_inds, :] - anchors = anchors[topk_inds, :] - scores = scores[topk_inds] - proposals = delta2bbox(anchors, rpn_bbox_pred, self.target_means, - self.target_stds, img_shape) - if cfg.min_bbox_size > 0: - w = proposals[:, 2] - proposals[:, 0] + 1 - h = proposals[:, 3] - proposals[:, 1] + 1 - valid_inds = torch.nonzero((w >= cfg.min_bbox_size) & - (h >= cfg.min_bbox_size)).squeeze() - proposals = proposals[valid_inds, :] - scores = scores[valid_inds] - proposals = torch.cat([proposals, scores.unsqueeze(-1)], dim=-1) - proposals, _ = nms(proposals, cfg.nms_thr) - proposals = proposals[:cfg.nms_post, :] - mlvl_proposals.append(proposals) - proposals = torch.cat(mlvl_proposals, 0) - if cfg.nms_across_levels: - proposals, _ = nms(proposals, cfg.nms_thr) - proposals = proposals[:cfg.max_num, :] - else: - scores = proposals[:, 4] - num = min(cfg.max_num, proposals.shape[0]) - _, topk_inds = scores.topk(num) - proposals = proposals[topk_inds, :] - return proposals diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solo_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solo_head.py deleted file mode 100644 index e6c060726..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solo_head.py +++ /dev/null @@ -1,433 +0,0 @@ -import mmcv -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import normal_init -from mmdet.ops import DeformConv, roi_align -from mmdet.core import multi_apply, bbox2roi, matrix_nms -from ..builder import build_loss -from ..registry import HEADS -from ..utils import bias_init_with_prob, ConvModule - -INF = 1e8 - -def center_of_mass(bitmasks): - _, h, w = bitmasks.size() - ys = torch.arange(0, h, dtype=torch.float32, device=bitmasks.device) - xs = torch.arange(0, w, dtype=torch.float32, device=bitmasks.device) - - m00 = bitmasks.sum(dim=-1).sum(dim=-1).clamp(min=1e-6) - m10 = (bitmasks * xs).sum(dim=-1).sum(dim=-1) - m01 = (bitmasks * ys[:, None]).sum(dim=-1).sum(dim=-1) - center_x = m10 / m00 - center_y = m01 / m00 - return center_x, center_y - -def points_nms(heat, kernel=2): - # kernel must be 2 - hmax = nn.functional.max_pool2d( - heat, (kernel, kernel), stride=1, padding=1) - keep = (hmax[:, :, :-1, :-1] == heat).float() - return heat * keep - -def dice_loss(input, target): - input = input.contiguous().view(input.size()[0], -1) - target = target.contiguous().view(target.size()[0], -1).float() - - a = torch.sum(input * target, 1) - b = torch.sum(input * input, 1) + 0.001 - c = torch.sum(target * target, 1) + 0.001 - d = (2 * a) / (b + c) - return 1-d - -@HEADS.register_module -class SOLOHead(nn.Module): - - def __init__(self, - num_classes, - in_channels, - seg_feat_channels=256, - stacked_convs=4, - strides=(4, 8, 16, 32, 64), - base_edge_list=(16, 32, 64, 128, 256), - scale_ranges=((8, 32), (16, 64), (32, 128), (64, 256), (128, 512)), - sigma=0.4, - num_grids=None, - cate_down_pos=0, - with_deform=False, - loss_ins=None, - loss_cate=None, - conv_cfg=None, - norm_cfg=None): - super(SOLOHead, self).__init__() - self.num_classes = num_classes - self.seg_num_grids = num_grids - self.cate_out_channels = self.num_classes - 1 - self.in_channels = in_channels - self.seg_feat_channels = seg_feat_channels - self.stacked_convs = stacked_convs - self.strides = strides - self.sigma = sigma - self.cate_down_pos = cate_down_pos - self.base_edge_list = base_edge_list - self.scale_ranges = scale_ranges - self.with_deform = with_deform - self.loss_cate = build_loss(loss_cate) - self.ins_loss_weight = loss_ins['loss_weight'] - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - self._init_layers() - - def _init_layers(self): - norm_cfg = dict(type='GN', num_groups=32, requires_grad=True) - self.ins_convs = nn.ModuleList() - self.cate_convs = nn.ModuleList() - for i in range(self.stacked_convs): - chn = self.in_channels + 2 if i == 0 else self.seg_feat_channels - self.ins_convs.append( - ConvModule( - chn, - self.seg_feat_channels, - 3, - stride=1, - padding=1, - norm_cfg=norm_cfg, - bias=norm_cfg is None)) - - chn = self.in_channels if i == 0 else self.seg_feat_channels - self.cate_convs.append( - ConvModule( - chn, - self.seg_feat_channels, - 3, - stride=1, - padding=1, - norm_cfg=norm_cfg, - bias=norm_cfg is None)) - - self.solo_ins_list = nn.ModuleList() - for seg_num_grid in self.seg_num_grids: - self.solo_ins_list.append( - nn.Conv2d( - self.seg_feat_channels, seg_num_grid**2, 1)) - - self.solo_cate = nn.Conv2d( - self.seg_feat_channels, self.cate_out_channels, 3, padding=1) - - def init_weights(self): - for m in self.ins_convs: - normal_init(m.conv, std=0.01) - for m in self.cate_convs: - normal_init(m.conv, std=0.01) - bias_ins = bias_init_with_prob(0.01) - for m in self.solo_ins_list: - normal_init(m, std=0.01, bias=bias_ins) - bias_cate = bias_init_with_prob(0.01) - normal_init(self.solo_cate, std=0.01, bias=bias_cate) - - def forward(self, feats, eval=False): - new_feats = self.split_feats(feats) - featmap_sizes = [featmap.size()[-2:] for featmap in new_feats] - upsampled_size = (featmap_sizes[0][0] * 2, featmap_sizes[0][1] * 2) - ins_pred, cate_pred = multi_apply(self.forward_single, new_feats, - list(range(len(self.seg_num_grids))), - eval=eval, upsampled_size=upsampled_size) - return ins_pred, cate_pred - - def split_feats(self, feats): - return (F.interpolate(feats[0], scale_factor=0.5, mode='bilinear'), - feats[1], - feats[2], - feats[3], - F.interpolate(feats[4], size=feats[3].shape[-2:], mode='bilinear')) - - def forward_single(self, x, idx, eval=False, upsampled_size=None): - ins_feat = x - cate_feat = x - # ins branch - # concat coord - x_range = torch.linspace(-1, 1, ins_feat.shape[-1], device=ins_feat.device) - y_range = torch.linspace(-1, 1, ins_feat.shape[-2], device=ins_feat.device) - y, x = torch.meshgrid(y_range, x_range) - y = y.expand([ins_feat.shape[0], 1, -1, -1]) - x = x.expand([ins_feat.shape[0], 1, -1, -1]) - coord_feat = torch.cat([x, y], 1) - ins_feat = torch.cat([ins_feat, coord_feat], 1) - - for i, ins_layer in enumerate(self.ins_convs): - ins_feat = ins_layer(ins_feat) - - ins_feat = F.interpolate(ins_feat, scale_factor=2, mode='bilinear') - ins_pred = self.solo_ins_list[idx](ins_feat) - - # cate branch - for i, cate_layer in enumerate(self.cate_convs): - if i == self.cate_down_pos: - seg_num_grid = self.seg_num_grids[idx] - cate_feat = F.interpolate(cate_feat, size=seg_num_grid, mode='bilinear') - cate_feat = cate_layer(cate_feat) - - cate_pred = self.solo_cate(cate_feat) - if eval: - ins_pred = F.interpolate(ins_pred.sigmoid(), size=upsampled_size, mode='bilinear') - cate_pred = points_nms(cate_pred.sigmoid(), kernel=2).permute(0, 2, 3, 1) - return ins_pred, cate_pred - - def loss(self, - ins_preds, - cate_preds, - gt_bbox_list, - gt_label_list, - gt_mask_list, - img_metas, - cfg, - gt_bboxes_ignore=None): - featmap_sizes = [featmap.size()[-2:] for featmap in - ins_preds] - ins_label_list, cate_label_list, ins_ind_label_list = multi_apply( - self.solo_target_single, - gt_bbox_list, - gt_label_list, - gt_mask_list, - featmap_sizes=featmap_sizes) - - # ins - ins_labels = [torch.cat([ins_labels_level_img[ins_ind_labels_level_img, ...] - for ins_labels_level_img, ins_ind_labels_level_img in - zip(ins_labels_level, ins_ind_labels_level)], 0) - for ins_labels_level, ins_ind_labels_level in zip(zip(*ins_label_list), zip(*ins_ind_label_list))] - - ins_preds = [torch.cat([ins_preds_level_img[ins_ind_labels_level_img, ...] - for ins_preds_level_img, ins_ind_labels_level_img in - zip(ins_preds_level, ins_ind_labels_level)], 0) - for ins_preds_level, ins_ind_labels_level in zip(ins_preds, zip(*ins_ind_label_list))] - - - ins_ind_labels = [ - torch.cat([ins_ind_labels_level_img.flatten() - for ins_ind_labels_level_img in ins_ind_labels_level]) - for ins_ind_labels_level in zip(*ins_ind_label_list) - ] - flatten_ins_ind_labels = torch.cat(ins_ind_labels) - - num_ins = flatten_ins_ind_labels.sum() - - # dice loss - loss_ins = [] - for input, target in zip(ins_preds, ins_labels): - if input.size()[0] == 0: - continue - input = torch.sigmoid(input) - loss_ins.append(dice_loss(input, target)) - loss_ins = torch.cat(loss_ins).mean() - loss_ins = loss_ins * self.ins_loss_weight - - # cate - cate_labels = [ - torch.cat([cate_labels_level_img.flatten() - for cate_labels_level_img in cate_labels_level]) - for cate_labels_level in zip(*cate_label_list) - ] - flatten_cate_labels = torch.cat(cate_labels) - - cate_preds = [ - cate_pred.permute(0, 2, 3, 1).reshape(-1, self.cate_out_channels) - for cate_pred in cate_preds - ] - flatten_cate_preds = torch.cat(cate_preds) - - loss_cate = self.loss_cate(flatten_cate_preds, flatten_cate_labels, avg_factor=num_ins + 1) - return dict( - loss_ins=loss_ins, - loss_cate=loss_cate) - - def solo_target_single(self, - gt_bboxes_raw, - gt_labels_raw, - gt_masks_raw, - featmap_sizes=None): - - device = gt_labels_raw[0].device - - # ins - gt_areas = torch.sqrt((gt_bboxes_raw[:, 2] - gt_bboxes_raw[:, 0]) * ( - gt_bboxes_raw[:, 3] - gt_bboxes_raw[:, 1])) - - ins_label_list = [] - cate_label_list = [] - ins_ind_label_list = [] - for (lower_bound, upper_bound), stride, featmap_size, num_grid \ - in zip(self.scale_ranges, self.strides, featmap_sizes, self.seg_num_grids): - - ins_label = torch.zeros([num_grid ** 2, featmap_size[0], featmap_size[1]], dtype=torch.uint8, device=device) - cate_label = torch.zeros([num_grid, num_grid], dtype=torch.int64, device=device) - ins_ind_label = torch.zeros([num_grid ** 2], dtype=torch.bool, device=device) - - hit_indices = ((gt_areas >= lower_bound) & (gt_areas <= upper_bound)).nonzero().flatten() - if len(hit_indices) == 0: - ins_label_list.append(ins_label) - cate_label_list.append(cate_label) - ins_ind_label_list.append(ins_ind_label) - continue - gt_bboxes = gt_bboxes_raw[hit_indices] - gt_labels = gt_labels_raw[hit_indices] - gt_masks = gt_masks_raw[hit_indices.cpu().numpy(), ...] - - half_ws = 0.5 * (gt_bboxes[:, 2] - gt_bboxes[:, 0]) * self.sigma - half_hs = 0.5 * (gt_bboxes[:, 3] - gt_bboxes[:, 1]) * self.sigma - - # mass center - gt_masks_pt = torch.from_numpy(gt_masks).to(device=device) - center_ws, center_hs = center_of_mass(gt_masks_pt) - valid_mask_flags = gt_masks_pt.sum(dim=-1).sum(dim=-1) > 0 - - output_stride = stride / 2 - for seg_mask, gt_label, half_h, half_w, center_h, center_w, valid_mask_flag in zip(gt_masks, gt_labels, half_hs, half_ws, center_hs, center_ws, valid_mask_flags): - if not valid_mask_flag: - continue - upsampled_size = (featmap_sizes[0][0] * 4, featmap_sizes[0][1] * 4) - coord_w = int((center_w / upsampled_size[1]) // (1. / num_grid)) - coord_h = int((center_h / upsampled_size[0]) // (1. / num_grid)) - - # left, top, right, down - top_box = max(0, int(((center_h - half_h) / upsampled_size[0]) // (1. / num_grid))) - down_box = min(num_grid - 1, int(((center_h + half_h) / upsampled_size[0]) // (1. / num_grid))) - left_box = max(0, int(((center_w - half_w) / upsampled_size[1]) // (1. / num_grid))) - right_box = min(num_grid - 1, int(((center_w + half_w) / upsampled_size[1]) // (1. / num_grid))) - - top = max(top_box, coord_h-1) - down = min(down_box, coord_h+1) - left = max(coord_w-1, left_box) - right = min(right_box, coord_w+1) - - cate_label[top:(down+1), left:(right+1)] = gt_label - # ins - seg_mask = mmcv.imrescale(seg_mask, scale=1. / output_stride) - seg_mask = torch.from_numpy(seg_mask).to(device=device) - for i in range(top, down+1): - for j in range(left, right+1): - label = int(i * num_grid + j) - ins_label[label, :seg_mask.shape[0], :seg_mask.shape[1]] = seg_mask - ins_ind_label[label] = True - ins_label_list.append(ins_label) - cate_label_list.append(cate_label) - ins_ind_label_list.append(ins_ind_label) - return ins_label_list, cate_label_list, ins_ind_label_list - - def get_seg(self, seg_preds, cate_preds, img_metas, cfg, rescale=None): - assert len(seg_preds) == len(cate_preds) - num_levels = len(cate_preds) - featmap_size = seg_preds[0].size()[-2:] - - result_list = [] - for img_id in range(len(img_metas)): - cate_pred_list = [ - cate_preds[i][img_id].view(-1, self.cate_out_channels).detach() for i in range(num_levels) - ] - seg_pred_list = [ - seg_preds[i][img_id].detach() for i in range(num_levels) - ] - img_shape = img_metas[img_id]['img_shape'] - scale_factor = img_metas[img_id]['scale_factor'] - ori_shape = img_metas[img_id]['ori_shape'] - - cate_pred_list = torch.cat(cate_pred_list, dim=0) - seg_pred_list = torch.cat(seg_pred_list, dim=0) - - result = self.get_seg_single(cate_pred_list, seg_pred_list, - featmap_size, img_shape, ori_shape, scale_factor, cfg, rescale) - result_list.append(result) - return result_list - - def get_seg_single(self, - cate_preds, - seg_preds, - featmap_size, - img_shape, - ori_shape, - scale_factor, - cfg, - rescale=False, debug=False): - assert len(cate_preds) == len(seg_preds) - - # overall info. - h, w, _ = img_shape - upsampled_size_out = (featmap_size[0] * 4, featmap_size[1] * 4) - - # process. - inds = (cate_preds > cfg.score_thr) - # category scores. - cate_scores = cate_preds[inds] - if len(cate_scores) == 0: - return None - # category labels. - inds = inds.nonzero() - cate_labels = inds[:, 1] - - # strides. - size_trans = cate_labels.new_tensor(self.seg_num_grids).pow(2).cumsum(0) - strides = cate_scores.new_ones(size_trans[-1]) - n_stage = len(self.seg_num_grids) - strides[:size_trans[0]] *= self.strides[0] - for ind_ in range(1, n_stage): - strides[size_trans[ind_ - 1]:size_trans[ind_]] *= self.strides[ind_] - strides = strides[inds[:, 0]] - - # masks. - seg_preds = seg_preds[inds[:, 0]] - seg_masks = seg_preds > cfg.mask_thr - sum_masks = seg_masks.sum((1, 2)).float() - - # filter. - keep = sum_masks > strides - if keep.sum() == 0: - return None - - seg_masks = seg_masks[keep, ...] - seg_preds = seg_preds[keep, ...] - sum_masks = sum_masks[keep] - cate_scores = cate_scores[keep] - cate_labels = cate_labels[keep] - - # maskness. - seg_scores = (seg_preds * seg_masks.float()).sum((1, 2)) / sum_masks - cate_scores *= seg_scores - - # sort and keep top nms_pre - sort_inds = torch.argsort(cate_scores, descending=True) - if len(sort_inds) > cfg.nms_pre: - sort_inds = sort_inds[:cfg.nms_pre] - seg_masks = seg_masks[sort_inds, :, :] - seg_preds = seg_preds[sort_inds, :, :] - sum_masks = sum_masks[sort_inds] - cate_scores = cate_scores[sort_inds] - cate_labels = cate_labels[sort_inds] - - # Matrix NMS - cate_scores = matrix_nms(seg_masks, cate_labels, cate_scores, - kernel=cfg.kernel, sigma=cfg.sigma, sum_masks=sum_masks) - - # filter. - keep = cate_scores >= cfg.update_thr - if keep.sum() == 0: - return None - seg_preds = seg_preds[keep, :, :] - cate_scores = cate_scores[keep] - cate_labels = cate_labels[keep] - - # sort and keep top_k - sort_inds = torch.argsort(cate_scores, descending=True) - if len(sort_inds) > cfg.max_per_img: - sort_inds = sort_inds[:cfg.max_per_img] - seg_preds = seg_preds[sort_inds, :, :] - cate_scores = cate_scores[sort_inds] - cate_labels = cate_labels[sort_inds] - - seg_preds = F.interpolate(seg_preds.unsqueeze(0), - size=upsampled_size_out, - mode='bilinear')[:, :, :h, :w] - seg_masks = F.interpolate(seg_preds, - size=ori_shape[:2], - mode='bilinear').squeeze(0) - seg_masks = seg_masks > cfg.mask_thr - return seg_masks, cate_labels, cate_scores diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solov2_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solov2_head.py deleted file mode 100644 index 9616b99b1..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solov2_head.py +++ /dev/null @@ -1,483 +0,0 @@ -import mmcv -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import normal_init -from mmdet.ops import DeformConv, roi_align -from mmdet.core import multi_apply, matrix_nms -from ..builder import build_loss -from ..registry import HEADS -from ..utils import bias_init_with_prob, ConvModule - -INF = 1e8 - -def center_of_mass(bitmasks): - _, h, w = bitmasks.size() - ys = torch.arange(0, h, dtype=torch.float32, device=bitmasks.device) - xs = torch.arange(0, w, dtype=torch.float32, device=bitmasks.device) - - m00 = bitmasks.sum(dim=-1).sum(dim=-1).clamp(min=1e-6) - m10 = (bitmasks * xs).sum(dim=-1).sum(dim=-1) - m01 = (bitmasks * ys[:, None]).sum(dim=-1).sum(dim=-1) - center_x = m10 / m00 - center_y = m01 / m00 - return center_x, center_y - -def points_nms(heat, kernel=2): - # kernel must be 2 - hmax = nn.functional.max_pool2d( - heat, (kernel, kernel), stride=1, padding=1) - keep = (hmax[:, :, :-1, :-1] == heat).float() - return heat * keep - -def dice_loss(input, target): - input = input.contiguous().view(input.size()[0], -1) - target = target.contiguous().view(target.size()[0], -1).float() - - a = torch.sum(input * target, 1) - b = torch.sum(input * input, 1) + 0.001 - c = torch.sum(target * target, 1) + 0.001 - d = (2 * a) / (b + c) - return 1-d - -@HEADS.register_module -class SOLOv2Head(nn.Module): - - def __init__(self, - num_classes, - in_channels, - seg_feat_channels=256, - stacked_convs=4, - strides=(4, 8, 16, 32, 64), - base_edge_list=(16, 32, 64, 128, 256), - scale_ranges=((8, 32), (16, 64), (32, 128), (64, 256), (128, 512)), - sigma=0.2, - num_grids=None, - ins_out_channels=64, - loss_ins=None, - loss_cate=None, - conv_cfg=None, - norm_cfg=None, - use_dcn_in_tower=False, - type_dcn=None): - super(SOLOv2Head, self).__init__() - self.num_classes = num_classes - self.seg_num_grids = num_grids - self.cate_out_channels = self.num_classes - 1 - self.ins_out_channels = ins_out_channels - self.in_channels = in_channels - self.seg_feat_channels = seg_feat_channels - self.stacked_convs = stacked_convs - self.strides = strides - self.sigma = sigma - self.stacked_convs = stacked_convs - self.kernel_out_channels = self.ins_out_channels * 1 * 1 - self.base_edge_list = base_edge_list - self.scale_ranges = scale_ranges - self.loss_cate = build_loss(loss_cate) - self.ins_loss_weight = loss_ins['loss_weight'] - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - self.use_dcn_in_tower = use_dcn_in_tower - self.type_dcn = type_dcn - self._init_layers() - - def _init_layers(self): - norm_cfg = dict(type='GN', num_groups=32, requires_grad=True) - self.cate_convs = nn.ModuleList() - self.kernel_convs = nn.ModuleList() - for i in range(self.stacked_convs): - if self.use_dcn_in_tower: - cfg_conv = dict(type=self.type_dcn) - else: - cfg_conv = self.conv_cfg - - chn = self.in_channels + 2 if i == 0 else self.seg_feat_channels - self.kernel_convs.append( - ConvModule( - chn, - self.seg_feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=cfg_conv, - norm_cfg=norm_cfg, - bias=norm_cfg is None)) - - chn = self.in_channels if i == 0 else self.seg_feat_channels - self.cate_convs.append( - ConvModule( - chn, - self.seg_feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=cfg_conv, - norm_cfg=norm_cfg, - bias=norm_cfg is None)) - - self.solo_cate = nn.Conv2d( - self.seg_feat_channels, self.cate_out_channels, 3, padding=1) - - self.solo_kernel = nn.Conv2d( - self.seg_feat_channels, self.kernel_out_channels, 3, padding=1) - - def init_weights(self): - for m in self.cate_convs: - normal_init(m.conv, std=0.01) - for m in self.kernel_convs: - normal_init(m.conv, std=0.01) - bias_cate = bias_init_with_prob(0.01) - normal_init(self.solo_cate, std=0.01, bias=bias_cate) - normal_init(self.solo_kernel, std=0.01) - - def forward(self, feats, eval=False): - new_feats = self.split_feats(feats) - featmap_sizes = [featmap.size()[-2:] for featmap in new_feats] - upsampled_size = (featmap_sizes[0][0] * 2, featmap_sizes[0][1] * 2) - cate_pred, kernel_pred = multi_apply(self.forward_single, new_feats, - list(range(len(self.seg_num_grids))), - eval=eval, upsampled_size=upsampled_size) - return cate_pred, kernel_pred - - def split_feats(self, feats): - return (F.interpolate(feats[0], scale_factor=0.5, mode='bilinear'), - feats[1], - feats[2], - feats[3], - F.interpolate(feats[4], size=feats[3].shape[-2:], mode='bilinear')) - - def forward_single(self, x, idx, eval=False, upsampled_size=None): - ins_kernel_feat = x - # ins branch - # concat coord - x_range = torch.linspace(-1, 1, ins_kernel_feat.shape[-1], device=ins_kernel_feat.device) - y_range = torch.linspace(-1, 1, ins_kernel_feat.shape[-2], device=ins_kernel_feat.device) - y, x = torch.meshgrid(y_range, x_range) - y = y.expand([ins_kernel_feat.shape[0], 1, -1, -1]) - x = x.expand([ins_kernel_feat.shape[0], 1, -1, -1]) - coord_feat = torch.cat([x, y], 1) - ins_kernel_feat = torch.cat([ins_kernel_feat, coord_feat], 1) - - # kernel branch - kernel_feat = ins_kernel_feat - seg_num_grid = self.seg_num_grids[idx] - kernel_feat = F.interpolate(kernel_feat, size=seg_num_grid, mode='bilinear') - - cate_feat = kernel_feat[:, :-2, :, :] - - kernel_feat = kernel_feat.contiguous() - for i, kernel_layer in enumerate(self.kernel_convs): - kernel_feat = kernel_layer(kernel_feat) - kernel_pred = self.solo_kernel(kernel_feat) - - # cate branch - cate_feat = cate_feat.contiguous() - for i, cate_layer in enumerate(self.cate_convs): - cate_feat = cate_layer(cate_feat) - cate_pred = self.solo_cate(cate_feat) - - if eval: - cate_pred = points_nms(cate_pred.sigmoid(), kernel=2).permute(0, 2, 3, 1) - return cate_pred, kernel_pred - - def loss(self, - cate_preds, - kernel_preds, - ins_pred, - gt_bbox_list, - gt_label_list, - gt_mask_list, - img_metas, - cfg, - gt_bboxes_ignore=None): - mask_feat_size = ins_pred.size()[-2:] - ins_label_list, cate_label_list, ins_ind_label_list, grid_order_list = multi_apply( - self.solov2_target_single, - gt_bbox_list, - gt_label_list, - gt_mask_list, - mask_feat_size=mask_feat_size) - - # ins - ins_labels = [torch.cat([ins_labels_level_img - for ins_labels_level_img in ins_labels_level], 0) - for ins_labels_level in zip(*ins_label_list)] - - kernel_preds = [[kernel_preds_level_img.view(kernel_preds_level_img.shape[0], -1)[:, grid_orders_level_img] - for kernel_preds_level_img, grid_orders_level_img in - zip(kernel_preds_level, grid_orders_level)] - for kernel_preds_level, grid_orders_level in zip(kernel_preds, zip(*grid_order_list))] - # generate masks - ins_pred = ins_pred - ins_pred_list = [] - for b_kernel_pred in kernel_preds: - b_mask_pred = [] - for idx, kernel_pred in enumerate(b_kernel_pred): - - if kernel_pred.size()[-1] == 0: - continue - cur_ins_pred = ins_pred[idx, ...] - H, W = cur_ins_pred.shape[-2:] - N, I = kernel_pred.shape - cur_ins_pred = cur_ins_pred.unsqueeze(0) - kernel_pred = kernel_pred.permute(1, 0).view(I, -1, 1, 1) - cur_ins_pred = F.conv2d(cur_ins_pred, kernel_pred, stride=1).view(-1, H, W) - b_mask_pred.append(cur_ins_pred) - if len(b_mask_pred) == 0: - b_mask_pred = None - else: - b_mask_pred = torch.cat(b_mask_pred, 0) - ins_pred_list.append(b_mask_pred) - - ins_ind_labels = [ - torch.cat([ins_ind_labels_level_img.flatten() - for ins_ind_labels_level_img in ins_ind_labels_level]) - for ins_ind_labels_level in zip(*ins_ind_label_list) - ] - flatten_ins_ind_labels = torch.cat(ins_ind_labels) - - num_ins = flatten_ins_ind_labels.sum() - - # dice loss - loss_ins = [] - for input, target in zip(ins_pred_list, ins_labels): - if input is None: - continue - input = torch.sigmoid(input) - loss_ins.append(dice_loss(input, target)) - loss_ins = torch.cat(loss_ins).mean() - loss_ins = loss_ins * self.ins_loss_weight - - # cate - cate_labels = [ - torch.cat([cate_labels_level_img.flatten() - for cate_labels_level_img in cate_labels_level]) - for cate_labels_level in zip(*cate_label_list) - ] - flatten_cate_labels = torch.cat(cate_labels) - - cate_preds = [ - cate_pred.permute(0, 2, 3, 1).reshape(-1, self.cate_out_channels) - for cate_pred in cate_preds - ] - flatten_cate_preds = torch.cat(cate_preds) - - loss_cate = self.loss_cate(flatten_cate_preds, flatten_cate_labels, avg_factor=num_ins + 1) - return dict( - loss_ins=loss_ins, - loss_cate=loss_cate) - - def solov2_target_single(self, - gt_bboxes_raw, - gt_labels_raw, - gt_masks_raw, - mask_feat_size): - - device = gt_labels_raw[0].device - - # ins - gt_areas = torch.sqrt((gt_bboxes_raw[:, 2] - gt_bboxes_raw[:, 0]) * ( - gt_bboxes_raw[:, 3] - gt_bboxes_raw[:, 1])) - - ins_label_list = [] - cate_label_list = [] - ins_ind_label_list = [] - grid_order_list = [] - for (lower_bound, upper_bound), stride, num_grid \ - in zip(self.scale_ranges, self.strides, self.seg_num_grids): - - hit_indices = ((gt_areas >= lower_bound) & (gt_areas <= upper_bound)).nonzero().flatten() - num_ins = len(hit_indices) - - ins_label = [] - grid_order = [] - cate_label = torch.zeros([num_grid, num_grid], dtype=torch.int64, device=device) - ins_ind_label = torch.zeros([num_grid ** 2], dtype=torch.bool, device=device) - - if num_ins == 0: - ins_label = torch.zeros([0, mask_feat_size[0], mask_feat_size[1]], dtype=torch.uint8, device=device) - ins_label_list.append(ins_label) - cate_label_list.append(cate_label) - ins_ind_label_list.append(ins_ind_label) - grid_order_list.append([]) - continue - gt_bboxes = gt_bboxes_raw[hit_indices] - gt_labels = gt_labels_raw[hit_indices] - gt_masks = gt_masks_raw[hit_indices.cpu().numpy(), ...] - - half_ws = 0.5 * (gt_bboxes[:, 2] - gt_bboxes[:, 0]) * self.sigma - half_hs = 0.5 * (gt_bboxes[:, 3] - gt_bboxes[:, 1]) * self.sigma - - # mass center - gt_masks_pt = torch.from_numpy(gt_masks).to(device=device) - center_ws, center_hs = center_of_mass(gt_masks_pt) - valid_mask_flags = gt_masks_pt.sum(dim=-1).sum(dim=-1) > 0 - - output_stride = 4 - for seg_mask, gt_label, half_h, half_w, center_h, center_w, valid_mask_flag in zip(gt_masks, gt_labels, half_hs, half_ws, center_hs, center_ws, valid_mask_flags): - if not valid_mask_flag: - continue - upsampled_size = (mask_feat_size[0] * 4, mask_feat_size[1] * 4) - coord_w = int((center_w / upsampled_size[1]) // (1. / num_grid)) - coord_h = int((center_h / upsampled_size[0]) // (1. / num_grid)) - - # left, top, right, down - top_box = max(0, int(((center_h - half_h) / upsampled_size[0]) // (1. / num_grid))) - down_box = min(num_grid - 1, int(((center_h + half_h) / upsampled_size[0]) // (1. / num_grid))) - left_box = max(0, int(((center_w - half_w) / upsampled_size[1]) // (1. / num_grid))) - right_box = min(num_grid - 1, int(((center_w + half_w) / upsampled_size[1]) // (1. / num_grid))) - - top = max(top_box, coord_h-1) - down = min(down_box, coord_h+1) - left = max(coord_w-1, left_box) - right = min(right_box, coord_w+1) - - cate_label[top:(down+1), left:(right+1)] = gt_label - seg_mask = mmcv.imrescale(seg_mask, scale=1. / output_stride) - seg_mask = torch.from_numpy(seg_mask).to(device=device) - for i in range(top, down+1): - for j in range(left, right+1): - label = int(i * num_grid + j) - - cur_ins_label = torch.zeros([mask_feat_size[0], mask_feat_size[1]], dtype=torch.uint8, - device=device) - cur_ins_label[:seg_mask.shape[0], :seg_mask.shape[1]] = seg_mask - ins_label.append(cur_ins_label) - ins_ind_label[label] = True - grid_order.append(label) - if len(ins_label) == 0: - ins_label = torch.zeros([0, mask_feat_size[0], mask_feat_size[1]], dtype=torch.uint8, device=device) - else: - ins_label = torch.stack(ins_label, 0) - ins_label_list.append(ins_label) - cate_label_list.append(cate_label) - ins_ind_label_list.append(ins_ind_label) - grid_order_list.append(grid_order) - return ins_label_list, cate_label_list, ins_ind_label_list, grid_order_list - - def get_seg(self, cate_preds, kernel_preds, seg_pred, img_metas, cfg, rescale=None): - num_levels = len(cate_preds) - featmap_size = seg_pred.size()[-2:] - - result_list = [] - for img_id in range(len(img_metas)): - cate_pred_list = [ - cate_preds[i][img_id].view(-1, self.cate_out_channels).detach() for i in range(num_levels) - ] - seg_pred_list = seg_pred[img_id, ...].unsqueeze(0) - kernel_pred_list = [ - kernel_preds[i][img_id].permute(1, 2, 0).view(-1, self.kernel_out_channels).detach() - for i in range(num_levels) - ] - img_shape = img_metas[img_id]['img_shape'] - scale_factor = img_metas[img_id]['scale_factor'] - ori_shape = img_metas[img_id]['ori_shape'] - - cate_pred_list = torch.cat(cate_pred_list, dim=0) - kernel_pred_list = torch.cat(kernel_pred_list, dim=0) - - result = self.get_seg_single(cate_pred_list, seg_pred_list, kernel_pred_list, - featmap_size, img_shape, ori_shape, scale_factor, cfg, rescale) - result_list.append(result) - return result_list - - def get_seg_single(self, - cate_preds, - seg_preds, - kernel_preds, - featmap_size, - img_shape, - ori_shape, - scale_factor, - cfg, - rescale=False, debug=False): - - assert len(cate_preds) == len(kernel_preds) - - # overall info. - h, w, _ = img_shape - upsampled_size_out = (featmap_size[0] * 4, featmap_size[1] * 4) - - # process. - inds = (cate_preds > cfg.score_thr) - cate_scores = cate_preds[inds] - if len(cate_scores) == 0: - return None - - # cate_labels & kernel_preds - inds = inds.nonzero() - cate_labels = inds[:, 1] - kernel_preds = kernel_preds[inds[:, 0]] - - # trans vector. - size_trans = cate_labels.new_tensor(self.seg_num_grids).pow(2).cumsum(0) - strides = kernel_preds.new_ones(size_trans[-1]) - - n_stage = len(self.seg_num_grids) - strides[:size_trans[0]] *= self.strides[0] - for ind_ in range(1, n_stage): - strides[size_trans[ind_-1]:size_trans[ind_]] *= self.strides[ind_] - strides = strides[inds[:, 0]] - - # mask encoding. - I, N = kernel_preds.shape - kernel_preds = kernel_preds.view(I, N, 1, 1) - seg_preds = F.conv2d(seg_preds, kernel_preds, stride=1).squeeze(0).sigmoid() - # mask. - seg_masks = seg_preds > cfg.mask_thr - sum_masks = seg_masks.sum((1, 2)).float() - - # filter. - keep = sum_masks > strides - if keep.sum() == 0: - return None - - seg_masks = seg_masks[keep, ...] - seg_preds = seg_preds[keep, ...] - sum_masks = sum_masks[keep] - cate_scores = cate_scores[keep] - cate_labels = cate_labels[keep] - - # maskness. - seg_scores = (seg_preds * seg_masks.float()).sum((1, 2)) / sum_masks - cate_scores *= seg_scores - - # sort and keep top nms_pre - sort_inds = torch.argsort(cate_scores, descending=True) - if len(sort_inds) > cfg.nms_pre: - sort_inds = sort_inds[:cfg.nms_pre] - seg_masks = seg_masks[sort_inds, :, :] - seg_preds = seg_preds[sort_inds, :, :] - sum_masks = sum_masks[sort_inds] - cate_scores = cate_scores[sort_inds] - cate_labels = cate_labels[sort_inds] - - # Matrix NMS - cate_scores = matrix_nms(seg_masks, cate_labels, cate_scores, - kernel=cfg.kernel,sigma=cfg.sigma, sum_masks=sum_masks) - - # filter. - keep = cate_scores >= cfg.update_thr - if keep.sum() == 0: - return None - seg_preds = seg_preds[keep, :, :] - cate_scores = cate_scores[keep] - cate_labels = cate_labels[keep] - - # sort and keep top_k - sort_inds = torch.argsort(cate_scores, descending=True) - if len(sort_inds) > cfg.max_per_img: - sort_inds = sort_inds[:cfg.max_per_img] - seg_preds = seg_preds[sort_inds, :, :] - cate_scores = cate_scores[sort_inds] - cate_labels = cate_labels[sort_inds] - - seg_preds = F.interpolate(seg_preds.unsqueeze(0), - size=upsampled_size_out, - mode='bilinear')[:, :, :h, :w] - seg_masks = F.interpolate(seg_preds, - size=ori_shape[:2], - mode='bilinear').squeeze(0) - seg_masks = seg_masks > cfg.mask_thr - return seg_masks, cate_labels, cate_scores diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solov2_light_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solov2_light_head.py deleted file mode 100644 index 46e90a159..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/solov2_light_head.py +++ /dev/null @@ -1,482 +0,0 @@ -import mmcv -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import normal_init -from mmdet.ops import DeformConv, roi_align -from mmdet.core import multi_apply, matrix_nms -from ..builder import build_loss -from ..registry import HEADS -from ..utils import bias_init_with_prob, ConvModule - -INF = 1e8 - -def center_of_mass(bitmasks): - _, h, w = bitmasks.size() - ys = torch.arange(0, h, dtype=torch.float32, device=bitmasks.device) - xs = torch.arange(0, w, dtype=torch.float32, device=bitmasks.device) - - m00 = bitmasks.sum(dim=-1).sum(dim=-1).clamp(min=1e-6) - m10 = (bitmasks * xs).sum(dim=-1).sum(dim=-1) - m01 = (bitmasks * ys[:, None]).sum(dim=-1).sum(dim=-1) - center_x = m10 / m00 - center_y = m01 / m00 - return center_x, center_y - -def points_nms(heat, kernel=2): - # kernel must be 2 - hmax = nn.functional.max_pool2d( - heat, (kernel, kernel), stride=1, padding=1) - keep = (hmax[:, :, :-1, :-1] == heat).float() - return heat * keep - -def dice_loss(input, target): - input = input.contiguous().view(input.size()[0], -1) - target = target.contiguous().view(target.size()[0], -1).float() - - a = torch.sum(input * target, 1) - b = torch.sum(input * input, 1) + 0.001 - c = torch.sum(target * target, 1) + 0.001 - d = (2 * a) / (b + c) - return 1-d - -@HEADS.register_module -class SOLOv2LightHead(nn.Module): - - def __init__(self, - num_classes, - in_channels, - seg_feat_channels=256, - strides=(4, 8, 16, 32, 64), - base_edge_list=(16, 32, 64, 128, 256), - scale_ranges=((8, 32), (16, 64), (32, 128), (64, 256), (128, 512)), - sigma=0.2, - num_grids=None, - ins_out_channels=64, - stacked_convs=4, - loss_ins=None, - loss_cate=None, - conv_cfg=None, - norm_cfg=None, - use_dcn_in_tower=False, - type_dcn=None): - super(SOLOv2LightHead, self).__init__() - self.num_classes = num_classes - self.seg_num_grids = num_grids - self.cate_out_channels = self.num_classes - 1 - self.ins_out_channels = ins_out_channels - self.in_channels = in_channels - self.seg_feat_channels = seg_feat_channels - self.stacked_convs = stacked_convs - self.strides = strides - self.sigma = sigma - self.stacked_convs = stacked_convs - self.kernel_out_channels = self.ins_out_channels * 1 * 1 - self.base_edge_list = base_edge_list - self.scale_ranges = scale_ranges - self.loss_cate = build_loss(loss_cate) - self.ins_loss_weight = loss_ins['loss_weight'] - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - self.use_dcn_in_tower = use_dcn_in_tower - self.type_dcn = type_dcn - self._init_layers() - - def _init_layers(self): - norm_cfg = dict(type='GN', num_groups=32, requires_grad=True) - self.cate_convs = nn.ModuleList() - self.kernel_convs = nn.ModuleList() - for i in range(self.stacked_convs): - if self.use_dcn_in_tower and i == self.stacked_convs - 1: - cfg_conv = dict(type=self.type_dcn) - else: - cfg_conv = self.conv_cfg - - chn = self.in_channels + 2 if i == 0 else self.seg_feat_channels - self.kernel_convs.append( - ConvModule( - chn, - self.seg_feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=cfg_conv, - norm_cfg=norm_cfg, - bias=norm_cfg is None)) - - chn = self.in_channels if i == 0 else self.seg_feat_channels - self.cate_convs.append( - ConvModule( - chn, - self.seg_feat_channels, - 3, - stride=1, - padding=1, - conv_cfg=cfg_conv, - norm_cfg=norm_cfg, - bias=norm_cfg is None)) - - self.solo_cate = nn.Conv2d( - self.seg_feat_channels, self.cate_out_channels, 3, padding=1) - - self.solo_kernel = nn.Conv2d( - self.seg_feat_channels, self.kernel_out_channels, 3, padding=1) - - def init_weights(self): - for m in self.cate_convs: - normal_init(m.conv, std=0.01) - for m in self.kernel_convs: - normal_init(m.conv, std=0.01) - bias_cate = bias_init_with_prob(0.01) - normal_init(self.solo_cate, std=0.01, bias=bias_cate) - normal_init(self.solo_kernel, std=0.01) - - def forward(self, feats, eval=False): - new_feats = self.split_feats(feats) - featmap_sizes = [featmap.size()[-2:] for featmap in new_feats] - upsampled_size = (featmap_sizes[0][0] * 2, featmap_sizes[0][1] * 2) - cate_pred, kernel_pred = multi_apply(self.forward_single, new_feats, - list(range(len(self.seg_num_grids))), - eval=eval, upsampled_size=upsampled_size) - return cate_pred, kernel_pred - - def split_feats(self, feats): - return (F.interpolate(feats[0], scale_factor=0.5, mode='bilinear'), - feats[1], - feats[2], - feats[3], - F.interpolate(feats[4], size=feats[3].shape[-2:], mode='bilinear')) - - def forward_single(self, x, idx, eval=False, upsampled_size=None): - ins_kernel_feat = x - # ins branch - # concat coord - x_range = torch.linspace(-1, 1, ins_kernel_feat.shape[-1], device=ins_kernel_feat.device) - y_range = torch.linspace(-1, 1, ins_kernel_feat.shape[-2], device=ins_kernel_feat.device) - y, x = torch.meshgrid(y_range, x_range) - y = y.expand([ins_kernel_feat.shape[0], 1, -1, -1]) - x = x.expand([ins_kernel_feat.shape[0], 1, -1, -1]) - coord_feat = torch.cat([x, y], 1) - ins_kernel_feat = torch.cat([ins_kernel_feat, coord_feat], 1) - - # kernel branch - kernel_feat = ins_kernel_feat - seg_num_grid = self.seg_num_grids[idx] - kernel_feat = F.interpolate(kernel_feat, size=seg_num_grid, mode='bilinear') - - cate_feat = kernel_feat[:, :-2, :, :] - - kernel_feat = kernel_feat.contiguous() - for i, kernel_layer in enumerate(self.kernel_convs): - kernel_feat = kernel_layer(kernel_feat) - kernel_pred = self.solo_kernel(kernel_feat) - - # cate branch - cate_feat = cate_feat.contiguous() - for i, cate_layer in enumerate(self.cate_convs): - cate_feat = cate_layer(cate_feat) - cate_pred = self.solo_cate(cate_feat) - - if eval: - cate_pred = points_nms(cate_pred.sigmoid(), kernel=2).permute(0, 2, 3, 1) - return cate_pred, kernel_pred - - def loss(self, - cate_preds, - kernel_preds, - ins_pred, - gt_bbox_list, - gt_label_list, - gt_mask_list, - img_metas, - cfg, - gt_bboxes_ignore=None): - mask_feat_size = ins_pred.size()[-2:] - ins_label_list, cate_label_list, ins_ind_label_list, grid_order_list = multi_apply( - self.solov2_target_single, - gt_bbox_list, - gt_label_list, - gt_mask_list, - mask_feat_size=mask_feat_size) - - # ins - ins_labels = [torch.cat([ins_labels_level_img - for ins_labels_level_img in ins_labels_level], 0) - for ins_labels_level in zip(*ins_label_list)] - - kernel_preds = [[kernel_preds_level_img.view(kernel_preds_level_img.shape[0], -1)[:, grid_orders_level_img] - for kernel_preds_level_img, grid_orders_level_img in - zip(kernel_preds_level, grid_orders_level)] - for kernel_preds_level, grid_orders_level in zip(kernel_preds, zip(*grid_order_list))] - # generate masks - ins_pred = ins_pred - ins_pred_list = [] - for b_kernel_pred in kernel_preds: - b_mask_pred = [] - for idx, kernel_pred in enumerate(b_kernel_pred): - - if kernel_pred.size()[-1] == 0: - continue - cur_ins_pred = ins_pred[idx, ...] - H, W = cur_ins_pred.shape[-2:] - N, I = kernel_pred.shape - cur_ins_pred = cur_ins_pred.unsqueeze(0) - kernel_pred = kernel_pred.permute(1, 0).view(I, -1, 1, 1) - cur_ins_pred = F.conv2d(cur_ins_pred, kernel_pred, stride=1).view(-1, H, W) - b_mask_pred.append(cur_ins_pred) - if len(b_mask_pred) == 0: - b_mask_pred = None - else: - b_mask_pred = torch.cat(b_mask_pred, 0) - ins_pred_list.append(b_mask_pred) - - ins_ind_labels = [ - torch.cat([ins_ind_labels_level_img.flatten() - for ins_ind_labels_level_img in ins_ind_labels_level]) - for ins_ind_labels_level in zip(*ins_ind_label_list) - ] - flatten_ins_ind_labels = torch.cat(ins_ind_labels) - - num_ins = flatten_ins_ind_labels.sum() - - # dice loss - loss_ins = [] - for input, target in zip(ins_pred_list, ins_labels): - if input is None: - continue - input = torch.sigmoid(input) - loss_ins.append(dice_loss(input, target)) - loss_ins = torch.cat(loss_ins).mean() - loss_ins = loss_ins * self.ins_loss_weight - - # cate - cate_labels = [ - torch.cat([cate_labels_level_img.flatten() - for cate_labels_level_img in cate_labels_level]) - for cate_labels_level in zip(*cate_label_list) - ] - flatten_cate_labels = torch.cat(cate_labels) - - cate_preds = [ - cate_pred.permute(0, 2, 3, 1).reshape(-1, self.cate_out_channels) - for cate_pred in cate_preds - ] - flatten_cate_preds = torch.cat(cate_preds) - - loss_cate = self.loss_cate(flatten_cate_preds, flatten_cate_labels, avg_factor=num_ins + 1) - return dict( - loss_ins=loss_ins, - loss_cate=loss_cate) - - def solov2_target_single(self, - gt_bboxes_raw, - gt_labels_raw, - gt_masks_raw, - mask_feat_size): - - device = gt_labels_raw[0].device - - # ins - gt_areas = torch.sqrt((gt_bboxes_raw[:, 2] - gt_bboxes_raw[:, 0]) * ( - gt_bboxes_raw[:, 3] - gt_bboxes_raw[:, 1])) - - ins_label_list = [] - cate_label_list = [] - ins_ind_label_list = [] - grid_order_list = [] - for (lower_bound, upper_bound), stride, num_grid \ - in zip(self.scale_ranges, self.strides, self.seg_num_grids): - - hit_indices = ((gt_areas >= lower_bound) & (gt_areas <= upper_bound)).nonzero().flatten() - num_ins = len(hit_indices) - - ins_label = [] - grid_order = [] - cate_label = torch.zeros([num_grid, num_grid], dtype=torch.int64, device=device) - ins_ind_label = torch.zeros([num_grid ** 2], dtype=torch.bool, device=device) - - if num_ins == 0: - ins_label = torch.zeros([0, mask_feat_size[0], mask_feat_size[1]], dtype=torch.uint8, device=device) - ins_label_list.append(ins_label) - cate_label_list.append(cate_label) - ins_ind_label_list.append(ins_ind_label) - grid_order_list.append([]) - continue - gt_bboxes = gt_bboxes_raw[hit_indices] - gt_labels = gt_labels_raw[hit_indices] - gt_masks = gt_masks_raw[hit_indices.cpu().numpy(), ...] - - half_ws = 0.5 * (gt_bboxes[:, 2] - gt_bboxes[:, 0]) * self.sigma - half_hs = 0.5 * (gt_bboxes[:, 3] - gt_bboxes[:, 1]) * self.sigma - - # mass center - gt_masks_pt = torch.from_numpy(gt_masks).to(device=device) - center_ws, center_hs = center_of_mass(gt_masks_pt) - valid_mask_flags = gt_masks_pt.sum(dim=-1).sum(dim=-1) > 0 - output_stride = 4 - for seg_mask, gt_label, half_h, half_w, center_h, center_w, valid_mask_flag in zip(gt_masks, gt_labels, half_hs, half_ws, center_hs, center_ws, valid_mask_flags): - if not valid_mask_flag: - continue - upsampled_size = (mask_feat_size[0] * 4, mask_feat_size[1] * 4) - coord_w = int((center_w / upsampled_size[1]) // (1. / num_grid)) - coord_h = int((center_h / upsampled_size[0]) // (1. / num_grid)) - - # left, top, right, down - top_box = max(0, int(((center_h - half_h) / upsampled_size[0]) // (1. / num_grid))) - down_box = min(num_grid - 1, int(((center_h + half_h) / upsampled_size[0]) // (1. / num_grid))) - left_box = max(0, int(((center_w - half_w) / upsampled_size[1]) // (1. / num_grid))) - right_box = min(num_grid - 1, int(((center_w + half_w) / upsampled_size[1]) // (1. / num_grid))) - - top = max(top_box, coord_h-1) - down = min(down_box, coord_h+1) - left = max(coord_w-1, left_box) - right = min(right_box, coord_w+1) - - cate_label[top:(down+1), left:(right+1)] = gt_label - seg_mask = mmcv.imrescale(seg_mask, scale=1. / output_stride) - seg_mask = torch.from_numpy(seg_mask).to(device=device) - for i in range(top, down+1): - for j in range(left, right+1): - label = int(i * num_grid + j) - - cur_ins_label = torch.zeros([mask_feat_size[0], mask_feat_size[1]], dtype=torch.uint8, - device=device) - cur_ins_label[:seg_mask.shape[0], :seg_mask.shape[1]] = seg_mask - ins_label.append(cur_ins_label) - ins_ind_label[label] = True - grid_order.append(label) - if len(ins_label) == 0: - ins_label = torch.zeros([0, mask_feat_size[0], mask_feat_size[1]], dtype=torch.uint8, device=device) - else: - ins_label = torch.stack(ins_label, 0) - ins_label_list.append(ins_label) - cate_label_list.append(cate_label) - ins_ind_label_list.append(ins_ind_label) - grid_order_list.append(grid_order) - return ins_label_list, cate_label_list, ins_ind_label_list, grid_order_list - - def get_seg(self, cate_preds, kernel_preds, seg_pred, img_metas, cfg, rescale=None): - num_levels = len(cate_preds) - featmap_size = seg_pred.size()[-2:] - - result_list = [] - for img_id in range(len(img_metas)): - cate_pred_list = [ - cate_preds[i][img_id].view(-1, self.cate_out_channels).detach() for i in range(num_levels) - ] - seg_pred_list = seg_pred[img_id, ...].unsqueeze(0) - kernel_pred_list = [ - kernel_preds[i][img_id].permute(1, 2, 0).view(-1, self.kernel_out_channels).detach() - for i in range(num_levels) - ] - img_shape = img_metas[img_id]['img_shape'] - scale_factor = img_metas[img_id]['scale_factor'] - ori_shape = img_metas[img_id]['ori_shape'] - - cate_pred_list = torch.cat(cate_pred_list, dim=0) - kernel_pred_list = torch.cat(kernel_pred_list, dim=0) - - result = self.get_seg_single(cate_pred_list, seg_pred_list, kernel_pred_list, - featmap_size, img_shape, ori_shape, scale_factor, cfg, rescale) - result_list.append(result) - return result_list - - def get_seg_single(self, - cate_preds, - seg_preds, - kernel_preds, - featmap_size, - img_shape, - ori_shape, - scale_factor, - cfg, - rescale=False, debug=False): - - assert len(cate_preds) == len(kernel_preds) - - # overall info. - h, w, _ = img_shape - upsampled_size_out = (featmap_size[0] * 4, featmap_size[1] * 4) - - # process. - inds = (cate_preds > cfg.score_thr) - cate_scores = cate_preds[inds] - if len(cate_scores) == 0: - return None - - # cate_labels & kernel_preds - inds = inds.nonzero() - cate_labels = inds[:, 1] - kernel_preds = kernel_preds[inds[:, 0]] - - # trans vector. - size_trans = cate_labels.new_tensor(self.seg_num_grids).pow(2).cumsum(0) - strides = kernel_preds.new_ones(size_trans[-1]) - - n_stage = len(self.seg_num_grids) - strides[:size_trans[0]] *= self.strides[0] - for ind_ in range(1, n_stage): - strides[size_trans[ind_-1]:size_trans[ind_]] *= self.strides[ind_] - strides = strides[inds[:, 0]] - - # mask encoding. - I, N = kernel_preds.shape - kernel_preds = kernel_preds.view(I, N, 1, 1) - seg_preds = F.conv2d(seg_preds, kernel_preds, stride=1).squeeze(0).sigmoid() - # mask. - seg_masks = seg_preds > cfg.mask_thr - sum_masks = seg_masks.sum((1, 2)).float() - - # filter. - keep = sum_masks > strides - if keep.sum() == 0: - return None - - seg_masks = seg_masks[keep, ...] - seg_preds = seg_preds[keep, ...] - sum_masks = sum_masks[keep] - cate_scores = cate_scores[keep] - cate_labels = cate_labels[keep] - - # maskness. - seg_scores = (seg_preds * seg_masks.float()).sum((1, 2)) / sum_masks - cate_scores *= seg_scores - - # sort and keep top nms_pre - sort_inds = torch.argsort(cate_scores, descending=True) - if len(sort_inds) > cfg.nms_pre: - sort_inds = sort_inds[:cfg.nms_pre] - seg_masks = seg_masks[sort_inds, :, :] - seg_preds = seg_preds[sort_inds, :, :] - sum_masks = sum_masks[sort_inds] - cate_scores = cate_scores[sort_inds] - cate_labels = cate_labels[sort_inds] - - # Matrix NMS - cate_scores = matrix_nms(seg_masks, cate_labels, cate_scores, - kernel=cfg.kernel,sigma=cfg.sigma, sum_masks=sum_masks) - - # filter. - keep = cate_scores >= cfg.update_thr - if keep.sum() == 0: - return None - seg_preds = seg_preds[keep, :, :] - cate_scores = cate_scores[keep] - cate_labels = cate_labels[keep] - - # sort and keep top_k - sort_inds = torch.argsort(cate_scores, descending=True) - if len(sort_inds) > cfg.max_per_img: - sort_inds = sort_inds[:cfg.max_per_img] - seg_preds = seg_preds[sort_inds, :, :] - cate_scores = cate_scores[sort_inds] - cate_labels = cate_labels[sort_inds] - - seg_preds = F.interpolate(seg_preds.unsqueeze(0), - size=upsampled_size_out, - mode='bilinear')[:, :, :h, :w] - seg_masks = F.interpolate(seg_preds, - size=ori_shape[:2], - mode='bilinear').squeeze(0) - seg_masks = seg_masks > cfg.mask_thr - return seg_masks, cate_labels, cate_scores diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ssd_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ssd_head.py deleted file mode 100644 index 57113679b..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/anchor_heads/ssd_head.py +++ /dev/null @@ -1,201 +0,0 @@ -import numpy as np -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import xavier_init - -from mmdet.core import AnchorGenerator, anchor_target, multi_apply -from ..losses import smooth_l1_loss -from ..registry import HEADS -from .anchor_head import AnchorHead - - -# TODO: add loss evaluator for SSD -@HEADS.register_module -class SSDHead(AnchorHead): - - def __init__(self, - input_size=300, - num_classes=81, - in_channels=(512, 1024, 512, 256, 256, 256), - anchor_strides=(8, 16, 32, 64, 100, 300), - basesize_ratio_range=(0.1, 0.9), - anchor_ratios=([2], [2, 3], [2, 3], [2, 3], [2], [2]), - target_means=(.0, .0, .0, .0), - target_stds=(1.0, 1.0, 1.0, 1.0)): - super(AnchorHead, self).__init__() - self.input_size = input_size - self.num_classes = num_classes - self.in_channels = in_channels - self.cls_out_channels = num_classes - num_anchors = [len(ratios) * 2 + 2 for ratios in anchor_ratios] - reg_convs = [] - cls_convs = [] - for i in range(len(in_channels)): - reg_convs.append( - nn.Conv2d( - in_channels[i], - num_anchors[i] * 4, - kernel_size=3, - padding=1)) - cls_convs.append( - nn.Conv2d( - in_channels[i], - num_anchors[i] * num_classes, - kernel_size=3, - padding=1)) - self.reg_convs = nn.ModuleList(reg_convs) - self.cls_convs = nn.ModuleList(cls_convs) - - min_ratio, max_ratio = basesize_ratio_range - min_ratio = int(min_ratio * 100) - max_ratio = int(max_ratio * 100) - step = int(np.floor(max_ratio - min_ratio) / (len(in_channels) - 2)) - min_sizes = [] - max_sizes = [] - for r in range(int(min_ratio), int(max_ratio) + 1, step): - min_sizes.append(int(input_size * r / 100)) - max_sizes.append(int(input_size * (r + step) / 100)) - if input_size == 300: - if basesize_ratio_range[0] == 0.15: # SSD300 COCO - min_sizes.insert(0, int(input_size * 7 / 100)) - max_sizes.insert(0, int(input_size * 15 / 100)) - elif basesize_ratio_range[0] == 0.2: # SSD300 VOC - min_sizes.insert(0, int(input_size * 10 / 100)) - max_sizes.insert(0, int(input_size * 20 / 100)) - elif input_size == 512: - if basesize_ratio_range[0] == 0.1: # SSD512 COCO - min_sizes.insert(0, int(input_size * 4 / 100)) - max_sizes.insert(0, int(input_size * 10 / 100)) - elif basesize_ratio_range[0] == 0.15: # SSD512 VOC - min_sizes.insert(0, int(input_size * 7 / 100)) - max_sizes.insert(0, int(input_size * 15 / 100)) - self.anchor_generators = [] - self.anchor_strides = anchor_strides - for k in range(len(anchor_strides)): - base_size = min_sizes[k] - stride = anchor_strides[k] - ctr = ((stride - 1) / 2., (stride - 1) / 2.) - scales = [1., np.sqrt(max_sizes[k] / min_sizes[k])] - ratios = [1.] - for r in anchor_ratios[k]: - ratios += [1 / r, r] # 4 or 6 ratio - anchor_generator = AnchorGenerator( - base_size, scales, ratios, scale_major=False, ctr=ctr) - indices = list(range(len(ratios))) - indices.insert(1, len(indices)) - anchor_generator.base_anchors = torch.index_select( - anchor_generator.base_anchors, 0, torch.LongTensor(indices)) - self.anchor_generators.append(anchor_generator) - - self.target_means = target_means - self.target_stds = target_stds - self.use_sigmoid_cls = False - self.cls_focal_loss = False - self.fp16_enabled = False - - def init_weights(self): - for m in self.modules(): - if isinstance(m, nn.Conv2d): - xavier_init(m, distribution='uniform', bias=0) - - def forward(self, feats): - cls_scores = [] - bbox_preds = [] - for feat, reg_conv, cls_conv in zip(feats, self.reg_convs, - self.cls_convs): - cls_scores.append(cls_conv(feat)) - bbox_preds.append(reg_conv(feat)) - return cls_scores, bbox_preds - - def loss_single(self, cls_score, bbox_pred, labels, label_weights, - bbox_targets, bbox_weights, num_total_samples, cfg): - loss_cls_all = F.cross_entropy( - cls_score, labels, reduction='none') * label_weights - pos_inds = (labels > 0).nonzero().view(-1) - neg_inds = (labels == 0).nonzero().view(-1) - - num_pos_samples = pos_inds.size(0) - num_neg_samples = cfg.neg_pos_ratio * num_pos_samples - if num_neg_samples > neg_inds.size(0): - num_neg_samples = neg_inds.size(0) - topk_loss_cls_neg, _ = loss_cls_all[neg_inds].topk(num_neg_samples) - loss_cls_pos = loss_cls_all[pos_inds].sum() - loss_cls_neg = topk_loss_cls_neg.sum() - loss_cls = (loss_cls_pos + loss_cls_neg) / num_total_samples - - loss_bbox = smooth_l1_loss( - bbox_pred, - bbox_targets, - bbox_weights, - beta=cfg.smoothl1_beta, - avg_factor=num_total_samples) - return loss_cls[None], loss_bbox - - def loss(self, - cls_scores, - bbox_preds, - gt_bboxes, - gt_labels, - img_metas, - cfg, - gt_bboxes_ignore=None): - featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] - assert len(featmap_sizes) == len(self.anchor_generators) - - device = cls_scores[0].device - - anchor_list, valid_flag_list = self.get_anchors( - featmap_sizes, img_metas, device=device) - cls_reg_targets = anchor_target( - anchor_list, - valid_flag_list, - gt_bboxes, - img_metas, - self.target_means, - self.target_stds, - cfg, - gt_bboxes_ignore_list=gt_bboxes_ignore, - gt_labels_list=gt_labels, - label_channels=1, - sampling=False, - unmap_outputs=False) - if cls_reg_targets is None: - return None - (labels_list, label_weights_list, bbox_targets_list, bbox_weights_list, - num_total_pos, num_total_neg) = cls_reg_targets - - num_images = len(img_metas) - all_cls_scores = torch.cat([ - s.permute(0, 2, 3, 1).reshape( - num_images, -1, self.cls_out_channels) for s in cls_scores - ], 1) - all_labels = torch.cat(labels_list, -1).view(num_images, -1) - all_label_weights = torch.cat(label_weights_list, - -1).view(num_images, -1) - all_bbox_preds = torch.cat([ - b.permute(0, 2, 3, 1).reshape(num_images, -1, 4) - for b in bbox_preds - ], -2) - all_bbox_targets = torch.cat(bbox_targets_list, - -2).view(num_images, -1, 4) - all_bbox_weights = torch.cat(bbox_weights_list, - -2).view(num_images, -1, 4) - - # check NaN and Inf - assert torch.isfinite(all_cls_scores).all().item(), \ - 'classification scores become infinite or NaN!' - assert torch.isfinite(all_bbox_preds).all().item(), \ - 'bbox predications become infinite or NaN!' - - losses_cls, losses_bbox = multi_apply( - self.loss_single, - all_cls_scores, - all_bbox_preds, - all_labels, - all_label_weights, - all_bbox_targets, - all_bbox_weights, - num_total_samples=num_total_pos, - cfg=cfg) - return dict(loss_cls=losses_cls, loss_bbox=losses_bbox) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/__init__.py index 6fb56d63c..c6f2540a8 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/__init__.py @@ -1,6 +1,6 @@ -from .hrnet import HRNet -from .resnet import ResNet, make_res_layer -from .resnext import ResNeXt -from .ssd_vgg import SSDVGG +# Copyright (c) OpenMMLab. All rights reserved. +from .resnet import ResNet, ResNetV1d -__all__ = ['ResNet', 'make_res_layer', 'ResNeXt', 'SSDVGG', 'HRNet'] +__all__ = [ + 'ResNet', 'ResNetV1d' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/hrnet.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/hrnet.py deleted file mode 100644 index 0f7a082cf..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/hrnet.py +++ /dev/null @@ -1,524 +0,0 @@ -import torch.nn as nn -from mmcv.cnn import constant_init, kaiming_init -from mmcv.runner import load_checkpoint -from torch.nn.modules.batchnorm import _BatchNorm - -from mmdet.utils import get_root_logger -from ..registry import BACKBONES -from ..utils import build_conv_layer, build_norm_layer -from .resnet import BasicBlock, Bottleneck - - -class HRModule(nn.Module): - """ High-Resolution Module for HRNet. In this module, every branch - has 4 BasicBlocks/Bottlenecks. Fusion/Exchange is in this module. - """ - - def __init__(self, - num_branches, - blocks, - num_blocks, - in_channels, - num_channels, - multiscale_output=True, - with_cp=False, - conv_cfg=None, - norm_cfg=dict(type='BN')): - super(HRModule, self).__init__() - self._check_branches(num_branches, num_blocks, in_channels, - num_channels) - - self.in_channels = in_channels - self.num_branches = num_branches - - self.multiscale_output = multiscale_output - self.norm_cfg = norm_cfg - self.conv_cfg = conv_cfg - self.with_cp = with_cp - self.branches = self._make_branches(num_branches, blocks, num_blocks, - num_channels) - self.fuse_layers = self._make_fuse_layers() - self.relu = nn.ReLU(inplace=False) - - def _check_branches(self, num_branches, num_blocks, in_channels, - num_channels): - if num_branches != len(num_blocks): - error_msg = 'NUM_BRANCHES({}) <> NUM_BLOCKS({})'.format( - num_branches, len(num_blocks)) - raise ValueError(error_msg) - - if num_branches != len(num_channels): - error_msg = 'NUM_BRANCHES({}) <> NUM_CHANNELS({})'.format( - num_branches, len(num_channels)) - raise ValueError(error_msg) - - if num_branches != len(in_channels): - error_msg = 'NUM_BRANCHES({}) <> NUM_INCHANNELS({})'.format( - num_branches, len(in_channels)) - raise ValueError(error_msg) - - def _make_one_branch(self, - branch_index, - block, - num_blocks, - num_channels, - stride=1): - downsample = None - if stride != 1 or \ - self.in_channels[branch_index] != \ - num_channels[branch_index] * block.expansion: - downsample = nn.Sequential( - build_conv_layer( - self.conv_cfg, - self.in_channels[branch_index], - num_channels[branch_index] * block.expansion, - kernel_size=1, - stride=stride, - bias=False), - build_norm_layer(self.norm_cfg, num_channels[branch_index] * - block.expansion)[1]) - - layers = [] - layers.append( - block( - self.in_channels[branch_index], - num_channels[branch_index], - stride, - downsample=downsample, - with_cp=self.with_cp, - norm_cfg=self.norm_cfg, - conv_cfg=self.conv_cfg)) - self.in_channels[branch_index] = \ - num_channels[branch_index] * block.expansion - for i in range(1, num_blocks[branch_index]): - layers.append( - block( - self.in_channels[branch_index], - num_channels[branch_index], - with_cp=self.with_cp, - norm_cfg=self.norm_cfg, - conv_cfg=self.conv_cfg)) - - return nn.Sequential(*layers) - - def _make_branches(self, num_branches, block, num_blocks, num_channels): - branches = [] - - for i in range(num_branches): - branches.append( - self._make_one_branch(i, block, num_blocks, num_channels)) - - return nn.ModuleList(branches) - - def _make_fuse_layers(self): - if self.num_branches == 1: - return None - - num_branches = self.num_branches - in_channels = self.in_channels - fuse_layers = [] - num_out_branches = num_branches if self.multiscale_output else 1 - for i in range(num_out_branches): - fuse_layer = [] - for j in range(num_branches): - if j > i: - fuse_layer.append( - nn.Sequential( - build_conv_layer( - self.conv_cfg, - in_channels[j], - in_channels[i], - kernel_size=1, - stride=1, - padding=0, - bias=False), - build_norm_layer(self.norm_cfg, in_channels[i])[1], - nn.Upsample( - scale_factor=2**(j - i), mode='nearest'))) - elif j == i: - fuse_layer.append(None) - else: - conv_downsamples = [] - for k in range(i - j): - if k == i - j - 1: - conv_downsamples.append( - nn.Sequential( - build_conv_layer( - self.conv_cfg, - in_channels[j], - in_channels[i], - kernel_size=3, - stride=2, - padding=1, - bias=False), - build_norm_layer(self.norm_cfg, - in_channels[i])[1])) - else: - conv_downsamples.append( - nn.Sequential( - build_conv_layer( - self.conv_cfg, - in_channels[j], - in_channels[j], - kernel_size=3, - stride=2, - padding=1, - bias=False), - build_norm_layer(self.norm_cfg, - in_channels[j])[1], - nn.ReLU(inplace=False))) - fuse_layer.append(nn.Sequential(*conv_downsamples)) - fuse_layers.append(nn.ModuleList(fuse_layer)) - - return nn.ModuleList(fuse_layers) - - def forward(self, x): - if self.num_branches == 1: - return [self.branches[0](x[0])] - - for i in range(self.num_branches): - x[i] = self.branches[i](x[i]) - - x_fuse = [] - for i in range(len(self.fuse_layers)): - y = 0 - for j in range(self.num_branches): - if i == j: - y += x[j] - else: - y += self.fuse_layers[i][j](x[j]) - x_fuse.append(self.relu(y)) - return x_fuse - - -@BACKBONES.register_module -class HRNet(nn.Module): - """HRNet backbone. - - High-Resolution Representations for Labeling Pixels and Regions - arXiv: https://arxiv.org/abs/1904.04514 - - Args: - extra (dict): detailed configuration for each stage of HRNet. - in_channels (int): Number of input image channels. Normally 3. - conv_cfg (dict): dictionary to construct and config conv layer. - norm_cfg (dict): dictionary to construct and config norm layer. - norm_eval (bool): Whether to set norm layers to eval mode, namely, - freeze running stats (mean and var). Note: Effect on Batch Norm - and its variants only. - with_cp (bool): Use checkpoint or not. Using checkpoint will save some - memory while slowing down the training speed. - zero_init_residual (bool): whether to use zero init for last norm layer - in resblocks to let them behave as identity. - - Example: - >>> from mmdet.models import HRNet - >>> import torch - >>> extra = dict( - >>> stage1=dict( - >>> num_modules=1, - >>> num_branches=1, - >>> block='BOTTLENECK', - >>> num_blocks=(4, ), - >>> num_channels=(64, )), - >>> stage2=dict( - >>> num_modules=1, - >>> num_branches=2, - >>> block='BASIC', - >>> num_blocks=(4, 4), - >>> num_channels=(32, 64)), - >>> stage3=dict( - >>> num_modules=4, - >>> num_branches=3, - >>> block='BASIC', - >>> num_blocks=(4, 4, 4), - >>> num_channels=(32, 64, 128)), - >>> stage4=dict( - >>> num_modules=3, - >>> num_branches=4, - >>> block='BASIC', - >>> num_blocks=(4, 4, 4, 4), - >>> num_channels=(32, 64, 128, 256))) - >>> self = HRNet(extra, in_channels=1) - >>> self.eval() - >>> inputs = torch.rand(1, 1, 32, 32) - >>> level_outputs = self.forward(inputs) - >>> for level_out in level_outputs: - ... print(tuple(level_out.shape)) - (1, 32, 8, 8) - (1, 64, 4, 4) - (1, 128, 2, 2) - (1, 256, 1, 1) - """ - - blocks_dict = {'BASIC': BasicBlock, 'BOTTLENECK': Bottleneck} - - def __init__(self, - extra, - in_channels=3, - conv_cfg=None, - norm_cfg=dict(type='BN'), - norm_eval=True, - with_cp=False, - zero_init_residual=False): - super(HRNet, self).__init__() - self.extra = extra - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - self.norm_eval = norm_eval - self.with_cp = with_cp - self.zero_init_residual = zero_init_residual - - # stem net - self.norm1_name, norm1 = build_norm_layer(self.norm_cfg, 64, postfix=1) - self.norm2_name, norm2 = build_norm_layer(self.norm_cfg, 64, postfix=2) - - self.conv1 = build_conv_layer( - self.conv_cfg, - in_channels, - 64, - kernel_size=3, - stride=2, - padding=1, - bias=False) - - self.add_module(self.norm1_name, norm1) - self.conv2 = build_conv_layer( - self.conv_cfg, - 64, - 64, - kernel_size=3, - stride=2, - padding=1, - bias=False) - - self.add_module(self.norm2_name, norm2) - self.relu = nn.ReLU(inplace=True) - - # stage 1 - self.stage1_cfg = self.extra['stage1'] - num_channels = self.stage1_cfg['num_channels'][0] - block_type = self.stage1_cfg['block'] - num_blocks = self.stage1_cfg['num_blocks'][0] - - block = self.blocks_dict[block_type] - stage1_out_channels = num_channels * block.expansion - self.layer1 = self._make_layer(block, 64, num_channels, num_blocks) - - # stage 2 - self.stage2_cfg = self.extra['stage2'] - num_channels = self.stage2_cfg['num_channels'] - block_type = self.stage2_cfg['block'] - - block = self.blocks_dict[block_type] - num_channels = [channel * block.expansion for channel in num_channels] - self.transition1 = self._make_transition_layer([stage1_out_channels], - num_channels) - self.stage2, pre_stage_channels = self._make_stage( - self.stage2_cfg, num_channels) - - # stage 3 - self.stage3_cfg = self.extra['stage3'] - num_channels = self.stage3_cfg['num_channels'] - block_type = self.stage3_cfg['block'] - - block = self.blocks_dict[block_type] - num_channels = [channel * block.expansion for channel in num_channels] - self.transition2 = self._make_transition_layer(pre_stage_channels, - num_channels) - self.stage3, pre_stage_channels = self._make_stage( - self.stage3_cfg, num_channels) - - # stage 4 - self.stage4_cfg = self.extra['stage4'] - num_channels = self.stage4_cfg['num_channels'] - block_type = self.stage4_cfg['block'] - - block = self.blocks_dict[block_type] - num_channels = [channel * block.expansion for channel in num_channels] - self.transition3 = self._make_transition_layer(pre_stage_channels, - num_channels) - self.stage4, pre_stage_channels = self._make_stage( - self.stage4_cfg, num_channels) - - @property - def norm1(self): - return getattr(self, self.norm1_name) - - @property - def norm2(self): - return getattr(self, self.norm2_name) - - def _make_transition_layer(self, num_channels_pre_layer, - num_channels_cur_layer): - num_branches_cur = len(num_channels_cur_layer) - num_branches_pre = len(num_channels_pre_layer) - - transition_layers = [] - for i in range(num_branches_cur): - if i < num_branches_pre: - if num_channels_cur_layer[i] != num_channels_pre_layer[i]: - transition_layers.append( - nn.Sequential( - build_conv_layer( - self.conv_cfg, - num_channels_pre_layer[i], - num_channels_cur_layer[i], - kernel_size=3, - stride=1, - padding=1, - bias=False), - build_norm_layer(self.norm_cfg, - num_channels_cur_layer[i])[1], - nn.ReLU(inplace=True))) - else: - transition_layers.append(None) - else: - conv_downsamples = [] - for j in range(i + 1 - num_branches_pre): - in_channels = num_channels_pre_layer[-1] - out_channels = num_channels_cur_layer[i] \ - if j == i - num_branches_pre else in_channels - conv_downsamples.append( - nn.Sequential( - build_conv_layer( - self.conv_cfg, - in_channels, - out_channels, - kernel_size=3, - stride=2, - padding=1, - bias=False), - build_norm_layer(self.norm_cfg, out_channels)[1], - nn.ReLU(inplace=True))) - transition_layers.append(nn.Sequential(*conv_downsamples)) - - return nn.ModuleList(transition_layers) - - def _make_layer(self, block, inplanes, planes, blocks, stride=1): - downsample = None - if stride != 1 or inplanes != planes * block.expansion: - downsample = nn.Sequential( - build_conv_layer( - self.conv_cfg, - inplanes, - planes * block.expansion, - kernel_size=1, - stride=stride, - bias=False), - build_norm_layer(self.norm_cfg, planes * block.expansion)[1]) - - layers = [] - layers.append( - block( - inplanes, - planes, - stride, - downsample=downsample, - with_cp=self.with_cp, - norm_cfg=self.norm_cfg, - conv_cfg=self.conv_cfg)) - inplanes = planes * block.expansion - for i in range(1, blocks): - layers.append( - block( - inplanes, - planes, - with_cp=self.with_cp, - norm_cfg=self.norm_cfg, - conv_cfg=self.conv_cfg)) - - return nn.Sequential(*layers) - - def _make_stage(self, layer_config, in_channels, multiscale_output=True): - num_modules = layer_config['num_modules'] - num_branches = layer_config['num_branches'] - num_blocks = layer_config['num_blocks'] - num_channels = layer_config['num_channels'] - block = self.blocks_dict[layer_config['block']] - - hr_modules = [] - for i in range(num_modules): - # multi_scale_output is only used for the last module - if not multiscale_output and i == num_modules - 1: - reset_multiscale_output = False - else: - reset_multiscale_output = True - - hr_modules.append( - HRModule( - num_branches, - block, - num_blocks, - in_channels, - num_channels, - reset_multiscale_output, - with_cp=self.with_cp, - norm_cfg=self.norm_cfg, - conv_cfg=self.conv_cfg)) - - return nn.Sequential(*hr_modules), in_channels - - def init_weights(self, pretrained=None): - if isinstance(pretrained, str): - logger = get_root_logger() - load_checkpoint(self, pretrained, strict=False, logger=logger) - elif pretrained is None: - for m in self.modules(): - if isinstance(m, nn.Conv2d): - kaiming_init(m) - elif isinstance(m, (_BatchNorm, nn.GroupNorm)): - constant_init(m, 1) - - if self.zero_init_residual: - for m in self.modules(): - if isinstance(m, Bottleneck): - constant_init(m.norm3, 0) - elif isinstance(m, BasicBlock): - constant_init(m.norm2, 0) - else: - raise TypeError('pretrained must be a str or None') - - def forward(self, x): - - x = self.conv1(x) - x = self.norm1(x) - x = self.relu(x) - x = self.conv2(x) - x = self.norm2(x) - x = self.relu(x) - x = self.layer1(x) - - x_list = [] - for i in range(self.stage2_cfg['num_branches']): - if self.transition1[i] is not None: - x_list.append(self.transition1[i](x)) - else: - x_list.append(x) - y_list = self.stage2(x_list) - - x_list = [] - for i in range(self.stage3_cfg['num_branches']): - if self.transition2[i] is not None: - x_list.append(self.transition2[i](y_list[-1])) - else: - x_list.append(y_list[i]) - y_list = self.stage3(x_list) - - x_list = [] - for i in range(self.stage4_cfg['num_branches']): - if self.transition3[i] is not None: - x_list.append(self.transition3[i](y_list[-1])) - else: - x_list.append(y_list[i]) - y_list = self.stage4(x_list) - - return y_list - - def train(self, mode=True): - super(HRNet, self).train(mode) - if mode and self.norm_eval: - for m in self.modules(): - # trick: eval have effect on BatchNorm only - if isinstance(m, _BatchNorm): - m.eval() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/resnet.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/resnet.py index ab6913e82..1eaaae67c 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/resnet.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/resnet.py @@ -1,17 +1,17 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import warnings + import torch.nn as nn import torch.utils.checkpoint as cp -from mmcv.cnn import constant_init, kaiming_init -from mmcv.runner import load_checkpoint +from mmcv.cnn import build_conv_layer, build_norm_layer, build_plugin_layer +from mmcv.runner import BaseModule from torch.nn.modules.batchnorm import _BatchNorm -from mmdet.models.plugins import GeneralizedAttention -from mmdet.ops import ContextBlock -from mmdet.utils import get_root_logger -from ..registry import BACKBONES -from ..utils import build_conv_layer, build_norm_layer +from ..builder import BACKBONES +from ..utils import ResLayer -class BasicBlock(nn.Module): +class BasicBlock(BaseModule): expansion = 1 def __init__(self, @@ -25,12 +25,11 @@ class BasicBlock(nn.Module): conv_cfg=None, norm_cfg=dict(type='BN'), dcn=None, - gcb=None, - gen_attention=None): - super(BasicBlock, self).__init__() - assert dcn is None, "Not implemented yet." - assert gen_attention is None, "Not implemented yet." - assert gcb is None, "Not implemented yet." + plugins=None, + init_cfg=None): + super(BasicBlock, self).__init__(init_cfg) + assert dcn is None, 'Not implemented yet.' + assert plugins is None, 'Not implemented yet.' self.norm1_name, norm1 = build_norm_layer(norm_cfg, planes, postfix=1) self.norm2_name, norm2 = build_norm_layer(norm_cfg, planes, postfix=2) @@ -53,36 +52,49 @@ class BasicBlock(nn.Module): self.downsample = downsample self.stride = stride self.dilation = dilation - assert not with_cp + self.with_cp = with_cp @property def norm1(self): + """nn.Module: normalization layer after the first convolution layer""" return getattr(self, self.norm1_name) @property def norm2(self): + """nn.Module: normalization layer after the second convolution layer""" return getattr(self, self.norm2_name) def forward(self, x): - identity = x + """Forward function.""" - out = self.conv1(x) - out = self.norm1(out) - out = self.relu(out) + def _inner_forward(x): + identity = x + + out = self.conv1(x) + out = self.norm1(out) + out = self.relu(out) + + out = self.conv2(out) + out = self.norm2(out) + + if self.downsample is not None: + identity = self.downsample(x) - out = self.conv2(out) - out = self.norm2(out) + out += identity - if self.downsample is not None: - identity = self.downsample(x) + return out + + if self.with_cp and x.requires_grad: + out = cp.checkpoint(_inner_forward, x) + else: + out = _inner_forward(x) - out += identity out = self.relu(out) return out -class Bottleneck(nn.Module): +class Bottleneck(BaseModule): expansion = 4 def __init__(self, @@ -96,17 +108,20 @@ class Bottleneck(nn.Module): conv_cfg=None, norm_cfg=dict(type='BN'), dcn=None, - gcb=None, - gen_attention=None): + plugins=None, + init_cfg=None): """Bottleneck block for ResNet. - If style is "pytorch", the stride-two layer is the 3x3 conv layer, - if it is "caffe", the stride-two layer is the first 1x1 conv layer. + + If style is "pytorch", the stride-two layer is the 3x3 conv layer, if + it is "caffe", the stride-two layer is the first 1x1 conv layer. """ - super(Bottleneck, self).__init__() + super(Bottleneck, self).__init__(init_cfg) assert style in ['pytorch', 'caffe'] assert dcn is None or isinstance(dcn, dict) - assert gcb is None or isinstance(gcb, dict) - assert gen_attention is None or isinstance(gen_attention, dict) + assert plugins is None or isinstance(plugins, list) + if plugins is not None: + allowed_position = ['after_conv1', 'after_conv2', 'after_conv3'] + assert all(p['position'] in allowed_position for p in plugins) self.inplanes = inplanes self.planes = planes @@ -118,10 +133,23 @@ class Bottleneck(nn.Module): self.norm_cfg = norm_cfg self.dcn = dcn self.with_dcn = dcn is not None - self.gcb = gcb - self.with_gcb = gcb is not None - self.gen_attention = gen_attention - self.with_gen_attention = gen_attention is not None + self.plugins = plugins + self.with_plugins = plugins is not None + + if self.with_plugins: + # collect plugins for conv1/conv2/conv3 + self.after_conv1_plugins = [ + plugin['cfg'] for plugin in plugins + if plugin['position'] == 'after_conv1' + ] + self.after_conv2_plugins = [ + plugin['cfg'] for plugin in plugins + if plugin['position'] == 'after_conv2' + ] + self.after_conv3_plugins = [ + plugin['cfg'] for plugin in plugins + if plugin['position'] == 'after_conv3' + ] if self.style == 'pytorch': self.conv1_stride = 1 @@ -157,7 +185,7 @@ class Bottleneck(nn.Module): dilation=dilation, bias=False) else: - assert self.conv_cfg is None, 'conv_cfg cannot be None for DCN' + assert self.conv_cfg is None, 'conv_cfg must be None for DCN' self.conv2 = build_conv_layer( dcn, planes, @@ -180,48 +208,82 @@ class Bottleneck(nn.Module): self.relu = nn.ReLU(inplace=True) self.downsample = downsample - if self.with_gcb: - gcb_inplanes = planes * self.expansion - self.context_block = ContextBlock(inplanes=gcb_inplanes, **gcb) + if self.with_plugins: + self.after_conv1_plugin_names = self.make_block_plugins( + planes, self.after_conv1_plugins) + self.after_conv2_plugin_names = self.make_block_plugins( + planes, self.after_conv2_plugins) + self.after_conv3_plugin_names = self.make_block_plugins( + planes * self.expansion, self.after_conv3_plugins) + + def make_block_plugins(self, in_channels, plugins): + """make plugins for block. + + Args: + in_channels (int): Input channels of plugin. + plugins (list[dict]): List of plugins cfg to build. - # gen_attention - if self.with_gen_attention: - self.gen_attention_block = GeneralizedAttention( - planes, **gen_attention) + Returns: + list[str]: List of the names of plugin. + """ + assert isinstance(plugins, list) + plugin_names = [] + for plugin in plugins: + plugin = plugin.copy() + name, layer = build_plugin_layer( + plugin, + in_channels=in_channels, + postfix=plugin.pop('postfix', '')) + assert not hasattr(self, name), f'duplicate plugin {name}' + self.add_module(name, layer) + plugin_names.append(name) + return plugin_names + + def forward_plugin(self, x, plugin_names): + out = x + for name in plugin_names: + out = getattr(self, name)(out) + return out @property def norm1(self): + """nn.Module: normalization layer after the first convolution layer""" return getattr(self, self.norm1_name) @property def norm2(self): + """nn.Module: normalization layer after the second convolution layer""" return getattr(self, self.norm2_name) @property def norm3(self): + """nn.Module: normalization layer after the third convolution layer""" return getattr(self, self.norm3_name) def forward(self, x): + """Forward function.""" def _inner_forward(x): identity = x - out = self.conv1(x) out = self.norm1(out) out = self.relu(out) + if self.with_plugins: + out = self.forward_plugin(out, self.after_conv1_plugin_names) + out = self.conv2(out) out = self.norm2(out) out = self.relu(out) - if self.with_gen_attention: - out = self.gen_attention_block(out) + if self.with_plugins: + out = self.forward_plugin(out, self.after_conv2_plugin_names) out = self.conv3(out) out = self.norm3(out) - if self.with_gcb: - out = self.context_block(out) + if self.with_plugins: + out = self.forward_plugin(out, self.after_conv3_plugin_names) if self.downsample is not None: identity = self.downsample(x) @@ -240,93 +302,46 @@ class Bottleneck(nn.Module): return out -def make_res_layer(block, - inplanes, - planes, - blocks, - stride=1, - dilation=1, - style='pytorch', - with_cp=False, - conv_cfg=None, - norm_cfg=dict(type='BN'), - dcn=None, - gcb=None, - gen_attention=None, - gen_attention_blocks=[]): - downsample = None - if stride != 1 or inplanes != planes * block.expansion: - downsample = nn.Sequential( - build_conv_layer( - conv_cfg, - inplanes, - planes * block.expansion, - kernel_size=1, - stride=stride, - bias=False), - build_norm_layer(norm_cfg, planes * block.expansion)[1], - ) - - layers = [] - layers.append( - block( - inplanes=inplanes, - planes=planes, - stride=stride, - dilation=dilation, - downsample=downsample, - style=style, - with_cp=with_cp, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg, - dcn=dcn, - gcb=gcb, - gen_attention=gen_attention if - (0 in gen_attention_blocks) else None)) - inplanes = planes * block.expansion - for i in range(1, blocks): - layers.append( - block( - inplanes=inplanes, - planes=planes, - stride=1, - dilation=dilation, - style=style, - with_cp=with_cp, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg, - dcn=dcn, - gcb=gcb, - gen_attention=gen_attention if - (i in gen_attention_blocks) else None)) - - return nn.Sequential(*layers) - - -@BACKBONES.register_module -class ResNet(nn.Module): +@BACKBONES.register_module() +class ResNet(BaseModule): """ResNet backbone. Args: depth (int): Depth of resnet, from {18, 34, 50, 101, 152}. - in_channels (int): Number of input image channels. Normally 3. - num_stages (int): Resnet stages, normally 4. + stem_channels (int | None): Number of stem channels. If not specified, + it will be the same as `base_channels`. Default: None. + base_channels (int): Number of base channels of res layer. Default: 64. + in_channels (int): Number of input image channels. Default: 3. + num_stages (int): Resnet stages. Default: 4. strides (Sequence[int]): Strides of the first block of each stage. dilations (Sequence[int]): Dilation of each stage. out_indices (Sequence[int]): Output from which stages. style (str): `pytorch` or `caffe`. If set to "pytorch", the stride-two layer is the 3x3 conv layer, otherwise the stride-two layer is the first 1x1 conv layer. + deep_stem (bool): Replace 7x7 conv in input stem with 3 3x3 conv + avg_down (bool): Use AvgPool instead of stride conv when + downsampling in the bottleneck. frozen_stages (int): Stages to be frozen (stop grad and set eval mode). -1 means not freezing any parameters. - norm_cfg (dict): dictionary to construct and config norm layer. + norm_cfg (dict): Dictionary to construct and config norm layer. norm_eval (bool): Whether to set norm layers to eval mode, namely, freeze running stats (mean and var). Note: Effect on Batch Norm and its variants only. + plugins (list[dict]): List of plugins for stages, each dict contains: + + - cfg (dict, required): Cfg dict to build plugin. + - position (str, required): Position inside block to insert + plugin, options are 'after_conv1', 'after_conv2', 'after_conv3'. + - stages (tuple[bool], optional): Stages to apply plugin, length + should be same as 'num_stages'. with_cp (bool): Use checkpoint or not. Using checkpoint will save some memory while slowing down the training speed. - zero_init_residual (bool): whether to use zero init for last norm layer + zero_init_residual (bool): Whether to use zero init for last norm layer in resblocks to let them behave as identity. + pretrained (str, optional): model pretrained path. Default: None + init_cfg (dict or list[dict], optional): Initialization config dict. + Default: None Example: >>> from mmdet.models import ResNet @@ -354,27 +369,67 @@ class ResNet(nn.Module): def __init__(self, depth, in_channels=3, + stem_channels=None, + base_channels=64, num_stages=4, strides=(1, 2, 2, 2), dilations=(1, 1, 1, 1), out_indices=(0, 1, 2, 3), style='pytorch', + deep_stem=False, + avg_down=False, frozen_stages=-1, conv_cfg=None, norm_cfg=dict(type='BN', requires_grad=True), norm_eval=True, dcn=None, stage_with_dcn=(False, False, False, False), - gcb=None, - stage_with_gcb=(False, False, False, False), - gen_attention=None, - stage_with_gen_attention=((), (), (), ()), + plugins=None, with_cp=False, - zero_init_residual=True): - super(ResNet, self).__init__() + zero_init_residual=True, + pretrained=None, + init_cfg=None): + super(ResNet, self).__init__(init_cfg) + self.zero_init_residual = zero_init_residual if depth not in self.arch_settings: - raise KeyError('invalid depth {} for resnet'.format(depth)) + raise KeyError(f'invalid depth {depth} for resnet') + + block_init_cfg = None + assert not (init_cfg and pretrained), \ + 'init_cfg and pretrained cannot be specified at the same time' + if isinstance(pretrained, str): + warnings.warn('DeprecationWarning: pretrained is deprecated, ' + 'please use "init_cfg" instead') + self.init_cfg = dict(type='Pretrained', checkpoint=pretrained) + elif pretrained is None: + if init_cfg is None: + self.init_cfg = [ + dict(type='Kaiming', layer='Conv2d'), + dict( + type='Constant', + val=1, + layer=['_BatchNorm', 'GroupNorm']) + ] + block = self.arch_settings[depth][0] + if self.zero_init_residual: + if block is BasicBlock: + block_init_cfg = dict( + type='Constant', + val=0, + override=dict(name='norm2')) + elif block is Bottleneck: + block_init_cfg = dict( + type='Constant', + val=0, + override=dict(name='norm3')) + else: + raise TypeError('pretrained must be a str or None') + self.depth = depth + if stem_channels is None: + stem_channels = base_channels + self.stem_channels = stem_channels + self.base_channels = base_channels self.num_stages = num_stages assert num_stages >= 1 and num_stages <= 4 self.strides = strides @@ -383,6 +438,8 @@ class ResNet(nn.Module): self.out_indices = out_indices assert max(out_indices) < num_stages self.style = style + self.deep_stem = deep_stem + self.avg_down = avg_down self.frozen_stages = frozen_stages self.conv_cfg = conv_cfg self.norm_cfg = norm_cfg @@ -392,111 +449,193 @@ class ResNet(nn.Module): self.stage_with_dcn = stage_with_dcn if dcn is not None: assert len(stage_with_dcn) == num_stages - self.gen_attention = gen_attention - self.gcb = gcb - self.stage_with_gcb = stage_with_gcb - if gcb is not None: - assert len(stage_with_gcb) == num_stages - self.zero_init_residual = zero_init_residual + self.plugins = plugins self.block, stage_blocks = self.arch_settings[depth] self.stage_blocks = stage_blocks[:num_stages] - self.inplanes = 64 + self.inplanes = stem_channels - self._make_stem_layer(in_channels) + self._make_stem_layer(in_channels, stem_channels) self.res_layers = [] for i, num_blocks in enumerate(self.stage_blocks): stride = strides[i] dilation = dilations[i] dcn = self.dcn if self.stage_with_dcn[i] else None - gcb = self.gcb if self.stage_with_gcb[i] else None - planes = 64 * 2**i - res_layer = make_res_layer( - self.block, - self.inplanes, - planes, - num_blocks, + if plugins is not None: + stage_plugins = self.make_stage_plugins(plugins, i) + else: + stage_plugins = None + planes = base_channels * 2**i + res_layer = self.make_res_layer( + block=self.block, + inplanes=self.inplanes, + planes=planes, + num_blocks=num_blocks, stride=stride, dilation=dilation, style=self.style, + avg_down=self.avg_down, with_cp=with_cp, conv_cfg=conv_cfg, norm_cfg=norm_cfg, dcn=dcn, - gcb=gcb, - gen_attention=gen_attention, - gen_attention_blocks=stage_with_gen_attention[i]) + plugins=stage_plugins, + init_cfg=block_init_cfg) self.inplanes = planes * self.block.expansion - layer_name = 'layer{}'.format(i + 1) + layer_name = f'layer{i + 1}' self.add_module(layer_name, res_layer) self.res_layers.append(layer_name) self._freeze_stages() - self.feat_dim = self.block.expansion * 64 * 2**( + self.feat_dim = self.block.expansion * base_channels * 2**( len(self.stage_blocks) - 1) + def make_stage_plugins(self, plugins, stage_idx): + """Make plugins for ResNet ``stage_idx`` th stage. + + Currently we support to insert ``context_block``, + ``empirical_attention_block``, ``nonlocal_block`` into the backbone + like ResNet/ResNeXt. They could be inserted after conv1/conv2/conv3 of + Bottleneck. + + An example of plugins format could be: + + Examples: + >>> plugins=[ + ... dict(cfg=dict(type='xxx', arg1='xxx'), + ... stages=(False, True, True, True), + ... position='after_conv2'), + ... dict(cfg=dict(type='yyy'), + ... stages=(True, True, True, True), + ... position='after_conv3'), + ... dict(cfg=dict(type='zzz', postfix='1'), + ... stages=(True, True, True, True), + ... position='after_conv3'), + ... dict(cfg=dict(type='zzz', postfix='2'), + ... stages=(True, True, True, True), + ... position='after_conv3') + ... ] + >>> self = ResNet(depth=18) + >>> stage_plugins = self.make_stage_plugins(plugins, 0) + >>> assert len(stage_plugins) == 3 + + Suppose ``stage_idx=0``, the structure of blocks in the stage would be: + + .. code-block:: none + + conv1-> conv2->conv3->yyy->zzz1->zzz2 + + Suppose 'stage_idx=1', the structure of blocks in the stage would be: + + .. code-block:: none + + conv1-> conv2->xxx->conv3->yyy->zzz1->zzz2 + + If stages is missing, the plugin would be applied to all stages. + + Args: + plugins (list[dict]): List of plugins cfg to build. The postfix is + required if multiple same type plugins are inserted. + stage_idx (int): Index of stage to build + + Returns: + list[dict]: Plugins for current stage + """ + stage_plugins = [] + for plugin in plugins: + plugin = plugin.copy() + stages = plugin.pop('stages', None) + assert stages is None or len(stages) == self.num_stages + # whether to insert plugin into current stage + if stages is None or stages[stage_idx]: + stage_plugins.append(plugin) + + return stage_plugins + + def make_res_layer(self, **kwargs): + """Pack all blocks in a stage into a ``ResLayer``.""" + return ResLayer(**kwargs) + @property def norm1(self): + """nn.Module: the normalization layer named "norm1" """ return getattr(self, self.norm1_name) - def _make_stem_layer(self, in_channels): - self.conv1 = build_conv_layer( - self.conv_cfg, - in_channels, - 64, - kernel_size=7, - stride=2, - padding=3, - bias=False) - self.norm1_name, norm1 = build_norm_layer(self.norm_cfg, 64, postfix=1) - self.add_module(self.norm1_name, norm1) - self.relu = nn.ReLU(inplace=True) + def _make_stem_layer(self, in_channels, stem_channels): + if self.deep_stem: + self.stem = nn.Sequential( + build_conv_layer( + self.conv_cfg, + in_channels, + stem_channels // 2, + kernel_size=3, + stride=2, + padding=1, + bias=False), + build_norm_layer(self.norm_cfg, stem_channels // 2)[1], + nn.ReLU(inplace=True), + build_conv_layer( + self.conv_cfg, + stem_channels // 2, + stem_channels // 2, + kernel_size=3, + stride=1, + padding=1, + bias=False), + build_norm_layer(self.norm_cfg, stem_channels // 2)[1], + nn.ReLU(inplace=True), + build_conv_layer( + self.conv_cfg, + stem_channels // 2, + stem_channels, + kernel_size=3, + stride=1, + padding=1, + bias=False), + build_norm_layer(self.norm_cfg, stem_channels)[1], + nn.ReLU(inplace=True)) + else: + self.conv1 = build_conv_layer( + self.conv_cfg, + in_channels, + stem_channels, + kernel_size=7, + stride=2, + padding=3, + bias=False) + self.norm1_name, norm1 = build_norm_layer( + self.norm_cfg, stem_channels, postfix=1) + self.add_module(self.norm1_name, norm1) + self.relu = nn.ReLU(inplace=True) self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1) def _freeze_stages(self): if self.frozen_stages >= 0: - self.norm1.eval() - for m in [self.conv1, self.norm1]: - for param in m.parameters(): + if self.deep_stem: + self.stem.eval() + for param in self.stem.parameters(): param.requires_grad = False + else: + self.norm1.eval() + for m in [self.conv1, self.norm1]: + for param in m.parameters(): + param.requires_grad = False for i in range(1, self.frozen_stages + 1): - m = getattr(self, 'layer{}'.format(i)) + m = getattr(self, f'layer{i}') m.eval() for param in m.parameters(): param.requires_grad = False - def init_weights(self, pretrained=None): - if isinstance(pretrained, str): - logger = get_root_logger() - load_checkpoint(self, pretrained, strict=False, logger=logger) - elif pretrained is None: - for m in self.modules(): - if isinstance(m, nn.Conv2d): - kaiming_init(m) - elif isinstance(m, (_BatchNorm, nn.GroupNorm)): - constant_init(m, 1) - - if self.dcn is not None: - for m in self.modules(): - if isinstance(m, Bottleneck) and hasattr( - m, 'conv2_offset'): - constant_init(m.conv2_offset, 0) - - if self.zero_init_residual: - for m in self.modules(): - if isinstance(m, Bottleneck): - constant_init(m.norm3, 0) - elif isinstance(m, BasicBlock): - constant_init(m.norm2, 0) - else: - raise TypeError('pretrained must be a str or None') - def forward(self, x): - x = self.conv1(x) - x = self.norm1(x) - x = self.relu(x) + """Forward function.""" + if self.deep_stem: + x = self.stem(x) + else: + x = self.conv1(x) + x = self.norm1(x) + x = self.relu(x) x = self.maxpool(x) outs = [] for i, layer_name in enumerate(self.res_layers): @@ -507,6 +646,8 @@ class ResNet(nn.Module): return tuple(outs) def train(self, mode=True): + """Convert the model into training mode while keep normalization layer + freezed.""" super(ResNet, self).train(mode) self._freeze_stages() if mode and self.norm_eval: @@ -514,3 +655,18 @@ class ResNet(nn.Module): # trick: eval have effect on BatchNorm only if isinstance(m, _BatchNorm): m.eval() + + +@BACKBONES.register_module() +class ResNetV1d(ResNet): + r"""ResNetV1d variant described in `Bag of Tricks + `_. + + Compared with default ResNet(ResNetV1b), ResNetV1d replaces the 7x7 conv in + the input stem with three 3x3 convs. And in the downsampling block, a 2x2 + avg_pool with stride 2 is added before conv, whose stride is changed to 1. + """ + + def __init__(self, **kwargs): + super(ResNetV1d, self).__init__( + deep_stem=True, avg_down=True, **kwargs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/resnext.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/resnext.py deleted file mode 100644 index 0c184abb6..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/resnext.py +++ /dev/null @@ -1,222 +0,0 @@ -import math - -import torch.nn as nn - -from ..registry import BACKBONES -from ..utils import build_conv_layer, build_norm_layer -from .resnet import Bottleneck as _Bottleneck -from .resnet import ResNet - - -class Bottleneck(_Bottleneck): - - def __init__(self, inplanes, planes, groups=1, base_width=4, **kwargs): - """Bottleneck block for ResNeXt. - If style is "pytorch", the stride-two layer is the 3x3 conv layer, - if it is "caffe", the stride-two layer is the first 1x1 conv layer. - """ - super(Bottleneck, self).__init__(inplanes, planes, **kwargs) - - if groups == 1: - width = self.planes - else: - width = math.floor(self.planes * (base_width / 64)) * groups - - self.norm1_name, norm1 = build_norm_layer( - self.norm_cfg, width, postfix=1) - self.norm2_name, norm2 = build_norm_layer( - self.norm_cfg, width, postfix=2) - self.norm3_name, norm3 = build_norm_layer( - self.norm_cfg, self.planes * self.expansion, postfix=3) - - self.conv1 = build_conv_layer( - self.conv_cfg, - self.inplanes, - width, - kernel_size=1, - stride=self.conv1_stride, - bias=False) - self.add_module(self.norm1_name, norm1) - fallback_on_stride = False - self.with_modulated_dcn = False - if self.with_dcn: - fallback_on_stride = self.dcn.pop('fallback_on_stride', False) - if not self.with_dcn or fallback_on_stride: - self.conv2 = build_conv_layer( - self.conv_cfg, - width, - width, - kernel_size=3, - stride=self.conv2_stride, - padding=self.dilation, - dilation=self.dilation, - groups=groups, - bias=False) - else: - assert self.conv_cfg is None, 'conv_cfg must be None for DCN' - self.conv2 = build_conv_layer( - self.dcn, - width, - width, - kernel_size=3, - stride=self.conv2_stride, - padding=self.dilation, - dilation=self.dilation, - groups=groups, - bias=False) - - self.add_module(self.norm2_name, norm2) - self.conv3 = build_conv_layer( - self.conv_cfg, - width, - self.planes * self.expansion, - kernel_size=1, - bias=False) - self.add_module(self.norm3_name, norm3) - - -def make_res_layer(block, - inplanes, - planes, - blocks, - stride=1, - dilation=1, - groups=1, - base_width=4, - style='pytorch', - with_cp=False, - conv_cfg=None, - norm_cfg=dict(type='BN'), - dcn=None, - gcb=None): - downsample = None - if stride != 1 or inplanes != planes * block.expansion: - downsample = nn.Sequential( - build_conv_layer( - conv_cfg, - inplanes, - planes * block.expansion, - kernel_size=1, - stride=stride, - bias=False), - build_norm_layer(norm_cfg, planes * block.expansion)[1], - ) - - layers = [] - layers.append( - block( - inplanes=inplanes, - planes=planes, - stride=stride, - dilation=dilation, - downsample=downsample, - groups=groups, - base_width=base_width, - style=style, - with_cp=with_cp, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg, - dcn=dcn, - gcb=gcb)) - inplanes = planes * block.expansion - for i in range(1, blocks): - layers.append( - block( - inplanes=inplanes, - planes=planes, - stride=1, - dilation=dilation, - groups=groups, - base_width=base_width, - style=style, - with_cp=with_cp, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg, - dcn=dcn, - gcb=gcb)) - - return nn.Sequential(*layers) - - -@BACKBONES.register_module -class ResNeXt(ResNet): - """ResNeXt backbone. - - Args: - depth (int): Depth of resnet, from {18, 34, 50, 101, 152}. - in_channels (int): Number of input image channels. Normally 3. - num_stages (int): Resnet stages, normally 4. - groups (int): Group of resnext. - base_width (int): Base width of resnext. - strides (Sequence[int]): Strides of the first block of each stage. - dilations (Sequence[int]): Dilation of each stage. - out_indices (Sequence[int]): Output from which stages. - style (str): `pytorch` or `caffe`. If set to "pytorch", the stride-two - layer is the 3x3 conv layer, otherwise the stride-two layer is - the first 1x1 conv layer. - frozen_stages (int): Stages to be frozen (all param fixed). -1 means - not freezing any parameters. - norm_cfg (dict): dictionary to construct and config norm layer. - norm_eval (bool): Whether to set norm layers to eval mode, namely, - freeze running stats (mean and var). Note: Effect on Batch Norm - and its variants only. - with_cp (bool): Use checkpoint or not. Using checkpoint will save some - memory while slowing down the training speed. - zero_init_residual (bool): whether to use zero init for last norm layer - in resblocks to let them behave as identity. - - Example: - >>> from mmdet.models import ResNeXt - >>> import torch - >>> self = ResNeXt(depth=50) - >>> self.eval() - >>> inputs = torch.rand(1, 3, 32, 32) - >>> level_outputs = self.forward(inputs) - >>> for level_out in level_outputs: - ... print(tuple(level_out.shape)) - (1, 256, 8, 8) - (1, 512, 4, 4) - (1, 1024, 2, 2) - (1, 2048, 1, 1) - """ - - arch_settings = { - 50: (Bottleneck, (3, 4, 6, 3)), - 101: (Bottleneck, (3, 4, 23, 3)), - 152: (Bottleneck, (3, 8, 36, 3)) - } - - def __init__(self, groups=1, base_width=4, **kwargs): - super(ResNeXt, self).__init__(**kwargs) - self.groups = groups - self.base_width = base_width - - self.inplanes = 64 - self.res_layers = [] - for i, num_blocks in enumerate(self.stage_blocks): - stride = self.strides[i] - dilation = self.dilations[i] - dcn = self.dcn if self.stage_with_dcn[i] else None - gcb = self.gcb if self.stage_with_gcb[i] else None - planes = 64 * 2**i - res_layer = make_res_layer( - self.block, - self.inplanes, - planes, - num_blocks, - stride=stride, - dilation=dilation, - groups=self.groups, - base_width=self.base_width, - style=self.style, - with_cp=self.with_cp, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg, - dcn=dcn, - gcb=gcb) - self.inplanes = planes * self.block.expansion - layer_name = 'layer{}'.format(i + 1) - self.add_module(layer_name, res_layer) - self.res_layers.append(layer_name) - - self._freeze_stages() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/ssd_vgg.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/ssd_vgg.py deleted file mode 100644 index c7615e2a7..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/backbones/ssd_vgg.py +++ /dev/null @@ -1,153 +0,0 @@ -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import VGG, constant_init, kaiming_init, normal_init, xavier_init -from mmcv.runner import load_checkpoint - -from mmdet.utils import get_root_logger -from ..registry import BACKBONES - - -@BACKBONES.register_module -class SSDVGG(VGG): - """VGG Backbone network for single-shot-detection - - Args: - input_size (int): width and height of input, from {300, 512}. - depth (int): Depth of vgg, from {11, 13, 16, 19}. - out_indices (Sequence[int]): Output from which stages. - - Example: - >>> self = SSDVGG(input_size=300, depth=11) - >>> self.eval() - >>> inputs = torch.rand(1, 3, 300, 300) - >>> level_outputs = self.forward(inputs) - >>> for level_out in level_outputs: - ... print(tuple(level_out.shape)) - (1, 1024, 19, 19) - (1, 512, 10, 10) - (1, 256, 5, 5) - (1, 256, 3, 3) - (1, 256, 1, 1) - """ - extra_setting = { - 300: (256, 'S', 512, 128, 'S', 256, 128, 256, 128, 256), - 512: (256, 'S', 512, 128, 'S', 256, 128, 'S', 256, 128, 'S', 256, 128), - } - - def __init__(self, - input_size, - depth, - with_last_pool=False, - ceil_mode=True, - out_indices=(3, 4), - out_feature_indices=(22, 34), - l2_norm_scale=20.): - # TODO: in_channels for mmcv.VGG - super(SSDVGG, self).__init__( - depth, - with_last_pool=with_last_pool, - ceil_mode=ceil_mode, - out_indices=out_indices) - assert input_size in (300, 512) - self.input_size = input_size - - self.features.add_module( - str(len(self.features)), - nn.MaxPool2d(kernel_size=3, stride=1, padding=1)) - self.features.add_module( - str(len(self.features)), - nn.Conv2d(512, 1024, kernel_size=3, padding=6, dilation=6)) - self.features.add_module( - str(len(self.features)), nn.ReLU(inplace=True)) - self.features.add_module( - str(len(self.features)), nn.Conv2d(1024, 1024, kernel_size=1)) - self.features.add_module( - str(len(self.features)), nn.ReLU(inplace=True)) - self.out_feature_indices = out_feature_indices - - self.inplanes = 1024 - self.extra = self._make_extra_layers(self.extra_setting[input_size]) - self.l2_norm = L2Norm( - self.features[out_feature_indices[0] - 1].out_channels, - l2_norm_scale) - - def init_weights(self, pretrained=None): - if isinstance(pretrained, str): - logger = get_root_logger() - load_checkpoint(self, pretrained, strict=False, logger=logger) - elif pretrained is None: - for m in self.features.modules(): - if isinstance(m, nn.Conv2d): - kaiming_init(m) - elif isinstance(m, nn.BatchNorm2d): - constant_init(m, 1) - elif isinstance(m, nn.Linear): - normal_init(m, std=0.01) - else: - raise TypeError('pretrained must be a str or None') - - for m in self.extra.modules(): - if isinstance(m, nn.Conv2d): - xavier_init(m, distribution='uniform') - - constant_init(self.l2_norm, self.l2_norm.scale) - - def forward(self, x): - outs = [] - for i, layer in enumerate(self.features): - x = layer(x) - if i in self.out_feature_indices: - outs.append(x) - for i, layer in enumerate(self.extra): - x = F.relu(layer(x), inplace=True) - if i % 2 == 1: - outs.append(x) - outs[0] = self.l2_norm(outs[0]) - if len(outs) == 1: - return outs[0] - else: - return tuple(outs) - - def _make_extra_layers(self, outplanes): - layers = [] - kernel_sizes = (1, 3) - num_layers = 0 - outplane = None - for i in range(len(outplanes)): - if self.inplanes == 'S': - self.inplanes = outplane - continue - k = kernel_sizes[num_layers % 2] - if outplanes[i] == 'S': - outplane = outplanes[i + 1] - conv = nn.Conv2d( - self.inplanes, outplane, k, stride=2, padding=1) - else: - outplane = outplanes[i] - conv = nn.Conv2d( - self.inplanes, outplane, k, stride=1, padding=0) - layers.append(conv) - self.inplanes = outplanes[i] - num_layers += 1 - if self.input_size == 512: - layers.append(nn.Conv2d(self.inplanes, 256, 4, padding=1)) - - return nn.Sequential(*layers) - - -class L2Norm(nn.Module): - - def __init__(self, n_dims, scale=20., eps=1e-10): - super(L2Norm, self).__init__() - self.n_dims = n_dims - self.weight = nn.Parameter(torch.Tensor(self.n_dims)) - self.eps = eps - self.scale = scale - - def forward(self, x): - # normalization layer convert to FP32 in FP16 training - x_float = x.float() - norm = x_float.pow(2).sum(1, keepdim=True).sqrt() + self.eps - return (self.weight[None, :, None, None].float().expand_as(x_float) * - x_float / norm).type_as(x) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/__init__.py deleted file mode 100644 index a668bdb01..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -from .bbox_head import BBoxHead -from .convfc_bbox_head import ConvFCBBoxHead, SharedFCBBoxHead -from .double_bbox_head import DoubleConvFCBBoxHead - -__all__ = [ - 'BBoxHead', 'ConvFCBBoxHead', 'SharedFCBBoxHead', 'DoubleConvFCBBoxHead' -] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/bbox_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/bbox_head.py deleted file mode 100644 index 8ab878a01..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/bbox_head.py +++ /dev/null @@ -1,282 +0,0 @@ -import torch -import torch.nn as nn -import torch.nn.functional as F -from torch.nn.modules.utils import _pair - -from mmdet.core import (auto_fp16, bbox_target, delta2bbox, force_fp32, - multiclass_nms) -from ..builder import build_loss -from ..losses import accuracy -from ..registry import HEADS - - -@HEADS.register_module -class BBoxHead(nn.Module): - """Simplest RoI head, with only two fc layers for classification and - regression respectively""" - - def __init__(self, - with_avg_pool=False, - with_cls=True, - with_reg=True, - roi_feat_size=7, - in_channels=256, - num_classes=81, - target_means=[0., 0., 0., 0.], - target_stds=[0.1, 0.1, 0.2, 0.2], - reg_class_agnostic=False, - loss_cls=dict( - type='CrossEntropyLoss', - use_sigmoid=False, - loss_weight=1.0), - loss_bbox=dict( - type='SmoothL1Loss', beta=1.0, loss_weight=1.0)): - super(BBoxHead, self).__init__() - assert with_cls or with_reg - self.with_avg_pool = with_avg_pool - self.with_cls = with_cls - self.with_reg = with_reg - self.roi_feat_size = _pair(roi_feat_size) - self.roi_feat_area = self.roi_feat_size[0] * self.roi_feat_size[1] - self.in_channels = in_channels - self.num_classes = num_classes - self.target_means = target_means - self.target_stds = target_stds - self.reg_class_agnostic = reg_class_agnostic - self.fp16_enabled = False - - self.loss_cls = build_loss(loss_cls) - self.loss_bbox = build_loss(loss_bbox) - - in_channels = self.in_channels - if self.with_avg_pool: - self.avg_pool = nn.AvgPool2d(self.roi_feat_size) - else: - in_channels *= self.roi_feat_area - if self.with_cls: - self.fc_cls = nn.Linear(in_channels, num_classes) - if self.with_reg: - out_dim_reg = 4 if reg_class_agnostic else 4 * num_classes - self.fc_reg = nn.Linear(in_channels, out_dim_reg) - self.debug_imgs = None - - def init_weights(self): - if self.with_cls: - nn.init.normal_(self.fc_cls.weight, 0, 0.01) - nn.init.constant_(self.fc_cls.bias, 0) - if self.with_reg: - nn.init.normal_(self.fc_reg.weight, 0, 0.001) - nn.init.constant_(self.fc_reg.bias, 0) - - @auto_fp16() - def forward(self, x): - if self.with_avg_pool: - x = self.avg_pool(x) - x = x.view(x.size(0), -1) - cls_score = self.fc_cls(x) if self.with_cls else None - bbox_pred = self.fc_reg(x) if self.with_reg else None - return cls_score, bbox_pred - - def get_target(self, sampling_results, gt_bboxes, gt_labels, - rcnn_train_cfg): - pos_proposals = [res.pos_bboxes for res in sampling_results] - neg_proposals = [res.neg_bboxes for res in sampling_results] - pos_gt_bboxes = [res.pos_gt_bboxes for res in sampling_results] - pos_gt_labels = [res.pos_gt_labels for res in sampling_results] - reg_classes = 1 if self.reg_class_agnostic else self.num_classes - cls_reg_targets = bbox_target( - pos_proposals, - neg_proposals, - pos_gt_bboxes, - pos_gt_labels, - rcnn_train_cfg, - reg_classes, - target_means=self.target_means, - target_stds=self.target_stds) - return cls_reg_targets - - @force_fp32(apply_to=('cls_score', 'bbox_pred')) - def loss(self, - cls_score, - bbox_pred, - labels, - label_weights, - bbox_targets, - bbox_weights, - reduction_override=None): - losses = dict() - if cls_score is not None: - avg_factor = max(torch.sum(label_weights > 0).float().item(), 1.) - if cls_score.numel() > 0: - losses['loss_cls'] = self.loss_cls( - cls_score, - labels, - label_weights, - avg_factor=avg_factor, - reduction_override=reduction_override) - losses['acc'] = accuracy(cls_score, labels) - if bbox_pred is not None: - pos_inds = labels > 0 - if pos_inds.any(): - if self.reg_class_agnostic: - pos_bbox_pred = bbox_pred.view(bbox_pred.size(0), - 4)[pos_inds] - else: - pos_bbox_pred = bbox_pred.view(bbox_pred.size(0), -1, - 4)[pos_inds, - labels[pos_inds]] - losses['loss_bbox'] = self.loss_bbox( - pos_bbox_pred, - bbox_targets[pos_inds], - bbox_weights[pos_inds], - avg_factor=bbox_targets.size(0), - reduction_override=reduction_override) - return losses - - @force_fp32(apply_to=('cls_score', 'bbox_pred')) - def get_det_bboxes(self, - rois, - cls_score, - bbox_pred, - img_shape, - scale_factor, - rescale=False, - cfg=None): - if isinstance(cls_score, list): - cls_score = sum(cls_score) / float(len(cls_score)) - scores = F.softmax(cls_score, dim=1) if cls_score is not None else None - - if bbox_pred is not None: - bboxes = delta2bbox(rois[:, 1:], bbox_pred, self.target_means, - self.target_stds, img_shape) - else: - bboxes = rois[:, 1:].clone() - if img_shape is not None: - bboxes[:, [0, 2]].clamp_(min=0, max=img_shape[1] - 1) - bboxes[:, [1, 3]].clamp_(min=0, max=img_shape[0] - 1) - - if rescale: - if isinstance(scale_factor, float): - bboxes /= scale_factor - else: - scale_factor = torch.from_numpy(scale_factor).to(bboxes.device) - bboxes = (bboxes.view(bboxes.size(0), -1, 4) / - scale_factor).view(bboxes.size()[0], -1) - - if cfg is None: - return bboxes, scores - else: - det_bboxes, det_labels = multiclass_nms(bboxes, scores, - cfg.score_thr, cfg.nms, - cfg.max_per_img) - - return det_bboxes, det_labels - - @force_fp32(apply_to=('bbox_preds', )) - def refine_bboxes(self, rois, labels, bbox_preds, pos_is_gts, img_metas): - """Refine bboxes during training. - - Args: - rois (Tensor): Shape (n*bs, 5), where n is image number per GPU, - and bs is the sampled RoIs per image. The first column is - the image id and the next 4 columns are x1, y1, x2, y2. - labels (Tensor): Shape (n*bs, ). - bbox_preds (Tensor): Shape (n*bs, 4) or (n*bs, 4*#class). - pos_is_gts (list[Tensor]): Flags indicating if each positive bbox - is a gt bbox. - img_metas (list[dict]): Meta info of each image. - - Returns: - list[Tensor]: Refined bboxes of each image in a mini-batch. - - Example: - >>> # xdoctest: +REQUIRES(module:kwarray) - >>> import kwarray - >>> import numpy as np - >>> from mmdet.core.bbox.demodata import random_boxes - >>> self = BBoxHead(reg_class_agnostic=True) - >>> n_roi = 2 - >>> n_img = 4 - >>> scale = 512 - >>> rng = np.random.RandomState(0) - >>> img_metas = [{'img_shape': (scale, scale)} - ... for _ in range(n_img)] - >>> # Create rois in the expected format - >>> roi_boxes = random_boxes(n_roi, scale=scale, rng=rng) - >>> img_ids = torch.randint(0, n_img, (n_roi,)) - >>> img_ids = img_ids.float() - >>> rois = torch.cat([img_ids[:, None], roi_boxes], dim=1) - >>> # Create other args - >>> labels = torch.randint(0, 2, (n_roi,)).long() - >>> bbox_preds = random_boxes(n_roi, scale=scale, rng=rng) - >>> # For each image, pretend random positive boxes are gts - >>> is_label_pos = (labels.numpy() > 0).astype(np.int) - >>> lbl_per_img = kwarray.group_items(is_label_pos, - ... img_ids.numpy()) - >>> pos_per_img = [sum(lbl_per_img.get(gid, [])) - ... for gid in range(n_img)] - >>> pos_is_gts = [ - >>> torch.randint(0, 2, (npos,)).byte().sort( - >>> descending=True)[0] - >>> for npos in pos_per_img - >>> ] - >>> bboxes_list = self.refine_bboxes(rois, labels, bbox_preds, - >>> pos_is_gts, img_metas) - >>> print(bboxes_list) - """ - img_ids = rois[:, 0].long().unique(sorted=True) - assert img_ids.numel() <= len(img_metas) - - bboxes_list = [] - for i in range(len(img_metas)): - inds = torch.nonzero(rois[:, 0] == i).squeeze(dim=1) - num_rois = inds.numel() - - bboxes_ = rois[inds, 1:] - label_ = labels[inds] - bbox_pred_ = bbox_preds[inds] - img_meta_ = img_metas[i] - pos_is_gts_ = pos_is_gts[i] - - bboxes = self.regress_by_class(bboxes_, label_, bbox_pred_, - img_meta_) - - # filter gt bboxes - pos_keep = 1 - pos_is_gts_ - keep_inds = pos_is_gts_.new_ones(num_rois) - keep_inds[:len(pos_is_gts_)] = pos_keep - - bboxes_list.append(bboxes[keep_inds]) - - return bboxes_list - - @force_fp32(apply_to=('bbox_pred', )) - def regress_by_class(self, rois, label, bbox_pred, img_meta): - """Regress the bbox for the predicted class. Used in Cascade R-CNN. - - Args: - rois (Tensor): shape (n, 4) or (n, 5) - label (Tensor): shape (n, ) - bbox_pred (Tensor): shape (n, 4*(#class+1)) or (n, 4) - img_meta (dict): Image meta info. - - Returns: - Tensor: Regressed bboxes, the same shape as input rois. - """ - assert rois.size(1) == 4 or rois.size(1) == 5, repr(rois.shape) - - if not self.reg_class_agnostic: - label = label * 4 - inds = torch.stack((label, label + 1, label + 2, label + 3), 1) - bbox_pred = torch.gather(bbox_pred, 1, inds) - assert bbox_pred.size(1) == 4 - - if rois.size(1) == 4: - new_rois = delta2bbox(rois, bbox_pred, self.target_means, - self.target_stds, img_meta['img_shape']) - else: - bboxes = delta2bbox(rois[:, 1:], bbox_pred, self.target_means, - self.target_stds, img_meta['img_shape']) - new_rois = torch.cat((rois[:, [0]], bboxes), dim=1) - - return new_rois diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/convfc_bbox_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/convfc_bbox_head.py deleted file mode 100644 index f0f89778e..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/convfc_bbox_head.py +++ /dev/null @@ -1,187 +0,0 @@ -import torch.nn as nn - -from ..registry import HEADS -from ..utils import ConvModule -from .bbox_head import BBoxHead - - -@HEADS.register_module -class ConvFCBBoxHead(BBoxHead): - r"""More general bbox head, with shared conv and fc layers and two optional - separated branches. - - /-> cls convs -> cls fcs -> cls - shared convs -> shared fcs - \-> reg convs -> reg fcs -> reg - """ # noqa: W605 - - def __init__(self, - num_shared_convs=0, - num_shared_fcs=0, - num_cls_convs=0, - num_cls_fcs=0, - num_reg_convs=0, - num_reg_fcs=0, - conv_out_channels=256, - fc_out_channels=1024, - conv_cfg=None, - norm_cfg=None, - *args, - **kwargs): - super(ConvFCBBoxHead, self).__init__(*args, **kwargs) - assert (num_shared_convs + num_shared_fcs + num_cls_convs + - num_cls_fcs + num_reg_convs + num_reg_fcs > 0) - if num_cls_convs > 0 or num_reg_convs > 0: - assert num_shared_fcs == 0 - if not self.with_cls: - assert num_cls_convs == 0 and num_cls_fcs == 0 - if not self.with_reg: - assert num_reg_convs == 0 and num_reg_fcs == 0 - self.num_shared_convs = num_shared_convs - self.num_shared_fcs = num_shared_fcs - self.num_cls_convs = num_cls_convs - self.num_cls_fcs = num_cls_fcs - self.num_reg_convs = num_reg_convs - self.num_reg_fcs = num_reg_fcs - self.conv_out_channels = conv_out_channels - self.fc_out_channels = fc_out_channels - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - - # add shared convs and fcs - self.shared_convs, self.shared_fcs, last_layer_dim = \ - self._add_conv_fc_branch( - self.num_shared_convs, self.num_shared_fcs, self.in_channels, - True) - self.shared_out_channels = last_layer_dim - - # add cls specific branch - self.cls_convs, self.cls_fcs, self.cls_last_dim = \ - self._add_conv_fc_branch( - self.num_cls_convs, self.num_cls_fcs, self.shared_out_channels) - - # add reg specific branch - self.reg_convs, self.reg_fcs, self.reg_last_dim = \ - self._add_conv_fc_branch( - self.num_reg_convs, self.num_reg_fcs, self.shared_out_channels) - - if self.num_shared_fcs == 0 and not self.with_avg_pool: - if self.num_cls_fcs == 0: - self.cls_last_dim *= self.roi_feat_area - if self.num_reg_fcs == 0: - self.reg_last_dim *= self.roi_feat_area - - self.relu = nn.ReLU(inplace=True) - # reconstruct fc_cls and fc_reg since input channels are changed - if self.with_cls: - self.fc_cls = nn.Linear(self.cls_last_dim, self.num_classes) - if self.with_reg: - out_dim_reg = (4 if self.reg_class_agnostic else 4 * - self.num_classes) - self.fc_reg = nn.Linear(self.reg_last_dim, out_dim_reg) - - def _add_conv_fc_branch(self, - num_branch_convs, - num_branch_fcs, - in_channels, - is_shared=False): - """Add shared or separable branch - - convs -> avg pool (optional) -> fcs - """ - last_layer_dim = in_channels - # add branch specific conv layers - branch_convs = nn.ModuleList() - if num_branch_convs > 0: - for i in range(num_branch_convs): - conv_in_channels = ( - last_layer_dim if i == 0 else self.conv_out_channels) - branch_convs.append( - ConvModule( - conv_in_channels, - self.conv_out_channels, - 3, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg)) - last_layer_dim = self.conv_out_channels - # add branch specific fc layers - branch_fcs = nn.ModuleList() - if num_branch_fcs > 0: - # for shared branch, only consider self.with_avg_pool - # for separated branches, also consider self.num_shared_fcs - if (is_shared - or self.num_shared_fcs == 0) and not self.with_avg_pool: - last_layer_dim *= self.roi_feat_area - for i in range(num_branch_fcs): - fc_in_channels = ( - last_layer_dim if i == 0 else self.fc_out_channels) - branch_fcs.append( - nn.Linear(fc_in_channels, self.fc_out_channels)) - last_layer_dim = self.fc_out_channels - return branch_convs, branch_fcs, last_layer_dim - - def init_weights(self): - super(ConvFCBBoxHead, self).init_weights() - for module_list in [self.shared_fcs, self.cls_fcs, self.reg_fcs]: - for m in module_list.modules(): - if isinstance(m, nn.Linear): - nn.init.xavier_uniform_(m.weight) - nn.init.constant_(m.bias, 0) - - def forward(self, x): - # shared part - if self.num_shared_convs > 0: - for conv in self.shared_convs: - x = conv(x) - - if self.num_shared_fcs > 0: - if self.with_avg_pool: - x = self.avg_pool(x) - - x = x.flatten(1) - - for fc in self.shared_fcs: - x = self.relu(fc(x)) - # separate branches - x_cls = x - x_reg = x - - for conv in self.cls_convs: - x_cls = conv(x_cls) - if x_cls.dim() > 2: - if self.with_avg_pool: - x_cls = self.avg_pool(x_cls) - x_cls = x_cls.flatten(1) - for fc in self.cls_fcs: - x_cls = self.relu(fc(x_cls)) - - for conv in self.reg_convs: - x_reg = conv(x_reg) - if x_reg.dim() > 2: - if self.with_avg_pool: - x_reg = self.avg_pool(x_reg) - x_reg = x_reg.flatten(1) - for fc in self.reg_fcs: - x_reg = self.relu(fc(x_reg)) - - cls_score = self.fc_cls(x_cls) if self.with_cls else None - bbox_pred = self.fc_reg(x_reg) if self.with_reg else None - return cls_score, bbox_pred - - -@HEADS.register_module -class SharedFCBBoxHead(ConvFCBBoxHead): - - def __init__(self, num_fcs=2, fc_out_channels=1024, *args, **kwargs): - assert num_fcs >= 1 - super(SharedFCBBoxHead, self).__init__( - num_shared_convs=0, - num_shared_fcs=num_fcs, - num_cls_convs=0, - num_cls_fcs=0, - num_reg_convs=0, - num_reg_fcs=0, - fc_out_channels=fc_out_channels, - *args, - **kwargs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/double_bbox_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/double_bbox_head.py deleted file mode 100644 index c8a0e2699..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/bbox_heads/double_bbox_head.py +++ /dev/null @@ -1,170 +0,0 @@ -import torch.nn as nn -from mmcv.cnn.weight_init import normal_init, xavier_init - -from ..backbones.resnet import Bottleneck -from ..registry import HEADS -from ..utils import ConvModule -from .bbox_head import BBoxHead - - -class BasicResBlock(nn.Module): - """Basic residual block. - - This block is a little different from the block in the ResNet backbone. - The kernel size of conv1 is 1 in this block while 3 in ResNet BasicBlock. - - Args: - in_channels (int): Channels of the input feature map. - out_channels (int): Channels of the output feature map. - conv_cfg (dict): The config dict for convolution layers. - norm_cfg (dict): The config dict for normalization layers. - """ - - def __init__(self, - in_channels, - out_channels, - conv_cfg=None, - norm_cfg=dict(type='BN')): - super(BasicResBlock, self).__init__() - - # main path - self.conv1 = ConvModule( - in_channels, - in_channels, - kernel_size=3, - padding=1, - bias=False, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg) - self.conv2 = ConvModule( - in_channels, - out_channels, - kernel_size=1, - bias=False, - activation=None, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg) - - # identity path - self.conv_identity = ConvModule( - in_channels, - out_channels, - kernel_size=1, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg, - activation=None) - - self.relu = nn.ReLU(inplace=True) - - def forward(self, x): - identity = x - - x = self.conv1(x) - x = self.conv2(x) - - identity = self.conv_identity(identity) - out = x + identity - - out = self.relu(out) - return out - - -@HEADS.register_module -class DoubleConvFCBBoxHead(BBoxHead): - r"""Bbox head used in Double-Head R-CNN - - /-> cls - /-> shared convs -> - \-> reg - roi features - /-> cls - \-> shared fc -> - \-> reg - """ # noqa: W605 - - def __init__(self, - num_convs=0, - num_fcs=0, - conv_out_channels=1024, - fc_out_channels=1024, - conv_cfg=None, - norm_cfg=dict(type='BN'), - **kwargs): - kwargs.setdefault('with_avg_pool', True) - super(DoubleConvFCBBoxHead, self).__init__(**kwargs) - assert self.with_avg_pool - assert num_convs > 0 - assert num_fcs > 0 - self.num_convs = num_convs - self.num_fcs = num_fcs - self.conv_out_channels = conv_out_channels - self.fc_out_channels = fc_out_channels - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - - # increase the channel of input features - self.res_block = BasicResBlock(self.in_channels, - self.conv_out_channels) - - # add conv heads - self.conv_branch = self._add_conv_branch() - # add fc heads - self.fc_branch = self._add_fc_branch() - - out_dim_reg = 4 if self.reg_class_agnostic else 4 * self.num_classes - self.fc_reg = nn.Linear(self.conv_out_channels, out_dim_reg) - - self.fc_cls = nn.Linear(self.fc_out_channels, self.num_classes) - self.relu = nn.ReLU(inplace=True) - - def _add_conv_branch(self): - """Add the fc branch which consists of a sequential of conv layers""" - branch_convs = nn.ModuleList() - for i in range(self.num_convs): - branch_convs.append( - Bottleneck( - inplanes=self.conv_out_channels, - planes=self.conv_out_channels // 4, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg)) - return branch_convs - - def _add_fc_branch(self): - """Add the fc branch which consists of a sequential of fc layers""" - branch_fcs = nn.ModuleList() - for i in range(self.num_fcs): - fc_in_channels = ( - self.in_channels * - self.roi_feat_area if i == 0 else self.fc_out_channels) - branch_fcs.append(nn.Linear(fc_in_channels, self.fc_out_channels)) - return branch_fcs - - def init_weights(self): - normal_init(self.fc_cls, std=0.01) - normal_init(self.fc_reg, std=0.001) - - for m in self.fc_branch.modules(): - if isinstance(m, nn.Linear): - xavier_init(m, distribution='uniform') - - def forward(self, x_cls, x_reg): - # conv head - x_conv = self.res_block(x_reg) - - for conv in self.conv_branch: - x_conv = conv(x_conv) - - if self.with_avg_pool: - x_conv = self.avg_pool(x_conv) - - x_conv = x_conv.view(x_conv.size(0), -1) - bbox_pred = self.fc_reg(x_conv) - - # fc head - x_fc = x_cls.view(x_cls.size(0), -1) - for fc in self.fc_branch: - x_fc = self.relu(fc(x_fc)) - - cls_score = self.fc_cls(x_fc) - - return cls_score, bbox_pred diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/builder.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/builder.py index dc82ab711..ace6209f7 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/builder.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/builder.py @@ -1,43 +1,59 @@ -from torch import nn +# Copyright (c) OpenMMLab. All rights reserved. +import warnings -from mmdet.utils import build_from_cfg -from .registry import (BACKBONES, DETECTORS, HEADS, LOSSES, NECKS, - ROI_EXTRACTORS, SHARED_HEADS) +from mmcv.cnn import MODELS as MMCV_MODELS +from mmcv.utils import Registry +MODELS = Registry('models', parent=MMCV_MODELS) -def build(cfg, registry, default_args=None): - if isinstance(cfg, list): - modules = [ - build_from_cfg(cfg_, registry, default_args) for cfg_ in cfg - ] - return nn.Sequential(*modules) - else: - return build_from_cfg(cfg, registry, default_args) +BACKBONES = MODELS +NECKS = MODELS +ROI_EXTRACTORS = MODELS +SHARED_HEADS = MODELS +HEADS = MODELS +LOSSES = MODELS +DETECTORS = MODELS def build_backbone(cfg): - return build(cfg, BACKBONES) + """Build backbone.""" + return BACKBONES.build(cfg) def build_neck(cfg): - return build(cfg, NECKS) + """Build neck.""" + return NECKS.build(cfg) def build_roi_extractor(cfg): - return build(cfg, ROI_EXTRACTORS) + """Build roi extractor.""" + return ROI_EXTRACTORS.build(cfg) def build_shared_head(cfg): - return build(cfg, SHARED_HEADS) + """Build shared head.""" + return SHARED_HEADS.build(cfg) def build_head(cfg): - return build(cfg, HEADS) + """Build head.""" + return HEADS.build(cfg) def build_loss(cfg): - return build(cfg, LOSSES) + """Build loss.""" + return LOSSES.build(cfg) def build_detector(cfg, train_cfg=None, test_cfg=None): - return build(cfg, DETECTORS, dict(train_cfg=train_cfg, test_cfg=test_cfg)) + """Build detector.""" + if train_cfg is not None or test_cfg is not None: + warnings.warn( + 'train_cfg and test_cfg is deprecated, ' + 'please specify them in model', UserWarning) + assert cfg.get('train_cfg') is None or train_cfg is None, \ + 'train_cfg specified in both outer field and model field ' + assert cfg.get('test_cfg') is None or test_cfg is None, \ + 'test_cfg specified in both outer field and model field ' + return DETECTORS.build( + cfg, default_args=dict(train_cfg=train_cfg, test_cfg=test_cfg)) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/__init__.py new file mode 100644 index 000000000..19aecea61 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/__init__.py @@ -0,0 +1,3 @@ +from .solo_head import SOLOHead + +__all__ = ['SOLOHead'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/anchor_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/anchor_head.py new file mode 100644 index 000000000..d1bfab62d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/anchor_head.py @@ -0,0 +1,542 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import warnings + +import torch +import torch.nn as nn +from mmcv.runner import force_fp32 + +from mmdet.core import (anchor_inside_flags, build_assigner, build_bbox_coder, + build_prior_generator, build_sampler, images_to_levels, + multi_apply, unmap) +from ..builder import HEADS, build_loss +from .base_dense_head import BaseDenseHead +from .dense_test_mixins import BBoxTestMixin + + +@HEADS.register_module() +class AnchorHead(BaseDenseHead, BBoxTestMixin): + """Anchor-based head (RPN, RetinaNet, SSD, etc.). + + Args: + num_classes (int): Number of categories excluding the background + category. + in_channels (int): Number of channels in the input feature map. + feat_channels (int): Number of hidden channels. Used in child classes. + anchor_generator (dict): Config dict for anchor generator + bbox_coder (dict): Config of bounding box coder. + reg_decoded_bbox (bool): If true, the regression loss would be + applied directly on decoded bounding boxes, converting both + the predicted boxes and regression targets to absolute + coordinates format. Default False. It should be `True` when + using `IoULoss`, `GIoULoss`, or `DIoULoss` in the bbox head. + loss_cls (dict): Config of classification loss. + loss_bbox (dict): Config of localization loss. + train_cfg (dict): Training config of anchor head. + test_cfg (dict): Testing config of anchor head. + init_cfg (dict or list[dict], optional): Initialization config dict. + """ # noqa: W605 + + def __init__(self, + num_classes, + in_channels, + feat_channels=256, + anchor_generator=dict( + type='AnchorGenerator', + scales=[8, 16, 32], + ratios=[0.5, 1.0, 2.0], + strides=[4, 8, 16, 32, 64]), + bbox_coder=dict( + type='DeltaXYWHBBoxCoder', + clip_border=True, + target_means=(.0, .0, .0, .0), + target_stds=(1.0, 1.0, 1.0, 1.0)), + reg_decoded_bbox=False, + loss_cls=dict( + type='CrossEntropyLoss', + use_sigmoid=True, + loss_weight=1.0), + loss_bbox=dict( + type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0), + train_cfg=None, + test_cfg=None, + init_cfg=dict(type='Normal', layer='Conv2d', std=0.01)): + super(AnchorHead, self).__init__(init_cfg) + self.in_channels = in_channels + self.num_classes = num_classes + self.feat_channels = feat_channels + self.use_sigmoid_cls = loss_cls.get('use_sigmoid', False) + if self.use_sigmoid_cls: + self.cls_out_channels = num_classes + else: + self.cls_out_channels = num_classes + 1 + + if self.cls_out_channels <= 0: + raise ValueError(f'num_classes={num_classes} is too small') + self.reg_decoded_bbox = reg_decoded_bbox + + self.bbox_coder = build_bbox_coder(bbox_coder) + self.loss_cls = build_loss(loss_cls) + self.loss_bbox = build_loss(loss_bbox) + self.train_cfg = train_cfg + self.test_cfg = test_cfg + if self.train_cfg: + self.assigner = build_assigner(self.train_cfg.assigner) + if hasattr(self.train_cfg, + 'sampler') and self.train_cfg.sampler.type.split( + '.')[-1] != 'PseudoSampler': + self.sampling = True + sampler_cfg = self.train_cfg.sampler + # avoid BC-breaking + if loss_cls['type'] in [ + 'FocalLoss', 'GHMC', 'QualityFocalLoss' + ]: + warnings.warn( + 'DeprecationWarning: Determining whether to sampling' + 'by loss type is deprecated, please delete sampler in' + 'your config when using `FocalLoss`, `GHMC`, ' + '`QualityFocalLoss` or other FocalLoss variant.') + self.sampling = False + sampler_cfg = dict(type='PseudoSampler') + else: + self.sampling = False + sampler_cfg = dict(type='PseudoSampler') + self.sampler = build_sampler(sampler_cfg, context=self) + self.fp16_enabled = False + + self.prior_generator = build_prior_generator(anchor_generator) + + # Usually the numbers of anchors for each level are the same + # except SSD detectors. So it is an int in the most dense + # heads but a list of int in SSDHead + self.num_base_priors = self.prior_generator.num_base_priors[0] + self._init_layers() + + @property + def num_anchors(self): + warnings.warn('DeprecationWarning: `num_anchors` is deprecated, ' + 'for consistency or also use ' + '`num_base_priors` instead') + return self.prior_generator.num_base_priors[0] + + @property + def anchor_generator(self): + warnings.warn('DeprecationWarning: anchor_generator is deprecated, ' + 'please use "prior_generator" instead') + return self.prior_generator + + def _init_layers(self): + """Initialize layers of the head.""" + self.conv_cls = nn.Conv2d(self.in_channels, + self.num_base_priors * self.cls_out_channels, + 1) + self.conv_reg = nn.Conv2d(self.in_channels, self.num_base_priors * 4, + 1) + + def forward_single(self, x): + """Forward feature of a single scale level. + + Args: + x (Tensor): Features of a single scale level. + + Returns: + tuple: + cls_score (Tensor): Cls scores for a single scale level \ + the channels number is num_base_priors * num_classes. + bbox_pred (Tensor): Box energies / deltas for a single scale \ + level, the channels number is num_base_priors * 4. + """ + cls_score = self.conv_cls(x) + bbox_pred = self.conv_reg(x) + return cls_score, bbox_pred + + def forward(self, feats): + """Forward features from the upstream network. + + Args: + feats (tuple[Tensor]): Features from the upstream network, each is + a 4D-tensor. + + Returns: + tuple: A tuple of classification scores and bbox prediction. + + - cls_scores (list[Tensor]): Classification scores for all \ + scale levels, each is a 4D-tensor, the channels number \ + is num_base_priors * num_classes. + - bbox_preds (list[Tensor]): Box energies / deltas for all \ + scale levels, each is a 4D-tensor, the channels number \ + is num_base_priors * 4. + """ + return multi_apply(self.forward_single, feats) + + def get_anchors(self, featmap_sizes, img_metas, device='cuda'): + """Get anchors according to feature map sizes. + + Args: + featmap_sizes (list[tuple]): Multi-level feature map sizes. + img_metas (list[dict]): Image meta info. + device (torch.device | str): Device for returned tensors + + Returns: + tuple: + anchor_list (list[Tensor]): Anchors of each image. + valid_flag_list (list[Tensor]): Valid flags of each image. + """ + num_imgs = len(img_metas) + + # since feature map sizes of all images are the same, we only compute + # anchors for one time + multi_level_anchors = self.prior_generator.grid_priors( + featmap_sizes, device=device) + anchor_list = [multi_level_anchors for _ in range(num_imgs)] + + # for each image, we compute valid flags of multi level anchors + valid_flag_list = [] + for img_id, img_meta in enumerate(img_metas): + multi_level_flags = self.prior_generator.valid_flags( + featmap_sizes, img_meta['pad_shape'], device) + valid_flag_list.append(multi_level_flags) + + return anchor_list, valid_flag_list + + def _get_targets_single(self, + flat_anchors, + valid_flags, + gt_bboxes, + gt_bboxes_ignore, + gt_labels, + img_meta, + label_channels=1, + unmap_outputs=True): + """Compute regression and classification targets for anchors in a + single image. + + Args: + flat_anchors (Tensor): Multi-level anchors of the image, which are + concatenated into a single tensor of shape (num_anchors ,4) + valid_flags (Tensor): Multi level valid flags of the image, + which are concatenated into a single tensor of + shape (num_anchors,). + gt_bboxes (Tensor): Ground truth bboxes of the image, + shape (num_gts, 4). + gt_bboxes_ignore (Tensor): Ground truth bboxes to be + ignored, shape (num_ignored_gts, 4). + img_meta (dict): Meta info of the image. + gt_labels (Tensor): Ground truth labels of each box, + shape (num_gts,). + label_channels (int): Channel of label. + unmap_outputs (bool): Whether to map outputs back to the original + set of anchors. + + Returns: + tuple: + labels_list (list[Tensor]): Labels of each level + label_weights_list (list[Tensor]): Label weights of each level + bbox_targets_list (list[Tensor]): BBox targets of each level + bbox_weights_list (list[Tensor]): BBox weights of each level + num_total_pos (int): Number of positive samples in all images + num_total_neg (int): Number of negative samples in all images + """ + inside_flags = anchor_inside_flags(flat_anchors, valid_flags, + img_meta['img_shape'][:2], + self.train_cfg.allowed_border) + if not inside_flags.any(): + return (None, ) * 7 + # assign gt and sample anchors + anchors = flat_anchors[inside_flags, :] + + assign_result = self.assigner.assign( + anchors, gt_bboxes, gt_bboxes_ignore, + None if self.sampling else gt_labels) + sampling_result = self.sampler.sample(assign_result, anchors, + gt_bboxes) + + num_valid_anchors = anchors.shape[0] + bbox_targets = torch.zeros_like(anchors) + bbox_weights = torch.zeros_like(anchors) + labels = anchors.new_full((num_valid_anchors, ), + self.num_classes, + dtype=torch.long) + label_weights = anchors.new_zeros(num_valid_anchors, dtype=torch.float) + + pos_inds = sampling_result.pos_inds + neg_inds = sampling_result.neg_inds + if len(pos_inds) > 0: + if not self.reg_decoded_bbox: + pos_bbox_targets = self.bbox_coder.encode( + sampling_result.pos_bboxes, sampling_result.pos_gt_bboxes) + else: + pos_bbox_targets = sampling_result.pos_gt_bboxes + bbox_targets[pos_inds, :] = pos_bbox_targets + bbox_weights[pos_inds, :] = 1.0 + if gt_labels is None: + # Only rpn gives gt_labels as None + # Foreground is the first class since v2.5.0 + labels[pos_inds] = 0 + else: + labels[pos_inds] = gt_labels[ + sampling_result.pos_assigned_gt_inds] + if self.train_cfg.pos_weight <= 0: + label_weights[pos_inds] = 1.0 + else: + label_weights[pos_inds] = self.train_cfg.pos_weight + if len(neg_inds) > 0: + label_weights[neg_inds] = 1.0 + + # map up to original set of anchors + if unmap_outputs: + num_total_anchors = flat_anchors.size(0) + labels = unmap( + labels, num_total_anchors, inside_flags, + fill=self.num_classes) # fill bg label + label_weights = unmap(label_weights, num_total_anchors, + inside_flags) + bbox_targets = unmap(bbox_targets, num_total_anchors, inside_flags) + bbox_weights = unmap(bbox_weights, num_total_anchors, inside_flags) + + return (labels, label_weights, bbox_targets, bbox_weights, pos_inds, + neg_inds, sampling_result) + + def get_targets(self, + anchor_list, + valid_flag_list, + gt_bboxes_list, + img_metas, + gt_bboxes_ignore_list=None, + gt_labels_list=None, + label_channels=1, + unmap_outputs=True, + return_sampling_results=False): + """Compute regression and classification targets for anchors in + multiple images. + + Args: + anchor_list (list[list[Tensor]]): Multi level anchors of each + image. The outer list indicates images, and the inner list + corresponds to feature levels of the image. Each element of + the inner list is a tensor of shape (num_anchors, 4). + valid_flag_list (list[list[Tensor]]): Multi level valid flags of + each image. The outer list indicates images, and the inner list + corresponds to feature levels of the image. Each element of + the inner list is a tensor of shape (num_anchors, ) + gt_bboxes_list (list[Tensor]): Ground truth bboxes of each image. + img_metas (list[dict]): Meta info of each image. + gt_bboxes_ignore_list (list[Tensor]): Ground truth bboxes to be + ignored. + gt_labels_list (list[Tensor]): Ground truth labels of each box. + label_channels (int): Channel of label. + unmap_outputs (bool): Whether to map outputs back to the original + set of anchors. + + Returns: + tuple: Usually returns a tuple containing learning targets. + + - labels_list (list[Tensor]): Labels of each level. + - label_weights_list (list[Tensor]): Label weights of each + level. + - bbox_targets_list (list[Tensor]): BBox targets of each level. + - bbox_weights_list (list[Tensor]): BBox weights of each level. + - num_total_pos (int): Number of positive samples in all + images. + - num_total_neg (int): Number of negative samples in all + images. + + additional_returns: This function enables user-defined returns from + `self._get_targets_single`. These returns are currently refined + to properties at each feature map (i.e. having HxW dimension). + The results will be concatenated after the end + """ + num_imgs = len(img_metas) + assert len(anchor_list) == len(valid_flag_list) == num_imgs + + # anchor number of multi levels + num_level_anchors = [anchors.size(0) for anchors in anchor_list[0]] + # concat all level anchors to a single tensor + concat_anchor_list = [] + concat_valid_flag_list = [] + for i in range(num_imgs): + assert len(anchor_list[i]) == len(valid_flag_list[i]) + concat_anchor_list.append(torch.cat(anchor_list[i])) + concat_valid_flag_list.append(torch.cat(valid_flag_list[i])) + + # compute targets for each image + if gt_bboxes_ignore_list is None: + gt_bboxes_ignore_list = [None for _ in range(num_imgs)] + if gt_labels_list is None: + gt_labels_list = [None for _ in range(num_imgs)] + results = multi_apply( + self._get_targets_single, + concat_anchor_list, + concat_valid_flag_list, + gt_bboxes_list, + gt_bboxes_ignore_list, + gt_labels_list, + img_metas, + label_channels=label_channels, + unmap_outputs=unmap_outputs) + (all_labels, all_label_weights, all_bbox_targets, all_bbox_weights, + pos_inds_list, neg_inds_list, sampling_results_list) = results[:7] + rest_results = list(results[7:]) # user-added return values + # no valid anchors + if any([labels is None for labels in all_labels]): + return None + # sampled anchors of all images + num_total_pos = sum([max(inds.numel(), 1) for inds in pos_inds_list]) + num_total_neg = sum([max(inds.numel(), 1) for inds in neg_inds_list]) + # split targets to a list w.r.t. multiple levels + labels_list = images_to_levels(all_labels, num_level_anchors) + label_weights_list = images_to_levels(all_label_weights, + num_level_anchors) + bbox_targets_list = images_to_levels(all_bbox_targets, + num_level_anchors) + bbox_weights_list = images_to_levels(all_bbox_weights, + num_level_anchors) + res = (labels_list, label_weights_list, bbox_targets_list, + bbox_weights_list, num_total_pos, num_total_neg) + if return_sampling_results: + res = res + (sampling_results_list, ) + for i, r in enumerate(rest_results): # user-added return values + rest_results[i] = images_to_levels(r, num_level_anchors) + + return res + tuple(rest_results) + + def loss_single(self, cls_score, bbox_pred, anchors, labels, label_weights, + bbox_targets, bbox_weights, num_total_samples): + """Compute loss of a single scale level. + + Args: + cls_score (Tensor): Box scores for each scale level + Has shape (N, num_anchors * num_classes, H, W). + bbox_pred (Tensor): Box energies / deltas for each scale + level with shape (N, num_anchors * 4, H, W). + anchors (Tensor): Box reference for each scale level with shape + (N, num_total_anchors, 4). + labels (Tensor): Labels of each anchors with shape + (N, num_total_anchors). + label_weights (Tensor): Label weights of each anchor with shape + (N, num_total_anchors) + bbox_targets (Tensor): BBox regression targets of each anchor + weight shape (N, num_total_anchors, 4). + bbox_weights (Tensor): BBox regression loss weights of each anchor + with shape (N, num_total_anchors, 4). + num_total_samples (int): If sampling, num total samples equal to + the number of total anchors; Otherwise, it is the number of + positive anchors. + + Returns: + dict[str, Tensor]: A dictionary of loss components. + """ + # classification loss + labels = labels.reshape(-1) + label_weights = label_weights.reshape(-1) + cls_score = cls_score.permute(0, 2, 3, + 1).reshape(-1, self.cls_out_channels) + loss_cls = self.loss_cls( + cls_score, labels, label_weights, avg_factor=num_total_samples) + # regression loss + bbox_targets = bbox_targets.reshape(-1, 4) + bbox_weights = bbox_weights.reshape(-1, 4) + bbox_pred = bbox_pred.permute(0, 2, 3, 1).reshape(-1, 4) + if self.reg_decoded_bbox: + # When the regression loss (e.g. `IouLoss`, `GIouLoss`) + # is applied directly on the decoded bounding boxes, it + # decodes the already encoded coordinates to absolute format. + anchors = anchors.reshape(-1, 4) + bbox_pred = self.bbox_coder.decode(anchors, bbox_pred) + loss_bbox = self.loss_bbox( + bbox_pred, + bbox_targets, + bbox_weights, + avg_factor=num_total_samples) + return loss_cls, loss_bbox + + @force_fp32(apply_to=('cls_scores', 'bbox_preds')) + def loss(self, + cls_scores, + bbox_preds, + gt_bboxes, + gt_labels, + img_metas, + gt_bboxes_ignore=None): + """Compute losses of the head. + + Args: + cls_scores (list[Tensor]): Box scores for each scale level + Has shape (N, num_anchors * num_classes, H, W) + bbox_preds (list[Tensor]): Box energies / deltas for each scale + level with shape (N, num_anchors * 4, H, W) + gt_bboxes (list[Tensor]): Ground truth bboxes for each image with + shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format. + gt_labels (list[Tensor]): class indices corresponding to each box + img_metas (list[dict]): Meta information of each image, e.g., + image size, scaling factor, etc. + gt_bboxes_ignore (None | list[Tensor]): specify which bounding + boxes can be ignored when computing the loss. Default: None + + Returns: + dict[str, Tensor]: A dictionary of loss components. + """ + featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] + assert len(featmap_sizes) == self.prior_generator.num_levels + + device = cls_scores[0].device + + anchor_list, valid_flag_list = self.get_anchors( + featmap_sizes, img_metas, device=device) + label_channels = self.cls_out_channels if self.use_sigmoid_cls else 1 + cls_reg_targets = self.get_targets( + anchor_list, + valid_flag_list, + gt_bboxes, + img_metas, + gt_bboxes_ignore_list=gt_bboxes_ignore, + gt_labels_list=gt_labels, + label_channels=label_channels) + if cls_reg_targets is None: + return None + (labels_list, label_weights_list, bbox_targets_list, bbox_weights_list, + num_total_pos, num_total_neg) = cls_reg_targets + num_total_samples = ( + num_total_pos + num_total_neg if self.sampling else num_total_pos) + + # anchor number of multi levels + num_level_anchors = [anchors.size(0) for anchors in anchor_list[0]] + # concat all level anchors and flags to a single tensor + concat_anchor_list = [] + for i in range(len(anchor_list)): + concat_anchor_list.append(torch.cat(anchor_list[i])) + all_anchor_list = images_to_levels(concat_anchor_list, + num_level_anchors) + + losses_cls, losses_bbox = multi_apply( + self.loss_single, + cls_scores, + bbox_preds, + all_anchor_list, + labels_list, + label_weights_list, + bbox_targets_list, + bbox_weights_list, + num_total_samples=num_total_samples) + return dict(loss_cls=losses_cls, loss_bbox=losses_bbox) + + def aug_test(self, feats, img_metas, rescale=False): + """Test function with test time augmentation. + + Args: + feats (list[Tensor]): the outer list indicates test-time + augmentations and inner Tensor should have a shape NxCxHxW, + which contains features for all images in the batch. + img_metas (list[list[dict]]): the outer list indicates test-time + augs (multiscale, flip, etc.) and the inner list indicates + images in a batch. each dict has image information. + rescale (bool, optional): Whether to rescale the results. + Defaults to False. + + Returns: + list[tuple[Tensor, Tensor]]: Each item in result_list is 2-tuple. + The first item is ``bboxes`` with shape (n, 5), where + 5 represent (tl_x, tl_y, br_x, br_y, score). + The shape of the second tensor in the tuple is ``labels`` + with shape (n,), The length of list should always be 1. + """ + return self.aug_test_bboxes(feats, img_metas, rescale=rescale) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/base_dense_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/base_dense_head.py new file mode 100644 index 000000000..0c7abb7b9 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/base_dense_head.py @@ -0,0 +1,526 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from abc import ABCMeta, abstractmethod + +import torch +from mmcv.cnn.utils.weight_init import constant_init +from mmcv.ops import batched_nms +from mmcv.runner import BaseModule, force_fp32 + +from mmdet.core.utils import filter_scores_and_topk, select_single_mlvl + + +class BaseDenseHead(BaseModule, metaclass=ABCMeta): + """Base class for DenseHeads.""" + + def __init__(self, init_cfg=None): + super(BaseDenseHead, self).__init__(init_cfg) + + def init_weights(self): + super(BaseDenseHead, self).init_weights() + # avoid init_cfg overwrite the initialization of `conv_offset` + for m in self.modules(): + # DeformConv2dPack, ModulatedDeformConv2dPack + if hasattr(m, 'conv_offset'): + constant_init(m.conv_offset, 0) + + @abstractmethod + def loss(self, **kwargs): + """Compute losses of the head.""" + pass + + @force_fp32(apply_to=('cls_scores', 'bbox_preds')) + def get_bboxes(self, + cls_scores, + bbox_preds, + score_factors=None, + img_metas=None, + cfg=None, + rescale=False, + with_nms=True, + **kwargs): + """Transform network outputs of a batch into bbox results. + + Note: When score_factors is not None, the cls_scores are + usually multiplied by it then obtain the real score used in NMS, + such as CenterNess in FCOS, IoU branch in ATSS. + + Args: + cls_scores (list[Tensor]): Classification scores for all + scale levels, each is a 4D-tensor, has shape + (batch_size, num_priors * num_classes, H, W). + bbox_preds (list[Tensor]): Box energies / deltas for all + scale levels, each is a 4D-tensor, has shape + (batch_size, num_priors * 4, H, W). + score_factors (list[Tensor], Optional): Score factor for + all scale level, each is a 4D-tensor, has shape + (batch_size, num_priors * 1, H, W). Default None. + img_metas (list[dict], Optional): Image meta info. Default None. + cfg (mmcv.Config, Optional): Test / postprocessing configuration, + if None, test_cfg would be used. Default None. + rescale (bool): If True, return boxes in original image space. + Default False. + with_nms (bool): If True, do nms before return boxes. + Default True. + + Returns: + list[list[Tensor, Tensor]]: Each item in result_list is 2-tuple. + The first item is an (n, 5) tensor, where the first 4 columns + are bounding box positions (tl_x, tl_y, br_x, br_y) and the + 5-th column is a score between 0 and 1. The second item is a + (n,) tensor where each item is the predicted class label of + the corresponding box. + """ + assert len(cls_scores) == len(bbox_preds) + + if score_factors is None: + # e.g. Retina, FreeAnchor, Foveabox, etc. + with_score_factors = False + else: + # e.g. FCOS, PAA, ATSS, AutoAssign, etc. + with_score_factors = True + assert len(cls_scores) == len(score_factors) + + num_levels = len(cls_scores) + + featmap_sizes = [cls_scores[i].shape[-2:] for i in range(num_levels)] + mlvl_priors = self.prior_generator.grid_priors( + featmap_sizes, + dtype=cls_scores[0].dtype, + device=cls_scores[0].device) + + result_list = [] + + for img_id in range(len(img_metas)): + img_meta = img_metas[img_id] + cls_score_list = select_single_mlvl(cls_scores, img_id) + bbox_pred_list = select_single_mlvl(bbox_preds, img_id) + if with_score_factors: + score_factor_list = select_single_mlvl(score_factors, img_id) + else: + score_factor_list = [None for _ in range(num_levels)] + + results = self._get_bboxes_single(cls_score_list, bbox_pred_list, + score_factor_list, mlvl_priors, + img_meta, cfg, rescale, with_nms, + **kwargs) + result_list.append(results) + return result_list + + def _get_bboxes_single(self, + cls_score_list, + bbox_pred_list, + score_factor_list, + mlvl_priors, + img_meta, + cfg, + rescale=False, + with_nms=True, + **kwargs): + """Transform outputs of a single image into bbox predictions. + + Args: + cls_score_list (list[Tensor]): Box scores from all scale + levels of a single image, each item has shape + (num_priors * num_classes, H, W). + bbox_pred_list (list[Tensor]): Box energies / deltas from + all scale levels of a single image, each item has shape + (num_priors * 4, H, W). + score_factor_list (list[Tensor]): Score factor from all scale + levels of a single image, each item has shape + (num_priors * 1, H, W). + mlvl_priors (list[Tensor]): Each element in the list is + the priors of a single level in feature pyramid. In all + anchor-based methods, it has shape (num_priors, 4). In + all anchor-free methods, it has shape (num_priors, 2) + when `with_stride=True`, otherwise it still has shape + (num_priors, 4). + img_meta (dict): Image meta info. + cfg (mmcv.Config): Test / postprocessing configuration, + if None, test_cfg would be used. + rescale (bool): If True, return boxes in original image space. + Default: False. + with_nms (bool): If True, do nms before return boxes. + Default: True. + + Returns: + tuple[Tensor]: Results of detected bboxes and labels. If with_nms + is False and mlvl_score_factor is None, return mlvl_bboxes and + mlvl_scores, else return mlvl_bboxes, mlvl_scores and + mlvl_score_factor. Usually with_nms is False is used for aug + test. If with_nms is True, then return the following format + + - det_bboxes (Tensor): Predicted bboxes with shape \ + [num_bboxes, 5], where the first 4 columns are bounding \ + box positions (tl_x, tl_y, br_x, br_y) and the 5-th \ + column are scores between 0 and 1. + - det_labels (Tensor): Predicted labels of the corresponding \ + box with shape [num_bboxes]. + """ + if score_factor_list[0] is None: + # e.g. Retina, FreeAnchor, etc. + with_score_factors = False + else: + # e.g. FCOS, PAA, ATSS, etc. + with_score_factors = True + + cfg = self.test_cfg if cfg is None else cfg + img_shape = img_meta['img_shape'] + nms_pre = cfg.get('nms_pre', -1) + + mlvl_bboxes = [] + mlvl_scores = [] + mlvl_labels = [] + if with_score_factors: + mlvl_score_factors = [] + else: + mlvl_score_factors = None + for level_idx, (cls_score, bbox_pred, score_factor, priors) in \ + enumerate(zip(cls_score_list, bbox_pred_list, + score_factor_list, mlvl_priors)): + + assert cls_score.size()[-2:] == bbox_pred.size()[-2:] + + bbox_pred = bbox_pred.permute(1, 2, 0).reshape(-1, 4) + if with_score_factors: + score_factor = score_factor.permute(1, 2, + 0).reshape(-1).sigmoid() + cls_score = cls_score.permute(1, 2, + 0).reshape(-1, self.cls_out_channels) + if self.use_sigmoid_cls: + scores = cls_score.sigmoid() + else: + # remind that we set FG labels to [0, num_class-1] + # since mmdet v2.0 + # BG cat_id: num_class + scores = cls_score.softmax(-1)[:, :-1] + + # After https://github.com/open-mmlab/mmdetection/pull/6268/, + # this operation keeps fewer bboxes under the same `nms_pre`. + # There is no difference in performance for most models. If you + # find a slight drop in performance, you can set a larger + # `nms_pre` than before. + results = filter_scores_and_topk( + scores, cfg.score_thr, nms_pre, + dict(bbox_pred=bbox_pred, priors=priors)) + scores, labels, keep_idxs, filtered_results = results + + bbox_pred = filtered_results['bbox_pred'] + priors = filtered_results['priors'] + + if with_score_factors: + score_factor = score_factor[keep_idxs] + + bboxes = self.bbox_coder.decode( + priors, bbox_pred, max_shape=img_shape) + + mlvl_bboxes.append(bboxes) + mlvl_scores.append(scores) + mlvl_labels.append(labels) + if with_score_factors: + mlvl_score_factors.append(score_factor) + + return self._bbox_post_process(mlvl_scores, mlvl_labels, mlvl_bboxes, + img_meta['scale_factor'], cfg, rescale, + with_nms, mlvl_score_factors, **kwargs) + + def _bbox_post_process(self, + mlvl_scores, + mlvl_labels, + mlvl_bboxes, + scale_factor, + cfg, + rescale=False, + with_nms=True, + mlvl_score_factors=None, + **kwargs): + """bbox post-processing method. + + The boxes would be rescaled to the original image scale and do + the nms operation. Usually `with_nms` is False is used for aug test. + + Args: + mlvl_scores (list[Tensor]): Box scores from all scale + levels of a single image, each item has shape + (num_bboxes, ). + mlvl_labels (list[Tensor]): Box class labels from all scale + levels of a single image, each item has shape + (num_bboxes, ). + mlvl_bboxes (list[Tensor]): Decoded bboxes from all scale + levels of a single image, each item has shape (num_bboxes, 4). + scale_factor (ndarray, optional): Scale factor of the image arange + as (w_scale, h_scale, w_scale, h_scale). + cfg (mmcv.Config): Test / postprocessing configuration, + if None, test_cfg would be used. + rescale (bool): If True, return boxes in original image space. + Default: False. + with_nms (bool): If True, do nms before return boxes. + Default: True. + mlvl_score_factors (list[Tensor], optional): Score factor from + all scale levels of a single image, each item has shape + (num_bboxes, ). Default: None. + + Returns: + tuple[Tensor]: Results of detected bboxes and labels. If with_nms + is False and mlvl_score_factor is None, return mlvl_bboxes and + mlvl_scores, else return mlvl_bboxes, mlvl_scores and + mlvl_score_factor. Usually with_nms is False is used for aug + test. If with_nms is True, then return the following format + + - det_bboxes (Tensor): Predicted bboxes with shape \ + [num_bboxes, 5], where the first 4 columns are bounding \ + box positions (tl_x, tl_y, br_x, br_y) and the 5-th \ + column are scores between 0 and 1. + - det_labels (Tensor): Predicted labels of the corresponding \ + box with shape [num_bboxes]. + """ + assert len(mlvl_scores) == len(mlvl_bboxes) == len(mlvl_labels) + + mlvl_bboxes = torch.cat(mlvl_bboxes) + if rescale: + mlvl_bboxes /= mlvl_bboxes.new_tensor(scale_factor) + mlvl_scores = torch.cat(mlvl_scores) + mlvl_labels = torch.cat(mlvl_labels) + + if mlvl_score_factors is not None: + # TODO: Add sqrt operation in order to be consistent with + # the paper. + mlvl_score_factors = torch.cat(mlvl_score_factors) + mlvl_scores = mlvl_scores * mlvl_score_factors + + if with_nms: + if mlvl_bboxes.numel() == 0: + det_bboxes = torch.cat([mlvl_bboxes, mlvl_scores[:, None]], -1) + return det_bboxes, mlvl_labels + + det_bboxes, keep_idxs = batched_nms(mlvl_bboxes, mlvl_scores, + mlvl_labels, cfg.nms) + det_bboxes = det_bboxes[:cfg.max_per_img] + det_labels = mlvl_labels[keep_idxs][:cfg.max_per_img] + return det_bboxes, det_labels + else: + return mlvl_bboxes, mlvl_scores, mlvl_labels + + def forward_train(self, + x, + img_metas, + gt_bboxes, + gt_labels=None, + gt_bboxes_ignore=None, + proposal_cfg=None, + **kwargs): + """ + Args: + x (list[Tensor]): Features from FPN. + img_metas (list[dict]): Meta information of each image, e.g., + image size, scaling factor, etc. + gt_bboxes (Tensor): Ground truth bboxes of the image, + shape (num_gts, 4). + gt_labels (Tensor): Ground truth labels of each box, + shape (num_gts,). + gt_bboxes_ignore (Tensor): Ground truth bboxes to be + ignored, shape (num_ignored_gts, 4). + proposal_cfg (mmcv.Config): Test / postprocessing configuration, + if None, test_cfg would be used + + Returns: + tuple: + losses: (dict[str, Tensor]): A dictionary of loss components. + proposal_list (list[Tensor]): Proposals of each image. + """ + outs = self(x) + if gt_labels is None: + loss_inputs = outs + (gt_bboxes, img_metas) + else: + loss_inputs = outs + (gt_bboxes, gt_labels, img_metas) + losses = self.loss(*loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) + if proposal_cfg is None: + return losses + else: + proposal_list = self.get_bboxes( + *outs, img_metas=img_metas, cfg=proposal_cfg) + return losses, proposal_list + + def simple_test(self, feats, img_metas, rescale=False): + """Test function without test-time augmentation. + + Args: + feats (tuple[torch.Tensor]): Multi-level features from the + upstream network, each is a 4D-tensor. + img_metas (list[dict]): List of image information. + rescale (bool, optional): Whether to rescale the results. + Defaults to False. + + Returns: + list[tuple[Tensor, Tensor]]: Each item in result_list is 2-tuple. + The first item is ``bboxes`` with shape (n, 5), + where 5 represent (tl_x, tl_y, br_x, br_y, score). + The shape of the second tensor in the tuple is ``labels`` + with shape (n, ). + """ + return self.simple_test_bboxes(feats, img_metas, rescale=rescale) + + @force_fp32(apply_to=('cls_scores', 'bbox_preds')) + def onnx_export(self, + cls_scores, + bbox_preds, + score_factors=None, + img_metas=None, + with_nms=True): + """Transform network output for a batch into bbox predictions. + + Args: + cls_scores (list[Tensor]): Box scores for each scale level + with shape (N, num_points * num_classes, H, W). + bbox_preds (list[Tensor]): Box energies / deltas for each scale + level with shape (N, num_points * 4, H, W). + score_factors (list[Tensor]): score_factors for each s + cale level with shape (N, num_points * 1, H, W). + Default: None. + img_metas (list[dict]): Meta information of each image, e.g., + image size, scaling factor, etc. Default: None. + with_nms (bool): Whether apply nms to the bboxes. Default: True. + + Returns: + tuple[Tensor, Tensor] | list[tuple]: When `with_nms` is True, + it is tuple[Tensor, Tensor], first tensor bboxes with shape + [N, num_det, 5], 5 arrange as (x1, y1, x2, y2, score) + and second element is class labels of shape [N, num_det]. + When `with_nms` is False, first tensor is bboxes with + shape [N, num_det, 4], second tensor is raw score has + shape [N, num_det, num_classes]. + """ + assert len(cls_scores) == len(bbox_preds) + + num_levels = len(cls_scores) + + featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores] + mlvl_priors = self.prior_generator.grid_priors( + featmap_sizes, + dtype=bbox_preds[0].dtype, + device=bbox_preds[0].device) + + mlvl_cls_scores = [cls_scores[i].detach() for i in range(num_levels)] + mlvl_bbox_preds = [bbox_preds[i].detach() for i in range(num_levels)] + + assert len( + img_metas + ) == 1, 'Only support one input image while in exporting to ONNX' + img_shape = img_metas[0]['img_shape_for_onnx'] + + cfg = self.test_cfg + assert len(cls_scores) == len(bbox_preds) == len(mlvl_priors) + device = cls_scores[0].device + batch_size = cls_scores[0].shape[0] + # convert to tensor to keep tracing + nms_pre_tensor = torch.tensor( + cfg.get('nms_pre', -1), device=device, dtype=torch.long) + + # e.g. Retina, FreeAnchor, etc. + if score_factors is None: + with_score_factors = False + mlvl_score_factor = [None for _ in range(num_levels)] + else: + # e.g. FCOS, PAA, ATSS, etc. + with_score_factors = True + mlvl_score_factor = [ + score_factors[i].detach() for i in range(num_levels) + ] + mlvl_score_factors = [] + + mlvl_batch_bboxes = [] + mlvl_scores = [] + + for cls_score, bbox_pred, score_factors, priors in zip( + mlvl_cls_scores, mlvl_bbox_preds, mlvl_score_factor, + mlvl_priors): + assert cls_score.size()[-2:] == bbox_pred.size()[-2:] + + scores = cls_score.permute(0, 2, 3, + 1).reshape(batch_size, -1, + self.cls_out_channels) + if self.use_sigmoid_cls: + scores = scores.sigmoid() + nms_pre_score = scores + else: + scores = scores.softmax(-1) + nms_pre_score = scores + + if with_score_factors: + score_factors = score_factors.permute(0, 2, 3, 1).reshape( + batch_size, -1).sigmoid() + bbox_pred = bbox_pred.permute(0, 2, 3, + 1).reshape(batch_size, -1, 4) + priors = priors.expand(batch_size, -1, priors.size(-1)) + # Get top-k predictions + from mmdet.core.export import get_k_for_topk + nms_pre = get_k_for_topk(nms_pre_tensor, bbox_pred.shape[1]) + if nms_pre > 0: + + if with_score_factors: + nms_pre_score = (nms_pre_score * score_factors[..., None]) + else: + nms_pre_score = nms_pre_score + + # Get maximum scores for foreground classes. + if self.use_sigmoid_cls: + max_scores, _ = nms_pre_score.max(-1) + else: + # remind that we set FG labels to [0, num_class-1] + # since mmdet v2.0 + # BG cat_id: num_class + max_scores, _ = nms_pre_score[..., :-1].max(-1) + _, topk_inds = max_scores.topk(nms_pre) + + batch_inds = torch.arange( + batch_size, device=bbox_pred.device).view( + -1, 1).expand_as(topk_inds).long() + # Avoid onnx2tensorrt issue in https://github.com/NVIDIA/TensorRT/issues/1134 # noqa: E501 + transformed_inds = bbox_pred.shape[1] * batch_inds + topk_inds + priors = priors.reshape( + -1, priors.size(-1))[transformed_inds, :].reshape( + batch_size, -1, priors.size(-1)) + bbox_pred = bbox_pred.reshape(-1, + 4)[transformed_inds, :].reshape( + batch_size, -1, 4) + scores = scores.reshape( + -1, self.cls_out_channels)[transformed_inds, :].reshape( + batch_size, -1, self.cls_out_channels) + if with_score_factors: + score_factors = score_factors.reshape( + -1, 1)[transformed_inds].reshape(batch_size, -1) + + bboxes = self.bbox_coder.decode( + priors, bbox_pred, max_shape=img_shape) + + mlvl_batch_bboxes.append(bboxes) + mlvl_scores.append(scores) + if with_score_factors: + mlvl_score_factors.append(score_factors) + + batch_bboxes = torch.cat(mlvl_batch_bboxes, dim=1) + batch_scores = torch.cat(mlvl_scores, dim=1) + if with_score_factors: + batch_score_factors = torch.cat(mlvl_score_factors, dim=1) + + # Replace multiclass_nms with ONNX::NonMaxSuppression in deployment + + from mmdet.core.export import add_dummy_nms_for_onnx + + if not self.use_sigmoid_cls: + batch_scores = batch_scores[..., :self.num_classes] + + if with_score_factors: + batch_scores = batch_scores * (batch_score_factors.unsqueeze(2)) + + if with_nms: + max_output_boxes_per_class = cfg.nms.get( + 'max_output_boxes_per_class', 200) + iou_threshold = cfg.nms.get('iou_threshold', 0.5) + score_threshold = cfg.score_thr + nms_pre = cfg.get('deploy_nms_pre', -1) + return add_dummy_nms_for_onnx(batch_bboxes, batch_scores, + max_output_boxes_per_class, + iou_threshold, score_threshold, + nms_pre, cfg.max_per_img) + else: + return batch_bboxes, batch_scores diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/base_mask_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/base_mask_head.py new file mode 100644 index 000000000..5eb94fb28 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/base_mask_head.py @@ -0,0 +1,116 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from abc import ABCMeta, abstractmethod + +from mmcv.runner import BaseModule + + +class BaseMaskHead(BaseModule, metaclass=ABCMeta): + """Base class for mask heads used in One-Stage Instance Segmentation.""" + + def __init__(self, init_cfg): + super(BaseMaskHead, self).__init__(init_cfg) + + @abstractmethod + def loss(self, **kwargs): + pass + + @abstractmethod + def get_results(self, **kwargs): + """Get precessed :obj:`InstanceData` of multiple images.""" + pass + + def forward_train(self, + x, + gt_labels, + gt_masks, + img_metas, + gt_bboxes=None, + gt_bboxes_ignore=None, + positive_infos=None, + **kwargs): + """ + Args: + x (list[Tensor] | tuple[Tensor]): Features from FPN. + Each has a shape (B, C, H, W). + gt_labels (list[Tensor]): Ground truth labels of all images. + each has a shape (num_gts,). + gt_masks (list[Tensor]) : Masks for each bbox, has a shape + (num_gts, h , w). + img_metas (list[dict]): Meta information of each image, e.g., + image size, scaling factor, etc. + gt_bboxes (list[Tensor]): Ground truth bboxes of the image, + each item has a shape (num_gts, 4). + gt_bboxes_ignore (list[Tensor], None): Ground truth bboxes to be + ignored, each item has a shape (num_ignored_gts, 4). + positive_infos (list[:obj:`InstanceData`], optional): Information + of positive samples. Used when the label assignment is + done outside the MaskHead, e.g., in BboxHead in + YOLACT or CondInst, etc. When the label assignment is done in + MaskHead, it would be None, like SOLO. All values + in it should have shape (num_positive_samples, *). + + Returns: + dict[str, Tensor]: A dictionary of loss components. + """ + if positive_infos is None: + outs = self(x) + else: + outs = self(x, positive_infos) + + assert isinstance(outs, tuple), 'Forward results should be a tuple, ' \ + 'even if only one item is returned' + loss = self.loss( + *outs, + gt_labels=gt_labels, + gt_masks=gt_masks, + img_metas=img_metas, + gt_bboxes=gt_bboxes, + gt_bboxes_ignore=gt_bboxes_ignore, + positive_infos=positive_infos, + **kwargs) + return loss + + def simple_test(self, + feats, + img_metas, + rescale=False, + instances_list=None, + **kwargs): + """Test function without test-time augmentation. + + Args: + feats (tuple[torch.Tensor]): Multi-level features from the + upstream network, each is a 4D-tensor. + img_metas (list[dict]): List of image information. + rescale (bool, optional): Whether to rescale the results. + Defaults to False. + instances_list (list[obj:`InstanceData`], optional): Detection + results of each image after the post process. Only exist + if there is a `bbox_head`, like `YOLACT`, `CondInst`, etc. + + Returns: + list[obj:`InstanceData`]: Instance segmentation \ + results of each image after the post process. \ + Each item usually contains following keys. \ + + - scores (Tensor): Classification scores, has a shape + (num_instance,) + - labels (Tensor): Has a shape (num_instances,). + - masks (Tensor): Processed mask results, has a + shape (num_instances, h, w). + """ + if instances_list is None: + outs = self(feats) + else: + outs = self(feats, instances_list=instances_list) + mask_inputs = outs + (img_metas, ) + results_list = self.get_results( + *mask_inputs, + rescale=rescale, + instances_list=instances_list, + **kwargs) + return results_list + + def onnx_export(self, img, img_metas): + raise NotImplementedError(f'{self.__class__.__name__} does ' + f'not support ONNX EXPORT') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/dense_test_mixins.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/dense_test_mixins.py new file mode 100644 index 000000000..342154895 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/dense_test_mixins.py @@ -0,0 +1,206 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import sys +from inspect import signature + +import torch +from mmcv.ops import batched_nms + +from mmdet.core import bbox_mapping_back, merge_aug_proposals + +if sys.version_info >= (3, 7): + from mmdet.utils.contextmanagers import completed + + +class BBoxTestMixin(object): + """Mixin class for testing det bboxes via DenseHead.""" + + def simple_test_bboxes(self, feats, img_metas, rescale=False): + """Test det bboxes without test-time augmentation, can be applied in + DenseHead except for ``RPNHead`` and its variants, e.g., ``GARPNHead``, + etc. + + Args: + feats (tuple[torch.Tensor]): Multi-level features from the + upstream network, each is a 4D-tensor. + img_metas (list[dict]): List of image information. + rescale (bool, optional): Whether to rescale the results. + Defaults to False. + + Returns: + list[tuple[Tensor, Tensor]]: Each item in result_list is 2-tuple. + The first item is ``bboxes`` with shape (n, 5), + where 5 represent (tl_x, tl_y, br_x, br_y, score). + The shape of the second tensor in the tuple is ``labels`` + with shape (n,) + """ + outs = self.forward(feats) + results_list = self.get_bboxes( + *outs, img_metas=img_metas, rescale=rescale) + return results_list + + def aug_test_bboxes(self, feats, img_metas, rescale=False): + """Test det bboxes with test time augmentation, can be applied in + DenseHead except for ``RPNHead`` and its variants, e.g., ``GARPNHead``, + etc. + + Args: + feats (list[Tensor]): the outer list indicates test-time + augmentations and inner Tensor should have a shape NxCxHxW, + which contains features for all images in the batch. + img_metas (list[list[dict]]): the outer list indicates test-time + augs (multiscale, flip, etc.) and the inner list indicates + images in a batch. each dict has image information. + rescale (bool, optional): Whether to rescale the results. + Defaults to False. + + Returns: + list[tuple[Tensor, Tensor]]: Each item in result_list is 2-tuple. + The first item is ``bboxes`` with shape (n, 5), + where 5 represent (tl_x, tl_y, br_x, br_y, score). + The shape of the second tensor in the tuple is ``labels`` + with shape (n,). The length of list should always be 1. + """ + # check with_nms argument + gb_sig = signature(self.get_bboxes) + gb_args = [p.name for p in gb_sig.parameters.values()] + gbs_sig = signature(self._get_bboxes_single) + gbs_args = [p.name for p in gbs_sig.parameters.values()] + assert ('with_nms' in gb_args) and ('with_nms' in gbs_args), \ + f'{self.__class__.__name__}' \ + ' does not support test-time augmentation' + + aug_bboxes = [] + aug_scores = [] + aug_labels = [] + for x, img_meta in zip(feats, img_metas): + # only one image in the batch + outs = self.forward(x) + bbox_outputs = self.get_bboxes( + *outs, + img_metas=img_meta, + cfg=self.test_cfg, + rescale=False, + with_nms=False)[0] + aug_bboxes.append(bbox_outputs[0]) + aug_scores.append(bbox_outputs[1]) + if len(bbox_outputs) >= 3: + aug_labels.append(bbox_outputs[2]) + + # after merging, bboxes will be rescaled to the original image size + merged_bboxes, merged_scores = self.merge_aug_bboxes( + aug_bboxes, aug_scores, img_metas) + merged_labels = torch.cat(aug_labels, dim=0) if aug_labels else None + + if merged_bboxes.numel() == 0: + det_bboxes = torch.cat([merged_bboxes, merged_scores[:, None]], -1) + return [ + (det_bboxes, merged_labels), + ] + + det_bboxes, keep_idxs = batched_nms(merged_bboxes, merged_scores, + merged_labels, self.test_cfg.nms) + det_bboxes = det_bboxes[:self.test_cfg.max_per_img] + det_labels = merged_labels[keep_idxs][:self.test_cfg.max_per_img] + + if rescale: + _det_bboxes = det_bboxes + else: + _det_bboxes = det_bboxes.clone() + _det_bboxes[:, :4] *= det_bboxes.new_tensor( + img_metas[0][0]['scale_factor']) + + return [ + (_det_bboxes, det_labels), + ] + + def simple_test_rpn(self, x, img_metas): + """Test without augmentation, only for ``RPNHead`` and its variants, + e.g., ``GARPNHead``, etc. + + Args: + x (tuple[Tensor]): Features from the upstream network, each is + a 4D-tensor. + img_metas (list[dict]): Meta info of each image. + + Returns: + list[Tensor]: Proposals of each image, each item has shape (n, 5), + where 5 represent (tl_x, tl_y, br_x, br_y, score). + """ + rpn_outs = self(x) + proposal_list = self.get_bboxes(*rpn_outs, img_metas=img_metas) + return proposal_list + + def aug_test_rpn(self, feats, img_metas): + """Test with augmentation for only for ``RPNHead`` and its variants, + e.g., ``GARPNHead``, etc. + + Args: + feats (tuple[Tensor]): Features from the upstream network, each is + a 4D-tensor. + img_metas (list[dict]): Meta info of each image. + + Returns: + list[Tensor]: Proposals of each image, each item has shape (n, 5), + where 5 represent (tl_x, tl_y, br_x, br_y, score). + """ + samples_per_gpu = len(img_metas[0]) + aug_proposals = [[] for _ in range(samples_per_gpu)] + for x, img_meta in zip(feats, img_metas): + proposal_list = self.simple_test_rpn(x, img_meta) + for i, proposals in enumerate(proposal_list): + aug_proposals[i].append(proposals) + # reorganize the order of 'img_metas' to match the dimensions + # of 'aug_proposals' + aug_img_metas = [] + for i in range(samples_per_gpu): + aug_img_meta = [] + for j in range(len(img_metas)): + aug_img_meta.append(img_metas[j][i]) + aug_img_metas.append(aug_img_meta) + # after merging, proposals will be rescaled to the original image size + merged_proposals = [ + merge_aug_proposals(proposals, aug_img_meta, self.test_cfg) + for proposals, aug_img_meta in zip(aug_proposals, aug_img_metas) + ] + return merged_proposals + + if sys.version_info >= (3, 7): + + async def async_simple_test_rpn(self, x, img_metas): + sleep_interval = self.test_cfg.pop('async_sleep_interval', 0.025) + async with completed( + __name__, 'rpn_head_forward', + sleep_interval=sleep_interval): + rpn_outs = self(x) + + proposal_list = self.get_bboxes(*rpn_outs, img_metas=img_metas) + return proposal_list + + def merge_aug_bboxes(self, aug_bboxes, aug_scores, img_metas): + """Merge augmented detection bboxes and scores. + + Args: + aug_bboxes (list[Tensor]): shape (n, 4*#class) + aug_scores (list[Tensor] or None): shape (n, #class) + img_shapes (list[Tensor]): shape (3, ). + + Returns: + tuple[Tensor]: ``bboxes`` with shape (n,4), where + 4 represent (tl_x, tl_y, br_x, br_y) + and ``scores`` with shape (n,). + """ + recovered_bboxes = [] + for bboxes, img_info in zip(aug_bboxes, img_metas): + img_shape = img_info[0]['img_shape'] + scale_factor = img_info[0]['scale_factor'] + flip = img_info[0]['flip'] + flip_direction = img_info[0]['flip_direction'] + bboxes = bbox_mapping_back(bboxes, img_shape, scale_factor, flip, + flip_direction) + recovered_bboxes.append(bboxes) + bboxes = torch.cat(recovered_bboxes, dim=0) + if aug_scores is None: + return bboxes + else: + scores = torch.cat(aug_scores, dim=0) + return bboxes, scores diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/solo_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/solo_head.py new file mode 100644 index 000000000..148f819fa --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/dense_heads/solo_head.py @@ -0,0 +1,1177 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import mmcv +import numpy as np +import torch +import torch.nn as nn +import torch.nn.functional as F +from mmcv.cnn import ConvModule + +from mmdet.core import InstanceData, mask_matrix_nms, multi_apply +from mmdet.core.utils import center_of_mass, generate_coordinate +from mmdet.models.builder import HEADS, build_loss +from .base_mask_head import BaseMaskHead + + +@HEADS.register_module() +class SOLOHead(BaseMaskHead): + """SOLO mask head used in `SOLO: Segmenting Objects by Locations. + + `_ + + Args: + num_classes (int): Number of categories excluding the background + category. + in_channels (int): Number of channels in the input feature map. + feat_channels (int): Number of hidden channels. Used in child classes. + Default: 256. + stacked_convs (int): Number of stacking convs of the head. + Default: 4. + strides (tuple): Downsample factor of each feature map. + scale_ranges (tuple[tuple[int, int]]): Area range of multiple + level masks, in the format [(min1, max1), (min2, max2), ...]. + A range of (16, 64) means the area range between (16, 64). + pos_scale (float): Constant scale factor to control the center region. + num_grids (list[int]): Divided image into a uniform grids, each + feature map has a different grid value. The number of output + channels is grid ** 2. Default: [40, 36, 24, 16, 12]. + cls_down_index (int): The index of downsample operation in + classification branch. Default: 0. + loss_mask (dict): Config of mask loss. + loss_cls (dict): Config of classification loss. + norm_cfg (dict): dictionary to construct and config norm layer. + Default: norm_cfg=dict(type='GN', num_groups=32, + requires_grad=True). + train_cfg (dict): Training config of head. + test_cfg (dict): Testing config of head. + init_cfg (dict or list[dict], optional): Initialization config dict. + """ + + def __init__( + self, + num_classes, + in_channels, + feat_channels=256, + stacked_convs=4, + strides=(4, 8, 16, 32, 64), + scale_ranges=((8, 32), (16, 64), (32, 128), (64, 256), (128, 512)), + pos_scale=0.2, + num_grids=[40, 36, 24, 16, 12], + cls_down_index=0, + loss_mask=None, + loss_cls=None, + norm_cfg=dict(type='GN', num_groups=32, requires_grad=True), + train_cfg=None, + test_cfg=None, + init_cfg=[ + dict(type='Normal', layer='Conv2d', std=0.01), + dict( + type='Normal', + std=0.01, + bias_prob=0.01, + override=dict(name='conv_mask_list')), + dict( + type='Normal', + std=0.01, + bias_prob=0.01, + override=dict(name='conv_cls')) + ], + ): + super(SOLOHead, self).__init__(init_cfg) + self.num_classes = num_classes + self.cls_out_channels = self.num_classes + self.in_channels = in_channels + self.feat_channels = feat_channels + self.stacked_convs = stacked_convs + self.strides = strides + self.num_grids = num_grids + # number of FPN feats + self.num_levels = len(strides) + assert self.num_levels == len(scale_ranges) == len(num_grids) + self.scale_ranges = scale_ranges + self.pos_scale = pos_scale + + self.cls_down_index = cls_down_index + self.loss_cls = build_loss(loss_cls) + self.loss_mask = build_loss(loss_mask) + self.norm_cfg = norm_cfg + self.init_cfg = init_cfg + self.train_cfg = train_cfg + self.test_cfg = test_cfg + self._init_layers() + + def _init_layers(self): + self.mask_convs = nn.ModuleList() + self.cls_convs = nn.ModuleList() + for i in range(self.stacked_convs): + chn = self.in_channels + 2 if i == 0 else self.feat_channels + self.mask_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + norm_cfg=self.norm_cfg)) + chn = self.in_channels if i == 0 else self.feat_channels + self.cls_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + norm_cfg=self.norm_cfg)) + self.conv_mask_list = nn.ModuleList() + for num_grid in self.num_grids: + self.conv_mask_list.append( + nn.Conv2d(self.feat_channels, num_grid**2, 1)) + + self.conv_cls = nn.Conv2d( + self.feat_channels, self.cls_out_channels, 3, padding=1) + + def resize_feats(self, feats): + """Downsample the first feat and upsample last feat in feats.""" + out = [] + for i in range(len(feats)): + if i == 0: + out.append( + F.interpolate(feats[0], scale_factor=0.5, mode='bilinear')) + elif i == len(feats) - 1: + out.append( + F.interpolate( + feats[i], + size=feats[i - 1].shape[-2:], + mode='bilinear')) + else: + out.append(feats[i]) + return out + + def forward(self, feats): + assert len(feats) == self.num_levels + feats = self.resize_feats(feats) + mlvl_mask_preds = [] + mlvl_cls_preds = [] + for i in range(self.num_levels): + x = feats[i] + mask_feat = x + cls_feat = x + # generate and concat the coordinate + coord_feat = generate_coordinate(mask_feat.size(), + mask_feat.device) + mask_feat = torch.cat([mask_feat, coord_feat], 1) + + for mask_layer in (self.mask_convs): + mask_feat = mask_layer(mask_feat) + + mask_feat = F.interpolate( + mask_feat, scale_factor=2, mode='bilinear') + mask_pred = self.conv_mask_list[i](mask_feat) + + # cls branch + for j, cls_layer in enumerate(self.cls_convs): + if j == self.cls_down_index: + num_grid = self.num_grids[i] + cls_feat = F.interpolate( + cls_feat, size=num_grid, mode='bilinear') + cls_feat = cls_layer(cls_feat) + + cls_pred = self.conv_cls(cls_feat) + + if not self.training: + feat_wh = feats[0].size()[-2:] + upsampled_size = (feat_wh[0] * 2, feat_wh[1] * 2) + mask_pred = F.interpolate( + mask_pred.sigmoid(), size=upsampled_size, mode='bilinear') + cls_pred = cls_pred.sigmoid() + # get local maximum + local_max = F.max_pool2d(cls_pred, 2, stride=1, padding=1) + keep_mask = local_max[:, :, :-1, :-1] == cls_pred + cls_pred = cls_pred * keep_mask + + mlvl_mask_preds.append(mask_pred) + mlvl_cls_preds.append(cls_pred) + return mlvl_mask_preds, mlvl_cls_preds + + def loss(self, + mlvl_mask_preds, + mlvl_cls_preds, + gt_labels, + gt_masks, + img_metas, + gt_bboxes=None, + **kwargs): + """Calculate the loss of total batch. + + Args: + mlvl_mask_preds (list[Tensor]): Multi-level mask prediction. + Each element in the list has shape + (batch_size, num_grids**2 ,h ,w). + mlvl_cls_preds (list[Tensor]): Multi-level scores. Each element + in the list has shape + (batch_size, num_classes, num_grids ,num_grids). + gt_labels (list[Tensor]): Labels of multiple images. + gt_masks (list[Tensor]): Ground truth masks of multiple images. + Each has shape (num_instances, h, w). + img_metas (list[dict]): Meta information of multiple images. + gt_bboxes (list[Tensor]): Ground truth bboxes of multiple + images. Default: None. + + Returns: + dict[str, Tensor]: A dictionary of loss components. + """ + num_levels = self.num_levels + num_imgs = len(gt_labels) + + featmap_sizes = [featmap.size()[-2:] for featmap in mlvl_mask_preds] + + # `BoolTensor` in `pos_masks` represent + # whether the corresponding point is + # positive + pos_mask_targets, labels, pos_masks = multi_apply( + self._get_targets_single, + gt_bboxes, + gt_labels, + gt_masks, + featmap_sizes=featmap_sizes) + + # change from the outside list meaning multi images + # to the outside list meaning multi levels + mlvl_pos_mask_targets = [[] for _ in range(num_levels)] + mlvl_pos_mask_preds = [[] for _ in range(num_levels)] + mlvl_pos_masks = [[] for _ in range(num_levels)] + mlvl_labels = [[] for _ in range(num_levels)] + for img_id in range(num_imgs): + assert num_levels == len(pos_mask_targets[img_id]) + for lvl in range(num_levels): + mlvl_pos_mask_targets[lvl].append( + pos_mask_targets[img_id][lvl]) + mlvl_pos_mask_preds[lvl].append( + mlvl_mask_preds[lvl][img_id, pos_masks[img_id][lvl], ...]) + mlvl_pos_masks[lvl].append(pos_masks[img_id][lvl].flatten()) + mlvl_labels[lvl].append(labels[img_id][lvl].flatten()) + + # cat multiple image + temp_mlvl_cls_preds = [] + for lvl in range(num_levels): + mlvl_pos_mask_targets[lvl] = torch.cat( + mlvl_pos_mask_targets[lvl], dim=0) + mlvl_pos_mask_preds[lvl] = torch.cat( + mlvl_pos_mask_preds[lvl], dim=0) + mlvl_pos_masks[lvl] = torch.cat(mlvl_pos_masks[lvl], dim=0) + mlvl_labels[lvl] = torch.cat(mlvl_labels[lvl], dim=0) + temp_mlvl_cls_preds.append(mlvl_cls_preds[lvl].permute( + 0, 2, 3, 1).reshape(-1, self.cls_out_channels)) + + num_pos = sum(item.sum() for item in mlvl_pos_masks) + # dice loss + loss_mask = [] + for pred, target in zip(mlvl_pos_mask_preds, mlvl_pos_mask_targets): + if pred.size()[0] == 0: + loss_mask.append(pred.sum().unsqueeze(0)) + continue + loss_mask.append( + self.loss_mask(pred, target, reduction_override='none')) + if num_pos > 0: + loss_mask = torch.cat(loss_mask).sum() / num_pos + else: + loss_mask = torch.cat(loss_mask).mean() + + flatten_labels = torch.cat(mlvl_labels) + flatten_cls_preds = torch.cat(temp_mlvl_cls_preds) + loss_cls = self.loss_cls( + flatten_cls_preds, flatten_labels, avg_factor=num_pos + 1) + return dict(loss_mask=loss_mask, loss_cls=loss_cls) + + def _get_targets_single(self, + gt_bboxes, + gt_labels, + gt_masks, + featmap_sizes=None): + """Compute targets for predictions of single image. + + Args: + gt_bboxes (Tensor): Ground truth bbox of each instance, + shape (num_gts, 4). + gt_labels (Tensor): Ground truth label of each instance, + shape (num_gts,). + gt_masks (Tensor): Ground truth mask of each instance, + shape (num_gts, h, w). + featmap_sizes (list[:obj:`torch.size`]): Size of each + feature map from feature pyramid, each element + means (feat_h, feat_w). Default: None. + + Returns: + Tuple: Usually returns a tuple containing targets for predictions. + + - mlvl_pos_mask_targets (list[Tensor]): Each element represent + the binary mask targets for positive points in this + level, has shape (num_pos, out_h, out_w). + - mlvl_labels (list[Tensor]): Each element is + classification labels for all + points in this level, has shape + (num_grid, num_grid). + - mlvl_pos_masks (list[Tensor]): Each element is + a `BoolTensor` to represent whether the + corresponding point in single level + is positive, has shape (num_grid **2). + """ + device = gt_labels.device + gt_areas = torch.sqrt((gt_bboxes[:, 2] - gt_bboxes[:, 0]) * + (gt_bboxes[:, 3] - gt_bboxes[:, 1])) + + mlvl_pos_mask_targets = [] + mlvl_labels = [] + mlvl_pos_masks = [] + for (lower_bound, upper_bound), stride, featmap_size, num_grid \ + in zip(self.scale_ranges, self.strides, + featmap_sizes, self.num_grids): + + mask_target = torch.zeros( + [num_grid**2, featmap_size[0], featmap_size[1]], + dtype=torch.uint8, + device=device) + # FG cat_id: [0, num_classes -1], BG cat_id: num_classes + labels = torch.zeros([num_grid, num_grid], + dtype=torch.int64, + device=device) + self.num_classes + pos_mask = torch.zeros([num_grid**2], + dtype=torch.bool, + device=device) + + gt_inds = ((gt_areas >= lower_bound) & + (gt_areas <= upper_bound)).nonzero().flatten() + if len(gt_inds) == 0: + mlvl_pos_mask_targets.append( + mask_target.new_zeros(0, featmap_size[0], featmap_size[1])) + mlvl_labels.append(labels) + mlvl_pos_masks.append(pos_mask) + continue + hit_gt_bboxes = gt_bboxes[gt_inds] + hit_gt_labels = gt_labels[gt_inds] + hit_gt_masks = gt_masks[gt_inds, ...] + + pos_w_ranges = 0.5 * (hit_gt_bboxes[:, 2] - + hit_gt_bboxes[:, 0]) * self.pos_scale + pos_h_ranges = 0.5 * (hit_gt_bboxes[:, 3] - + hit_gt_bboxes[:, 1]) * self.pos_scale + + # Make sure hit_gt_masks has a value + valid_mask_flags = hit_gt_masks.sum(dim=-1).sum(dim=-1) > 0 + output_stride = stride / 2 + + for gt_mask, gt_label, pos_h_range, pos_w_range, \ + valid_mask_flag in \ + zip(hit_gt_masks, hit_gt_labels, pos_h_ranges, + pos_w_ranges, valid_mask_flags): + if not valid_mask_flag: + continue + upsampled_size = (featmap_sizes[0][0] * 4, + featmap_sizes[0][1] * 4) + center_h, center_w = center_of_mass(gt_mask) + + coord_w = int( + (center_w / upsampled_size[1]) // (1. / num_grid)) + coord_h = int( + (center_h / upsampled_size[0]) // (1. / num_grid)) + + # left, top, right, down + top_box = max( + 0, + int(((center_h - pos_h_range) / upsampled_size[0]) // + (1. / num_grid))) + down_box = min( + num_grid - 1, + int(((center_h + pos_h_range) / upsampled_size[0]) // + (1. / num_grid))) + left_box = max( + 0, + int(((center_w - pos_w_range) / upsampled_size[1]) // + (1. / num_grid))) + right_box = min( + num_grid - 1, + int(((center_w + pos_w_range) / upsampled_size[1]) // + (1. / num_grid))) + + top = max(top_box, coord_h - 1) + down = min(down_box, coord_h + 1) + left = max(coord_w - 1, left_box) + right = min(right_box, coord_w + 1) + + labels[top:(down + 1), left:(right + 1)] = gt_label + # ins + gt_mask = np.uint8(gt_mask.cpu().numpy()) + # Follow the original implementation, F.interpolate is + # different from cv2 and opencv + gt_mask = mmcv.imrescale(gt_mask, scale=1. / output_stride) + gt_mask = torch.from_numpy(gt_mask).to(device=device) + + for i in range(top, down + 1): + for j in range(left, right + 1): + index = int(i * num_grid + j) + mask_target[index, :gt_mask.shape[0], :gt_mask. + shape[1]] = gt_mask + pos_mask[index] = True + mlvl_pos_mask_targets.append(mask_target[pos_mask]) + mlvl_labels.append(labels) + mlvl_pos_masks.append(pos_mask) + return mlvl_pos_mask_targets, mlvl_labels, mlvl_pos_masks + + def get_results(self, mlvl_mask_preds, mlvl_cls_scores, img_metas, + **kwargs): + """Get multi-image mask results. + + Args: + mlvl_mask_preds (list[Tensor]): Multi-level mask prediction. + Each element in the list has shape + (batch_size, num_grids**2 ,h ,w). + mlvl_cls_scores (list[Tensor]): Multi-level scores. Each element + in the list has shape + (batch_size, num_classes, num_grids ,num_grids). + img_metas (list[dict]): Meta information of all images. + + Returns: + list[:obj:`InstanceData`]: Processed results of multiple + images.Each :obj:`InstanceData` usually contains + following keys. + + - scores (Tensor): Classification scores, has shape + (num_instance,). + - labels (Tensor): Has shape (num_instances,). + - masks (Tensor): Processed mask results, has + shape (num_instances, h, w). + """ + mlvl_cls_scores = [ + item.permute(0, 2, 3, 1) for item in mlvl_cls_scores + ] + assert len(mlvl_mask_preds) == len(mlvl_cls_scores) + num_levels = len(mlvl_cls_scores) + + results_list = [] + for img_id in range(len(img_metas)): + cls_pred_list = [ + mlvl_cls_scores[lvl][img_id].view(-1, self.cls_out_channels) + for lvl in range(num_levels) + ] + mask_pred_list = [ + mlvl_mask_preds[lvl][img_id] for lvl in range(num_levels) + ] + + cls_pred_list = torch.cat(cls_pred_list, dim=0) + mask_pred_list = torch.cat(mask_pred_list, dim=0) + + results = self._get_results_single( + cls_pred_list, mask_pred_list, img_meta=img_metas[img_id]) + results_list.append(results) + + return results_list + + def _get_results_single(self, cls_scores, mask_preds, img_meta, cfg=None): + """Get processed mask related results of single image. + + Args: + cls_scores (Tensor): Classification score of all points + in single image, has shape (num_points, num_classes). + mask_preds (Tensor): Mask prediction of all points in + single image, has shape (num_points, feat_h, feat_w). + img_meta (dict): Meta information of corresponding image. + cfg (dict, optional): Config used in test phase. + Default: None. + + Returns: + :obj:`InstanceData`: Processed results of single image. + it usually contains following keys. + + - scores (Tensor): Classification scores, has shape + (num_instance,). + - labels (Tensor): Has shape (num_instances,). + - masks (Tensor): Processed mask results, has + shape (num_instances, h, w). + """ + + def empty_results(results, cls_scores): + """Generate a empty results.""" + results.scores = cls_scores.new_ones(0) + results.masks = cls_scores.new_zeros(0, *results.ori_shape[:2]) + results.labels = cls_scores.new_ones(0) + return results + + cfg = self.test_cfg if cfg is None else cfg + assert len(cls_scores) == len(mask_preds) + results = InstanceData(img_meta) + + featmap_size = mask_preds.size()[-2:] + + img_shape = results.img_shape + ori_shape = results.ori_shape + + h, w, _ = img_shape + upsampled_size = (featmap_size[0] * 4, featmap_size[1] * 4) + + score_mask = (cls_scores > cfg.score_thr) + cls_scores = cls_scores[score_mask] + if len(cls_scores) == 0: + return empty_results(results, cls_scores) + + inds = score_mask.nonzero() + cls_labels = inds[:, 1] + + # Filter the mask mask with an area is smaller than + # stride of corresponding feature level + lvl_interval = cls_labels.new_tensor(self.num_grids).pow(2).cumsum(0) + strides = cls_scores.new_ones(lvl_interval[-1]) + strides[:lvl_interval[0]] *= self.strides[0] + for lvl in range(1, self.num_levels): + strides[lvl_interval[lvl - + 1]:lvl_interval[lvl]] *= self.strides[lvl] + strides = strides[inds[:, 0]] + mask_preds = mask_preds[inds[:, 0]] + + masks = mask_preds > cfg.mask_thr + sum_masks = masks.sum((1, 2)).float() + keep = sum_masks > strides + if keep.sum() == 0: + return empty_results(results, cls_scores) + masks = masks[keep] + mask_preds = mask_preds[keep] + sum_masks = sum_masks[keep] + cls_scores = cls_scores[keep] + cls_labels = cls_labels[keep] + + # maskness. + mask_scores = (mask_preds * masks).sum((1, 2)) / sum_masks + cls_scores *= mask_scores + + scores, labels, _, keep_inds = mask_matrix_nms( + masks, + cls_labels, + cls_scores, + mask_area=sum_masks, + nms_pre=cfg.nms_pre, + max_num=cfg.max_per_img, + kernel=cfg.kernel, + sigma=cfg.sigma, + filter_thr=cfg.filter_thr) + mask_preds = mask_preds[keep_inds] + mask_preds = F.interpolate( + mask_preds.unsqueeze(0), size=upsampled_size, + mode='bilinear')[:, :, :h, :w] + mask_preds = F.interpolate( + mask_preds, size=ori_shape[:2], mode='bilinear').squeeze(0) + masks = mask_preds > cfg.mask_thr + + results.masks = masks + results.labels = labels + results.scores = scores + + return results + + +@HEADS.register_module() +class DecoupledSOLOHead(SOLOHead): + """Decoupled SOLO mask head used in `SOLO: Segmenting Objects by Locations. + + `_ + + Args: + init_cfg (dict or list[dict], optional): Initialization config dict. + """ + + def __init__(self, + *args, + init_cfg=[ + dict(type='Normal', layer='Conv2d', std=0.01), + dict( + type='Normal', + std=0.01, + bias_prob=0.01, + override=dict(name='conv_mask_list_x')), + dict( + type='Normal', + std=0.01, + bias_prob=0.01, + override=dict(name='conv_mask_list_y')), + dict( + type='Normal', + std=0.01, + bias_prob=0.01, + override=dict(name='conv_cls')) + ], + **kwargs): + super(DecoupledSOLOHead, self).__init__( + *args, init_cfg=init_cfg, **kwargs) + + def _init_layers(self): + self.mask_convs_x = nn.ModuleList() + self.mask_convs_y = nn.ModuleList() + self.cls_convs = nn.ModuleList() + + for i in range(self.stacked_convs): + chn = self.in_channels + 1 if i == 0 else self.feat_channels + self.mask_convs_x.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + norm_cfg=self.norm_cfg)) + self.mask_convs_y.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + norm_cfg=self.norm_cfg)) + + chn = self.in_channels if i == 0 else self.feat_channels + self.cls_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + norm_cfg=self.norm_cfg)) + + self.conv_mask_list_x = nn.ModuleList() + self.conv_mask_list_y = nn.ModuleList() + for num_grid in self.num_grids: + self.conv_mask_list_x.append( + nn.Conv2d(self.feat_channels, num_grid, 3, padding=1)) + self.conv_mask_list_y.append( + nn.Conv2d(self.feat_channels, num_grid, 3, padding=1)) + self.conv_cls = nn.Conv2d( + self.feat_channels, self.cls_out_channels, 3, padding=1) + + def forward(self, feats): + assert len(feats) == self.num_levels + feats = self.resize_feats(feats) + mask_preds_x = [] + mask_preds_y = [] + cls_preds = [] + for i in range(self.num_levels): + x = feats[i] + mask_feat = x + cls_feat = x + # generate and concat the coordinate + coord_feat = generate_coordinate(mask_feat.size(), + mask_feat.device) + mask_feat_x = torch.cat([mask_feat, coord_feat[:, 0:1, ...]], 1) + mask_feat_y = torch.cat([mask_feat, coord_feat[:, 1:2, ...]], 1) + + for mask_layer_x, mask_layer_y in \ + zip(self.mask_convs_x, self.mask_convs_y): + mask_feat_x = mask_layer_x(mask_feat_x) + mask_feat_y = mask_layer_y(mask_feat_y) + + mask_feat_x = F.interpolate( + mask_feat_x, scale_factor=2, mode='bilinear') + mask_feat_y = F.interpolate( + mask_feat_y, scale_factor=2, mode='bilinear') + + mask_pred_x = self.conv_mask_list_x[i](mask_feat_x) + mask_pred_y = self.conv_mask_list_y[i](mask_feat_y) + + # cls branch + for j, cls_layer in enumerate(self.cls_convs): + if j == self.cls_down_index: + num_grid = self.num_grids[i] + cls_feat = F.interpolate( + cls_feat, size=num_grid, mode='bilinear') + cls_feat = cls_layer(cls_feat) + + cls_pred = self.conv_cls(cls_feat) + + if not self.training: + feat_wh = feats[0].size()[-2:] + upsampled_size = (feat_wh[0] * 2, feat_wh[1] * 2) + mask_pred_x = F.interpolate( + mask_pred_x.sigmoid(), + size=upsampled_size, + mode='bilinear') + mask_pred_y = F.interpolate( + mask_pred_y.sigmoid(), + size=upsampled_size, + mode='bilinear') + cls_pred = cls_pred.sigmoid() + # get local maximum + local_max = F.max_pool2d(cls_pred, 2, stride=1, padding=1) + keep_mask = local_max[:, :, :-1, :-1] == cls_pred + cls_pred = cls_pred * keep_mask + + mask_preds_x.append(mask_pred_x) + mask_preds_y.append(mask_pred_y) + cls_preds.append(cls_pred) + return mask_preds_x, mask_preds_y, cls_preds + + def loss(self, + mlvl_mask_preds_x, + mlvl_mask_preds_y, + mlvl_cls_preds, + gt_labels, + gt_masks, + img_metas, + gt_bboxes=None, + **kwargs): + """Calculate the loss of total batch. + + Args: + mlvl_mask_preds_x (list[Tensor]): Multi-level mask prediction + from x branch. Each element in the list has shape + (batch_size, num_grids ,h ,w). + mlvl_mask_preds_x (list[Tensor]): Multi-level mask prediction + from y branch. Each element in the list has shape + (batch_size, num_grids ,h ,w). + mlvl_cls_preds (list[Tensor]): Multi-level scores. Each element + in the list has shape + (batch_size, num_classes, num_grids ,num_grids). + gt_labels (list[Tensor]): Labels of multiple images. + gt_masks (list[Tensor]): Ground truth masks of multiple images. + Each has shape (num_instances, h, w). + img_metas (list[dict]): Meta information of multiple images. + gt_bboxes (list[Tensor]): Ground truth bboxes of multiple + images. Default: None. + + Returns: + dict[str, Tensor]: A dictionary of loss components. + """ + num_levels = self.num_levels + num_imgs = len(gt_labels) + featmap_sizes = [featmap.size()[-2:] for featmap in mlvl_mask_preds_x] + + pos_mask_targets, labels, \ + xy_pos_indexes = \ + multi_apply(self._get_targets_single, + gt_bboxes, + gt_labels, + gt_masks, + featmap_sizes=featmap_sizes) + + # change from the outside list meaning multi images + # to the outside list meaning multi levels + mlvl_pos_mask_targets = [[] for _ in range(num_levels)] + mlvl_pos_mask_preds_x = [[] for _ in range(num_levels)] + mlvl_pos_mask_preds_y = [[] for _ in range(num_levels)] + mlvl_labels = [[] for _ in range(num_levels)] + for img_id in range(num_imgs): + + for lvl in range(num_levels): + mlvl_pos_mask_targets[lvl].append( + pos_mask_targets[img_id][lvl]) + mlvl_pos_mask_preds_x[lvl].append( + mlvl_mask_preds_x[lvl][img_id, + xy_pos_indexes[img_id][lvl][:, 1]]) + mlvl_pos_mask_preds_y[lvl].append( + mlvl_mask_preds_y[lvl][img_id, + xy_pos_indexes[img_id][lvl][:, 0]]) + mlvl_labels[lvl].append(labels[img_id][lvl].flatten()) + + # cat multiple image + temp_mlvl_cls_preds = [] + for lvl in range(num_levels): + mlvl_pos_mask_targets[lvl] = torch.cat( + mlvl_pos_mask_targets[lvl], dim=0) + mlvl_pos_mask_preds_x[lvl] = torch.cat( + mlvl_pos_mask_preds_x[lvl], dim=0) + mlvl_pos_mask_preds_y[lvl] = torch.cat( + mlvl_pos_mask_preds_y[lvl], dim=0) + mlvl_labels[lvl] = torch.cat(mlvl_labels[lvl], dim=0) + temp_mlvl_cls_preds.append(mlvl_cls_preds[lvl].permute( + 0, 2, 3, 1).reshape(-1, self.cls_out_channels)) + + num_pos = 0. + # dice loss + loss_mask = [] + for pred_x, pred_y, target in \ + zip(mlvl_pos_mask_preds_x, + mlvl_pos_mask_preds_y, mlvl_pos_mask_targets): + num_masks = pred_x.size(0) + if num_masks == 0: + # make sure can get grad + loss_mask.append((pred_x.sum() + pred_y.sum()).unsqueeze(0)) + continue + num_pos += num_masks + pred_mask = pred_y.sigmoid() * pred_x.sigmoid() + loss_mask.append( + self.loss_mask(pred_mask, target, reduction_override='none')) + if num_pos > 0: + loss_mask = torch.cat(loss_mask).sum() / num_pos + else: + loss_mask = torch.cat(loss_mask).mean() + + # cate + flatten_labels = torch.cat(mlvl_labels) + flatten_cls_preds = torch.cat(temp_mlvl_cls_preds) + + loss_cls = self.loss_cls( + flatten_cls_preds, flatten_labels, avg_factor=num_pos + 1) + return dict(loss_mask=loss_mask, loss_cls=loss_cls) + + def _get_targets_single(self, + gt_bboxes, + gt_labels, + gt_masks, + featmap_sizes=None): + """Compute targets for predictions of single image. + + Args: + gt_bboxes (Tensor): Ground truth bbox of each instance, + shape (num_gts, 4). + gt_labels (Tensor): Ground truth label of each instance, + shape (num_gts,). + gt_masks (Tensor): Ground truth mask of each instance, + shape (num_gts, h, w). + featmap_sizes (list[:obj:`torch.size`]): Size of each + feature map from feature pyramid, each element + means (feat_h, feat_w). Default: None. + + Returns: + Tuple: Usually returns a tuple containing targets for predictions. + + - mlvl_pos_mask_targets (list[Tensor]): Each element represent + the binary mask targets for positive points in this + level, has shape (num_pos, out_h, out_w). + - mlvl_labels (list[Tensor]): Each element is + classification labels for all + points in this level, has shape + (num_grid, num_grid). + - mlvl_xy_pos_indexes (list[Tensor]): Each element + in the list contains the index of positive samples in + corresponding level, has shape (num_pos, 2), last + dimension 2 present (index_x, index_y). + """ + mlvl_pos_mask_targets, mlvl_labels, \ + mlvl_pos_masks = \ + super()._get_targets_single(gt_bboxes, gt_labels, gt_masks, + featmap_sizes=featmap_sizes) + + mlvl_xy_pos_indexes = [(item - self.num_classes).nonzero() + for item in mlvl_labels] + + return mlvl_pos_mask_targets, mlvl_labels, mlvl_xy_pos_indexes + + def get_results(self, + mlvl_mask_preds_x, + mlvl_mask_preds_y, + mlvl_cls_scores, + img_metas, + rescale=None, + **kwargs): + """Get multi-image mask results. + + Args: + mlvl_mask_preds_x (list[Tensor]): Multi-level mask prediction + from x branch. Each element in the list has shape + (batch_size, num_grids ,h ,w). + mlvl_mask_preds_y (list[Tensor]): Multi-level mask prediction + from y branch. Each element in the list has shape + (batch_size, num_grids ,h ,w). + mlvl_cls_scores (list[Tensor]): Multi-level scores. Each element + in the list has shape + (batch_size, num_classes ,num_grids ,num_grids). + img_metas (list[dict]): Meta information of all images. + + Returns: + list[:obj:`InstanceData`]: Processed results of multiple + images.Each :obj:`InstanceData` usually contains + following keys. + + - scores (Tensor): Classification scores, has shape + (num_instance,). + - labels (Tensor): Has shape (num_instances,). + - masks (Tensor): Processed mask results, has + shape (num_instances, h, w). + """ + mlvl_cls_scores = [ + item.permute(0, 2, 3, 1) for item in mlvl_cls_scores + ] + assert len(mlvl_mask_preds_x) == len(mlvl_cls_scores) + num_levels = len(mlvl_cls_scores) + + results_list = [] + for img_id in range(len(img_metas)): + cls_pred_list = [ + mlvl_cls_scores[i][img_id].view( + -1, self.cls_out_channels).detach() + for i in range(num_levels) + ] + mask_pred_list_x = [ + mlvl_mask_preds_x[i][img_id] for i in range(num_levels) + ] + mask_pred_list_y = [ + mlvl_mask_preds_y[i][img_id] for i in range(num_levels) + ] + + cls_pred_list = torch.cat(cls_pred_list, dim=0) + mask_pred_list_x = torch.cat(mask_pred_list_x, dim=0) + mask_pred_list_y = torch.cat(mask_pred_list_y, dim=0) + + results = self._get_results_single( + cls_pred_list, + mask_pred_list_x, + mask_pred_list_y, + img_meta=img_metas[img_id], + cfg=self.test_cfg) + results_list.append(results) + return results_list + + def _get_results_single(self, cls_scores, mask_preds_x, mask_preds_y, + img_meta, cfg): + """Get processed mask related results of single image. + + Args: + cls_scores (Tensor): Classification score of all points + in single image, has shape (num_points, num_classes). + mask_preds_x (Tensor): Mask prediction of x branch of + all points in single image, has shape + (sum_num_grids, feat_h, feat_w). + mask_preds_y (Tensor): Mask prediction of y branch of + all points in single image, has shape + (sum_num_grids, feat_h, feat_w). + img_meta (dict): Meta information of corresponding image. + cfg (dict): Config used in test phase. + + Returns: + :obj:`InstanceData`: Processed results of single image. + it usually contains following keys. + + - scores (Tensor): Classification scores, has shape + (num_instance,). + - labels (Tensor): Has shape (num_instances,). + - masks (Tensor): Processed mask results, has + shape (num_instances, h, w). + """ + + def empty_results(results, cls_scores): + """Generate a empty results.""" + results.scores = cls_scores.new_ones(0) + results.masks = cls_scores.new_zeros(0, *results.ori_shape[:2]) + results.labels = cls_scores.new_ones(0) + return results + + cfg = self.test_cfg if cfg is None else cfg + + results = InstanceData(img_meta) + img_shape = results.img_shape + ori_shape = results.ori_shape + h, w, _ = img_shape + featmap_size = mask_preds_x.size()[-2:] + upsampled_size = (featmap_size[0] * 4, featmap_size[1] * 4) + + score_mask = (cls_scores > cfg.score_thr) + cls_scores = cls_scores[score_mask] + inds = score_mask.nonzero() + lvl_interval = inds.new_tensor(self.num_grids).pow(2).cumsum(0) + num_all_points = lvl_interval[-1] + lvl_start_index = inds.new_ones(num_all_points) + num_grids = inds.new_ones(num_all_points) + seg_size = inds.new_tensor(self.num_grids).cumsum(0) + mask_lvl_start_index = inds.new_ones(num_all_points) + strides = inds.new_ones(num_all_points) + + lvl_start_index[:lvl_interval[0]] *= 0 + mask_lvl_start_index[:lvl_interval[0]] *= 0 + num_grids[:lvl_interval[0]] *= self.num_grids[0] + strides[:lvl_interval[0]] *= self.strides[0] + + for lvl in range(1, self.num_levels): + lvl_start_index[lvl_interval[lvl - 1]:lvl_interval[lvl]] *= \ + lvl_interval[lvl - 1] + mask_lvl_start_index[lvl_interval[lvl - 1]:lvl_interval[lvl]] *= \ + seg_size[lvl - 1] + num_grids[lvl_interval[lvl - 1]:lvl_interval[lvl]] *= \ + self.num_grids[lvl] + strides[lvl_interval[lvl - 1]:lvl_interval[lvl]] *= \ + self.strides[lvl] + + lvl_start_index = lvl_start_index[inds[:, 0]] + mask_lvl_start_index = mask_lvl_start_index[inds[:, 0]] + num_grids = num_grids[inds[:, 0]] + strides = strides[inds[:, 0]] + + y_lvl_offset = (inds[:, 0] - lvl_start_index) // num_grids + x_lvl_offset = (inds[:, 0] - lvl_start_index) % num_grids + y_inds = mask_lvl_start_index + y_lvl_offset + x_inds = mask_lvl_start_index + x_lvl_offset + + cls_labels = inds[:, 1] + mask_preds = mask_preds_x[x_inds, ...] * mask_preds_y[y_inds, ...] + + masks = mask_preds > cfg.mask_thr + sum_masks = masks.sum((1, 2)).float() + keep = sum_masks > strides + if keep.sum() == 0: + return empty_results(results, cls_scores) + + masks = masks[keep] + mask_preds = mask_preds[keep] + sum_masks = sum_masks[keep] + cls_scores = cls_scores[keep] + cls_labels = cls_labels[keep] + + # maskness. + mask_scores = (mask_preds * masks).sum((1, 2)) / sum_masks + cls_scores *= mask_scores + + scores, labels, _, keep_inds = mask_matrix_nms( + masks, + cls_labels, + cls_scores, + mask_area=sum_masks, + nms_pre=cfg.nms_pre, + max_num=cfg.max_per_img, + kernel=cfg.kernel, + sigma=cfg.sigma, + filter_thr=cfg.filter_thr) + mask_preds = mask_preds[keep_inds] + mask_preds = F.interpolate( + mask_preds.unsqueeze(0), size=upsampled_size, + mode='bilinear')[:, :, :h, :w] + mask_preds = F.interpolate( + mask_preds, size=ori_shape[:2], mode='bilinear').squeeze(0) + masks = mask_preds > cfg.mask_thr + + results.masks = masks + results.labels = labels + results.scores = scores + + return results + + +@HEADS.register_module() +class DecoupledSOLOLightHead(DecoupledSOLOHead): + """Decoupled Light SOLO mask head used in `SOLO: Segmenting Objects by + Locations `_ + + Args: + with_dcn (bool): Whether use dcn in mask_convs and cls_convs, + default: False. + init_cfg (dict or list[dict], optional): Initialization config dict. + """ + + def __init__(self, + *args, + dcn_cfg=None, + init_cfg=[ + dict(type='Normal', layer='Conv2d', std=0.01), + dict( + type='Normal', + std=0.01, + bias_prob=0.01, + override=dict(name='conv_mask_list_x')), + dict( + type='Normal', + std=0.01, + bias_prob=0.01, + override=dict(name='conv_mask_list_y')), + dict( + type='Normal', + std=0.01, + bias_prob=0.01, + override=dict(name='conv_cls')) + ], + **kwargs): + assert dcn_cfg is None or isinstance(dcn_cfg, dict) + self.dcn_cfg = dcn_cfg + super(DecoupledSOLOLightHead, self).__init__( + *args, init_cfg=init_cfg, **kwargs) + + def _init_layers(self): + self.mask_convs = nn.ModuleList() + self.cls_convs = nn.ModuleList() + + for i in range(self.stacked_convs): + if self.dcn_cfg is not None\ + and i == self.stacked_convs - 1: + conv_cfg = self.dcn_cfg + else: + conv_cfg = None + + chn = self.in_channels + 2 if i == 0 else self.feat_channels + self.mask_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=conv_cfg, + norm_cfg=self.norm_cfg)) + + chn = self.in_channels if i == 0 else self.feat_channels + self.cls_convs.append( + ConvModule( + chn, + self.feat_channels, + 3, + stride=1, + padding=1, + conv_cfg=conv_cfg, + norm_cfg=self.norm_cfg)) + + self.conv_mask_list_x = nn.ModuleList() + self.conv_mask_list_y = nn.ModuleList() + for num_grid in self.num_grids: + self.conv_mask_list_x.append( + nn.Conv2d(self.feat_channels, num_grid, 3, padding=1)) + self.conv_mask_list_y.append( + nn.Conv2d(self.feat_channels, num_grid, 3, padding=1)) + self.conv_cls = nn.Conv2d( + self.feat_channels, self.cls_out_channels, 3, padding=1) + + def forward(self, feats): + assert len(feats) == self.num_levels + feats = self.resize_feats(feats) + mask_preds_x = [] + mask_preds_y = [] + cls_preds = [] + for i in range(self.num_levels): + x = feats[i] + mask_feat = x + cls_feat = x + # generate and concat the coordinate + coord_feat = generate_coordinate(mask_feat.size(), + mask_feat.device) + mask_feat = torch.cat([mask_feat, coord_feat], 1) + + for mask_layer in self.mask_convs: + mask_feat = mask_layer(mask_feat) + + mask_feat = F.interpolate( + mask_feat, scale_factor=2, mode='bilinear') + + mask_pred_x = self.conv_mask_list_x[i](mask_feat) + mask_pred_y = self.conv_mask_list_y[i](mask_feat) + + # cls branch + for j, cls_layer in enumerate(self.cls_convs): + if j == self.cls_down_index: + num_grid = self.num_grids[i] + cls_feat = F.interpolate( + cls_feat, size=num_grid, mode='bilinear') + cls_feat = cls_layer(cls_feat) + + cls_pred = self.conv_cls(cls_feat) + + if not self.training: + feat_wh = feats[0].size()[-2:] + upsampled_size = (feat_wh[0] * 2, feat_wh[1] * 2) + mask_pred_x = F.interpolate( + mask_pred_x.sigmoid(), + size=upsampled_size, + mode='bilinear') + mask_pred_y = F.interpolate( + mask_pred_y.sigmoid(), + size=upsampled_size, + mode='bilinear') + cls_pred = cls_pred.sigmoid() + # get local maximum + local_max = F.max_pool2d(cls_pred, 2, stride=1, padding=1) + keep_mask = local_max[:, :, :-1, :-1] == cls_pred + cls_pred = cls_pred * keep_mask + + mask_preds_x.append(mask_pred_x) + mask_preds_y.append(mask_pred_y) + cls_preds.append(cls_pred) + return mask_preds_x, mask_preds_y, cls_preds diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/__init__.py index e7aad355d..45b2597e3 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/__init__.py @@ -1,27 +1,6 @@ -from .atss import ATSS -from .base import BaseDetector -from .cascade_rcnn import CascadeRCNN -from .double_head_rcnn import DoubleHeadRCNN -from .fast_rcnn import FastRCNN -from .faster_rcnn import FasterRCNN -from .fcos import FCOS -from .fovea import FOVEA -from .grid_rcnn import GridRCNN -from .htc import HybridTaskCascade -from .mask_rcnn import MaskRCNN -from .mask_scoring_rcnn import MaskScoringRCNN -from .reppoints_detector import RepPointsDetector -from .retinanet import RetinaNet -from .rpn import RPN -from .single_stage import SingleStageDetector -from .single_stage_ins import SingleStageInsDetector -from .two_stage import TwoStageDetector from .solo import SOLO -from .solov2 import SOLOv2 -__all__ = [ - 'ATSS', 'BaseDetector', 'SingleStageDetector', 'TwoStageDetector', 'RPN', - 'FastRCNN', 'FasterRCNN', 'MaskRCNN', 'CascadeRCNN', 'HybridTaskCascade', - 'DoubleHeadRCNN', 'RetinaNet', 'FCOS', 'GridRCNN', 'MaskScoringRCNN', - 'RepPointsDetector', 'FOVEA', 'SingleStageInsDetector', 'SOLO', 'SOLOv2' -] +__all__ = ['SOLO'] + + + diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/atss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/atss.py deleted file mode 100644 index ac22bf928..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/atss.py +++ /dev/null @@ -1,16 +0,0 @@ -from ..registry import DETECTORS -from .single_stage import SingleStageDetector - - -@DETECTORS.register_module -class ATSS(SingleStageDetector): - - def __init__(self, - backbone, - neck, - bbox_head, - train_cfg=None, - test_cfg=None, - pretrained=None): - super(ATSS, self).__init__(backbone, neck, bbox_head, train_cfg, - test_cfg, pretrained) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/base.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/base.py index 82f91bd10..691a0c316 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/base.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/base.py @@ -1,101 +1,111 @@ +# Copyright (c) OpenMMLab. All rights reserved. from abc import ABCMeta, abstractmethod +from collections import OrderedDict import mmcv import numpy as np -import pycocotools.mask as maskUtils -import torch.nn as nn +import torch +import torch.distributed as dist +from mmcv.runner import BaseModule, auto_fp16 -from mmdet.core import auto_fp16, get_classes, tensor2imgs -from mmdet.utils import print_log +# from mmdet.core.visualization import imshow_det_bboxes -class BaseDetector(nn.Module, metaclass=ABCMeta): - """Base class for detectors""" +class BaseDetector(BaseModule, metaclass=ABCMeta): + """Base class for detectors.""" - def __init__(self): - super(BaseDetector, self).__init__() + def __init__(self, init_cfg=None): + super(BaseDetector, self).__init__(init_cfg) self.fp16_enabled = False @property def with_neck(self): + """bool: whether the detector has a neck""" return hasattr(self, 'neck') and self.neck is not None - @property - def with_mask_feat_head(self): - return hasattr(self, 'mask_feat_head') and \ - self.mask_feat_head is not None - + # TODO: these properties need to be carefully handled + # for both single stage & two stage detectors @property def with_shared_head(self): - return hasattr(self, 'shared_head') and self.shared_head is not None + """bool: whether the detector has a shared head in the RoI Head""" + return hasattr(self, 'roi_head') and self.roi_head.with_shared_head @property def with_bbox(self): - return hasattr(self, 'bbox_head') and self.bbox_head is not None + """bool: whether the detector has a bbox head""" + return ((hasattr(self, 'roi_head') and self.roi_head.with_bbox) + or (hasattr(self, 'bbox_head') and self.bbox_head is not None)) @property def with_mask(self): - return hasattr(self, 'mask_head') and self.mask_head is not None + """bool: whether the detector has a mask head""" + return ((hasattr(self, 'roi_head') and self.roi_head.with_mask) + or (hasattr(self, 'mask_head') and self.mask_head is not None)) @abstractmethod def extract_feat(self, imgs): + """Extract features from images.""" pass def extract_feats(self, imgs): + """Extract features from multiple images. + + Args: + imgs (list[torch.Tensor]): A list of images. The images are + augmented from the same image but in different ways. + + Returns: + list[torch.Tensor]: Features of different images + """ assert isinstance(imgs, list) - for img in imgs: - yield self.extract_feat(img) + return [self.extract_feat(img) for img in imgs] - @abstractmethod def forward_train(self, imgs, img_metas, **kwargs): """ Args: - img (list[Tensor]): list of tensors of shape (1, C, H, W). + img (Tensor): of shape (N, C, H, W) encoding input images. Typically these should be mean centered and std scaled. - - img_metas (list[dict]): list of image info dict where each dict - has: - 'img_shape', 'scale_factor', 'flip', and my also contain + img_metas (list[dict]): List of image info dict where each dict + has: 'img_shape', 'scale_factor', 'flip', and may also contain 'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'. - For details on the values of these keys see - `mmdet/datasets/pipelines/formatting.py:Collect`. - - **kwargs: specific to concrete implementation + For details on the values of these keys, see + :class:`mmdet.datasets.pipelines.Collect`. + kwargs (keyword arguments): Specific to concrete implementation. """ - pass + # NOTE the batched image size information may be useful, e.g. + # in DETR, this is needed for the construction of masks, which is + # then used for the transformer_head. + batch_input_shape = tuple(imgs[0].size()[-2:]) + for img_meta in img_metas: + img_meta['batch_input_shape'] = batch_input_shape - async def async_simple_test(self, img, img_meta, **kwargs): + async def async_simple_test(self, img, img_metas, **kwargs): raise NotImplementedError @abstractmethod - def simple_test(self, img, img_meta, **kwargs): + def simple_test(self, img, img_metas, **kwargs): pass @abstractmethod def aug_test(self, imgs, img_metas, **kwargs): + """Test function with test time augmentation.""" pass - def init_weights(self, pretrained=None): - if pretrained is not None: - print_log('load model from: {}'.format(pretrained), logger='root') - - async def aforward_test(self, *, img, img_meta, **kwargs): - for var, name in [(img, 'img'), (img_meta, 'img_meta')]: + async def aforward_test(self, *, img, img_metas, **kwargs): + for var, name in [(img, 'img'), (img_metas, 'img_metas')]: if not isinstance(var, list): - raise TypeError('{} must be a list, but got {}'.format( - name, type(var))) + raise TypeError(f'{name} must be a list, but got {type(var)}') num_augs = len(img) - if num_augs != len(img_meta): - raise ValueError( - 'num of augmentations ({}) != num of image meta ({})'.format( - len(img), len(img_meta))) - # TODO: remove the restriction of imgs_per_gpu == 1 when prepared - imgs_per_gpu = img[0].size(0) - assert imgs_per_gpu == 1 + if num_augs != len(img_metas): + raise ValueError(f'num of augmentations ({len(img)}) ' + f'!= num of image metas ({len(img_metas)})') + # TODO: remove the restriction of samples_per_gpu == 1 when prepared + samples_per_gpu = img[0].size(0) + assert samples_per_gpu == 1 if num_augs == 1: - return await self.async_simple_test(img[0], img_meta[0], **kwargs) + return await self.async_simple_test(img[0], img_metas[0], **kwargs) else: raise NotImplementedError @@ -105,89 +115,246 @@ class BaseDetector(nn.Module, metaclass=ABCMeta): imgs (List[Tensor]): the outer list indicates test-time augmentations and inner Tensor should have a shape NxCxHxW, which contains all images in the batch. - img_meta (List[List[dict]]): the outer list indicates test-time + img_metas (List[List[dict]]): the outer list indicates test-time augs (multiscale, flip, etc.) and the inner list indicates - images in a batch + images in a batch. """ for var, name in [(imgs, 'imgs'), (img_metas, 'img_metas')]: if not isinstance(var, list): - raise TypeError('{} must be a list, but got {}'.format( - name, type(var))) + raise TypeError(f'{name} must be a list, but got {type(var)}') num_augs = len(imgs) if num_augs != len(img_metas): - raise ValueError( - 'num of augmentations ({}) != num of image meta ({})'.format( - len(imgs), len(img_metas))) - # TODO: remove the restriction of imgs_per_gpu == 1 when prepared - imgs_per_gpu = imgs[0].size(0) - assert imgs_per_gpu == 1 + raise ValueError(f'num of augmentations ({len(imgs)}) ' + f'!= num of image meta ({len(img_metas)})') + + # NOTE the batched image size information may be useful, e.g. + # in DETR, this is needed for the construction of masks, which is + # then used for the transformer_head. + for img, img_meta in zip(imgs, img_metas): + batch_size = len(img_meta) + for img_id in range(batch_size): + img_meta[img_id]['batch_input_shape'] = tuple(img.size()[-2:]) if num_augs == 1: + # proposals (List[List[Tensor]]): the outer list indicates + # test-time augs (multiscale, flip, etc.) and the inner list + # indicates images in a batch. + # The Tensor should have a shape Px4, where P is the number of + # proposals. + if 'proposals' in kwargs: + kwargs['proposals'] = kwargs['proposals'][0] return self.simple_test(imgs[0], img_metas[0], **kwargs) else: + assert imgs[0].size(0) == 1, 'aug test does not support ' \ + 'inference with batch size ' \ + f'{imgs[0].size(0)}' + # TODO: support test augmentation for predefined proposals + assert 'proposals' not in kwargs return self.aug_test(imgs, img_metas, **kwargs) @auto_fp16(apply_to=('img', )) - def forward(self, img, img_meta, return_loss=True, **kwargs): - """ - Calls either forward_train or forward_test depending on whether - return_loss=True. Note this setting will change the expected inputs. - When `return_loss=True`, img and img_meta are single-nested (i.e. - Tensor and List[dict]), and when `resturn_loss=False`, img and img_meta + def forward(self, img, img_metas, return_loss=True, **kwargs): + """Calls either :func:`forward_train` or :func:`forward_test` depending + on whether ``return_loss`` is ``True``. + + Note this setting will change the expected inputs. When + ``return_loss=True``, img and img_meta are single-nested (i.e. Tensor + and List[dict]), and when ``resturn_loss=False``, img and img_meta should be double nested (i.e. List[Tensor], List[List[dict]]), with the outer list indicating test time augmentations. """ + if torch.onnx.is_in_onnx_export(): + assert len(img_metas) == 1 + return self.onnx_export(img[0], img_metas[0]) + if return_loss: - return self.forward_train(img, img_meta, **kwargs) + return self.forward_train(img, img_metas, **kwargs) else: - return self.forward_test(img, img_meta, **kwargs) + return self.forward_test(img, img_metas, **kwargs) + + def _parse_losses(self, losses): + """Parse the raw outputs (losses) of the network. + + Args: + losses (dict): Raw output of the network, which usually contain + losses and other necessary information. + + Returns: + tuple[Tensor, dict]: (loss, log_vars), loss is the loss tensor \ + which may be a weighted sum of all losses, log_vars contains \ + all the variables to be sent to the logger. + """ + log_vars = OrderedDict() + for loss_name, loss_value in losses.items(): + if isinstance(loss_value, torch.Tensor): + log_vars[loss_name] = loss_value.mean() + elif isinstance(loss_value, list): + log_vars[loss_name] = sum(_loss.mean() for _loss in loss_value) + else: + raise TypeError( + f'{loss_name} is not a tensor or list of tensors') + + loss = sum(_value for _key, _value in log_vars.items() + if 'loss' in _key) - def show_result(self, data, result, dataset=None, score_thr=0.3): + # If the loss_vars has different length, GPUs will wait infinitely + if dist.is_available() and dist.is_initialized(): + log_var_length = torch.tensor(len(log_vars), device=loss.device) + dist.all_reduce(log_var_length) + message = (f'rank {dist.get_rank()}' + + f' len(log_vars): {len(log_vars)}' + ' keys: ' + + ','.join(log_vars.keys())) + assert log_var_length == len(log_vars) * dist.get_world_size(), \ + 'loss log variables are different across GPUs!\n' + message + + log_vars['loss'] = loss + for loss_name, loss_value in log_vars.items(): + # reduce loss when distributed training + if dist.is_available() and dist.is_initialized(): + loss_value = loss_value.data.clone() + dist.all_reduce(loss_value.div_(dist.get_world_size())) + log_vars[loss_name] = loss_value.item() + + return loss, log_vars + + def train_step(self, data, optimizer): + """The iteration step during training. + + This method defines an iteration step during training, except for the + back propagation and optimizer updating, which are done in an optimizer + hook. Note that in some complicated cases or models, the whole process + including back propagation and optimizer updating is also defined in + this method, such as GAN. + + Args: + data (dict): The output of dataloader. + optimizer (:obj:`torch.optim.Optimizer` | dict): The optimizer of + runner is passed to ``train_step()``. This argument is unused + and reserved. + + Returns: + dict: It should contain at least 3 keys: ``loss``, ``log_vars``, \ + ``num_samples``. + + - ``loss`` is a tensor for back propagation, which can be a + weighted sum of multiple losses. + - ``log_vars`` contains all the variables to be sent to the + logger. + - ``num_samples`` indicates the batch size (when the model is + DDP, it means the batch size on each GPU), which is used for + averaging the logs. + """ + losses = self(**data) + loss, log_vars = self._parse_losses(losses) + + outputs = dict( + loss=loss, log_vars=log_vars, num_samples=len(data['img_metas'])) + + return outputs + + def val_step(self, data, optimizer=None): + """The iteration step during validation. + + This method shares the same signature as :func:`train_step`, but used + during val epochs. Note that the evaluation after training epochs is + not implemented with this method, but an evaluation hook. + """ + losses = self(**data) + loss, log_vars = self._parse_losses(losses) + + outputs = dict( + loss=loss, log_vars=log_vars, num_samples=len(data['img_metas'])) + + return outputs + + def show_result(self, + img, + result, + score_thr=0.3, + bbox_color=(72, 101, 241), + text_color=(72, 101, 241), + mask_color=None, + thickness=2, + font_size=13, + win_name='', + show=False, + wait_time=0, + out_file=None): + """Draw `result` over `img`. + + Args: + img (str or Tensor): The image to be displayed. + result (Tensor or tuple): The results to draw over `img` + bbox_result or (bbox_result, segm_result). + score_thr (float, optional): Minimum score of bboxes to be shown. + Default: 0.3. + bbox_color (str or tuple(int) or :obj:`Color`):Color of bbox lines. + The tuple of color should be in BGR order. Default: 'green' + text_color (str or tuple(int) or :obj:`Color`):Color of texts. + The tuple of color should be in BGR order. Default: 'green' + mask_color (None or str or tuple(int) or :obj:`Color`): + Color of masks. The tuple of color should be in BGR order. + Default: None + thickness (int): Thickness of lines. Default: 2 + font_size (int): Font size of texts. Default: 13 + win_name (str): The window name. Default: '' + wait_time (float): Value of waitKey param. + Default: 0. + show (bool): Whether to show the image. + Default: False. + out_file (str or None): The filename to write the image. + Default: None. + + Returns: + img (Tensor): Only if not `show` or `out_file` + """ + img = mmcv.imread(img) + img = img.copy() if isinstance(result, tuple): bbox_result, segm_result = result + if isinstance(segm_result, tuple): + segm_result = segm_result[0] # ms rcnn else: bbox_result, segm_result = result, None + bboxes = np.vstack(bbox_result) + labels = [ + np.full(bbox.shape[0], i, dtype=np.int32) + for i, bbox in enumerate(bbox_result) + ] + labels = np.concatenate(labels) + # draw segmentation masks + segms = None + if segm_result is not None and len(labels) > 0: # non empty + segms = mmcv.concat_list(segm_result) + if isinstance(segms[0], torch.Tensor): + segms = torch.stack(segms, dim=0).detach().cpu().numpy() + else: + segms = np.stack(segms, axis=0) + # if out_file specified, do not show image in window + if out_file is not None: + show = False + # draw bounding boxes + # img = imshow_det_bboxes( + # img, + # bboxes, + # labels, + # segms, + # class_names=self.CLASSES, + # score_thr=score_thr, + # bbox_color=bbox_color, + # text_color=text_color, + # mask_color=mask_color, + # thickness=thickness, + # font_size=font_size, + # win_name=win_name, + # show=show, + # wait_time=wait_time, + # out_file=out_file) - img_tensor = data['img'][0] - img_metas = data['img_meta'][0].data[0] - imgs = tensor2imgs(img_tensor, **img_metas[0]['img_norm_cfg']) - assert len(imgs) == len(img_metas) - - if dataset is None: - class_names = self.CLASSES - elif isinstance(dataset, str): - class_names = get_classes(dataset) - elif isinstance(dataset, (list, tuple)): - class_names = dataset - else: - raise TypeError( - 'dataset must be a valid dataset name or a sequence' - ' of class names, not {}'.format(type(dataset))) + # if not (show or out_file): + # return img - for img, img_meta in zip(imgs, img_metas): - h, w, _ = img_meta['img_shape'] - img_show = img[:h, :w, :] - - bboxes = np.vstack(bbox_result) - # draw segmentation masks - if segm_result is not None: - segms = mmcv.concat_list(segm_result) - inds = np.where(bboxes[:, -1] > score_thr)[0] - for i in inds: - color_mask = np.random.randint( - 0, 256, (1, 3), dtype=np.uint8) - mask = maskUtils.decode(segms[i]).astype(np.bool) - img_show[mask] = img_show[mask] * 0.5 + color_mask * 0.5 - # draw bounding boxes - labels = [ - np.full(bbox.shape[0], i, dtype=np.int32) - for i, bbox in enumerate(bbox_result) - ] - labels = np.concatenate(labels) - mmcv.imshow_det_bboxes( - img_show, - bboxes, - labels, - class_names=class_names, - score_thr=score_thr) + def onnx_export(self, img, img_metas): + raise NotImplementedError(f'{self.__class__.__name__} does ' + f'not support ONNX EXPORT') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/cascade_rcnn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/cascade_rcnn.py deleted file mode 100644 index 4ab1e5789..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/cascade_rcnn.py +++ /dev/null @@ -1,520 +0,0 @@ -from __future__ import division - -import torch -import torch.nn as nn - -from mmdet.core import (bbox2result, bbox2roi, bbox_mapping, build_assigner, - build_sampler, merge_aug_bboxes, merge_aug_masks, - multiclass_nms) -from .. import builder -from ..registry import DETECTORS -from .base import BaseDetector -from .test_mixins import RPNTestMixin - - -@DETECTORS.register_module -class CascadeRCNN(BaseDetector, RPNTestMixin): - - def __init__(self, - num_stages, - backbone, - neck=None, - shared_head=None, - rpn_head=None, - bbox_roi_extractor=None, - bbox_head=None, - mask_roi_extractor=None, - mask_head=None, - train_cfg=None, - test_cfg=None, - pretrained=None): - assert bbox_roi_extractor is not None - assert bbox_head is not None - super(CascadeRCNN, self).__init__() - - self.num_stages = num_stages - self.backbone = builder.build_backbone(backbone) - - if neck is not None: - self.neck = builder.build_neck(neck) - - if rpn_head is not None: - self.rpn_head = builder.build_head(rpn_head) - - if shared_head is not None: - self.shared_head = builder.build_shared_head(shared_head) - - if bbox_head is not None: - self.bbox_roi_extractor = nn.ModuleList() - self.bbox_head = nn.ModuleList() - if not isinstance(bbox_roi_extractor, list): - bbox_roi_extractor = [ - bbox_roi_extractor for _ in range(num_stages) - ] - if not isinstance(bbox_head, list): - bbox_head = [bbox_head for _ in range(num_stages)] - assert len(bbox_roi_extractor) == len(bbox_head) == self.num_stages - for roi_extractor, head in zip(bbox_roi_extractor, bbox_head): - self.bbox_roi_extractor.append( - builder.build_roi_extractor(roi_extractor)) - self.bbox_head.append(builder.build_head(head)) - - if mask_head is not None: - self.mask_head = nn.ModuleList() - if not isinstance(mask_head, list): - mask_head = [mask_head for _ in range(num_stages)] - assert len(mask_head) == self.num_stages - for head in mask_head: - self.mask_head.append(builder.build_head(head)) - if mask_roi_extractor is not None: - self.share_roi_extractor = False - self.mask_roi_extractor = nn.ModuleList() - if not isinstance(mask_roi_extractor, list): - mask_roi_extractor = [ - mask_roi_extractor for _ in range(num_stages) - ] - assert len(mask_roi_extractor) == self.num_stages - for roi_extractor in mask_roi_extractor: - self.mask_roi_extractor.append( - builder.build_roi_extractor(roi_extractor)) - else: - self.share_roi_extractor = True - self.mask_roi_extractor = self.bbox_roi_extractor - - self.train_cfg = train_cfg - self.test_cfg = test_cfg - - self.init_weights(pretrained=pretrained) - - @property - def with_rpn(self): - return hasattr(self, 'rpn_head') and self.rpn_head is not None - - def init_weights(self, pretrained=None): - super(CascadeRCNN, self).init_weights(pretrained) - self.backbone.init_weights(pretrained=pretrained) - if self.with_neck: - if isinstance(self.neck, nn.Sequential): - for m in self.neck: - m.init_weights() - else: - self.neck.init_weights() - if self.with_rpn: - self.rpn_head.init_weights() - if self.with_shared_head: - self.shared_head.init_weights(pretrained=pretrained) - for i in range(self.num_stages): - if self.with_bbox: - self.bbox_roi_extractor[i].init_weights() - self.bbox_head[i].init_weights() - if self.with_mask: - if not self.share_roi_extractor: - self.mask_roi_extractor[i].init_weights() - self.mask_head[i].init_weights() - - def extract_feat(self, img): - x = self.backbone(img) - if self.with_neck: - x = self.neck(x) - return x - - def forward_dummy(self, img): - outs = () - # backbone - x = self.extract_feat(img) - # rpn - if self.with_rpn: - rpn_outs = self.rpn_head(x) - outs = outs + (rpn_outs, ) - proposals = torch.randn(1000, 4).cuda() - # bbox heads - rois = bbox2roi([proposals]) - if self.with_bbox: - for i in range(self.num_stages): - bbox_feats = self.bbox_roi_extractor[i]( - x[:self.bbox_roi_extractor[i].num_inputs], rois) - if self.with_shared_head: - bbox_feats = self.shared_head(bbox_feats) - cls_score, bbox_pred = self.bbox_head[i](bbox_feats) - outs = outs + (cls_score, bbox_pred) - # mask heads - if self.with_mask: - mask_rois = rois[:100] - for i in range(self.num_stages): - mask_feats = self.mask_roi_extractor[i]( - x[:self.mask_roi_extractor[i].num_inputs], mask_rois) - if self.with_shared_head: - mask_feats = self.shared_head(mask_feats) - mask_pred = self.mask_head[i](mask_feats) - outs = outs + (mask_pred, ) - return outs - - def forward_train(self, - img, - img_meta, - gt_bboxes, - gt_labels, - gt_bboxes_ignore=None, - gt_masks=None, - proposals=None): - """ - Args: - img (Tensor): of shape (N, C, H, W) encoding input images. - Typically these should be mean centered and std scaled. - - img_meta (list[dict]): list of image info dict where each dict has: - 'img_shape', 'scale_factor', 'flip', and my also contain - 'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'. - For details on the values of these keys see - `mmdet/datasets/pipelines/formatting.py:Collect`. - - gt_bboxes (list[Tensor]): each item are the truth boxes for each - image in [tl_x, tl_y, br_x, br_y] format. - - gt_labels (list[Tensor]): class indices corresponding to each box - - gt_bboxes_ignore (None | list[Tensor]): specify which bounding - boxes can be ignored when computing the loss. - - gt_masks (None | Tensor) : true segmentation masks for each box - used if the architecture supports a segmentation task. - - proposals : override rpn proposals with custom proposals. Use when - `with_rpn` is False. - - Returns: - dict[str, Tensor]: a dictionary of loss components - """ - x = self.extract_feat(img) - - losses = dict() - - if self.with_rpn: - rpn_outs = self.rpn_head(x) - rpn_loss_inputs = rpn_outs + (gt_bboxes, img_meta, - self.train_cfg.rpn) - rpn_losses = self.rpn_head.loss( - *rpn_loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) - losses.update(rpn_losses) - - proposal_cfg = self.train_cfg.get('rpn_proposal', - self.test_cfg.rpn) - proposal_inputs = rpn_outs + (img_meta, proposal_cfg) - proposal_list = self.rpn_head.get_bboxes(*proposal_inputs) - else: - proposal_list = proposals - - for i in range(self.num_stages): - self.current_stage = i - rcnn_train_cfg = self.train_cfg.rcnn[i] - lw = self.train_cfg.stage_loss_weights[i] - - # assign gts and sample proposals - sampling_results = [] - if self.with_bbox or self.with_mask: - bbox_assigner = build_assigner(rcnn_train_cfg.assigner) - bbox_sampler = build_sampler( - rcnn_train_cfg.sampler, context=self) - num_imgs = img.size(0) - if gt_bboxes_ignore is None: - gt_bboxes_ignore = [None for _ in range(num_imgs)] - - for j in range(num_imgs): - assign_result = bbox_assigner.assign( - proposal_list[j], gt_bboxes[j], gt_bboxes_ignore[j], - gt_labels[j]) - sampling_result = bbox_sampler.sample( - assign_result, - proposal_list[j], - gt_bboxes[j], - gt_labels[j], - feats=[lvl_feat[j][None] for lvl_feat in x]) - sampling_results.append(sampling_result) - - # bbox head forward and loss - bbox_roi_extractor = self.bbox_roi_extractor[i] - bbox_head = self.bbox_head[i] - - rois = bbox2roi([res.bboxes for res in sampling_results]) - - if len(rois) == 0: - # If there are no predicted and/or truth boxes, then we cannot - # compute head / mask losses - continue - - bbox_feats = bbox_roi_extractor(x[:bbox_roi_extractor.num_inputs], - rois) - if self.with_shared_head: - bbox_feats = self.shared_head(bbox_feats) - cls_score, bbox_pred = bbox_head(bbox_feats) - - bbox_targets = bbox_head.get_target(sampling_results, gt_bboxes, - gt_labels, rcnn_train_cfg) - loss_bbox = bbox_head.loss(cls_score, bbox_pred, *bbox_targets) - for name, value in loss_bbox.items(): - losses['s{}.{}'.format(i, name)] = ( - value * lw if 'loss' in name else value) - - # mask head forward and loss - if self.with_mask: - if not self.share_roi_extractor: - mask_roi_extractor = self.mask_roi_extractor[i] - pos_rois = bbox2roi( - [res.pos_bboxes for res in sampling_results]) - mask_feats = mask_roi_extractor( - x[:mask_roi_extractor.num_inputs], pos_rois) - if self.with_shared_head: - mask_feats = self.shared_head(mask_feats) - else: - # reuse positive bbox feats - pos_inds = [] - device = bbox_feats.device - for res in sampling_results: - pos_inds.append( - torch.ones( - res.pos_bboxes.shape[0], - device=device, - dtype=torch.uint8)) - pos_inds.append( - torch.zeros( - res.neg_bboxes.shape[0], - device=device, - dtype=torch.uint8)) - pos_inds = torch.cat(pos_inds) - mask_feats = bbox_feats[pos_inds] - mask_head = self.mask_head[i] - mask_pred = mask_head(mask_feats) - mask_targets = mask_head.get_target(sampling_results, gt_masks, - rcnn_train_cfg) - pos_labels = torch.cat( - [res.pos_gt_labels for res in sampling_results]) - loss_mask = mask_head.loss(mask_pred, mask_targets, pos_labels) - for name, value in loss_mask.items(): - losses['s{}.{}'.format(i, name)] = ( - value * lw if 'loss' in name else value) - - # refine bboxes - if i < self.num_stages - 1: - pos_is_gts = [res.pos_is_gt for res in sampling_results] - roi_labels = bbox_targets[0] # bbox_targets is a tuple - with torch.no_grad(): - proposal_list = bbox_head.refine_bboxes( - rois, roi_labels, bbox_pred, pos_is_gts, img_meta) - - return losses - - def simple_test(self, img, img_meta, proposals=None, rescale=False): - """Run inference on a single image. - - Args: - img (Tensor): must be in shape (N, C, H, W) - img_meta (list[dict]): a list with one dictionary element. - See `mmdet/datasets/pipelines/formatting.py:Collect` for - details of meta dicts. - proposals : if specified overrides rpn proposals - rescale (bool): if True returns boxes in original image space - - Returns: - dict: results - """ - x = self.extract_feat(img) - - proposal_list = self.simple_test_rpn( - x, img_meta, self.test_cfg.rpn) if proposals is None else proposals - - img_shape = img_meta[0]['img_shape'] - ori_shape = img_meta[0]['ori_shape'] - scale_factor = img_meta[0]['scale_factor'] - - # "ms" in variable names means multi-stage - ms_bbox_result = {} - ms_segm_result = {} - ms_scores = [] - rcnn_test_cfg = self.test_cfg.rcnn - - rois = bbox2roi(proposal_list) - for i in range(self.num_stages): - bbox_roi_extractor = self.bbox_roi_extractor[i] - bbox_head = self.bbox_head[i] - - bbox_feats = bbox_roi_extractor( - x[:len(bbox_roi_extractor.featmap_strides)], rois) - if self.with_shared_head: - bbox_feats = self.shared_head(bbox_feats) - - cls_score, bbox_pred = bbox_head(bbox_feats) - ms_scores.append(cls_score) - - if i < self.num_stages - 1: - bbox_label = cls_score.argmax(dim=1) - rois = bbox_head.regress_by_class(rois, bbox_label, bbox_pred, - img_meta[0]) - - cls_score = sum(ms_scores) / self.num_stages - det_bboxes, det_labels = self.bbox_head[-1].get_det_bboxes( - rois, - cls_score, - bbox_pred, - img_shape, - scale_factor, - rescale=rescale, - cfg=rcnn_test_cfg) - bbox_result = bbox2result(det_bboxes, det_labels, - self.bbox_head[-1].num_classes) - ms_bbox_result['ensemble'] = bbox_result - - if self.with_mask: - if det_bboxes.shape[0] == 0: - mask_classes = self.mask_head[-1].num_classes - 1 - segm_result = [[] for _ in range(mask_classes)] - else: - if isinstance(scale_factor, float): # aspect ratio fixed - _bboxes = ( - det_bboxes[:, :4] * - scale_factor if rescale else det_bboxes) - else: - _bboxes = ( - det_bboxes[:, :4] * - torch.from_numpy(scale_factor).to(det_bboxes.device) - if rescale else det_bboxes) - - mask_rois = bbox2roi([_bboxes]) - aug_masks = [] - for i in range(self.num_stages): - mask_roi_extractor = self.mask_roi_extractor[i] - mask_feats = mask_roi_extractor( - x[:len(mask_roi_extractor.featmap_strides)], mask_rois) - if self.with_shared_head: - mask_feats = self.shared_head(mask_feats) - mask_pred = self.mask_head[i](mask_feats) - aug_masks.append(mask_pred.sigmoid().cpu().numpy()) - merged_masks = merge_aug_masks(aug_masks, - [img_meta] * self.num_stages, - self.test_cfg.rcnn) - segm_result = self.mask_head[-1].get_seg_masks( - merged_masks, _bboxes, det_labels, rcnn_test_cfg, - ori_shape, scale_factor, rescale) - ms_segm_result['ensemble'] = segm_result - - if self.with_mask: - results = (ms_bbox_result['ensemble'], ms_segm_result['ensemble']) - else: - results = ms_bbox_result['ensemble'] - - return results - - def aug_test(self, imgs, img_metas, proposals=None, rescale=False): - """Test with augmentations. - - If rescale is False, then returned bboxes and masks will fit the scale - of imgs[0]. - """ - # recompute feats to save memory - proposal_list = self.aug_test_rpn( - self.extract_feats(imgs), img_metas, self.test_cfg.rpn) - - rcnn_test_cfg = self.test_cfg.rcnn - aug_bboxes = [] - aug_scores = [] - for x, img_meta in zip(self.extract_feats(imgs), img_metas): - # only one image in the batch - img_shape = img_meta[0]['img_shape'] - scale_factor = img_meta[0]['scale_factor'] - flip = img_meta[0]['flip'] - - proposals = bbox_mapping(proposal_list[0][:, :4], img_shape, - scale_factor, flip) - # "ms" in variable names means multi-stage - ms_scores = [] - - rois = bbox2roi([proposals]) - for i in range(self.num_stages): - bbox_roi_extractor = self.bbox_roi_extractor[i] - bbox_head = self.bbox_head[i] - - bbox_feats = bbox_roi_extractor( - x[:len(bbox_roi_extractor.featmap_strides)], rois) - if self.with_shared_head: - bbox_feats = self.shared_head(bbox_feats) - - cls_score, bbox_pred = bbox_head(bbox_feats) - ms_scores.append(cls_score) - - if i < self.num_stages - 1: - bbox_label = cls_score.argmax(dim=1) - rois = bbox_head.regress_by_class(rois, bbox_label, - bbox_pred, img_meta[0]) - - cls_score = sum(ms_scores) / float(len(ms_scores)) - bboxes, scores = self.bbox_head[-1].get_det_bboxes( - rois, - cls_score, - bbox_pred, - img_shape, - scale_factor, - rescale=False, - cfg=None) - aug_bboxes.append(bboxes) - aug_scores.append(scores) - - # after merging, bboxes will be rescaled to the original image size - merged_bboxes, merged_scores = merge_aug_bboxes( - aug_bboxes, aug_scores, img_metas, rcnn_test_cfg) - det_bboxes, det_labels = multiclass_nms(merged_bboxes, merged_scores, - rcnn_test_cfg.score_thr, - rcnn_test_cfg.nms, - rcnn_test_cfg.max_per_img) - - bbox_result = bbox2result(det_bboxes, det_labels, - self.bbox_head[-1].num_classes) - - if self.with_mask: - if det_bboxes.shape[0] == 0: - segm_result = [[] - for _ in range(self.mask_head[-1].num_classes - - 1)] - else: - aug_masks = [] - aug_img_metas = [] - for x, img_meta in zip(self.extract_feats(imgs), img_metas): - img_shape = img_meta[0]['img_shape'] - scale_factor = img_meta[0]['scale_factor'] - flip = img_meta[0]['flip'] - _bboxes = bbox_mapping(det_bboxes[:, :4], img_shape, - scale_factor, flip) - mask_rois = bbox2roi([_bboxes]) - for i in range(self.num_stages): - mask_feats = self.mask_roi_extractor[i]( - x[:len(self.mask_roi_extractor[i].featmap_strides - )], mask_rois) - if self.with_shared_head: - mask_feats = self.shared_head(mask_feats) - mask_pred = self.mask_head[i](mask_feats) - aug_masks.append(mask_pred.sigmoid().cpu().numpy()) - aug_img_metas.append(img_meta) - merged_masks = merge_aug_masks(aug_masks, aug_img_metas, - self.test_cfg.rcnn) - - ori_shape = img_metas[0][0]['ori_shape'] - segm_result = self.mask_head[-1].get_seg_masks( - merged_masks, - det_bboxes, - det_labels, - rcnn_test_cfg, - ori_shape, - scale_factor=1.0, - rescale=False) - return bbox_result, segm_result - else: - return bbox_result - - def show_result(self, data, result, **kwargs): - if self.with_mask: - ms_bbox_result, ms_segm_result = result - if isinstance(ms_bbox_result, dict): - result = (ms_bbox_result['ensemble'], - ms_segm_result['ensemble']) - else: - if isinstance(result, dict): - result = result['ensemble'] - super(CascadeRCNN, self).show_result(data, result, **kwargs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/double_head_rcnn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/double_head_rcnn.py deleted file mode 100644 index 7a783353f..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/double_head_rcnn.py +++ /dev/null @@ -1,178 +0,0 @@ -import torch - -from mmdet.core import bbox2roi, build_assigner, build_sampler -from ..registry import DETECTORS -from .two_stage import TwoStageDetector - - -@DETECTORS.register_module -class DoubleHeadRCNN(TwoStageDetector): - - def __init__(self, reg_roi_scale_factor, **kwargs): - super().__init__(**kwargs) - self.reg_roi_scale_factor = reg_roi_scale_factor - - def forward_dummy(self, img): - outs = () - # backbone - x = self.extract_feat(img) - # rpn - if self.with_rpn: - rpn_outs = self.rpn_head(x) - outs = outs + (rpn_outs, ) - proposals = torch.randn(1000, 4).cuda() - # bbox head - rois = bbox2roi([proposals]) - bbox_cls_feats = self.bbox_roi_extractor( - x[:self.bbox_roi_extractor.num_inputs], rois) - bbox_reg_feats = self.bbox_roi_extractor( - x[:self.bbox_roi_extractor.num_inputs], - rois, - roi_scale_factor=self.reg_roi_scale_factor) - if self.with_shared_head: - bbox_cls_feats = self.shared_head(bbox_cls_feats) - bbox_reg_feats = self.shared_head(bbox_reg_feats) - cls_score, bbox_pred = self.bbox_head(bbox_cls_feats, bbox_reg_feats) - outs += (cls_score, bbox_pred) - return outs - - def forward_train(self, - img, - img_meta, - gt_bboxes, - gt_labels, - gt_bboxes_ignore=None, - gt_masks=None, - proposals=None): - x = self.extract_feat(img) - - losses = dict() - - # RPN forward and loss - if self.with_rpn: - rpn_outs = self.rpn_head(x) - rpn_loss_inputs = rpn_outs + (gt_bboxes, img_meta, - self.train_cfg.rpn) - rpn_losses = self.rpn_head.loss( - *rpn_loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) - losses.update(rpn_losses) - - proposal_cfg = self.train_cfg.get('rpn_proposal', - self.test_cfg.rpn) - proposal_inputs = rpn_outs + (img_meta, proposal_cfg) - proposal_list = self.rpn_head.get_bboxes(*proposal_inputs) - else: - proposal_list = proposals - - # assign gts and sample proposals - if self.with_bbox or self.with_mask: - bbox_assigner = build_assigner(self.train_cfg.rcnn.assigner) - bbox_sampler = build_sampler( - self.train_cfg.rcnn.sampler, context=self) - num_imgs = img.size(0) - if gt_bboxes_ignore is None: - gt_bboxes_ignore = [None for _ in range(num_imgs)] - sampling_results = [] - for i in range(num_imgs): - assign_result = bbox_assigner.assign(proposal_list[i], - gt_bboxes[i], - gt_bboxes_ignore[i], - gt_labels[i]) - sampling_result = bbox_sampler.sample( - assign_result, - proposal_list[i], - gt_bboxes[i], - gt_labels[i], - feats=[lvl_feat[i][None] for lvl_feat in x]) - sampling_results.append(sampling_result) - - # bbox head forward and loss - if self.with_bbox: - rois = bbox2roi([res.bboxes for res in sampling_results]) - # TODO: a more flexible way to decide which feature maps to use - bbox_cls_feats = self.bbox_roi_extractor( - x[:self.bbox_roi_extractor.num_inputs], rois) - bbox_reg_feats = self.bbox_roi_extractor( - x[:self.bbox_roi_extractor.num_inputs], - rois, - roi_scale_factor=self.reg_roi_scale_factor) - if self.with_shared_head: - bbox_cls_feats = self.shared_head(bbox_cls_feats) - bbox_reg_feats = self.shared_head(bbox_reg_feats) - cls_score, bbox_pred = self.bbox_head(bbox_cls_feats, - bbox_reg_feats) - - bbox_targets = self.bbox_head.get_target(sampling_results, - gt_bboxes, gt_labels, - self.train_cfg.rcnn) - loss_bbox = self.bbox_head.loss(cls_score, bbox_pred, - *bbox_targets) - losses.update(loss_bbox) - - # mask head forward and loss - if self.with_mask: - if not self.share_roi_extractor: - pos_rois = bbox2roi( - [res.pos_bboxes for res in sampling_results]) - mask_feats = self.mask_roi_extractor( - x[:self.mask_roi_extractor.num_inputs], pos_rois) - if self.with_shared_head: - mask_feats = self.shared_head(mask_feats) - else: - pos_inds = [] - device = bbox_cls_feats.device - for res in sampling_results: - pos_inds.append( - torch.ones( - res.pos_bboxes.shape[0], - device=device, - dtype=torch.uint8)) - pos_inds.append( - torch.zeros( - res.neg_bboxes.shape[0], - device=device, - dtype=torch.uint8)) - pos_inds = torch.cat(pos_inds) - mask_feats = bbox_cls_feats[pos_inds] - mask_pred = self.mask_head(mask_feats) - - mask_targets = self.mask_head.get_target(sampling_results, - gt_masks, - self.train_cfg.rcnn) - pos_labels = torch.cat( - [res.pos_gt_labels for res in sampling_results]) - loss_mask = self.mask_head.loss(mask_pred, mask_targets, - pos_labels) - losses.update(loss_mask) - - return losses - - def simple_test_bboxes(self, - x, - img_meta, - proposals, - rcnn_test_cfg, - rescale=False): - """Test only det bboxes without augmentation.""" - rois = bbox2roi(proposals) - bbox_cls_feats = self.bbox_roi_extractor( - x[:self.bbox_roi_extractor.num_inputs], rois) - bbox_reg_feats = self.bbox_roi_extractor( - x[:self.bbox_roi_extractor.num_inputs], - rois, - roi_scale_factor=self.reg_roi_scale_factor) - if self.with_shared_head: - bbox_cls_feats = self.shared_head(bbox_cls_feats) - bbox_reg_feats = self.shared_head(bbox_reg_feats) - cls_score, bbox_pred = self.bbox_head(bbox_cls_feats, bbox_reg_feats) - img_shape = img_meta[0]['img_shape'] - scale_factor = img_meta[0]['scale_factor'] - det_bboxes, det_labels = self.bbox_head.get_det_bboxes( - rois, - cls_score, - bbox_pred, - img_shape, - scale_factor, - rescale=rescale, - cfg=rcnn_test_cfg) - return det_bboxes, det_labels diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fast_rcnn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fast_rcnn.py deleted file mode 100644 index 8e4231855..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fast_rcnn.py +++ /dev/null @@ -1,61 +0,0 @@ -from ..registry import DETECTORS -from .two_stage import TwoStageDetector - - -@DETECTORS.register_module -class FastRCNN(TwoStageDetector): - - def __init__(self, - backbone, - bbox_roi_extractor, - bbox_head, - train_cfg, - test_cfg, - neck=None, - shared_head=None, - mask_roi_extractor=None, - mask_head=None, - pretrained=None): - super(FastRCNN, self).__init__( - backbone=backbone, - neck=neck, - shared_head=shared_head, - bbox_roi_extractor=bbox_roi_extractor, - bbox_head=bbox_head, - train_cfg=train_cfg, - test_cfg=test_cfg, - mask_roi_extractor=mask_roi_extractor, - mask_head=mask_head, - pretrained=pretrained) - - def forward_test(self, imgs, img_metas, proposals, **kwargs): - """ - Args: - imgs (List[Tensor]): the outer list indicates test-time - augmentations and inner Tensor should have a shape NxCxHxW, - which contains all images in the batch. - img_meta (List[List[dict]]): the outer list indicates test-time - augs (multiscale, flip, etc.) and the inner list indicates - images in a batch - proposals (List[List[Tensor | None]]): predefiend proposals for - each test-time augmentation and each item. - """ - for var, name in [(imgs, 'imgs'), (img_metas, 'img_metas')]: - if not isinstance(var, list): - raise TypeError('{} must be a list, but got {}'.format( - name, type(var))) - - num_augs = len(imgs) - if num_augs != len(img_metas): - raise ValueError( - 'num of augmentations ({}) != num of image meta ({})'.format( - len(imgs), len(img_metas))) - # TODO: remove the restriction of imgs_per_gpu == 1 when prepared - imgs_per_gpu = imgs[0].size(0) - assert imgs_per_gpu == 1 - - if num_augs == 1: - return self.simple_test(imgs[0], img_metas[0], proposals[0], - **kwargs) - else: - return self.aug_test(imgs, img_metas, proposals, **kwargs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/faster_rcnn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/faster_rcnn.py deleted file mode 100644 index 969cd7ccd..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/faster_rcnn.py +++ /dev/null @@ -1,27 +0,0 @@ -from ..registry import DETECTORS -from .two_stage import TwoStageDetector - - -@DETECTORS.register_module -class FasterRCNN(TwoStageDetector): - - def __init__(self, - backbone, - rpn_head, - bbox_roi_extractor, - bbox_head, - train_cfg, - test_cfg, - neck=None, - shared_head=None, - pretrained=None): - super(FasterRCNN, self).__init__( - backbone=backbone, - neck=neck, - shared_head=shared_head, - rpn_head=rpn_head, - bbox_roi_extractor=bbox_roi_extractor, - bbox_head=bbox_head, - train_cfg=train_cfg, - test_cfg=test_cfg, - pretrained=pretrained) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fcos.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fcos.py deleted file mode 100644 index 89cc5929a..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fcos.py +++ /dev/null @@ -1,16 +0,0 @@ -from ..registry import DETECTORS -from .single_stage import SingleStageDetector - - -@DETECTORS.register_module -class FCOS(SingleStageDetector): - - def __init__(self, - backbone, - neck, - bbox_head, - train_cfg=None, - test_cfg=None, - pretrained=None): - super(FCOS, self).__init__(backbone, neck, bbox_head, train_cfg, - test_cfg, pretrained) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fovea.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fovea.py deleted file mode 100644 index 0d264bb24..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/fovea.py +++ /dev/null @@ -1,16 +0,0 @@ -from ..registry import DETECTORS -from .single_stage import SingleStageDetector - - -@DETECTORS.register_module -class FOVEA(SingleStageDetector): - - def __init__(self, - backbone, - neck, - bbox_head, - train_cfg=None, - test_cfg=None, - pretrained=None): - super(FOVEA, self).__init__(backbone, neck, bbox_head, train_cfg, - test_cfg, pretrained) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/grid_rcnn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/grid_rcnn.py deleted file mode 100644 index 853242c16..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/grid_rcnn.py +++ /dev/null @@ -1,229 +0,0 @@ -import torch - -from mmdet.core import bbox2result, bbox2roi, build_assigner, build_sampler -from .. import builder -from ..registry import DETECTORS -from .two_stage import TwoStageDetector - - -@DETECTORS.register_module -class GridRCNN(TwoStageDetector): - """Grid R-CNN. - - This detector is the implementation of: - - Grid R-CNN (https://arxiv.org/abs/1811.12030) - - Grid R-CNN Plus: Faster and Better (https://arxiv.org/abs/1906.05688) - """ - - def __init__(self, - backbone, - rpn_head, - bbox_roi_extractor, - bbox_head, - grid_roi_extractor, - grid_head, - train_cfg, - test_cfg, - neck=None, - shared_head=None, - pretrained=None): - assert grid_head is not None - super(GridRCNN, self).__init__( - backbone=backbone, - neck=neck, - shared_head=shared_head, - rpn_head=rpn_head, - bbox_roi_extractor=bbox_roi_extractor, - bbox_head=bbox_head, - train_cfg=train_cfg, - test_cfg=test_cfg, - pretrained=pretrained) - - if grid_roi_extractor is not None: - self.grid_roi_extractor = builder.build_roi_extractor( - grid_roi_extractor) - self.share_roi_extractor = False - else: - self.share_roi_extractor = True - self.grid_roi_extractor = self.bbox_roi_extractor - self.grid_head = builder.build_head(grid_head) - - self.init_extra_weights() - - def init_extra_weights(self): - self.grid_head.init_weights() - if not self.share_roi_extractor: - self.grid_roi_extractor.init_weights() - - def _random_jitter(self, sampling_results, img_metas, amplitude=0.15): - """Ramdom jitter positive proposals for training.""" - for sampling_result, img_meta in zip(sampling_results, img_metas): - bboxes = sampling_result.pos_bboxes - random_offsets = bboxes.new_empty(bboxes.shape[0], 4).uniform_( - -amplitude, amplitude) - # before jittering - cxcy = (bboxes[:, 2:4] + bboxes[:, :2]) / 2 - wh = (bboxes[:, 2:4] - bboxes[:, :2]).abs() - # after jittering - new_cxcy = cxcy + wh * random_offsets[:, :2] - new_wh = wh * (1 + random_offsets[:, 2:]) - # xywh to xyxy - new_x1y1 = (new_cxcy - new_wh / 2) - new_x2y2 = (new_cxcy + new_wh / 2) - new_bboxes = torch.cat([new_x1y1, new_x2y2], dim=1) - # clip bboxes - max_shape = img_meta['img_shape'] - if max_shape is not None: - new_bboxes[:, 0::2].clamp_(min=0, max=max_shape[1] - 1) - new_bboxes[:, 1::2].clamp_(min=0, max=max_shape[0] - 1) - - sampling_result.pos_bboxes = new_bboxes - return sampling_results - - def forward_dummy(self, img): - outs = () - # backbone - x = self.extract_feat(img) - # rpn - if self.with_rpn: - rpn_outs = self.rpn_head(x) - outs = outs + (rpn_outs, ) - proposals = torch.randn(1000, 4).cuda() - # bbox head - rois = bbox2roi([proposals]) - bbox_feats = self.bbox_roi_extractor( - x[:self.bbox_roi_extractor.num_inputs], rois) - if self.with_shared_head: - bbox_feats = self.shared_head(bbox_feats) - cls_score, bbox_pred = self.bbox_head(bbox_feats) - # grid head - grid_rois = rois[:100] - grid_feats = self.grid_roi_extractor( - x[:self.grid_roi_extractor.num_inputs], grid_rois) - if self.with_shared_head: - grid_feats = self.shared_head(grid_feats) - grid_pred = self.grid_head(grid_feats) - return rpn_outs, cls_score, bbox_pred, grid_pred - - def forward_train(self, - img, - img_meta, - gt_bboxes, - gt_labels, - gt_bboxes_ignore=None, - gt_masks=None, - proposals=None): - x = self.extract_feat(img) - - losses = dict() - - # RPN forward and loss - if self.with_rpn: - rpn_outs = self.rpn_head(x) - rpn_loss_inputs = rpn_outs + (gt_bboxes, img_meta, - self.train_cfg.rpn) - rpn_losses = self.rpn_head.loss( - *rpn_loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) - losses.update(rpn_losses) - - proposal_cfg = self.train_cfg.get('rpn_proposal', - self.test_cfg.rpn) - proposal_inputs = rpn_outs + (img_meta, proposal_cfg) - proposal_list = self.rpn_head.get_bboxes(*proposal_inputs) - else: - proposal_list = proposals - - if self.with_bbox: - # assign gts and sample proposals - bbox_assigner = build_assigner(self.train_cfg.rcnn.assigner) - bbox_sampler = build_sampler( - self.train_cfg.rcnn.sampler, context=self) - num_imgs = img.size(0) - if gt_bboxes_ignore is None: - gt_bboxes_ignore = [None for _ in range(num_imgs)] - sampling_results = [] - for i in range(num_imgs): - assign_result = bbox_assigner.assign(proposal_list[i], - gt_bboxes[i], - gt_bboxes_ignore[i], - gt_labels[i]) - sampling_result = bbox_sampler.sample( - assign_result, - proposal_list[i], - gt_bboxes[i], - gt_labels[i], - feats=[lvl_feat[i][None] for lvl_feat in x]) - sampling_results.append(sampling_result) - - # bbox head forward and loss - rois = bbox2roi([res.bboxes for res in sampling_results]) - # TODO: a more flexible way to decide which feature maps to use - bbox_feats = self.bbox_roi_extractor( - x[:self.bbox_roi_extractor.num_inputs], rois) - if self.with_shared_head: - bbox_feats = self.shared_head(bbox_feats) - cls_score, bbox_pred = self.bbox_head(bbox_feats) - - bbox_targets = self.bbox_head.get_target(sampling_results, - gt_bboxes, gt_labels, - self.train_cfg.rcnn) - loss_bbox = self.bbox_head.loss(cls_score, bbox_pred, - *bbox_targets) - losses.update(loss_bbox) - - # Grid head forward and loss - sampling_results = self._random_jitter(sampling_results, img_meta) - pos_rois = bbox2roi([res.pos_bboxes for res in sampling_results]) - grid_feats = self.grid_roi_extractor( - x[:self.grid_roi_extractor.num_inputs], pos_rois) - if self.with_shared_head: - grid_feats = self.shared_head(grid_feats) - # Accelerate training - max_sample_num_grid = self.train_cfg.rcnn.get('max_num_grid', 192) - sample_idx = torch.randperm( - grid_feats.shape[0])[:min(grid_feats. - shape[0], max_sample_num_grid)] - grid_feats = grid_feats[sample_idx] - - grid_pred = self.grid_head(grid_feats) - - grid_targets = self.grid_head.get_target(sampling_results, - self.train_cfg.rcnn) - grid_targets = grid_targets[sample_idx] - - loss_grid = self.grid_head.loss(grid_pred, grid_targets) - losses.update(loss_grid) - - return losses - - def simple_test(self, img, img_meta, proposals=None, rescale=False): - """Test without augmentation.""" - assert self.with_bbox, "Bbox head must be implemented." - - x = self.extract_feat(img) - - proposal_list = self.simple_test_rpn( - x, img_meta, self.test_cfg.rpn) if proposals is None else proposals - - det_bboxes, det_labels = self.simple_test_bboxes( - x, img_meta, proposal_list, self.test_cfg.rcnn, rescale=False) - - # pack rois into bboxes - grid_rois = bbox2roi([det_bboxes[:, :4]]) - grid_feats = self.grid_roi_extractor( - x[:len(self.grid_roi_extractor.featmap_strides)], grid_rois) - if grid_rois.shape[0] != 0: - self.grid_head.test_mode = True - grid_pred = self.grid_head(grid_feats) - det_bboxes = self.grid_head.get_bboxes(det_bboxes, - grid_pred['fused'], - img_meta) - if rescale: - det_bboxes[:, :4] /= img_meta[0]['scale_factor'] - else: - det_bboxes = torch.Tensor([]) - - bbox_results = bbox2result(det_bboxes, det_labels, - self.bbox_head.num_classes) - - return bbox_results diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/htc.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/htc.py deleted file mode 100644 index a989e17f0..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/htc.py +++ /dev/null @@ -1,516 +0,0 @@ -import torch -import torch.nn.functional as F - -from mmdet.core import (bbox2result, bbox2roi, bbox_mapping, build_assigner, - build_sampler, merge_aug_bboxes, merge_aug_masks, - multiclass_nms) -from .. import builder -from ..registry import DETECTORS -from .cascade_rcnn import CascadeRCNN - - -@DETECTORS.register_module -class HybridTaskCascade(CascadeRCNN): - - def __init__(self, - num_stages, - backbone, - semantic_roi_extractor=None, - semantic_head=None, - semantic_fusion=('bbox', 'mask'), - interleaved=True, - mask_info_flow=True, - **kwargs): - super(HybridTaskCascade, self).__init__(num_stages, backbone, **kwargs) - assert self.with_bbox and self.with_mask - assert not self.with_shared_head # shared head not supported - if semantic_head is not None: - self.semantic_roi_extractor = builder.build_roi_extractor( - semantic_roi_extractor) - self.semantic_head = builder.build_head(semantic_head) - - self.semantic_fusion = semantic_fusion - self.interleaved = interleaved - self.mask_info_flow = mask_info_flow - - @property - def with_semantic(self): - if hasattr(self, 'semantic_head') and self.semantic_head is not None: - return True - else: - return False - - def _bbox_forward_train(self, - stage, - x, - sampling_results, - gt_bboxes, - gt_labels, - rcnn_train_cfg, - semantic_feat=None): - rois = bbox2roi([res.bboxes for res in sampling_results]) - bbox_roi_extractor = self.bbox_roi_extractor[stage] - bbox_head = self.bbox_head[stage] - bbox_feats = bbox_roi_extractor(x[:bbox_roi_extractor.num_inputs], - rois) - # semantic feature fusion - # element-wise sum for original features and pooled semantic features - if self.with_semantic and 'bbox' in self.semantic_fusion: - bbox_semantic_feat = self.semantic_roi_extractor([semantic_feat], - rois) - if bbox_semantic_feat.shape[-2:] != bbox_feats.shape[-2:]: - bbox_semantic_feat = F.adaptive_avg_pool2d( - bbox_semantic_feat, bbox_feats.shape[-2:]) - bbox_feats += bbox_semantic_feat - - cls_score, bbox_pred = bbox_head(bbox_feats) - - bbox_targets = bbox_head.get_target(sampling_results, gt_bboxes, - gt_labels, rcnn_train_cfg) - loss_bbox = bbox_head.loss(cls_score, bbox_pred, *bbox_targets) - return loss_bbox, rois, bbox_targets, bbox_pred - - def _mask_forward_train(self, - stage, - x, - sampling_results, - gt_masks, - rcnn_train_cfg, - semantic_feat=None): - mask_roi_extractor = self.mask_roi_extractor[stage] - mask_head = self.mask_head[stage] - pos_rois = bbox2roi([res.pos_bboxes for res in sampling_results]) - mask_feats = mask_roi_extractor(x[:mask_roi_extractor.num_inputs], - pos_rois) - - # semantic feature fusion - # element-wise sum for original features and pooled semantic features - if self.with_semantic and 'mask' in self.semantic_fusion: - mask_semantic_feat = self.semantic_roi_extractor([semantic_feat], - pos_rois) - if mask_semantic_feat.shape[-2:] != mask_feats.shape[-2:]: - mask_semantic_feat = F.adaptive_avg_pool2d( - mask_semantic_feat, mask_feats.shape[-2:]) - mask_feats += mask_semantic_feat - - # mask information flow - # forward all previous mask heads to obtain last_feat, and fuse it - # with the normal mask feature - if self.mask_info_flow: - last_feat = None - for i in range(stage): - last_feat = self.mask_head[i]( - mask_feats, last_feat, return_logits=False) - mask_pred = mask_head(mask_feats, last_feat, return_feat=False) - else: - mask_pred = mask_head(mask_feats) - - mask_targets = mask_head.get_target(sampling_results, gt_masks, - rcnn_train_cfg) - pos_labels = torch.cat([res.pos_gt_labels for res in sampling_results]) - loss_mask = mask_head.loss(mask_pred, mask_targets, pos_labels) - return loss_mask - - def _bbox_forward_test(self, stage, x, rois, semantic_feat=None): - bbox_roi_extractor = self.bbox_roi_extractor[stage] - bbox_head = self.bbox_head[stage] - bbox_feats = bbox_roi_extractor( - x[:len(bbox_roi_extractor.featmap_strides)], rois) - if self.with_semantic and 'bbox' in self.semantic_fusion: - bbox_semantic_feat = self.semantic_roi_extractor([semantic_feat], - rois) - if bbox_semantic_feat.shape[-2:] != bbox_feats.shape[-2:]: - bbox_semantic_feat = F.adaptive_avg_pool2d( - bbox_semantic_feat, bbox_feats.shape[-2:]) - bbox_feats += bbox_semantic_feat - cls_score, bbox_pred = bbox_head(bbox_feats) - return cls_score, bbox_pred - - def _mask_forward_test(self, stage, x, bboxes, semantic_feat=None): - mask_roi_extractor = self.mask_roi_extractor[stage] - mask_head = self.mask_head[stage] - mask_rois = bbox2roi([bboxes]) - mask_feats = mask_roi_extractor( - x[:len(mask_roi_extractor.featmap_strides)], mask_rois) - if self.with_semantic and 'mask' in self.semantic_fusion: - mask_semantic_feat = self.semantic_roi_extractor([semantic_feat], - mask_rois) - if mask_semantic_feat.shape[-2:] != mask_feats.shape[-2:]: - mask_semantic_feat = F.adaptive_avg_pool2d( - mask_semantic_feat, mask_feats.shape[-2:]) - mask_feats += mask_semantic_feat - if self.mask_info_flow: - last_feat = None - last_pred = None - for i in range(stage): - mask_pred, last_feat = self.mask_head[i](mask_feats, last_feat) - if last_pred is not None: - mask_pred = mask_pred + last_pred - last_pred = mask_pred - mask_pred = mask_head(mask_feats, last_feat, return_feat=False) - if last_pred is not None: - mask_pred = mask_pred + last_pred - else: - mask_pred = mask_head(mask_feats) - return mask_pred - - def forward_dummy(self, img): - outs = () - # backbone - x = self.extract_feat(img) - # rpn - if self.with_rpn: - rpn_outs = self.rpn_head(x) - outs = outs + (rpn_outs, ) - proposals = torch.randn(1000, 4).cuda() - # semantic head - if self.with_semantic: - _, semantic_feat = self.semantic_head(x) - else: - semantic_feat = None - # bbox heads - rois = bbox2roi([proposals]) - for i in range(self.num_stages): - cls_score, bbox_pred = self._bbox_forward_test( - i, x, rois, semantic_feat=semantic_feat) - outs = outs + (cls_score, bbox_pred) - # mask heads - if self.with_mask: - mask_rois = rois[:100] - mask_roi_extractor = self.mask_roi_extractor[-1] - mask_feats = mask_roi_extractor( - x[:len(mask_roi_extractor.featmap_strides)], mask_rois) - if self.with_semantic and 'mask' in self.semantic_fusion: - mask_semantic_feat = self.semantic_roi_extractor( - [semantic_feat], mask_rois) - mask_feats += mask_semantic_feat - last_feat = None - for i in range(self.num_stages): - mask_head = self.mask_head[i] - if self.mask_info_flow: - mask_pred, last_feat = mask_head(mask_feats, last_feat) - else: - mask_pred = mask_head(mask_feats) - outs = outs + (mask_pred, ) - return outs - - def forward_train(self, - img, - img_meta, - gt_bboxes, - gt_labels, - gt_bboxes_ignore=None, - gt_masks=None, - gt_semantic_seg=None, - proposals=None): - x = self.extract_feat(img) - - losses = dict() - - # RPN part, the same as normal two-stage detectors - if self.with_rpn: - rpn_outs = self.rpn_head(x) - rpn_loss_inputs = rpn_outs + (gt_bboxes, img_meta, - self.train_cfg.rpn) - rpn_losses = self.rpn_head.loss( - *rpn_loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) - losses.update(rpn_losses) - - proposal_cfg = self.train_cfg.get('rpn_proposal', - self.test_cfg.rpn) - proposal_inputs = rpn_outs + (img_meta, proposal_cfg) - proposal_list = self.rpn_head.get_bboxes(*proposal_inputs) - else: - proposal_list = proposals - - # semantic segmentation part - # 2 outputs: segmentation prediction and embedded features - if self.with_semantic: - semantic_pred, semantic_feat = self.semantic_head(x) - loss_seg = self.semantic_head.loss(semantic_pred, gt_semantic_seg) - losses['loss_semantic_seg'] = loss_seg - else: - semantic_feat = None - - for i in range(self.num_stages): - self.current_stage = i - rcnn_train_cfg = self.train_cfg.rcnn[i] - lw = self.train_cfg.stage_loss_weights[i] - - # assign gts and sample proposals - sampling_results = [] - bbox_assigner = build_assigner(rcnn_train_cfg.assigner) - bbox_sampler = build_sampler(rcnn_train_cfg.sampler, context=self) - num_imgs = img.size(0) - if gt_bboxes_ignore is None: - gt_bboxes_ignore = [None for _ in range(num_imgs)] - - for j in range(num_imgs): - assign_result = bbox_assigner.assign(proposal_list[j], - gt_bboxes[j], - gt_bboxes_ignore[j], - gt_labels[j]) - sampling_result = bbox_sampler.sample( - assign_result, - proposal_list[j], - gt_bboxes[j], - gt_labels[j], - feats=[lvl_feat[j][None] for lvl_feat in x]) - sampling_results.append(sampling_result) - - # bbox head forward and loss - loss_bbox, rois, bbox_targets, bbox_pred = \ - self._bbox_forward_train( - i, x, sampling_results, gt_bboxes, gt_labels, - rcnn_train_cfg, semantic_feat) - roi_labels = bbox_targets[0] - - for name, value in loss_bbox.items(): - losses['s{}.{}'.format(i, name)] = ( - value * lw if 'loss' in name else value) - - # mask head forward and loss - if self.with_mask: - # interleaved execution: use regressed bboxes by the box branch - # to train the mask branch - if self.interleaved: - pos_is_gts = [res.pos_is_gt for res in sampling_results] - with torch.no_grad(): - proposal_list = self.bbox_head[i].refine_bboxes( - rois, roi_labels, bbox_pred, pos_is_gts, img_meta) - # re-assign and sample 512 RoIs from 512 RoIs - sampling_results = [] - for j in range(num_imgs): - assign_result = bbox_assigner.assign( - proposal_list[j], gt_bboxes[j], - gt_bboxes_ignore[j], gt_labels[j]) - sampling_result = bbox_sampler.sample( - assign_result, - proposal_list[j], - gt_bboxes[j], - gt_labels[j], - feats=[lvl_feat[j][None] for lvl_feat in x]) - sampling_results.append(sampling_result) - loss_mask = self._mask_forward_train(i, x, sampling_results, - gt_masks, rcnn_train_cfg, - semantic_feat) - for name, value in loss_mask.items(): - losses['s{}.{}'.format(i, name)] = ( - value * lw if 'loss' in name else value) - - # refine bboxes (same as Cascade R-CNN) - if i < self.num_stages - 1 and not self.interleaved: - pos_is_gts = [res.pos_is_gt for res in sampling_results] - with torch.no_grad(): - proposal_list = self.bbox_head[i].refine_bboxes( - rois, roi_labels, bbox_pred, pos_is_gts, img_meta) - - return losses - - def simple_test(self, img, img_meta, proposals=None, rescale=False): - x = self.extract_feat(img) - proposal_list = self.simple_test_rpn( - x, img_meta, self.test_cfg.rpn) if proposals is None else proposals - - if self.with_semantic: - _, semantic_feat = self.semantic_head(x) - else: - semantic_feat = None - - img_shape = img_meta[0]['img_shape'] - ori_shape = img_meta[0]['ori_shape'] - scale_factor = img_meta[0]['scale_factor'] - - # "ms" in variable names means multi-stage - ms_bbox_result = {} - ms_segm_result = {} - ms_scores = [] - rcnn_test_cfg = self.test_cfg.rcnn - - rois = bbox2roi(proposal_list) - for i in range(self.num_stages): - bbox_head = self.bbox_head[i] - cls_score, bbox_pred = self._bbox_forward_test( - i, x, rois, semantic_feat=semantic_feat) - ms_scores.append(cls_score) - - if i < self.num_stages - 1: - bbox_label = cls_score.argmax(dim=1) - rois = bbox_head.regress_by_class(rois, bbox_label, bbox_pred, - img_meta[0]) - - cls_score = sum(ms_scores) / float(len(ms_scores)) - det_bboxes, det_labels = self.bbox_head[-1].get_det_bboxes( - rois, - cls_score, - bbox_pred, - img_shape, - scale_factor, - rescale=rescale, - cfg=rcnn_test_cfg) - bbox_result = bbox2result(det_bboxes, det_labels, - self.bbox_head[-1].num_classes) - ms_bbox_result['ensemble'] = bbox_result - - if self.with_mask: - if det_bboxes.shape[0] == 0: - mask_classes = self.mask_head[-1].num_classes - 1 - segm_result = [[] for _ in range(mask_classes)] - else: - _bboxes = ( - det_bboxes[:, :4] * - scale_factor if rescale else det_bboxes) - - mask_rois = bbox2roi([_bboxes]) - aug_masks = [] - mask_roi_extractor = self.mask_roi_extractor[-1] - mask_feats = mask_roi_extractor( - x[:len(mask_roi_extractor.featmap_strides)], mask_rois) - if self.with_semantic and 'mask' in self.semantic_fusion: - mask_semantic_feat = self.semantic_roi_extractor( - [semantic_feat], mask_rois) - mask_feats += mask_semantic_feat - last_feat = None - for i in range(self.num_stages): - mask_head = self.mask_head[i] - if self.mask_info_flow: - mask_pred, last_feat = mask_head(mask_feats, last_feat) - else: - mask_pred = mask_head(mask_feats) - aug_masks.append(mask_pred.sigmoid().cpu().numpy()) - merged_masks = merge_aug_masks(aug_masks, - [img_meta] * self.num_stages, - self.test_cfg.rcnn) - segm_result = self.mask_head[-1].get_seg_masks( - merged_masks, _bboxes, det_labels, rcnn_test_cfg, - ori_shape, scale_factor, rescale) - ms_segm_result['ensemble'] = segm_result - - if self.with_mask: - results = (ms_bbox_result['ensemble'], ms_segm_result['ensemble']) - else: - results = ms_bbox_result['ensemble'] - - return results - - def aug_test(self, imgs, img_metas, proposals=None, rescale=False): - """Test with augmentations. - - If rescale is False, then returned bboxes and masks will fit the scale - of imgs[0]. - """ - if self.with_semantic: - semantic_feats = [ - self.semantic_head(feat)[1] - for feat in self.extract_feats(imgs) - ] - else: - semantic_feats = [None] * len(img_metas) - - # recompute feats to save memory - proposal_list = self.aug_test_rpn( - self.extract_feats(imgs), img_metas, self.test_cfg.rpn) - - rcnn_test_cfg = self.test_cfg.rcnn - aug_bboxes = [] - aug_scores = [] - for x, img_meta, semantic in zip( - self.extract_feats(imgs), img_metas, semantic_feats): - # only one image in the batch - img_shape = img_meta[0]['img_shape'] - scale_factor = img_meta[0]['scale_factor'] - flip = img_meta[0]['flip'] - - proposals = bbox_mapping(proposal_list[0][:, :4], img_shape, - scale_factor, flip) - # "ms" in variable names means multi-stage - ms_scores = [] - - rois = bbox2roi([proposals]) - for i in range(self.num_stages): - bbox_head = self.bbox_head[i] - cls_score, bbox_pred = self._bbox_forward_test( - i, x, rois, semantic_feat=semantic) - ms_scores.append(cls_score) - - if i < self.num_stages - 1: - bbox_label = cls_score.argmax(dim=1) - rois = bbox_head.regress_by_class(rois, bbox_label, - bbox_pred, img_meta[0]) - - cls_score = sum(ms_scores) / float(len(ms_scores)) - bboxes, scores = self.bbox_head[-1].get_det_bboxes( - rois, - cls_score, - bbox_pred, - img_shape, - scale_factor, - rescale=False, - cfg=None) - aug_bboxes.append(bboxes) - aug_scores.append(scores) - - # after merging, bboxes will be rescaled to the original image size - merged_bboxes, merged_scores = merge_aug_bboxes( - aug_bboxes, aug_scores, img_metas, rcnn_test_cfg) - det_bboxes, det_labels = multiclass_nms(merged_bboxes, merged_scores, - rcnn_test_cfg.score_thr, - rcnn_test_cfg.nms, - rcnn_test_cfg.max_per_img) - - bbox_result = bbox2result(det_bboxes, det_labels, - self.bbox_head[-1].num_classes) - - if self.with_mask: - if det_bboxes.shape[0] == 0: - segm_result = [[] - for _ in range(self.mask_head[-1].num_classes - - 1)] - else: - aug_masks = [] - aug_img_metas = [] - for x, img_meta, semantic in zip( - self.extract_feats(imgs), img_metas, semantic_feats): - img_shape = img_meta[0]['img_shape'] - scale_factor = img_meta[0]['scale_factor'] - flip = img_meta[0]['flip'] - _bboxes = bbox_mapping(det_bboxes[:, :4], img_shape, - scale_factor, flip) - mask_rois = bbox2roi([_bboxes]) - mask_feats = self.mask_roi_extractor[-1]( - x[:len(self.mask_roi_extractor[-1].featmap_strides)], - mask_rois) - if self.with_semantic: - semantic_feat = semantic - mask_semantic_feat = self.semantic_roi_extractor( - [semantic_feat], mask_rois) - if mask_semantic_feat.shape[-2:] != mask_feats.shape[ - -2:]: - mask_semantic_feat = F.adaptive_avg_pool2d( - mask_semantic_feat, mask_feats.shape[-2:]) - mask_feats += mask_semantic_feat - last_feat = None - for i in range(self.num_stages): - mask_head = self.mask_head[i] - if self.mask_info_flow: - mask_pred, last_feat = mask_head( - mask_feats, last_feat) - else: - mask_pred = mask_head(mask_feats) - aug_masks.append(mask_pred.sigmoid().cpu().numpy()) - aug_img_metas.append(img_meta) - merged_masks = merge_aug_masks(aug_masks, aug_img_metas, - self.test_cfg.rcnn) - - ori_shape = img_metas[0][0]['ori_shape'] - segm_result = self.mask_head[-1].get_seg_masks( - merged_masks, - det_bboxes, - det_labels, - rcnn_test_cfg, - ori_shape, - scale_factor=1.0, - rescale=False) - return bbox_result, segm_result - else: - return bbox_result diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/mask_rcnn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/mask_rcnn.py deleted file mode 100644 index becfdad53..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/mask_rcnn.py +++ /dev/null @@ -1,31 +0,0 @@ -from ..registry import DETECTORS -from .two_stage import TwoStageDetector - - -@DETECTORS.register_module -class MaskRCNN(TwoStageDetector): - - def __init__(self, - backbone, - rpn_head, - bbox_roi_extractor, - bbox_head, - mask_roi_extractor, - mask_head, - train_cfg, - test_cfg, - neck=None, - shared_head=None, - pretrained=None): - super(MaskRCNN, self).__init__( - backbone=backbone, - neck=neck, - shared_head=shared_head, - rpn_head=rpn_head, - bbox_roi_extractor=bbox_roi_extractor, - bbox_head=bbox_head, - mask_roi_extractor=mask_roi_extractor, - mask_head=mask_head, - train_cfg=train_cfg, - test_cfg=test_cfg, - pretrained=pretrained) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/mask_scoring_rcnn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/mask_scoring_rcnn.py deleted file mode 100644 index f184c453b..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/mask_scoring_rcnn.py +++ /dev/null @@ -1,200 +0,0 @@ -import torch - -from mmdet.core import bbox2roi, build_assigner, build_sampler -from .. import builder -from ..registry import DETECTORS -from .two_stage import TwoStageDetector - - -@DETECTORS.register_module -class MaskScoringRCNN(TwoStageDetector): - """Mask Scoring RCNN. - - https://arxiv.org/abs/1903.00241 - """ - - def __init__(self, - backbone, - rpn_head, - bbox_roi_extractor, - bbox_head, - mask_roi_extractor, - mask_head, - train_cfg, - test_cfg, - neck=None, - shared_head=None, - mask_iou_head=None, - pretrained=None): - super(MaskScoringRCNN, self).__init__( - backbone=backbone, - neck=neck, - shared_head=shared_head, - rpn_head=rpn_head, - bbox_roi_extractor=bbox_roi_extractor, - bbox_head=bbox_head, - mask_roi_extractor=mask_roi_extractor, - mask_head=mask_head, - train_cfg=train_cfg, - test_cfg=test_cfg, - pretrained=pretrained) - - self.mask_iou_head = builder.build_head(mask_iou_head) - self.mask_iou_head.init_weights() - - def forward_dummy(self, img): - raise NotImplementedError - - # TODO: refactor forward_train in two stage to reduce code redundancy - def forward_train(self, - img, - img_meta, - gt_bboxes, - gt_labels, - gt_bboxes_ignore=None, - gt_masks=None, - proposals=None): - x = self.extract_feat(img) - - losses = dict() - - # RPN forward and loss - if self.with_rpn: - rpn_outs = self.rpn_head(x) - rpn_loss_inputs = rpn_outs + (gt_bboxes, img_meta, - self.train_cfg.rpn) - rpn_losses = self.rpn_head.loss( - *rpn_loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) - losses.update(rpn_losses) - - proposal_cfg = self.train_cfg.get('rpn_proposal', - self.test_cfg.rpn) - proposal_inputs = rpn_outs + (img_meta, proposal_cfg) - proposal_list = self.rpn_head.get_bboxes(*proposal_inputs) - else: - proposal_list = proposals - - # assign gts and sample proposals - if self.with_bbox or self.with_mask: - bbox_assigner = build_assigner(self.train_cfg.rcnn.assigner) - bbox_sampler = build_sampler( - self.train_cfg.rcnn.sampler, context=self) - num_imgs = img.size(0) - if gt_bboxes_ignore is None: - gt_bboxes_ignore = [None for _ in range(num_imgs)] - sampling_results = [] - for i in range(num_imgs): - assign_result = bbox_assigner.assign(proposal_list[i], - gt_bboxes[i], - gt_bboxes_ignore[i], - gt_labels[i]) - sampling_result = bbox_sampler.sample( - assign_result, - proposal_list[i], - gt_bboxes[i], - gt_labels[i], - feats=[lvl_feat[i][None] for lvl_feat in x]) - sampling_results.append(sampling_result) - - # bbox head forward and loss - if self.with_bbox: - rois = bbox2roi([res.bboxes for res in sampling_results]) - # TODO: a more flexible way to decide which feature maps to use - bbox_feats = self.bbox_roi_extractor( - x[:self.bbox_roi_extractor.num_inputs], rois) - if self.with_shared_head: - bbox_feats = self.shared_head(bbox_feats) - cls_score, bbox_pred = self.bbox_head(bbox_feats) - - bbox_targets = self.bbox_head.get_target(sampling_results, - gt_bboxes, gt_labels, - self.train_cfg.rcnn) - loss_bbox = self.bbox_head.loss(cls_score, bbox_pred, - *bbox_targets) - losses.update(loss_bbox) - - # mask head forward and loss - if self.with_mask: - if not self.share_roi_extractor: - pos_rois = bbox2roi( - [res.pos_bboxes for res in sampling_results]) - mask_feats = self.mask_roi_extractor( - x[:self.mask_roi_extractor.num_inputs], pos_rois) - if self.with_shared_head: - mask_feats = self.shared_head(mask_feats) - else: - pos_inds = [] - device = bbox_feats.device - for res in sampling_results: - pos_inds.append( - torch.ones( - res.pos_bboxes.shape[0], - device=device, - dtype=torch.uint8)) - pos_inds.append( - torch.zeros( - res.neg_bboxes.shape[0], - device=device, - dtype=torch.uint8)) - pos_inds = torch.cat(pos_inds) - mask_feats = bbox_feats[pos_inds] - mask_pred = self.mask_head(mask_feats) - - mask_targets = self.mask_head.get_target(sampling_results, - gt_masks, - self.train_cfg.rcnn) - pos_labels = torch.cat( - [res.pos_gt_labels for res in sampling_results]) - loss_mask = self.mask_head.loss(mask_pred, mask_targets, - pos_labels) - losses.update(loss_mask) - - # mask iou head forward and loss - pos_mask_pred = mask_pred[range(mask_pred.size(0)), pos_labels] - mask_iou_pred = self.mask_iou_head(mask_feats, pos_mask_pred) - pos_mask_iou_pred = mask_iou_pred[range(mask_iou_pred.size(0)), - pos_labels] - mask_iou_targets = self.mask_iou_head.get_target( - sampling_results, gt_masks, pos_mask_pred, mask_targets, - self.train_cfg.rcnn) - loss_mask_iou = self.mask_iou_head.loss(pos_mask_iou_pred, - mask_iou_targets) - losses.update(loss_mask_iou) - return losses - - def simple_test_mask(self, - x, - img_meta, - det_bboxes, - det_labels, - rescale=False): - # image shape of the first image in the batch (only one) - ori_shape = img_meta[0]['ori_shape'] - scale_factor = img_meta[0]['scale_factor'] - - if det_bboxes.shape[0] == 0: - segm_result = [[] for _ in range(self.mask_head.num_classes - 1)] - mask_scores = [[] for _ in range(self.mask_head.num_classes - 1)] - else: - # if det_bboxes is rescaled to the original image size, we need to - # rescale it back to the testing scale to obtain RoIs. - _bboxes = ( - det_bboxes[:, :4] * scale_factor if rescale else det_bboxes) - mask_rois = bbox2roi([_bboxes]) - mask_feats = self.mask_roi_extractor( - x[:len(self.mask_roi_extractor.featmap_strides)], mask_rois) - if self.with_shared_head: - mask_feats = self.shared_head(mask_feats) - mask_pred = self.mask_head(mask_feats) - segm_result = self.mask_head.get_seg_masks(mask_pred, _bboxes, - det_labels, - self.test_cfg.rcnn, - ori_shape, scale_factor, - rescale) - # get mask scores with mask iou head - mask_iou_pred = self.mask_iou_head( - mask_feats, mask_pred[range(det_labels.size(0)), - det_labels + 1]) - mask_scores = self.mask_iou_head.get_mask_scores( - mask_iou_pred, det_bboxes, det_labels) - return segm_result, mask_scores diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/reppoints_detector.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/reppoints_detector.py deleted file mode 100644 index 53d698f1f..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/reppoints_detector.py +++ /dev/null @@ -1,81 +0,0 @@ -import torch - -from mmdet.core import bbox2result, bbox_mapping_back, multiclass_nms -from ..registry import DETECTORS -from .single_stage import SingleStageDetector - - -@DETECTORS.register_module -class RepPointsDetector(SingleStageDetector): - """RepPoints: Point Set Representation for Object Detection. - - This detector is the implementation of: - - RepPoints detector (https://arxiv.org/pdf/1904.11490) - """ - - def __init__(self, - backbone, - neck, - bbox_head, - train_cfg=None, - test_cfg=None, - pretrained=None): - super(RepPointsDetector, - self).__init__(backbone, neck, bbox_head, train_cfg, test_cfg, - pretrained) - - def merge_aug_results(self, aug_bboxes, aug_scores, img_metas): - """Merge augmented detection bboxes and scores. - - Args: - aug_bboxes (list[Tensor]): shape (n, 4*#class) - aug_scores (list[Tensor] or None): shape (n, #class) - img_shapes (list[Tensor]): shape (3, ). - - Returns: - tuple: (bboxes, scores) - """ - recovered_bboxes = [] - for bboxes, img_info in zip(aug_bboxes, img_metas): - img_shape = img_info[0]['img_shape'] - scale_factor = img_info[0]['scale_factor'] - flip = img_info[0]['flip'] - bboxes = bbox_mapping_back(bboxes, img_shape, scale_factor, flip) - recovered_bboxes.append(bboxes) - bboxes = torch.cat(recovered_bboxes, dim=0) - if aug_scores is None: - return bboxes - else: - scores = torch.cat(aug_scores, dim=0) - return bboxes, scores - - def aug_test(self, imgs, img_metas, rescale=False): - # recompute feats to save memory - feats = self.extract_feats(imgs) - - aug_bboxes = [] - aug_scores = [] - for x, img_meta in zip(feats, img_metas): - # only one image in the batch - outs = self.bbox_head(x) - bbox_inputs = outs + (img_meta, self.test_cfg, False, False) - det_bboxes, det_scores = self.bbox_head.get_bboxes(*bbox_inputs)[0] - aug_bboxes.append(det_bboxes) - aug_scores.append(det_scores) - - # after merging, bboxes will be rescaled to the original image size - merged_bboxes, merged_scores = self.merge_aug_results( - aug_bboxes, aug_scores, img_metas) - det_bboxes, det_labels = multiclass_nms(merged_bboxes, merged_scores, - self.test_cfg.score_thr, - self.test_cfg.nms, - self.test_cfg.max_per_img) - - if rescale: - _det_bboxes = det_bboxes - else: - _det_bboxes = det_bboxes.clone() - _det_bboxes[:, :4] *= img_metas[0][0]['scale_factor'] - bbox_results = bbox2result(_det_bboxes, det_labels, - self.bbox_head.num_classes) - return bbox_results diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/retinanet.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/retinanet.py deleted file mode 100644 index 7c93d7419..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/retinanet.py +++ /dev/null @@ -1,16 +0,0 @@ -from ..registry import DETECTORS -from .single_stage import SingleStageDetector - - -@DETECTORS.register_module -class RetinaNet(SingleStageDetector): - - def __init__(self, - backbone, - neck, - bbox_head, - train_cfg=None, - test_cfg=None, - pretrained=None): - super(RetinaNet, self).__init__(backbone, neck, bbox_head, train_cfg, - test_cfg, pretrained) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/rpn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/rpn.py deleted file mode 100644 index fafee4fc2..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/rpn.py +++ /dev/null @@ -1,97 +0,0 @@ -import mmcv - -from mmdet.core import bbox_mapping, tensor2imgs -from .. import builder -from ..registry import DETECTORS -from .base import BaseDetector -from .test_mixins import RPNTestMixin - - -@DETECTORS.register_module -class RPN(BaseDetector, RPNTestMixin): - - def __init__(self, - backbone, - neck, - rpn_head, - train_cfg, - test_cfg, - pretrained=None): - super(RPN, self).__init__() - self.backbone = builder.build_backbone(backbone) - self.neck = builder.build_neck(neck) if neck is not None else None - self.rpn_head = builder.build_head(rpn_head) - self.train_cfg = train_cfg - self.test_cfg = test_cfg - self.init_weights(pretrained=pretrained) - - def init_weights(self, pretrained=None): - super(RPN, self).init_weights(pretrained) - self.backbone.init_weights(pretrained=pretrained) - if self.with_neck: - self.neck.init_weights() - self.rpn_head.init_weights() - - def extract_feat(self, img): - x = self.backbone(img) - if self.with_neck: - x = self.neck(x) - return x - - def forward_dummy(self, img): - x = self.extract_feat(img) - rpn_outs = self.rpn_head(x) - return rpn_outs - - def forward_train(self, - img, - img_meta, - gt_bboxes=None, - gt_bboxes_ignore=None): - if self.train_cfg.rpn.get('debug', False): - self.rpn_head.debug_imgs = tensor2imgs(img) - - x = self.extract_feat(img) - rpn_outs = self.rpn_head(x) - - rpn_loss_inputs = rpn_outs + (gt_bboxes, img_meta, self.train_cfg.rpn) - losses = self.rpn_head.loss( - *rpn_loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) - return losses - - def simple_test(self, img, img_meta, rescale=False): - x = self.extract_feat(img) - proposal_list = self.simple_test_rpn(x, img_meta, self.test_cfg.rpn) - if rescale: - for proposals, meta in zip(proposal_list, img_meta): - proposals[:, :4] /= meta['scale_factor'] - # TODO: remove this restriction - return proposal_list[0].cpu().numpy() - - def aug_test(self, imgs, img_metas, rescale=False): - proposal_list = self.aug_test_rpn( - self.extract_feats(imgs), img_metas, self.test_cfg.rpn) - if not rescale: - for proposals, img_meta in zip(proposal_list, img_metas[0]): - img_shape = img_meta['img_shape'] - scale_factor = img_meta['scale_factor'] - flip = img_meta['flip'] - proposals[:, :4] = bbox_mapping(proposals[:, :4], img_shape, - scale_factor, flip) - # TODO: remove this restriction - return proposal_list[0].cpu().numpy() - - def show_result(self, data, result, dataset=None, top_k=20): - """Show RPN proposals on the image. - - Although we assume batch size is 1, this method supports arbitrary - batch size. - """ - img_tensor = data['img'][0] - img_metas = data['img_meta'][0].data[0] - imgs = tensor2imgs(img_tensor, **img_metas[0]['img_norm_cfg']) - assert len(imgs) == len(img_metas) - for img, img_meta in zip(imgs, img_metas): - h, w, _ = img_meta['img_shape'] - img_show = img[:h, :w, :] - mmcv.imshow_bboxes(img_show, result, top_k=top_k) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage.py deleted file mode 100644 index b25af7b82..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage.py +++ /dev/null @@ -1,86 +0,0 @@ -import torch.nn as nn - -from mmdet.core import bbox2result -from .. import builder -from ..registry import DETECTORS -from .base import BaseDetector - - -@DETECTORS.register_module -class SingleStageDetector(BaseDetector): - """Base class for single-stage detectors. - - Single-stage detectors directly and densely predict bounding boxes on the - output features of the backbone+neck. - """ - - def __init__(self, - backbone, - neck=None, - bbox_head=None, - train_cfg=None, - test_cfg=None, - pretrained=None): - super(SingleStageDetector, self).__init__() - self.backbone = builder.build_backbone(backbone) - if neck is not None: - self.neck = builder.build_neck(neck) - self.bbox_head = builder.build_head(bbox_head) - self.train_cfg = train_cfg - self.test_cfg = test_cfg - self.init_weights(pretrained=pretrained) - - def init_weights(self, pretrained=None): - super(SingleStageDetector, self).init_weights(pretrained) - self.backbone.init_weights(pretrained=pretrained) - if self.with_neck: - if isinstance(self.neck, nn.Sequential): - for m in self.neck: - m.init_weights() - else: - self.neck.init_weights() - self.bbox_head.init_weights() - - def extract_feat(self, img): - """Directly extract features from the backbone+neck - """ - x = self.backbone(img) - if self.with_neck: - x = self.neck(x) - return x - - def forward_dummy(self, img): - """Used for computing network flops. - - See `mmedetection/tools/get_flops.py` - """ - x = self.extract_feat(img) - outs = self.bbox_head(x) - return outs - - def forward_train(self, - img, - img_metas, - gt_bboxes, - gt_labels, - gt_bboxes_ignore=None): - x = self.extract_feat(img) - outs = self.bbox_head(x) - loss_inputs = outs + (gt_bboxes, gt_labels, img_metas, self.train_cfg) - losses = self.bbox_head.loss( - *loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) - return losses - - def simple_test(self, img, img_meta, rescale=False): - x = self.extract_feat(img) - outs = self.bbox_head(x) - bbox_inputs = outs + (img_meta, self.test_cfg, rescale) - bbox_list = self.bbox_head.get_bboxes(*bbox_inputs) - bbox_results = [ - bbox2result(det_bboxes, det_labels, self.bbox_head.num_classes) - for det_bboxes, det_labels in bbox_list - ] - return bbox_results[0] - - def aug_test(self, imgs, img_metas, rescale=False): - raise NotImplementedError diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage_ins.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage_ins.py deleted file mode 100644 index 773d5d22e..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage_ins.py +++ /dev/null @@ -1,96 +0,0 @@ -import torch.nn as nn - -from mmdet.core import bbox2result -from .. import builder -from ..registry import DETECTORS -from .base import BaseDetector - - -@DETECTORS.register_module -class SingleStageInsDetector(BaseDetector): - - def __init__(self, - backbone, - neck=None, - bbox_head=None, - mask_feat_head=None, - train_cfg=None, - test_cfg=None, - pretrained=None): - super(SingleStageInsDetector, self).__init__() - self.backbone = builder.build_backbone(backbone) - if neck is not None: - self.neck = builder.build_neck(neck) - if mask_feat_head is not None: - self.mask_feat_head = builder.build_head(mask_feat_head) - - self.bbox_head = builder.build_head(bbox_head) - self.train_cfg = train_cfg - self.test_cfg = test_cfg - self.init_weights(pretrained=pretrained) - - def init_weights(self, pretrained=None): - super(SingleStageInsDetector, self).init_weights(pretrained) - self.backbone.init_weights(pretrained=pretrained) - if self.with_neck: - if isinstance(self.neck, nn.Sequential): - for m in self.neck: - m.init_weights() - else: - self.neck.init_weights() - if self.with_mask_feat_head: - if isinstance(self.mask_feat_head, nn.Sequential): - for m in self.mask_feat_head: - m.init_weights() - else: - self.mask_feat_head.init_weights() - self.bbox_head.init_weights() - - def extract_feat(self, img): - x = self.backbone(img) - if self.with_neck: - x = self.neck(x) - return x - - def forward_dummy(self, img): - x = self.extract_feat(img) - outs = self.bbox_head(x) - return outs - - def forward_train(self, - img, - img_metas, - gt_bboxes, - gt_labels, - gt_bboxes_ignore=None, - gt_masks=None): - x = self.extract_feat(img) - outs = self.bbox_head(x) - - if self.with_mask_feat_head: - mask_feat_pred = self.mask_feat_head( - x[self.mask_feat_head. - start_level:self.mask_feat_head.end_level + 1]) - loss_inputs = outs + (mask_feat_pred, gt_bboxes, gt_labels, gt_masks, img_metas, self.train_cfg) - else: - loss_inputs = outs + (gt_bboxes, gt_labels, gt_masks, img_metas, self.train_cfg) - losses = self.bbox_head.loss( - *loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) - return losses - - def simple_test(self, img, img_meta, rescale=False): - x = self.extract_feat(img) - outs = self.bbox_head(x, eval=True) - - if self.with_mask_feat_head: - mask_feat_pred = self.mask_feat_head( - x[self.mask_feat_head. - start_level:self.mask_feat_head.end_level + 1]) - seg_inputs = outs + (mask_feat_pred, img_meta, self.test_cfg, rescale) - else: - seg_inputs = outs + (img_meta, self.test_cfg, rescale) - seg_result = self.bbox_head.get_seg(*seg_inputs) - return seg_result - - def aug_test(self, imgs, img_metas, rescale=False): - raise NotImplementedError diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage_instance_seg.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage_instance_seg.py new file mode 100644 index 000000000..98d5328b0 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/single_stage_instance_seg.py @@ -0,0 +1,343 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import copy +import warnings + +import mmcv +import numpy as np +import torch + +from ..builder import DETECTORS, build_backbone, build_head, build_neck +from .base import BaseDetector + +INF = 1e8 + + +@DETECTORS.register_module() +class SingleStageInstanceSegmentor(BaseDetector): + """Base class for single-stage instance segmentors.""" + + def __init__(self, + backbone, + neck=None, + bbox_head=None, + mask_head=None, + train_cfg=None, + test_cfg=None, + pretrained=None, + init_cfg=None): + + if pretrained: + warnings.warn('DeprecationWarning: pretrained is deprecated, ' + 'please use "init_cfg" instead') + backbone.pretrained = pretrained + super(SingleStageInstanceSegmentor, self).__init__(init_cfg=init_cfg) + self.backbone = build_backbone(backbone) + if neck is not None: + self.neck = build_neck(neck) + else: + self.neck = None + if bbox_head is not None: + bbox_head.update(train_cfg=copy.deepcopy(train_cfg)) + bbox_head.update(test_cfg=copy.deepcopy(test_cfg)) + self.bbox_head = build_head(bbox_head) + else: + self.bbox_head = None + + assert mask_head, f'`mask_head` must ' \ + f'be implemented in {self.__class__.__name__}' + mask_head.update(train_cfg=copy.deepcopy(train_cfg)) + mask_head.update(test_cfg=copy.deepcopy(test_cfg)) + self.mask_head = build_head(mask_head) + + self.train_cfg = train_cfg + self.test_cfg = test_cfg + + def extract_feat(self, img): + """Directly extract features from the backbone and neck.""" + x = self.backbone(img) + if self.with_neck: + x = self.neck(x) + return x + + def forward_dummy(self, img): + """Used for computing network flops. + + See `mmdetection/tools/analysis_tools/get_flops.py` + """ + raise NotImplementedError( + f'`forward_dummy` is not implemented in {self.__class__.__name__}') + + def forward_train(self, + img, + img_metas, + gt_masks, + gt_labels, + gt_bboxes=None, + gt_bboxes_ignore=None, + **kwargs): + """ + Args: + img (Tensor): Input images of shape (B, C, H, W). + Typically these should be mean centered and std scaled. + img_metas (list[dict]): A List of image info dict where each dict + has: 'img_shape', 'scale_factor', 'flip', and may also contain + 'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'. + For details on the values of these keys see + :class:`mmdet.datasets.pipelines.Collect`. + gt_masks (list[:obj:`BitmapMasks`] | None) : The segmentation + masks for each box. + gt_labels (list[Tensor]): Class indices corresponding to each box + gt_bboxes (list[Tensor]): Each item is the truth boxes + of each image in [tl_x, tl_y, br_x, br_y] format. + Default: None. + gt_bboxes_ignore (list[Tensor] | None): Specify which bounding + boxes can be ignored when computing the loss. + + Returns: + dict[str, Tensor]: A dictionary of loss components. + """ + + gt_masks = [ + gt_mask.to_tensor(dtype=torch.bool, device=img.device) + for gt_mask in gt_masks + ] + x = self.extract_feat(img) + losses = dict() + + # CondInst and YOLACT have bbox_head + if self.bbox_head: + # bbox_head_preds is a tuple + bbox_head_preds = self.bbox_head(x) + # positive_infos is a list of obj:`InstanceData` + # It contains the information about the positive samples + # CondInst, YOLACT + det_losses, positive_infos = self.bbox_head.loss( + *bbox_head_preds, + gt_bboxes=gt_bboxes, + gt_labels=gt_labels, + gt_masks=gt_masks, + img_metas=img_metas, + gt_bboxes_ignore=gt_bboxes_ignore, + **kwargs) + losses.update(det_losses) + else: + positive_infos = None + + mask_loss = self.mask_head.forward_train( + x, + gt_labels, + gt_masks, + img_metas, + positive_infos=positive_infos, + gt_bboxes=gt_bboxes, + gt_bboxes_ignore=gt_bboxes_ignore, + **kwargs) + # avoid loss override + assert not set(mask_loss.keys()) & set(losses.keys()) + + losses.update(mask_loss) + return losses + + def simple_test(self, img, img_metas, rescale=False): + """Test function without test-time augmentation. + + Args: + img (torch.Tensor): Images with shape (B, C, H, W). + img_metas (list[dict]): List of image information. + rescale (bool, optional): Whether to rescale the results. + Defaults to False. + + Returns: + list(tuple): Formatted bbox and mask results of multiple \ + images. The outer list corresponds to each image. \ + Each tuple contains two type of results of single image: + + - bbox_results (list[np.ndarray]): BBox results of + single image. The list corresponds to each class. + each ndarray has a shape (N, 5), N is the number of + bboxes with this category, and last dimension + 5 arrange as (x1, y1, x2, y2, scores). + - mask_results (list[np.ndarray]): Mask results of + single image. The list corresponds to each class. + each ndarray has a shape (N, img_h, img_w), N + is the number of masks with this category. + """ + feat = self.extract_feat(img) + if self.bbox_head: + outs = self.bbox_head(feat) + # results_list is list[obj:`InstanceData`] + results_list = self.bbox_head.get_results( + *outs, img_metas=img_metas, cfg=self.test_cfg, rescale=rescale) + else: + results_list = None + + results_list = self.mask_head.simple_test( + feat, img_metas, rescale=rescale, instances_list=results_list) + + format_results_list = [] + for results in results_list: + format_results_list.append(self.format_results(results)) + + return format_results_list + + def format_results(self, results): + """Format the model predictions according to the interface with + dataset. + + Args: + results (:obj:`InstanceData`): Processed + results of single images. Usually contains + following keys. + + - scores (Tensor): Classification scores, has shape + (num_instance,) + - labels (Tensor): Has shape (num_instances,). + - masks (Tensor): Processed mask results, has + shape (num_instances, h, w). + + Returns: + tuple: Formatted bbox and mask results.. It contains two items: + + - bbox_results (list[np.ndarray]): BBox results of + single image. The list corresponds to each class. + each ndarray has a shape (N, 5), N is the number of + bboxes with this category, and last dimension + 5 arrange as (x1, y1, x2, y2, scores). + - mask_results (list[np.ndarray]): Mask results of + single image. The list corresponds to each class. + each ndarray has shape (N, img_h, img_w), N + is the number of masks with this category. + """ + data_keys = results.keys() + assert 'scores' in data_keys + assert 'labels' in data_keys + + assert 'masks' in data_keys, \ + 'results should contain ' \ + 'masks when format the results ' + mask_results = [[] for _ in range(self.mask_head.num_classes)] + + num_masks = len(results) + + if num_masks == 0: + bbox_results = [ + np.zeros((0, 5), dtype=np.float32) + for _ in range(self.mask_head.num_classes) + ] + return bbox_results, mask_results + + labels = results.labels.detach().cpu().numpy() + + if 'bboxes' not in results: + # create dummy bbox results to store the scores + results.bboxes = results.scores.new_zeros(len(results), 4) + + det_bboxes = torch.cat([results.bboxes, results.scores[:, None]], + dim=-1) + det_bboxes = det_bboxes.detach().cpu().numpy() + bbox_results = [ + det_bboxes[labels == i, :] + for i in range(self.mask_head.num_classes) + ] + + masks = results.masks.detach().cpu().numpy() + + for idx in range(num_masks): + mask = masks[idx] + mask_results[labels[idx]].append(mask) + + return bbox_results, mask_results + + def aug_test(self, imgs, img_metas, rescale=False): + raise NotImplementedError + + def show_result(self, + img, + result, + score_thr=0.3, + bbox_color=(72, 101, 241), + text_color=(72, 101, 241), + mask_color=None, + thickness=2, + font_size=13, + win_name='', + show=False, + wait_time=0, + out_file=None): + """Draw `result` over `img`. + + Args: + img (str or Tensor): The image to be displayed. + result (tuple): Format bbox and mask results. + It contains two items: + + - bbox_results (list[np.ndarray]): BBox results of + single image. The list corresponds to each class. + each ndarray has a shape (N, 5), N is the number of + bboxes with this category, and last dimension + 5 arrange as (x1, y1, x2, y2, scores). + - mask_results (list[np.ndarray]): Mask results of + single image. The list corresponds to each class. + each ndarray has shape (N, img_h, img_w), N + is the number of masks with this category. + + score_thr (float, optional): Minimum score of bboxes to be shown. + Default: 0.3. + bbox_color (str or tuple(int) or :obj:`Color`):Color of bbox lines. + The tuple of color should be in BGR order. Default: 'green' + text_color (str or tuple(int) or :obj:`Color`):Color of texts. + The tuple of color should be in BGR order. Default: 'green' + mask_color (None or str or tuple(int) or :obj:`Color`): + Color of masks. The tuple of color should be in BGR order. + Default: None + thickness (int): Thickness of lines. Default: 2 + font_size (int): Font size of texts. Default: 13 + win_name (str): The window name. Default: '' + wait_time (float): Value of waitKey param. + Default: 0. + show (bool): Whether to show the image. + Default: False. + out_file (str or None): The filename to write the image. + Default: None. + + Returns: + img (Tensor): Only if not `show` or `out_file` + """ + + assert isinstance(result, tuple) + bbox_result, mask_result = result + bboxes = np.vstack(bbox_result) + img = mmcv.imread(img) + img = img.copy() + labels = [ + np.full(bbox.shape[0], i, dtype=np.int32) + for i, bbox in enumerate(bbox_result) + ] + labels = np.concatenate(labels) + if len(labels) == 0: + bboxes = np.zeros([0, 5]) + masks = np.zeros([0, 0, 0]) + # draw segmentation masks + else: + masks = mmcv.concat_list(mask_result) + + if isinstance(masks[0], torch.Tensor): + masks = torch.stack(masks, dim=0).detach().cpu().numpy() + else: + masks = np.stack(masks, axis=0) + # dummy bboxes + if bboxes[:, :4].sum() == 0: + num_masks = len(bboxes) + x_any = masks.any(axis=1) + y_any = masks.any(axis=2) + for idx in range(num_masks): + x = np.where(x_any[idx, :])[0] + y = np.where(y_any[idx, :])[0] + if len(x) > 0 and len(y) > 0: + bboxes[idx, :4] = np.array( + [x[0], y[0], x[-1] + 1, y[-1] + 1], + dtype=np.float32) + + + if not (show or out_file): + return img diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/solo.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/solo.py index cd0df7486..df6f6de01 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/solo.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/solo.py @@ -1,16 +1,30 @@ -from .single_stage_ins import SingleStageInsDetector -from ..registry import DETECTORS +# Copyright (c) OpenMMLab. All rights reserved. +from ..builder import DETECTORS +from .single_stage_instance_seg import SingleStageInstanceSegmentor -@DETECTORS.register_module -class SOLO(SingleStageInsDetector): +@DETECTORS.register_module() +class SOLO(SingleStageInstanceSegmentor): + """`SOLO: Segmenting Objects by Locations + `_ + + """ def __init__(self, backbone, - neck, - bbox_head, + neck=None, + bbox_head=None, + mask_head=None, train_cfg=None, test_cfg=None, + init_cfg=None, pretrained=None): - super(SOLO, self).__init__(backbone, neck, bbox_head, None, train_cfg, - test_cfg, pretrained) + super().__init__( + backbone=backbone, + neck=neck, + bbox_head=bbox_head, + mask_head=mask_head, + train_cfg=train_cfg, + test_cfg=test_cfg, + init_cfg=init_cfg, + pretrained=pretrained) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/solov2.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/solov2.py deleted file mode 100644 index 02dac9646..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/solov2.py +++ /dev/null @@ -1,17 +0,0 @@ -from .single_stage_ins import SingleStageInsDetector -from ..registry import DETECTORS - - -@DETECTORS.register_module -class SOLOv2(SingleStageInsDetector): - - def __init__(self, - backbone, - neck, - bbox_head, - mask_feat_head, - train_cfg=None, - test_cfg=None, - pretrained=None): - super(SOLOv2, self).__init__(backbone, neck, bbox_head, mask_feat_head, train_cfg, - test_cfg, pretrained) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/test_mixins.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/test_mixins.py deleted file mode 100644 index 84a96d167..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/test_mixins.py +++ /dev/null @@ -1,266 +0,0 @@ -import logging -import sys - -import torch - -from mmdet.core import (bbox2roi, bbox_mapping, merge_aug_bboxes, - merge_aug_masks, merge_aug_proposals, multiclass_nms) - -logger = logging.getLogger(__name__) - -if sys.version_info >= (3, 7): - from mmdet.utils.contextmanagers import completed - - -class RPNTestMixin(object): - - if sys.version_info >= (3, 7): - - async def async_test_rpn(self, x, img_meta, rpn_test_cfg): - sleep_interval = rpn_test_cfg.pop("async_sleep_interval", 0.025) - async with completed( - __name__, "rpn_head_forward", - sleep_interval=sleep_interval): - rpn_outs = self.rpn_head(x) - - proposal_inputs = rpn_outs + (img_meta, rpn_test_cfg) - - proposal_list = self.rpn_head.get_bboxes(*proposal_inputs) - return proposal_list - - def simple_test_rpn(self, x, img_meta, rpn_test_cfg): - rpn_outs = self.rpn_head(x) - proposal_inputs = rpn_outs + (img_meta, rpn_test_cfg) - proposal_list = self.rpn_head.get_bboxes(*proposal_inputs) - return proposal_list - - def aug_test_rpn(self, feats, img_metas, rpn_test_cfg): - imgs_per_gpu = len(img_metas[0]) - aug_proposals = [[] for _ in range(imgs_per_gpu)] - for x, img_meta in zip(feats, img_metas): - proposal_list = self.simple_test_rpn(x, img_meta, rpn_test_cfg) - for i, proposals in enumerate(proposal_list): - aug_proposals[i].append(proposals) - # reorganize the order of 'img_metas' to match the dimensions - # of 'aug_proposals' - aug_img_metas = [] - for i in range(imgs_per_gpu): - aug_img_meta = [] - for j in range(len(img_metas)): - aug_img_meta.append(img_metas[j][i]) - aug_img_metas.append(aug_img_meta) - # after merging, proposals will be rescaled to the original image size - merged_proposals = [ - merge_aug_proposals(proposals, aug_img_meta, rpn_test_cfg) - for proposals, aug_img_meta in zip(aug_proposals, aug_img_metas) - ] - return merged_proposals - - -class BBoxTestMixin(object): - - if sys.version_info >= (3, 7): - - async def async_test_bboxes(self, - x, - img_meta, - proposals, - rcnn_test_cfg, - rescale=False, - bbox_semaphore=None, - global_lock=None): - """Async test only det bboxes without augmentation.""" - rois = bbox2roi(proposals) - roi_feats = self.bbox_roi_extractor( - x[:len(self.bbox_roi_extractor.featmap_strides)], rois) - if self.with_shared_head: - roi_feats = self.shared_head(roi_feats) - sleep_interval = rcnn_test_cfg.get("async_sleep_interval", 0.017) - - async with completed( - __name__, "bbox_head_forward", - sleep_interval=sleep_interval): - cls_score, bbox_pred = self.bbox_head(roi_feats) - - img_shape = img_meta[0]['img_shape'] - scale_factor = img_meta[0]['scale_factor'] - det_bboxes, det_labels = self.bbox_head.get_det_bboxes( - rois, - cls_score, - bbox_pred, - img_shape, - scale_factor, - rescale=rescale, - cfg=rcnn_test_cfg) - return det_bboxes, det_labels - - def simple_test_bboxes(self, - x, - img_meta, - proposals, - rcnn_test_cfg, - rescale=False): - """Test only det bboxes without augmentation.""" - rois = bbox2roi(proposals) - roi_feats = self.bbox_roi_extractor( - x[:len(self.bbox_roi_extractor.featmap_strides)], rois) - if self.with_shared_head: - roi_feats = self.shared_head(roi_feats) - cls_score, bbox_pred = self.bbox_head(roi_feats) - img_shape = img_meta[0]['img_shape'] - scale_factor = img_meta[0]['scale_factor'] - det_bboxes, det_labels = self.bbox_head.get_det_bboxes( - rois, - cls_score, - bbox_pred, - img_shape, - scale_factor, - rescale=rescale, - cfg=rcnn_test_cfg) - return det_bboxes, det_labels - - def aug_test_bboxes(self, feats, img_metas, proposal_list, rcnn_test_cfg): - aug_bboxes = [] - aug_scores = [] - for x, img_meta in zip(feats, img_metas): - # only one image in the batch - img_shape = img_meta[0]['img_shape'] - scale_factor = img_meta[0]['scale_factor'] - flip = img_meta[0]['flip'] - # TODO more flexible - proposals = bbox_mapping(proposal_list[0][:, :4], img_shape, - scale_factor, flip) - rois = bbox2roi([proposals]) - # recompute feature maps to save GPU memory - roi_feats = self.bbox_roi_extractor( - x[:len(self.bbox_roi_extractor.featmap_strides)], rois) - if self.with_shared_head: - roi_feats = self.shared_head(roi_feats) - cls_score, bbox_pred = self.bbox_head(roi_feats) - bboxes, scores = self.bbox_head.get_det_bboxes( - rois, - cls_score, - bbox_pred, - img_shape, - scale_factor, - rescale=False, - cfg=None) - aug_bboxes.append(bboxes) - aug_scores.append(scores) - # after merging, bboxes will be rescaled to the original image size - merged_bboxes, merged_scores = merge_aug_bboxes( - aug_bboxes, aug_scores, img_metas, rcnn_test_cfg) - det_bboxes, det_labels = multiclass_nms(merged_bboxes, merged_scores, - rcnn_test_cfg.score_thr, - rcnn_test_cfg.nms, - rcnn_test_cfg.max_per_img) - return det_bboxes, det_labels - - -class MaskTestMixin(object): - - if sys.version_info >= (3, 7): - - async def async_test_mask(self, - x, - img_meta, - det_bboxes, - det_labels, - rescale=False, - mask_test_cfg=None): - # image shape of the first image in the batch (only one) - ori_shape = img_meta[0]['ori_shape'] - scale_factor = img_meta[0]['scale_factor'] - if det_bboxes.shape[0] == 0: - segm_result = [[] - for _ in range(self.mask_head.num_classes - 1)] - else: - _bboxes = ( - det_bboxes[:, :4] * - scale_factor if rescale else det_bboxes) - mask_rois = bbox2roi([_bboxes]) - mask_feats = self.mask_roi_extractor( - x[:len(self.mask_roi_extractor.featmap_strides)], - mask_rois) - - if self.with_shared_head: - mask_feats = self.shared_head(mask_feats) - if mask_test_cfg and mask_test_cfg.get('async_sleep_interval'): - sleep_interval = mask_test_cfg['async_sleep_interval'] - else: - sleep_interval = 0.035 - async with completed( - __name__, - "mask_head_forward", - sleep_interval=sleep_interval): - mask_pred = self.mask_head(mask_feats) - segm_result = self.mask_head.get_seg_masks( - mask_pred, _bboxes, det_labels, self.test_cfg.rcnn, - ori_shape, scale_factor, rescale) - return segm_result - - def simple_test_mask(self, - x, - img_meta, - det_bboxes, - det_labels, - rescale=False): - # image shape of the first image in the batch (only one) - ori_shape = img_meta[0]['ori_shape'] - scale_factor = img_meta[0]['scale_factor'] - if det_bboxes.shape[0] == 0: - segm_result = [[] for _ in range(self.mask_head.num_classes - 1)] - else: - # if det_bboxes is rescaled to the original image size, we need to - # rescale it back to the testing scale to obtain RoIs. - if rescale and not isinstance(scale_factor, float): - scale_factor = torch.from_numpy(scale_factor).to( - det_bboxes.device) - _bboxes = ( - det_bboxes[:, :4] * scale_factor if rescale else det_bboxes) - mask_rois = bbox2roi([_bboxes]) - mask_feats = self.mask_roi_extractor( - x[:len(self.mask_roi_extractor.featmap_strides)], mask_rois) - if self.with_shared_head: - mask_feats = self.shared_head(mask_feats) - mask_pred = self.mask_head(mask_feats) - segm_result = self.mask_head.get_seg_masks(mask_pred, _bboxes, - det_labels, - self.test_cfg.rcnn, - ori_shape, scale_factor, - rescale) - return segm_result - - def aug_test_mask(self, feats, img_metas, det_bboxes, det_labels): - if det_bboxes.shape[0] == 0: - segm_result = [[] for _ in range(self.mask_head.num_classes - 1)] - else: - aug_masks = [] - for x, img_meta in zip(feats, img_metas): - img_shape = img_meta[0]['img_shape'] - scale_factor = img_meta[0]['scale_factor'] - flip = img_meta[0]['flip'] - _bboxes = bbox_mapping(det_bboxes[:, :4], img_shape, - scale_factor, flip) - mask_rois = bbox2roi([_bboxes]) - mask_feats = self.mask_roi_extractor( - x[:len(self.mask_roi_extractor.featmap_strides)], - mask_rois) - if self.with_shared_head: - mask_feats = self.shared_head(mask_feats) - mask_pred = self.mask_head(mask_feats) - # convert to numpy array to save memory - aug_masks.append(mask_pred.sigmoid().cpu().numpy()) - merged_masks = merge_aug_masks(aug_masks, img_metas, - self.test_cfg.rcnn) - - ori_shape = img_metas[0][0]['ori_shape'] - segm_result = self.mask_head.get_seg_masks( - merged_masks, - det_bboxes, - det_labels, - self.test_cfg.rcnn, - ori_shape, - scale_factor=1.0, - rescale=False) - return segm_result diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/two_stage.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/two_stage.py deleted file mode 100644 index 962e0cb51..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/detectors/two_stage.py +++ /dev/null @@ -1,346 +0,0 @@ -import torch -import torch.nn as nn - -from mmdet.core import bbox2result, bbox2roi, build_assigner, build_sampler -from .. import builder -from ..registry import DETECTORS -from .base import BaseDetector -from .test_mixins import BBoxTestMixin, MaskTestMixin, RPNTestMixin - - -@DETECTORS.register_module -class TwoStageDetector(BaseDetector, RPNTestMixin, BBoxTestMixin, - MaskTestMixin): - """Base class for two-stage detectors. - - Two-stage detectors typically consisting of a region proposal network and a - task-specific regression head. - """ - - def __init__(self, - backbone, - neck=None, - shared_head=None, - rpn_head=None, - bbox_roi_extractor=None, - bbox_head=None, - mask_roi_extractor=None, - mask_head=None, - train_cfg=None, - test_cfg=None, - pretrained=None): - super(TwoStageDetector, self).__init__() - self.backbone = builder.build_backbone(backbone) - - if neck is not None: - self.neck = builder.build_neck(neck) - - if shared_head is not None: - self.shared_head = builder.build_shared_head(shared_head) - - if rpn_head is not None: - self.rpn_head = builder.build_head(rpn_head) - - if bbox_head is not None: - self.bbox_roi_extractor = builder.build_roi_extractor( - bbox_roi_extractor) - self.bbox_head = builder.build_head(bbox_head) - - if mask_head is not None: - if mask_roi_extractor is not None: - self.mask_roi_extractor = builder.build_roi_extractor( - mask_roi_extractor) - self.share_roi_extractor = False - else: - self.share_roi_extractor = True - self.mask_roi_extractor = self.bbox_roi_extractor - self.mask_head = builder.build_head(mask_head) - - self.train_cfg = train_cfg - self.test_cfg = test_cfg - - self.init_weights(pretrained=pretrained) - - @property - def with_rpn(self): - return hasattr(self, 'rpn_head') and self.rpn_head is not None - - def init_weights(self, pretrained=None): - super(TwoStageDetector, self).init_weights(pretrained) - self.backbone.init_weights(pretrained=pretrained) - if self.with_neck: - if isinstance(self.neck, nn.Sequential): - for m in self.neck: - m.init_weights() - else: - self.neck.init_weights() - if self.with_shared_head: - self.shared_head.init_weights(pretrained=pretrained) - if self.with_rpn: - self.rpn_head.init_weights() - if self.with_bbox: - self.bbox_roi_extractor.init_weights() - self.bbox_head.init_weights() - if self.with_mask: - self.mask_head.init_weights() - if not self.share_roi_extractor: - self.mask_roi_extractor.init_weights() - - def extract_feat(self, img): - """Directly extract features from the backbone+neck - """ - x = self.backbone(img) - if self.with_neck: - x = self.neck(x) - return x - - def forward_dummy(self, img): - """Used for computing network flops. - - See `mmedetection/tools/get_flops.py` - """ - outs = () - # backbone - x = self.extract_feat(img) - # rpn - if self.with_rpn: - rpn_outs = self.rpn_head(x) - outs = outs + (rpn_outs, ) - proposals = torch.randn(1000, 4).cuda() - # bbox head - rois = bbox2roi([proposals]) - if self.with_bbox: - bbox_feats = self.bbox_roi_extractor( - x[:self.bbox_roi_extractor.num_inputs], rois) - if self.with_shared_head: - bbox_feats = self.shared_head(bbox_feats) - cls_score, bbox_pred = self.bbox_head(bbox_feats) - outs = outs + (cls_score, bbox_pred) - # mask head - if self.with_mask: - mask_rois = rois[:100] - mask_feats = self.mask_roi_extractor( - x[:self.mask_roi_extractor.num_inputs], mask_rois) - if self.with_shared_head: - mask_feats = self.shared_head(mask_feats) - mask_pred = self.mask_head(mask_feats) - outs = outs + (mask_pred, ) - return outs - - def forward_train(self, - img, - img_meta, - gt_bboxes, - gt_labels, - gt_bboxes_ignore=None, - gt_masks=None, - proposals=None): - """ - Args: - img (Tensor): of shape (N, C, H, W) encoding input images. - Typically these should be mean centered and std scaled. - - img_meta (list[dict]): list of image info dict where each dict has: - 'img_shape', 'scale_factor', 'flip', and may also contain - 'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'. - For details on the values of these keys see - `mmdet/datasets/pipelines/formatting.py:Collect`. - - gt_bboxes (list[Tensor]): each item are the truth boxes for each - image in [tl_x, tl_y, br_x, br_y] format. - - gt_labels (list[Tensor]): class indices corresponding to each box - - gt_bboxes_ignore (None | list[Tensor]): specify which bounding - boxes can be ignored when computing the loss. - - gt_masks (None | Tensor) : true segmentation masks for each box - used if the architecture supports a segmentation task. - - proposals : override rpn proposals with custom proposals. Use when - `with_rpn` is False. - - Returns: - dict[str, Tensor]: a dictionary of loss components - """ - x = self.extract_feat(img) - - losses = dict() - - # RPN forward and loss - if self.with_rpn: - rpn_outs = self.rpn_head(x) - rpn_loss_inputs = rpn_outs + (gt_bboxes, img_meta, - self.train_cfg.rpn) - rpn_losses = self.rpn_head.loss( - *rpn_loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore) - losses.update(rpn_losses) - - proposal_cfg = self.train_cfg.get('rpn_proposal', - self.test_cfg.rpn) - proposal_inputs = rpn_outs + (img_meta, proposal_cfg) - proposal_list = self.rpn_head.get_bboxes(*proposal_inputs) - else: - proposal_list = proposals - - # assign gts and sample proposals - if self.with_bbox or self.with_mask: - bbox_assigner = build_assigner(self.train_cfg.rcnn.assigner) - bbox_sampler = build_sampler( - self.train_cfg.rcnn.sampler, context=self) - num_imgs = img.size(0) - if gt_bboxes_ignore is None: - gt_bboxes_ignore = [None for _ in range(num_imgs)] - sampling_results = [] - for i in range(num_imgs): - assign_result = bbox_assigner.assign(proposal_list[i], - gt_bboxes[i], - gt_bboxes_ignore[i], - gt_labels[i]) - sampling_result = bbox_sampler.sample( - assign_result, - proposal_list[i], - gt_bboxes[i], - gt_labels[i], - feats=[lvl_feat[i][None] for lvl_feat in x]) - sampling_results.append(sampling_result) - - # bbox head forward and loss - if self.with_bbox: - rois = bbox2roi([res.bboxes for res in sampling_results]) - # TODO: a more flexible way to decide which feature maps to use - bbox_feats = self.bbox_roi_extractor( - x[:self.bbox_roi_extractor.num_inputs], rois) - if self.with_shared_head: - bbox_feats = self.shared_head(bbox_feats) - cls_score, bbox_pred = self.bbox_head(bbox_feats) - - bbox_targets = self.bbox_head.get_target(sampling_results, - gt_bboxes, gt_labels, - self.train_cfg.rcnn) - loss_bbox = self.bbox_head.loss(cls_score, bbox_pred, - *bbox_targets) - losses.update(loss_bbox) - - # mask head forward and loss - if self.with_mask: - if not self.share_roi_extractor: - pos_rois = bbox2roi( - [res.pos_bboxes for res in sampling_results]) - mask_feats = self.mask_roi_extractor( - x[:self.mask_roi_extractor.num_inputs], pos_rois) - if self.with_shared_head: - mask_feats = self.shared_head(mask_feats) - else: - pos_inds = [] - device = bbox_feats.device - for res in sampling_results: - pos_inds.append( - torch.ones( - res.pos_bboxes.shape[0], - device=device, - dtype=torch.uint8)) - pos_inds.append( - torch.zeros( - res.neg_bboxes.shape[0], - device=device, - dtype=torch.uint8)) - pos_inds = torch.cat(pos_inds) - mask_feats = bbox_feats[pos_inds] - - if mask_feats.shape[0] > 0: - mask_pred = self.mask_head(mask_feats) - mask_targets = self.mask_head.get_target( - sampling_results, gt_masks, self.train_cfg.rcnn) - pos_labels = torch.cat( - [res.pos_gt_labels for res in sampling_results]) - loss_mask = self.mask_head.loss(mask_pred, mask_targets, - pos_labels) - losses.update(loss_mask) - - return losses - - async def async_simple_test(self, - img, - img_meta, - proposals=None, - rescale=False): - """Async test without augmentation.""" - assert self.with_bbox, "Bbox head must be implemented." - x = self.extract_feat(img) - - if proposals is None: - proposal_list = await self.async_test_rpn(x, img_meta, - self.test_cfg.rpn) - else: - proposal_list = proposals - - det_bboxes, det_labels = await self.async_test_bboxes( - x, img_meta, proposal_list, self.test_cfg.rcnn, rescale=rescale) - bbox_results = bbox2result(det_bboxes, det_labels, - self.bbox_head.num_classes) - - if not self.with_mask: - return bbox_results - else: - segm_results = await self.async_test_mask( - x, - img_meta, - det_bboxes, - det_labels, - rescale=rescale, - mask_test_cfg=self.test_cfg.get('mask')) - return bbox_results, segm_results - - def simple_test(self, img, img_meta, proposals=None, rescale=False): - """Test without augmentation.""" - assert self.with_bbox, "Bbox head must be implemented." - - x = self.extract_feat(img) - - if proposals is None: - proposal_list = self.simple_test_rpn(x, img_meta, - self.test_cfg.rpn) - else: - proposal_list = proposals - - det_bboxes, det_labels = self.simple_test_bboxes( - x, img_meta, proposal_list, self.test_cfg.rcnn, rescale=rescale) - bbox_results = bbox2result(det_bboxes, det_labels, - self.bbox_head.num_classes) - - if not self.with_mask: - return bbox_results - else: - segm_results = self.simple_test_mask( - x, img_meta, det_bboxes, det_labels, rescale=rescale) - return bbox_results, segm_results - - def aug_test(self, imgs, img_metas, rescale=False): - """Test with augmentations. - - If rescale is False, then returned bboxes and masks will fit the scale - of imgs[0]. - """ - # recompute feats to save memory - proposal_list = self.aug_test_rpn( - self.extract_feats(imgs), img_metas, self.test_cfg.rpn) - det_bboxes, det_labels = self.aug_test_bboxes( - self.extract_feats(imgs), img_metas, proposal_list, - self.test_cfg.rcnn) - - if rescale: - _det_bboxes = det_bboxes - else: - _det_bboxes = det_bboxes.clone() - _det_bboxes[:, :4] *= img_metas[0][0]['scale_factor'] - bbox_results = bbox2result(_det_bboxes, det_labels, - self.bbox_head.num_classes) - - # det_bboxes always keep the original scale - if self.with_mask: - segm_results = self.aug_test_mask( - self.extract_feats(imgs), img_metas, det_bboxes, det_labels) - return bbox_results, segm_results - else: - return bbox_results diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/__init__.py index 07731d710..30016bb9c 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/__init__.py @@ -1,20 +1,15 @@ +# Copyright (c) OpenMMLab. All rights reserved. from .accuracy import Accuracy, accuracy -from .balanced_l1_loss import BalancedL1Loss, balanced_l1_loss -from .cross_entropy_loss import (CrossEntropyLoss, binary_cross_entropy, - cross_entropy, mask_cross_entropy) from .focal_loss import FocalLoss, sigmoid_focal_loss -from .ghm_loss import GHMC, GHMR -from .iou_loss import (BoundedIoULoss, GIoULoss, IoULoss, bounded_iou_loss, - iou_loss) -from .mse_loss import MSELoss, mse_loss -from .smooth_l1_loss import SmoothL1Loss, smooth_l1_loss +from .iou_loss import (BoundedIoULoss, CIoULoss, DIoULoss, GIoULoss, IoULoss, + bounded_iou_loss, iou_loss) from .utils import reduce_loss, weight_reduce_loss, weighted_loss +from .dice_loss import DiceLoss __all__ = [ - 'accuracy', 'Accuracy', 'cross_entropy', 'binary_cross_entropy', - 'mask_cross_entropy', 'CrossEntropyLoss', 'sigmoid_focal_loss', - 'FocalLoss', 'smooth_l1_loss', 'SmoothL1Loss', 'balanced_l1_loss', - 'BalancedL1Loss', 'mse_loss', 'MSELoss', 'iou_loss', 'bounded_iou_loss', - 'IoULoss', 'BoundedIoULoss', 'GIoULoss', 'GHMC', 'GHMR', 'reduce_loss', - 'weight_reduce_loss', 'weighted_loss' + 'accuracy', 'Accuracy', 'sigmoid_focal_loss', + 'FocalLoss', 'reduce_loss', 'weight_reduce_loss', 'weighted_loss', + 'iou_loss', 'bounded_iou_loss', + 'IoULoss', 'BoundedIoULoss', 'GIoULoss', 'DIoULoss', 'CIoULoss', + 'DiceLoss' ] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/accuracy.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/accuracy.py index 20d0ad8cd..fe765a39f 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/accuracy.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/accuracy.py @@ -1,7 +1,28 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import mmcv import torch.nn as nn -def accuracy(pred, target, topk=1): +@mmcv.jit(coderize=True) +def accuracy(pred, target, topk=1, thresh=None): + """Calculate accuracy according to the prediction and target. + + Args: + pred (torch.Tensor): The model prediction, shape (N, num_class) + target (torch.Tensor): The target of each prediction, shape (N, ) + topk (int | tuple[int], optional): If the predictions in ``topk`` + matches the target, the predictions will be regarded as + correct ones. Defaults to 1. + thresh (float, optional): If not None, predictions with scores under + this threshold are considered incorrect. Default to None. + + Returns: + float | tuple[float]: If the input ``topk`` is a single integer, + the function will return a single float as accuracy. If + ``topk`` is a tuple containing multiple integers, the + function will return a tuple containing accuracies of + each ``topk`` number. + """ assert isinstance(topk, (int, tuple)) if isinstance(topk, int): topk = (topk, ) @@ -10,22 +31,49 @@ def accuracy(pred, target, topk=1): return_single = False maxk = max(topk) - _, pred_label = pred.topk(maxk, dim=1) - pred_label = pred_label.t() + if pred.size(0) == 0: + accu = [pred.new_tensor(0.) for i in range(len(topk))] + return accu[0] if return_single else accu + assert pred.ndim == 2 and target.ndim == 1 + assert pred.size(0) == target.size(0) + assert maxk <= pred.size(1), \ + f'maxk {maxk} exceeds pred dimension {pred.size(1)}' + pred_value, pred_label = pred.topk(maxk, dim=1) + pred_label = pred_label.t() # transpose to shape (maxk, N) correct = pred_label.eq(target.view(1, -1).expand_as(pred_label)) - + if thresh is not None: + # Only prediction values larger than thresh are counted as correct + correct = correct & (pred_value > thresh).t() res = [] for k in topk: - correct_k = correct[:k].view(-1).float().sum(0, keepdim=True) + correct_k = correct[:k].reshape(-1).float().sum(0, keepdim=True) res.append(correct_k.mul_(100.0 / pred.size(0))) return res[0] if return_single else res class Accuracy(nn.Module): - def __init__(self, topk=(1, )): + def __init__(self, topk=(1, ), thresh=None): + """Module to calculate the accuracy. + + Args: + topk (tuple, optional): The criterion used to calculate the + accuracy. Defaults to (1,). + thresh (float, optional): If not None, predictions with scores + under this threshold are considered incorrect. Default to None. + """ super().__init__() self.topk = topk + self.thresh = thresh def forward(self, pred, target): - return accuracy(pred, target, self.topk) + """Forward function to calculate accuracy. + + Args: + pred (torch.Tensor): Prediction of models. + target (torch.Tensor): Target for each prediction. + + Returns: + tuple[float]: The accuracies under different topk criterions. + """ + return accuracy(pred, target, self.topk, self.thresh) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/balanced_l1_loss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/balanced_l1_loss.py deleted file mode 100644 index fab60dbc6..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/balanced_l1_loss.py +++ /dev/null @@ -1,69 +0,0 @@ -import numpy as np -import torch -import torch.nn as nn - -from ..registry import LOSSES -from .utils import weighted_loss - - -@weighted_loss -def balanced_l1_loss(pred, - target, - beta=1.0, - alpha=0.5, - gamma=1.5, - reduction='mean'): - assert beta > 0 - assert pred.size() == target.size() and target.numel() > 0 - - diff = torch.abs(pred - target) - b = np.e**(gamma / alpha) - 1 - loss = torch.where( - diff < beta, alpha / b * - (b * diff + 1) * torch.log(b * diff / beta + 1) - alpha * diff, - gamma * diff + gamma / b - alpha * beta) - - return loss - - -@LOSSES.register_module -class BalancedL1Loss(nn.Module): - """Balanced L1 Loss - - arXiv: https://arxiv.org/pdf/1904.02701.pdf (CVPR 2019) - """ - - def __init__(self, - alpha=0.5, - gamma=1.5, - beta=1.0, - reduction='mean', - loss_weight=1.0): - super(BalancedL1Loss, self).__init__() - self.alpha = alpha - self.gamma = gamma - self.beta = beta - self.reduction = reduction - self.loss_weight = loss_weight - - def forward(self, - pred, - target, - weight=None, - avg_factor=None, - reduction_override=None, - **kwargs): - assert reduction_override in (None, 'none', 'mean', 'sum') - reduction = ( - reduction_override if reduction_override else self.reduction) - loss_bbox = self.loss_weight * balanced_l1_loss( - pred, - target, - weight, - alpha=self.alpha, - gamma=self.gamma, - beta=self.beta, - reduction=reduction, - avg_factor=avg_factor, - **kwargs) - return loss_bbox diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/cross_entropy_loss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/cross_entropy_loss.py deleted file mode 100644 index dd9d4776f..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/cross_entropy_loss.py +++ /dev/null @@ -1,103 +0,0 @@ -import torch -import torch.nn as nn -import torch.nn.functional as F - -from ..registry import LOSSES -from .utils import weight_reduce_loss - - -def cross_entropy(pred, label, weight=None, reduction='mean', avg_factor=None): - # element-wise losses - loss = F.cross_entropy(pred, label, reduction='none') - - # apply weights and do the reduction - if weight is not None: - weight = weight.float() - loss = weight_reduce_loss( - loss, weight=weight, reduction=reduction, avg_factor=avg_factor) - - return loss - - -def _expand_binary_labels(labels, label_weights, label_channels): - bin_labels = labels.new_full((labels.size(0), label_channels), 0) - inds = torch.nonzero(labels >= 1).squeeze() - if inds.numel() > 0: - bin_labels[inds, labels[inds] - 1] = 1 - if label_weights is None: - bin_label_weights = None - else: - bin_label_weights = label_weights.view(-1, 1).expand( - label_weights.size(0), label_channels) - return bin_labels, bin_label_weights - - -def binary_cross_entropy(pred, - label, - weight=None, - reduction='mean', - avg_factor=None): - if pred.dim() != label.dim(): - label, weight = _expand_binary_labels(label, weight, pred.size(-1)) - - # weighted element-wise losses - if weight is not None: - weight = weight.float() - loss = F.binary_cross_entropy_with_logits( - pred, label.float(), weight, reduction='none') - # do the reduction for the weighted loss - loss = weight_reduce_loss(loss, reduction=reduction, avg_factor=avg_factor) - - return loss - - -def mask_cross_entropy(pred, target, label, reduction='mean', avg_factor=None): - # TODO: handle these two reserved arguments - assert reduction == 'mean' and avg_factor is None - num_rois = pred.size()[0] - inds = torch.arange(0, num_rois, dtype=torch.long, device=pred.device) - pred_slice = pred[inds, label].squeeze(1) - return F.binary_cross_entropy_with_logits( - pred_slice, target, reduction='mean')[None] - - -@LOSSES.register_module -class CrossEntropyLoss(nn.Module): - - def __init__(self, - use_sigmoid=False, - use_mask=False, - reduction='mean', - loss_weight=1.0): - super(CrossEntropyLoss, self).__init__() - assert (use_sigmoid is False) or (use_mask is False) - self.use_sigmoid = use_sigmoid - self.use_mask = use_mask - self.reduction = reduction - self.loss_weight = loss_weight - - if self.use_sigmoid: - self.cls_criterion = binary_cross_entropy - elif self.use_mask: - self.cls_criterion = mask_cross_entropy - else: - self.cls_criterion = cross_entropy - - def forward(self, - cls_score, - label, - weight=None, - avg_factor=None, - reduction_override=None, - **kwargs): - assert reduction_override in (None, 'none', 'mean', 'sum') - reduction = ( - reduction_override if reduction_override else self.reduction) - loss_cls = self.loss_weight * self.cls_criterion( - cls_score, - label, - weight, - reduction=reduction, - avg_factor=avg_factor, - **kwargs) - return loss_cls diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/dice_loss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/dice_loss.py new file mode 100644 index 000000000..585beeaf1 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/dice_loss.py @@ -0,0 +1,146 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch +import torch.nn as nn + +from ..builder import LOSSES +from .utils import weight_reduce_loss + + +def dice_loss(pred, + target, + weight=None, + eps=1e-3, + reduction='mean', + naive_dice=False, + avg_factor=None): + """Calculate dice loss, there are two forms of dice loss is supported: + + - the one proposed in `V-Net: Fully Convolutional Neural + Networks for Volumetric Medical Image Segmentation + `_. + - the dice loss in which the power of the number in the + denominator is the first power instead of the second + power. + + Args: + pred (torch.Tensor): The prediction, has a shape (n, *) + target (torch.Tensor): The learning label of the prediction, + shape (n, *), same shape of pred. + weight (torch.Tensor, optional): The weight of loss for each + prediction, has a shape (n,). Defaults to None. + eps (float): Avoid dividing by zero. Default: 1e-3. + reduction (str, optional): The method used to reduce the loss into + a scalar. Defaults to 'mean'. + Options are "none", "mean" and "sum". + naive_dice (bool, optional): If false, use the dice + loss defined in the V-Net paper, otherwise, use the + naive dice loss in which the power of the number in the + denominator is the first power instead of the second + power.Defaults to False. + avg_factor (int, optional): Average factor that is used to average + the loss. Defaults to None. + """ + + input = pred.flatten(1) + target = target.flatten(1).float() + + a = torch.sum(input * target, 1) + if naive_dice: + b = torch.sum(input, 1) + c = torch.sum(target, 1) + d = (2 * a + eps) / (b + c + eps) + else: + b = torch.sum(input * input, 1) + eps + c = torch.sum(target * target, 1) + eps + d = (2 * a) / (b + c) + + loss = 1 - d + if weight is not None: + assert weight.ndim == loss.ndim + assert len(weight) == len(pred) + loss = weight_reduce_loss(loss, weight, reduction, avg_factor) + return loss + + +@LOSSES.register_module() +class DiceLoss(nn.Module): + + def __init__(self, + use_sigmoid=True, + activate=True, + reduction='mean', + naive_dice=False, + loss_weight=1.0, + eps=1e-3): + """Compute dice loss. + + Args: + use_sigmoid (bool, optional): Whether to the prediction is + used for sigmoid or softmax. Defaults to True. + activate (bool): Whether to activate the predictions inside, + this will disable the inside sigmoid operation. + Defaults to True. + reduction (str, optional): The method used + to reduce the loss. Options are "none", + "mean" and "sum". Defaults to 'mean'. + naive_dice (bool, optional): If false, use the dice + loss defined in the V-Net paper, otherwise, use the + naive dice loss in which the power of the number in the + denominator is the first power instead of the second + power. Defaults to False. + loss_weight (float, optional): Weight of loss. Defaults to 1.0. + eps (float): Avoid dividing by zero. Defaults to 1e-3. + """ + + super(DiceLoss, self).__init__() + self.use_sigmoid = use_sigmoid + self.reduction = reduction + self.naive_dice = naive_dice + self.loss_weight = loss_weight + self.eps = eps + self.activate = activate + + def forward(self, + pred, + target, + weight=None, + reduction_override=None, + avg_factor=None): + """Forward function. + + Args: + pred (torch.Tensor): The prediction, has a shape (n, *). + target (torch.Tensor): The label of the prediction, + shape (n, *), same shape of pred. + weight (torch.Tensor, optional): The weight of loss for each + prediction, has a shape (n,). Defaults to None. + avg_factor (int, optional): Average factor that is used to average + the loss. Defaults to None. + reduction_override (str, optional): The reduction method used to + override the original reduction method of the loss. + Options are "none", "mean" and "sum". + + Returns: + torch.Tensor: The calculated loss + """ + + assert reduction_override in (None, 'none', 'mean', 'sum') + reduction = ( + reduction_override if reduction_override else self.reduction) + + if self.activate: + if self.use_sigmoid: + pred = pred.sigmoid() + else: + raise NotImplementedError + + loss = self.loss_weight * dice_loss( + pred, + target, + weight, + eps=self.eps, + reduction=reduction, + naive_dice=self.naive_dice, + avg_factor=avg_factor) + + return loss diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/focal_loss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/focal_loss.py index 6b28e1257..6c20fddd5 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/focal_loss.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/focal_loss.py @@ -1,8 +1,10 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch import torch.nn as nn import torch.nn.functional as F +from mmcv.ops import sigmoid_focal_loss as _sigmoid_focal_loss -from mmdet.ops import sigmoid_focal_loss as _sigmoid_focal_loss -from ..registry import LOSSES +from ..builder import LOSSES from .utils import weight_reduce_loss @@ -14,6 +16,22 @@ def py_sigmoid_focal_loss(pred, alpha=0.25, reduction='mean', avg_factor=None): + """PyTorch version of `Focal Loss `_. + + Args: + pred (torch.Tensor): The prediction with shape (N, C), C is the + number of classes + target (torch.Tensor): The learning label of the prediction. + weight (torch.Tensor, optional): Sample-wise loss weight. + gamma (float, optional): The gamma for calculating the modulating + factor. Defaults to 2.0. + alpha (float, optional): A balanced form for Focal Loss. + Defaults to 0.25. + reduction (str, optional): The method used to reduce the loss into + a scalar. Defaults to 'mean'. + avg_factor (int, optional): Average factor that is used to average + the loss. Defaults to None. + """ pred_sigmoid = pred.sigmoid() target = target.type_as(pred) pt = (1 - pred_sigmoid) * target + pred_sigmoid * (1 - target) @@ -21,6 +39,73 @@ def py_sigmoid_focal_loss(pred, (1 - target)) * pt.pow(gamma) loss = F.binary_cross_entropy_with_logits( pred, target, reduction='none') * focal_weight + if weight is not None: + if weight.shape != loss.shape: + if weight.size(0) == loss.size(0): + # For most cases, weight is of shape (num_priors, ), + # which means it does not have the second axis num_class + weight = weight.view(-1, 1) + else: + # Sometimes, weight per anchor per class is also needed. e.g. + # in FSAF. But it may be flattened of shape + # (num_priors x num_class, ), while loss is still of shape + # (num_priors, num_class). + assert weight.numel() == loss.numel() + weight = weight.view(loss.size(0), -1) + assert weight.ndim == loss.ndim + loss = weight_reduce_loss(loss, weight, reduction, avg_factor) + return loss + + +def py_focal_loss_with_prob(pred, + target, + weight=None, + gamma=2.0, + alpha=0.25, + reduction='mean', + avg_factor=None): + """PyTorch version of `Focal Loss `_. + Different from `py_sigmoid_focal_loss`, this function accepts probability + as input. + + Args: + pred (torch.Tensor): The prediction probability with shape (N, C), + C is the number of classes. + target (torch.Tensor): The learning label of the prediction. + weight (torch.Tensor, optional): Sample-wise loss weight. + gamma (float, optional): The gamma for calculating the modulating + factor. Defaults to 2.0. + alpha (float, optional): A balanced form for Focal Loss. + Defaults to 0.25. + reduction (str, optional): The method used to reduce the loss into + a scalar. Defaults to 'mean'. + avg_factor (int, optional): Average factor that is used to average + the loss. Defaults to None. + """ + num_classes = pred.size(1) + target = F.one_hot(target, num_classes=num_classes + 1) + target = target[:, :num_classes] + + target = target.type_as(pred) + pt = (1 - pred) * target + pred * (1 - target) + focal_weight = (alpha * target + (1 - alpha) * + (1 - target)) * pt.pow(gamma) + loss = F.binary_cross_entropy( + pred, target, reduction='none') * focal_weight + if weight is not None: + if weight.shape != loss.shape: + if weight.size(0) == loss.size(0): + # For most cases, weight is of shape (num_priors, ), + # which means it does not have the second axis num_class + weight = weight.view(-1, 1) + else: + # Sometimes, weight per anchor per class is also needed. e.g. + # in FSAF. But it may be flattened of shape + # (num_priors x num_class, ), while loss is still of shape + # (num_priors, num_class). + assert weight.numel() == loss.numel() + weight = weight.view(loss.size(0), -1) + assert weight.ndim == loss.ndim loss = weight_reduce_loss(loss, weight, reduction, avg_factor) return loss @@ -32,17 +117,46 @@ def sigmoid_focal_loss(pred, alpha=0.25, reduction='mean', avg_factor=None): + r"""A warpper of cuda version `Focal Loss + `_. + + Args: + pred (torch.Tensor): The prediction with shape (N, C), C is the number + of classes. + target (torch.Tensor): The learning label of the prediction. + weight (torch.Tensor, optional): Sample-wise loss weight. + gamma (float, optional): The gamma for calculating the modulating + factor. Defaults to 2.0. + alpha (float, optional): A balanced form for Focal Loss. + Defaults to 0.25. + reduction (str, optional): The method used to reduce the loss into + a scalar. Defaults to 'mean'. Options are "none", "mean" and "sum". + avg_factor (int, optional): Average factor that is used to average + the loss. Defaults to None. + """ # Function.apply does not accept keyword arguments, so the decorator # "weighted_loss" is not applicable - loss = _sigmoid_focal_loss(pred, target, gamma, alpha) - # TODO: find a proper way to handle the shape of weight + loss = _sigmoid_focal_loss(pred.contiguous(), target.contiguous(), gamma, + alpha, None, 'none') if weight is not None: - weight = weight.view(-1, 1) + if weight.shape != loss.shape: + if weight.size(0) == loss.size(0): + # For most cases, weight is of shape (num_priors, ), + # which means it does not have the second axis num_class + weight = weight.view(-1, 1) + else: + # Sometimes, weight per anchor per class is also needed. e.g. + # in FSAF. But it may be flattened of shape + # (num_priors x num_class, ), while loss is still of shape + # (num_priors, num_class). + assert weight.numel() == loss.numel() + weight = weight.view(loss.size(0), -1) + assert weight.ndim == loss.ndim loss = weight_reduce_loss(loss, weight, reduction, avg_factor) return loss -@LOSSES.register_module +@LOSSES.register_module() class FocalLoss(nn.Module): def __init__(self, @@ -50,7 +164,26 @@ class FocalLoss(nn.Module): gamma=2.0, alpha=0.25, reduction='mean', - loss_weight=1.0): + loss_weight=1.0, + activated=False): + """`Focal Loss `_ + + Args: + use_sigmoid (bool, optional): Whether to the prediction is + used for sigmoid or softmax. Defaults to True. + gamma (float, optional): The gamma for calculating the modulating + factor. Defaults to 2.0. + alpha (float, optional): A balanced form for Focal Loss. + Defaults to 0.25. + reduction (str, optional): The method used to reduce the loss into + a scalar. Defaults to 'mean'. Options are "none", "mean" and + "sum". + loss_weight (float, optional): Weight of loss. Defaults to 1.0. + activated (bool, optional): Whether the input is activated. + If True, it means the input has been activated and can be + treated as probabilities. Else, it should be treated as logits. + Defaults to False. + """ super(FocalLoss, self).__init__() assert use_sigmoid is True, 'Only sigmoid focal loss supported now.' self.use_sigmoid = use_sigmoid @@ -58,6 +191,7 @@ class FocalLoss(nn.Module): self.alpha = alpha self.reduction = reduction self.loss_weight = loss_weight + self.activated = activated def forward(self, pred, @@ -65,11 +199,38 @@ class FocalLoss(nn.Module): weight=None, avg_factor=None, reduction_override=None): + """Forward function. + + Args: + pred (torch.Tensor): The prediction. + target (torch.Tensor): The learning label of the prediction. + weight (torch.Tensor, optional): The weight of loss for each + prediction. Defaults to None. + avg_factor (int, optional): Average factor that is used to average + the loss. Defaults to None. + reduction_override (str, optional): The reduction method used to + override the original reduction method of the loss. + Options are "none", "mean" and "sum". + + Returns: + torch.Tensor: The calculated loss + """ assert reduction_override in (None, 'none', 'mean', 'sum') reduction = ( reduction_override if reduction_override else self.reduction) if self.use_sigmoid: - loss_cls = self.loss_weight * sigmoid_focal_loss( + if self.activated: + calculate_loss_func = py_focal_loss_with_prob + else: + if torch.cuda.is_available() and pred.is_cuda: + calculate_loss_func = sigmoid_focal_loss + else: + num_classes = pred.size(1) + target = F.one_hot(target, num_classes=num_classes + 1) + target = target[:, :num_classes] + calculate_loss_func = py_sigmoid_focal_loss + + loss_cls = self.loss_weight * calculate_loss_func( pred, target, weight, @@ -77,6 +238,7 @@ class FocalLoss(nn.Module): alpha=self.alpha, reduction=reduction, avg_factor=avg_factor) + else: raise NotImplementedError return loss_cls diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/ghm_loss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/ghm_loss.py deleted file mode 100644 index e62b9904f..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/ghm_loss.py +++ /dev/null @@ -1,171 +0,0 @@ -import torch -import torch.nn as nn -import torch.nn.functional as F - -from ..registry import LOSSES - - -def _expand_binary_labels(labels, label_weights, label_channels): - bin_labels = labels.new_full((labels.size(0), label_channels), 0) - inds = torch.nonzero(labels >= 1).squeeze() - if inds.numel() > 0: - bin_labels[inds, labels[inds] - 1] = 1 - bin_label_weights = label_weights.view(-1, 1).expand( - label_weights.size(0), label_channels) - return bin_labels, bin_label_weights - - -# TODO: code refactoring to make it consistent with other losses -@LOSSES.register_module -class GHMC(nn.Module): - """GHM Classification Loss. - - Details of the theorem can be viewed in the paper - "Gradient Harmonized Single-stage Detector". - https://arxiv.org/abs/1811.05181 - - Args: - bins (int): Number of the unit regions for distribution calculation. - momentum (float): The parameter for moving average. - use_sigmoid (bool): Can only be true for BCE based loss now. - loss_weight (float): The weight of the total GHM-C loss. - """ - - def __init__(self, bins=10, momentum=0, use_sigmoid=True, loss_weight=1.0): - super(GHMC, self).__init__() - self.bins = bins - self.momentum = momentum - edges = torch.arange(bins + 1).float() / bins - self.register_buffer('edges', edges) - self.edges[-1] += 1e-6 - if momentum > 0: - acc_sum = torch.zeros(bins) - self.register_buffer('acc_sum', acc_sum) - self.use_sigmoid = use_sigmoid - if not self.use_sigmoid: - raise NotImplementedError - self.loss_weight = loss_weight - - def forward(self, pred, target, label_weight, *args, **kwargs): - """Calculate the GHM-C loss. - - Args: - pred (float tensor of size [batch_num, class_num]): - The direct prediction of classification fc layer. - target (float tensor of size [batch_num, class_num]): - Binary class target for each sample. - label_weight (float tensor of size [batch_num, class_num]): - the value is 1 if the sample is valid and 0 if ignored. - Returns: - The gradient harmonized loss. - """ - # the target should be binary class label - if pred.dim() != target.dim(): - target, label_weight = _expand_binary_labels( - target, label_weight, pred.size(-1)) - target, label_weight = target.float(), label_weight.float() - edges = self.edges - mmt = self.momentum - weights = torch.zeros_like(pred) - - # gradient length - g = torch.abs(pred.sigmoid().detach() - target) - - valid = label_weight > 0 - tot = max(valid.float().sum().item(), 1.0) - n = 0 # n valid bins - for i in range(self.bins): - inds = (g >= edges[i]) & (g < edges[i + 1]) & valid - num_in_bin = inds.sum().item() - if num_in_bin > 0: - if mmt > 0: - self.acc_sum[i] = mmt * self.acc_sum[i] \ - + (1 - mmt) * num_in_bin - weights[inds] = tot / self.acc_sum[i] - else: - weights[inds] = tot / num_in_bin - n += 1 - if n > 0: - weights = weights / n - - loss = F.binary_cross_entropy_with_logits( - pred, target, weights, reduction='sum') / tot - return loss * self.loss_weight - - -# TODO: code refactoring to make it consistent with other losses -@LOSSES.register_module -class GHMR(nn.Module): - """GHM Regression Loss. - - Details of the theorem can be viewed in the paper - "Gradient Harmonized Single-stage Detector" - https://arxiv.org/abs/1811.05181 - - Args: - mu (float): The parameter for the Authentic Smooth L1 loss. - bins (int): Number of the unit regions for distribution calculation. - momentum (float): The parameter for moving average. - loss_weight (float): The weight of the total GHM-R loss. - """ - - def __init__(self, mu=0.02, bins=10, momentum=0, loss_weight=1.0): - super(GHMR, self).__init__() - self.mu = mu - self.bins = bins - edges = torch.arange(bins + 1).float() / bins - self.register_buffer('edges', edges) - self.edges[-1] = 1e3 - self.momentum = momentum - if momentum > 0: - acc_sum = torch.zeros(bins) - self.register_buffer('acc_sum', acc_sum) - self.loss_weight = loss_weight - - # TODO: support reduction parameter - def forward(self, pred, target, label_weight, avg_factor=None): - """Calculate the GHM-R loss. - - Args: - pred (float tensor of size [batch_num, 4 (* class_num)]): - The prediction of box regression layer. Channel number can be 4 - or 4 * class_num depending on whether it is class-agnostic. - target (float tensor of size [batch_num, 4 (* class_num)]): - The target regression values with the same size of pred. - label_weight (float tensor of size [batch_num, 4 (* class_num)]): - The weight of each sample, 0 if ignored. - Returns: - The gradient harmonized loss. - """ - mu = self.mu - edges = self.edges - mmt = self.momentum - - # ASL1 loss - diff = pred - target - loss = torch.sqrt(diff * diff + mu * mu) - mu - - # gradient length - g = torch.abs(diff / torch.sqrt(mu * mu + diff * diff)).detach() - weights = torch.zeros_like(g) - - valid = label_weight > 0 - tot = max(label_weight.float().sum().item(), 1.0) - n = 0 # n: valid bins - for i in range(self.bins): - inds = (g >= edges[i]) & (g < edges[i + 1]) & valid - num_in_bin = inds.sum().item() - if num_in_bin > 0: - n += 1 - if mmt > 0: - self.acc_sum[i] = mmt * self.acc_sum[i] \ - + (1 - mmt) * num_in_bin - weights[inds] = tot / self.acc_sum[i] - else: - weights[inds] = tot / num_in_bin - if n > 0: - weights /= n - - loss = loss * weights - loss = loss.sum() / tot - return loss * self.loss_weight diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/iou_loss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/iou_loss.py index c19c1d1d6..bf1ed04e1 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/iou_loss.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/iou_loss.py @@ -1,52 +1,79 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import math +import warnings + +import mmcv import torch import torch.nn as nn from mmdet.core import bbox_overlaps -from ..registry import LOSSES +from ..builder import LOSSES from .utils import weighted_loss +@mmcv.jit(derivate=True, coderize=True) @weighted_loss -def iou_loss(pred, target, eps=1e-6): +def iou_loss(pred, target, linear=False, mode='log', eps=1e-6): """IoU loss. Computing the IoU loss between a set of predicted bboxes and target bboxes. The loss is calculated as negative log of IoU. Args: - pred (Tensor): Predicted bboxes of format (x1, y1, x2, y2), + pred (torch.Tensor): Predicted bboxes of format (x1, y1, x2, y2), shape (n, 4). - target (Tensor): Corresponding gt bboxes, shape (n, 4). + target (torch.Tensor): Corresponding gt bboxes, shape (n, 4). + linear (bool, optional): If True, use linear scale of loss instead of + log scale. Default: False. + mode (str): Loss scaling mode, including "linear", "square", and "log". + Default: 'log' eps (float): Eps to avoid log(0). Return: - Tensor: Loss tensor. + torch.Tensor: Loss tensor. """ + assert mode in ['linear', 'square', 'log'] + if linear: + mode = 'linear' + warnings.warn('DeprecationWarning: Setting "linear=True" in ' + 'iou_loss is deprecated, please use "mode=`linear`" ' + 'instead.') ious = bbox_overlaps(pred, target, is_aligned=True).clamp(min=eps) - loss = -ious.log() + if mode == 'linear': + loss = 1 - ious + elif mode == 'square': + loss = 1 - ious**2 + elif mode == 'log': + loss = -ious.log() + else: + raise NotImplementedError return loss +@mmcv.jit(derivate=True, coderize=True) @weighted_loss def bounded_iou_loss(pred, target, beta=0.2, eps=1e-3): - """Improving Object Localization with Fitness NMS and Bounded IoU Loss, - https://arxiv.org/abs/1711.00164. + """BIoULoss. + + This is an implementation of paper + `Improving Object Localization with Fitness NMS and Bounded IoU Loss. + `_. Args: - pred (tensor): Predicted bboxes. - target (tensor): Target bboxes. + pred (torch.Tensor): Predicted bboxes. + target (torch.Tensor): Target bboxes. beta (float): beta parameter in smoothl1. eps (float): eps to avoid NaN. """ pred_ctrx = (pred[:, 0] + pred[:, 2]) * 0.5 pred_ctry = (pred[:, 1] + pred[:, 3]) * 0.5 - pred_w = pred[:, 2] - pred[:, 0] + 1 - pred_h = pred[:, 3] - pred[:, 1] + 1 + pred_w = pred[:, 2] - pred[:, 0] + pred_h = pred[:, 3] - pred[:, 1] with torch.no_grad(): target_ctrx = (target[:, 0] + target[:, 2]) * 0.5 target_ctry = (target[:, 1] + target[:, 3]) * 0.5 - target_w = target[:, 2] - target[:, 0] + 1 - target_h = target[:, 3] - target[:, 1] + 1 + target_w = target[:, 2] - target[:, 0] + target_h = target[:, 3] - target[:, 1] dx = target_ctrx - pred_ctrx dy = target_ctry - pred_ctry @@ -61,42 +88,116 @@ def bounded_iou_loss(pred, target, beta=0.2, eps=1e-3): (target_w + eps)) loss_dh = 1 - torch.min(target_h / (pred_h + eps), pred_h / (target_h + eps)) + # view(..., -1) does not work for empty tensor loss_comb = torch.stack([loss_dx, loss_dy, loss_dw, loss_dh], - dim=-1).view(loss_dx.size(0), -1) + dim=-1).flatten(1) loss = torch.where(loss_comb < beta, 0.5 * loss_comb * loss_comb / beta, loss_comb - 0.5 * beta) return loss +@mmcv.jit(derivate=True, coderize=True) @weighted_loss def giou_loss(pred, target, eps=1e-7): + r"""`Generalized Intersection over Union: A Metric and A Loss for Bounding + Box Regression `_. + + Args: + pred (torch.Tensor): Predicted bboxes of format (x1, y1, x2, y2), + shape (n, 4). + target (torch.Tensor): Corresponding gt bboxes, shape (n, 4). + eps (float): Eps to avoid log(0). + + Return: + Tensor: Loss tensor. """ - Generalized Intersection over Union: A Metric and A Loss for - Bounding Box Regression - https://arxiv.org/abs/1902.09630 + gious = bbox_overlaps(pred, target, mode='giou', is_aligned=True, eps=eps) + loss = 1 - gious + return loss - code refer to: - https://github.com/sfzhang15/ATSS/blob/master/atss_core/modeling/rpn/atss/loss.py#L36 + +@mmcv.jit(derivate=True, coderize=True) +@weighted_loss +def diou_loss(pred, target, eps=1e-7): + r"""`Implementation of Distance-IoU Loss: Faster and Better + Learning for Bounding Box Regression, https://arxiv.org/abs/1911.08287`_. + + Code is modified from https://github.com/Zzh-tju/DIoU. Args: pred (Tensor): Predicted bboxes of format (x1, y1, x2, y2), shape (n, 4). target (Tensor): Corresponding gt bboxes, shape (n, 4). eps (float): Eps to avoid log(0). + Return: + Tensor: Loss tensor. + """ + # overlap + lt = torch.max(pred[:, :2], target[:, :2]) + rb = torch.min(pred[:, 2:], target[:, 2:]) + wh = (rb - lt).clamp(min=0) + overlap = wh[:, 0] * wh[:, 1] + + # union + ap = (pred[:, 2] - pred[:, 0]) * (pred[:, 3] - pred[:, 1]) + ag = (target[:, 2] - target[:, 0]) * (target[:, 3] - target[:, 1]) + union = ap + ag - overlap + eps + + # IoU + ious = overlap / union + + # enclose area + enclose_x1y1 = torch.min(pred[:, :2], target[:, :2]) + enclose_x2y2 = torch.max(pred[:, 2:], target[:, 2:]) + enclose_wh = (enclose_x2y2 - enclose_x1y1).clamp(min=0) + + cw = enclose_wh[:, 0] + ch = enclose_wh[:, 1] + + c2 = cw**2 + ch**2 + eps + + b1_x1, b1_y1 = pred[:, 0], pred[:, 1] + b1_x2, b1_y2 = pred[:, 2], pred[:, 3] + b2_x1, b2_y1 = target[:, 0], target[:, 1] + b2_x2, b2_y2 = target[:, 2], target[:, 3] + + left = ((b2_x1 + b2_x2) - (b1_x1 + b1_x2))**2 / 4 + right = ((b2_y1 + b2_y2) - (b1_y1 + b1_y2))**2 / 4 + rho2 = left + right + + # DIoU + dious = ious - rho2 / c2 + loss = 1 - dious + return loss + + +@mmcv.jit(derivate=True, coderize=True) +@weighted_loss +def ciou_loss(pred, target, eps=1e-7): + r"""`Implementation of paper `Enhancing Geometric Factors into + Model Learning and Inference for Object Detection and Instance + Segmentation `_. + Code is modified from https://github.com/Zzh-tju/CIoU. + + Args: + pred (Tensor): Predicted bboxes of format (x1, y1, x2, y2), + shape (n, 4). + target (Tensor): Corresponding gt bboxes, shape (n, 4). + eps (float): Eps to avoid log(0). Return: Tensor: Loss tensor. """ # overlap lt = torch.max(pred[:, :2], target[:, :2]) rb = torch.min(pred[:, 2:], target[:, 2:]) - wh = (rb - lt + 1).clamp(min=0) + wh = (rb - lt).clamp(min=0) overlap = wh[:, 0] * wh[:, 1] # union - ap = (pred[:, 2] - pred[:, 0] + 1) * (pred[:, 3] - pred[:, 1] + 1) - ag = (target[:, 2] - target[:, 0] + 1) * (target[:, 3] - target[:, 1] + 1) + ap = (pred[:, 2] - pred[:, 0]) * (pred[:, 3] - pred[:, 1]) + ag = (target[:, 2] - target[:, 0]) * (target[:, 3] - target[:, 1]) union = ap + ag - overlap + eps # IoU @@ -105,20 +206,68 @@ def giou_loss(pred, target, eps=1e-7): # enclose area enclose_x1y1 = torch.min(pred[:, :2], target[:, :2]) enclose_x2y2 = torch.max(pred[:, 2:], target[:, 2:]) - enclose_wh = (enclose_x2y2 - enclose_x1y1 + 1).clamp(min=0) - enclose_area = enclose_wh[:, 0] * enclose_wh[:, 1] + eps + enclose_wh = (enclose_x2y2 - enclose_x1y1).clamp(min=0) - # GIoU - gious = ious - (enclose_area - union) / enclose_area - loss = 1 - gious + cw = enclose_wh[:, 0] + ch = enclose_wh[:, 1] + + c2 = cw**2 + ch**2 + eps + + b1_x1, b1_y1 = pred[:, 0], pred[:, 1] + b1_x2, b1_y2 = pred[:, 2], pred[:, 3] + b2_x1, b2_y1 = target[:, 0], target[:, 1] + b2_x2, b2_y2 = target[:, 2], target[:, 3] + + w1, h1 = b1_x2 - b1_x1, b1_y2 - b1_y1 + eps + w2, h2 = b2_x2 - b2_x1, b2_y2 - b2_y1 + eps + + left = ((b2_x1 + b2_x2) - (b1_x1 + b1_x2))**2 / 4 + right = ((b2_y1 + b2_y2) - (b1_y1 + b1_y2))**2 / 4 + rho2 = left + right + + factor = 4 / math.pi**2 + v = factor * torch.pow(torch.atan(w2 / h2) - torch.atan(w1 / h1), 2) + + with torch.no_grad(): + alpha = (ious > 0.5).float() * v / (1 - ious + v) + + # CIoU + cious = ious - (rho2 / c2 + alpha * v) + loss = 1 - cious.clamp(min=-1.0, max=1.0) return loss -@LOSSES.register_module +@LOSSES.register_module() class IoULoss(nn.Module): + """IoULoss. - def __init__(self, eps=1e-6, reduction='mean', loss_weight=1.0): + Computing the IoU loss between a set of predicted bboxes and target bboxes. + + Args: + linear (bool): If True, use linear scale of loss else determined + by mode. Default: False. + eps (float): Eps to avoid log(0). + reduction (str): Options are "none", "mean" and "sum". + loss_weight (float): Weight of loss. + mode (str): Loss scaling mode, including "linear", "square", and "log". + Default: 'log' + """ + + def __init__(self, + linear=False, + eps=1e-6, + reduction='mean', + loss_weight=1.0, + mode='log'): super(IoULoss, self).__init__() + assert mode in ['linear', 'square', 'log'] + if linear: + mode = 'linear' + warnings.warn('DeprecationWarning: Setting "linear=True" in ' + 'IOULoss is deprecated, please use "mode=`linear`" ' + 'instead.') + self.mode = mode + self.linear = linear self.eps = eps self.reduction = reduction self.loss_weight = loss_weight @@ -130,15 +279,38 @@ class IoULoss(nn.Module): avg_factor=None, reduction_override=None, **kwargs): - if weight is not None and not torch.any(weight > 0): - return (pred * weight).sum() # 0 + """Forward function. + + Args: + pred (torch.Tensor): The prediction. + target (torch.Tensor): The learning target of the prediction. + weight (torch.Tensor, optional): The weight of loss for each + prediction. Defaults to None. + avg_factor (int, optional): Average factor that is used to average + the loss. Defaults to None. + reduction_override (str, optional): The reduction method used to + override the original reduction method of the loss. + Defaults to None. Options are "none", "mean" and "sum". + """ assert reduction_override in (None, 'none', 'mean', 'sum') reduction = ( reduction_override if reduction_override else self.reduction) + if (weight is not None) and (not torch.any(weight > 0)) and ( + reduction != 'none'): + if pred.dim() == weight.dim() + 1: + weight = weight.unsqueeze(1) + return (pred * weight).sum() # 0 + if weight is not None and weight.dim() > 1: + # TODO: remove this in the future + # reduce the weight of shape (n, 4) to (n,) to match the + # iou_loss of shape (n,) + assert weight.shape == pred.shape + weight = weight.mean(-1) loss = self.loss_weight * iou_loss( pred, target, weight, + mode=self.mode, eps=self.eps, reduction=reduction, avg_factor=avg_factor, @@ -146,7 +318,7 @@ class IoULoss(nn.Module): return loss -@LOSSES.register_module +@LOSSES.register_module() class BoundedIoULoss(nn.Module): def __init__(self, beta=0.2, eps=1e-3, reduction='mean', loss_weight=1.0): @@ -164,6 +336,8 @@ class BoundedIoULoss(nn.Module): reduction_override=None, **kwargs): if weight is not None and not torch.any(weight > 0): + if pred.dim() == weight.dim() + 1: + weight = weight.unsqueeze(1) return (pred * weight).sum() # 0 assert reduction_override in (None, 'none', 'mean', 'sum') reduction = ( @@ -180,7 +354,7 @@ class BoundedIoULoss(nn.Module): return loss -@LOSSES.register_module +@LOSSES.register_module() class GIoULoss(nn.Module): def __init__(self, eps=1e-6, reduction='mean', loss_weight=1.0): @@ -197,10 +371,18 @@ class GIoULoss(nn.Module): reduction_override=None, **kwargs): if weight is not None and not torch.any(weight > 0): + if pred.dim() == weight.dim() + 1: + weight = weight.unsqueeze(1) return (pred * weight).sum() # 0 assert reduction_override in (None, 'none', 'mean', 'sum') reduction = ( reduction_override if reduction_override else self.reduction) + if weight is not None and weight.dim() > 1: + # TODO: remove this in the future + # reduce the weight of shape (n, 4) to (n,) to match the + # giou_loss of shape (n,) + assert weight.shape == pred.shape + weight = weight.mean(-1) loss = self.loss_weight * giou_loss( pred, target, @@ -210,3 +392,83 @@ class GIoULoss(nn.Module): avg_factor=avg_factor, **kwargs) return loss + + +@LOSSES.register_module() +class DIoULoss(nn.Module): + + def __init__(self, eps=1e-6, reduction='mean', loss_weight=1.0): + super(DIoULoss, self).__init__() + self.eps = eps + self.reduction = reduction + self.loss_weight = loss_weight + + def forward(self, + pred, + target, + weight=None, + avg_factor=None, + reduction_override=None, + **kwargs): + if weight is not None and not torch.any(weight > 0): + if pred.dim() == weight.dim() + 1: + weight = weight.unsqueeze(1) + return (pred * weight).sum() # 0 + assert reduction_override in (None, 'none', 'mean', 'sum') + reduction = ( + reduction_override if reduction_override else self.reduction) + if weight is not None and weight.dim() > 1: + # TODO: remove this in the future + # reduce the weight of shape (n, 4) to (n,) to match the + # giou_loss of shape (n,) + assert weight.shape == pred.shape + weight = weight.mean(-1) + loss = self.loss_weight * diou_loss( + pred, + target, + weight, + eps=self.eps, + reduction=reduction, + avg_factor=avg_factor, + **kwargs) + return loss + + +@LOSSES.register_module() +class CIoULoss(nn.Module): + + def __init__(self, eps=1e-6, reduction='mean', loss_weight=1.0): + super(CIoULoss, self).__init__() + self.eps = eps + self.reduction = reduction + self.loss_weight = loss_weight + + def forward(self, + pred, + target, + weight=None, + avg_factor=None, + reduction_override=None, + **kwargs): + if weight is not None and not torch.any(weight > 0): + if pred.dim() == weight.dim() + 1: + weight = weight.unsqueeze(1) + return (pred * weight).sum() # 0 + assert reduction_override in (None, 'none', 'mean', 'sum') + reduction = ( + reduction_override if reduction_override else self.reduction) + if weight is not None and weight.dim() > 1: + # TODO: remove this in the future + # reduce the weight of shape (n, 4) to (n,) to match the + # giou_loss of shape (n,) + assert weight.shape == pred.shape + weight = weight.mean(-1) + loss = self.loss_weight * ciou_loss( + pred, + target, + weight, + eps=self.eps, + reduction=reduction, + avg_factor=avg_factor, + **kwargs) + return loss diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/mse_loss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/mse_loss.py deleted file mode 100644 index a868b2be9..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/mse_loss.py +++ /dev/null @@ -1,25 +0,0 @@ -import torch.nn as nn -import torch.nn.functional as F - -from ..registry import LOSSES -from .utils import weighted_loss - -mse_loss = weighted_loss(F.mse_loss) - - -@LOSSES.register_module -class MSELoss(nn.Module): - - def __init__(self, reduction='mean', loss_weight=1.0): - super().__init__() - self.reduction = reduction - self.loss_weight = loss_weight - - def forward(self, pred, target, weight=None, avg_factor=None): - loss = self.loss_weight * mse_loss( - pred, - target, - weight, - reduction=self.reduction, - avg_factor=avg_factor) - return loss diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/smooth_l1_loss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/smooth_l1_loss.py deleted file mode 100644 index bc340730b..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/smooth_l1_loss.py +++ /dev/null @@ -1,45 +0,0 @@ -import torch -import torch.nn as nn - -from ..registry import LOSSES -from .utils import weighted_loss - - -@weighted_loss -def smooth_l1_loss(pred, target, beta=1.0): - assert beta > 0 - assert pred.size() == target.size() and target.numel() > 0 - diff = torch.abs(pred - target) - loss = torch.where(diff < beta, 0.5 * diff * diff / beta, - diff - 0.5 * beta) - return loss - - -@LOSSES.register_module -class SmoothL1Loss(nn.Module): - - def __init__(self, beta=1.0, reduction='mean', loss_weight=1.0): - super(SmoothL1Loss, self).__init__() - self.beta = beta - self.reduction = reduction - self.loss_weight = loss_weight - - def forward(self, - pred, - target, - weight=None, - avg_factor=None, - reduction_override=None, - **kwargs): - assert reduction_override in (None, 'none', 'mean', 'sum') - reduction = ( - reduction_override if reduction_override else self.reduction) - loss_bbox = self.loss_weight * smooth_l1_loss( - pred, - target, - weight, - beta=self.beta, - reduction=reduction, - avg_factor=avg_factor, - **kwargs) - return loss_bbox diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/utils.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/utils.py index 3361c6cad..778237ebf 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/utils.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/losses/utils.py @@ -1,5 +1,8 @@ +# Copyright (c) OpenMMLab. All rights reserved. import functools +import mmcv +import torch import torch.nn.functional as F @@ -23,6 +26,7 @@ def reduce_loss(loss, reduction): return loss.sum() +@mmcv.jit(derivate=True, coderize=True) def weight_reduce_loss(loss, weight=None, reduction='mean', avg_factor=None): """Apply element-wise weight and reduce loss. @@ -30,7 +34,7 @@ def weight_reduce_loss(loss, weight=None, reduction='mean', avg_factor=None): loss (Tensor): Element-wise loss. weight (Tensor): Element-wise weights. reduction (str): Same as built-in losses of PyTorch. - avg_factor (float): Avarage factor when computing the mean of losses. + avg_factor (float): Average factor when computing the mean of losses. Returns: Tensor: Processed loss values. @@ -45,7 +49,10 @@ def weight_reduce_loss(loss, weight=None, reduction='mean', avg_factor=None): else: # if reduction is mean, then average the loss by avg_factor if reduction == 'mean': - loss = loss.sum() / avg_factor + # Avoid causing ZeroDivisionError when avg_factor is 0.0, + # i.e., all labels of an image belong to ignore index. + eps = torch.finfo(torch.float32).eps + loss = loss.sum() / (avg_factor + eps) # if reduction is 'none', then do nothing, otherwise raise an error elif reduction != 'none': raise ValueError('avg_factor can not be used with reduction="sum"') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/__init__.py deleted file mode 100644 index 0cae03ac7..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -from .fcn_mask_head import FCNMaskHead -from .fused_semantic_head import FusedSemanticHead -from .grid_head import GridHead -from .htc_mask_head import HTCMaskHead -from .maskiou_head import MaskIoUHead -from .mask_feat_head import MaskFeatHead - -__all__ = [ - 'FCNMaskHead', 'HTCMaskHead', 'FusedSemanticHead', 'GridHead', - 'MaskIoUHead', 'MaskFeatHead' -] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/fcn_mask_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/fcn_mask_head.py deleted file mode 100644 index 6d11cfffc..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/fcn_mask_head.py +++ /dev/null @@ -1,191 +0,0 @@ -import mmcv -import numpy as np -import pycocotools.mask as mask_util -import torch -import torch.nn as nn -from torch.nn.modules.utils import _pair - -from mmdet.core import auto_fp16, force_fp32, mask_target -from ..builder import build_loss -from ..registry import HEADS -from ..utils import ConvModule - - -@HEADS.register_module -class FCNMaskHead(nn.Module): - - def __init__(self, - num_convs=4, - roi_feat_size=14, - in_channels=256, - conv_kernel_size=3, - conv_out_channels=256, - upsample_method='deconv', - upsample_ratio=2, - num_classes=81, - class_agnostic=False, - conv_cfg=None, - norm_cfg=None, - loss_mask=dict( - type='CrossEntropyLoss', use_mask=True, loss_weight=1.0)): - super(FCNMaskHead, self).__init__() - if upsample_method not in [None, 'deconv', 'nearest', 'bilinear']: - raise ValueError( - 'Invalid upsample method {}, accepted methods ' - 'are "deconv", "nearest", "bilinear"'.format(upsample_method)) - self.num_convs = num_convs - # WARN: roi_feat_size is reserved and not used - self.roi_feat_size = _pair(roi_feat_size) - self.in_channels = in_channels - self.conv_kernel_size = conv_kernel_size - self.conv_out_channels = conv_out_channels - self.upsample_method = upsample_method - self.upsample_ratio = upsample_ratio - self.num_classes = num_classes - self.class_agnostic = class_agnostic - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - self.fp16_enabled = False - self.loss_mask = build_loss(loss_mask) - - self.convs = nn.ModuleList() - for i in range(self.num_convs): - in_channels = ( - self.in_channels if i == 0 else self.conv_out_channels) - padding = (self.conv_kernel_size - 1) // 2 - self.convs.append( - ConvModule( - in_channels, - self.conv_out_channels, - self.conv_kernel_size, - padding=padding, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg)) - upsample_in_channels = ( - self.conv_out_channels if self.num_convs > 0 else in_channels) - if self.upsample_method is None: - self.upsample = None - elif self.upsample_method == 'deconv': - self.upsample = nn.ConvTranspose2d( - upsample_in_channels, - self.conv_out_channels, - self.upsample_ratio, - stride=self.upsample_ratio) - else: - self.upsample = nn.Upsample( - scale_factor=self.upsample_ratio, mode=self.upsample_method) - - out_channels = 1 if self.class_agnostic else self.num_classes - logits_in_channel = ( - self.conv_out_channels - if self.upsample_method == 'deconv' else upsample_in_channels) - self.conv_logits = nn.Conv2d(logits_in_channel, out_channels, 1) - self.relu = nn.ReLU(inplace=True) - self.debug_imgs = None - - def init_weights(self): - for m in [self.upsample, self.conv_logits]: - if m is None: - continue - nn.init.kaiming_normal_( - m.weight, mode='fan_out', nonlinearity='relu') - nn.init.constant_(m.bias, 0) - - @auto_fp16() - def forward(self, x): - for conv in self.convs: - x = conv(x) - if self.upsample is not None: - x = self.upsample(x) - if self.upsample_method == 'deconv': - x = self.relu(x) - mask_pred = self.conv_logits(x) - return mask_pred - - def get_target(self, sampling_results, gt_masks, rcnn_train_cfg): - pos_proposals = [res.pos_bboxes for res in sampling_results] - pos_assigned_gt_inds = [ - res.pos_assigned_gt_inds for res in sampling_results - ] - mask_targets = mask_target(pos_proposals, pos_assigned_gt_inds, - gt_masks, rcnn_train_cfg) - return mask_targets - - @force_fp32(apply_to=('mask_pred', )) - def loss(self, mask_pred, mask_targets, labels): - loss = dict() - if self.class_agnostic: - loss_mask = self.loss_mask(mask_pred, mask_targets, - torch.zeros_like(labels)) - else: - loss_mask = self.loss_mask(mask_pred, mask_targets, labels) - loss['loss_mask'] = loss_mask - return loss - - def get_seg_masks(self, mask_pred, det_bboxes, det_labels, rcnn_test_cfg, - ori_shape, scale_factor, rescale): - """Get segmentation masks from mask_pred and bboxes. - - Args: - mask_pred (Tensor or ndarray): shape (n, #class+1, h, w). - For single-scale testing, mask_pred is the direct output of - model, whose type is Tensor, while for multi-scale testing, - it will be converted to numpy array outside of this method. - det_bboxes (Tensor): shape (n, 4/5) - det_labels (Tensor): shape (n, ) - img_shape (Tensor): shape (3, ) - rcnn_test_cfg (dict): rcnn testing config - ori_shape: original image size - - Returns: - list[list]: encoded masks - """ - if isinstance(mask_pred, torch.Tensor): - mask_pred = mask_pred.sigmoid().cpu().numpy() - assert isinstance(mask_pred, np.ndarray) - # when enabling mixed precision training, mask_pred may be float16 - # numpy array - mask_pred = mask_pred.astype(np.float32) - - cls_segms = [[] for _ in range(self.num_classes - 1)] - bboxes = det_bboxes.cpu().numpy()[:, :4] - labels = det_labels.cpu().numpy() + 1 - - if rescale: - img_h, img_w = ori_shape[:2] - else: - img_h = np.round(ori_shape[0] * scale_factor).astype(np.int32) - img_w = np.round(ori_shape[1] * scale_factor).astype(np.int32) - scale_factor = 1.0 - - for i in range(bboxes.shape[0]): - if not isinstance(scale_factor, (float, np.ndarray)): - scale_factor = scale_factor.cpu().numpy() - bbox = (bboxes[i, :] / scale_factor).astype(np.int32) - label = labels[i] - w = max(bbox[2] - bbox[0] + 1, 1) - h = max(bbox[3] - bbox[1] + 1, 1) - - if not self.class_agnostic: - mask_pred_ = mask_pred[i, label, :, :] - else: - mask_pred_ = mask_pred[i, 0, :, :] - - bbox_mask = mmcv.imresize(mask_pred_, (w, h)) - bbox_mask = (bbox_mask > rcnn_test_cfg.mask_thr_binary).astype( - np.uint8) - - if rcnn_test_cfg.get('crop_mask', False): - im_mask = bbox_mask - else: - im_mask = np.zeros((img_h, img_w), dtype=np.uint8) - im_mask[bbox[1]:bbox[1] + h, bbox[0]:bbox[0] + w] = bbox_mask - - if rcnn_test_cfg.get('rle_mask_encode', True): - rle = mask_util.encode( - np.array(im_mask[:, :, np.newaxis], order='F'))[0] - cls_segms[label - 1].append(rle) - else: - cls_segms[label - 1].append(im_mask) - - return cls_segms diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/fused_semantic_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/fused_semantic_head.py deleted file mode 100644 index 80dab0516..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/fused_semantic_head.py +++ /dev/null @@ -1,106 +0,0 @@ -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import kaiming_init - -from mmdet.core import auto_fp16, force_fp32 -from ..registry import HEADS -from ..utils import ConvModule - - -@HEADS.register_module -class FusedSemanticHead(nn.Module): - r"""Multi-level fused semantic segmentation head. - - in_1 -> 1x1 conv --- - | - in_2 -> 1x1 conv -- | - || - in_3 -> 1x1 conv - || - ||| /-> 1x1 conv (mask prediction) - in_4 -> 1x1 conv -----> 3x3 convs (*4) - | \-> 1x1 conv (feature) - in_5 -> 1x1 conv --- - """ # noqa: W605 - - def __init__(self, - num_ins, - fusion_level, - num_convs=4, - in_channels=256, - conv_out_channels=256, - num_classes=183, - ignore_label=255, - loss_weight=0.2, - conv_cfg=None, - norm_cfg=None): - super(FusedSemanticHead, self).__init__() - self.num_ins = num_ins - self.fusion_level = fusion_level - self.num_convs = num_convs - self.in_channels = in_channels - self.conv_out_channels = conv_out_channels - self.num_classes = num_classes - self.ignore_label = ignore_label - self.loss_weight = loss_weight - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - self.fp16_enabled = False - - self.lateral_convs = nn.ModuleList() - for i in range(self.num_ins): - self.lateral_convs.append( - ConvModule( - self.in_channels, - self.in_channels, - 1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg, - inplace=False)) - - self.convs = nn.ModuleList() - for i in range(self.num_convs): - in_channels = self.in_channels if i == 0 else conv_out_channels - self.convs.append( - ConvModule( - in_channels, - conv_out_channels, - 3, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg)) - self.conv_embedding = ConvModule( - conv_out_channels, - conv_out_channels, - 1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg) - self.conv_logits = nn.Conv2d(conv_out_channels, self.num_classes, 1) - - self.criterion = nn.CrossEntropyLoss(ignore_index=ignore_label) - - def init_weights(self): - kaiming_init(self.conv_logits) - - @auto_fp16() - def forward(self, feats): - x = self.lateral_convs[self.fusion_level](feats[self.fusion_level]) - fused_size = tuple(x.shape[-2:]) - for i, feat in enumerate(feats): - if i != self.fusion_level: - feat = F.interpolate( - feat, size=fused_size, mode='bilinear', align_corners=True) - x += self.lateral_convs[i](feat) - - for i in range(self.num_convs): - x = self.convs[i](x) - - mask_pred = self.conv_logits(x) - x = self.conv_embedding(x) - return mask_pred, x - - @force_fp32(apply_to=('mask_pred', )) - def loss(self, mask_pred, labels): - labels = labels.squeeze(1).long() - loss_semantic_seg = self.criterion(mask_pred, labels) - loss_semantic_seg *= self.loss_weight - return loss_semantic_seg diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/grid_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/grid_head.py deleted file mode 100644 index 72065309b..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/grid_head.py +++ /dev/null @@ -1,361 +0,0 @@ -import numpy as np -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import kaiming_init, normal_init - -from ..builder import build_loss -from ..registry import HEADS -from ..utils import ConvModule - - -@HEADS.register_module -class GridHead(nn.Module): - - def __init__(self, - grid_points=9, - num_convs=8, - roi_feat_size=14, - in_channels=256, - conv_kernel_size=3, - point_feat_channels=64, - deconv_kernel_size=4, - class_agnostic=False, - loss_grid=dict( - type='CrossEntropyLoss', use_sigmoid=True, - loss_weight=15), - conv_cfg=None, - norm_cfg=dict(type='GN', num_groups=36)): - super(GridHead, self).__init__() - self.grid_points = grid_points - self.num_convs = num_convs - self.roi_feat_size = roi_feat_size - self.in_channels = in_channels - self.conv_kernel_size = conv_kernel_size - self.point_feat_channels = point_feat_channels - self.conv_out_channels = self.point_feat_channels * self.grid_points - self.class_agnostic = class_agnostic - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - if isinstance(norm_cfg, dict) and norm_cfg['type'] == 'GN': - assert self.conv_out_channels % norm_cfg['num_groups'] == 0 - - assert self.grid_points >= 4 - self.grid_size = int(np.sqrt(self.grid_points)) - if self.grid_size * self.grid_size != self.grid_points: - raise ValueError('grid_points must be a square number') - - # the predicted heatmap is half of whole_map_size - if not isinstance(self.roi_feat_size, int): - raise ValueError('Only square RoIs are supporeted in Grid R-CNN') - self.whole_map_size = self.roi_feat_size * 4 - - # compute point-wise sub-regions - self.sub_regions = self.calc_sub_regions() - - self.convs = [] - for i in range(self.num_convs): - in_channels = ( - self.in_channels if i == 0 else self.conv_out_channels) - stride = 2 if i == 0 else 1 - padding = (self.conv_kernel_size - 1) // 2 - self.convs.append( - ConvModule( - in_channels, - self.conv_out_channels, - self.conv_kernel_size, - stride=stride, - padding=padding, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg, - bias=True)) - self.convs = nn.Sequential(*self.convs) - - self.deconv1 = nn.ConvTranspose2d( - self.conv_out_channels, - self.conv_out_channels, - kernel_size=deconv_kernel_size, - stride=2, - padding=(deconv_kernel_size - 2) // 2, - groups=grid_points) - self.norm1 = nn.GroupNorm(grid_points, self.conv_out_channels) - self.deconv2 = nn.ConvTranspose2d( - self.conv_out_channels, - grid_points, - kernel_size=deconv_kernel_size, - stride=2, - padding=(deconv_kernel_size - 2) // 2, - groups=grid_points) - - # find the 4-neighbor of each grid point - self.neighbor_points = [] - grid_size = self.grid_size - for i in range(grid_size): # i-th column - for j in range(grid_size): # j-th row - neighbors = [] - if i > 0: # left: (i - 1, j) - neighbors.append((i - 1) * grid_size + j) - if j > 0: # up: (i, j - 1) - neighbors.append(i * grid_size + j - 1) - if j < grid_size - 1: # down: (i, j + 1) - neighbors.append(i * grid_size + j + 1) - if i < grid_size - 1: # right: (i + 1, j) - neighbors.append((i + 1) * grid_size + j) - self.neighbor_points.append(tuple(neighbors)) - # total edges in the grid - self.num_edges = sum([len(p) for p in self.neighbor_points]) - - self.forder_trans = nn.ModuleList() # first-order feature transition - self.sorder_trans = nn.ModuleList() # second-order feature transition - for neighbors in self.neighbor_points: - fo_trans = nn.ModuleList() - so_trans = nn.ModuleList() - for _ in range(len(neighbors)): - # each transition module consists of a 5x5 depth-wise conv and - # 1x1 conv. - fo_trans.append( - nn.Sequential( - nn.Conv2d( - self.point_feat_channels, - self.point_feat_channels, - 5, - stride=1, - padding=2, - groups=self.point_feat_channels), - nn.Conv2d(self.point_feat_channels, - self.point_feat_channels, 1))) - so_trans.append( - nn.Sequential( - nn.Conv2d( - self.point_feat_channels, - self.point_feat_channels, - 5, - 1, - 2, - groups=self.point_feat_channels), - nn.Conv2d(self.point_feat_channels, - self.point_feat_channels, 1))) - self.forder_trans.append(fo_trans) - self.sorder_trans.append(so_trans) - - self.loss_grid = build_loss(loss_grid) - - def init_weights(self): - for m in self.modules(): - if isinstance(m, nn.Conv2d) or isinstance(m, nn.Linear): - # TODO: compare mode = "fan_in" or "fan_out" - kaiming_init(m) - for m in self.modules(): - if isinstance(m, nn.ConvTranspose2d): - normal_init(m, std=0.001) - nn.init.constant_(self.deconv2.bias, -np.log(0.99 / 0.01)) - - def forward(self, x): - assert x.shape[-1] == x.shape[-2] == self.roi_feat_size - # RoI feature transformation, downsample 2x - x = self.convs(x) - - c = self.point_feat_channels - # first-order fusion - x_fo = [None for _ in range(self.grid_points)] - for i, points in enumerate(self.neighbor_points): - x_fo[i] = x[:, i * c:(i + 1) * c] - for j, point_idx in enumerate(points): - x_fo[i] = x_fo[i] + self.forder_trans[i][j]( - x[:, point_idx * c:(point_idx + 1) * c]) - - # second-order fusion - x_so = [None for _ in range(self.grid_points)] - for i, points in enumerate(self.neighbor_points): - x_so[i] = x[:, i * c:(i + 1) * c] - for j, point_idx in enumerate(points): - x_so[i] = x_so[i] + self.sorder_trans[i][j](x_fo[point_idx]) - - # predicted heatmap with fused features - x2 = torch.cat(x_so, dim=1) - x2 = self.deconv1(x2) - x2 = F.relu(self.norm1(x2), inplace=True) - heatmap = self.deconv2(x2) - - # predicted heatmap with original features (applicable during training) - if self.training: - x1 = x - x1 = self.deconv1(x1) - x1 = F.relu(self.norm1(x1), inplace=True) - heatmap_unfused = self.deconv2(x1) - else: - heatmap_unfused = heatmap - - return dict(fused=heatmap, unfused=heatmap_unfused) - - def calc_sub_regions(self): - """Compute point specific representation regions. - - See Grid R-CNN Plus (https://arxiv.org/abs/1906.05688) for details. - """ - # to make it consistent with the original implementation, half_size - # is computed as 2 * quarter_size, which is smaller - half_size = self.whole_map_size // 4 * 2 - sub_regions = [] - for i in range(self.grid_points): - x_idx = i // self.grid_size - y_idx = i % self.grid_size - if x_idx == 0: - sub_x1 = 0 - elif x_idx == self.grid_size - 1: - sub_x1 = half_size - else: - ratio = x_idx / (self.grid_size - 1) - 0.25 - sub_x1 = max(int(ratio * self.whole_map_size), 0) - - if y_idx == 0: - sub_y1 = 0 - elif y_idx == self.grid_size - 1: - sub_y1 = half_size - else: - ratio = y_idx / (self.grid_size - 1) - 0.25 - sub_y1 = max(int(ratio * self.whole_map_size), 0) - sub_regions.append( - (sub_x1, sub_y1, sub_x1 + half_size, sub_y1 + half_size)) - return sub_regions - - def get_target(self, sampling_results, rcnn_train_cfg): - # mix all samples (across images) together. - pos_bboxes = torch.cat([res.pos_bboxes for res in sampling_results], - dim=0).cpu() - pos_gt_bboxes = torch.cat( - [res.pos_gt_bboxes for res in sampling_results], dim=0).cpu() - assert pos_bboxes.shape == pos_gt_bboxes.shape - - # expand pos_bboxes to 2x of original size - x1 = pos_bboxes[:, 0] - (pos_bboxes[:, 2] - pos_bboxes[:, 0]) / 2 - y1 = pos_bboxes[:, 1] - (pos_bboxes[:, 3] - pos_bboxes[:, 1]) / 2 - x2 = pos_bboxes[:, 2] + (pos_bboxes[:, 2] - pos_bboxes[:, 0]) / 2 - y2 = pos_bboxes[:, 3] + (pos_bboxes[:, 3] - pos_bboxes[:, 1]) / 2 - pos_bboxes = torch.stack([x1, y1, x2, y2], dim=-1) - pos_bbox_ws = (pos_bboxes[:, 2] - pos_bboxes[:, 0]).unsqueeze(-1) - pos_bbox_hs = (pos_bboxes[:, 3] - pos_bboxes[:, 1]).unsqueeze(-1) - - num_rois = pos_bboxes.shape[0] - map_size = self.whole_map_size - # this is not the final target shape - targets = torch.zeros((num_rois, self.grid_points, map_size, map_size), - dtype=torch.float) - - # pre-compute interpolation factors for all grid points. - # the first item is the factor of x-dim, and the second is y-dim. - # for a 9-point grid, factors are like (1, 0), (0.5, 0.5), (0, 1) - factors = [] - for j in range(self.grid_points): - x_idx = j // self.grid_size - y_idx = j % self.grid_size - factors.append((1 - x_idx / (self.grid_size - 1), - 1 - y_idx / (self.grid_size - 1))) - - radius = rcnn_train_cfg.pos_radius - radius2 = radius**2 - for i in range(num_rois): - # ignore small bboxes - if (pos_bbox_ws[i] <= self.grid_size - or pos_bbox_hs[i] <= self.grid_size): - continue - # for each grid point, mark a small circle as positive - for j in range(self.grid_points): - factor_x, factor_y = factors[j] - gridpoint_x = factor_x * pos_gt_bboxes[i, 0] + ( - 1 - factor_x) * pos_gt_bboxes[i, 2] - gridpoint_y = factor_y * pos_gt_bboxes[i, 1] + ( - 1 - factor_y) * pos_gt_bboxes[i, 3] - - cx = int((gridpoint_x - pos_bboxes[i, 0]) / pos_bbox_ws[i] * - map_size) - cy = int((gridpoint_y - pos_bboxes[i, 1]) / pos_bbox_hs[i] * - map_size) - - for x in range(cx - radius, cx + radius + 1): - for y in range(cy - radius, cy + radius + 1): - if x >= 0 and x < map_size and y >= 0 and y < map_size: - if (x - cx)**2 + (y - cy)**2 <= radius2: - targets[i, j, y, x] = 1 - # reduce the target heatmap size by a half - # proposed in Grid R-CNN Plus (https://arxiv.org/abs/1906.05688). - sub_targets = [] - for i in range(self.grid_points): - sub_x1, sub_y1, sub_x2, sub_y2 = self.sub_regions[i] - sub_targets.append(targets[:, [i], sub_y1:sub_y2, sub_x1:sub_x2]) - sub_targets = torch.cat(sub_targets, dim=1) - sub_targets = sub_targets.cuda() - return sub_targets - - def loss(self, grid_pred, grid_targets): - loss_fused = self.loss_grid(grid_pred['fused'], grid_targets) - loss_unfused = self.loss_grid(grid_pred['unfused'], grid_targets) - loss_grid = loss_fused + loss_unfused - return dict(loss_grid=loss_grid) - - def get_bboxes(self, det_bboxes, grid_pred, img_meta): - # TODO: refactoring - assert det_bboxes.shape[0] == grid_pred.shape[0] - det_bboxes = det_bboxes.cpu() - cls_scores = det_bboxes[:, [4]] - det_bboxes = det_bboxes[:, :4] - grid_pred = grid_pred.sigmoid().cpu() - - R, c, h, w = grid_pred.shape - half_size = self.whole_map_size // 4 * 2 - assert h == w == half_size - assert c == self.grid_points - - # find the point with max scores in the half-sized heatmap - grid_pred = grid_pred.view(R * c, h * w) - pred_scores, pred_position = grid_pred.max(dim=1) - xs = pred_position % w - ys = pred_position // w - - # get the position in the whole heatmap instead of half-sized heatmap - for i in range(self.grid_points): - xs[i::self.grid_points] += self.sub_regions[i][0] - ys[i::self.grid_points] += self.sub_regions[i][1] - - # reshape to (num_rois, grid_points) - pred_scores, xs, ys = tuple( - map(lambda x: x.view(R, c), [pred_scores, xs, ys])) - - # get expanded pos_bboxes - widths = (det_bboxes[:, 2] - det_bboxes[:, 0]).unsqueeze(-1) - heights = (det_bboxes[:, 3] - det_bboxes[:, 1]).unsqueeze(-1) - x1 = (det_bboxes[:, 0, None] - widths / 2) - y1 = (det_bboxes[:, 1, None] - heights / 2) - # map the grid point to the absolute coordinates - abs_xs = (xs.float() + 0.5) / w * widths + x1 - abs_ys = (ys.float() + 0.5) / h * heights + y1 - - # get the grid points indices that fall on the bbox boundaries - x1_inds = [i for i in range(self.grid_size)] - y1_inds = [i * self.grid_size for i in range(self.grid_size)] - x2_inds = [ - self.grid_points - self.grid_size + i - for i in range(self.grid_size) - ] - y2_inds = [(i + 1) * self.grid_size - 1 for i in range(self.grid_size)] - - # voting of all grid points on some boundary - bboxes_x1 = (abs_xs[:, x1_inds] * pred_scores[:, x1_inds]).sum( - dim=1, keepdim=True) / ( - pred_scores[:, x1_inds].sum(dim=1, keepdim=True)) - bboxes_y1 = (abs_ys[:, y1_inds] * pred_scores[:, y1_inds]).sum( - dim=1, keepdim=True) / ( - pred_scores[:, y1_inds].sum(dim=1, keepdim=True)) - bboxes_x2 = (abs_xs[:, x2_inds] * pred_scores[:, x2_inds]).sum( - dim=1, keepdim=True) / ( - pred_scores[:, x2_inds].sum(dim=1, keepdim=True)) - bboxes_y2 = (abs_ys[:, y2_inds] * pred_scores[:, y2_inds]).sum( - dim=1, keepdim=True) / ( - pred_scores[:, y2_inds].sum(dim=1, keepdim=True)) - - bbox_res = torch.cat( - [bboxes_x1, bboxes_y1, bboxes_x2, bboxes_y2, cls_scores], dim=1) - bbox_res[:, [0, 2]].clamp_(min=0, max=img_meta[0]['img_shape'][1] - 1) - bbox_res[:, [1, 3]].clamp_(min=0, max=img_meta[0]['img_shape'][0] - 1) - - return bbox_res diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/htc_mask_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/htc_mask_head.py deleted file mode 100644 index 7c8125543..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/htc_mask_head.py +++ /dev/null @@ -1,38 +0,0 @@ -from ..registry import HEADS -from ..utils import ConvModule -from .fcn_mask_head import FCNMaskHead - - -@HEADS.register_module -class HTCMaskHead(FCNMaskHead): - - def __init__(self, *args, **kwargs): - super(HTCMaskHead, self).__init__(*args, **kwargs) - self.conv_res = ConvModule( - self.conv_out_channels, - self.conv_out_channels, - 1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg) - - def init_weights(self): - super(HTCMaskHead, self).init_weights() - self.conv_res.init_weights() - - def forward(self, x, res_feat=None, return_logits=True, return_feat=True): - if res_feat is not None: - res_feat = self.conv_res(res_feat) - x = x + res_feat - for conv in self.convs: - x = conv(x) - res_feat = x - outs = [] - if return_logits: - x = self.upsample(x) - if self.upsample_method == 'deconv': - x = self.relu(x) - mask_pred = self.conv_logits(x) - outs.append(mask_pred) - if return_feat: - outs.append(res_feat) - return outs if len(outs) > 1 else outs[0] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/mask_feat_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/mask_feat_head.py deleted file mode 100644 index 980b4ad8f..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/mask_feat_head.py +++ /dev/null @@ -1,119 +0,0 @@ -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import xavier_init, normal_init - -from ..registry import HEADS -from ..builder import build_loss -from ..utils import ConvModule - -import torch -import numpy as np - - -@HEADS.register_module -class MaskFeatHead(nn.Module): - def __init__(self, - in_channels, - out_channels, - start_level, - end_level, - num_classes, - conv_cfg=None, - norm_cfg=None): - super(MaskFeatHead, self).__init__() - - self.in_channels = in_channels - self.out_channels = out_channels - self.start_level = start_level - self.end_level = end_level - assert start_level >= 0 and end_level >= start_level - self.num_classes = num_classes - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - - self.convs_all_levels = nn.ModuleList() - for i in range(self.start_level, self.end_level + 1): - convs_per_level = nn.Sequential() - if i == 0: - one_conv = ConvModule( - self.in_channels, - self.out_channels, - 3, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg, - inplace=False) - convs_per_level.add_module('conv' + str(i), one_conv) - self.convs_all_levels.append(convs_per_level) - continue - - for j in range(i): - if j == 0: - chn = self.in_channels+2 if i==3 else self.in_channels - one_conv = ConvModule( - chn, - self.out_channels, - 3, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg, - inplace=False) - convs_per_level.add_module('conv' + str(j), one_conv) - one_upsample = nn.Upsample( - scale_factor=2, mode='bilinear', align_corners=False) - convs_per_level.add_module( - 'upsample' + str(j), one_upsample) - continue - - one_conv = ConvModule( - self.out_channels, - self.out_channels, - 3, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg, - inplace=False) - convs_per_level.add_module('conv' + str(j), one_conv) - one_upsample = nn.Upsample( - scale_factor=2, - mode='bilinear', - align_corners=False) - convs_per_level.add_module('upsample' + str(j), one_upsample) - - self.convs_all_levels.append(convs_per_level) - - self.conv_pred = nn.Sequential( - ConvModule( - self.out_channels, - self.num_classes, - 1, - padding=0, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg), - ) - - def init_weights(self): - for m in self.modules(): - if isinstance(m, nn.Conv2d): - normal_init(m, std=0.01) - - def forward(self, inputs): - assert len(inputs) == (self.end_level - self.start_level + 1) - - feature_add_all_level = self.convs_all_levels[0](inputs[0]) - for i in range(1, len(inputs)): - input_p = inputs[i] - if i == 3: - input_feat = input_p - x_range = torch.linspace(-1, 1, input_feat.shape[-1], device=input_feat.device) - y_range = torch.linspace(-1, 1, input_feat.shape[-2], device=input_feat.device) - y, x = torch.meshgrid(y_range, x_range) - y = y.expand([input_feat.shape[0], 1, -1, -1]) - x = x.expand([input_feat.shape[0], 1, -1, -1]) - coord_feat = torch.cat([x, y], 1) - input_p = torch.cat([input_p, coord_feat], 1) - - feature_add_all_level += self.convs_all_levels[i](input_p) - - feature_pred = self.conv_pred(feature_add_all_level) - return feature_pred diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/maskiou_head.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/maskiou_head.py deleted file mode 100644 index d509f177f..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/mask_heads/maskiou_head.py +++ /dev/null @@ -1,190 +0,0 @@ -import numpy as np -import torch -import torch.nn as nn -from mmcv.cnn import kaiming_init, normal_init -from torch.nn.modules.utils import _pair - -from mmdet.core import force_fp32 -from ..builder import build_loss -from ..registry import HEADS - - -@HEADS.register_module -class MaskIoUHead(nn.Module): - """Mask IoU Head. - - This head predicts the IoU of predicted masks and corresponding gt masks. - """ - - def __init__(self, - num_convs=4, - num_fcs=2, - roi_feat_size=14, - in_channels=256, - conv_out_channels=256, - fc_out_channels=1024, - num_classes=81, - loss_iou=dict(type='MSELoss', loss_weight=0.5)): - super(MaskIoUHead, self).__init__() - self.in_channels = in_channels - self.conv_out_channels = conv_out_channels - self.fc_out_channels = fc_out_channels - self.num_classes = num_classes - self.fp16_enabled = False - - self.convs = nn.ModuleList() - for i in range(num_convs): - if i == 0: - # concatenation of mask feature and mask prediction - in_channels = self.in_channels + 1 - else: - in_channels = self.conv_out_channels - stride = 2 if i == num_convs - 1 else 1 - self.convs.append( - nn.Conv2d( - in_channels, - self.conv_out_channels, - 3, - stride=stride, - padding=1)) - - roi_feat_size = _pair(roi_feat_size) - pooled_area = (roi_feat_size[0] // 2) * (roi_feat_size[1] // 2) - self.fcs = nn.ModuleList() - for i in range(num_fcs): - in_channels = ( - self.conv_out_channels * - pooled_area if i == 0 else self.fc_out_channels) - self.fcs.append(nn.Linear(in_channels, self.fc_out_channels)) - - self.fc_mask_iou = nn.Linear(self.fc_out_channels, self.num_classes) - self.relu = nn.ReLU() - self.max_pool = nn.MaxPool2d(2, 2) - self.loss_iou = build_loss(loss_iou) - - def init_weights(self): - for conv in self.convs: - kaiming_init(conv) - for fc in self.fcs: - kaiming_init( - fc, - a=1, - mode='fan_in', - nonlinearity='leaky_relu', - distribution='uniform') - normal_init(self.fc_mask_iou, std=0.01) - - def forward(self, mask_feat, mask_pred): - mask_pred = mask_pred.sigmoid() - mask_pred_pooled = self.max_pool(mask_pred.unsqueeze(1)) - - x = torch.cat((mask_feat, mask_pred_pooled), 1) - - for conv in self.convs: - x = self.relu(conv(x)) - x = x.view(x.size(0), -1) - for fc in self.fcs: - x = self.relu(fc(x)) - mask_iou = self.fc_mask_iou(x) - return mask_iou - - @force_fp32(apply_to=('mask_iou_pred', )) - def loss(self, mask_iou_pred, mask_iou_targets): - pos_inds = mask_iou_targets > 0 - if pos_inds.sum() > 0: - loss_mask_iou = self.loss_iou(mask_iou_pred[pos_inds], - mask_iou_targets[pos_inds]) - else: - loss_mask_iou = mask_iou_pred * 0 - return dict(loss_mask_iou=loss_mask_iou) - - @force_fp32(apply_to=('mask_pred', )) - def get_target(self, sampling_results, gt_masks, mask_pred, mask_targets, - rcnn_train_cfg): - """Compute target of mask IoU. - - Mask IoU target is the IoU of the predicted mask (inside a bbox) and - the gt mask of corresponding gt mask (the whole instance). - The intersection area is computed inside the bbox, and the gt mask area - is computed with two steps, firstly we compute the gt area inside the - bbox, then divide it by the area ratio of gt area inside the bbox and - the gt area of the whole instance. - - Args: - sampling_results (list[:obj:`SamplingResult`]): sampling results. - gt_masks (list[ndarray]): Gt masks (the whole instance) of each - image, binary maps with the same shape of the input image. - mask_pred (Tensor): Predicted masks of each positive proposal, - shape (num_pos, h, w). - mask_targets (Tensor): Gt mask of each positive proposal, - binary map of the shape (num_pos, h, w). - rcnn_train_cfg (dict): Training config for R-CNN part. - - Returns: - Tensor: mask iou target (length == num positive). - """ - pos_proposals = [res.pos_bboxes for res in sampling_results] - pos_assigned_gt_inds = [ - res.pos_assigned_gt_inds for res in sampling_results - ] - - # compute the area ratio of gt areas inside the proposals and - # the whole instance - area_ratios = map(self._get_area_ratio, pos_proposals, - pos_assigned_gt_inds, gt_masks) - area_ratios = torch.cat(list(area_ratios)) - assert mask_targets.size(0) == area_ratios.size(0) - - mask_pred = (mask_pred > rcnn_train_cfg.mask_thr_binary).float() - mask_pred_areas = mask_pred.sum((-1, -2)) - - # mask_pred and mask_targets are binary maps - overlap_areas = (mask_pred * mask_targets).sum((-1, -2)) - - # compute the mask area of the whole instance - gt_full_areas = mask_targets.sum((-1, -2)) / (area_ratios + 1e-7) - - mask_iou_targets = overlap_areas / ( - mask_pred_areas + gt_full_areas - overlap_areas) - return mask_iou_targets - - def _get_area_ratio(self, pos_proposals, pos_assigned_gt_inds, gt_masks): - """Compute area ratio of the gt mask inside the proposal and the gt - mask of the corresponding instance""" - num_pos = pos_proposals.size(0) - if num_pos > 0: - area_ratios = [] - proposals_np = pos_proposals.cpu().numpy() - pos_assigned_gt_inds = pos_assigned_gt_inds.cpu().numpy() - # compute mask areas of gt instances (batch processing for speedup) - gt_instance_mask_area = gt_masks.sum((-1, -2)) - for i in range(num_pos): - gt_mask = gt_masks[pos_assigned_gt_inds[i]] - - # crop the gt mask inside the proposal - x1, y1, x2, y2 = proposals_np[i, :].astype(np.int32) - gt_mask_in_proposal = gt_mask[y1:y2 + 1, x1:x2 + 1] - - ratio = gt_mask_in_proposal.sum() / ( - gt_instance_mask_area[pos_assigned_gt_inds[i]] + 1e-7) - area_ratios.append(ratio) - area_ratios = torch.from_numpy(np.stack(area_ratios)).float().to( - pos_proposals.device) - else: - area_ratios = pos_proposals.new_zeros((0, )) - return area_ratios - - @force_fp32(apply_to=('mask_iou_pred', )) - def get_mask_scores(self, mask_iou_pred, det_bboxes, det_labels): - """Get the mask scores. - - mask_score = bbox_score * mask_iou - """ - inds = range(det_labels.size(0)) - mask_scores = mask_iou_pred[inds, det_labels + 1] * det_bboxes[inds, - -1] - mask_scores = mask_scores.cpu().numpy() - det_labels = det_labels.cpu().numpy() - return [ - mask_scores[det_labels == i] for i in range(self.num_classes - 1) - ] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/__init__.py index fa5740443..e79a2a0d7 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/__init__.py @@ -1,6 +1,7 @@ -from .bfp import BFP +# Copyright (c) OpenMMLab. All rights reserved. + from .fpn import FPN -from .hrfpn import HRFPN -from .nas_fpn import NASFPN -__all__ = ['FPN', 'BFP', 'HRFPN', 'NASFPN'] +__all__ = [ + 'FPN' +] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/bfp.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/bfp.py deleted file mode 100644 index 03aee106d..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/bfp.py +++ /dev/null @@ -1,102 +0,0 @@ -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import xavier_init - -from ..plugins import NonLocal2D -from ..registry import NECKS -from ..utils import ConvModule - - -@NECKS.register_module -class BFP(nn.Module): - """BFP (Balanced Feature Pyrmamids) - - BFP takes multi-level features as inputs and gather them into a single one, - then refine the gathered feature and scatter the refined results to - multi-level features. This module is used in Libra R-CNN (CVPR 2019), see - https://arxiv.org/pdf/1904.02701.pdf for details. - - Args: - in_channels (int): Number of input channels (feature maps of all levels - should have the same channels). - num_levels (int): Number of input feature levels. - conv_cfg (dict): The config dict for convolution layers. - norm_cfg (dict): The config dict for normalization layers. - refine_level (int): Index of integration and refine level of BSF in - multi-level features from bottom to top. - refine_type (str): Type of the refine op, currently support - [None, 'conv', 'non_local']. - """ - - def __init__(self, - in_channels, - num_levels, - refine_level=2, - refine_type=None, - conv_cfg=None, - norm_cfg=None): - super(BFP, self).__init__() - assert refine_type in [None, 'conv', 'non_local'] - - self.in_channels = in_channels - self.num_levels = num_levels - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - - self.refine_level = refine_level - self.refine_type = refine_type - assert 0 <= self.refine_level < self.num_levels - - if self.refine_type == 'conv': - self.refine = ConvModule( - self.in_channels, - self.in_channels, - 3, - padding=1, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg) - elif self.refine_type == 'non_local': - self.refine = NonLocal2D( - self.in_channels, - reduction=1, - use_scale=False, - conv_cfg=self.conv_cfg, - norm_cfg=self.norm_cfg) - - def init_weights(self): - for m in self.modules(): - if isinstance(m, nn.Conv2d): - xavier_init(m, distribution='uniform') - - def forward(self, inputs): - assert len(inputs) == self.num_levels - - # step 1: gather multi-level features by resize and average - feats = [] - gather_size = inputs[self.refine_level].size()[2:] - for i in range(self.num_levels): - if i < self.refine_level: - gathered = F.adaptive_max_pool2d( - inputs[i], output_size=gather_size) - else: - gathered = F.interpolate( - inputs[i], size=gather_size, mode='nearest') - feats.append(gathered) - - bsf = sum(feats) / len(feats) - - # step 2: refine gathered features - if self.refine_type is not None: - bsf = self.refine(bsf) - - # step 3: scatter refined features to multi-levels by a residual path - outs = [] - for i in range(self.num_levels): - out_size = inputs[i].size()[2:] - if i < self.refine_level: - residual = F.interpolate(bsf, size=out_size, mode='nearest') - else: - residual = F.adaptive_max_pool2d(bsf, output_size=out_size) - outs.append(residual + inputs[i]) - - return tuple(outs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/fpn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/fpn.py index 77dd409c4..9f6013865 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/fpn.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/fpn.py @@ -1,14 +1,63 @@ +# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn import torch.nn.functional as F -from mmcv.cnn import xavier_init +from mmcv.cnn import ConvModule +from mmcv.runner import BaseModule, auto_fp16 -from mmdet.core import auto_fp16 -from ..registry import NECKS -from ..utils import ConvModule +from ..builder import NECKS -@NECKS.register_module -class FPN(nn.Module): +@NECKS.register_module() +class FPN(BaseModule): + r"""Feature Pyramid Network. + + This is an implementation of paper `Feature Pyramid Networks for Object + Detection `_. + + Args: + in_channels (List[int]): Number of input channels per scale. + out_channels (int): Number of output channels (used at each scale) + num_outs (int): Number of output scales. + start_level (int): Index of the start input backbone level used to + build the feature pyramid. Default: 0. + end_level (int): Index of the end input backbone level (exclusive) to + build the feature pyramid. Default: -1, which means the last level. + add_extra_convs (bool | str): If bool, it decides whether to add conv + layers on top of the original feature maps. Default to False. + If True, it is equivalent to `add_extra_convs='on_input'`. + If str, it specifies the source feature map of the extra convs. + Only the following options are allowed + + - 'on_input': Last feat map of neck inputs (i.e. backbone feature). + - 'on_lateral': Last feature map after lateral convs. + - 'on_output': The last output feature map after fpn convs. + relu_before_extra_convs (bool): Whether to apply relu before the extra + conv. Default: False. + no_norm_on_lateral (bool): Whether to apply norm on lateral. + Default: False. + conv_cfg (dict): Config dict for convolution layer. Default: None. + norm_cfg (dict): Config dict for normalization layer. Default: None. + act_cfg (str): Config dict for activation layer in ConvModule. + Default: None. + upsample_cfg (dict): Config dict for interpolate layer. + Default: `dict(mode='nearest')` + init_cfg (dict or list[dict], optional): Initialization config dict. + + Example: + >>> import torch + >>> in_channels = [2, 3, 5, 7] + >>> scales = [340, 170, 84, 43] + >>> inputs = [torch.rand(1, c, s, s) + ... for c, s in zip(in_channels, scales)] + >>> self = FPN(in_channels, 11, len(in_channels)).eval() + >>> outputs = self.forward(inputs) + >>> for i in range(len(outputs)): + ... print(f'outputs[{i}].shape = {outputs[i].shape}') + outputs[0].shape = torch.Size([1, 11, 340, 340]) + outputs[1].shape = torch.Size([1, 11, 170, 170]) + outputs[2].shape = torch.Size([1, 11, 84, 84]) + outputs[3].shape = torch.Size([1, 11, 43, 43]) + """ def __init__(self, in_channels, @@ -17,22 +66,24 @@ class FPN(nn.Module): start_level=0, end_level=-1, add_extra_convs=False, - extra_convs_on_inputs=True, relu_before_extra_convs=False, no_norm_on_lateral=False, conv_cfg=None, norm_cfg=None, - activation=None): - super(FPN, self).__init__() + act_cfg=None, + upsample_cfg=dict(mode='nearest'), + init_cfg=dict( + type='Xavier', layer='Conv2d', distribution='uniform')): + super(FPN, self).__init__(init_cfg) assert isinstance(in_channels, list) self.in_channels = in_channels self.out_channels = out_channels self.num_ins = len(in_channels) self.num_outs = num_outs - self.activation = activation self.relu_before_extra_convs = relu_before_extra_convs self.no_norm_on_lateral = no_norm_on_lateral self.fp16_enabled = False + self.upsample_cfg = upsample_cfg.copy() if end_level == -1: self.backbone_end_level = self.num_ins @@ -45,7 +96,12 @@ class FPN(nn.Module): self.start_level = start_level self.end_level = end_level self.add_extra_convs = add_extra_convs - self.extra_convs_on_inputs = extra_convs_on_inputs + assert isinstance(add_extra_convs, (str, bool)) + if isinstance(add_extra_convs, str): + # Extra_convs_source choices: 'on_input', 'on_lateral', 'on_output' + assert add_extra_convs in ('on_input', 'on_lateral', 'on_output') + elif add_extra_convs: # True + self.add_extra_convs = 'on_input' self.lateral_convs = nn.ModuleList() self.fpn_convs = nn.ModuleList() @@ -57,7 +113,7 @@ class FPN(nn.Module): 1, conv_cfg=conv_cfg, norm_cfg=norm_cfg if not self.no_norm_on_lateral else None, - activation=self.activation, + act_cfg=act_cfg, inplace=False) fpn_conv = ConvModule( out_channels, @@ -66,7 +122,7 @@ class FPN(nn.Module): padding=1, conv_cfg=conv_cfg, norm_cfg=norm_cfg, - activation=self.activation, + act_cfg=act_cfg, inplace=False) self.lateral_convs.append(l_conv) @@ -74,9 +130,9 @@ class FPN(nn.Module): # add extra conv layers (e.g., RetinaNet) extra_levels = num_outs - self.backbone_end_level + self.start_level - if add_extra_convs and extra_levels >= 1: + if self.add_extra_convs and extra_levels >= 1: for i in range(extra_levels): - if i == 0 and self.extra_convs_on_inputs: + if i == 0 and self.add_extra_convs == 'on_input': in_channels = self.in_channels[self.backbone_end_level - 1] else: in_channels = out_channels @@ -88,18 +144,13 @@ class FPN(nn.Module): padding=1, conv_cfg=conv_cfg, norm_cfg=norm_cfg, - activation=self.activation, + act_cfg=act_cfg, inplace=False) self.fpn_convs.append(extra_fpn_conv) - # default init_weights for conv(msra) and norm in ConvModule - def init_weights(self): - for m in self.modules(): - if isinstance(m, nn.Conv2d): - xavier_init(m, distribution='uniform') - @auto_fp16() def forward(self, inputs): + """Forward function.""" assert len(inputs) == len(self.in_channels) # build laterals @@ -111,8 +162,16 @@ class FPN(nn.Module): # build top-down path used_backbone_levels = len(laterals) for i in range(used_backbone_levels - 1, 0, -1): - laterals[i - 1] += F.interpolate( - laterals[i], scale_factor=2, mode='nearest') + # In some cases, fixing `scale factor` (e.g. 2) is preferred, but + # it cannot co-exist with `size` in `F.interpolate`. + if 'scale_factor' in self.upsample_cfg: + # fix runtime error of "+=" inplace operation in PyTorch 1.10 + laterals[i - 1] = laterals[i - 1] + F.interpolate( + laterals[i], **self.upsample_cfg) + else: + prev_shape = laterals[i - 1].shape[2:] + laterals[i - 1] = laterals[i - 1] + F.interpolate( + laterals[i], size=prev_shape, **self.upsample_cfg) # build outputs # part 1: from original levels @@ -128,11 +187,15 @@ class FPN(nn.Module): outs.append(F.max_pool2d(outs[-1], 1, stride=2)) # add conv layers on top of original feature maps (RetinaNet) else: - if self.extra_convs_on_inputs: - orig = inputs[self.backbone_end_level - 1] - outs.append(self.fpn_convs[used_backbone_levels](orig)) + if self.add_extra_convs == 'on_input': + extra_source = inputs[self.backbone_end_level - 1] + elif self.add_extra_convs == 'on_lateral': + extra_source = laterals[-1] + elif self.add_extra_convs == 'on_output': + extra_source = outs[-1] else: - outs.append(self.fpn_convs[used_backbone_levels](outs[-1])) + raise NotImplementedError + outs.append(self.fpn_convs[used_backbone_levels](extra_source)) for i in range(used_backbone_levels + 1, self.num_outs): if self.relu_before_extra_convs: outs.append(self.fpn_convs[i](F.relu(outs[-1]))) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/hrfpn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/hrfpn.py deleted file mode 100644 index 33155f057..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/hrfpn.py +++ /dev/null @@ -1,100 +0,0 @@ -import torch -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn.weight_init import caffe2_xavier_init -from torch.utils.checkpoint import checkpoint - -from ..registry import NECKS -from ..utils import ConvModule - - -@NECKS.register_module -class HRFPN(nn.Module): - """HRFPN (High Resolution Feature Pyrmamids) - - arXiv: https://arxiv.org/abs/1904.04514 - - Args: - in_channels (list): number of channels for each branch. - out_channels (int): output channels of feature pyramids. - num_outs (int): number of output stages. - pooling_type (str): pooling for generating feature pyramids - from {MAX, AVG}. - conv_cfg (dict): dictionary to construct and config conv layer. - norm_cfg (dict): dictionary to construct and config norm layer. - with_cp (bool): Use checkpoint or not. Using checkpoint will save some - memory while slowing down the training speed. - stride (int): stride of 3x3 convolutional layers - """ - - def __init__(self, - in_channels, - out_channels, - num_outs=5, - pooling_type='AVG', - conv_cfg=None, - norm_cfg=None, - with_cp=False, - stride=1): - super(HRFPN, self).__init__() - assert isinstance(in_channels, list) - self.in_channels = in_channels - self.out_channels = out_channels - self.num_ins = len(in_channels) - self.num_outs = num_outs - self.with_cp = with_cp - self.conv_cfg = conv_cfg - self.norm_cfg = norm_cfg - - self.reduction_conv = ConvModule( - sum(in_channels), - out_channels, - kernel_size=1, - conv_cfg=self.conv_cfg, - activation=None) - - self.fpn_convs = nn.ModuleList() - for i in range(self.num_outs): - self.fpn_convs.append( - ConvModule( - out_channels, - out_channels, - kernel_size=3, - padding=1, - stride=stride, - conv_cfg=self.conv_cfg, - activation=None)) - - if pooling_type == 'MAX': - self.pooling = F.max_pool2d - else: - self.pooling = F.avg_pool2d - - def init_weights(self): - for m in self.modules(): - if isinstance(m, nn.Conv2d): - caffe2_xavier_init(m) - - def forward(self, inputs): - assert len(inputs) == self.num_ins - outs = [inputs[0]] - for i in range(1, self.num_ins): - outs.append( - F.interpolate(inputs[i], scale_factor=2**i, mode='bilinear')) - out = torch.cat(outs, dim=1) - if out.requires_grad and self.with_cp: - out = checkpoint(self.reduction_conv, out) - else: - out = self.reduction_conv(out) - outs = [out] - for i in range(1, self.num_outs): - outs.append(self.pooling(out, kernel_size=2**i, stride=2**i)) - outputs = [] - - for i in range(self.num_outs): - if outs[i].requires_grad and self.with_cp: - tmp_out = checkpoint(self.fpn_convs[i], outs[i]) - else: - tmp_out = self.fpn_convs[i](outs[i]) - outputs.append(tmp_out) - return tuple(outputs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/nas_fpn.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/nas_fpn.py deleted file mode 100644 index b0a689837..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/necks/nas_fpn.py +++ /dev/null @@ -1,186 +0,0 @@ -import torch.nn as nn -import torch.nn.functional as F -from mmcv.cnn import caffe2_xavier_init - -from ..registry import NECKS -from ..utils import ConvModule - - -class MergingCell(nn.Module): - - def __init__(self, channels=256, with_conv=True, norm_cfg=None): - super(MergingCell, self).__init__() - self.with_conv = with_conv - if self.with_conv: - self.conv_out = ConvModule( - channels, - channels, - 3, - padding=1, - norm_cfg=norm_cfg, - order=('act', 'conv', 'norm')) - - def _binary_op(self, x1, x2): - raise NotImplementedError - - def _resize(self, x, size): - if x.shape[-2:] == size: - return x - elif x.shape[-2:] < size: - return F.interpolate(x, size=size, mode='nearest') - else: - assert x.shape[-2] % size[-2] == 0 and x.shape[-1] % size[-1] == 0 - kernel_size = x.shape[-1] // size[-1] - x = F.max_pool2d(x, kernel_size=kernel_size, stride=kernel_size) - return x - - def forward(self, x1, x2, out_size): - assert x1.shape[:2] == x2.shape[:2] - assert len(out_size) == 2 - - x1 = self._resize(x1, out_size) - x2 = self._resize(x2, out_size) - - x = self._binary_op(x1, x2) - if self.with_conv: - x = self.conv_out(x) - return x - - -class SumCell(MergingCell): - - def _binary_op(self, x1, x2): - return x1 + x2 - - -class GPCell(MergingCell): - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.global_pool = nn.AdaptiveAvgPool2d((1, 1)) - - def _binary_op(self, x1, x2): - x2_att = self.global_pool(x2).sigmoid() - return x2 + x2_att * x1 - - -@NECKS.register_module -class NASFPN(nn.Module): - """NAS-FPN. - - NAS-FPN: Learning Scalable Feature Pyramid Architecture for Object - Detection. (https://arxiv.org/abs/1904.07392) - """ - - def __init__(self, - in_channels, - out_channels, - num_outs, - stack_times, - start_level=0, - end_level=-1, - add_extra_convs=False, - norm_cfg=None): - super(NASFPN, self).__init__() - assert isinstance(in_channels, list) - self.in_channels = in_channels - self.out_channels = out_channels - self.num_ins = len(in_channels) # num of input feature levels - self.num_outs = num_outs # num of output feature levels - self.stack_times = stack_times - self.norm_cfg = norm_cfg - - if end_level == -1: - self.backbone_end_level = self.num_ins - assert num_outs >= self.num_ins - start_level - else: - # if end_level < inputs, no extra level is allowed - self.backbone_end_level = end_level - assert end_level <= len(in_channels) - assert num_outs == end_level - start_level - self.start_level = start_level - self.end_level = end_level - self.add_extra_convs = add_extra_convs - - # add lateral connections - self.lateral_convs = nn.ModuleList() - for i in range(self.start_level, self.backbone_end_level): - l_conv = ConvModule( - in_channels[i], - out_channels, - 1, - norm_cfg=norm_cfg, - activation=None) - self.lateral_convs.append(l_conv) - - # add extra downsample layers (stride-2 pooling or conv) - extra_levels = num_outs - self.backbone_end_level + self.start_level - self.extra_downsamples = nn.ModuleList() - for i in range(extra_levels): - extra_conv = ConvModule( - out_channels, - out_channels, - 1, - norm_cfg=norm_cfg, - activation=None) - self.extra_downsamples.append( - nn.Sequential(extra_conv, nn.MaxPool2d(2, 2))) - - # add NAS FPN connections - self.fpn_stages = nn.ModuleList() - for _ in range(self.stack_times): - stage = nn.ModuleDict() - # gp(p6, p4) -> p4_1 - stage['gp_64_4'] = GPCell(out_channels, norm_cfg=norm_cfg) - # sum(p4_1, p4) -> p4_2 - stage['sum_44_4'] = SumCell(out_channels, norm_cfg=norm_cfg) - # sum(p4_2, p3) -> p3_out - stage['sum_43_3'] = SumCell(out_channels, norm_cfg=norm_cfg) - # sum(p3_out, p4_2) -> p4_out - stage['sum_34_4'] = SumCell(out_channels, norm_cfg=norm_cfg) - # sum(p5, gp(p4_out, p3_out)) -> p5_out - stage['gp_43_5'] = GPCell(with_conv=False) - stage['sum_55_5'] = SumCell(out_channels, norm_cfg=norm_cfg) - # sum(p7, gp(p5_out, p4_2)) -> p7_out - stage['gp_54_7'] = GPCell(with_conv=False) - stage['sum_77_7'] = SumCell(out_channels, norm_cfg=norm_cfg) - # gp(p7_out, p5_out) -> p6_out - stage['gp_75_6'] = GPCell(out_channels, norm_cfg=norm_cfg) - self.fpn_stages.append(stage) - - def init_weights(self): - for m in self.modules(): - if isinstance(m, nn.Conv2d): - caffe2_xavier_init(m) - - def forward(self, inputs): - # build P3-P5 - feats = [ - lateral_conv(inputs[i + self.start_level]) - for i, lateral_conv in enumerate(self.lateral_convs) - ] - # build P6-P7 on top of P5 - for downsample in self.extra_downsamples: - feats.append(downsample(feats[-1])) - - p3, p4, p5, p6, p7 = feats - - for stage in self.fpn_stages: - # gp(p6, p4) -> p4_1 - p4_1 = stage['gp_64_4'](p6, p4, out_size=p4.shape[-2:]) - # sum(p4_1, p4) -> p4_2 - p4_2 = stage['sum_44_4'](p4_1, p4, out_size=p4.shape[-2:]) - # sum(p4_2, p3) -> p3_out - p3 = stage['sum_43_3'](p4_2, p3, out_size=p3.shape[-2:]) - # sum(p3_out, p4_2) -> p4_out - p4 = stage['sum_34_4'](p3, p4_2, out_size=p4.shape[-2:]) - # sum(p5, gp(p4_out, p3_out)) -> p5_out - p5_tmp = stage['gp_43_5'](p4, p3, out_size=p5.shape[-2:]) - p5 = stage['sum_55_5'](p5, p5_tmp, out_size=p5.shape[-2:]) - # sum(p7, gp(p5_out, p4_2)) -> p7_out - p7_tmp = stage['gp_54_7'](p5, p4_2, out_size=p7.shape[-2:]) - p7 = stage['sum_77_7'](p7, p7_tmp, out_size=p7.shape[-2:]) - # gp(p7_out, p5_out) -> p6_out - p6 = stage['gp_75_6'](p7, p5, out_size=p6.shape[-2:]) - - return p3, p4, p5, p6, p7 diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/__init__.py deleted file mode 100644 index 0ff85f2f5..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from .generalized_attention import GeneralizedAttention -from .non_local import NonLocal2D - -__all__ = ['NonLocal2D', 'GeneralizedAttention'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/non_local.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/non_local.py deleted file mode 100644 index 2e89c2fdc..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/plugins/non_local.py +++ /dev/null @@ -1,114 +0,0 @@ -import torch -import torch.nn as nn -from mmcv.cnn import constant_init, normal_init - -from ..utils import ConvModule - - -class NonLocal2D(nn.Module): - """Non-local module. - - See https://arxiv.org/abs/1711.07971 for details. - - Args: - in_channels (int): Channels of the input feature map. - reduction (int): Channel reduction ratio. - use_scale (bool): Whether to scale pairwise_weight by 1/inter_channels. - conv_cfg (dict): The config dict for convolution layers. - (only applicable to conv_out) - norm_cfg (dict): The config dict for normalization layers. - (only applicable to conv_out) - mode (str): Options are `embedded_gaussian` and `dot_product`. - """ - - def __init__(self, - in_channels, - reduction=2, - use_scale=True, - conv_cfg=None, - norm_cfg=None, - mode='embedded_gaussian'): - super(NonLocal2D, self).__init__() - self.in_channels = in_channels - self.reduction = reduction - self.use_scale = use_scale - self.inter_channels = in_channels // reduction - self.mode = mode - assert mode in ['embedded_gaussian', 'dot_product'] - - # g, theta, phi are actually `nn.Conv2d`. Here we use ConvModule for - # potential usage. - self.g = ConvModule( - self.in_channels, - self.inter_channels, - kernel_size=1, - activation=None) - self.theta = ConvModule( - self.in_channels, - self.inter_channels, - kernel_size=1, - activation=None) - self.phi = ConvModule( - self.in_channels, - self.inter_channels, - kernel_size=1, - activation=None) - self.conv_out = ConvModule( - self.inter_channels, - self.in_channels, - kernel_size=1, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg, - activation=None) - - self.init_weights() - - def init_weights(self, std=0.01, zeros_init=True): - for m in [self.g, self.theta, self.phi]: - normal_init(m.conv, std=std) - if zeros_init: - constant_init(self.conv_out.conv, 0) - else: - normal_init(self.conv_out.conv, std=std) - - def embedded_gaussian(self, theta_x, phi_x): - # pairwise_weight: [N, HxW, HxW] - pairwise_weight = torch.matmul(theta_x, phi_x) - if self.use_scale: - # theta_x.shape[-1] is `self.inter_channels` - pairwise_weight /= theta_x.shape[-1]**0.5 - pairwise_weight = pairwise_weight.softmax(dim=-1) - return pairwise_weight - - def dot_product(self, theta_x, phi_x): - # pairwise_weight: [N, HxW, HxW] - pairwise_weight = torch.matmul(theta_x, phi_x) - pairwise_weight /= pairwise_weight.shape[-1] - return pairwise_weight - - def forward(self, x): - n, _, h, w = x.shape - - # g_x: [N, HxW, C] - g_x = self.g(x).view(n, self.inter_channels, -1) - g_x = g_x.permute(0, 2, 1) - - # theta_x: [N, HxW, C] - theta_x = self.theta(x).view(n, self.inter_channels, -1) - theta_x = theta_x.permute(0, 2, 1) - - # phi_x: [N, C, HxW] - phi_x = self.phi(x).view(n, self.inter_channels, -1) - - pairwise_func = getattr(self, self.mode) - # pairwise_weight: [N, HxW, HxW] - pairwise_weight = pairwise_func(theta_x, phi_x) - - # y: [N, HxW, C] - y = torch.matmul(pairwise_weight, g_x) - # y: [N, C, H, W] - y = y.permute(0, 2, 1).reshape(n, self.inter_channels, h, w) - - output = x + self.conv_out(y) - - return output diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/registry.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/registry.py deleted file mode 100644 index 78ef24815..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/registry.py +++ /dev/null @@ -1,9 +0,0 @@ -from mmdet.utils import Registry - -BACKBONES = Registry('backbone') -NECKS = Registry('neck') -ROI_EXTRACTORS = Registry('roi_extractor') -SHARED_HEADS = Registry('shared_head') -HEADS = Registry('head') -LOSSES = Registry('loss') -DETECTORS = Registry('detector') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/roi_extractors/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/roi_extractors/__init__.py deleted file mode 100644 index 9161708ce..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/roi_extractors/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .single_level import SingleRoIExtractor - -__all__ = ['SingleRoIExtractor'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/roi_extractors/single_level.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/roi_extractors/single_level.py deleted file mode 100644 index 6620d1d86..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/roi_extractors/single_level.py +++ /dev/null @@ -1,107 +0,0 @@ -from __future__ import division - -import torch -import torch.nn as nn - -from mmdet import ops -from mmdet.core import force_fp32 -from ..registry import ROI_EXTRACTORS - - -@ROI_EXTRACTORS.register_module -class SingleRoIExtractor(nn.Module): - """Extract RoI features from a single level feature map. - - If there are mulitple input feature levels, each RoI is mapped to a level - according to its scale. - - Args: - roi_layer (dict): Specify RoI layer type and arguments. - out_channels (int): Output channels of RoI layers. - featmap_strides (int): Strides of input feature maps. - finest_scale (int): Scale threshold of mapping to level 0. - """ - - def __init__(self, - roi_layer, - out_channels, - featmap_strides, - finest_scale=56): - super(SingleRoIExtractor, self).__init__() - self.roi_layers = self.build_roi_layers(roi_layer, featmap_strides) - self.out_channels = out_channels - self.featmap_strides = featmap_strides - self.finest_scale = finest_scale - self.fp16_enabled = False - - @property - def num_inputs(self): - """int: Input feature map levels.""" - return len(self.featmap_strides) - - def init_weights(self): - pass - - def build_roi_layers(self, layer_cfg, featmap_strides): - cfg = layer_cfg.copy() - layer_type = cfg.pop('type') - assert hasattr(ops, layer_type) - layer_cls = getattr(ops, layer_type) - roi_layers = nn.ModuleList( - [layer_cls(spatial_scale=1 / s, **cfg) for s in featmap_strides]) - return roi_layers - - def map_roi_levels(self, rois, num_levels): - """Map rois to corresponding feature levels by scales. - - - scale < finest_scale * 2: level 0 - - finest_scale * 2 <= scale < finest_scale * 4: level 1 - - finest_scale * 4 <= scale < finest_scale * 8: level 2 - - scale >= finest_scale * 8: level 3 - - Args: - rois (Tensor): Input RoIs, shape (k, 5). - num_levels (int): Total level number. - - Returns: - Tensor: Level index (0-based) of each RoI, shape (k, ) - """ - scale = torch.sqrt( - (rois[:, 3] - rois[:, 1] + 1) * (rois[:, 4] - rois[:, 2] + 1)) - target_lvls = torch.floor(torch.log2(scale / self.finest_scale + 1e-6)) - target_lvls = target_lvls.clamp(min=0, max=num_levels - 1).long() - return target_lvls - - def roi_rescale(self, rois, scale_factor): - cx = (rois[:, 1] + rois[:, 3]) * 0.5 - cy = (rois[:, 2] + rois[:, 4]) * 0.5 - w = rois[:, 3] - rois[:, 1] + 1 - h = rois[:, 4] - rois[:, 2] + 1 - new_w = w * scale_factor - new_h = h * scale_factor - x1 = cx - new_w * 0.5 + 0.5 - x2 = cx + new_w * 0.5 - 0.5 - y1 = cy - new_h * 0.5 + 0.5 - y2 = cy + new_h * 0.5 - 0.5 - new_rois = torch.stack((rois[:, 0], x1, y1, x2, y2), dim=-1) - return new_rois - - @force_fp32(apply_to=('feats', ), out_fp16=True) - def forward(self, feats, rois, roi_scale_factor=None): - if len(feats) == 1: - return self.roi_layers[0](feats[0], rois) - - out_size = self.roi_layers[0].out_size - num_levels = len(feats) - target_lvls = self.map_roi_levels(rois, num_levels) - roi_feats = feats[0].new_zeros( - rois.size(0), self.out_channels, *out_size) - if roi_scale_factor is not None: - rois = self.roi_rescale(rois, roi_scale_factor) - for i in range(num_levels): - inds = target_lvls == i - if inds.any(): - rois_ = rois[inds, :] - roi_feats_t = self.roi_layers[i](feats[i], rois_) - roi_feats[inds] = roi_feats_t - return roi_feats diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/shared_heads/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/shared_heads/__init__.py deleted file mode 100644 index bbe70145b..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/shared_heads/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .res_layer import ResLayer - -__all__ = ['ResLayer'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/shared_heads/res_layer.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/shared_heads/res_layer.py deleted file mode 100644 index e1a1ba0d7..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/shared_heads/res_layer.py +++ /dev/null @@ -1,71 +0,0 @@ -import torch.nn as nn -from mmcv.cnn import constant_init, kaiming_init -from mmcv.runner import load_checkpoint - -from mmdet.core import auto_fp16 -from mmdet.utils import get_root_logger -from ..backbones import ResNet, make_res_layer -from ..registry import SHARED_HEADS - - -@SHARED_HEADS.register_module -class ResLayer(nn.Module): - - def __init__(self, - depth, - stage=3, - stride=2, - dilation=1, - style='pytorch', - norm_cfg=dict(type='BN', requires_grad=True), - norm_eval=True, - with_cp=False, - dcn=None): - super(ResLayer, self).__init__() - self.norm_eval = norm_eval - self.norm_cfg = norm_cfg - self.stage = stage - self.fp16_enabled = False - block, stage_blocks = ResNet.arch_settings[depth] - stage_block = stage_blocks[stage] - planes = 64 * 2**stage - inplanes = 64 * 2**(stage - 1) * block.expansion - - res_layer = make_res_layer( - block, - inplanes, - planes, - stage_block, - stride=stride, - dilation=dilation, - style=style, - with_cp=with_cp, - norm_cfg=self.norm_cfg, - dcn=dcn) - self.add_module('layer{}'.format(stage + 1), res_layer) - - def init_weights(self, pretrained=None): - if isinstance(pretrained, str): - logger = get_root_logger() - load_checkpoint(self, pretrained, strict=False, logger=logger) - elif pretrained is None: - for m in self.modules(): - if isinstance(m, nn.Conv2d): - kaiming_init(m) - elif isinstance(m, nn.BatchNorm2d): - constant_init(m, 1) - else: - raise TypeError('pretrained must be a str or None') - - @auto_fp16() - def forward(self, x): - res_layer = getattr(self, 'layer{}'.format(self.stage + 1)) - out = res_layer(x) - return out - - def train(self, mode=True): - super(ResLayer, self).train(mode) - if self.norm_eval: - for m in self.modules(): - if isinstance(m, nn.BatchNorm2d): - m.eval() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/__init__.py index 3db40920d..bacd833c0 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/__init__.py @@ -1,12 +1,5 @@ -from .conv_module import ConvModule, build_conv_layer -from .conv_ws import ConvWS2d, conv_ws_2d -from .norm import build_norm_layer -from .scale import Scale -from .weight_init import (bias_init_with_prob, kaiming_init, normal_init, - uniform_init, xavier_init) - +# Copyright (c) OpenMMLab. All rights reserved. +from .res_layer import ResLayer __all__ = [ - 'conv_ws_2d', 'ConvWS2d', 'build_conv_layer', 'ConvModule', - 'build_norm_layer', 'xavier_init', 'normal_init', 'uniform_init', - 'kaiming_init', 'bias_init_with_prob', 'Scale' -] + 'ResLayer'] + diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/conv_ws.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/conv_ws.py deleted file mode 100644 index 5ccd735fd..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/conv_ws.py +++ /dev/null @@ -1,46 +0,0 @@ -import torch.nn as nn -import torch.nn.functional as F - - -def conv_ws_2d(input, - weight, - bias=None, - stride=1, - padding=0, - dilation=1, - groups=1, - eps=1e-5): - c_in = weight.size(0) - weight_flat = weight.view(c_in, -1) - mean = weight_flat.mean(dim=1, keepdim=True).view(c_in, 1, 1, 1) - std = weight_flat.std(dim=1, keepdim=True).view(c_in, 1, 1, 1) - weight = (weight - mean) / (std + eps) - return F.conv2d(input, weight, bias, stride, padding, dilation, groups) - - -class ConvWS2d(nn.Conv2d): - - def __init__(self, - in_channels, - out_channels, - kernel_size, - stride=1, - padding=0, - dilation=1, - groups=1, - bias=True, - eps=1e-5): - super(ConvWS2d, self).__init__( - in_channels, - out_channels, - kernel_size, - stride=stride, - padding=padding, - dilation=dilation, - groups=groups, - bias=bias) - self.eps = eps - - def forward(self, x): - return conv_ws_2d(x, self.weight, self.bias, self.stride, self.padding, - self.dilation, self.groups, self.eps) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/norm.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/norm.py deleted file mode 100644 index d5687cbd9..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/norm.py +++ /dev/null @@ -1,55 +0,0 @@ -import torch.nn as nn - -norm_cfg = { - # format: layer_type: (abbreviation, module) - 'BN': ('bn', nn.BatchNorm2d), - 'SyncBN': ('bn', nn.SyncBatchNorm), - 'GN': ('gn', nn.GroupNorm), - # and potentially 'SN' -} - - -def build_norm_layer(cfg, num_features, postfix=''): - """ Build normalization layer - - Args: - cfg (dict): cfg should contain: - type (str): identify norm layer type. - layer args: args needed to instantiate a norm layer. - requires_grad (bool): [optional] whether stop gradient updates - num_features (int): number of channels from input. - postfix (int, str): appended into norm abbreviation to - create named layer. - - Returns: - name (str): abbreviation + postfix - layer (nn.Module): created norm layer - """ - assert isinstance(cfg, dict) and 'type' in cfg - cfg_ = cfg.copy() - - layer_type = cfg_.pop('type') - if layer_type not in norm_cfg: - raise KeyError('Unrecognized norm type {}'.format(layer_type)) - else: - abbr, norm_layer = norm_cfg[layer_type] - if norm_layer is None: - raise NotImplementedError - - assert isinstance(postfix, (int, str)) - name = abbr + str(postfix) - - requires_grad = cfg_.pop('requires_grad', True) - cfg_.setdefault('eps', 1e-5) - if layer_type != 'GN': - layer = norm_layer(num_features, **cfg_) - if layer_type == 'SyncBN': - layer._specify_ddp_gpu_num(1) - else: - assert 'num_groups' in cfg_ - layer = norm_layer(num_channels=num_features, **cfg_) - - for param in layer.parameters(): - param.requires_grad = requires_grad - - return name, layer diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/res_layer.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/res_layer.py new file mode 100644 index 000000000..5c3e89fb0 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/res_layer.py @@ -0,0 +1,190 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from mmcv.cnn import build_conv_layer, build_norm_layer +from mmcv.runner import BaseModule, Sequential +from torch import nn as nn + + +class ResLayer(Sequential): + """ResLayer to build ResNet style backbone. + + Args: + block (nn.Module): block used to build ResLayer. + inplanes (int): inplanes of block. + planes (int): planes of block. + num_blocks (int): number of blocks. + stride (int): stride of the first block. Default: 1 + avg_down (bool): Use AvgPool instead of stride conv when + downsampling in the bottleneck. Default: False + conv_cfg (dict): dictionary to construct and config conv layer. + Default: None + norm_cfg (dict): dictionary to construct and config norm layer. + Default: dict(type='BN') + downsample_first (bool): Downsample at the first block or last block. + False for Hourglass, True for ResNet. Default: True + """ + + def __init__(self, + block, + inplanes, + planes, + num_blocks, + stride=1, + avg_down=False, + conv_cfg=None, + norm_cfg=dict(type='BN'), + downsample_first=True, + **kwargs): + self.block = block + + downsample = None + if stride != 1 or inplanes != planes * block.expansion: + downsample = [] + conv_stride = stride + if avg_down: + conv_stride = 1 + downsample.append( + nn.AvgPool2d( + kernel_size=stride, + stride=stride, + ceil_mode=True, + count_include_pad=False)) + downsample.extend([ + build_conv_layer( + conv_cfg, + inplanes, + planes * block.expansion, + kernel_size=1, + stride=conv_stride, + bias=False), + build_norm_layer(norm_cfg, planes * block.expansion)[1] + ]) + downsample = nn.Sequential(*downsample) + + layers = [] + if downsample_first: + layers.append( + block( + inplanes=inplanes, + planes=planes, + stride=stride, + downsample=downsample, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + **kwargs)) + inplanes = planes * block.expansion + for _ in range(1, num_blocks): + layers.append( + block( + inplanes=inplanes, + planes=planes, + stride=1, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + **kwargs)) + + else: # downsample_first=False is for HourglassModule + for _ in range(num_blocks - 1): + layers.append( + block( + inplanes=inplanes, + planes=inplanes, + stride=1, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + **kwargs)) + layers.append( + block( + inplanes=inplanes, + planes=planes, + stride=stride, + downsample=downsample, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + **kwargs)) + super(ResLayer, self).__init__(*layers) + + +class SimplifiedBasicBlock(BaseModule): + """Simplified version of original basic residual block. This is used in + `SCNet `_. + + - Norm layer is now optional + - Last ReLU in forward function is removed + """ + expansion = 1 + + def __init__(self, + inplanes, + planes, + stride=1, + dilation=1, + downsample=None, + style='pytorch', + with_cp=False, + conv_cfg=None, + norm_cfg=dict(type='BN'), + dcn=None, + plugins=None, + init_fg=None): + super(SimplifiedBasicBlock, self).__init__(init_fg) + assert dcn is None, 'Not implemented yet.' + assert plugins is None, 'Not implemented yet.' + assert not with_cp, 'Not implemented yet.' + self.with_norm = norm_cfg is not None + with_bias = True if norm_cfg is None else False + self.conv1 = build_conv_layer( + conv_cfg, + inplanes, + planes, + 3, + stride=stride, + padding=dilation, + dilation=dilation, + bias=with_bias) + if self.with_norm: + self.norm1_name, norm1 = build_norm_layer( + norm_cfg, planes, postfix=1) + self.add_module(self.norm1_name, norm1) + self.conv2 = build_conv_layer( + conv_cfg, planes, planes, 3, padding=1, bias=with_bias) + if self.with_norm: + self.norm2_name, norm2 = build_norm_layer( + norm_cfg, planes, postfix=2) + self.add_module(self.norm2_name, norm2) + + self.relu = nn.ReLU(inplace=True) + self.downsample = downsample + self.stride = stride + self.dilation = dilation + self.with_cp = with_cp + + @property + def norm1(self): + """nn.Module: normalization layer after the first convolution layer""" + return getattr(self, self.norm1_name) if self.with_norm else None + + @property + def norm2(self): + """nn.Module: normalization layer after the second convolution layer""" + return getattr(self, self.norm2_name) if self.with_norm else None + + def forward(self, x): + """Forward function.""" + + identity = x + + out = self.conv1(x) + if self.with_norm: + out = self.norm1(out) + out = self.relu(out) + + out = self.conv2(out) + if self.with_norm: + out = self.norm2(out) + + if self.downsample is not None: + identity = self.downsample(x) + + out += identity + + return out diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/weight_init.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/weight_init.py deleted file mode 100644 index 17d49880f..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/models/utils/weight_init.py +++ /dev/null @@ -1,46 +0,0 @@ -import numpy as np -import torch.nn as nn - - -def xavier_init(module, gain=1, bias=0, distribution='normal'): - assert distribution in ['uniform', 'normal'] - if distribution == 'uniform': - nn.init.xavier_uniform_(module.weight, gain=gain) - else: - nn.init.xavier_normal_(module.weight, gain=gain) - if hasattr(module, 'bias'): - nn.init.constant_(module.bias, bias) - - -def normal_init(module, mean=0, std=1, bias=0): - nn.init.normal_(module.weight, mean, std) - if hasattr(module, 'bias'): - nn.init.constant_(module.bias, bias) - - -def uniform_init(module, a=0, b=1, bias=0): - nn.init.uniform_(module.weight, a, b) - if hasattr(module, 'bias'): - nn.init.constant_(module.bias, bias) - - -def kaiming_init(module, - mode='fan_out', - nonlinearity='relu', - bias=0, - distribution='normal'): - assert distribution in ['uniform', 'normal'] - if distribution == 'uniform': - nn.init.kaiming_uniform_( - module.weight, mode=mode, nonlinearity=nonlinearity) - else: - nn.init.kaiming_normal_( - module.weight, mode=mode, nonlinearity=nonlinearity) - if hasattr(module, 'bias'): - nn.init.constant_(module.bias, bias) - - -def bias_init_with_prob(prior_prob): - """ initialize conv/fc bias value according to giving probablity""" - bias_init = float(-np.log((1 - prior_prob) / prior_prob)) - return bias_init diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/__init__.py deleted file mode 100644 index 5c6a1f37c..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -from .context_block import ContextBlock -from .dcn import (DeformConv, DeformConvPack, DeformRoIPooling, - DeformRoIPoolingPack, ModulatedDeformConv, - ModulatedDeformConvPack, ModulatedDeformRoIPoolingPack, - deform_conv, deform_roi_pooling, modulated_deform_conv) -from .masked_conv import MaskedConv2d -from .nms import nms, soft_nms -from .roi_align import RoIAlign, roi_align -from .roi_pool import RoIPool, roi_pool -from .sigmoid_focal_loss import SigmoidFocalLoss, sigmoid_focal_loss -from .utils import get_compiler_version, get_compiling_cuda_version - -__all__ = [ - 'nms', 'soft_nms', 'RoIAlign', 'roi_align', 'RoIPool', 'roi_pool', - 'DeformConv', 'DeformConvPack', 'DeformRoIPooling', 'DeformRoIPoolingPack', - 'ModulatedDeformRoIPoolingPack', 'ModulatedDeformConv', - 'ModulatedDeformConvPack', 'deform_conv', 'modulated_deform_conv', - 'deform_roi_pooling', 'SigmoidFocalLoss', 'sigmoid_focal_loss', - 'MaskedConv2d', 'ContextBlock', 'get_compiler_version', - 'get_compiling_cuda_version' -] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/__init__.py deleted file mode 100644 index 79594c90b..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/__init__.py +++ /dev/null @@ -1,12 +0,0 @@ -from .deform_conv import (DeformConv, DeformConvPack, ModulatedDeformConv, - ModulatedDeformConvPack, deform_conv, - modulated_deform_conv) -from .deform_pool import (DeformRoIPooling, DeformRoIPoolingPack, - ModulatedDeformRoIPoolingPack, deform_roi_pooling) - -__all__ = [ - 'DeformConv', 'DeformConvPack', 'ModulatedDeformConv', - 'ModulatedDeformConvPack', 'DeformRoIPooling', 'DeformRoIPoolingPack', - 'ModulatedDeformRoIPoolingPack', 'deform_conv', 'modulated_deform_conv', - 'deform_roi_pooling' -] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/deform_conv.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/deform_conv.py deleted file mode 100644 index 5ba5a5e8f..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/deform_conv.py +++ /dev/null @@ -1,431 +0,0 @@ -import math - -import torch -import torch.nn as nn -from torch.autograd import Function -from torch.autograd.function import once_differentiable -from torch.nn.modules.utils import _pair, _single - -from mmdet.utils import print_log -from . import deform_conv_cuda - - -class DeformConvFunction(Function): - - @staticmethod - def forward(ctx, - input, - offset, - weight, - stride=1, - padding=0, - dilation=1, - groups=1, - deformable_groups=1, - im2col_step=64): - if input is not None and input.dim() != 4: - raise ValueError( - 'Expected 4D tensor as input, got {}D tensor instead.'.format( - input.dim())) - ctx.stride = _pair(stride) - ctx.padding = _pair(padding) - ctx.dilation = _pair(dilation) - ctx.groups = groups - ctx.deformable_groups = deformable_groups - ctx.im2col_step = im2col_step - - ctx.save_for_backward(input, offset, weight) - - output = input.new_empty( - DeformConvFunction._output_size(input, weight, ctx.padding, - ctx.dilation, ctx.stride)) - - ctx.bufs_ = [input.new_empty(0), input.new_empty(0)] # columns, ones - - if not input.is_cuda: - raise NotImplementedError - else: - cur_im2col_step = min(ctx.im2col_step, input.shape[0]) - assert (input.shape[0] % - cur_im2col_step) == 0, 'im2col step must divide batchsize' - deform_conv_cuda.deform_conv_forward_cuda( - input, weight, offset, output, ctx.bufs_[0], ctx.bufs_[1], - weight.size(3), weight.size(2), ctx.stride[1], ctx.stride[0], - ctx.padding[1], ctx.padding[0], ctx.dilation[1], - ctx.dilation[0], ctx.groups, ctx.deformable_groups, - cur_im2col_step) - return output - - @staticmethod - @once_differentiable - def backward(ctx, grad_output): - input, offset, weight = ctx.saved_tensors - - grad_input = grad_offset = grad_weight = None - - if not grad_output.is_cuda: - raise NotImplementedError - else: - cur_im2col_step = min(ctx.im2col_step, input.shape[0]) - assert (input.shape[0] % - cur_im2col_step) == 0, 'im2col step must divide batchsize' - - if ctx.needs_input_grad[0] or ctx.needs_input_grad[1]: - grad_input = torch.zeros_like(input) - grad_offset = torch.zeros_like(offset) - deform_conv_cuda.deform_conv_backward_input_cuda( - input, offset, grad_output, grad_input, - grad_offset, weight, ctx.bufs_[0], weight.size(3), - weight.size(2), ctx.stride[1], ctx.stride[0], - ctx.padding[1], ctx.padding[0], ctx.dilation[1], - ctx.dilation[0], ctx.groups, ctx.deformable_groups, - cur_im2col_step) - - if ctx.needs_input_grad[2]: - grad_weight = torch.zeros_like(weight) - deform_conv_cuda.deform_conv_backward_parameters_cuda( - input, offset, grad_output, - grad_weight, ctx.bufs_[0], ctx.bufs_[1], weight.size(3), - weight.size(2), ctx.stride[1], ctx.stride[0], - ctx.padding[1], ctx.padding[0], ctx.dilation[1], - ctx.dilation[0], ctx.groups, ctx.deformable_groups, 1, - cur_im2col_step) - - return (grad_input, grad_offset, grad_weight, None, None, None, None, - None) - - @staticmethod - def _output_size(input, weight, padding, dilation, stride): - channels = weight.size(0) - output_size = (input.size(0), channels) - for d in range(input.dim() - 2): - in_size = input.size(d + 2) - pad = padding[d] - kernel = dilation[d] * (weight.size(d + 2) - 1) + 1 - stride_ = stride[d] - output_size += ((in_size + (2 * pad) - kernel) // stride_ + 1, ) - if not all(map(lambda s: s > 0, output_size)): - raise ValueError( - 'convolution input is too small (output would be {})'.format( - 'x'.join(map(str, output_size)))) - return output_size - - -class ModulatedDeformConvFunction(Function): - - @staticmethod - def forward(ctx, - input, - offset, - mask, - weight, - bias=None, - stride=1, - padding=0, - dilation=1, - groups=1, - deformable_groups=1): - ctx.stride = stride - ctx.padding = padding - ctx.dilation = dilation - ctx.groups = groups - ctx.deformable_groups = deformable_groups - ctx.with_bias = bias is not None - if not ctx.with_bias: - bias = input.new_empty(1) # fake tensor - if not input.is_cuda: - raise NotImplementedError - if weight.requires_grad or mask.requires_grad or offset.requires_grad \ - or input.requires_grad: - ctx.save_for_backward(input, offset, mask, weight, bias) - output = input.new_empty( - ModulatedDeformConvFunction._infer_shape(ctx, input, weight)) - ctx._bufs = [input.new_empty(0), input.new_empty(0)] - deform_conv_cuda.modulated_deform_conv_cuda_forward( - input, weight, bias, ctx._bufs[0], offset, mask, output, - ctx._bufs[1], weight.shape[2], weight.shape[3], ctx.stride, - ctx.stride, ctx.padding, ctx.padding, ctx.dilation, ctx.dilation, - ctx.groups, ctx.deformable_groups, ctx.with_bias) - return output - - @staticmethod - @once_differentiable - def backward(ctx, grad_output): - if not grad_output.is_cuda: - raise NotImplementedError - input, offset, mask, weight, bias = ctx.saved_tensors - grad_input = torch.zeros_like(input) - grad_offset = torch.zeros_like(offset) - grad_mask = torch.zeros_like(mask) - grad_weight = torch.zeros_like(weight) - grad_bias = torch.zeros_like(bias) - deform_conv_cuda.modulated_deform_conv_cuda_backward( - input, weight, bias, ctx._bufs[0], offset, mask, ctx._bufs[1], - grad_input, grad_weight, grad_bias, grad_offset, grad_mask, - grad_output, weight.shape[2], weight.shape[3], ctx.stride, - ctx.stride, ctx.padding, ctx.padding, ctx.dilation, ctx.dilation, - ctx.groups, ctx.deformable_groups, ctx.with_bias) - if not ctx.with_bias: - grad_bias = None - - return (grad_input, grad_offset, grad_mask, grad_weight, grad_bias, - None, None, None, None, None) - - @staticmethod - def _infer_shape(ctx, input, weight): - n = input.size(0) - channels_out = weight.size(0) - height, width = input.shape[2:4] - kernel_h, kernel_w = weight.shape[2:4] - height_out = (height + 2 * ctx.padding - - (ctx.dilation * (kernel_h - 1) + 1)) // ctx.stride + 1 - width_out = (width + 2 * ctx.padding - - (ctx.dilation * (kernel_w - 1) + 1)) // ctx.stride + 1 - return n, channels_out, height_out, width_out - - -deform_conv = DeformConvFunction.apply -modulated_deform_conv = ModulatedDeformConvFunction.apply - - -class DeformConv(nn.Module): - - def __init__(self, - in_channels, - out_channels, - kernel_size, - stride=1, - padding=0, - dilation=1, - groups=1, - deformable_groups=1, - bias=False): - super(DeformConv, self).__init__() - - assert not bias - assert in_channels % groups == 0, \ - 'in_channels {} cannot be divisible by groups {}'.format( - in_channels, groups) - assert out_channels % groups == 0, \ - 'out_channels {} cannot be divisible by groups {}'.format( - out_channels, groups) - - self.in_channels = in_channels - self.out_channels = out_channels - self.kernel_size = _pair(kernel_size) - self.stride = _pair(stride) - self.padding = _pair(padding) - self.dilation = _pair(dilation) - self.groups = groups - self.deformable_groups = deformable_groups - # enable compatibility with nn.Conv2d - self.transposed = False - self.output_padding = _single(0) - - self.weight = nn.Parameter( - torch.Tensor(out_channels, in_channels // self.groups, - *self.kernel_size)) - - self.reset_parameters() - - def reset_parameters(self): - n = self.in_channels - for k in self.kernel_size: - n *= k - stdv = 1. / math.sqrt(n) - self.weight.data.uniform_(-stdv, stdv) - - def forward(self, x, offset): - return deform_conv(x, offset, self.weight, self.stride, self.padding, - self.dilation, self.groups, self.deformable_groups) - - -class DeformConvPack(DeformConv): - """A Deformable Conv Encapsulation that acts as normal Conv layers. - - Args: - in_channels (int): Same as nn.Conv2d. - out_channels (int): Same as nn.Conv2d. - kernel_size (int or tuple[int]): Same as nn.Conv2d. - stride (int or tuple[int]): Same as nn.Conv2d. - padding (int or tuple[int]): Same as nn.Conv2d. - dilation (int or tuple[int]): Same as nn.Conv2d. - groups (int): Same as nn.Conv2d. - bias (bool or str): If specified as `auto`, it will be decided by the - norm_cfg. Bias will be set as True if norm_cfg is None, otherwise - False. - """ - - _version = 2 - - def __init__(self, *args, **kwargs): - super(DeformConvPack, self).__init__(*args, **kwargs) - - self.conv_offset = nn.Conv2d( - self.in_channels, - self.deformable_groups * 2 * self.kernel_size[0] * - self.kernel_size[1], - kernel_size=self.kernel_size, - stride=_pair(self.stride), - padding=_pair(self.padding), - bias=True) - self.init_offset() - - def init_offset(self): - self.conv_offset.weight.data.zero_() - self.conv_offset.bias.data.zero_() - - def forward(self, x): - offset = self.conv_offset(x) - return deform_conv(x, offset, self.weight, self.stride, self.padding, - self.dilation, self.groups, self.deformable_groups) - - def _load_from_state_dict(self, state_dict, prefix, local_metadata, strict, - missing_keys, unexpected_keys, error_msgs): - version = local_metadata.get('version', None) - - if version is None or version < 2: - # the key is different in early versions - # In version < 2, DeformConvPack loads previous benchmark models. - if (prefix + 'conv_offset.weight' not in state_dict - and prefix[:-1] + '_offset.weight' in state_dict): - state_dict[prefix + 'conv_offset.weight'] = state_dict.pop( - prefix[:-1] + '_offset.weight') - if (prefix + 'conv_offset.bias' not in state_dict - and prefix[:-1] + '_offset.bias' in state_dict): - state_dict[prefix + - 'conv_offset.bias'] = state_dict.pop(prefix[:-1] + - '_offset.bias') - - if version is not None and version > 1: - print_log( - 'DeformConvPack {} is upgraded to version 2.'.format( - prefix.rstrip('.')), - logger='root') - - super()._load_from_state_dict(state_dict, prefix, local_metadata, - strict, missing_keys, unexpected_keys, - error_msgs) - - -class ModulatedDeformConv(nn.Module): - - def __init__(self, - in_channels, - out_channels, - kernel_size, - stride=1, - padding=0, - dilation=1, - groups=1, - deformable_groups=1, - bias=True): - super(ModulatedDeformConv, self).__init__() - self.in_channels = in_channels - self.out_channels = out_channels - self.kernel_size = _pair(kernel_size) - self.stride = stride - self.padding = padding - self.dilation = dilation - self.groups = groups - self.deformable_groups = deformable_groups - self.with_bias = bias - # enable compatibility with nn.Conv2d - self.transposed = False - self.output_padding = _single(0) - - self.weight = nn.Parameter( - torch.Tensor(out_channels, in_channels // groups, - *self.kernel_size)) - if bias: - self.bias = nn.Parameter(torch.Tensor(out_channels)) - else: - self.register_parameter('bias', None) - self.reset_parameters() - - def reset_parameters(self): - n = self.in_channels - for k in self.kernel_size: - n *= k - stdv = 1. / math.sqrt(n) - self.weight.data.uniform_(-stdv, stdv) - if self.bias is not None: - self.bias.data.zero_() - - def forward(self, x, offset, mask): - return modulated_deform_conv(x, offset, mask, self.weight, self.bias, - self.stride, self.padding, self.dilation, - self.groups, self.deformable_groups) - - -class ModulatedDeformConvPack(ModulatedDeformConv): - """A ModulatedDeformable Conv Encapsulation that acts as normal Conv layers. - - Args: - in_channels (int): Same as nn.Conv2d. - out_channels (int): Same as nn.Conv2d. - kernel_size (int or tuple[int]): Same as nn.Conv2d. - stride (int or tuple[int]): Same as nn.Conv2d. - padding (int or tuple[int]): Same as nn.Conv2d. - dilation (int or tuple[int]): Same as nn.Conv2d. - groups (int): Same as nn.Conv2d. - bias (bool or str): If specified as `auto`, it will be decided by the - norm_cfg. Bias will be set as True if norm_cfg is None, otherwise - False. - """ - - _version = 2 - - def __init__(self, *args, **kwargs): - super(ModulatedDeformConvPack, self).__init__(*args, **kwargs) - - self.conv_offset = nn.Conv2d( - self.in_channels, - self.deformable_groups * 3 * self.kernel_size[0] * - self.kernel_size[1], - kernel_size=self.kernel_size, - stride=_pair(self.stride), - padding=_pair(self.padding), - bias=True) - self.init_offset() - - def init_offset(self): - self.conv_offset.weight.data.zero_() - self.conv_offset.bias.data.zero_() - - def forward(self, x): - out = self.conv_offset(x) - o1, o2, mask = torch.chunk(out, 3, dim=1) - offset = torch.cat((o1, o2), dim=1) - mask = torch.sigmoid(mask) - return modulated_deform_conv(x, offset, mask, self.weight, self.bias, - self.stride, self.padding, self.dilation, - self.groups, self.deformable_groups) - - def _load_from_state_dict(self, state_dict, prefix, local_metadata, strict, - missing_keys, unexpected_keys, error_msgs): - version = local_metadata.get('version', None) - - if version is None or version < 2: - # the key is different in early versions - # In version < 2, ModulatedDeformConvPack - # loads previous benchmark models. - if (prefix + 'conv_offset.weight' not in state_dict - and prefix[:-1] + '_offset.weight' in state_dict): - state_dict[prefix + 'conv_offset.weight'] = state_dict.pop( - prefix[:-1] + '_offset.weight') - if (prefix + 'conv_offset.bias' not in state_dict - and prefix[:-1] + '_offset.bias' in state_dict): - state_dict[prefix + - 'conv_offset.bias'] = state_dict.pop(prefix[:-1] + - '_offset.bias') - - if version is not None and version > 1: - print_log( - 'ModulatedDeformConvPack {} is upgraded to version 2.'.format( - prefix.rstrip('.')), - logger='root') - - super()._load_from_state_dict(state_dict, prefix, local_metadata, - strict, missing_keys, unexpected_keys, - error_msgs) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/deform_pool.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/deform_pool.py deleted file mode 100644 index 99a4a3618..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/deform_pool.py +++ /dev/null @@ -1,252 +0,0 @@ -import torch -import torch.nn as nn -from torch.autograd import Function -from torch.autograd.function import once_differentiable -from torch.nn.modules.utils import _pair - -from . import deform_pool_cuda - - -class DeformRoIPoolingFunction(Function): - - @staticmethod - def forward(ctx, - data, - rois, - offset, - spatial_scale, - out_size, - out_channels, - no_trans, - group_size=1, - part_size=None, - sample_per_part=4, - trans_std=.0): - # TODO: support unsquare RoIs - out_h, out_w = _pair(out_size) - assert isinstance(out_h, int) and isinstance(out_w, int) - assert out_h == out_w - out_size = out_h # out_h and out_w must be equal - - ctx.spatial_scale = spatial_scale - ctx.out_size = out_size - ctx.out_channels = out_channels - ctx.no_trans = no_trans - ctx.group_size = group_size - ctx.part_size = out_size if part_size is None else part_size - ctx.sample_per_part = sample_per_part - ctx.trans_std = trans_std - - assert 0.0 <= ctx.trans_std <= 1.0 - if not data.is_cuda: - raise NotImplementedError - - n = rois.shape[0] - output = data.new_empty(n, out_channels, out_size, out_size) - output_count = data.new_empty(n, out_channels, out_size, out_size) - deform_pool_cuda.deform_psroi_pooling_cuda_forward( - data, rois, offset, output, output_count, ctx.no_trans, - ctx.spatial_scale, ctx.out_channels, ctx.group_size, ctx.out_size, - ctx.part_size, ctx.sample_per_part, ctx.trans_std) - - if data.requires_grad or rois.requires_grad or offset.requires_grad: - ctx.save_for_backward(data, rois, offset) - ctx.output_count = output_count - - return output - - @staticmethod - @once_differentiable - def backward(ctx, grad_output): - if not grad_output.is_cuda: - raise NotImplementedError - - data, rois, offset = ctx.saved_tensors - output_count = ctx.output_count - grad_input = torch.zeros_like(data) - grad_rois = None - grad_offset = torch.zeros_like(offset) - - deform_pool_cuda.deform_psroi_pooling_cuda_backward( - grad_output, data, rois, offset, output_count, grad_input, - grad_offset, ctx.no_trans, ctx.spatial_scale, ctx.out_channels, - ctx.group_size, ctx.out_size, ctx.part_size, ctx.sample_per_part, - ctx.trans_std) - return (grad_input, grad_rois, grad_offset, None, None, None, None, - None, None, None, None) - - -deform_roi_pooling = DeformRoIPoolingFunction.apply - - -class DeformRoIPooling(nn.Module): - - def __init__(self, - spatial_scale, - out_size, - out_channels, - no_trans, - group_size=1, - part_size=None, - sample_per_part=4, - trans_std=.0): - super(DeformRoIPooling, self).__init__() - self.spatial_scale = spatial_scale - self.out_size = _pair(out_size) - self.out_channels = out_channels - self.no_trans = no_trans - self.group_size = group_size - self.part_size = out_size if part_size is None else part_size - self.sample_per_part = sample_per_part - self.trans_std = trans_std - - def forward(self, data, rois, offset): - if self.no_trans: - offset = data.new_empty(0) - return deform_roi_pooling(data, rois, offset, self.spatial_scale, - self.out_size, self.out_channels, - self.no_trans, self.group_size, - self.part_size, self.sample_per_part, - self.trans_std) - - -class DeformRoIPoolingPack(DeformRoIPooling): - - def __init__(self, - spatial_scale, - out_size, - out_channels, - no_trans, - group_size=1, - part_size=None, - sample_per_part=4, - trans_std=.0, - num_offset_fcs=3, - deform_fc_channels=1024): - super(DeformRoIPoolingPack, - self).__init__(spatial_scale, out_size, out_channels, no_trans, - group_size, part_size, sample_per_part, trans_std) - - self.num_offset_fcs = num_offset_fcs - self.deform_fc_channels = deform_fc_channels - - if not no_trans: - seq = [] - ic = self.out_size[0] * self.out_size[1] * self.out_channels - for i in range(self.num_offset_fcs): - if i < self.num_offset_fcs - 1: - oc = self.deform_fc_channels - else: - oc = self.out_size[0] * self.out_size[1] * 2 - seq.append(nn.Linear(ic, oc)) - ic = oc - if i < self.num_offset_fcs - 1: - seq.append(nn.ReLU(inplace=True)) - self.offset_fc = nn.Sequential(*seq) - self.offset_fc[-1].weight.data.zero_() - self.offset_fc[-1].bias.data.zero_() - - def forward(self, data, rois): - assert data.size(1) == self.out_channels - if self.no_trans: - offset = data.new_empty(0) - return deform_roi_pooling(data, rois, offset, self.spatial_scale, - self.out_size, self.out_channels, - self.no_trans, self.group_size, - self.part_size, self.sample_per_part, - self.trans_std) - else: - n = rois.shape[0] - offset = data.new_empty(0) - x = deform_roi_pooling(data, rois, offset, self.spatial_scale, - self.out_size, self.out_channels, True, - self.group_size, self.part_size, - self.sample_per_part, self.trans_std) - offset = self.offset_fc(x.view(n, -1)) - offset = offset.view(n, 2, self.out_size[0], self.out_size[1]) - return deform_roi_pooling(data, rois, offset, self.spatial_scale, - self.out_size, self.out_channels, - self.no_trans, self.group_size, - self.part_size, self.sample_per_part, - self.trans_std) - - -class ModulatedDeformRoIPoolingPack(DeformRoIPooling): - - def __init__(self, - spatial_scale, - out_size, - out_channels, - no_trans, - group_size=1, - part_size=None, - sample_per_part=4, - trans_std=.0, - num_offset_fcs=3, - num_mask_fcs=2, - deform_fc_channels=1024): - super(ModulatedDeformRoIPoolingPack, - self).__init__(spatial_scale, out_size, out_channels, no_trans, - group_size, part_size, sample_per_part, trans_std) - - self.num_offset_fcs = num_offset_fcs - self.num_mask_fcs = num_mask_fcs - self.deform_fc_channels = deform_fc_channels - - if not no_trans: - offset_fc_seq = [] - ic = self.out_size[0] * self.out_size[1] * self.out_channels - for i in range(self.num_offset_fcs): - if i < self.num_offset_fcs - 1: - oc = self.deform_fc_channels - else: - oc = self.out_size[0] * self.out_size[1] * 2 - offset_fc_seq.append(nn.Linear(ic, oc)) - ic = oc - if i < self.num_offset_fcs - 1: - offset_fc_seq.append(nn.ReLU(inplace=True)) - self.offset_fc = nn.Sequential(*offset_fc_seq) - self.offset_fc[-1].weight.data.zero_() - self.offset_fc[-1].bias.data.zero_() - - mask_fc_seq = [] - ic = self.out_size[0] * self.out_size[1] * self.out_channels - for i in range(self.num_mask_fcs): - if i < self.num_mask_fcs - 1: - oc = self.deform_fc_channels - else: - oc = self.out_size[0] * self.out_size[1] - mask_fc_seq.append(nn.Linear(ic, oc)) - ic = oc - if i < self.num_mask_fcs - 1: - mask_fc_seq.append(nn.ReLU(inplace=True)) - else: - mask_fc_seq.append(nn.Sigmoid()) - self.mask_fc = nn.Sequential(*mask_fc_seq) - self.mask_fc[-2].weight.data.zero_() - self.mask_fc[-2].bias.data.zero_() - - def forward(self, data, rois): - assert data.size(1) == self.out_channels - if self.no_trans: - offset = data.new_empty(0) - return deform_roi_pooling(data, rois, offset, self.spatial_scale, - self.out_size, self.out_channels, - self.no_trans, self.group_size, - self.part_size, self.sample_per_part, - self.trans_std) - else: - n = rois.shape[0] - offset = data.new_empty(0) - x = deform_roi_pooling(data, rois, offset, self.spatial_scale, - self.out_size, self.out_channels, True, - self.group_size, self.part_size, - self.sample_per_part, self.trans_std) - offset = self.offset_fc(x.view(n, -1)) - offset = offset.view(n, 2, self.out_size[0], self.out_size[1]) - mask = self.mask_fc(x.view(n, -1)) - mask = mask.view(n, 1, self.out_size[0], self.out_size[1]) - return deform_roi_pooling( - data, rois, offset, self.spatial_scale, self.out_size, - self.out_channels, self.no_trans, self.group_size, - self.part_size, self.sample_per_part, self.trans_std) * mask diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_conv_cuda.cpp b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_conv_cuda.cpp deleted file mode 100644 index ffe740dba..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_conv_cuda.cpp +++ /dev/null @@ -1,701 +0,0 @@ -// modify from -// https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/mmdetection/mmdet/ops/dcn/src/deform_conv_cuda.c - -#include -#include - -#include -#include - -void deformable_im2col(const at::Tensor data_im, const at::Tensor data_offset, - const int channels, const int height, const int width, - const int ksize_h, const int ksize_w, const int pad_h, - const int pad_w, const int stride_h, const int stride_w, - const int dilation_h, const int dilation_w, - const int parallel_imgs, const int deformable_group, - at::Tensor data_col); - -void deformable_col2im(const at::Tensor data_col, const at::Tensor data_offset, - const int channels, const int height, const int width, - const int ksize_h, const int ksize_w, const int pad_h, - const int pad_w, const int stride_h, const int stride_w, - const int dilation_h, const int dilation_w, - const int parallel_imgs, const int deformable_group, - at::Tensor grad_im); - -void deformable_col2im_coord( - const at::Tensor data_col, const at::Tensor data_im, - const at::Tensor data_offset, const int channels, const int height, - const int width, const int ksize_h, const int ksize_w, const int pad_h, - const int pad_w, const int stride_h, const int stride_w, - const int dilation_h, const int dilation_w, const int parallel_imgs, - const int deformable_group, at::Tensor grad_offset); - -void modulated_deformable_im2col_cuda( - const at::Tensor data_im, const at::Tensor data_offset, - const at::Tensor data_mask, const int batch_size, const int channels, - const int height_im, const int width_im, const int height_col, - const int width_col, const int kernel_h, const int kenerl_w, - const int pad_h, const int pad_w, const int stride_h, const int stride_w, - const int dilation_h, const int dilation_w, const int deformable_group, - at::Tensor data_col); - -void modulated_deformable_col2im_cuda( - const at::Tensor data_col, const at::Tensor data_offset, - const at::Tensor data_mask, const int batch_size, const int channels, - const int height_im, const int width_im, const int height_col, - const int width_col, const int kernel_h, const int kenerl_w, - const int pad_h, const int pad_w, const int stride_h, const int stride_w, - const int dilation_h, const int dilation_w, const int deformable_group, - at::Tensor grad_im); - -void modulated_deformable_col2im_coord_cuda( - const at::Tensor data_col, const at::Tensor data_im, - const at::Tensor data_offset, const at::Tensor data_mask, - const int batch_size, const int channels, const int height_im, - const int width_im, const int height_col, const int width_col, - const int kernel_h, const int kenerl_w, const int pad_h, const int pad_w, - const int stride_h, const int stride_w, const int dilation_h, - const int dilation_w, const int deformable_group, at::Tensor grad_offset, - at::Tensor grad_mask); - -void shape_check(at::Tensor input, at::Tensor offset, at::Tensor *gradOutput, - at::Tensor weight, int kH, int kW, int dH, int dW, int padH, - int padW, int dilationH, int dilationW, int group, - int deformable_group) { - TORCH_CHECK(weight.ndimension() == 4, - "4D weight tensor (nOutputPlane,nInputPlane,kH,kW) expected, " - "but got: %s", - weight.ndimension()); - - TORCH_CHECK(weight.is_contiguous(), "weight tensor has to be contiguous"); - - TORCH_CHECK(kW > 0 && kH > 0, - "kernel size should be greater than zero, but got kH: %d kW: %d", kH, - kW); - - TORCH_CHECK((weight.size(2) == kH && weight.size(3) == kW), - "kernel size should be consistent with weight, ", - "but got kH: %d kW: %d weight.size(2): %d, weight.size(3): %d", kH, - kW, weight.size(2), weight.size(3)); - - TORCH_CHECK(dW > 0 && dH > 0, - "stride should be greater than zero, but got dH: %d dW: %d", dH, dW); - - TORCH_CHECK( - dilationW > 0 && dilationH > 0, - "dilation should be greater than 0, but got dilationH: %d dilationW: %d", - dilationH, dilationW); - - int ndim = input.ndimension(); - int dimf = 0; - int dimh = 1; - int dimw = 2; - - if (ndim == 4) { - dimf++; - dimh++; - dimw++; - } - - TORCH_CHECK(ndim == 3 || ndim == 4, "3D or 4D input tensor expected but got: %s", - ndim); - - long nInputPlane = weight.size(1) * group; - long inputHeight = input.size(dimh); - long inputWidth = input.size(dimw); - long nOutputPlane = weight.size(0); - long outputHeight = - (inputHeight + 2 * padH - (dilationH * (kH - 1) + 1)) / dH + 1; - long outputWidth = - (inputWidth + 2 * padW - (dilationW * (kW - 1) + 1)) / dW + 1; - - TORCH_CHECK(nInputPlane % deformable_group == 0, - "input channels must divide deformable group size"); - - if (outputWidth < 1 || outputHeight < 1) - AT_ERROR( - "Given input size: (%ld x %ld x %ld). " - "Calculated output size: (%ld x %ld x %ld). Output size is too small", - nInputPlane, inputHeight, inputWidth, nOutputPlane, outputHeight, - outputWidth); - - TORCH_CHECK(input.size(1) == nInputPlane, - "invalid number of input planes, expected: %d, but got: %d", - nInputPlane, input.size(1)); - - TORCH_CHECK((inputHeight >= kH && inputWidth >= kW), - "input image is smaller than kernel"); - - TORCH_CHECK((offset.size(2) == outputHeight && offset.size(3) == outputWidth), - "invalid spatial size of offset, expected height: %d width: %d, but " - "got height: %d width: %d", - outputHeight, outputWidth, offset.size(2), offset.size(3)); - - TORCH_CHECK((offset.size(1) == deformable_group * 2 * kH * kW), - "invalid number of channels of offset"); - - if (gradOutput != NULL) { - TORCH_CHECK(gradOutput->size(dimf) == nOutputPlane, - "invalid number of gradOutput planes, expected: %d, but got: %d", - nOutputPlane, gradOutput->size(dimf)); - - TORCH_CHECK((gradOutput->size(dimh) == outputHeight && - gradOutput->size(dimw) == outputWidth), - "invalid size of gradOutput, expected height: %d width: %d , but " - "got height: %d width: %d", - outputHeight, outputWidth, gradOutput->size(dimh), - gradOutput->size(dimw)); - } -} - -int deform_conv_forward_cuda(at::Tensor input, at::Tensor weight, - at::Tensor offset, at::Tensor output, - at::Tensor columns, at::Tensor ones, int kW, - int kH, int dW, int dH, int padW, int padH, - int dilationW, int dilationH, int group, - int deformable_group, int im2col_step) { - // todo: resize columns to include im2col: done - // todo: add im2col_step as input - // todo: add new output buffer and transpose it to output (or directly - // transpose output) todo: possibly change data indexing because of - // parallel_imgs - - shape_check(input, offset, NULL, weight, kH, kW, dH, dW, padH, padW, - dilationH, dilationW, group, deformable_group); - at::DeviceGuard guard(input.device()); - - input = input.contiguous(); - offset = offset.contiguous(); - weight = weight.contiguous(); - - int batch = 1; - if (input.ndimension() == 3) { - // Force batch - batch = 0; - input.unsqueeze_(0); - offset.unsqueeze_(0); - } - - // todo: assert batchsize dividable by im2col_step - - long batchSize = input.size(0); - long nInputPlane = input.size(1); - long inputHeight = input.size(2); - long inputWidth = input.size(3); - - long nOutputPlane = weight.size(0); - - long outputWidth = - (inputWidth + 2 * padW - (dilationW * (kW - 1) + 1)) / dW + 1; - long outputHeight = - (inputHeight + 2 * padH - (dilationH * (kH - 1) + 1)) / dH + 1; - - TORCH_CHECK((offset.size(0) == batchSize), "invalid batch size of offset"); - - output = output.view({batchSize / im2col_step, im2col_step, nOutputPlane, - outputHeight, outputWidth}); - columns = at::zeros( - {nInputPlane * kW * kH, im2col_step * outputHeight * outputWidth}, - input.options()); - - if (ones.ndimension() != 2 || - ones.size(0) * ones.size(1) < outputHeight * outputWidth) { - ones = at::ones({outputHeight, outputWidth}, input.options()); - } - - input = input.view({batchSize / im2col_step, im2col_step, nInputPlane, - inputHeight, inputWidth}); - offset = - offset.view({batchSize / im2col_step, im2col_step, - deformable_group * 2 * kH * kW, outputHeight, outputWidth}); - - at::Tensor output_buffer = - at::zeros({batchSize / im2col_step, nOutputPlane, - im2col_step * outputHeight, outputWidth}, - output.options()); - - output_buffer = output_buffer.view( - {output_buffer.size(0), group, output_buffer.size(1) / group, - output_buffer.size(2), output_buffer.size(3)}); - - for (int elt = 0; elt < batchSize / im2col_step; elt++) { - deformable_im2col(input[elt], offset[elt], nInputPlane, inputHeight, - inputWidth, kH, kW, padH, padW, dH, dW, dilationH, - dilationW, im2col_step, deformable_group, columns); - - columns = columns.view({group, columns.size(0) / group, columns.size(1)}); - weight = weight.view({group, weight.size(0) / group, weight.size(1), - weight.size(2), weight.size(3)}); - - for (int g = 0; g < group; g++) { - output_buffer[elt][g] = output_buffer[elt][g] - .flatten(1) - .addmm_(weight[g].flatten(1), columns[g]) - .view_as(output_buffer[elt][g]); - } - } - - output_buffer = output_buffer.view( - {output_buffer.size(0), output_buffer.size(1) * output_buffer.size(2), - output_buffer.size(3), output_buffer.size(4)}); - - output_buffer = output_buffer.view({batchSize / im2col_step, nOutputPlane, - im2col_step, outputHeight, outputWidth}); - output_buffer.transpose_(1, 2); - output.copy_(output_buffer); - output = output.view({batchSize, nOutputPlane, outputHeight, outputWidth}); - - input = input.view({batchSize, nInputPlane, inputHeight, inputWidth}); - offset = offset.view( - {batchSize, deformable_group * 2 * kH * kW, outputHeight, outputWidth}); - - if (batch == 0) { - output = output.view({nOutputPlane, outputHeight, outputWidth}); - input = input.view({nInputPlane, inputHeight, inputWidth}); - offset = offset.view({offset.size(1), offset.size(2), offset.size(3)}); - } - - return 1; -} - -int deform_conv_backward_input_cuda(at::Tensor input, at::Tensor offset, - at::Tensor gradOutput, at::Tensor gradInput, - at::Tensor gradOffset, at::Tensor weight, - at::Tensor columns, int kW, int kH, int dW, - int dH, int padW, int padH, int dilationW, - int dilationH, int group, - int deformable_group, int im2col_step) { - shape_check(input, offset, &gradOutput, weight, kH, kW, dH, dW, padH, padW, - dilationH, dilationW, group, deformable_group); - at::DeviceGuard guard(input.device()); - - input = input.contiguous(); - offset = offset.contiguous(); - gradOutput = gradOutput.contiguous(); - weight = weight.contiguous(); - - int batch = 1; - - if (input.ndimension() == 3) { - // Force batch - batch = 0; - input = input.view({1, input.size(0), input.size(1), input.size(2)}); - offset = offset.view({1, offset.size(0), offset.size(1), offset.size(2)}); - gradOutput = gradOutput.view( - {1, gradOutput.size(0), gradOutput.size(1), gradOutput.size(2)}); - } - - long batchSize = input.size(0); - long nInputPlane = input.size(1); - long inputHeight = input.size(2); - long inputWidth = input.size(3); - - long nOutputPlane = weight.size(0); - - long outputWidth = - (inputWidth + 2 * padW - (dilationW * (kW - 1) + 1)) / dW + 1; - long outputHeight = - (inputHeight + 2 * padH - (dilationH * (kH - 1) + 1)) / dH + 1; - - TORCH_CHECK((offset.size(0) == batchSize), 3, "invalid batch size of offset"); - gradInput = gradInput.view({batchSize, nInputPlane, inputHeight, inputWidth}); - columns = at::zeros( - {nInputPlane * kW * kH, im2col_step * outputHeight * outputWidth}, - input.options()); - - // change order of grad output - gradOutput = gradOutput.view({batchSize / im2col_step, im2col_step, - nOutputPlane, outputHeight, outputWidth}); - gradOutput.transpose_(1, 2); - - gradInput = gradInput.view({batchSize / im2col_step, im2col_step, nInputPlane, - inputHeight, inputWidth}); - input = input.view({batchSize / im2col_step, im2col_step, nInputPlane, - inputHeight, inputWidth}); - gradOffset = gradOffset.view({batchSize / im2col_step, im2col_step, - deformable_group * 2 * kH * kW, outputHeight, - outputWidth}); - offset = - offset.view({batchSize / im2col_step, im2col_step, - deformable_group * 2 * kH * kW, outputHeight, outputWidth}); - - for (int elt = 0; elt < batchSize / im2col_step; elt++) { - // divide into groups - columns = columns.view({group, columns.size(0) / group, columns.size(1)}); - weight = weight.view({group, weight.size(0) / group, weight.size(1), - weight.size(2), weight.size(3)}); - gradOutput = gradOutput.view( - {gradOutput.size(0), group, gradOutput.size(1) / group, - gradOutput.size(2), gradOutput.size(3), gradOutput.size(4)}); - - for (int g = 0; g < group; g++) { - columns[g] = columns[g].addmm_(weight[g].flatten(1).transpose(0, 1), - gradOutput[elt][g].flatten(1), 0.0f, 1.0f); - } - - columns = - columns.view({columns.size(0) * columns.size(1), columns.size(2)}); - gradOutput = gradOutput.view( - {gradOutput.size(0), gradOutput.size(1) * gradOutput.size(2), - gradOutput.size(3), gradOutput.size(4), gradOutput.size(5)}); - - deformable_col2im_coord(columns, input[elt], offset[elt], nInputPlane, - inputHeight, inputWidth, kH, kW, padH, padW, dH, dW, - dilationH, dilationW, im2col_step, deformable_group, - gradOffset[elt]); - - deformable_col2im(columns, offset[elt], nInputPlane, inputHeight, - inputWidth, kH, kW, padH, padW, dH, dW, dilationH, - dilationW, im2col_step, deformable_group, gradInput[elt]); - } - - gradOutput.transpose_(1, 2); - gradOutput = - gradOutput.view({batchSize, nOutputPlane, outputHeight, outputWidth}); - - gradInput = gradInput.view({batchSize, nInputPlane, inputHeight, inputWidth}); - input = input.view({batchSize, nInputPlane, inputHeight, inputWidth}); - gradOffset = gradOffset.view( - {batchSize, deformable_group * 2 * kH * kW, outputHeight, outputWidth}); - offset = offset.view( - {batchSize, deformable_group * 2 * kH * kW, outputHeight, outputWidth}); - - if (batch == 0) { - gradOutput = gradOutput.view({nOutputPlane, outputHeight, outputWidth}); - input = input.view({nInputPlane, inputHeight, inputWidth}); - gradInput = gradInput.view({nInputPlane, inputHeight, inputWidth}); - offset = offset.view({offset.size(1), offset.size(2), offset.size(3)}); - gradOffset = - gradOffset.view({offset.size(1), offset.size(2), offset.size(3)}); - } - - return 1; -} - -int deform_conv_backward_parameters_cuda( - at::Tensor input, at::Tensor offset, at::Tensor gradOutput, - at::Tensor gradWeight, // at::Tensor gradBias, - at::Tensor columns, at::Tensor ones, int kW, int kH, int dW, int dH, - int padW, int padH, int dilationW, int dilationH, int group, - int deformable_group, float scale, int im2col_step) { - // todo: transpose and reshape outGrad - // todo: reshape columns - // todo: add im2col_step as input - - shape_check(input, offset, &gradOutput, gradWeight, kH, kW, dH, dW, padH, - padW, dilationH, dilationW, group, deformable_group); - at::DeviceGuard guard(input.device()); - - input = input.contiguous(); - offset = offset.contiguous(); - gradOutput = gradOutput.contiguous(); - - int batch = 1; - - if (input.ndimension() == 3) { - // Force batch - batch = 0; - input = input.view( - at::IntList({1, input.size(0), input.size(1), input.size(2)})); - gradOutput = gradOutput.view( - {1, gradOutput.size(0), gradOutput.size(1), gradOutput.size(2)}); - } - - long batchSize = input.size(0); - long nInputPlane = input.size(1); - long inputHeight = input.size(2); - long inputWidth = input.size(3); - - long nOutputPlane = gradWeight.size(0); - - long outputWidth = - (inputWidth + 2 * padW - (dilationW * (kW - 1) + 1)) / dW + 1; - long outputHeight = - (inputHeight + 2 * padH - (dilationH * (kH - 1) + 1)) / dH + 1; - - TORCH_CHECK((offset.size(0) == batchSize), "invalid batch size of offset"); - - columns = at::zeros( - {nInputPlane * kW * kH, im2col_step * outputHeight * outputWidth}, - input.options()); - - gradOutput = gradOutput.view({batchSize / im2col_step, im2col_step, - nOutputPlane, outputHeight, outputWidth}); - gradOutput.transpose_(1, 2); - - at::Tensor gradOutputBuffer = at::zeros_like(gradOutput); - gradOutputBuffer = - gradOutputBuffer.view({batchSize / im2col_step, nOutputPlane, im2col_step, - outputHeight, outputWidth}); - gradOutputBuffer.copy_(gradOutput); - gradOutputBuffer = - gradOutputBuffer.view({batchSize / im2col_step, nOutputPlane, - im2col_step * outputHeight, outputWidth}); - - gradOutput.transpose_(1, 2); - gradOutput = - gradOutput.view({batchSize, nOutputPlane, outputHeight, outputWidth}); - - input = input.view({batchSize / im2col_step, im2col_step, nInputPlane, - inputHeight, inputWidth}); - offset = - offset.view({batchSize / im2col_step, im2col_step, - deformable_group * 2 * kH * kW, outputHeight, outputWidth}); - - for (int elt = 0; elt < batchSize / im2col_step; elt++) { - deformable_im2col(input[elt], offset[elt], nInputPlane, inputHeight, - inputWidth, kH, kW, padH, padW, dH, dW, dilationH, - dilationW, im2col_step, deformable_group, columns); - - // divide into group - gradOutputBuffer = gradOutputBuffer.view( - {gradOutputBuffer.size(0), group, gradOutputBuffer.size(1) / group, - gradOutputBuffer.size(2), gradOutputBuffer.size(3)}); - columns = columns.view({group, columns.size(0) / group, columns.size(1)}); - gradWeight = - gradWeight.view({group, gradWeight.size(0) / group, gradWeight.size(1), - gradWeight.size(2), gradWeight.size(3)}); - - for (int g = 0; g < group; g++) { - gradWeight[g] = gradWeight[g] - .flatten(1) - .addmm_(gradOutputBuffer[elt][g].flatten(1), - columns[g].transpose(1, 0), 1.0, scale) - .view_as(gradWeight[g]); - } - gradOutputBuffer = gradOutputBuffer.view( - {gradOutputBuffer.size(0), - gradOutputBuffer.size(1) * gradOutputBuffer.size(2), - gradOutputBuffer.size(3), gradOutputBuffer.size(4)}); - columns = - columns.view({columns.size(0) * columns.size(1), columns.size(2)}); - gradWeight = gradWeight.view({gradWeight.size(0) * gradWeight.size(1), - gradWeight.size(2), gradWeight.size(3), - gradWeight.size(4)}); - } - - input = input.view({batchSize, nInputPlane, inputHeight, inputWidth}); - offset = offset.view( - {batchSize, deformable_group * 2 * kH * kW, outputHeight, outputWidth}); - - if (batch == 0) { - gradOutput = gradOutput.view({nOutputPlane, outputHeight, outputWidth}); - input = input.view({nInputPlane, inputHeight, inputWidth}); - } - - return 1; -} - -void modulated_deform_conv_cuda_forward( - at::Tensor input, at::Tensor weight, at::Tensor bias, at::Tensor ones, - at::Tensor offset, at::Tensor mask, at::Tensor output, at::Tensor columns, - int kernel_h, int kernel_w, const int stride_h, const int stride_w, - const int pad_h, const int pad_w, const int dilation_h, - const int dilation_w, const int group, const int deformable_group, - const bool with_bias) { - TORCH_CHECK(input.is_contiguous(), "input tensor has to be contiguous"); - TORCH_CHECK(weight.is_contiguous(), "weight tensor has to be contiguous"); - at::DeviceGuard guard(input.device()); - - const int batch = input.size(0); - const int channels = input.size(1); - const int height = input.size(2); - const int width = input.size(3); - - const int channels_out = weight.size(0); - const int channels_kernel = weight.size(1); - const int kernel_h_ = weight.size(2); - const int kernel_w_ = weight.size(3); - - if (kernel_h_ != kernel_h || kernel_w_ != kernel_w) - AT_ERROR("Input shape and kernel shape wont match: (%d x %d vs %d x %d).", - kernel_h_, kernel_w, kernel_h_, kernel_w_); - if (channels != channels_kernel * group) - AT_ERROR("Input shape and kernel channels wont match: (%d vs %d).", - channels, channels_kernel * group); - - const int height_out = - (height + 2 * pad_h - (dilation_h * (kernel_h - 1) + 1)) / stride_h + 1; - const int width_out = - (width + 2 * pad_w - (dilation_w * (kernel_w - 1) + 1)) / stride_w + 1; - - if (ones.ndimension() != 2 || - ones.size(0) * ones.size(1) < height_out * width_out) { - // Resize plane and fill with ones... - ones = at::ones({height_out, width_out}, input.options()); - } - - // resize output - output = output.view({batch, channels_out, height_out, width_out}).zero_(); - // resize temporary columns - columns = - at::zeros({channels * kernel_h * kernel_w, 1 * height_out * width_out}, - input.options()); - - output = output.view({output.size(0), group, output.size(1) / group, - output.size(2), output.size(3)}); - - for (int b = 0; b < batch; b++) { - modulated_deformable_im2col_cuda( - input[b], offset[b], mask[b], 1, channels, height, width, height_out, - width_out, kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, - dilation_h, dilation_w, deformable_group, columns); - - // divide into group - weight = weight.view({group, weight.size(0) / group, weight.size(1), - weight.size(2), weight.size(3)}); - columns = columns.view({group, columns.size(0) / group, columns.size(1)}); - - for (int g = 0; g < group; g++) { - output[b][g] = output[b][g] - .flatten(1) - .addmm_(weight[g].flatten(1), columns[g]) - .view_as(output[b][g]); - } - - weight = weight.view({weight.size(0) * weight.size(1), weight.size(2), - weight.size(3), weight.size(4)}); - columns = - columns.view({columns.size(0) * columns.size(1), columns.size(2)}); - } - - output = output.view({output.size(0), output.size(1) * output.size(2), - output.size(3), output.size(4)}); - - if (with_bias) { - output += bias.view({1, bias.size(0), 1, 1}); - } -} - -void modulated_deform_conv_cuda_backward( - at::Tensor input, at::Tensor weight, at::Tensor bias, at::Tensor ones, - at::Tensor offset, at::Tensor mask, at::Tensor columns, - at::Tensor grad_input, at::Tensor grad_weight, at::Tensor grad_bias, - at::Tensor grad_offset, at::Tensor grad_mask, at::Tensor grad_output, - int kernel_h, int kernel_w, int stride_h, int stride_w, int pad_h, - int pad_w, int dilation_h, int dilation_w, int group, int deformable_group, - const bool with_bias) { - TORCH_CHECK(input.is_contiguous(), "input tensor has to be contiguous"); - TORCH_CHECK(weight.is_contiguous(), "weight tensor has to be contiguous"); - at::DeviceGuard guard(input.device()); - - const int batch = input.size(0); - const int channels = input.size(1); - const int height = input.size(2); - const int width = input.size(3); - - const int channels_kernel = weight.size(1); - const int kernel_h_ = weight.size(2); - const int kernel_w_ = weight.size(3); - if (kernel_h_ != kernel_h || kernel_w_ != kernel_w) - AT_ERROR("Input shape and kernel shape wont match: (%d x %d vs %d x %d).", - kernel_h_, kernel_w, kernel_h_, kernel_w_); - if (channels != channels_kernel * group) - AT_ERROR("Input shape and kernel channels wont match: (%d vs %d).", - channels, channels_kernel * group); - - const int height_out = - (height + 2 * pad_h - (dilation_h * (kernel_h - 1) + 1)) / stride_h + 1; - const int width_out = - (width + 2 * pad_w - (dilation_w * (kernel_w - 1) + 1)) / stride_w + 1; - - if (ones.ndimension() != 2 || - ones.size(0) * ones.size(1) < height_out * width_out) { - // Resize plane and fill with ones... - ones = at::ones({height_out, width_out}, input.options()); - } - - grad_input = grad_input.view({batch, channels, height, width}); - columns = at::zeros({channels * kernel_h * kernel_w, height_out * width_out}, - input.options()); - - grad_output = - grad_output.view({grad_output.size(0), group, grad_output.size(1) / group, - grad_output.size(2), grad_output.size(3)}); - - for (int b = 0; b < batch; b++) { - // divide int group - columns = columns.view({group, columns.size(0) / group, columns.size(1)}); - weight = weight.view({group, weight.size(0) / group, weight.size(1), - weight.size(2), weight.size(3)}); - - for (int g = 0; g < group; g++) { - columns[g].addmm_(weight[g].flatten(1).transpose(0, 1), - grad_output[b][g].flatten(1), 0.0f, 1.0f); - } - - columns = - columns.view({columns.size(0) * columns.size(1), columns.size(2)}); - weight = weight.view({weight.size(0) * weight.size(1), weight.size(2), - weight.size(3), weight.size(4)}); - - // gradient w.r.t. input coordinate data - modulated_deformable_col2im_coord_cuda( - columns, input[b], offset[b], mask[b], 1, channels, height, width, - height_out, width_out, kernel_h, kernel_w, pad_h, pad_w, stride_h, - stride_w, dilation_h, dilation_w, deformable_group, grad_offset[b], - grad_mask[b]); - // gradient w.r.t. input data - modulated_deformable_col2im_cuda( - columns, offset[b], mask[b], 1, channels, height, width, height_out, - width_out, kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, - dilation_h, dilation_w, deformable_group, grad_input[b]); - - // gradient w.r.t. weight, dWeight should accumulate across the batch and - // group - modulated_deformable_im2col_cuda( - input[b], offset[b], mask[b], 1, channels, height, width, height_out, - width_out, kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, - dilation_h, dilation_w, deformable_group, columns); - - columns = columns.view({group, columns.size(0) / group, columns.size(1)}); - grad_weight = grad_weight.view({group, grad_weight.size(0) / group, - grad_weight.size(1), grad_weight.size(2), - grad_weight.size(3)}); - if (with_bias) - grad_bias = grad_bias.view({group, grad_bias.size(0) / group}); - - for (int g = 0; g < group; g++) { - grad_weight[g] = - grad_weight[g] - .flatten(1) - .addmm_(grad_output[b][g].flatten(1), columns[g].transpose(0, 1)) - .view_as(grad_weight[g]); - if (with_bias) { - grad_bias[g] = - grad_bias[g] - .view({-1, 1}) - .addmm_(grad_output[b][g].flatten(1), ones.view({-1, 1})) - .view(-1); - } - } - - columns = - columns.view({columns.size(0) * columns.size(1), columns.size(2)}); - grad_weight = grad_weight.view({grad_weight.size(0) * grad_weight.size(1), - grad_weight.size(2), grad_weight.size(3), - grad_weight.size(4)}); - if (with_bias) - grad_bias = grad_bias.view({grad_bias.size(0) * grad_bias.size(1)}); - } - grad_output = grad_output.view({grad_output.size(0) * grad_output.size(1), - grad_output.size(2), grad_output.size(3), - grad_output.size(4)}); -} - -PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { - m.def("deform_conv_forward_cuda", &deform_conv_forward_cuda, - "deform forward (CUDA)"); - m.def("deform_conv_backward_input_cuda", &deform_conv_backward_input_cuda, - "deform_conv_backward_input (CUDA)"); - m.def("deform_conv_backward_parameters_cuda", - &deform_conv_backward_parameters_cuda, - "deform_conv_backward_parameters (CUDA)"); - m.def("modulated_deform_conv_cuda_forward", - &modulated_deform_conv_cuda_forward, - "modulated deform conv forward (CUDA)"); - m.def("modulated_deform_conv_cuda_backward", - &modulated_deform_conv_cuda_backward, - "modulated deform conv backward (CUDA)"); -} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_conv_cuda_kernel.cu b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_conv_cuda_kernel.cu deleted file mode 100644 index e7a26f2e8..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_conv_cuda_kernel.cu +++ /dev/null @@ -1,867 +0,0 @@ -/*! - ******************* BEGIN Caffe Copyright Notice and Disclaimer **************** - * - * COPYRIGHT - * - * All contributions by the University of California: - * Copyright (c) 2014-2017 The Regents of the University of California (Regents) - * All rights reserved. - * - * All other contributions: - * Copyright (c) 2014-2017, the respective contributors - * All rights reserved. - * - * Caffe uses a shared copyright model: each contributor holds copyright over - * their contributions to Caffe. The project versioning records all such - * contribution and copyright details. If a contributor wants to further mark - * their specific copyright on a particular contribution, they should indicate - * their copyright solely in the commit message of the change when it is - * committed. - * - * LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * CONTRIBUTION AGREEMENT - * - * By contributing to the BVLC/caffe repository through pull-request, comment, - * or otherwise, the contributor releases their content to the - * license and copyright terms herein. - * - ***************** END Caffe Copyright Notice and Disclaimer ******************** - * - * Copyright (c) 2018 Microsoft - * Licensed under The MIT License [see LICENSE for details] - * \file modulated_deformable_im2col.cuh - * \brief Function definitions of converting an image to - * column matrix based on kernel, padding, dilation, and offset. - * These functions are mainly used in deformable convolution operators. - * \ref: https://arxiv.org/abs/1703.06211 - * \author Yuwen Xiong, Haozhi Qi, Jifeng Dai, Xizhou Zhu, Han Hu, Dazhi Cheng - */ - -// modified from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/mmdetection/mmdet/ops/dcn/src/deform_conv_cuda_kernel.cu - -#include -#include -#include -#include -#include -#include - -using namespace at; - -#define CUDA_KERNEL_LOOP(i, n) \ - for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < (n); \ - i += blockDim.x * gridDim.x) - -const int CUDA_NUM_THREADS = 1024; -const int kMaxGridNum = 65535; - -inline int GET_BLOCKS(const int N) -{ - return std::min(kMaxGridNum, (N + CUDA_NUM_THREADS - 1) / CUDA_NUM_THREADS); -} - -template -__device__ scalar_t deformable_im2col_bilinear(const scalar_t *bottom_data, const int data_width, - const int height, const int width, scalar_t h, scalar_t w) -{ - - int h_low = floor(h); - int w_low = floor(w); - int h_high = h_low + 1; - int w_high = w_low + 1; - - scalar_t lh = h - h_low; - scalar_t lw = w - w_low; - scalar_t hh = 1 - lh, hw = 1 - lw; - - scalar_t v1 = 0; - if (h_low >= 0 && w_low >= 0) - v1 = bottom_data[h_low * data_width + w_low]; - scalar_t v2 = 0; - if (h_low >= 0 && w_high <= width - 1) - v2 = bottom_data[h_low * data_width + w_high]; - scalar_t v3 = 0; - if (h_high <= height - 1 && w_low >= 0) - v3 = bottom_data[h_high * data_width + w_low]; - scalar_t v4 = 0; - if (h_high <= height - 1 && w_high <= width - 1) - v4 = bottom_data[h_high * data_width + w_high]; - - scalar_t w1 = hh * hw, w2 = hh * lw, w3 = lh * hw, w4 = lh * lw; - - scalar_t val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); - return val; -} - -template -__device__ scalar_t get_gradient_weight(scalar_t argmax_h, scalar_t argmax_w, - const int h, const int w, const int height, const int width) -{ - - if (argmax_h <= -1 || argmax_h >= height || argmax_w <= -1 || argmax_w >= width) - { - //empty - return 0; - } - - int argmax_h_low = floor(argmax_h); - int argmax_w_low = floor(argmax_w); - int argmax_h_high = argmax_h_low + 1; - int argmax_w_high = argmax_w_low + 1; - - scalar_t weight = 0; - if (h == argmax_h_low && w == argmax_w_low) - weight = (h + 1 - argmax_h) * (w + 1 - argmax_w); - if (h == argmax_h_low && w == argmax_w_high) - weight = (h + 1 - argmax_h) * (argmax_w + 1 - w); - if (h == argmax_h_high && w == argmax_w_low) - weight = (argmax_h + 1 - h) * (w + 1 - argmax_w); - if (h == argmax_h_high && w == argmax_w_high) - weight = (argmax_h + 1 - h) * (argmax_w + 1 - w); - return weight; -} - -template -__device__ scalar_t get_coordinate_weight(scalar_t argmax_h, scalar_t argmax_w, - const int height, const int width, const scalar_t *im_data, - const int data_width, const int bp_dir) -{ - - if (argmax_h <= -1 || argmax_h >= height || argmax_w <= -1 || argmax_w >= width) - { - //empty - return 0; - } - - int argmax_h_low = floor(argmax_h); - int argmax_w_low = floor(argmax_w); - int argmax_h_high = argmax_h_low + 1; - int argmax_w_high = argmax_w_low + 1; - - scalar_t weight = 0; - - if (bp_dir == 0) - { - if (argmax_h_low >= 0 && argmax_w_low >= 0) - weight += -1 * (argmax_w_low + 1 - argmax_w) * im_data[argmax_h_low * data_width + argmax_w_low]; - if (argmax_h_low >= 0 && argmax_w_high <= width - 1) - weight += -1 * (argmax_w - argmax_w_low) * im_data[argmax_h_low * data_width + argmax_w_high]; - if (argmax_h_high <= height - 1 && argmax_w_low >= 0) - weight += (argmax_w_low + 1 - argmax_w) * im_data[argmax_h_high * data_width + argmax_w_low]; - if (argmax_h_high <= height - 1 && argmax_w_high <= width - 1) - weight += (argmax_w - argmax_w_low) * im_data[argmax_h_high * data_width + argmax_w_high]; - } - else if (bp_dir == 1) - { - if (argmax_h_low >= 0 && argmax_w_low >= 0) - weight += -1 * (argmax_h_low + 1 - argmax_h) * im_data[argmax_h_low * data_width + argmax_w_low]; - if (argmax_h_low >= 0 && argmax_w_high <= width - 1) - weight += (argmax_h_low + 1 - argmax_h) * im_data[argmax_h_low * data_width + argmax_w_high]; - if (argmax_h_high <= height - 1 && argmax_w_low >= 0) - weight += -1 * (argmax_h - argmax_h_low) * im_data[argmax_h_high * data_width + argmax_w_low]; - if (argmax_h_high <= height - 1 && argmax_w_high <= width - 1) - weight += (argmax_h - argmax_h_low) * im_data[argmax_h_high * data_width + argmax_w_high]; - } - - return weight; -} - -template -__global__ void deformable_im2col_gpu_kernel(const int n, const scalar_t *data_im, const scalar_t *data_offset, - const int height, const int width, const int kernel_h, const int kernel_w, - const int pad_h, const int pad_w, const int stride_h, const int stride_w, - const int dilation_h, const int dilation_w, const int channel_per_deformable_group, - const int batch_size, const int num_channels, const int deformable_group, - const int height_col, const int width_col, - scalar_t *data_col) -{ - CUDA_KERNEL_LOOP(index, n) - { - // index index of output matrix - const int w_col = index % width_col; - const int h_col = (index / width_col) % height_col; - const int b_col = (index / width_col / height_col) % batch_size; - const int c_im = (index / width_col / height_col) / batch_size; - const int c_col = c_im * kernel_h * kernel_w; - - // compute deformable group index - const int deformable_group_index = c_im / channel_per_deformable_group; - - const int h_in = h_col * stride_h - pad_h; - const int w_in = w_col * stride_w - pad_w; - scalar_t *data_col_ptr = data_col + ((c_col * batch_size + b_col) * height_col + h_col) * width_col + w_col; - //const scalar_t* data_im_ptr = data_im + ((b_col * num_channels + c_im) * height + h_in) * width + w_in; - const scalar_t *data_im_ptr = data_im + (b_col * num_channels + c_im) * height * width; - const scalar_t *data_offset_ptr = data_offset + (b_col * deformable_group + deformable_group_index) * 2 * kernel_h * kernel_w * height_col * width_col; - - for (int i = 0; i < kernel_h; ++i) - { - for (int j = 0; j < kernel_w; ++j) - { - const int data_offset_h_ptr = ((2 * (i * kernel_w + j)) * height_col + h_col) * width_col + w_col; - const int data_offset_w_ptr = ((2 * (i * kernel_w + j) + 1) * height_col + h_col) * width_col + w_col; - const scalar_t offset_h = data_offset_ptr[data_offset_h_ptr]; - const scalar_t offset_w = data_offset_ptr[data_offset_w_ptr]; - scalar_t val = static_cast(0); - const scalar_t h_im = h_in + i * dilation_h + offset_h; - const scalar_t w_im = w_in + j * dilation_w + offset_w; - if (h_im > -1 && w_im > -1 && h_im < height && w_im < width) - { - //const scalar_t map_h = i * dilation_h + offset_h; - //const scalar_t map_w = j * dilation_w + offset_w; - //const int cur_height = height - h_in; - //const int cur_width = width - w_in; - //val = deformable_im2col_bilinear(data_im_ptr, width, cur_height, cur_width, map_h, map_w); - val = deformable_im2col_bilinear(data_im_ptr, width, height, width, h_im, w_im); - } - *data_col_ptr = val; - data_col_ptr += batch_size * height_col * width_col; - } - } - } -} - -void deformable_im2col( - const at::Tensor data_im, const at::Tensor data_offset, const int channels, - const int height, const int width, const int ksize_h, const int ksize_w, - const int pad_h, const int pad_w, const int stride_h, const int stride_w, - const int dilation_h, const int dilation_w, const int parallel_imgs, - const int deformable_group, at::Tensor data_col) -{ - // num_axes should be smaller than block size - // todo: check parallel_imgs is correctly passed in - int height_col = (height + 2 * pad_h - (dilation_h * (ksize_h - 1) + 1)) / stride_h + 1; - int width_col = (width + 2 * pad_w - (dilation_w * (ksize_w - 1) + 1)) / stride_w + 1; - int num_kernels = channels * height_col * width_col * parallel_imgs; - int channel_per_deformable_group = channels / deformable_group; - - AT_DISPATCH_FLOATING_TYPES_AND_HALF( - data_im.scalar_type(), "deformable_im2col_gpu", ([&] { - const scalar_t *data_im_ = data_im.data(); - const scalar_t *data_offset_ = data_offset.data(); - scalar_t *data_col_ = data_col.data(); - - deformable_im2col_gpu_kernel<<>>( - num_kernels, data_im_, data_offset_, height, width, ksize_h, ksize_w, - pad_h, pad_w, stride_h, stride_w, dilation_h, dilation_w, - channel_per_deformable_group, parallel_imgs, channels, deformable_group, - height_col, width_col, data_col_); - })); - - cudaError_t err = cudaGetLastError(); - if (err != cudaSuccess) - { - printf("error in deformable_im2col: %s\n", cudaGetErrorString(err)); - } -} - -template -__global__ void deformable_col2im_gpu_kernel( - const int n, const scalar_t *data_col, const scalar_t *data_offset, - const int channels, const int height, const int width, - const int kernel_h, const int kernel_w, - const int pad_h, const int pad_w, - const int stride_h, const int stride_w, - const int dilation_h, const int dilation_w, - const int channel_per_deformable_group, - const int batch_size, const int deformable_group, - const int height_col, const int width_col, - scalar_t *grad_im) -{ - CUDA_KERNEL_LOOP(index, n) - { - const int j = (index / width_col / height_col / batch_size) % kernel_w; - const int i = (index / width_col / height_col / batch_size / kernel_w) % kernel_h; - const int c = index / width_col / height_col / batch_size / kernel_w / kernel_h; - // compute the start and end of the output - - const int deformable_group_index = c / channel_per_deformable_group; - - int w_out = index % width_col; - int h_out = (index / width_col) % height_col; - int b = (index / width_col / height_col) % batch_size; - int w_in = w_out * stride_w - pad_w; - int h_in = h_out * stride_h - pad_h; - - const scalar_t *data_offset_ptr = data_offset + (b * deformable_group + deformable_group_index) * - 2 * kernel_h * kernel_w * height_col * width_col; - const int data_offset_h_ptr = ((2 * (i * kernel_w + j)) * height_col + h_out) * width_col + w_out; - const int data_offset_w_ptr = ((2 * (i * kernel_w + j) + 1) * height_col + h_out) * width_col + w_out; - const scalar_t offset_h = data_offset_ptr[data_offset_h_ptr]; - const scalar_t offset_w = data_offset_ptr[data_offset_w_ptr]; - const scalar_t cur_inv_h_data = h_in + i * dilation_h + offset_h; - const scalar_t cur_inv_w_data = w_in + j * dilation_w + offset_w; - - const scalar_t cur_top_grad = data_col[index]; - const int cur_h = (int)cur_inv_h_data; - const int cur_w = (int)cur_inv_w_data; - for (int dy = -2; dy <= 2; dy++) - { - for (int dx = -2; dx <= 2; dx++) - { - if (cur_h + dy >= 0 && cur_h + dy < height && - cur_w + dx >= 0 && cur_w + dx < width && - abs(cur_inv_h_data - (cur_h + dy)) < 1 && - abs(cur_inv_w_data - (cur_w + dx)) < 1) - { - int cur_bottom_grad_pos = ((b * channels + c) * height + cur_h + dy) * width + cur_w + dx; - scalar_t weight = get_gradient_weight(cur_inv_h_data, cur_inv_w_data, cur_h + dy, cur_w + dx, height, width); - atomicAdd(grad_im + cur_bottom_grad_pos, weight * cur_top_grad); - } - } - } - } -} - -void deformable_col2im( - const at::Tensor data_col, const at::Tensor data_offset, const int channels, - const int height, const int width, const int ksize_h, - const int ksize_w, const int pad_h, const int pad_w, - const int stride_h, const int stride_w, - const int dilation_h, const int dilation_w, - const int parallel_imgs, const int deformable_group, - at::Tensor grad_im) -{ - - // todo: make sure parallel_imgs is passed in correctly - int height_col = (height + 2 * pad_h - (dilation_h * (ksize_h - 1) + 1)) / stride_h + 1; - int width_col = (width + 2 * pad_w - (dilation_w * (ksize_w - 1) + 1)) / stride_w + 1; - int num_kernels = channels * ksize_h * ksize_w * height_col * width_col * parallel_imgs; - int channel_per_deformable_group = channels / deformable_group; - - AT_DISPATCH_FLOATING_TYPES_AND_HALF( - data_col.scalar_type(), "deformable_col2im_gpu", ([&] { - const scalar_t *data_col_ = data_col.data(); - const scalar_t *data_offset_ = data_offset.data(); - scalar_t *grad_im_ = grad_im.data(); - - deformable_col2im_gpu_kernel<<>>( - num_kernels, data_col_, data_offset_, channels, height, width, ksize_h, - ksize_w, pad_h, pad_w, stride_h, stride_w, - dilation_h, dilation_w, channel_per_deformable_group, - parallel_imgs, deformable_group, height_col, width_col, grad_im_); - })); - - cudaError_t err = cudaGetLastError(); - if (err != cudaSuccess) - { - printf("error in deformable_col2im: %s\n", cudaGetErrorString(err)); - } -} - -template -__global__ void deformable_col2im_coord_gpu_kernel(const int n, const scalar_t *data_col, - const scalar_t *data_im, const scalar_t *data_offset, - const int channels, const int height, const int width, - const int kernel_h, const int kernel_w, - const int pad_h, const int pad_w, - const int stride_h, const int stride_w, - const int dilation_h, const int dilation_w, - const int channel_per_deformable_group, - const int batch_size, const int offset_channels, const int deformable_group, - const int height_col, const int width_col, scalar_t *grad_offset) -{ - CUDA_KERNEL_LOOP(index, n) - { - scalar_t val = 0; - int w = index % width_col; - int h = (index / width_col) % height_col; - int c = (index / width_col / height_col) % offset_channels; - int b = (index / width_col / height_col) / offset_channels; - // compute the start and end of the output - - const int deformable_group_index = c / (2 * kernel_h * kernel_w); - const int col_step = kernel_h * kernel_w; - int cnt = 0; - const scalar_t *data_col_ptr = data_col + deformable_group_index * channel_per_deformable_group * - batch_size * width_col * height_col; - const scalar_t *data_im_ptr = data_im + (b * deformable_group + deformable_group_index) * - channel_per_deformable_group / kernel_h / kernel_w * height * width; - const scalar_t *data_offset_ptr = data_offset + (b * deformable_group + deformable_group_index) * 2 * - kernel_h * kernel_w * height_col * width_col; - - const int offset_c = c - deformable_group_index * 2 * kernel_h * kernel_w; - - for (int col_c = (offset_c / 2); col_c < channel_per_deformable_group; col_c += col_step) - { - const int col_pos = (((col_c * batch_size + b) * height_col) + h) * width_col + w; - const int bp_dir = offset_c % 2; - - int j = (col_pos / width_col / height_col / batch_size) % kernel_w; - int i = (col_pos / width_col / height_col / batch_size / kernel_w) % kernel_h; - int w_out = col_pos % width_col; - int h_out = (col_pos / width_col) % height_col; - int w_in = w_out * stride_w - pad_w; - int h_in = h_out * stride_h - pad_h; - const int data_offset_h_ptr = (((2 * (i * kernel_w + j)) * height_col + h_out) * width_col + w_out); - const int data_offset_w_ptr = (((2 * (i * kernel_w + j) + 1) * height_col + h_out) * width_col + w_out); - const scalar_t offset_h = data_offset_ptr[data_offset_h_ptr]; - const scalar_t offset_w = data_offset_ptr[data_offset_w_ptr]; - scalar_t inv_h = h_in + i * dilation_h + offset_h; - scalar_t inv_w = w_in + j * dilation_w + offset_w; - if (inv_h <= -1 || inv_w <= -1 || inv_h >= height || inv_w >= width) - { - inv_h = inv_w = -2; - } - const scalar_t weight = get_coordinate_weight( - inv_h, inv_w, - height, width, data_im_ptr + cnt * height * width, width, bp_dir); - val += weight * data_col_ptr[col_pos]; - cnt += 1; - } - - grad_offset[index] = val; - } -} - -void deformable_col2im_coord( - const at::Tensor data_col, const at::Tensor data_im, const at::Tensor data_offset, - const int channels, const int height, const int width, const int ksize_h, - const int ksize_w, const int pad_h, const int pad_w, const int stride_h, - const int stride_w, const int dilation_h, const int dilation_w, - const int parallel_imgs, const int deformable_group, at::Tensor grad_offset) -{ - - int height_col = (height + 2 * pad_h - (dilation_h * (ksize_h - 1) + 1)) / stride_h + 1; - int width_col = (width + 2 * pad_w - (dilation_w * (ksize_w - 1) + 1)) / stride_w + 1; - int num_kernels = height_col * width_col * 2 * ksize_h * ksize_w * deformable_group * parallel_imgs; - int channel_per_deformable_group = channels * ksize_h * ksize_w / deformable_group; - - AT_DISPATCH_FLOATING_TYPES_AND_HALF( - data_col.scalar_type(), "deformable_col2im_coord_gpu", ([&] { - const scalar_t *data_col_ = data_col.data(); - const scalar_t *data_im_ = data_im.data(); - const scalar_t *data_offset_ = data_offset.data(); - scalar_t *grad_offset_ = grad_offset.data(); - - deformable_col2im_coord_gpu_kernel<<>>( - num_kernels, data_col_, data_im_, data_offset_, channels, height, width, - ksize_h, ksize_w, pad_h, pad_w, stride_h, stride_w, - dilation_h, dilation_w, channel_per_deformable_group, - parallel_imgs, 2 * ksize_h * ksize_w * deformable_group, deformable_group, - height_col, width_col, grad_offset_); - })); -} - -template -__device__ scalar_t dmcn_im2col_bilinear(const scalar_t *bottom_data, const int data_width, - const int height, const int width, scalar_t h, scalar_t w) -{ - int h_low = floor(h); - int w_low = floor(w); - int h_high = h_low + 1; - int w_high = w_low + 1; - - scalar_t lh = h - h_low; - scalar_t lw = w - w_low; - scalar_t hh = 1 - lh, hw = 1 - lw; - - scalar_t v1 = 0; - if (h_low >= 0 && w_low >= 0) - v1 = bottom_data[h_low * data_width + w_low]; - scalar_t v2 = 0; - if (h_low >= 0 && w_high <= width - 1) - v2 = bottom_data[h_low * data_width + w_high]; - scalar_t v3 = 0; - if (h_high <= height - 1 && w_low >= 0) - v3 = bottom_data[h_high * data_width + w_low]; - scalar_t v4 = 0; - if (h_high <= height - 1 && w_high <= width - 1) - v4 = bottom_data[h_high * data_width + w_high]; - - scalar_t w1 = hh * hw, w2 = hh * lw, w3 = lh * hw, w4 = lh * lw; - - scalar_t val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); - return val; -} - -template -__device__ scalar_t dmcn_get_gradient_weight(scalar_t argmax_h, scalar_t argmax_w, - const int h, const int w, const int height, const int width) -{ - if (argmax_h <= -1 || argmax_h >= height || argmax_w <= -1 || argmax_w >= width) - { - //empty - return 0; - } - - int argmax_h_low = floor(argmax_h); - int argmax_w_low = floor(argmax_w); - int argmax_h_high = argmax_h_low + 1; - int argmax_w_high = argmax_w_low + 1; - - scalar_t weight = 0; - if (h == argmax_h_low && w == argmax_w_low) - weight = (h + 1 - argmax_h) * (w + 1 - argmax_w); - if (h == argmax_h_low && w == argmax_w_high) - weight = (h + 1 - argmax_h) * (argmax_w + 1 - w); - if (h == argmax_h_high && w == argmax_w_low) - weight = (argmax_h + 1 - h) * (w + 1 - argmax_w); - if (h == argmax_h_high && w == argmax_w_high) - weight = (argmax_h + 1 - h) * (argmax_w + 1 - w); - return weight; -} - -template -__device__ scalar_t dmcn_get_coordinate_weight(scalar_t argmax_h, scalar_t argmax_w, - const int height, const int width, const scalar_t *im_data, - const int data_width, const int bp_dir) -{ - if (argmax_h <= -1 || argmax_h >= height || argmax_w <= -1 || argmax_w >= width) - { - //empty - return 0; - } - - int argmax_h_low = floor(argmax_h); - int argmax_w_low = floor(argmax_w); - int argmax_h_high = argmax_h_low + 1; - int argmax_w_high = argmax_w_low + 1; - - scalar_t weight = 0; - - if (bp_dir == 0) - { - if (argmax_h_low >= 0 && argmax_w_low >= 0) - weight += -1 * (argmax_w_low + 1 - argmax_w) * im_data[argmax_h_low * data_width + argmax_w_low]; - if (argmax_h_low >= 0 && argmax_w_high <= width - 1) - weight += -1 * (argmax_w - argmax_w_low) * im_data[argmax_h_low * data_width + argmax_w_high]; - if (argmax_h_high <= height - 1 && argmax_w_low >= 0) - weight += (argmax_w_low + 1 - argmax_w) * im_data[argmax_h_high * data_width + argmax_w_low]; - if (argmax_h_high <= height - 1 && argmax_w_high <= width - 1) - weight += (argmax_w - argmax_w_low) * im_data[argmax_h_high * data_width + argmax_w_high]; - } - else if (bp_dir == 1) - { - if (argmax_h_low >= 0 && argmax_w_low >= 0) - weight += -1 * (argmax_h_low + 1 - argmax_h) * im_data[argmax_h_low * data_width + argmax_w_low]; - if (argmax_h_low >= 0 && argmax_w_high <= width - 1) - weight += (argmax_h_low + 1 - argmax_h) * im_data[argmax_h_low * data_width + argmax_w_high]; - if (argmax_h_high <= height - 1 && argmax_w_low >= 0) - weight += -1 * (argmax_h - argmax_h_low) * im_data[argmax_h_high * data_width + argmax_w_low]; - if (argmax_h_high <= height - 1 && argmax_w_high <= width - 1) - weight += (argmax_h - argmax_h_low) * im_data[argmax_h_high * data_width + argmax_w_high]; - } - - return weight; -} - -template -__global__ void modulated_deformable_im2col_gpu_kernel(const int n, - const scalar_t *data_im, const scalar_t *data_offset, const scalar_t *data_mask, - const int height, const int width, const int kernel_h, const int kernel_w, - const int pad_h, const int pad_w, - const int stride_h, const int stride_w, - const int dilation_h, const int dilation_w, - const int channel_per_deformable_group, - const int batch_size, const int num_channels, const int deformable_group, - const int height_col, const int width_col, - scalar_t *data_col) -{ - CUDA_KERNEL_LOOP(index, n) - { - // index index of output matrix - const int w_col = index % width_col; - const int h_col = (index / width_col) % height_col; - const int b_col = (index / width_col / height_col) % batch_size; - const int c_im = (index / width_col / height_col) / batch_size; - const int c_col = c_im * kernel_h * kernel_w; - - // compute deformable group index - const int deformable_group_index = c_im / channel_per_deformable_group; - - const int h_in = h_col * stride_h - pad_h; - const int w_in = w_col * stride_w - pad_w; - - scalar_t *data_col_ptr = data_col + ((c_col * batch_size + b_col) * height_col + h_col) * width_col + w_col; - //const float* data_im_ptr = data_im + ((b_col * num_channels + c_im) * height + h_in) * width + w_in; - const scalar_t *data_im_ptr = data_im + (b_col * num_channels + c_im) * height * width; - const scalar_t *data_offset_ptr = data_offset + (b_col * deformable_group + deformable_group_index) * 2 * kernel_h * kernel_w * height_col * width_col; - - const scalar_t *data_mask_ptr = data_mask + (b_col * deformable_group + deformable_group_index) * kernel_h * kernel_w * height_col * width_col; - - for (int i = 0; i < kernel_h; ++i) - { - for (int j = 0; j < kernel_w; ++j) - { - const int data_offset_h_ptr = ((2 * (i * kernel_w + j)) * height_col + h_col) * width_col + w_col; - const int data_offset_w_ptr = ((2 * (i * kernel_w + j) + 1) * height_col + h_col) * width_col + w_col; - const int data_mask_hw_ptr = ((i * kernel_w + j) * height_col + h_col) * width_col + w_col; - const scalar_t offset_h = data_offset_ptr[data_offset_h_ptr]; - const scalar_t offset_w = data_offset_ptr[data_offset_w_ptr]; - const scalar_t mask = data_mask_ptr[data_mask_hw_ptr]; - scalar_t val = static_cast(0); - const scalar_t h_im = h_in + i * dilation_h + offset_h; - const scalar_t w_im = w_in + j * dilation_w + offset_w; - //if (h_im >= 0 && w_im >= 0 && h_im < height && w_im < width) { - if (h_im > -1 && w_im > -1 && h_im < height && w_im < width) - { - //const float map_h = i * dilation_h + offset_h; - //const float map_w = j * dilation_w + offset_w; - //const int cur_height = height - h_in; - //const int cur_width = width - w_in; - //val = dmcn_im2col_bilinear(data_im_ptr, width, cur_height, cur_width, map_h, map_w); - val = dmcn_im2col_bilinear(data_im_ptr, width, height, width, h_im, w_im); - } - *data_col_ptr = val * mask; - data_col_ptr += batch_size * height_col * width_col; - //data_col_ptr += height_col * width_col; - } - } - } -} - -template -__global__ void modulated_deformable_col2im_gpu_kernel(const int n, - const scalar_t *data_col, const scalar_t *data_offset, const scalar_t *data_mask, - const int channels, const int height, const int width, - const int kernel_h, const int kernel_w, - const int pad_h, const int pad_w, - const int stride_h, const int stride_w, - const int dilation_h, const int dilation_w, - const int channel_per_deformable_group, - const int batch_size, const int deformable_group, - const int height_col, const int width_col, - scalar_t *grad_im) -{ - CUDA_KERNEL_LOOP(index, n) - { - const int j = (index / width_col / height_col / batch_size) % kernel_w; - const int i = (index / width_col / height_col / batch_size / kernel_w) % kernel_h; - const int c = index / width_col / height_col / batch_size / kernel_w / kernel_h; - // compute the start and end of the output - - const int deformable_group_index = c / channel_per_deformable_group; - - int w_out = index % width_col; - int h_out = (index / width_col) % height_col; - int b = (index / width_col / height_col) % batch_size; - int w_in = w_out * stride_w - pad_w; - int h_in = h_out * stride_h - pad_h; - - const scalar_t *data_offset_ptr = data_offset + (b * deformable_group + deformable_group_index) * 2 * kernel_h * kernel_w * height_col * width_col; - const scalar_t *data_mask_ptr = data_mask + (b * deformable_group + deformable_group_index) * kernel_h * kernel_w * height_col * width_col; - const int data_offset_h_ptr = ((2 * (i * kernel_w + j)) * height_col + h_out) * width_col + w_out; - const int data_offset_w_ptr = ((2 * (i * kernel_w + j) + 1) * height_col + h_out) * width_col + w_out; - const int data_mask_hw_ptr = ((i * kernel_w + j) * height_col + h_out) * width_col + w_out; - const scalar_t offset_h = data_offset_ptr[data_offset_h_ptr]; - const scalar_t offset_w = data_offset_ptr[data_offset_w_ptr]; - const scalar_t mask = data_mask_ptr[data_mask_hw_ptr]; - const scalar_t cur_inv_h_data = h_in + i * dilation_h + offset_h; - const scalar_t cur_inv_w_data = w_in + j * dilation_w + offset_w; - - const scalar_t cur_top_grad = data_col[index] * mask; - const int cur_h = (int)cur_inv_h_data; - const int cur_w = (int)cur_inv_w_data; - for (int dy = -2; dy <= 2; dy++) - { - for (int dx = -2; dx <= 2; dx++) - { - if (cur_h + dy >= 0 && cur_h + dy < height && - cur_w + dx >= 0 && cur_w + dx < width && - abs(cur_inv_h_data - (cur_h + dy)) < 1 && - abs(cur_inv_w_data - (cur_w + dx)) < 1) - { - int cur_bottom_grad_pos = ((b * channels + c) * height + cur_h + dy) * width + cur_w + dx; - scalar_t weight = dmcn_get_gradient_weight(cur_inv_h_data, cur_inv_w_data, cur_h + dy, cur_w + dx, height, width); - atomicAdd(grad_im + cur_bottom_grad_pos, weight * cur_top_grad); - } - } - } - } -} - -template -__global__ void modulated_deformable_col2im_coord_gpu_kernel(const int n, - const scalar_t *data_col, const scalar_t *data_im, - const scalar_t *data_offset, const scalar_t *data_mask, - const int channels, const int height, const int width, - const int kernel_h, const int kernel_w, - const int pad_h, const int pad_w, - const int stride_h, const int stride_w, - const int dilation_h, const int dilation_w, - const int channel_per_deformable_group, - const int batch_size, const int offset_channels, const int deformable_group, - const int height_col, const int width_col, - scalar_t *grad_offset, scalar_t *grad_mask) -{ - CUDA_KERNEL_LOOP(index, n) - { - scalar_t val = 0, mval = 0; - int w = index % width_col; - int h = (index / width_col) % height_col; - int c = (index / width_col / height_col) % offset_channels; - int b = (index / width_col / height_col) / offset_channels; - // compute the start and end of the output - - const int deformable_group_index = c / (2 * kernel_h * kernel_w); - const int col_step = kernel_h * kernel_w; - int cnt = 0; - const scalar_t *data_col_ptr = data_col + deformable_group_index * channel_per_deformable_group * batch_size * width_col * height_col; - const scalar_t *data_im_ptr = data_im + (b * deformable_group + deformable_group_index) * channel_per_deformable_group / kernel_h / kernel_w * height * width; - const scalar_t *data_offset_ptr = data_offset + (b * deformable_group + deformable_group_index) * 2 * kernel_h * kernel_w * height_col * width_col; - const scalar_t *data_mask_ptr = data_mask + (b * deformable_group + deformable_group_index) * kernel_h * kernel_w * height_col * width_col; - - const int offset_c = c - deformable_group_index * 2 * kernel_h * kernel_w; - - for (int col_c = (offset_c / 2); col_c < channel_per_deformable_group; col_c += col_step) - { - const int col_pos = (((col_c * batch_size + b) * height_col) + h) * width_col + w; - const int bp_dir = offset_c % 2; - - int j = (col_pos / width_col / height_col / batch_size) % kernel_w; - int i = (col_pos / width_col / height_col / batch_size / kernel_w) % kernel_h; - int w_out = col_pos % width_col; - int h_out = (col_pos / width_col) % height_col; - int w_in = w_out * stride_w - pad_w; - int h_in = h_out * stride_h - pad_h; - const int data_offset_h_ptr = (((2 * (i * kernel_w + j)) * height_col + h_out) * width_col + w_out); - const int data_offset_w_ptr = (((2 * (i * kernel_w + j) + 1) * height_col + h_out) * width_col + w_out); - const int data_mask_hw_ptr = (((i * kernel_w + j) * height_col + h_out) * width_col + w_out); - const scalar_t offset_h = data_offset_ptr[data_offset_h_ptr]; - const scalar_t offset_w = data_offset_ptr[data_offset_w_ptr]; - const scalar_t mask = data_mask_ptr[data_mask_hw_ptr]; - scalar_t inv_h = h_in + i * dilation_h + offset_h; - scalar_t inv_w = w_in + j * dilation_w + offset_w; - if (inv_h <= -1 || inv_w <= -1 || inv_h >= height || inv_w >= width) - { - inv_h = inv_w = -2; - } - else - { - mval += data_col_ptr[col_pos] * dmcn_im2col_bilinear(data_im_ptr + cnt * height * width, width, height, width, inv_h, inv_w); - } - const scalar_t weight = dmcn_get_coordinate_weight( - inv_h, inv_w, - height, width, data_im_ptr + cnt * height * width, width, bp_dir); - val += weight * data_col_ptr[col_pos] * mask; - cnt += 1; - } - // KERNEL_ASSIGN(grad_offset[index], offset_req, val); - grad_offset[index] = val; - if (offset_c % 2 == 0) - // KERNEL_ASSIGN(grad_mask[(((b * deformable_group + deformable_group_index) * kernel_h * kernel_w + offset_c / 2) * height_col + h) * width_col + w], mask_req, mval); - grad_mask[(((b * deformable_group + deformable_group_index) * kernel_h * kernel_w + offset_c / 2) * height_col + h) * width_col + w] = mval; - } -} - -void modulated_deformable_im2col_cuda( - const at::Tensor data_im, const at::Tensor data_offset, const at::Tensor data_mask, - const int batch_size, const int channels, const int height_im, const int width_im, - const int height_col, const int width_col, const int kernel_h, const int kenerl_w, - const int pad_h, const int pad_w, const int stride_h, const int stride_w, - const int dilation_h, const int dilation_w, - const int deformable_group, at::Tensor data_col) -{ - // num_axes should be smaller than block size - const int channel_per_deformable_group = channels / deformable_group; - const int num_kernels = channels * batch_size * height_col * width_col; - - AT_DISPATCH_FLOATING_TYPES_AND_HALF( - data_im.scalar_type(), "modulated_deformable_im2col_gpu", ([&] { - const scalar_t *data_im_ = data_im.data(); - const scalar_t *data_offset_ = data_offset.data(); - const scalar_t *data_mask_ = data_mask.data(); - scalar_t *data_col_ = data_col.data(); - - modulated_deformable_im2col_gpu_kernel<<>>( - num_kernels, data_im_, data_offset_, data_mask_, height_im, width_im, kernel_h, kenerl_w, - pad_h, pad_w, stride_h, stride_w, dilation_h, dilation_w, channel_per_deformable_group, - batch_size, channels, deformable_group, height_col, width_col, data_col_); - })); - - cudaError_t err = cudaGetLastError(); - if (err != cudaSuccess) - { - printf("error in modulated_deformable_im2col_cuda: %s\n", cudaGetErrorString(err)); - } -} - -void modulated_deformable_col2im_cuda( - const at::Tensor data_col, const at::Tensor data_offset, const at::Tensor data_mask, - const int batch_size, const int channels, const int height_im, const int width_im, - const int height_col, const int width_col, const int kernel_h, const int kernel_w, - const int pad_h, const int pad_w, const int stride_h, const int stride_w, - const int dilation_h, const int dilation_w, - const int deformable_group, at::Tensor grad_im) -{ - - const int channel_per_deformable_group = channels / deformable_group; - const int num_kernels = channels * kernel_h * kernel_w * batch_size * height_col * width_col; - - AT_DISPATCH_FLOATING_TYPES_AND_HALF( - data_col.scalar_type(), "modulated_deformable_col2im_gpu", ([&] { - const scalar_t *data_col_ = data_col.data(); - const scalar_t *data_offset_ = data_offset.data(); - const scalar_t *data_mask_ = data_mask.data(); - scalar_t *grad_im_ = grad_im.data(); - - modulated_deformable_col2im_gpu_kernel<<>>( - num_kernels, data_col_, data_offset_, data_mask_, channels, height_im, width_im, - kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, - dilation_h, dilation_w, channel_per_deformable_group, - batch_size, deformable_group, height_col, width_col, grad_im_); - })); - - cudaError_t err = cudaGetLastError(); - if (err != cudaSuccess) - { - printf("error in modulated_deformable_col2im_cuda: %s\n", cudaGetErrorString(err)); - } -} - -void modulated_deformable_col2im_coord_cuda( - const at::Tensor data_col, const at::Tensor data_im, const at::Tensor data_offset, const at::Tensor data_mask, - const int batch_size, const int channels, const int height_im, const int width_im, - const int height_col, const int width_col, const int kernel_h, const int kernel_w, - const int pad_h, const int pad_w, const int stride_h, const int stride_w, - const int dilation_h, const int dilation_w, - const int deformable_group, - at::Tensor grad_offset, at::Tensor grad_mask) -{ - const int num_kernels = batch_size * height_col * width_col * 2 * kernel_h * kernel_w * deformable_group; - const int channel_per_deformable_group = channels * kernel_h * kernel_w / deformable_group; - - AT_DISPATCH_FLOATING_TYPES_AND_HALF( - data_col.scalar_type(), "modulated_deformable_col2im_coord_gpu", ([&] { - const scalar_t *data_col_ = data_col.data(); - const scalar_t *data_im_ = data_im.data(); - const scalar_t *data_offset_ = data_offset.data(); - const scalar_t *data_mask_ = data_mask.data(); - scalar_t *grad_offset_ = grad_offset.data(); - scalar_t *grad_mask_ = grad_mask.data(); - - modulated_deformable_col2im_coord_gpu_kernel<<>>( - num_kernels, data_col_, data_im_, data_offset_, data_mask_, channels, height_im, width_im, - kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, - dilation_h, dilation_w, channel_per_deformable_group, - batch_size, 2 * kernel_h * kernel_w * deformable_group, deformable_group, height_col, width_col, - grad_offset_, grad_mask_); - })); - cudaError_t err = cudaGetLastError(); - if (err != cudaSuccess) - { - printf("error in modulated_deformable_col2im_coord_cuda: %s\n", cudaGetErrorString(err)); - } -} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_pool_cuda.cpp b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_pool_cuda.cpp deleted file mode 100644 index f6f087b88..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_pool_cuda.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// modify from -// https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/mmdetection/mmdet/ops/dcn/src/modulated_dcn_cuda.c - -// based on -// author: Charles Shang -// https://github.com/torch/cunn/blob/master/lib/THCUNN/generic/SpatialConvolutionMM.cu - -#include -#include - -#include -#include - -void DeformablePSROIPoolForward( - const at::Tensor data, const at::Tensor bbox, const at::Tensor trans, - at::Tensor out, at::Tensor top_count, const int batch, const int channels, - const int height, const int width, const int num_bbox, - const int channels_trans, const int no_trans, const float spatial_scale, - const int output_dim, const int group_size, const int pooled_size, - const int part_size, const int sample_per_part, const float trans_std); - -void DeformablePSROIPoolBackwardAcc( - const at::Tensor out_grad, const at::Tensor data, const at::Tensor bbox, - const at::Tensor trans, const at::Tensor top_count, at::Tensor in_grad, - at::Tensor trans_grad, const int batch, const int channels, - const int height, const int width, const int num_bbox, - const int channels_trans, const int no_trans, const float spatial_scale, - const int output_dim, const int group_size, const int pooled_size, - const int part_size, const int sample_per_part, const float trans_std); - -void deform_psroi_pooling_cuda_forward( - at::Tensor input, at::Tensor bbox, at::Tensor trans, at::Tensor out, - at::Tensor top_count, const int no_trans, const float spatial_scale, - const int output_dim, const int group_size, const int pooled_size, - const int part_size, const int sample_per_part, const float trans_std) { - TORCH_CHECK(input.is_contiguous(), "input tensor has to be contiguous"); - at::DeviceGuard guard(input.device()); - - const int batch = input.size(0); - const int channels = input.size(1); - const int height = input.size(2); - const int width = input.size(3); - const int channels_trans = no_trans ? 2 : trans.size(1); - - const int num_bbox = bbox.size(0); - if (num_bbox != out.size(0)) - AT_ERROR("Output shape and bbox number wont match: (%d vs %d).", - out.size(0), num_bbox); - - DeformablePSROIPoolForward( - input, bbox, trans, out, top_count, batch, channels, height, width, - num_bbox, channels_trans, no_trans, spatial_scale, output_dim, group_size, - pooled_size, part_size, sample_per_part, trans_std); -} - -void deform_psroi_pooling_cuda_backward( - at::Tensor out_grad, at::Tensor input, at::Tensor bbox, at::Tensor trans, - at::Tensor top_count, at::Tensor input_grad, at::Tensor trans_grad, - const int no_trans, const float spatial_scale, const int output_dim, - const int group_size, const int pooled_size, const int part_size, - const int sample_per_part, const float trans_std) { - TORCH_CHECK(out_grad.is_contiguous(), "out_grad tensor has to be contiguous"); - TORCH_CHECK(input.is_contiguous(), "input tensor has to be contiguous"); - at::DeviceGuard guard(input.device()); - - const int batch = input.size(0); - const int channels = input.size(1); - const int height = input.size(2); - const int width = input.size(3); - const int channels_trans = no_trans ? 2 : trans.size(1); - - const int num_bbox = bbox.size(0); - if (num_bbox != out_grad.size(0)) - AT_ERROR("Output shape and bbox number wont match: (%d vs %d).", - out_grad.size(0), num_bbox); - - DeformablePSROIPoolBackwardAcc( - out_grad, input, bbox, trans, top_count, input_grad, trans_grad, batch, - channels, height, width, num_bbox, channels_trans, no_trans, - spatial_scale, output_dim, group_size, pooled_size, part_size, - sample_per_part, trans_std); -} - -PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { - m.def("deform_psroi_pooling_cuda_forward", &deform_psroi_pooling_cuda_forward, - "deform psroi pooling forward(CUDA)"); - m.def("deform_psroi_pooling_cuda_backward", - &deform_psroi_pooling_cuda_backward, - "deform psroi pooling backward(CUDA)"); -} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_pool_cuda_kernel.cu b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_pool_cuda_kernel.cu deleted file mode 100644 index 05b00d4be..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/dcn/src/deform_pool_cuda_kernel.cu +++ /dev/null @@ -1,364 +0,0 @@ -/*! - * Copyright (c) 2017 Microsoft - * Licensed under The MIT License [see LICENSE for details] - * \file deformable_psroi_pooling.cu - * \brief - * \author Yi Li, Guodong Zhang, Jifeng Dai -*/ -/***************** Adapted by Charles Shang *********************/ -// modify from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/mmdetection/mmdet/ops/dcn/src/cuda/deform_psroi_pooling_cuda.cu - -#include -#include -#include -#include -#include - -using namespace at; - -#define CUDA_KERNEL_LOOP(i, n) \ - for (int i = blockIdx.x * blockDim.x + threadIdx.x; \ - i < (n); \ - i += blockDim.x * gridDim.x) - -const int CUDA_NUM_THREADS = 1024; -inline int GET_BLOCKS(const int N) -{ - return (N + CUDA_NUM_THREADS - 1) / CUDA_NUM_THREADS; -} - -template -__device__ scalar_t bilinear_interp( - const scalar_t *data, - const scalar_t x, - const scalar_t y, - const int width, - const int height) -{ - int x1 = floor(x); - int x2 = ceil(x); - int y1 = floor(y); - int y2 = ceil(y); - scalar_t dist_x = (scalar_t)(x - x1); - scalar_t dist_y = (scalar_t)(y - y1); - scalar_t value11 = data[y1 * width + x1]; - scalar_t value12 = data[y2 * width + x1]; - scalar_t value21 = data[y1 * width + x2]; - scalar_t value22 = data[y2 * width + x2]; - scalar_t value = (1 - dist_x) * (1 - dist_y) * value11 + (1 - dist_x) * dist_y * value12 + dist_x * (1 - dist_y) * value21 + dist_x * dist_y * value22; - return value; -} - -template -__global__ void DeformablePSROIPoolForwardKernel( - const int count, - const scalar_t *bottom_data, - const scalar_t spatial_scale, - const int channels, - const int height, const int width, - const int pooled_height, const int pooled_width, - const scalar_t *bottom_rois, const scalar_t *bottom_trans, - const int no_trans, - const scalar_t trans_std, - const int sample_per_part, - const int output_dim, - const int group_size, - const int part_size, - const int num_classes, - const int channels_each_class, - scalar_t *top_data, - scalar_t *top_count) -{ - CUDA_KERNEL_LOOP(index, count) - { - // The output is in order (n, ctop, ph, pw) - int pw = index % pooled_width; - int ph = (index / pooled_width) % pooled_height; - int ctop = (index / pooled_width / pooled_height) % output_dim; - int n = index / pooled_width / pooled_height / output_dim; - - // [start, end) interval for spatial sampling - const scalar_t *offset_bottom_rois = bottom_rois + n * 5; - int roi_batch_ind = offset_bottom_rois[0]; - scalar_t roi_start_w = (scalar_t)(round(offset_bottom_rois[1])) * spatial_scale - 0.5; - scalar_t roi_start_h = (scalar_t)(round(offset_bottom_rois[2])) * spatial_scale - 0.5; - scalar_t roi_end_w = (scalar_t)(round(offset_bottom_rois[3]) + 1.) * spatial_scale - 0.5; - scalar_t roi_end_h = (scalar_t)(round(offset_bottom_rois[4]) + 1.) * spatial_scale - 0.5; - - // Force too small ROIs to be 1x1 - scalar_t roi_width = max(roi_end_w - roi_start_w, 0.1); //avoid 0 - scalar_t roi_height = max(roi_end_h - roi_start_h, 0.1); - - // Compute w and h at bottom - scalar_t bin_size_h = roi_height / (scalar_t)(pooled_height); - scalar_t bin_size_w = roi_width / (scalar_t)(pooled_width); - - scalar_t sub_bin_size_h = bin_size_h / (scalar_t)(sample_per_part); - scalar_t sub_bin_size_w = bin_size_w / (scalar_t)(sample_per_part); - - int part_h = floor((scalar_t)(ph) / pooled_height * part_size); - int part_w = floor((scalar_t)(pw) / pooled_width * part_size); - int class_id = ctop / channels_each_class; - scalar_t trans_x = no_trans ? (scalar_t)(0) : bottom_trans[(((n * num_classes + class_id) * 2) * part_size + part_h) * part_size + part_w] * (scalar_t)trans_std; - scalar_t trans_y = no_trans ? (scalar_t)(0) : bottom_trans[(((n * num_classes + class_id) * 2 + 1) * part_size + part_h) * part_size + part_w] * (scalar_t)trans_std; - - scalar_t wstart = (scalar_t)(pw)*bin_size_w + roi_start_w; - wstart += trans_x * roi_width; - scalar_t hstart = (scalar_t)(ph)*bin_size_h + roi_start_h; - hstart += trans_y * roi_height; - - scalar_t sum = 0; - int count = 0; - int gw = floor((scalar_t)(pw)*group_size / pooled_width); - int gh = floor((scalar_t)(ph)*group_size / pooled_height); - gw = min(max(gw, 0), group_size - 1); - gh = min(max(gh, 0), group_size - 1); - - const scalar_t *offset_bottom_data = bottom_data + (roi_batch_ind * channels) * height * width; - for (int ih = 0; ih < sample_per_part; ih++) - { - for (int iw = 0; iw < sample_per_part; iw++) - { - scalar_t w = wstart + iw * sub_bin_size_w; - scalar_t h = hstart + ih * sub_bin_size_h; - // bilinear interpolation - if (w < -0.5 || w > width - 0.5 || h < -0.5 || h > height - 0.5) - { - continue; - } - w = min(max(w, 0.), width - 1.); - h = min(max(h, 0.), height - 1.); - int c = (ctop * group_size + gh) * group_size + gw; - scalar_t val = bilinear_interp(offset_bottom_data + c * height * width, w, h, width, height); - sum += val; - count++; - } - } - top_data[index] = count == 0 ? (scalar_t)(0) : sum / count; - top_count[index] = count; - } -} - -template -__global__ void DeformablePSROIPoolBackwardAccKernel( - const int count, - const scalar_t *top_diff, - const scalar_t *top_count, - const int num_rois, - const scalar_t spatial_scale, - const int channels, - const int height, const int width, - const int pooled_height, const int pooled_width, - const int output_dim, - scalar_t *bottom_data_diff, scalar_t *bottom_trans_diff, - const scalar_t *bottom_data, - const scalar_t *bottom_rois, - const scalar_t *bottom_trans, - const int no_trans, - const scalar_t trans_std, - const int sample_per_part, - const int group_size, - const int part_size, - const int num_classes, - const int channels_each_class) -{ - CUDA_KERNEL_LOOP(index, count) - { - // The output is in order (n, ctop, ph, pw) - int pw = index % pooled_width; - int ph = (index / pooled_width) % pooled_height; - int ctop = (index / pooled_width / pooled_height) % output_dim; - int n = index / pooled_width / pooled_height / output_dim; - - // [start, end) interval for spatial sampling - const scalar_t *offset_bottom_rois = bottom_rois + n * 5; - int roi_batch_ind = offset_bottom_rois[0]; - scalar_t roi_start_w = (scalar_t)(round(offset_bottom_rois[1])) * spatial_scale - 0.5; - scalar_t roi_start_h = (scalar_t)(round(offset_bottom_rois[2])) * spatial_scale - 0.5; - scalar_t roi_end_w = (scalar_t)(round(offset_bottom_rois[3]) + 1.) * spatial_scale - 0.5; - scalar_t roi_end_h = (scalar_t)(round(offset_bottom_rois[4]) + 1.) * spatial_scale - 0.5; - - // Force too small ROIs to be 1x1 - scalar_t roi_width = max(roi_end_w - roi_start_w, 0.1); //avoid 0 - scalar_t roi_height = max(roi_end_h - roi_start_h, 0.1); - - // Compute w and h at bottom - scalar_t bin_size_h = roi_height / (scalar_t)(pooled_height); - scalar_t bin_size_w = roi_width / (scalar_t)(pooled_width); - - scalar_t sub_bin_size_h = bin_size_h / (scalar_t)(sample_per_part); - scalar_t sub_bin_size_w = bin_size_w / (scalar_t)(sample_per_part); - - int part_h = floor((scalar_t)(ph) / pooled_height * part_size); - int part_w = floor((scalar_t)(pw) / pooled_width * part_size); - int class_id = ctop / channels_each_class; - scalar_t trans_x = no_trans ? (scalar_t)(0) : bottom_trans[(((n * num_classes + class_id) * 2) * part_size + part_h) * part_size + part_w] * (scalar_t)trans_std; - scalar_t trans_y = no_trans ? (scalar_t)(0) : bottom_trans[(((n * num_classes + class_id) * 2 + 1) * part_size + part_h) * part_size + part_w] * (scalar_t)trans_std; - - scalar_t wstart = (scalar_t)(pw)*bin_size_w + roi_start_w; - wstart += trans_x * roi_width; - scalar_t hstart = (scalar_t)(ph)*bin_size_h + roi_start_h; - hstart += trans_y * roi_height; - - if (top_count[index] <= 0) - { - continue; - } - scalar_t diff_val = top_diff[index] / top_count[index]; - const scalar_t *offset_bottom_data = bottom_data + roi_batch_ind * channels * height * width; - scalar_t *offset_bottom_data_diff = bottom_data_diff + roi_batch_ind * channels * height * width; - int gw = floor((scalar_t)(pw)*group_size / pooled_width); - int gh = floor((scalar_t)(ph)*group_size / pooled_height); - gw = min(max(gw, 0), group_size - 1); - gh = min(max(gh, 0), group_size - 1); - - for (int ih = 0; ih < sample_per_part; ih++) - { - for (int iw = 0; iw < sample_per_part; iw++) - { - scalar_t w = wstart + iw * sub_bin_size_w; - scalar_t h = hstart + ih * sub_bin_size_h; - // bilinear interpolation - if (w < -0.5 || w > width - 0.5 || h < -0.5 || h > height - 0.5) - { - continue; - } - w = min(max(w, 0.), width - 1.); - h = min(max(h, 0.), height - 1.); - int c = (ctop * group_size + gh) * group_size + gw; - // backward on feature - int x0 = floor(w); - int x1 = ceil(w); - int y0 = floor(h); - int y1 = ceil(h); - scalar_t dist_x = w - x0, dist_y = h - y0; - scalar_t q00 = (1 - dist_x) * (1 - dist_y); - scalar_t q01 = (1 - dist_x) * dist_y; - scalar_t q10 = dist_x * (1 - dist_y); - scalar_t q11 = dist_x * dist_y; - int bottom_index_base = c * height * width; - atomicAdd(offset_bottom_data_diff + bottom_index_base + y0 * width + x0, q00 * diff_val); - atomicAdd(offset_bottom_data_diff + bottom_index_base + y1 * width + x0, q01 * diff_val); - atomicAdd(offset_bottom_data_diff + bottom_index_base + y0 * width + x1, q10 * diff_val); - atomicAdd(offset_bottom_data_diff + bottom_index_base + y1 * width + x1, q11 * diff_val); - - if (no_trans) - { - continue; - } - scalar_t U00 = offset_bottom_data[bottom_index_base + y0 * width + x0]; - scalar_t U01 = offset_bottom_data[bottom_index_base + y1 * width + x0]; - scalar_t U10 = offset_bottom_data[bottom_index_base + y0 * width + x1]; - scalar_t U11 = offset_bottom_data[bottom_index_base + y1 * width + x1]; - scalar_t diff_x = (U11 * dist_y + U10 * (1 - dist_y) - U01 * dist_y - U00 * (1 - dist_y)) * trans_std * diff_val; - diff_x *= roi_width; - scalar_t diff_y = (U11 * dist_x + U01 * (1 - dist_x) - U10 * dist_x - U00 * (1 - dist_x)) * trans_std * diff_val; - diff_y *= roi_height; - - atomicAdd(bottom_trans_diff + (((n * num_classes + class_id) * 2) * part_size + part_h) * part_size + part_w, diff_x); - atomicAdd(bottom_trans_diff + (((n * num_classes + class_id) * 2 + 1) * part_size + part_h) * part_size + part_w, diff_y); - } - } - } -} - -void DeformablePSROIPoolForward(const at::Tensor data, - const at::Tensor bbox, - const at::Tensor trans, - at::Tensor out, - at::Tensor top_count, - const int batch, - const int channels, - const int height, - const int width, - const int num_bbox, - const int channels_trans, - const int no_trans, - const float spatial_scale, - const int output_dim, - const int group_size, - const int pooled_size, - const int part_size, - const int sample_per_part, - const float trans_std) -{ - const int pooled_height = pooled_size; - const int pooled_width = pooled_size; - const int count = num_bbox * output_dim * pooled_height * pooled_width; - const int num_classes = no_trans ? 1 : channels_trans / 2; - const int channels_each_class = no_trans ? output_dim : output_dim / num_classes; - - AT_DISPATCH_FLOATING_TYPES_AND_HALF( - data.scalar_type(), "deformable_psroi_pool_forward", ([&] { - const scalar_t *bottom_data = data.data(); - const scalar_t *bottom_rois = bbox.data(); - const scalar_t *bottom_trans = no_trans ? NULL : trans.data(); - scalar_t *top_data = out.data(); - scalar_t *top_count_data = top_count.data(); - - DeformablePSROIPoolForwardKernel<<>>( - count, bottom_data, (scalar_t)spatial_scale, channels, height, width, pooled_height, pooled_width, - bottom_rois, bottom_trans, no_trans, (scalar_t)trans_std, sample_per_part, output_dim, - group_size, part_size, num_classes, channels_each_class, top_data, top_count_data); - })); - - cudaError_t err = cudaGetLastError(); - if (err != cudaSuccess) - { - printf("error in DeformablePSROIPoolForward: %s\n", cudaGetErrorString(err)); - } -} - -void DeformablePSROIPoolBackwardAcc(const at::Tensor out_grad, - const at::Tensor data, - const at::Tensor bbox, - const at::Tensor trans, - const at::Tensor top_count, - at::Tensor in_grad, - at::Tensor trans_grad, - const int batch, - const int channels, - const int height, - const int width, - const int num_bbox, - const int channels_trans, - const int no_trans, - const float spatial_scale, - const int output_dim, - const int group_size, - const int pooled_size, - const int part_size, - const int sample_per_part, - const float trans_std) -{ - // LOG(INFO) << "DeformablePSROIPoolBackward"; - const int num_rois = num_bbox; - const int pooled_height = pooled_size; - const int pooled_width = pooled_size; - const int count = num_bbox * output_dim * pooled_height * pooled_width; - const int num_classes = no_trans ? 1 : channels_trans / 2; - const int channels_each_class = no_trans ? output_dim : output_dim / num_classes; - - AT_DISPATCH_FLOATING_TYPES_AND_HALF( - out_grad.scalar_type(), "deformable_psroi_pool_backward_acc", ([&] { - const scalar_t *top_diff = out_grad.data(); - const scalar_t *bottom_data = data.data(); - const scalar_t *bottom_rois = bbox.data(); - const scalar_t *bottom_trans = no_trans ? NULL : trans.data(); - scalar_t *bottom_data_diff = in_grad.data(); - scalar_t *bottom_trans_diff = no_trans ? NULL : trans_grad.data(); - const scalar_t *top_count_data = top_count.data(); - - DeformablePSROIPoolBackwardAccKernel<<>>( - count, top_diff, top_count_data, num_rois, (scalar_t)spatial_scale, channels, height, width, - pooled_height, pooled_width, output_dim, bottom_data_diff, bottom_trans_diff, - bottom_data, bottom_rois, bottom_trans, no_trans, (scalar_t)trans_std, sample_per_part, - group_size, part_size, num_classes, channels_each_class); - })); - - cudaError_t err = cudaGetLastError(); - if (err != cudaSuccess) - { - printf("error in DeformablePSROIPoolForward: %s\n", cudaGetErrorString(err)); - } -} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/__init__.py deleted file mode 100644 index f537ace08..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .masked_conv import MaskedConv2d, masked_conv2d - -__all__ = ['masked_conv2d', 'MaskedConv2d'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/masked_conv.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/masked_conv.py deleted file mode 100644 index 7d84f503c..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/masked_conv.py +++ /dev/null @@ -1,89 +0,0 @@ -import math - -import torch -import torch.nn as nn -from torch.autograd import Function -from torch.autograd.function import once_differentiable -from torch.nn.modules.utils import _pair - -from . import masked_conv2d_cuda - - -class MaskedConv2dFunction(Function): - - @staticmethod - def forward(ctx, features, mask, weight, bias, padding=0, stride=1): - assert mask.dim() == 3 and mask.size(0) == 1 - assert features.dim() == 4 and features.size(0) == 1 - assert features.size()[2:] == mask.size()[1:] - pad_h, pad_w = _pair(padding) - stride_h, stride_w = _pair(stride) - if stride_h != 1 or stride_w != 1: - raise ValueError( - 'Stride could not only be 1 in masked_conv2d currently.') - if not features.is_cuda: - raise NotImplementedError - - out_channel, in_channel, kernel_h, kernel_w = weight.size() - - batch_size = features.size(0) - out_h = int( - math.floor((features.size(2) + 2 * pad_h - - (kernel_h - 1) - 1) / stride_h + 1)) - out_w = int( - math.floor((features.size(3) + 2 * pad_w - - (kernel_h - 1) - 1) / stride_w + 1)) - mask_inds = torch.nonzero(mask[0] > 0) - output = features.new_zeros(batch_size, out_channel, out_h, out_w) - if mask_inds.numel() > 0: - mask_h_idx = mask_inds[:, 0].contiguous() - mask_w_idx = mask_inds[:, 1].contiguous() - data_col = features.new_zeros(in_channel * kernel_h * kernel_w, - mask_inds.size(0)) - masked_conv2d_cuda.masked_im2col_forward(features, mask_h_idx, - mask_w_idx, kernel_h, - kernel_w, pad_h, pad_w, - data_col) - - masked_output = torch.addmm(1, bias[:, None], 1, - weight.view(out_channel, -1), data_col) - masked_conv2d_cuda.masked_col2im_forward(masked_output, mask_h_idx, - mask_w_idx, out_h, out_w, - out_channel, output) - return output - - @staticmethod - @once_differentiable - def backward(ctx, grad_output): - return (None, ) * 5 - - -masked_conv2d = MaskedConv2dFunction.apply - - -class MaskedConv2d(nn.Conv2d): - """A MaskedConv2d which inherits the official Conv2d. - - The masked forward doesn't implement the backward function and only - supports the stride parameter to be 1 currently. - """ - - def __init__(self, - in_channels, - out_channels, - kernel_size, - stride=1, - padding=0, - dilation=1, - groups=1, - bias=True): - super(MaskedConv2d, - self).__init__(in_channels, out_channels, kernel_size, stride, - padding, dilation, groups, bias) - - def forward(self, input, mask=None): - if mask is None: # fallback to the normal Conv2d - return super(MaskedConv2d, self).forward(input) - else: - return masked_conv2d(input, mask, self.weight, self.bias, - self.padding) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/src/masked_conv2d_cuda.cpp b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/src/masked_conv2d_cuda.cpp deleted file mode 100644 index 6e495abe3..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/src/masked_conv2d_cuda.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include - -#include -#include - -int MaskedIm2colForwardLaucher(const at::Tensor im, const int height, - const int width, const int channels, - const int kernel_h, const int kernel_w, - const int pad_h, const int pad_w, - const at::Tensor mask_h_idx, - const at::Tensor mask_w_idx, const int mask_cnt, - at::Tensor col); - -int MaskedCol2imForwardLaucher(const at::Tensor col, const int height, - const int width, const int channels, - const at::Tensor mask_h_idx, - const at::Tensor mask_w_idx, const int mask_cnt, - at::Tensor im); - -#define CHECK_CUDA(x) TORCH_CHECK(x.is_cuda(), #x, " must be a CUDAtensor ") -#define CHECK_CONTIGUOUS(x) \ - TORCH_CHECK(x.is_contiguous(), #x, " must be contiguous ") -#define CHECK_INPUT(x) \ - CHECK_CUDA(x); \ - CHECK_CONTIGUOUS(x) - -int masked_im2col_forward_cuda(const at::Tensor im, const at::Tensor mask_h_idx, - const at::Tensor mask_w_idx, const int kernel_h, - const int kernel_w, const int pad_h, - const int pad_w, at::Tensor col) { - CHECK_INPUT(im); - CHECK_INPUT(mask_h_idx); - CHECK_INPUT(mask_w_idx); - CHECK_INPUT(col); - // im: (n, ic, h, w), kernel size (kh, kw) - // kernel: (oc, ic * kh * kw), col: (kh * kw * ic, ow * oh) - - int channels = im.size(1); - int height = im.size(2); - int width = im.size(3); - int mask_cnt = mask_h_idx.size(0); - - MaskedIm2colForwardLaucher(im, height, width, channels, kernel_h, kernel_w, - pad_h, pad_w, mask_h_idx, mask_w_idx, mask_cnt, - col); - - return 1; -} - -int masked_col2im_forward_cuda(const at::Tensor col, - const at::Tensor mask_h_idx, - const at::Tensor mask_w_idx, int height, - int width, int channels, at::Tensor im) { - CHECK_INPUT(col); - CHECK_INPUT(mask_h_idx); - CHECK_INPUT(mask_w_idx); - CHECK_INPUT(im); - // im: (n, ic, h, w), kernel size (kh, kw) - // kernel: (oc, ic * kh * kh), col: (kh * kw * ic, ow * oh) - - int mask_cnt = mask_h_idx.size(0); - - MaskedCol2imForwardLaucher(col, height, width, channels, mask_h_idx, - mask_w_idx, mask_cnt, im); - - return 1; -} - -PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { - m.def("masked_im2col_forward", &masked_im2col_forward_cuda, - "masked_im2col forward (CUDA)"); - m.def("masked_col2im_forward", &masked_col2im_forward_cuda, - "masked_col2im forward (CUDA)"); -} \ No newline at end of file diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/src/masked_conv2d_kernel.cu b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/src/masked_conv2d_kernel.cu deleted file mode 100644 index 0f66eb71b..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/masked_conv/src/masked_conv2d_kernel.cu +++ /dev/null @@ -1,114 +0,0 @@ -#include -#include -#include - -#define CUDA_1D_KERNEL_LOOP(i, n) \ - for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ - i += blockDim.x * gridDim.x) - -#define THREADS_PER_BLOCK 1024 - -inline int GET_BLOCKS(const int N) { - int optimal_block_num = (N + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK; - int max_block_num = 65000; - return optimal_block_num - max_block_num < 0? optimal_block_num: max_block_num; -} - -template -__global__ void MaskedIm2colForward(const int n, const scalar_t *data_im, - const int height, const int width, - const int kernel_h, const int kernel_w, - const int pad_h, const int pad_w, - const int64_t *mask_h_idx, - const int64_t *mask_w_idx, - const int mask_cnt, scalar_t *data_col) { - // mask_cnt * channels - CUDA_1D_KERNEL_LOOP(index, n) { - const int m_index = index % mask_cnt; - const int h_col = mask_h_idx[m_index]; - const int w_col = mask_w_idx[m_index]; - const int c_im = index / mask_cnt; - const int c_col = c_im * kernel_h * kernel_w; - const int h_offset = h_col - pad_h; - const int w_offset = w_col - pad_w; - scalar_t *data_col_ptr = data_col + c_col * mask_cnt + m_index; - for (int i = 0; i < kernel_h; ++i) { - int h_im = h_offset + i; - for (int j = 0; j < kernel_w; ++j) { - int w_im = w_offset + j; - if (h_im >= 0 && w_im >= 0 && h_im < height && w_im < width) { - *data_col_ptr = - (scalar_t)data_im[(c_im * height + h_im) * width + w_im]; - } else { - *data_col_ptr = 0.0; - } - data_col_ptr += mask_cnt; - } - } - } -} - -int MaskedIm2colForwardLaucher(const at::Tensor bottom_data, const int height, - const int width, const int channels, - const int kernel_h, const int kernel_w, - const int pad_h, const int pad_w, - const at::Tensor mask_h_idx, - const at::Tensor mask_w_idx, const int mask_cnt, - at::Tensor top_data) { - const int output_size = mask_cnt * channels; - - AT_DISPATCH_FLOATING_TYPES_AND_HALF( - bottom_data.scalar_type(), "MaskedIm2colLaucherForward", ([&] { - const scalar_t *bottom_data_ = bottom_data.data(); - const int64_t *mask_h_idx_ = mask_h_idx.data(); - const int64_t *mask_w_idx_ = mask_w_idx.data(); - scalar_t *top_data_ = top_data.data(); - MaskedIm2colForward - <<>>( - output_size, bottom_data_, height, width, kernel_h, kernel_w, - pad_h, pad_w, mask_h_idx_, mask_w_idx_, mask_cnt, top_data_); - })); - THCudaCheck(cudaGetLastError()); - return 1; -} - -template -__global__ void MaskedCol2imForward(const int n, const scalar_t *data_col, - const int height, const int width, - const int channels, - const int64_t *mask_h_idx, - const int64_t *mask_w_idx, - const int mask_cnt, scalar_t *data_im) { - CUDA_1D_KERNEL_LOOP(index, n) { - const int m_index = index % mask_cnt; - const int h_im = mask_h_idx[m_index]; - const int w_im = mask_w_idx[m_index]; - const int c_im = index / mask_cnt; - // compute the start and end of the output - data_im[(c_im * height + h_im) * width + w_im] = data_col[index]; - } -} - -int MaskedCol2imForwardLaucher(const at::Tensor bottom_data, const int height, - const int width, const int channels, - const at::Tensor mask_h_idx, - const at::Tensor mask_w_idx, const int mask_cnt, - at::Tensor top_data) { - const int output_size = mask_cnt * channels; - - AT_DISPATCH_FLOATING_TYPES_AND_HALF( - bottom_data.scalar_type(), "MaskedCol2imLaucherForward", ([&] { - const scalar_t *bottom_data_ = bottom_data.data(); - const int64_t *mask_h_idx_ = mask_h_idx.data(); - const int64_t *mask_w_idx_ = mask_w_idx.data(); - scalar_t *top_data_ = top_data.data(); - - MaskedCol2imForward - <<>>( - output_size, bottom_data_, height, width, channels, mask_h_idx_, - mask_w_idx_, mask_cnt, top_data_); - })); - THCudaCheck(cudaGetLastError()); - return 1; -} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/__init__.py deleted file mode 100644 index c4407041a..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .nms_wrapper import nms, soft_nms - -__all__ = ['nms', 'soft_nms'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/nms_wrapper.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/nms_wrapper.py deleted file mode 100644 index b82e49345..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/nms_wrapper.py +++ /dev/null @@ -1,102 +0,0 @@ -import numpy as np -import torch - -from . import nms_cpu, nms_cuda -from .soft_nms_cpu import soft_nms_cpu - - -def nms(dets, iou_thr, device_id=None): - """Dispatch to either CPU or GPU NMS implementations. - - The input can be either a torch tensor or numpy array. GPU NMS will be used - if the input is a gpu tensor or device_id is specified, otherwise CPU NMS - will be used. The returned type will always be the same as inputs. - - Arguments: - dets (torch.Tensor or np.ndarray): bboxes with scores. - iou_thr (float): IoU threshold for NMS. - device_id (int, optional): when `dets` is a numpy array, if `device_id` - is None, then cpu nms is used, otherwise gpu_nms will be used. - - Returns: - tuple: kept bboxes and indice, which is always the same data type as - the input. - - Example: - >>> dets = np.array([[49.1, 32.4, 51.0, 35.9, 0.9], - >>> [49.3, 32.9, 51.0, 35.3, 0.9], - >>> [49.2, 31.8, 51.0, 35.4, 0.5], - >>> [35.1, 11.5, 39.1, 15.7, 0.5], - >>> [35.6, 11.8, 39.3, 14.2, 0.5], - >>> [35.3, 11.5, 39.9, 14.5, 0.4], - >>> [35.2, 11.7, 39.7, 15.7, 0.3]], dtype=np.float32) - >>> iou_thr = 0.7 - >>> supressed, inds = nms(dets, iou_thr) - >>> assert len(inds) == len(supressed) == 3 - """ - # convert dets (tensor or numpy array) to tensor - if isinstance(dets, torch.Tensor): - is_numpy = False - dets_th = dets - elif isinstance(dets, np.ndarray): - is_numpy = True - device = 'cpu' if device_id is None else 'cuda:{}'.format(device_id) - dets_th = torch.from_numpy(dets).to(device) - else: - raise TypeError( - 'dets must be either a Tensor or numpy array, but got {}'.format( - type(dets))) - - # execute cpu or cuda nms - if dets_th.shape[0] == 0: - inds = dets_th.new_zeros(0, dtype=torch.long) - else: - if dets_th.is_cuda: - inds = nms_cuda.nms(dets_th, iou_thr) - else: - inds = nms_cpu.nms(dets_th, iou_thr) - - if is_numpy: - inds = inds.cpu().numpy() - return dets[inds, :], inds - - -def soft_nms(dets, iou_thr, method='linear', sigma=0.5, min_score=1e-3): - """ - Example: - >>> dets = np.array([[4., 3., 5., 3., 0.9], - >>> [4., 3., 5., 4., 0.9], - >>> [3., 1., 3., 1., 0.5], - >>> [3., 1., 3., 1., 0.5], - >>> [3., 1., 3., 1., 0.4], - >>> [3., 1., 3., 1., 0.0]], dtype=np.float32) - >>> iou_thr = 0.7 - >>> supressed, inds = soft_nms(dets, iou_thr, sigma=0.5) - >>> assert len(inds) == len(supressed) == 3 - """ - if isinstance(dets, torch.Tensor): - is_tensor = True - dets_np = dets.detach().cpu().numpy() - elif isinstance(dets, np.ndarray): - is_tensor = False - dets_np = dets - else: - raise TypeError( - 'dets must be either a Tensor or numpy array, but got {}'.format( - type(dets))) - - method_codes = {'linear': 1, 'gaussian': 2} - if method not in method_codes: - raise ValueError('Invalid method for SoftNMS: {}'.format(method)) - new_dets, inds = soft_nms_cpu( - dets_np, - iou_thr, - method=method_codes[method], - sigma=sigma, - min_score=min_score) - - if is_tensor: - return dets.new_tensor(new_dets), dets.new_tensor( - inds, dtype=torch.long) - else: - return new_dets.astype(np.float32), inds.astype(np.int64) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_cpu.cpp b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_cpu.cpp deleted file mode 100644 index f7cffb490..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_cpu.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -#include - -template -at::Tensor nms_cpu_kernel(const at::Tensor& dets, const float threshold) { - AT_ASSERTM(!dets.type().is_cuda(), "dets must be a CPU tensor"); - - if (dets.numel() == 0) { - return at::empty({0}, dets.options().dtype(at::kLong).device(at::kCPU)); - } - - auto x1_t = dets.select(1, 0).contiguous(); - auto y1_t = dets.select(1, 1).contiguous(); - auto x2_t = dets.select(1, 2).contiguous(); - auto y2_t = dets.select(1, 3).contiguous(); - auto scores = dets.select(1, 4).contiguous(); - - at::Tensor areas_t = (x2_t - x1_t + 1) * (y2_t - y1_t + 1); - - auto order_t = std::get<1>(scores.sort(0, /* descending=*/true)); - - auto ndets = dets.size(0); - at::Tensor suppressed_t = - at::zeros({ndets}, dets.options().dtype(at::kByte).device(at::kCPU)); - - auto suppressed = suppressed_t.data(); - auto order = order_t.data(); - auto x1 = x1_t.data(); - auto y1 = y1_t.data(); - auto x2 = x2_t.data(); - auto y2 = y2_t.data(); - auto areas = areas_t.data(); - - for (int64_t _i = 0; _i < ndets; _i++) { - auto i = order[_i]; - if (suppressed[i] == 1) continue; - auto ix1 = x1[i]; - auto iy1 = y1[i]; - auto ix2 = x2[i]; - auto iy2 = y2[i]; - auto iarea = areas[i]; - - for (int64_t _j = _i + 1; _j < ndets; _j++) { - auto j = order[_j]; - if (suppressed[j] == 1) continue; - auto xx1 = std::max(ix1, x1[j]); - auto yy1 = std::max(iy1, y1[j]); - auto xx2 = std::min(ix2, x2[j]); - auto yy2 = std::min(iy2, y2[j]); - - auto w = std::max(static_cast(0), xx2 - xx1 + 1); - auto h = std::max(static_cast(0), yy2 - yy1 + 1); - auto inter = w * h; - auto ovr = inter / (iarea + areas[j] - inter); - if (ovr >= threshold) suppressed[j] = 1; - } - } - return at::nonzero(suppressed_t == 0).squeeze(1); -} - -at::Tensor nms(const at::Tensor& dets, const float threshold) { - at::Tensor result; - AT_DISPATCH_FLOATING_TYPES(dets.scalar_type(), "nms", [&] { - result = nms_cpu_kernel(dets, threshold); - }); - return result; -} - -PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { - m.def("nms", &nms, "non-maximum suppression"); -} \ No newline at end of file diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_cuda.cpp b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_cuda.cpp deleted file mode 100644 index 2ac6cd23f..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_cuda.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -#include - -#define CHECK_CUDA(x) TORCH_CHECK(x.is_cuda(), #x, " must be a CUDAtensor ") - -at::Tensor nms_cuda(const at::Tensor boxes, float nms_overlap_thresh); - -at::Tensor nms(const at::Tensor& dets, const float threshold) { - CHECK_CUDA(dets); - if (dets.numel() == 0) - return at::empty({0}, dets.options().dtype(at::kLong).device(at::kCPU)); - return nms_cuda(dets, threshold); -} - -PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { - m.def("nms", &nms, "non-maximum suppression"); -} \ No newline at end of file diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_kernel.cu b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_kernel.cu deleted file mode 100644 index ada9bea25..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/nms_kernel.cu +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -#include -#include -#include - -#include -#include - -#include -#include - -int const threadsPerBlock = sizeof(unsigned long long) * 8; - -__device__ inline float devIoU(float const * const a, float const * const b) { - float left = max(a[0], b[0]), right = min(a[2], b[2]); - float top = max(a[1], b[1]), bottom = min(a[3], b[3]); - float width = max(right - left + 1, 0.f), height = max(bottom - top + 1, 0.f); - float interS = width * height; - float Sa = (a[2] - a[0] + 1) * (a[3] - a[1] + 1); - float Sb = (b[2] - b[0] + 1) * (b[3] - b[1] + 1); - return interS / (Sa + Sb - interS); -} - -__global__ void nms_kernel(const int n_boxes, const float nms_overlap_thresh, - const float *dev_boxes, unsigned long long *dev_mask) { - const int row_start = blockIdx.y; - const int col_start = blockIdx.x; - - // if (row_start > col_start) return; - - const int row_size = - min(n_boxes - row_start * threadsPerBlock, threadsPerBlock); - const int col_size = - min(n_boxes - col_start * threadsPerBlock, threadsPerBlock); - - __shared__ float block_boxes[threadsPerBlock * 5]; - if (threadIdx.x < col_size) { - block_boxes[threadIdx.x * 5 + 0] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 0]; - block_boxes[threadIdx.x * 5 + 1] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 1]; - block_boxes[threadIdx.x * 5 + 2] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 2]; - block_boxes[threadIdx.x * 5 + 3] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 3]; - block_boxes[threadIdx.x * 5 + 4] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 4]; - } - __syncthreads(); - - if (threadIdx.x < row_size) { - const int cur_box_idx = threadsPerBlock * row_start + threadIdx.x; - const float *cur_box = dev_boxes + cur_box_idx * 5; - int i = 0; - unsigned long long t = 0; - int start = 0; - if (row_start == col_start) { - start = threadIdx.x + 1; - } - for (i = start; i < col_size; i++) { - if (devIoU(cur_box, block_boxes + i * 5) > nms_overlap_thresh) { - t |= 1ULL << i; - } - } - const int col_blocks = THCCeilDiv(n_boxes, threadsPerBlock); - dev_mask[cur_box_idx * col_blocks + col_start] = t; - } -} - -// boxes is a N x 5 tensor -at::Tensor nms_cuda(const at::Tensor boxes, float nms_overlap_thresh) { - - // Ensure CUDA uses the input tensor device. - at::DeviceGuard guard(boxes.device()); - - using scalar_t = float; - AT_ASSERTM(boxes.type().is_cuda(), "boxes must be a CUDA tensor"); - auto scores = boxes.select(1, 4); - auto order_t = std::get<1>(scores.sort(0, /* descending=*/true)); - auto boxes_sorted = boxes.index_select(0, order_t); - - int boxes_num = boxes.size(0); - - const int col_blocks = THCCeilDiv(boxes_num, threadsPerBlock); - - scalar_t* boxes_dev = boxes_sorted.data(); - - THCState *state = at::globalContext().lazyInitCUDA(); // TODO replace with getTHCState - - unsigned long long* mask_dev = NULL; - //THCudaCheck(THCudaMalloc(state, (void**) &mask_dev, - // boxes_num * col_blocks * sizeof(unsigned long long))); - - mask_dev = (unsigned long long*) THCudaMalloc(state, boxes_num * col_blocks * sizeof(unsigned long long)); - - dim3 blocks(THCCeilDiv(boxes_num, threadsPerBlock), - THCCeilDiv(boxes_num, threadsPerBlock)); - dim3 threads(threadsPerBlock); - nms_kernel<<>>(boxes_num, - nms_overlap_thresh, - boxes_dev, - mask_dev); - - std::vector mask_host(boxes_num * col_blocks); - THCudaCheck(cudaMemcpyAsync( - &mask_host[0], - mask_dev, - sizeof(unsigned long long) * boxes_num * col_blocks, - cudaMemcpyDeviceToHost, - at::cuda::getCurrentCUDAStream() - )); - - std::vector remv(col_blocks); - memset(&remv[0], 0, sizeof(unsigned long long) * col_blocks); - - at::Tensor keep = at::empty({boxes_num}, boxes.options().dtype(at::kLong).device(at::kCPU)); - int64_t* keep_out = keep.data(); - - int num_to_keep = 0; - for (int i = 0; i < boxes_num; i++) { - int nblock = i / threadsPerBlock; - int inblock = i % threadsPerBlock; - - if (!(remv[nblock] & (1ULL << inblock))) { - keep_out[num_to_keep++] = i; - unsigned long long *p = &mask_host[0] + i * col_blocks; - for (int j = nblock; j < col_blocks; j++) { - remv[j] |= p[j]; - } - } - } - - THCudaFree(state, mask_dev); - // TODO improve this part - return std::get<0>(order_t.index({ - keep.narrow(/*dim=*/0, /*start=*/0, /*length=*/num_to_keep).to( - order_t.device(), keep.scalar_type()) - }).sort(0, false)); -} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/soft_nms_cpu.pyx b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/soft_nms_cpu.pyx deleted file mode 100644 index 97f53f18d..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/nms/src/soft_nms_cpu.pyx +++ /dev/null @@ -1,127 +0,0 @@ -# ---------------------------------------------------------- -# Soft-NMS: Improving Object Detection With One Line of Code -# Copyright (c) University of Maryland, College Park -# Licensed under The MIT License [see LICENSE for details] -# Written by Navaneeth Bodla and Bharat Singh -# Modified by Kai Chen -# ---------------------------------------------------------- - -# cython: language_level=3, boundscheck=False - -import numpy as np -cimport numpy as np - - -cdef inline np.float32_t max(np.float32_t a, np.float32_t b): - return a if a >= b else b - -cdef inline np.float32_t min(np.float32_t a, np.float32_t b): - return a if a <= b else b - - -def soft_nms_cpu( - np.ndarray[float, ndim=2] boxes_in, - float iou_thr, - unsigned int method=1, - float sigma=0.5, - float min_score=0.001, -): - boxes = boxes_in.copy() - cdef int N = boxes.shape[0] - cdef float iw, ih, box_area - cdef float ua - cdef int pos = 0 - cdef float maxscore = 0 - cdef int maxpos = 0 - cdef float x1, x2, y1, y2, tx1, tx2, ty1, ty2, ts, area, weight, ov - inds = np.arange(N) - - for i in range(N): - maxscore = boxes[i, 4] - maxpos = i - - tx1 = boxes[i, 0] - ty1 = boxes[i, 1] - tx2 = boxes[i, 2] - ty2 = boxes[i, 3] - ts = boxes[i, 4] - ti = inds[i] - - pos = i + 1 - # get max box - while pos < N: - if maxscore < boxes[pos, 4]: - maxscore = boxes[pos, 4] - maxpos = pos - pos = pos + 1 - - # add max box as a detection - boxes[i, 0] = boxes[maxpos, 0] - boxes[i, 1] = boxes[maxpos, 1] - boxes[i, 2] = boxes[maxpos, 2] - boxes[i, 3] = boxes[maxpos, 3] - boxes[i, 4] = boxes[maxpos, 4] - inds[i] = inds[maxpos] - - # swap ith box with position of max box - boxes[maxpos, 0] = tx1 - boxes[maxpos, 1] = ty1 - boxes[maxpos, 2] = tx2 - boxes[maxpos, 3] = ty2 - boxes[maxpos, 4] = ts - inds[maxpos] = ti - - tx1 = boxes[i, 0] - ty1 = boxes[i, 1] - tx2 = boxes[i, 2] - ty2 = boxes[i, 3] - ts = boxes[i, 4] - - pos = i + 1 - # NMS iterations, note that N changes if detection boxes fall below - # threshold - while pos < N: - x1 = boxes[pos, 0] - y1 = boxes[pos, 1] - x2 = boxes[pos, 2] - y2 = boxes[pos, 3] - s = boxes[pos, 4] - - area = (x2 - x1 + 1) * (y2 - y1 + 1) - iw = (min(tx2, x2) - max(tx1, x1) + 1) - if iw > 0: - ih = (min(ty2, y2) - max(ty1, y1) + 1) - if ih > 0: - ua = float((tx2 - tx1 + 1) * (ty2 - ty1 + 1) + area - iw * ih) - ov = iw * ih / ua # iou between max box and detection box - - if method == 1: # linear - if ov > iou_thr: - weight = 1 - ov - else: - weight = 1 - elif method == 2: # gaussian - weight = np.exp(-(ov * ov) / sigma) - else: # original NMS - if ov > iou_thr: - weight = 0 - else: - weight = 1 - - boxes[pos, 4] = weight * boxes[pos, 4] - - # if box score falls below threshold, discard the box by - # swapping with last box update N - if boxes[pos, 4] < min_score: - boxes[pos, 0] = boxes[N-1, 0] - boxes[pos, 1] = boxes[N-1, 1] - boxes[pos, 2] = boxes[N-1, 2] - boxes[pos, 3] = boxes[N-1, 3] - boxes[pos, 4] = boxes[N-1, 4] - inds[pos] = inds[N - 1] - N = N - 1 - pos = pos - 1 - - pos = pos + 1 - - return boxes[:N], inds[:N] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/__init__.py deleted file mode 100644 index 6da98298f..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .roi_align import RoIAlign, roi_align - -__all__ = ['roi_align', 'RoIAlign'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/gradcheck.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/gradcheck.py deleted file mode 100644 index 136456b39..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/gradcheck.py +++ /dev/null @@ -1,30 +0,0 @@ -import os.path as osp -import sys - -import numpy as np -import torch -from torch.autograd import gradcheck - -sys.path.append(osp.abspath(osp.join(__file__, '../../'))) -from roi_align import RoIAlign # noqa: E402, isort:skip - -feat_size = 15 -spatial_scale = 1.0 / 8 -img_size = feat_size / spatial_scale -num_imgs = 2 -num_rois = 20 - -batch_ind = np.random.randint(num_imgs, size=(num_rois, 1)) -rois = np.random.rand(num_rois, 4) * img_size * 0.5 -rois[:, 2:] += img_size * 0.5 -rois = np.hstack((batch_ind, rois)) - -feat = torch.randn( - num_imgs, 16, feat_size, feat_size, requires_grad=True, device='cuda:0') -rois = torch.from_numpy(rois).float().cuda() -inputs = (feat, rois) -print('Gradcheck for roi align...') -test = gradcheck(RoIAlign(3, spatial_scale), inputs, atol=1e-3, eps=1e-3) -print(test) -test = gradcheck(RoIAlign(3, spatial_scale, 2), inputs, atol=1e-3, eps=1e-3) -print(test) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/roi_align.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/roi_align.py deleted file mode 100644 index a4cf24459..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/roi_align.py +++ /dev/null @@ -1,87 +0,0 @@ -import torch.nn as nn -from torch.autograd import Function -from torch.autograd.function import once_differentiable -from torch.nn.modules.utils import _pair - -from . import roi_align_cuda - - -class RoIAlignFunction(Function): - - @staticmethod - def forward(ctx, features, rois, out_size, spatial_scale, sample_num=0): - out_h, out_w = _pair(out_size) - assert isinstance(out_h, int) and isinstance(out_w, int) - ctx.spatial_scale = spatial_scale - ctx.sample_num = sample_num - ctx.save_for_backward(rois) - ctx.feature_size = features.size() - - batch_size, num_channels, data_height, data_width = features.size() - num_rois = rois.size(0) - - output = features.new_zeros(num_rois, num_channels, out_h, out_w) - if features.is_cuda: - roi_align_cuda.forward(features, rois, out_h, out_w, spatial_scale, - sample_num, output) - else: - raise NotImplementedError - - return output - - @staticmethod - @once_differentiable - def backward(ctx, grad_output): - feature_size = ctx.feature_size - spatial_scale = ctx.spatial_scale - sample_num = ctx.sample_num - rois = ctx.saved_tensors[0] - assert (feature_size is not None and grad_output.is_cuda) - - batch_size, num_channels, data_height, data_width = feature_size - out_w = grad_output.size(3) - out_h = grad_output.size(2) - - grad_input = grad_rois = None - if ctx.needs_input_grad[0]: - grad_input = rois.new_zeros(batch_size, num_channels, data_height, - data_width) - roi_align_cuda.backward(grad_output.contiguous(), rois, out_h, - out_w, spatial_scale, sample_num, - grad_input) - - return grad_input, grad_rois, None, None, None - - -roi_align = RoIAlignFunction.apply - - -class RoIAlign(nn.Module): - - def __init__(self, - out_size, - spatial_scale, - sample_num=0, - use_torchvision=False): - super(RoIAlign, self).__init__() - - self.out_size = _pair(out_size) - self.spatial_scale = float(spatial_scale) - self.sample_num = int(sample_num) - self.use_torchvision = use_torchvision - - def forward(self, features, rois): - if self.use_torchvision: - from torchvision.ops import roi_align as tv_roi_align - return tv_roi_align(features, rois, self.out_size, - self.spatial_scale, self.sample_num) - else: - return roi_align(features, rois, self.out_size, self.spatial_scale, - self.sample_num) - - def __repr__(self): - format_str = self.__class__.__name__ - format_str += '(out_size={}, spatial_scale={}, sample_num={}'.format( - self.out_size, self.spatial_scale, self.sample_num) - format_str += ', use_torchvision={})'.format(self.use_torchvision) - return format_str diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/src/roi_align_cuda.cpp b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/src/roi_align_cuda.cpp deleted file mode 100644 index 66a557252..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/src/roi_align_cuda.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include - -#include - -#include -#include - -int ROIAlignForwardLaucher(const at::Tensor features, const at::Tensor rois, - const float spatial_scale, const int sample_num, - const int channels, const int height, - const int width, const int num_rois, - const int pooled_height, const int pooled_width, - at::Tensor output); - -int ROIAlignBackwardLaucher(const at::Tensor top_grad, const at::Tensor rois, - const float spatial_scale, const int sample_num, - const int channels, const int height, - const int width, const int num_rois, - const int pooled_height, const int pooled_width, - at::Tensor bottom_grad); - -#define CHECK_CUDA(x) TORCH_CHECK(x.is_cuda(), #x, " must be a CUDAtensor ") -#define CHECK_CONTIGUOUS(x) \ - TORCH_CHECK(x.is_contiguous(), #x, " must be contiguous ") -#define CHECK_INPUT(x) \ - CHECK_CUDA(x); \ - CHECK_CONTIGUOUS(x) - -int roi_align_forward_cuda(at::Tensor features, at::Tensor rois, - int pooled_height, int pooled_width, - float spatial_scale, int sample_num, - at::Tensor output) { - CHECK_INPUT(features); - CHECK_INPUT(rois); - CHECK_INPUT(output); - - // Number of ROIs - int num_rois = rois.size(0); - int size_rois = rois.size(1); - - if (size_rois != 5) { - printf("wrong roi size\n"); - return 0; - } - - int num_channels = features.size(1); - int data_height = features.size(2); - int data_width = features.size(3); - - ROIAlignForwardLaucher(features, rois, spatial_scale, sample_num, - num_channels, data_height, data_width, num_rois, - pooled_height, pooled_width, output); - - return 1; -} - -int roi_align_backward_cuda(at::Tensor top_grad, at::Tensor rois, - int pooled_height, int pooled_width, - float spatial_scale, int sample_num, - at::Tensor bottom_grad) { - CHECK_INPUT(top_grad); - CHECK_INPUT(rois); - CHECK_INPUT(bottom_grad); - - // Number of ROIs - int num_rois = rois.size(0); - int size_rois = rois.size(1); - if (size_rois != 5) { - printf("wrong roi size\n"); - return 0; - } - - int num_channels = bottom_grad.size(1); - int data_height = bottom_grad.size(2); - int data_width = bottom_grad.size(3); - - ROIAlignBackwardLaucher(top_grad, rois, spatial_scale, sample_num, - num_channels, data_height, data_width, num_rois, - pooled_height, pooled_width, bottom_grad); - - return 1; -} - -PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { - m.def("forward", &roi_align_forward_cuda, "Roi_Align forward (CUDA)"); - m.def("backward", &roi_align_backward_cuda, "Roi_Align backward (CUDA)"); -} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/src/roi_align_kernel.cu b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/src/roi_align_kernel.cu deleted file mode 100644 index 038fc23e0..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_align/src/roi_align_kernel.cu +++ /dev/null @@ -1,283 +0,0 @@ -#include -#include -#include - -#define CUDA_1D_KERNEL_LOOP(i, n) \ - for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ - i += blockDim.x * gridDim.x) - -#define THREADS_PER_BLOCK 1024 - -inline int GET_BLOCKS(const int N) { - int optimal_block_num = (N + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK; - int max_block_num = 65000; - return optimal_block_num - max_block_num < 0? optimal_block_num: max_block_num; -} - -template -__device__ scalar_t bilinear_interpolate(const scalar_t *bottom_data, - const int height, const int width, - scalar_t y, scalar_t x) { - // deal with cases that inverse elements are out of feature map boundary - if (y < -1.0 || y > height || x < -1.0 || x > width) { - return 0; - } - - if (y <= 0) y = 0; - if (x <= 0) x = 0; - - int y_low = (int)y; - int x_low = (int)x; - int y_high; - int x_high; - - if (y_low >= height - 1) { - y_high = y_low = height - 1; - y = (scalar_t)y_low; - } else { - y_high = y_low + 1; - } - - if (x_low >= width - 1) { - x_high = x_low = width - 1; - x = (scalar_t)x_low; - } else { - x_high = x_low + 1; - } - - scalar_t ly = y - y_low; - scalar_t lx = x - x_low; - scalar_t hy = 1. - ly; - scalar_t hx = 1. - lx; - // do bilinear interpolation - scalar_t lt = bottom_data[y_low * width + x_low]; - scalar_t rt = bottom_data[y_low * width + x_high]; - scalar_t lb = bottom_data[y_high * width + x_low]; - scalar_t rb = bottom_data[y_high * width + x_high]; - scalar_t w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; - - scalar_t val = (w1 * lt + w2 * rt + w3 * lb + w4 * rb); - - return val; -} - -template -__global__ void ROIAlignForward(const int nthreads, const scalar_t *bottom_data, - const scalar_t *bottom_rois, - const scalar_t spatial_scale, - const int sample_num, const int channels, - const int height, const int width, - const int pooled_height, const int pooled_width, - scalar_t *top_data) { - CUDA_1D_KERNEL_LOOP(index, nthreads) { - // (n, c, ph, pw) is an element in the aligned output - int pw = index % pooled_width; - int ph = (index / pooled_width) % pooled_height; - int c = (index / pooled_width / pooled_height) % channels; - int n = index / pooled_width / pooled_height / channels; - - const scalar_t *offset_bottom_rois = bottom_rois + n * 5; - int roi_batch_ind = offset_bottom_rois[0]; - scalar_t roi_start_w = offset_bottom_rois[1] * spatial_scale; - scalar_t roi_start_h = offset_bottom_rois[2] * spatial_scale; - scalar_t roi_end_w = (offset_bottom_rois[3] + 1) * spatial_scale; - scalar_t roi_end_h = (offset_bottom_rois[4] + 1) * spatial_scale; - - // Force malformed ROIs to be 1x1 - scalar_t roi_width = fmaxf((scalar_t)roi_end_w - roi_start_w, 0.); - scalar_t roi_height = fmaxf((scalar_t)roi_end_h - roi_start_h, 0.); - - scalar_t bin_size_h = roi_height / pooled_height; - scalar_t bin_size_w = roi_width / pooled_width; - - const scalar_t *offset_bottom_data = - bottom_data + (roi_batch_ind * channels + c) * height * width; - - int sample_num_h = (sample_num > 0) - ? sample_num - : ceil(roi_height / pooled_height); // e.g., = 2 - int sample_num_w = - (sample_num > 0) ? sample_num : ceil(roi_width / pooled_width); - - scalar_t output_val = 0; - for (int iy = 0; iy < sample_num_h; iy++) { - const scalar_t y = roi_start_h + ph * bin_size_h + - (scalar_t)(iy + scalar_t(.5f)) * bin_size_h / - (scalar_t)(sample_num_h); - for (int ix = 0; ix < sample_num_w; ix++) { - const scalar_t x = roi_start_w + pw * bin_size_w + - (scalar_t)(ix + scalar_t(.5f)) * bin_size_w / - (scalar_t)(sample_num_w); - scalar_t val = bilinear_interpolate(offset_bottom_data, - height, width, y, x); - output_val += val; - } - } - output_val /= (sample_num_h * sample_num_w); - top_data[index] = output_val; - } -} - -int ROIAlignForwardLaucher(const at::Tensor features, const at::Tensor rois, - const float spatial_scale, const int sample_num, - const int channels, const int height, - const int width, const int num_rois, - const int pooled_height, const int pooled_width, - at::Tensor output) { - const int output_size = num_rois * pooled_height * pooled_width * channels; - AT_DISPATCH_FLOATING_TYPES_AND_HALF( - features.scalar_type(), "ROIAlignLaucherForward", ([&] { - const scalar_t *bottom_data = features.data(); - const scalar_t *rois_data = rois.data(); - scalar_t *top_data = output.data(); - - ROIAlignForward - <<>>( - output_size, bottom_data, rois_data, scalar_t(spatial_scale), - sample_num, channels, height, width, pooled_height, - pooled_width, top_data); - })); - THCudaCheck(cudaGetLastError()); - return 1; -} - -template -__device__ void bilinear_interpolate_gradient(const int height, const int width, - scalar_t y, scalar_t x, - scalar_t &w1, scalar_t &w2, - scalar_t &w3, scalar_t &w4, - int &x_low, int &x_high, - int &y_low, int &y_high) { - // deal with cases that inverse elements are out of feature map boundary - if (y < -1.0 || y > height || x < -1.0 || x > width) { - w1 = w2 = w3 = w4 = 0.; - x_low = x_high = y_low = y_high = -1; - return; - } - - if (y <= 0) y = 0; - if (x <= 0) x = 0; - - y_low = (int)y; - x_low = (int)x; - - if (y_low >= height - 1) { - y_high = y_low = height - 1; - y = (scalar_t)y_low; - } else { - y_high = y_low + 1; - } - - if (x_low >= width - 1) { - x_high = x_low = width - 1; - x = (scalar_t)x_low; - } else { - x_high = x_low + 1; - } - - scalar_t ly = y - y_low; - scalar_t lx = x - x_low; - scalar_t hy = 1. - ly; - scalar_t hx = 1. - lx; - - w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; - - return; -} - -template -__global__ void ROIAlignBackward( - const int nthreads, const scalar_t *top_diff, const scalar_t *bottom_rois, - const scalar_t spatial_scale, const int sample_num, const int channels, - const int height, const int width, const int pooled_height, - const int pooled_width, scalar_t *bottom_diff) { - CUDA_1D_KERNEL_LOOP(index, nthreads) { - // (n, c, ph, pw) is an element in the aligned output - int pw = index % pooled_width; - int ph = (index / pooled_width) % pooled_height; - int c = (index / pooled_width / pooled_height) % channels; - int n = index / pooled_width / pooled_height / channels; - - const scalar_t *offset_bottom_rois = bottom_rois + n * 5; - int roi_batch_ind = offset_bottom_rois[0]; - scalar_t roi_start_w = offset_bottom_rois[1] * spatial_scale; - scalar_t roi_start_h = offset_bottom_rois[2] * spatial_scale; - scalar_t roi_end_w = (offset_bottom_rois[3] + 1) * spatial_scale; - scalar_t roi_end_h = (offset_bottom_rois[4] + 1) * spatial_scale; - - // Force malformed ROIs to be 1x1 - scalar_t roi_width = fmaxf((scalar_t)roi_end_w - roi_start_w, 0.); - scalar_t roi_height = fmaxf((scalar_t)roi_end_h - roi_start_h, 0.); - - scalar_t bin_size_h = roi_height / pooled_height; - scalar_t bin_size_w = roi_width / pooled_width; - - scalar_t *offset_bottom_diff = - bottom_diff + (roi_batch_ind * channels + c) * height * width; - int offset_top = (n * channels + c) * pooled_height * pooled_width + - ph * pooled_width + pw; - scalar_t offset_top_diff = top_diff[offset_top]; - - int sample_num_h = (sample_num > 0) - ? sample_num - : ceil(roi_height / pooled_height); // e.g., = 2 - int sample_num_w = - (sample_num > 0) ? sample_num : ceil(roi_width / pooled_width); - - const scalar_t count = (scalar_t)(sample_num_h * sample_num_w); - - for (int iy = 0; iy < sample_num_h; iy++) { - const scalar_t y = - roi_start_h + ph * bin_size_h + - (scalar_t)(iy + .5f) * bin_size_h / (scalar_t)(sample_num_h); - for (int ix = 0; ix < sample_num_w; ix++) { - const scalar_t x = - roi_start_w + pw * bin_size_w + - (scalar_t)(ix + .5f) * bin_size_w / (scalar_t)(sample_num_w); - scalar_t w1, w2, w3, w4; - int x_low, x_high, y_low, y_high; - - bilinear_interpolate_gradient( - height, width, y, x, w1, w2, w3, w4, x_low, x_high, y_low, y_high); - scalar_t g1 = offset_top_diff * w1 / count; - scalar_t g2 = offset_top_diff * w2 / count; - scalar_t g3 = offset_top_diff * w3 / count; - scalar_t g4 = offset_top_diff * w4 / count; - if (x_low >= 0 && x_high >= 0 && y_low >= 0 && y_high >= 0) { - atomicAdd(offset_bottom_diff + y_low * width + x_low, g1); - atomicAdd(offset_bottom_diff + y_low * width + x_high, g2); - atomicAdd(offset_bottom_diff + y_high * width + x_low, g3); - atomicAdd(offset_bottom_diff + y_high * width + x_high, g4); - } - } - } - } -} - -int ROIAlignBackwardLaucher(const at::Tensor top_grad, const at::Tensor rois, - const float spatial_scale, const int sample_num, - const int channels, const int height, - const int width, const int num_rois, - const int pooled_height, const int pooled_width, - at::Tensor bottom_grad) { - const int output_size = num_rois * pooled_height * pooled_width * channels; - - AT_DISPATCH_FLOATING_TYPES_AND_HALF( - top_grad.scalar_type(), "ROIAlignLaucherBackward", ([&] { - const scalar_t *top_diff = top_grad.data(); - const scalar_t *rois_data = rois.data(); - scalar_t *bottom_diff = bottom_grad.data(); - if (sizeof(scalar_t) == sizeof(double)) { - fprintf(stderr, "double is not supported\n"); - exit(-1); - } - - ROIAlignBackward - <<>>( - output_size, top_diff, rois_data, spatial_scale, sample_num, - channels, height, width, pooled_height, pooled_width, - bottom_diff); - })); - THCudaCheck(cudaGetLastError()); - return 1; -} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/__init__.py deleted file mode 100644 index 9f0474e59..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .roi_pool import RoIPool, roi_pool - -__all__ = ['roi_pool', 'RoIPool'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/gradcheck.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/gradcheck.py deleted file mode 100644 index d11af7902..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/gradcheck.py +++ /dev/null @@ -1,16 +0,0 @@ -import os.path as osp -import sys - -import torch -from torch.autograd import gradcheck - -sys.path.append(osp.abspath(osp.join(__file__, '../../'))) -from roi_pool import RoIPool # noqa: E402, isort:skip - -feat = torch.randn(4, 16, 15, 15, requires_grad=True).cuda() -rois = torch.Tensor([[0, 0, 0, 50, 50], [0, 10, 30, 43, 55], - [1, 67, 40, 110, 120]]).cuda() -inputs = (feat, rois) -print('Gradcheck for roi pooling...') -test = gradcheck(RoIPool(4, 1.0 / 8), inputs, eps=1e-5, atol=1e-3) -print(test) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/roi_pool.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/roi_pool.py deleted file mode 100644 index 26d900f78..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/roi_pool.py +++ /dev/null @@ -1,75 +0,0 @@ -import torch -import torch.nn as nn -from torch.autograd import Function -from torch.autograd.function import once_differentiable -from torch.nn.modules.utils import _pair - -from . import roi_pool_cuda - - -class RoIPoolFunction(Function): - - @staticmethod - def forward(ctx, features, rois, out_size, spatial_scale): - assert features.is_cuda - out_h, out_w = _pair(out_size) - assert isinstance(out_h, int) and isinstance(out_w, int) - ctx.save_for_backward(rois) - num_channels = features.size(1) - num_rois = rois.size(0) - out_size = (num_rois, num_channels, out_h, out_w) - output = features.new_zeros(out_size) - argmax = features.new_zeros(out_size, dtype=torch.int) - roi_pool_cuda.forward(features, rois, out_h, out_w, spatial_scale, - output, argmax) - ctx.spatial_scale = spatial_scale - ctx.feature_size = features.size() - ctx.argmax = argmax - - return output - - @staticmethod - @once_differentiable - def backward(ctx, grad_output): - assert grad_output.is_cuda - spatial_scale = ctx.spatial_scale - feature_size = ctx.feature_size - argmax = ctx.argmax - rois = ctx.saved_tensors[0] - assert feature_size is not None - - grad_input = grad_rois = None - if ctx.needs_input_grad[0]: - grad_input = grad_output.new_zeros(feature_size) - roi_pool_cuda.backward(grad_output.contiguous(), rois, argmax, - spatial_scale, grad_input) - - return grad_input, grad_rois, None, None - - -roi_pool = RoIPoolFunction.apply - - -class RoIPool(nn.Module): - - def __init__(self, out_size, spatial_scale, use_torchvision=False): - super(RoIPool, self).__init__() - - self.out_size = _pair(out_size) - self.spatial_scale = float(spatial_scale) - self.use_torchvision = use_torchvision - - def forward(self, features, rois): - if self.use_torchvision: - from torchvision.ops import roi_pool as tv_roi_pool - return tv_roi_pool(features, rois, self.out_size, - self.spatial_scale) - else: - return roi_pool(features, rois, self.out_size, self.spatial_scale) - - def __repr__(self): - format_str = self.__class__.__name__ - format_str += '(out_size={}, spatial_scale={}'.format( - self.out_size, self.spatial_scale) - format_str += ', use_torchvision={})'.format(self.use_torchvision) - return format_str diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/src/roi_pool_cuda.cpp b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/src/roi_pool_cuda.cpp deleted file mode 100644 index 740c6fdcf..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/src/roi_pool_cuda.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include - -#include -#include - -int ROIPoolForwardLaucher(const at::Tensor features, const at::Tensor rois, - const float spatial_scale, const int channels, - const int height, const int width, const int num_rois, - const int pooled_h, const int pooled_w, - at::Tensor output, at::Tensor argmax); - -int ROIPoolBackwardLaucher(const at::Tensor top_grad, const at::Tensor rois, - const at::Tensor argmax, const float spatial_scale, - const int batch_size, const int channels, - const int height, const int width, - const int num_rois, const int pooled_h, - const int pooled_w, at::Tensor bottom_grad); - -#define CHECK_CUDA(x) TORCH_CHECK(x.is_cuda(), #x, " must be a CUDAtensor ") -#define CHECK_CONTIGUOUS(x) \ - TORCH_CHECK(x.is_contiguous(), #x, " must be contiguous ") -#define CHECK_INPUT(x) \ - CHECK_CUDA(x); \ - CHECK_CONTIGUOUS(x) - -int roi_pooling_forward_cuda(at::Tensor features, at::Tensor rois, - int pooled_height, int pooled_width, - float spatial_scale, at::Tensor output, - at::Tensor argmax) { - CHECK_INPUT(features); - CHECK_INPUT(rois); - CHECK_INPUT(output); - CHECK_INPUT(argmax); - - // Number of ROIs - int num_rois = rois.size(0); - int size_rois = rois.size(1); - - if (size_rois != 5) { - printf("wrong roi size\n"); - return 0; - } - - int channels = features.size(1); - int height = features.size(2); - int width = features.size(3); - - ROIPoolForwardLaucher(features, rois, spatial_scale, channels, height, width, - num_rois, pooled_height, pooled_width, output, argmax); - - return 1; -} - -int roi_pooling_backward_cuda(at::Tensor top_grad, at::Tensor rois, - at::Tensor argmax, float spatial_scale, - at::Tensor bottom_grad) { - CHECK_INPUT(top_grad); - CHECK_INPUT(rois); - CHECK_INPUT(argmax); - CHECK_INPUT(bottom_grad); - - int pooled_height = top_grad.size(2); - int pooled_width = top_grad.size(3); - int num_rois = rois.size(0); - int size_rois = rois.size(1); - - if (size_rois != 5) { - printf("wrong roi size\n"); - return 0; - } - int batch_size = bottom_grad.size(0); - int channels = bottom_grad.size(1); - int height = bottom_grad.size(2); - int width = bottom_grad.size(3); - - ROIPoolBackwardLaucher(top_grad, rois, argmax, spatial_scale, batch_size, - channels, height, width, num_rois, pooled_height, - pooled_width, bottom_grad); - - return 1; -} - -PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { - m.def("forward", &roi_pooling_forward_cuda, "Roi_Pooling forward (CUDA)"); - m.def("backward", &roi_pooling_backward_cuda, "Roi_Pooling backward (CUDA)"); -} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/src/roi_pool_kernel.cu b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/src/roi_pool_kernel.cu deleted file mode 100644 index 82a70beaa..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/roi_pool/src/roi_pool_kernel.cu +++ /dev/null @@ -1,157 +0,0 @@ -#include -#include -#include - -#define CUDA_1D_KERNEL_LOOP(i, n) \ - for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ - i += blockDim.x * gridDim.x) - -#define THREADS_PER_BLOCK 1024 - -inline int GET_BLOCKS(const int N) { - int optimal_block_num = (N + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK; - int max_block_num = 65000; - return optimal_block_num - max_block_num < 0? optimal_block_num: max_block_num; -} - -template -__global__ void ROIPoolForward(const int nthreads, const scalar_t *bottom_data, - const scalar_t *rois, - const scalar_t spatial_scale, const int channels, - const int height, const int width, - const int pooled_h, const int pooled_w, - scalar_t *top_data, int *argmax_data) { - CUDA_1D_KERNEL_LOOP(index, nthreads) { - // (n, c, ph, pw) is an element in the pooled output - int pw = index % pooled_w; - int ph = (index / pooled_w) % pooled_h; - int c = (index / pooled_w / pooled_h) % channels; - int n = index / pooled_w / pooled_h / channels; - - const scalar_t *offset_rois = rois + n * 5; - int roi_batch_ind = offset_rois[0]; - // calculate the roi region on feature maps - scalar_t roi_x1 = offset_rois[1] * spatial_scale; - scalar_t roi_y1 = offset_rois[2] * spatial_scale; - scalar_t roi_x2 = (offset_rois[3] + 1) * spatial_scale; - scalar_t roi_y2 = (offset_rois[4] + 1) * spatial_scale; - - // force malformed rois to be 1x1 - scalar_t roi_w = roi_x2 - roi_x1; - scalar_t roi_h = roi_y2 - roi_y1; - if (roi_w <= 0 || roi_h <= 0) continue; - - scalar_t bin_size_w = roi_w / static_cast(pooled_w); - scalar_t bin_size_h = roi_h / static_cast(pooled_h); - - // the corresponding bin region - int bin_x1 = floor(static_cast(pw) * bin_size_w + roi_x1); - int bin_y1 = floor(static_cast(ph) * bin_size_h + roi_y1); - int bin_x2 = ceil(static_cast(pw + 1) * bin_size_w + roi_x1); - int bin_y2 = ceil(static_cast(ph + 1) * bin_size_h + roi_y1); - - // add roi offsets and clip to input boundaries - bin_x1 = min(max(bin_x1, 0), width); - bin_y1 = min(max(bin_y1, 0), height); - bin_x2 = min(max(bin_x2, 0), width); - bin_y2 = min(max(bin_y2, 0), height); - bool is_empty = (bin_y2 <= bin_y1) || (bin_x2 <= bin_x1); - - // If nothing is pooled, argmax = -1 causes nothing to be backprop'd - int max_idx = -1; - bottom_data += (roi_batch_ind * channels + c) * height * width; - - // Define an empty pooling region to be zero - scalar_t max_val = is_empty ? static_cast(0) - : bottom_data[bin_y1 * width + bin_x1] - 1; - - for (int h = bin_y1; h < bin_y2; ++h) { - for (int w = bin_x1; w < bin_x2; ++w) { - int offset = h * width + w; - if (bottom_data[offset] > max_val) { - max_val = bottom_data[offset]; - max_idx = offset; - } - } - } - top_data[index] = max_val; - if (argmax_data != NULL) argmax_data[index] = max_idx; - } -} - -int ROIPoolForwardLaucher(const at::Tensor features, const at::Tensor rois, - const float spatial_scale, const int channels, - const int height, const int width, const int num_rois, - const int pooled_h, const int pooled_w, - at::Tensor output, at::Tensor argmax) { - const int output_size = num_rois * channels * pooled_h * pooled_w; - - AT_DISPATCH_FLOATING_TYPES_AND_HALF( - features.scalar_type(), "ROIPoolLaucherForward", ([&] { - const scalar_t *bottom_data = features.data(); - const scalar_t *rois_data = rois.data(); - scalar_t *top_data = output.data(); - int *argmax_data = argmax.data(); - - ROIPoolForward - <<>>( - output_size, bottom_data, rois_data, scalar_t(spatial_scale), - channels, height, width, pooled_h, pooled_w, top_data, - argmax_data); - })); - THCudaCheck(cudaGetLastError()); - return 1; -} - -template -__global__ void ROIPoolBackward(const int nthreads, const scalar_t *top_diff, - const scalar_t *rois, const int *argmax_data, - const scalar_t spatial_scale, - const int channels, const int height, - const int width, const int pooled_h, - const int pooled_w, scalar_t *bottom_diff) { - CUDA_1D_KERNEL_LOOP(index, nthreads) { - int pw = index % pooled_w; - int ph = (index / pooled_w) % pooled_h; - int c = (index / pooled_w / pooled_h) % channels; - int n = index / pooled_w / pooled_h / channels; - - int roi_batch_ind = rois[n * 5]; - int bottom_index = argmax_data[(n * channels + c) * pooled_h * pooled_w + - ph * pooled_w + pw]; - - atomicAdd(bottom_diff + (roi_batch_ind * channels + c) * height * width + - bottom_index, - top_diff[index]); - } -} - -int ROIPoolBackwardLaucher(const at::Tensor top_grad, const at::Tensor rois, - const at::Tensor argmax, const float spatial_scale, - const int batch_size, const int channels, - const int height, const int width, - const int num_rois, const int pooled_h, - const int pooled_w, at::Tensor bottom_grad) { - const int output_size = num_rois * pooled_h * pooled_w * channels; - - AT_DISPATCH_FLOATING_TYPES_AND_HALF( - top_grad.scalar_type(), "ROIPoolLaucherBackward", ([&] { - const scalar_t *top_diff = top_grad.data(); - const scalar_t *rois_data = rois.data(); - const int *argmax_data = argmax.data(); - scalar_t *bottom_diff = bottom_grad.data(); - - if (sizeof(scalar_t) == sizeof(double)) { - fprintf(stderr, "double is not supported\n"); - exit(-1); - } - - ROIPoolBackward - <<>>( - output_size, top_diff, rois_data, argmax_data, - scalar_t(spatial_scale), channels, height, width, pooled_h, - pooled_w, bottom_diff); - })); - THCudaCheck(cudaGetLastError()); - return 1; -} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/__init__.py deleted file mode 100644 index 218032945..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .sigmoid_focal_loss import SigmoidFocalLoss, sigmoid_focal_loss - -__all__ = ['SigmoidFocalLoss', 'sigmoid_focal_loss'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/sigmoid_focal_loss.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/sigmoid_focal_loss.py deleted file mode 100644 index 8298f433f..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/sigmoid_focal_loss.py +++ /dev/null @@ -1,54 +0,0 @@ -import torch.nn as nn -from torch.autograd import Function -from torch.autograd.function import once_differentiable - -from . import sigmoid_focal_loss_cuda - - -class SigmoidFocalLossFunction(Function): - - @staticmethod - def forward(ctx, input, target, gamma=2.0, alpha=0.25): - ctx.save_for_backward(input, target) - num_classes = input.shape[1] - ctx.num_classes = num_classes - ctx.gamma = gamma - ctx.alpha = alpha - - loss = sigmoid_focal_loss_cuda.forward(input, target, num_classes, - gamma, alpha) - return loss - - @staticmethod - @once_differentiable - def backward(ctx, d_loss): - input, target = ctx.saved_tensors - num_classes = ctx.num_classes - gamma = ctx.gamma - alpha = ctx.alpha - d_loss = d_loss.contiguous() - d_input = sigmoid_focal_loss_cuda.backward(input, target, d_loss, - num_classes, gamma, alpha) - return d_input, None, None, None, None - - -sigmoid_focal_loss = SigmoidFocalLossFunction.apply - - -# TODO: remove this module -class SigmoidFocalLoss(nn.Module): - - def __init__(self, gamma, alpha): - super(SigmoidFocalLoss, self).__init__() - self.gamma = gamma - self.alpha = alpha - - def forward(self, logits, targets): - assert logits.is_cuda - loss = sigmoid_focal_loss(logits, targets, self.gamma, self.alpha) - return loss.sum() - - def __repr__(self): - tmpstr = self.__class__.__name__ + '(gamma={}, alpha={})'.format( - self.gamma, self.alpha) - return tmpstr diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss.cpp b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss.cpp deleted file mode 100644 index 8330c9b45..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// modify from -// https://github.com/facebookresearch/maskrcnn-benchmark/blob/master/maskrcnn_benchmark/csrc/SigmoidFocalLoss.h -#include - -at::Tensor SigmoidFocalLoss_forward_cuda(const at::Tensor &logits, - const at::Tensor &targets, - const int num_classes, - const float gamma, const float alpha); - -at::Tensor SigmoidFocalLoss_backward_cuda(const at::Tensor &logits, - const at::Tensor &targets, - const at::Tensor &d_losses, - const int num_classes, - const float gamma, const float alpha); - -// Interface for Python -at::Tensor SigmoidFocalLoss_forward(const at::Tensor &logits, - const at::Tensor &targets, - const int num_classes, const float gamma, - const float alpha) { - if (logits.type().is_cuda()) { - return SigmoidFocalLoss_forward_cuda(logits, targets, num_classes, gamma, - alpha); - } - AT_ERROR("SigmoidFocalLoss is not implemented on the CPU"); -} - -at::Tensor SigmoidFocalLoss_backward(const at::Tensor &logits, - const at::Tensor &targets, - const at::Tensor &d_losses, - const int num_classes, const float gamma, - const float alpha) { - if (logits.is_cuda()) { - return SigmoidFocalLoss_backward_cuda(logits, targets, d_losses, - num_classes, gamma, alpha); - } - AT_ERROR("SigmoidFocalLoss is not implemented on the CPU"); -} - -PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { - m.def("forward", &SigmoidFocalLoss_forward, - "SigmoidFocalLoss forward (CUDA)"); - m.def("backward", &SigmoidFocalLoss_backward, - "SigmoidFocalLoss backward (CUDA)"); -} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss_cuda.cu b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss_cuda.cu deleted file mode 100644 index 0e152d38f..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss_cuda.cu +++ /dev/null @@ -1,171 +0,0 @@ -// modified from -// https://github.com/facebookresearch/maskrcnn-benchmark/blob/master/maskrcnn_benchmark/csrc/cuda/SigmoidFocalLoss_cuda.cu - -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. -// This file is modified from -// https://github.com/pytorch/pytorch/blob/master/modules/detectron/sigmoid_focal_loss_op.cu -// Cheng-Yang Fu -// cyfu@cs.unc.edu -#include -#include - -#include -#include -#include - -#include - -// TODO make it in a common file -#define CUDA_1D_KERNEL_LOOP(i, n) \ - for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ - i += blockDim.x * gridDim.x) - -template -__global__ void SigmoidFocalLossForward(const int nthreads, - const scalar_t *logits, - const int64_t *targets, - const int num_classes, - const float gamma, const float alpha, - const int num, scalar_t *losses) { - CUDA_1D_KERNEL_LOOP(i, nthreads) { - int n = i / num_classes; - int d = i % num_classes; // current class[0~79]; - int t = targets[n]; // target class [1~80]; - - // Decide it is positive or negative case. - scalar_t c1 = (t == (d + 1)); - scalar_t c2 = (t >= 0 & t != (d + 1)); - - scalar_t zn = (1.0 - alpha); - scalar_t zp = (alpha); - - // p = 1. / 1. + expf(-x); p = sigmoid(x) - scalar_t p = 1. / (1. + expf(-logits[i])); - - // (1-p)**gamma * log(p) where - scalar_t term1 = powf((1. - p), gamma) * logf(max(p, FLT_MIN)); - - // p**gamma * log(1-p) - scalar_t term2 = - powf(p, gamma) * - (-1. * logits[i] * (logits[i] >= 0) - - logf(1. + expf(logits[i] - 2. * logits[i] * (logits[i] >= 0)))); - - losses[i] = 0.0; - losses[i] += -c1 * term1 * zp; - losses[i] += -c2 * term2 * zn; - - } // CUDA_1D_KERNEL_LOOP -} // SigmoidFocalLossForward - -template -__global__ void SigmoidFocalLossBackward( - const int nthreads, const scalar_t *logits, const int64_t *targets, - const scalar_t *d_losses, const int num_classes, const float gamma, - const float alpha, const int num, scalar_t *d_logits) { - CUDA_1D_KERNEL_LOOP(i, nthreads) { - int n = i / num_classes; - int d = i % num_classes; // current class[0~79]; - int t = targets[n]; // target class [1~80], 0 is background; - - // Decide it is positive or negative case. - scalar_t c1 = (t == (d + 1)); - scalar_t c2 = (t >= 0 & t != (d + 1)); - - scalar_t zn = (1.0 - alpha); - scalar_t zp = (alpha); - // p = 1. / 1. + expf(-x); p = sigmoid(x) - scalar_t p = 1. / (1. + expf(-logits[i])); - - // (1-p)**g * (1 - p - g*p*log(p) - scalar_t term1 = - powf((1. - p), gamma) * (1. - p - (p * gamma * logf(max(p, FLT_MIN)))); - - // (p**g) * (g*(1-p)*log(1-p) - p) - scalar_t term2 = - powf(p, gamma) * - ((-1. * logits[i] * (logits[i] >= 0) - - logf(1. + expf(logits[i] - 2. * logits[i] * (logits[i] >= 0)))) * - (1. - p) * gamma - - p); - d_logits[i] = 0.0; - d_logits[i] += -c1 * term1 * zp; - d_logits[i] += -c2 * term2 * zn; - d_logits[i] = d_logits[i] * d_losses[i]; - - } // CUDA_1D_KERNEL_LOOP -} // SigmoidFocalLossBackward - -at::Tensor SigmoidFocalLoss_forward_cuda(const at::Tensor &logits, - const at::Tensor &targets, - const int num_classes, - const float gamma, const float alpha) { - AT_ASSERTM(logits.type().is_cuda(), "logits must be a CUDA tensor"); - AT_ASSERTM(targets.type().is_cuda(), "targets must be a CUDA tensor"); - AT_ASSERTM(logits.dim() == 2, "logits should be NxClass"); - - const int num_samples = logits.size(0); - - auto losses = at::empty({num_samples, logits.size(1)}, logits.options()); - auto losses_size = num_samples * logits.size(1); - - dim3 grid( - std::min(THCCeilDiv((int64_t)losses_size, (int64_t)512), (int64_t)4096)); - dim3 block(512); - - if (losses.numel() == 0) { - THCudaCheck(cudaGetLastError()); - return losses; - } - - AT_DISPATCH_FLOATING_TYPES_AND_HALF( - logits.scalar_type(), "SigmoidFocalLoss_forward", [&] { - SigmoidFocalLossForward<<>>( - losses_size, logits.contiguous().data(), - targets.contiguous().data(), num_classes, gamma, alpha, - num_samples, losses.data()); - }); - THCudaCheck(cudaGetLastError()); - return losses; -} - -at::Tensor SigmoidFocalLoss_backward_cuda(const at::Tensor &logits, - const at::Tensor &targets, - const at::Tensor &d_losses, - const int num_classes, - const float gamma, - const float alpha) { - AT_ASSERTM(logits.type().is_cuda(), "logits must be a CUDA tensor"); - AT_ASSERTM(targets.type().is_cuda(), "targets must be a CUDA tensor"); - AT_ASSERTM(d_losses.type().is_cuda(), "d_losses must be a CUDA tensor"); - - AT_ASSERTM(logits.dim() == 2, "logits should be NxClass"); - - const int num_samples = logits.size(0); - AT_ASSERTM(logits.size(1) == num_classes, - "logits.size(1) should be num_classes"); - - auto d_logits = at::zeros({num_samples, num_classes}, logits.options()); - auto d_logits_size = num_samples * logits.size(1); - - dim3 grid(std::min(THCCeilDiv((int64_t)d_logits_size, (int64_t)512), - (int64_t)4096)); - dim3 block(512); - - if (d_logits.numel() == 0) { - THCudaCheck(cudaGetLastError()); - return d_logits; - } - - AT_DISPATCH_FLOATING_TYPES_AND_HALF( - logits.scalar_type(), "SigmoidFocalLoss_backward", [&] { - SigmoidFocalLossBackward<<>>( - d_logits_size, logits.contiguous().data(), - targets.contiguous().data(), - d_losses.contiguous().data(), num_classes, gamma, alpha, - num_samples, d_logits.data()); - }); - - THCudaCheck(cudaGetLastError()); - return d_logits; -} diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/utils/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/utils/__init__.py deleted file mode 100644 index 0244c0f54..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/ops/utils/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -# from . import compiling_info -from .compiling_info import get_compiler_version, get_compiling_cuda_version - -# get_compiler_version = compiling_info.get_compiler_version -# get_compiling_cuda_version = compiling_info.get_compiling_cuda_version - -__all__ = ['get_compiler_version', 'get_compiling_cuda_version'] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/__init__.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/__init__.py index 537a34a13..f57acb5f0 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/__init__.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/__init__.py @@ -1,8 +1,17 @@ -from .flops_counter import get_model_complexity_info -from .logger import get_root_logger, print_log -from .registry import Registry, build_from_cfg +# Copyright (c) OpenMMLab. All rights reserved. +from .collect_env import collect_env +from .compat_config import compat_cfg +from .logger import get_caller_name, get_root_logger, log_img_scale +from .memory import AvoidCUDAOOM, AvoidOOM +from .misc import find_latest_checkpoint, update_data_root +from .replace_cfg_vals import replace_cfg_vals +from .setup_env import setup_multi_processes +from .split_batch import split_batch +from .util_distribution import build_ddp, build_dp, get_device __all__ = [ - 'Registry', 'build_from_cfg', 'get_model_complexity_info', - 'get_root_logger', 'print_log' + 'get_root_logger', 'collect_env', 'find_latest_checkpoint', + 'update_data_root', 'setup_multi_processes', 'get_caller_name', + 'log_img_scale', 'compat_cfg', 'split_batch', 'build_ddp', 'build_dp', + 'get_device', 'replace_cfg_vals', 'AvoidOOM', 'AvoidCUDAOOM' ] diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/collect_env.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/collect_env.py new file mode 100644 index 000000000..97e25c0e9 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/collect_env.py @@ -0,0 +1,17 @@ +# Copyright (c) OpenMMLab. All rights reserved. +from mmcv.utils import collect_env as collect_base_env +from mmcv.utils import get_git_hash + +import mmdet + + +def collect_env(): + """Collect the information of the running environments.""" + env_info = collect_base_env() + env_info['MMDetection'] = mmdet.__version__ + '+' + get_git_hash()[:7] + return env_info + + +if __name__ == '__main__': + for name, val in collect_env().items(): + print(f'{name}: {val}') diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/compat_config.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/compat_config.py new file mode 100644 index 000000000..05aa37dcd --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/compat_config.py @@ -0,0 +1,139 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import copy +import warnings + +from mmcv import ConfigDict + + +def compat_cfg(cfg): + """This function would modify some filed to keep the compatibility of + config. + + For example, it will move some args which will be deprecated to the correct + fields. + """ + cfg = copy.deepcopy(cfg) + cfg = compat_imgs_per_gpu(cfg) + cfg = compat_loader_args(cfg) + cfg = compat_runner_args(cfg) + return cfg + + +def compat_runner_args(cfg): + if 'runner' not in cfg: + cfg.runner = ConfigDict({ + 'type': 'EpochBasedRunner', + 'max_epochs': cfg.total_epochs + }) + warnings.warn( + 'config is now expected to have a `runner` section, ' + 'please set `runner` in your config.', UserWarning) + else: + if 'total_epochs' in cfg: + assert cfg.total_epochs == cfg.runner.max_epochs + return cfg + + +def compat_imgs_per_gpu(cfg): + cfg = copy.deepcopy(cfg) + if 'imgs_per_gpu' in cfg.data: + warnings.warn('"imgs_per_gpu" is deprecated in MMDet V2.0. ' + 'Please use "samples_per_gpu" instead') + if 'samples_per_gpu' in cfg.data: + warnings.warn( + f'Got "imgs_per_gpu"={cfg.data.imgs_per_gpu} and ' + f'"samples_per_gpu"={cfg.data.samples_per_gpu}, "imgs_per_gpu"' + f'={cfg.data.imgs_per_gpu} is used in this experiments') + else: + warnings.warn('Automatically set "samples_per_gpu"="imgs_per_gpu"=' + f'{cfg.data.imgs_per_gpu} in this experiments') + cfg.data.samples_per_gpu = cfg.data.imgs_per_gpu + return cfg + + +def compat_loader_args(cfg): + """Deprecated sample_per_gpu in cfg.data.""" + + cfg = copy.deepcopy(cfg) + if 'train_dataloader' not in cfg.data: + cfg.data['train_dataloader'] = ConfigDict() + if 'val_dataloader' not in cfg.data: + cfg.data['val_dataloader'] = ConfigDict() + if 'test_dataloader' not in cfg.data: + cfg.data['test_dataloader'] = ConfigDict() + + # special process for train_dataloader + if 'samples_per_gpu' in cfg.data: + + samples_per_gpu = cfg.data.pop('samples_per_gpu') + assert 'samples_per_gpu' not in \ + cfg.data.train_dataloader, ('`samples_per_gpu` are set ' + 'in `data` field and ` ' + 'data.train_dataloader` ' + 'at the same time. ' + 'Please only set it in ' + '`data.train_dataloader`. ') + cfg.data.train_dataloader['samples_per_gpu'] = samples_per_gpu + + if 'persistent_workers' in cfg.data: + + persistent_workers = cfg.data.pop('persistent_workers') + assert 'persistent_workers' not in \ + cfg.data.train_dataloader, ('`persistent_workers` are set ' + 'in `data` field and ` ' + 'data.train_dataloader` ' + 'at the same time. ' + 'Please only set it in ' + '`data.train_dataloader`. ') + cfg.data.train_dataloader['persistent_workers'] = persistent_workers + + if 'workers_per_gpu' in cfg.data: + + workers_per_gpu = cfg.data.pop('workers_per_gpu') + cfg.data.train_dataloader['workers_per_gpu'] = workers_per_gpu + cfg.data.val_dataloader['workers_per_gpu'] = workers_per_gpu + cfg.data.test_dataloader['workers_per_gpu'] = workers_per_gpu + + # special process for val_dataloader + if 'samples_per_gpu' in cfg.data.val: + # keep default value of `sample_per_gpu` is 1 + assert 'samples_per_gpu' not in \ + cfg.data.val_dataloader, ('`samples_per_gpu` are set ' + 'in `data.val` field and ` ' + 'data.val_dataloader` at ' + 'the same time. ' + 'Please only set it in ' + '`data.val_dataloader`. ') + cfg.data.val_dataloader['samples_per_gpu'] = \ + cfg.data.val.pop('samples_per_gpu') + # special process for val_dataloader + + # in case the test dataset is concatenated + if isinstance(cfg.data.test, dict): + if 'samples_per_gpu' in cfg.data.test: + assert 'samples_per_gpu' not in \ + cfg.data.test_dataloader, ('`samples_per_gpu` are set ' + 'in `data.test` field and ` ' + 'data.test_dataloader` ' + 'at the same time. ' + 'Please only set it in ' + '`data.test_dataloader`. ') + + cfg.data.test_dataloader['samples_per_gpu'] = \ + cfg.data.test.pop('samples_per_gpu') + + elif isinstance(cfg.data.test, list): + for ds_cfg in cfg.data.test: + if 'samples_per_gpu' in ds_cfg: + assert 'samples_per_gpu' not in \ + cfg.data.test_dataloader, ('`samples_per_gpu` are set ' + 'in `data.test` field and ` ' + 'data.test_dataloader` at' + ' the same time. ' + 'Please only set it in ' + '`data.test_dataloader`. ') + samples_per_gpu = max( + [ds_cfg.pop('samples_per_gpu', 1) for ds_cfg in cfg.data.test]) + cfg.data.test_dataloader['samples_per_gpu'] = samples_per_gpu + + return cfg diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/contextmanagers.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/contextmanagers.py index 0363f0145..fa12bfcaf 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/contextmanagers.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/contextmanagers.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# Copyright (c) OpenMMLab. All rights reserved. import asyncio import contextlib import logging @@ -18,11 +18,8 @@ async def completed(trace_name='', name='', sleep_interval=0.05, streams: List[torch.cuda.Stream] = None): - """ - Async context manager that waits for work to complete on - given CUDA streams. - - """ + """Async context manager that waits for work to complete on given CUDA + streams.""" if not torch.cuda.is_available(): yield return @@ -86,7 +83,7 @@ async def completed(trace_name='', stream_times_ms = '' for i, stream in enumerate(streams): elapsed_time = start.elapsed_time(end_events[i]) - stream_times_ms += ' {} {:.2f} ms'.format(stream, elapsed_time) + stream_times_ms += f' {stream} {elapsed_time:.2f} ms' logger.info('%s %s %.2f ms %s', trace_name, name, cpu_time, stream_times_ms) @@ -100,7 +97,6 @@ async def concurrent(streamqueue: asyncio.Queue, :param streamqueue: asyncio.Queue instance. Queue tasks define the pool of streams used for concurrent execution. - """ if not torch.cuda.is_available(): yield diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/logger.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/logger.py index 3e6a1396b..485f641b7 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/logger.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/logger.py @@ -1,66 +1,65 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import inspect import logging -from mmcv.runner import get_dist_info +from mmcv.utils import get_logger def get_root_logger(log_file=None, log_level=logging.INFO): - """Get the root logger. - - The logger will be initialized if it has not been initialized. By default a - StreamHandler will be added. If `log_file` is specified, a FileHandler will - also be added. The name of the root logger is the top-level package name, - e.g., "mmdet". + """Get root logger. Args: - log_file (str | None): The log filename. If specified, a FileHandler - will be added to the root logger. - log_level (int): The root logger level. Note that only the process of - rank 0 is affected, while other processes will set the level to - "Error" and be silent most of the time. + log_file (str, optional): File path of log. Defaults to None. + log_level (int, optional): The level of logger. + Defaults to logging.INFO. Returns: - logging.Logger: The root logger. + :obj:`logging.Logger`: The obtained logger """ - logger = logging.getLogger(__name__.split('.')[0]) # i.e., mmdet - # if the logger has been initialized, just return it - if logger.hasHandlers(): - return logger - - format_str = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' - logging.basicConfig(format=format_str, level=log_level) - rank, _ = get_dist_info() - if rank != 0: - logger.setLevel('ERROR') - elif log_file is not None: - file_handler = logging.FileHandler(log_file, 'w') - file_handler.setFormatter(logging.Formatter(format_str)) - file_handler.setLevel(log_level) - logger.addHandler(file_handler) + logger = get_logger(name='mmdet', log_file=log_file, log_level=log_level) return logger -def print_log(msg, logger=None, level=logging.INFO): - """Print a log message. +def get_caller_name(): + """Get name of caller method.""" + # this_func_frame = inspect.stack()[0][0] # i.e., get_caller_name + # callee_frame = inspect.stack()[1][0] # e.g., log_img_scale + caller_frame = inspect.stack()[2][0] # e.g., caller of log_img_scale + caller_method = caller_frame.f_code.co_name + try: + caller_class = caller_frame.f_locals['self'].__class__.__name__ + return f'{caller_class}.{caller_method}' + except KeyError: # caller is a function + return caller_method + + +def log_img_scale(img_scale, shape_order='hw', skip_square=False): + """Log image size. Args: - msg (str): The message to be logged. - logger (logging.Logger | str | None): The logger to be used. Some - special loggers are: - - "root": the root logger obtained with `get_root_logger()`. - - "silent": no message will be printed. - - None: The `print()` method will be used to print log messages. - level (int): Logging level. Only available when `logger` is a Logger - object or "root". + img_scale (tuple): Image size to be logged. + shape_order (str, optional): The order of image shape. + 'hw' for (height, width) and 'wh' for (width, height). + Defaults to 'hw'. + skip_square (bool, optional): Whether to skip logging for square + img_scale. Defaults to False. + + Returns: + bool: Whether to have done logging. """ - if logger is None: - print(msg) - elif logger == 'root': - _logger = get_root_logger() - _logger.log(level, msg) - elif isinstance(logger, logging.Logger): - logger.log(level, msg) - elif logger != 'silent': - raise TypeError( - 'logger should be either a logging.Logger object, "root", ' - '"silent" or None, but got {}'.format(logger)) + if shape_order == 'hw': + height, width = img_scale + elif shape_order == 'wh': + width, height = img_scale + else: + raise ValueError(f'Invalid shape_order {shape_order}.') + + if skip_square and (height == width): + return False + + logger = get_root_logger() + caller = get_caller_name() + logger.info(f'image shape: height={height}, width={width} in {caller}') + + return True diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/memory.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/memory.py new file mode 100644 index 000000000..eb212bcae --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/memory.py @@ -0,0 +1,213 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import warnings +from collections import abc +from contextlib import contextmanager +from functools import wraps + +import torch + +from mmdet.utils import get_root_logger + + +def cast_tensor_type(inputs, src_type=None, dst_type=None): + """Recursively convert Tensor in inputs from ``src_type`` to ``dst_type``. + + Args: + inputs: Inputs that to be casted. + src_type (torch.dtype | torch.device): Source type. + src_type (torch.dtype | torch.device): Destination type. + + Returns: + The same type with inputs, but all contained Tensors have been cast. + """ + assert dst_type is not None + if isinstance(inputs, torch.Tensor): + if isinstance(dst_type, torch.device): + # convert Tensor to dst_device + if hasattr(inputs, 'to') and \ + hasattr(inputs, 'device') and \ + (inputs.device == src_type or src_type is None): + return inputs.to(dst_type) + else: + return inputs + else: + # convert Tensor to dst_dtype + if hasattr(inputs, 'to') and \ + hasattr(inputs, 'dtype') and \ + (inputs.dtype == src_type or src_type is None): + return inputs.to(dst_type) + else: + return inputs + # we need to ensure that the type of inputs to be casted are the same + # as the argument `src_type`. + elif isinstance(inputs, abc.Mapping): + return type(inputs)({ + k: cast_tensor_type(v, src_type=src_type, dst_type=dst_type) + for k, v in inputs.items() + }) + elif isinstance(inputs, abc.Iterable): + return type(inputs)( + cast_tensor_type(item, src_type=src_type, dst_type=dst_type) + for item in inputs) + # TODO: Currently not supported + # elif isinstance(inputs, InstanceData): + # for key, value in inputs.items(): + # inputs[key] = cast_tensor_type( + # value, src_type=src_type, dst_type=dst_type) + # return inputs + else: + return inputs + + +@contextmanager +def _ignore_torch_cuda_oom(): + """A context which ignores CUDA OOM exception from pytorch. + + Code is modified from + # noqa: E501 + """ + try: + yield + except RuntimeError as e: + # NOTE: the string may change? + if 'CUDA out of memory. ' in str(e): + pass + else: + raise + + +class AvoidOOM: + """Try to convert inputs to FP16 and CPU if got a PyTorch's CUDA Out of + Memory error. It will do the following steps: + + 1. First retry after calling `torch.cuda.empty_cache()`. + 2. If that still fails, it will then retry by converting inputs + to FP16. + 3. If that still fails trying to convert inputs to CPUs. + In this case, it expects the function to dispatch to + CPU implementation. + + Args: + to_cpu (bool): Whether to convert outputs to CPU if get an OOM + error. This will slow down the code significantly. + Defaults to True. + test (bool): Skip `_ignore_torch_cuda_oom` operate that can use + lightweight data in unit test, only used in + test unit. Defaults to False. + + Examples: + >>> from mmdet.utils.memory import AvoidOOM + >>> AvoidCUDAOOM = AvoidOOM() + >>> output = AvoidOOM.retry_if_cuda_oom( + >>> some_torch_function)(input1, input2) + >>> # To use as a decorator + >>> # from mmdet.utils import AvoidCUDAOOM + >>> @AvoidCUDAOOM.retry_if_cuda_oom + >>> def function(*args, **kwargs): + >>> return None + ``` + + Note: + 1. The output may be on CPU even if inputs are on GPU. Processing + on CPU will slow down the code significantly. + 2. When converting inputs to CPU, it will only look at each argument + and check if it has `.device` and `.to` for conversion. Nested + structures of tensors are not supported. + 3. Since the function might be called more than once, it has to be + stateless. + """ + + def __init__(self, to_cpu=True, test=False): + self.to_cpu = to_cpu + self.test = test + + def retry_if_cuda_oom(self, func): + """Makes a function retry itself after encountering pytorch's CUDA OOM + error. + + The implementation logic is referred to + https://github.com/facebookresearch/detectron2/blob/main/detectron2/utils/memory.py + + Args: + func: a stateless callable that takes tensor-like objects + as arguments. + Returns: + func: a callable which retries `func` if OOM is encountered. + """ # noqa: W605 + + @wraps(func) + def wrapped(*args, **kwargs): + + # raw function + if not self.test: + with _ignore_torch_cuda_oom(): + return func(*args, **kwargs) + + # Clear cache and retry + torch.cuda.empty_cache() + with _ignore_torch_cuda_oom(): + return func(*args, **kwargs) + + # get the type and device of first tensor + dtype, device = None, None + values = args + tuple(kwargs.values()) + for value in values: + if isinstance(value, torch.Tensor): + dtype = value.dtype + device = value.device + break + if dtype is None or device is None: + raise ValueError('There is no tensor in the inputs, ' + 'cannot get dtype and device.') + + # Convert to FP16 + fp16_args = cast_tensor_type(args, dst_type=torch.half) + fp16_kwargs = cast_tensor_type(kwargs, dst_type=torch.half) + logger = get_root_logger() + logger.warning(f'Attempting to copy inputs of {str(func)} ' + 'to FP16 due to CUDA OOM') + + # get input tensor type, the output type will same as + # the first parameter type. + with _ignore_torch_cuda_oom(): + output = func(*fp16_args, **fp16_kwargs) + output = cast_tensor_type( + output, src_type=torch.half, dst_type=dtype) + if not self.test: + return output + logger.warning('Using FP16 still meet CUDA OOM') + + # Try on CPU. This will slow down the code significantly, + # therefore print a notice. + if self.to_cpu: + logger.warning(f'Attempting to copy inputs of {str(func)} ' + 'to CPU due to CUDA OOM') + cpu_device = torch.empty(0).device + cpu_args = cast_tensor_type(args, dst_type=cpu_device) + cpu_kwargs = cast_tensor_type(kwargs, dst_type=cpu_device) + + # convert outputs to GPU + with _ignore_torch_cuda_oom(): + logger.warning(f'Convert outputs to GPU (device={device})') + output = func(*cpu_args, **cpu_kwargs) + output = cast_tensor_type( + output, src_type=cpu_device, dst_type=device) + return output + + warnings.warn('Cannot convert output to GPU due to CUDA OOM, ' + 'the output is now on CPU, which might cause ' + 'errors if the output need to interact with GPU ' + 'data in subsequent operations') + logger.warning('Cannot convert output to GPU due to ' + 'CUDA OOM, the output is on CPU now.') + + return func(*cpu_args, **cpu_kwargs) + else: + # may still get CUDA OOM error + return func(*args, **kwargs) + + return wrapped + + +# To use AvoidOOM as a decorator +AvoidCUDAOOM = AvoidOOM() diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/misc.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/misc.py new file mode 100644 index 000000000..4113672ac --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/misc.py @@ -0,0 +1,76 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import glob +import os +import os.path as osp +import warnings + +import mmcv +from mmcv.utils import print_log + + +def find_latest_checkpoint(path, suffix='pth'): + """Find the latest checkpoint from the working directory. + + Args: + path(str): The path to find checkpoints. + suffix(str): File extension. + Defaults to pth. + + Returns: + latest_path(str | None): File path of the latest checkpoint. + References: + .. [1] https://github.com/microsoft/SoftTeacher + /blob/main/ssod/utils/patch.py + """ + if not osp.exists(path): + warnings.warn('The path of checkpoints does not exist.') + return None + if osp.exists(osp.join(path, f'latest.{suffix}')): + return osp.join(path, f'latest.{suffix}') + + checkpoints = glob.glob(osp.join(path, f'*.{suffix}')) + if len(checkpoints) == 0: + warnings.warn('There are no checkpoints in the path.') + return None + latest = -1 + latest_path = None + for checkpoint in checkpoints: + count = int(osp.basename(checkpoint).split('_')[-1].split('.')[0]) + if count > latest: + latest = count + latest_path = checkpoint + return latest_path + + +def update_data_root(cfg, logger=None): + """Update data root according to env MMDET_DATASETS. + + If set env MMDET_DATASETS, update cfg.data_root according to + MMDET_DATASETS. Otherwise, using cfg.data_root as default. + + Args: + cfg (mmcv.Config): The model config need to modify + logger (logging.Logger | str | None): the way to print msg + """ + assert isinstance(cfg, mmcv.Config), \ + f'cfg got wrong type: {type(cfg)}, expected mmcv.Config' + + if 'MMDET_DATASETS' in os.environ: + dst_root = os.environ['MMDET_DATASETS'] + print_log(f'MMDET_DATASETS has been set to be {dst_root}.' + f'Using {dst_root} as data root.') + else: + return + + assert isinstance(cfg, mmcv.Config), \ + f'cfg got wrong type: {type(cfg)}, expected mmcv.Config' + + def update(cfg, src_str, dst_str): + for k, v in cfg.items(): + if isinstance(v, mmcv.ConfigDict): + update(cfg[k], src_str, dst_str) + if isinstance(v, str) and src_str in v: + cfg[k] = v.replace(src_str, dst_str) + + update(cfg.data, cfg.data_root, dst_root) + cfg.data_root = dst_root diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/profiling.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/profiling.py index 58b1c87dd..2f53f456c 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/profiling.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/profiling.py @@ -1,3 +1,4 @@ +# Copyright (c) OpenMMLab. All rights reserved. import contextlib import sys import time @@ -14,9 +15,8 @@ if sys.version_info >= (3, 7): end_stream=None): """Print time spent by CPU and GPU. - Useful as a temporary context manager to find sweet spots of - code suitable for async implementation. - + Useful as a temporary context manager to find sweet spots of code + suitable for async implementation. """ if (not enabled) or not torch.cuda.is_available(): yield @@ -35,7 +35,6 @@ if sys.version_info >= (3, 7): end.synchronize() cpu_time = (cpu_end - cpu_start) * 1000 gpu_time = start.elapsed_time(end) - msg = "{} {} cpu_time {:.2f} ms ".format(trace_name, name, - cpu_time) - msg += "gpu_time {:.2f} ms stream {}".format(gpu_time, stream) + msg = f'{trace_name} {name} cpu_time {cpu_time:.2f} ms ' + msg += f'gpu_time {gpu_time:.2f} ms stream {stream}' print(msg, end_stream) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/registry.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/registry.py deleted file mode 100644 index 4ad9f876c..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/registry.py +++ /dev/null @@ -1,79 +0,0 @@ -import inspect -from functools import partial - -import mmcv - - -class Registry(object): - - def __init__(self, name): - self._name = name - self._module_dict = dict() - - def __repr__(self): - format_str = self.__class__.__name__ + '(name={}, items={})'.format( - self._name, list(self._module_dict.keys())) - return format_str - - @property - def name(self): - return self._name - - @property - def module_dict(self): - return self._module_dict - - def get(self, key): - return self._module_dict.get(key, None) - - def _register_module(self, module_class, force=False): - """Register a module. - - Args: - module (:obj:`nn.Module`): Module to be registered. - """ - if not inspect.isclass(module_class): - raise TypeError('module must be a class, but got {}'.format( - type(module_class))) - module_name = module_class.__name__ - if not force and module_name in self._module_dict: - raise KeyError('{} is already registered in {}'.format( - module_name, self.name)) - self._module_dict[module_name] = module_class - - def register_module(self, cls=None, force=False): - if cls is None: - return partial(self.register_module, force=force) - self._register_module(cls, force=force) - return cls - - -def build_from_cfg(cfg, registry, default_args=None): - """Build a module from config dict. - - Args: - cfg (dict): Config dict. It should at least contain the key "type". - registry (:obj:`Registry`): The registry to search the type from. - default_args (dict, optional): Default initialization arguments. - - Returns: - obj: The constructed object. - """ - assert isinstance(cfg, dict) and 'type' in cfg - assert isinstance(default_args, dict) or default_args is None - args = cfg.copy() - obj_type = args.pop('type') - if mmcv.is_str(obj_type): - obj_cls = registry.get(obj_type) - if obj_cls is None: - raise KeyError('{} is not in the {} registry'.format( - obj_type, registry.name)) - elif inspect.isclass(obj_type): - obj_cls = obj_type - else: - raise TypeError('type must be a str or valid type, but got {}'.format( - type(obj_type))) - if default_args is not None: - for name, value in default_args.items(): - args.setdefault(name, value) - return obj_cls(**args) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/replace_cfg_vals.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/replace_cfg_vals.py new file mode 100644 index 000000000..6ca301dc9 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/replace_cfg_vals.py @@ -0,0 +1,70 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import re + +from mmcv.utils import Config + + +def replace_cfg_vals(ori_cfg): + """Replace the string "${key}" with the corresponding value. + + Replace the "${key}" with the value of ori_cfg.key in the config. And + support replacing the chained ${key}. Such as, replace "${key0.key1}" + with the value of cfg.key0.key1. Code is modified from `vars.py + < https://github.com/microsoft/SoftTeacher/blob/main/ssod/utils/vars.py>`_ # noqa: E501 + + Args: + ori_cfg (mmcv.utils.config.Config): + The origin config with "${key}" generated from a file. + + Returns: + updated_cfg [mmcv.utils.config.Config]: + The config with "${key}" replaced by the corresponding value. + """ + + def get_value(cfg, key): + for k in key.split('.'): + cfg = cfg[k] + return cfg + + def replace_value(cfg): + if isinstance(cfg, dict): + return {key: replace_value(value) for key, value in cfg.items()} + elif isinstance(cfg, list): + return [replace_value(item) for item in cfg] + elif isinstance(cfg, tuple): + return tuple([replace_value(item) for item in cfg]) + elif isinstance(cfg, str): + # the format of string cfg may be: + # 1) "${key}", which will be replaced with cfg.key directly + # 2) "xxx${key}xxx" or "xxx${key1}xxx${key2}xxx", + # which will be replaced with the string of the cfg.key + keys = pattern_key.findall(cfg) + values = [get_value(ori_cfg, key[2:-1]) for key in keys] + if len(keys) == 1 and keys[0] == cfg: + # the format of string cfg is "${key}" + cfg = values[0] + else: + for key, value in zip(keys, values): + # the format of string cfg is + # "xxx${key}xxx" or "xxx${key1}xxx${key2}xxx" + assert not isinstance(value, (dict, list, tuple)), \ + f'for the format of string cfg is ' \ + f"'xxxxx${key}xxxxx' or 'xxx${key}xxx${key}xxx', " \ + f"the type of the value of '${key}' " \ + f'can not be dict, list, or tuple' \ + f'but you input {type(value)} in {cfg}' + cfg = cfg.replace(key, str(value)) + return cfg + else: + return cfg + + # the pattern of string "${key}" + pattern_key = re.compile(r'\$\{[a-zA-Z\d_.]*\}') + # the type of ori_cfg._cfg_dict is mmcv.utils.config.ConfigDict + updated_cfg = Config( + replace_value(ori_cfg._cfg_dict), filename=ori_cfg.filename) + # replace the model with model_wrapper + if updated_cfg.get('model_wrapper', None) is not None: + updated_cfg.model = updated_cfg.model_wrapper + updated_cfg.pop('model_wrapper') + return updated_cfg diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/setup_env.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/setup_env.py new file mode 100644 index 000000000..6637cf878 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/setup_env.py @@ -0,0 +1,53 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import os +import platform +import warnings + +import cv2 +import torch.multiprocessing as mp + + +def setup_multi_processes(cfg): + """Setup multi-processing environment variables.""" + # set multi-process start method as `fork` to speed up the training + if platform.system() != 'Windows': + mp_start_method = cfg.get('mp_start_method', 'fork') + current_method = mp.get_start_method(allow_none=True) + if current_method is not None and current_method != mp_start_method: + warnings.warn( + f'Multi-processing start method `{mp_start_method}` is ' + f'different from the previous setting `{current_method}`.' + f'It will be force set to `{mp_start_method}`. You can change ' + f'this behavior by changing `mp_start_method` in your config.') + mp.set_start_method(mp_start_method, force=True) + + # disable opencv multithreading to avoid system being overloaded + opencv_num_threads = cfg.get('opencv_num_threads', 0) + cv2.setNumThreads(opencv_num_threads) + + # setup OMP threads + # This code is referred from https://github.com/pytorch/pytorch/blob/master/torch/distributed/run.py # noqa + workers_per_gpu = cfg.data.get('workers_per_gpu', 1) + if 'train_dataloader' in cfg.data: + workers_per_gpu = \ + max(cfg.data.train_dataloader.get('workers_per_gpu', 1), + workers_per_gpu) + + if 'OMP_NUM_THREADS' not in os.environ and workers_per_gpu > 1: + omp_num_threads = 1 + warnings.warn( + f'Setting OMP_NUM_THREADS environment variable for each process ' + f'to be {omp_num_threads} in default, to avoid your system being ' + f'overloaded, please further tune the variable for optimal ' + f'performance in your application as needed.') + os.environ['OMP_NUM_THREADS'] = str(omp_num_threads) + + # setup MKL threads + if 'MKL_NUM_THREADS' not in os.environ and workers_per_gpu > 1: + mkl_num_threads = 1 + warnings.warn( + f'Setting MKL_NUM_THREADS environment variable for each process ' + f'to be {mkl_num_threads} in default, to avoid your system being ' + f'overloaded, please further tune the variable for optimal ' + f'performance in your application as needed.') + os.environ['MKL_NUM_THREADS'] = str(mkl_num_threads) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/split_batch.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/split_batch.py new file mode 100644 index 000000000..0276fb331 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/split_batch.py @@ -0,0 +1,45 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch + + +def split_batch(img, img_metas, kwargs): + """Split data_batch by tags. + + Code is modified from + # noqa: E501 + + Args: + img (Tensor): of shape (N, C, H, W) encoding input images. + Typically these should be mean centered and std scaled. + img_metas (list[dict]): List of image info dict where each dict + has: 'img_shape', 'scale_factor', 'flip', and may also contain + 'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'. + For details on the values of these keys, see + :class:`mmdet.datasets.pipelines.Collect`. + kwargs (dict): Specific to concrete implementation. + + Returns: + data_groups (dict): a dict that data_batch splited by tags, + such as 'sup', 'unsup_teacher', and 'unsup_student'. + """ + + # only stack img in the batch + def fuse_list(obj_list, obj): + return torch.stack(obj_list) if isinstance(obj, + torch.Tensor) else obj_list + + # select data with tag from data_batch + def select_group(data_batch, current_tag): + group_flag = [tag == current_tag for tag in data_batch['tag']] + return { + k: fuse_list([vv for vv, gf in zip(v, group_flag) if gf], v) + for k, v in data_batch.items() + } + + kwargs.update({'img': img, 'img_metas': img_metas}) + kwargs.update({'tag': [meta['tag'] for meta in img_metas]}) + tags = list(set(kwargs['tag'])) + data_groups = {tag: select_group(kwargs, tag) for tag in tags} + for tag, group in data_groups.items(): + group.pop('tag') + return data_groups diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/util_distribution.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/util_distribution.py new file mode 100644 index 000000000..a186bf6cb --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/util_distribution.py @@ -0,0 +1,74 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch +from mmcv.parallel import MMDataParallel, MMDistributedDataParallel + +dp_factory = {'cuda': MMDataParallel, 'cpu': MMDataParallel} + +ddp_factory = {'cuda': MMDistributedDataParallel} + + +def build_dp(model, device='cuda', dim=0, *args, **kwargs): + """build DataParallel module by device type. + + if device is cuda, return a MMDataParallel model; if device is mlu, + return a MLUDataParallel model. + + Args: + model (:class:`nn.Module`): model to be parallelized. + device (str): device type, cuda, cpu or mlu. Defaults to cuda. + dim (int): Dimension used to scatter the data. Defaults to 0. + + Returns: + nn.Module: the model to be parallelized. + """ + if device == 'cuda': + model = model.cuda() + elif device == 'mlu': + from mmcv.device.mlu import MLUDataParallel + dp_factory['mlu'] = MLUDataParallel + model = model.mlu() + + return dp_factory[device](model, dim=dim, *args, **kwargs) + + +def build_ddp(model, device='cuda', *args, **kwargs): + """Build DistributedDataParallel module by device type. + + If device is cuda, return a MMDistributedDataParallel model; + if device is mlu, return a MLUDistributedDataParallel model. + + Args: + model (:class:`nn.Module`): module to be parallelized. + device (str): device type, mlu or cuda. + + Returns: + :class:`nn.Module`: the module to be parallelized + + References: + .. [1] https://pytorch.org/docs/stable/generated/torch.nn.parallel. + DistributedDataParallel.html + """ + assert device in ['cuda', 'mlu'], 'Only available for cuda or mlu devices.' + if device == 'cuda': + model = model.cuda() + elif device == 'mlu': + from mmcv.device.mlu import MLUDistributedDataParallel + ddp_factory['mlu'] = MLUDistributedDataParallel + model = model.mlu() + + return ddp_factory[device](model, *args, **kwargs) + + +def is_mlu_available(): + """Returns a bool indicating if MLU is currently available.""" + return hasattr(torch, 'is_mlu_available') and torch.is_mlu_available() + + +def get_device(): + """Returns an available device, cpu, cuda or mlu.""" + is_device_available = { + 'cuda': torch.cuda.is_available(), + 'mlu': is_mlu_available() + } + device_list = [k for k, v in is_device_available.items() if v] + return device_list[0] if len(device_list) == 1 else 'cpu' diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/util_mixins.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/util_mixins.py index 5585ac652..b83b6617f 100644 --- a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/util_mixins.py +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/util_mixins.py @@ -1,6 +1,5 @@ -# -*- coding: utf-8 -*- -""" -This module defines the :class:`NiceRepr` mixin class, which defines a +# Copyright (c) OpenMMLab. All rights reserved. +"""This module defines the :class:`NiceRepr` mixin class, which defines a ``__repr__`` and ``__str__`` method that only depend on a custom ``__nice__`` method, which you must define. This means you only have to overload one function instead of two. Furthermore, if the object defines a ``__len__`` @@ -21,8 +20,8 @@ Example: ... return self.name >>> s1 = Student('Alice') >>> s2 = Student('Bob') - >>> print('s1 = {}'.format(s1)) - >>> print('s2 = {}'.format(s2)) + >>> print(f's1 = {s1}') + >>> print(f's2 = {s2}') s1 = s2 = @@ -34,16 +33,14 @@ Example: ... def __len__(self): ... return len(self.data) >>> g = Group([1, 2, 3]) - >>> print('g = {}'.format(g)) + >>> print(f'g = {g}') g = - """ import warnings -class NiceRepr(object): - """ - Inherit from this class and define ``__nice__`` to "nicely" print your +class NiceRepr: + """Inherit from this class and define ``__nice__`` to "nicely" print your objects. Defines ``__str__`` and ``__repr__`` in terms of ``__nice__`` function @@ -77,6 +74,7 @@ class NiceRepr(object): """ def __nice__(self): + """str: a "nice" summary string describing this module""" if hasattr(self, '__len__'): # It is a common pattern for objects to use __len__ in __nice__ # As a convenience we define a default __nice__ for these objects @@ -84,22 +82,24 @@ class NiceRepr(object): else: # In all other cases force the subclass to overload __nice__ raise NotImplementedError( - 'Define the __nice__ method for {!r}'.format(self.__class__)) + f'Define the __nice__ method for {self.__class__!r}') def __repr__(self): + """str: the string of the module""" try: nice = self.__nice__() classname = self.__class__.__name__ - return '<{0}({1}) at {2}>'.format(classname, nice, hex(id(self))) + return f'<{classname}({nice}) at {hex(id(self))}>' except NotImplementedError as ex: warnings.warn(str(ex), category=RuntimeWarning) return object.__repr__(self) def __str__(self): + """str: the string of the module""" try: classname = self.__class__.__name__ nice = self.__nice__() - return '<{0}({1})>'.format(classname, nice) + return f'<{classname}({nice})>' except NotImplementedError as ex: warnings.warn(str(ex), category=RuntimeWarning) return object.__repr__(self) diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/util_random.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/util_random.py new file mode 100644 index 000000000..dc1ecb6c0 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/utils/util_random.py @@ -0,0 +1,34 @@ +# Copyright (c) OpenMMLab. All rights reserved. +"""Helpers for random number generators.""" +import numpy as np + + +def ensure_rng(rng=None): + """Coerces input into a random number generator. + + If the input is None, then a global random state is returned. + + If the input is a numeric value, then that is used as a seed to construct a + random state. Otherwise the input is returned as-is. + + Adapted from [1]_. + + Args: + rng (int | numpy.random.RandomState | None): + if None, then defaults to the global rng. Otherwise this can be an + integer or a RandomState class + Returns: + (numpy.random.RandomState) : rng - + a numpy random number generator + + References: + .. [1] https://gitlab.kitware.com/computer-vision/kwarray/blob/master/kwarray/util_random.py#L270 # noqa: E501 + """ + + if rng is None: + rng = np.random.mtrand._rand + elif isinstance(rng, int): + rng = np.random.RandomState(rng) + else: + rng = rng + return rng diff --git a/cv/instance_segmentation/SOLO/pytorch/mmdet/version.py b/cv/instance_segmentation/SOLO/pytorch/mmdet/version.py new file mode 100644 index 000000000..56e9b0757 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/mmdet/version.py @@ -0,0 +1,19 @@ +# Copyright (c) OpenMMLab. All rights reserved. + +__version__ = '2.25.0' +short_version = __version__ + + +def parse_version_info(version_str): + version_info = [] + for x in version_str.split('.'): + if x.isdigit(): + version_info.append(int(x)) + elif x.find('rc') != -1: + patch_version = x.split('rc') + version_info.append(int(patch_version[0])) + version_info.append(f'rc{patch_version[1]}') + return tuple(version_info) + + +version_info = parse_version_info(__version__) diff --git a/cv/instance_segmentation/SOLO/pytorch/requirements.txt b/cv/instance_segmentation/SOLO/pytorch/requirements.txt index 52ee8f552..683611773 100644 --- a/cv/instance_segmentation/SOLO/pytorch/requirements.txt +++ b/cv/instance_segmentation/SOLO/pytorch/requirements.txt @@ -1,4 +1,7 @@ --r requirements/runtime.txt --r requirements/optional.txt --r requirements/tests.txt --r requirements/build.txt +addict +yapf +matplotlib +pycocotools +six +terminaltables +opencv-python diff --git a/cv/instance_segmentation/SOLO/pytorch/requirements/build.txt b/cv/instance_segmentation/SOLO/pytorch/requirements/build.txt deleted file mode 100644 index a24ea0c6f..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/requirements/build.txt +++ /dev/null @@ -1,4 +0,0 @@ -# These must be installed before building mmdetection -cython -numpy -torch>=1.1 diff --git a/cv/instance_segmentation/SOLO/pytorch/requirements/optional.txt b/cv/instance_segmentation/SOLO/pytorch/requirements/optional.txt deleted file mode 100644 index eb36729e0..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/requirements/optional.txt +++ /dev/null @@ -1,2 +0,0 @@ -albumentations>=0.3.2 -imagecorruptions diff --git a/cv/instance_segmentation/SOLO/pytorch/requirements/runtime.txt b/cv/instance_segmentation/SOLO/pytorch/requirements/runtime.txt deleted file mode 100644 index 0d0178788..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/requirements/runtime.txt +++ /dev/null @@ -1,10 +0,0 @@ -matplotlib -mmcv==0.2.16 -numpy -scipy -# need older pillow until torchvision is fixed -Pillow<=6.2.2 -six -terminaltables -torch>=1.1 -torchvision diff --git a/cv/instance_segmentation/SOLO/pytorch/requirements/tests.txt b/cv/instance_segmentation/SOLO/pytorch/requirements/tests.txt deleted file mode 100644 index d45e54096..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/requirements/tests.txt +++ /dev/null @@ -1,11 +0,0 @@ -asynctest -codecov -flake8 -isort -pytest -pytest-cov -pytest-runner -xdoctest >= 0.10.0 -yapf -# Note: used for kwarray.group_items, this may be ported to mmcv in the future. -kwarray diff --git a/cv/instance_segmentation/SOLO/pytorch/setup.py b/cv/instance_segmentation/SOLO/pytorch/setup.py index aee4ddbf6..3cc9f7a46 100644 --- a/cv/instance_segmentation/SOLO/pytorch/setup.py +++ b/cv/instance_segmentation/SOLO/pytorch/setup.py @@ -1,141 +1,50 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +# Copyright (c) 2022, Shanghai Iluvatar CoreX Semiconductor Co., Ltd. +import glob import os -import platform -import subprocess -import time -from setuptools import Extension, dist, find_packages, setup - -import torch -from torch.utils.cpp_extension import BuildExtension, CUDAExtension - -dist.Distribution().fetch_build_eggs(['Cython', 'numpy>=1.11.1']) -import numpy as np # noqa: E402, isort:skip -from Cython.Build import cythonize # noqa: E402, isort:skip - - -def readme(): - with open('README.md', encoding='utf-8') as f: - content = f.read() - return content - - -MAJOR = 1 -MINOR = 0 -PATCH = 0 -SUFFIX = '' -if PATCH != '': - SHORT_VERSION = '{}.{}.{}{}'.format(MAJOR, MINOR, PATCH, SUFFIX) -else: - SHORT_VERSION = '{}.{}{}'.format(MAJOR, MINOR, SUFFIX) - -version_file = 'mmdet/version.py' - - -def get_git_hash(): - - def _minimal_ext_cmd(cmd): - # construct minimal environment - env = {} - for k in ['SYSTEMROOT', 'PATH', 'HOME']: - v = os.environ.get(k) - if v is not None: - env[k] = v - # LANGUAGE is used on win32 - env['LANGUAGE'] = 'C' - env['LANG'] = 'C' - env['LC_ALL'] = 'C' - out = subprocess.Popen( - cmd, stdout=subprocess.PIPE, env=env).communicate()[0] - return out - - try: - out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD']) - sha = out.strip().decode('ascii') - except OSError: - sha = 'unknown' - - return sha - - -def get_hash(): - if os.path.exists('.git'): - sha = get_git_hash()[:7] - elif os.path.exists(version_file): - try: - from mmdet.version import __version__ - sha = __version__.split('+')[-1] - except ImportError: - raise ImportError('Unable to get git version') +import re +from pkg_resources import DistributionNotFound, get_distribution +from setuptools import find_packages, setup + +EXT_TYPE = '' +try: + import torch + if torch.__version__ == 'parrots': + from parrots.utils.build_extension import BuildExtension + EXT_TYPE = 'parrots' else: - sha = 'unknown' - - return sha + from torch.utils.cpp_extension import BuildExtension + EXT_TYPE = 'pytorch' + cmd_class = {'build_ext': BuildExtension} +except ModuleNotFoundError: + cmd_class = {} + print('Skip building ext ops due to the absence of torch.') -def write_version_py(): - content = """# GENERATED VERSION FILE -# TIME: {} - -__version__ = '{}' -short_version = '{}' -""" - sha = get_hash() - VERSION = SHORT_VERSION + '+' + sha +def choose_requirement(primary, secondary): + """If some version of primary requirement installed, return primary, else + return secondary.""" + try: + name = re.split(r'[!<>=]', primary)[0] + get_distribution(name) + except DistributionNotFound: + return secondary - with open(version_file, 'w') as f: - f.write(content.format(time.asctime(), VERSION, SHORT_VERSION)) + return str(primary) def get_version(): - with open(version_file, 'r') as f: + version_file = 'mmcv/version.py' + with open(version_file, 'r', encoding='utf-8') as f: exec(compile(f.read(), version_file, 'exec')) - return locals()['__version__'] + version = locals()['__version__'] + local_version_identifier = os.environ.get('MMCV_LOCAL_VERSION_IDENTIFIER', '') + if local_version_identifier != '': + version += '+' + local_version_identifier + return version -def make_cuda_ext(name, module, sources): - - define_macros = [] - - if torch.cuda.is_available() or os.getenv('FORCE_CUDA', '0') == '1': - define_macros += [("WITH_CUDA", None)] - else: - raise EnvironmentError('CUDA is required to compile MMDetection!') - - return CUDAExtension( - name='{}.{}'.format(module, name), - sources=[os.path.join(*module.split('.'), p) for p in sources], - define_macros=define_macros, - extra_compile_args={ - 'cxx': [], - 'nvcc': [ - '-D__CUDA_NO_HALF_OPERATORS__', - '-D__CUDA_NO_HALF_CONVERSIONS__', - '-D__CUDA_NO_HALF2_OPERATORS__', - ] - }) - - -def make_cython_ext(name, module, sources): - extra_compile_args = None - if platform.system() != 'Windows': - extra_compile_args = { - 'cxx': ['-Wno-unused-function', '-Wno-write-strings'] - } - - extension = Extension( - '{}.{}'.format(module, name), - [os.path.join(*module.split('.'), p) for p in sources], - include_dirs=[np.get_include()], - language='c++', - extra_compile_args=extra_compile_args) - extension, = cythonize(extension) - return extension - - -def parse_requirements(fname='requirements.txt', with_version=True): - """ - Parse the package dependencies listed in a requirements file but strips +def parse_requirements(fname='requirements/runtime.txt', with_version=True): + """Parse the package dependencies listed in a requirements file but strips specific versioning information. Args: @@ -150,13 +59,10 @@ def parse_requirements(fname='requirements.txt', with_version=True): """ import sys from os.path import exists - import re require_fpath = fname def parse_line(line): - """ - Parse information from a line in a requirements text file - """ + """Parse information from a line in a requirements text file.""" if line.startswith('-r '): # Allow specifying requirements in other files target = line.split(' ')[1] @@ -212,90 +118,237 @@ def parse_requirements(fname='requirements.txt', with_version=True): return packages -if __name__ == '__main__': - write_version_py() - setup( - name='mmdet', - version=get_version(), - description='Open MMLab Detection Toolbox and Benchmark', - long_description=readme(), - author='OpenMMLab', - author_email='chenkaidev@gmail.com', - keywords='computer vision, object detection', - url='https://github.com/open-mmlab/mmdetection', - packages=find_packages(exclude=('configs', 'tools', 'demo')), - package_data={'mmdet.ops': ['*/*.so']}, - classifiers=[ - 'Development Status :: 4 - Beta', - 'License :: OSI Approved :: Apache Software License', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - ], - license='Apache License 2.0', - setup_requires=parse_requirements('requirements/build.txt'), - tests_require=parse_requirements('requirements/tests.txt'), - install_requires=parse_requirements('requirements/runtime.txt'), - extras_require={ - 'all': parse_requirements('requirements.txt'), - 'tests': parse_requirements('requirements/tests.txt'), - 'build': parse_requirements('requirements/build.txt'), - 'optional': parse_requirements('requirements/optional.txt'), - }, - ext_modules=[ - make_cuda_ext( - name='compiling_info', - module='mmdet.ops.utils', - sources=['src/compiling_info.cpp']), - make_cython_ext( - name='soft_nms_cpu', - module='mmdet.ops.nms', - sources=['src/soft_nms_cpu.pyx']), - make_cuda_ext( - name='nms_cpu', - module='mmdet.ops.nms', - sources=['src/nms_cpu.cpp']), - make_cuda_ext( - name='nms_cuda', - module='mmdet.ops.nms', - sources=['src/nms_cuda.cpp', 'src/nms_kernel.cu']), - make_cuda_ext( - name='roi_align_cuda', - module='mmdet.ops.roi_align', - sources=['src/roi_align_cuda.cpp', 'src/roi_align_kernel.cu']), - make_cuda_ext( - name='roi_pool_cuda', - module='mmdet.ops.roi_pool', - sources=['src/roi_pool_cuda.cpp', 'src/roi_pool_kernel.cu']), - make_cuda_ext( - name='deform_conv_cuda', - module='mmdet.ops.dcn', - sources=[ - 'src/deform_conv_cuda.cpp', - 'src/deform_conv_cuda_kernel.cu' - ]), - make_cuda_ext( - name='deform_pool_cuda', - module='mmdet.ops.dcn', - sources=[ - 'src/deform_pool_cuda.cpp', - 'src/deform_pool_cuda_kernel.cu' - ]), - make_cuda_ext( - name='sigmoid_focal_loss_cuda', - module='mmdet.ops.sigmoid_focal_loss', - sources=[ - 'src/sigmoid_focal_loss.cpp', - 'src/sigmoid_focal_loss_cuda.cu' - ]), - make_cuda_ext( - name='masked_conv2d_cuda', - module='mmdet.ops.masked_conv', - sources=[ - 'src/masked_conv2d_cuda.cpp', 'src/masked_conv2d_kernel.cu' - ]), - ], - cmdclass={'build_ext': BuildExtension}, - zip_safe=False) +install_requires = parse_requirements() + +try: + # OpenCV installed via conda. + import cv2 # NOQA: F401 + major, minor, *rest = cv2.__version__.split('.') + if int(major) < 3: + raise RuntimeError( + f'OpenCV >=3 is required but {cv2.__version__} is installed') +except ImportError: + # If first not installed install second package + CHOOSE_INSTALL_REQUIRES = [('opencv-python-headless>=3', + 'opencv-python>=3')] + for main, secondary in CHOOSE_INSTALL_REQUIRES: + install_requires.append(choose_requirement(main, secondary)) + + +def get_extensions(): + extensions = [] + + if os.getenv('MMCV_WITH_TRT', '0') != '0': + ext_name = 'mmcv._ext_trt' + from torch.utils.cpp_extension import include_paths, library_paths + library_dirs = [] + libraries = [] + include_dirs = [] + tensorrt_path = os.getenv('TENSORRT_DIR', '0') + tensorrt_lib_path = glob.glob( + os.path.join(tensorrt_path, 'targets', '*', 'lib'))[0] + library_dirs += [tensorrt_lib_path] + libraries += ['nvinfer', 'nvparsers', 'nvinfer_plugin'] + libraries += ['cudart'] + define_macros = [] + extra_compile_args = {'cxx': []} + + include_path = os.path.abspath('./mmcv/ops/csrc/common/cuda') + include_trt_path = os.path.abspath('./mmcv/ops/csrc/tensorrt') + include_dirs.append(include_path) + include_dirs.append(include_trt_path) + include_dirs.append(os.path.join(tensorrt_path, 'include')) + include_dirs += include_paths(cuda=True) + + op_files = glob.glob('./mmcv/ops/csrc/tensorrt/plugins/*') + define_macros += [('MMCV_WITH_CUDA', None)] + define_macros += [('MMCV_WITH_TRT', None)] + cuda_args = os.getenv('MMCV_CUDA_ARGS') + extra_compile_args['nvcc'] = [cuda_args] if cuda_args else [] + library_dirs += library_paths(cuda=True) + + from setuptools import Extension + ext_ops = Extension( + name=ext_name, + sources=op_files, + include_dirs=include_dirs, + define_macros=define_macros, + extra_compile_args=extra_compile_args, + language='c++', + library_dirs=library_dirs, + libraries=libraries) + extensions.append(ext_ops) + + if os.getenv('MMCV_WITH_OPS', '0') == '0': + return extensions + + if EXT_TYPE == 'parrots': + ext_name = 'mmcv._ext' + from parrots.utils.build_extension import Extension + # new parrots op impl do not use MMCV_USE_PARROTS + # define_macros = [('MMCV_USE_PARROTS', None)] + define_macros = [] + include_dirs = [] + op_files = glob.glob('./mmcv/ops/csrc/pytorch/cuda/*.cu') +\ + glob.glob('./mmcv/ops/csrc/parrots/*.cpp') + include_dirs.append(os.path.abspath('./mmcv/ops/csrc/common')) + include_dirs.append(os.path.abspath('./mmcv/ops/csrc/common/cuda')) + cuda_args = os.getenv('MMCV_CUDA_ARGS') + extra_compile_args = { + 'nvcc': [cuda_args] if cuda_args else [], + 'cxx': [], + } + if torch.cuda.is_available() or os.getenv('FORCE_CUDA', '0') == '1': + define_macros += [('MMCV_WITH_CUDA', None)] + extra_compile_args['nvcc'] += [ + '-D__CUDA_NO_HALF_OPERATORS__', + '-D__CUDA_NO_HALF_CONVERSIONS__', + '-D__CUDA_NO_HALF2_OPERATORS__', + ] + ext_ops = Extension( + name=ext_name, + sources=op_files, + include_dirs=include_dirs, + define_macros=define_macros, + extra_compile_args=extra_compile_args, + cuda=True, + pytorch=True) + extensions.append(ext_ops) + elif EXT_TYPE == 'pytorch': + ext_name = 'mmcv._ext' + from torch.utils.cpp_extension import CppExtension, CUDAExtension + + # prevent ninja from using too many resources + try: + import psutil + num_cpu = len(psutil.Process().cpu_affinity()) + cpu_use = max(4, num_cpu - 1) + except (ModuleNotFoundError, AttributeError): + cpu_use = 4 + + os.environ.setdefault('MAX_JOBS', str(cpu_use)) + define_macros = [] + extra_compile_args = {'cxx': []} + include_dirs = [] + + is_rocm_pytorch = False + try: + from torch.utils.cpp_extension import ROCM_HOME + is_rocm_pytorch = True if ((torch.version.hip is not None) and + (ROCM_HOME is not None)) else False + except ImportError: + pass + + project_dir = 'mmcv/ops/csrc/' + if is_rocm_pytorch: + from torch.utils.hipify import hipify_python + + hipify_python.hipify( + project_directory=project_dir, + output_directory=project_dir, + includes='mmcv/ops/csrc/*', + show_detailed=True, + is_pytorch_extension=True, + ) + define_macros += [('MMCV_WITH_CUDA', None)] + define_macros += [('HIP_DIFF', None)] + cuda_args = os.getenv('MMCV_CUDA_ARGS') + extra_compile_args['nvcc'] = [cuda_args] if cuda_args else [] + op_files = glob.glob('./mmcv/ops/csrc/pytorch/hip/*') + extension = CUDAExtension + include_dirs.append(os.path.abspath('./mmcv/ops/csrc/common/hip')) + elif torch.cuda.is_available() or os.getenv('FORCE_CUDA', '0') == '1': + define_macros += [('MMCV_WITH_CUDA', None)] + cuda_args = os.getenv('MMCV_CUDA_ARGS') + extra_compile_args['nvcc'] = [cuda_args] if cuda_args else [] + op_files = glob.glob('./mmcv/ops/csrc/pytorch/*.cpp') + \ + glob.glob('./mmcv/ops/csrc/pytorch/cuda/*.cu') + extension = CUDAExtension + include_dirs.append(os.path.abspath('./mmcv/ops/csrc/common')) + include_dirs.append(os.path.abspath('./mmcv/ops/csrc/common/cuda')) + else: + print(f'Compiling {ext_name} without CUDA') + op_files = glob.glob('./mmcv/ops/csrc/pytorch/*.cpp') + extension = CppExtension + include_dirs.append(os.path.abspath('./mmcv/ops/csrc/common')) + + ext_ops = extension( + name=ext_name, + sources=op_files, + include_dirs=include_dirs, + define_macros=define_macros, + extra_compile_args=extra_compile_args) + extensions.append(ext_ops) + + if EXT_TYPE == 'pytorch' and os.getenv('MMCV_WITH_ORT', '0') != '0': + ext_name = 'mmcv._ext_ort' + from torch.utils.cpp_extension import library_paths, include_paths + import onnxruntime + library_dirs = [] + libraries = [] + include_dirs = [] + ort_path = os.getenv('ONNXRUNTIME_DIR', '0') + library_dirs += [os.path.join(ort_path, 'lib')] + libraries.append('onnxruntime') + define_macros = [] + extra_compile_args = {'cxx': []} + + include_path = os.path.abspath('./mmcv/ops/csrc/onnxruntime') + include_dirs.append(include_path) + include_dirs.append(os.path.join(ort_path, 'include')) + + op_files = glob.glob('./mmcv/ops/csrc/onnxruntime/cpu/*') + if onnxruntime.get_device() == 'GPU' or os.getenv('FORCE_CUDA', + '0') == '1': + define_macros += [('MMCV_WITH_CUDA', None)] + cuda_args = os.getenv('MMCV_CUDA_ARGS') + extra_compile_args['nvcc'] = [cuda_args] if cuda_args else [] + op_files += glob.glob('./mmcv/ops/csrc/onnxruntime/gpu/*') + include_dirs += include_paths(cuda=True) + library_dirs += library_paths(cuda=True) + else: + include_dirs += include_paths(cuda=False) + library_dirs += library_paths(cuda=False) + + from setuptools import Extension + ext_ops = Extension( + name=ext_name, + sources=op_files, + include_dirs=include_dirs, + define_macros=define_macros, + extra_compile_args=extra_compile_args, + language='c++', + library_dirs=library_dirs, + libraries=libraries) + extensions.append(ext_ops) + + return extensions + + +setup( + name='mmcv' if os.getenv('MMCV_WITH_OPS', '0') == '0' else 'mmcv-full', + version=get_version(), + description='OpenMMLab Computer Vision Foundation', + keywords='computer vision', + packages=find_packages(), + include_package_data=True, + classifiers=[ + 'Development Status :: 4 - Beta', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Topic :: Utilities', + ], + url='https://github.com/open-mmlab/mmcv', + author='MMCV Contributors', + author_email='openmmlab@gmail.com', + setup_requires=[], + tests_require=['pytest'], + install_requires=install_requires, + ext_modules=get_extensions(), + cmdclass=cmd_class, + zip_safe=False) diff --git a/cv/instance_segmentation/SOLO/pytorch/tests/async_benchmark.py b/cv/instance_segmentation/SOLO/pytorch/tests/async_benchmark.py deleted file mode 100644 index 0017783d3..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tests/async_benchmark.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding: utf-8 - -import asyncio -import os -import shutil -import urllib - -import mmcv -import torch - -from mmdet.apis import (async_inference_detector, inference_detector, - init_detector, show_result) -from mmdet.utils.contextmanagers import concurrent -from mmdet.utils.profiling import profile_time - - -async def main(): - """ - - Benchmark between async and synchronous inference interfaces. - - Sample runs for 20 demo images on K80 GPU, model - mask_rcnn_r50_fpn_1x: - - async sync - - 7981.79 ms 9660.82 ms - 8074.52 ms 9660.94 ms - 7976.44 ms 9406.83 ms - - Async variant takes about 0.83-0.85 of the time of the synchronous - interface. - - """ - project_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) - - config_file = os.path.join(project_dir, 'configs/mask_rcnn_r50_fpn_1x.py') - checkpoint_file = os.path.join( - project_dir, 'checkpoints/mask_rcnn_r50_fpn_1x_20181010-069fa190.pth') - - if not os.path.exists(checkpoint_file): - url = ('https://s3.ap-northeast-2.amazonaws.com/open-mmlab/mmdetection' - '/models/mask_rcnn_r50_fpn_1x_20181010-069fa190.pth') - print('Downloading {} ...'.format(url)) - local_filename, _ = urllib.request.urlretrieve(url) - os.makedirs(os.path.dirname(checkpoint_file), exist_ok=True) - shutil.move(local_filename, checkpoint_file) - print('Saved as {}'.format(checkpoint_file)) - else: - print('Using existing checkpoint {}'.format(checkpoint_file)) - - device = 'cuda:0' - model = init_detector( - config_file, checkpoint=checkpoint_file, device=device) - - # queue is used for concurrent inference of multiple images - streamqueue = asyncio.Queue() - # queue size defines concurrency level - streamqueue_size = 4 - - for _ in range(streamqueue_size): - streamqueue.put_nowait(torch.cuda.Stream(device=device)) - - # test a single image and show the results - img = mmcv.imread(os.path.join(project_dir, 'demo/demo.jpg')) - - # warmup - await async_inference_detector(model, img) - - async def detect(img): - async with concurrent(streamqueue): - return await async_inference_detector(model, img) - - num_of_images = 20 - with profile_time('benchmark', 'async'): - tasks = [ - asyncio.create_task(detect(img)) for _ in range(num_of_images) - ] - async_results = await asyncio.gather(*tasks) - - with torch.cuda.stream(torch.cuda.default_stream()): - with profile_time('benchmark', 'sync'): - sync_results = [ - inference_detector(model, img) for _ in range(num_of_images) - ] - - result_dir = os.path.join(project_dir, 'demo') - show_result( - img, - async_results[0], - model.CLASSES, - score_thr=0.5, - show=False, - out_file=os.path.join(result_dir, 'result_async.jpg')) - show_result( - img, - sync_results[0], - model.CLASSES, - score_thr=0.5, - show=False, - out_file=os.path.join(result_dir, 'result_sync.jpg')) - - -if __name__ == '__main__': - asyncio.run(main()) diff --git a/cv/instance_segmentation/SOLO/pytorch/tests/test_assigner.py b/cv/instance_segmentation/SOLO/pytorch/tests/test_assigner.py deleted file mode 100644 index 5348eaba3..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tests/test_assigner.py +++ /dev/null @@ -1,277 +0,0 @@ -""" -Tests the Assigner objects. - -CommandLine: - pytest tests/test_assigner.py - xdoctest tests/test_assigner.py zero - - - -""" -import torch - -from mmdet.core import MaxIoUAssigner -from mmdet.core.bbox.assigners import ApproxMaxIoUAssigner, PointAssigner - - -def test_max_iou_assigner(): - self = MaxIoUAssigner( - pos_iou_thr=0.5, - neg_iou_thr=0.5, - ) - bboxes = torch.FloatTensor([ - [0, 0, 10, 10], - [10, 10, 20, 20], - [5, 5, 15, 15], - [32, 32, 38, 42], - ]) - gt_bboxes = torch.FloatTensor([ - [0, 0, 10, 9], - [0, 10, 10, 19], - ]) - gt_labels = torch.LongTensor([2, 3]) - assign_result = self.assign(bboxes, gt_bboxes, gt_labels=gt_labels) - assert len(assign_result.gt_inds) == 4 - assert len(assign_result.labels) == 4 - - expected_gt_inds = torch.LongTensor([1, 0, 2, 0]) - assert torch.all(assign_result.gt_inds == expected_gt_inds) - - -def test_max_iou_assigner_with_ignore(): - self = MaxIoUAssigner( - pos_iou_thr=0.5, - neg_iou_thr=0.5, - ignore_iof_thr=0.5, - ignore_wrt_candidates=False, - ) - bboxes = torch.FloatTensor([ - [0, 0, 10, 10], - [10, 10, 20, 20], - [5, 5, 15, 15], - [32, 32, 38, 42], - ]) - gt_bboxes = torch.FloatTensor([ - [0, 0, 10, 9], - [0, 10, 10, 19], - ]) - gt_bboxes_ignore = torch.Tensor([ - [30, 30, 40, 40], - ]) - assign_result = self.assign( - bboxes, gt_bboxes, gt_bboxes_ignore=gt_bboxes_ignore) - - expected_gt_inds = torch.LongTensor([1, 0, 2, -1]) - assert torch.all(assign_result.gt_inds == expected_gt_inds) - - -def test_max_iou_assigner_with_empty_gt(): - """ - Test corner case where an image might have no true detections - """ - self = MaxIoUAssigner( - pos_iou_thr=0.5, - neg_iou_thr=0.5, - ) - bboxes = torch.FloatTensor([ - [0, 0, 10, 10], - [10, 10, 20, 20], - [5, 5, 15, 15], - [32, 32, 38, 42], - ]) - gt_bboxes = torch.FloatTensor([]) - assign_result = self.assign(bboxes, gt_bboxes) - - expected_gt_inds = torch.LongTensor([0, 0, 0, 0]) - assert torch.all(assign_result.gt_inds == expected_gt_inds) - - -def test_max_iou_assigner_with_empty_boxes(): - """ - Test corner case where an network might predict no boxes - """ - self = MaxIoUAssigner( - pos_iou_thr=0.5, - neg_iou_thr=0.5, - ) - bboxes = torch.empty((0, 4)) - gt_bboxes = torch.FloatTensor([ - [0, 0, 10, 9], - [0, 10, 10, 19], - ]) - gt_labels = torch.LongTensor([2, 3]) - - # Test with gt_labels - assign_result = self.assign(bboxes, gt_bboxes, gt_labels=gt_labels) - assert len(assign_result.gt_inds) == 0 - assert tuple(assign_result.labels.shape) == (0, ) - - # Test without gt_labels - assign_result = self.assign(bboxes, gt_bboxes, gt_labels=None) - assert len(assign_result.gt_inds) == 0 - assert assign_result.labels is None - - -def test_max_iou_assigner_with_empty_boxes_and_gt(): - """ - Test corner case where an network might predict no boxes and no gt - """ - self = MaxIoUAssigner( - pos_iou_thr=0.5, - neg_iou_thr=0.5, - ) - bboxes = torch.empty((0, 4)) - gt_bboxes = torch.empty((0, 4)) - assign_result = self.assign(bboxes, gt_bboxes) - assert len(assign_result.gt_inds) == 0 - - -def test_point_assigner(): - self = PointAssigner() - points = torch.FloatTensor([ # [x, y, stride] - [0, 0, 1], - [10, 10, 1], - [5, 5, 1], - [32, 32, 1], - ]) - gt_bboxes = torch.FloatTensor([ - [0, 0, 10, 9], - [0, 10, 10, 19], - ]) - assign_result = self.assign(points, gt_bboxes) - expected_gt_inds = torch.LongTensor([1, 2, 1, 0]) - assert torch.all(assign_result.gt_inds == expected_gt_inds) - - -def test_point_assigner_with_empty_gt(): - """ - Test corner case where an image might have no true detections - """ - self = PointAssigner() - points = torch.FloatTensor([ # [x, y, stride] - [0, 0, 1], - [10, 10, 1], - [5, 5, 1], - [32, 32, 1], - ]) - gt_bboxes = torch.FloatTensor([]) - assign_result = self.assign(points, gt_bboxes) - - expected_gt_inds = torch.LongTensor([0, 0, 0, 0]) - assert torch.all(assign_result.gt_inds == expected_gt_inds) - - -def test_point_assigner_with_empty_boxes_and_gt(): - """ - Test corner case where an image might predict no points and no gt - """ - self = PointAssigner() - points = torch.FloatTensor([]) - gt_bboxes = torch.FloatTensor([]) - assign_result = self.assign(points, gt_bboxes) - assert len(assign_result.gt_inds) == 0 - - -def test_approx_iou_assigner(): - self = ApproxMaxIoUAssigner( - pos_iou_thr=0.5, - neg_iou_thr=0.5, - ) - bboxes = torch.FloatTensor([ - [0, 0, 10, 10], - [10, 10, 20, 20], - [5, 5, 15, 15], - [32, 32, 38, 42], - ]) - gt_bboxes = torch.FloatTensor([ - [0, 0, 10, 9], - [0, 10, 10, 19], - ]) - approxs_per_octave = 1 - approxs = bboxes - squares = bboxes - assign_result = self.assign(approxs, squares, approxs_per_octave, - gt_bboxes) - - expected_gt_inds = torch.LongTensor([1, 0, 2, 0]) - assert torch.all(assign_result.gt_inds == expected_gt_inds) - - -def test_approx_iou_assigner_with_empty_gt(): - """ - Test corner case where an image might have no true detections - """ - self = ApproxMaxIoUAssigner( - pos_iou_thr=0.5, - neg_iou_thr=0.5, - ) - bboxes = torch.FloatTensor([ - [0, 0, 10, 10], - [10, 10, 20, 20], - [5, 5, 15, 15], - [32, 32, 38, 42], - ]) - gt_bboxes = torch.FloatTensor([]) - approxs_per_octave = 1 - approxs = bboxes - squares = bboxes - assign_result = self.assign(approxs, squares, approxs_per_octave, - gt_bboxes) - - expected_gt_inds = torch.LongTensor([0, 0, 0, 0]) - assert torch.all(assign_result.gt_inds == expected_gt_inds) - - -def test_approx_iou_assigner_with_empty_boxes(): - """ - Test corner case where an network might predict no boxes - """ - self = ApproxMaxIoUAssigner( - pos_iou_thr=0.5, - neg_iou_thr=0.5, - ) - bboxes = torch.empty((0, 4)) - gt_bboxes = torch.FloatTensor([ - [0, 0, 10, 9], - [0, 10, 10, 19], - ]) - approxs_per_octave = 1 - approxs = bboxes - squares = bboxes - assign_result = self.assign(approxs, squares, approxs_per_octave, - gt_bboxes) - assert len(assign_result.gt_inds) == 0 - - -def test_approx_iou_assigner_with_empty_boxes_and_gt(): - """ - Test corner case where an network might predict no boxes and no gt - """ - self = ApproxMaxIoUAssigner( - pos_iou_thr=0.5, - neg_iou_thr=0.5, - ) - bboxes = torch.empty((0, 4)) - gt_bboxes = torch.empty((0, 4)) - approxs_per_octave = 1 - approxs = bboxes - squares = bboxes - assign_result = self.assign(approxs, squares, approxs_per_octave, - gt_bboxes) - assert len(assign_result.gt_inds) == 0 - - -def test_random_assign_result(): - """ - Test random instantiation of assign result to catch corner cases - """ - from mmdet.core.bbox.assigners.assign_result import AssignResult - AssignResult.random() - - AssignResult.random(num_gts=0, num_preds=0) - AssignResult.random(num_gts=0, num_preds=3) - AssignResult.random(num_gts=3, num_preds=3) - AssignResult.random(num_gts=0, num_preds=3) - AssignResult.random(num_gts=7, num_preds=7) - AssignResult.random(num_gts=7, num_preds=64) - AssignResult.random(num_gts=24, num_preds=3) diff --git a/cv/instance_segmentation/SOLO/pytorch/tests/test_async.py b/cv/instance_segmentation/SOLO/pytorch/tests/test_async.py deleted file mode 100644 index 68ecde33d..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tests/test_async.py +++ /dev/null @@ -1,78 +0,0 @@ -"""Tests for async interface.""" - -import asyncio -import os -import sys - -import asynctest -import mmcv -import torch - -from mmdet.apis import async_inference_detector, init_detector - -if sys.version_info >= (3, 7): - from mmdet.utils.contextmanagers import concurrent - - -class AsyncTestCase(asynctest.TestCase): - use_default_loop = False - forbid_get_event_loop = True - - TEST_TIMEOUT = int(os.getenv("ASYNCIO_TEST_TIMEOUT", "30")) - - def _run_test_method(self, method): - result = method() - if asyncio.iscoroutine(result): - self.loop.run_until_complete( - asyncio.wait_for(result, timeout=self.TEST_TIMEOUT)) - - -class MaskRCNNDetector: - - def __init__(self, - model_config, - checkpoint=None, - streamqueue_size=3, - device="cuda:0"): - - self.streamqueue_size = streamqueue_size - self.device = device - # build the model and load checkpoint - self.model = init_detector( - model_config, checkpoint=None, device=self.device) - self.streamqueue = None - - async def init(self): - self.streamqueue = asyncio.Queue() - for _ in range(self.streamqueue_size): - stream = torch.cuda.Stream(device=self.device) - self.streamqueue.put_nowait(stream) - - if sys.version_info >= (3, 7): - - async def apredict(self, img): - if isinstance(img, str): - img = mmcv.imread(img) - async with concurrent(self.streamqueue): - result = await async_inference_detector(self.model, img) - return result - - -class AsyncInferenceTestCase(AsyncTestCase): - - if sys.version_info >= (3, 7): - - async def test_simple_inference(self): - if not torch.cuda.is_available(): - import pytest - - pytest.skip("test requires GPU and torch+cuda") - - root_dir = os.path.dirname(os.path.dirname(__name__)) - model_config = os.path.join(root_dir, - "configs/mask_rcnn_r50_fpn_1x.py") - detector = MaskRCNNDetector(model_config) - await detector.init() - img_path = os.path.join(root_dir, "demo/demo.jpg") - bboxes, _ = await detector.apredict(img_path) - self.assertTrue(bboxes) diff --git a/cv/instance_segmentation/SOLO/pytorch/tests/test_config.py b/cv/instance_segmentation/SOLO/pytorch/tests/test_config.py deleted file mode 100644 index ebc399ff3..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tests/test_config.py +++ /dev/null @@ -1,172 +0,0 @@ -from os.path import dirname, exists, join - - -def _get_config_directory(): - """ Find the predefined detector config directory """ - try: - # Assume we are running in the source mmdetection repo - repo_dpath = dirname(dirname(__file__)) - except NameError: - # For IPython development when this __file__ is not defined - import mmdet - repo_dpath = dirname(dirname(mmdet.__file__)) - config_dpath = join(repo_dpath, 'configs') - if not exists(config_dpath): - raise Exception('Cannot find config path') - return config_dpath - - -def test_config_build_detector(): - """ - Test that all detection models defined in the configs can be initialized. - """ - from xdoctest.utils import import_module_from_path - from mmdet.models import build_detector - - config_dpath = _get_config_directory() - print('Found config_dpath = {!r}'.format(config_dpath)) - - # import glob - # config_fpaths = list(glob.glob(join(config_dpath, '**', '*.py'))) - # config_names = [relpath(p, config_dpath) for p in config_fpaths] - - # Only tests a representative subset of configurations - - config_names = [ - # 'dcn/faster_rcnn_dconv_c3-c5_r50_fpn_1x.py', - # 'dcn/cascade_mask_rcnn_dconv_c3-c5_r50_fpn_1x.py', - # 'dcn/faster_rcnn_dpool_r50_fpn_1x.py', - 'dcn/mask_rcnn_dconv_c3-c5_r50_fpn_1x.py', - # 'dcn/faster_rcnn_dconv_c3-c5_x101_32x4d_fpn_1x.py', - # 'dcn/cascade_rcnn_dconv_c3-c5_r50_fpn_1x.py', - # 'dcn/faster_rcnn_mdpool_r50_fpn_1x.py', - # 'dcn/faster_rcnn_mdconv_c3-c5_group4_r50_fpn_1x.py', - # 'dcn/faster_rcnn_mdconv_c3-c5_r50_fpn_1x.py', - # --- - # 'htc/htc_x101_32x4d_fpn_20e_16gpu.py', - 'htc/htc_without_semantic_r50_fpn_1x.py', - # 'htc/htc_dconv_c3-c5_mstrain_400_1400_x101_64x4d_fpn_20e.py', - # 'htc/htc_x101_64x4d_fpn_20e_16gpu.py', - # 'htc/htc_r50_fpn_1x.py', - # 'htc/htc_r101_fpn_20e.py', - # 'htc/htc_r50_fpn_20e.py', - # --- - 'cityscapes/mask_rcnn_r50_fpn_1x_cityscapes.py', - # 'cityscapes/faster_rcnn_r50_fpn_1x_cityscapes.py', - # --- - # 'scratch/scratch_faster_rcnn_r50_fpn_gn_6x.py', - # 'scratch/scratch_mask_rcnn_r50_fpn_gn_6x.py', - # --- - # 'grid_rcnn/grid_rcnn_gn_head_x101_32x4d_fpn_2x.py', - 'grid_rcnn/grid_rcnn_gn_head_r50_fpn_2x.py', - # --- - 'double_heads/dh_faster_rcnn_r50_fpn_1x.py', - # --- - 'empirical_attention/faster_rcnn_r50_fpn_attention_0010_dcn_1x.py', - # 'empirical_attention/faster_rcnn_r50_fpn_attention_1111_1x.py', - # 'empirical_attention/faster_rcnn_r50_fpn_attention_0010_1x.py', - # 'empirical_attention/faster_rcnn_r50_fpn_attention_1111_dcn_1x.py', - # --- - # 'ms_rcnn/ms_rcnn_r101_caffe_fpn_1x.py', - # 'ms_rcnn/ms_rcnn_x101_64x4d_fpn_1x.py', - # 'ms_rcnn/ms_rcnn_r50_caffe_fpn_1x.py', - # --- - # 'guided_anchoring/ga_faster_x101_32x4d_fpn_1x.py', - # 'guided_anchoring/ga_rpn_x101_32x4d_fpn_1x.py', - # 'guided_anchoring/ga_retinanet_r50_caffe_fpn_1x.py', - # 'guided_anchoring/ga_fast_r50_caffe_fpn_1x.py', - # 'guided_anchoring/ga_retinanet_x101_32x4d_fpn_1x.py', - # 'guided_anchoring/ga_rpn_r101_caffe_rpn_1x.py', - # 'guided_anchoring/ga_faster_r50_caffe_fpn_1x.py', - 'guided_anchoring/ga_rpn_r50_caffe_fpn_1x.py', - # --- - 'foveabox/fovea_r50_fpn_4gpu_1x.py', - # 'foveabox/fovea_align_gn_ms_r101_fpn_4gpu_2x.py', - # 'foveabox/fovea_align_gn_r50_fpn_4gpu_2x.py', - # 'foveabox/fovea_align_gn_r101_fpn_4gpu_2x.py', - 'foveabox/fovea_align_gn_ms_r50_fpn_4gpu_2x.py', - # --- - # 'hrnet/cascade_rcnn_hrnetv2p_w32_20e.py', - # 'hrnet/mask_rcnn_hrnetv2p_w32_1x.py', - # 'hrnet/cascade_mask_rcnn_hrnetv2p_w32_20e.py', - # 'hrnet/htc_hrnetv2p_w32_20e.py', - # 'hrnet/faster_rcnn_hrnetv2p_w18_1x.py', - # 'hrnet/mask_rcnn_hrnetv2p_w18_1x.py', - # 'hrnet/faster_rcnn_hrnetv2p_w32_1x.py', - # 'hrnet/faster_rcnn_hrnetv2p_w40_1x.py', - 'hrnet/fcos_hrnetv2p_w32_gn_1x_4gpu.py', - # --- - # 'gn+ws/faster_rcnn_r50_fpn_gn_ws_1x.py', - # 'gn+ws/mask_rcnn_x101_32x4d_fpn_gn_ws_2x.py', - 'gn+ws/mask_rcnn_r50_fpn_gn_ws_2x.py', - # 'gn+ws/mask_rcnn_r50_fpn_gn_ws_20_23_24e.py', - # --- - # 'wider_face/ssd300_wider_face.py', - # --- - 'pascal_voc/ssd300_voc.py', - 'pascal_voc/faster_rcnn_r50_fpn_1x_voc0712.py', - 'pascal_voc/ssd512_voc.py', - # --- - # 'gcnet/mask_rcnn_r4_gcb_c3-c5_r50_fpn_syncbn_1x.py', - # 'gcnet/mask_rcnn_r16_gcb_c3-c5_r50_fpn_syncbn_1x.py', - # 'gcnet/mask_rcnn_r4_gcb_c3-c5_r50_fpn_1x.py', - # 'gcnet/mask_rcnn_r16_gcb_c3-c5_r50_fpn_1x.py', - 'gcnet/mask_rcnn_r50_fpn_sbn_1x.py', - # --- - 'gn/mask_rcnn_r50_fpn_gn_contrib_2x.py', - # 'gn/mask_rcnn_r50_fpn_gn_2x.py', - # 'gn/mask_rcnn_r101_fpn_gn_2x.py', - # --- - # 'reppoints/reppoints_moment_x101_dcn_fpn_2x.py', - 'reppoints/reppoints_moment_r50_fpn_2x.py', - # 'reppoints/reppoints_moment_x101_dcn_fpn_2x_mt.py', - 'reppoints/reppoints_partial_minmax_r50_fpn_1x.py', - 'reppoints/bbox_r50_grid_center_fpn_1x.py', - # 'reppoints/reppoints_moment_r101_dcn_fpn_2x.py', - # 'reppoints/reppoints_moment_r101_fpn_2x_mt.py', - # 'reppoints/reppoints_moment_r50_fpn_2x_mt.py', - 'reppoints/reppoints_minmax_r50_fpn_1x.py', - # 'reppoints/reppoints_moment_r50_fpn_1x.py', - # 'reppoints/reppoints_moment_r101_fpn_2x.py', - # 'reppoints/reppoints_moment_r101_dcn_fpn_2x_mt.py', - 'reppoints/bbox_r50_grid_fpn_1x.py', - # --- - # 'fcos/fcos_mstrain_640_800_x101_64x4d_fpn_gn_2x.py', - # 'fcos/fcos_mstrain_640_800_r101_caffe_fpn_gn_2x_4gpu.py', - 'fcos/fcos_r50_caffe_fpn_gn_1x_4gpu.py', - # --- - 'albu_example/mask_rcnn_r50_fpn_1x.py', - # --- - 'libra_rcnn/libra_faster_rcnn_r50_fpn_1x.py', - # 'libra_rcnn/libra_retinanet_r50_fpn_1x.py', - # 'libra_rcnn/libra_faster_rcnn_r101_fpn_1x.py', - # 'libra_rcnn/libra_faster_rcnn_x101_64x4d_fpn_1x.py', - # 'libra_rcnn/libra_fast_rcnn_r50_fpn_1x.py', - # --- - # 'ghm/retinanet_ghm_r50_fpn_1x.py', - # --- - # 'fp16/retinanet_r50_fpn_fp16_1x.py', - 'fp16/mask_rcnn_r50_fpn_fp16_1x.py', - 'fp16/faster_rcnn_r50_fpn_fp16_1x.py' - ] - - print('Using {} config files'.format(len(config_names))) - - for config_fname in config_names: - config_fpath = join(config_dpath, config_fname) - config_mod = import_module_from_path(config_fpath) - - config_mod.model - config_mod.train_cfg - config_mod.test_cfg - print('Building detector, config_fpath = {!r}'.format(config_fpath)) - - # Remove pretrained keys to allow for testing in an offline environment - if 'pretrained' in config_mod.model: - config_mod.model['pretrained'] = None - - detector = build_detector( - config_mod.model, - train_cfg=config_mod.train_cfg, - test_cfg=config_mod.test_cfg) - assert detector is not None diff --git a/cv/instance_segmentation/SOLO/pytorch/tests/test_forward.py b/cv/instance_segmentation/SOLO/pytorch/tests/test_forward.py deleted file mode 100644 index 5ba56bf24..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tests/test_forward.py +++ /dev/null @@ -1,388 +0,0 @@ -""" -pytest tests/test_forward.py -""" -import copy -from os.path import dirname, exists, join - -import numpy as np -import torch - - -def _get_config_directory(): - """ Find the predefined detector config directory """ - try: - # Assume we are running in the source mmdetection repo - repo_dpath = dirname(dirname(__file__)) - except NameError: - # For IPython development when this __file__ is not defined - import mmdet - repo_dpath = dirname(dirname(mmdet.__file__)) - config_dpath = join(repo_dpath, 'configs') - if not exists(config_dpath): - raise Exception('Cannot find config path') - return config_dpath - - -def _get_config_module(fname): - """ - Load a configuration as a python module - """ - from xdoctest.utils import import_module_from_path - config_dpath = _get_config_directory() - config_fpath = join(config_dpath, fname) - config_mod = import_module_from_path(config_fpath) - return config_mod - - -def _get_detector_cfg(fname): - """ - Grab configs necessary to create a detector. These are deep copied to allow - for safe modification of parameters without influencing other tests. - """ - import mmcv - config = _get_config_module(fname) - model = copy.deepcopy(config.model) - train_cfg = mmcv.Config(copy.deepcopy(config.train_cfg)) - test_cfg = mmcv.Config(copy.deepcopy(config.test_cfg)) - return model, train_cfg, test_cfg - - -def test_ssd300_forward(): - model, train_cfg, test_cfg = _get_detector_cfg('ssd300_coco.py') - model['pretrained'] = None - - from mmdet.models import build_detector - detector = build_detector(model, train_cfg=train_cfg, test_cfg=test_cfg) - - input_shape = (1, 3, 300, 300) - mm_inputs = _demo_mm_inputs(input_shape) - - imgs = mm_inputs.pop('imgs') - img_metas = mm_inputs.pop('img_metas') - - # Test forward train - gt_bboxes = mm_inputs['gt_bboxes'] - gt_labels = mm_inputs['gt_labels'] - losses = detector.forward( - imgs, - img_metas, - gt_bboxes=gt_bboxes, - gt_labels=gt_labels, - return_loss=True) - assert isinstance(losses, dict) - - # Test forward test - with torch.no_grad(): - img_list = [g[None, :] for g in imgs] - batch_results = [] - for one_img, one_meta in zip(img_list, img_metas): - result = detector.forward([one_img], [[one_meta]], - return_loss=False) - batch_results.append(result) - - -def test_rpn_forward(): - model, train_cfg, test_cfg = _get_detector_cfg('rpn_r50_fpn_1x.py') - model['pretrained'] = None - - from mmdet.models import build_detector - detector = build_detector(model, train_cfg=train_cfg, test_cfg=test_cfg) - - input_shape = (1, 3, 224, 224) - mm_inputs = _demo_mm_inputs(input_shape) - - imgs = mm_inputs.pop('imgs') - img_metas = mm_inputs.pop('img_metas') - - # Test forward train - gt_bboxes = mm_inputs['gt_bboxes'] - losses = detector.forward( - imgs, img_metas, gt_bboxes=gt_bboxes, return_loss=True) - assert isinstance(losses, dict) - - # Test forward test - with torch.no_grad(): - img_list = [g[None, :] for g in imgs] - batch_results = [] - for one_img, one_meta in zip(img_list, img_metas): - result = detector.forward([one_img], [[one_meta]], - return_loss=False) - batch_results.append(result) - - -def test_retina_ghm_forward(): - model, train_cfg, test_cfg = _get_detector_cfg( - 'ghm/retinanet_ghm_r50_fpn_1x.py') - model['pretrained'] = None - - from mmdet.models import build_detector - detector = build_detector(model, train_cfg=train_cfg, test_cfg=test_cfg) - - input_shape = (3, 3, 224, 224) - mm_inputs = _demo_mm_inputs(input_shape) - - imgs = mm_inputs.pop('imgs') - img_metas = mm_inputs.pop('img_metas') - - # Test forward train - gt_bboxes = mm_inputs['gt_bboxes'] - gt_labels = mm_inputs['gt_labels'] - losses = detector.forward( - imgs, - img_metas, - gt_bboxes=gt_bboxes, - gt_labels=gt_labels, - return_loss=True) - assert isinstance(losses, dict) - - # Test forward test - with torch.no_grad(): - img_list = [g[None, :] for g in imgs] - batch_results = [] - for one_img, one_meta in zip(img_list, img_metas): - result = detector.forward([one_img], [[one_meta]], - return_loss=False) - batch_results.append(result) - - if torch.cuda.is_available(): - detector = detector.cuda() - imgs = imgs.cuda() - # Test forward train - gt_bboxes = [b.cuda() for b in mm_inputs['gt_bboxes']] - gt_labels = [g.cuda() for g in mm_inputs['gt_labels']] - losses = detector.forward( - imgs, - img_metas, - gt_bboxes=gt_bboxes, - gt_labels=gt_labels, - return_loss=True) - assert isinstance(losses, dict) - - # Test forward test - with torch.no_grad(): - img_list = [g[None, :] for g in imgs] - batch_results = [] - for one_img, one_meta in zip(img_list, img_metas): - result = detector.forward([one_img], [[one_meta]], - return_loss=False) - batch_results.append(result) - - -def test_cascade_forward(): - try: - from torchvision import _C as C # NOQA - except ImportError: - import pytest - raise pytest.skip('requires torchvision on cpu') - - model, train_cfg, test_cfg = _get_detector_cfg( - 'cascade_rcnn_r50_fpn_1x.py') - model['pretrained'] = None - # torchvision roi align supports CPU - model['bbox_roi_extractor']['roi_layer']['use_torchvision'] = True - - from mmdet.models import build_detector - detector = build_detector(model, train_cfg=train_cfg, test_cfg=test_cfg) - - input_shape = (1, 3, 256, 256) - - # Test forward train with a non-empty truth batch - mm_inputs = _demo_mm_inputs(input_shape, num_items=[10]) - imgs = mm_inputs.pop('imgs') - img_metas = mm_inputs.pop('img_metas') - gt_bboxes = mm_inputs['gt_bboxes'] - gt_labels = mm_inputs['gt_labels'] - losses = detector.forward( - imgs, - img_metas, - gt_bboxes=gt_bboxes, - gt_labels=gt_labels, - return_loss=True) - assert isinstance(losses, dict) - from mmdet.apis.train import parse_losses - total_loss = float(parse_losses(losses)[0].item()) - assert total_loss > 0 - - # Test forward train with an empty truth batch - mm_inputs = _demo_mm_inputs(input_shape, num_items=[0]) - imgs = mm_inputs.pop('imgs') - img_metas = mm_inputs.pop('img_metas') - gt_bboxes = mm_inputs['gt_bboxes'] - gt_labels = mm_inputs['gt_labels'] - losses = detector.forward( - imgs, - img_metas, - gt_bboxes=gt_bboxes, - gt_labels=gt_labels, - return_loss=True) - assert isinstance(losses, dict) - from mmdet.apis.train import parse_losses - total_loss = float(parse_losses(losses)[0].item()) - assert total_loss > 0 - - -def test_faster_rcnn_forward(): - try: - from torchvision import _C as C # NOQA - except ImportError: - import pytest - raise pytest.skip('requires torchvision on cpu') - - model, train_cfg, test_cfg = _get_detector_cfg('faster_rcnn_r50_fpn_1x.py') - model['pretrained'] = None - # torchvision roi align supports CPU - model['bbox_roi_extractor']['roi_layer']['use_torchvision'] = True - - from mmdet.models import build_detector - detector = build_detector(model, train_cfg=train_cfg, test_cfg=test_cfg) - - input_shape = (1, 3, 256, 256) - - # Test forward train with a non-empty truth batch - mm_inputs = _demo_mm_inputs(input_shape, num_items=[10]) - imgs = mm_inputs.pop('imgs') - img_metas = mm_inputs.pop('img_metas') - gt_bboxes = mm_inputs['gt_bboxes'] - gt_labels = mm_inputs['gt_labels'] - losses = detector.forward( - imgs, - img_metas, - gt_bboxes=gt_bboxes, - gt_labels=gt_labels, - return_loss=True) - assert isinstance(losses, dict) - from mmdet.apis.train import parse_losses - total_loss = float(parse_losses(losses)[0].item()) - assert total_loss > 0 - - # Test forward train with an empty truth batch - mm_inputs = _demo_mm_inputs(input_shape, num_items=[0]) - imgs = mm_inputs.pop('imgs') - img_metas = mm_inputs.pop('img_metas') - gt_bboxes = mm_inputs['gt_bboxes'] - gt_labels = mm_inputs['gt_labels'] - losses = detector.forward( - imgs, - img_metas, - gt_bboxes=gt_bboxes, - gt_labels=gt_labels, - return_loss=True) - assert isinstance(losses, dict) - from mmdet.apis.train import parse_losses - total_loss = float(parse_losses(losses)[0].item()) - assert total_loss > 0 - - -def test_faster_rcnn_ohem_forward(): - try: - from torchvision import _C as C # NOQA - except ImportError: - import pytest - raise pytest.skip('requires torchvision on cpu') - - model, train_cfg, test_cfg = _get_detector_cfg( - 'faster_rcnn_ohem_r50_fpn_1x.py') - model['pretrained'] = None - # torchvision roi align supports CPU - model['bbox_roi_extractor']['roi_layer']['use_torchvision'] = True - - from mmdet.models import build_detector - detector = build_detector(model, train_cfg=train_cfg, test_cfg=test_cfg) - - input_shape = (1, 3, 256, 256) - - # Test forward train with a non-empty truth batch - mm_inputs = _demo_mm_inputs(input_shape, num_items=[10]) - imgs = mm_inputs.pop('imgs') - img_metas = mm_inputs.pop('img_metas') - gt_bboxes = mm_inputs['gt_bboxes'] - gt_labels = mm_inputs['gt_labels'] - losses = detector.forward( - imgs, - img_metas, - gt_bboxes=gt_bboxes, - gt_labels=gt_labels, - return_loss=True) - assert isinstance(losses, dict) - from mmdet.apis.train import parse_losses - total_loss = float(parse_losses(losses)[0].item()) - assert total_loss > 0 - - # Test forward train with an empty truth batch - mm_inputs = _demo_mm_inputs(input_shape, num_items=[0]) - imgs = mm_inputs.pop('imgs') - img_metas = mm_inputs.pop('img_metas') - gt_bboxes = mm_inputs['gt_bboxes'] - gt_labels = mm_inputs['gt_labels'] - losses = detector.forward( - imgs, - img_metas, - gt_bboxes=gt_bboxes, - gt_labels=gt_labels, - return_loss=True) - assert isinstance(losses, dict) - from mmdet.apis.train import parse_losses - total_loss = float(parse_losses(losses)[0].item()) - assert total_loss > 0 - - -def _demo_mm_inputs(input_shape=(1, 3, 300, 300), - num_items=None, num_classes=10): # yapf: disable - """ - Create a superset of inputs needed to run test or train batches. - - Args: - input_shape (tuple): - input batch dimensions - - num_items (None | List[int]): - specifies the number of boxes in each batch item - - num_classes (int): - number of different labels a box might have - """ - (N, C, H, W) = input_shape - - rng = np.random.RandomState(0) - - imgs = rng.rand(*input_shape) - - img_metas = [{ - 'img_shape': (H, W, C), - 'ori_shape': (H, W, C), - 'pad_shape': (H, W, C), - 'filename': '.png', - 'scale_factor': 1.0, - 'flip': False, - } for _ in range(N)] - - gt_bboxes = [] - gt_labels = [] - - for batch_idx in range(N): - if num_items is None: - num_boxes = rng.randint(1, 10) - else: - num_boxes = num_items[batch_idx] - - cx, cy, bw, bh = rng.rand(num_boxes, 4).T - - tl_x = ((cx * W) - (W * bw / 2)).clip(0, W) - tl_y = ((cy * H) - (H * bh / 2)).clip(0, H) - br_x = ((cx * W) + (W * bw / 2)).clip(0, W) - br_y = ((cy * H) + (H * bh / 2)).clip(0, H) - - boxes = np.vstack([tl_x, tl_y, br_x, br_y]).T - class_idxs = rng.randint(1, num_classes, size=num_boxes) - - gt_bboxes.append(torch.FloatTensor(boxes)) - gt_labels.append(torch.LongTensor(class_idxs)) - - mm_inputs = { - 'imgs': torch.FloatTensor(imgs), - 'img_metas': img_metas, - 'gt_bboxes': gt_bboxes, - 'gt_labels': gt_labels, - 'gt_bboxes_ignore': None, - } - return mm_inputs diff --git a/cv/instance_segmentation/SOLO/pytorch/tests/test_heads.py b/cv/instance_segmentation/SOLO/pytorch/tests/test_heads.py deleted file mode 100644 index b1e4ceebf..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tests/test_heads.py +++ /dev/null @@ -1,340 +0,0 @@ -import mmcv -import torch - -from mmdet.core import build_assigner, build_sampler -from mmdet.models.anchor_heads import AnchorHead -from mmdet.models.bbox_heads import BBoxHead - - -def test_anchor_head_loss(): - """ - Tests anchor head loss when truth is empty and non-empty - """ - self = AnchorHead(num_classes=4, in_channels=1) - s = 256 - img_metas = [{ - 'img_shape': (s, s, 3), - 'scale_factor': 1, - 'pad_shape': (s, s, 3) - }] - - cfg = mmcv.Config({ - 'assigner': { - 'type': 'MaxIoUAssigner', - 'pos_iou_thr': 0.7, - 'neg_iou_thr': 0.3, - 'min_pos_iou': 0.3, - 'ignore_iof_thr': -1 - }, - 'sampler': { - 'type': 'RandomSampler', - 'num': 256, - 'pos_fraction': 0.5, - 'neg_pos_ub': -1, - 'add_gt_as_proposals': False - }, - 'allowed_border': 0, - 'pos_weight': -1, - 'debug': False - }) - - # Anchor head expects a multiple levels of features per image - feat = [ - torch.rand(1, 1, s // (2**(i + 2)), s // (2**(i + 2))) - for i in range(len(self.anchor_generators)) - ] - cls_scores, bbox_preds = self.forward(feat) - - # Test that empty ground truth encourages the network to predict background - gt_bboxes = [torch.empty((0, 4))] - gt_labels = [torch.LongTensor([])] - - gt_bboxes_ignore = None - empty_gt_losses = self.loss(cls_scores, bbox_preds, gt_bboxes, gt_labels, - img_metas, cfg, gt_bboxes_ignore) - # When there is no truth, the cls loss should be nonzero but there should - # be no box loss. - empty_cls_loss = sum(empty_gt_losses['loss_cls']) - empty_box_loss = sum(empty_gt_losses['loss_bbox']) - assert empty_cls_loss.item() > 0, 'cls loss should be non-zero' - assert empty_box_loss.item() == 0, ( - 'there should be no box loss when there are no true boxes') - - # When truth is non-empty then both cls and box loss should be nonzero for - # random inputs - gt_bboxes = [ - torch.Tensor([[23.6667, 23.8757, 238.6326, 151.8874]]), - ] - gt_labels = [torch.LongTensor([2])] - one_gt_losses = self.loss(cls_scores, bbox_preds, gt_bboxes, gt_labels, - img_metas, cfg, gt_bboxes_ignore) - onegt_cls_loss = sum(one_gt_losses['loss_cls']) - onegt_box_loss = sum(one_gt_losses['loss_bbox']) - assert onegt_cls_loss.item() > 0, 'cls loss should be non-zero' - assert onegt_box_loss.item() > 0, 'box loss should be non-zero' - - -def test_bbox_head_loss(): - """ - Tests bbox head loss when truth is empty and non-empty - """ - self = BBoxHead(in_channels=8, roi_feat_size=3) - - num_imgs = 1 - feat = torch.rand(1, 1, 3, 3) - - # Dummy proposals - proposal_list = [ - torch.Tensor([[23.6667, 23.8757, 228.6326, 153.8874]]), - ] - - target_cfg = mmcv.Config({'pos_weight': 1}) - - def _dummy_bbox_sampling(proposal_list, gt_bboxes, gt_labels): - """ - Create sample results that can be passed to BBoxHead.get_target - """ - assign_config = { - 'type': 'MaxIoUAssigner', - 'pos_iou_thr': 0.5, - 'neg_iou_thr': 0.5, - 'min_pos_iou': 0.5, - 'ignore_iof_thr': -1 - } - sampler_config = { - 'type': 'RandomSampler', - 'num': 512, - 'pos_fraction': 0.25, - 'neg_pos_ub': -1, - 'add_gt_as_proposals': True - } - bbox_assigner = build_assigner(assign_config) - bbox_sampler = build_sampler(sampler_config) - gt_bboxes_ignore = [None for _ in range(num_imgs)] - sampling_results = [] - for i in range(num_imgs): - assign_result = bbox_assigner.assign(proposal_list[i], - gt_bboxes[i], - gt_bboxes_ignore[i], - gt_labels[i]) - sampling_result = bbox_sampler.sample( - assign_result, - proposal_list[i], - gt_bboxes[i], - gt_labels[i], - feats=feat) - sampling_results.append(sampling_result) - return sampling_results - - # Test bbox loss when truth is empty - gt_bboxes = [torch.empty((0, 4))] - gt_labels = [torch.LongTensor([])] - - sampling_results = _dummy_bbox_sampling(proposal_list, gt_bboxes, - gt_labels) - - bbox_targets = self.get_target(sampling_results, gt_bboxes, gt_labels, - target_cfg) - labels, label_weights, bbox_targets, bbox_weights = bbox_targets - - # Create dummy features "extracted" for each sampled bbox - num_sampled = sum(len(res.bboxes) for res in sampling_results) - dummy_feats = torch.rand(num_sampled, 8 * 3 * 3) - cls_scores, bbox_preds = self.forward(dummy_feats) - - losses = self.loss(cls_scores, bbox_preds, labels, label_weights, - bbox_targets, bbox_weights) - assert losses.get('loss_cls', 0) > 0, 'cls-loss should be non-zero' - assert losses.get('loss_bbox', 0) == 0, 'empty gt loss should be zero' - - # Test bbox loss when truth is non-empty - gt_bboxes = [ - torch.Tensor([[23.6667, 23.8757, 238.6326, 151.8874]]), - ] - gt_labels = [torch.LongTensor([2])] - - sampling_results = _dummy_bbox_sampling(proposal_list, gt_bboxes, - gt_labels) - - bbox_targets = self.get_target(sampling_results, gt_bboxes, gt_labels, - target_cfg) - labels, label_weights, bbox_targets, bbox_weights = bbox_targets - - # Create dummy features "extracted" for each sampled bbox - num_sampled = sum(len(res.bboxes) for res in sampling_results) - dummy_feats = torch.rand(num_sampled, 8 * 3 * 3) - cls_scores, bbox_preds = self.forward(dummy_feats) - - losses = self.loss(cls_scores, bbox_preds, labels, label_weights, - bbox_targets, bbox_weights) - assert losses.get('loss_cls', 0) > 0, 'cls-loss should be non-zero' - assert losses.get('loss_bbox', 0) > 0, 'box-loss should be non-zero' - - -def test_refine_boxes(): - """ - Mirrors the doctest in - ``mmdet.models.bbox_heads.bbox_head.BBoxHead.refine_boxes`` but checks for - multiple values of n_roi / n_img. - """ - self = BBoxHead(reg_class_agnostic=True) - - test_settings = [ - - # Corner case: less rois than images - { - 'n_roi': 2, - 'n_img': 4, - 'rng': 34285940 - }, - - # Corner case: no images - { - 'n_roi': 0, - 'n_img': 0, - 'rng': 52925222 - }, - - # Corner cases: few images / rois - { - 'n_roi': 1, - 'n_img': 1, - 'rng': 1200281 - }, - { - 'n_roi': 2, - 'n_img': 1, - 'rng': 1200282 - }, - { - 'n_roi': 2, - 'n_img': 2, - 'rng': 1200283 - }, - { - 'n_roi': 1, - 'n_img': 2, - 'rng': 1200284 - }, - - # Corner case: no rois few images - { - 'n_roi': 0, - 'n_img': 1, - 'rng': 23955860 - }, - { - 'n_roi': 0, - 'n_img': 2, - 'rng': 25830516 - }, - - # Corner case: no rois many images - { - 'n_roi': 0, - 'n_img': 10, - 'rng': 671346 - }, - { - 'n_roi': 0, - 'n_img': 20, - 'rng': 699807 - }, - - # Corner case: similar num rois and images - { - 'n_roi': 20, - 'n_img': 20, - 'rng': 1200238 - }, - { - 'n_roi': 10, - 'n_img': 20, - 'rng': 1200238 - }, - { - 'n_roi': 5, - 'n_img': 5, - 'rng': 1200238 - }, - - # ---------------------------------- - # Common case: more rois than images - { - 'n_roi': 100, - 'n_img': 1, - 'rng': 337156 - }, - { - 'n_roi': 150, - 'n_img': 2, - 'rng': 275898 - }, - { - 'n_roi': 500, - 'n_img': 5, - 'rng': 4903221 - }, - ] - - for demokw in test_settings: - try: - n_roi = demokw['n_roi'] - n_img = demokw['n_img'] - rng = demokw['rng'] - - print('Test refine_boxes case: {!r}'.format(demokw)) - tup = _demodata_refine_boxes(n_roi, n_img, rng=rng) - rois, labels, bbox_preds, pos_is_gts, img_metas = tup - bboxes_list = self.refine_bboxes(rois, labels, bbox_preds, - pos_is_gts, img_metas) - assert len(bboxes_list) == n_img - assert sum(map(len, bboxes_list)) <= n_roi - assert all(b.shape[1] == 4 for b in bboxes_list) - except Exception: - print('Test failed with demokw={!r}'.format(demokw)) - raise - - -def _demodata_refine_boxes(n_roi, n_img, rng=0): - """ - Create random test data for the - ``mmdet.models.bbox_heads.bbox_head.BBoxHead.refine_boxes`` method - """ - import numpy as np - from mmdet.core.bbox.demodata import random_boxes - from mmdet.core.bbox.demodata import ensure_rng - try: - import kwarray - except ImportError: - import pytest - pytest.skip('kwarray is required for this test') - scale = 512 - rng = ensure_rng(rng) - img_metas = [{'img_shape': (scale, scale)} for _ in range(n_img)] - # Create rois in the expected format - roi_boxes = random_boxes(n_roi, scale=scale, rng=rng) - if n_img == 0: - assert n_roi == 0, 'cannot have any rois if there are no images' - img_ids = torch.empty((0, ), dtype=torch.long) - roi_boxes = torch.empty((0, 4), dtype=torch.float32) - else: - img_ids = rng.randint(0, n_img, (n_roi, )) - img_ids = torch.from_numpy(img_ids) - rois = torch.cat([img_ids[:, None].float(), roi_boxes], dim=1) - # Create other args - labels = rng.randint(0, 2, (n_roi, )) - labels = torch.from_numpy(labels).long() - bbox_preds = random_boxes(n_roi, scale=scale, rng=rng) - # For each image, pretend random positive boxes are gts - is_label_pos = (labels.numpy() > 0).astype(np.int) - lbl_per_img = kwarray.group_items(is_label_pos, img_ids.numpy()) - pos_per_img = [sum(lbl_per_img.get(gid, [])) for gid in range(n_img)] - # randomly generate with numpy then sort with torch - _pos_is_gts = [ - rng.randint(0, 2, (npos, )).astype(np.uint8) for npos in pos_per_img - ] - pos_is_gts = [ - torch.from_numpy(p).sort(descending=True)[0] for p in _pos_is_gts - ] - return rois, labels, bbox_preds, pos_is_gts, img_metas diff --git a/cv/instance_segmentation/SOLO/pytorch/tests/test_nms.py b/cv/instance_segmentation/SOLO/pytorch/tests/test_nms.py deleted file mode 100644 index 6861f1e59..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tests/test_nms.py +++ /dev/null @@ -1,70 +0,0 @@ -""" -CommandLine: - pytest tests/test_nms.py -""" -import numpy as np -import torch - -from mmdet.ops.nms.nms_wrapper import nms - - -def test_nms_device_and_dtypes_cpu(): - """ - CommandLine: - xdoctest -m tests/test_nms.py test_nms_device_and_dtypes_cpu - """ - iou_thr = 0.7 - base_dets = np.array([[49.1, 32.4, 51.0, 35.9, 0.9], - [49.3, 32.9, 51.0, 35.3, 0.9], - [35.3, 11.5, 39.9, 14.5, 0.4], - [35.2, 11.7, 39.7, 15.7, 0.3]]) - - # CPU can handle float32 and float64 - dets = base_dets.astype(np.float32) - supressed, inds = nms(dets, iou_thr) - assert dets.dtype == supressed.dtype - assert len(inds) == len(supressed) == 3 - - dets = torch.FloatTensor(base_dets) - surpressed, inds = nms(dets, iou_thr) - assert dets.dtype == surpressed.dtype - assert len(inds) == len(surpressed) == 3 - - dets = base_dets.astype(np.float64) - supressed, inds = nms(dets, iou_thr) - assert dets.dtype == supressed.dtype - assert len(inds) == len(supressed) == 3 - - dets = torch.DoubleTensor(base_dets) - surpressed, inds = nms(dets, iou_thr) - assert dets.dtype == surpressed.dtype - assert len(inds) == len(surpressed) == 3 - - -def test_nms_device_and_dtypes_gpu(): - """ - CommandLine: - xdoctest -m tests/test_nms.py test_nms_device_and_dtypes_gpu - """ - if not torch.cuda.is_available(): - import pytest - pytest.skip('test requires GPU and torch+cuda') - - iou_thr = 0.7 - base_dets = np.array([[49.1, 32.4, 51.0, 35.9, 0.9], - [49.3, 32.9, 51.0, 35.3, 0.9], - [35.3, 11.5, 39.9, 14.5, 0.4], - [35.2, 11.7, 39.7, 15.7, 0.3]]) - - for device_id in range(torch.cuda.device_count()): - print('Run NMS on device_id = {!r}'.format(device_id)) - # GPU can handle float32 but not float64 - dets = base_dets.astype(np.float32) - supressed, inds = nms(dets, iou_thr, device_id) - assert dets.dtype == supressed.dtype - assert len(inds) == len(supressed) == 3 - - dets = torch.FloatTensor(base_dets).to(device_id) - surpressed, inds = nms(dets, iou_thr) - assert dets.dtype == surpressed.dtype - assert len(inds) == len(surpressed) == 3 diff --git a/cv/instance_segmentation/SOLO/pytorch/tests/test_sampler.py b/cv/instance_segmentation/SOLO/pytorch/tests/test_sampler.py deleted file mode 100644 index c75360268..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tests/test_sampler.py +++ /dev/null @@ -1,249 +0,0 @@ -import torch - -from mmdet.core import MaxIoUAssigner -from mmdet.core.bbox.samplers import OHEMSampler, RandomSampler - - -def test_random_sampler(): - assigner = MaxIoUAssigner( - pos_iou_thr=0.5, - neg_iou_thr=0.5, - ignore_iof_thr=0.5, - ignore_wrt_candidates=False, - ) - bboxes = torch.FloatTensor([ - [0, 0, 10, 10], - [10, 10, 20, 20], - [5, 5, 15, 15], - [32, 32, 38, 42], - ]) - gt_bboxes = torch.FloatTensor([ - [0, 0, 10, 9], - [0, 10, 10, 19], - ]) - gt_labels = torch.LongTensor([1, 2]) - gt_bboxes_ignore = torch.Tensor([ - [30, 30, 40, 40], - ]) - assign_result = assigner.assign( - bboxes, - gt_bboxes, - gt_bboxes_ignore=gt_bboxes_ignore, - gt_labels=gt_labels) - - sampler = RandomSampler( - num=10, pos_fraction=0.5, neg_pos_ub=-1, add_gt_as_proposals=True) - - sample_result = sampler.sample(assign_result, bboxes, gt_bboxes, gt_labels) - - assert len(sample_result.pos_bboxes) == len(sample_result.pos_inds) - assert len(sample_result.neg_bboxes) == len(sample_result.neg_inds) - - -def test_random_sampler_empty_gt(): - assigner = MaxIoUAssigner( - pos_iou_thr=0.5, - neg_iou_thr=0.5, - ignore_iof_thr=0.5, - ignore_wrt_candidates=False, - ) - bboxes = torch.FloatTensor([ - [0, 0, 10, 10], - [10, 10, 20, 20], - [5, 5, 15, 15], - [32, 32, 38, 42], - ]) - gt_bboxes = torch.empty(0, 4) - gt_labels = torch.empty(0, ).long() - assign_result = assigner.assign(bboxes, gt_bboxes, gt_labels=gt_labels) - - sampler = RandomSampler( - num=10, pos_fraction=0.5, neg_pos_ub=-1, add_gt_as_proposals=True) - - sample_result = sampler.sample(assign_result, bboxes, gt_bboxes, gt_labels) - - assert len(sample_result.pos_bboxes) == len(sample_result.pos_inds) - assert len(sample_result.neg_bboxes) == len(sample_result.neg_inds) - - -def test_random_sampler_empty_pred(): - assigner = MaxIoUAssigner( - pos_iou_thr=0.5, - neg_iou_thr=0.5, - ignore_iof_thr=0.5, - ignore_wrt_candidates=False, - ) - bboxes = torch.empty(0, 4) - gt_bboxes = torch.FloatTensor([ - [0, 0, 10, 9], - [0, 10, 10, 19], - ]) - gt_labels = torch.LongTensor([1, 2]) - assign_result = assigner.assign(bboxes, gt_bboxes, gt_labels=gt_labels) - - sampler = RandomSampler( - num=10, pos_fraction=0.5, neg_pos_ub=-1, add_gt_as_proposals=True) - - sample_result = sampler.sample(assign_result, bboxes, gt_bboxes, gt_labels) - - assert len(sample_result.pos_bboxes) == len(sample_result.pos_inds) - assert len(sample_result.neg_bboxes) == len(sample_result.neg_inds) - - -def _context_for_ohem(): - try: - from test_forward import _get_detector_cfg - except ImportError: - # Hack: grab testing utils from test_forward to make a context for ohem - import sys - from os.path import dirname - sys.path.insert(0, dirname(__file__)) - from test_forward import _get_detector_cfg - model, train_cfg, test_cfg = _get_detector_cfg( - 'faster_rcnn_ohem_r50_fpn_1x.py') - model['pretrained'] = None - # torchvision roi align supports CPU - model['bbox_roi_extractor']['roi_layer']['use_torchvision'] = True - from mmdet.models import build_detector - context = build_detector(model, train_cfg=train_cfg, test_cfg=test_cfg) - return context - - -def test_ohem_sampler(): - - assigner = MaxIoUAssigner( - pos_iou_thr=0.5, - neg_iou_thr=0.5, - ignore_iof_thr=0.5, - ignore_wrt_candidates=False, - ) - bboxes = torch.FloatTensor([ - [0, 0, 10, 10], - [10, 10, 20, 20], - [5, 5, 15, 15], - [32, 32, 38, 42], - ]) - gt_bboxes = torch.FloatTensor([ - [0, 0, 10, 9], - [0, 10, 10, 19], - ]) - gt_labels = torch.LongTensor([1, 2]) - gt_bboxes_ignore = torch.Tensor([ - [30, 30, 40, 40], - ]) - assign_result = assigner.assign( - bboxes, - gt_bboxes, - gt_bboxes_ignore=gt_bboxes_ignore, - gt_labels=gt_labels) - - context = _context_for_ohem() - - sampler = OHEMSampler( - num=10, - pos_fraction=0.5, - context=context, - neg_pos_ub=-1, - add_gt_as_proposals=True) - - feats = [torch.rand(1, 256, int(2**i), int(2**i)) for i in [6, 5, 4, 3, 2]] - sample_result = sampler.sample( - assign_result, bboxes, gt_bboxes, gt_labels, feats=feats) - - assert len(sample_result.pos_bboxes) == len(sample_result.pos_inds) - assert len(sample_result.neg_bboxes) == len(sample_result.neg_inds) - - -def test_ohem_sampler_empty_gt(): - - assigner = MaxIoUAssigner( - pos_iou_thr=0.5, - neg_iou_thr=0.5, - ignore_iof_thr=0.5, - ignore_wrt_candidates=False, - ) - bboxes = torch.FloatTensor([ - [0, 0, 10, 10], - [10, 10, 20, 20], - [5, 5, 15, 15], - [32, 32, 38, 42], - ]) - gt_bboxes = torch.empty(0, 4) - gt_labels = torch.LongTensor([]) - gt_bboxes_ignore = torch.Tensor([]) - assign_result = assigner.assign( - bboxes, - gt_bboxes, - gt_bboxes_ignore=gt_bboxes_ignore, - gt_labels=gt_labels) - - context = _context_for_ohem() - - sampler = OHEMSampler( - num=10, - pos_fraction=0.5, - context=context, - neg_pos_ub=-1, - add_gt_as_proposals=True) - - feats = [torch.rand(1, 256, int(2**i), int(2**i)) for i in [6, 5, 4, 3, 2]] - - sample_result = sampler.sample( - assign_result, bboxes, gt_bboxes, gt_labels, feats=feats) - - assert len(sample_result.pos_bboxes) == len(sample_result.pos_inds) - assert len(sample_result.neg_bboxes) == len(sample_result.neg_inds) - - -def test_ohem_sampler_empty_pred(): - assigner = MaxIoUAssigner( - pos_iou_thr=0.5, - neg_iou_thr=0.5, - ignore_iof_thr=0.5, - ignore_wrt_candidates=False, - ) - bboxes = torch.empty(0, 4) - gt_bboxes = torch.FloatTensor([ - [0, 0, 10, 10], - [10, 10, 20, 20], - [5, 5, 15, 15], - [32, 32, 38, 42], - ]) - gt_labels = torch.LongTensor([1, 2, 2, 3]) - gt_bboxes_ignore = torch.Tensor([]) - assign_result = assigner.assign( - bboxes, - gt_bboxes, - gt_bboxes_ignore=gt_bboxes_ignore, - gt_labels=gt_labels) - - context = _context_for_ohem() - - sampler = OHEMSampler( - num=10, - pos_fraction=0.5, - context=context, - neg_pos_ub=-1, - add_gt_as_proposals=True) - - feats = [torch.rand(1, 256, int(2**i), int(2**i)) for i in [6, 5, 4, 3, 2]] - - sample_result = sampler.sample( - assign_result, bboxes, gt_bboxes, gt_labels, feats=feats) - - assert len(sample_result.pos_bboxes) == len(sample_result.pos_inds) - assert len(sample_result.neg_bboxes) == len(sample_result.neg_inds) - - -def test_random_sample_result(): - from mmdet.core.bbox.samplers.sampling_result import SamplingResult - SamplingResult.random(num_gts=0, num_preds=0) - SamplingResult.random(num_gts=0, num_preds=3) - SamplingResult.random(num_gts=3, num_preds=3) - SamplingResult.random(num_gts=0, num_preds=3) - SamplingResult.random(num_gts=7, num_preds=7) - SamplingResult.random(num_gts=7, num_preds=64) - SamplingResult.random(num_gts=24, num_preds=3) - - for i in range(3): - SamplingResult.random(rng=i) diff --git a/cv/instance_segmentation/SOLO/pytorch/tests/test_utils.py b/cv/instance_segmentation/SOLO/pytorch/tests/test_utils.py deleted file mode 100644 index cdefd2df2..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tests/test_utils.py +++ /dev/null @@ -1,9 +0,0 @@ -import numpy.testing as npt - -from mmdet.utils.flops_counter import params_to_string - - -def test_params_to_string(): - npt.assert_equal(params_to_string(1e9), '1000.0 M') - npt.assert_equal(params_to_string(2e5), '200.0 k') - npt.assert_equal(params_to_string(3e-9), '3e-09') diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/analyze_logs.py b/cv/instance_segmentation/SOLO/pytorch/tools/analyze_logs.py deleted file mode 100644 index 2810c98f1..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tools/analyze_logs.py +++ /dev/null @@ -1,178 +0,0 @@ -import argparse -import json -from collections import defaultdict - -import matplotlib.pyplot as plt -import numpy as np -import seaborn as sns - - -def cal_train_time(log_dicts, args): - for i, log_dict in enumerate(log_dicts): - print('{}Analyze train time of {}{}'.format('-' * 5, args.json_logs[i], - '-' * 5)) - all_times = [] - for epoch in log_dict.keys(): - if args.include_outliers: - all_times.append(log_dict[epoch]['time']) - else: - all_times.append(log_dict[epoch]['time'][1:]) - all_times = np.array(all_times) - epoch_ave_time = all_times.mean(-1) - slowest_epoch = epoch_ave_time.argmax() - fastest_epoch = epoch_ave_time.argmin() - std_over_epoch = epoch_ave_time.std() - print('slowest epoch {}, average time is {:.4f}'.format( - slowest_epoch + 1, epoch_ave_time[slowest_epoch])) - print('fastest epoch {}, average time is {:.4f}'.format( - fastest_epoch + 1, epoch_ave_time[fastest_epoch])) - print('time std over epochs is {:.4f}'.format(std_over_epoch)) - print('average iter time: {:.4f} s/iter'.format(np.mean(all_times))) - print() - - -def plot_curve(log_dicts, args): - if args.backend is not None: - plt.switch_backend(args.backend) - sns.set_style(args.style) - # if legend is None, use {filename}_{key} as legend - legend = args.legend - if legend is None: - legend = [] - for json_log in args.json_logs: - for metric in args.keys: - legend.append('{}_{}'.format(json_log, metric)) - assert len(legend) == (len(args.json_logs) * len(args.keys)) - metrics = args.keys - - num_metrics = len(metrics) - for i, log_dict in enumerate(log_dicts): - epochs = list(log_dict.keys()) - for j, metric in enumerate(metrics): - print('plot curve of {}, metric is {}'.format( - args.json_logs[i], metric)) - if metric not in log_dict[epochs[0]]: - raise KeyError('{} does not contain metric {}'.format( - args.json_logs[i], metric)) - - if 'mAP' in metric: - xs = np.arange(1, max(epochs) + 1) - ys = [] - for epoch in epochs: - ys += log_dict[epoch][metric] - ax = plt.gca() - ax.set_xticks(xs) - plt.xlabel('epoch') - plt.plot(xs, ys, label=legend[i * num_metrics + j], marker='o') - else: - xs = [] - ys = [] - num_iters_per_epoch = log_dict[epochs[0]]['iter'][-1] - for epoch in epochs: - iters = log_dict[epoch]['iter'] - if log_dict[epoch]['mode'][-1] == 'val': - iters = iters[:-1] - xs.append( - np.array(iters) + (epoch - 1) * num_iters_per_epoch) - ys.append(np.array(log_dict[epoch][metric][:len(iters)])) - xs = np.concatenate(xs) - ys = np.concatenate(ys) - plt.xlabel('iter') - plt.plot( - xs, ys, label=legend[i * num_metrics + j], linewidth=0.5) - plt.legend() - if args.title is not None: - plt.title(args.title) - if args.out is None: - plt.show() - else: - print('save curve to: {}'.format(args.out)) - plt.savefig(args.out) - plt.cla() - - -def add_plot_parser(subparsers): - parser_plt = subparsers.add_parser( - 'plot_curve', help='parser for plotting curves') - parser_plt.add_argument( - 'json_logs', - type=str, - nargs='+', - help='path of train log in json format') - parser_plt.add_argument( - '--keys', - type=str, - nargs='+', - default=['bbox_mAP'], - help='the metric that you want to plot') - parser_plt.add_argument('--title', type=str, help='title of figure') - parser_plt.add_argument( - '--legend', - type=str, - nargs='+', - default=None, - help='legend of each plot') - parser_plt.add_argument( - '--backend', type=str, default=None, help='backend of plt') - parser_plt.add_argument( - '--style', type=str, default='dark', help='style of plt') - parser_plt.add_argument('--out', type=str, default=None) - - -def add_time_parser(subparsers): - parser_time = subparsers.add_parser( - 'cal_train_time', - help='parser for computing the average time per training iteration') - parser_time.add_argument( - 'json_logs', - type=str, - nargs='+', - help='path of train log in json format') - parser_time.add_argument( - '--include-outliers', - action='store_true', - help='include the first value of every epoch when computing ' - 'the average time') - - -def parse_args(): - parser = argparse.ArgumentParser(description='Analyze Json Log') - # currently only support plot curve and calculate average train time - subparsers = parser.add_subparsers(dest='task', help='task parser') - add_plot_parser(subparsers) - add_time_parser(subparsers) - args = parser.parse_args() - return args - - -def load_json_logs(json_logs): - # load and convert json_logs to log_dict, key is epoch, value is a sub dict - # keys of sub dict is different metrics, e.g. memory, bbox_mAP - # value of sub dict is a list of corresponding values of all iterations - log_dicts = [dict() for _ in json_logs] - for json_log, log_dict in zip(json_logs, log_dicts): - with open(json_log, 'r') as log_file: - for l in log_file: - log = json.loads(l.strip()) - epoch = log.pop('epoch') - if epoch not in log_dict: - log_dict[epoch] = defaultdict(list) - for k, v in log.items(): - log_dict[epoch][k].append(v) - return log_dicts - - -def main(): - args = parse_args() - - json_logs = args.json_logs - for json_log in json_logs: - assert json_log.endswith('.json') - - log_dicts = load_json_logs(json_logs) - - eval(args.task)(log_dicts, args) - - -if __name__ == '__main__': - main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/coco_error_analysis.py b/cv/instance_segmentation/SOLO/pytorch/tools/coco_error_analysis.py deleted file mode 100644 index 6aeadadb9..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tools/coco_error_analysis.py +++ /dev/null @@ -1,174 +0,0 @@ -import copy -import os -from argparse import ArgumentParser -from multiprocessing import Pool - -import matplotlib.pyplot as plt -import numpy as np -from pycocotools.coco import COCO -from pycocotools.cocoeval import COCOeval - - -def makeplot(rs, ps, outDir, class_name, iou_type): - cs = np.vstack([ - np.ones((2, 3)), - np.array([.31, .51, .74]), - np.array([.75, .31, .30]), - np.array([.36, .90, .38]), - np.array([.50, .39, .64]), - np.array([1, .6, 0]) - ]) - areaNames = ['allarea', 'small', 'medium', 'large'] - types = ['C75', 'C50', 'Loc', 'Sim', 'Oth', 'BG', 'FN'] - for i in range(len(areaNames)): - area_ps = ps[..., i, 0] - figure_tile = iou_type + '-' + class_name + '-' + areaNames[i] - aps = [ps_.mean() for ps_ in area_ps] - ps_curve = [ - ps_.mean(axis=1) if ps_.ndim > 1 else ps_ for ps_ in area_ps - ] - ps_curve.insert(0, np.zeros(ps_curve[0].shape)) - fig = plt.figure() - ax = plt.subplot(111) - for k in range(len(types)): - ax.plot(rs, ps_curve[k + 1], color=[0, 0, 0], linewidth=0.5) - ax.fill_between( - rs, - ps_curve[k], - ps_curve[k + 1], - color=cs[k], - label=str('[{:.3f}'.format(aps[k]) + ']' + types[k])) - plt.xlabel('recall') - plt.ylabel('precision') - plt.xlim(0, 1.) - plt.ylim(0, 1.) - plt.title(figure_tile) - plt.legend() - # plt.show() - fig.savefig(outDir + '/{}.png'.format(figure_tile)) - plt.close(fig) - - -def analyze_individual_category(k, cocoDt, cocoGt, catId, iou_type): - nm = cocoGt.loadCats(catId)[0] - print('--------------analyzing {}-{}---------------'.format( - k + 1, nm['name'])) - ps_ = {} - dt = copy.deepcopy(cocoDt) - nm = cocoGt.loadCats(catId)[0] - imgIds = cocoGt.getImgIds() - dt_anns = dt.dataset['annotations'] - select_dt_anns = [] - for ann in dt_anns: - if ann['category_id'] == catId: - select_dt_anns.append(ann) - dt.dataset['annotations'] = select_dt_anns - dt.createIndex() - # compute precision but ignore superclass confusion - gt = copy.deepcopy(cocoGt) - child_catIds = gt.getCatIds(supNms=[nm['supercategory']]) - for idx, ann in enumerate(gt.dataset['annotations']): - if (ann['category_id'] in child_catIds - and ann['category_id'] != catId): - gt.dataset['annotations'][idx]['ignore'] = 1 - gt.dataset['annotations'][idx]['iscrowd'] = 1 - gt.dataset['annotations'][idx]['category_id'] = catId - cocoEval = COCOeval(gt, copy.deepcopy(dt), iou_type) - cocoEval.params.imgIds = imgIds - cocoEval.params.maxDets = [100] - cocoEval.params.iouThrs = [.1] - cocoEval.params.useCats = 1 - cocoEval.evaluate() - cocoEval.accumulate() - ps_supercategory = cocoEval.eval['precision'][0, :, k, :, :] - ps_['ps_supercategory'] = ps_supercategory - # compute precision but ignore any class confusion - gt = copy.deepcopy(cocoGt) - for idx, ann in enumerate(gt.dataset['annotations']): - if ann['category_id'] != catId: - gt.dataset['annotations'][idx]['ignore'] = 1 - gt.dataset['annotations'][idx]['iscrowd'] = 1 - gt.dataset['annotations'][idx]['category_id'] = catId - cocoEval = COCOeval(gt, copy.deepcopy(dt), iou_type) - cocoEval.params.imgIds = imgIds - cocoEval.params.maxDets = [100] - cocoEval.params.iouThrs = [.1] - cocoEval.params.useCats = 1 - cocoEval.evaluate() - cocoEval.accumulate() - ps_allcategory = cocoEval.eval['precision'][0, :, k, :, :] - ps_['ps_allcategory'] = ps_allcategory - return k, ps_ - - -def analyze_results(res_file, ann_file, res_types, out_dir): - for res_type in res_types: - assert res_type in ['bbox', 'segm'] - - directory = os.path.dirname(out_dir + '/') - if not os.path.exists(directory): - print('-------------create {}-----------------'.format(out_dir)) - os.makedirs(directory) - - cocoGt = COCO(ann_file) - cocoDt = cocoGt.loadRes(res_file) - imgIds = cocoGt.getImgIds() - for res_type in res_types: - res_out_dir = out_dir + '/' + res_type + '/' - res_directory = os.path.dirname(res_out_dir) - if not os.path.exists(res_directory): - print( - '-------------create {}-----------------'.format(res_out_dir)) - os.makedirs(res_directory) - iou_type = res_type - cocoEval = COCOeval( - copy.deepcopy(cocoGt), copy.deepcopy(cocoDt), iou_type) - cocoEval.params.imgIds = imgIds - cocoEval.params.iouThrs = [.75, .5, .1] - cocoEval.params.maxDets = [100] - cocoEval.evaluate() - cocoEval.accumulate() - ps = cocoEval.eval['precision'] - ps = np.vstack([ps, np.zeros((4, *ps.shape[1:]))]) - catIds = cocoGt.getCatIds() - recThrs = cocoEval.params.recThrs - with Pool(processes=48) as pool: - args = [(k, cocoDt, cocoGt, catId, iou_type) - for k, catId in enumerate(catIds)] - analyze_results = pool.starmap(analyze_individual_category, args) - for k, catId in enumerate(catIds): - nm = cocoGt.loadCats(catId)[0] - print('--------------saving {}-{}---------------'.format( - k + 1, nm['name'])) - analyze_result = analyze_results[k] - assert k == analyze_result[0] - ps_supercategory = analyze_result[1]['ps_supercategory'] - ps_allcategory = analyze_result[1]['ps_allcategory'] - # compute precision but ignore superclass confusion - ps[3, :, k, :, :] = ps_supercategory - # compute precision but ignore any class confusion - ps[4, :, k, :, :] = ps_allcategory - # fill in background and false negative errors and plot - ps[ps == -1] = 0 - ps[5, :, k, :, :] = (ps[4, :, k, :, :] > 0) - ps[6, :, k, :, :] = 1.0 - makeplot(recThrs, ps[:, :, k], res_out_dir, nm['name'], iou_type) - makeplot(recThrs, ps, res_out_dir, 'allclass', iou_type) - - -def main(): - parser = ArgumentParser(description='COCO Error Analysis Tool') - parser.add_argument('result', help='result file (json format) path') - parser.add_argument('out_dir', help='dir to save analyze result images') - parser.add_argument( - '--ann', - default='data/coco/annotations/instances_val2017.json', - help='annotation file path') - parser.add_argument( - '--types', type=str, nargs='+', default=['bbox'], help='result types') - args = parser.parse_args() - analyze_results(args.result, args.ann, args.types, out_dir=args.out_dir) - - -if __name__ == '__main__': - main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/coco_eval.py b/cv/instance_segmentation/SOLO/pytorch/tools/coco_eval.py deleted file mode 100644 index bc3c96b3c..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tools/coco_eval.py +++ /dev/null @@ -1,30 +0,0 @@ -from argparse import ArgumentParser - -from mmdet.core import coco_eval - - -def main(): - parser = ArgumentParser(description='COCO Evaluation') - parser.add_argument('result', help='result file path') - parser.add_argument('--ann', help='annotation file path') - parser.add_argument( - '--types', - type=str, - nargs='+', - choices=['proposal_fast', 'proposal', 'bbox', 'segm', 'keypoint'], - default=['bbox'], - help='result types') - parser.add_argument( - '--max-dets', - type=int, - nargs='+', - default=[100, 300, 1000], - help='proposal numbers, only used for recall evaluation') - parser.add_argument( - '--classwise', action='store_true', help='whether eval class wise ap') - args = parser.parse_args() - coco_eval(args.result, args.types, args.ann, args.max_dets, args.classwise) - - -if __name__ == '__main__': - main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/convert_datasets/pascal_voc.py b/cv/instance_segmentation/SOLO/pytorch/tools/convert_datasets/pascal_voc.py deleted file mode 100644 index 029eeb0a9..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tools/convert_datasets/pascal_voc.py +++ /dev/null @@ -1,141 +0,0 @@ -import argparse -import os.path as osp -import xml.etree.ElementTree as ET - -import mmcv -import numpy as np - -from mmdet.core import voc_classes - -label_ids = {name: i + 1 for i, name in enumerate(voc_classes())} - - -def parse_xml(args): - xml_path, img_path = args - tree = ET.parse(xml_path) - root = tree.getroot() - size = root.find('size') - w = int(size.find('width').text) - h = int(size.find('height').text) - bboxes = [] - labels = [] - bboxes_ignore = [] - labels_ignore = [] - for obj in root.findall('object'): - name = obj.find('name').text - label = label_ids[name] - difficult = int(obj.find('difficult').text) - bnd_box = obj.find('bndbox') - bbox = [ - int(bnd_box.find('xmin').text), - int(bnd_box.find('ymin').text), - int(bnd_box.find('xmax').text), - int(bnd_box.find('ymax').text) - ] - if difficult: - bboxes_ignore.append(bbox) - labels_ignore.append(label) - else: - bboxes.append(bbox) - labels.append(label) - if not bboxes: - bboxes = np.zeros((0, 4)) - labels = np.zeros((0, )) - else: - bboxes = np.array(bboxes, ndmin=2) - 1 - labels = np.array(labels) - if not bboxes_ignore: - bboxes_ignore = np.zeros((0, 4)) - labels_ignore = np.zeros((0, )) - else: - bboxes_ignore = np.array(bboxes_ignore, ndmin=2) - 1 - labels_ignore = np.array(labels_ignore) - annotation = { - 'filename': img_path, - 'width': w, - 'height': h, - 'ann': { - 'bboxes': bboxes.astype(np.float32), - 'labels': labels.astype(np.int64), - 'bboxes_ignore': bboxes_ignore.astype(np.float32), - 'labels_ignore': labels_ignore.astype(np.int64) - } - } - return annotation - - -def cvt_annotations(devkit_path, years, split, out_file): - if not isinstance(years, list): - years = [years] - annotations = [] - for year in years: - filelist = osp.join(devkit_path, - 'VOC{}/ImageSets/Main/{}.txt'.format(year, split)) - if not osp.isfile(filelist): - print('filelist does not exist: {}, skip voc{} {}'.format( - filelist, year, split)) - return - img_names = mmcv.list_from_file(filelist) - xml_paths = [ - osp.join(devkit_path, - 'VOC{}/Annotations/{}.xml'.format(year, img_name)) - for img_name in img_names - ] - img_paths = [ - 'VOC{}/JPEGImages/{}.jpg'.format(year, img_name) - for img_name in img_names - ] - part_annotations = mmcv.track_progress(parse_xml, - list(zip(xml_paths, img_paths))) - annotations.extend(part_annotations) - mmcv.dump(annotations, out_file) - return annotations - - -def parse_args(): - parser = argparse.ArgumentParser( - description='Convert PASCAL VOC annotations to mmdetection format') - parser.add_argument('devkit_path', help='pascal voc devkit path') - parser.add_argument('-o', '--out-dir', help='output path') - args = parser.parse_args() - return args - - -def main(): - args = parse_args() - devkit_path = args.devkit_path - out_dir = args.out_dir if args.out_dir else devkit_path - mmcv.mkdir_or_exist(out_dir) - - years = [] - if osp.isdir(osp.join(devkit_path, 'VOC2007')): - years.append('2007') - if osp.isdir(osp.join(devkit_path, 'VOC2012')): - years.append('2012') - if '2007' in years and '2012' in years: - years.append(['2007', '2012']) - if not years: - raise IOError('The devkit path {} contains neither "VOC2007" nor ' - '"VOC2012" subfolder'.format(devkit_path)) - for year in years: - if year == '2007': - prefix = 'voc07' - elif year == '2012': - prefix = 'voc12' - elif year == ['2007', '2012']: - prefix = 'voc0712' - for split in ['train', 'val', 'trainval']: - dataset_name = prefix + '_' + split - print('processing {} ...'.format(dataset_name)) - cvt_annotations(devkit_path, year, split, - osp.join(out_dir, dataset_name + '.pkl')) - if not isinstance(year, list): - dataset_name = prefix + '_test' - print('processing {} ...'.format(dataset_name)) - cvt_annotations(devkit_path, year, 'test', - osp.join(out_dir, dataset_name + '.pkl')) - print('Done!') - - -if __name__ == '__main__': - main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/detectron2pytorch.py b/cv/instance_segmentation/SOLO/pytorch/tools/detectron2pytorch.py deleted file mode 100644 index 0a90ad172..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tools/detectron2pytorch.py +++ /dev/null @@ -1,88 +0,0 @@ -import argparse -from collections import OrderedDict - -import mmcv -import torch - -arch_settings = {50: (3, 4, 6, 3), 101: (3, 4, 23, 3)} - - -def convert_bn(blobs, state_dict, caffe_name, torch_name, converted_names): - # detectron replace bn with affine channel layer - state_dict[torch_name + '.bias'] = torch.from_numpy(blobs[caffe_name + - '_b']) - state_dict[torch_name + '.weight'] = torch.from_numpy(blobs[caffe_name + - '_s']) - bn_size = state_dict[torch_name + '.weight'].size() - state_dict[torch_name + '.running_mean'] = torch.zeros(bn_size) - state_dict[torch_name + '.running_var'] = torch.ones(bn_size) - converted_names.add(caffe_name + '_b') - converted_names.add(caffe_name + '_s') - - -def convert_conv_fc(blobs, state_dict, caffe_name, torch_name, - converted_names): - state_dict[torch_name + '.weight'] = torch.from_numpy(blobs[caffe_name + - '_w']) - converted_names.add(caffe_name + '_w') - if caffe_name + '_b' in blobs: - state_dict[torch_name + '.bias'] = torch.from_numpy(blobs[caffe_name + - '_b']) - converted_names.add(caffe_name + '_b') - - -def convert(src, dst, depth): - """Convert keys in detectron pretrained ResNet models to pytorch style.""" - # load arch_settings - if depth not in arch_settings: - raise ValueError('Only support ResNet-50 and ResNet-101 currently') - block_nums = arch_settings[depth] - # load caffe model - caffe_model = mmcv.load(src, encoding='latin1') - blobs = caffe_model['blobs'] if 'blobs' in caffe_model else caffe_model - # convert to pytorch style - state_dict = OrderedDict() - converted_names = set() - convert_conv_fc(blobs, state_dict, 'conv1', 'conv1', converted_names) - convert_bn(blobs, state_dict, 'res_conv1_bn', 'bn1', converted_names) - for i in range(1, len(block_nums) + 1): - for j in range(block_nums[i - 1]): - if j == 0: - convert_conv_fc(blobs, state_dict, - 'res{}_{}_branch1'.format(i + 1, j), - 'layer{}.{}.downsample.0'.format(i, j), - converted_names) - convert_bn(blobs, state_dict, - 'res{}_{}_branch1_bn'.format(i + 1, j), - 'layer{}.{}.downsample.1'.format(i, j), - converted_names) - for k, letter in enumerate(['a', 'b', 'c']): - convert_conv_fc(blobs, state_dict, - 'res{}_{}_branch2{}'.format(i + 1, j, letter), - 'layer{}.{}.conv{}'.format(i, j, k + 1), - converted_names) - convert_bn(blobs, state_dict, - 'res{}_{}_branch2{}_bn'.format(i + 1, j, letter), - 'layer{}.{}.bn{}'.format(i, j, - k + 1), converted_names) - # check if all layers are converted - for key in blobs: - if key not in converted_names: - print('Not Convert: {}'.format(key)) - # save checkpoint - checkpoint = dict() - checkpoint['state_dict'] = state_dict - torch.save(checkpoint, dst) - - -def main(): - parser = argparse.ArgumentParser(description='Convert model keys') - parser.add_argument('src', help='src detectron model path') - parser.add_argument('dst', help='save path') - parser.add_argument('depth', type=int, help='ResNet model depth') - args = parser.parse_args() - convert(args.src, args.dst, args.depth) - - -if __name__ == '__main__': - main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/dist_test.sh b/cv/instance_segmentation/SOLO/pytorch/tools/dist_test.sh deleted file mode 100644 index efab6ea27..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tools/dist_test.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -PYTHON=${PYTHON:-"python"} - -CONFIG=$1 -CHECKPOINT=$2 -GPUS=$3 -PORT=${PORT:-29500} - -$PYTHON -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \ - $(dirname "$0")/test_ins.py $CONFIG $CHECKPOINT --launcher pytorch ${@:4} diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/dist_train.sh b/cv/instance_segmentation/SOLO/pytorch/tools/dist_train.sh deleted file mode 100644 index 0b8adf711..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tools/dist_train.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -CONFIG=$1 -GPUS=$2 -PORT=${PORT:-29500} - -python3 -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \ - $(dirname "$0")/train.py $CONFIG --launcher pytorch ${@:3} diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/get_flops.py b/cv/instance_segmentation/SOLO/pytorch/tools/get_flops.py deleted file mode 100644 index 6c9cb2340..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tools/get_flops.py +++ /dev/null @@ -1,55 +0,0 @@ -import argparse - -from mmcv import Config - -from mmdet.models import build_detector -from mmdet.utils import get_model_complexity_info - - -def parse_args(): - parser = argparse.ArgumentParser(description='Train a detector') - parser.add_argument('config', help='train config file path') - parser.add_argument( - '--shape', - type=int, - nargs='+', - default=[1280, 800], - help='input image size') - args = parser.parse_args() - return args - - -def main(): - - args = parse_args() - - if len(args.shape) == 1: - input_shape = (3, args.shape[0], args.shape[0]) - elif len(args.shape) == 2: - input_shape = (3, ) + tuple(args.shape) - else: - raise ValueError('invalid input shape') - - cfg = Config.fromfile(args.config) - model = build_detector( - cfg.model, train_cfg=cfg.train_cfg, test_cfg=cfg.test_cfg).cuda() - model.eval() - - if hasattr(model, 'forward_dummy'): - model.forward = model.forward_dummy - else: - raise NotImplementedError( - 'FLOPs counter is currently not currently supported with {}'. - format(model.__class__.__name__)) - - flops, params = get_model_complexity_info(model, input_shape) - split_line = '=' * 30 - print('{0}\nInput shape: {1}\nFlops: {2}\nParams: {3}\n{0}'.format( - split_line, input_shape, flops, params)) - print('!!!Please be cautious if you use the results in papers. ' - 'You may need to check if all ops are supported and verify that the ' - 'flops computation is correct.') - - -if __name__ == '__main__': - main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/publish_model.py b/cv/instance_segmentation/SOLO/pytorch/tools/publish_model.py deleted file mode 100644 index a049f1767..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tools/publish_model.py +++ /dev/null @@ -1,35 +0,0 @@ -import argparse -import subprocess - -import torch - - -def parse_args(): - parser = argparse.ArgumentParser( - description='Process a checkpoint to be published') - parser.add_argument('in_file', help='input checkpoint filename') - parser.add_argument('out_file', help='output checkpoint filename') - args = parser.parse_args() - return args - - -def process_checkpoint(in_file, out_file): - checkpoint = torch.load(in_file, map_location='cpu') - # remove optimizer for smaller file size - if 'optimizer' in checkpoint: - del checkpoint['optimizer'] - # if it is necessary to remove some sensitive data in checkpoint['meta'], - # add the code here. - torch.save(checkpoint, out_file) - sha = subprocess.check_output(['sha256sum', out_file]).decode() - final_file = out_file.rstrip('.pth') + '-{}.pth'.format(sha[:8]) - subprocess.Popen(['mv', out_file, final_file]) - - -def main(): - args = parse_args() - process_checkpoint(args.in_file, args.out_file) - - -if __name__ == '__main__': - main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/robustness_eval.py b/cv/instance_segmentation/SOLO/pytorch/tools/robustness_eval.py deleted file mode 100644 index a07aa0159..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tools/robustness_eval.py +++ /dev/null @@ -1,256 +0,0 @@ -import os.path as osp -from argparse import ArgumentParser - -import mmcv -import numpy as np - - -def print_coco_results(results): - - def _print(result, ap=1, iouThr=None, areaRng='all', maxDets=100): - iStr = ' {:<18} {} @[ IoU={:<9} | \ - area={:>6s} | maxDets={:>3d} ] = {:0.3f}' - - titleStr = 'Average Precision' if ap == 1 else 'Average Recall' - typeStr = '(AP)' if ap == 1 else '(AR)' - iouStr = '{:0.2f}:{:0.2f}'.format(.5, .95) \ - if iouThr is None else '{:0.2f}'.format(iouThr) - print(iStr.format(titleStr, typeStr, iouStr, areaRng, maxDets, result)) - - stats = np.zeros((12, )) - stats[0] = _print(results[0], 1) - stats[1] = _print(results[1], 1, iouThr=.5) - stats[2] = _print(results[2], 1, iouThr=.75) - stats[3] = _print(results[3], 1, areaRng='small') - stats[4] = _print(results[4], 1, areaRng='medium') - stats[5] = _print(results[5], 1, areaRng='large') - stats[6] = _print(results[6], 0, maxDets=1) - stats[7] = _print(results[7], 0, maxDets=10) - stats[8] = _print(results[8], 0) - stats[9] = _print(results[9], 0, areaRng='small') - stats[10] = _print(results[10], 0, areaRng='medium') - stats[11] = _print(results[11], 0, areaRng='large') - - -def get_coco_style_results(filename, - task='bbox', - metric=None, - prints='mPC', - aggregate='benchmark'): - - assert aggregate in ['benchmark', 'all'] - - if prints == 'all': - prints = ['P', 'mPC', 'rPC'] - elif isinstance(prints, str): - prints = [prints] - for p in prints: - assert p in ['P', 'mPC', 'rPC'] - - if metric is None: - metrics = [ - 'AP', 'AP50', 'AP75', 'APs', 'APm', 'APl', 'AR1', 'AR10', 'AR100', - 'ARs', 'ARm', 'ARl' - ] - elif isinstance(metric, list): - metrics = metric - else: - metrics = [metric] - - for metric_name in metrics: - assert metric_name in [ - 'AP', 'AP50', 'AP75', 'APs', 'APm', 'APl', 'AR1', 'AR10', 'AR100', - 'ARs', 'ARm', 'ARl' - ] - - eval_output = mmcv.load(filename) - - num_distortions = len(list(eval_output.keys())) - results = np.zeros((num_distortions, 6, len(metrics)), dtype='float32') - - for corr_i, distortion in enumerate(eval_output): - for severity in eval_output[distortion]: - for metric_j, metric_name in enumerate(metrics): - mAP = eval_output[distortion][severity][task][metric_name] - results[corr_i, severity, metric_j] = mAP - - P = results[0, 0, :] - if aggregate == 'benchmark': - mPC = np.mean(results[:15, 1:, :], axis=(0, 1)) - else: - mPC = np.mean(results[:, 1:, :], axis=(0, 1)) - rPC = mPC / P - - print('\nmodel: {}'.format(osp.basename(filename))) - if metric is None: - if 'P' in prints: - print('Performance on Clean Data [P] ({})'.format(task)) - print_coco_results(P) - if 'mPC' in prints: - print('Mean Performance under Corruption [mPC] ({})'.format(task)) - print_coco_results(mPC) - if 'rPC' in prints: - print('Realtive Performance under Corruption [rPC] ({})'.format( - task)) - print_coco_results(rPC) - else: - if 'P' in prints: - print('Performance on Clean Data [P] ({})'.format(task)) - for metric_i, metric_name in enumerate(metrics): - print('{:5} = {:0.3f}'.format(metric_name, P[metric_i])) - if 'mPC' in prints: - print('Mean Performance under Corruption [mPC] ({})'.format(task)) - for metric_i, metric_name in enumerate(metrics): - print('{:5} = {:0.3f}'.format(metric_name, mPC[metric_i])) - if 'rPC' in prints: - print('Relative Performance under Corruption [rPC] ({})'.format( - task)) - for metric_i, metric_name in enumerate(metrics): - print('{:5} => {:0.1f} %'.format(metric_name, - rPC[metric_i] * 100)) - - return results - - -def get_voc_style_results(filename, prints='mPC', aggregate='benchmark'): - - assert aggregate in ['benchmark', 'all'] - - if prints == 'all': - prints = ['P', 'mPC', 'rPC'] - elif isinstance(prints, str): - prints = [prints] - for p in prints: - assert p in ['P', 'mPC', 'rPC'] - - eval_output = mmcv.load(filename) - - num_distortions = len(list(eval_output.keys())) - results = np.zeros((num_distortions, 6, 20), dtype='float32') - - for i, distortion in enumerate(eval_output): - for severity in eval_output[distortion]: - mAP = [ - eval_output[distortion][severity][j]['ap'] - for j in range(len(eval_output[distortion][severity])) - ] - results[i, severity, :] = mAP - - P = results[0, 0, :] - if aggregate == 'benchmark': - mPC = np.mean(results[:15, 1:, :], axis=(0, 1)) - else: - mPC = np.mean(results[:, 1:, :], axis=(0, 1)) - rPC = mPC / P - - print('\nmodel: {}'.format(osp.basename(filename))) - if 'P' in prints: - print('{:48} = {:0.3f}'.format('Performance on Clean Data [P] in AP50', - np.mean(P))) - if 'mPC' in prints: - print('{:48} = {:0.3f}'.format( - 'Mean Performance under Corruption [mPC] in AP50', np.mean(mPC))) - if 'rPC' in prints: - print('{:48} = {:0.1f}'.format( - 'Realtive Performance under Corruption [rPC] in %', - np.mean(rPC) * 100)) - - return np.mean(results, axis=2, keepdims=True) - - -def get_results(filename, - dataset='coco', - task='bbox', - metric=None, - prints='mPC', - aggregate='benchmark'): - assert dataset in ['coco', 'voc', 'cityscapes'] - - if dataset in ['coco', 'cityscapes']: - results = get_coco_style_results( - filename, - task=task, - metric=metric, - prints=prints, - aggregate=aggregate) - elif dataset == 'voc': - if task != 'bbox': - print('Only bbox analysis is supported for Pascal VOC') - print('Will report bbox results\n') - if metric not in [None, ['AP'], ['AP50']]: - print('Only the AP50 metric is supported for Pascal VOC') - print('Will report AP50 metric\n') - results = get_voc_style_results( - filename, prints=prints, aggregate=aggregate) - - return results - - -def get_distortions_from_file(filename): - - eval_output = mmcv.load(filename) - - return get_distortions_from_results(eval_output) - - -def get_distortions_from_results(eval_output): - distortions = [] - for i, distortion in enumerate(eval_output): - distortions.append(distortion.replace("_", " ")) - return distortions - - -def main(): - parser = ArgumentParser(description='Corruption Result Analysis') - parser.add_argument('filename', help='result file path') - parser.add_argument( - '--dataset', - type=str, - choices=['coco', 'voc', 'cityscapes'], - default='coco', - help='dataset type') - parser.add_argument( - '--task', - type=str, - nargs='+', - choices=['bbox', 'segm'], - default=['bbox'], - help='task to report') - parser.add_argument( - '--metric', - nargs='+', - choices=[ - None, 'AP', 'AP50', 'AP75', 'APs', 'APm', 'APl', 'AR1', 'AR10', - 'AR100', 'ARs', 'ARm', 'ARl' - ], - default=None, - help='metric to report') - parser.add_argument( - '--prints', - type=str, - nargs='+', - choices=['P', 'mPC', 'rPC'], - default='mPC', - help='corruption benchmark metric to print') - parser.add_argument( - '--aggregate', - type=str, - choices=['all', 'benchmark'], - default='benchmark', - help='aggregate all results or only those \ - for benchmark corruptions') - - args = parser.parse_args() - - for task in args.task: - get_results( - args.filename, - dataset=args.dataset, - task=task, - metric=args.metric, - prints=args.prints, - aggregate=args.aggregate) - - -if __name__ == '__main__': - main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/slurm_test.sh b/cv/instance_segmentation/SOLO/pytorch/tools/slurm_test.sh deleted file mode 100644 index 8950bc816..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tools/slurm_test.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -set -x - -PARTITION=$1 -JOB_NAME=$2 -CONFIG=$3 -CHECKPOINT=$4 -GPUS=${GPUS:-8} -GPUS_PER_NODE=${GPUS_PER_NODE:-8} -CPUS_PER_TASK=${CPUS_PER_TASK:-5} -PY_ARGS=${@:5} -SRUN_ARGS=${SRUN_ARGS:-""} - -srun -p ${PARTITION} \ - --job-name=${JOB_NAME} \ - --gres=gpu:${GPUS_PER_NODE} \ - --ntasks=${GPUS} \ - --ntasks-per-node=${GPUS_PER_NODE} \ - --cpus-per-task=${CPUS_PER_TASK} \ - --kill-on-bad-exit=1 \ - ${SRUN_ARGS} \ - python -u tools/test.py ${CONFIG} ${CHECKPOINT} --launcher="slurm" ${PY_ARGS} diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/slurm_train.sh b/cv/instance_segmentation/SOLO/pytorch/tools/slurm_train.sh deleted file mode 100644 index 45474c46a..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tools/slurm_train.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -set -x - -PARTITION=$1 -JOB_NAME=$2 -CONFIG=$3 -WORK_DIR=$4 -GPUS=${5:-8} -GPUS_PER_NODE=${GPUS_PER_NODE:-8} -CPUS_PER_TASK=${CPUS_PER_TASK:-5} -SRUN_ARGS=${SRUN_ARGS:-""} -PY_ARGS=${PY_ARGS:-"--validate"} - -srun -p ${PARTITION} \ - --job-name=${JOB_NAME} \ - --gres=gpu:${GPUS_PER_NODE} \ - --ntasks=${GPUS} \ - --ntasks-per-node=${GPUS_PER_NODE} \ - --cpus-per-task=${CPUS_PER_TASK} \ - --kill-on-bad-exit=1 \ - ${SRUN_ARGS} \ - python -u tools/train.py ${CONFIG} --work_dir=${WORK_DIR} --launcher="slurm" ${PY_ARGS} diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/test_ins.py b/cv/instance_segmentation/SOLO/pytorch/tools/test_ins.py deleted file mode 100644 index 66843fb1d..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tools/test_ins.py +++ /dev/null @@ -1,257 +0,0 @@ -import argparse -import os -import os.path as osp -import shutil -import tempfile - -import mmcv -import torch -import torch.nn.functional as F -import torch.distributed as dist -from mmcv.parallel import MMDataParallel, MMDistributedDataParallel -from mmcv.runner import init_dist, get_dist_info, load_checkpoint - -from mmdet.core import coco_eval, results2json, results2json_segm, wrap_fp16_model, tensor2imgs, get_classes -from mmdet.datasets import build_dataloader, build_dataset -from mmdet.models import build_detector -import time -import numpy as np -import pycocotools.mask as mask_util - - -def get_masks(result, num_classes=80): - for cur_result in result: - masks = [[] for _ in range(num_classes)] - if cur_result is None: - return masks - seg_pred = cur_result[0].cpu().numpy().astype(np.uint8) - cate_label = cur_result[1].cpu().numpy().astype(np.int) - cate_score = cur_result[2].cpu().numpy().astype(np.float) - num_ins = seg_pred.shape[0] - for idx in range(num_ins): - cur_mask = seg_pred[idx, ...] - rle = mask_util.encode( - np.array(cur_mask[:, :, np.newaxis], order='F'))[0] - rst = (rle, cate_score[idx]) - masks[cate_label[idx]].append(rst) - - return masks - - -def single_gpu_test(model, data_loader, show=False, verbose=True): - model.eval() - results = [] - dataset = data_loader.dataset - - num_classes = len(dataset.CLASSES) - - prog_bar = mmcv.ProgressBar(len(dataset)) - for i, data in enumerate(data_loader): - with torch.no_grad(): - seg_result = model(return_loss=False, rescale=not show, **data) - - result = get_masks(seg_result, num_classes=num_classes) - results.append(result) - - batch_size = data['img'][0].size(0) - for _ in range(batch_size): - prog_bar.update() - return results - - -def multi_gpu_test(model, data_loader, tmpdir=None): - model.eval() - results = [] - dataset = data_loader.dataset - num_classes = len(dataset.CLASSES) - - rank, world_size = get_dist_info() - if rank == 0: - prog_bar = mmcv.ProgressBar(len(dataset)) - for i, data in enumerate(data_loader): - with torch.no_grad(): - seg_result = model(return_loss=False, rescale=True, **data) - - result = get_masks(seg_result, num_classes=num_classes) - results.append(result) - - if rank == 0: - batch_size = data['img'][0].size(0) - for _ in range(batch_size * world_size): - prog_bar.update() - - # collect results from all ranks - results = collect_results(results, len(dataset), tmpdir) - - return results - - -def collect_results(result_part, size, tmpdir=None): - rank, world_size = get_dist_info() - # create a tmp dir if it is not specified - if tmpdir is None: - MAX_LEN = 512 - # 32 is whitespace - dir_tensor = torch.full((MAX_LEN, ), - 32, - dtype=torch.uint8, - device='cuda') - if rank == 0: - tmpdir = tempfile.mkdtemp() - tmpdir = torch.tensor( - bytearray(tmpdir.encode()), dtype=torch.uint8, device='cuda') - dir_tensor[:len(tmpdir)] = tmpdir - dist.broadcast(dir_tensor, 0) - tmpdir = dir_tensor.cpu().numpy().tobytes().decode().rstrip() - else: - mmcv.mkdir_or_exist(tmpdir) - # dump the part result to the dir - mmcv.dump(result_part, osp.join(tmpdir, 'part_{}.pkl'.format(rank))) - dist.barrier() - # collect all parts - if rank != 0: - return None - else: - # load results of all parts from tmp dir - part_list = [] - for i in range(world_size): - part_file = osp.join(tmpdir, 'part_{}.pkl'.format(i)) - part_list.append(mmcv.load(part_file)) - # sort the results - ordered_results = [] - for res in zip(*part_list): - ordered_results.extend(list(res)) - # the dataloader may pad some samples - ordered_results = ordered_results[:size] - # remove tmp dir - shutil.rmtree(tmpdir) - return ordered_results - - -def parse_args(): - parser = argparse.ArgumentParser(description='MMDet test detector') - parser.add_argument('config', help='test config file path') - parser.add_argument('checkpoint', help='checkpoint file') - parser.add_argument('--out', help='output result file') - parser.add_argument( - '--json_out', - help='output result file name without extension', - type=str) - parser.add_argument( - '--eval', - type=str, - nargs='+', - choices=['proposal', 'proposal_fast', 'bbox', 'segm', 'keypoints'], - help='eval types') - parser.add_argument('--show', action='store_true', help='show results') - parser.add_argument('--tmpdir', help='tmp dir for writing some results') - parser.add_argument( - '--launcher', - choices=['none', 'pytorch', 'slurm', 'mpi'], - default='none', - help='job launcher') - parser.add_argument('--local_rank', type=int, default=0) - args = parser.parse_args() - if 'LOCAL_RANK' not in os.environ: - os.environ['LOCAL_RANK'] = str(args.local_rank) - return args - - -def main(): - args = parse_args() - - assert args.out or args.show or args.json_out, \ - ('Please specify at least one operation (save or show the results) ' - 'with the argument "--out" or "--show" or "--json_out"') - - if args.out is not None and not args.out.endswith(('.pkl', '.pickle')): - raise ValueError('The output file must be a pkl file.') - - if args.json_out is not None and args.json_out.endswith('.json'): - args.json_out = args.json_out[:-5] - - cfg = mmcv.Config.fromfile(args.config) - # set cudnn_benchmark - if cfg.get('cudnn_benchmark', False): - torch.backends.cudnn.benchmark = True - cfg.model.pretrained = None - cfg.data.test.test_mode = True - - # init distributed env first, since logger depends on the dist info. - if args.launcher == 'none': - distributed = False - else: - distributed = True - init_dist(args.launcher, **cfg.dist_params) - - # build the dataloader - # TODO: support multiple images per gpu (only minor changes are needed) - dataset = build_dataset(cfg.data.test) - data_loader = build_dataloader( - dataset, - imgs_per_gpu=1, - workers_per_gpu=cfg.data.workers_per_gpu, - dist=distributed, - shuffle=False) - - # build the model and load checkpoint - model = build_detector(cfg.model, train_cfg=None, test_cfg=cfg.test_cfg) - fp16_cfg = cfg.get('fp16', None) - if fp16_cfg is not None: - wrap_fp16_model(model) - - while not osp.isfile(args.checkpoint): - print('Waiting for {} to exist...'.format(args.checkpoint)) - time.sleep(60) - - checkpoint = load_checkpoint(model, args.checkpoint, map_location='cpu') - # old versions did not save class info in checkpoints, this walkaround is - # for backward compatibility - if 'CLASSES' in checkpoint['meta']: - model.CLASSES = checkpoint['meta']['CLASSES'] - else: - model.CLASSES = dataset.CLASSES - - if not distributed: - model = MMDataParallel(model, device_ids=[0]) - outputs = single_gpu_test(model, data_loader) - else: - model = MMDistributedDataParallel(model.cuda()) - outputs = multi_gpu_test(model, data_loader, args.tmpdir) - - rank, _ = get_dist_info() - if args.out and rank == 0: - print('\nwriting results to {}'.format(args.out)) - mmcv.dump(outputs, args.out) - eval_types = args.eval - if eval_types: - print('Starting evaluate {}'.format(' and '.join(eval_types))) - if eval_types == ['proposal_fast']: - result_file = args.out - coco_eval(result_file, eval_types, dataset.coco) - else: - if not isinstance(outputs[0], dict): - result_files = results2json_segm(dataset, outputs, args.out) - coco_eval(result_files, eval_types, dataset.coco) - else: - for name in outputs[0]: - print('\nEvaluating {}'.format(name)) - outputs_ = [out[name] for out in outputs] - result_file = args.out + '.{}'.format(name) - result_files = results2json(dataset, outputs_, - result_file) - coco_eval(result_files, eval_types, dataset.coco) - - # Save predictions in the COCO json format - if args.json_out and rank == 0: - if not isinstance(outputs[0], dict): - results2json(dataset, outputs, args.json_out) - else: - for name in outputs[0]: - outputs_ = [out[name] for out in outputs] - result_file = args.json_out + '.{}'.format(name) - results2json(dataset, outputs_, result_file) - - -if __name__ == '__main__': - main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/test_ins_vis.py b/cv/instance_segmentation/SOLO/pytorch/tools/test_ins_vis.py deleted file mode 100644 index e4490d25e..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tools/test_ins_vis.py +++ /dev/null @@ -1,296 +0,0 @@ -import argparse -import os -import os.path as osp -import shutil -import tempfile -from scipy import ndimage -import mmcv -import torch -import torch.distributed as dist -from mmcv.parallel import MMDataParallel, MMDistributedDataParallel -from mmcv.runner import init_dist, get_dist_info, load_checkpoint - -from mmdet.core import coco_eval, results2json, wrap_fp16_model, tensor2imgs, get_classes -from mmdet.datasets import build_dataloader, build_dataset -from mmdet.models import build_detector -import cv2 - -import numpy as np -import matplotlib.cm as cm - -def vis_seg(data, result, img_norm_cfg, data_id, colors, score_thr, save_dir): - img_tensor = data['img'][0] - img_metas = data['img_meta'][0].data[0] - imgs = tensor2imgs(img_tensor, **img_norm_cfg) - assert len(imgs) == len(img_metas) - class_names = get_classes('coco') - - for img, img_meta, cur_result in zip(imgs, img_metas, result): - if cur_result is None: - continue - h, w, _ = img_meta['img_shape'] - img_show = img[:h, :w, :] - - seg_label = cur_result[0] - seg_label = seg_label.cpu().numpy().astype(np.uint8) - cate_label = cur_result[1] - cate_label = cate_label.cpu().numpy() - score = cur_result[2].cpu().numpy() - - vis_inds = score > score_thr - seg_label = seg_label[vis_inds] - num_mask = seg_label.shape[0] - cate_label = cate_label[vis_inds] - cate_score = score[vis_inds] - - mask_density = [] - for idx in range(num_mask): - cur_mask = seg_label[idx, :, :] - cur_mask = mmcv.imresize(cur_mask, (w, h)) - cur_mask = (cur_mask > 0.5).astype(np.int32) - mask_density.append(cur_mask.sum()) - orders = np.argsort(mask_density) - seg_label = seg_label[orders] - cate_label = cate_label[orders] - cate_score = cate_score[orders] - - seg_show = img_show.copy() - for idx in range(num_mask): - idx = -(idx+1) - cur_mask = seg_label[idx, :,:] - cur_mask = mmcv.imresize(cur_mask, (w, h)) - cur_mask = (cur_mask > 0.5).astype(np.uint8) - if cur_mask.sum() == 0: - continue - color_mask = np.random.randint( - 0, 256, (1, 3), dtype=np.uint8) - cur_mask_bool = cur_mask.astype(np.bool) - seg_show[cur_mask_bool] = img_show[cur_mask_bool] * 0.5 + color_mask * 0.5 - - cur_cate = cate_label[idx] - cur_score = cate_score[idx] - - label_text = class_names[cur_cate] - #label_text += '|{:.02f}'.format(cur_score) - # center - center_y, center_x = ndimage.measurements.center_of_mass(cur_mask) - vis_pos = (max(int(center_x) - 10, 0), int(center_y)) - cv2.putText(seg_show, label_text, vis_pos, - cv2.FONT_HERSHEY_COMPLEX, 0.3, (255, 255, 255)) # green - mmcv.imwrite(seg_show, '{}/{}.jpg'.format(save_dir, data_id)) - - -def single_gpu_test(model, data_loader, args, cfg=None, verbose=True): - model.eval() - results = [] - dataset = data_loader.dataset - - class_num = 1000 # ins - colors = [(np.random.random((1, 3)) * 255).tolist()[0] for i in range(class_num)] - - prog_bar = mmcv.ProgressBar(len(dataset)) - for i, data in enumerate(data_loader): - with torch.no_grad(): - seg_result = model(return_loss=False, rescale=True, **data) - result = None - results.append(result) - - if verbose: - vis_seg(data, seg_result, cfg.img_norm_cfg, data_id=i, colors=colors, score_thr=args.score_thr, save_dir=args.save_dir) - - batch_size = data['img'][0].size(0) - for _ in range(batch_size): - prog_bar.update() - return results - - -def multi_gpu_test(model, data_loader, tmpdir=None): - model.eval() - results = [] - dataset = data_loader.dataset - rank, world_size = get_dist_info() - if rank == 0: - prog_bar = mmcv.ProgressBar(len(dataset)) - for i, data in enumerate(data_loader): - with torch.no_grad(): - result = model(return_loss=False, rescale=True, **data) - results.append(result) - - if rank == 0: - batch_size = data['img'][0].size(0) - for _ in range(batch_size * world_size): - prog_bar.update() - - # collect results from all ranks - results = collect_results(results, len(dataset), tmpdir) - - return results - - -def collect_results(result_part, size, tmpdir=None): - rank, world_size = get_dist_info() - # create a tmp dir if it is not specified - if tmpdir is None: - MAX_LEN = 512 - # 32 is whitespace - dir_tensor = torch.full((MAX_LEN, ), - 32, - dtype=torch.uint8, - device='cuda') - if rank == 0: - tmpdir = tempfile.mkdtemp() - tmpdir = torch.tensor( - bytearray(tmpdir.encode()), dtype=torch.uint8, device='cuda') - dir_tensor[:len(tmpdir)] = tmpdir - dist.broadcast(dir_tensor, 0) - tmpdir = dir_tensor.cpu().numpy().tobytes().decode().rstrip() - else: - mmcv.mkdir_or_exist(tmpdir) - # dump the part result to the dir - mmcv.dump(result_part, osp.join(tmpdir, 'part_{}.pkl'.format(rank))) - dist.barrier() - # collect all parts - if rank != 0: - return None - else: - # load results of all parts from tmp dir - part_list = [] - for i in range(world_size): - part_file = osp.join(tmpdir, 'part_{}.pkl'.format(i)) - part_list.append(mmcv.load(part_file)) - # sort the results - ordered_results = [] - for res in zip(*part_list): - ordered_results.extend(list(res)) - # the dataloader may pad some samples - ordered_results = ordered_results[:size] - # remove tmp dir - shutil.rmtree(tmpdir) - return ordered_results - - -def parse_args(): - parser = argparse.ArgumentParser(description='MMDet test detector') - parser.add_argument('config', help='test config file path') - parser.add_argument('checkpoint', help='checkpoint file') - parser.add_argument('--out', help='output result file') - parser.add_argument( - '--json_out', - help='output result file name without extension', - type=str) - parser.add_argument( - '--eval', - type=str, - nargs='+', - choices=['proposal', 'proposal_fast', 'bbox', 'segm', 'keypoints'], - help='eval types') - parser.add_argument('--show', action='store_true', help='show results') - parser.add_argument('--score_thr', type=float, default=0.3, help='score threshold for visualization') - parser.add_argument('--tmpdir', help='tmp dir for writing some results') - parser.add_argument('--save_dir', help='dir for saveing visualized images') - parser.add_argument( - '--launcher', - choices=['none', 'pytorch', 'slurm', 'mpi'], - default='none', - help='job launcher') - parser.add_argument('--local_rank', type=int, default=0) - args = parser.parse_args() - if 'LOCAL_RANK' not in os.environ: - os.environ['LOCAL_RANK'] = str(args.local_rank) - return args - - -def main(): - args = parse_args() - - assert args.out or args.show or args.json_out, \ - ('Please specify at least one operation (save or show the results) ' - 'with the argument "--out" or "--show" or "--json_out"') - - if args.out is not None and not args.out.endswith(('.pkl', '.pickle')): - raise ValueError('The output file must be a pkl file.') - - if args.json_out is not None and args.json_out.endswith('.json'): - args.json_out = args.json_out[:-5] - - cfg = mmcv.Config.fromfile(args.config) - # set cudnn_benchmark - if cfg.get('cudnn_benchmark', False): - torch.backends.cudnn.benchmark = True - cfg.model.pretrained = None - cfg.data.test.test_mode = True - - # init distributed env first, since logger depends on the dist info. - if args.launcher == 'none': - distributed = False - else: - distributed = True - init_dist(args.launcher, **cfg.dist_params) - - # build the dataloader - # TODO: support multiple images per gpu (only minor changes are needed) - dataset = build_dataset(cfg.data.test) - data_loader = build_dataloader( - dataset, - imgs_per_gpu=1, - workers_per_gpu=cfg.data.workers_per_gpu, - dist=distributed, - shuffle=False) - - # build the model and load checkpoint - model = build_detector(cfg.model, train_cfg=None, test_cfg=cfg.test_cfg) - fp16_cfg = cfg.get('fp16', None) - if fp16_cfg is not None: - wrap_fp16_model(model) - checkpoint = load_checkpoint(model, args.checkpoint, map_location='cpu') - # old versions did not save class info in checkpoints, this walkaround is - # for backward compatibility - if 'CLASSES' in checkpoint['meta']: - model.CLASSES = checkpoint['meta']['CLASSES'] - else: - model.CLASSES = dataset.CLASSES - - assert not distributed - if not distributed: - model = MMDataParallel(model, device_ids=[0]) - outputs = single_gpu_test(model, data_loader, args, cfg=cfg) - else: - model = MMDistributedDataParallel(model.cuda()) - outputs = multi_gpu_test(model, data_loader, args.tmpdir) - - rank, _ = get_dist_info() - if args.out and rank == 0: - print('\nwriting results to {}'.format(args.out)) - mmcv.dump(outputs, args.out) - eval_types = args.eval - if eval_types: - print('Starting evaluate {}'.format(' and '.join(eval_types))) - if eval_types == ['proposal_fast']: - result_file = args.out - coco_eval(result_file, eval_types, dataset.coco) - else: - if not isinstance(outputs[0], dict): - result_files = results2json(dataset, outputs, args.out) - coco_eval(result_files, eval_types, dataset.coco) - else: - for name in outputs[0]: - print('\nEvaluating {}'.format(name)) - outputs_ = [out[name] for out in outputs] - result_file = args.out + '.{}'.format(name) - result_files = results2json(dataset, outputs_, - result_file) - coco_eval(result_files, eval_types, dataset.coco) - - # Save predictions in the COCO json format - if args.json_out and rank == 0: - if not isinstance(outputs[0], dict): - results2json(dataset, outputs, args.json_out) - else: - for name in outputs[0]: - outputs_ = [out[name] for out in outputs] - result_file = args.json_out + '.{}'.format(name) - results2json(dataset, outputs_, result_file) - - -if __name__ == '__main__': - main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/test_robustness.py b/cv/instance_segmentation/SOLO/pytorch/tools/test_robustness.py deleted file mode 100644 index 2271f4c06..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tools/test_robustness.py +++ /dev/null @@ -1,453 +0,0 @@ -import argparse -import copy -import os -import os.path as osp -import shutil -import tempfile - -import mmcv -import numpy as np -import torch -import torch.distributed as dist -from mmcv.parallel import MMDataParallel, MMDistributedDataParallel -from mmcv.runner import get_dist_info, init_dist, load_checkpoint -from pycocotools.coco import COCO -from pycocotools.cocoeval import COCOeval -from robustness_eval import get_results - -from mmdet import datasets -from mmdet.apis import set_random_seed -from mmdet.core import (eval_map, fast_eval_recall, results2json, - wrap_fp16_model) -from mmdet.datasets import build_dataloader, build_dataset -from mmdet.models import build_detector - - -def coco_eval_with_return(result_files, - result_types, - coco, - max_dets=(100, 300, 1000)): - for res_type in result_types: - assert res_type in [ - 'proposal', 'proposal_fast', 'bbox', 'segm', 'keypoints' - ] - - if mmcv.is_str(coco): - coco = COCO(coco) - assert isinstance(coco, COCO) - - if result_types == ['proposal_fast']: - ar = fast_eval_recall(result_files, coco, np.array(max_dets)) - for i, num in enumerate(max_dets): - print('AR@{}\t= {:.4f}'.format(num, ar[i])) - return - - eval_results = {} - for res_type in result_types: - result_file = result_files[res_type] - assert result_file.endswith('.json') - - coco_dets = coco.loadRes(result_file) - img_ids = coco.getImgIds() - iou_type = 'bbox' if res_type == 'proposal' else res_type - cocoEval = COCOeval(coco, coco_dets, iou_type) - cocoEval.params.imgIds = img_ids - if res_type == 'proposal': - cocoEval.params.useCats = 0 - cocoEval.params.maxDets = list(max_dets) - cocoEval.evaluate() - cocoEval.accumulate() - cocoEval.summarize() - if res_type == 'segm' or res_type == 'bbox': - metric_names = [ - 'AP', 'AP50', 'AP75', 'APs', 'APm', 'APl', 'AR1', 'AR10', - 'AR100', 'ARs', 'ARm', 'ARl' - ] - eval_results[res_type] = { - metric_names[i]: cocoEval.stats[i] - for i in range(len(metric_names)) - } - else: - eval_results[res_type] = cocoEval.stats - - return eval_results - - -def voc_eval_with_return(result_file, - dataset, - iou_thr=0.5, - logger='print', - only_ap=True): - det_results = mmcv.load(result_file) - annotations = [dataset.get_ann_info(i) for i in range(len(dataset))] - if hasattr(dataset, 'year') and dataset.year == 2007: - dataset_name = 'voc07' - else: - dataset_name = dataset.CLASSES - mean_ap, eval_results = eval_map( - det_results, - annotations, - scale_ranges=None, - iou_thr=iou_thr, - dataset=dataset_name, - logger=logger) - - if only_ap: - eval_results = [{ - 'ap': eval_results[i]['ap'] - } for i in range(len(eval_results))] - - return mean_ap, eval_results - - -def single_gpu_test(model, data_loader, show=False): - model.eval() - results = [] - dataset = data_loader.dataset - prog_bar = mmcv.ProgressBar(len(dataset)) - for i, data in enumerate(data_loader): - with torch.no_grad(): - result = model(return_loss=False, rescale=not show, **data) - results.append(result) - - if show: - model.module.show_result(data, result, dataset.img_norm_cfg) - - batch_size = data['img'][0].size(0) - for _ in range(batch_size): - prog_bar.update() - return results - - -def multi_gpu_test(model, data_loader, tmpdir=None): - model.eval() - results = [] - dataset = data_loader.dataset - rank, world_size = get_dist_info() - if rank == 0: - prog_bar = mmcv.ProgressBar(len(dataset)) - for i, data in enumerate(data_loader): - with torch.no_grad(): - result = model(return_loss=False, rescale=True, **data) - results.append(result) - - if rank == 0: - batch_size = data['img'][0].size(0) - for _ in range(batch_size * world_size): - prog_bar.update() - - # collect results from all ranks - results = collect_results(results, len(dataset), tmpdir) - - return results - - -def collect_results(result_part, size, tmpdir=None): - rank, world_size = get_dist_info() - # create a tmp dir if it is not specified - if tmpdir is None: - MAX_LEN = 512 - # 32 is whitespace - dir_tensor = torch.full((MAX_LEN, ), - 32, - dtype=torch.uint8, - device='cuda') - if rank == 0: - tmpdir = tempfile.mkdtemp() - tmpdir = torch.tensor( - bytearray(tmpdir.encode()), dtype=torch.uint8, device='cuda') - dir_tensor[:len(tmpdir)] = tmpdir - dist.broadcast(dir_tensor, 0) - tmpdir = dir_tensor.cpu().numpy().tobytes().decode().rstrip() - else: - mmcv.mkdir_or_exist(tmpdir) - # dump the part result to the dir - mmcv.dump(result_part, osp.join(tmpdir, 'part_{}.pkl'.format(rank))) - dist.barrier() - # collect all parts - if rank != 0: - return None - else: - # load results of all parts from tmp dir - part_list = [] - for i in range(world_size): - part_file = osp.join(tmpdir, 'part_{}.pkl'.format(i)) - part_list.append(mmcv.load(part_file)) - # sort the results - ordered_results = [] - for res in zip(*part_list): - ordered_results.extend(list(res)) - # the dataloader may pad some samples - ordered_results = ordered_results[:size] - # remove tmp dir - shutil.rmtree(tmpdir) - return ordered_results - - -def parse_args(): - parser = argparse.ArgumentParser(description='MMDet test detector') - parser.add_argument('config', help='test config file path') - parser.add_argument('checkpoint', help='checkpoint file') - parser.add_argument('--out', help='output result file') - parser.add_argument( - '--corruptions', - type=str, - nargs='+', - default='benchmark', - choices=[ - 'all', 'benchmark', 'noise', 'blur', 'weather', 'digital', - 'holdout', 'None', 'gaussian_noise', 'shot_noise', 'impulse_noise', - 'defocus_blur', 'glass_blur', 'motion_blur', 'zoom_blur', 'snow', - 'frost', 'fog', 'brightness', 'contrast', 'elastic_transform', - 'pixelate', 'jpeg_compression', 'speckle_noise', 'gaussian_blur', - 'spatter', 'saturate' - ], - help='corruptions') - parser.add_argument( - '--severities', - type=int, - nargs='+', - default=[0, 1, 2, 3, 4, 5], - help='corruption severity levels') - parser.add_argument( - '--eval', - type=str, - nargs='+', - choices=['proposal', 'proposal_fast', 'bbox', 'segm', 'keypoints'], - help='eval types') - parser.add_argument( - '--iou-thr', - type=float, - default=0.5, - help='IoU threshold for pascal voc evaluation') - parser.add_argument( - '--summaries', - type=bool, - default=False, - help='Print summaries for every corruption and severity') - parser.add_argument( - '--workers', type=int, default=32, help='workers per gpu') - parser.add_argument('--show', action='store_true', help='show results') - parser.add_argument('--tmpdir', help='tmp dir for writing some results') - parser.add_argument('--seed', type=int, default=None, help='random seed') - parser.add_argument( - '--launcher', - choices=['none', 'pytorch', 'slurm', 'mpi'], - default='none', - help='job launcher') - parser.add_argument('--local_rank', type=int, default=0) - parser.add_argument( - '--final-prints', - type=str, - nargs='+', - choices=['P', 'mPC', 'rPC'], - default='mPC', - help='corruption benchmark metric to print at the end') - parser.add_argument( - '--final-prints-aggregate', - type=str, - choices=['all', 'benchmark'], - default='benchmark', - help='aggregate all results or only those for benchmark corruptions') - args = parser.parse_args() - if 'LOCAL_RANK' not in os.environ: - os.environ['LOCAL_RANK'] = str(args.local_rank) - return args - - -def main(): - args = parse_args() - - assert args.out or args.show, \ - ('Please specify at least one operation (save or show the results) ' - 'with the argument "--out" or "--show"') - - if args.out is not None and not args.out.endswith(('.pkl', '.pickle')): - raise ValueError('The output file must be a pkl file.') - - cfg = mmcv.Config.fromfile(args.config) - # set cudnn_benchmark - if cfg.get('cudnn_benchmark', False): - torch.backends.cudnn.benchmark = True - cfg.model.pretrained = None - cfg.data.test.test_mode = True - if args.workers == 0: - args.workers = cfg.data.workers_per_gpu - - # init distributed env first, since logger depends on the dist info. - if args.launcher == 'none': - distributed = False - else: - distributed = True - init_dist(args.launcher, **cfg.dist_params) - - # set random seeds - if args.seed is not None: - set_random_seed(args.seed) - - if 'all' in args.corruptions: - corruptions = [ - 'gaussian_noise', 'shot_noise', 'impulse_noise', 'defocus_blur', - 'glass_blur', 'motion_blur', 'zoom_blur', 'snow', 'frost', 'fog', - 'brightness', 'contrast', 'elastic_transform', 'pixelate', - 'jpeg_compression', 'speckle_noise', 'gaussian_blur', 'spatter', - 'saturate' - ] - elif 'benchmark' in args.corruptions: - corruptions = [ - 'gaussian_noise', 'shot_noise', 'impulse_noise', 'defocus_blur', - 'glass_blur', 'motion_blur', 'zoom_blur', 'snow', 'frost', 'fog', - 'brightness', 'contrast', 'elastic_transform', 'pixelate', - 'jpeg_compression' - ] - elif 'noise' in args.corruptions: - corruptions = ['gaussian_noise', 'shot_noise', 'impulse_noise'] - elif 'blur' in args.corruptions: - corruptions = [ - 'defocus_blur', 'glass_blur', 'motion_blur', 'zoom_blur' - ] - elif 'weather' in args.corruptions: - corruptions = ['snow', 'frost', 'fog', 'brightness'] - elif 'digital' in args.corruptions: - corruptions = [ - 'contrast', 'elastic_transform', 'pixelate', 'jpeg_compression' - ] - elif 'holdout' in args.corruptions: - corruptions = ['speckle_noise', 'gaussian_blur', 'spatter', 'saturate'] - elif 'None' in args.corruptions: - corruptions = ['None'] - args.severities = [0] - else: - corruptions = args.corruptions - - aggregated_results = {} - for corr_i, corruption in enumerate(corruptions): - aggregated_results[corruption] = {} - for sev_i, corruption_severity in enumerate(args.severities): - # evaluate severity 0 (= no corruption) only once - if corr_i > 0 and corruption_severity == 0: - aggregated_results[corruption][0] = \ - aggregated_results[corruptions[0]][0] - continue - - test_data_cfg = copy.deepcopy(cfg.data.test) - # assign corruption and severity - if corruption_severity > 0: - corruption_trans = dict( - type='Corrupt', - corruption=corruption, - severity=corruption_severity) - # TODO: hard coded "1", we assume that the first step is - # loading images, which needs to be fixed in the future - test_data_cfg['pipeline'].insert(1, corruption_trans) - - # print info - print('\nTesting {} at severity {}'.format(corruption, - corruption_severity)) - - # build the dataloader - # TODO: support multiple images per gpu - # (only minor changes are needed) - dataset = build_dataset(test_data_cfg) - data_loader = build_dataloader( - dataset, - imgs_per_gpu=1, - workers_per_gpu=args.workers, - dist=distributed, - shuffle=False) - - # build the model and load checkpoint - model = build_detector( - cfg.model, train_cfg=None, test_cfg=cfg.test_cfg) - fp16_cfg = cfg.get('fp16', None) - if fp16_cfg is not None: - wrap_fp16_model(model) - checkpoint = load_checkpoint( - model, args.checkpoint, map_location='cpu') - # old versions did not save class info in checkpoints, - # this walkaround is for backward compatibility - if 'CLASSES' in checkpoint['meta']: - model.CLASSES = checkpoint['meta']['CLASSES'] - else: - model.CLASSES = dataset.CLASSES - - if not distributed: - model = MMDataParallel(model, device_ids=[0]) - outputs = single_gpu_test(model, data_loader, args.show) - else: - model = MMDistributedDataParallel(model.cuda()) - outputs = multi_gpu_test(model, data_loader, args.tmpdir) - - rank, _ = get_dist_info() - if args.out and rank == 0: - eval_results_filename = ( - osp.splitext(args.out)[0] + '_results' + - osp.splitext(args.out)[1]) - mmcv.dump(outputs, args.out) - eval_types = args.eval - if cfg.dataset_type == 'VOCDataset': - if eval_types: - for eval_type in eval_types: - if eval_type == 'bbox': - test_dataset = mmcv.runner.obj_from_dict( - cfg.data.test, datasets) - logger = 'print' if args.summaries else None - mean_ap, eval_results = \ - voc_eval_with_return( - args.out, test_dataset, - args.iou_thr, logger) - aggregated_results[corruption][ - corruption_severity] = eval_results - else: - print('\nOnly "bbox" evaluation \ - is supported for pascal voc') - else: - if eval_types: - print('Starting evaluate {}'.format( - ' and '.join(eval_types))) - if eval_types == ['proposal_fast']: - result_file = args.out - else: - if not isinstance(outputs[0], dict): - result_files = results2json( - dataset, outputs, args.out) - else: - for name in outputs[0]: - print('\nEvaluating {}'.format(name)) - outputs_ = [out[name] for out in outputs] - result_file = args.out - + '.{}'.format(name) - result_files = results2json( - dataset, outputs_, result_file) - eval_results = coco_eval_with_return( - result_files, eval_types, dataset.coco) - aggregated_results[corruption][ - corruption_severity] = eval_results - else: - print('\nNo task was selected for evaluation;' - '\nUse --eval to select a task') - - # save results after each evaluation - mmcv.dump(aggregated_results, eval_results_filename) - - # print filan results - print('\nAggregated results:') - prints = args.final_prints - aggregate = args.final_prints_aggregate - - if cfg.dataset_type == 'VOCDataset': - get_results( - eval_results_filename, - dataset='voc', - prints=prints, - aggregate=aggregate) - else: - get_results( - eval_results_filename, - dataset='coco', - prints=prints, - aggregate=aggregate) - - -if __name__ == '__main__': - main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/train.py b/cv/instance_segmentation/SOLO/pytorch/tools/train.py deleted file mode 100644 index 7f89795d5..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tools/train.py +++ /dev/null @@ -1,125 +0,0 @@ -from __future__ import division -import argparse -import os -import os.path as osp -import time - -import mmcv -import torch -from mmcv import Config -from mmcv.runner import init_dist - -from mmdet import __version__ -from mmdet.apis import set_random_seed, train_detector -from mmdet.datasets import build_dataset -from mmdet.models import build_detector -from mmdet.utils import get_root_logger - - -def parse_args(): - parser = argparse.ArgumentParser(description='Train a detector') - parser.add_argument('config', help='train config file path') - parser.add_argument('--work_dir', help='the dir to save logs and models') - parser.add_argument( - '--resume_from', help='the checkpoint file to resume from') - parser.add_argument( - '--validate', - action='store_true', - help='whether to evaluate the checkpoint during training') - parser.add_argument( - '--gpus', - type=int, - default=1, - help='number of gpus to use ' - '(only applicable to non-distributed training)') - parser.add_argument('--seed', type=int, default=None, help='random seed') - parser.add_argument( - '--deterministic', - action='store_true', - help='whether to set deterministic options for CUDNN backend.') - parser.add_argument( - '--launcher', - choices=['none', 'pytorch', 'slurm', 'mpi'], - default='none', - help='job launcher') - parser.add_argument('--local_rank', type=int, default=0) - parser.add_argument( - '--autoscale-lr', - action='store_true', - help='automatically scale lr with the number of gpus') - args = parser.parse_args() - if 'LOCAL_RANK' not in os.environ: - os.environ['LOCAL_RANK'] = str(args.local_rank) - - return args - - -def main(): - args = parse_args() - - cfg = Config.fromfile(args.config) - # set cudnn_benchmark - if cfg.get('cudnn_benchmark', False): - torch.backends.cudnn.benchmark = True - # update configs according to CLI args - if args.work_dir is not None: - cfg.work_dir = args.work_dir - if args.resume_from is not None: - cfg.resume_from = args.resume_from - cfg.gpus = args.gpus - - if args.autoscale_lr: - # apply the linear scaling rule (https://arxiv.org/abs/1706.02677) - cfg.optimizer['lr'] = cfg.optimizer['lr'] * cfg.gpus / 8 - - # init distributed env first, since logger depends on the dist info. - if args.launcher == 'none': - distributed = False - else: - distributed = True - init_dist(args.launcher, **cfg.dist_params) - - # create work_dir - mmcv.mkdir_or_exist(osp.abspath(cfg.work_dir)) - # init the logger before other steps - timestamp = time.strftime('%Y%m%d_%H%M%S', time.localtime()) - log_file = osp.join(cfg.work_dir, '{}.log'.format(timestamp)) - logger = get_root_logger(log_file=log_file, log_level=cfg.log_level) - - # log some basic info - logger.info('Distributed training: {}'.format(distributed)) - logger.info('MMDetection Version: {}'.format(__version__)) - logger.info('Config:\n{}'.format(cfg.text)) - - # set random seeds - if args.seed is not None: - logger.info('Set random seed to {}, deterministic: {}'.format( - args.seed, args.deterministic)) - set_random_seed(args.seed, deterministic=args.deterministic) - - model = build_detector( - cfg.model, train_cfg=cfg.train_cfg, test_cfg=cfg.test_cfg) - - datasets = [build_dataset(cfg.data.train)] - if len(cfg.workflow) == 2: - datasets.append(build_dataset(cfg.data.val)) - if cfg.checkpoint_config is not None: - # save mmdet version, config file content and class names in - # checkpoints as meta data - cfg.checkpoint_config.meta = dict( - mmdet_version=__version__, - config=cfg.text, - CLASSES=datasets[0].CLASSES) - # add an attribute for visualization convenience - model.CLASSES = datasets[0].CLASSES - train_detector( - model, - datasets, - cfg, - distributed=distributed, - validate=args.validate, - timestamp=timestamp) - - -if __name__ == '__main__': - main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/upgrade_model_version.py b/cv/instance_segmentation/SOLO/pytorch/tools/upgrade_model_version.py deleted file mode 100644 index 00bcdf44a..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tools/upgrade_model_version.py +++ /dev/null @@ -1,42 +0,0 @@ -import argparse -import re -from collections import OrderedDict - -import torch - - -def convert(in_file, out_file): - """Convert keys in checkpoints. - - There can be some breaking changes during the development of mmdetection, - and this tool is used for upgrading checkpoints trained with old versions - to the latest one. - """ - checkpoint = torch.load(in_file) - in_state_dict = checkpoint.pop('state_dict') - out_state_dict = OrderedDict() - for key, val in in_state_dict.items(): - # Use ConvModule instead of nn.Conv2d in RetinaNet - # cls_convs.0.weight -> cls_convs.0.conv.weight - m = re.search(r'(cls_convs|reg_convs).\d.(weight|bias)', key) - if m is not None: - param = m.groups()[1] - new_key = key.replace(param, 'conv.{}'.format(param)) - out_state_dict[new_key] = val - continue - - out_state_dict[key] = val - checkpoint['state_dict'] = out_state_dict - torch.save(checkpoint, out_file) - - -def main(): - parser = argparse.ArgumentParser(description='Upgrade model version') - parser.add_argument('in_file', help='input checkpoint file') - parser.add_argument('out_file', help='output checkpoint file') - args = parser.parse_args() - convert(args.in_file, args.out_file) - - -if __name__ == '__main__': - main() diff --git a/cv/instance_segmentation/SOLO/pytorch/tools/voc_eval.py b/cv/instance_segmentation/SOLO/pytorch/tools/voc_eval.py deleted file mode 100644 index be0bde6db..000000000 --- a/cv/instance_segmentation/SOLO/pytorch/tools/voc_eval.py +++ /dev/null @@ -1,47 +0,0 @@ -from argparse import ArgumentParser - -import mmcv - -from mmdet import datasets -from mmdet.core import eval_map - - -def voc_eval(result_file, dataset, iou_thr=0.5, nproc=4): - det_results = mmcv.load(result_file) - annotations = [dataset.get_ann_info(i) for i in range(len(dataset))] - if hasattr(dataset, 'year') and dataset.year == 2007: - dataset_name = 'voc07' - else: - dataset_name = dataset.CLASSES - eval_map( - det_results, - annotations, - scale_ranges=None, - iou_thr=iou_thr, - dataset=dataset_name, - logger='print', - nproc=nproc) - - -def main(): - parser = ArgumentParser(description='VOC Evaluation') - parser.add_argument('result', help='result file path') - parser.add_argument('config', help='config file path') - parser.add_argument( - '--iou-thr', - type=float, - default=0.5, - help='IoU threshold for evaluation') - parser.add_argument( - '--nproc', - type=int, - default=4, - help='Processes to be used for computing mAP') - args = parser.parse_args() - cfg = mmcv.Config.fromfile(args.config) - test_dataset = mmcv.runner.obj_from_dict(cfg.data.test, datasets) - voc_eval(args.result, test_dataset, args.iou_thr, args.nproc) - - -if __name__ == '__main__': - main() diff --git a/cv/instance_segmentation/SOLO/pytorch/train.py b/cv/instance_segmentation/SOLO/pytorch/train.py new file mode 100644 index 000000000..ab3e60c62 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/train.py @@ -0,0 +1,243 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import argparse +import copy +import os +import os.path as osp +import time +import warnings + +import mmcv +import torch +import torch.distributed as dist +from mmcv import Config, DictAction +from mmcv.runner import get_dist_info, init_dist +from mmcv.utils import get_git_hash +import sys +sys.path.append('./') +from mmdet import __version__ +from mmdet.apis import init_random_seed, set_random_seed, train_detector +from mmdet.datasets import build_dataset +from mmdet.models import build_detector +from mmdet.utils import (collect_env, get_device, get_root_logger, + replace_cfg_vals, setup_multi_processes, + update_data_root) + + +def parse_args(): + parser = argparse.ArgumentParser(description='Train a detector') + parser.add_argument('config', help='train config file path') + parser.add_argument('--work-dir', help='the dir to save logs and models') + parser.add_argument( + '--resume-from', help='the checkpoint file to resume from') + parser.add_argument( + '--auto-resume', + action='store_true', + help='resume from the latest checkpoint automatically') + parser.add_argument( + '--no-validate', + action='store_true', + help='whether not to evaluate the checkpoint during training') + group_gpus = parser.add_mutually_exclusive_group() + group_gpus.add_argument( + '--gpus', + type=int, + help='(Deprecated, please use --gpu-id) number of gpus to use ' + '(only applicable to non-distributed training)') + group_gpus.add_argument( + '--gpu-ids', + type=int, + nargs='+', + help='(Deprecated, please use --gpu-id) ids of gpus to use ' + '(only applicable to non-distributed training)') + group_gpus.add_argument( + '--gpu-id', + type=int, + default=0, + help='id of gpu to use ' + '(only applicable to non-distributed training)') + parser.add_argument('--seed', type=int, default=None, help='random seed') + parser.add_argument( + '--diff-seed', + action='store_true', + help='Whether or not set different seeds for different ranks') + parser.add_argument( + '--deterministic', + action='store_true', + help='whether to set deterministic options for CUDNN backend.') + parser.add_argument( + '--options', + nargs='+', + action=DictAction, + help='override some settings in the used config, the key-value pair ' + 'in xxx=yyy format will be merged into config file (deprecate), ' + 'change to --cfg-options instead.') + parser.add_argument( + '--cfg-options', + nargs='+', + action=DictAction, + help='override some settings in the used config, the key-value pair ' + 'in xxx=yyy format will be merged into config file. If the value to ' + 'be overwritten is a list, it should be like key="[a,b]" or key=a,b ' + 'It also allows nested list/tuple values, e.g. key="[(a,b),(c,d)]" ' + 'Note that the quotation marks are necessary and that no white space ' + 'is allowed.') + parser.add_argument( + '--launcher', + choices=['none', 'pytorch', 'slurm', 'mpi'], + default='none', + help='job launcher') + parser.add_argument('--local_rank', type=int, default=0) + parser.add_argument( + '--auto-scale-lr', + action='store_true', + help='enable automatically scaling LR.') + args = parser.parse_args() + if 'LOCAL_RANK' not in os.environ: + os.environ['LOCAL_RANK'] = str(args.local_rank) + + if args.options and args.cfg_options: + raise ValueError( + '--options and --cfg-options cannot be both ' + 'specified, --options is deprecated in favor of --cfg-options') + if args.options: + warnings.warn('--options is deprecated in favor of --cfg-options') + args.cfg_options = args.options + + return args + + +def main(): + args = parse_args() + + cfg = Config.fromfile(args.config) + + # replace the ${key} with the value of cfg.key + cfg = replace_cfg_vals(cfg) + + # update data root according to MMDET_DATASETS + update_data_root(cfg) + + if args.cfg_options is not None: + cfg.merge_from_dict(args.cfg_options) + + if args.auto_scale_lr: + if 'auto_scale_lr' in cfg and \ + 'enable' in cfg.auto_scale_lr and \ + 'base_batch_size' in cfg.auto_scale_lr: + cfg.auto_scale_lr.enable = True + else: + warnings.warn('Can not find "auto_scale_lr" or ' + '"auto_scale_lr.enable" or ' + '"auto_scale_lr.base_batch_size" in your' + ' configuration file. Please update all the ' + 'configuration files to mmdet >= 2.24.1.') + + # set multi-process settings + setup_multi_processes(cfg) + + # set cudnn_benchmark + if cfg.get('cudnn_benchmark', False): + torch.backends.cudnn.benchmark = True + + # work_dir is determined in this priority: CLI > segment in file > filename + if args.work_dir is not None: + # update configs according to CLI args if args.work_dir is not None + cfg.work_dir = args.work_dir + elif cfg.get('work_dir', None) is None: + # use config filename as default work_dir if cfg.work_dir is None + cfg.work_dir = osp.join('./work_dirs', + osp.splitext(osp.basename(args.config))[0]) + + if args.resume_from is not None: + cfg.resume_from = args.resume_from + cfg.auto_resume = args.auto_resume + if args.gpus is not None: + cfg.gpu_ids = range(1) + warnings.warn('`--gpus` is deprecated because we only support ' + 'single GPU mode in non-distributed training. ' + 'Use `gpus=1` now.') + if args.gpu_ids is not None: + cfg.gpu_ids = args.gpu_ids[0:1] + warnings.warn('`--gpu-ids` is deprecated, please use `--gpu-id`. ' + 'Because we only support single GPU mode in ' + 'non-distributed training. Use the first GPU ' + 'in `gpu_ids` now.') + if args.gpus is None and args.gpu_ids is None: + cfg.gpu_ids = [args.gpu_id] + + # init distributed env first, since logger depends on the dist info. + if args.launcher == 'none': + distributed = False + else: + distributed = True + init_dist(args.launcher, **cfg.dist_params) + # re-set gpu_ids with distributed training mode + _, world_size = get_dist_info() + cfg.gpu_ids = range(world_size) + + # create work_dir + mmcv.mkdir_or_exist(osp.abspath(cfg.work_dir)) + # dump config + cfg.dump(osp.join(cfg.work_dir, osp.basename(args.config))) + # init the logger before other steps + timestamp = time.strftime('%Y%m%d_%H%M%S', time.localtime()) + log_file = osp.join(cfg.work_dir, f'{timestamp}.log') + logger = get_root_logger(log_file=log_file, log_level=cfg.log_level) + + # init the meta dict to record some important information such as + # environment info and seed, which will be logged + meta = dict() + # log env info + env_info_dict = collect_env() + env_info = '\n'.join([(f'{k}: {v}') for k, v in env_info_dict.items()]) + dash_line = '-' * 60 + '\n' + logger.info('Environment info:\n' + dash_line + env_info + '\n' + + dash_line) + meta['env_info'] = env_info + meta['config'] = cfg.pretty_text + # log some basic info + logger.info(f'Distributed training: {distributed}') + logger.info(f'Config:\n{cfg.pretty_text}') + + cfg.device = get_device() + # set random seeds + seed = init_random_seed(args.seed, device=cfg.device) + seed = seed + dist.get_rank() if args.diff_seed else seed + logger.info(f'Set random seed to {seed}, ' + f'deterministic: {args.deterministic}') + set_random_seed(seed, deterministic=args.deterministic) + cfg.seed = seed + meta['seed'] = seed + meta['exp_name'] = osp.basename(args.config) + + model = build_detector( + cfg.model, + train_cfg=cfg.get('train_cfg'), + test_cfg=cfg.get('test_cfg')) + model.init_weights() + + datasets = [build_dataset(cfg.data.train)] + if len(cfg.workflow) == 2: + val_dataset = copy.deepcopy(cfg.data.val) + val_dataset.pipeline = cfg.data.train.pipeline + datasets.append(build_dataset(val_dataset)) + if cfg.checkpoint_config is not None: + # save mmdet version, config file content and class names in + # checkpoints as meta data + cfg.checkpoint_config.meta = dict( + mmdet_version=__version__ + get_git_hash()[:7], + CLASSES=datasets[0].CLASSES) + # add an attribute for visualization convenience + model.CLASSES = datasets[0].CLASSES + train_detector( + model, + datasets, + cfg, + distributed=distributed, + validate=(not args.no_validate), + timestamp=timestamp, + meta=meta) + + +if __name__ == '__main__': + main() diff --git a/cv/instance_segmentation/SOLO/pytorch/train.sh b/cv/instance_segmentation/SOLO/pytorch/train.sh new file mode 100644 index 000000000..14957276d --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/train.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# Copyright (c) 2022, Shanghai Iluvatar CoreX Semiconductor Co., Ltd. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +python3 train.py configs/solo/solo_r50_fpn_1x_coco.py \ No newline at end of file diff --git a/cv/instance_segmentation/SOLO/pytorch/train_dist.sh b/cv/instance_segmentation/SOLO/pytorch/train_dist.sh new file mode 100644 index 000000000..fd762b216 --- /dev/null +++ b/cv/instance_segmentation/SOLO/pytorch/train_dist.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# Copyright (c) 2022, Shanghai Iluvatar CoreX Semiconductor Co., Ltd. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +CONFIG=$1 +GPUS=$2 +NNODES=${NNODES:-1} +NODE_RANK=${NODE_RANK:-0} +PORT=${PORT:-29500} +MASTER_ADDR=${MASTER_ADDR:-"127.0.0.1"} + +PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ +python3 -m torch.distributed.launch \ + --nnodes=$NNODES \ + --node_rank=$NODE_RANK \ + --master_addr=$MASTER_ADDR \ + --nproc_per_node=$GPUS \ + --master_port=$PORT \ + $(dirname "$0")/train.py \ + $CONFIG \ + --seed 0 \ + --launcher pytorch ${@:3} -- Gitee From 82bfd9196a650e2573efd09f1d7809f3cc3253f5 Mon Sep 17 00:00:00 2001 From: "li.ding" Date: Mon, 13 Mar 2023 13:44:11 +0800 Subject: [PATCH 3/4] delete unnecessary file --- cv/instance_segmentation/SOLO.zip | Bin 604461 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 cv/instance_segmentation/SOLO.zip diff --git a/cv/instance_segmentation/SOLO.zip b/cv/instance_segmentation/SOLO.zip deleted file mode 100644 index bf78bb57d9197c7157c70878cc67ebac9c6c3b2a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 604461 zcmbSy18^)_x^-;Z&WY`u*tTU=S35KYqfq%~k&P;=g`Dd_CK`IojA8n9|Ap*D45rYCkiTqq___bYK90 z3s3+6q(7~qH8FEEGqJX@H?mTajM-p?>B7G8L5R&p!+o2{57|n;0uzg)_P3ssl*6c> zsB1EaC?9cig@3suHJWtPd>{&!y}gyUnOINKJGKq;4(@FPBYqp~K6v{b0&h%bUtUoi zQPE)SUu|)IRvmV(8q%L*|C_ctDuX6WUaOO#8>@vL!s&Pfyj;D%9Mip{-c5X(&DfV-gdW#>uX2Rhnbg7Wqkb+G;WYOtSnzG z%g74IQ6`tq1v7$rhO{jBe`}>e#QpiT+f{F^A-XY6*U%q zc5fZ#K(nwsSpjHlX8C~#laA$$2f>t9%+Ak)Pe`79a^x_ctAnMRAU0!POb{S0w>4Ov zQKr-->8cMMf0NM+wcw*0kkM#eB%#D_%Zmf!)C!j*`@*A(M~h9ZiXy#=s(_HpSS%?< z)fE}yM^~)qb=ga$M)A`I$=czPDT0lf8aWBDBvl=Kmc5Y@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ee From 8387b4f2eeffd6442b0a1429172ea56b5ca5cb13 Mon Sep 17 00:00:00 2001 From: "li.ding" Date: Fri, 17 Mar 2023 00:00:32 +0800 Subject: [PATCH 4/4] Modify readme --- cv/instance_segmentation/SOLO/pytorch/README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cv/instance_segmentation/SOLO/pytorch/README.md b/cv/instance_segmentation/SOLO/pytorch/README.md index 17fdb4e63..ff87af9b2 100644 --- a/cv/instance_segmentation/SOLO/pytorch/README.md +++ b/cv/instance_segmentation/SOLO/pytorch/README.md @@ -35,10 +35,13 @@ bash train.sh ### Multiple GPUs on one machine ```bash -$ bash dist_train.sh [training args] # config file can be found in the configs directory -# Avaiable configs are in configs/solo +$ bash train_dist.sh [training args] # config file can be found in the configs directory ``` +## Results on BI-V100 + +Average Precision (AP) @[ loU=0.50:0.95 | area= all | maxDets=1001 ] = 0.361 + ## Reference Reference: https://github.com/WXinlong/SOLO -- Gitee

    !;%@*L*CF*aQj7wH3~w_KZ7#q{y{b zGytG>ApHYSy49I?t2=ukAR9BbDnXdbJXEv|QWga-zTx(wwuizHNv-K8#H>bMNo769 zoRS2iBVR@_cE{+j20?rA)6%KW9`wQ&25x;0uFa}McPKD6w!rpI`CUIXnyixauQj^b3h2bn7(u0%zTN;{j9S+E( zZHa;dN)}Jgl3B`eMpjPMd0cAplGl2PIGKf;-C_d@kP9&FpgShD%Be`&ADoWwAuasn zjh3eM{)?Pozmmxy7w`n`Fx@gntkWKSl3}=D9@^p+$87`e#WaLZm6G7g^wg4Vrf4mUn;1a?VD|LmN<4p|3y>>Q zsuzTeDxs%E?M~n9Q=06&u)J*A&((S)y@^>J$+jB!Ne$#yZe7Ts!e8?Iax99t*7CHB z^K}Kk*h$Xi$jH3t>a~H!#t}L=Em!>GGo99;yQ8iO#cB=GfFyRi4JKwAor^Yrg$2#C zSapP^0;lOls!`YRjdg{R8YAaiYrJCd9)X7i@&-uWhp9;O5y|qZ85zuwCd6KAc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