├── .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 │ ├── feature-request.md │ ├── questions-help-support.md │ └── unexpected-problems-bugs.md ├── pull_request_template.md └── workflows │ └── workflow.yml ├── .gitignore ├── .gitmodules ├── GETTING_STARTED.md ├── INSTALL.md ├── LICENSE ├── MODEL_ZOO.md ├── README.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 │ ├── retinanet_R_101_FPN_3x.yaml │ ├── 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.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.yaml │ ├── mask_rcnn_R_50_FPN_1x_giou.yaml │ ├── mask_rcnn_R_50_FPN_3x.yaml │ └── mask_rcnn_X_101_32x8d_FPN_3x.yaml ├── COCO-Keypoints │ ├── Base-Keypoint-RCNN-FPN.yaml │ ├── keypoint_rcnn_R_101_FPN_3x.yaml │ ├── 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.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 │ ├── 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 ├── PascalVOC-Detection │ ├── faster_rcnn_R_50_C4.yaml │ └── faster_rcnn_R_50_FPN.yaml └── 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 ├── 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 ├── data │ ├── __init__.py │ ├── build.py │ ├── catalog.py │ ├── common.py │ ├── dataset_mapper.py │ ├── datasets │ │ ├── README.md │ │ ├── __init__.py │ │ ├── builtin.py │ │ ├── builtin_meta.py │ │ ├── cityscapes.py │ │ ├── coco.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 │ ├── patcher.py │ ├── shared.py │ └── torchscript.py ├── layers │ ├── __init__.py │ ├── aspp.py │ ├── batch_norm.py │ ├── blocks.py │ ├── csrc │ │ ├── README.md │ │ ├── ROIAlign │ │ │ ├── ROIAlign.h │ │ │ ├── ROIAlign_cpu.cpp │ │ │ └── ROIAlign_cuda.cu │ │ ├── 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 │ ├── 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 │ │ └── resnet.py │ ├── box_regression.py │ ├── matcher.py │ ├── meta_arch │ │ ├── __init__.py │ │ ├── build.py │ │ ├── panoptic_fpn.py │ │ ├── rcnn.py │ │ ├── retinanet.py │ │ └── semantic_seg.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 ├── 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 │ ├── logger.py │ ├── memory.py │ ├── registry.py │ ├── serialize.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 ├── Dockerfile-circleci ├── README.md └── docker-compose.yml ├── docs ├── .gitignore ├── Makefile ├── README.md ├── _static │ └── css │ │ └── custom.css ├── conf.py ├── index.rst ├── modules │ ├── checkpoint.rst │ ├── config.rst │ ├── data.rst │ ├── engine.rst │ ├── evaluation.rst │ ├── export.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 │ ├── builtin_datasets.md │ ├── configs.md │ ├── data_loading.md │ ├── datasets.md │ ├── deployment.md │ ├── evaluation.md │ ├── extend.md │ ├── getting_started.md │ ├── index.rst │ ├── install.md │ ├── models.md │ ├── training.md │ └── write-models.md ├── projects ├── DeepLab │ ├── README.md │ ├── configs │ │ └── Cityscapes-SemanticSegmentation │ │ │ ├── Base-DeepLabV3-OS16-Semantic.yaml │ │ │ ├── deeplab_v3_R_103_os16_mg124_poly_90k_bs16.yaml │ │ │ └── deeplab_v3_plus_R_103_os16_mg124_poly_90k_bs16.yaml │ ├── deeplab │ │ ├── __init__.py │ │ ├── build_solver.py │ │ ├── config.py │ │ ├── loss.py │ │ ├── lr_scheduler.py │ │ ├── resnet.py │ │ └── semantic_seg.py │ └── train_net.py ├── DensePose │ ├── README.md │ ├── apply_net.py │ ├── configs │ │ ├── Base-DensePose-RCNN-FPN.yaml │ │ ├── HRNet │ │ │ ├── densepose_rcnn_HRFPN_HRNet_w32_s1x.yaml │ │ │ ├── densepose_rcnn_HRFPN_HRNet_w40_s1x.yaml │ │ │ └── densepose_rcnn_HRFPN_HRNet_w48_s1x.yaml │ │ ├── densepose_rcnn_R_101_FPN_DL_WC1_s1x.yaml │ │ ├── densepose_rcnn_R_101_FPN_DL_WC2_s1x.yaml │ │ ├── densepose_rcnn_R_101_FPN_DL_s1x.yaml │ │ ├── densepose_rcnn_R_101_FPN_WC1_s1x.yaml │ │ ├── densepose_rcnn_R_101_FPN_WC2_s1x.yaml │ │ ├── densepose_rcnn_R_101_FPN_s1x.yaml │ │ ├── densepose_rcnn_R_101_FPN_s1x_legacy.yaml │ │ ├── densepose_rcnn_R_50_FPN_DL_WC1_s1x.yaml │ │ ├── densepose_rcnn_R_50_FPN_DL_WC2_s1x.yaml │ │ ├── densepose_rcnn_R_50_FPN_DL_s1x.yaml │ │ ├── densepose_rcnn_R_50_FPN_WC1_s1x.yaml │ │ ├── densepose_rcnn_R_50_FPN_WC2_s1x.yaml │ │ ├── densepose_rcnn_R_50_FPN_s1x.yaml │ │ ├── densepose_rcnn_R_50_FPN_s1x_legacy.yaml │ │ ├── evolution │ │ │ ├── Base-RCNN-FPN-MC-B.yaml │ │ │ ├── Base-RCNN-FPN-MC.yaml │ │ │ ├── densepose_R_101_FPN_1x_Atop10_toP.yaml │ │ │ ├── densepose_R_101_FPN_DL_1x_Atop10_toP.yaml │ │ │ ├── densepose_R_101_FPN_DL_WC1M_1x_Atop10_toP.yaml │ │ │ ├── densepose_R_101_FPN_DL_WC1_1x_Atop10_toP.yaml │ │ │ ├── densepose_R_101_FPN_WC1M_1x_Atop10_toP.yaml │ │ │ ├── densepose_R_101_FPN_WC1_1x_Atop10_toP.yaml │ │ │ ├── densepose_R_50_FPN_1x_Atop10_toP.yaml │ │ │ ├── densepose_R_50_FPN_DL_1x_Atop10_toP.yaml │ │ │ ├── densepose_R_50_FPN_DL_WC1M_1x_Atop10_toP.yaml │ │ │ ├── densepose_R_50_FPN_DL_WC1_1x_Atop10_toP.yaml │ │ │ ├── densepose_R_50_FPN_WC1M_1x_Atop10_toP.yaml │ │ │ ├── densepose_R_50_FPN_WC1M_1x_Atop10_toP_B.yaml │ │ │ ├── densepose_R_50_FPN_WC1_1x_Atop10_toP.yaml │ │ │ └── faster_rcnn_R_50_FPN_1x_MC.yaml │ │ └── quick_schedules │ │ │ ├── densepose_rcnn_HRFPN_HRNet_w32_training_acc_test.yaml │ │ │ ├── densepose_rcnn_R_50_FPN_DL_instant_test.yaml │ │ │ ├── densepose_rcnn_R_50_FPN_TTA_inference_acc_test.yaml │ │ │ ├── densepose_rcnn_R_50_FPN_WC1_instant_test.yaml │ │ │ ├── densepose_rcnn_R_50_FPN_WC2_instant_test.yaml │ │ │ ├── densepose_rcnn_R_50_FPN_inference_acc_test.yaml │ │ │ ├── densepose_rcnn_R_50_FPN_instant_test.yaml │ │ │ └── densepose_rcnn_R_50_FPN_training_acc_test.yaml │ ├── densepose │ │ ├── __init__.py │ │ ├── config.py │ │ ├── data │ │ │ ├── __init__.py │ │ │ ├── build.py │ │ │ ├── combined_loader.py │ │ │ ├── dataset_mapper.py │ │ │ ├── datasets │ │ │ │ ├── __init__.py │ │ │ │ ├── builtin.py │ │ │ │ ├── chimpnsee.py │ │ │ │ ├── coco.py │ │ │ │ └── dataset_type.py │ │ │ ├── inference_based_loader.py │ │ │ ├── samplers │ │ │ │ ├── __init__.py │ │ │ │ ├── densepose_base.py │ │ │ │ ├── densepose_confidence_based.py │ │ │ │ ├── densepose_uniform.py │ │ │ │ ├── mask_from_densepose.py │ │ │ │ └── prediction_to_gt.py │ │ │ ├── structures.py │ │ │ ├── transform │ │ │ │ ├── __init__.py │ │ │ │ └── image.py │ │ │ ├── utils.py │ │ │ └── video │ │ │ │ ├── __init__.py │ │ │ │ ├── frame_selector.py │ │ │ │ └── video_keyframe_dataset.py │ │ ├── densepose_coco_evaluation.py │ │ ├── densepose_head.py │ │ ├── engine │ │ │ ├── __init__.py │ │ │ └── trainer.py │ │ ├── evaluator.py │ │ ├── modeling │ │ │ ├── densepose_checkpoint.py │ │ │ ├── hrfpn.py │ │ │ ├── hrnet.py │ │ │ └── test_time_augmentation.py │ │ ├── roi_head.py │ │ ├── utils │ │ │ ├── dbhelper.py │ │ │ ├── logger.py │ │ │ └── transform.py │ │ └── vis │ │ │ ├── base.py │ │ │ ├── bounding_box.py │ │ │ ├── densepose.py │ │ │ └── extractor.py │ ├── dev │ │ ├── README.md │ │ ├── run_inference_tests.sh │ │ └── run_instant_tests.sh │ ├── doc │ │ ├── GETTING_STARTED.md │ │ ├── MODEL_ZOO.md │ │ ├── TOOL_APPLY_NET.md │ │ ├── TOOL_QUERY_DB.md │ │ └── images │ │ │ ├── res_bbox_dp_contour.jpg │ │ │ ├── res_bbox_dp_segm.jpg │ │ │ ├── res_bbox_dp_u.jpg │ │ │ ├── res_bbox_dp_v.jpg │ │ │ ├── vis_bbox_dp_i.jpg │ │ │ ├── vis_bbox_dp_pts.jpg │ │ │ ├── vis_bbox_dp_segm.jpg │ │ │ ├── vis_bbox_dp_u.jpg │ │ │ └── vis_bbox_dp_v.jpg │ ├── query_db.py │ ├── tests │ │ ├── common.py │ │ ├── test_combine_data_loader.py │ │ ├── test_frame_selector.py │ │ ├── test_image_resize_transform.py │ │ ├── test_model_e2e.py │ │ ├── test_setup.py │ │ ├── test_structures.py │ │ └── test_video_keyframe_dataset.py │ └── train_net.py ├── PointRend │ ├── README.md │ ├── configs │ │ ├── InstanceSegmentation │ │ │ ├── Base-PointRend-RCNN-FPN.yaml │ │ │ ├── pointrend_rcnn_R_50_FPN_1x_cityscapes.yaml │ │ │ ├── pointrend_rcnn_R_50_FPN_1x_coco.yaml │ │ │ └── pointrend_rcnn_R_50_FPN_3x_coco.yaml │ │ └── SemanticSegmentation │ │ │ ├── Base-PointRend-Semantic-FPN.yaml │ │ │ └── pointrend_semantic_R_101_FPN_1x_cityscapes.yaml │ ├── point_rend │ │ ├── __init__.py │ │ ├── coarse_mask_head.py │ │ ├── color_augmentation.py │ │ ├── config.py │ │ ├── point_features.py │ │ ├── point_head.py │ │ ├── roi_heads.py │ │ └── semantic_seg.py │ └── train_net.py ├── README.md ├── TensorMask │ ├── README.md │ ├── configs │ │ ├── Base-TensorMask.yaml │ │ ├── tensormask_R_50_FPN_1x.yaml │ │ └── tensormask_R_50_FPN_6x.yaml │ ├── setup.py │ ├── tensormask │ │ ├── __init__.py │ │ ├── arch.py │ │ ├── config.py │ │ └── layers │ │ │ ├── __init__.py │ │ │ ├── csrc │ │ │ ├── SwapAlign2Nat │ │ │ │ ├── SwapAlign2Nat.h │ │ │ │ └── SwapAlign2Nat_cuda.cu │ │ │ └── vision.cpp │ │ │ └── swap_align2nat.py │ ├── tests │ │ ├── __init__.py │ │ └── test_swap_align2nat.py │ └── train_net.py ├── TridentNet │ ├── README.md │ ├── configs │ │ ├── Base-TridentNet-Fast-C4.yaml │ │ ├── tridentnet_fast_R_101_C4_3x.yaml │ │ ├── tridentnet_fast_R_50_C4_1x.yaml │ │ └── tridentnet_fast_R_50_C4_3x.yaml │ ├── train_net.py │ └── tridentnet │ │ ├── __init__.py │ │ ├── config.py │ │ ├── trident_backbone.py │ │ ├── trident_conv.py │ │ ├── trident_rcnn.py │ │ └── trident_rpn.py └── WSL │ ├── .gitignore │ ├── README.md │ ├── configs │ ├── Base-RCNN-DilatedC5.yaml │ ├── COCO-Detection │ │ ├── Base-RCNN-DilatedC5.yaml │ │ ├── oicr_V_16_DC5_1x.yaml │ │ ├── oicr_WSR_101_DC5_1x.yaml │ │ ├── oicr_WSR_18_DC5_1x.yaml │ │ ├── oicr_WSR_50_DC5_1x.yaml │ │ ├── reg │ │ │ ├── oicr_V_16_DC5_1x.yaml │ │ │ ├── oicr_WSR_101_DC5_1x.yaml │ │ │ ├── oicr_WSR_18_DC5_1x.yaml │ │ │ └── oicr_WSR_50_DC5_1x.yaml │ │ ├── wsddn_V_16_DC5_1x.yaml │ │ └── wsddn_WSR_18_DC5_1x.yaml │ ├── FlickrVOC-Detection │ │ ├── Base-RCNN-DilatedC5.yaml │ │ ├── oicr_V_16_DC5_1x.yaml │ │ ├── oicr_WSR_18_DC5_1x.yaml │ │ ├── reg │ │ │ └── oicr_WSR_18_DC5_1x.yaml │ │ ├── wsddn_V_16_DC5_1x.yaml │ │ └── wsddn_WSR_18_DC5_1x.yaml │ ├── PascalVOC-Detection │ │ ├── Base-RCNN-DilatedC5.yaml │ │ ├── Base-RCNN-DilatedC5_VOC2012.yaml │ │ ├── csc_V_16_DC5_1x.yaml │ │ ├── csc_WSR_18_DC5_1x.yaml │ │ ├── csc_oicr_V_16_DC5_1x.yaml │ │ ├── oicr_V_16_DC5_1x.yaml │ │ ├── oicr_WSR_101_DC5_1x.yaml │ │ ├── oicr_WSR_18_DC5_1x.yaml │ │ ├── oicr_WSR_50_DC5_1x.yaml │ │ ├── pcl_V_16_DC5_1x.yaml │ │ ├── pcl_WSR_101_DC5_1x.yaml │ │ ├── pcl_WSR_18_DC5_1x.yaml │ │ ├── pcl_WSR_50_DC5_1x.yaml │ │ ├── reg │ │ │ ├── csc_oicr_V_16_DC5_1x.yaml │ │ │ ├── oicr_V_16_DC5_1x.yaml │ │ │ ├── oicr_WSR_101_DC5_1x.yaml │ │ │ ├── oicr_WSR_18_DC5_1x.yaml │ │ │ ├── oicr_WSR_50_DC5_1x.yaml │ │ │ ├── pcl_V_16_DC5_1x.yaml │ │ │ ├── pcl_WSR_101_DC5_1x.yaml │ │ │ ├── pcl_WSR_18_DC5_1x.yaml │ │ │ └── pcl_WSR_50_DC5_1x.yaml │ │ ├── wsddn_R_101_DC5_1x.yaml │ │ ├── wsddn_R_18_DC5_1x.yaml │ │ ├── wsddn_R_50_DC5_1x.yaml │ │ ├── wsddn_V_16_DC5_1x.yaml │ │ ├── wsddn_WSR_101_DC5_1x.yaml │ │ ├── wsddn_WSR_18_DC5_1x.yaml │ │ └── wsddn_WSR_50_DC5_1x.yaml │ └── PascalVOC-DetectionSegmentation │ │ ├── Base-RCNN-DilatedC5_Det.yaml │ │ ├── Base-RCNN-DilatedC5_Seg.yaml │ │ ├── ws-jds_V_16_DC5_1x_Det.yaml │ │ └── ws-jds_V_16_DC5_1x_Seg.yaml │ ├── requirements.txt │ ├── scripts │ ├── auto_run.sh │ ├── train_resnet101_ws.sh │ ├── train_resnet18.sh │ ├── train_resnet18_nas.sh │ ├── train_resnet18_ws.sh │ └── train_resnet50_ws.sh │ ├── setup.py │ ├── tools │ ├── convert_resnet_ws_c2.py │ ├── convert_resnet_ws_pth.py │ ├── convert_vgg.py │ ├── convert_vgg_init.py │ ├── filter_events.py │ ├── imagenet.py │ ├── proposal_convert.py │ ├── train_net.py │ └── visualize_json_results.py │ └── wsl │ ├── __init__.py │ ├── config │ ├── __init__.py │ └── defaults.py │ ├── data │ ├── __init__.py │ └── datasets │ │ ├── __init__.py │ │ └── builtin.py │ ├── layers │ ├── __init__.py │ ├── crf.py │ ├── csc.py │ ├── csrc │ │ ├── crf │ │ │ ├── crf.h │ │ │ └── crf_cpu.cpp │ │ ├── csc │ │ │ ├── csc.h │ │ │ └── csc_cuda.cu │ │ ├── pcl_loss │ │ │ ├── pcl_loss.h │ │ │ ├── pcl_loss_cpu.cpp │ │ │ ├── pcl_loss_cuda.cu │ │ │ └── pcl_loss_cuda_kernel.cu │ │ └── vision.cpp │ └── pcl_loss.py │ └── modeling │ ├── __init__.py │ ├── backbone │ ├── __init__.py │ ├── resnet_ws.py │ └── vgg.py │ ├── meta_arch │ ├── __init__.py │ └── rcnn.py │ ├── postprocessing.py │ ├── roi_heads │ ├── __init__.py │ ├── box_head.py │ ├── fast_rcnn.py │ ├── roi_heads.py │ ├── roi_heads_csc.py │ ├── roi_heads_oicr.py │ ├── roi_heads_pcl.py │ ├── roi_heads_wsddn.py │ └── third_party │ │ ├── cpg_stats.py │ │ └── pcl.py │ ├── seg_heads │ ├── __init__.py │ ├── crf.py │ ├── seg_heads.py │ └── wsjds_heads.py │ ├── test_time_augmentation_avg.py │ └── test_time_augmentation_union.py ├── setup.cfg ├── setup.py ├── tests ├── README.md ├── __init__.py ├── data │ ├── __init__.py │ ├── test_coco.py │ ├── test_coco_evaluation.py │ ├── test_detection_utils.py │ ├── test_rotation_transform.py │ ├── test_sampler.py │ └── test_transforms.py ├── layers │ ├── __init__.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_box2box_transform.py │ ├── test_fast_rcnn.py │ ├── test_matcher.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_rotated_boxes.py ├── test_checkpoint.py ├── test_config.py ├── test_engine.py ├── test_export_caffe2.py ├── test_model_analysis.py ├── test_model_zoo.py └── test_visualizer.py └── tools ├── README.md ├── analyze_model.py ├── benchmark.py ├── convert-torchvision-to-d2.py ├── deploy ├── CMakeLists.txt ├── README.md ├── caffe2_converter.py ├── caffe2_mask_rcnn.cpp └── torchscript_traced_mask_rcnn.cpp ├── plain_train_net.py ├── train_net.py ├── visualize_data.py └── visualize_json_results.py /.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, E741 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 12 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | 10 | 1. what changes you made (`git diff`) or what code you wrote 11 | ``` 12 | 13 | ``` 14 | 2. what exact command you run: 15 | 3. what you observed (including __full logs__): 16 | ``` 17 | 18 | ``` 19 | 4. please simplify the steps as much as possible so they do not require additional resources to 20 | run, such as a private dataset. 21 | 22 | ## Expected behavior: 23 | 24 | If there are no obvious error in "what you observed" provided above, 25 | please tell us the expected behavior. 26 | 27 | ## Environment: 28 | 29 | Provide your environment information using the following command: 30 | ``` 31 | wget -nc -q https://github.com/facebookresearch/detectron2/raw/master/detectron2/utils/collect_env.py && python collect_env.py 32 | ``` 33 | 34 | If your issue looks like an installation issue / environment issue, 35 | please first try to solve it yourself with the instructions in 36 | https://detectron2.readthedocs.io/tutorials/install.html#common-installation-issues 37 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | # require an issue template to be chosen 2 | blank_issues_enabled: false 3 | 4 | contact_links: 5 | - name: Detectron2 Documentation 6 | url: https://detectron2.readthedocs.io/index.html 7 | about: Check if your question is answered in docs 8 | 9 | # Unexpected behaviors & bugs are split to two templates. 10 | # When they are one template, users think "it's not a bug" and don't choose the template. 11 | # 12 | # But the file name is still "unexpected-problems-bugs.md" so that old references 13 | # to this issue template still works. 14 | # It's ok since this template should be a superset of "bugs.md" (unexpected behaviors is a superset of bugs) 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F680Feature Request" 3 | about: Suggest an improvement or new feature 4 | 5 | --- 6 | 7 | ## 🚀 Feature 8 | A clear and concise description of the feature proposal. 9 | 10 | ## Motivation & Examples 11 | 12 | Tell us why the feature is useful. 13 | 14 | Describe what the feature would look like, if it is implemented. 15 | Best demonstrated using **code examples** in addition to words. 16 | 17 | ## Note 18 | 19 | We only consider adding new features if they are relevant to many users. 20 | 21 | If you request implementation of research papers -- we only consider papers that have enough significance and prevalance in the object detection field. 22 | 23 | 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. 24 | 25 | "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. 26 | 27 | Instead of adding features inside detectron2, 28 | you can implement many features by [extending detectron2](https://detectron2.readthedocs.io/tutorials/extend.html). 29 | The [projects/](https://github.com/facebookresearch/detectron2/tree/master/projects/) directory contains many of such examples. 30 | 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/questions-help-support.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "How to do something❓" 3 | about: How to do something using detectron2? What does an API do? 4 | 5 | --- 6 | 7 | ## ❓ How to do something using detectron2 8 | 9 | Describe what you want to do, including: 10 | 1. what inputs you will provide, if any: 11 | 2. what outputs you are expecting: 12 | 13 | ## ❓ What does an API do and how to use it? 14 | Please link to which API or documentation you're asking about from 15 | https://detectron2.readthedocs.io/ 16 | 17 | 18 | NOTE: 19 | 20 | 1. Only general answers are provided. 21 | If you want to ask about "why X did not work", please use the 22 | [Unexpected behaviors](https://github.com/facebookresearch/detectron2/issues/new/choose) issue template. 23 | 24 | 2. About how to implement new models / new dataloader / new training logic, etc., check documentation first. 25 | 26 | 3. We do not answer general machine learning / computer vision questions that are not specific to detectron2, such as how a model works, how to improve your training/make it converge, or what algorithm/methods can be used to achieve X. 27 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | Thanks for your contribution! 2 | 3 | If you're sending a large PR (e.g., >50 lines), 4 | please open an issue first about the feature / bug, and indicate how you want to contribute. 5 | 6 | Before submitting a PR, please run `dev/linter.sh` to lint the code. 7 | 8 | See https://detectron2.readthedocs.io/notes/contributing.html#pull-requests 9 | about how we handle PRs. 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # output dir 2 | output 3 | instant_test_output 4 | inference_test_output 5 | 6 | 7 | *.jpg 8 | *.png 9 | *.txt 10 | *.json 11 | *.diff 12 | 13 | # compilation and distribution 14 | __pycache__ 15 | _ext 16 | *.pyc 17 | *.pyd 18 | *.so 19 | detectron2.egg-info/ 20 | build/ 21 | dist/ 22 | wheels/ 23 | 24 | # pytorch/python/numpy formats 25 | *.pth 26 | *.pkl 27 | *.npy 28 | 29 | # ipython/jupyter notebooks 30 | *.ipynb 31 | **/.ipynb_checkpoints/ 32 | 33 | # Editor temporaries 34 | *.swn 35 | *.swo 36 | *.swp 37 | *~ 38 | 39 | # editor settings 40 | .idea 41 | .vscode 42 | 43 | # project dirs 44 | /detectron2/model_zoo/configs 45 | /datasets 46 | /projects/*/datasets 47 | /models 48 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "projects/WSL/wsl/layers/csrc/crf/densecrf"] 2 | path = projects/WSL/wsl/layers/csrc/crf/densecrf 3 | url = https://github.com/shenyunhang/densecrf.git 4 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /configs/quick_schedules/README.md: -------------------------------------------------------------------------------- 1 | These are quick configs for performance or accuracy regression tracking purposes. 2 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | DATASETS: 6 | TRAIN: ("keypoints_coco_2017_val_100",) 7 | TEST: ("keypoints_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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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", 38.73, 0.7], ["sem_seg", "mIoU", 64.73, 1.2], ["panoptic_seg", "PQ", 48.13, 0.8]] 21 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /datasets/prepare_for_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 3 | 4 | # Download some files needed for running tests. 5 | 6 | cd "${0%/*}" 7 | 8 | BASE=https://dl.fbaipublicfiles.com/detectron2 9 | mkdir -p coco/annotations 10 | 11 | for anno in instances_val2017_100 \ 12 | person_keypoints_val2017_100 \ 13 | instances_minival2014_100 \ 14 | person_keypoints_minival2014_100; do 15 | 16 | dest=coco/annotations/$anno.json 17 | [[ -s $dest ]] && { 18 | echo "$dest exists. Skipping ..." 19 | } || { 20 | wget $BASE/annotations/coco/$anno.json -O $dest 21 | } 22 | done 23 | -------------------------------------------------------------------------------- /demo/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Detectron2 Demo 3 | 4 | We provide a command line tool to run a simple demo of builtin models. 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 | -------------------------------------------------------------------------------- /detectron2/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 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.2" 11 | -------------------------------------------------------------------------------- /detectron2/checkpoint/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 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 | -------------------------------------------------------------------------------- /detectron2/config/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from .compat import downgrade_config, upgrade_config 3 | from .config import CfgNode, get_cfg, global_cfg, set_global_cfg, configurable 4 | 5 | __all__ = [ 6 | "CfgNode", 7 | "get_cfg", 8 | "global_cfg", 9 | "set_global_cfg", 10 | "downgrade_config", 11 | "upgrade_config", 12 | "configurable", 13 | ] 14 | -------------------------------------------------------------------------------- /detectron2/data/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 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 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /detectron2/data/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from .cityscapes import load_cityscapes_instances 3 | from .coco import load_coco_json, load_sem_seg 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 .register_coco import register_coco_instances, register_coco_panoptic_separated 7 | from . import builtin # ensure the builtin datasets are registered 8 | 9 | 10 | __all__ = [k for k in globals().keys() if "builtin" not in k and not k.startswith("_")] 11 | -------------------------------------------------------------------------------- /detectron2/data/samplers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from .distributed_sampler import InferenceSampler, RepeatFactorTrainingSampler, TrainingSampler 3 | from .grouped_batch_sampler import GroupedBatchSampler 4 | 5 | __all__ = [ 6 | "GroupedBatchSampler", 7 | "TrainingSampler", 8 | "InferenceSampler", 9 | "RepeatFactorTrainingSampler", 10 | ] 11 | -------------------------------------------------------------------------------- /detectron2/data/transforms/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from .transform import * 3 | from fvcore.transforms.transform import * 4 | from .augmentation import * 5 | from .augmentation_impl import * 6 | 7 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 8 | -------------------------------------------------------------------------------- /detectron2/engine/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 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 | -------------------------------------------------------------------------------- /detectron2/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /detectron2/export/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .api import * 4 | 5 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 6 | -------------------------------------------------------------------------------- /detectron2/layers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from .batch_norm import FrozenBatchNorm2d, get_norm, NaiveSyncBatchNorm 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 BatchNorm2d, Conv2d, ConvTranspose2d, cat, interpolate, Linear, nonzero_tuple 10 | from .blocks import CNNBlockBase 11 | from .aspp import ASPP 12 | 13 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /detectron2/layers/csrc/box_iou_rotated/box_iou_rotated.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 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("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 | -------------------------------------------------------------------------------- /detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cpu.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 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 | -------------------------------------------------------------------------------- /detectron2/layers/csrc/cuda_version.cu: -------------------------------------------------------------------------------- 1 | // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 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 | -------------------------------------------------------------------------------- /detectron2/layers/csrc/nms_rotated/nms_rotated.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 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 float 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 float 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 float 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("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 | -------------------------------------------------------------------------------- /detectron2/layers/rotated_boxes.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from __future__ import absolute_import, division, print_function, unicode_literals 3 | 4 | from detectron2 import _C 5 | 6 | 7 | def pairwise_iou_rotated(boxes1, boxes2): 8 | """ 9 | Return intersection-over-union (Jaccard index) of boxes. 10 | 11 | Both sets of boxes are expected to be in 12 | (x_center, y_center, width, height, angle) format. 13 | 14 | Arguments: 15 | boxes1 (Tensor[N, 5]) 16 | boxes2 (Tensor[M, 5]) 17 | 18 | Returns: 19 | iou (Tensor[N, M]): the NxM matrix containing the pairwise 20 | IoU values for every element in boxes1 and boxes2 21 | """ 22 | return _C.box_iou_rotated(boxes1, boxes2) 23 | -------------------------------------------------------------------------------- /detectron2/layers/shape_spec.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 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 obtain the 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 | -------------------------------------------------------------------------------- /detectron2/model_zoo/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | """ 3 | Model Zoo API for Detectron2: a collection of functions to create common model architectures and 4 | optionally load pre-trained weights as released in 5 | `MODEL_ZOO.md `_. 6 | """ 7 | from .model_zoo import get, get_config_file, get_checkpoint_url 8 | 9 | __all__ = ["get_checkpoint_url", "get", "get_config_file"] 10 | -------------------------------------------------------------------------------- /detectron2/modeling/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 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 | ) 26 | from .postprocessing import detector_postprocess 27 | from .proposal_generator import ( 28 | PROPOSAL_GENERATOR_REGISTRY, 29 | build_proposal_generator, 30 | RPN_HEAD_REGISTRY, 31 | build_rpn_head, 32 | ) 33 | from .roi_heads import ( 34 | ROI_BOX_HEAD_REGISTRY, 35 | ROI_HEADS_REGISTRY, 36 | ROI_KEYPOINT_HEAD_REGISTRY, 37 | ROI_MASK_HEAD_REGISTRY, 38 | ROIHeads, 39 | StandardROIHeads, 40 | BaseMaskRCNNHead, 41 | BaseKeypointRCNNHead, 42 | build_box_head, 43 | build_keypoint_head, 44 | build_mask_head, 45 | build_roi_heads, 46 | ) 47 | from .test_time_augmentation import DatasetMapperTTA, GeneralizedRCNNWithTTA 48 | 49 | _EXCLUDE = {"ShapeSpec"} 50 | __all__ = [k for k in globals().keys() if k not in _EXCLUDE and not k.startswith("_")] 51 | -------------------------------------------------------------------------------- /detectron2/modeling/backbone/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 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 .resnet import ResNet, ResNetBlockBase, build_resnet_backbone, make_stage 7 | 8 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 9 | # TODO can expose more resnet blocks after careful consideration 10 | -------------------------------------------------------------------------------- /detectron2/modeling/backbone/build.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 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 | It must returns an 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 | -------------------------------------------------------------------------------- /detectron2/modeling/meta_arch/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 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 .retinanet import RetinaNet 11 | from .semantic_seg import SEM_SEG_HEADS_REGISTRY, SemanticSegmentor, build_sem_seg_head 12 | 13 | 14 | __all__ = list(globals().keys()) 15 | -------------------------------------------------------------------------------- /detectron2/modeling/meta_arch/build.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | import torch 3 | 4 | from detectron2.utils.registry import Registry 5 | 6 | META_ARCH_REGISTRY = Registry("META_ARCH") # noqa F401 isort:skip 7 | META_ARCH_REGISTRY.__doc__ = """ 8 | Registry for meta-architectures, i.e. the whole model. 9 | 10 | The registered object will be called with `obj(cfg)` 11 | and expected to return a `nn.Module` object. 12 | """ 13 | 14 | 15 | def build_model(cfg): 16 | """ 17 | Build the whole model architecture, defined by ``cfg.MODEL.META_ARCHITECTURE``. 18 | Note that it does not load any weights from ``cfg``. 19 | """ 20 | meta_arch = cfg.MODEL.META_ARCHITECTURE 21 | model = META_ARCH_REGISTRY.get(meta_arch)(cfg) 22 | model.to(torch.device(cfg.MODEL.DEVICE)) 23 | return model 24 | -------------------------------------------------------------------------------- /detectron2/modeling/proposal_generator/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from .build import PROPOSAL_GENERATOR_REGISTRY, build_proposal_generator 3 | from .rpn import RPN_HEAD_REGISTRY, build_rpn_head, RPN 4 | 5 | __all__ = list(globals().keys()) 6 | -------------------------------------------------------------------------------- /detectron2/modeling/proposal_generator/build.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 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 | -------------------------------------------------------------------------------- /detectron2/modeling/roi_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from .box_head import ROI_BOX_HEAD_REGISTRY, build_box_head 3 | from .keypoint_head import ROI_KEYPOINT_HEAD_REGISTRY, build_keypoint_head, BaseKeypointRCNNHead 4 | from .mask_head import ROI_MASK_HEAD_REGISTRY, build_mask_head, BaseMaskRCNNHead 5 | from .roi_heads import ( 6 | ROI_HEADS_REGISTRY, 7 | ROIHeads, 8 | Res5ROIHeads, 9 | StandardROIHeads, 10 | build_roi_heads, 11 | select_foreground_proposals, 12 | ) 13 | from .rotated_fast_rcnn import RROIHeads 14 | from .fast_rcnn import FastRCNNOutputLayers 15 | 16 | from . import cascade_rcnn # isort:skip 17 | 18 | __all__ = list(globals().keys()) 19 | -------------------------------------------------------------------------------- /detectron2/solver/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from .build import build_lr_scheduler, build_optimizer 3 | from .lr_scheduler import WarmupCosineLR, WarmupMultiStepLR 4 | 5 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 6 | -------------------------------------------------------------------------------- /detectron2/structures/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from .boxes import Boxes, BoxMode, pairwise_iou 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, rasterize_polygons_within_box, polygons_to_bitmask 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /detectron2/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | -------------------------------------------------------------------------------- /detectron2/utils/registry.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | # Keep this module for backward compatibility. 4 | from fvcore.common.registry import Registry # noqa 5 | 6 | __all__ = ["Registry"] 7 | -------------------------------------------------------------------------------- /detectron2/utils/serialize.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 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 | self._obj = obj 17 | 18 | def __reduce__(self): 19 | s = cloudpickle.dumps(self._obj) 20 | return cloudpickle.loads, (s,) 21 | 22 | def __call__(self, *args, **kwargs): 23 | return self._obj(*args, **kwargs) 24 | 25 | def __getattr__(self, attr): 26 | # Ensure that the wrapped object can be used seamlessly as the previous object. 27 | if attr not in ["_obj"]: 28 | return getattr(self._obj, attr) 29 | return getattr(self, attr) 30 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /dev/linter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 3 | 4 | # Run this script at project root by "./dev/linter.sh" before you commit 5 | 6 | { 7 | black --version | grep -E "(19.3b0.*6733274)|(19.3b0\\+8)" > /dev/null 8 | } || { 9 | echo "Linter requires 'black @ git+https://github.com/psf/black@673327449f86fce558adde153bb6cbe54bfebad2' !" 10 | exit 1 11 | } 12 | 13 | ISORT_VERSION=$(isort --version-number) 14 | if [[ "$ISORT_VERSION" != 4.3* ]]; then 15 | echo "Linter requires isort==4.3.21 !" 16 | exit 1 17 | fi 18 | 19 | set -v 20 | 21 | echo "Running isort ..." 22 | isort -y -sp . --atomic 23 | 24 | echo "Running black ..." 25 | black -l 100 . 26 | 27 | echo "Running flake8 ..." 28 | if [ -x "$(command -v flake8-3)" ]; then 29 | flake8-3 . 30 | else 31 | python3 -m flake8 . 32 | fi 33 | 34 | # echo "Running mypy ..." 35 | # Pytorch does not have enough type annotations 36 | # mypy detectron2/solver detectron2/structures detectron2/config 37 | 38 | echo "Running clang-format ..." 39 | find . -regex ".*\.\(cpp\|c\|cc\|cu\|cxx\|h\|hh\|hpp\|hxx\|tcc\|mm\|m\)" -print0 | xargs -0 clang-format -i 40 | 41 | command -v arc > /dev/null && arc lint 42 | -------------------------------------------------------------------------------- /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.4 10 | # ./dev/packaging/build_wheel.sh 11 | ``` 12 | 13 | ## To build all wheels for `CUDA {9.2,10.0,10.1}` x `Python {3.6,3.7,3.8}`: 14 | ``` 15 | ./dev/packaging/build_all_wheels.sh 16 | ./dev/packaging/gen_wheel_index.sh /path/to/wheels 17 | ``` 18 | -------------------------------------------------------------------------------- /dev/packaging/build_all_wheels.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 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 | 28 | for py in 3.6 3.7 3.8; do 29 | docker run -itd \ 30 | --name $container_name \ 31 | --mount type=bind,source="$(pwd)",target=/detectron2 \ 32 | pytorch/$container_name 33 | 34 | 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$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 | -------------------------------------------------------------------------------- /dev/packaging/gen_wheel_index.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 3 | 4 | 5 | root=$1 6 | if [[ -z "$root" ]]; then 7 | echo "Usage: ./gen_wheel_index.sh /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; do 18 | cd "$root/$cu" 19 | echo "Creating $PWD/index.html ..." 20 | # First sort by torch version, then stable sort by d2 version with unique. 21 | # As a result, the latest torch version for each d2 version is kept. 22 | for whl in $(find -type f -name '*.whl' -printf '%P\n' \ 23 | | sort -k 1 -r | sort -t '/' -k 2 --stable -r --unique); do 24 | echo "$whl
" 25 | done > index.html 26 | 27 | 28 | for torch in torch*; do 29 | cd "$root/$cu/$torch" 30 | 31 | # list all whl for each cuda,torch version 32 | echo "Creating $PWD/index.html ..." 33 | for whl in $(find . -type f -name '*.whl' -printf '%P\n' | sort -r); do 34 | echo "$whl
" 35 | done > index.html 36 | done 37 | done 38 | 39 | cd "$root" 40 | # Just list everything: 41 | echo "Creating $index ..." 42 | for whl in $(find . -type f -name '*.whl' -printf '%P\n' | sort -r); do 43 | echo "$whl
" 44 | done > "$index" 45 | 46 | -------------------------------------------------------------------------------- /dev/run_instant_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 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 | -------------------------------------------------------------------------------- /docker/Dockerfile-circleci: -------------------------------------------------------------------------------- 1 | FROM nvidia/cuda:10.1-cudnn7-devel 2 | # This dockerfile only aims to provide an environment for unittest on CircleCI 3 | 4 | ENV DEBIAN_FRONTEND noninteractive 5 | RUN apt-get update && apt-get install -y \ 6 | ca-certificates python3-dev git wget sudo ninja-build libglib2.0-0 && \ 7 | rm -rf /var/lib/apt/lists/* 8 | 9 | RUN wget -q https://bootstrap.pypa.io/get-pip.py && \ 10 | python3 get-pip.py && \ 11 | rm get-pip.py 12 | 13 | # install dependencies 14 | RUN pip install tensorboard opencv-python-headless pytest-xdist 15 | ARG PYTORCH_VERSION 16 | ARG TORCHVISION_VERSION 17 | RUN pip install torch==${PYTORCH_VERSION} torchvision==${TORCHVISION_VERSION} -f https://download.pytorch.org/whl/cu101/torch_stable.html 18 | -------------------------------------------------------------------------------- /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 | # Run: 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 < 19.03) 18 | 19 | Install docker-compose and nvidia-docker2, then run: 20 | ``` 21 | cd docker && USER_ID=$UID docker-compose run detectron2 22 | ``` 23 | 24 | #### Using a persistent cache directory 25 | 26 | You can prevent models from being re-downloaded on every run, 27 | by storing them in a cache directory. 28 | 29 | To do this, add `--volume=$HOME/.torch/fvcore_cache:/tmp:rw` in the run command. 30 | 31 | ## Install new dependencies 32 | Add the following to `Dockerfile` to make persistent changes. 33 | ``` 34 | RUN sudo apt-get update && sudo apt-get install -y vim 35 | ``` 36 | Or run them in the container to make temporary changes. 37 | -------------------------------------------------------------------------------- /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 | runtime: nvidia # TODO: Exchange with "gpu: all" in the future (see https://github.com/facebookresearch/detectron2/pull/197/commits/00545e1f376918db4a8ce264d427a07c1e896c5a). 10 | shm_size: "8gb" 11 | ulimits: 12 | memlock: -1 13 | stack: 67108864 14 | volumes: 15 | - /tmp/.X11-unix:/tmp/.X11-unix:ro 16 | environment: 17 | - DISPLAY=$DISPLAY 18 | - NVIDIA_VISIBLE_DEVICES=all 19 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 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 | -------------------------------------------------------------------------------- /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.0.0 12 | - recommonmark==0.6.0 13 | - sphinx_rtd_theme 14 | - mock 15 | 16 | 3. Run `make html` from this directory. 17 | -------------------------------------------------------------------------------- /docs/_static/css/custom.css: -------------------------------------------------------------------------------- 1 | /* 2 | * some extra css to make markdown look similar between github/sphinx 3 | */ 4 | 5 | /* 6 | * Below is for install.md: 7 | */ 8 | .rst-content code { 9 | white-space: pre; 10 | border: 0px; 11 | } 12 | 13 | th { 14 | border: 1px solid #e1e4e5; 15 | } 16 | 17 | div.section > details { 18 | padding-bottom: 1em; 19 | } 20 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /docs/modules/checkpoint.rst: -------------------------------------------------------------------------------- 1 | detectron2.checkpoint package 2 | ============================= 3 | 4 | .. automodule:: detectron2.checkpoint 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/modules/config.rst: -------------------------------------------------------------------------------- 1 | detectron2.config package 2 | ========================= 3 | 4 | .. automodule:: detectron2.config 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | :inherited-members: 9 | 10 | 11 | Config References 12 | ----------------- 13 | 14 | .. literalinclude:: ../../detectron2/config/defaults.py 15 | :language: python 16 | :linenos: 17 | :lines: 4- 18 | -------------------------------------------------------------------------------- /docs/modules/data.rst: -------------------------------------------------------------------------------- 1 | detectron2.data package 2 | ======================= 3 | 4 | .. automodule:: detectron2.data 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | 9 | detectron2.data.detection\_utils module 10 | --------------------------------------- 11 | 12 | .. automodule:: detectron2.data.detection_utils 13 | :members: 14 | :undoc-members: 15 | :show-inheritance: 16 | 17 | detectron2.data.datasets module 18 | --------------------------------------- 19 | 20 | .. automodule:: detectron2.data.datasets 21 | :members: 22 | :undoc-members: 23 | :show-inheritance: 24 | 25 | detectron2.data.samplers module 26 | --------------------------------------- 27 | 28 | .. automodule:: detectron2.data.samplers 29 | :members: 30 | :undoc-members: 31 | :show-inheritance: 32 | 33 | 34 | detectron2.data.transforms module 35 | --------------------------------------- 36 | 37 | .. automodule:: detectron2.data.transforms 38 | :members: 39 | :undoc-members: 40 | :show-inheritance: 41 | -------------------------------------------------------------------------------- /docs/modules/engine.rst: -------------------------------------------------------------------------------- 1 | detectron2.engine package 2 | ========================= 3 | 4 | 5 | .. automodule:: detectron2.engine 6 | :members: 7 | :undoc-members: 8 | :show-inheritance: 9 | 10 | 11 | detectron2.engine.defaults module 12 | --------------------------------- 13 | 14 | .. automodule:: detectron2.engine.defaults 15 | :members: 16 | :undoc-members: 17 | :show-inheritance: 18 | 19 | detectron2.engine.hooks module 20 | --------------------------------- 21 | 22 | .. automodule:: detectron2.engine.hooks 23 | :members: 24 | :undoc-members: 25 | :show-inheritance: 26 | -------------------------------------------------------------------------------- /docs/modules/evaluation.rst: -------------------------------------------------------------------------------- 1 | detectron2.evaluation package 2 | ============================= 3 | 4 | .. automodule:: detectron2.evaluation 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/modules/export.rst: -------------------------------------------------------------------------------- 1 | detectron2.export package 2 | ========================= 3 | 4 | .. automodule:: detectron2.export 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/modules/index.rst: -------------------------------------------------------------------------------- 1 | API Documentation 2 | ================== 3 | 4 | .. toctree:: 5 | 6 | checkpoint 7 | config 8 | data 9 | engine 10 | evaluation 11 | layers 12 | model_zoo 13 | modeling 14 | solver 15 | structures 16 | utils 17 | export 18 | -------------------------------------------------------------------------------- /docs/modules/layers.rst: -------------------------------------------------------------------------------- 1 | detectron2.layers package 2 | ========================= 3 | 4 | .. automodule:: detectron2.layers 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/modules/model_zoo.rst: -------------------------------------------------------------------------------- 1 | detectron2.model_zoo package 2 | ============================ 3 | 4 | .. automodule:: detectron2.model_zoo 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/modules/solver.rst: -------------------------------------------------------------------------------- 1 | detectron2.solver package 2 | ========================= 3 | 4 | .. automodule:: detectron2.solver 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/modules/structures.rst: -------------------------------------------------------------------------------- 1 | detectron2.structures package 2 | ============================= 3 | 4 | .. automodule:: detectron2.structures 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/notes/contributing.md: -------------------------------------------------------------------------------- 1 | ../../.github/CONTRIBUTING.md -------------------------------------------------------------------------------- /docs/notes/index.rst: -------------------------------------------------------------------------------- 1 | Notes 2 | ====================================== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | benchmarks 8 | compatibility 9 | contributing 10 | changelog 11 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | termcolor 2 | numpy 3 | tqdm 4 | docutils==0.16 5 | # https://github.com/sphinx-doc/sphinx/commit/7acd3ada3f38076af7b2b5c9f3b60bb9c2587a3d 6 | git+git://github.com/sphinx-doc/sphinx.git@7acd3ada3f38076af7b2b5c9f3b60bb9c2587a3d 7 | recommonmark==0.6.0 8 | sphinx_rtd_theme 9 | mock 10 | matplotlib 11 | termcolor 12 | yacs 13 | tabulate 14 | cloudpickle 15 | Pillow==6.2.2 16 | future 17 | requests 18 | six 19 | git+git://github.com/facebookresearch/fvcore.git 20 | https://download.pytorch.org/whl/cpu/torch-1.5.0%2Bcpu-cp37-cp37m-linux_x86_64.whl 21 | https://download.pytorch.org/whl/cpu/torchvision-0.6.0%2Bcpu-cp37-cp37m-linux_x86_64.whl 22 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /docs/tutorials/builtin_datasets.md: -------------------------------------------------------------------------------- 1 | ../../datasets/README.md -------------------------------------------------------------------------------- /docs/tutorials/getting_started.md: -------------------------------------------------------------------------------- 1 | ../../GETTING_STARTED.md -------------------------------------------------------------------------------- /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 | models 14 | write-models 15 | training 16 | evaluation 17 | configs 18 | deployment 19 | -------------------------------------------------------------------------------- /docs/tutorials/install.md: -------------------------------------------------------------------------------- 1 | ../../INSTALL.md -------------------------------------------------------------------------------- /projects/DeepLab/configs/Cityscapes-SemanticSegmentation/Base-DeepLabV3-OS16-Semantic.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../../../configs/Base-RCNN-DilatedC5.yaml" 2 | MODEL: 3 | META_ARCHITECTURE: "SemanticSegmentor" 4 | BACKBONE: 5 | FREEZE_AT: 0 6 | SEM_SEG_HEAD: 7 | NAME: "DeepLabV3Head" 8 | IN_FEATURES: ["res5"] 9 | ASPP_CHANNELS: 256 10 | ASPP_DILATIONS: [6, 12, 18] 11 | ASPP_DROPOUT: 0.1 12 | CONVS_DIM: 256 13 | COMMON_STRIDE: 16 14 | NUM_CLASSES: 19 15 | LOSS_TYPE: "hard_pixel_mining" 16 | DATASETS: 17 | TRAIN: ("cityscapes_fine_sem_seg_train",) 18 | TEST: ("cityscapes_fine_sem_seg_val",) 19 | SOLVER: 20 | BASE_LR: 0.01 21 | MAX_ITER: 90000 22 | LR_SCHEDULER_NAME: "WarmupPolyLR" 23 | IMS_PER_BATCH: 16 24 | INPUT: 25 | FORMAT: "RGB" 26 | MIN_SIZE_TRAIN: (512, 768, 1024, 1280, 1536, 1792, 2048) 27 | MIN_SIZE_TRAIN_SAMPLING: "choice" 28 | MIN_SIZE_TEST: 1024 29 | MAX_SIZE_TRAIN: 4096 30 | MAX_SIZE_TEST: 2048 31 | CROP: 32 | ENABLED: True 33 | TYPE: "absolute" 34 | SIZE: (512, 1024) 35 | SINGLE_CATEGORY_MAX_AREA: 1.0 36 | DATALOADER: 37 | NUM_WORKERS: 10 -------------------------------------------------------------------------------- /projects/DeepLab/configs/Cityscapes-SemanticSegmentation/deeplab_v3_R_103_os16_mg124_poly_90k_bs16.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: Base-DeepLabV3-OS16-Semantic.yaml 2 | MODEL: 3 | WEIGHTS: "detectron2://DeepLab/R-103.pkl" 4 | PIXEL_MEAN: [123.675, 116.280, 103.530] 5 | PIXEL_STD: [58.395, 57.120, 57.375] 6 | BACKBONE: 7 | NAME: "build_resnet_deeplab_backbone" 8 | RESNETS: 9 | DEPTH: 101 10 | NORM: "SyncBN" 11 | RES5_MULTI_GRID: [1, 2, 4] 12 | STEM_TYPE: "deeplab" 13 | STEM_OUT_CHANNELS: 128 14 | STRIDE_IN_1X1: False 15 | SEM_SEG_HEAD: 16 | NAME: "DeepLabV3Head" 17 | NORM: "SyncBN" 18 | 19 | -------------------------------------------------------------------------------- /projects/DeepLab/configs/Cityscapes-SemanticSegmentation/deeplab_v3_plus_R_103_os16_mg124_poly_90k_bs16.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: Base-DeepLabV3-OS16-Semantic.yaml 2 | MODEL: 3 | WEIGHTS: "detectron2://DeepLab/R-103.pkl" 4 | PIXEL_MEAN: [123.675, 116.280, 103.530] 5 | PIXEL_STD: [58.395, 57.120, 57.375] 6 | BACKBONE: 7 | NAME: "build_resnet_deeplab_backbone" 8 | RESNETS: 9 | DEPTH: 101 10 | NORM: "SyncBN" 11 | OUT_FEATURES: ["res2", "res5"] 12 | RES5_MULTI_GRID: [1, 2, 4] 13 | STEM_TYPE: "deeplab" 14 | STEM_OUT_CHANNELS: 128 15 | STRIDE_IN_1X1: False 16 | SEM_SEG_HEAD: 17 | NAME: "DeepLabV3PlusHead" 18 | IN_FEATURES: ["res2", "res5"] 19 | PROJECT_FEATURES: ["res2"] 20 | PROJECT_CHANNELS: [48] 21 | NORM: "SyncBN" 22 | COMMON_STRIDE: 4 23 | -------------------------------------------------------------------------------- /projects/DeepLab/deeplab/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from .build_solver import build_lr_scheduler 3 | from .config import add_deeplab_config 4 | from .resnet import build_resnet_deeplab_backbone 5 | from .semantic_seg import DeepLabV3Head, DeepLabV3PlusHead 6 | -------------------------------------------------------------------------------- /projects/DeepLab/deeplab/build_solver.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | import torch 3 | 4 | from detectron2.config import CfgNode 5 | from detectron2.solver import build_lr_scheduler as build_d2_lr_scheduler 6 | 7 | from .lr_scheduler import WarmupPolyLR 8 | 9 | 10 | def build_lr_scheduler( 11 | cfg: CfgNode, optimizer: torch.optim.Optimizer 12 | ) -> torch.optim.lr_scheduler._LRScheduler: 13 | """ 14 | Build a LR scheduler from config. 15 | """ 16 | name = cfg.SOLVER.LR_SCHEDULER_NAME 17 | if name == "WarmupPolyLR": 18 | return WarmupPolyLR( 19 | optimizer, 20 | cfg.SOLVER.MAX_ITER, 21 | warmup_factor=cfg.SOLVER.WARMUP_FACTOR, 22 | warmup_iters=cfg.SOLVER.WARMUP_ITERS, 23 | warmup_method=cfg.SOLVER.WARMUP_METHOD, 24 | power=cfg.SOLVER.POLY_LR_POWER, 25 | constant_ending=cfg.SOLVER.POLY_LR_CONSTANT_ENDING, 26 | ) 27 | else: 28 | return build_d2_lr_scheduler(cfg, optimizer) 29 | -------------------------------------------------------------------------------- /projects/DeepLab/deeplab/config.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 3 | 4 | 5 | def add_deeplab_config(cfg): 6 | """ 7 | Add config for DeepLab. 8 | """ 9 | # We retry random cropping until no single category in semantic segmentation GT occupies more 10 | # than `SINGLE_CATEGORY_MAX_AREA` part of the crop. 11 | cfg.INPUT.CROP.SINGLE_CATEGORY_MAX_AREA = 1.0 12 | # Used for `poly` learning rate schedule. 13 | cfg.SOLVER.POLY_LR_POWER = 0.9 14 | cfg.SOLVER.POLY_LR_CONSTANT_ENDING = 0.0 15 | # Loss type, choose from `cross_entropy`, `hard_pixel_mining`. 16 | cfg.MODEL.SEM_SEG_HEAD.LOSS_TYPE = "hard_pixel_mining" 17 | # DeepLab settings 18 | cfg.MODEL.SEM_SEG_HEAD.PROJECT_FEATURES = ["res2"] 19 | cfg.MODEL.SEM_SEG_HEAD.PROJECT_CHANNELS = [48] 20 | cfg.MODEL.SEM_SEG_HEAD.ASPP_CHANNELS = 256 21 | cfg.MODEL.SEM_SEG_HEAD.ASPP_DILATIONS = [6, 12, 18] 22 | cfg.MODEL.SEM_SEG_HEAD.ASPP_DROPOUT = 0.1 23 | # Backbone new configs 24 | cfg.MODEL.RESNETS.RES4_DILATION = 1 25 | cfg.MODEL.RESNETS.RES5_MULTI_GRID = [1, 2, 4] 26 | # ResNet stem type from: `basic`, `deeplab` 27 | cfg.MODEL.RESNETS.STEM_TYPE = "deeplab" 28 | -------------------------------------------------------------------------------- /projects/DensePose/configs/HRNet/densepose_rcnn_HRFPN_HRNet_w32_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "https://1drv.ms/u/s!Aus8VCZ_C_33dYBMemi9xOUFR0w" 4 | BACKBONE: 5 | NAME: "build_hrfpn_backbone" 6 | RPN: 7 | IN_FEATURES: ['p1', 'p2', 'p3', 'p4', 'p5'] 8 | ROI_HEADS: 9 | IN_FEATURES: ['p1', 'p2', 'p3', 'p4', 'p5'] 10 | SOLVER: 11 | MAX_ITER: 130000 12 | STEPS: (100000, 120000) 13 | CLIP_GRADIENTS: 14 | ENABLED: True 15 | CLIP_TYPE: "norm" 16 | BASE_LR: 0.03 17 | -------------------------------------------------------------------------------- /projects/DensePose/configs/HRNet/densepose_rcnn_HRFPN_HRNet_w40_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "https://1drv.ms/u/s!Aus8VCZ_C_33ck0gvo5jfoWBOPo" 4 | BACKBONE: 5 | NAME: "build_hrfpn_backbone" 6 | RPN: 7 | IN_FEATURES: ['p1', 'p2', 'p3', 'p4', 'p5'] 8 | ROI_HEADS: 9 | IN_FEATURES: ['p1', 'p2', 'p3', 'p4', 'p5'] 10 | HRNET: 11 | STAGE2: 12 | NUM_CHANNELS: [40, 80] 13 | STAGE3: 14 | NUM_CHANNELS: [40, 80, 160] 15 | STAGE4: 16 | NUM_CHANNELS: [40, 80, 160, 320] 17 | SOLVER: 18 | MAX_ITER: 130000 19 | STEPS: (100000, 120000) 20 | CLIP_GRADIENTS: 21 | ENABLED: True 22 | CLIP_TYPE: "norm" 23 | BASE_LR: 0.03 24 | -------------------------------------------------------------------------------- /projects/DensePose/configs/HRNet/densepose_rcnn_HRFPN_HRNet_w48_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "https://1drv.ms/u/s!Aus8VCZ_C_33dKvqI6pBZlifgJk" 4 | BACKBONE: 5 | NAME: "build_hrfpn_backbone" 6 | RPN: 7 | IN_FEATURES: ['p1', 'p2', 'p3', 'p4', 'p5'] 8 | ROI_HEADS: 9 | IN_FEATURES: ['p1', 'p2', 'p3', 'p4', 'p5'] 10 | HRNET: 11 | STAGE2: 12 | NUM_CHANNELS: [48, 96] 13 | STAGE3: 14 | NUM_CHANNELS: [48, 96, 192] 15 | STAGE4: 16 | NUM_CHANNELS: [48, 96, 192, 384] 17 | SOLVER: 18 | MAX_ITER: 130000 19 | STEPS: (100000, 120000) 20 | CLIP_GRADIENTS: 21 | ENABLED: True 22 | CLIP_TYPE: "norm" 23 | BASE_LR: 0.03 24 | -------------------------------------------------------------------------------- /projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC1_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | ROI_DENSEPOSE_HEAD: 7 | NAME: "DensePoseDeepLabHead" 8 | UV_CONFIDENCE: 9 | ENABLED: True 10 | TYPE: "iid_iso" 11 | POINT_REGRESSION_WEIGHTS: 0.0005 12 | SOLVER: 13 | CLIP_GRADIENTS: 14 | ENABLED: True 15 | MAX_ITER: 130000 16 | STEPS: (100000, 120000) 17 | -------------------------------------------------------------------------------- /projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC2_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | ROI_DENSEPOSE_HEAD: 7 | NAME: "DensePoseDeepLabHead" 8 | UV_CONFIDENCE: 9 | ENABLED: True 10 | TYPE: "indep_aniso" 11 | POINT_REGRESSION_WEIGHTS: 0.0005 12 | SOLVER: 13 | CLIP_GRADIENTS: 14 | ENABLED: True 15 | MAX_ITER: 130000 16 | STEPS: (100000, 120000) 17 | -------------------------------------------------------------------------------- /projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | ROI_DENSEPOSE_HEAD: 7 | NAME: "DensePoseDeepLabHead" 8 | SOLVER: 9 | MAX_ITER: 130000 10 | STEPS: (100000, 120000) 11 | -------------------------------------------------------------------------------- /projects/DensePose/configs/densepose_rcnn_R_101_FPN_WC1_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | ROI_DENSEPOSE_HEAD: 7 | UV_CONFIDENCE: 8 | ENABLED: True 9 | TYPE: "iid_iso" 10 | POINT_REGRESSION_WEIGHTS: 0.0005 11 | SOLVER: 12 | CLIP_GRADIENTS: 13 | ENABLED: True 14 | MAX_ITER: 130000 15 | STEPS: (100000, 120000) 16 | WARMUP_FACTOR: 0.025 17 | -------------------------------------------------------------------------------- /projects/DensePose/configs/densepose_rcnn_R_101_FPN_WC2_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | ROI_DENSEPOSE_HEAD: 7 | UV_CONFIDENCE: 8 | ENABLED: True 9 | TYPE: "indep_aniso" 10 | POINT_REGRESSION_WEIGHTS: 0.0005 11 | SOLVER: 12 | CLIP_GRADIENTS: 13 | ENABLED: True 14 | MAX_ITER: 130000 15 | STEPS: (100000, 120000) 16 | WARMUP_FACTOR: 0.025 17 | -------------------------------------------------------------------------------- /projects/DensePose/configs/densepose_rcnn_R_101_FPN_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | SOLVER: 7 | MAX_ITER: 130000 8 | STEPS: (100000, 120000) 9 | -------------------------------------------------------------------------------- /projects/DensePose/configs/densepose_rcnn_R_101_FPN_s1x_legacy.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | ROI_DENSEPOSE_HEAD: 7 | NUM_COARSE_SEGM_CHANNELS: 15 8 | POOLER_RESOLUTION: 14 9 | HEATMAP_SIZE: 56 10 | INDEX_WEIGHTS: 2.0 11 | PART_WEIGHTS: 0.3 12 | POINT_REGRESSION_WEIGHTS: 0.1 13 | DECODER_ON: False 14 | SOLVER: 15 | BASE_LR: 0.002 16 | MAX_ITER: 130000 17 | STEPS: (100000, 120000) 18 | -------------------------------------------------------------------------------- /projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_WC1_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | ROI_DENSEPOSE_HEAD: 7 | NAME: "DensePoseDeepLabHead" 8 | UV_CONFIDENCE: 9 | ENABLED: True 10 | TYPE: "iid_iso" 11 | POINT_REGRESSION_WEIGHTS: 0.0005 12 | SOLVER: 13 | CLIP_GRADIENTS: 14 | ENABLED: True 15 | MAX_ITER: 130000 16 | STEPS: (100000, 120000) 17 | -------------------------------------------------------------------------------- /projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_WC2_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | ROI_DENSEPOSE_HEAD: 7 | NAME: "DensePoseDeepLabHead" 8 | UV_CONFIDENCE: 9 | ENABLED: True 10 | TYPE: "indep_aniso" 11 | POINT_REGRESSION_WEIGHTS: 0.0005 12 | SOLVER: 13 | CLIP_GRADIENTS: 14 | ENABLED: True 15 | MAX_ITER: 130000 16 | STEPS: (100000, 120000) 17 | -------------------------------------------------------------------------------- /projects/DensePose/configs/densepose_rcnn_R_50_FPN_DL_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | ROI_DENSEPOSE_HEAD: 7 | NAME: "DensePoseDeepLabHead" 8 | SOLVER: 9 | MAX_ITER: 130000 10 | STEPS: (100000, 120000) 11 | -------------------------------------------------------------------------------- /projects/DensePose/configs/densepose_rcnn_R_50_FPN_WC1_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | ROI_DENSEPOSE_HEAD: 7 | UV_CONFIDENCE: 8 | ENABLED: True 9 | TYPE: "iid_iso" 10 | POINT_REGRESSION_WEIGHTS: 0.0005 11 | SOLVER: 12 | CLIP_GRADIENTS: 13 | ENABLED: True 14 | MAX_ITER: 130000 15 | STEPS: (100000, 120000) 16 | WARMUP_FACTOR: 0.025 17 | -------------------------------------------------------------------------------- /projects/DensePose/configs/densepose_rcnn_R_50_FPN_WC2_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | ROI_DENSEPOSE_HEAD: 7 | UV_CONFIDENCE: 8 | ENABLED: True 9 | TYPE: "indep_aniso" 10 | POINT_REGRESSION_WEIGHTS: 0.0005 11 | SOLVER: 12 | CLIP_GRADIENTS: 13 | ENABLED: True 14 | MAX_ITER: 130000 15 | STEPS: (100000, 120000) 16 | WARMUP_FACTOR: 0.025 17 | -------------------------------------------------------------------------------- /projects/DensePose/configs/densepose_rcnn_R_50_FPN_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | SOLVER: 7 | MAX_ITER: 130000 8 | STEPS: (100000, 120000) 9 | -------------------------------------------------------------------------------- /projects/DensePose/configs/densepose_rcnn_R_50_FPN_s1x_legacy.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | ROI_DENSEPOSE_HEAD: 7 | NUM_COARSE_SEGM_CHANNELS: 15 8 | POOLER_RESOLUTION: 14 9 | HEATMAP_SIZE: 56 10 | INDEX_WEIGHTS: 2.0 11 | PART_WEIGHTS: 0.3 12 | POINT_REGRESSION_WEIGHTS: 0.1 13 | DECODER_ON: False 14 | SOLVER: 15 | BASE_LR: 0.002 16 | MAX_ITER: 130000 17 | STEPS: (100000, 120000) 18 | -------------------------------------------------------------------------------- /projects/DensePose/configs/evolution/densepose_R_101_FPN_1x_Atop10_toP.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-FPN-MC.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | DENSEPOSE_ON: True 7 | ROI_HEADS: 8 | NAME: "DensePoseROIHeads" 9 | IN_FEATURES: ["p2", "p3", "p4", "p5"] 10 | NUM_CLASSES: 1 11 | ROI_DENSEPOSE_HEAD: 12 | NAME: "DensePoseV1ConvXHead" 13 | POOLER_TYPE: "ROIAlign" 14 | NUM_COARSE_SEGM_CHANNELS: 2 15 | COARSE_SEGM_TRAINED_BY_MASKS: True 16 | INDEX_WEIGHTS: 1.0 17 | DATASETS: 18 | TRAIN: ("base_coco_2017_train", "densepose_coco_2014_train") 19 | TEST: ("densepose_chimps",) 20 | -------------------------------------------------------------------------------- /projects/DensePose/configs/evolution/densepose_R_101_FPN_DL_1x_Atop10_toP.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-FPN-MC.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | DENSEPOSE_ON: True 7 | ROI_HEADS: 8 | NAME: "DensePoseROIHeads" 9 | IN_FEATURES: ["p2", "p3", "p4", "p5"] 10 | NUM_CLASSES: 1 11 | ROI_DENSEPOSE_HEAD: 12 | NAME: "DensePoseDeepLabHead" 13 | POOLER_TYPE: "ROIAlign" 14 | NUM_COARSE_SEGM_CHANNELS: 2 15 | COARSE_SEGM_TRAINED_BY_MASKS: True 16 | INDEX_WEIGHTS: 1.0 17 | DATASETS: 18 | TRAIN: ("base_coco_2017_train", "densepose_coco_2014_train") 19 | TEST: ("densepose_chimps",) 20 | -------------------------------------------------------------------------------- /projects/DensePose/configs/evolution/densepose_R_101_FPN_DL_WC1M_1x_Atop10_toP.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-FPN-MC.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | DENSEPOSE_ON: True 7 | ROI_HEADS: 8 | NAME: "DensePoseROIHeads" 9 | IN_FEATURES: ["p2", "p3", "p4", "p5"] 10 | NUM_CLASSES: 1 11 | ROI_DENSEPOSE_HEAD: 12 | NAME: "DensePoseDeepLabHead" 13 | UV_CONFIDENCE: 14 | ENABLED: True 15 | TYPE: "iid_iso" 16 | SEGM_CONFIDENCE: 17 | ENABLED: True 18 | POINT_REGRESSION_WEIGHTS: 0.0005 19 | POOLER_TYPE: "ROIAlign" 20 | NUM_COARSE_SEGM_CHANNELS: 2 21 | COARSE_SEGM_TRAINED_BY_MASKS: True 22 | INDEX_WEIGHTS: 1.0 23 | SOLVER: 24 | CLIP_GRADIENTS: 25 | ENABLED: True 26 | WARMUP_FACTOR: 0.025 27 | DATASETS: 28 | TRAIN: ("base_coco_2017_train", "densepose_coco_2014_train") 29 | TEST: ("densepose_chimps",) 30 | -------------------------------------------------------------------------------- /projects/DensePose/configs/evolution/densepose_R_101_FPN_DL_WC1_1x_Atop10_toP.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-FPN-MC.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | DENSEPOSE_ON: True 7 | ROI_HEADS: 8 | NAME: "DensePoseROIHeads" 9 | IN_FEATURES: ["p2", "p3", "p4", "p5"] 10 | NUM_CLASSES: 1 11 | ROI_DENSEPOSE_HEAD: 12 | NAME: "DensePoseDeepLabHead" 13 | UV_CONFIDENCE: 14 | ENABLED: True 15 | TYPE: "iid_iso" 16 | POINT_REGRESSION_WEIGHTS: 0.0005 17 | POOLER_TYPE: "ROIAlign" 18 | NUM_COARSE_SEGM_CHANNELS: 2 19 | COARSE_SEGM_TRAINED_BY_MASKS: True 20 | INDEX_WEIGHTS: 1.0 21 | SOLVER: 22 | CLIP_GRADIENTS: 23 | ENABLED: True 24 | WARMUP_FACTOR: 0.025 25 | DATASETS: 26 | TRAIN: ("base_coco_2017_train", "densepose_coco_2014_train") 27 | TEST: ("densepose_chimps",) 28 | -------------------------------------------------------------------------------- /projects/DensePose/configs/evolution/densepose_R_101_FPN_WC1M_1x_Atop10_toP.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-FPN-MC.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | DENSEPOSE_ON: True 7 | ROI_HEADS: 8 | NAME: "DensePoseROIHeads" 9 | IN_FEATURES: ["p2", "p3", "p4", "p5"] 10 | NUM_CLASSES: 1 11 | ROI_DENSEPOSE_HEAD: 12 | NAME: "DensePoseV1ConvXHead" 13 | UV_CONFIDENCE: 14 | ENABLED: True 15 | TYPE: "iid_iso" 16 | SEGM_CONFIDENCE: 17 | ENABLED: True 18 | POINT_REGRESSION_WEIGHTS: 0.0005 19 | POOLER_TYPE: "ROIAlign" 20 | NUM_COARSE_SEGM_CHANNELS: 2 21 | COARSE_SEGM_TRAINED_BY_MASKS: True 22 | INDEX_WEIGHTS: 1.0 23 | SOLVER: 24 | CLIP_GRADIENTS: 25 | ENABLED: True 26 | WARMUP_FACTOR: 0.025 27 | DATASETS: 28 | TRAIN: ("base_coco_2017_train", "densepose_coco_2014_train") 29 | TEST: ("densepose_chimps",) 30 | -------------------------------------------------------------------------------- /projects/DensePose/configs/evolution/densepose_R_101_FPN_WC1_1x_Atop10_toP.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-FPN-MC.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | DENSEPOSE_ON: True 7 | ROI_HEADS: 8 | NAME: "DensePoseROIHeads" 9 | IN_FEATURES: ["p2", "p3", "p4", "p5"] 10 | NUM_CLASSES: 1 11 | ROI_DENSEPOSE_HEAD: 12 | NAME: "DensePoseV1ConvXHead" 13 | UV_CONFIDENCE: 14 | ENABLED: True 15 | TYPE: "iid_iso" 16 | POINT_REGRESSION_WEIGHTS: 0.0005 17 | POOLER_TYPE: "ROIAlign" 18 | NUM_COARSE_SEGM_CHANNELS: 2 19 | COARSE_SEGM_TRAINED_BY_MASKS: True 20 | INDEX_WEIGHTS: 1.0 21 | SOLVER: 22 | CLIP_GRADIENTS: 23 | ENABLED: True 24 | WARMUP_FACTOR: 0.025 25 | DATASETS: 26 | TRAIN: ("base_coco_2017_train", "densepose_coco_2014_train") 27 | TEST: ("densepose_chimps",) 28 | -------------------------------------------------------------------------------- /projects/DensePose/configs/evolution/densepose_R_50_FPN_1x_Atop10_toP.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-FPN-MC.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | DENSEPOSE_ON: True 7 | ROI_HEADS: 8 | NAME: "DensePoseROIHeads" 9 | IN_FEATURES: ["p2", "p3", "p4", "p5"] 10 | NUM_CLASSES: 1 11 | ROI_DENSEPOSE_HEAD: 12 | NAME: "DensePoseV1ConvXHead" 13 | POOLER_TYPE: "ROIAlign" 14 | NUM_COARSE_SEGM_CHANNELS: 2 15 | COARSE_SEGM_TRAINED_BY_MASKS: True 16 | INDEX_WEIGHTS: 1.0 17 | DATASETS: 18 | TRAIN: ("base_coco_2017_train", "densepose_coco_2014_train") 19 | TEST: ("densepose_chimps",) 20 | -------------------------------------------------------------------------------- /projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_1x_Atop10_toP.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-FPN-MC.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | DENSEPOSE_ON: True 7 | ROI_HEADS: 8 | NAME: "DensePoseROIHeads" 9 | IN_FEATURES: ["p2", "p3", "p4", "p5"] 10 | NUM_CLASSES: 1 11 | ROI_DENSEPOSE_HEAD: 12 | NAME: "DensePoseDeepLabHead" 13 | POOLER_TYPE: "ROIAlign" 14 | NUM_COARSE_SEGM_CHANNELS: 2 15 | COARSE_SEGM_TRAINED_BY_MASKS: True 16 | INDEX_WEIGHTS: 1.0 17 | DATASETS: 18 | TRAIN: ("base_coco_2017_train", "densepose_coco_2014_train") 19 | TEST: ("densepose_chimps",) 20 | -------------------------------------------------------------------------------- /projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1M_1x_Atop10_toP.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-FPN-MC.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | DENSEPOSE_ON: True 7 | ROI_HEADS: 8 | NAME: "DensePoseROIHeads" 9 | IN_FEATURES: ["p2", "p3", "p4", "p5"] 10 | NUM_CLASSES: 1 11 | ROI_DENSEPOSE_HEAD: 12 | NAME: "DensePoseDeepLabHead" 13 | UV_CONFIDENCE: 14 | ENABLED: True 15 | TYPE: "iid_iso" 16 | SEGM_CONFIDENCE: 17 | ENABLED: True 18 | POINT_REGRESSION_WEIGHTS: 0.0005 19 | POOLER_TYPE: "ROIAlign" 20 | NUM_COARSE_SEGM_CHANNELS: 2 21 | COARSE_SEGM_TRAINED_BY_MASKS: True 22 | INDEX_WEIGHTS: 1.0 23 | SOLVER: 24 | CLIP_GRADIENTS: 25 | ENABLED: True 26 | WARMUP_FACTOR: 0.025 27 | DATASETS: 28 | TRAIN: ("base_coco_2017_train", "densepose_coco_2014_train") 29 | TEST: ("densepose_chimps",) 30 | -------------------------------------------------------------------------------- /projects/DensePose/configs/evolution/densepose_R_50_FPN_DL_WC1_1x_Atop10_toP.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-FPN-MC.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | DENSEPOSE_ON: True 7 | ROI_HEADS: 8 | NAME: "DensePoseROIHeads" 9 | IN_FEATURES: ["p2", "p3", "p4", "p5"] 10 | NUM_CLASSES: 1 11 | ROI_DENSEPOSE_HEAD: 12 | NAME: "DensePoseDeepLabHead" 13 | UV_CONFIDENCE: 14 | ENABLED: True 15 | TYPE: "iid_iso" 16 | POINT_REGRESSION_WEIGHTS: 0.0005 17 | POOLER_TYPE: "ROIAlign" 18 | NUM_COARSE_SEGM_CHANNELS: 2 19 | COARSE_SEGM_TRAINED_BY_MASKS: True 20 | INDEX_WEIGHTS: 1.0 21 | SOLVER: 22 | CLIP_GRADIENTS: 23 | ENABLED: True 24 | WARMUP_FACTOR: 0.025 25 | DATASETS: 26 | TRAIN: ("base_coco_2017_train", "densepose_coco_2014_train") 27 | TEST: ("densepose_chimps",) 28 | -------------------------------------------------------------------------------- /projects/DensePose/configs/evolution/densepose_R_50_FPN_WC1M_1x_Atop10_toP.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-FPN-MC.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | DENSEPOSE_ON: True 7 | ROI_HEADS: 8 | NAME: "DensePoseROIHeads" 9 | IN_FEATURES: ["p2", "p3", "p4", "p5"] 10 | NUM_CLASSES: 1 11 | ROI_DENSEPOSE_HEAD: 12 | NAME: "DensePoseV1ConvXHead" 13 | UV_CONFIDENCE: 14 | ENABLED: True 15 | TYPE: "iid_iso" 16 | SEGM_CONFIDENCE: 17 | ENABLED: True 18 | POINT_REGRESSION_WEIGHTS: 0.0005 19 | POOLER_TYPE: "ROIAlign" 20 | NUM_COARSE_SEGM_CHANNELS: 2 21 | COARSE_SEGM_TRAINED_BY_MASKS: True 22 | INDEX_WEIGHTS: 1.0 23 | SOLVER: 24 | CLIP_GRADIENTS: 25 | ENABLED: True 26 | WARMUP_FACTOR: 0.025 27 | DATASETS: 28 | TRAIN: ("base_coco_2017_train", "densepose_coco_2014_train") 29 | TEST: ("densepose_chimps",) 30 | -------------------------------------------------------------------------------- /projects/DensePose/configs/evolution/densepose_R_50_FPN_WC1M_1x_Atop10_toP_B.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-FPN-MC-B.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | DENSEPOSE_ON: True 7 | ROI_HEADS: 8 | NAME: "DensePoseROIHeads" 9 | IN_FEATURES: ["p2", "p3", "p4", "p5"] 10 | NUM_CLASSES: 1 11 | ROI_DENSEPOSE_HEAD: 12 | NAME: "DensePoseV1ConvXHead" 13 | UV_CONFIDENCE: 14 | ENABLED: True 15 | TYPE: "iid_iso" 16 | SEGM_CONFIDENCE: 17 | ENABLED: True 18 | POINT_REGRESSION_WEIGHTS: 0.0005 19 | POOLER_TYPE: "ROIAlign" 20 | NUM_COARSE_SEGM_CHANNELS: 2 21 | COARSE_SEGM_TRAINED_BY_MASKS: True 22 | INDEX_WEIGHTS: 1.0 23 | SOLVER: 24 | CLIP_GRADIENTS: 25 | ENABLED: True 26 | CLIP_TYPE: "norm" 27 | WARMUP_FACTOR: 0.025 28 | DATASETS: 29 | TRAIN: ("base_coco_2017_train", "densepose_coco_2014_train") 30 | TEST: ("densepose_chimps",) 31 | -------------------------------------------------------------------------------- /projects/DensePose/configs/evolution/densepose_R_50_FPN_WC1_1x_Atop10_toP.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-FPN-MC.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | DENSEPOSE_ON: True 7 | ROI_HEADS: 8 | NAME: "DensePoseROIHeads" 9 | IN_FEATURES: ["p2", "p3", "p4", "p5"] 10 | NUM_CLASSES: 1 11 | ROI_DENSEPOSE_HEAD: 12 | NAME: "DensePoseV1ConvXHead" 13 | UV_CONFIDENCE: 14 | ENABLED: True 15 | TYPE: "iid_iso" 16 | POINT_REGRESSION_WEIGHTS: 0.0005 17 | POOLER_TYPE: "ROIAlign" 18 | NUM_COARSE_SEGM_CHANNELS: 2 19 | COARSE_SEGM_TRAINED_BY_MASKS: True 20 | INDEX_WEIGHTS: 1.0 21 | SOLVER: 22 | CLIP_GRADIENTS: 23 | ENABLED: True 24 | WARMUP_FACTOR: 0.025 25 | DATASETS: 26 | TRAIN: ("base_coco_2017_train", "densepose_coco_2014_train") 27 | TEST: ("densepose_chimps",) 28 | -------------------------------------------------------------------------------- /projects/DensePose/configs/evolution/faster_rcnn_R_50_FPN_1x_MC.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-FPN-MC.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: False 5 | DENSEPOSE_ON: False 6 | RESNETS: 7 | DEPTH: 50 8 | -------------------------------------------------------------------------------- /projects/DensePose/configs/quick_schedules/densepose_rcnn_HRFPN_HRNet_w32_training_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../HRNet/densepose_rcnn_HRFPN_HRNet_w32_s1x.yaml" 2 | DATASETS: 3 | TRAIN: ("densepose_coco_2014_minival_100",) 4 | TEST: ("densepose_coco_2014_minival_100",) 5 | SOLVER: 6 | MAX_ITER: 40 7 | STEPS: (30,) 8 | -------------------------------------------------------------------------------- /projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_DL_instant_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | ROI_DENSEPOSE_HEAD: 5 | NAME: "DensePoseDeepLabHead" 6 | DATASETS: 7 | TRAIN: ("densepose_coco_2014_minival_100",) 8 | TEST: ("densepose_coco_2014_minival_100",) 9 | SOLVER: 10 | MAX_ITER: 40 11 | STEPS: (30,) 12 | -------------------------------------------------------------------------------- /projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_TTA_inference_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../densepose_rcnn_R_50_FPN_s1x.yaml" 2 | MODEL: 3 | WEIGHTS: "https://dl.fbaipublicfiles.com/densepose/densepose_rcnn_R_50_FPN_s1x/165712039/model_final_162be9.pkl" 4 | DATASETS: 5 | TRAIN: () 6 | TEST: ("densepose_coco_2014_minival_100",) 7 | TEST: 8 | AUG: 9 | ENABLED: True 10 | MIN_SIZES: (400, 500, 600, 700, 800, 900, 1000, 1100, 1200) 11 | MAX_SIZE: 4000 12 | FLIP: True 13 | EXPECTED_RESULTS: [["bbox_TTA", "AP", 61.74, 0.03], ["densepose_gps_TTA", "AP", 60.22, 0.03], ["densepose_gpsm_TTA", "AP", 63.85, 0.03]] 14 | -------------------------------------------------------------------------------- /projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_WC1_instant_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | ROI_DENSEPOSE_HEAD: 7 | UV_CONFIDENCE: 8 | ENABLED: True 9 | TYPE: "iid_iso" 10 | POINT_REGRESSION_WEIGHTS: 0.0005 11 | DATASETS: 12 | TRAIN: ("densepose_coco_2014_minival_100",) 13 | TEST: ("densepose_coco_2014_minival_100",) 14 | SOLVER: 15 | CLIP_GRADIENTS: 16 | ENABLED: True 17 | MAX_ITER: 40 18 | STEPS: (30,) 19 | WARMUP_FACTOR: 0.025 20 | -------------------------------------------------------------------------------- /projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_WC2_instant_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | ROI_DENSEPOSE_HEAD: 7 | UV_CONFIDENCE: 8 | ENABLED: True 9 | TYPE: "indep_aniso" 10 | POINT_REGRESSION_WEIGHTS: 0.0005 11 | DATASETS: 12 | TRAIN: ("densepose_coco_2014_minival_100",) 13 | TEST: ("densepose_coco_2014_minival_100",) 14 | SOLVER: 15 | CLIP_GRADIENTS: 16 | ENABLED: True 17 | MAX_ITER: 40 18 | STEPS: (30,) 19 | WARMUP_FACTOR: 0.025 20 | -------------------------------------------------------------------------------- /projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_inference_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../densepose_rcnn_R_50_FPN_s1x.yaml" 2 | MODEL: 3 | WEIGHTS: "https://dl.fbaipublicfiles.com/densepose/densepose_rcnn_R_50_FPN_s1x/165712039/model_final_162be9.pkl" 4 | DATASETS: 5 | TRAIN: () 6 | TEST: ("densepose_coco_2014_minival_100",) 7 | TEST: 8 | EXPECTED_RESULTS: [["bbox", "AP", 59.27, 0.025], ["densepose_gps", "AP", 60.11, 0.02], ["densepose_gpsm", "AP", 64.20, 0.02]] 9 | -------------------------------------------------------------------------------- /projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_instant_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | DATASETS: 5 | TRAIN: ("densepose_coco_2014_minival_100",) 6 | TEST: ("densepose_coco_2014_minival_100",) 7 | SOLVER: 8 | MAX_ITER: 40 9 | STEPS: (30,) 10 | -------------------------------------------------------------------------------- /projects/DensePose/configs/quick_schedules/densepose_rcnn_R_50_FPN_training_acc_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | ROI_HEADS: 5 | NUM_CLASSES: 1 6 | DATASETS: 7 | TRAIN: ("densepose_coco_2014_minival",) 8 | TEST: ("densepose_coco_2014_minival",) 9 | SOLVER: 10 | CLIP_GRADIENTS: 11 | ENABLED: True 12 | CLIP_TYPE: norm 13 | CLIP_VALUE: 1.0 14 | MAX_ITER: 6000 15 | STEPS: (5500, 5800) 16 | TEST: 17 | EXPECTED_RESULTS: [["bbox", "AP", 76.2477, 1.0], ["densepose_gps", "AP", 79.6090, 1.5], ["densepose_gpsm", "AP", 80.0061, 1.5]] 18 | 19 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from .data.datasets import builtin # just to register data 3 | from .config import ( 4 | add_densepose_config, 5 | add_hrnet_config, 6 | add_dataset_category_config, 7 | add_bootstrap_config, 8 | load_bootstrap_config, 9 | ) 10 | from .densepose_head import ROI_DENSEPOSE_HEAD_REGISTRY 11 | from .evaluator import DensePoseCOCOEvaluator 12 | from .roi_head import DensePoseROIHeads 13 | from .data.structures import DensePoseDataRelative, DensePoseList, DensePoseTransformData 14 | from .modeling.test_time_augmentation import ( 15 | DensePoseGeneralizedRCNNWithTTA, 16 | DensePoseDatasetMapperTTA, 17 | ) 18 | from .utils.transform import load_from_cfg 19 | from .modeling.hrfpn import build_hrfpn_backbone 20 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | from .build import ( 4 | build_detection_test_loader, 5 | build_detection_train_loader, 6 | build_combined_loader, 7 | build_frame_selector, 8 | build_inference_based_loaders, 9 | has_inference_based_loaders, 10 | ) 11 | from .combined_loader import CombinedDataLoader 12 | from .dataset_mapper import DatasetMapper 13 | from .inference_based_loader import InferenceBasedLoader, ScoreBasedFilter 14 | from .utils import is_relative_local_path, maybe_prepend_base_path 15 | 16 | # ensure the builtin datasets are registered 17 | from . import datasets 18 | 19 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 20 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | from . import builtin # ensure the builtin datasets are registered 4 | 5 | __all__ = [k for k in globals().keys() if "builtin" not in k and not k.startswith("_")] 6 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/datasets/builtin.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from .chimpnsee import register_dataset as register_chimpnsee_dataset 3 | from .coco import BASE_DATASETS as BASE_COCO_DATASETS 4 | from .coco import DATASETS as COCO_DATASETS 5 | from .coco import register_datasets as register_coco_datasets 6 | 7 | DEFAULT_DATASETS_ROOT = "datasets" 8 | 9 | 10 | register_coco_datasets(COCO_DATASETS, DEFAULT_DATASETS_ROOT) 11 | register_coco_datasets(BASE_COCO_DATASETS, DEFAULT_DATASETS_ROOT) 12 | 13 | register_chimpnsee_dataset(DEFAULT_DATASETS_ROOT) 14 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/datasets/chimpnsee.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | import os 4 | from typing import Optional 5 | 6 | from detectron2.data import DatasetCatalog, MetadataCatalog 7 | 8 | from ..utils import maybe_prepend_base_path 9 | from .dataset_type import DatasetType 10 | 11 | CHIMPNSEE_DATASET_NAME = "chimpnsee" 12 | 13 | 14 | def register_dataset(datasets_root: Optional[os.PathLike] = None): 15 | def empty_load_callback(): 16 | pass 17 | 18 | video_list_fpath = maybe_prepend_base_path( 19 | datasets_root, "chimpnsee/cdna.eva.mpg.de/video_list.txt" 20 | ) 21 | video_base_path = maybe_prepend_base_path(datasets_root, "chimpnsee/cdna.eva.mpg.de") 22 | 23 | DatasetCatalog.register(CHIMPNSEE_DATASET_NAME, empty_load_callback) 24 | MetadataCatalog.get(CHIMPNSEE_DATASET_NAME).set( 25 | dataset_type=DatasetType.VIDEO_LIST, 26 | video_list_fpath=video_list_fpath, 27 | video_base_path=video_base_path, 28 | ) 29 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/datasets/dataset_type.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | from enum import Enum 4 | 5 | 6 | class DatasetType(Enum): 7 | """ 8 | Dataset type, mostly used for datasets that contain data to bootstrap models on 9 | """ 10 | 11 | VIDEO_LIST = "video_list" 12 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/samplers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | from .densepose_uniform import DensePoseUniformSampler 4 | from .densepose_confidence_based import DensePoseConfidenceBasedSampler 5 | from .mask_from_densepose import MaskFromDensePoseSampler 6 | from .prediction_to_gt import PredictionToGroundTruthSampler 7 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/transform/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | from .image import ImageResizeTransform 4 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | import os 4 | from typing import Optional 5 | 6 | 7 | def is_relative_local_path(path: os.PathLike): 8 | path_str = os.fsdecode(path) 9 | return ("://" not in path_str) and not os.path.isabs(path) 10 | 11 | 12 | def maybe_prepend_base_path(base_path: Optional[os.PathLike], path: os.PathLike): 13 | """ 14 | Prepends the provided path with a base path prefix if: 15 | 1) base path is not None; 16 | 2) path is a local path 17 | """ 18 | if base_path is None: 19 | return path 20 | if is_relative_local_path(path): 21 | return os.path.join(base_path, path) 22 | return path 23 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/video/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | from .frame_selector import ( 4 | FrameSelectionStrategy, 5 | RandomKFramesSelector, 6 | FirstKFramesSelector, 7 | LastKFramesSelector, 8 | FrameTsList, 9 | FrameSelector, 10 | ) 11 | 12 | from .video_keyframe_dataset import ( 13 | VideoKeyframeDataset, 14 | video_list_from_file, 15 | list_keyframes, 16 | read_keyframes, 17 | ) 18 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/engine/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | from .trainer import Trainer 4 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/modeling/densepose_checkpoint.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from collections import OrderedDict 3 | 4 | from detectron2.checkpoint import DetectionCheckpointer 5 | 6 | 7 | def _rename_HRNet_weights(weights): 8 | # We detect and rename HRNet weights for DensePose. 1956 and 1716 are values that are 9 | # common to all HRNet pretrained weights, and should be enough to accurately identify them 10 | if ( 11 | len(weights["model"].keys()) == 1956 12 | and len([k for k in weights["model"].keys() if k.startswith("stage")]) == 1716 13 | ): 14 | hrnet_weights = OrderedDict() 15 | for k in weights["model"].keys(): 16 | hrnet_weights["backbone.bottom_up." + str(k)] = weights["model"][k] 17 | return {"model": hrnet_weights} 18 | else: 19 | return weights 20 | 21 | 22 | class DensePoseCheckpointer(DetectionCheckpointer): 23 | """ 24 | Same as :class:`DetectionCheckpointer`, but is able to handle HRNet weights 25 | """ 26 | 27 | def __init__(self, model, save_dir="", *, save_to_disk=None, **checkpointables): 28 | super().__init__(model, save_dir, save_to_disk=save_to_disk, **checkpointables) 29 | 30 | def _load_file(self, filename: str) -> object: 31 | """ 32 | Adding hrnet support 33 | """ 34 | weights = super()._load_file(filename) 35 | return _rename_HRNet_weights(weights) 36 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/utils/logger.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | import logging 3 | 4 | 5 | def verbosity_to_level(verbosity): 6 | if verbosity is not None: 7 | if verbosity == 0: 8 | return logging.WARNING 9 | elif verbosity == 1: 10 | return logging.INFO 11 | elif verbosity >= 2: 12 | return logging.DEBUG 13 | return logging.WARNING 14 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/utils/transform.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from fvcore.common.file_io import PathManager 3 | 4 | from detectron2.data import MetadataCatalog 5 | 6 | from densepose import DensePoseTransformData 7 | 8 | 9 | def load_for_dataset(dataset_name): 10 | path = MetadataCatalog.get(dataset_name).densepose_transform_src 11 | densepose_transform_data_fpath = PathManager.get_local_path(path) 12 | return DensePoseTransformData.load(densepose_transform_data_fpath) 13 | 14 | 15 | def load_from_cfg(cfg): 16 | return load_for_dataset(cfg.DATASETS.TEST[0]) 17 | -------------------------------------------------------------------------------- /projects/DensePose/dev/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Some scripts for developers to use, include: 3 | 4 | - `run_instant_tests.sh`: run training for a few iterations. 5 | - `run_inference_tests.sh`: run inference on a small dataset. 6 | - `../../dev/linter.sh`: lint the codebase before commit 7 | - `../../dev/parse_results.sh`: parse results from log file. 8 | -------------------------------------------------------------------------------- /projects/DensePose/dev/run_inference_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 3 | 4 | BIN="python train_net.py" 5 | OUTPUT="inference_test_output" 6 | NUM_GPUS=2 7 | IMS_PER_GPU=2 8 | IMS_PER_BATCH=$(( NUM_GPUS * IMS_PER_GPU )) 9 | 10 | CFG_LIST=( "${@:1}" ) 11 | 12 | if [ ${#CFG_LIST[@]} -eq 0 ]; then 13 | CFG_LIST=( ./configs/quick_schedules/*inference_acc_test.yaml ) 14 | fi 15 | 16 | echo "========================================================================" 17 | echo "Configs to run:" 18 | echo "${CFG_LIST[@]}" 19 | echo "========================================================================" 20 | 21 | for cfg in "${CFG_LIST[@]}"; do 22 | echo "========================================================================" 23 | echo "Running $cfg ..." 24 | echo "========================================================================" 25 | $BIN \ 26 | --eval-only \ 27 | --num-gpus $NUM_GPUS \ 28 | --config-file "$cfg" \ 29 | OUTPUT_DIR "$OUTPUT" \ 30 | SOLVER.IMS_PER_BATCH $IMS_PER_BATCH 31 | rm -rf $OUTPUT 32 | done 33 | 34 | -------------------------------------------------------------------------------- /projects/DensePose/dev/run_instant_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 3 | 4 | BIN="python train_net.py" 5 | OUTPUT="instant_test_output" 6 | NUM_GPUS=2 7 | SOLVER_IMS_PER_BATCH=$((NUM_GPUS * 2)) 8 | 9 | CFG_LIST=( "${@:1}" ) 10 | if [ ${#CFG_LIST[@]} -eq 0 ]; then 11 | CFG_LIST=( ./configs/quick_schedules/*instant_test.yaml ) 12 | fi 13 | 14 | echo "========================================================================" 15 | echo "Configs to run:" 16 | echo "${CFG_LIST[@]}" 17 | echo "========================================================================" 18 | 19 | for cfg in "${CFG_LIST[@]}"; do 20 | echo "========================================================================" 21 | echo "Running $cfg ..." 22 | echo "========================================================================" 23 | $BIN --num-gpus $NUM_GPUS --config-file "$cfg" \ 24 | SOLVER.IMS_PER_BATCH $SOLVER_IMS_PER_BATCH \ 25 | OUTPUT_DIR "$OUTPUT" 26 | rm -rf "$OUTPUT" 27 | done 28 | 29 | -------------------------------------------------------------------------------- /projects/DensePose/doc/images/res_bbox_dp_contour.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shenyunhang/DRN-WSOD-pytorch/ff6168effcff68a77fbd6576ce108726ff14034c/projects/DensePose/doc/images/res_bbox_dp_contour.jpg -------------------------------------------------------------------------------- /projects/DensePose/doc/images/res_bbox_dp_segm.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shenyunhang/DRN-WSOD-pytorch/ff6168effcff68a77fbd6576ce108726ff14034c/projects/DensePose/doc/images/res_bbox_dp_segm.jpg -------------------------------------------------------------------------------- /projects/DensePose/doc/images/res_bbox_dp_u.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shenyunhang/DRN-WSOD-pytorch/ff6168effcff68a77fbd6576ce108726ff14034c/projects/DensePose/doc/images/res_bbox_dp_u.jpg -------------------------------------------------------------------------------- /projects/DensePose/doc/images/res_bbox_dp_v.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shenyunhang/DRN-WSOD-pytorch/ff6168effcff68a77fbd6576ce108726ff14034c/projects/DensePose/doc/images/res_bbox_dp_v.jpg -------------------------------------------------------------------------------- /projects/DensePose/doc/images/vis_bbox_dp_i.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shenyunhang/DRN-WSOD-pytorch/ff6168effcff68a77fbd6576ce108726ff14034c/projects/DensePose/doc/images/vis_bbox_dp_i.jpg -------------------------------------------------------------------------------- /projects/DensePose/doc/images/vis_bbox_dp_pts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shenyunhang/DRN-WSOD-pytorch/ff6168effcff68a77fbd6576ce108726ff14034c/projects/DensePose/doc/images/vis_bbox_dp_pts.jpg -------------------------------------------------------------------------------- /projects/DensePose/doc/images/vis_bbox_dp_segm.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shenyunhang/DRN-WSOD-pytorch/ff6168effcff68a77fbd6576ce108726ff14034c/projects/DensePose/doc/images/vis_bbox_dp_segm.jpg -------------------------------------------------------------------------------- /projects/DensePose/doc/images/vis_bbox_dp_u.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shenyunhang/DRN-WSOD-pytorch/ff6168effcff68a77fbd6576ce108726ff14034c/projects/DensePose/doc/images/vis_bbox_dp_u.jpg -------------------------------------------------------------------------------- /projects/DensePose/doc/images/vis_bbox_dp_v.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shenyunhang/DRN-WSOD-pytorch/ff6168effcff68a77fbd6576ce108726ff14034c/projects/DensePose/doc/images/vis_bbox_dp_v.jpg -------------------------------------------------------------------------------- /projects/DensePose/tests/test_image_resize_transform.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | import unittest 4 | import torch 5 | 6 | from densepose.data.transform import ImageResizeTransform 7 | 8 | 9 | class TestImageResizeTransform(unittest.TestCase): 10 | def test_image_resize_1(self): 11 | images_batch = torch.ones((3, 100, 100, 3), dtype=torch.uint8) * 100 12 | transform = ImageResizeTransform() 13 | images_transformed = transform(images_batch) 14 | IMAGES_GT = torch.ones((3, 3, 800, 800), dtype=torch.float) * 100 15 | self.assertEqual(images_transformed.size(), IMAGES_GT.size()) 16 | self.assertAlmostEqual(torch.abs(IMAGES_GT - images_transformed).max().item(), 0.0) 17 | -------------------------------------------------------------------------------- /projects/DensePose/tests/test_model_e2e.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 2 | 3 | import unittest 4 | import torch 5 | 6 | from detectron2.structures import BitMasks, Boxes, Instances 7 | 8 | from .common import get_model 9 | 10 | 11 | # TODO(plabatut): Modularize detectron2 tests and re-use 12 | def make_model_inputs(image, instances=None): 13 | if instances is None: 14 | return {"image": image} 15 | 16 | return {"image": image, "instances": instances} 17 | 18 | 19 | def make_empty_instances(h, w): 20 | instances = Instances((h, w)) 21 | instances.gt_boxes = Boxes(torch.rand(0, 4)) 22 | instances.gt_classes = torch.tensor([]).to(dtype=torch.int64) 23 | instances.gt_masks = BitMasks(torch.rand(0, h, w)) 24 | return instances 25 | 26 | 27 | class ModelE2ETest(unittest.TestCase): 28 | CONFIG_PATH = "" 29 | 30 | def setUp(self): 31 | self.model = get_model(self.CONFIG_PATH) 32 | 33 | def _test_eval(self, sizes): 34 | inputs = [make_model_inputs(torch.rand(3, size[0], size[1])) for size in sizes] 35 | self.model.eval() 36 | self.model(inputs) 37 | 38 | 39 | class DensePoseRCNNE2ETest(ModelE2ETest): 40 | CONFIG_PATH = "densepose_rcnn_R_101_FPN_s1x.yaml" 41 | 42 | def test_empty_data(self): 43 | self._test_eval([(200, 250), (200, 249)]) 44 | -------------------------------------------------------------------------------- /projects/DensePose/tests/test_setup.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 2 | 3 | import unittest 4 | 5 | from .common import ( 6 | get_config_files, 7 | get_evolution_config_files, 8 | get_hrnet_config_files, 9 | get_quick_schedules_config_files, 10 | setup, 11 | ) 12 | 13 | 14 | class TestSetup(unittest.TestCase): 15 | def _test_setup(self, config_file): 16 | setup(config_file) 17 | 18 | def test_setup_configs(self): 19 | config_files = get_config_files() 20 | for config_file in config_files: 21 | self._test_setup(config_file) 22 | 23 | def test_setup_evolution_configs(self): 24 | config_files = get_evolution_config_files() 25 | for config_file in config_files: 26 | self._test_setup(config_file) 27 | 28 | def test_setup_hrnet_configs(self): 29 | config_files = get_hrnet_config_files() 30 | for config_file in config_files: 31 | self._test_setup(config_file) 32 | 33 | def test_setup_quick_schedules_configs(self): 34 | config_files = get_quick_schedules_config_files() 35 | for config_file in config_files: 36 | self._test_setup(config_file) 37 | -------------------------------------------------------------------------------- /projects/DensePose/tests/test_structures.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 2 | 3 | import unittest 4 | 5 | from densepose.data.structures import normalized_coords_transform 6 | 7 | 8 | class TestStructures(unittest.TestCase): 9 | def test_normalized_coords_transform(self): 10 | bbox = (32, 24, 288, 216) 11 | x0, y0, w, h = bbox 12 | xmin, ymin, xmax, ymax = x0, y0, x0 + w, y0 + h 13 | f = normalized_coords_transform(*bbox) 14 | # Top-left 15 | expected_p, actual_p = (-1, -1), f((xmin, ymin)) 16 | self.assertEqual(expected_p, actual_p) 17 | # Top-right 18 | expected_p, actual_p = (1, -1), f((xmax, ymin)) 19 | self.assertEqual(expected_p, actual_p) 20 | # Bottom-left 21 | expected_p, actual_p = (-1, 1), f((xmin, ymax)) 22 | self.assertEqual(expected_p, actual_p) 23 | # Bottom-right 24 | expected_p, actual_p = (1, 1), f((xmax, ymax)) 25 | self.assertEqual(expected_p, actual_p) 26 | -------------------------------------------------------------------------------- /projects/PointRend/configs/InstanceSegmentation/Base-PointRend-RCNN-FPN.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../../../configs/Base-RCNN-FPN.yaml" 2 | MODEL: 3 | ROI_HEADS: 4 | NAME: "PointRendROIHeads" 5 | IN_FEATURES: ["p2", "p3", "p4", "p5"] 6 | ROI_BOX_HEAD: 7 | TRAIN_ON_PRED_BOXES: True 8 | ROI_MASK_HEAD: 9 | NAME: "CoarseMaskHead" 10 | FC_DIM: 1024 11 | NUM_FC: 2 12 | OUTPUT_SIDE_RESOLUTION: 7 13 | IN_FEATURES: ["p2"] 14 | POINT_HEAD_ON: True 15 | POINT_HEAD: 16 | FC_DIM: 256 17 | NUM_FC: 3 18 | IN_FEATURES: ["p2"] 19 | INPUT: 20 | # PointRend for instance segmenation does not work with "polygon" mask_format. 21 | MASK_FORMAT: "bitmask" 22 | -------------------------------------------------------------------------------- /projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_50_FPN_1x_cityscapes.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: Base-PointRend-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: 8 9 | POINT_HEAD: 10 | NUM_CLASSES: 8 11 | DATASETS: 12 | TEST: ("cityscapes_fine_instance_seg_val",) 13 | TRAIN: ("cityscapes_fine_instance_seg_train",) 14 | SOLVER: 15 | BASE_LR: 0.01 16 | IMS_PER_BATCH: 8 17 | MAX_ITER: 24000 18 | STEPS: (18000,) 19 | INPUT: 20 | MAX_SIZE_TEST: 2048 21 | MAX_SIZE_TRAIN: 2048 22 | MIN_SIZE_TEST: 1024 23 | MIN_SIZE_TRAIN: (800, 832, 864, 896, 928, 960, 992, 1024) 24 | -------------------------------------------------------------------------------- /projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_50_FPN_1x_coco.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: Base-PointRend-RCNN-FPN.yaml 2 | MODEL: 3 | WEIGHTS: detectron2://ImageNetPretrained/MSRA/R-50.pkl 4 | MASK_ON: true 5 | RESNETS: 6 | DEPTH: 50 7 | # To add COCO AP evaluation against the higher-quality LVIS annotations. 8 | # DATASETS: 9 | # TEST: ("coco_2017_val", "lvis_v0.5_val_cocofied") 10 | -------------------------------------------------------------------------------- /projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_50_FPN_3x_coco.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: Base-PointRend-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 | # To add COCO AP evaluation against the higher-quality LVIS annotations. 11 | # DATASETS: 12 | # TEST: ("coco_2017_val", "lvis_v0.5_val_cocofied") 13 | 14 | -------------------------------------------------------------------------------- /projects/PointRend/configs/SemanticSegmentation/Base-PointRend-Semantic-FPN.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../../../configs/Base-RCNN-FPN.yaml" 2 | MODEL: 3 | META_ARCHITECTURE: "SemanticSegmentor" 4 | BACKBONE: 5 | FREEZE_AT: 0 6 | SEM_SEG_HEAD: 7 | NAME: "PointRendSemSegHead" 8 | POINT_HEAD: 9 | NUM_CLASSES: 54 10 | FC_DIM: 256 11 | NUM_FC: 3 12 | IN_FEATURES: ["p2"] 13 | TRAIN_NUM_POINTS: 1024 14 | SUBDIVISION_STEPS: 2 15 | SUBDIVISION_NUM_POINTS: 8192 16 | COARSE_SEM_SEG_HEAD_NAME: "SemSegFPNHead" 17 | COARSE_PRED_EACH_LAYER: False 18 | DATASETS: 19 | TRAIN: ("coco_2017_train_panoptic_stuffonly",) 20 | TEST: ("coco_2017_val_panoptic_stuffonly",) 21 | -------------------------------------------------------------------------------- /projects/PointRend/configs/SemanticSegmentation/pointrend_semantic_R_101_FPN_1x_cityscapes.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: Base-PointRend-Semantic-FPN.yaml 2 | MODEL: 3 | WEIGHTS: detectron2://ImageNetPretrained/MSRA/R-101.pkl 4 | RESNETS: 5 | DEPTH: 101 6 | SEM_SEG_HEAD: 7 | NUM_CLASSES: 19 8 | POINT_HEAD: 9 | NUM_CLASSES: 19 10 | TRAIN_NUM_POINTS: 2048 11 | SUBDIVISION_NUM_POINTS: 8192 12 | DATASETS: 13 | TRAIN: ("cityscapes_fine_sem_seg_train",) 14 | TEST: ("cityscapes_fine_sem_seg_val",) 15 | SOLVER: 16 | BASE_LR: 0.01 17 | STEPS: (40000, 55000) 18 | MAX_ITER: 65000 19 | IMS_PER_BATCH: 32 20 | INPUT: 21 | MIN_SIZE_TRAIN: (512, 768, 1024, 1280, 1536, 1792, 2048) 22 | MIN_SIZE_TRAIN_SAMPLING: "choice" 23 | MIN_SIZE_TEST: 1024 24 | MAX_SIZE_TRAIN: 4096 25 | MAX_SIZE_TEST: 2048 26 | CROP: 27 | ENABLED: True 28 | TYPE: "absolute" 29 | SIZE: (512, 1024) 30 | SINGLE_CATEGORY_MAX_AREA: 0.75 31 | COLOR_AUG_SSD: True 32 | DATALOADER: 33 | NUM_WORKERS: 10 34 | -------------------------------------------------------------------------------- /projects/PointRend/point_rend/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from .config import add_pointrend_config 3 | from .coarse_mask_head import CoarseMaskHead 4 | from .roi_heads import PointRendROIHeads 5 | from .semantic_seg import PointRendSemSegHead 6 | from .color_augmentation import ColorAugSSDTransform 7 | -------------------------------------------------------------------------------- /projects/TensorMask/configs/Base-TensorMask.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | META_ARCHITECTURE: "TensorMask" 3 | MASK_ON: True 4 | BACKBONE: 5 | NAME: "build_retinanet_resnet_fpn_backbone" 6 | RESNETS: 7 | OUT_FEATURES: ["res2", "res3", "res4", "res5"] 8 | ANCHOR_GENERATOR: 9 | SIZES: [[44, 60], [88, 120], [176, 240], [352, 480], [704, 960], [1408, 1920]] 10 | ASPECT_RATIOS: [[1.0]] 11 | FPN: 12 | IN_FEATURES: ["res2", "res3", "res4", "res5"] 13 | FUSE_TYPE: "avg" 14 | TENSOR_MASK: 15 | ALIGNED_ON: True 16 | BIPYRAMID_ON: True 17 | DATASETS: 18 | TRAIN: ("coco_2017_train",) 19 | TEST: ("coco_2017_val",) 20 | SOLVER: 21 | IMS_PER_BATCH: 16 22 | BASE_LR: 0.02 23 | STEPS: (60000, 80000) 24 | MAX_ITER: 90000 25 | VERSION: 2 26 | -------------------------------------------------------------------------------- /projects/TensorMask/configs/tensormask_R_50_FPN_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-TensorMask.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | -------------------------------------------------------------------------------- /projects/TensorMask/configs/tensormask_R_50_FPN_6x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-TensorMask.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | SOLVER: 7 | STEPS: (480000, 520000) 8 | MAX_ITER: 540000 9 | INPUT: 10 | MIN_SIZE_TRAIN_SAMPLING: "range" 11 | MIN_SIZE_TRAIN: (640, 800) 12 | -------------------------------------------------------------------------------- /projects/TensorMask/tensormask/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from .config import add_tensormask_config 3 | from .arch import TensorMask 4 | -------------------------------------------------------------------------------- /projects/TensorMask/tensormask/layers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from .swap_align2nat import SwapAlign2Nat, swap_align2nat 3 | 4 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 5 | -------------------------------------------------------------------------------- /projects/TensorMask/tensormask/layers/csrc/vision.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | #include 4 | #include "SwapAlign2Nat/SwapAlign2Nat.h" 5 | 6 | namespace tensormask { 7 | 8 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 9 | m.def( 10 | "swap_align2nat_forward", 11 | &SwapAlign2Nat_forward, 12 | "SwapAlign2Nat_forward"); 13 | m.def( 14 | "swap_align2nat_backward", 15 | &SwapAlign2Nat_backward, 16 | "SwapAlign2Nat_backward"); 17 | } 18 | 19 | } // namespace tensormask 20 | -------------------------------------------------------------------------------- /projects/TensorMask/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | -------------------------------------------------------------------------------- /projects/TensorMask/tests/test_swap_align2nat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 3 | 4 | import unittest 5 | import torch 6 | from torch.autograd import gradcheck 7 | 8 | from tensormask.layers.swap_align2nat import SwapAlign2Nat 9 | 10 | 11 | class SwapAlign2NatTest(unittest.TestCase): 12 | @unittest.skipIf(not torch.cuda.is_available(), "CUDA not available") 13 | def test_swap_align2nat_gradcheck_cuda(self): 14 | dtype = torch.float64 15 | device = torch.device("cuda") 16 | m = SwapAlign2Nat(2).to(dtype=dtype, device=device) 17 | x = torch.rand(2, 4, 10, 10, dtype=dtype, device=device, requires_grad=True) 18 | 19 | self.assertTrue(gradcheck(m, x), "gradcheck failed for SwapAlign2Nat CUDA") 20 | 21 | def _swap_align2nat(self, tensor, lambda_val): 22 | """ 23 | The basic setup for testing Swap_Align 24 | """ 25 | op = SwapAlign2Nat(lambda_val, pad_val=0.0) 26 | input = torch.from_numpy(tensor[None, :, :, :].astype("float32")) 27 | output = op.forward(input.cuda()).cpu().numpy() 28 | return output[0] 29 | 30 | 31 | if __name__ == "__main__": 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /projects/TridentNet/configs/Base-TridentNet-Fast-C4.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | META_ARCHITECTURE: "GeneralizedRCNN" 3 | BACKBONE: 4 | NAME: "build_trident_resnet_backbone" 5 | ROI_HEADS: 6 | NAME: "TridentRes5ROIHeads" 7 | POSITIVE_FRACTION: 0.5 8 | BATCH_SIZE_PER_IMAGE: 128 9 | PROPOSAL_APPEND_GT: False 10 | PROPOSAL_GENERATOR: 11 | NAME: "TridentRPN" 12 | RPN: 13 | POST_NMS_TOPK_TRAIN: 500 14 | TRIDENT: 15 | NUM_BRANCH: 3 16 | BRANCH_DILATIONS: [1, 2, 3] 17 | TEST_BRANCH_IDX: 1 18 | TRIDENT_STAGE: "res4" 19 | DATASETS: 20 | TRAIN: ("coco_2017_train",) 21 | TEST: ("coco_2017_val",) 22 | SOLVER: 23 | IMS_PER_BATCH: 16 24 | BASE_LR: 0.02 25 | STEPS: (60000, 80000) 26 | MAX_ITER: 90000 27 | INPUT: 28 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 29 | VERSION: 2 30 | -------------------------------------------------------------------------------- /projects/TridentNet/configs/tridentnet_fast_R_101_C4_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-TridentNet-Fast-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 | -------------------------------------------------------------------------------- /projects/TridentNet/configs/tridentnet_fast_R_50_C4_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-TridentNet-Fast-C4.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | -------------------------------------------------------------------------------- /projects/TridentNet/configs/tridentnet_fast_R_50_C4_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-TridentNet-Fast-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 | -------------------------------------------------------------------------------- /projects/TridentNet/tridentnet/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from .config import add_tridentnet_config 3 | from .trident_backbone import ( 4 | TridentBottleneckBlock, 5 | build_trident_resnet_backbone, 6 | make_trident_stage, 7 | ) 8 | from .trident_rpn import TridentRPN 9 | from .trident_rcnn import TridentRes5ROIHeads, TridentStandardROIHeads 10 | -------------------------------------------------------------------------------- /projects/TridentNet/tridentnet/config.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 3 | 4 | from detectron2.config import CfgNode as CN 5 | 6 | 7 | def add_tridentnet_config(cfg): 8 | """ 9 | Add config for tridentnet. 10 | """ 11 | _C = cfg 12 | 13 | _C.MODEL.TRIDENT = CN() 14 | 15 | # Number of branches for TridentNet. 16 | _C.MODEL.TRIDENT.NUM_BRANCH = 3 17 | # Specify the dilations for each branch. 18 | _C.MODEL.TRIDENT.BRANCH_DILATIONS = [1, 2, 3] 19 | # Specify the stage for applying trident blocks. Default stage is Res4 according to the 20 | # TridentNet paper. 21 | _C.MODEL.TRIDENT.TRIDENT_STAGE = "res4" 22 | # Specify the test branch index TridentNet Fast inference: 23 | # - use -1 to aggregate results of all branches during inference. 24 | # - otherwise, only using specified branch for fast inference. Recommended setting is 25 | # to use the middle branch. 26 | _C.MODEL.TRIDENT.TEST_BRANCH_IDX = 1 27 | -------------------------------------------------------------------------------- /projects/TridentNet/tridentnet/trident_rpn.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | import torch 3 | 4 | from detectron2.modeling import PROPOSAL_GENERATOR_REGISTRY 5 | from detectron2.modeling.proposal_generator.rpn import RPN 6 | from detectron2.structures import ImageList 7 | 8 | 9 | @PROPOSAL_GENERATOR_REGISTRY.register() 10 | class TridentRPN(RPN): 11 | """ 12 | Trident RPN subnetwork. 13 | """ 14 | 15 | def __init__(self, cfg, input_shape): 16 | super(TridentRPN, self).__init__(cfg, input_shape) 17 | 18 | self.num_branch = cfg.MODEL.TRIDENT.NUM_BRANCH 19 | self.trident_fast = cfg.MODEL.TRIDENT.TEST_BRANCH_IDX != -1 20 | 21 | def forward(self, images, features, gt_instances=None): 22 | """ 23 | See :class:`RPN.forward`. 24 | """ 25 | num_branch = self.num_branch if self.training or not self.trident_fast else 1 26 | # Duplicate images and gt_instances for all branches in TridentNet. 27 | all_images = ImageList( 28 | torch.cat([images.tensor] * num_branch), images.image_sizes * num_branch 29 | ) 30 | all_gt_instances = gt_instances * num_branch if gt_instances is not None else None 31 | 32 | return super(TridentRPN, self).forward(all_images, features, all_gt_instances) 33 | -------------------------------------------------------------------------------- /projects/WSL/.gitignore: -------------------------------------------------------------------------------- 1 | # output dir 2 | output 3 | instant_test_output 4 | inference_test_output 5 | 6 | 7 | *.jpg 8 | *.png 9 | *.txt 10 | 11 | # compilation and distribution 12 | __pycache__ 13 | _ext 14 | *.pyc 15 | *.so 16 | wsl.egg-info/ 17 | build/ 18 | dist/ 19 | 20 | # pytorch/python/numpy formats 21 | *.pth 22 | *.pkl 23 | *.npy 24 | 25 | # ipython/jupyter notebooks 26 | *.ipynb 27 | **/.ipynb_checkpoints/ 28 | 29 | # Editor temporaries 30 | *.swn 31 | *.swo 32 | *.swp 33 | *~ 34 | 35 | # Pycharm editor settings 36 | .idea 37 | 38 | # project dirs 39 | /wsl/model_zoo/configs 40 | /datasets 41 | /models 42 | -------------------------------------------------------------------------------- /projects/WSL/configs/Base-RCNN-DilatedC5.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | META_ARCHITECTURE: "GeneralizedRCNNWSL" 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: "WSDDNROIHeads" 12 | IN_FEATURES: ["res5"] 13 | BATCH_SIZE_PER_IMAGE: 4096 14 | POSITIVE_FRACTION: 1.0 15 | ROI_BOX_HEAD: 16 | NAME: "DiscriminativeAdaptionNeck" 17 | NUM_FC: 2 18 | DAN_DIM: [4096, 4096] 19 | POOLER_RESOLUTION: 7 20 | ROI_MASK_HEAD: 21 | NAME: "MaskRCNNConvUpsampleHead" 22 | NUM_CONV: 4 23 | POOLER_RESOLUTION: 14 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 | -------------------------------------------------------------------------------- /projects/WSL/configs/COCO-Detection/Base-RCNN-DilatedC5.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-DilatedC5.yaml" 2 | DATASETS: 3 | TRAIN: ('coco_2014_train', 'coco_2014_valminusminival') 4 | PROPOSAL_FILES_TRAIN: ('datasets/proposals/mcg_coco_2014_train_d2.pkl', 'datasets/proposals/mcg_coco_2014_valminusminival_d2.pkl') 5 | PRECOMPUTED_PROPOSAL_TOPK_TRAIN: 4000 6 | TEST: ('coco_2014_minival',) 7 | PROPOSAL_FILES_TEST: ('datasets/proposals/mcg_coco_2014_minival_d2.pkl', ) 8 | PRECOMPUTED_PROPOSAL_TOPK_TEST: 4000 9 | TEST: 10 | EVAL_TRAIN: False 11 | DATALOADER: 12 | NUM_WORKERS: 2 13 | -------------------------------------------------------------------------------- /projects/WSL/configs/COCO-Detection/reg/oicr_V_16_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../oicr_V_16_DC5_1x.yaml" 2 | WSL: 3 | REFINE_NUM: 4 4 | REFINE_REG: [False, False, False, True] 5 | -------------------------------------------------------------------------------- /projects/WSL/configs/COCO-Detection/reg/oicr_WSR_101_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../oicr_WSR_101_DC5_1x.yaml" 2 | WSL: 3 | REFINE_NUM: 4 4 | REFINE_REG: [False, False, False, True] 5 | -------------------------------------------------------------------------------- /projects/WSL/configs/COCO-Detection/reg/oicr_WSR_18_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../oicr_WSR_18_DC5_1x.yaml" 2 | WSL: 3 | REFINE_NUM: 4 4 | REFINE_REG: [False, False, False, True] 5 | -------------------------------------------------------------------------------- /projects/WSL/configs/COCO-Detection/reg/oicr_WSR_50_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../oicr_WSR_50_DC5_1x.yaml" 2 | WSL: 3 | REFINE_NUM: 4 4 | REFINE_REG: [False, False, False, True] 5 | -------------------------------------------------------------------------------- /projects/WSL/configs/COCO-Detection/wsddn_WSR_18_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-DilatedC5.yaml" 2 | MODEL: 3 | WEIGHTS: "models/DRN-WSOD/resnet18_ws_model_120_d2.pkl" 4 | PIXEL_MEAN: [102.9801, 115.9465, 122.7717] 5 | MASK_ON: False 6 | LOAD_PROPOSALS: True 7 | BACKBONE: 8 | NAME: "build_ws_resnet_backbone" 9 | FREEZE_AT: 5 10 | RESNETS: 11 | DEPTH: 18 12 | RES5_DILATION: 2 13 | RES2_OUT_CHANNELS: 64 14 | PROPOSAL_GENERATOR: 15 | NAME: "PrecomputedProposals" 16 | MIN_SIZE: 20 17 | ROI_HEADS: 18 | NUM_CLASSES: 80 19 | SCORE_THRESH_TEST: 0.000000001 20 | NMS_THRESH_TEST: 0.5 21 | PROPOSAL_APPEND_GT: False 22 | ROI_BOX_HEAD: 23 | POOLER_TYPE: "ROIPool" 24 | NUM_CONV: 0 25 | NUM_FC: 2 26 | DAN_DIM: [4096, 4096] 27 | INPUT: 28 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800, 832, 864, 896, 928, 960, 992, 1024, 1056, 1088, 1120, 1152, 1184, 1216) 29 | MAX_SIZE_TRAIN: 2000 30 | MIN_SIZE_TEST: 688 31 | MAX_SIZE_TEST: 2000 32 | CROP: 33 | ENABLED: True 34 | SOLVER: 35 | STEPS: (140000, 200000) 36 | MAX_ITER: 200000 # 10.0 epochs 37 | WARMUP_ITERS: 0 38 | IMS_PER_BATCH: 4 39 | BASE_LR: 0.01 40 | WEIGHT_DECAY: 0.0005 41 | BIAS_LR_FACTOR: 2.0 42 | WEIGHT_DECAY_BIAS: 0.0 43 | TEST: 44 | AUG: 45 | ENABLED: True 46 | MIN_SIZES: (480, 576, 672, 768, 864, 960, 1056, 1152) 47 | MAX_SIZE: 4000 48 | FLIP: True 49 | EVAL_PERIOD: 10000 50 | WSL: 51 | ITER_SIZE: 32 52 | MEAN_LOSS: False 53 | -------------------------------------------------------------------------------- /projects/WSL/configs/FlickrVOC-Detection/Base-RCNN-DilatedC5.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-DilatedC5.yaml" 2 | DATASETS: 3 | TRAIN: ('flickr_voc', ) 4 | PROPOSAL_FILES_TRAIN: ('datasets/flickr_voc/mcg_d2.pkl', ) 5 | PRECOMPUTED_PROPOSAL_TOPK_TRAIN: 4000 6 | TEST: ('voc_2007_test',) 7 | PROPOSAL_FILES_TEST: ('datasets/proposals/mcg_voc_2007_test_d2.pkl', ) 8 | PRECOMPUTED_PROPOSAL_TOPK_TEST: 4000 9 | TEST: 10 | EVAL_TRAIN: False 11 | -------------------------------------------------------------------------------- /projects/WSL/configs/FlickrVOC-Detection/reg/oicr_WSR_18_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../oicr_R_18_WS_DC5_1x.yaml" 2 | WSL: 3 | HAS_REG: True 4 | -------------------------------------------------------------------------------- /projects/WSL/configs/PascalVOC-Detection/Base-RCNN-DilatedC5.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-DilatedC5.yaml" 2 | DATASETS: 3 | TRAIN: ('voc_2007_train', 'voc_2007_val') 4 | PROPOSAL_FILES_TRAIN: ('datasets/proposals/mcg_voc_2007_train_d2.pkl', 'datasets/proposals/mcg_voc_2007_val_d2.pkl') 5 | PRECOMPUTED_PROPOSAL_TOPK_TRAIN: 4000 6 | TEST: ('voc_2007_test',) 7 | PROPOSAL_FILES_TEST: ('datasets/proposals/mcg_voc_2007_test_d2.pkl', ) 8 | PRECOMPUTED_PROPOSAL_TOPK_TEST: 4000 9 | -------------------------------------------------------------------------------- /projects/WSL/configs/PascalVOC-Detection/Base-RCNN-DilatedC5_VOC2012.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-DilatedC5.yaml" 2 | DATASETS: 3 | TRAIN: ('voc_2012_train', 'voc_2012_val') 4 | PROPOSAL_FILES_TRAIN: ('datasets/proposals/mcg_voc_2012_train_d2.pkl', 'datasets/proposals/mcg_voc_2012_val_d2.pkl') 5 | PRECOMPUTED_PROPOSAL_TOPK_TRAIN: 4000 6 | TEST: ('voc_2007_test',) 7 | PROPOSAL_FILES_TEST: ('datasets/proposals/mcg_voc_2007_test_d2.pkl', ) 8 | #TEST: ('voc_2012_test',) 9 | #PROPOSAL_FILES_TEST: ('datasets/proposals/mcg_voc_2012_test_d2.pkl', ) 10 | PRECOMPUTED_PROPOSAL_TOPK_TEST: 4000 11 | -------------------------------------------------------------------------------- /projects/WSL/configs/PascalVOC-Detection/reg/csc_oicr_V_16_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../csc_oicr_V_16_DC5_1x.yaml" 2 | WSL: 3 | REFINE_NUM: 4 4 | REFINE_REG: [False, False, False, True] 5 | -------------------------------------------------------------------------------- /projects/WSL/configs/PascalVOC-Detection/reg/oicr_V_16_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../oicr_V_16_DC5_1x.yaml" 2 | WSL: 3 | REFINE_NUM: 4 4 | REFINE_REG: [False, False, False, True] 5 | -------------------------------------------------------------------------------- /projects/WSL/configs/PascalVOC-Detection/reg/oicr_WSR_101_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../oicr_WSR_101_DC5_1x.yaml" 2 | WSL: 3 | REFINE_NUM: 4 4 | REFINE_REG: [False, False, False, True] 5 | TEST: 6 | EVAL_PERIOD: 1000 7 | -------------------------------------------------------------------------------- /projects/WSL/configs/PascalVOC-Detection/reg/oicr_WSR_18_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../oicr_WSR_18_DC5_1x.yaml" 2 | WSL: 3 | REFINE_NUM: 4 4 | REFINE_REG: [False, False, False, True] 5 | TEST: 6 | EVAL_PERIOD: 10000 7 | -------------------------------------------------------------------------------- /projects/WSL/configs/PascalVOC-Detection/reg/oicr_WSR_50_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../oicr_WSR_50_DC5_1x.yaml" 2 | WSL: 3 | REFINE_NUM: 4 4 | REFINE_REG: [False, False, False, True] 5 | -------------------------------------------------------------------------------- /projects/WSL/configs/PascalVOC-Detection/reg/pcl_V_16_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../pcl_V_16_DC5_1x.yaml" 2 | WSL: 3 | REFINE_NUM: 4 4 | REFINE_REG: [False, False, False, True] 5 | -------------------------------------------------------------------------------- /projects/WSL/configs/PascalVOC-Detection/reg/pcl_WSR_101_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../pcl_WSR_101_DC5_1x.yaml" 2 | WSL: 3 | REFINE_NUM: 4 4 | REFINE_REG: [False, False, False, True] 5 | -------------------------------------------------------------------------------- /projects/WSL/configs/PascalVOC-Detection/reg/pcl_WSR_18_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../pcl_WSR_18_DC5_1x.yaml" 2 | WSL: 3 | REFINE_NUM: 4 4 | REFINE_REG: [False, False, False, True] 5 | -------------------------------------------------------------------------------- /projects/WSL/configs/PascalVOC-Detection/reg/pcl_WSR_50_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../pcl_WSR_50_DC5_1x.yaml" 2 | WSL: 3 | REFINE_NUM: 4 4 | REFINE_REG: [False, False, False, True] 5 | -------------------------------------------------------------------------------- /projects/WSL/configs/PascalVOC-Detection/wsddn_R_101_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-DilatedC5.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: False 5 | LOAD_PROPOSALS: True 6 | BACKBONE: 7 | NAME: "build_resnet_backbone" 8 | FREEZE_AT: 5 9 | RESNETS: 10 | DEPTH: 101 11 | RES5_DILATION: 2 12 | PROPOSAL_GENERATOR: 13 | NAME: "PrecomputedProposals" 14 | MIN_SIZE: 20 15 | ROI_HEADS: 16 | NUM_CLASSES: 20 17 | SCORE_THRESH_TEST: 0.000000001 18 | NMS_THRESH_TEST: 0.5 19 | PROPOSAL_APPEND_GT: False 20 | ROI_BOX_HEAD: 21 | POOLER_TYPE: "ROIPool" 22 | NUM_CONV: 0 23 | NUM_FC: 0 24 | INPUT: 25 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800, 832, 864, 896, 928, 960, 992, 1024, 1056, 1088, 1120, 1152, 1184, 1216) 26 | MAX_SIZE_TRAIN: 2000 27 | MIN_SIZE_TEST: 688 28 | MAX_SIZE_TEST: 2000 29 | CROP: 30 | ENABLED: True 31 | SOLVER: 32 | STEPS: (35000, 35000) 33 | MAX_ITER: 35000 # 28.0 epochs for 07 34 | WARMUP_ITERS: 0 35 | IMS_PER_BATCH: 4 36 | BASE_LR: 0.01 37 | WEIGHT_DECAY: 0.0005 38 | BIAS_LR_FACTOR: 2.0 39 | WEIGHT_DECAY_BIAS: 0.0 40 | TEST: 41 | AUG: 42 | ENABLED: True 43 | MIN_SIZES: (480, 576, 672, 768, 864, 960, 1056, 1152) 44 | MAX_SIZE: 4000 45 | FLIP: True 46 | EVAL_PERIOD: 10000 47 | -------------------------------------------------------------------------------- /projects/WSL/configs/PascalVOC-Detection/wsddn_R_18_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-DilatedC5.yaml" 2 | MODEL: 3 | WEIGHTS: "models/DRN-WSOD/resnet18_model_120.pkl" 4 | PIXEL_MEAN: [102.9801, 115.9465, 122.7717] 5 | MASK_ON: False 6 | LOAD_PROPOSALS: True 7 | BACKBONE: 8 | NAME: "build_resnet_18_backbone" 9 | FREEZE_AT: 2 10 | RESNETS: 11 | DEPTH: 18 12 | RES5_DILATION: 2 13 | RES2_OUT_CHANNELS: 64 14 | PROPOSAL_GENERATOR: 15 | NAME: "PrecomputedProposals" 16 | MIN_SIZE: 20 17 | ROI_HEADS: 18 | NUM_CLASSES: 20 19 | SCORE_THRESH_TEST: 0.000000001 20 | NMS_THRESH_TEST: 0.5 21 | PROPOSAL_APPEND_GT: False 22 | ROI_BOX_HEAD: 23 | POOLER_TYPE: "ROIPool" 24 | NUM_CONV: 0 25 | NUM_FC: 0 26 | INPUT: 27 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800, 832, 864, 896, 928, 960, 992, 1024, 1056, 1088, 1120, 1152, 1184, 1216) 28 | MAX_SIZE_TRAIN: 2000 29 | MIN_SIZE_TEST: 688 30 | MAX_SIZE_TEST: 2000 31 | CROP: 32 | ENABLED: True 33 | SOLVER: 34 | STEPS: (35000, 35000) 35 | MAX_ITER: 35000 # 28.0 epochs for 07 36 | WARMUP_ITERS: 0 37 | IMS_PER_BATCH: 4 38 | BASE_LR: 0.001 39 | WEIGHT_DECAY: 0.0005 40 | BIAS_LR_FACTOR: 2.0 41 | WEIGHT_DECAY_BIAS: 0.0 42 | TEST: 43 | AUG: 44 | ENABLED: True 45 | MIN_SIZES: (480, 576, 672, 768, 864, 960, 1056, 1152) 46 | MAX_SIZE: 4000 47 | FLIP: True 48 | EVAL_PERIOD: 10000 49 | -------------------------------------------------------------------------------- /projects/WSL/configs/PascalVOC-Detection/wsddn_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 | LOAD_PROPOSALS: True 6 | BACKBONE: 7 | NAME: "build_resnet_backbone" 8 | FREEZE_AT: 5 9 | RESNETS: 10 | DEPTH: 50 11 | RES5_DILATION: 1 12 | PROPOSAL_GENERATOR: 13 | NAME: "PrecomputedProposals" 14 | MIN_SIZE: 20 15 | ROI_HEADS: 16 | NUM_CLASSES: 20 17 | SCORE_THRESH_TEST: 0.000000001 18 | NMS_THRESH_TEST: 0.5 19 | PROPOSAL_APPEND_GT: False 20 | ROI_BOX_HEAD: 21 | POOLER_TYPE: "ROIPool" 22 | NAME: "FastRCNNConvFCHead" 23 | NUM_CONV: 0 24 | NUM_FC: 2 25 | #CONV_DIM: 128 26 | FC_DIM: 1024 27 | INPUT: 28 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800, 832, 864, 896, 928, 960, 992, 1024, 1056, 1088, 1120, 1152, 1184, 1216) 29 | MAX_SIZE_TRAIN: 2000 30 | MIN_SIZE_TEST: 688 31 | MAX_SIZE_TEST: 2000 32 | CROP: 33 | ENABLED: True 34 | SOLVER: 35 | STEPS: (35000, 35000) 36 | MAX_ITER: 35000 37 | WARMUP_ITERS: 0 38 | IMS_PER_BATCH: 4 39 | BASE_LR: 0.01 40 | WEIGHT_DECAY: 0.0005 41 | BIAS_LR_FACTOR: 2.0 42 | WEIGHT_DECAY_BIAS: 0.0 43 | TEST: 44 | AUG: 45 | ENABLED: True 46 | MIN_SIZES: (480, 576, 672, 768, 864, 960, 1056, 1152) 47 | MAX_SIZE: 4000 48 | FLIP: True 49 | EVAL_PERIOD: 10000 50 | -------------------------------------------------------------------------------- /projects/WSL/configs/PascalVOC-Detection/wsddn_WSR_101_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-DilatedC5.yaml" 2 | MODEL: 3 | WEIGHTS: "models/DRN-WSOD/resnet101_ws_model_120_d2.pkl" 4 | PIXEL_MEAN: [102.9801, 115.9465, 122.7717] 5 | MASK_ON: False 6 | LOAD_PROPOSALS: True 7 | BACKBONE: 8 | NAME: "build_ws_resnet_backbone" 9 | FREEZE_AT: 5 10 | RESNETS: 11 | DEPTH: 101 12 | RES5_DILATION: 2 13 | PROPOSAL_GENERATOR: 14 | NAME: "PrecomputedProposals" 15 | MIN_SIZE: 20 16 | ROI_HEADS: 17 | NUM_CLASSES: 20 18 | SCORE_THRESH_TEST: 0.000000001 19 | NMS_THRESH_TEST: 0.5 20 | PROPOSAL_APPEND_GT: False 21 | ROI_BOX_HEAD: 22 | POOLER_TYPE: "ROIPool" 23 | NUM_CONV: 0 24 | NUM_FC: 2 25 | DAN_DIM: [2048, 4096] 26 | INPUT: 27 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800, 832, 864, 896, 928, 960, 992, 1024, 1056, 1088, 1120, 1152, 1184, 1216) 28 | MAX_SIZE_TRAIN: 2000 29 | MIN_SIZE_TEST: 688 30 | MAX_SIZE_TEST: 2000 31 | CROP: 32 | ENABLED: True 33 | SOLVER: 34 | STEPS: (200000, 200000) 35 | MAX_ITER: 200000 # 160.0 epochs 36 | WARMUP_ITERS: 0 37 | IMS_PER_BATCH: 4 38 | BASE_LR: 0.01 39 | WEIGHT_DECAY: 0.0005 40 | BIAS_LR_FACTOR: 2.0 41 | WEIGHT_DECAY_BIAS: 0.0 42 | TEST: 43 | AUG: 44 | ENABLED: True 45 | MIN_SIZES: (480, 576, 672, 768, 864, 960, 1056, 1152) 46 | MAX_SIZE: 4000 47 | FLIP: True 48 | EVAL_PERIOD: 10000 49 | WSL: 50 | ITER_SIZE: 32 51 | MEAN_LOSS: False 52 | -------------------------------------------------------------------------------- /projects/WSL/configs/PascalVOC-Detection/wsddn_WSR_50_DC5_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-DilatedC5.yaml" 2 | MODEL: 3 | WEIGHTS: "models/DRN-WSOD/resnet50_ws_model_120_d2.pkl" 4 | PIXEL_MEAN: [102.9801, 115.9465, 122.7717] 5 | MASK_ON: False 6 | LOAD_PROPOSALS: True 7 | BACKBONE: 8 | NAME: "build_ws_resnet_backbone" 9 | FREEZE_AT: 5 10 | RESNETS: 11 | DEPTH: 50 12 | RES5_DILATION: 1 13 | PROPOSAL_GENERATOR: 14 | NAME: "PrecomputedProposals" 15 | MIN_SIZE: 20 16 | ROI_HEADS: 17 | NUM_CLASSES: 20 18 | SCORE_THRESH_TEST: 0.000000001 19 | NMS_THRESH_TEST: 0.5 20 | PROPOSAL_APPEND_GT: False 21 | ROI_BOX_HEAD: 22 | POOLER_TYPE: "ROIPool" 23 | NUM_CONV: 0 24 | NUM_FC: 2 25 | DAN_DIM: [2048, 4096] 26 | INPUT: 27 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800, 832, 864, 896, 928, 960, 992, 1024, 1056, 1088, 1120, 1152, 1184, 1216) 28 | MAX_SIZE_TRAIN: 2000 29 | MIN_SIZE_TEST: 688 30 | MAX_SIZE_TEST: 2000 31 | CROP: 32 | ENABLED: True 33 | SOLVER: 34 | STEPS: (200000, 200000) 35 | MAX_ITER: 200000 # 160.0 epochs 36 | WARMUP_ITERS: 0 37 | IMS_PER_BATCH: 4 38 | BASE_LR: 0.01 39 | WEIGHT_DECAY: 0.0005 40 | BIAS_LR_FACTOR: 2.0 41 | WEIGHT_DECAY_BIAS: 0.0 42 | TEST: 43 | AUG: 44 | ENABLED: True 45 | MIN_SIZES: (480, 576, 672, 768, 864, 960, 1056, 1152) 46 | MAX_SIZE: 4000 47 | FLIP: True 48 | EVAL_PERIOD: 10000 49 | WSL: 50 | ITER_SIZE: 32 51 | MEAN_LOSS: False 52 | -------------------------------------------------------------------------------- /projects/WSL/configs/PascalVOC-DetectionSegmentation/Base-RCNN-DilatedC5_Det.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-DilatedC5.yaml" 2 | DATASETS: 3 | TRAIN: ('voc_2007_train', 'voc_2007_val') 4 | PROPOSAL_FILES_TRAIN: ('datasets/proposals/mcg_voc_2007_train_d2.pkl', 'datasets/proposals/mcg_voc_2007_val_d2.pkl') 5 | #PROPOSAL_FILES_TRAIN: ('datasets/proposals/ss_voc_2007_train_d2.pkl', 'datasets/proposals/ss_voc_2007_val_d2.pkl') 6 | #TRAIN: ('voc_2012_train', 'voc_2012_val') 7 | #PROPOSAL_FILES_TRAIN: ('datasets/proposals/mcg_voc_2012_train_d2.pkl', 'datasets/proposals/mcg_voc_2012_val_d2.pkl') 8 | #PROPOSAL_FILES_TRAIN: ('datasets/proposals/ss_voc_2012_train_d2.pkl', 'datasets/proposals/ss_voc_2012_val_d2.pkl') 9 | PRECOMPUTED_PROPOSAL_TOPK_TRAIN: 4000 10 | TEST: ('voc_2007_test',) 11 | PROPOSAL_FILES_TEST: ('datasets/proposals/mcg_voc_2007_test_d2.pkl', ) 12 | #PROPOSAL_FILES_TEST: ('datasets/proposals/ss_voc_2007_test_d2.pkl', ) 13 | #TEST: ('voc_2012_test',) 14 | #PROPOSAL_FILES_TEST: ('datasets/proposals/mcg_voc_2012_test_d2.pkl', ) 15 | #PROPOSAL_FILES_TEST: ('datasets/proposals/ss_voc_2012_test_d2.pkl', ) 16 | #TEST: ('voc_2012_val_instance',) 17 | #PROPOSAL_FILES_TEST: ('datasets/proposals/mcg_voc_2012_val_instance_d2.pkl', ) 18 | PRECOMPUTED_PROPOSAL_TOPK_TEST: 4000 19 | -------------------------------------------------------------------------------- /projects/WSL/configs/PascalVOC-DetectionSegmentation/Base-RCNN-DilatedC5_Seg.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-DilatedC5.yaml" 2 | DATASETS: 3 | TRAIN: ('voc_2012_train_instance', 'sbd_9118_instance') 4 | PROPOSAL_FILES_TRAIN: ('datasets/proposals/mcg_voc_2012_train_instance_d2.pkl', 'datasets/proposals/mcg_sbd_9118_instance_d2.pkl') 5 | #TRAIN: ('sbd_9118_instance',) 6 | #PROPOSAL_FILES_TRAIN: ('datasets/proposals/mcg_sbd_9118_instance_d2.pkl',) 7 | PRECOMPUTED_PROPOSAL_TOPK_TRAIN: 4000 8 | TEST: ('voc_2012_val_instance',) 9 | PROPOSAL_FILES_TEST: ('datasets/proposals/mcg_voc_2012_val_instance_d2.pkl', ) 10 | PRECOMPUTED_PROPOSAL_TOPK_TEST: 4000 11 | -------------------------------------------------------------------------------- /projects/WSL/requirements.txt: -------------------------------------------------------------------------------- 1 | git+https://github.com/lucasb-eyer/pydensecrf.git 2 | opencv-python 3 | sklearn 4 | -------------------------------------------------------------------------------- /projects/WSL/scripts/auto_run.sh: -------------------------------------------------------------------------------- 1 | 2 | set -x 3 | 4 | CMD="$@" 5 | echo ${CMD} 6 | until ${CMD} 7 | do 8 | echo "Try again" 9 | echo ${CMD} 10 | done 11 | -------------------------------------------------------------------------------- /projects/WSL/scripts/train_resnet101_ws.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x 3 | set -e 4 | 5 | export PYTHONUNBUFFERED="True" 6 | 7 | array=( $@ ) 8 | len=${#array[@]} 9 | ARGS=${array[@]:0:$len} 10 | 11 | EXP_DIR="output/resnet101_ws_`date +'%Y-%m-%d_%H-%M-%S'`" 12 | 13 | mkdir -p "${EXP_DIR}" 14 | LOG="${EXP_DIR}/train.log" 15 | exec &> >(tee -a "$LOG") 16 | echo Logging output to "$LOG" 17 | 18 | 19 | echo --------------------------------------------------------------------- 20 | git log -1 21 | git submodule foreach 'git log -1' 22 | echo --------------------------------------------------------------------- 23 | 24 | python3 projects/WSL/tools/imagenet.py \ 25 | -a resnet101_ws \ 26 | --dist-url 'tcp://127.0.0.1:12345' \ 27 | --dist-backend 'nccl' \ 28 | --multiprocessing-distributed \ 29 | --world-size 1 \ 30 | --rank 0 \ 31 | --output_dir ${EXP_DIR} \ 32 | --epochs 120 \ 33 | --batch-size 128 \ 34 | --learning-rate 0.05 \ 35 | --workers 12 \ 36 | --print-freq 100 \ 37 | ${ARGS} 38 | -------------------------------------------------------------------------------- /projects/WSL/scripts/train_resnet18.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x 3 | set -e 4 | 5 | export PYTHONUNBUFFERED="True" 6 | 7 | array=( $@ ) 8 | len=${#array[@]} 9 | ARGS=${array[@]:0:$len} 10 | 11 | EXP_DIR="output/resnet18_`date +'%Y-%m-%d_%H-%M-%S'`" 12 | 13 | mkdir -p "${EXP_DIR}" 14 | LOG="${EXP_DIR}/train.log" 15 | exec &> >(tee -a "$LOG") 16 | echo Logging output to "$LOG" 17 | 18 | 19 | echo --------------------------------------------------------------------- 20 | git log -1 21 | git submodule foreach 'git log -1' 22 | echo --------------------------------------------------------------------- 23 | 24 | python3 projects/WSL/tools/imagenet.py \ 25 | -a resnet18 \ 26 | --dist-url 'tcp://127.0.0.1:12345' \ 27 | --dist-backend 'nccl' \ 28 | --multiprocessing-distributed \ 29 | --world-size 1 \ 30 | --rank 0 \ 31 | --output_dir ${EXP_DIR} \ 32 | --epochs 120 \ 33 | --batch-size 256 \ 34 | --learning-rate 0.1 \ 35 | --workers 12 \ 36 | --print-freq 100 \ 37 | ${ARGS} 38 | -------------------------------------------------------------------------------- /projects/WSL/scripts/train_resnet18_nas.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x 3 | set -e 4 | 5 | export PYTHONUNBUFFERED="True" 6 | 7 | array=( $@ ) 8 | len=${#array[@]} 9 | ARGS=${array[@]:0:$len} 10 | 11 | EXP_DIR="output/resnet18_nas_`date +'%Y-%m-%d_%H-%M-%S'`" 12 | 13 | mkdir -p "${EXP_DIR}" 14 | LOG="${EXP_DIR}/train.log" 15 | exec &> >(tee -a "$LOG") 16 | echo Logging output to "$LOG" 17 | 18 | 19 | echo --------------------------------------------------------------------- 20 | git log -1 21 | git submodule foreach 'git log -1' 22 | echo --------------------------------------------------------------------- 23 | 24 | python3 projects/WSL/tools/imagenet.py \ 25 | -a resnet18_nas \ 26 | --dist-url 'tcp://127.0.0.1:12345' \ 27 | --dist-backend 'nccl' \ 28 | --multiprocessing-distributed \ 29 | --world-size 1 \ 30 | --rank 0 \ 31 | --output_dir ${EXP_DIR} \ 32 | --epochs 120 \ 33 | --batch-size 256 \ 34 | --learning-rate 0.1 \ 35 | --workers 12 \ 36 | --print-freq 100 \ 37 | ${ARGS} 38 | -------------------------------------------------------------------------------- /projects/WSL/scripts/train_resnet18_ws.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x 3 | set -e 4 | 5 | export PYTHONUNBUFFERED="True" 6 | 7 | array=( $@ ) 8 | len=${#array[@]} 9 | ARGS=${array[@]:0:$len} 10 | 11 | EXP_DIR="output/resnet18_ws_`date +'%Y-%m-%d_%H-%M-%S'`" 12 | 13 | mkdir -p "${EXP_DIR}" 14 | LOG="${EXP_DIR}/train.log" 15 | exec &> >(tee -a "$LOG") 16 | echo Logging output to "$LOG" 17 | 18 | 19 | echo --------------------------------------------------------------------- 20 | git log -1 21 | git submodule foreach 'git log -1' 22 | echo --------------------------------------------------------------------- 23 | 24 | python3 projects/WSL/tools/imagenet.py \ 25 | -a resnet18_ws \ 26 | --dist-url 'tcp://127.0.0.1:12345' \ 27 | --dist-backend 'nccl' \ 28 | --multiprocessing-distributed \ 29 | --world-size 1 \ 30 | --rank 0 \ 31 | --output_dir ${EXP_DIR} \ 32 | --epochs 120 \ 33 | --batch-size 256 \ 34 | --learning-rate 0.1 \ 35 | --workers 12 \ 36 | --print-freq 100 \ 37 | ${ARGS} 38 | -------------------------------------------------------------------------------- /projects/WSL/scripts/train_resnet50_ws.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x 3 | set -e 4 | 5 | export PYTHONUNBUFFERED="True" 6 | 7 | array=( $@ ) 8 | len=${#array[@]} 9 | ARGS=${array[@]:0:$len} 10 | 11 | EXP_DIR="output/resnet50_ws_`date +'%Y-%m-%d_%H-%M-%S'`" 12 | 13 | mkdir -p "${EXP_DIR}" 14 | LOG="${EXP_DIR}/train.log" 15 | exec &> >(tee -a "$LOG") 16 | echo Logging output to "$LOG" 17 | 18 | 19 | echo --------------------------------------------------------------------- 20 | git log -1 21 | git submodule foreach 'git log -1' 22 | echo --------------------------------------------------------------------- 23 | 24 | python3 projects/WSL/tools/imagenet.py \ 25 | -a resnet50_ws \ 26 | --dist-url 'tcp://127.0.0.1:12345' \ 27 | --dist-backend 'nccl' \ 28 | --multiprocessing-distributed \ 29 | --world-size 1 \ 30 | --rank 0 \ 31 | --output_dir ${EXP_DIR} \ 32 | --epochs 120 \ 33 | --batch-size 128 \ 34 | --learning-rate 0.05 \ 35 | --workers 12 \ 36 | --print-freq 100 \ 37 | --weights 'detectron2://ImageNetPretrained/MSRA/R-50.pkl' \ 38 | ${ARGS} 39 | -------------------------------------------------------------------------------- /projects/WSL/tools/convert_resnet_ws_pth.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import sys 3 | import torch 4 | 5 | logger = logging.getLogger(__name__) 6 | 7 | in_path = sys.argv[1] 8 | out_path = sys.argv[2] 9 | 10 | in_pth = torch.load(in_path) 11 | print(in_pth.keys()) 12 | in_pth = in_pth["state_dict"] 13 | print(in_pth.keys()) 14 | 15 | out_pth = dict() 16 | for k in list(in_pth.keys()): 17 | if "module.neck.fc" in k: 18 | k_new = k.replace("module.neck.fc", "roi_heads.box_head.fc") 19 | elif "module.backbone." in k: 20 | k_new = k.replace("module.backbone.", "backbone.") 21 | elif "module.neck" in k: 22 | k_new = k.replace("module.neck.", "roi_heads.box_head.") 23 | else: 24 | print("Unknown k pattern:", k) 25 | k_new = k 26 | out_pth[k_new] = in_pth[k] 27 | print("{} \t-->\t {}".format(k, k_new)) 28 | print(out_pth.keys()) 29 | 30 | torch.save(out_pth, out_path) 31 | -------------------------------------------------------------------------------- /projects/WSL/wsl/__init__.py: -------------------------------------------------------------------------------- 1 | from .modeling import ( 2 | build_vgg_backbone, 3 | build_ws_resnet_backbone, 4 | ) 5 | -------------------------------------------------------------------------------- /projects/WSL/wsl/config/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | from .defaults import add_wsl_config 4 | -------------------------------------------------------------------------------- /projects/WSL/wsl/config/defaults.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 3 | 4 | from detectron2.config import CfgNode as CN 5 | 6 | 7 | def add_wsl_config(cfg): 8 | """ 9 | Add config for mrrpnet. 10 | """ 11 | _C = cfg 12 | 13 | _C.MODEL.VGG = CN() 14 | 15 | _C.MODEL.VGG.DEPTH = 16 16 | _C.MODEL.VGG.OUT_FEATURES = ["plain5"] 17 | _C.MODEL.VGG.CONV5_DILATION = 1 18 | 19 | _C.WSL = CN() 20 | _C.WSL.VIS_TEST = False 21 | _C.WSL.ITER_SIZE = 1 22 | _C.WSL.MEAN_LOSS = True 23 | 24 | _C.MODEL.ROI_BOX_HEAD.DAN_DIM = [4096, 4096] 25 | 26 | _C.WSL.USE_OBN = True 27 | 28 | _C.WSL.CSC_MAX_ITER = 35000 29 | 30 | _C.WSL.REFINE_NUM = 3 31 | _C.WSL.REFINE_REG = [False, False, False] 32 | 33 | # List of the dataset names for testing. Must be registered in DatasetCatalog 34 | _C.DATASETS.VAL = () 35 | # List of the pre-computed proposal files for test, which must be consistent 36 | # with datasets listed in DATASETS.VAL. 37 | _C.DATASETS.PROPOSAL_FILES_VAL = () 38 | 39 | _C.MODEL.SEM_SEG_HEAD.ASSP_CONVS_DIM = [1024, 1024] 40 | _C.MODEL.SEM_SEG_HEAD.MASK_SOFTMAX = False 41 | _C.MODEL.SEM_SEG_HEAD.CONSTRAINT = False 42 | 43 | _C.TEST.EVAL_TRAIN = True 44 | -------------------------------------------------------------------------------- /projects/WSL/wsl/data/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | # ensure the builtin datasets are registered 4 | from . import datasets # isort:skip 5 | 6 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 7 | -------------------------------------------------------------------------------- /projects/WSL/wsl/data/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from . import builtin # ensure the builtin datasets are registered 3 | -------------------------------------------------------------------------------- /projects/WSL/wsl/layers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from .pcl_loss import PCLLoss, pcl_loss 3 | from .csc import CSC, csc, CSCConstraint, csc_constraint 4 | from .crf import CRF, crf 5 | 6 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 7 | -------------------------------------------------------------------------------- /projects/WSL/wsl/layers/csrc/vision.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | #include 4 | #include "crf/crf.h" 5 | #include "csc/csc.h" 6 | #include "pcl_loss/pcl_loss.h" 7 | 8 | namespace wsl { 9 | 10 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 11 | m.def("pcl_loss_forward", &pcl_loss_forward, "pcl_loss_forward"); 12 | m.def("pcl_loss_backward", &pcl_loss_backward, "pcl_loss_backward"); 13 | 14 | m.def("csc_forward", &csc_forward, "csc_forward"); 15 | 16 | m.def("crf_forward", &crf_forward, "crf_forward"); 17 | } 18 | 19 | } // namespace wsl 20 | -------------------------------------------------------------------------------- /projects/WSL/wsl/modeling/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | from .backbone import ( 4 | build_vgg_backbone, 5 | build_ws_resnet_backbone, 6 | ) 7 | 8 | from .postprocessing import detector_postprocess 9 | 10 | from .roi_heads import WSDDNROIHeads, CSCROIHeads, OICRROIHeads, PCLROIHeads 11 | 12 | from .seg_heads import WSJDSROIHeads 13 | 14 | from .test_time_augmentation_avg import DatasetMapperTTAAVG, GeneralizedRCNNWithTTAAVG 15 | from .test_time_augmentation_union import DatasetMapperTTAUNION, GeneralizedRCNNWithTTAUNION 16 | 17 | _EXCLUDE = {"torch", "ShapeSpec"} 18 | __all__ = [k for k in globals().keys() if k not in _EXCLUDE and not k.startswith("_")] 19 | -------------------------------------------------------------------------------- /projects/WSL/wsl/modeling/backbone/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | from .vgg import VGG16, PlainBlockBase, build_vgg_backbone 4 | from .resnet_ws import build_ws_resnet_backbone, make_stage 5 | 6 | # TODO can expose more resnet blocks after careful consideration 7 | -------------------------------------------------------------------------------- /projects/WSL/wsl/modeling/meta_arch/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 3 | 4 | from .rcnn import GeneralizedRCNNWSL, ProposalNetworkWSL 5 | -------------------------------------------------------------------------------- /projects/WSL/wsl/modeling/roi_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | from .box_head import DiscriminativeAdaptionNeck 4 | from .roi_heads_wsddn import WSDDNROIHeads 5 | from .roi_heads_csc import CSCROIHeads 6 | from .roi_heads_oicr import OICRROIHeads 7 | from .roi_heads_pcl import PCLROIHeads 8 | -------------------------------------------------------------------------------- /projects/WSL/wsl/modeling/seg_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | from .seg_heads import ASPPHead 4 | from .wsjds_heads import WSJDSROIHeads 5 | -------------------------------------------------------------------------------- /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 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 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | -------------------------------------------------------------------------------- /tests/data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shenyunhang/DRN-WSOD-pytorch/ff6168effcff68a77fbd6576ce108726ff14034c/tests/data/__init__.py -------------------------------------------------------------------------------- /tests/data/test_sampler.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 2 | import unittest 3 | from torch.utils.data.sampler import SequentialSampler 4 | 5 | from detectron2.data.samplers import GroupedBatchSampler 6 | 7 | 8 | class TestGroupedBatchSampler(unittest.TestCase): 9 | def test_missing_group_id(self): 10 | sampler = SequentialSampler(list(range(100))) 11 | group_ids = [1] * 100 12 | samples = GroupedBatchSampler(sampler, group_ids, 2) 13 | 14 | for mini_batch in samples: 15 | self.assertEqual(len(mini_batch), 2) 16 | 17 | def test_groups(self): 18 | sampler = SequentialSampler(list(range(100))) 19 | group_ids = [1, 0] * 50 20 | samples = GroupedBatchSampler(sampler, group_ids, 2) 21 | 22 | for mini_batch in samples: 23 | self.assertEqual((mini_batch[0] + mini_batch[1]) % 2, 0) 24 | -------------------------------------------------------------------------------- /tests/layers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shenyunhang/DRN-WSOD-pytorch/ff6168effcff68a77fbd6576ce108726ff14034c/tests/layers/__init__.py -------------------------------------------------------------------------------- /tests/modeling/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shenyunhang/DRN-WSOD-pytorch/ff6168effcff68a77fbd6576ce108726ff14034c/tests/modeling/__init__.py -------------------------------------------------------------------------------- /tests/structures/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shenyunhang/DRN-WSOD-pytorch/ff6168effcff68a77fbd6576ce108726ff14034c/tests/structures/__init__.py -------------------------------------------------------------------------------- /tests/test_engine.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | 4 | import unittest 5 | import torch 6 | from torch import nn 7 | 8 | from detectron2.engine import SimpleTrainer 9 | 10 | 11 | class SimpleModel(nn.Sequential): 12 | def forward(self, x): 13 | return {"loss": x.sum() + sum([x.mean() for x in self.parameters()])} 14 | 15 | 16 | class TestTrainer(unittest.TestCase): 17 | def test_simple_trainer(self, device="cpu"): 18 | device = torch.device(device) 19 | model = SimpleModel(nn.Linear(10, 10)).to(device) 20 | 21 | def data_loader(): 22 | while True: 23 | yield torch.rand(3, 3).to(device) 24 | 25 | trainer = SimpleTrainer(model, data_loader(), torch.optim.SGD(model.parameters(), 0.1)) 26 | trainer.train(0, 10) 27 | 28 | @unittest.skipIf(not torch.cuda.is_available(), "CUDA not available") 29 | def test_simple_trainer_cuda(self): 30 | self.test_simple_trainer(device="cuda") 31 | -------------------------------------------------------------------------------- /tests/test_model_zoo.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | import logging 3 | import unittest 4 | 5 | from detectron2 import model_zoo 6 | from detectron2.modeling import FPN, GeneralizedRCNN 7 | 8 | logger = logging.getLogger(__name__) 9 | 10 | 11 | class TestModelZoo(unittest.TestCase): 12 | def test_get_returns_model(self): 13 | model = model_zoo.get("Misc/scratch_mask_rcnn_R_50_FPN_3x_gn.yaml", trained=False) 14 | self.assertIsInstance(model, GeneralizedRCNN) 15 | self.assertIsInstance(model.backbone, FPN) 16 | 17 | def test_get_invalid_model(self): 18 | self.assertRaises(RuntimeError, model_zoo.get, "Invalid/config.yaml") 19 | 20 | def test_get_url(self): 21 | url = model_zoo.get_checkpoint_url("Misc/scratch_mask_rcnn_R_50_FPN_3x_gn.yaml") 22 | self.assertEqual( 23 | url, 24 | "https://dl.fbaipublicfiles.com/detectron2/Misc/scratch_mask_rcnn_R_50_FPN_3x_gn/138602908/model_final_01ca85.pkl", # noqa 25 | ) 26 | 27 | 28 | if __name__ == "__main__": 29 | unittest.main() 30 | -------------------------------------------------------------------------------- /tools/README.md: -------------------------------------------------------------------------------- 1 | 2 | This directory contains a few scripts that use 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 | * `visualize_json_results.py` 26 | 27 | Visualize the json instance detection/segmentation results dumped by `COCOEvalutor` or `LVISEvaluator` 28 | 29 | Usage: 30 | ``` 31 | python visualize_json_results.py --input x.json --output dir/ --dataset coco_2017_val 32 | ``` 33 | If not using a builtin dataset, you'll need your own script or modify this script. 34 | 35 | * `visualize_data.py` 36 | 37 | Visualize ground truth raw annotations or training data (after preprocessing/augmentations). 38 | 39 | Usage: 40 | ``` 41 | python visualize_data.py --config-file config.yaml --source annotation/dataloader --output-dir dir/ [--show] 42 | ``` 43 | 44 | NOTE: the script does not stop by itself when using `--source dataloader` because a training 45 | dataloader is usually infinite. 46 | -------------------------------------------------------------------------------- /tools/deploy/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 2 | # See https://pytorch.org/tutorials/advanced/cpp_frontend.html 3 | cmake_minimum_required(VERSION 3.0 FATAL_ERROR) 4 | project(caffe2_mask_rcnn) 5 | 6 | find_package(Torch REQUIRED) 7 | find_package(gflags REQUIRED) 8 | find_package(OpenCV REQUIRED) 9 | 10 | add_executable(caffe2_mask_rcnn caffe2_mask_rcnn.cpp) 11 | target_link_libraries( 12 | caffe2_mask_rcnn 13 | "${TORCH_LIBRARIES}" gflags glog ${OpenCV_LIBS}) 14 | set_property(TARGET caffe2_mask_rcnn PROPERTY CXX_STANDARD 14) 15 | 16 | 17 | add_executable(torchscript_traced_mask_rcnn torchscript_traced_mask_rcnn.cpp) 18 | target_link_libraries( 19 | torchscript_traced_mask_rcnn 20 | "${TORCH_LIBRARIES}" ${OpenCV_LIBS}) 21 | set_property(TARGET torchscript_traced_mask_rcnn PROPERTY CXX_STANDARD 14) 22 | -------------------------------------------------------------------------------- /tools/deploy/README.md: -------------------------------------------------------------------------------- 1 | 2 | This directory contains: 3 | 4 | 1. A script that converts a detectron2 model to caffe2 format. 5 | 6 | 2. An example that loads a Mask R-CNN model in caffe2 format and runs inference. 7 | 8 | See [tutorial](https://detectron2.readthedocs.io/tutorials/deployment.html) 9 | for their usage. 10 | --------------------------------------------------------------------------------