├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── configs ├── Base.yaml ├── GRiT_B_DenseCap.yaml ├── GRiT_B_DenseCap_ObjectDet.yaml ├── GRiT_B_ObjectDet.yaml ├── GRiT_H_ObjectDet.yaml └── GRiT_L_ObjectDet.yaml ├── datasets └── DATASETS.md ├── demo.py ├── demo_images ├── 000000353174.jpg ├── 000000438652.jpg ├── 000000453583.jpg ├── 000000466185.jpg ├── 000000497110.jpg ├── 000000497861.jpg └── 000000546072.jpg ├── docs ├── INSTALL.md ├── chatgpt.png ├── demo.png └── grit.png ├── grit ├── __init__.py ├── config.py ├── custom_solver.py ├── data │ ├── custom_build_augmentation.py │ ├── custom_dataset_dataloader.py │ ├── custom_dataset_mapper.py │ ├── datasets │ │ ├── grit_coco.py │ │ ├── object365.py │ │ └── vg.py │ └── transforms │ │ ├── custom_augmentation_impl.py │ │ └── custom_transform.py ├── evaluation │ └── eval.py ├── modeling │ ├── backbone │ │ ├── utils.py │ │ └── vit.py │ ├── meta_arch │ │ └── grit.py │ ├── roi_heads │ │ ├── grit_fast_rcnn.py │ │ └── grit_roi_heads.py │ ├── soft_nms.py │ └── text │ │ ├── file_utils.py │ │ ├── load_text_token.py │ │ ├── modeling_bert.py │ │ └── text_decoder.py └── predictor.py ├── lauch_deepspeed.py ├── requirements.txt ├── third_party └── CenterNet2 │ ├── .circleci │ └── config.yml │ ├── .clang-format │ ├── .flake8 │ ├── .github │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── Detectron2-Logo-Horz.svg │ ├── ISSUE_TEMPLATE.md │ ├── ISSUE_TEMPLATE │ │ ├── bugs.md │ │ ├── config.yml │ │ ├── documentation.md │ │ ├── feature-request.md │ │ └── unexpected-problems-bugs.md │ ├── pull_request_template.md │ └── workflows │ │ ├── check-template.yml │ │ ├── levenshtein.js │ │ ├── needs-reply.yml │ │ ├── remove-needs-reply.yml │ │ └── workflow.yml │ ├── .gitignore │ ├── GETTING_STARTED.md │ ├── INSTALL.md │ ├── LICENSE │ ├── MODEL_ZOO.md │ ├── README.md │ ├── README_D2.md │ ├── configs │ ├── Base-RCNN-C4.yaml │ ├── Base-RCNN-DilatedC5.yaml │ ├── Base-RCNN-FPN.yaml │ ├── Base-RetinaNet.yaml │ ├── COCO-Detection │ │ ├── fast_rcnn_R_50_FPN_1x.yaml │ │ ├── faster_rcnn_R_101_C4_3x.yaml │ │ ├── faster_rcnn_R_101_DC5_3x.yaml │ │ ├── faster_rcnn_R_101_FPN_3x.yaml │ │ ├── faster_rcnn_R_50_C4_1x.yaml │ │ ├── faster_rcnn_R_50_C4_3x.yaml │ │ ├── faster_rcnn_R_50_DC5_1x.yaml │ │ ├── faster_rcnn_R_50_DC5_3x.yaml │ │ ├── faster_rcnn_R_50_FPN_1x.yaml │ │ ├── faster_rcnn_R_50_FPN_3x.yaml │ │ ├── faster_rcnn_X_101_32x8d_FPN_3x.yaml │ │ ├── fcos_R_50_FPN_1x.py │ │ ├── retinanet_R_101_FPN_3x.yaml │ │ ├── retinanet_R_50_FPN_1x.py │ │ ├── retinanet_R_50_FPN_1x.yaml │ │ ├── retinanet_R_50_FPN_3x.yaml │ │ ├── rpn_R_50_C4_1x.yaml │ │ └── rpn_R_50_FPN_1x.yaml │ ├── COCO-InstanceSegmentation │ │ ├── mask_rcnn_R_101_C4_3x.yaml │ │ ├── mask_rcnn_R_101_DC5_3x.yaml │ │ ├── mask_rcnn_R_101_FPN_3x.yaml │ │ ├── mask_rcnn_R_50_C4_1x.py │ │ ├── mask_rcnn_R_50_C4_1x.yaml │ │ ├── mask_rcnn_R_50_C4_3x.yaml │ │ ├── mask_rcnn_R_50_DC5_1x.yaml │ │ ├── mask_rcnn_R_50_DC5_3x.yaml │ │ ├── mask_rcnn_R_50_FPN_1x.py │ │ ├── mask_rcnn_R_50_FPN_1x.yaml │ │ ├── mask_rcnn_R_50_FPN_1x_giou.yaml │ │ ├── mask_rcnn_R_50_FPN_3x.yaml │ │ ├── mask_rcnn_X_101_32x8d_FPN_3x.yaml │ │ ├── mask_rcnn_regnetx_4gf_dds_fpn_1x.py │ │ └── mask_rcnn_regnety_4gf_dds_fpn_1x.py │ ├── COCO-Keypoints │ │ ├── Base-Keypoint-RCNN-FPN.yaml │ │ ├── keypoint_rcnn_R_101_FPN_3x.yaml │ │ ├── keypoint_rcnn_R_50_FPN_1x.py │ │ ├── keypoint_rcnn_R_50_FPN_1x.yaml │ │ ├── keypoint_rcnn_R_50_FPN_3x.yaml │ │ └── keypoint_rcnn_X_101_32x8d_FPN_3x.yaml │ ├── COCO-PanopticSegmentation │ │ ├── Base-Panoptic-FPN.yaml │ │ ├── panoptic_fpn_R_101_3x.yaml │ │ ├── panoptic_fpn_R_50_1x.py │ │ ├── panoptic_fpn_R_50_1x.yaml │ │ └── panoptic_fpn_R_50_3x.yaml │ ├── Cityscapes │ │ └── mask_rcnn_R_50_FPN.yaml │ ├── Detectron1-Comparisons │ │ ├── README.md │ │ ├── faster_rcnn_R_50_FPN_noaug_1x.yaml │ │ ├── keypoint_rcnn_R_50_FPN_1x.yaml │ │ └── mask_rcnn_R_50_FPN_noaug_1x.yaml │ ├── LVISv0.5-InstanceSegmentation │ │ ├── mask_rcnn_R_101_FPN_1x.yaml │ │ ├── mask_rcnn_R_50_FPN_1x.yaml │ │ └── mask_rcnn_X_101_32x8d_FPN_1x.yaml │ ├── LVISv1-InstanceSegmentation │ │ ├── mask_rcnn_R_101_FPN_1x.yaml │ │ ├── mask_rcnn_R_50_FPN_1x.yaml │ │ └── mask_rcnn_X_101_32x8d_FPN_1x.yaml │ ├── Misc │ │ ├── cascade_mask_rcnn_R_50_FPN_1x.yaml │ │ ├── cascade_mask_rcnn_R_50_FPN_3x.yaml │ │ ├── cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv.yaml │ │ ├── mask_rcnn_R_50_FPN_1x_cls_agnostic.yaml │ │ ├── mask_rcnn_R_50_FPN_1x_dconv_c3-c5.yaml │ │ ├── mask_rcnn_R_50_FPN_3x_dconv_c3-c5.yaml │ │ ├── mask_rcnn_R_50_FPN_3x_gn.yaml │ │ ├── mask_rcnn_R_50_FPN_3x_syncbn.yaml │ │ ├── mmdet_mask_rcnn_R_50_FPN_1x.py │ │ ├── panoptic_fpn_R_101_dconv_cascade_gn_3x.yaml │ │ ├── scratch_mask_rcnn_R_50_FPN_3x_gn.yaml │ │ ├── scratch_mask_rcnn_R_50_FPN_9x_gn.yaml │ │ ├── scratch_mask_rcnn_R_50_FPN_9x_syncbn.yaml │ │ ├── semantic_R_50_FPN_1x.yaml │ │ └── torchvision_imagenet_R_50.py │ ├── PascalVOC-Detection │ │ ├── faster_rcnn_R_50_C4.yaml │ │ └── faster_rcnn_R_50_FPN.yaml │ ├── common │ │ ├── README.md │ │ ├── coco_schedule.py │ │ ├── data │ │ │ ├── coco.py │ │ │ ├── coco_keypoint.py │ │ │ └── coco_panoptic_separated.py │ │ ├── models │ │ │ ├── cascade_rcnn.py │ │ │ ├── fcos.py │ │ │ ├── keypoint_rcnn_fpn.py │ │ │ ├── mask_rcnn_c4.py │ │ │ ├── mask_rcnn_fpn.py │ │ │ ├── panoptic_fpn.py │ │ │ └── retinanet.py │ │ ├── optim.py │ │ └── train.py │ ├── new_baselines │ │ ├── mask_rcnn_R_101_FPN_100ep_LSJ.py │ │ ├── mask_rcnn_R_101_FPN_200ep_LSJ.py │ │ ├── mask_rcnn_R_101_FPN_400ep_LSJ.py │ │ ├── mask_rcnn_R_50_FPN_100ep_LSJ.py │ │ ├── mask_rcnn_R_50_FPN_200ep_LSJ.py │ │ ├── mask_rcnn_R_50_FPN_400ep_LSJ.py │ │ ├── mask_rcnn_R_50_FPN_50ep_LSJ.py │ │ ├── mask_rcnn_regnetx_4gf_dds_FPN_100ep_LSJ.py │ │ ├── mask_rcnn_regnetx_4gf_dds_FPN_200ep_LSJ.py │ │ ├── mask_rcnn_regnetx_4gf_dds_FPN_400ep_LSJ.py │ │ ├── mask_rcnn_regnety_4gf_dds_FPN_100ep_LSJ.py │ │ ├── mask_rcnn_regnety_4gf_dds_FPN_200ep_LSJ.py │ │ └── mask_rcnn_regnety_4gf_dds_FPN_400ep_LSJ.py │ └── quick_schedules │ │ ├── README.md │ │ ├── cascade_mask_rcnn_R_50_FPN_inference_acc_test.yaml │ │ ├── cascade_mask_rcnn_R_50_FPN_instant_test.yaml │ │ ├── fast_rcnn_R_50_FPN_inference_acc_test.yaml │ │ ├── fast_rcnn_R_50_FPN_instant_test.yaml │ │ ├── keypoint_rcnn_R_50_FPN_inference_acc_test.yaml │ │ ├── keypoint_rcnn_R_50_FPN_instant_test.yaml │ │ ├── keypoint_rcnn_R_50_FPN_normalized_training_acc_test.yaml │ │ ├── keypoint_rcnn_R_50_FPN_training_acc_test.yaml │ │ ├── mask_rcnn_R_50_C4_GCV_instant_test.yaml │ │ ├── mask_rcnn_R_50_C4_inference_acc_test.yaml │ │ ├── mask_rcnn_R_50_C4_instant_test.yaml │ │ ├── mask_rcnn_R_50_C4_training_acc_test.yaml │ │ ├── mask_rcnn_R_50_DC5_inference_acc_test.yaml │ │ ├── mask_rcnn_R_50_FPN_inference_acc_test.yaml │ │ ├── mask_rcnn_R_50_FPN_instant_test.yaml │ │ ├── mask_rcnn_R_50_FPN_pred_boxes_training_acc_test.yaml │ │ ├── mask_rcnn_R_50_FPN_training_acc_test.yaml │ │ ├── panoptic_fpn_R_50_inference_acc_test.yaml │ │ ├── panoptic_fpn_R_50_instant_test.yaml │ │ ├── panoptic_fpn_R_50_training_acc_test.yaml │ │ ├── retinanet_R_50_FPN_inference_acc_test.yaml │ │ ├── retinanet_R_50_FPN_instant_test.yaml │ │ ├── rpn_R_50_FPN_inference_acc_test.yaml │ │ ├── rpn_R_50_FPN_instant_test.yaml │ │ ├── semantic_R_50_FPN_inference_acc_test.yaml │ │ ├── semantic_R_50_FPN_instant_test.yaml │ │ └── semantic_R_50_FPN_training_acc_test.yaml │ ├── datasets │ ├── README.md │ ├── lvis │ │ └── lvis_v1_train_cat_info.json │ ├── prepare_ade20k_sem_seg.py │ ├── prepare_cocofied_lvis.py │ ├── prepare_for_tests.sh │ └── prepare_panoptic_fpn.py │ ├── demo │ ├── README.md │ ├── demo.py │ └── predictor.py │ ├── detectron2 │ ├── __init__.py │ ├── checkpoint │ │ ├── __init__.py │ │ ├── c2_model_loading.py │ │ ├── catalog.py │ │ └── detection_checkpoint.py │ ├── config │ │ ├── __init__.py │ │ ├── compat.py │ │ ├── config.py │ │ ├── defaults.py │ │ ├── instantiate.py │ │ └── lazy.py │ ├── data │ │ ├── __init__.py │ │ ├── benchmark.py │ │ ├── build.py │ │ ├── catalog.py │ │ ├── common.py │ │ ├── dataset_mapper.py │ │ ├── datasets │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── builtin.py │ │ │ ├── builtin_meta.py │ │ │ ├── cityscapes.py │ │ │ ├── cityscapes_panoptic.py │ │ │ ├── coco.py │ │ │ ├── coco_panoptic.py │ │ │ ├── lvis.py │ │ │ ├── lvis_v0_5_categories.py │ │ │ ├── lvis_v1_categories.py │ │ │ ├── pascal_voc.py │ │ │ └── register_coco.py │ │ ├── detection_utils.py │ │ ├── samplers │ │ │ ├── __init__.py │ │ │ ├── distributed_sampler.py │ │ │ └── grouped_batch_sampler.py │ │ └── transforms │ │ │ ├── __init__.py │ │ │ ├── augmentation.py │ │ │ ├── augmentation_impl.py │ │ │ └── transform.py │ ├── engine │ │ ├── __init__.py │ │ ├── defaults.py │ │ ├── hooks.py │ │ ├── launch.py │ │ └── train_loop.py │ ├── evaluation │ │ ├── __init__.py │ │ ├── cityscapes_evaluation.py │ │ ├── coco_evaluation.py │ │ ├── evaluator.py │ │ ├── fast_eval_api.py │ │ ├── lvis_evaluation.py │ │ ├── panoptic_evaluation.py │ │ ├── pascal_voc_evaluation.py │ │ ├── rotated_coco_evaluation.py │ │ ├── sem_seg_evaluation.py │ │ └── testing.py │ ├── export │ │ ├── README.md │ │ ├── __init__.py │ │ ├── api.py │ │ ├── c10.py │ │ ├── caffe2_export.py │ │ ├── caffe2_inference.py │ │ ├── caffe2_modeling.py │ │ ├── caffe2_patch.py │ │ ├── flatten.py │ │ ├── shared.py │ │ ├── torchscript.py │ │ └── torchscript_patch.py │ ├── layers │ │ ├── __init__.py │ │ ├── aspp.py │ │ ├── batch_norm.py │ │ ├── blocks.py │ │ ├── csrc │ │ │ ├── README.md │ │ │ ├── ROIAlignRotated │ │ │ │ ├── ROIAlignRotated.h │ │ │ │ ├── ROIAlignRotated_cpu.cpp │ │ │ │ └── ROIAlignRotated_cuda.cu │ │ │ ├── box_iou_rotated │ │ │ │ ├── box_iou_rotated.h │ │ │ │ ├── box_iou_rotated_cpu.cpp │ │ │ │ ├── box_iou_rotated_cuda.cu │ │ │ │ └── box_iou_rotated_utils.h │ │ │ ├── cocoeval │ │ │ │ ├── cocoeval.cpp │ │ │ │ └── cocoeval.h │ │ │ ├── cuda_version.cu │ │ │ ├── deformable │ │ │ │ ├── deform_conv.h │ │ │ │ ├── deform_conv_cuda.cu │ │ │ │ └── deform_conv_cuda_kernel.cu │ │ │ ├── nms_rotated │ │ │ │ ├── nms_rotated.h │ │ │ │ ├── nms_rotated_cpu.cpp │ │ │ │ └── nms_rotated_cuda.cu │ │ │ └── vision.cpp │ │ ├── deform_conv.py │ │ ├── losses.py │ │ ├── mask_ops.py │ │ ├── nms.py │ │ ├── roi_align.py │ │ ├── roi_align_rotated.py │ │ ├── rotated_boxes.py │ │ ├── shape_spec.py │ │ └── wrappers.py │ ├── model_zoo │ │ ├── __init__.py │ │ └── model_zoo.py │ ├── modeling │ │ ├── __init__.py │ │ ├── anchor_generator.py │ │ ├── backbone │ │ │ ├── __init__.py │ │ │ ├── backbone.py │ │ │ ├── build.py │ │ │ ├── fpn.py │ │ │ ├── regnet.py │ │ │ └── resnet.py │ │ ├── box_regression.py │ │ ├── matcher.py │ │ ├── meta_arch │ │ │ ├── __init__.py │ │ │ ├── build.py │ │ │ ├── dense_detector.py │ │ │ ├── fcos.py │ │ │ ├── panoptic_fpn.py │ │ │ ├── rcnn.py │ │ │ ├── retinanet.py │ │ │ └── semantic_seg.py │ │ ├── mmdet_wrapper.py │ │ ├── poolers.py │ │ ├── postprocessing.py │ │ ├── proposal_generator │ │ │ ├── __init__.py │ │ │ ├── build.py │ │ │ ├── proposal_utils.py │ │ │ ├── rpn.py │ │ │ └── rrpn.py │ │ ├── roi_heads │ │ │ ├── __init__.py │ │ │ ├── box_head.py │ │ │ ├── cascade_rcnn.py │ │ │ ├── fast_rcnn.py │ │ │ ├── keypoint_head.py │ │ │ ├── mask_head.py │ │ │ ├── roi_heads.py │ │ │ └── rotated_fast_rcnn.py │ │ ├── sampling.py │ │ └── test_time_augmentation.py │ ├── projects │ │ ├── README.md │ │ └── __init__.py │ ├── solver │ │ ├── __init__.py │ │ ├── build.py │ │ └── lr_scheduler.py │ ├── structures │ │ ├── __init__.py │ │ ├── boxes.py │ │ ├── image_list.py │ │ ├── instances.py │ │ ├── keypoints.py │ │ ├── masks.py │ │ └── rotated_boxes.py │ └── utils │ │ ├── README.md │ │ ├── __init__.py │ │ ├── analysis.py │ │ ├── collect_env.py │ │ ├── colormap.py │ │ ├── comm.py │ │ ├── env.py │ │ ├── events.py │ │ ├── file_io.py │ │ ├── logger.py │ │ ├── memory.py │ │ ├── registry.py │ │ ├── serialize.py │ │ ├── testing.py │ │ ├── video_visualizer.py │ │ └── visualizer.py │ ├── dev │ ├── README.md │ ├── linter.sh │ ├── packaging │ │ ├── README.md │ │ ├── build_all_wheels.sh │ │ ├── build_wheel.sh │ │ ├── gen_install_table.py │ │ ├── gen_wheel_index.sh │ │ └── pkg_helpers.bash │ ├── parse_results.sh │ ├── run_inference_tests.sh │ └── run_instant_tests.sh │ ├── docker │ ├── Dockerfile │ ├── README.md │ ├── deploy.Dockerfile │ └── docker-compose.yml │ ├── docs │ ├── .gitignore │ ├── Makefile │ ├── README.md │ ├── _static │ │ └── css │ │ │ └── custom.css │ ├── conf.py │ ├── index.rst │ ├── modules │ │ ├── checkpoint.rst │ │ ├── config.rst │ │ ├── data.rst │ │ ├── data_transforms.rst │ │ ├── engine.rst │ │ ├── evaluation.rst │ │ ├── export.rst │ │ ├── fvcore.rst │ │ ├── index.rst │ │ ├── layers.rst │ │ ├── model_zoo.rst │ │ ├── modeling.rst │ │ ├── solver.rst │ │ ├── structures.rst │ │ └── utils.rst │ ├── notes │ │ ├── benchmarks.md │ │ ├── changelog.md │ │ ├── compatibility.md │ │ ├── contributing.md │ │ └── index.rst │ ├── requirements.txt │ └── tutorials │ │ ├── README.md │ │ ├── augmentation.md │ │ ├── builtin_datasets.md │ │ ├── configs.md │ │ ├── data_loading.md │ │ ├── datasets.md │ │ ├── deployment.md │ │ ├── evaluation.md │ │ ├── extend.md │ │ ├── getting_started.md │ │ ├── index.rst │ │ ├── install.md │ │ ├── lazyconfigs.md │ │ ├── models.md │ │ ├── training.md │ │ └── write-models.md │ ├── projects │ └── CenterNet2 │ │ ├── .gitignore │ │ ├── centernet │ │ ├── __init__.py │ │ ├── config.py │ │ ├── data │ │ │ ├── custom_build_augmentation.py │ │ │ ├── custom_dataset_dataloader.py │ │ │ ├── datasets │ │ │ │ ├── coco.py │ │ │ │ ├── nuimages.py │ │ │ │ └── objects365.py │ │ │ └── transforms │ │ │ │ ├── custom_augmentation_impl.py │ │ │ │ └── custom_transform.py │ │ └── modeling │ │ │ ├── backbone │ │ │ ├── bifpn.py │ │ │ ├── bifpn_fcos.py │ │ │ ├── dla.py │ │ │ ├── dlafpn.py │ │ │ ├── fpn_p5.py │ │ │ └── res2net.py │ │ │ ├── debug.py │ │ │ ├── dense_heads │ │ │ ├── centernet.py │ │ │ ├── centernet_head.py │ │ │ └── utils.py │ │ │ ├── layers │ │ │ ├── deform_conv.py │ │ │ ├── heatmap_focal_loss.py │ │ │ ├── iou_loss.py │ │ │ └── ml_nms.py │ │ │ ├── meta_arch │ │ │ └── centernet_detector.py │ │ │ └── roi_heads │ │ │ ├── custom_fast_rcnn.py │ │ │ ├── custom_roi_heads.py │ │ │ └── fed_loss.py │ │ ├── centernet2_docs │ │ └── MODEL_ZOO.md │ │ ├── configs │ │ ├── Base-CenterNet-FPN.yaml │ │ ├── Base-CenterNet2.yaml │ │ ├── Base_S4_DLA.yaml │ │ ├── CenterNet-FPN_R50_1x.yaml │ │ ├── CenterNet-S4_DLA_8x.yaml │ │ ├── CenterNet2-F_R50_1x.yaml │ │ ├── CenterNet2_DLA-BiFPN-P3_24x.yaml │ │ ├── CenterNet2_DLA-BiFPN-P3_4x.yaml │ │ ├── CenterNet2_DLA-BiFPN-P5_640_16x.yaml │ │ ├── CenterNet2_DLA-BiFPN-P5_640_16x_ST.yaml │ │ ├── CenterNet2_DLA-fcosBiFPN-P5_640_16x_ST.yaml │ │ ├── CenterNet2_R2-101-DCN-BiFPN_1280_4x.yaml │ │ ├── CenterNet2_R2-101-DCN-BiFPN_4x+4x_1560_ST.yaml │ │ ├── CenterNet2_R2-101-DCN_896_4x.yaml │ │ ├── CenterNet2_R50_1x.yaml │ │ ├── CenterNet2_X101-DCN_2x.yaml │ │ ├── LVIS_CenterNet2_R50_1x.yaml │ │ ├── LVIS_CenterNet2_R50_Fed_1x.yaml │ │ ├── O365_CenterNet2_R50_1x.yaml │ │ └── nuImages_CenterNet2_DLA_640_8x.yaml │ │ ├── demo.py │ │ ├── predictor.py │ │ └── train_net.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ ├── README.md │ ├── __init__.py │ ├── config │ │ ├── dir1 │ │ │ ├── dir1_a.py │ │ │ └── dir1_b.py │ │ ├── root_cfg.py │ │ ├── test_instantiate_config.py │ │ ├── test_lazy_config.py │ │ └── test_yacs_config.py │ ├── data │ │ ├── __init__.py │ │ ├── test_coco.py │ │ ├── test_coco_evaluation.py │ │ ├── test_dataset.py │ │ ├── test_detection_utils.py │ │ ├── test_rotation_transform.py │ │ ├── test_sampler.py │ │ └── test_transforms.py │ ├── layers │ │ ├── __init__.py │ │ ├── test_blocks.py │ │ ├── test_deformable.py │ │ ├── test_losses.py │ │ ├── test_mask_ops.py │ │ ├── test_nms.py │ │ ├── test_nms_rotated.py │ │ ├── test_roi_align.py │ │ └── test_roi_align_rotated.py │ ├── modeling │ │ ├── __init__.py │ │ ├── test_anchor_generator.py │ │ ├── test_backbone.py │ │ ├── test_box2box_transform.py │ │ ├── test_fast_rcnn.py │ │ ├── test_matcher.py │ │ ├── test_mmdet.py │ │ ├── test_model_e2e.py │ │ ├── test_roi_heads.py │ │ ├── test_roi_pooler.py │ │ └── test_rpn.py │ ├── structures │ │ ├── __init__.py │ │ ├── test_boxes.py │ │ ├── test_imagelist.py │ │ ├── test_instances.py │ │ ├── test_keypoints.py │ │ ├── test_masks.py │ │ └── test_rotated_boxes.py │ ├── test_checkpoint.py │ ├── test_engine.py │ ├── test_events.py │ ├── test_export_caffe2.py │ ├── test_export_torchscript.py │ ├── test_model_analysis.py │ ├── test_model_zoo.py │ ├── test_packaging.py │ ├── test_registry.py │ ├── test_scheduler.py │ ├── test_solver.py │ └── test_visualizer.py │ └── tools │ ├── README.md │ ├── __init__.py │ ├── analyze_model.py │ ├── benchmark.py │ ├── convert-torchvision-to-d2.py │ ├── deploy │ ├── CMakeLists.txt │ ├── README.md │ ├── export_model.py │ └── torchscript_mask_rcnn.cpp │ ├── lazyconfig_train_net.py │ ├── lightning_train_net.py │ ├── plain_train_net.py │ ├── train_net.py │ ├── visualize_data.py │ └── visualize_json_results.py ├── train_deepspeed.py └── train_net.py /.gitignore: -------------------------------------------------------------------------------- 1 | third_party/detectron2 2 | ./models 3 | configs-experimental 4 | experiments 5 | # output dir 6 | index.html 7 | data/* 8 | slurm/ 9 | slurm 10 | slurm-output 11 | slurm-output/ 12 | output 13 | instant_test_output 14 | inference_test_output 15 | ./aux_data 16 | train.sh 17 | install.sh 18 | 19 | 20 | *.diff 21 | 22 | # compilation and distribution 23 | __pycache__ 24 | _ext 25 | *.pyc 26 | *.pyd 27 | *.so 28 | *.dll 29 | *.egg-info/ 30 | build/ 31 | dist/ 32 | wheels/ 33 | 34 | # pytorch/python/numpy formats 35 | *.pth 36 | *.pkl 37 | *.ts 38 | model_ts*.txt 39 | 40 | # ipython/jupyter notebooks 41 | *.ipynb 42 | **/.ipynb_checkpoints/ 43 | 44 | # Editor temporaries 45 | *.swn 46 | *.swo 47 | *.swp 48 | *~ 49 | 50 | # editor settings 51 | .idea 52 | .vscode 53 | _darcs 54 | 55 | # project dirs 56 | /detectron2/model_zoo/configs 57 | /datasets/* 58 | !/datasets/*.* 59 | !/datasets/metadata 60 | /projects/*/datasets 61 | /models 62 | /snippet 63 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "third_party/CenterNet2"] 2 | path = third_party/CenterNet2 3 | url = https://github.com/xingyizhou/CenterNet2.git 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Microsoft Corporation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /configs/GRiT_B_DenseCap.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base.yaml" 2 | MODEL: 3 | TRAIN_TASK: ["DenseCap"] 4 | TEST_TASK: "DenseCap" 5 | MASK_ON: False 6 | ROI_HEADS: 7 | SOFT_NMS_ENABLED: False 8 | BEAM_SIZE: 1 9 | WEIGHTS: "detectron2://ImageNetPretrained/MAE/mae_pretrain_vit_base.pth" 10 | BACKBONE: 11 | NAME: build_vit_fpn_backbone 12 | VIT_LAYERS: 12 13 | SOLVER: 14 | VIT_LAYER_DECAY_RATE: 0.7 15 | DATASETS: 16 | TRAIN: ("vg_train",) 17 | TEST: ("vg_test",) 18 | DATALOADER: 19 | DATASET_BS: 2 20 | OUTPUT_DIR: "./output/GRiT_B_DenseCap" -------------------------------------------------------------------------------- /configs/GRiT_B_DenseCap_ObjectDet.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base.yaml" 2 | MODEL: 3 | TRAIN_TASK: ["ObjectDet", "DenseCap"] 4 | TEST_TASK: "DenseCap" # DenseCap or ObjectDet: Choose one for testing 5 | MASK_ON: True 6 | ROI_HEADS: 7 | SOFT_NMS_ENABLED: False 8 | BEAM_SIZE: 1 9 | WEIGHTS: "detectron2://ImageNetPretrained/MAE/mae_pretrain_vit_base.pth" 10 | BACKBONE: 11 | NAME: build_vit_fpn_backbone 12 | VIT_LAYERS: 12 13 | SOLVER: 14 | VIT_LAYER_DECAY_RATE: 0.7 15 | DATASETS: 16 | TRAIN: ("GRiT_coco2017_train", "vg_train") 17 | TEST: ("coco_2017_test-dev",) 18 | DATALOADER: 19 | DATASET_RATIO: [1, 1] 20 | DATASET_BS: 2 21 | DATASET_INPUT_SIZE: [1024, 1024] 22 | DATASET_INPUT_SCALE: [[0.1, 2.0], [0.1, 2.0]] 23 | OUTPUT_DIR: "./output/GRiT_B_DenseCap_ObjectDet" -------------------------------------------------------------------------------- /configs/GRiT_B_ObjectDet.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base.yaml" 2 | MODEL: 3 | TRAIN_TASK: ["ObjectDet"] 4 | TEST_TASK: "ObjectDet" 5 | MASK_ON: True 6 | ROI_HEADS: 7 | SOFT_NMS_ENABLED: True 8 | BEAM_SIZE: 3 9 | WEIGHTS: "detectron2://ImageNetPretrained/MAE/mae_pretrain_vit_base.pth" 10 | BACKBONE: 11 | NAME: build_vit_fpn_backbone 12 | VIT_LAYERS: 12 13 | SOLVER: 14 | VIT_LAYER_DECAY_RATE: 0.7 15 | DATASETS: 16 | TRAIN: ("GRiT_coco2017_train",) 17 | TEST: ("coco_2017_val",) 18 | DATALOADER: 19 | DATASET_BS: 2 20 | OUTPUT_DIR: "./output/GRiT_B_ObjectDet" -------------------------------------------------------------------------------- /configs/GRiT_H_ObjectDet.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base.yaml" 2 | MODEL: 3 | TRAIN_TASK: ["ObjectDet"] 4 | TEST_TASK: "ObjectDet" 5 | MASK_ON: True 6 | ROI_HEADS: 7 | SOFT_NMS_ENABLED: True 8 | BEAM_SIZE: 3 9 | WEIGHTS: "detectron2://ImageNetPretrained/MAE/mae_pretrain_vit_huge_p14to16.pth" 10 | BACKBONE: 11 | NAME: build_vit_fpn_backbone_huge 12 | VIT_LAYERS: 32 13 | SOLVER: 14 | MAX_ITER: 135000 15 | VIT_LAYER_DECAY_RATE: 0.9 16 | DATASETS: 17 | TRAIN: ("GRiT_coco2017_train",) 18 | TEST: ("coco_2017_val",) 19 | DATALOADER: 20 | DATASET_BS: 1 21 | OUTPUT_DIR: "./output/GRiT_H_ObjectDet" -------------------------------------------------------------------------------- /configs/GRiT_L_ObjectDet.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base.yaml" 2 | MODEL: 3 | TRAIN_TASK: ["ObjectDet"] 4 | TEST_TASK: "ObjectDet" 5 | MASK_ON: True 6 | ROI_HEADS: 7 | SOFT_NMS_ENABLED: True 8 | BEAM_SIZE: 3 9 | WEIGHTS: "detectron2://ImageNetPretrained/MAE/mae_pretrain_vit_large.pth" 10 | BACKBONE: 11 | NAME: build_vit_fpn_backbone_large 12 | VIT_LAYERS: 24 13 | SOLVER: 14 | VIT_LAYER_DECAY_RATE: 0.8 15 | DATASETS: 16 | TRAIN: ("GRiT_coco2017_train",) 17 | TEST: ("coco_2017_val",) 18 | DATALOADER: 19 | DATASET_BS: 1 20 | OUTPUT_DIR: "./output/GRiT_L_ObjectDet" -------------------------------------------------------------------------------- /demo_images/000000353174.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JialianW/GRiT/39b33dbc0900e4be0458af14597fcb1a82d933bb/demo_images/000000353174.jpg -------------------------------------------------------------------------------- /demo_images/000000438652.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JialianW/GRiT/39b33dbc0900e4be0458af14597fcb1a82d933bb/demo_images/000000438652.jpg -------------------------------------------------------------------------------- /demo_images/000000453583.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JialianW/GRiT/39b33dbc0900e4be0458af14597fcb1a82d933bb/demo_images/000000453583.jpg -------------------------------------------------------------------------------- /demo_images/000000466185.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JialianW/GRiT/39b33dbc0900e4be0458af14597fcb1a82d933bb/demo_images/000000466185.jpg -------------------------------------------------------------------------------- /demo_images/000000497110.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JialianW/GRiT/39b33dbc0900e4be0458af14597fcb1a82d933bb/demo_images/000000497110.jpg -------------------------------------------------------------------------------- /demo_images/000000497861.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JialianW/GRiT/39b33dbc0900e4be0458af14597fcb1a82d933bb/demo_images/000000497861.jpg -------------------------------------------------------------------------------- /demo_images/000000546072.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JialianW/GRiT/39b33dbc0900e4be0458af14597fcb1a82d933bb/demo_images/000000546072.jpg -------------------------------------------------------------------------------- /docs/INSTALL.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | Our experiments are based on Python 3.8, PyTorch 1.9.0, and CUDA 11.1. 4 | Newer version of PyTorch may also work. 5 | 6 | ### Installation Outline 7 | 8 | - Download and install Pytorch 9 | - Download and install Detectron2. We use the version at the commit ID cc87e7ec 10 | - Download and install GRiT 11 | 12 | ### Installation Example 13 | ```bash 14 | conda create --name grit python=3.8 -y 15 | conda activate grit 16 | pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html 17 | 18 | git clone https://github.com/facebookresearch/detectron2.git 19 | cd detectron2 20 | git checkout cc87e7ec 21 | pip install -e . 22 | 23 | cd .. 24 | git clone https://github.com/JialianW/GRiT.git 25 | cd GRiT 26 | pip install -r requirements.txt 27 | ``` -------------------------------------------------------------------------------- /docs/chatgpt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JialianW/GRiT/39b33dbc0900e4be0458af14597fcb1a82d933bb/docs/chatgpt.png -------------------------------------------------------------------------------- /docs/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JialianW/GRiT/39b33dbc0900e4be0458af14597fcb1a82d933bb/docs/demo.png -------------------------------------------------------------------------------- /docs/grit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JialianW/GRiT/39b33dbc0900e4be0458af14597fcb1a82d933bb/docs/grit.png -------------------------------------------------------------------------------- /grit/__init__.py: -------------------------------------------------------------------------------- 1 | from .modeling.meta_arch import grit 2 | from .modeling.roi_heads import grit_roi_heads 3 | from .modeling.backbone import vit 4 | 5 | from .data.datasets import object365 6 | from .data.datasets import vg 7 | from .data.datasets import grit_coco -------------------------------------------------------------------------------- /grit/config.py: -------------------------------------------------------------------------------- 1 | from detectron2.config import CfgNode as CN 2 | 3 | 4 | def add_grit_config(cfg): 5 | _C = cfg 6 | 7 | _C.MODEL.BEAM_SIZE = 1 8 | _C.MODEL.TRAIN_TASK = ["ObjectDet", "DenseCap"] 9 | _C.MODEL.TEST_TASK = "DenseCap" # This can be varied if the model is jointly trained on multiple tasks 10 | 11 | _C.MODEL.ROI_BOX_HEAD.USE_BIAS = 0.0 # >= 0: not use 12 | _C.MODEL.ROI_BOX_HEAD.MULT_PROPOSAL_SCORE = False 13 | 14 | _C.MODEL.ROI_HEADS.MASK_WEIGHT = 1.0 15 | _C.MODEL.ROI_HEADS.OBJECT_FEAT_POOLER_RES = 14 16 | _C.MODEL.ROI_HEADS.SOFT_NMS_ENABLED = False 17 | 18 | # Backbones 19 | _C.MODEL.VIT_LAYERS = 12 20 | 21 | # Text Decoder 22 | _C.TEXT_DECODER = CN() 23 | _C.TEXT_DECODER.VOCAB_SIZE = 30522 24 | _C.TEXT_DECODER.HIDDEN_SIZE = 768 25 | _C.TEXT_DECODER.NUM_LAYERS = 6 26 | _C.TEXT_DECODER.ATTENTION_HEADS = 12 27 | _C.TEXT_DECODER.FEEDFORWARD_SIZE = 768 * 4 28 | 29 | # Multi-dataset dataloader 30 | _C.DATALOADER.DATASET_RATIO = [1, 1] # sample ratio 31 | _C.DATALOADER.DATASET_BS = 1 32 | _C.DATALOADER.DATASET_INPUT_SIZE = [1024, 1024] 33 | _C.DATALOADER.DATASET_INPUT_SCALE = [(0.1, 2.0), (0.1, 2.0)] 34 | _C.DATALOADER.DATASET_MIN_SIZES = [(640, 800), (640, 800)] 35 | _C.DATALOADER.DATASET_MAX_SIZES = [1333, 1333] 36 | 37 | _C.SOLVER.USE_CUSTOM_SOLVER = True 38 | _C.SOLVER.OPTIMIZER = 'ADAMW' 39 | _C.SOLVER.VIT_LAYER_DECAY = True 40 | _C.SOLVER.VIT_LAYER_DECAY_RATE = 0.7 41 | 42 | _C.INPUT.CUSTOM_AUG = 'EfficientDetResizeCrop' 43 | _C.INPUT.TRAIN_SIZE = 1024 44 | _C.INPUT.TEST_SIZE = 1024 45 | _C.INPUT.SCALE_RANGE = (0.1, 2.) 46 | # 'default' for fixed short / long edge 47 | _C.INPUT.TEST_INPUT_TYPE = 'default' 48 | 49 | _C.FIND_UNUSED_PARAM = True 50 | _C.USE_ACT_CHECKPOINT = True -------------------------------------------------------------------------------- /grit/data/custom_build_augmentation.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from detectron2.data import transforms as T 3 | from .transforms.custom_augmentation_impl import EfficientDetResizeCrop 4 | 5 | 6 | def build_custom_augmentation(cfg, is_train, scale=None, size=None, \ 7 | min_size=None, max_size=None): 8 | """ 9 | Create a list of default :class:`Augmentation` from config. 10 | Now it includes resizing and flipping. 11 | 12 | Returns: 13 | list[Augmentation] 14 | """ 15 | if cfg.INPUT.CUSTOM_AUG == 'ResizeShortestEdge': 16 | if is_train: 17 | min_size = cfg.INPUT.MIN_SIZE_TRAIN if min_size is None else min_size 18 | max_size = cfg.INPUT.MAX_SIZE_TRAIN if max_size is None else max_size 19 | sample_style = cfg.INPUT.MIN_SIZE_TRAIN_SAMPLING 20 | else: 21 | min_size = cfg.INPUT.MIN_SIZE_TEST 22 | max_size = cfg.INPUT.MAX_SIZE_TEST 23 | sample_style = "choice" 24 | augmentation = [T.ResizeShortestEdge(min_size, max_size, sample_style)] 25 | elif cfg.INPUT.CUSTOM_AUG == 'EfficientDetResizeCrop': 26 | if is_train: 27 | scale = cfg.INPUT.SCALE_RANGE if scale is None else scale 28 | size = cfg.INPUT.TRAIN_SIZE if size is None else size 29 | else: 30 | scale = (1, 1) 31 | size = cfg.INPUT.TEST_SIZE 32 | augmentation = [EfficientDetResizeCrop(size, scale)] 33 | else: 34 | assert 0, cfg.INPUT.CUSTOM_AUG 35 | 36 | if is_train: 37 | augmentation.append(T.RandomFlip()) 38 | return augmentation 39 | 40 | 41 | build_custom_transform_gen = build_custom_augmentation 42 | """ 43 | Alias for backward-compatibility. 44 | """ -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | opencv-python==4.5.5.64 2 | mss 3 | timm==0.6.7 4 | dataclasses 5 | ftfy 6 | regex 7 | fasttext 8 | scikit-learn 9 | lvis 10 | nltk 11 | tqdm 12 | matplotlib 13 | requests 14 | anytree 15 | boto3 16 | scikit-image 17 | pyyaml 18 | inflect 19 | protobuf==3.19.4 20 | einops==0.4.1 21 | transformers==4.21.1 22 | deepspeed==0.7.0 23 | -------------------------------------------------------------------------------- /third_party/CenterNet2/.flake8: -------------------------------------------------------------------------------- 1 | # This is an example .flake8 config, used when developing *Black* itself. 2 | # Keep in sync with setup.cfg which is used for source packages. 3 | 4 | [flake8] 5 | ignore = W503, E203, E221, C901, C408, E741, C407, B017 6 | max-line-length = 100 7 | max-complexity = 18 8 | select = B,C,E,F,W,T4,B9 9 | exclude = build 10 | per-file-ignores = 11 | **/__init__.py:F401,F403,E402 12 | **/configs/**.py:F401,E402 13 | configs/**.py:F401,E402 14 | **/tests/config/**.py:F401,E402 15 | tests/config/**.py:F401,E402 16 | -------------------------------------------------------------------------------- /third_party/CenterNet2/.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | Facebook has adopted a Code of Conduct that we expect project participants to adhere to. 4 | Please read the [full text](https://code.fb.com/codeofconduct/) 5 | so that you can understand what actions will and will not be tolerated. 6 | -------------------------------------------------------------------------------- /third_party/CenterNet2/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | Please select an issue template from 3 | https://github.com/facebookresearch/detectron2/issues/new/choose . 4 | 5 | Otherwise your issue will be closed. 6 | -------------------------------------------------------------------------------- /third_party/CenterNet2/.github/ISSUE_TEMPLATE/bugs.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "🐛 Bugs" 3 | about: Report bugs in detectron2 4 | title: Please read & provide the following 5 | 6 | --- 7 | 8 | ## Instructions To Reproduce the 🐛 Bug: 9 | 1. Full runnable code or full changes you made: 10 | ``` 11 | If making changes to the project itself, please use output of the following command: 12 | git rev-parse HEAD; git diff 13 | 14 | 15 | ``` 16 | 2. What exact command you run: 17 | 3. __Full logs__ or other relevant observations: 18 | ``` 19 | 20 | ``` 21 | 4. please simplify the steps as much as possible so they do not require additional resources to 22 | run, such as a private dataset. 23 | 24 | ## Expected behavior: 25 | 26 | If there are no obvious error in "full logs" provided above, 27 | please tell us the expected behavior. 28 | 29 | ## Environment: 30 | 31 | Provide your environment information using the following command: 32 | ``` 33 | wget -nc -q https://github.com/facebookresearch/detectron2/raw/main/detectron2/utils/collect_env.py && python collect_env.py 34 | ``` 35 | 36 | If your issue looks like an installation issue / environment issue, 37 | please first try to solve it yourself with the instructions in 38 | https://detectron2.readthedocs.io/tutorials/install.html#common-installation-issues 39 | -------------------------------------------------------------------------------- /third_party/CenterNet2/.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | # require an issue template to be chosen 2 | blank_issues_enabled: false 3 | 4 | contact_links: 5 | - name: How-To / All Other Questions 6 | url: https://github.com/facebookresearch/detectron2/discussions 7 | about: Use "github discussions" for community support on general questions that don't belong to the above issue categories 8 | - name: Detectron2 Documentation 9 | url: https://detectron2.readthedocs.io/index.html 10 | about: Check if your question is answered in tutorials or API docs 11 | 12 | # Unexpected behaviors & bugs are split to two templates. 13 | # When they are one template, users think "it's not a bug" and don't choose the template. 14 | # 15 | # But the file name is still "unexpected-problems-bugs.md" so that old references 16 | # to this issue template still works. 17 | # It's ok since this template should be a superset of "bugs.md" (unexpected behaviors is a superset of bugs) 18 | -------------------------------------------------------------------------------- /third_party/CenterNet2/.github/ISSUE_TEMPLATE/documentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F4DA Documentation Issue" 3 | about: Report a problem about existing documentation, comments, website or tutorials. 4 | labels: documentation 5 | 6 | --- 7 | 8 | ## 📚 Documentation Issue 9 | 10 | This issue category is for problems about existing documentation, not for asking how-to questions. 11 | 12 | * Provide a link to an existing documentation/comment/tutorial: 13 | 14 | * How should the above documentation/comment/tutorial improve: 15 | -------------------------------------------------------------------------------- /third_party/CenterNet2/.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F680Feature Request" 3 | about: Suggest an improvement or new feature 4 | labels: enhancement 5 | 6 | --- 7 | 8 | ## 🚀 Feature 9 | A clear and concise description of the feature proposal. 10 | 11 | ## Motivation & Examples 12 | 13 | Tell us why the feature is useful. 14 | 15 | Describe what the feature would look like, if it is implemented. 16 | Best demonstrated using **code examples** in addition to words. 17 | 18 | ## Note 19 | 20 | We only consider adding new features if they are relevant to many users. 21 | 22 | If you request implementation of research papers -- we only consider papers that have enough significance and prevalance in the object detection field. 23 | 24 | We do not take requests for most projects in the `projects/` directory, because they are research code release that is mainly for other researchers to reproduce results. 25 | 26 | "Make X faster/accurate" is not a valid feature request. "Implement a concrete feature that can make X faster/accurate" can be a valid feature request. 27 | 28 | Instead of adding features inside detectron2, 29 | you can implement many features by [extending detectron2](https://detectron2.readthedocs.io/tutorials/extend.html). 30 | The [projects/](https://github.com/facebookresearch/detectron2/tree/main/projects/) directory contains many of such examples. 31 | 32 | -------------------------------------------------------------------------------- /third_party/CenterNet2/.github/ISSUE_TEMPLATE/unexpected-problems-bugs.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "😩 Unexpected behaviors" 3 | about: Report unexpected behaviors when using detectron2 4 | title: Please read & provide the following 5 | 6 | --- 7 | 8 | If you do not know the root cause of the problem, please post according to this template: 9 | 10 | ## Instructions To Reproduce the Issue: 11 | 12 | Check https://stackoverflow.com/help/minimal-reproducible-example for how to ask good questions. 13 | Simplify the steps to reproduce the issue using suggestions from the above link, and provide them below: 14 | 15 | 1. Full runnable code or full changes you made: 16 | ``` 17 | If making changes to the project itself, please use output of the following command: 18 | git rev-parse HEAD; git diff 19 | 20 | 21 | ``` 22 | 2. What exact command you run: 23 | 3. __Full logs__ or other relevant observations: 24 | ``` 25 | 26 | ``` 27 | 28 | ## Expected behavior: 29 | 30 | If there are no obvious crash in "full logs" provided above, 31 | please tell us the expected behavior. 32 | 33 | If you expect a model to converge / work better, we do not help with such issues, unless 34 | a model fails to reproduce the results in detectron2 model zoo, or proves existence of bugs. 35 | 36 | ## Environment: 37 | 38 | Paste the output of the following command: 39 | ``` 40 | wget -nc -nv https://github.com/facebookresearch/detectron2/raw/main/detectron2/utils/collect_env.py && python collect_env.py 41 | ``` 42 | 43 | If your issue looks like an installation issue / environment issue, 44 | please first check common issues in https://detectron2.readthedocs.io/tutorials/install.html#common-installation-issues 45 | -------------------------------------------------------------------------------- /third_party/CenterNet2/.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | Thanks for your contribution! 2 | 3 | If you're sending a large PR (e.g., >100 lines), 4 | please open an issue first about the feature / bug, and indicate how you want to contribute. 5 | 6 | We do not always accept features. 7 | See https://detectron2.readthedocs.io/notes/contributing.html#pull-requests about how we handle PRs. 8 | 9 | Before submitting a PR, please run `dev/linter.sh` to lint the code. 10 | 11 | -------------------------------------------------------------------------------- /third_party/CenterNet2/.github/workflows/remove-needs-reply.yml: -------------------------------------------------------------------------------- 1 | name: Remove needs-more-info label 2 | 3 | on: 4 | issue_comment: 5 | types: [created] 6 | issues: 7 | types: [edited] 8 | 9 | jobs: 10 | remove-needs-more-info-label: 11 | runs-on: ubuntu-latest 12 | # 1. issue_comment events could include PR comment, filter them out 13 | # 2. Only trigger action if event was produced by the original author 14 | if: ${{ !github.event.issue.pull_request && github.event.sender.login == github.event.issue.user.login }} 15 | steps: 16 | - name: Remove needs-more-info label 17 | uses: octokit/request-action@v2.x 18 | continue-on-error: true 19 | with: 20 | route: DELETE /repos/:repository/issues/:issue/labels/:label 21 | repository: ${{ github.repository }} 22 | issue: ${{ github.event.issue.number }} 23 | label: needs-more-info 24 | env: 25 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 26 | -------------------------------------------------------------------------------- /third_party/CenterNet2/.gitignore: -------------------------------------------------------------------------------- 1 | slurm* 2 | # output dir 3 | output 4 | instant_test_output 5 | inference_test_output 6 | 7 | 8 | *.png 9 | *.json 10 | *.diff 11 | # *.jpg 12 | !/projects/DensePose/doc/images/*.jpg 13 | 14 | # compilation and distribution 15 | __pycache__ 16 | _ext 17 | *.pyc 18 | *.pyd 19 | *.so 20 | *.dll 21 | *.egg-info/ 22 | build/ 23 | dist/ 24 | wheels/ 25 | 26 | # pytorch/python/numpy formats 27 | *.pth 28 | *.pkl 29 | *.npy 30 | *.ts 31 | model_ts*.txt 32 | 33 | # ipython/jupyter notebooks 34 | *.ipynb 35 | **/.ipynb_checkpoints/ 36 | 37 | # Editor temporaries 38 | *.swn 39 | *.swo 40 | *.swp 41 | *~ 42 | 43 | # editor settings 44 | .idea 45 | .vscode 46 | _darcs 47 | 48 | # project dirs 49 | /detectron2/model_zoo/configs 50 | /datasets/* 51 | !/datasets/*.* 52 | !/datasets/lvis/ 53 | /datasets/lvis/* 54 | !/datasets/lvis/lvis_v1_train_cat_info.json 55 | /projects/*/datasets 56 | /models 57 | /snippet 58 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Base-RCNN-C4.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | META_ARCHITECTURE: "GeneralizedRCNN" 3 | RPN: 4 | PRE_NMS_TOPK_TEST: 6000 5 | POST_NMS_TOPK_TEST: 1000 6 | ROI_HEADS: 7 | NAME: "Res5ROIHeads" 8 | DATASETS: 9 | TRAIN: ("coco_2017_train",) 10 | TEST: ("coco_2017_val",) 11 | SOLVER: 12 | IMS_PER_BATCH: 16 13 | BASE_LR: 0.02 14 | STEPS: (60000, 80000) 15 | MAX_ITER: 90000 16 | INPUT: 17 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 18 | VERSION: 2 19 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Base-RCNN-DilatedC5.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | META_ARCHITECTURE: "GeneralizedRCNN" 3 | RESNETS: 4 | OUT_FEATURES: ["res5"] 5 | RES5_DILATION: 2 6 | RPN: 7 | IN_FEATURES: ["res5"] 8 | PRE_NMS_TOPK_TEST: 6000 9 | POST_NMS_TOPK_TEST: 1000 10 | ROI_HEADS: 11 | NAME: "StandardROIHeads" 12 | IN_FEATURES: ["res5"] 13 | ROI_BOX_HEAD: 14 | NAME: "FastRCNNConvFCHead" 15 | NUM_FC: 2 16 | POOLER_RESOLUTION: 7 17 | ROI_MASK_HEAD: 18 | NAME: "MaskRCNNConvUpsampleHead" 19 | NUM_CONV: 4 20 | POOLER_RESOLUTION: 14 21 | DATASETS: 22 | TRAIN: ("coco_2017_train",) 23 | TEST: ("coco_2017_val",) 24 | SOLVER: 25 | IMS_PER_BATCH: 16 26 | BASE_LR: 0.02 27 | STEPS: (60000, 80000) 28 | MAX_ITER: 90000 29 | INPUT: 30 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 31 | VERSION: 2 32 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Base-RCNN-FPN.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | META_ARCHITECTURE: "GeneralizedRCNN" 3 | BACKBONE: 4 | NAME: "build_resnet_fpn_backbone" 5 | RESNETS: 6 | OUT_FEATURES: ["res2", "res3", "res4", "res5"] 7 | FPN: 8 | IN_FEATURES: ["res2", "res3", "res4", "res5"] 9 | ANCHOR_GENERATOR: 10 | SIZES: [[32], [64], [128], [256], [512]] # One size for each in feature map 11 | ASPECT_RATIOS: [[0.5, 1.0, 2.0]] # Three aspect ratios (same for all in feature maps) 12 | RPN: 13 | IN_FEATURES: ["p2", "p3", "p4", "p5", "p6"] 14 | PRE_NMS_TOPK_TRAIN: 2000 # Per FPN level 15 | PRE_NMS_TOPK_TEST: 1000 # Per FPN level 16 | # Detectron1 uses 2000 proposals per-batch, 17 | # (See "modeling/rpn/rpn_outputs.py" for details of this legacy issue) 18 | # which is approximately 1000 proposals per-image since the default batch size for FPN is 2. 19 | POST_NMS_TOPK_TRAIN: 1000 20 | POST_NMS_TOPK_TEST: 1000 21 | ROI_HEADS: 22 | NAME: "StandardROIHeads" 23 | IN_FEATURES: ["p2", "p3", "p4", "p5"] 24 | ROI_BOX_HEAD: 25 | NAME: "FastRCNNConvFCHead" 26 | NUM_FC: 2 27 | POOLER_RESOLUTION: 7 28 | ROI_MASK_HEAD: 29 | NAME: "MaskRCNNConvUpsampleHead" 30 | NUM_CONV: 4 31 | POOLER_RESOLUTION: 14 32 | DATASETS: 33 | TRAIN: ("coco_2017_train",) 34 | TEST: ("coco_2017_val",) 35 | SOLVER: 36 | IMS_PER_BATCH: 16 37 | BASE_LR: 0.02 38 | STEPS: (60000, 80000) 39 | MAX_ITER: 90000 40 | INPUT: 41 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 42 | VERSION: 2 43 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Base-RetinaNet.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | META_ARCHITECTURE: "RetinaNet" 3 | BACKBONE: 4 | NAME: "build_retinanet_resnet_fpn_backbone" 5 | RESNETS: 6 | OUT_FEATURES: ["res3", "res4", "res5"] 7 | ANCHOR_GENERATOR: 8 | SIZES: !!python/object/apply:eval ["[[x, x * 2**(1.0/3), x * 2**(2.0/3) ] for x in [32, 64, 128, 256, 512 ]]"] 9 | FPN: 10 | IN_FEATURES: ["res3", "res4", "res5"] 11 | RETINANET: 12 | IOU_THRESHOLDS: [0.4, 0.5] 13 | IOU_LABELS: [0, -1, 1] 14 | SMOOTH_L1_LOSS_BETA: 0.0 15 | DATASETS: 16 | TRAIN: ("coco_2017_train",) 17 | TEST: ("coco_2017_val",) 18 | SOLVER: 19 | IMS_PER_BATCH: 16 20 | BASE_LR: 0.01 # Note that RetinaNet uses a different default learning rate 21 | STEPS: (60000, 80000) 22 | MAX_ITER: 90000 23 | INPUT: 24 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 25 | VERSION: 2 26 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Detection/fast_rcnn_R_50_FPN_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: False 5 | LOAD_PROPOSALS: True 6 | RESNETS: 7 | DEPTH: 50 8 | PROPOSAL_GENERATOR: 9 | NAME: "PrecomputedProposals" 10 | DATASETS: 11 | TRAIN: ("coco_2017_train",) 12 | PROPOSAL_FILES_TRAIN: ("detectron2://COCO-Detection/rpn_R_50_FPN_1x/137258492/coco_2017_train_box_proposals_21bc3a.pkl", ) 13 | TEST: ("coco_2017_val",) 14 | PROPOSAL_FILES_TEST: ("detectron2://COCO-Detection/rpn_R_50_FPN_1x/137258492/coco_2017_val_box_proposals_ee0dad.pkl", ) 15 | DATALOADER: 16 | # proposals are part of the dataset_dicts, and take a lot of RAM 17 | NUM_WORKERS: 2 18 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Detection/faster_rcnn_R_101_C4_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-C4.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | SOLVER: 8 | STEPS: (210000, 250000) 9 | MAX_ITER: 270000 10 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Detection/faster_rcnn_R_101_DC5_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-DilatedC5.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | SOLVER: 8 | STEPS: (210000, 250000) 9 | MAX_ITER: 270000 10 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Detection/faster_rcnn_R_101_FPN_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | SOLVER: 8 | STEPS: (210000, 250000) 9 | MAX_ITER: 270000 10 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Detection/faster_rcnn_R_50_C4_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-C4.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Detection/faster_rcnn_R_50_C4_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-C4.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | SOLVER: 8 | STEPS: (210000, 250000) 9 | MAX_ITER: 270000 10 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Detection/faster_rcnn_R_50_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-DilatedC5.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Detection/faster_rcnn_R_50_DC5_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-DilatedC5.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | SOLVER: 8 | STEPS: (210000, 250000) 9 | MAX_ITER: 270000 10 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Detection/faster_rcnn_R_50_FPN_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | SOLVER: 8 | STEPS: (210000, 250000) 9 | MAX_ITER: 270000 10 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Detection/faster_rcnn_X_101_32x8d_FPN_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | MASK_ON: False 4 | WEIGHTS: "detectron2://ImageNetPretrained/FAIR/X-101-32x8d.pkl" 5 | PIXEL_STD: [57.375, 57.120, 58.395] 6 | RESNETS: 7 | STRIDE_IN_1X1: False # this is a C2 model 8 | NUM_GROUPS: 32 9 | WIDTH_PER_GROUP: 8 10 | DEPTH: 101 11 | SOLVER: 12 | STEPS: (210000, 250000) 13 | MAX_ITER: 270000 14 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Detection/fcos_R_50_FPN_1x.py: -------------------------------------------------------------------------------- 1 | from ..common.optim import SGD as optimizer 2 | from ..common.coco_schedule import lr_multiplier_1x as lr_multiplier 3 | from ..common.data.coco import dataloader 4 | from ..common.models.fcos import model 5 | from ..common.train import train 6 | 7 | dataloader.train.mapper.use_instance_mask = False 8 | optimizer.lr = 0.01 9 | 10 | model.backbone.bottom_up.freeze_at = 2 11 | train.init_checkpoint = "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 12 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Detection/retinanet_R_101_FPN_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RetinaNet.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | SOLVER: 7 | STEPS: (210000, 250000) 8 | MAX_ITER: 270000 9 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Detection/retinanet_R_50_FPN_1x.py: -------------------------------------------------------------------------------- 1 | from ..common.optim import SGD as optimizer 2 | from ..common.coco_schedule import lr_multiplier_1x as lr_multiplier 3 | from ..common.data.coco import dataloader 4 | from ..common.models.retinanet import model 5 | from ..common.train import train 6 | 7 | dataloader.train.mapper.use_instance_mask = False 8 | model.backbone.bottom_up.freeze_at = 2 9 | optimizer.lr = 0.01 10 | 11 | train.init_checkpoint = "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 12 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Detection/retinanet_R_50_FPN_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RetinaNet.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Detection/retinanet_R_50_FPN_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RetinaNet.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | SOLVER: 7 | STEPS: (210000, 250000) 8 | MAX_ITER: 270000 9 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Detection/rpn_R_50_C4_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-C4.yaml" 2 | MODEL: 3 | META_ARCHITECTURE: "ProposalNetwork" 4 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 5 | MASK_ON: False 6 | RESNETS: 7 | DEPTH: 50 8 | RPN: 9 | PRE_NMS_TOPK_TEST: 12000 10 | POST_NMS_TOPK_TEST: 2000 11 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Detection/rpn_R_50_FPN_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | META_ARCHITECTURE: "ProposalNetwork" 4 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 5 | MASK_ON: False 6 | RESNETS: 7 | DEPTH: 50 8 | RPN: 9 | POST_NMS_TOPK_TEST: 2000 10 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-InstanceSegmentation/mask_rcnn_R_101_C4_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-C4.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 101 7 | SOLVER: 8 | STEPS: (210000, 250000) 9 | MAX_ITER: 270000 10 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-InstanceSegmentation/mask_rcnn_R_101_DC5_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-DilatedC5.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 101 7 | SOLVER: 8 | STEPS: (210000, 250000) 9 | MAX_ITER: 270000 10 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-InstanceSegmentation/mask_rcnn_R_101_FPN_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 101 7 | SOLVER: 8 | STEPS: (210000, 250000) 9 | MAX_ITER: 270000 10 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_1x.py: -------------------------------------------------------------------------------- 1 | from ..common.train import train 2 | from ..common.optim import SGD as optimizer 3 | from ..common.coco_schedule import lr_multiplier_1x as lr_multiplier 4 | from ..common.data.coco import dataloader 5 | from ..common.models.mask_rcnn_c4 import model 6 | 7 | model.backbone.freeze_at = 2 8 | train.init_checkpoint = "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 9 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-C4.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-C4.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | SOLVER: 8 | STEPS: (210000, 250000) 9 | MAX_ITER: 270000 10 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-DilatedC5.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-DilatedC5.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | SOLVER: 8 | STEPS: (210000, 250000) 9 | MAX_ITER: 270000 10 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.py: -------------------------------------------------------------------------------- 1 | from ..common.optim import SGD as optimizer 2 | from ..common.coco_schedule import lr_multiplier_1x as lr_multiplier 3 | from ..common.data.coco import dataloader 4 | from ..common.models.mask_rcnn_fpn import model 5 | from ..common.train import train 6 | 7 | model.backbone.bottom_up.freeze_at = 2 8 | train.init_checkpoint = "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 9 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x_giou.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | RPN: 8 | BBOX_REG_LOSS_TYPE: "giou" 9 | BBOX_REG_LOSS_WEIGHT: 2.0 10 | ROI_BOX_HEAD: 11 | BBOX_REG_LOSS_TYPE: "giou" 12 | BBOX_REG_LOSS_WEIGHT: 10.0 13 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | SOLVER: 8 | STEPS: (210000, 250000) 9 | MAX_ITER: 270000 10 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | MASK_ON: True 4 | WEIGHTS: "detectron2://ImageNetPretrained/FAIR/X-101-32x8d.pkl" 5 | PIXEL_STD: [57.375, 57.120, 58.395] 6 | RESNETS: 7 | STRIDE_IN_1X1: False # this is a C2 model 8 | NUM_GROUPS: 32 9 | WIDTH_PER_GROUP: 8 10 | DEPTH: 101 11 | SOLVER: 12 | STEPS: (210000, 250000) 13 | MAX_ITER: 270000 14 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-InstanceSegmentation/mask_rcnn_regnetx_4gf_dds_fpn_1x.py: -------------------------------------------------------------------------------- 1 | from ..common.optim import SGD as optimizer 2 | from ..common.coco_schedule import lr_multiplier_1x as lr_multiplier 3 | from ..common.data.coco import dataloader 4 | from ..common.models.mask_rcnn_fpn import model 5 | from ..common.train import train 6 | 7 | from detectron2.config import LazyCall as L 8 | from detectron2.modeling.backbone import RegNet 9 | from detectron2.modeling.backbone.regnet import SimpleStem, ResBottleneckBlock 10 | 11 | 12 | # Replace default ResNet with RegNetX-4GF from the DDS paper. Config source: 13 | # https://github.com/facebookresearch/pycls/blob/2c152a6e5d913e898cca4f0a758f41e6b976714d/configs/dds_baselines/regnetx/RegNetX-4.0GF_dds_8gpu.yaml#L4-L9 # noqa 14 | model.backbone.bottom_up = L(RegNet)( 15 | stem_class=SimpleStem, 16 | stem_width=32, 17 | block_class=ResBottleneckBlock, 18 | depth=23, 19 | w_a=38.65, 20 | w_0=96, 21 | w_m=2.43, 22 | group_width=40, 23 | freeze_at=2, 24 | norm="FrozenBN", 25 | out_features=["s1", "s2", "s3", "s4"], 26 | ) 27 | model.pixel_std = [57.375, 57.120, 58.395] 28 | 29 | optimizer.weight_decay = 5e-5 30 | train.init_checkpoint = ( 31 | "https://dl.fbaipublicfiles.com/pycls/dds_baselines/160906383/RegNetX-4.0GF_dds_8gpu.pyth" 32 | ) 33 | # RegNets benefit from enabling cudnn benchmark mode 34 | train.cudnn_benchmark = True 35 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-InstanceSegmentation/mask_rcnn_regnety_4gf_dds_fpn_1x.py: -------------------------------------------------------------------------------- 1 | from ..common.optim import SGD as optimizer 2 | from ..common.coco_schedule import lr_multiplier_1x as lr_multiplier 3 | from ..common.data.coco import dataloader 4 | from ..common.models.mask_rcnn_fpn import model 5 | from ..common.train import train 6 | 7 | from detectron2.config import LazyCall as L 8 | from detectron2.modeling.backbone import RegNet 9 | from detectron2.modeling.backbone.regnet import SimpleStem, ResBottleneckBlock 10 | 11 | 12 | # Replace default ResNet with RegNetY-4GF from the DDS paper. Config source: 13 | # https://github.com/facebookresearch/pycls/blob/2c152a6e5d913e898cca4f0a758f41e6b976714d/configs/dds_baselines/regnety/RegNetY-4.0GF_dds_8gpu.yaml#L4-L10 # noqa 14 | model.backbone.bottom_up = L(RegNet)( 15 | stem_class=SimpleStem, 16 | stem_width=32, 17 | block_class=ResBottleneckBlock, 18 | depth=22, 19 | w_a=31.41, 20 | w_0=96, 21 | w_m=2.24, 22 | group_width=64, 23 | se_ratio=0.25, 24 | freeze_at=2, 25 | norm="FrozenBN", 26 | out_features=["s1", "s2", "s3", "s4"], 27 | ) 28 | model.pixel_std = [57.375, 57.120, 58.395] 29 | 30 | optimizer.weight_decay = 5e-5 31 | train.init_checkpoint = ( 32 | "https://dl.fbaipublicfiles.com/pycls/dds_baselines/160906838/RegNetY-4.0GF_dds_8gpu.pyth" 33 | ) 34 | # RegNets benefit from enabling cudnn benchmark mode 35 | train.cudnn_benchmark = True 36 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Keypoints/Base-Keypoint-RCNN-FPN.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | KEYPOINT_ON: True 4 | ROI_HEADS: 5 | NUM_CLASSES: 1 6 | ROI_BOX_HEAD: 7 | SMOOTH_L1_BETA: 0.5 # Keypoint AP degrades (though box AP improves) when using plain L1 loss 8 | RPN: 9 | # Detectron1 uses 2000 proposals per-batch, but this option is per-image in detectron2. 10 | # 1000 proposals per-image is found to hurt box AP. 11 | # Therefore we increase it to 1500 per-image. 12 | POST_NMS_TOPK_TRAIN: 1500 13 | DATASETS: 14 | TRAIN: ("keypoints_coco_2017_train",) 15 | TEST: ("keypoints_coco_2017_val",) 16 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Keypoints/keypoint_rcnn_R_101_FPN_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-Keypoint-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | SOLVER: 7 | STEPS: (210000, 250000) 8 | MAX_ITER: 270000 9 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_1x.py: -------------------------------------------------------------------------------- 1 | from ..common.optim import SGD as optimizer 2 | from ..common.coco_schedule import lr_multiplier_1x as lr_multiplier 3 | from ..common.data.coco_keypoint import dataloader 4 | from ..common.models.keypoint_rcnn_fpn import model 5 | from ..common.train import train 6 | 7 | model.backbone.bottom_up.freeze_at = 2 8 | train.init_checkpoint = "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 9 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-Keypoint-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-Keypoint-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | SOLVER: 7 | STEPS: (210000, 250000) 8 | MAX_ITER: 270000 9 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-Keypoints/keypoint_rcnn_X_101_32x8d_FPN_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-Keypoint-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/FAIR/X-101-32x8d.pkl" 4 | PIXEL_STD: [57.375, 57.120, 58.395] 5 | RESNETS: 6 | STRIDE_IN_1X1: False # this is a C2 model 7 | NUM_GROUPS: 32 8 | WIDTH_PER_GROUP: 8 9 | DEPTH: 101 10 | SOLVER: 11 | STEPS: (210000, 250000) 12 | MAX_ITER: 270000 13 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-PanopticSegmentation/Base-Panoptic-FPN.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | META_ARCHITECTURE: "PanopticFPN" 4 | MASK_ON: True 5 | SEM_SEG_HEAD: 6 | LOSS_WEIGHT: 0.5 7 | DATASETS: 8 | TRAIN: ("coco_2017_train_panoptic_separated",) 9 | TEST: ("coco_2017_val_panoptic_separated",) 10 | DATALOADER: 11 | FILTER_EMPTY_ANNOTATIONS: False 12 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_101_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-Panoptic-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | SOLVER: 7 | STEPS: (210000, 250000) 8 | MAX_ITER: 270000 9 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_1x.py: -------------------------------------------------------------------------------- 1 | from ..common.optim import SGD as optimizer 2 | from ..common.coco_schedule import lr_multiplier_1x as lr_multiplier 3 | from ..common.data.coco_panoptic_separated import dataloader 4 | from ..common.models.panoptic_fpn import model 5 | from ..common.train import train 6 | 7 | model.backbone.bottom_up.freeze_at = 2 8 | train.init_checkpoint = "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 9 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-Panoptic-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-Panoptic-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | SOLVER: 7 | STEPS: (210000, 250000) 8 | MAX_ITER: 270000 9 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Cityscapes/mask_rcnn_R_50_FPN.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | # WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | # For better, more stable performance initialize from COCO 5 | WEIGHTS: "detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl" 6 | MASK_ON: True 7 | ROI_HEADS: 8 | NUM_CLASSES: 8 9 | # This is similar to the setting used in Mask R-CNN paper, Appendix A 10 | # But there are some differences, e.g., we did not initialize the output 11 | # layer using the corresponding classes from COCO 12 | INPUT: 13 | MIN_SIZE_TRAIN: (800, 832, 864, 896, 928, 960, 992, 1024) 14 | MIN_SIZE_TRAIN_SAMPLING: "choice" 15 | MIN_SIZE_TEST: 1024 16 | MAX_SIZE_TRAIN: 2048 17 | MAX_SIZE_TEST: 2048 18 | DATASETS: 19 | TRAIN: ("cityscapes_fine_instance_seg_train",) 20 | TEST: ("cityscapes_fine_instance_seg_val",) 21 | SOLVER: 22 | BASE_LR: 0.01 23 | STEPS: (18000,) 24 | MAX_ITER: 24000 25 | IMS_PER_BATCH: 8 26 | TEST: 27 | EVAL_PERIOD: 8000 28 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Detectron1-Comparisons/faster_rcnn_R_50_FPN_noaug_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | # Detectron1 uses smooth L1 loss with some magic beta values. 8 | # The defaults are changed to L1 loss in Detectron2. 9 | RPN: 10 | SMOOTH_L1_BETA: 0.1111 11 | ROI_BOX_HEAD: 12 | SMOOTH_L1_BETA: 1.0 13 | POOLER_SAMPLING_RATIO: 2 14 | POOLER_TYPE: "ROIAlign" 15 | INPUT: 16 | # no scale augmentation 17 | MIN_SIZE_TRAIN: (800, ) 18 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Detectron1-Comparisons/keypoint_rcnn_R_50_FPN_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | KEYPOINT_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 1 9 | ROI_KEYPOINT_HEAD: 10 | POOLER_RESOLUTION: 14 11 | POOLER_SAMPLING_RATIO: 2 12 | POOLER_TYPE: "ROIAlign" 13 | # Detectron1 uses smooth L1 loss with some magic beta values. 14 | # The defaults are changed to L1 loss in Detectron2. 15 | ROI_BOX_HEAD: 16 | SMOOTH_L1_BETA: 1.0 17 | POOLER_SAMPLING_RATIO: 2 18 | POOLER_TYPE: "ROIAlign" 19 | RPN: 20 | SMOOTH_L1_BETA: 0.1111 21 | # Detectron1 uses 2000 proposals per-batch, but this option is per-image in detectron2 22 | # 1000 proposals per-image is found to hurt box AP. 23 | # Therefore we increase it to 1500 per-image. 24 | POST_NMS_TOPK_TRAIN: 1500 25 | DATASETS: 26 | TRAIN: ("keypoints_coco_2017_train",) 27 | TEST: ("keypoints_coco_2017_val",) 28 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Detectron1-Comparisons/mask_rcnn_R_50_FPN_noaug_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | # Detectron1 uses smooth L1 loss with some magic beta values. 8 | # The defaults are changed to L1 loss in Detectron2. 9 | RPN: 10 | SMOOTH_L1_BETA: 0.1111 11 | ROI_BOX_HEAD: 12 | SMOOTH_L1_BETA: 1.0 13 | POOLER_SAMPLING_RATIO: 2 14 | POOLER_TYPE: "ROIAlign" 15 | ROI_MASK_HEAD: 16 | POOLER_SAMPLING_RATIO: 2 17 | POOLER_TYPE: "ROIAlign" 18 | INPUT: 19 | # no scale augmentation 20 | MIN_SIZE_TRAIN: (800, ) 21 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/LVISv0.5-InstanceSegmentation/mask_rcnn_R_101_FPN_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | SCORE_THRESH_TEST: 0.0001 10 | INPUT: 11 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 12 | DATASETS: 13 | TRAIN: ("lvis_v0.5_train",) 14 | TEST: ("lvis_v0.5_val",) 15 | TEST: 16 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 17 | DATALOADER: 18 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 19 | REPEAT_THRESHOLD: 0.001 20 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/LVISv0.5-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | SCORE_THRESH_TEST: 0.0001 10 | INPUT: 11 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 12 | DATASETS: 13 | TRAIN: ("lvis_v0.5_train",) 14 | TEST: ("lvis_v0.5_val",) 15 | TEST: 16 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 17 | DATALOADER: 18 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 19 | REPEAT_THRESHOLD: 0.001 20 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/LVISv0.5-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/FAIR/X-101-32x8d.pkl" 4 | PIXEL_STD: [57.375, 57.120, 58.395] 5 | MASK_ON: True 6 | RESNETS: 7 | STRIDE_IN_1X1: False # this is a C2 model 8 | NUM_GROUPS: 32 9 | WIDTH_PER_GROUP: 8 10 | DEPTH: 101 11 | ROI_HEADS: 12 | NUM_CLASSES: 1230 13 | SCORE_THRESH_TEST: 0.0001 14 | INPUT: 15 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 16 | DATASETS: 17 | TRAIN: ("lvis_v0.5_train",) 18 | TEST: ("lvis_v0.5_val",) 19 | TEST: 20 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 21 | DATALOADER: 22 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 23 | REPEAT_THRESHOLD: 0.001 24 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/LVISv1-InstanceSegmentation/mask_rcnn_R_101_FPN_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 1203 9 | SCORE_THRESH_TEST: 0.0001 10 | INPUT: 11 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 12 | DATASETS: 13 | TRAIN: ("lvis_v1_train",) 14 | TEST: ("lvis_v1_val",) 15 | TEST: 16 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 17 | SOLVER: 18 | STEPS: (120000, 160000) 19 | MAX_ITER: 180000 # 180000 * 16 / 100000 ~ 28.8 epochs 20 | DATALOADER: 21 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 22 | REPEAT_THRESHOLD: 0.001 23 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/LVISv1-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 1203 9 | SCORE_THRESH_TEST: 0.0001 10 | INPUT: 11 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 12 | DATASETS: 13 | TRAIN: ("lvis_v1_train",) 14 | TEST: ("lvis_v1_val",) 15 | TEST: 16 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 17 | SOLVER: 18 | STEPS: (120000, 160000) 19 | MAX_ITER: 180000 # 180000 * 16 / 100000 ~ 28.8 epochs 20 | DATALOADER: 21 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 22 | REPEAT_THRESHOLD: 0.001 23 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/LVISv1-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/FAIR/X-101-32x8d.pkl" 4 | PIXEL_STD: [57.375, 57.120, 58.395] 5 | MASK_ON: True 6 | RESNETS: 7 | STRIDE_IN_1X1: False # this is a C2 model 8 | NUM_GROUPS: 32 9 | WIDTH_PER_GROUP: 8 10 | DEPTH: 101 11 | ROI_HEADS: 12 | NUM_CLASSES: 1203 13 | SCORE_THRESH_TEST: 0.0001 14 | INPUT: 15 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 16 | DATASETS: 17 | TRAIN: ("lvis_v1_train",) 18 | TEST: ("lvis_v1_val",) 19 | SOLVER: 20 | STEPS: (120000, 160000) 21 | MAX_ITER: 180000 # 180000 * 16 / 100000 ~ 28.8 epochs 22 | TEST: 23 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 24 | DATALOADER: 25 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 26 | REPEAT_THRESHOLD: 0.001 27 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Misc/cascade_mask_rcnn_R_50_FPN_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NAME: CascadeROIHeads 9 | ROI_BOX_HEAD: 10 | CLS_AGNOSTIC_BBOX_REG: True 11 | RPN: 12 | POST_NMS_TOPK_TRAIN: 2000 13 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Misc/cascade_mask_rcnn_R_50_FPN_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NAME: CascadeROIHeads 9 | ROI_BOX_HEAD: 10 | CLS_AGNOSTIC_BBOX_REG: True 11 | RPN: 12 | POST_NMS_TOPK_TRAIN: 2000 13 | SOLVER: 14 | STEPS: (210000, 250000) 15 | MAX_ITER: 270000 16 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Misc/cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | MASK_ON: True 4 | WEIGHTS: "catalog://ImageNetPretrained/FAIR/X-152-32x8d-IN5k" 5 | RESNETS: 6 | STRIDE_IN_1X1: False # this is a C2 model 7 | NUM_GROUPS: 32 8 | WIDTH_PER_GROUP: 8 9 | DEPTH: 152 10 | DEFORM_ON_PER_STAGE: [False, True, True, True] 11 | ROI_HEADS: 12 | NAME: "CascadeROIHeads" 13 | ROI_BOX_HEAD: 14 | NAME: "FastRCNNConvFCHead" 15 | NUM_CONV: 4 16 | NUM_FC: 1 17 | NORM: "GN" 18 | CLS_AGNOSTIC_BBOX_REG: True 19 | ROI_MASK_HEAD: 20 | NUM_CONV: 8 21 | NORM: "GN" 22 | RPN: 23 | POST_NMS_TOPK_TRAIN: 2000 24 | SOLVER: 25 | IMS_PER_BATCH: 128 26 | STEPS: (35000, 45000) 27 | MAX_ITER: 50000 28 | BASE_LR: 0.16 29 | INPUT: 30 | MIN_SIZE_TRAIN: (640, 864) 31 | MIN_SIZE_TRAIN_SAMPLING: "range" 32 | MAX_SIZE_TRAIN: 1440 33 | CROP: 34 | ENABLED: True 35 | TEST: 36 | EVAL_PERIOD: 2500 37 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Misc/mask_rcnn_R_50_FPN_1x_cls_agnostic.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_BOX_HEAD: 8 | CLS_AGNOSTIC_BBOX_REG: True 9 | ROI_MASK_HEAD: 10 | CLS_AGNOSTIC_MASK: True 11 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Misc/mask_rcnn_R_50_FPN_1x_dconv_c3-c5.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | DEFORM_ON_PER_STAGE: [False, True, True, True] # on Res3,Res4,Res5 8 | DEFORM_MODULATED: False 9 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Misc/mask_rcnn_R_50_FPN_3x_dconv_c3-c5.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | DEFORM_ON_PER_STAGE: [False, True, True, True] # on Res3,Res4,Res5 8 | DEFORM_MODULATED: False 9 | SOLVER: 10 | STEPS: (210000, 250000) 11 | MAX_ITER: 270000 12 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Misc/mask_rcnn_R_50_FPN_3x_gn.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "catalog://ImageNetPretrained/FAIR/R-50-GN" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | NORM: "GN" 8 | STRIDE_IN_1X1: False 9 | FPN: 10 | NORM: "GN" 11 | ROI_BOX_HEAD: 12 | NAME: "FastRCNNConvFCHead" 13 | NUM_CONV: 4 14 | NUM_FC: 1 15 | NORM: "GN" 16 | ROI_MASK_HEAD: 17 | NORM: "GN" 18 | SOLVER: 19 | # 3x schedule 20 | STEPS: (210000, 250000) 21 | MAX_ITER: 270000 22 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Misc/mask_rcnn_R_50_FPN_3x_syncbn.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | NORM: "SyncBN" 8 | STRIDE_IN_1X1: True 9 | FPN: 10 | NORM: "SyncBN" 11 | ROI_BOX_HEAD: 12 | NAME: "FastRCNNConvFCHead" 13 | NUM_CONV: 4 14 | NUM_FC: 1 15 | NORM: "SyncBN" 16 | ROI_MASK_HEAD: 17 | NORM: "SyncBN" 18 | SOLVER: 19 | # 3x schedule 20 | STEPS: (210000, 250000) 21 | MAX_ITER: 270000 22 | TEST: 23 | PRECISE_BN: 24 | ENABLED: True 25 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Misc/panoptic_fpn_R_101_dconv_cascade_gn_3x.yaml: -------------------------------------------------------------------------------- 1 | # A large PanopticFPN for demo purposes. 2 | # Use GN on backbone to support semantic seg. 3 | # Use Cascade + Deform Conv to improve localization. 4 | _BASE_: "../COCO-PanopticSegmentation/Base-Panoptic-FPN.yaml" 5 | MODEL: 6 | WEIGHTS: "catalog://ImageNetPretrained/FAIR/R-101-GN" 7 | RESNETS: 8 | DEPTH: 101 9 | NORM: "GN" 10 | DEFORM_ON_PER_STAGE: [False, True, True, True] 11 | STRIDE_IN_1X1: False 12 | FPN: 13 | NORM: "GN" 14 | ROI_HEADS: 15 | NAME: CascadeROIHeads 16 | ROI_BOX_HEAD: 17 | CLS_AGNOSTIC_BBOX_REG: True 18 | ROI_MASK_HEAD: 19 | NORM: "GN" 20 | RPN: 21 | POST_NMS_TOPK_TRAIN: 2000 22 | SOLVER: 23 | STEPS: (105000, 125000) 24 | MAX_ITER: 135000 25 | IMS_PER_BATCH: 32 26 | BASE_LR: 0.04 27 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Misc/scratch_mask_rcnn_R_50_FPN_3x_gn.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "mask_rcnn_R_50_FPN_3x_gn.yaml" 2 | MODEL: 3 | # Train from random initialization. 4 | WEIGHTS: "" 5 | # It makes sense to divide by STD when training from scratch 6 | # But it seems to make no difference on the results and C2's models didn't do this. 7 | # So we keep things consistent with C2. 8 | # PIXEL_STD: [57.375, 57.12, 58.395] 9 | MASK_ON: True 10 | BACKBONE: 11 | FREEZE_AT: 0 12 | # NOTE: Please refer to Rethinking ImageNet Pre-training https://arxiv.org/abs/1811.08883 13 | # to learn what you need for training from scratch. 14 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Misc/scratch_mask_rcnn_R_50_FPN_9x_gn.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "mask_rcnn_R_50_FPN_3x_gn.yaml" 2 | MODEL: 3 | PIXEL_STD: [57.375, 57.12, 58.395] 4 | WEIGHTS: "" 5 | MASK_ON: True 6 | RESNETS: 7 | STRIDE_IN_1X1: False 8 | BACKBONE: 9 | FREEZE_AT: 0 10 | SOLVER: 11 | # 9x schedule 12 | IMS_PER_BATCH: 64 # 4x the standard 13 | STEPS: (187500, 197500) # last 60/4==15k and last 20/4==5k 14 | MAX_ITER: 202500 # 90k * 9 / 4 15 | BASE_LR: 0.08 16 | TEST: 17 | EVAL_PERIOD: 2500 18 | # NOTE: Please refer to Rethinking ImageNet Pre-training https://arxiv.org/abs/1811.08883 19 | # to learn what you need for training from scratch. 20 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Misc/scratch_mask_rcnn_R_50_FPN_9x_syncbn.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "mask_rcnn_R_50_FPN_3x_syncbn.yaml" 2 | MODEL: 3 | PIXEL_STD: [57.375, 57.12, 58.395] 4 | WEIGHTS: "" 5 | MASK_ON: True 6 | RESNETS: 7 | STRIDE_IN_1X1: False 8 | BACKBONE: 9 | FREEZE_AT: 0 10 | SOLVER: 11 | # 9x schedule 12 | IMS_PER_BATCH: 64 # 4x the standard 13 | STEPS: (187500, 197500) # last 60/4==15k and last 20/4==5k 14 | MAX_ITER: 202500 # 90k * 9 / 4 15 | BASE_LR: 0.08 16 | TEST: 17 | EVAL_PERIOD: 2500 18 | # NOTE: Please refer to Rethinking ImageNet Pre-training https://arxiv.org/abs/1811.08883 19 | # to learn what you need for training from scratch. 20 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/Misc/semantic_R_50_FPN_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | META_ARCHITECTURE: "SemanticSegmentor" 4 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 5 | RESNETS: 6 | DEPTH: 50 7 | DATASETS: 8 | TRAIN: ("coco_2017_train_panoptic_stuffonly",) 9 | TEST: ("coco_2017_val_panoptic_stuffonly",) 10 | INPUT: 11 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 12 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/PascalVOC-Detection/faster_rcnn_R_50_C4.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-C4.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | INPUT: 10 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 11 | MIN_SIZE_TEST: 800 12 | DATASETS: 13 | TRAIN: ('voc_2007_trainval', 'voc_2012_trainval') 14 | TEST: ('voc_2007_test',) 15 | SOLVER: 16 | STEPS: (12000, 16000) 17 | MAX_ITER: 18000 # 17.4 epochs 18 | WARMUP_ITERS: 100 19 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/PascalVOC-Detection/faster_rcnn_R_50_FPN.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | INPUT: 10 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 11 | MIN_SIZE_TEST: 800 12 | DATASETS: 13 | TRAIN: ('voc_2007_trainval', 'voc_2012_trainval') 14 | TEST: ('voc_2007_test',) 15 | SOLVER: 16 | STEPS: (12000, 16000) 17 | MAX_ITER: 18000 # 17.4 epochs 18 | WARMUP_ITERS: 100 19 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/common/README.md: -------------------------------------------------------------------------------- 1 | This directory provides definitions for a few common models, dataloaders, scheduler, 2 | and optimizers that are often used in training. 3 | The definition of these objects are provided in the form of lazy instantiation: 4 | their arguments can be edited by users before constructing the objects. 5 | 6 | They can be imported, or loaded by `model_zoo.get_config` API in users' own configs. 7 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/common/coco_schedule.py: -------------------------------------------------------------------------------- 1 | from fvcore.common.param_scheduler import MultiStepParamScheduler 2 | 3 | from detectron2.config import LazyCall as L 4 | from detectron2.solver import WarmupParamScheduler 5 | 6 | 7 | def default_X_scheduler(num_X): 8 | """ 9 | Returns the config for a default multi-step LR scheduler such as "1x", "3x", 10 | commonly referred to in papers, where every 1x has the total length of 1440k 11 | training images (~12 COCO epochs). LR is decayed twice at the end of training 12 | following the strategy defined in "Rethinking ImageNet Pretraining", Sec 4. 13 | 14 | Args: 15 | num_X: a positive real number 16 | 17 | Returns: 18 | DictConfig: configs that define the multiplier for LR during training 19 | """ 20 | # total number of iterations assuming 16 batch size, using 1440000/16=90000 21 | total_steps_16bs = num_X * 90000 22 | 23 | if num_X <= 2: 24 | scheduler = L(MultiStepParamScheduler)( 25 | values=[1.0, 0.1, 0.01], 26 | # note that scheduler is scale-invariant. This is equivalent to 27 | # milestones=[6, 8, 9] 28 | milestones=[60000, 80000, 90000], 29 | ) 30 | else: 31 | scheduler = L(MultiStepParamScheduler)( 32 | values=[1.0, 0.1, 0.01], 33 | milestones=[total_steps_16bs - 60000, total_steps_16bs - 20000, total_steps_16bs], 34 | ) 35 | return L(WarmupParamScheduler)( 36 | scheduler=scheduler, 37 | warmup_length=1000 / total_steps_16bs, 38 | warmup_method="linear", 39 | warmup_factor=0.001, 40 | ) 41 | 42 | 43 | lr_multiplier_1x = default_X_scheduler(1) 44 | lr_multiplier_2x = default_X_scheduler(2) 45 | lr_multiplier_3x = default_X_scheduler(3) 46 | lr_multiplier_6x = default_X_scheduler(6) 47 | lr_multiplier_9x = default_X_scheduler(9) 48 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/common/data/coco.py: -------------------------------------------------------------------------------- 1 | from omegaconf import OmegaConf 2 | 3 | import detectron2.data.transforms as T 4 | from detectron2.config import LazyCall as L 5 | from detectron2.data import ( 6 | DatasetMapper, 7 | build_detection_test_loader, 8 | build_detection_train_loader, 9 | get_detection_dataset_dicts, 10 | ) 11 | from detectron2.evaluation import COCOEvaluator 12 | 13 | dataloader = OmegaConf.create() 14 | 15 | dataloader.train = L(build_detection_train_loader)( 16 | dataset=L(get_detection_dataset_dicts)(names="coco_2017_train"), 17 | mapper=L(DatasetMapper)( 18 | is_train=True, 19 | augmentations=[ 20 | L(T.ResizeShortestEdge)( 21 | short_edge_length=(640, 672, 704, 736, 768, 800), 22 | sample_style="choice", 23 | max_size=1333, 24 | ), 25 | L(T.RandomFlip)(horizontal=True), 26 | ], 27 | image_format="BGR", 28 | use_instance_mask=True, 29 | ), 30 | total_batch_size=16, 31 | num_workers=4, 32 | ) 33 | 34 | dataloader.test = L(build_detection_test_loader)( 35 | dataset=L(get_detection_dataset_dicts)(names="coco_2017_val", filter_empty=False), 36 | mapper=L(DatasetMapper)( 37 | is_train=False, 38 | augmentations=[ 39 | L(T.ResizeShortestEdge)(short_edge_length=800, max_size=1333), 40 | ], 41 | image_format="${...train.mapper.image_format}", 42 | ), 43 | num_workers=4, 44 | ) 45 | 46 | dataloader.evaluator = L(COCOEvaluator)( 47 | dataset_name="${..test.dataset.names}", 48 | ) 49 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/common/data/coco_keypoint.py: -------------------------------------------------------------------------------- 1 | from detectron2.data.detection_utils import create_keypoint_hflip_indices 2 | 3 | from .coco import dataloader 4 | 5 | dataloader.train.dataset.min_keypoints = 1 6 | dataloader.train.dataset.names = "keypoints_coco_2017_train" 7 | dataloader.test.dataset.names = "keypoints_coco_2017_val" 8 | 9 | dataloader.train.mapper.update( 10 | use_instance_mask=False, 11 | use_keypoint=True, 12 | keypoint_hflip_indices=create_keypoint_hflip_indices(dataloader.train.dataset.names), 13 | ) 14 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/common/data/coco_panoptic_separated.py: -------------------------------------------------------------------------------- 1 | from detectron2.config import LazyCall as L 2 | from detectron2.evaluation import ( 3 | COCOEvaluator, 4 | COCOPanopticEvaluator, 5 | DatasetEvaluators, 6 | SemSegEvaluator, 7 | ) 8 | 9 | from .coco import dataloader 10 | 11 | dataloader.train.dataset.names = "coco_2017_train_panoptic_separated" 12 | dataloader.train.dataset.filter_empty = False 13 | dataloader.test.dataset.names = "coco_2017_val_panoptic_separated" 14 | 15 | 16 | dataloader.evaluator = [ 17 | L(COCOEvaluator)( 18 | dataset_name="${...test.dataset.names}", 19 | ), 20 | L(SemSegEvaluator)( 21 | dataset_name="${...test.dataset.names}", 22 | ), 23 | L(COCOPanopticEvaluator)( 24 | dataset_name="${...test.dataset.names}", 25 | ), 26 | ] 27 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/common/models/cascade_rcnn.py: -------------------------------------------------------------------------------- 1 | from detectron2.config import LazyCall as L 2 | from detectron2.layers import ShapeSpec 3 | from detectron2.modeling.box_regression import Box2BoxTransform 4 | from detectron2.modeling.matcher import Matcher 5 | from detectron2.modeling.roi_heads import FastRCNNOutputLayers, FastRCNNConvFCHead, CascadeROIHeads 6 | 7 | from .mask_rcnn_fpn import model 8 | 9 | # arguments that don't exist for Cascade R-CNN 10 | [model.roi_heads.pop(k) for k in ["box_head", "box_predictor", "proposal_matcher"]] 11 | 12 | model.roi_heads.update( 13 | _target_=CascadeROIHeads, 14 | box_heads=[ 15 | L(FastRCNNConvFCHead)( 16 | input_shape=ShapeSpec(channels=256, height=7, width=7), 17 | conv_dims=[], 18 | fc_dims=[1024, 1024], 19 | ) 20 | for k in range(3) 21 | ], 22 | box_predictors=[ 23 | L(FastRCNNOutputLayers)( 24 | input_shape=ShapeSpec(channels=1024), 25 | test_score_thresh=0.05, 26 | box2box_transform=L(Box2BoxTransform)(weights=(w1, w1, w2, w2)), 27 | cls_agnostic_bbox_reg=True, 28 | num_classes="${...num_classes}", 29 | ) 30 | for (w1, w2) in [(10, 5), (20, 10), (30, 15)] 31 | ], 32 | proposal_matchers=[ 33 | L(Matcher)(thresholds=[th], labels=[0, 1], allow_low_quality_matches=False) 34 | for th in [0.5, 0.6, 0.7] 35 | ], 36 | ) 37 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/common/models/fcos.py: -------------------------------------------------------------------------------- 1 | from detectron2.modeling.meta_arch.fcos import FCOS, FCOSHead 2 | 3 | from .retinanet import model 4 | 5 | model._target_ = FCOS 6 | 7 | del model.anchor_generator 8 | del model.box2box_transform 9 | del model.anchor_matcher 10 | del model.input_format 11 | 12 | # Use P5 instead of C5 to compute P6/P7 13 | # (Sec 2.2 of https://arxiv.org/abs/2006.09214) 14 | model.backbone.top_block.in_feature = "p5" 15 | model.backbone.top_block.in_channels = 256 16 | 17 | # New score threshold determined based on sqrt(cls_score * centerness) 18 | model.test_score_thresh = 0.2 19 | model.test_nms_thresh = 0.6 20 | 21 | model.head._target_ = FCOSHead 22 | del model.head.num_anchors 23 | model.head.norm = "GN" 24 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/common/models/keypoint_rcnn_fpn.py: -------------------------------------------------------------------------------- 1 | from detectron2.config import LazyCall as L 2 | from detectron2.layers import ShapeSpec 3 | from detectron2.modeling.poolers import ROIPooler 4 | from detectron2.modeling.roi_heads import KRCNNConvDeconvUpsampleHead 5 | 6 | from .mask_rcnn_fpn import model 7 | 8 | [model.roi_heads.pop(x) for x in ["mask_in_features", "mask_pooler", "mask_head"]] 9 | 10 | model.roi_heads.update( 11 | num_classes=1, 12 | keypoint_in_features=["p2", "p3", "p4", "p5"], 13 | keypoint_pooler=L(ROIPooler)( 14 | output_size=14, 15 | scales=(1.0 / 4, 1.0 / 8, 1.0 / 16, 1.0 / 32), 16 | sampling_ratio=0, 17 | pooler_type="ROIAlignV2", 18 | ), 19 | keypoint_head=L(KRCNNConvDeconvUpsampleHead)( 20 | input_shape=ShapeSpec(channels=256, width=14, height=14), 21 | num_keypoints=17, 22 | conv_dims=[512] * 8, 23 | loss_normalizer="visible", 24 | ), 25 | ) 26 | 27 | # Detectron1 uses 2000 proposals per-batch, but this option is per-image in detectron2. 28 | # 1000 proposals per-image is found to hurt box AP. 29 | # Therefore we increase it to 1500 per-image. 30 | model.proposal_generator.post_nms_topk = (1500, 1000) 31 | 32 | # Keypoint AP degrades (though box AP improves) when using plain L1 loss 33 | model.roi_heads.box_predictor.smooth_l1_beta = 0.5 34 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/common/models/panoptic_fpn.py: -------------------------------------------------------------------------------- 1 | from detectron2.config import LazyCall as L 2 | from detectron2.layers import ShapeSpec 3 | from detectron2.modeling import PanopticFPN 4 | from detectron2.modeling.meta_arch.semantic_seg import SemSegFPNHead 5 | 6 | from .mask_rcnn_fpn import model 7 | 8 | model._target_ = PanopticFPN 9 | model.sem_seg_head = L(SemSegFPNHead)( 10 | input_shape={ 11 | f: L(ShapeSpec)(stride=s, channels="${....backbone.out_channels}") 12 | for f, s in zip(["p2", "p3", "p4", "p5"], [4, 8, 16, 32]) 13 | }, 14 | ignore_value=255, 15 | num_classes=54, # COCO stuff + 1 16 | conv_dims=128, 17 | common_stride=4, 18 | loss_weight=0.5, 19 | norm="GN", 20 | ) 21 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/common/optim.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | from detectron2.config import LazyCall as L 4 | from detectron2.solver.build import get_default_optimizer_params 5 | 6 | SGD = L(torch.optim.SGD)( 7 | params=L(get_default_optimizer_params)( 8 | # params.model is meant to be set to the model object, before instantiating 9 | # the optimizer. 10 | weight_decay_norm=0.0 11 | ), 12 | lr=0.02, 13 | momentum=0.9, 14 | weight_decay=1e-4, 15 | ) 16 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/common/train.py: -------------------------------------------------------------------------------- 1 | # Common training-related configs that are designed for "tools/lazyconfig_train_net.py" 2 | # You can use your own instead, together with your own train_net.py 3 | train = dict( 4 | output_dir="./output", 5 | init_checkpoint="", 6 | max_iter=90000, 7 | amp=dict(enabled=False), # options for Automatic Mixed Precision 8 | ddp=dict( # options for DistributedDataParallel 9 | broadcast_buffers=False, 10 | find_unused_parameters=False, 11 | fp16_compression=False, 12 | ), 13 | checkpointer=dict(period=5000, max_to_keep=100), # options for PeriodicCheckpointer 14 | eval_period=5000, 15 | log_period=20, 16 | device="cuda" 17 | # ... 18 | ) 19 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/new_baselines/mask_rcnn_R_101_FPN_100ep_LSJ.py: -------------------------------------------------------------------------------- 1 | from .mask_rcnn_R_50_FPN_100ep_LSJ import ( 2 | dataloader, 3 | lr_multiplier, 4 | model, 5 | optimizer, 6 | train, 7 | ) 8 | 9 | model.backbone.bottom_up.stages.depth = 101 10 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/new_baselines/mask_rcnn_R_101_FPN_200ep_LSJ.py: -------------------------------------------------------------------------------- 1 | from .mask_rcnn_R_101_FPN_100ep_LSJ import ( 2 | dataloader, 3 | lr_multiplier, 4 | model, 5 | optimizer, 6 | train, 7 | ) 8 | 9 | train.max_iter *= 2 # 100ep -> 200ep 10 | 11 | lr_multiplier.scheduler.milestones = [ 12 | milestone * 2 for milestone in lr_multiplier.scheduler.milestones 13 | ] 14 | lr_multiplier.scheduler.num_updates = train.max_iter 15 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/new_baselines/mask_rcnn_R_101_FPN_400ep_LSJ.py: -------------------------------------------------------------------------------- 1 | from .mask_rcnn_R_101_FPN_100ep_LSJ import ( 2 | dataloader, 3 | lr_multiplier, 4 | model, 5 | optimizer, 6 | train, 7 | ) 8 | 9 | train.max_iter *= 4 # 100ep -> 400ep 10 | 11 | lr_multiplier.scheduler.milestones = [ 12 | milestone * 4 for milestone in lr_multiplier.scheduler.milestones 13 | ] 14 | lr_multiplier.scheduler.num_updates = train.max_iter 15 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/new_baselines/mask_rcnn_R_50_FPN_200ep_LSJ.py: -------------------------------------------------------------------------------- 1 | from .mask_rcnn_R_50_FPN_100ep_LSJ import ( 2 | dataloader, 3 | lr_multiplier, 4 | model, 5 | optimizer, 6 | train, 7 | ) 8 | 9 | train.max_iter *= 2 # 100ep -> 200ep 10 | 11 | lr_multiplier.scheduler.milestones = [ 12 | milestone * 2 for milestone in lr_multiplier.scheduler.milestones 13 | ] 14 | lr_multiplier.scheduler.num_updates = train.max_iter 15 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/new_baselines/mask_rcnn_R_50_FPN_400ep_LSJ.py: -------------------------------------------------------------------------------- 1 | from .mask_rcnn_R_50_FPN_100ep_LSJ import ( 2 | dataloader, 3 | lr_multiplier, 4 | model, 5 | optimizer, 6 | train, 7 | ) 8 | 9 | train.max_iter *= 4 # 100ep -> 400ep 10 | 11 | lr_multiplier.scheduler.milestones = [ 12 | milestone * 4 for milestone in lr_multiplier.scheduler.milestones 13 | ] 14 | lr_multiplier.scheduler.num_updates = train.max_iter 15 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/new_baselines/mask_rcnn_R_50_FPN_50ep_LSJ.py: -------------------------------------------------------------------------------- 1 | from .mask_rcnn_R_50_FPN_100ep_LSJ import ( 2 | dataloader, 3 | lr_multiplier, 4 | model, 5 | optimizer, 6 | train, 7 | ) 8 | 9 | train.max_iter //= 2 # 100ep -> 50ep 10 | 11 | lr_multiplier.scheduler.milestones = [ 12 | milestone // 2 for milestone in lr_multiplier.scheduler.milestones 13 | ] 14 | lr_multiplier.scheduler.num_updates = train.max_iter 15 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_100ep_LSJ.py: -------------------------------------------------------------------------------- 1 | from .mask_rcnn_R_50_FPN_100ep_LSJ import ( 2 | dataloader, 3 | lr_multiplier, 4 | model, 5 | optimizer, 6 | train, 7 | ) 8 | from detectron2.config import LazyCall as L 9 | from detectron2.modeling.backbone import RegNet 10 | from detectron2.modeling.backbone.regnet import SimpleStem, ResBottleneckBlock 11 | 12 | # Config source: 13 | # https://github.com/facebookresearch/detectron2/blob/main/configs/COCO-InstanceSegmentation/mask_rcnn_regnetx_4gf_dds_fpn_1x.py # noqa 14 | model.backbone.bottom_up = L(RegNet)( 15 | stem_class=SimpleStem, 16 | stem_width=32, 17 | block_class=ResBottleneckBlock, 18 | depth=23, 19 | w_a=38.65, 20 | w_0=96, 21 | w_m=2.43, 22 | group_width=40, 23 | norm="SyncBN", 24 | out_features=["s1", "s2", "s3", "s4"], 25 | ) 26 | model.pixel_std = [57.375, 57.120, 58.395] 27 | 28 | # RegNets benefit from enabling cudnn benchmark mode 29 | train.cudnn_benchmark = True 30 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_200ep_LSJ.py: -------------------------------------------------------------------------------- 1 | from .mask_rcnn_regnetx_4gf_dds_FPN_100ep_LSJ import ( 2 | dataloader, 3 | lr_multiplier, 4 | model, 5 | optimizer, 6 | train, 7 | ) 8 | 9 | train.max_iter *= 2 # 100ep -> 200ep 10 | 11 | lr_multiplier.scheduler.milestones = [ 12 | milestone * 2 for milestone in lr_multiplier.scheduler.milestones 13 | ] 14 | lr_multiplier.scheduler.num_updates = train.max_iter 15 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_400ep_LSJ.py: -------------------------------------------------------------------------------- 1 | from .mask_rcnn_regnetx_4gf_dds_FPN_100ep_LSJ import ( 2 | dataloader, 3 | lr_multiplier, 4 | model, 5 | optimizer, 6 | train, 7 | ) 8 | 9 | train.max_iter *= 4 # 100ep -> 400ep 10 | 11 | lr_multiplier.scheduler.milestones = [ 12 | milestone * 4 for milestone in lr_multiplier.scheduler.milestones 13 | ] 14 | lr_multiplier.scheduler.num_updates = train.max_iter 15 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_100ep_LSJ.py: -------------------------------------------------------------------------------- 1 | from .mask_rcnn_R_50_FPN_100ep_LSJ import ( 2 | dataloader, 3 | lr_multiplier, 4 | model, 5 | optimizer, 6 | train, 7 | ) 8 | from detectron2.config import LazyCall as L 9 | from detectron2.modeling.backbone import RegNet 10 | from detectron2.modeling.backbone.regnet import SimpleStem, ResBottleneckBlock 11 | 12 | # Config source: 13 | # https://github.com/facebookresearch/detectron2/blob/main/configs/COCO-InstanceSegmentation/mask_rcnn_regnety_4gf_dds_fpn_1x.py # noqa 14 | model.backbone.bottom_up = L(RegNet)( 15 | stem_class=SimpleStem, 16 | stem_width=32, 17 | block_class=ResBottleneckBlock, 18 | depth=22, 19 | w_a=31.41, 20 | w_0=96, 21 | w_m=2.24, 22 | group_width=64, 23 | se_ratio=0.25, 24 | norm="SyncBN", 25 | out_features=["s1", "s2", "s3", "s4"], 26 | ) 27 | model.pixel_std = [57.375, 57.120, 58.395] 28 | 29 | # RegNets benefit from enabling cudnn benchmark mode 30 | train.cudnn_benchmark = True 31 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_200ep_LSJ.py: -------------------------------------------------------------------------------- 1 | from .mask_rcnn_regnety_4gf_dds_FPN_100ep_LSJ import ( 2 | dataloader, 3 | lr_multiplier, 4 | model, 5 | optimizer, 6 | train, 7 | ) 8 | 9 | train.max_iter *= 2 # 100ep -> 200ep 10 | 11 | lr_multiplier.scheduler.milestones = [ 12 | milestone * 2 for milestone in lr_multiplier.scheduler.milestones 13 | ] 14 | lr_multiplier.scheduler.num_updates = train.max_iter 15 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_400ep_LSJ.py: -------------------------------------------------------------------------------- 1 | from .mask_rcnn_regnety_4gf_dds_FPN_100ep_LSJ import ( 2 | dataloader, 3 | lr_multiplier, 4 | model, 5 | optimizer, 6 | train, 7 | ) 8 | 9 | train.max_iter *= 4 # 100ep -> 400ep 10 | 11 | lr_multiplier.scheduler.milestones = [ 12 | milestone * 4 for milestone in lr_multiplier.scheduler.milestones 13 | ] 14 | lr_multiplier.scheduler.num_updates = train.max_iter 15 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/README.md: -------------------------------------------------------------------------------- 1 | These are quick configs for performance or accuracy regression tracking purposes. 2 | 3 | * `*instance_test.yaml`: can train on 2 GPUs. They are used to test whether the training can 4 | successfully finish. They are not expected to produce reasonable training results. 5 | * `*inference_acc_test.yaml`: They should be run using `--eval-only`. They run inference using pre-trained models and verify 6 | the results are as expected. 7 | * `*training_acc_test.yaml`: They should be trained on 8 GPUs. They finish in about an hour and verify the training accuracy 8 | is within the normal range. 9 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/cascade_mask_rcnn_R_50_FPN_inference_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Misc/cascade_mask_rcnn_R_50_FPN_3x.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://Misc/cascade_mask_rcnn_R_50_FPN_3x/144998488/model_final_480dd8.pkl" 4 | DATASETS: 5 | TEST: ("coco_2017_val_100",) 6 | TEST: 7 | EXPECTED_RESULTS: [["bbox", "AP", 50.18, 0.02], ["segm", "AP", 43.87, 0.02]] 8 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/cascade_mask_rcnn_R_50_FPN_instant_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Misc/cascade_mask_rcnn_R_50_FPN_3x.yaml" 2 | DATASETS: 3 | TRAIN: ("coco_2017_val_100",) 4 | TEST: ("coco_2017_val_100",) 5 | SOLVER: 6 | BASE_LR: 0.005 7 | STEPS: (30,) 8 | MAX_ITER: 40 9 | IMS_PER_BATCH: 4 10 | DATALOADER: 11 | NUM_WORKERS: 2 12 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/fast_rcnn_R_50_FPN_inference_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../COCO-Detection/fast_rcnn_R_50_FPN_1x.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://COCO-Detection/fast_rcnn_R_50_FPN_1x/137635226/model_final_e5f7ce.pkl" 4 | DATASETS: 5 | TEST: ("coco_2017_val_100",) 6 | TEST: 7 | EXPECTED_RESULTS: [["bbox", "AP", 45.70, 0.02]] 8 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/fast_rcnn_R_50_FPN_instant_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../COCO-Detection/fast_rcnn_R_50_FPN_1x.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | DATASETS: 5 | TRAIN: ("coco_2017_val_100",) 6 | PROPOSAL_FILES_TRAIN: ("detectron2://COCO-Detection/rpn_R_50_FPN_1x/137258492/coco_2017_val_box_proposals_ee0dad.pkl", ) 7 | TEST: ("coco_2017_val_100",) 8 | PROPOSAL_FILES_TEST: ("detectron2://COCO-Detection/rpn_R_50_FPN_1x/137258492/coco_2017_val_box_proposals_ee0dad.pkl", ) 9 | SOLVER: 10 | BASE_LR: 0.005 11 | STEPS: (30,) 12 | MAX_ITER: 40 13 | IMS_PER_BATCH: 4 14 | DATALOADER: 15 | NUM_WORKERS: 2 16 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_inference_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x/137849621/model_final_a6e10b.pkl" 4 | DATASETS: 5 | TEST: ("keypoints_coco_2017_val_100",) 6 | TEST: 7 | EXPECTED_RESULTS: [["bbox", "AP", 52.47, 0.02], ["keypoints", "AP", 67.36, 0.02]] 8 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_instant_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | KEYPOINT_ON: True 5 | ROI_HEADS: 6 | NUM_CLASSES: 1 7 | DATASETS: 8 | TRAIN: ("keypoints_coco_2017_val_100",) 9 | TEST: ("keypoints_coco_2017_val_100",) 10 | SOLVER: 11 | BASE_LR: 0.005 12 | STEPS: (30,) 13 | MAX_ITER: 40 14 | IMS_PER_BATCH: 4 15 | DATALOADER: 16 | NUM_WORKERS: 2 17 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_normalized_training_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | KEYPOINT_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | BATCH_SIZE_PER_IMAGE: 256 9 | NUM_CLASSES: 1 10 | ROI_KEYPOINT_HEAD: 11 | POOLER_RESOLUTION: 14 12 | POOLER_SAMPLING_RATIO: 2 13 | NORMALIZE_LOSS_BY_VISIBLE_KEYPOINTS: False 14 | LOSS_WEIGHT: 4.0 15 | ROI_BOX_HEAD: 16 | SMOOTH_L1_BETA: 1.0 # Keypoint AP degrades when using plain L1 loss 17 | RPN: 18 | SMOOTH_L1_BETA: 0.2 # Keypoint AP degrades when using plain L1 loss 19 | DATASETS: 20 | TRAIN: ("keypoints_coco_2017_val",) 21 | TEST: ("keypoints_coco_2017_val",) 22 | INPUT: 23 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 24 | SOLVER: 25 | WARMUP_FACTOR: 0.33333333 26 | WARMUP_ITERS: 100 27 | STEPS: (5500, 5800) 28 | MAX_ITER: 6000 29 | TEST: 30 | EXPECTED_RESULTS: [["bbox", "AP", 55.35, 1.0], ["keypoints", "AP", 76.91, 1.0]] 31 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/keypoint_rcnn_R_50_FPN_training_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | KEYPOINT_ON: True 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | BATCH_SIZE_PER_IMAGE: 256 9 | NUM_CLASSES: 1 10 | ROI_KEYPOINT_HEAD: 11 | POOLER_RESOLUTION: 14 12 | POOLER_SAMPLING_RATIO: 2 13 | ROI_BOX_HEAD: 14 | SMOOTH_L1_BETA: 1.0 # Keypoint AP degrades when using plain L1 loss 15 | RPN: 16 | SMOOTH_L1_BETA: 0.2 # Keypoint AP degrades when using plain L1 loss 17 | DATASETS: 18 | TRAIN: ("keypoints_coco_2017_val",) 19 | TEST: ("keypoints_coco_2017_val",) 20 | INPUT: 21 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 22 | SOLVER: 23 | WARMUP_FACTOR: 0.33333333 24 | WARMUP_ITERS: 100 25 | STEPS: (5500, 5800) 26 | MAX_ITER: 6000 27 | TEST: 28 | EXPECTED_RESULTS: [["bbox", "AP", 53.5, 1.0], ["keypoints", "AP", 72.4, 1.0]] 29 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/mask_rcnn_R_50_C4_GCV_instant_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-C4.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | DATASETS: 6 | TRAIN: ("coco_2017_val_100",) 7 | TEST: ("coco_2017_val_100",) 8 | SOLVER: 9 | BASE_LR: 0.001 10 | STEPS: (30,) 11 | MAX_ITER: 40 12 | IMS_PER_BATCH: 4 13 | CLIP_GRADIENTS: 14 | ENABLED: True 15 | CLIP_TYPE: "value" 16 | CLIP_VALUE: 1.0 17 | DATALOADER: 18 | NUM_WORKERS: 2 19 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/mask_rcnn_R_50_C4_inference_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../COCO-InstanceSegmentation/mask_rcnn_R_50_C4_3x.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_C4_3x/137849525/model_final_4ce675.pkl" 4 | DATASETS: 5 | TEST: ("coco_2017_val_100",) 6 | TEST: 7 | EXPECTED_RESULTS: [["bbox", "AP", 47.37, 0.02], ["segm", "AP", 40.99, 0.02]] 8 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/mask_rcnn_R_50_C4_instant_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-C4.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | DATASETS: 6 | TRAIN: ("coco_2017_val_100",) 7 | TEST: ("coco_2017_val_100",) 8 | SOLVER: 9 | BASE_LR: 0.001 10 | STEPS: (30,) 11 | MAX_ITER: 40 12 | IMS_PER_BATCH: 4 13 | DATALOADER: 14 | NUM_WORKERS: 2 15 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/mask_rcnn_R_50_C4_training_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-C4.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | ROI_HEADS: 5 | BATCH_SIZE_PER_IMAGE: 256 6 | MASK_ON: True 7 | DATASETS: 8 | TRAIN: ("coco_2017_val",) 9 | TEST: ("coco_2017_val",) 10 | INPUT: 11 | MIN_SIZE_TRAIN: (600,) 12 | MAX_SIZE_TRAIN: 1000 13 | MIN_SIZE_TEST: 800 14 | MAX_SIZE_TEST: 1000 15 | SOLVER: 16 | IMS_PER_BATCH: 8 # base uses 16 17 | WARMUP_FACTOR: 0.33333 18 | WARMUP_ITERS: 100 19 | STEPS: (11000, 11600) 20 | MAX_ITER: 12000 21 | TEST: 22 | EXPECTED_RESULTS: [["bbox", "AP", 41.88, 0.7], ["segm", "AP", 33.79, 0.5]] 23 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/mask_rcnn_R_50_DC5_inference_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_3x.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_3x/137849551/model_final_84107b.pkl" 4 | DATASETS: 5 | TEST: ("coco_2017_val_100",) 6 | TEST: 7 | EXPECTED_RESULTS: [["bbox", "AP", 47.44, 0.02], ["segm", "AP", 42.94, 0.02]] 8 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/mask_rcnn_R_50_FPN_inference_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl" 4 | DATASETS: 5 | TEST: ("coco_2017_val_100",) 6 | TEST: 7 | EXPECTED_RESULTS: [["bbox", "AP", 47.34, 0.02], ["segm", "AP", 42.67, 0.02], ["bbox_TTA", "AP", 49.11, 0.02], ["segm_TTA", "AP", 45.04, 0.02]] 8 | AUG: 9 | ENABLED: True 10 | MIN_SIZES: (700, 800) # to save some time 11 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/mask_rcnn_R_50_FPN_instant_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: True 5 | DATASETS: 6 | TRAIN: ("coco_2017_val_100",) 7 | TEST: ("coco_2017_val_100",) 8 | SOLVER: 9 | BASE_LR: 0.005 10 | STEPS: (30,) 11 | MAX_ITER: 40 12 | IMS_PER_BATCH: 4 13 | DATALOADER: 14 | NUM_WORKERS: 2 15 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/mask_rcnn_R_50_FPN_pred_boxes_training_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "./mask_rcnn_R_50_FPN_training_acc_test.yaml" 2 | MODEL: 3 | ROI_BOX_HEAD: 4 | TRAIN_ON_PRED_BOXES: True 5 | TEST: 6 | EXPECTED_RESULTS: [["bbox", "AP", 42.6, 1.0], ["segm", "AP", 35.8, 0.8]] 7 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/mask_rcnn_R_50_FPN_training_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | ROI_HEADS: 5 | BATCH_SIZE_PER_IMAGE: 256 6 | MASK_ON: True 7 | DATASETS: 8 | TRAIN: ("coco_2017_val",) 9 | TEST: ("coco_2017_val",) 10 | INPUT: 11 | MIN_SIZE_TRAIN: (600,) 12 | MAX_SIZE_TRAIN: 1000 13 | MIN_SIZE_TEST: 800 14 | MAX_SIZE_TEST: 1000 15 | SOLVER: 16 | WARMUP_FACTOR: 0.3333333 17 | WARMUP_ITERS: 100 18 | STEPS: (5500, 5800) 19 | MAX_ITER: 6000 20 | TEST: 21 | EXPECTED_RESULTS: [["bbox", "AP", 42.5, 1.0], ["segm", "AP", 35.8, 0.8]] 22 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/panoptic_fpn_R_50_inference_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../COCO-PanopticSegmentation/panoptic_fpn_R_50_3x.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://COCO-PanopticSegmentation/panoptic_fpn_R_50_3x/139514569/model_final_c10459.pkl" 4 | DATASETS: 5 | TEST: ("coco_2017_val_100_panoptic_separated",) 6 | TEST: 7 | EXPECTED_RESULTS: [["bbox", "AP", 46.47, 0.02], ["segm", "AP", 43.39, 0.02], ["sem_seg", "mIoU", 42.55, 0.02], ["panoptic_seg", "PQ", 38.99, 0.02]] 8 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/panoptic_fpn_R_50_instant_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | META_ARCHITECTURE: "PanopticFPN" 4 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 5 | MASK_ON: True 6 | RESNETS: 7 | DEPTH: 50 8 | SEM_SEG_HEAD: 9 | LOSS_WEIGHT: 0.5 10 | DATASETS: 11 | TRAIN: ("coco_2017_val_100_panoptic_separated",) 12 | TEST: ("coco_2017_val_100_panoptic_separated",) 13 | SOLVER: 14 | BASE_LR: 0.005 15 | STEPS: (30,) 16 | MAX_ITER: 40 17 | IMS_PER_BATCH: 4 18 | DATALOADER: 19 | NUM_WORKERS: 1 20 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/panoptic_fpn_R_50_training_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | META_ARCHITECTURE: "PanopticFPN" 4 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 5 | MASK_ON: True 6 | RESNETS: 7 | DEPTH: 50 8 | SEM_SEG_HEAD: 9 | LOSS_WEIGHT: 0.5 10 | DATASETS: 11 | TRAIN: ("coco_2017_val_panoptic_separated",) 12 | TEST: ("coco_2017_val_panoptic_separated",) 13 | SOLVER: 14 | BASE_LR: 0.01 15 | WARMUP_FACTOR: 0.001 16 | WARMUP_ITERS: 500 17 | STEPS: (5500,) 18 | MAX_ITER: 7000 19 | TEST: 20 | EXPECTED_RESULTS: [["bbox", "AP", 46.70, 1.1], ["segm", "AP", 39.0, 0.7], ["sem_seg", "mIoU", 64.73, 1.3], ["panoptic_seg", "PQ", 48.13, 0.8]] 21 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/retinanet_R_50_FPN_inference_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../COCO-Detection/retinanet_R_50_FPN_3x.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://COCO-Detection/retinanet_R_50_FPN_3x/190397829/model_final_5bd44e.pkl" 4 | DATASETS: 5 | TEST: ("coco_2017_val_100",) 6 | TEST: 7 | EXPECTED_RESULTS: [["bbox", "AP", 44.45, 0.02]] 8 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/retinanet_R_50_FPN_instant_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../COCO-Detection/retinanet_R_50_FPN_1x.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | DATASETS: 5 | TRAIN: ("coco_2017_val_100",) 6 | TEST: ("coco_2017_val_100",) 7 | SOLVER: 8 | BASE_LR: 0.005 9 | STEPS: (30,) 10 | MAX_ITER: 40 11 | IMS_PER_BATCH: 4 12 | DATALOADER: 13 | NUM_WORKERS: 2 14 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/rpn_R_50_FPN_inference_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../COCO-Detection/rpn_R_50_FPN_1x.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://COCO-Detection/rpn_R_50_FPN_1x/137258492/model_final_02ce48.pkl" 4 | DATASETS: 5 | TEST: ("coco_2017_val_100",) 6 | TEST: 7 | EXPECTED_RESULTS: [["box_proposals", "AR@1000", 58.16, 0.02]] 8 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/rpn_R_50_FPN_instant_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../COCO-Detection/rpn_R_50_FPN_1x.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | DATASETS: 5 | TRAIN: ("coco_2017_val_100",) 6 | TEST: ("coco_2017_val_100",) 7 | SOLVER: 8 | STEPS: (30,) 9 | MAX_ITER: 40 10 | BASE_LR: 0.005 11 | IMS_PER_BATCH: 4 12 | DATALOADER: 13 | NUM_WORKERS: 2 14 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/semantic_R_50_FPN_inference_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | META_ARCHITECTURE: "SemanticSegmentor" 4 | WEIGHTS: "detectron2://semantic_R_50_FPN_1x/111802073/model_final_c18079783c55a94968edc28b7101c5f0.pkl" 5 | RESNETS: 6 | DEPTH: 50 7 | DATASETS: 8 | TEST: ("coco_2017_val_100_panoptic_stuffonly",) 9 | TEST: 10 | EXPECTED_RESULTS: [["sem_seg", "mIoU", 39.53, 0.02], ["sem_seg", "mACC", 51.50, 0.02]] 11 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/semantic_R_50_FPN_instant_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | META_ARCHITECTURE: "SemanticSegmentor" 4 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 5 | RESNETS: 6 | DEPTH: 50 7 | DATASETS: 8 | TRAIN: ("coco_2017_val_100_panoptic_stuffonly",) 9 | TEST: ("coco_2017_val_100_panoptic_stuffonly",) 10 | INPUT: 11 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 12 | SOLVER: 13 | BASE_LR: 0.005 14 | STEPS: (30,) 15 | MAX_ITER: 40 16 | IMS_PER_BATCH: 4 17 | DATALOADER: 18 | NUM_WORKERS: 2 19 | -------------------------------------------------------------------------------- /third_party/CenterNet2/configs/quick_schedules/semantic_R_50_FPN_training_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | META_ARCHITECTURE: "SemanticSegmentor" 4 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 5 | RESNETS: 6 | DEPTH: 50 7 | DATASETS: 8 | TRAIN: ("coco_2017_val_panoptic_stuffonly",) 9 | TEST: ("coco_2017_val_panoptic_stuffonly",) 10 | SOLVER: 11 | BASE_LR: 0.01 12 | WARMUP_FACTOR: 0.001 13 | WARMUP_ITERS: 300 14 | STEPS: (5500,) 15 | MAX_ITER: 7000 16 | TEST: 17 | EXPECTED_RESULTS: [["sem_seg", "mIoU", 76.51, 1.0], ["sem_seg", "mACC", 83.25, 1.0]] 18 | INPUT: 19 | # no scale augmentation 20 | MIN_SIZE_TRAIN: (800, ) 21 | -------------------------------------------------------------------------------- /third_party/CenterNet2/datasets/prepare_ade20k_sem_seg.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # Copyright (c) Facebook, Inc. and its affiliates. 4 | import numpy as np 5 | import os 6 | from pathlib import Path 7 | import tqdm 8 | from PIL import Image 9 | 10 | 11 | def convert(input, output): 12 | img = np.asarray(Image.open(input)) 13 | assert img.dtype == np.uint8 14 | img = img - 1 # 0 (ignore) becomes 255. others are shifted by 1 15 | Image.fromarray(img).save(output) 16 | 17 | 18 | if __name__ == "__main__": 19 | dataset_dir = Path(os.getenv("DETECTRON2_DATASETS", "datasets")) / "ADEChallengeData2016" 20 | for name in ["training", "validation"]: 21 | annotation_dir = dataset_dir / "annotations" / name 22 | output_dir = dataset_dir / "annotations_detectron2" / name 23 | output_dir.mkdir(parents=True, exist_ok=True) 24 | for file in tqdm.tqdm(list(annotation_dir.iterdir())): 25 | output_file = output_dir / file.name 26 | convert(file, output_file) 27 | -------------------------------------------------------------------------------- /third_party/CenterNet2/datasets/prepare_for_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | 4 | # Download the mini dataset (coco val2017_100, with only 100 images) 5 | # to be used in unittests & integration tests. 6 | 7 | cd "${0%/*}" 8 | 9 | BASE=https://dl.fbaipublicfiles.com/detectron2 10 | ROOT=${DETECTRON2_DATASETS:-./} 11 | ROOT=${ROOT/#\~/$HOME} # expand ~ to HOME 12 | mkdir -p $ROOT/coco/annotations 13 | 14 | for anno in instances_val2017_100 \ 15 | person_keypoints_val2017_100 ; do 16 | 17 | dest=$ROOT/coco/annotations/$anno.json 18 | [[ -s $dest ]] && { 19 | echo "$dest exists. Skipping ..." 20 | } || { 21 | wget $BASE/annotations/coco/$anno.json -O $dest 22 | } 23 | done 24 | 25 | dest=$ROOT/coco/val2017_100.tgz 26 | [[ -d $ROOT/coco/val2017 ]] && { 27 | echo "$ROOT/coco/val2017 exists. Skipping ..." 28 | } || { 29 | wget $BASE/annotations/coco/val2017_100.tgz -O $dest 30 | tar xzf $dest -C $ROOT/coco/ && rm -f $dest 31 | } 32 | -------------------------------------------------------------------------------- /third_party/CenterNet2/demo/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Detectron2 Demo 3 | 4 | We provide a command line tool to run a simple demo of builtin configs. 5 | The usage is explained in [GETTING_STARTED.md](../GETTING_STARTED.md). 6 | 7 | See our [blog post](https://ai.facebook.com/blog/-detectron2-a-pytorch-based-modular-object-detection-library-) 8 | for a high-quality demo generated with this tool. 9 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from .utils.env import setup_environment 4 | 5 | setup_environment() 6 | 7 | 8 | # This line will be programatically read/write by setup.py. 9 | # Leave them at the bottom of this file and don't touch them. 10 | __version__ = "0.6" 11 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/checkpoint/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # File: 4 | 5 | 6 | from . import catalog as _UNUSED # register the handler 7 | from .detection_checkpoint import DetectionCheckpointer 8 | from fvcore.common.checkpoint import Checkpointer, PeriodicCheckpointer 9 | 10 | __all__ = ["Checkpointer", "PeriodicCheckpointer", "DetectionCheckpointer"] 11 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/config/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .compat import downgrade_config, upgrade_config 3 | from .config import CfgNode, get_cfg, global_cfg, set_global_cfg, configurable 4 | from .instantiate import instantiate 5 | from .lazy import LazyCall, LazyConfig 6 | 7 | __all__ = [ 8 | "CfgNode", 9 | "get_cfg", 10 | "global_cfg", 11 | "set_global_cfg", 12 | "downgrade_config", 13 | "upgrade_config", 14 | "configurable", 15 | "instantiate", 16 | "LazyCall", 17 | "LazyConfig", 18 | ] 19 | 20 | 21 | from detectron2.utils.env import fixup_module_metadata 22 | 23 | fixup_module_metadata(__name__, globals(), __all__) 24 | del fixup_module_metadata 25 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/data/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from . import transforms # isort:skip 3 | 4 | from .build import ( 5 | build_batch_data_loader, 6 | build_detection_test_loader, 7 | build_detection_train_loader, 8 | get_detection_dataset_dicts, 9 | load_proposals_into_dataset, 10 | print_instances_class_histogram, 11 | ) 12 | from .catalog import DatasetCatalog, MetadataCatalog, Metadata 13 | from .common import DatasetFromList, MapDataset, ToIterableDataset 14 | from .dataset_mapper import DatasetMapper 15 | 16 | # ensure the builtin datasets are registered 17 | from . import datasets, samplers # isort:skip 18 | 19 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 20 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/data/datasets/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ### Common Datasets 4 | 5 | The dataset implemented here do not need to load the data into the final format. 6 | It should provide the minimal data structure needed to use the dataset, so it can be very efficient. 7 | 8 | For example, for an image dataset, just provide the file names and labels, but don't read the images. 9 | Let the downstream decide how to read. 10 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/data/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .coco import load_coco_json, load_sem_seg, register_coco_instances, convert_to_coco_json 3 | from .coco_panoptic import register_coco_panoptic, register_coco_panoptic_separated 4 | from .lvis import load_lvis_json, register_lvis_instances, get_lvis_instances_meta 5 | from .pascal_voc import load_voc_instances, register_pascal_voc 6 | from . import builtin as _builtin # ensure the builtin datasets are registered 7 | 8 | 9 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 10 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/data/datasets/register_coco.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .coco import register_coco_instances # noqa 3 | from .coco_panoptic import register_coco_panoptic_separated # noqa 4 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/data/samplers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .distributed_sampler import ( 3 | InferenceSampler, 4 | RandomSubsetTrainingSampler, 5 | RepeatFactorTrainingSampler, 6 | TrainingSampler, 7 | ) 8 | 9 | from .grouped_batch_sampler import GroupedBatchSampler 10 | 11 | __all__ = [ 12 | "GroupedBatchSampler", 13 | "TrainingSampler", 14 | "RandomSubsetTrainingSampler", 15 | "InferenceSampler", 16 | "RepeatFactorTrainingSampler", 17 | ] 18 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/data/transforms/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from fvcore.transforms.transform import Transform, TransformList # order them first 3 | from fvcore.transforms.transform import * 4 | from .transform import * 5 | from .augmentation import * 6 | from .augmentation_impl import * 7 | 8 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 9 | 10 | 11 | from detectron2.utils.env import fixup_module_metadata 12 | 13 | fixup_module_metadata(__name__, globals(), __all__) 14 | del fixup_module_metadata 15 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/engine/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from .launch import * 4 | from .train_loop import * 5 | 6 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 7 | 8 | 9 | # prefer to let hooks and defaults live in separate namespaces (therefore not in __all__) 10 | # but still make them available here 11 | from .hooks import * 12 | from .defaults import * 13 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .cityscapes_evaluation import CityscapesInstanceEvaluator, CityscapesSemSegEvaluator 3 | from .coco_evaluation import COCOEvaluator 4 | from .rotated_coco_evaluation import RotatedCOCOEvaluator 5 | from .evaluator import DatasetEvaluator, DatasetEvaluators, inference_context, inference_on_dataset 6 | from .lvis_evaluation import LVISEvaluator 7 | from .panoptic_evaluation import COCOPanopticEvaluator 8 | from .pascal_voc_evaluation import PascalVOCDetectionEvaluator 9 | from .sem_seg_evaluation import SemSegEvaluator 10 | from .testing import print_csv_format, verify_results 11 | 12 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 13 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/export/README.md: -------------------------------------------------------------------------------- 1 | 2 | This directory contains code to prepare a detectron2 model for deployment. 3 | Currently it supports exporting a detectron2 model to Caffe2 format through ONNX. 4 | 5 | Please see [documentation](https://detectron2.readthedocs.io/tutorials/deployment.html) for its usage. 6 | 7 | 8 | ### Acknowledgements 9 | 10 | Thanks to Mobile Vision team at Facebook for developing the Caffe2 conversion tools. 11 | 12 | Thanks to Computing Platform Department - PAI team at Alibaba Group (@bddpqq, @chenbohua3) who 13 | help export Detectron2 models to TorchScript. 14 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/export/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | try: 4 | from caffe2.proto import caffe2_pb2 as _tmp 5 | 6 | # caffe2 is optional 7 | except ImportError: 8 | pass 9 | else: 10 | from .api import * 11 | 12 | from .flatten import TracingAdapter 13 | from .torchscript import scripting_with_instances, dump_torchscript_IR 14 | 15 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 16 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/layers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .batch_norm import FrozenBatchNorm2d, get_norm, NaiveSyncBatchNorm, CycleBatchNormList 3 | from .deform_conv import DeformConv, ModulatedDeformConv 4 | from .mask_ops import paste_masks_in_image 5 | from .nms import batched_nms, batched_nms_rotated, nms, nms_rotated 6 | from .roi_align import ROIAlign, roi_align 7 | from .roi_align_rotated import ROIAlignRotated, roi_align_rotated 8 | from .shape_spec import ShapeSpec 9 | from .wrappers import ( 10 | BatchNorm2d, 11 | Conv2d, 12 | ConvTranspose2d, 13 | cat, 14 | interpolate, 15 | Linear, 16 | nonzero_tuple, 17 | cross_entropy, 18 | shapes_to_tensor, 19 | ) 20 | from .blocks import CNNBlockBase, DepthwiseSeparableConv2d 21 | from .aspp import ASPP 22 | from .losses import ciou_loss, diou_loss 23 | 24 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 25 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/layers/csrc/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | To add a new Op: 4 | 5 | 1. Create a new directory 6 | 2. Implement new ops there 7 | 3. Delcare its Python interface in `vision.cpp`. 8 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Facebook, Inc. and its affiliates. 2 | #pragma once 3 | #include 4 | 5 | namespace detectron2 { 6 | 7 | at::Tensor box_iou_rotated_cpu( 8 | const at::Tensor& boxes1, 9 | const at::Tensor& boxes2); 10 | 11 | #if defined(WITH_CUDA) || defined(WITH_HIP) 12 | at::Tensor box_iou_rotated_cuda( 13 | const at::Tensor& boxes1, 14 | const at::Tensor& boxes2); 15 | #endif 16 | 17 | // Interface for Python 18 | // inline is needed to prevent multiple function definitions when this header is 19 | // included by different cpps 20 | inline at::Tensor box_iou_rotated( 21 | const at::Tensor& boxes1, 22 | const at::Tensor& boxes2) { 23 | assert(boxes1.device().is_cuda() == boxes2.device().is_cuda()); 24 | if (boxes1.device().is_cuda()) { 25 | #if defined(WITH_CUDA) || defined(WITH_HIP) 26 | return box_iou_rotated_cuda(boxes1.contiguous(), boxes2.contiguous()); 27 | #else 28 | AT_ERROR("Detectron2 is not compiled with GPU support!"); 29 | #endif 30 | } 31 | 32 | return box_iou_rotated_cpu(boxes1.contiguous(), boxes2.contiguous()); 33 | } 34 | 35 | } // namespace detectron2 36 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cpu.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Facebook, Inc. and its affiliates. 2 | #include "box_iou_rotated.h" 3 | #include "box_iou_rotated_utils.h" 4 | 5 | namespace detectron2 { 6 | 7 | template 8 | void box_iou_rotated_cpu_kernel( 9 | const at::Tensor& boxes1, 10 | const at::Tensor& boxes2, 11 | at::Tensor& ious) { 12 | auto num_boxes1 = boxes1.size(0); 13 | auto num_boxes2 = boxes2.size(0); 14 | 15 | for (int i = 0; i < num_boxes1; i++) { 16 | for (int j = 0; j < num_boxes2; j++) { 17 | ious[i * num_boxes2 + j] = single_box_iou_rotated( 18 | boxes1[i].data_ptr(), boxes2[j].data_ptr()); 19 | } 20 | } 21 | } 22 | 23 | at::Tensor box_iou_rotated_cpu( 24 | // input must be contiguous: 25 | const at::Tensor& boxes1, 26 | const at::Tensor& boxes2) { 27 | auto num_boxes1 = boxes1.size(0); 28 | auto num_boxes2 = boxes2.size(0); 29 | at::Tensor ious = 30 | at::empty({num_boxes1 * num_boxes2}, boxes1.options().dtype(at::kFloat)); 31 | 32 | box_iou_rotated_cpu_kernel(boxes1, boxes2, ious); 33 | 34 | // reshape from 1d array to 2d array 35 | auto shape = std::vector{num_boxes1, num_boxes2}; 36 | return ious.reshape(shape); 37 | } 38 | 39 | } // namespace detectron2 40 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/layers/csrc/cuda_version.cu: -------------------------------------------------------------------------------- 1 | // Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | #include 4 | 5 | namespace detectron2 { 6 | int get_cudart_version() { 7 | // Not a ROCM platform: Either HIP is not used, or 8 | // it is used, but platform is not ROCM (i.e. it is CUDA) 9 | #if !defined(__HIP_PLATFORM_HCC__) 10 | return CUDART_VERSION; 11 | #else 12 | int version = 0; 13 | 14 | #if HIP_VERSION_MAJOR != 0 15 | // Create a convention similar to that of CUDA, as assumed by other 16 | // parts of the code. 17 | 18 | version = HIP_VERSION_MINOR; 19 | version += (HIP_VERSION_MAJOR * 100); 20 | #else 21 | hipRuntimeGetVersion(&version); 22 | #endif 23 | return version; 24 | #endif 25 | } 26 | } // namespace detectron2 27 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/layers/csrc/nms_rotated/nms_rotated.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Facebook, Inc. and its affiliates. 2 | #pragma once 3 | #include 4 | 5 | namespace detectron2 { 6 | 7 | at::Tensor nms_rotated_cpu( 8 | const at::Tensor& dets, 9 | const at::Tensor& scores, 10 | const double iou_threshold); 11 | 12 | #if defined(WITH_CUDA) || defined(WITH_HIP) 13 | at::Tensor nms_rotated_cuda( 14 | const at::Tensor& dets, 15 | const at::Tensor& scores, 16 | const double iou_threshold); 17 | #endif 18 | 19 | // Interface for Python 20 | // inline is needed to prevent multiple function definitions when this header is 21 | // included by different cpps 22 | inline at::Tensor nms_rotated( 23 | const at::Tensor& dets, 24 | const at::Tensor& scores, 25 | const double iou_threshold) { 26 | assert(dets.device().is_cuda() == scores.device().is_cuda()); 27 | if (dets.device().is_cuda()) { 28 | #if defined(WITH_CUDA) || defined(WITH_HIP) 29 | return nms_rotated_cuda( 30 | dets.contiguous(), scores.contiguous(), iou_threshold); 31 | #else 32 | AT_ERROR("Detectron2 is not compiled with GPU support!"); 33 | #endif 34 | } 35 | 36 | return nms_rotated_cpu(dets.contiguous(), scores.contiguous(), iou_threshold); 37 | } 38 | 39 | } // namespace detectron2 40 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/layers/rotated_boxes.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from __future__ import absolute_import, division, print_function, unicode_literals 3 | import torch 4 | 5 | 6 | def pairwise_iou_rotated(boxes1, boxes2): 7 | """ 8 | Return intersection-over-union (Jaccard index) of boxes. 9 | 10 | Both sets of boxes are expected to be in 11 | (x_center, y_center, width, height, angle) format. 12 | 13 | Arguments: 14 | boxes1 (Tensor[N, 5]) 15 | boxes2 (Tensor[M, 5]) 16 | 17 | Returns: 18 | iou (Tensor[N, M]): the NxM matrix containing the pairwise 19 | IoU values for every element in boxes1 and boxes2 20 | """ 21 | return torch.ops.detectron2.box_iou_rotated(boxes1, boxes2) 22 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/layers/shape_spec.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | from collections import namedtuple 4 | 5 | 6 | class ShapeSpec(namedtuple("_ShapeSpec", ["channels", "height", "width", "stride"])): 7 | """ 8 | A simple structure that contains basic shape specification about a tensor. 9 | It is often used as the auxiliary inputs/outputs of models, 10 | to complement the lack of shape inference ability among pytorch modules. 11 | 12 | Attributes: 13 | channels: 14 | height: 15 | width: 16 | stride: 17 | """ 18 | 19 | def __new__(cls, channels=None, height=None, width=None, stride=None): 20 | return super().__new__(cls, channels, height, width, stride) 21 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/model_zoo/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | """ 3 | Model Zoo API for Detectron2: a collection of functions to create common model architectures 4 | listed in `MODEL_ZOO.md `_, 5 | and optionally load their pre-trained weights. 6 | """ 7 | 8 | from .model_zoo import get, get_config_file, get_checkpoint_url, get_config 9 | 10 | __all__ = ["get_checkpoint_url", "get", "get_config_file", "get_config"] 11 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/modeling/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from detectron2.layers import ShapeSpec 3 | 4 | from .anchor_generator import build_anchor_generator, ANCHOR_GENERATOR_REGISTRY 5 | from .backbone import ( 6 | BACKBONE_REGISTRY, 7 | FPN, 8 | Backbone, 9 | ResNet, 10 | ResNetBlockBase, 11 | build_backbone, 12 | build_resnet_backbone, 13 | make_stage, 14 | ) 15 | from .meta_arch import ( 16 | META_ARCH_REGISTRY, 17 | SEM_SEG_HEADS_REGISTRY, 18 | GeneralizedRCNN, 19 | PanopticFPN, 20 | ProposalNetwork, 21 | RetinaNet, 22 | SemanticSegmentor, 23 | build_model, 24 | build_sem_seg_head, 25 | FCOS, 26 | ) 27 | from .postprocessing import detector_postprocess 28 | from .proposal_generator import ( 29 | PROPOSAL_GENERATOR_REGISTRY, 30 | build_proposal_generator, 31 | RPN_HEAD_REGISTRY, 32 | build_rpn_head, 33 | ) 34 | from .roi_heads import ( 35 | ROI_BOX_HEAD_REGISTRY, 36 | ROI_HEADS_REGISTRY, 37 | ROI_KEYPOINT_HEAD_REGISTRY, 38 | ROI_MASK_HEAD_REGISTRY, 39 | ROIHeads, 40 | StandardROIHeads, 41 | BaseMaskRCNNHead, 42 | BaseKeypointRCNNHead, 43 | FastRCNNOutputLayers, 44 | build_box_head, 45 | build_keypoint_head, 46 | build_mask_head, 47 | build_roi_heads, 48 | ) 49 | from .test_time_augmentation import DatasetMapperTTA, GeneralizedRCNNWithTTA 50 | from .mmdet_wrapper import MMDetBackbone, MMDetDetector 51 | 52 | _EXCLUDE = {"ShapeSpec"} 53 | __all__ = [k for k in globals().keys() if k not in _EXCLUDE and not k.startswith("_")] 54 | 55 | 56 | from detectron2.utils.env import fixup_module_metadata 57 | 58 | fixup_module_metadata(__name__, globals(), __all__) 59 | del fixup_module_metadata 60 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/modeling/backbone/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .build import build_backbone, BACKBONE_REGISTRY # noqa F401 isort:skip 3 | 4 | from .backbone import Backbone 5 | from .fpn import FPN 6 | from .regnet import RegNet 7 | from .resnet import ( 8 | BasicStem, 9 | ResNet, 10 | ResNetBlockBase, 11 | build_resnet_backbone, 12 | make_stage, 13 | BottleneckBlock, 14 | ) 15 | 16 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 17 | # TODO can expose more resnet blocks after careful consideration 18 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/modeling/backbone/backbone.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from abc import ABCMeta, abstractmethod 3 | import torch.nn as nn 4 | 5 | from detectron2.layers import ShapeSpec 6 | 7 | __all__ = ["Backbone"] 8 | 9 | 10 | class Backbone(nn.Module, metaclass=ABCMeta): 11 | """ 12 | Abstract base class for network backbones. 13 | """ 14 | 15 | def __init__(self): 16 | """ 17 | The `__init__` method of any subclass can specify its own set of arguments. 18 | """ 19 | super().__init__() 20 | 21 | @abstractmethod 22 | def forward(self): 23 | """ 24 | Subclasses must override this method, but adhere to the same return type. 25 | 26 | Returns: 27 | dict[str->Tensor]: mapping from feature name (e.g., "res2") to tensor 28 | """ 29 | pass 30 | 31 | @property 32 | def size_divisibility(self) -> int: 33 | """ 34 | Some backbones require the input height and width to be divisible by a 35 | specific integer. This is typically true for encoder / decoder type networks 36 | with lateral connection (e.g., FPN) for which feature maps need to match 37 | dimension in the "bottom up" and "top down" paths. Set to 0 if no specific 38 | input size divisibility is required. 39 | """ 40 | return 0 41 | 42 | def output_shape(self): 43 | """ 44 | Returns: 45 | dict[str->ShapeSpec] 46 | """ 47 | # this is a backward-compatible default 48 | return { 49 | name: ShapeSpec( 50 | channels=self._out_feature_channels[name], stride=self._out_feature_strides[name] 51 | ) 52 | for name in self._out_features 53 | } 54 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/modeling/backbone/build.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from detectron2.layers import ShapeSpec 3 | from detectron2.utils.registry import Registry 4 | 5 | from .backbone import Backbone 6 | 7 | BACKBONE_REGISTRY = Registry("BACKBONE") 8 | BACKBONE_REGISTRY.__doc__ = """ 9 | Registry for backbones, which extract feature maps from images 10 | 11 | The registered object must be a callable that accepts two arguments: 12 | 13 | 1. A :class:`detectron2.config.CfgNode` 14 | 2. A :class:`detectron2.layers.ShapeSpec`, which contains the input shape specification. 15 | 16 | Registered object must return instance of :class:`Backbone`. 17 | """ 18 | 19 | 20 | def build_backbone(cfg, input_shape=None): 21 | """ 22 | Build a backbone from `cfg.MODEL.BACKBONE.NAME`. 23 | 24 | Returns: 25 | an instance of :class:`Backbone` 26 | """ 27 | if input_shape is None: 28 | input_shape = ShapeSpec(channels=len(cfg.MODEL.PIXEL_MEAN)) 29 | 30 | backbone_name = cfg.MODEL.BACKBONE.NAME 31 | backbone = BACKBONE_REGISTRY.get(backbone_name)(cfg, input_shape) 32 | assert isinstance(backbone, Backbone) 33 | return backbone 34 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/modeling/meta_arch/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | 4 | from .build import META_ARCH_REGISTRY, build_model # isort:skip 5 | 6 | from .panoptic_fpn import PanopticFPN 7 | 8 | # import all the meta_arch, so they will be registered 9 | from .rcnn import GeneralizedRCNN, ProposalNetwork 10 | from .dense_detector import DenseDetector 11 | from .retinanet import RetinaNet 12 | from .fcos import FCOS 13 | from .semantic_seg import SEM_SEG_HEADS_REGISTRY, SemanticSegmentor, build_sem_seg_head 14 | 15 | 16 | __all__ = list(globals().keys()) 17 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/modeling/meta_arch/build.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | import torch 3 | 4 | from detectron2.utils.logger import _log_api_usage 5 | from detectron2.utils.registry import Registry 6 | 7 | META_ARCH_REGISTRY = Registry("META_ARCH") # noqa F401 isort:skip 8 | META_ARCH_REGISTRY.__doc__ = """ 9 | Registry for meta-architectures, i.e. the whole model. 10 | 11 | The registered object will be called with `obj(cfg)` 12 | and expected to return a `nn.Module` object. 13 | """ 14 | 15 | 16 | def build_model(cfg): 17 | """ 18 | Build the whole model architecture, defined by ``cfg.MODEL.META_ARCHITECTURE``. 19 | Note that it does not load any weights from ``cfg``. 20 | """ 21 | meta_arch = cfg.MODEL.META_ARCHITECTURE 22 | model = META_ARCH_REGISTRY.get(meta_arch)(cfg) 23 | model.to(torch.device(cfg.MODEL.DEVICE)) 24 | _log_api_usage("modeling.meta_arch." + meta_arch) 25 | return model 26 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/modeling/proposal_generator/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .build import PROPOSAL_GENERATOR_REGISTRY, build_proposal_generator 3 | from .rpn import RPN_HEAD_REGISTRY, build_rpn_head, RPN, StandardRPNHead 4 | 5 | __all__ = list(globals().keys()) 6 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/modeling/proposal_generator/build.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from detectron2.utils.registry import Registry 3 | 4 | PROPOSAL_GENERATOR_REGISTRY = Registry("PROPOSAL_GENERATOR") 5 | PROPOSAL_GENERATOR_REGISTRY.__doc__ = """ 6 | Registry for proposal generator, which produces object proposals from feature maps. 7 | 8 | The registered object will be called with `obj(cfg, input_shape)`. 9 | The call should return a `nn.Module` object. 10 | """ 11 | 12 | from . import rpn, rrpn # noqa F401 isort:skip 13 | 14 | 15 | def build_proposal_generator(cfg, input_shape): 16 | """ 17 | Build a proposal generator from `cfg.MODEL.PROPOSAL_GENERATOR.NAME`. 18 | The name can be "PrecomputedProposals" to use no proposal generator. 19 | """ 20 | name = cfg.MODEL.PROPOSAL_GENERATOR.NAME 21 | if name == "PrecomputedProposals": 22 | return None 23 | 24 | return PROPOSAL_GENERATOR_REGISTRY.get(name)(cfg, input_shape) 25 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/modeling/roi_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .box_head import ROI_BOX_HEAD_REGISTRY, build_box_head, FastRCNNConvFCHead 3 | from .keypoint_head import ( 4 | ROI_KEYPOINT_HEAD_REGISTRY, 5 | build_keypoint_head, 6 | BaseKeypointRCNNHead, 7 | KRCNNConvDeconvUpsampleHead, 8 | ) 9 | from .mask_head import ( 10 | ROI_MASK_HEAD_REGISTRY, 11 | build_mask_head, 12 | BaseMaskRCNNHead, 13 | MaskRCNNConvUpsampleHead, 14 | ) 15 | from .roi_heads import ( 16 | ROI_HEADS_REGISTRY, 17 | ROIHeads, 18 | Res5ROIHeads, 19 | StandardROIHeads, 20 | build_roi_heads, 21 | select_foreground_proposals, 22 | ) 23 | from .cascade_rcnn import CascadeROIHeads 24 | from .rotated_fast_rcnn import RROIHeads 25 | from .fast_rcnn import FastRCNNOutputLayers 26 | 27 | from . import cascade_rcnn # isort:skip 28 | 29 | __all__ = list(globals().keys()) 30 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/projects/README.md: -------------------------------------------------------------------------------- 1 | 2 | Projects live in the [`projects` directory](../../projects) under the root of this repository, but not here. 3 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/projects/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | import importlib 3 | from pathlib import Path 4 | 5 | _PROJECTS = { 6 | "point_rend": "PointRend", 7 | "deeplab": "DeepLab", 8 | "panoptic_deeplab": "Panoptic-DeepLab", 9 | } 10 | _PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent / "projects" 11 | 12 | if _PROJECT_ROOT.is_dir(): 13 | # This is true only for in-place installation (pip install -e, setup.py develop), 14 | # where setup(package_dir=) does not work: https://github.com/pypa/setuptools/issues/230 15 | 16 | class _D2ProjectsFinder(importlib.abc.MetaPathFinder): 17 | def find_spec(self, name, path, target=None): 18 | if not name.startswith("detectron2.projects."): 19 | return 20 | project_name = name.split(".")[-1] 21 | project_dir = _PROJECTS.get(project_name) 22 | if not project_dir: 23 | return 24 | target_file = _PROJECT_ROOT / f"{project_dir}/{project_name}/__init__.py" 25 | if not target_file.is_file(): 26 | return 27 | return importlib.util.spec_from_file_location(name, target_file) 28 | 29 | import sys 30 | 31 | sys.meta_path.append(_D2ProjectsFinder()) 32 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/solver/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .build import build_lr_scheduler, build_optimizer, get_default_optimizer_params 3 | from .lr_scheduler import WarmupCosineLR, WarmupMultiStepLR, LRMultiplier, WarmupParamScheduler 4 | 5 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 6 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/structures/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .boxes import Boxes, BoxMode, pairwise_iou, pairwise_ioa, pairwise_point_box_distance 3 | from .image_list import ImageList 4 | 5 | from .instances import Instances 6 | from .keypoints import Keypoints, heatmaps_to_keypoints 7 | from .masks import BitMasks, PolygonMasks, polygons_to_bitmask, ROIMasks 8 | from .rotated_boxes import RotatedBoxes 9 | from .rotated_boxes import pairwise_iou as pairwise_iou_rotated 10 | 11 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 12 | 13 | 14 | from detectron2.utils.env import fixup_module_metadata 15 | 16 | fixup_module_metadata(__name__, globals(), __all__) 17 | del fixup_module_metadata 18 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/utils/README.md: -------------------------------------------------------------------------------- 1 | # Utility functions 2 | 3 | This folder contain utility functions that are not used in the 4 | core library, but are useful for building models or training 5 | code using the config system. 6 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/utils/file_io.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from iopath.common.file_io import HTTPURLHandler, OneDrivePathHandler, PathHandler 3 | from iopath.common.file_io import PathManager as PathManagerBase 4 | 5 | __all__ = ["PathManager", "PathHandler"] 6 | 7 | 8 | PathManager = PathManagerBase() 9 | """ 10 | This is a detectron2 project-specific PathManager. 11 | We try to stay away from global PathManager in fvcore as it 12 | introduces potential conflicts among other libraries. 13 | """ 14 | 15 | 16 | class Detectron2Handler(PathHandler): 17 | """ 18 | Resolve anything that's hosted under detectron2's namespace. 19 | """ 20 | 21 | PREFIX = "detectron2://" 22 | S3_DETECTRON2_PREFIX = "https://dl.fbaipublicfiles.com/detectron2/" 23 | 24 | def _get_supported_prefixes(self): 25 | return [self.PREFIX] 26 | 27 | def _get_local_path(self, path, **kwargs): 28 | name = path[len(self.PREFIX) :] 29 | return PathManager.get_local_path(self.S3_DETECTRON2_PREFIX + name, **kwargs) 30 | 31 | def _open(self, path, mode="r", **kwargs): 32 | return PathManager.open(self._get_local_path(path), mode, **kwargs) 33 | 34 | 35 | PathManager.register_handler(HTTPURLHandler()) 36 | PathManager.register_handler(OneDrivePathHandler()) 37 | PathManager.register_handler(Detectron2Handler()) 38 | -------------------------------------------------------------------------------- /third_party/CenterNet2/detectron2/utils/serialize.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | import cloudpickle 3 | 4 | 5 | class PicklableWrapper(object): 6 | """ 7 | Wrap an object to make it more picklable, note that it uses 8 | heavy weight serialization libraries that are slower than pickle. 9 | It's best to use it only on closures (which are usually not picklable). 10 | 11 | This is a simplified version of 12 | https://github.com/joblib/joblib/blob/master/joblib/externals/loky/cloudpickle_wrapper.py 13 | """ 14 | 15 | def __init__(self, obj): 16 | while isinstance(obj, PicklableWrapper): 17 | # Wrapping an object twice is no-op 18 | obj = obj._obj 19 | self._obj = obj 20 | 21 | def __reduce__(self): 22 | s = cloudpickle.dumps(self._obj) 23 | return cloudpickle.loads, (s,) 24 | 25 | def __call__(self, *args, **kwargs): 26 | return self._obj(*args, **kwargs) 27 | 28 | def __getattr__(self, attr): 29 | # Ensure that the wrapped object can be used seamlessly as the previous object. 30 | if attr not in ["_obj"]: 31 | return getattr(self._obj, attr) 32 | return getattr(self, attr) 33 | -------------------------------------------------------------------------------- /third_party/CenterNet2/dev/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Some scripts for developers to use, include: 3 | 4 | - `linter.sh`: lint the codebase before commit. 5 | - `run_{inference,instant}_tests.sh`: run inference/training for a few iterations. 6 | Note that these tests require 2 GPUs. 7 | - `parse_results.sh`: parse results from a log file. 8 | -------------------------------------------------------------------------------- /third_party/CenterNet2/dev/linter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | 4 | # cd to detectron2 project root 5 | cd "$(dirname "${BASH_SOURCE[0]}")/.." 6 | 7 | { 8 | black --version | grep -E "21\." > /dev/null 9 | } || { 10 | echo "Linter requires 'black==21.*' !" 11 | exit 1 12 | } 13 | 14 | ISORT_VERSION=$(isort --version-number) 15 | if [[ "$ISORT_VERSION" != 4.3* ]]; then 16 | echo "Linter requires isort==4.3.21 !" 17 | exit 1 18 | fi 19 | 20 | set -v 21 | 22 | echo "Running isort ..." 23 | isort -y -sp . --atomic 24 | 25 | echo "Running black ..." 26 | black -l 100 . 27 | 28 | echo "Running flake8 ..." 29 | if [ -x "$(command -v flake8-3)" ]; then 30 | flake8-3 . 31 | else 32 | python3 -m flake8 . 33 | fi 34 | 35 | # echo "Running mypy ..." 36 | # Pytorch does not have enough type annotations 37 | # mypy detectron2/solver detectron2/structures detectron2/config 38 | 39 | echo "Running clang-format ..." 40 | find . -regex ".*\.\(cpp\|c\|cc\|cu\|cxx\|h\|hh\|hpp\|hxx\|tcc\|mm\|m\)" -print0 | xargs -0 clang-format -i 41 | 42 | command -v arc > /dev/null && arc lint 43 | -------------------------------------------------------------------------------- /third_party/CenterNet2/dev/packaging/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## To build a cu101 wheel for release: 3 | 4 | ``` 5 | $ nvidia-docker run -it --storage-opt "size=20GB" --name pt pytorch/manylinux-cuda101 6 | # inside the container: 7 | # git clone https://github.com/facebookresearch/detectron2/ 8 | # cd detectron2 9 | # export CU_VERSION=cu101 D2_VERSION_SUFFIX= PYTHON_VERSION=3.7 PYTORCH_VERSION=1.8 10 | # ./dev/packaging/build_wheel.sh 11 | ``` 12 | 13 | ## To build all wheels for combinations of CUDA and Python 14 | ``` 15 | ./dev/packaging/build_all_wheels.sh 16 | ./dev/packaging/gen_wheel_index.sh /path/to/wheels 17 | ``` 18 | -------------------------------------------------------------------------------- /third_party/CenterNet2/dev/packaging/build_all_wheels.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | 4 | [[ -d "dev/packaging" ]] || { 5 | echo "Please run this script at detectron2 root!" 6 | exit 1 7 | } 8 | 9 | build_one() { 10 | cu=$1 11 | pytorch_ver=$2 12 | 13 | case "$cu" in 14 | cu*) 15 | container_name=manylinux-cuda${cu/cu/} 16 | ;; 17 | cpu) 18 | container_name=manylinux-cuda101 19 | ;; 20 | *) 21 | echo "Unrecognized cu=$cu" 22 | exit 1 23 | ;; 24 | esac 25 | 26 | echo "Launching container $container_name ..." 27 | container_id="$container_name"_"$cu"_"$pytorch_ver" 28 | 29 | py_versions=(3.6 3.7 3.8 3.9) 30 | 31 | for py in "${py_versions[@]}"; do 32 | docker run -itd \ 33 | --name "$container_id" \ 34 | --mount type=bind,source="$(pwd)",target=/detectron2 \ 35 | pytorch/$container_name 36 | 37 | cat </dev/null 2>&1 && pwd )" 8 | . "$script_dir/pkg_helpers.bash" 9 | 10 | echo "Build Settings:" 11 | echo "CU_VERSION: $CU_VERSION" # e.g. cu101 12 | echo "D2_VERSION_SUFFIX: $D2_VERSION_SUFFIX" # e.g. +cu101 or "" 13 | echo "PYTHON_VERSION: $PYTHON_VERSION" # e.g. 3.6 14 | echo "PYTORCH_VERSION: $PYTORCH_VERSION" # e.g. 1.4 15 | 16 | setup_cuda 17 | setup_wheel_python 18 | 19 | yum install ninja-build -y 20 | ln -sv /usr/bin/ninja-build /usr/bin/ninja || true 21 | 22 | pip_install pip numpy -U 23 | pip_install "torch==$PYTORCH_VERSION" \ 24 | -f https://download.pytorch.org/whl/"$CU_VERSION"/torch_stable.html 25 | 26 | # use separate directories to allow parallel build 27 | BASE_BUILD_DIR=build/$CU_VERSION-py$PYTHON_VERSION-pt$PYTORCH_VERSION 28 | python setup.py \ 29 | build -b "$BASE_BUILD_DIR" \ 30 | bdist_wheel -b "$BASE_BUILD_DIR/build_dist" -d "wheels/$CU_VERSION/torch$PYTORCH_VERSION" 31 | rm -rf "$BASE_BUILD_DIR" 32 | -------------------------------------------------------------------------------- /third_party/CenterNet2/dev/packaging/gen_wheel_index.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | 4 | 5 | root=$(readlink -f $1) 6 | if [[ -z "$root" ]]; then 7 | echo "Usage: ./gen_wheel_index.sh /absolute/path/to/wheels" 8 | exit 9 | fi 10 | 11 | export LC_ALL=C # reproducible sort 12 | # NOTE: all sort in this script might not work when xx.10 is released 13 | 14 | index=$root/index.html 15 | 16 | cd "$root" 17 | for cu in cpu cu92 cu100 cu101 cu102 cu110 cu111 cu113; do 18 | mkdir -p "$root/$cu" 19 | cd "$root/$cu" 20 | echo "Creating $PWD/index.html ..." 21 | # First sort by torch version, then stable sort by d2 version with unique. 22 | # As a result, the latest torch version for each d2 version is kept. 23 | for whl in $(find -type f -name '*.whl' -printf '%P\n' \ 24 | | sort -k 1 -r | sort -t '/' -k 2 --stable -r --unique); do 25 | echo "$whl
" 26 | done > index.html 27 | 28 | 29 | for torch in torch*; do 30 | cd "$root/$cu/$torch" 31 | 32 | # list all whl for each cuda,torch version 33 | echo "Creating $PWD/index.html ..." 34 | for whl in $(find . -type f -name '*.whl' -printf '%P\n' | sort -r); do 35 | echo "$whl
" 36 | done > index.html 37 | done 38 | done 39 | 40 | cd "$root" 41 | # Just list everything: 42 | echo "Creating $index ..." 43 | for whl in $(find . -type f -name '*.whl' -printf '%P\n' | sort -r); do 44 | echo "$whl
" 45 | done > "$index" 46 | 47 | -------------------------------------------------------------------------------- /third_party/CenterNet2/dev/run_inference_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | 4 | BIN="python tools/train_net.py" 5 | OUTPUT="inference_test_output" 6 | NUM_GPUS=2 7 | 8 | CFG_LIST=( "${@:1}" ) 9 | 10 | if [ ${#CFG_LIST[@]} -eq 0 ]; then 11 | CFG_LIST=( ./configs/quick_schedules/*inference_acc_test.yaml ) 12 | fi 13 | 14 | echo "========================================================================" 15 | echo "Configs to run:" 16 | echo "${CFG_LIST[@]}" 17 | echo "========================================================================" 18 | 19 | 20 | for cfg in "${CFG_LIST[@]}"; do 21 | echo "========================================================================" 22 | echo "Running $cfg ..." 23 | echo "========================================================================" 24 | $BIN \ 25 | --eval-only \ 26 | --num-gpus $NUM_GPUS \ 27 | --config-file "$cfg" \ 28 | OUTPUT_DIR $OUTPUT 29 | rm -rf $OUTPUT 30 | done 31 | 32 | 33 | echo "========================================================================" 34 | echo "Running demo.py ..." 35 | echo "========================================================================" 36 | DEMO_BIN="python demo/demo.py" 37 | COCO_DIR=datasets/coco/val2014 38 | mkdir -pv $OUTPUT 39 | 40 | set -v 41 | 42 | $DEMO_BIN --config-file ./configs/quick_schedules/panoptic_fpn_R_50_inference_acc_test.yaml \ 43 | --input $COCO_DIR/COCO_val2014_0000001933* --output $OUTPUT 44 | rm -rf $OUTPUT 45 | -------------------------------------------------------------------------------- /third_party/CenterNet2/dev/run_instant_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | 4 | BIN="python tools/train_net.py" 5 | OUTPUT="instant_test_output" 6 | NUM_GPUS=2 7 | 8 | CFG_LIST=( "${@:1}" ) 9 | if [ ${#CFG_LIST[@]} -eq 0 ]; then 10 | CFG_LIST=( ./configs/quick_schedules/*instant_test.yaml ) 11 | fi 12 | 13 | echo "========================================================================" 14 | echo "Configs to run:" 15 | echo "${CFG_LIST[@]}" 16 | echo "========================================================================" 17 | 18 | for cfg in "${CFG_LIST[@]}"; do 19 | echo "========================================================================" 20 | echo "Running $cfg ..." 21 | echo "========================================================================" 22 | $BIN --num-gpus $NUM_GPUS --config-file "$cfg" \ 23 | SOLVER.IMS_PER_BATCH $(($NUM_GPUS * 2)) \ 24 | OUTPUT_DIR "$OUTPUT" 25 | rm -rf "$OUTPUT" 26 | done 27 | 28 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docker/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Use the container (with docker ≥ 19.03) 3 | 4 | ``` 5 | cd docker/ 6 | # Build: 7 | docker build --build-arg USER_ID=$UID -t detectron2:v0 . 8 | # Launch (require GPUs): 9 | docker run --gpus all -it \ 10 | --shm-size=8gb --env="DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ 11 | --name=detectron2 detectron2:v0 12 | 13 | # Grant docker access to host X server to show images 14 | xhost +local:`docker inspect --format='{{ .Config.Hostname }}' detectron2` 15 | ``` 16 | 17 | ## Use the container (with docker-compose ≥ 1.28.0) 18 | 19 | Install docker-compose and nvidia-docker-toolkit, then run: 20 | ``` 21 | cd docker && USER_ID=$UID docker-compose run detectron2 22 | ``` 23 | 24 | ## Use the deployment container (to test C++ examples) 25 | After building the base detectron2 container as above, do: 26 | ``` 27 | # Build: 28 | docker build -t detectron2-deploy:v0 -f deploy.Dockerfile . 29 | # Launch: 30 | docker run --gpus all -it detectron2-deploy:v0 31 | ``` 32 | 33 | #### Using a persistent cache directory 34 | 35 | You can prevent models from being re-downloaded on every run, 36 | by storing them in a cache directory. 37 | 38 | To do this, add `--volume=$HOME/.torch/fvcore_cache:/tmp:rw` in the run command. 39 | 40 | ## Install new dependencies 41 | Add the following to `Dockerfile` to make persistent changes. 42 | ``` 43 | RUN sudo apt-get update && sudo apt-get install -y vim 44 | ``` 45 | Or run them in the container to make temporary changes. 46 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docker/deploy.Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # This file defines a container that compiles the C++ examples of detectron2. 3 | # See docker/README.md for usage. 4 | 5 | # Depends on the image produced by "./Dockerfile" 6 | FROM detectron2:v0 7 | 8 | USER appuser 9 | ENV HOME=/home/appuser 10 | WORKDIR $HOME 11 | 12 | # Let torchvision find libtorch 13 | ENV CMAKE_PREFIX_PATH=$HOME/.local/lib/python3.6/site-packages/torch/ 14 | 15 | RUN sudo apt-get update && sudo apt-get install libopencv-dev --yes 16 | 17 | # install libtorchvision 18 | RUN git clone --branch v0.11.1 https://github.com/pytorch/vision/ 19 | RUN mkdir vision/build && cd vision/build && \ 20 | cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/.local -DCMAKE_BUILD_TYPE=Release -DWITH_CUDA=on -DTORCH_CUDA_ARCH_LIST=$TORCH_CUDA_ARCH_LIST && \ 21 | make -j && make install 22 | 23 | # make our installation take effect 24 | ENV CPATH=$HOME/.local/include \ 25 | LIBRARY_PATH=$HOME/.local/lib \ 26 | LD_LIBRARY_PATH=$HOME/.local/lib 27 | 28 | 29 | # build C++ examples of detectron2 30 | RUN cd detectron2_repo/tools/deploy && mkdir build && cd build && \ 31 | cmake -DTORCH_CUDA_ARCH_LIST=$TORCH_CUDA_ARCH_LIST .. && make 32 | # binaries will be available under tools/deploy/build 33 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "2.3" 2 | services: 3 | detectron2: 4 | build: 5 | context: . 6 | dockerfile: Dockerfile 7 | args: 8 | USER_ID: ${USER_ID:-1000} 9 | deploy: 10 | resources: 11 | reservations: 12 | devices: 13 | - capabilities: 14 | - gpu 15 | shm_size: "8gb" 16 | ulimits: 17 | memlock: -1 18 | stack: 67108864 19 | volumes: 20 | - /tmp/.X11-unix:/tmp/.X11-unix:ro 21 | environment: 22 | - DISPLAY=$DISPLAY 23 | - NVIDIA_VISIBLE_DEVICES=all 24 | # Uncomment with proper source to access webcam from docker 25 | # devices: 26 | # - /dev/video0:/dev/video0 27 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SOURCEDIR = . 8 | BUILDDIR = _build 9 | 10 | # Put it first so that "make" without argument is like "make help". 11 | help: 12 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 13 | 14 | .PHONY: help Makefile 15 | 16 | # Catch-all target: route all unknown targets to Sphinx using the new 17 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 18 | %: Makefile 19 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 20 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/README.md: -------------------------------------------------------------------------------- 1 | # Read the docs: 2 | 3 | The latest documentation built from this directory is available at [detectron2.readthedocs.io](https://detectron2.readthedocs.io/). 4 | Documents in this directory are not meant to be read on github. 5 | 6 | # Build the docs: 7 | 8 | 1. Install detectron2 according to [INSTALL.md](../INSTALL.md). 9 | 2. Install additional libraries required to build docs: 10 | - docutils==0.16 11 | - Sphinx==3.2.0 12 | - recommonmark==0.6.0 13 | - sphinx_rtd_theme 14 | 15 | 3. Run `make html` from this directory. 16 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/_static/css/custom.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * some extra css to make markdown look similar between github/sphinx 4 | */ 5 | 6 | /* 7 | * Below is for install.md: 8 | */ 9 | .rst-content code { 10 | white-space: pre; 11 | border: 0px; 12 | } 13 | 14 | .rst-content th { 15 | border: 1px solid #e1e4e5; 16 | } 17 | 18 | .rst-content th p { 19 | /* otherwise will be default 24px for regular paragraph */ 20 | margin-bottom: 0px; 21 | } 22 | 23 | .rst-content .line-block { 24 | /* otherwise will be 24px */ 25 | margin-bottom: 0px; 26 | } 27 | 28 | div.section > details { 29 | padding-bottom: 1em; 30 | } 31 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/index.rst: -------------------------------------------------------------------------------- 1 | .. detectron2 documentation master file, created by 2 | sphinx-quickstart on Sat Sep 21 13:46:45 2019. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to detectron2's documentation! 7 | ====================================== 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | 12 | tutorials/index 13 | notes/index 14 | modules/index 15 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/modules/checkpoint.rst: -------------------------------------------------------------------------------- 1 | detectron2.checkpoint 2 | ============================= 3 | 4 | .. automodule:: detectron2.checkpoint 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/modules/config.rst: -------------------------------------------------------------------------------- 1 | detectron2.config 2 | ========================= 3 | 4 | Related tutorials: :doc:`../tutorials/configs`, :doc:`../tutorials/extend`. 5 | 6 | .. automodule:: detectron2.config 7 | :members: 8 | :undoc-members: 9 | :show-inheritance: 10 | 11 | 12 | Yaml Config References 13 | ----------------- 14 | 15 | .. literalinclude:: ../../detectron2/config/defaults.py 16 | :language: python 17 | :linenos: 18 | :lines: 7- 19 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/modules/data.rst: -------------------------------------------------------------------------------- 1 | detectron2.data 2 | ======================= 3 | 4 | .. autodata:: detectron2.data.DatasetCatalog(dict) 5 | :annotation: 6 | 7 | .. autodata:: detectron2.data.MetadataCatalog(dict) 8 | :annotation: 9 | 10 | .. automodule:: detectron2.data 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | detectron2.data.detection\_utils module 16 | --------------------------------------- 17 | 18 | .. automodule:: detectron2.data.detection_utils 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | detectron2.data.datasets module 24 | --------------------------------------- 25 | 26 | .. automodule:: detectron2.data.datasets 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | detectron2.data.samplers module 32 | --------------------------------------- 33 | 34 | .. automodule:: detectron2.data.samplers 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/modules/data_transforms.rst: -------------------------------------------------------------------------------- 1 | detectron2.data.transforms 2 | ==================================== 3 | 4 | Related tutorial: :doc:`../tutorials/augmentation`. 5 | 6 | .. automodule:: detectron2.data.transforms 7 | :members: 8 | :undoc-members: 9 | :show-inheritance: 10 | :imported-members: 11 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/modules/engine.rst: -------------------------------------------------------------------------------- 1 | detectron2.engine 2 | ========================= 3 | 4 | Related tutorial: :doc:`../tutorials/training`. 5 | 6 | .. automodule:: detectron2.engine 7 | :members: 8 | :undoc-members: 9 | :show-inheritance: 10 | 11 | 12 | detectron2.engine.defaults module 13 | --------------------------------- 14 | 15 | .. automodule:: detectron2.engine.defaults 16 | :members: 17 | :undoc-members: 18 | :show-inheritance: 19 | 20 | detectron2.engine.hooks module 21 | --------------------------------- 22 | 23 | .. automodule:: detectron2.engine.hooks 24 | :members: 25 | :undoc-members: 26 | :show-inheritance: 27 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/modules/evaluation.rst: -------------------------------------------------------------------------------- 1 | detectron2.evaluation 2 | ============================= 3 | 4 | .. automodule:: detectron2.evaluation 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/modules/export.rst: -------------------------------------------------------------------------------- 1 | detectron2.export 2 | ========================= 3 | 4 | Related tutorial: :doc:`../tutorials/deployment`. 5 | 6 | .. automodule:: detectron2.export 7 | :members: 8 | :undoc-members: 9 | :show-inheritance: 10 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/modules/fvcore.rst: -------------------------------------------------------------------------------- 1 | fvcore documentation 2 | ==================== 3 | 4 | Detectron2 depends on utilities in 5 | `fvcore `_. 6 | We include part of fvcore documentation here for easier reference. 7 | 8 | fvcore.nn 9 | ----------------- 10 | 11 | .. automodule:: fvcore.nn 12 | :members: 13 | :inherited-members: 14 | :undoc-members: 15 | :show-inheritance: 16 | 17 | fvcore.common 18 | --------------------- 19 | 20 | .. automodule:: fvcore.common.checkpoint 21 | :members: 22 | :undoc-members: 23 | :show-inheritance: 24 | 25 | .. automodule:: fvcore.common.config 26 | :members: 27 | :undoc-members: 28 | :show-inheritance: 29 | 30 | .. automodule:: fvcore.common.history_buffer 31 | :members: 32 | :undoc-members: 33 | :show-inheritance: 34 | 35 | .. automodule:: fvcore.common.param_scheduler 36 | :members: 37 | :inherited-members: 38 | :undoc-members: 39 | :show-inheritance: 40 | 41 | .. automodule:: fvcore.common.registry 42 | :members: 43 | :undoc-members: 44 | :show-inheritance: 45 | 46 | .. automodule:: fvcore.common.timer 47 | :members: 48 | :undoc-members: 49 | :show-inheritance: 50 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/modules/index.rst: -------------------------------------------------------------------------------- 1 | API Documentation 2 | ================== 3 | 4 | .. toctree:: 5 | 6 | checkpoint 7 | config 8 | data 9 | data_transforms 10 | engine 11 | evaluation 12 | layers 13 | model_zoo 14 | modeling 15 | solver 16 | structures 17 | utils 18 | export 19 | fvcore 20 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/modules/layers.rst: -------------------------------------------------------------------------------- 1 | detectron2.layers 2 | ========================= 3 | 4 | .. automodule:: detectron2.layers 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/modules/model_zoo.rst: -------------------------------------------------------------------------------- 1 | detectron2.model_zoo 2 | ============================ 3 | 4 | .. automodule:: detectron2.model_zoo 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/modules/modeling.rst: -------------------------------------------------------------------------------- 1 | detectron2.modeling 2 | =========================== 3 | 4 | .. automodule:: detectron2.modeling 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | 9 | 10 | detectron2.modeling.poolers module 11 | --------------------------------------- 12 | 13 | .. automodule:: detectron2.modeling.poolers 14 | :members: 15 | :undoc-members: 16 | :show-inheritance: 17 | 18 | 19 | detectron2.modeling.sampling module 20 | ------------------------------------ 21 | 22 | .. automodule:: detectron2.modeling.sampling 23 | :members: 24 | :undoc-members: 25 | :show-inheritance: 26 | 27 | 28 | detectron2.modeling.box_regression module 29 | ------------------------------------------ 30 | 31 | .. automodule:: detectron2.modeling.box_regression 32 | :members: 33 | :undoc-members: 34 | :show-inheritance: 35 | 36 | 37 | Model Registries 38 | ----------------- 39 | 40 | These are different registries provided in modeling. 41 | Each registry provide you the ability to replace it with your customized component, 42 | without having to modify detectron2's code. 43 | 44 | Note that it is impossible to allow users to customize any line of code directly. 45 | Even just to add one line at some place, 46 | you'll likely need to find out the smallest registry which contains that line, 47 | and register your component to that registry. 48 | 49 | 50 | .. autodata:: detectron2.modeling.META_ARCH_REGISTRY 51 | .. autodata:: detectron2.modeling.BACKBONE_REGISTRY 52 | .. autodata:: detectron2.modeling.PROPOSAL_GENERATOR_REGISTRY 53 | .. autodata:: detectron2.modeling.RPN_HEAD_REGISTRY 54 | .. autodata:: detectron2.modeling.ANCHOR_GENERATOR_REGISTRY 55 | .. autodata:: detectron2.modeling.ROI_HEADS_REGISTRY 56 | .. autodata:: detectron2.modeling.ROI_BOX_HEAD_REGISTRY 57 | .. autodata:: detectron2.modeling.ROI_MASK_HEAD_REGISTRY 58 | .. autodata:: detectron2.modeling.ROI_KEYPOINT_HEAD_REGISTRY 59 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/modules/solver.rst: -------------------------------------------------------------------------------- 1 | detectron2.solver 2 | ========================= 3 | 4 | .. automodule:: detectron2.solver 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/modules/structures.rst: -------------------------------------------------------------------------------- 1 | detectron2.structures 2 | ============================= 3 | 4 | .. automodule:: detectron2.structures 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/modules/utils.rst: -------------------------------------------------------------------------------- 1 | detectron2.utils 2 | ======================== 3 | 4 | detectron2.utils.colormap module 5 | -------------------------------- 6 | 7 | .. automodule:: detectron2.utils.colormap 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | 12 | detectron2.utils.comm module 13 | ---------------------------- 14 | 15 | .. automodule:: detectron2.utils.comm 16 | :members: 17 | :undoc-members: 18 | :show-inheritance: 19 | 20 | 21 | detectron2.utils.events module 22 | ------------------------------ 23 | 24 | .. automodule:: detectron2.utils.events 25 | :members: 26 | :undoc-members: 27 | :show-inheritance: 28 | 29 | 30 | detectron2.utils.logger module 31 | ------------------------------ 32 | 33 | .. automodule:: detectron2.utils.logger 34 | :members: 35 | :undoc-members: 36 | :show-inheritance: 37 | 38 | 39 | detectron2.utils.registry module 40 | -------------------------------- 41 | 42 | .. automodule:: detectron2.utils.registry 43 | :members: 44 | :undoc-members: 45 | :show-inheritance: 46 | 47 | detectron2.utils.memory module 48 | ---------------------------------- 49 | 50 | .. automodule:: detectron2.utils.memory 51 | :members: 52 | :undoc-members: 53 | :show-inheritance: 54 | 55 | 56 | detectron2.utils.analysis module 57 | ---------------------------------- 58 | 59 | .. automodule:: detectron2.utils.analysis 60 | :members: 61 | :undoc-members: 62 | :show-inheritance: 63 | 64 | 65 | detectron2.utils.visualizer module 66 | ---------------------------------- 67 | 68 | .. automodule:: detectron2.utils.visualizer 69 | :members: 70 | :undoc-members: 71 | :show-inheritance: 72 | 73 | detectron2.utils.video\_visualizer module 74 | ----------------------------------------- 75 | 76 | .. automodule:: detectron2.utils.video_visualizer 77 | :members: 78 | :undoc-members: 79 | :show-inheritance: 80 | 81 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/notes/contributing.md: -------------------------------------------------------------------------------- 1 | ../../.github/CONTRIBUTING.md -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/notes/index.rst: -------------------------------------------------------------------------------- 1 | Notes 2 | ====================================== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | benchmarks 8 | compatibility 9 | contributing 10 | changelog 11 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/requirements.txt: -------------------------------------------------------------------------------- 1 | docutils==0.16 2 | # https://github.com/sphinx-doc/sphinx/commit/7acd3ada3f38076af7b2b5c9f3b60bb9c2587a3d 3 | sphinx==3.2.0 4 | recommonmark==0.6.0 5 | sphinx_rtd_theme 6 | # Dependencies here are only those required by import 7 | termcolor 8 | numpy 9 | tqdm 10 | matplotlib 11 | termcolor 12 | yacs 13 | tabulate 14 | cloudpickle 15 | Pillow 16 | future 17 | git+git://github.com/facebookresearch/fvcore.git 18 | https://download.pytorch.org/whl/cpu/torch-1.8.1%2Bcpu-cp37-cp37m-linux_x86_64.whl 19 | https://download.pytorch.org/whl/cpu/torchvision-0.9.1%2Bcpu-cp37-cp37m-linux_x86_64.whl 20 | omegaconf>=2.1.0.dev24 21 | hydra-core>=1.1.0.dev5 22 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/tutorials/README.md: -------------------------------------------------------------------------------- 1 | # Read the docs: 2 | 3 | The latest documentation built from this directory is available at [detectron2.readthedocs.io](https://detectron2.readthedocs.io/). 4 | Documents in this directory are not meant to be read on github. 5 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/tutorials/builtin_datasets.md: -------------------------------------------------------------------------------- 1 | ../../datasets/README.md -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/tutorials/getting_started.md: -------------------------------------------------------------------------------- 1 | ../../GETTING_STARTED.md -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/tutorials/index.rst: -------------------------------------------------------------------------------- 1 | Tutorials 2 | ====================================== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | install 8 | getting_started 9 | builtin_datasets 10 | extend 11 | datasets 12 | data_loading 13 | augmentation 14 | models 15 | write-models 16 | training 17 | evaluation 18 | configs 19 | lazyconfigs 20 | deployment 21 | -------------------------------------------------------------------------------- /third_party/CenterNet2/docs/tutorials/install.md: -------------------------------------------------------------------------------- 1 | ../../INSTALL.md -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/.gitignore: -------------------------------------------------------------------------------- 1 | # compilation and distribution 2 | __pycache__ 3 | _ext 4 | *.pyc 5 | *.pyd 6 | *.so 7 | centernet.egg-info/ 8 | build/ 9 | dist/ 10 | wheels/ 11 | -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/centernet/__init__.py: -------------------------------------------------------------------------------- 1 | from .modeling.meta_arch.centernet_detector import CenterNetDetector 2 | from .modeling.dense_heads.centernet import CenterNet 3 | from .modeling.roi_heads.custom_roi_heads import CustomROIHeads, CustomCascadeROIHeads 4 | 5 | from .modeling.backbone.fpn_p5 import build_p67_resnet_fpn_backbone 6 | from .modeling.backbone.dla import build_dla_backbone 7 | from .modeling.backbone.dlafpn import build_dla_fpn3_backbone 8 | from .modeling.backbone.bifpn import build_resnet_bifpn_backbone 9 | from .modeling.backbone.bifpn_fcos import build_fcos_resnet_bifpn_backbone 10 | from .modeling.backbone.res2net import build_p67_res2net_fpn_backbone 11 | 12 | from .data.datasets.objects365 import categories_v1 13 | from .data.datasets.coco import _PREDEFINED_SPLITS_COCO 14 | from .data.datasets import nuimages 15 | -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/centernet/data/custom_build_augmentation.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import numpy as np 3 | import pycocotools.mask as mask_util 4 | import torch 5 | from fvcore.common.file_io import PathManager 6 | from PIL import Image 7 | 8 | from detectron2.structures import ( 9 | BitMasks, 10 | Boxes, 11 | BoxMode, 12 | Instances, 13 | Keypoints, 14 | PolygonMasks, 15 | RotatedBoxes, 16 | polygons_to_bitmask, 17 | ) 18 | 19 | from detectron2.data import transforms as T 20 | from .transforms.custom_augmentation_impl import EfficientDetResizeCrop 21 | 22 | def build_custom_augmentation(cfg, is_train): 23 | """ 24 | Create a list of default :class:`Augmentation` from config. 25 | Now it includes resizing and flipping. 26 | 27 | Returns: 28 | list[Augmentation] 29 | """ 30 | if cfg.INPUT.CUSTOM_AUG == 'ResizeShortestEdge': 31 | if is_train: 32 | min_size = cfg.INPUT.MIN_SIZE_TRAIN 33 | max_size = cfg.INPUT.MAX_SIZE_TRAIN 34 | sample_style = cfg.INPUT.MIN_SIZE_TRAIN_SAMPLING 35 | else: 36 | min_size = cfg.INPUT.MIN_SIZE_TEST 37 | max_size = cfg.INPUT.MAX_SIZE_TEST 38 | sample_style = "choice" 39 | augmentation = [T.ResizeShortestEdge(min_size, max_size, sample_style)] 40 | elif cfg.INPUT.CUSTOM_AUG == 'EfficientDetResizeCrop': 41 | if is_train: 42 | scale = cfg.INPUT.SCALE_RANGE 43 | size = cfg.INPUT.TRAIN_SIZE 44 | else: 45 | scale = (1, 1) 46 | size = cfg.INPUT.TEST_SIZE 47 | augmentation = [EfficientDetResizeCrop(size, scale)] 48 | else: 49 | assert 0, cfg.INPUT.CUSTOM_AUG 50 | 51 | if is_train: 52 | augmentation.append(T.RandomFlip()) 53 | return augmentation 54 | 55 | 56 | build_custom_transform_gen = build_custom_augmentation 57 | """ 58 | Alias for backward-compatibility. 59 | """ -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/centernet/data/datasets/nuimages.py: -------------------------------------------------------------------------------- 1 | from detectron2.data.datasets.register_coco import register_coco_instances 2 | import os 3 | 4 | categories = [ 5 | {'id': 0, 'name': 'car'}, 6 | {'id': 1, 'name': 'truck'}, 7 | {'id': 2, 'name': 'trailer'}, 8 | {'id': 3, 'name': 'bus'}, 9 | {'id': 4, 'name': 'construction_vehicle'}, 10 | {'id': 5, 'name': 'bicycle'}, 11 | {'id': 6, 'name': 'motorcycle'}, 12 | {'id': 7, 'name': 'pedestrian'}, 13 | {'id': 8, 'name': 'traffic_cone'}, 14 | {'id': 9, 'name': 'barrier'}, 15 | ] 16 | 17 | def _get_builtin_metadata(): 18 | id_to_name = {x['id']: x['name'] for x in categories} 19 | thing_dataset_id_to_contiguous_id = {i: i for i in range(len(categories))} 20 | thing_classes = [id_to_name[k] for k in sorted(id_to_name)] 21 | return { 22 | "thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id, 23 | "thing_classes": thing_classes} 24 | 25 | _PREDEFINED_SPLITS = { 26 | "nuimages_train": ("nuimages", "nuimages/annotations/nuimages_v1.0-train.json"), 27 | "nuimages_val": ("nuimages", "nuimages/annotations/nuimages_v1.0-val.json"), 28 | "nuimages_mini": ("nuimages", "nuimages/annotations/nuimages_v1.0-mini.json"), 29 | } 30 | 31 | for key, (image_root, json_file) in _PREDEFINED_SPLITS.items(): 32 | register_coco_instances( 33 | key, 34 | _get_builtin_metadata(), 35 | os.path.join("datasets", json_file) if "://" not in json_file else json_file, 36 | os.path.join("datasets", image_root), 37 | ) 38 | -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/centernet/modeling/dense_heads/utils.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import torch 3 | from torch import nn 4 | from detectron2.utils.comm import get_world_size 5 | from detectron2.structures import pairwise_iou, Boxes 6 | # from .data import CenterNetCrop 7 | import torch.nn.functional as F 8 | import numpy as np 9 | from detectron2.structures import Boxes, ImageList, Instances 10 | 11 | __all__ = ['reduce_sum', '_transpose'] 12 | 13 | INF = 1000000000 14 | 15 | def _transpose(training_targets, num_loc_list): 16 | ''' 17 | This function is used to transpose image first training targets to 18 | level first ones 19 | :return: level first training targets 20 | ''' 21 | for im_i in range(len(training_targets)): 22 | training_targets[im_i] = torch.split( 23 | training_targets[im_i], num_loc_list, dim=0) 24 | 25 | targets_level_first = [] 26 | for targets_per_level in zip(*training_targets): 27 | targets_level_first.append( 28 | torch.cat(targets_per_level, dim=0)) 29 | return targets_level_first 30 | 31 | 32 | def reduce_sum(tensor): 33 | world_size = get_world_size() 34 | if world_size < 2: 35 | return tensor 36 | tensor = tensor.clone() 37 | torch.distributed.all_reduce(tensor, op=torch.distributed.ReduceOp.SUM) 38 | return tensor -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/centernet/modeling/layers/ml_nms.py: -------------------------------------------------------------------------------- 1 | from detectron2.layers import batched_nms 2 | 3 | 4 | def ml_nms(boxlist, nms_thresh, max_proposals=-1, 5 | score_field="scores", label_field="labels"): 6 | """ 7 | Performs non-maximum suppression on a boxlist, with scores specified 8 | in a boxlist field via score_field. 9 | Arguments: 10 | boxlist(BoxList) 11 | nms_thresh (float) 12 | max_proposals (int): if > 0, then only the top max_proposals are kept 13 | after non-maximum suppression 14 | score_field (str) 15 | """ 16 | if nms_thresh <= 0: 17 | return boxlist 18 | if boxlist.has('pred_boxes'): 19 | boxes = boxlist.pred_boxes.tensor 20 | labels = boxlist.pred_classes 21 | else: 22 | boxes = boxlist.proposal_boxes.tensor 23 | labels = boxlist.proposal_boxes.tensor.new_zeros( 24 | len(boxlist.proposal_boxes.tensor)) 25 | scores = boxlist.scores 26 | 27 | keep = batched_nms(boxes, scores, labels, nms_thresh) 28 | if max_proposals > 0: 29 | keep = keep[: max_proposals] 30 | boxlist = boxlist[keep] 31 | return boxlist 32 | -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/centernet/modeling/roi_heads/fed_loss.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import json 3 | import numpy as np 4 | from torch.nn import functional as F 5 | 6 | def load_class_freq( 7 | path='datasets/lvis/lvis_v1_train_cat_info.json', 8 | freq_weight=0.5): 9 | cat_info = json.load(open(path, 'r')) 10 | cat_info = torch.tensor( 11 | [c['image_count'] for c in sorted(cat_info, key=lambda x: x['id'])]) 12 | freq_weight = cat_info.float() ** freq_weight 13 | return freq_weight 14 | 15 | def get_fed_loss_inds( 16 | gt_classes, num_sample_cats=50, C=1203, \ 17 | weight=None, fed_cls_inds=-1): 18 | appeared = torch.unique(gt_classes) # C' 19 | prob = appeared.new_ones(C + 1).float() 20 | prob[-1] = 0 21 | if len(appeared) < num_sample_cats: 22 | if weight is not None: 23 | prob[:C] = weight.float().clone() 24 | prob[appeared] = 0 25 | if fed_cls_inds > 0: 26 | prob[fed_cls_inds:] = 0 27 | more_appeared = torch.multinomial( 28 | prob, num_sample_cats - len(appeared), 29 | replacement=False) 30 | appeared = torch.cat([appeared, more_appeared]) 31 | return appeared -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/Base-CenterNet-FPN.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | META_ARCHITECTURE: "CenterNetDetector" 3 | PROPOSAL_GENERATOR: 4 | NAME: "CenterNet" 5 | BACKBONE: 6 | NAME: "build_p67_resnet_fpn_backbone" 7 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 8 | RESNETS: 9 | DEPTH: 50 10 | OUT_FEATURES: ["res3", "res4", "res5"] 11 | FPN: 12 | IN_FEATURES: ["res3", "res4", "res5"] 13 | DATASETS: 14 | TRAIN: ("coco_2017_train",) 15 | TEST: ("coco_2017_val",) 16 | SOLVER: 17 | IMS_PER_BATCH: 16 18 | BASE_LR: 0.01 19 | STEPS: (60000, 80000) 20 | MAX_ITER: 90000 21 | CHECKPOINT_PERIOD: 1000000000 22 | WARMUP_ITERS: 4000 23 | WARMUP_FACTOR: 0.00025 24 | CLIP_GRADIENTS: 25 | ENABLED: True 26 | INPUT: 27 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 28 | OUTPUT_DIR: "./output/CenterNet2/auto" 29 | -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/Base-CenterNet2.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | META_ARCHITECTURE: "GeneralizedRCNN" 3 | PROPOSAL_GENERATOR: 4 | NAME: "CenterNet" 5 | BACKBONE: 6 | NAME: "build_p67_resnet_fpn_backbone" 7 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 8 | RESNETS: 9 | DEPTH: 50 10 | OUT_FEATURES: ["res3", "res4", "res5"] 11 | FPN: 12 | IN_FEATURES: ["res3", "res4", "res5"] 13 | ROI_HEADS: 14 | NAME: CustomCascadeROIHeads 15 | IN_FEATURES: ["p3", "p4", "p5", "p6", "p7"] 16 | IOU_THRESHOLDS: [0.6] 17 | NMS_THRESH_TEST: 0.7 18 | ROI_BOX_CASCADE_HEAD: 19 | IOUS: [0.6, 0.7, 0.8] 20 | ROI_BOX_HEAD: 21 | NAME: "FastRCNNConvFCHead" 22 | NUM_FC: 2 23 | POOLER_RESOLUTION: 7 24 | CLS_AGNOSTIC_BBOX_REG: True 25 | MULT_PROPOSAL_SCORE: True 26 | CENTERNET: 27 | REG_WEIGHT: 1. 28 | NOT_NORM_REG: True 29 | ONLY_PROPOSAL: True 30 | WITH_AGN_HM: True 31 | INFERENCE_TH: 0.0001 32 | PRE_NMS_TOPK_TRAIN: 4000 33 | POST_NMS_TOPK_TRAIN: 2000 34 | PRE_NMS_TOPK_TEST: 1000 35 | POST_NMS_TOPK_TEST: 256 36 | NMS_TH_TRAIN: 0.9 37 | NMS_TH_TEST: 0.9 38 | POS_WEIGHT: 0.5 39 | NEG_WEIGHT: 0.5 40 | IGNORE_HIGH_FP: 0.85 41 | DATASETS: 42 | TRAIN: ("coco_2017_train",) 43 | TEST: ("coco_2017_val",) 44 | SOLVER: 45 | IMS_PER_BATCH: 16 46 | BASE_LR: 0.02 47 | STEPS: (60000, 80000) 48 | MAX_ITER: 90000 49 | CHECKPOINT_PERIOD: 1000000000 50 | WARMUP_ITERS: 4000 51 | WARMUP_FACTOR: 0.00025 52 | CLIP_GRADIENTS: 53 | ENABLED: True 54 | INPUT: 55 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 56 | OUTPUT_DIR: "./output/CenterNet2/auto" 57 | -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/Base_S4_DLA.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | META_ARCHITECTURE: "CenterNetDetector" 3 | PROPOSAL_GENERATOR: 4 | NAME: "CenterNet" 5 | PIXEL_STD: [57.375, 57.120, 58.395] 6 | BACKBONE: 7 | NAME: "build_dla_backbone" 8 | DLA: 9 | NORM: "BN" 10 | CENTERNET: 11 | IN_FEATURES: ["dla2"] 12 | FPN_STRIDES: [4] 13 | SOI: [[0, 1000000]] 14 | NUM_CLS_CONVS: 1 15 | NUM_BOX_CONVS: 1 16 | REG_WEIGHT: 1. 17 | MORE_POS: True 18 | HM_FOCAL_ALPHA: 0.25 19 | DATASETS: 20 | TRAIN: ("coco_2017_train",) 21 | TEST: ("coco_2017_val",) 22 | SOLVER: 23 | LR_SCHEDULER_NAME: "WarmupCosineLR" 24 | MAX_ITER: 90000 25 | BASE_LR: 0.04 26 | IMS_PER_BATCH: 64 27 | WEIGHT_DECAY: 0.0001 28 | CHECKPOINT_PERIOD: 1000000 29 | CLIP_GRADIENTS: 30 | ENABLED: True 31 | INPUT: 32 | CUSTOM_AUG: EfficientDetResizeCrop 33 | TRAIN_SIZE: 640 34 | MIN_SIZE_TEST: 608 35 | MAX_SIZE_TEST: 900 36 | TEST: 37 | EVAL_PERIOD: 7500 38 | DATALOADER: 39 | NUM_WORKERS: 8 40 | OUTPUT_DIR: "output/CenterNet2/auto" 41 | -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/CenterNet-FPN_R50_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-CenterNet-FPN.yaml" 2 | MODEL: 3 | CENTERNET: 4 | MORE_POS: True -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/CenterNet-S4_DLA_8x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base_S4_DLA.yaml" 2 | SOLVER: 3 | MAX_ITER: 90000 4 | BASE_LR: 0.08 5 | IMS_PER_BATCH: 128 -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/CenterNet2-F_R50_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-CenterNet2.yaml" 2 | MODEL: 3 | ROI_HEADS: 4 | NAME: CustomROIHeads -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/CenterNet2_DLA-BiFPN-P3_24x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-CenterNet2.yaml" 2 | MODEL: 3 | BACKBONE: 4 | NAME: "build_p35_fcos_dla_bifpn_backbone" 5 | BIFPN: 6 | OUT_CHANNELS: 160 7 | NUM_LEVELS: 3 8 | NUM_BIFPN: 4 9 | DLA: 10 | NUM_LAYERS: 34 11 | NORM: "SyncBN" 12 | FPN: 13 | IN_FEATURES: ["dla3", "dla4", "dla5"] 14 | ROI_HEADS: 15 | IN_FEATURES: ["p3", "p4", "p5"] 16 | CENTERNET: 17 | POST_NMS_TOPK_TEST: 128 18 | FPN_STRIDES: [8, 16, 32] 19 | IN_FEATURES: ['p3', 'p4', 'p5'] 20 | SOI: [[0, 64], [48, 192], [128, 1000000]] 21 | DATASETS: 22 | TRAIN: ("coco_2017_train",) 23 | TEST: ("coco_2017_val",) 24 | SOLVER: 25 | IMS_PER_BATCH: 16 26 | BASE_LR: 0.02 27 | STEPS: (300000, 340000) 28 | MAX_ITER: 360000 29 | CHECKPOINT_PERIOD: 100000 30 | WARMUP_ITERS: 4000 31 | WARMUP_FACTOR: 0.00025 32 | INPUT: 33 | MIN_SIZE_TRAIN: (256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608) 34 | MAX_SIZE_TRAIN: 900 35 | MAX_SIZE_TEST: 736 36 | MIN_SIZE_TEST: 512 -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/CenterNet2_DLA-BiFPN-P3_4x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-CenterNet2.yaml" 2 | MODEL: 3 | BACKBONE: 4 | NAME: "build_p35_fcos_dla_bifpn_backbone" 5 | BIFPN: 6 | OUT_CHANNELS: 160 7 | NUM_LEVELS: 3 8 | NUM_BIFPN: 4 9 | DLA: 10 | NUM_LAYERS: 34 11 | NORM: "SyncBN" 12 | FPN: 13 | IN_FEATURES: ["dla3", "dla4", "dla5"] 14 | ROI_HEADS: 15 | IN_FEATURES: ["p3", "p4", "p5"] 16 | CENTERNET: 17 | POST_NMS_TOPK_TEST: 128 18 | FPN_STRIDES: [8, 16, 32] 19 | IN_FEATURES: ['p3', 'p4', 'p5'] 20 | SOI: [[0, 64], [48, 192], [128, 1000000]] 21 | DATASETS: 22 | TRAIN: ("coco_2017_train",) 23 | TEST: ("coco_2017_val",) 24 | SOLVER: 25 | IMS_PER_BATCH: 16 26 | BASE_LR: 0.02 27 | STEPS: (300000, 340000) 28 | MAX_ITER: 360000 29 | CHECKPOINT_PERIOD: 100000 30 | WARMUP_ITERS: 4000 31 | WARMUP_FACTOR: 0.00025 32 | INPUT: 33 | MIN_SIZE_TRAIN: (256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608) 34 | MAX_SIZE_TRAIN: 900 35 | MAX_SIZE_TEST: 736 36 | MIN_SIZE_TEST: 512 -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/CenterNet2_DLA-BiFPN-P5_640_16x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-CenterNet2.yaml" 2 | MODEL: 3 | BACKBONE: 4 | NAME: "build_p37_dla_bifpn_backbone" 5 | BIFPN: 6 | OUT_CHANNELS: 160 7 | NUM_LEVELS: 5 8 | NUM_BIFPN: 3 9 | CENTERNET: 10 | POST_NMS_TOPK_TEST: 128 11 | WEIGHTS: '' 12 | PIXEL_MEAN: [123.675, 116.280, 103.530] 13 | PIXEL_STD: [58.395, 57.12, 57.375] 14 | FPN: 15 | IN_FEATURES: ["dla3", "dla4", "dla5"] 16 | SOLVER: 17 | LR_SCHEDULER_NAME: "WarmupCosineLR" 18 | MAX_ITER: 360000 19 | BASE_LR: 0.08 20 | IMS_PER_BATCH: 64 21 | CHECKPOINT_PERIOD: 90000 22 | TEST: 23 | EVAL_PERIOD: 7500 24 | INPUT: 25 | FORMAT: RGB 26 | CUSTOM_AUG: EfficientDetResizeCrop 27 | TRAIN_SIZE: 640 28 | MIN_SIZE_TEST: 608 29 | MAX_SIZE_TEST: 900 30 | -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/CenterNet2_DLA-BiFPN-P5_640_16x_ST.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-CenterNet2.yaml" 2 | MODEL: 3 | BACKBONE: 4 | NAME: "build_p37_dla_bifpn_backbone" 5 | BIFPN: 6 | OUT_CHANNELS: 160 7 | NUM_LEVELS: 5 8 | NUM_BIFPN: 3 9 | CENTERNET: 10 | POST_NMS_TOPK_TEST: 128 11 | WEIGHTS: '' 12 | PIXEL_MEAN: [123.675, 116.280, 103.530] 13 | PIXEL_STD: [58.395, 57.12, 57.375] 14 | FPN: 15 | IN_FEATURES: ["dla3", "dla4", "dla5"] 16 | SOLVER: 17 | LR_SCHEDULER_NAME: "WarmupCosineLR" 18 | MAX_ITER: 360000 19 | BASE_LR: 0.08 20 | IMS_PER_BATCH: 64 21 | TEST: 22 | EVAL_PERIOD: 7500 23 | INPUT: 24 | FORMAT: RGB 25 | CUSTOM_AUG: EfficientDetResizeCrop 26 | TRAIN_SIZE: 640 27 | MIN_SIZE_TEST: 608 28 | MAX_SIZE_TEST: 900 29 | DATASETS: 30 | TRAIN: ("coco_2017_train","coco_un_yolov4_55_0.5",) 31 | -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/CenterNet2_DLA-fcosBiFPN-P5_640_16x_ST.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-CenterNet2.yaml" 2 | MODEL: 3 | BACKBONE: 4 | NAME: "build_p37_fcos_dla_bifpn_backbone" 5 | BIFPN: 6 | OUT_CHANNELS: 160 7 | NUM_LEVELS: 5 8 | NUM_BIFPN: 3 9 | CENTERNET: 10 | POST_NMS_TOPK_TEST: 128 11 | WEIGHTS: '' 12 | PIXEL_MEAN: [123.675, 116.280, 103.530] 13 | PIXEL_STD: [58.395, 57.12, 57.375] 14 | FPN: 15 | IN_FEATURES: ["dla3", "dla4", "dla5"] 16 | TEST: 17 | EVAL_PERIOD: 7500 18 | SOLVER: 19 | LR_SCHEDULER_NAME: "WarmupCosineLR" 20 | MAX_ITER: 360000 21 | BASE_LR: 0.08 22 | IMS_PER_BATCH: 64 23 | INPUT: 24 | FORMAT: RGB 25 | CUSTOM_AUG: EfficientDetResizeCrop 26 | TRAIN_SIZE: 640 27 | MIN_SIZE_TEST: 608 28 | MAX_SIZE_TEST: 900 29 | DATASETS: 30 | TRAIN: ("coco_2017_train","coco_un_yolov4_55_0.5",) 31 | -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/CenterNet2_R2-101-DCN-BiFPN_1280_4x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-CenterNet2.yaml" 2 | MODEL: 3 | BACKBONE: 4 | NAME: "build_res2net_bifpn_backbone" 5 | BIFPN: 6 | NUM_BIFPN: 7 7 | OUT_CHANNELS: 288 8 | WEIGHTS: "output/r2_101.pkl" 9 | RESNETS: 10 | DEPTH: 101 11 | WIDTH_PER_GROUP: 26 12 | DEFORM_ON_PER_STAGE: [False, False, True, True] # on Res4, Res5 13 | DEFORM_MODULATED: True 14 | PIXEL_MEAN: [123.675, 116.280, 103.530] 15 | PIXEL_STD: [58.395, 57.12, 57.375] 16 | CENTERNET: 17 | USE_DEFORMABLE: True 18 | ROI_HEADS: 19 | IN_FEATURES: ["p3", "p4"] 20 | INPUT: 21 | FORMAT: RGB 22 | TEST: 23 | EVAL_PERIOD: 7500 24 | SOLVER: 25 | MAX_ITER: 180000 26 | CHECKPOINT_PERIOD: 60000 27 | LR_SCHEDULER_NAME: "WarmupCosineLR" 28 | BASE_LR: 0.04 29 | IMS_PER_BATCH: 32 30 | INPUT: 31 | CUSTOM_AUG: EfficientDetResizeCrop 32 | TRAIN_SIZE: 1280 33 | -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/CenterNet2_R2-101-DCN-BiFPN_4x+4x_1560_ST.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-CenterNet2.yaml" 2 | MODEL: 3 | BACKBONE: 4 | NAME: "build_res2net_bifpn_backbone" 5 | BIFPN: 6 | NUM_BIFPN: 7 7 | OUT_CHANNELS: 288 8 | WEIGHTS: "output/r2_101.pkl" 9 | RESNETS: 10 | DEPTH: 101 11 | WIDTH_PER_GROUP: 26 12 | DEFORM_ON_PER_STAGE: [False, False, True, True] # on Res4, Res5 13 | DEFORM_MODULATED: True 14 | PIXEL_MEAN: [123.675, 116.280, 103.530] 15 | PIXEL_STD: [58.395, 57.12, 57.375] 16 | CENTERNET: 17 | USE_DEFORMABLE: True 18 | ROI_HEADS: 19 | IN_FEATURES: ["p3", "p4"] 20 | TEST: 21 | EVAL_PERIOD: 7500 22 | SOLVER: 23 | MAX_ITER: 180000 24 | CHECKPOINT_PERIOD: 7500 25 | LR_SCHEDULER_NAME: "WarmupCosineLR" 26 | BASE_LR: 0.04 27 | IMS_PER_BATCH: 32 28 | DATASETS: 29 | TRAIN: "('coco_2017_train', 'coco_un_yolov4_55_0.5')" 30 | INPUT: 31 | FORMAT: RGB 32 | CUSTOM_AUG: EfficientDetResizeCrop 33 | TRAIN_SIZE: 1280 34 | TEST_SIZE: 1560 35 | TEST_INPUT_TYPE: 'square' 36 | -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/CenterNet2_R2-101-DCN_896_4x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-CenterNet2.yaml" 2 | MODEL: 3 | BACKBONE: 4 | NAME: "build_p67_res2net_fpn_backbone" 5 | WEIGHTS: "output/r2_101.pkl" 6 | RESNETS: 7 | DEPTH: 101 8 | WIDTH_PER_GROUP: 26 9 | DEFORM_ON_PER_STAGE: [False, False, True, True] # on Res4, Res5 10 | DEFORM_MODULATED: True 11 | PIXEL_MEAN: [123.675, 116.280, 103.530] 12 | PIXEL_STD: [58.395, 57.12, 57.375] 13 | CENTERNET: 14 | USE_DEFORMABLE: True 15 | ROI_HEADS: 16 | IN_FEATURES: ["p3", "p4"] 17 | INPUT: 18 | FORMAT: RGB 19 | TEST: 20 | EVAL_PERIOD: 7500 21 | SOLVER: 22 | MAX_ITER: 180000 23 | CHECKPOINT_PERIOD: 600000 24 | LR_SCHEDULER_NAME: "WarmupCosineLR" 25 | BASE_LR: 0.04 26 | IMS_PER_BATCH: 32 27 | INPUT: 28 | CUSTOM_AUG: EfficientDetResizeCrop 29 | TRAIN_SIZE: 896 -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/CenterNet2_R50_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-CenterNet2.yaml" 2 | -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/CenterNet2_X101-DCN_2x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-CenterNet2.yaml" 2 | MODEL: 3 | CENTERNET: 4 | USE_DEFORMABLE: True 5 | WEIGHTS: "detectron2://ImageNetPretrained/FAIR/X-101-32x8d.pkl" 6 | PIXEL_STD: [57.375, 57.120, 58.395] 7 | RESNETS: 8 | STRIDE_IN_1X1: False 9 | NUM_GROUPS: 32 10 | WIDTH_PER_GROUP: 8 11 | DEPTH: 101 12 | DEFORM_ON_PER_STAGE: [False, False, True, True] # on Res4, Res5 13 | DEFORM_MODULATED: True 14 | ROI_HEADS: 15 | IN_FEATURES: ["p3", "p4"] 16 | SOLVER: 17 | STEPS: (120000, 160000) 18 | MAX_ITER: 180000 19 | CHECKPOINT_PERIOD: 40000 20 | INPUT: 21 | MIN_SIZE_TRAIN: (480, 960) 22 | MIN_SIZE_TRAIN_SAMPLING: "range" 23 | -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/LVIS_CenterNet2_R50_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-CenterNet2.yaml" 2 | MODEL: 3 | ROI_HEADS: 4 | NUM_CLASSES: 1203 5 | SCORE_THRESH_TEST: 0.02 6 | NMS_THRESH_TEST: 0.5 7 | CENTERNET: 8 | NUM_CLASSES: 1203 9 | 10 | DATASETS: 11 | TRAIN: ("lvis_v1_train",) 12 | TEST: ("lvis_v1_val",) 13 | DATALOADER: 14 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 15 | REPEAT_THRESHOLD: 0.001 16 | TEST: 17 | DETECTIONS_PER_IMAGE: 300 18 | -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/LVIS_CenterNet2_R50_Fed_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-CenterNet2.yaml" 2 | MODEL: 3 | ROI_HEADS: 4 | NUM_CLASSES: 1203 5 | SCORE_THRESH_TEST: 0.02 6 | NMS_THRESH_TEST: 0.5 7 | CENTERNET: 8 | NUM_CLASSES: 1203 9 | ROI_BOX_HEAD: 10 | USE_SIGMOID_CE: True 11 | USE_FED_LOSS: True 12 | DATASETS: 13 | TRAIN: ("lvis_v1_train",) 14 | TEST: ("lvis_v1_val",) 15 | DATALOADER: 16 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 17 | REPEAT_THRESHOLD: 0.001 18 | TEST: 19 | DETECTIONS_PER_IMAGE: 300 20 | -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/O365_CenterNet2_R50_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-CenterNet2.yaml" 2 | MODEL: 3 | ROI_HEADS: 4 | NUM_CLASSES: 365 5 | CENTERNET: 6 | NUM_CLASSES: 365 7 | DATASETS: 8 | TRAIN: ("objects365_train",) 9 | TEST: ("objects365_val",) 10 | DATALOADER: 11 | SAMPLER_TRAIN: "ClassAwareSampler" 12 | TEST: 13 | DETECTIONS_PER_IMAGE: 300 -------------------------------------------------------------------------------- /third_party/CenterNet2/projects/CenterNet2/configs/nuImages_CenterNet2_DLA_640_8x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-CenterNet2.yaml" 2 | MODEL: 3 | MASK_ON: True 4 | ROI_MASK_HEAD: 5 | NAME: "MaskRCNNConvUpsampleHead" 6 | NUM_CONV: 4 7 | POOLER_RESOLUTION: 14 8 | ROI_HEADS: 9 | NUM_CLASSES: 10 10 | IN_FEATURES: ["dla2"] 11 | BACKBONE: 12 | NAME: "build_dla_backbone" 13 | DLA: 14 | NORM: "BN" 15 | CENTERNET: 16 | IN_FEATURES: ["dla2"] 17 | FPN_STRIDES: [4] 18 | SOI: [[0, 1000000]] 19 | NUM_CLS_CONVS: 1 20 | NUM_BOX_CONVS: 1 21 | REG_WEIGHT: 1. 22 | MORE_POS: True 23 | HM_FOCAL_ALPHA: 0.25 24 | POST_NMS_TOPK_TEST: 128 25 | WEIGHTS: '' 26 | PIXEL_MEAN: [123.675, 116.280, 103.530] 27 | PIXEL_STD: [58.395, 57.12, 57.375] 28 | SOLVER: 29 | MAX_ITER: 180000 30 | STEPS: (120000, 160000) 31 | BASE_LR: 0.08 32 | IMS_PER_BATCH: 64 33 | INPUT: 34 | FORMAT: RGB 35 | CUSTOM_AUG: EfficientDetResizeCrop 36 | TRAIN_SIZE: 640 37 | MIN_SIZE_TEST: 608 38 | MAX_SIZE_TEST: 900 39 | MASK_FORMAT: bitmask 40 | DATASETS: 41 | TRAIN: ("nuimages_train",) 42 | TEST: ("nuimages_val",) 43 | -------------------------------------------------------------------------------- /third_party/CenterNet2/setup.cfg: -------------------------------------------------------------------------------- 1 | [isort] 2 | line_length=100 3 | multi_line_output=3 4 | include_trailing_comma=True 5 | known_standard_library=numpy,setuptools,mock 6 | skip=./datasets,docs 7 | skip_glob=*/__init__.py,**/configs/**,tests/config/** 8 | known_myself=detectron2 9 | known_third_party=fvcore,matplotlib,cv2,torch,torchvision,PIL,pycocotools,yacs,termcolor,cityscapesscripts,tabulate,tqdm,scipy,lvis,psutil,pkg_resources,caffe2,onnx,panopticapi,black,isort,av,iopath,omegaconf,hydra,yaml,pydoc,submitit,cloudpickle 10 | no_lines_before=STDLIB,THIRDPARTY 11 | sections=FUTURE,STDLIB,THIRDPARTY,myself,FIRSTPARTY,LOCALFOLDER 12 | default_section=FIRSTPARTY 13 | 14 | [mypy] 15 | python_version=3.6 16 | ignore_missing_imports = True 17 | warn_unused_configs = True 18 | disallow_untyped_defs = True 19 | check_untyped_defs = True 20 | warn_unused_ignores = True 21 | warn_redundant_casts = True 22 | show_column_numbers = True 23 | follow_imports = silent 24 | allow_redefinition = True 25 | ; Require all functions to be annotated 26 | disallow_incomplete_defs = True 27 | -------------------------------------------------------------------------------- /third_party/CenterNet2/tests/README.md: -------------------------------------------------------------------------------- 1 | ## Unit Tests 2 | 3 | To run the unittests, do: 4 | ``` 5 | cd detectron2 6 | python -m unittest discover -v -s ./tests 7 | ``` 8 | 9 | There are also end-to-end inference & training tests, in [dev/run_*_tests.sh](../dev). 10 | -------------------------------------------------------------------------------- /third_party/CenterNet2/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | -------------------------------------------------------------------------------- /third_party/CenterNet2/tests/config/dir1/dir1_a.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | dir1a_str = "base_a_1" 3 | dir1a_dict = {"a": 1, "b": 2} 4 | -------------------------------------------------------------------------------- /third_party/CenterNet2/tests/config/dir1/dir1_b.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from detectron2.config import LazyConfig 3 | 4 | # equivalent to relative import 5 | dir1a_str, dir1a_dict = LazyConfig.load_rel("dir1_a.py", ("dir1a_str", "dir1a_dict")) 6 | 7 | dir1b_str = dir1a_str + "_from_b" 8 | dir1b_dict = dir1a_dict 9 | 10 | # Every import is a reload: not modified by other config files 11 | assert dir1a_dict.a == 1 12 | -------------------------------------------------------------------------------- /third_party/CenterNet2/tests/config/root_cfg.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from itertools import count 3 | 4 | from detectron2.config import LazyCall as L 5 | 6 | from .dir1.dir1_a import dir1a_dict, dir1a_str 7 | 8 | dir1a_dict.a = "modified" 9 | 10 | # modification above won't affect future imports 11 | from .dir1.dir1_b import dir1b_dict, dir1b_str 12 | 13 | 14 | lazyobj = L(count)(x=dir1a_str, y=dir1b_str) 15 | -------------------------------------------------------------------------------- /third_party/CenterNet2/tests/data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JialianW/GRiT/39b33dbc0900e4be0458af14597fcb1a82d933bb/third_party/CenterNet2/tests/data/__init__.py -------------------------------------------------------------------------------- /third_party/CenterNet2/tests/layers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JialianW/GRiT/39b33dbc0900e4be0458af14597fcb1a82d933bb/third_party/CenterNet2/tests/layers/__init__.py -------------------------------------------------------------------------------- /third_party/CenterNet2/tests/layers/test_nms.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from __future__ import absolute_import, division, print_function, unicode_literals 3 | import unittest 4 | import torch 5 | 6 | from detectron2.layers import batched_nms 7 | from detectron2.utils.testing import random_boxes 8 | 9 | 10 | class TestNMS(unittest.TestCase): 11 | def _create_tensors(self, N): 12 | boxes = random_boxes(N, 200) 13 | scores = torch.rand(N) 14 | return boxes, scores 15 | 16 | def test_nms_scriptability(self): 17 | N = 2000 18 | num_classes = 50 19 | boxes, scores = self._create_tensors(N) 20 | idxs = torch.randint(0, num_classes, (N,)) 21 | scripted_batched_nms = torch.jit.script(batched_nms) 22 | err_msg = "NMS is incompatible with jit-scripted NMS for IoU={}" 23 | 24 | for iou in [0.2, 0.5, 0.8]: 25 | keep_ref = batched_nms(boxes, scores, idxs, iou) 26 | backup = boxes.clone() 27 | scripted_keep = scripted_batched_nms(boxes, scores, idxs, iou) 28 | assert torch.allclose(boxes, backup), "boxes modified by jit-scripted batched_nms" 29 | self.assertTrue(torch.equal(keep_ref, scripted_keep), err_msg.format(iou)) 30 | 31 | 32 | if __name__ == "__main__": 33 | unittest.main() 34 | -------------------------------------------------------------------------------- /third_party/CenterNet2/tests/modeling/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JialianW/GRiT/39b33dbc0900e4be0458af14597fcb1a82d933bb/third_party/CenterNet2/tests/modeling/__init__.py -------------------------------------------------------------------------------- /third_party/CenterNet2/tests/modeling/test_backbone.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | import unittest 4 | import torch 5 | 6 | import detectron2.export.torchscript # apply patch # noqa 7 | from detectron2 import model_zoo 8 | from detectron2.config import get_cfg 9 | from detectron2.layers import ShapeSpec 10 | from detectron2.modeling.backbone import build_resnet_backbone 11 | from detectron2.modeling.backbone.fpn import build_resnet_fpn_backbone 12 | 13 | 14 | class TestBackBone(unittest.TestCase): 15 | def test_resnet_scriptability(self): 16 | cfg = get_cfg() 17 | resnet = build_resnet_backbone(cfg, ShapeSpec(channels=3)) 18 | 19 | scripted_resnet = torch.jit.script(resnet) 20 | 21 | inp = torch.rand(2, 3, 100, 100) 22 | out1 = resnet(inp)["res4"] 23 | out2 = scripted_resnet(inp)["res4"] 24 | self.assertTrue(torch.allclose(out1, out2)) 25 | 26 | def test_fpn_scriptability(self): 27 | cfg = model_zoo.get_config("Misc/scratch_mask_rcnn_R_50_FPN_3x_gn.yaml") 28 | bb = build_resnet_fpn_backbone(cfg, ShapeSpec(channels=3)) 29 | bb_s = torch.jit.script(bb) 30 | 31 | inp = torch.rand(2, 3, 128, 128) 32 | out1 = bb(inp)["p5"] 33 | out2 = bb_s(inp)["p5"] 34 | self.assertTrue(torch.allclose(out1, out2)) 35 | -------------------------------------------------------------------------------- /third_party/CenterNet2/tests/modeling/test_matcher.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | import unittest 3 | from typing import List 4 | import torch 5 | 6 | from detectron2.config import get_cfg 7 | from detectron2.modeling.matcher import Matcher 8 | 9 | 10 | class TestMatcher(unittest.TestCase): 11 | def test_scriptability(self): 12 | cfg = get_cfg() 13 | anchor_matcher = Matcher( 14 | cfg.MODEL.RPN.IOU_THRESHOLDS, cfg.MODEL.RPN.IOU_LABELS, allow_low_quality_matches=True 15 | ) 16 | match_quality_matrix = torch.tensor( 17 | [[0.15, 0.45, 0.2, 0.6], [0.3, 0.65, 0.05, 0.1], [0.05, 0.4, 0.25, 0.4]] 18 | ) 19 | expected_matches = torch.tensor([1, 1, 2, 0]) 20 | expected_match_labels = torch.tensor([-1, 1, 0, 1], dtype=torch.int8) 21 | 22 | matches, match_labels = anchor_matcher(match_quality_matrix) 23 | self.assertTrue(torch.allclose(matches, expected_matches)) 24 | self.assertTrue(torch.allclose(match_labels, expected_match_labels)) 25 | 26 | # nonzero_tuple must be import explicitly to let jit know what it is. 27 | # https://github.com/pytorch/pytorch/issues/38964 28 | from detectron2.layers import nonzero_tuple # noqa F401 29 | 30 | def f(thresholds: List[float], labels: List[int]): 31 | return Matcher(thresholds, labels, allow_low_quality_matches=True) 32 | 33 | scripted_anchor_matcher = torch.jit.script(f)( 34 | cfg.MODEL.RPN.IOU_THRESHOLDS, cfg.MODEL.RPN.IOU_LABELS 35 | ) 36 | matches, match_labels = scripted_anchor_matcher(match_quality_matrix) 37 | self.assertTrue(torch.allclose(matches, expected_matches)) 38 | self.assertTrue(torch.allclose(match_labels, expected_match_labels)) 39 | 40 | 41 | if __name__ == "__main__": 42 | unittest.main() 43 | -------------------------------------------------------------------------------- /third_party/CenterNet2/tests/structures/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JialianW/GRiT/39b33dbc0900e4be0458af14597fcb1a82d933bb/third_party/CenterNet2/tests/structures/__init__.py -------------------------------------------------------------------------------- /third_party/CenterNet2/tests/structures/test_keypoints.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | import unittest 3 | import torch 4 | 5 | from detectron2.structures.keypoints import Keypoints 6 | 7 | 8 | class TestKeypoints(unittest.TestCase): 9 | def test_cat_keypoints(self): 10 | keypoints1 = Keypoints(torch.rand(2, 21, 3)) 11 | keypoints2 = Keypoints(torch.rand(4, 21, 3)) 12 | 13 | cat_keypoints = keypoints1.cat([keypoints1, keypoints2]) 14 | self.assertTrue(torch.all(cat_keypoints.tensor[:2] == keypoints1.tensor).item()) 15 | self.assertTrue(torch.all(cat_keypoints.tensor[2:] == keypoints2.tensor).item()) 16 | 17 | 18 | if __name__ == "__main__": 19 | unittest.main() 20 | -------------------------------------------------------------------------------- /third_party/CenterNet2/tests/test_checkpoint.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | import unittest 3 | from collections import OrderedDict 4 | import torch 5 | from torch import nn 6 | 7 | from detectron2.checkpoint.c2_model_loading import align_and_update_state_dicts 8 | from detectron2.utils.logger import setup_logger 9 | 10 | 11 | class TestCheckpointer(unittest.TestCase): 12 | def setUp(self): 13 | setup_logger() 14 | 15 | def create_complex_model(self): 16 | m = nn.Module() 17 | m.block1 = nn.Module() 18 | m.block1.layer1 = nn.Linear(2, 3) 19 | m.layer2 = nn.Linear(3, 2) 20 | m.res = nn.Module() 21 | m.res.layer2 = nn.Linear(3, 2) 22 | 23 | state_dict = OrderedDict() 24 | state_dict["layer1.weight"] = torch.rand(3, 2) 25 | state_dict["layer1.bias"] = torch.rand(3) 26 | state_dict["layer2.weight"] = torch.rand(2, 3) 27 | state_dict["layer2.bias"] = torch.rand(2) 28 | state_dict["res.layer2.weight"] = torch.rand(2, 3) 29 | state_dict["res.layer2.bias"] = torch.rand(2) 30 | return m, state_dict 31 | 32 | def test_complex_model_loaded(self): 33 | for add_data_parallel in [False, True]: 34 | model, state_dict = self.create_complex_model() 35 | if add_data_parallel: 36 | model = nn.DataParallel(model) 37 | model_sd = model.state_dict() 38 | 39 | sd_to_load = align_and_update_state_dicts(model_sd, state_dict) 40 | model.load_state_dict(sd_to_load) 41 | for loaded, stored in zip(model_sd.values(), state_dict.values()): 42 | # different tensor references 43 | self.assertFalse(id(loaded) == id(stored)) 44 | # same content 45 | self.assertTrue(loaded.to(stored).equal(stored)) 46 | 47 | 48 | if __name__ == "__main__": 49 | unittest.main() 50 | -------------------------------------------------------------------------------- /third_party/CenterNet2/tests/test_model_zoo.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | import logging 3 | import unittest 4 | 5 | from detectron2 import model_zoo 6 | from detectron2.config import instantiate 7 | from detectron2.modeling import FPN, GeneralizedRCNN 8 | 9 | logger = logging.getLogger(__name__) 10 | 11 | 12 | class TestModelZoo(unittest.TestCase): 13 | def test_get_returns_model(self): 14 | model = model_zoo.get("Misc/scratch_mask_rcnn_R_50_FPN_3x_gn.yaml", trained=False) 15 | self.assertIsInstance(model, GeneralizedRCNN) 16 | self.assertIsInstance(model.backbone, FPN) 17 | 18 | def test_get_invalid_model(self): 19 | self.assertRaises(RuntimeError, model_zoo.get, "Invalid/config.yaml") 20 | 21 | def test_get_url(self): 22 | url = model_zoo.get_checkpoint_url("Misc/scratch_mask_rcnn_R_50_FPN_3x_gn.yaml") 23 | self.assertEqual( 24 | url, 25 | "https://dl.fbaipublicfiles.com/detectron2/Misc/scratch_mask_rcnn_R_50_FPN_3x_gn/138602908/model_final_01ca85.pkl", # noqa 26 | ) 27 | url2 = model_zoo.get_checkpoint_url("Misc/scratch_mask_rcnn_R_50_FPN_3x_gn.py") 28 | self.assertEqual(url, url2) 29 | 30 | def _build_lazy_model(self, name): 31 | cfg = model_zoo.get_config("common/models/" + name) 32 | instantiate(cfg.model) 33 | 34 | def test_mask_rcnn_fpn(self): 35 | self._build_lazy_model("mask_rcnn_fpn.py") 36 | 37 | def test_mask_rcnn_c4(self): 38 | self._build_lazy_model("mask_rcnn_c4.py") 39 | 40 | def test_panoptic_fpn(self): 41 | self._build_lazy_model("panoptic_fpn.py") 42 | 43 | def test_schedule(self): 44 | cfg = model_zoo.get_config("common/coco_schedule.py") 45 | for _, v in cfg.items(): 46 | instantiate(v) 47 | 48 | 49 | if __name__ == "__main__": 50 | unittest.main() 51 | -------------------------------------------------------------------------------- /third_party/CenterNet2/tests/test_packaging.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | import unittest 3 | 4 | from detectron2.utils.collect_env import collect_env_info 5 | 6 | 7 | class TestProjects(unittest.TestCase): 8 | def test_import(self): 9 | from detectron2.projects import point_rend 10 | 11 | _ = point_rend.add_pointrend_config 12 | 13 | import detectron2.projects.deeplab as deeplab 14 | 15 | _ = deeplab.add_deeplab_config 16 | 17 | # import detectron2.projects.panoptic_deeplab as panoptic_deeplab 18 | 19 | # _ = panoptic_deeplab.add_panoptic_deeplab_config 20 | 21 | 22 | class TestCollectEnv(unittest.TestCase): 23 | def test(self): 24 | _ = collect_env_info() 25 | -------------------------------------------------------------------------------- /third_party/CenterNet2/tests/test_registry.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | import unittest 3 | import torch 4 | 5 | from detectron2.modeling.meta_arch import GeneralizedRCNN 6 | from detectron2.utils.registry import _convert_target_to_string, locate 7 | 8 | 9 | class A: 10 | class B: 11 | pass 12 | 13 | 14 | class TestLocate(unittest.TestCase): 15 | def _test_obj(self, obj): 16 | name = _convert_target_to_string(obj) 17 | newobj = locate(name) 18 | self.assertIs(obj, newobj) 19 | 20 | def test_basic(self): 21 | self._test_obj(GeneralizedRCNN) 22 | 23 | def test_inside_class(self): 24 | # requires using __qualname__ instead of __name__ 25 | self._test_obj(A.B) 26 | 27 | def test_builtin(self): 28 | self._test_obj(len) 29 | self._test_obj(dict) 30 | 31 | def test_pytorch_optim(self): 32 | # pydoc.locate does not work for it 33 | self._test_obj(torch.optim.SGD) 34 | 35 | def test_failure(self): 36 | with self.assertRaises(ImportError): 37 | locate("asdf") 38 | 39 | def test_compress_target(self): 40 | from detectron2.data.transforms import RandomCrop 41 | 42 | name = _convert_target_to_string(RandomCrop) 43 | # name shouldn't contain 'augmentation_impl' 44 | self.assertEqual(name, "detectron2.data.transforms.RandomCrop") 45 | self.assertIs(RandomCrop, locate(name)) 46 | -------------------------------------------------------------------------------- /third_party/CenterNet2/tools/README.md: -------------------------------------------------------------------------------- 1 | 2 | This directory contains a few example scripts that demonstrate features of detectron2. 3 | 4 | 5 | * `train_net.py` 6 | 7 | An example training script that's made to train builtin models of detectron2. 8 | 9 | For usage, see [GETTING_STARTED.md](../GETTING_STARTED.md). 10 | 11 | * `plain_train_net.py` 12 | 13 | Similar to `train_net.py`, but implements a training loop instead of using `Trainer`. 14 | This script includes fewer features but it may be more friendly to hackers. 15 | 16 | * `benchmark.py` 17 | 18 | Benchmark the training speed, inference speed or data loading speed of a given config. 19 | 20 | Usage: 21 | ``` 22 | python benchmark.py --config-file config.yaml --task train/eval/data [optional DDP flags] 23 | ``` 24 | 25 | * `analyze_model.py` 26 | 27 | Analyze FLOPs, parameters, activations of a detectron2 model. See its `--help` for usage. 28 | 29 | * `visualize_json_results.py` 30 | 31 | Visualize the json instance detection/segmentation results dumped by `COCOEvalutor` or `LVISEvaluator` 32 | 33 | Usage: 34 | ``` 35 | python visualize_json_results.py --input x.json --output dir/ --dataset coco_2017_val 36 | ``` 37 | If not using a builtin dataset, you'll need your own script or modify this script. 38 | 39 | * `visualize_data.py` 40 | 41 | Visualize ground truth raw annotations or training data (after preprocessing/augmentations). 42 | 43 | Usage: 44 | ``` 45 | python visualize_data.py --config-file config.yaml --source annotation/dataloader --output-dir dir/ [--show] 46 | ``` 47 | 48 | NOTE: the script does not stop by itself when using `--source dataloader` because a training 49 | dataloader is usually infinite. 50 | -------------------------------------------------------------------------------- /third_party/CenterNet2/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JialianW/GRiT/39b33dbc0900e4be0458af14597fcb1a82d933bb/third_party/CenterNet2/tools/__init__.py -------------------------------------------------------------------------------- /third_party/CenterNet2/tools/convert-torchvision-to-d2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | 4 | import pickle as pkl 5 | import sys 6 | import torch 7 | 8 | """ 9 | Usage: 10 | # download one of the ResNet{18,34,50,101,152} models from torchvision: 11 | wget https://download.pytorch.org/models/resnet50-19c8e357.pth -O r50.pth 12 | # run the conversion 13 | ./convert-torchvision-to-d2.py r50.pth r50.pkl 14 | 15 | # Then, use r50.pkl with the following changes in config: 16 | 17 | MODEL: 18 | WEIGHTS: "/path/to/r50.pkl" 19 | PIXEL_MEAN: [123.675, 116.280, 103.530] 20 | PIXEL_STD: [58.395, 57.120, 57.375] 21 | RESNETS: 22 | DEPTH: 50 23 | STRIDE_IN_1X1: False 24 | INPUT: 25 | FORMAT: "RGB" 26 | 27 | These models typically produce slightly worse results than the 28 | pre-trained ResNets we use in official configs, which are the 29 | original ResNet models released by MSRA. 30 | """ 31 | 32 | if __name__ == "__main__": 33 | input = sys.argv[1] 34 | 35 | obj = torch.load(input, map_location="cpu") 36 | 37 | newmodel = {} 38 | for k in list(obj.keys()): 39 | old_k = k 40 | if "layer" not in k: 41 | k = "stem." + k 42 | for t in [1, 2, 3, 4]: 43 | k = k.replace("layer{}".format(t), "res{}".format(t + 1)) 44 | for t in [1, 2, 3]: 45 | k = k.replace("bn{}".format(t), "conv{}.norm".format(t)) 46 | k = k.replace("downsample.0", "shortcut") 47 | k = k.replace("downsample.1", "shortcut.norm") 48 | print(old_k, "->", k) 49 | newmodel[k] = obj.pop(old_k).detach().numpy() 50 | 51 | res = {"model": newmodel, "__author__": "torchvision", "matching_heuristics": True} 52 | 53 | with open(sys.argv[2], "wb") as f: 54 | pkl.dump(res, f) 55 | if obj: 56 | print("Unconverted keys:", obj.keys()) 57 | -------------------------------------------------------------------------------- /third_party/CenterNet2/tools/deploy/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # See https://pytorch.org/tutorials/advanced/cpp_frontend.html 3 | cmake_minimum_required(VERSION 3.12 FATAL_ERROR) 4 | project(torchscript_mask_rcnn) 5 | 6 | find_package(Torch REQUIRED) 7 | find_package(OpenCV REQUIRED) 8 | find_package(TorchVision REQUIRED) # needed by export-method=tracing/scripting 9 | 10 | add_executable(torchscript_mask_rcnn torchscript_mask_rcnn.cpp) 11 | target_link_libraries( 12 | torchscript_mask_rcnn 13 | -Wl,--no-as-needed TorchVision::TorchVision -Wl,--as-needed 14 | "${TORCH_LIBRARIES}" ${OpenCV_LIBS}) 15 | set_property(TARGET torchscript_mask_rcnn PROPERTY CXX_STANDARD 14) 16 | --------------------------------------------------------------------------------