├── LICENSE ├── README.md ├── configs ├── Base-RCNN-C4.yaml ├── Base-RCNN-DilatedC5.yaml ├── Base-RCNN-FPN.yaml ├── Base-RetinaNet.yaml ├── LVISv0.5-InstanceSegmentation │ └── 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_dconv_c3-c5_4gpu.yaml │ ├── mask_rcnn_R_50_FPN_3x_gn.yaml │ ├── mask_rcnn_R_50_FPN_3x_syncbn.yaml │ ├── mmdet_mask_rcnn_R_50_FPN_1x.py │ ├── panoptic_fpn_R_101_dconv_cascade_gn_3x.yaml │ ├── scratch_mask_rcnn_R_50_FPN_3x_gn.yaml │ ├── scratch_mask_rcnn_R_50_FPN_9x_gn.yaml │ ├── scratch_mask_rcnn_R_50_FPN_9x_syncbn.yaml │ ├── semantic_R_50_FPN_1x.yaml │ └── torchvision_imagenet_R_50.py ├── common │ ├── README.md │ ├── coco_schedule.py │ ├── data │ │ ├── coco.py │ │ ├── coco_keypoint.py │ │ └── coco_panoptic_separated.py │ ├── models │ │ ├── cascade_rcnn.py │ │ ├── keypoint_rcnn_fpn.py │ │ ├── mask_rcnn_c4.py │ │ ├── mask_rcnn_fpn.py │ │ ├── panoptic_fpn.py │ │ └── retinanet.py │ ├── optim.py │ └── train.py └── transfiner │ ├── mask_rcnn_R_101_FPN_3x.yaml │ ├── mask_rcnn_R_101_FPN_3x_deform.yaml │ ├── mask_rcnn_R_50_FPN_1x.yaml │ ├── mask_rcnn_R_50_FPN_3x.yaml │ ├── mask_rcnn_R_50_FPN_3x_deform.yaml │ ├── mask_rcnn_swinb_FPN_3x.yaml │ └── mask_rcnn_swint_FPN_3x.yaml ├── demo ├── README.md ├── demo.py ├── demo_swinb.py ├── predictor.py └── sample_imgs │ ├── 000000008844.jpg │ ├── 000000018737.jpg │ ├── 000000126137.jpg │ ├── 000000131444.jpg │ ├── 000000132408.jpg │ ├── 000000157365.jpg │ ├── 000000176037.jpg │ ├── 000000224200.jpg │ ├── 000000244019.jpg │ ├── 000000252776.jpg │ ├── 000000286849.jpg │ ├── 000000292997.jpg │ ├── 000000321214.jpg │ ├── 000000344909.jpg │ ├── 000000360661.jpg │ ├── 000000396903.jpg │ ├── 000000404922.jpg │ ├── 000000442836.jpg │ ├── 000000464144.jpg │ ├── 000000482477.jpg │ ├── 000000495054.jpg │ └── 000000558073.jpg ├── detectron2.egg-info ├── PKG-INFO ├── SOURCES.txt ├── dependency_links.txt ├── requires.txt └── top_level.txt ├── detectron2 ├── __init__.py ├── checkpoint │ ├── __init__.py │ ├── c2_model_loading.py │ ├── catalog.py │ └── detection_checkpoint.py ├── config │ ├── __init__.py │ ├── compat.py │ ├── config.py │ ├── defaults.py │ ├── defaults.py~ │ ├── instantiate.py │ └── lazy.py ├── data │ ├── __init__.py │ ├── benchmark.py │ ├── build.py │ ├── catalog.py │ ├── common.py │ ├── dataset_mapper.py │ ├── datasets │ │ ├── README.md │ │ ├── __init__.py │ │ ├── builtin.py │ │ ├── builtin_meta.py │ │ ├── cityscapes.py │ │ ├── cityscapes_panoptic.py │ │ ├── coco.py │ │ ├── coco_panoptic.py │ │ ├── lvis.py │ │ ├── lvis_v0_5_categories.py │ │ ├── lvis_v1_categories.py │ │ ├── pascal_voc.py │ │ ├── process_dataset.py │ │ ├── process_dataset_occ.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 │ │ └── transform_gen.py ├── engine │ ├── __init__.py │ ├── defaults.py │ ├── hooks.py │ ├── launch.py │ └── train_loop.py ├── evaluation │ ├── __init__.py │ ├── cityscapes_evaluation.py │ ├── coco_evaluation.py │ ├── evaluator.py │ ├── fast_eval_api.py │ ├── lvis_evaluation.py │ ├── panoptic_evaluation.py │ ├── pascal_voc_evaluation.py │ ├── rotated_coco_evaluation.py │ ├── sem_seg_evaluation.py │ └── testing.py ├── export │ ├── README.md │ ├── __init__.py │ ├── api.py │ ├── c10.py │ ├── caffe2_export.py │ ├── caffe2_inference.py │ ├── caffe2_modeling.py │ ├── caffe2_patch.py │ ├── flatten.py │ ├── patcher.py │ ├── shared.py │ ├── torchscript.py │ └── torchscript_patch.py ├── layers │ ├── __init__.py │ ├── aspp.py │ ├── batch_norm.py │ ├── blocks.py │ ├── boundary.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 │ ├── iou_loss.py │ ├── mask_ops.py │ ├── misc.py │ ├── nms.py │ ├── roi_align.py │ ├── roi_align_rotated.py │ ├── rotated_boxes.py │ ├── scale.py │ ├── shape_spec.py │ └── wrappers.py ├── model_zoo │ ├── __init__.py │ ├── configs │ └── model_zoo.py ├── modeling │ ├── __init__.py │ ├── anchor_generator.py │ ├── backbone │ │ ├── __init__.py │ │ ├── backbone.py │ │ ├── build.py │ │ ├── fpn.py │ │ ├── fpn.py~ │ │ ├── pafpn.py │ │ ├── pafpn.py~ │ │ ├── regnet.py │ │ └── resnet.py │ ├── box_regression.py │ ├── matcher.py │ ├── meta_arch │ │ ├── __init__.py │ │ ├── build.py │ │ ├── fcos.py │ │ ├── fcos.py~ │ │ ├── inference_fcos.py │ │ ├── inference_fcos.py~ │ │ ├── loss_fcos.py │ │ ├── panoptic_fpn.py │ │ ├── rcnn.py │ │ ├── retinanet.py │ │ └── semantic_seg.py │ ├── mmdet_wrapper.py │ ├── poolers.py │ ├── postprocessing.py │ ├── proposal_generator │ │ ├── __init__.py │ │ ├── build.py │ │ ├── proposal_utils.py │ │ ├── rpn.py │ │ ├── rpn_outputs.py │ │ ├── rrpn.py │ │ └── rrpn_outputs.py │ ├── roi_heads │ │ ├── __init__.py │ │ ├── box_head.py │ │ ├── cascade_rcnn.py │ │ ├── fast_rcnn.py │ │ ├── keypoint_head.py │ │ ├── mask_head.py │ │ ├── roi_heads.py │ │ └── rotated_fast_rcnn.py │ ├── sampling.py │ └── test_time_augmentation.py ├── projects │ ├── README.md │ └── __init__.py ├── solver │ ├── __init__.py │ ├── build.py │ └── lr_scheduler.py ├── structures │ ├── __init__.py │ ├── boxes.py │ ├── image_list.py │ ├── instances.py │ ├── keypoints.py │ ├── masks.py │ └── rotated_boxes.py └── utils │ ├── README.md │ ├── __init__.py │ ├── analysis.py │ ├── collect_env.py │ ├── colormap.py │ ├── comm.py │ ├── env.py │ ├── events.py │ ├── file_io.py │ ├── logger.py │ ├── memory.py │ ├── registry.py │ ├── serialize.py │ ├── testing.py │ ├── video_visualizer.py │ ├── visualizer.py │ └── visualizer_old.py ├── dev ├── README.md ├── linter.sh ├── packaging │ ├── README.md │ ├── build_all_wheels.sh │ ├── build_wheel.sh │ ├── gen_install_table.py │ ├── gen_wheel_index.sh │ └── pkg_helpers.bash ├── parse_results.sh ├── run_inference_tests.sh └── run_instant_tests.sh ├── docker ├── Dockerfile ├── README.md ├── deploy.Dockerfile └── docker-compose.yml ├── docs ├── .gitignore ├── Makefile ├── README.md ├── _static │ └── css │ │ └── custom.css ├── conf.py ├── index.rst ├── modules │ ├── checkpoint.rst │ ├── config.rst │ ├── data.rst │ ├── data_transforms.rst │ ├── engine.rst │ ├── evaluation.rst │ ├── export.rst │ ├── fvcore.rst │ ├── index.rst │ ├── layers.rst │ ├── model_zoo.rst │ ├── modeling.rst │ ├── solver.rst │ ├── structures.rst │ └── utils.rst ├── notes │ ├── benchmarks.md │ ├── changelog.md │ ├── compatibility.md │ ├── contributing.md │ └── index.rst ├── requirements.txt └── tutorials │ ├── README.md │ ├── augmentation.md │ ├── builtin_datasets.md │ ├── configs.md │ ├── data_loading.md │ ├── datasets.md │ ├── deployment.md │ ├── evaluation.md │ ├── extend.md │ ├── getting_started.md │ ├── index.rst │ ├── install.md │ ├── lazyconfig.jpg │ ├── lazyconfigs.md │ ├── models.md │ ├── training.md │ └── write-models.md ├── figures ├── case-a1.gif ├── case-a2.gif ├── case-a3.gif ├── case-a6.gif ├── mask_transfiner.gif ├── mask_transfiner_banner.gif └── transfiner-banner.png ├── 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 │ │ ├── cse │ │ │ ├── Base-DensePose-RCNN-FPN-Human.yaml │ │ │ ├── Base-DensePose-RCNN-FPN.yaml │ │ │ ├── densepose_rcnn_R_101_FPN_DL_s1x.yaml │ │ │ ├── densepose_rcnn_R_101_FPN_DL_soft_s1x.yaml │ │ │ ├── densepose_rcnn_R_101_FPN_s1x.yaml │ │ │ ├── densepose_rcnn_R_101_FPN_soft_s1x.yaml │ │ │ ├── densepose_rcnn_R_50_FPN_DL_s1x.yaml │ │ │ ├── densepose_rcnn_R_50_FPN_DL_soft_s1x.yaml │ │ │ ├── densepose_rcnn_R_50_FPN_s1x.yaml │ │ │ ├── densepose_rcnn_R_50_FPN_soft_animals_CA_finetune_16k.yaml │ │ │ ├── densepose_rcnn_R_50_FPN_soft_animals_CA_finetune_4k.yaml │ │ │ ├── densepose_rcnn_R_50_FPN_soft_animals_I0_finetune_16k.yaml │ │ │ ├── densepose_rcnn_R_50_FPN_soft_animals_I0_finetune_i2m_16k.yaml │ │ │ ├── densepose_rcnn_R_50_FPN_soft_animals_I0_finetune_m2m_16k.yaml │ │ │ ├── densepose_rcnn_R_50_FPN_soft_animals_finetune_16k.yaml │ │ │ ├── densepose_rcnn_R_50_FPN_soft_animals_finetune_4k.yaml │ │ │ ├── densepose_rcnn_R_50_FPN_soft_animals_finetune_maskonly_24k.yaml │ │ │ ├── densepose_rcnn_R_50_FPN_soft_chimps_finetune_4k.yaml │ │ │ └── densepose_rcnn_R_50_FPN_soft_s1x.yaml │ │ ├── densepose_rcnn_R_101_FPN_DL_WC1M_s1x.yaml │ │ ├── densepose_rcnn_R_101_FPN_DL_WC1_s1x.yaml │ │ ├── densepose_rcnn_R_101_FPN_DL_WC2M_s1x.yaml │ │ ├── densepose_rcnn_R_101_FPN_DL_WC2_s1x.yaml │ │ ├── densepose_rcnn_R_101_FPN_DL_s1x.yaml │ │ ├── densepose_rcnn_R_101_FPN_WC1M_s1x.yaml │ │ ├── densepose_rcnn_R_101_FPN_WC1_s1x.yaml │ │ ├── densepose_rcnn_R_101_FPN_WC2M_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_WC1M_s1x.yaml │ │ ├── densepose_rcnn_R_50_FPN_DL_WC1_s1x.yaml │ │ ├── densepose_rcnn_R_50_FPN_DL_WC2M_s1x.yaml │ │ ├── densepose_rcnn_R_50_FPN_DL_WC2_s1x.yaml │ │ ├── densepose_rcnn_R_50_FPN_DL_s1x.yaml │ │ ├── densepose_rcnn_R_50_FPN_WC1M_s1x.yaml │ │ ├── densepose_rcnn_R_50_FPN_WC1_s1x.yaml │ │ ├── densepose_rcnn_R_50_FPN_WC2M_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-Atop10P_CA.yaml │ │ │ ├── densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA.yaml │ │ │ ├── densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_coarsesegm.yaml │ │ │ ├── densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_finesegm.yaml │ │ │ ├── densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_uniform.yaml │ │ │ └── densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA_B_uv.yaml │ │ └── quick_schedules │ │ │ ├── cse │ │ │ ├── densepose_rcnn_R_50_FPN_DL_instant_test.yaml │ │ │ └── densepose_rcnn_R_50_FPN_soft_animals_finetune_instant_test.yaml │ │ │ ├── densepose_rcnn_HRFPN_HRNet_w32_instant_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 │ │ ├── converters │ │ │ ├── __init__.py │ │ │ ├── base.py │ │ │ ├── builtin.py │ │ │ ├── chart_output_hflip.py │ │ │ ├── chart_output_to_chart_result.py │ │ │ ├── hflip.py │ │ │ ├── segm_to_mask.py │ │ │ ├── to_chart_result.py │ │ │ └── to_mask.py │ │ ├── data │ │ │ ├── __init__.py │ │ │ ├── build.py │ │ │ ├── combined_loader.py │ │ │ ├── dataset_mapper.py │ │ │ ├── datasets │ │ │ │ ├── __init__.py │ │ │ │ ├── builtin.py │ │ │ │ ├── chimpnsee.py │ │ │ │ ├── coco.py │ │ │ │ ├── dataset_type.py │ │ │ │ └── lvis.py │ │ │ ├── image_list_dataset.py │ │ │ ├── inference_based_loader.py │ │ │ ├── meshes │ │ │ │ ├── __init__.py │ │ │ │ ├── builtin.py │ │ │ │ └── catalog.py │ │ │ ├── samplers │ │ │ │ ├── __init__.py │ │ │ │ ├── densepose_base.py │ │ │ │ ├── densepose_confidence_based.py │ │ │ │ ├── densepose_cse_base.py │ │ │ │ ├── densepose_cse_confidence_based.py │ │ │ │ ├── densepose_cse_uniform.py │ │ │ │ ├── densepose_uniform.py │ │ │ │ ├── mask_from_densepose.py │ │ │ │ └── prediction_to_gt.py │ │ │ ├── transform │ │ │ │ ├── __init__.py │ │ │ │ └── image.py │ │ │ ├── utils.py │ │ │ └── video │ │ │ │ ├── __init__.py │ │ │ │ ├── frame_selector.py │ │ │ │ └── video_keyframe_dataset.py │ │ ├── engine │ │ │ ├── __init__.py │ │ │ └── trainer.py │ │ ├── evaluation │ │ │ ├── __init__.py │ │ │ ├── d2_evaluator_adapter.py │ │ │ ├── densepose_coco_evaluation.py │ │ │ ├── evaluator.py │ │ │ ├── mesh_alignment_evaluator.py │ │ │ └── tensor_storage.py │ │ ├── modeling │ │ │ ├── __init__.py │ │ │ ├── build.py │ │ │ ├── confidence.py │ │ │ ├── cse │ │ │ │ ├── __init__.py │ │ │ │ ├── embedder.py │ │ │ │ ├── utils.py │ │ │ │ ├── vertex_direct_embedder.py │ │ │ │ └── vertex_feature_embedder.py │ │ │ ├── densepose_checkpoint.py │ │ │ ├── filter.py │ │ │ ├── hrfpn.py │ │ │ ├── hrnet.py │ │ │ ├── inference.py │ │ │ ├── losses │ │ │ │ ├── __init__.py │ │ │ │ ├── chart.py │ │ │ │ ├── chart_with_confidences.py │ │ │ │ ├── cse.py │ │ │ │ ├── cycle_pix2shape.py │ │ │ │ ├── cycle_shape2shape.py │ │ │ │ ├── embed.py │ │ │ │ ├── embed_utils.py │ │ │ │ ├── mask.py │ │ │ │ ├── mask_or_segm.py │ │ │ │ ├── registry.py │ │ │ │ ├── segm.py │ │ │ │ ├── soft_embed.py │ │ │ │ └── utils.py │ │ │ ├── predictors │ │ │ │ ├── __init__.py │ │ │ │ ├── chart.py │ │ │ │ ├── chart_confidence.py │ │ │ │ ├── chart_with_confidence.py │ │ │ │ ├── cse.py │ │ │ │ ├── cse_confidence.py │ │ │ │ ├── cse_with_confidence.py │ │ │ │ └── registry.py │ │ │ ├── roi_heads │ │ │ │ ├── __init__.py │ │ │ │ ├── deeplab.py │ │ │ │ ├── registry.py │ │ │ │ ├── roi_head.py │ │ │ │ └── v1convx.py │ │ │ ├── test_time_augmentation.py │ │ │ └── utils.py │ │ ├── structures │ │ │ ├── __init__.py │ │ │ ├── chart.py │ │ │ ├── chart_confidence.py │ │ │ ├── chart_result.py │ │ │ ├── cse.py │ │ │ ├── cse_confidence.py │ │ │ ├── data_relative.py │ │ │ ├── list.py │ │ │ ├── mesh.py │ │ │ └── transform_data.py │ │ ├── utils │ │ │ ├── __init__.py │ │ │ ├── dbhelper.py │ │ │ ├── logger.py │ │ │ └── transform.py │ │ └── vis │ │ │ ├── __init__.py │ │ │ ├── base.py │ │ │ ├── bounding_box.py │ │ │ ├── densepose_data_points.py │ │ │ ├── densepose_outputs_iuv.py │ │ │ ├── densepose_outputs_vertex.py │ │ │ ├── densepose_results.py │ │ │ ├── densepose_results_textures.py │ │ │ └── extractor.py │ ├── dev │ │ ├── README.md │ │ ├── run_inference_tests.sh │ │ └── run_instant_tests.sh │ ├── doc │ │ ├── BOOTSTRAPPING_PIPELINE.md │ │ ├── DENSEPOSE_CSE.md │ │ ├── DENSEPOSE_DATASETS.md │ │ ├── DENSEPOSE_IUV.md │ │ ├── GETTING_STARTED.md │ │ ├── RELEASE_2020_04.md │ │ ├── RELEASE_2021_03.md │ │ ├── RELEASE_2021_06.md │ │ ├── TOOL_APPLY_NET.md │ │ └── TOOL_QUERY_DB.md │ ├── query_db.py │ ├── setup.py │ ├── tests │ │ ├── common.py │ │ ├── test_chart_based_annotations_accumulator.py │ │ ├── test_combine_data_loader.py │ │ ├── test_cse_annotations_accumulator.py │ │ ├── test_dataset_loaded_annotations.py │ │ ├── test_frame_selector.py │ │ ├── test_image_list_dataset.py │ │ ├── test_image_resize_transform.py │ │ ├── test_model_e2e.py │ │ ├── test_setup.py │ │ ├── test_structures.py │ │ ├── test_tensor_storage.py │ │ └── test_video_keyframe_dataset.py │ └── train_net.py ├── Panoptic-DeepLab │ ├── README.md │ ├── configs │ │ ├── COCO-PanopticSegmentation │ │ │ └── panoptic_deeplab_R_52_os16_mg124_poly_200k_bs64_crop_640_640_coco_dsconv.yaml │ │ └── Cityscapes-PanopticSegmentation │ │ │ ├── Base-PanopticDeepLab-OS16.yaml │ │ │ ├── panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024.yaml │ │ │ └── panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024_dsconv.yaml │ ├── panoptic_deeplab │ │ ├── __init__.py │ │ ├── config.py │ │ ├── dataset_mapper.py │ │ ├── panoptic_seg.py │ │ ├── post_processing.py │ │ └── target_generator.py │ └── train_net.py ├── PointRend │ ├── README.md │ ├── configs │ │ ├── InstanceSegmentation │ │ │ ├── Base-Implicit-PointRend.yaml │ │ │ ├── Base-PointRend-RCNN-FPN.yaml │ │ │ ├── implicit_pointrend_R_50_FPN_1x_coco.yaml │ │ │ ├── implicit_pointrend_R_50_FPN_3x_coco.yaml │ │ │ ├── pointrend_rcnn_R_101_FPN_3x_coco.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 │ │ │ └── pointrend_rcnn_X_101_32x8d_FPN_3x_coco.yaml │ │ └── SemanticSegmentation │ │ │ ├── Base-PointRend-Semantic-FPN.yaml │ │ │ └── pointrend_semantic_R_101_FPN_1x_cityscapes.yaml │ ├── demo │ │ ├── README.md │ │ ├── demo.py │ │ └── predictor.py │ ├── point_rend │ │ ├── __init__.py │ │ ├── color_augmentation.py │ │ ├── config.py │ │ ├── mask_head.py │ │ ├── point_features.py │ │ ├── point_head.py │ │ ├── roi_heads.py │ │ └── semantic_seg.py │ └── train_net.py ├── PointSup │ ├── README.md │ ├── configs │ │ ├── implicit_pointrend_R_50_FPN_3x_point_sup_point_aug_coco.yaml │ │ ├── mask_rcnn_R_50_FPN_3x_point_sup_coco.yaml │ │ └── mask_rcnn_R_50_FPN_3x_point_sup_point_aug_coco.yaml │ ├── point_sup │ │ ├── __init__.py │ │ ├── config.py │ │ ├── dataset_mapper.py │ │ ├── detection_utils.py │ │ ├── mask_head.py │ │ ├── point_utils.py │ │ └── register_point_annotations.py │ ├── tools │ │ └── prepare_coco_point_annotations_without_masks.py │ └── train_net.py ├── README.md ├── Rethinking-BatchNorm │ ├── README.md │ ├── configs │ │ ├── mask_rcnn_BNhead.py │ │ ├── mask_rcnn_BNhead_batch_stats.py │ │ ├── mask_rcnn_BNhead_shuffle.py │ │ ├── mask_rcnn_SyncBNhead.py │ │ ├── retinanet_SyncBNhead.py │ │ └── retinanet_SyncBNhead_SharedTraining.py │ └── retinanet-eval-domain-specific.py ├── 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 ├── pytorch_toolbelt ├── __init__.py ├── __pycache__ │ └── __init__.cpython-38.pyc ├── inference │ ├── __init__.py │ ├── functional.py │ ├── tiles.py │ └── tta.py ├── losses │ ├── __init__.py │ ├── __init__.py~ │ ├── __pycache__ │ │ ├── __init__.cpython-35.pyc │ │ ├── __init__.cpython-36.pyc │ │ ├── __init__.cpython-38.pyc │ │ ├── dice.cpython-35.pyc │ │ ├── dice.cpython-36.pyc │ │ ├── dice.cpython-38.pyc │ │ ├── focal.cpython-35.pyc │ │ ├── focal.cpython-36.pyc │ │ ├── focal.cpython-38.pyc │ │ ├── functional.cpython-35.pyc │ │ ├── functional.cpython-36.pyc │ │ ├── functional.cpython-38.pyc │ │ ├── jaccard.cpython-35.pyc │ │ ├── jaccard.cpython-36.pyc │ │ ├── jaccard.cpython-38.pyc │ │ ├── joint_loss.cpython-35.pyc │ │ ├── joint_loss.cpython-36.pyc │ │ ├── joint_loss.cpython-38.pyc │ │ ├── lovasz.cpython-35.pyc │ │ ├── lovasz.cpython-36.pyc │ │ ├── lovasz.cpython-38.pyc │ │ ├── other_losses.cpython-36.pyc │ │ ├── other_losses.cpython-38.pyc │ │ ├── wing_loss.cpython-35.pyc │ │ ├── wing_loss.cpython-36.pyc │ │ └── wing_loss.cpython-38.pyc │ ├── dice.py │ ├── focal.py │ ├── functional.py │ ├── functional.py~ │ ├── jaccard.py │ ├── joint_loss.py │ ├── lovasz.py │ ├── other_losses.py │ ├── other_losses.py~ │ └── wing_loss.py ├── modules │ ├── __init__.py │ ├── __init__.py~ │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── abn.cpython-36.pyc │ │ ├── activations.cpython-36.pyc │ │ ├── coord_conv.cpython-36.pyc │ │ ├── dsconv.cpython-36.pyc │ │ ├── fpn.cpython-36.pyc │ │ ├── hypercolumn.cpython-36.pyc │ │ ├── identity.cpython-36.pyc │ │ └── scse.cpython-36.pyc │ ├── abn.py │ ├── activations.py │ ├── agn.py │ ├── backbone │ │ ├── __init__.py │ │ ├── efficient_net.py │ │ ├── inceptionv4.py │ │ ├── mobilenet.py │ │ ├── mobilenetv3.py │ │ ├── senet.py │ │ └── wider_resnet.py │ ├── coord_conv.py │ ├── decoders.py │ ├── dropblock.py │ ├── dsconv.py │ ├── encoders.py │ ├── fpn.py │ ├── hypercolumn.py │ ├── identity.py │ ├── pooling.py │ ├── scse.py │ ├── srm.py │ └── unet.py ├── optimization │ ├── __init__.py │ ├── functional.py │ └── lr_schedules.py └── utils │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-35.pyc │ ├── __init__.cpython-36.pyc │ ├── __init__.cpython-38.pyc │ ├── torch_utils.cpython-35.pyc │ ├── torch_utils.cpython-36.pyc │ └── torch_utils.cpython-38.pyc │ ├── catalyst │ ├── __init__.py │ ├── criterions.py │ ├── metrics.py │ ├── utils.py │ └── visualization.py │ ├── catalyst_utils.py │ ├── dataset_utils.py │ ├── fs.py │ ├── namesgenerator.py │ ├── random.py │ ├── rle.py │ ├── torch_utils.py │ └── visualization.py ├── scores ├── r101_deform_score.txt ├── r101_score.txt ├── r50_deform_score.txt └── r50_score.txt ├── scripts ├── test_1x_transfiner_50.sh ├── test_3x_transfiner_101.sh ├── test_3x_transfiner_101_deform.sh ├── test_3x_transfiner_50.sh ├── test_3x_transfiner_50_deform.sh ├── test_3x_transfiner_swinb.sh ├── test_3x_transfiner_swint.sh ├── train_transfiner_1x_50.sh ├── train_transfiner_1x_x101_lvis.sh ├── train_transfiner_3x_101.sh ├── train_transfiner_3x_101_deform.sh ├── train_transfiner_3x_50.sh ├── train_transfiner_3x_50_deform.sh ├── train_transfiner_3x_swinb.sh ├── train_transfiner_3x_swint.sh ├── visual.sh └── visual_swinb.sh ├── setup.py ├── swinb ├── __init__.py ├── config.py └── swin_transformer.py ├── swint ├── __init__.py ├── config.py └── swin_transformer.py ├── tests ├── README.md ├── __init__.py ├── config │ ├── dir1 │ │ ├── dir1_a.py │ │ └── dir1_b.py │ ├── root_cfg.py │ ├── test_instantiate_config.py │ ├── test_lazy_config.py │ └── test_yacs_config.py ├── data │ ├── __init__.py │ ├── test_coco.py │ ├── test_coco_evaluation.py │ ├── test_dataset.py │ ├── test_detection_utils.py │ ├── test_rotation_transform.py │ ├── test_sampler.py │ └── test_transforms.py ├── layers │ ├── __init__.py │ ├── test_blocks.py │ ├── test_deformable.py │ ├── test_mask_ops.py │ ├── test_nms.py │ ├── test_nms_rotated.py │ ├── test_roi_align.py │ └── test_roi_align_rotated.py ├── modeling │ ├── __init__.py │ ├── test_anchor_generator.py │ ├── test_backbone.py │ ├── test_box2box_transform.py │ ├── test_fast_rcnn.py │ ├── test_matcher.py │ ├── test_mmdet.py │ ├── test_model_e2e.py │ ├── test_roi_heads.py │ ├── test_roi_pooler.py │ └── test_rpn.py ├── structures │ ├── __init__.py │ ├── test_boxes.py │ ├── test_imagelist.py │ ├── test_instances.py │ ├── test_keypoints.py │ ├── test_masks.py │ └── test_rotated_boxes.py ├── test_checkpoint.py ├── test_engine.py ├── test_events.py ├── test_export_caffe2.py ├── test_export_torchscript.py ├── test_model_analysis.py ├── test_model_zoo.py ├── test_packaging.py ├── test_registry.py ├── test_scheduler.py └── test_visualizer.py └── tools ├── README.md ├── __init__.py ├── analyze_model.py ├── benchmark.py ├── convert-torchvision-to-d2.py ├── deploy ├── CMakeLists.txt ├── README.md ├── caffe2_mask_rcnn.cpp ├── export_model.py └── torchscript_traced_mask_rcnn.cpp ├── lazyconfig_train_net.py ├── lightning_train_net.py ├── plain_train_net.py ├── train_net.py ├── train_net_swinb.py ├── train_net_swint.py ├── visualize_data.py └── visualize_json_results.py /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-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/LVISv0.5-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | OUTPUT_DIR: "./output_x101_lvis/" 3 | MODEL: 4 | WEIGHTS: "detectron2://ImageNetPretrained/FAIR/X-101-32x8d.pkl" 5 | PIXEL_STD: [57.375, 57.120, 58.395] 6 | MASK_ON: True 7 | RESNETS: 8 | STRIDE_IN_1X1: False # this is a C2 model 9 | NUM_GROUPS: 32 10 | WIDTH_PER_GROUP: 8 11 | DEPTH: 101 12 | ROI_HEADS: 13 | NUM_CLASSES: 1230 14 | SCORE_THRESH_TEST: 0.0001 15 | INPUT: 16 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 17 | DATASETS: 18 | TRAIN: ("lvis_v0.5_train",) 19 | TEST: ("lvis_v0.5_val",) 20 | TEST: 21 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 22 | DATALOADER: 23 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 24 | REPEAT_THRESHOLD: 0.001 25 | -------------------------------------------------------------------------------- /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_dconv_c3-c5_4gpu.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN-4gpu.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: (420000, 500000) # (210000, 250000) 11 | MAX_ITER: 540000 # 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/common/README.md: -------------------------------------------------------------------------------- 1 | This directory provides definitions for a few common models, dataloaders, scheduler, 2 | and optimizers that are often used in training. 3 | The definition of these objects are provided in the form of lazy instantiation: 4 | their arguments can be edited by users before constructing the objects. 5 | 6 | They can be imported, or loaded by `model_zoo.get_config` API in users' own configs. 7 | -------------------------------------------------------------------------------- /configs/common/data/coco_keypoint.py: -------------------------------------------------------------------------------- 1 | from detectron2.data.detection_utils import create_keypoint_hflip_indices 2 | 3 | from .coco import dataloader 4 | 5 | dataloader.train.dataset.min_keypoints = 1 6 | dataloader.train.dataset.names = "keypoints_coco_2017_train" 7 | dataloader.test.dataset.names = "keypoints_coco_2017_val" 8 | 9 | dataloader.train.mapper.update( 10 | use_instance_mask=False, 11 | use_keypoint=True, 12 | keypoint_hflip_indices=create_keypoint_hflip_indices(dataloader.train.dataset.names), 13 | ) 14 | -------------------------------------------------------------------------------- /configs/common/data/coco_panoptic_separated.py: -------------------------------------------------------------------------------- 1 | from detectron2.config import LazyCall as L 2 | from detectron2.evaluation import ( 3 | COCOEvaluator, 4 | COCOPanopticEvaluator, 5 | DatasetEvaluators, 6 | SemSegEvaluator, 7 | ) 8 | 9 | from .coco import dataloader 10 | 11 | dataloader.train.dataset.names = "coco_2017_train_panoptic_separated" 12 | dataloader.train.dataset.filter_empty = False 13 | dataloader.test.dataset.names = "coco_2017_val_panoptic_separated" 14 | 15 | 16 | dataloader.evaluator = [ 17 | L(COCOEvaluator)( 18 | dataset_name="${...test.dataset.names}", 19 | ), 20 | L(SemSegEvaluator)( 21 | dataset_name="${...test.dataset.names}", 22 | ), 23 | L(COCOPanopticEvaluator)( 24 | dataset_name="${...test.dataset.names}", 25 | ), 26 | ] 27 | -------------------------------------------------------------------------------- /configs/common/models/keypoint_rcnn_fpn.py: -------------------------------------------------------------------------------- 1 | from detectron2.config import LazyCall as L 2 | from detectron2.layers import ShapeSpec 3 | from detectron2.modeling.poolers import ROIPooler 4 | from detectron2.modeling.roi_heads import KRCNNConvDeconvUpsampleHead 5 | 6 | from .mask_rcnn_fpn import model 7 | 8 | [model.roi_heads.pop(x) for x in ["mask_in_features", "mask_pooler", "mask_head"]] 9 | 10 | model.roi_heads.update( 11 | num_classes=1, 12 | keypoint_in_features=["p2", "p3", "p4", "p5"], 13 | keypoint_pooler=L(ROIPooler)( 14 | output_size=14, 15 | scales=(1.0 / 4, 1.0 / 8, 1.0 / 16, 1.0 / 32), 16 | sampling_ratio=0, 17 | pooler_type="ROIAlignV2", 18 | ), 19 | keypoint_head=L(KRCNNConvDeconvUpsampleHead)( 20 | input_shape=ShapeSpec(channels=256, width=14, height=14), 21 | num_keypoints=17, 22 | conv_dims=[512] * 8, 23 | loss_normalizer="visible", 24 | ), 25 | ) 26 | 27 | # Detectron1 uses 2000 proposals per-batch, but this option is per-image in detectron2. 28 | # 1000 proposals per-image is found to hurt box AP. 29 | # Therefore we increase it to 1500 per-image. 30 | model.proposal_generator.post_nms_topk = (1500, 1000) 31 | 32 | # Keypoint AP degrades (though box AP improves) when using plain L1 loss 33 | model.roi_heads.box_predictor.smooth_l1_beta = 0.5 34 | -------------------------------------------------------------------------------- /configs/common/models/panoptic_fpn.py: -------------------------------------------------------------------------------- 1 | from detectron2.config import LazyCall as L 2 | from detectron2.layers import ShapeSpec 3 | from detectron2.modeling import PanopticFPN 4 | from detectron2.modeling.meta_arch.semantic_seg import SemSegFPNHead 5 | 6 | from .mask_rcnn_fpn import model 7 | 8 | model._target_ = PanopticFPN 9 | model.sem_seg_head = L(SemSegFPNHead)( 10 | input_shape={ 11 | f: L(ShapeSpec)(stride=s, channels="${....backbone.out_channels}") 12 | for f, s in zip(["p2", "p3", "p4", "p5"], [4, 8, 16, 32]) 13 | }, 14 | ignore_value=255, 15 | num_classes=54, # COCO stuff + 1 16 | conv_dims=128, 17 | common_stride=4, 18 | loss_weight=0.5, 19 | norm="GN", 20 | ) 21 | -------------------------------------------------------------------------------- /configs/common/optim.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | from detectron2.config import LazyCall as L 4 | from detectron2.solver.build import get_default_optimizer_params 5 | 6 | SGD = L(torch.optim.SGD)( 7 | params=L(get_default_optimizer_params)( 8 | # params.model is meant to be set to the model object, before instantiating 9 | # the optimizer. 10 | weight_decay_norm=0.0 11 | ), 12 | lr=0.02, 13 | momentum=0.9, 14 | weight_decay=1e-4, 15 | ) 16 | -------------------------------------------------------------------------------- /configs/common/train.py: -------------------------------------------------------------------------------- 1 | # Common training-related configs that are designed for "tools/lazyconfig_train_net.py" 2 | # You can use your own instead, together with your own train_net.py 3 | train = dict( 4 | output_dir="./output", 5 | init_checkpoint="detectron2://ImageNetPretrained/MSRA/R-50.pkl", 6 | max_iter=90000, 7 | amp=dict(enabled=False), # options for Automatic Mixed Precision 8 | ddp=dict( # options for DistributedDataParallel 9 | broadcast_buffers=False, 10 | find_unused_parameters=False, 11 | fp16_compression=False, 12 | ), 13 | checkpointer=dict(period=5000, max_to_keep=100), # options for PeriodicCheckpointer 14 | eval_period=5000, 15 | log_period=20, 16 | device="cuda" 17 | # ... 18 | ) 19 | -------------------------------------------------------------------------------- /configs/transfiner/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 | OUTPUT_DIR: "./output_101_3x" 11 | -------------------------------------------------------------------------------- /configs/transfiner/mask_rcnn_R_101_FPN_3x_deform.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 | 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 | OUTPUT_DIR: "./output_101_3x_deform" 13 | -------------------------------------------------------------------------------- /configs/transfiner/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 | OUTPUT_DIR: "./output_r50_1x" 8 | -------------------------------------------------------------------------------- /configs/transfiner/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 | OUTPUT_DIR: "./output_r50_3x" 11 | -------------------------------------------------------------------------------- /configs/transfiner/mask_rcnn_R_50_FPN_3x_deform.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 | OUTPUT_DIR: "./output_r50_3x_deform" 13 | -------------------------------------------------------------------------------- /configs/transfiner/mask_rcnn_swinb_FPN_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "swin_base_patch4_window7_224_22k_d2.pth" 4 | PIXEL_MEAN: [123.675, 116.28, 103.53] 5 | PIXEL_STD: [58.395, 57.12, 57.375] 6 | MASK_ON: True 7 | RESNETS: 8 | DEPTH: 50 9 | BACKBONE: 10 | NAME: "build_swinb_fpn_backbone" 11 | SWINT: 12 | OUT_FEATURES: ["stage2", "stage3", "stage4", "stage5"] 13 | FPN: 14 | IN_FEATURES: ["stage2", "stage3", "stage4", "stage5"] 15 | INPUT: 16 | FORMAT: "RGB" 17 | SOLVER: 18 | STEPS: (210000, 250000) 19 | MAX_ITER: 270000 20 | WEIGHT_DECAY: 0.05 21 | BASE_LR: 0.0001 22 | AMP: 23 | ENABLED: True 24 | TEST: 25 | EVAL_PERIOD: 10000 26 | INPUT: 27 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 28 | DATASETS: 29 | TRAIN: ("coco_2017_train",) 30 | TEST: ("coco_2017_val",) 31 | OUTPUT_DIR: "./output_swin_B_3x" 32 | -------------------------------------------------------------------------------- /configs/transfiner/mask_rcnn_swint_FPN_3x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "swin_tiny_patch4_window7_224_d2.pth" 4 | PIXEL_MEAN: [123.675, 116.28, 103.53] 5 | PIXEL_STD: [58.395, 57.12, 57.375] 6 | MASK_ON: True 7 | RESNETS: 8 | DEPTH: 50 9 | BACKBONE: 10 | NAME: "build_swint_fpn_backbone" 11 | SWINT: 12 | OUT_FEATURES: ["stage2", "stage3", "stage4", "stage5"] 13 | FPN: 14 | IN_FEATURES: ["stage2", "stage3", "stage4", "stage5"] 15 | INPUT: 16 | FORMAT: "RGB" 17 | SOLVER: 18 | STEPS: (210000, 250000) 19 | MAX_ITER: 270000 20 | WEIGHT_DECAY: 0.05 21 | BASE_LR: 0.0001 22 | AMP: 23 | ENABLED: True 24 | TEST: 25 | EVAL_PERIOD: 10000 26 | 27 | DATASETS: 28 | TRAIN: ("coco_2017_train",) 29 | TEST: ("coco_2017_val",) 30 | 31 | INPUT: 32 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 33 | 34 | OUTPUT_DIR: "./output_swin_t_3x" 35 | -------------------------------------------------------------------------------- /demo/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Mask Transfiner Demo 3 | 4 | For visualization demo, please refer to our [visualization script](https://github.com/SysCV/transfiner#visualization). 5 | 6 | -------------------------------------------------------------------------------- /demo/sample_imgs/000000008844.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000008844.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000018737.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000018737.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000126137.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000126137.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000131444.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000131444.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000132408.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000132408.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000157365.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000157365.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000176037.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000176037.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000224200.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000224200.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000244019.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000244019.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000252776.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000252776.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000286849.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000286849.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000292997.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000292997.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000321214.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000321214.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000344909.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000344909.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000360661.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000360661.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000396903.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000396903.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000404922.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000404922.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000442836.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000442836.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000464144.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000464144.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000482477.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000482477.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000495054.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000495054.jpg -------------------------------------------------------------------------------- /demo/sample_imgs/000000558073.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/demo/sample_imgs/000000558073.jpg -------------------------------------------------------------------------------- /detectron2.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: detectron2 3 | Version: 0.5 4 | Summary: Detectron2 is FAIR's next-generation research platform for object detection and segmentation. 5 | Home-page: https://github.com/facebookresearch/detectron2 6 | Author: FAIR 7 | License: UNKNOWN 8 | Description: UNKNOWN 9 | Platform: UNKNOWN 10 | Requires-Python: >=3.6 11 | Provides-Extra: all 12 | Provides-Extra: dev 13 | -------------------------------------------------------------------------------- /detectron2.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /detectron2.egg-info/requires.txt: -------------------------------------------------------------------------------- 1 | Pillow>=7.1 2 | matplotlib 3 | pycocotools>=2.0.2 4 | termcolor>=1.1 5 | yacs>=0.1.6 6 | tabulate 7 | cloudpickle 8 | tqdm>4.29.0 9 | tensorboard 10 | fvcore<0.1.6,>=0.1.5 11 | iopath<0.1.10,>=0.1.7 12 | future 13 | pydot 14 | omegaconf>=2.1 15 | hydra-core>=1.1 16 | black==21.4b2 17 | 18 | [:python_version < "3.7"] 19 | dataclasses 20 | 21 | [all] 22 | shapely 23 | pygments>=2.2 24 | psutil 25 | panopticapi@ https://github.com/cocodataset/panopticapi/archive/master.zip 26 | 27 | [dev] 28 | flake8==3.8.1 29 | isort==4.3.21 30 | flake8-bugbear 31 | flake8-comprehensions 32 | -------------------------------------------------------------------------------- /detectron2.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | detectron2 2 | tools 3 | -------------------------------------------------------------------------------- /detectron2/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from .utils.env import setup_environment 4 | 5 | setup_environment() 6 | 7 | 8 | # This line will be programatically read/write by setup.py. 9 | # Leave them at the bottom of this file and don't touch them. 10 | __version__ = "0.5" 11 | -------------------------------------------------------------------------------- /detectron2/checkpoint/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # File: 4 | 5 | 6 | from . import catalog as _UNUSED # register the handler 7 | from .detection_checkpoint import DetectionCheckpointer 8 | from fvcore.common.checkpoint import Checkpointer, PeriodicCheckpointer 9 | 10 | __all__ = ["Checkpointer", "PeriodicCheckpointer", "DetectionCheckpointer"] 11 | -------------------------------------------------------------------------------- /detectron2/config/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .compat import downgrade_config, upgrade_config 3 | from .config import CfgNode, get_cfg, global_cfg, set_global_cfg, configurable 4 | from .instantiate import instantiate 5 | from .lazy import LazyCall, LazyConfig 6 | 7 | __all__ = [ 8 | "CfgNode", 9 | "get_cfg", 10 | "global_cfg", 11 | "set_global_cfg", 12 | "downgrade_config", 13 | "upgrade_config", 14 | "configurable", 15 | "instantiate", 16 | "LazyCall", 17 | "LazyConfig", 18 | ] 19 | 20 | 21 | from detectron2.utils.env import fixup_module_metadata 22 | 23 | fixup_module_metadata(__name__, globals(), __all__) 24 | del fixup_module_metadata 25 | -------------------------------------------------------------------------------- /detectron2/data/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from . import transforms # isort:skip 3 | 4 | from .build import ( 5 | build_batch_data_loader, 6 | build_detection_test_loader, 7 | build_detection_train_loader, 8 | get_detection_dataset_dicts, 9 | load_proposals_into_dataset, 10 | print_instances_class_histogram, 11 | ) 12 | from .catalog import DatasetCatalog, MetadataCatalog, Metadata 13 | from .common import DatasetFromList, MapDataset, ToIterableDataset 14 | from .dataset_mapper import DatasetMapper 15 | 16 | # ensure the builtin datasets are registered 17 | from . import datasets, samplers # isort:skip 18 | 19 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 20 | -------------------------------------------------------------------------------- /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. 2 | from .coco import load_coco_json, load_sem_seg, register_coco_instances, convert_to_coco_json 3 | from .coco_panoptic import register_coco_panoptic, register_coco_panoptic_separated 4 | from .lvis import load_lvis_json, register_lvis_instances, get_lvis_instances_meta 5 | from .pascal_voc import load_voc_instances, register_pascal_voc 6 | from . import builtin as _builtin # ensure the builtin datasets are registered 7 | 8 | 9 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 10 | -------------------------------------------------------------------------------- /detectron2/data/datasets/register_coco.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .coco import register_coco_instances # noqa 3 | from .coco_panoptic import register_coco_panoptic_separated # noqa 4 | -------------------------------------------------------------------------------- /detectron2/data/samplers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .distributed_sampler import ( 3 | InferenceSampler, 4 | RandomSubsetTrainingSampler, 5 | RepeatFactorTrainingSampler, 6 | TrainingSampler, 7 | ) 8 | 9 | from .grouped_batch_sampler import GroupedBatchSampler 10 | 11 | __all__ = [ 12 | "GroupedBatchSampler", 13 | "TrainingSampler", 14 | "RandomSubsetTrainingSampler", 15 | "InferenceSampler", 16 | "RepeatFactorTrainingSampler", 17 | ] 18 | -------------------------------------------------------------------------------- /detectron2/data/transforms/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from fvcore.transforms.transform import Transform, TransformList # order them first 3 | from fvcore.transforms.transform import * 4 | from .transform import * 5 | from .augmentation import * 6 | from .augmentation_impl import * 7 | 8 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 9 | 10 | 11 | from detectron2.utils.env import fixup_module_metadata 12 | 13 | fixup_module_metadata(__name__, globals(), __all__) 14 | del fixup_module_metadata 15 | -------------------------------------------------------------------------------- /detectron2/engine/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from .launch import * 4 | from .train_loop import * 5 | 6 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 7 | 8 | 9 | # prefer to let hooks and defaults live in separate namespaces (therefore not in __all__) 10 | # but still make them available here 11 | from .hooks import * 12 | from .defaults import * 13 | -------------------------------------------------------------------------------- /detectron2/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .cityscapes_evaluation import CityscapesInstanceEvaluator, CityscapesSemSegEvaluator 3 | from .coco_evaluation import COCOEvaluator 4 | from .rotated_coco_evaluation import RotatedCOCOEvaluator 5 | from .evaluator import DatasetEvaluator, DatasetEvaluators, inference_context, inference_on_dataset 6 | from .lvis_evaluation import LVISEvaluator 7 | from .panoptic_evaluation import COCOPanopticEvaluator 8 | from .pascal_voc_evaluation import PascalVOCDetectionEvaluator 9 | from .sem_seg_evaluation import SemSegEvaluator 10 | from .testing import print_csv_format, verify_results 11 | 12 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 13 | -------------------------------------------------------------------------------- /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 | from .flatten import TracingAdapter 5 | from .torchscript import scripting_with_instances, dump_torchscript_IR 6 | 7 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 8 | -------------------------------------------------------------------------------- /detectron2/layers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 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 ( 10 | BatchNorm2d, 11 | Conv2d, 12 | ConvTranspose2d, 13 | cat, 14 | interpolate, 15 | Linear, 16 | nonzero_tuple, 17 | cross_entropy, 18 | ) 19 | from .blocks import CNNBlockBase, DepthwiseSeparableConv2d 20 | from .aspp import ASPP 21 | from .boundary import get_instances_contour_interior 22 | 23 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 24 | -------------------------------------------------------------------------------- /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. 2 | #pragma once 3 | #include 4 | 5 | namespace detectron2 { 6 | 7 | at::Tensor box_iou_rotated_cpu( 8 | const at::Tensor& boxes1, 9 | const at::Tensor& boxes2); 10 | 11 | #if defined(WITH_CUDA) || defined(WITH_HIP) 12 | at::Tensor box_iou_rotated_cuda( 13 | const at::Tensor& boxes1, 14 | const at::Tensor& boxes2); 15 | #endif 16 | 17 | // Interface for Python 18 | // inline is needed to prevent multiple function definitions when this header is 19 | // included by different cpps 20 | inline at::Tensor box_iou_rotated( 21 | const at::Tensor& boxes1, 22 | const at::Tensor& boxes2) { 23 | assert(boxes1.device().is_cuda() == boxes2.device().is_cuda()); 24 | if (boxes1.device().is_cuda()) { 25 | #if defined(WITH_CUDA) || defined(WITH_HIP) 26 | return box_iou_rotated_cuda(boxes1.contiguous(), boxes2.contiguous()); 27 | #else 28 | AT_ERROR("Detectron2 is not compiled with GPU support!"); 29 | #endif 30 | } 31 | 32 | return box_iou_rotated_cpu(boxes1.contiguous(), boxes2.contiguous()); 33 | } 34 | 35 | } // namespace detectron2 36 | -------------------------------------------------------------------------------- /detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cpu.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Facebook, Inc. and its affiliates. 2 | #include "box_iou_rotated.h" 3 | #include "box_iou_rotated_utils.h" 4 | 5 | namespace detectron2 { 6 | 7 | template 8 | void box_iou_rotated_cpu_kernel( 9 | const at::Tensor& boxes1, 10 | const at::Tensor& boxes2, 11 | at::Tensor& ious) { 12 | auto num_boxes1 = boxes1.size(0); 13 | auto num_boxes2 = boxes2.size(0); 14 | 15 | for (int i = 0; i < num_boxes1; i++) { 16 | for (int j = 0; j < num_boxes2; j++) { 17 | ious[i * num_boxes2 + j] = single_box_iou_rotated( 18 | boxes1[i].data_ptr(), boxes2[j].data_ptr()); 19 | } 20 | } 21 | } 22 | 23 | at::Tensor box_iou_rotated_cpu( 24 | // input must be contiguous: 25 | const at::Tensor& boxes1, 26 | const at::Tensor& boxes2) { 27 | auto num_boxes1 = boxes1.size(0); 28 | auto num_boxes2 = boxes2.size(0); 29 | at::Tensor ious = 30 | at::empty({num_boxes1 * num_boxes2}, boxes1.options().dtype(at::kFloat)); 31 | 32 | box_iou_rotated_cpu_kernel(boxes1, boxes2, ious); 33 | 34 | // reshape from 1d array to 2d array 35 | auto shape = std::vector{num_boxes1, num_boxes2}; 36 | return ious.reshape(shape); 37 | } 38 | 39 | } // namespace detectron2 40 | -------------------------------------------------------------------------------- /detectron2/layers/csrc/cuda_version.cu: -------------------------------------------------------------------------------- 1 | // Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | #include 4 | 5 | namespace detectron2 { 6 | int get_cudart_version() { 7 | // Not a ROCM platform: Either HIP is not used, or 8 | // it is used, but platform is not ROCM (i.e. it is CUDA) 9 | #if !defined(__HIP_PLATFORM_HCC__) 10 | return CUDART_VERSION; 11 | #else 12 | int version = 0; 13 | 14 | #if HIP_VERSION_MAJOR != 0 15 | // Create a convention similar to that of CUDA, as assumed by other 16 | // parts of the code. 17 | 18 | version = HIP_VERSION_MINOR; 19 | version += (HIP_VERSION_MAJOR * 100); 20 | #else 21 | hipRuntimeGetVersion(&version); 22 | #endif 23 | return version; 24 | #endif 25 | } 26 | } // namespace detectron2 27 | -------------------------------------------------------------------------------- /detectron2/layers/csrc/nms_rotated/nms_rotated.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Facebook, Inc. and its affiliates. 2 | #pragma once 3 | #include 4 | 5 | namespace detectron2 { 6 | 7 | at::Tensor nms_rotated_cpu( 8 | const at::Tensor& dets, 9 | const at::Tensor& scores, 10 | const double iou_threshold); 11 | 12 | #if defined(WITH_CUDA) || defined(WITH_HIP) 13 | at::Tensor nms_rotated_cuda( 14 | const at::Tensor& dets, 15 | const at::Tensor& scores, 16 | const double iou_threshold); 17 | #endif 18 | 19 | // Interface for Python 20 | // inline is needed to prevent multiple function definitions when this header is 21 | // included by different cpps 22 | inline at::Tensor nms_rotated( 23 | const at::Tensor& dets, 24 | const at::Tensor& scores, 25 | const double iou_threshold) { 26 | assert(dets.device().is_cuda() == scores.device().is_cuda()); 27 | if (dets.device().is_cuda()) { 28 | #if defined(WITH_CUDA) || defined(WITH_HIP) 29 | return nms_rotated_cuda( 30 | dets.contiguous(), scores.contiguous(), iou_threshold); 31 | #else 32 | AT_ERROR("Detectron2 is not compiled with GPU support!"); 33 | #endif 34 | } 35 | 36 | return nms_rotated_cpu(dets.contiguous(), scores.contiguous(), iou_threshold); 37 | } 38 | 39 | } // namespace detectron2 40 | -------------------------------------------------------------------------------- /detectron2/layers/rotated_boxes.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from __future__ import absolute_import, division, print_function, unicode_literals 3 | 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/scale.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch import nn 3 | 4 | 5 | class Scale(nn.Module): 6 | def __init__(self, init_value=1.0): 7 | super(Scale, self).__init__() 8 | self.scale = nn.Parameter(torch.FloatTensor([init_value])) 9 | 10 | def forward(self, input): 11 | return input * self.scale 12 | -------------------------------------------------------------------------------- /detectron2/layers/shape_spec.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | from collections import namedtuple 4 | 5 | 6 | class ShapeSpec(namedtuple("_ShapeSpec", ["channels", "height", "width", "stride"])): 7 | """ 8 | A simple structure that contains basic shape specification about a tensor. 9 | It is often used as the auxiliary inputs/outputs of models, 10 | to complement the lack of shape inference ability among pytorch modules. 11 | 12 | Attributes: 13 | channels: 14 | height: 15 | width: 16 | stride: 17 | """ 18 | 19 | def __new__(cls, channels=None, height=None, width=None, stride=None): 20 | return super().__new__(cls, channels, height, width, stride) 21 | -------------------------------------------------------------------------------- /detectron2/model_zoo/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | """ 3 | Model Zoo API for Detectron2: a collection of functions to create common model architectures 4 | listed in `MODEL_ZOO.md `_, 5 | and optionally load their pre-trained weights. 6 | """ 7 | 8 | from .model_zoo import get, get_config_file, get_checkpoint_url, get_config 9 | 10 | __all__ = ["get_checkpoint_url", "get", "get_config_file", "get_config"] 11 | -------------------------------------------------------------------------------- /detectron2/model_zoo/configs: -------------------------------------------------------------------------------- 1 | /cluster/project/cvl/leikel/detectron2-exp6/configs -------------------------------------------------------------------------------- /detectron2/modeling/backbone/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .build import build_backbone, BACKBONE_REGISTRY # noqa F401 isort:skip 3 | 4 | from .backbone import Backbone 5 | from .fpn import FPN 6 | from .regnet import RegNet 7 | from .resnet import ( 8 | BasicStem, 9 | ResNet, 10 | ResNetBlockBase, 11 | build_resnet_backbone, 12 | make_stage, 13 | BottleneckBlock, 14 | ) 15 | 16 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 17 | # TODO can expose more resnet blocks after careful consideration 18 | -------------------------------------------------------------------------------- /detectron2/modeling/backbone/build.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from detectron2.layers import ShapeSpec 3 | from detectron2.utils.registry import Registry 4 | 5 | from .backbone import Backbone 6 | 7 | BACKBONE_REGISTRY = Registry("BACKBONE") 8 | BACKBONE_REGISTRY.__doc__ = """ 9 | Registry for backbones, which extract feature maps from images 10 | 11 | The registered object must be a callable that accepts two arguments: 12 | 13 | 1. A :class:`detectron2.config.CfgNode` 14 | 2. A :class:`detectron2.layers.ShapeSpec`, which contains the input shape specification. 15 | 16 | Registered object must return instance of :class:`Backbone`. 17 | """ 18 | 19 | 20 | def build_backbone(cfg, input_shape=None): 21 | """ 22 | Build a backbone from `cfg.MODEL.BACKBONE.NAME`. 23 | 24 | Returns: 25 | an instance of :class:`Backbone` 26 | """ 27 | if input_shape is None: 28 | input_shape = ShapeSpec(channels=len(cfg.MODEL.PIXEL_MEAN)) 29 | 30 | backbone_name = cfg.MODEL.BACKBONE.NAME 31 | backbone = BACKBONE_REGISTRY.get(backbone_name)(cfg, input_shape) 32 | assert isinstance(backbone, Backbone) 33 | return backbone 34 | -------------------------------------------------------------------------------- /detectron2/modeling/meta_arch/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | 4 | from .build import META_ARCH_REGISTRY, build_model # isort:skip 5 | 6 | from .panoptic_fpn import PanopticFPN 7 | 8 | # import all the meta_arch, so they will be registered 9 | from .rcnn import GeneralizedRCNN, ProposalNetwork 10 | from .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. 2 | import torch 3 | 4 | from detectron2.utils.logger import _log_api_usage 5 | from detectron2.utils.registry import Registry 6 | 7 | META_ARCH_REGISTRY = Registry("META_ARCH") # noqa F401 isort:skip 8 | META_ARCH_REGISTRY.__doc__ = """ 9 | Registry for meta-architectures, i.e. the whole model. 10 | 11 | The registered object will be called with `obj(cfg)` 12 | and expected to return a `nn.Module` object. 13 | """ 14 | 15 | 16 | def build_model(cfg): 17 | """ 18 | Build the whole model architecture, defined by ``cfg.MODEL.META_ARCHITECTURE``. 19 | Note that it does not load any weights from ``cfg``. 20 | """ 21 | meta_arch = cfg.MODEL.META_ARCHITECTURE 22 | model = META_ARCH_REGISTRY.get(meta_arch)(cfg) 23 | model.to(torch.device(cfg.MODEL.DEVICE)) 24 | _log_api_usage("modeling.meta_arch." + meta_arch) 25 | return model 26 | -------------------------------------------------------------------------------- /detectron2/modeling/proposal_generator/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .build import PROPOSAL_GENERATOR_REGISTRY, build_proposal_generator 3 | from .rpn import RPN_HEAD_REGISTRY, build_rpn_head, RPN, StandardRPNHead 4 | 5 | __all__ = list(globals().keys()) 6 | -------------------------------------------------------------------------------- /detectron2/modeling/proposal_generator/build.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from detectron2.utils.registry import Registry 3 | 4 | PROPOSAL_GENERATOR_REGISTRY = Registry("PROPOSAL_GENERATOR") 5 | PROPOSAL_GENERATOR_REGISTRY.__doc__ = """ 6 | Registry for proposal generator, which produces object proposals from feature maps. 7 | 8 | The registered object will be called with `obj(cfg, input_shape)`. 9 | The call should return a `nn.Module` object. 10 | """ 11 | 12 | from . import rpn, rrpn # noqa F401 isort:skip 13 | 14 | 15 | def build_proposal_generator(cfg, input_shape): 16 | """ 17 | Build a proposal generator from `cfg.MODEL.PROPOSAL_GENERATOR.NAME`. 18 | The name can be "PrecomputedProposals" to use no proposal generator. 19 | """ 20 | name = cfg.MODEL.PROPOSAL_GENERATOR.NAME 21 | if name == "PrecomputedProposals": 22 | return None 23 | 24 | return PROPOSAL_GENERATOR_REGISTRY.get(name)(cfg, input_shape) 25 | -------------------------------------------------------------------------------- /detectron2/modeling/roi_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .box_head import ROI_BOX_HEAD_REGISTRY, build_box_head, FastRCNNConvFCHead 3 | from .keypoint_head import ( 4 | ROI_KEYPOINT_HEAD_REGISTRY, 5 | build_keypoint_head, 6 | BaseKeypointRCNNHead, 7 | KRCNNConvDeconvUpsampleHead, 8 | ) 9 | from .mask_head import ( 10 | ROI_MASK_HEAD_REGISTRY, 11 | build_mask_head, 12 | BaseMaskRCNNHead, 13 | MaskRCNNConvUpsampleHead, 14 | ) 15 | from .roi_heads import ( 16 | ROI_HEADS_REGISTRY, 17 | ROIHeads, 18 | Res5ROIHeads, 19 | StandardROIHeads, 20 | build_roi_heads, 21 | select_foreground_proposals, 22 | ) 23 | from .cascade_rcnn import CascadeROIHeads 24 | from .rotated_fast_rcnn import RROIHeads 25 | from .fast_rcnn import FastRCNNOutputLayers 26 | 27 | from . import cascade_rcnn # isort:skip 28 | 29 | __all__ = list(globals().keys()) 30 | -------------------------------------------------------------------------------- /detectron2/projects/README.md: -------------------------------------------------------------------------------- 1 | 2 | Projects live in the [`projects` directory](../../projects) under the root of this repository, but not here. 3 | -------------------------------------------------------------------------------- /detectron2/projects/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | import importlib 3 | from pathlib import Path 4 | 5 | _PROJECTS = { 6 | "point_rend": "PointRend", 7 | "deeplab": "DeepLab", 8 | "panoptic_deeplab": "Panoptic-DeepLab", 9 | } 10 | _PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent / "projects" 11 | 12 | if _PROJECT_ROOT.is_dir(): 13 | # This is true only for in-place installation (pip install -e, setup.py develop), 14 | # where setup(package_dir=) does not work: https://github.com/pypa/setuptools/issues/230 15 | 16 | class _D2ProjectsFinder(importlib.abc.MetaPathFinder): 17 | def find_spec(self, name, path, target=None): 18 | if not name.startswith("detectron2.projects."): 19 | return 20 | project_name = name.split(".")[-1] 21 | project_dir = _PROJECTS.get(project_name) 22 | if not project_dir: 23 | return 24 | target_file = _PROJECT_ROOT / f"{project_dir}/{project_name}/__init__.py" 25 | if not target_file.is_file(): 26 | return 27 | return importlib.util.spec_from_file_location(name, target_file) 28 | 29 | import sys 30 | 31 | sys.meta_path.append(_D2ProjectsFinder()) 32 | -------------------------------------------------------------------------------- /detectron2/solver/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .build import build_lr_scheduler, build_optimizer, get_default_optimizer_params 3 | from .lr_scheduler import WarmupCosineLR, WarmupMultiStepLR, LRMultiplier, WarmupParamScheduler 4 | 5 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 6 | -------------------------------------------------------------------------------- /detectron2/structures/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .boxes import Boxes, BoxMode, pairwise_iou, pairwise_ioa, pairwise_point_box_distance 3 | from .image_list import ImageList 4 | 5 | from .instances import Instances 6 | from .keypoints import Keypoints, heatmaps_to_keypoints 7 | from .masks import BitMasks, PolygonMasks, polygons_to_bitmask, ROIMasks 8 | from .rotated_boxes import RotatedBoxes 9 | from .rotated_boxes import pairwise_iou as pairwise_iou_rotated 10 | 11 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 12 | 13 | 14 | from detectron2.utils.env import fixup_module_metadata 15 | 16 | fixup_module_metadata(__name__, globals(), __all__) 17 | del fixup_module_metadata 18 | -------------------------------------------------------------------------------- /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. 2 | -------------------------------------------------------------------------------- /detectron2/utils/file_io.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from iopath.common.file_io import HTTPURLHandler, OneDrivePathHandler, PathHandler 3 | from iopath.common.file_io import PathManager as PathManagerBase 4 | 5 | __all__ = ["PathManager", "PathHandler"] 6 | 7 | 8 | PathManager = PathManagerBase() 9 | """ 10 | This is a detectron2 project-specific PathManager. 11 | We try to stay away from global PathManager in fvcore as it 12 | introduces potential conflicts among other libraries. 13 | """ 14 | 15 | 16 | class Detectron2Handler(PathHandler): 17 | """ 18 | Resolve anything that's hosted under detectron2's namespace. 19 | """ 20 | 21 | PREFIX = "detectron2://" 22 | S3_DETECTRON2_PREFIX = "https://dl.fbaipublicfiles.com/detectron2/" 23 | 24 | def _get_supported_prefixes(self): 25 | return [self.PREFIX] 26 | 27 | def _get_local_path(self, path, **kwargs): 28 | name = path[len(self.PREFIX) :] 29 | return PathManager.get_local_path(self.S3_DETECTRON2_PREFIX + name, **kwargs) 30 | 31 | def _open(self, path, mode="r", **kwargs): 32 | return PathManager.open(self._get_local_path(path), mode, **kwargs) 33 | 34 | 35 | PathManager.register_handler(HTTPURLHandler()) 36 | PathManager.register_handler(OneDrivePathHandler()) 37 | PathManager.register_handler(Detectron2Handler()) 38 | -------------------------------------------------------------------------------- /detectron2/utils/serialize.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | import cloudpickle 3 | 4 | 5 | class PicklableWrapper(object): 6 | """ 7 | Wrap an object to make it more picklable, note that it uses 8 | heavy weight serialization libraries that are slower than pickle. 9 | It's best to use it only on closures (which are usually not picklable). 10 | 11 | This is a simplified version of 12 | https://github.com/joblib/joblib/blob/master/joblib/externals/loky/cloudpickle_wrapper.py 13 | """ 14 | 15 | def __init__(self, obj): 16 | while isinstance(obj, PicklableWrapper): 17 | # Wrapping an object twice is no-op 18 | obj = obj._obj 19 | self._obj = obj 20 | 21 | def __reduce__(self): 22 | s = cloudpickle.dumps(self._obj) 23 | return cloudpickle.loads, (s,) 24 | 25 | def __call__(self, *args, **kwargs): 26 | return self._obj(*args, **kwargs) 27 | 28 | def __getattr__(self, attr): 29 | # Ensure that the wrapped object can be used seamlessly as the previous object. 30 | if attr not in ["_obj"]: 31 | return getattr(self._obj, attr) 32 | return getattr(self, attr) 33 | -------------------------------------------------------------------------------- /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. 3 | 4 | # Run this script at project root by "./dev/linter.sh" before you commit 5 | 6 | { 7 | black --version | grep -E "21.4b2" > /dev/null 8 | } || { 9 | echo "Linter requires 'black==21.4b2' !" 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.8 10 | # ./dev/packaging/build_wheel.sh 11 | ``` 12 | 13 | ## To build all wheels for combinations of CUDA and Python 14 | ``` 15 | ./dev/packaging/build_all_wheels.sh 16 | ./dev/packaging/gen_wheel_index.sh /path/to/wheels 17 | ``` 18 | -------------------------------------------------------------------------------- /dev/packaging/build_wheel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | set -ex 4 | 5 | ldconfig # https://github.com/NVIDIA/nvidia-docker/issues/854 6 | 7 | script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 8 | . "$script_dir/pkg_helpers.bash" 9 | 10 | echo "Build Settings:" 11 | echo "CU_VERSION: $CU_VERSION" # e.g. cu101 12 | echo "D2_VERSION_SUFFIX: $D2_VERSION_SUFFIX" # e.g. +cu101 or "" 13 | echo "PYTHON_VERSION: $PYTHON_VERSION" # e.g. 3.6 14 | echo "PYTORCH_VERSION: $PYTORCH_VERSION" # e.g. 1.4 15 | 16 | setup_cuda 17 | setup_wheel_python 18 | 19 | yum install ninja-build -y 20 | ln -sv /usr/bin/ninja-build /usr/bin/ninja || true 21 | 22 | pip_install pip numpy -U 23 | pip_install "torch==$PYTORCH_VERSION" \ 24 | -f https://download.pytorch.org/whl/"$CU_VERSION"/torch_stable.html 25 | 26 | # use separate directories to allow parallel build 27 | BASE_BUILD_DIR=build/$CU_VERSION-py$PYTHON_VERSION-pt$PYTORCH_VERSION 28 | python setup.py \ 29 | build -b "$BASE_BUILD_DIR" \ 30 | bdist_wheel -b "$BASE_BUILD_DIR/build_dist" -d "wheels/$CU_VERSION/torch$PYTORCH_VERSION" 31 | rm -rf "$BASE_BUILD_DIR" 32 | -------------------------------------------------------------------------------- /dev/run_instant_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | 4 | BIN="python tools/train_net.py" 5 | OUTPUT="instant_test_output" 6 | NUM_GPUS=2 7 | 8 | CFG_LIST=( "${@:1}" ) 9 | if [ ${#CFG_LIST[@]} -eq 0 ]; then 10 | CFG_LIST=( ./configs/quick_schedules/*instant_test.yaml ) 11 | fi 12 | 13 | echo "========================================================================" 14 | echo "Configs to run:" 15 | echo "${CFG_LIST[@]}" 16 | echo "========================================================================" 17 | 18 | for cfg in "${CFG_LIST[@]}"; do 19 | echo "========================================================================" 20 | echo "Running $cfg ..." 21 | echo "========================================================================" 22 | $BIN --num-gpus $NUM_GPUS --config-file "$cfg" \ 23 | SOLVER.IMS_PER_BATCH $(($NUM_GPUS * 2)) \ 24 | OUTPUT_DIR "$OUTPUT" 25 | rm -rf "$OUTPUT" 26 | done 27 | 28 | -------------------------------------------------------------------------------- /docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "2.3" 2 | services: 3 | detectron2: 4 | build: 5 | context: . 6 | dockerfile: Dockerfile 7 | args: 8 | USER_ID: ${USER_ID:-1000} 9 | deploy: 10 | resources: 11 | reservations: 12 | devices: 13 | - capabilities: 14 | - gpu 15 | shm_size: "8gb" 16 | ulimits: 17 | memlock: -1 18 | stack: 67108864 19 | volumes: 20 | - /tmp/.X11-unix:/tmp/.X11-unix:ro 21 | environment: 22 | - DISPLAY=$DISPLAY 23 | - NVIDIA_VISIBLE_DEVICES=all 24 | # Uncomment with proper source to access webcam from docker 25 | # devices: 26 | # - /dev/video0:/dev/video0 27 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SOURCEDIR = . 8 | BUILDDIR = _build 9 | 10 | # Put it first so that "make" without argument is like "make help". 11 | help: 12 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 13 | 14 | .PHONY: help Makefile 15 | 16 | # Catch-all target: route all unknown targets to Sphinx using the new 17 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 18 | %: Makefile 19 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 20 | -------------------------------------------------------------------------------- /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](https://github.com/facebookresearch/detectron2/blob/master/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 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * some extra css to make markdown look similar between github/sphinx 4 | */ 5 | 6 | /* 7 | * Below is for install.md: 8 | */ 9 | .rst-content code { 10 | white-space: pre; 11 | border: 0px; 12 | } 13 | 14 | .rst-content th { 15 | border: 1px solid #e1e4e5; 16 | } 17 | 18 | .rst-content th p { 19 | /* otherwise will be default 24px for regular paragraph */ 20 | margin-bottom: 0px; 21 | } 22 | 23 | .rst-content .line-block { 24 | /* otherwise will be 24px */ 25 | margin-bottom: 0px; 26 | } 27 | 28 | div.section > details { 29 | padding-bottom: 1em; 30 | } 31 | -------------------------------------------------------------------------------- /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 2 | ============================= 3 | 4 | .. automodule:: detectron2.checkpoint 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/modules/config.rst: -------------------------------------------------------------------------------- 1 | detectron2.config 2 | ========================= 3 | 4 | Related tutorials: :doc:`../tutorials/configs`, :doc:`../tutorials/extend`. 5 | 6 | .. automodule:: detectron2.config 7 | :members: 8 | :undoc-members: 9 | :show-inheritance: 10 | 11 | 12 | Yaml Config References 13 | ----------------- 14 | 15 | .. literalinclude:: ../../detectron2/config/defaults.py 16 | :language: python 17 | :linenos: 18 | :lines: 7- 19 | -------------------------------------------------------------------------------- /docs/modules/data.rst: -------------------------------------------------------------------------------- 1 | detectron2.data 2 | ======================= 3 | 4 | .. autodata:: detectron2.data.DatasetCatalog(dict) 5 | :annotation: 6 | 7 | .. autodata:: detectron2.data.MetadataCatalog(dict) 8 | :annotation: 9 | 10 | .. automodule:: detectron2.data 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | detectron2.data.detection\_utils module 16 | --------------------------------------- 17 | 18 | .. automodule:: detectron2.data.detection_utils 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | detectron2.data.datasets module 24 | --------------------------------------- 25 | 26 | .. automodule:: detectron2.data.datasets 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | detectron2.data.samplers module 32 | --------------------------------------- 33 | 34 | .. automodule:: detectron2.data.samplers 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | -------------------------------------------------------------------------------- /docs/modules/data_transforms.rst: -------------------------------------------------------------------------------- 1 | detectron2.data.transforms 2 | ==================================== 3 | 4 | Related tutorial: :doc:`../tutorials/augmentation`. 5 | 6 | .. automodule:: detectron2.data.transforms 7 | :members: 8 | :undoc-members: 9 | :show-inheritance: 10 | :imported-members: 11 | -------------------------------------------------------------------------------- /docs/modules/engine.rst: -------------------------------------------------------------------------------- 1 | detectron2.engine 2 | ========================= 3 | 4 | Related tutorial: :doc:`../tutorials/training`. 5 | 6 | .. automodule:: detectron2.engine 7 | :members: 8 | :undoc-members: 9 | :show-inheritance: 10 | 11 | 12 | detectron2.engine.defaults module 13 | --------------------------------- 14 | 15 | .. automodule:: detectron2.engine.defaults 16 | :members: 17 | :undoc-members: 18 | :show-inheritance: 19 | 20 | detectron2.engine.hooks module 21 | --------------------------------- 22 | 23 | .. automodule:: detectron2.engine.hooks 24 | :members: 25 | :undoc-members: 26 | :show-inheritance: 27 | -------------------------------------------------------------------------------- /docs/modules/evaluation.rst: -------------------------------------------------------------------------------- 1 | detectron2.evaluation 2 | ============================= 3 | 4 | .. automodule:: detectron2.evaluation 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/modules/export.rst: -------------------------------------------------------------------------------- 1 | detectron2.export 2 | ========================= 3 | 4 | Related tutorial: :doc:`../tutorials/deployment`. 5 | 6 | .. automodule:: detectron2.export 7 | :members: 8 | :undoc-members: 9 | :show-inheritance: 10 | -------------------------------------------------------------------------------- /docs/modules/fvcore.rst: -------------------------------------------------------------------------------- 1 | fvcore documentation 2 | ==================== 3 | 4 | Detectron2 depends on utilities in 5 | `fvcore `_. 6 | We include part of fvcore documentation here for easier reference. 7 | 8 | fvcore.nn 9 | ----------------- 10 | 11 | .. automodule:: fvcore.nn 12 | :members: 13 | :inherited-members: 14 | :undoc-members: 15 | :show-inheritance: 16 | 17 | fvcore.common 18 | --------------------- 19 | 20 | .. automodule:: fvcore.common.checkpoint 21 | :members: 22 | :undoc-members: 23 | :show-inheritance: 24 | 25 | .. automodule:: fvcore.common.config 26 | :members: 27 | :undoc-members: 28 | :show-inheritance: 29 | 30 | .. automodule:: fvcore.common.history_buffer 31 | :members: 32 | :undoc-members: 33 | :show-inheritance: 34 | 35 | .. automodule:: fvcore.common.param_scheduler 36 | :members: 37 | :inherited-members: 38 | :undoc-members: 39 | :show-inheritance: 40 | 41 | .. automodule:: fvcore.common.registry 42 | :members: 43 | :undoc-members: 44 | :show-inheritance: 45 | 46 | .. automodule:: fvcore.common.timer 47 | :members: 48 | :undoc-members: 49 | :show-inheritance: 50 | -------------------------------------------------------------------------------- /docs/modules/index.rst: -------------------------------------------------------------------------------- 1 | API Documentation 2 | ================== 3 | 4 | .. toctree:: 5 | 6 | checkpoint 7 | config 8 | data 9 | data_transforms 10 | engine 11 | evaluation 12 | layers 13 | model_zoo 14 | modeling 15 | solver 16 | structures 17 | utils 18 | export 19 | fvcore 20 | -------------------------------------------------------------------------------- /docs/modules/layers.rst: -------------------------------------------------------------------------------- 1 | detectron2.layers 2 | ========================= 3 | 4 | .. automodule:: detectron2.layers 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/modules/model_zoo.rst: -------------------------------------------------------------------------------- 1 | detectron2.model_zoo 2 | ============================ 3 | 4 | .. automodule:: detectron2.model_zoo 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/modules/solver.rst: -------------------------------------------------------------------------------- 1 | detectron2.solver 2 | ========================= 3 | 4 | .. automodule:: detectron2.solver 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/modules/structures.rst: -------------------------------------------------------------------------------- 1 | detectron2.structures 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 | docutils==0.16 2 | # https://github.com/sphinx-doc/sphinx/commit/7acd3ada3f38076af7b2b5c9f3b60bb9c2587a3d 3 | sphinx==3.2.0 4 | recommonmark==0.6.0 5 | sphinx_rtd_theme 6 | # Dependencies here are only those required by import 7 | termcolor 8 | numpy 9 | tqdm 10 | matplotlib 11 | termcolor 12 | yacs 13 | tabulate 14 | cloudpickle 15 | Pillow 16 | future 17 | git+git://github.com/facebookresearch/fvcore.git 18 | https://download.pytorch.org/whl/cpu/torch-1.7.0%2Bcpu-cp37-cp37m-linux_x86_64.whl 19 | https://download.pytorch.org/whl/cpu/torchvision-0.8.1%2Bcpu-cp37-cp37m-linux_x86_64.whl 20 | omegaconf>=2.1.0.dev24 21 | hydra-core>=1.1.0.dev5 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 | augmentation 14 | models 15 | write-models 16 | training 17 | evaluation 18 | configs 19 | lazyconfigs 20 | deployment 21 | -------------------------------------------------------------------------------- /docs/tutorials/install.md: -------------------------------------------------------------------------------- 1 | ../../INSTALL.md -------------------------------------------------------------------------------- /docs/tutorials/lazyconfig.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/docs/tutorials/lazyconfig.jpg -------------------------------------------------------------------------------- /figures/case-a1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/figures/case-a1.gif -------------------------------------------------------------------------------- /figures/case-a2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/figures/case-a2.gif -------------------------------------------------------------------------------- /figures/case-a3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/figures/case-a3.gif -------------------------------------------------------------------------------- /figures/case-a6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/figures/case-a6.gif -------------------------------------------------------------------------------- /figures/mask_transfiner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/figures/mask_transfiner.gif -------------------------------------------------------------------------------- /figures/mask_transfiner_banner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/figures/mask_transfiner_banner.gif -------------------------------------------------------------------------------- /figures/transfiner-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/figures/transfiner-banner.png -------------------------------------------------------------------------------- /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 | MIN_SIZE_TRAIN: (512, 768, 1024, 1280, 1536, 1792, 2048) 26 | MIN_SIZE_TRAIN_SAMPLING: "choice" 27 | MIN_SIZE_TEST: 1024 28 | MAX_SIZE_TRAIN: 4096 29 | MAX_SIZE_TEST: 2048 30 | CROP: 31 | ENABLED: True 32 | TYPE: "absolute" 33 | SIZE: (512, 1024) 34 | SINGLE_CATEGORY_MAX_AREA: 1.0 35 | DATALOADER: 36 | NUM_WORKERS: 10 37 | -------------------------------------------------------------------------------- /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 | INPUT: 19 | FORMAT: "RGB" 20 | -------------------------------------------------------------------------------- /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 | INPUT: 24 | FORMAT: "RGB" 25 | -------------------------------------------------------------------------------- /projects/DeepLab/deeplab/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 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. 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. 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 | cfg.MODEL.SEM_SEG_HEAD.USE_DEPTHWISE_SEPARABLE_CONV = False 24 | # Backbone new configs 25 | cfg.MODEL.RESNETS.RES4_DILATION = 1 26 | cfg.MODEL.RESNETS.RES5_MULTI_GRID = [1, 2, 4] 27 | # ResNet stem type from: `basic`, `deeplab` 28 | cfg.MODEL.RESNETS.STEM_TYPE = "deeplab" 29 | -------------------------------------------------------------------------------- /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/cse/Base-DensePose-RCNN-FPN-Human.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | ROI_DENSEPOSE_HEAD: 4 | CSE: 5 | EMBEDDERS: 6 | "smpl_27554": 7 | TYPE: vertex_feature 8 | NUM_VERTICES: 27554 9 | FEATURE_DIM: 256 10 | FEATURES_TRAINABLE: False 11 | IS_TRAINABLE: True 12 | INIT_FILE: "https://dl.fbaipublicfiles.com/densepose/data/cse/lbo/phi_smpl_27554_256.pkl" 13 | DATASETS: 14 | TRAIN: 15 | - "densepose_coco_2014_train_cse" 16 | - "densepose_coco_2014_valminusminival_cse" 17 | TEST: 18 | - "densepose_coco_2014_minival_cse" 19 | CLASS_TO_MESH_NAME_MAPPING: 20 | "0": "smpl_27554" 21 | -------------------------------------------------------------------------------- /projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_DL_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN-Human.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | ROI_DENSEPOSE_HEAD: 7 | NAME: "DensePoseDeepLabHead" 8 | CSE: 9 | EMBED_LOSS_NAME: "EmbeddingLoss" 10 | SOLVER: 11 | MAX_ITER: 130000 12 | STEPS: (100000, 120000) 13 | -------------------------------------------------------------------------------- /projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_DL_soft_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN-Human.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | ROI_DENSEPOSE_HEAD: 7 | NAME: "DensePoseDeepLabHead" 8 | CSE: 9 | EMBED_LOSS_NAME: "SoftEmbeddingLoss" 10 | SOLVER: 11 | MAX_ITER: 130000 12 | STEPS: (100000, 120000) 13 | -------------------------------------------------------------------------------- /projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN-Human.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | ROI_DENSEPOSE_HEAD: 7 | NAME: "DensePoseV1ConvXHead" 8 | CSE: 9 | EMBED_LOSS_NAME: "EmbeddingLoss" 10 | SOLVER: 11 | MAX_ITER: 130000 12 | STEPS: (100000, 120000) 13 | -------------------------------------------------------------------------------- /projects/DensePose/configs/cse/densepose_rcnn_R_101_FPN_soft_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN-Human.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | RESNETS: 5 | DEPTH: 101 6 | ROI_DENSEPOSE_HEAD: 7 | NAME: "DensePoseV1ConvXHead" 8 | CSE: 9 | EMBED_LOSS_NAME: "SoftEmbeddingLoss" 10 | SOLVER: 11 | MAX_ITER: 130000 12 | STEPS: (100000, 120000) 13 | -------------------------------------------------------------------------------- /projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_DL_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN-Human.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | ROI_DENSEPOSE_HEAD: 7 | NAME: "DensePoseDeepLabHead" 8 | CSE: 9 | EMBED_LOSS_NAME: "EmbeddingLoss" 10 | SOLVER: 11 | MAX_ITER: 130000 12 | STEPS: (100000, 120000) 13 | -------------------------------------------------------------------------------- /projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_DL_soft_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN-Human.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | ROI_DENSEPOSE_HEAD: 7 | NAME: "DensePoseDeepLabHead" 8 | CSE: 9 | EMBED_LOSS_NAME: "SoftEmbeddingLoss" 10 | SOLVER: 11 | MAX_ITER: 130000 12 | STEPS: (100000, 120000) 13 | -------------------------------------------------------------------------------- /projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN-Human.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | ROI_DENSEPOSE_HEAD: 7 | NAME: "DensePoseV1ConvXHead" 8 | CSE: 9 | EMBED_LOSS_NAME: "EmbeddingLoss" 10 | SOLVER: 11 | MAX_ITER: 130000 12 | STEPS: (100000, 120000) 13 | -------------------------------------------------------------------------------- /projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_chimps_finetune_4k.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "https://dl.fbaipublicfiles.com/densepose/cse/densepose_rcnn_R_50_FPN_soft_s1x/250533982/model_final_2c4512.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | ROI_DENSEPOSE_HEAD: 7 | NAME: "DensePoseV1ConvXHead" 8 | CSE: 9 | EMBED_LOSS_NAME: "SoftEmbeddingLoss" 10 | EMBEDDING_DIST_GAUSS_SIGMA: 0.1 11 | GEODESIC_DIST_GAUSS_SIGMA: 0.1 12 | EMBEDDERS: 13 | "chimp_5029": 14 | TYPE: vertex_feature 15 | NUM_VERTICES: 5029 16 | FEATURE_DIM: 256 17 | FEATURES_TRAINABLE: False 18 | IS_TRAINABLE: True 19 | INIT_FILE: "https://dl.fbaipublicfiles.com/densepose/data/cse/lbo/phi_chimp_5029_256.pkl" 20 | DATASETS: 21 | TRAIN: 22 | - "densepose_chimps_cse_train" 23 | TEST: 24 | - "densepose_chimps_cse_val" 25 | CLASS_TO_MESH_NAME_MAPPING: 26 | "0": "chimp_5029" 27 | SOLVER: 28 | MAX_ITER: 4000 29 | STEPS: (3000, 3500) 30 | -------------------------------------------------------------------------------- /projects/DensePose/configs/cse/densepose_rcnn_R_50_FPN_soft_s1x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-DensePose-RCNN-FPN-Human.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | RESNETS: 5 | DEPTH: 50 6 | ROI_DENSEPOSE_HEAD: 7 | NAME: "DensePoseV1ConvXHead" 8 | CSE: 9 | EMBED_LOSS_NAME: "SoftEmbeddingLoss" 10 | SOLVER: 11 | MAX_ITER: 130000 12 | STEPS: (100000, 120000) 13 | -------------------------------------------------------------------------------- /projects/DensePose/configs/densepose_rcnn_R_101_FPN_DL_WC1M_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 | SEGM_CONFIDENCE: 12 | ENABLED: True 13 | POINT_REGRESSION_WEIGHTS: 0.0005 14 | SOLVER: 15 | CLIP_GRADIENTS: 16 | ENABLED: True 17 | MAX_ITER: 130000 18 | STEPS: (100000, 120000) 19 | -------------------------------------------------------------------------------- /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_WC2M_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 | SEGM_CONFIDENCE: 12 | ENABLED: True 13 | POINT_REGRESSION_WEIGHTS: 0.0005 14 | SOLVER: 15 | CLIP_GRADIENTS: 16 | ENABLED: True 17 | MAX_ITER: 130000 18 | STEPS: (100000, 120000) 19 | -------------------------------------------------------------------------------- /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_WC1M_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 | SEGM_CONFIDENCE: 11 | ENABLED: True 12 | POINT_REGRESSION_WEIGHTS: 0.0005 13 | SOLVER: 14 | CLIP_GRADIENTS: 15 | ENABLED: True 16 | MAX_ITER: 130000 17 | STEPS: (100000, 120000) 18 | WARMUP_FACTOR: 0.025 19 | -------------------------------------------------------------------------------- /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_WC2M_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 | SEGM_CONFIDENCE: 11 | ENABLED: True 12 | POINT_REGRESSION_WEIGHTS: 0.0005 13 | SOLVER: 14 | CLIP_GRADIENTS: 15 | ENABLED: True 16 | MAX_ITER: 130000 17 | STEPS: (100000, 120000) 18 | WARMUP_FACTOR: 0.025 19 | -------------------------------------------------------------------------------- /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_WC1M_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 | SEGM_CONFIDENCE: 12 | ENABLED: True 13 | POINT_REGRESSION_WEIGHTS: 0.0005 14 | SOLVER: 15 | CLIP_GRADIENTS: 16 | ENABLED: True 17 | MAX_ITER: 130000 18 | STEPS: (100000, 120000) 19 | -------------------------------------------------------------------------------- /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_WC2M_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 | SEGM_CONFIDENCE: 12 | ENABLED: True 13 | POINT_REGRESSION_WEIGHTS: 0.0005 14 | SOLVER: 15 | CLIP_GRADIENTS: 16 | ENABLED: True 17 | MAX_ITER: 130000 18 | STEPS: (100000, 120000) 19 | -------------------------------------------------------------------------------- /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_WC1M_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 | SEGM_CONFIDENCE: 11 | ENABLED: True 12 | POINT_REGRESSION_WEIGHTS: 0.0005 13 | SOLVER: 14 | CLIP_GRADIENTS: 15 | ENABLED: True 16 | CLIP_TYPE: norm 17 | CLIP_VALUE: 100.0 18 | MAX_ITER: 130000 19 | STEPS: (100000, 120000) 20 | WARMUP_FACTOR: 0.025 21 | -------------------------------------------------------------------------------- /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_WC2M_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 | SEGM_CONFIDENCE: 11 | ENABLED: True 12 | POINT_REGRESSION_WEIGHTS: 0.0005 13 | SOLVER: 14 | CLIP_GRADIENTS: 15 | ENABLED: True 16 | MAX_ITER: 130000 17 | STEPS: (100000, 120000) 18 | WARMUP_FACTOR: 0.025 19 | -------------------------------------------------------------------------------- /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_50_FPN_DL_WC1M_3x_Atop10P_CA.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-FPN-Atop10P_CA.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 | MAX_ITER: 270000 28 | STEPS: (210000, 250000) 29 | -------------------------------------------------------------------------------- /projects/DensePose/configs/quick_schedules/cse/densepose_rcnn_R_50_FPN_DL_instant_test.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../cse/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_cse",) 8 | TEST: ("densepose_coco_2014_minival_100_cse",) 9 | SOLVER: 10 | MAX_ITER: 40 11 | STEPS: (30,) 12 | -------------------------------------------------------------------------------- /projects/DensePose/configs/quick_schedules/densepose_rcnn_HRFPN_HRNet_w32_instant_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 | IMS_PER_BATCH: 2 9 | -------------------------------------------------------------------------------- /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.59, 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.09, 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. 2 | from .data.datasets import builtin # just to register data 3 | from .converters import builtin as builtin_converters # register converters 4 | from .config import ( 5 | add_densepose_config, 6 | add_densepose_head_config, 7 | add_hrnet_config, 8 | add_dataset_category_config, 9 | add_bootstrap_config, 10 | load_bootstrap_config, 11 | ) 12 | from .structures import DensePoseDataRelative, DensePoseList, DensePoseTransformData 13 | from .evaluation import DensePoseCOCOEvaluator 14 | from .modeling.roi_heads import DensePoseROIHeads 15 | from .modeling.test_time_augmentation import ( 16 | DensePoseGeneralizedRCNNWithTTA, 17 | DensePoseDatasetMapperTTA, 18 | ) 19 | from .utils.transform import load_from_cfg 20 | from .modeling.hrfpn import build_hrfpn_backbone 21 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/converters/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from .hflip import HFlipConverter 4 | from .to_mask import ToMaskConverter 5 | from .to_chart_result import ToChartResultConverter, ToChartResultConverterWithConfidences 6 | from .segm_to_mask import ( 7 | predictor_output_with_fine_and_coarse_segm_to_mask, 8 | predictor_output_with_coarse_segm_to_mask, 9 | resample_fine_and_coarse_segm_to_bbox, 10 | ) 11 | from .chart_output_to_chart_result import ( 12 | densepose_chart_predictor_output_to_result, 13 | densepose_chart_predictor_output_to_result_with_confidences, 14 | ) 15 | from .chart_output_hflip import densepose_chart_predictor_output_hflip 16 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/converters/builtin.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from ..structures import DensePoseChartPredictorOutput, DensePoseEmbeddingPredictorOutput 4 | from . import ( 5 | HFlipConverter, 6 | ToChartResultConverter, 7 | ToChartResultConverterWithConfidences, 8 | ToMaskConverter, 9 | densepose_chart_predictor_output_hflip, 10 | densepose_chart_predictor_output_to_result, 11 | densepose_chart_predictor_output_to_result_with_confidences, 12 | predictor_output_with_coarse_segm_to_mask, 13 | predictor_output_with_fine_and_coarse_segm_to_mask, 14 | ) 15 | 16 | ToMaskConverter.register( 17 | DensePoseChartPredictorOutput, predictor_output_with_fine_and_coarse_segm_to_mask 18 | ) 19 | ToMaskConverter.register( 20 | DensePoseEmbeddingPredictorOutput, predictor_output_with_coarse_segm_to_mask 21 | ) 22 | 23 | ToChartResultConverter.register( 24 | DensePoseChartPredictorOutput, densepose_chart_predictor_output_to_result 25 | ) 26 | 27 | ToChartResultConverterWithConfidences.register( 28 | DensePoseChartPredictorOutput, densepose_chart_predictor_output_to_result_with_confidences 29 | ) 30 | 31 | HFlipConverter.register(DensePoseChartPredictorOutput, densepose_chart_predictor_output_hflip) 32 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/converters/hflip.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from typing import Any 4 | 5 | from .base import BaseConverter 6 | 7 | 8 | class HFlipConverter(BaseConverter): 9 | """ 10 | Converts various DensePose predictor outputs to DensePose results. 11 | Each DensePose predictor output type has to register its convertion strategy. 12 | """ 13 | 14 | registry = {} 15 | dst_type = None 16 | 17 | @classmethod 18 | def convert(cls, predictor_outputs: Any, transform_data: Any, *args, **kwargs): 19 | """ 20 | Performs an horizontal flip on DensePose predictor outputs. 21 | Does recursive lookup for base classes, so there's no need 22 | for explicit registration for derived classes. 23 | 24 | Args: 25 | predictor_outputs: DensePose predictor output to be converted to BitMasks 26 | transform_data: Anything useful for the flip 27 | Return: 28 | An instance of the same type as predictor_outputs 29 | """ 30 | return super(HFlipConverter, cls).convert( 31 | predictor_outputs, transform_data, *args, **kwargs 32 | ) 33 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from .meshes import builtin 4 | from .build import ( 5 | build_detection_test_loader, 6 | build_detection_train_loader, 7 | build_combined_loader, 8 | build_frame_selector, 9 | build_inference_based_loaders, 10 | has_inference_based_loaders, 11 | BootstrapDatasetFactoryCatalog, 12 | ) 13 | from .combined_loader import CombinedDataLoader 14 | from .dataset_mapper import DatasetMapper 15 | from .inference_based_loader import InferenceBasedLoader, ScoreBasedFilter 16 | from .image_list_dataset import ImageListDataset 17 | from .utils import is_relative_local_path, maybe_prepend_base_path 18 | 19 | # ensure the builtin datasets are registered 20 | from . import datasets 21 | 22 | # ensure the bootstrap datasets builders are registered 23 | from . import build 24 | 25 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 26 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 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. 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 | from .lvis import DATASETS as LVIS_DATASETS 7 | from .lvis import register_datasets as register_lvis_datasets 8 | 9 | DEFAULT_DATASETS_ROOT = "datasets" 10 | 11 | 12 | register_coco_datasets(COCO_DATASETS, DEFAULT_DATASETS_ROOT) 13 | register_coco_datasets(BASE_COCO_DATASETS, DEFAULT_DATASETS_ROOT) 14 | register_lvis_datasets(LVIS_DATASETS, DEFAULT_DATASETS_ROOT) 15 | 16 | register_chimpnsee_dataset(DEFAULT_DATASETS_ROOT) # pyre-ignore[19] 17 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/datasets/chimpnsee.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from typing import Optional 4 | 5 | from detectron2.data import DatasetCatalog, MetadataCatalog 6 | 7 | from ..utils import maybe_prepend_base_path 8 | from .dataset_type import DatasetType 9 | 10 | CHIMPNSEE_DATASET_NAME = "chimpnsee" 11 | 12 | 13 | def register_dataset(datasets_root: Optional[str] = None): 14 | def empty_load_callback(): 15 | pass 16 | 17 | video_list_fpath = maybe_prepend_base_path( 18 | datasets_root, 19 | "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 | category="chimpanzee", 29 | ) 30 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/datasets/dataset_type.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 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/meshes/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | from . import builtin 4 | 5 | __all__ = [k for k in globals().keys() if "builtin" not in k and not k.startswith("_")] 6 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/samplers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from .densepose_uniform import DensePoseUniformSampler 4 | from .densepose_confidence_based import DensePoseConfidenceBasedSampler 5 | from .densepose_cse_uniform import DensePoseCSEUniformSampler 6 | from .densepose_cse_confidence_based import DensePoseCSEConfidenceBasedSampler 7 | from .mask_from_densepose import MaskFromDensePoseSampler 8 | from .prediction_to_gt import PredictionToGroundTruthSampler 9 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/samplers/densepose_cse_uniform.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from .densepose_cse_base import DensePoseCSEBaseSampler 4 | from .densepose_uniform import DensePoseUniformSampler 5 | 6 | 7 | class DensePoseCSEUniformSampler(DensePoseCSEBaseSampler, DensePoseUniformSampler): 8 | """ 9 | Uniform Sampler for CSE 10 | """ 11 | 12 | pass 13 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/samplers/mask_from_densepose.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from detectron2.structures import BitMasks, Instances 4 | 5 | from densepose.converters import ToMaskConverter 6 | 7 | 8 | class MaskFromDensePoseSampler: 9 | """ 10 | Produce mask GT from DensePose predictions 11 | This sampler simply converts DensePose predictions to BitMasks 12 | that a contain a bool tensor of the size of the input image 13 | """ 14 | 15 | def __call__(self, instances: Instances) -> BitMasks: 16 | """ 17 | Converts predicted data from `instances` into the GT mask data 18 | 19 | Args: 20 | instances (Instances): predicted results, expected to have `pred_densepose` field 21 | 22 | Returns: 23 | Boolean Tensor of the size of the input image that has non-zero 24 | values at pixels that are estimated to belong to the detected object 25 | """ 26 | return ToMaskConverter.convert( 27 | instances.pred_densepose, instances.pred_boxes, instances.image_size 28 | ) 29 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/transform/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from .image import ImageResizeTransform 4 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | import os 4 | from typing import Dict, Optional 5 | 6 | from detectron2.config import CfgNode 7 | 8 | 9 | def is_relative_local_path(path: str): 10 | path_str = os.fsdecode(path) 11 | return ("://" not in path_str) and not os.path.isabs(path) 12 | 13 | 14 | def maybe_prepend_base_path(base_path: Optional[str], path: str): 15 | """ 16 | Prepends the provided path with a base path prefix if: 17 | 1) base path is not None; 18 | 2) path is a local path 19 | """ 20 | if base_path is None: 21 | return path 22 | if is_relative_local_path(path): 23 | return os.path.join(base_path, path) 24 | return path 25 | 26 | 27 | def get_class_to_mesh_name_mapping(cfg: CfgNode) -> Dict[int, str]: 28 | return { 29 | int(class_id): mesh_name 30 | for class_id, mesh_name in cfg.DATASETS.CLASS_TO_MESH_NAME_MAPPING.items() 31 | } 32 | 33 | 34 | def get_category_to_class_mapping(dataset_cfg: CfgNode) -> Dict[str, int]: 35 | return { 36 | category: int(class_id) 37 | for category, class_id in dataset_cfg.CATEGORY_TO_CLASS_MAPPING.items() 38 | } 39 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/data/video/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 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. 2 | 3 | from .trainer import Trainer 4 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from .evaluator import DensePoseCOCOEvaluator 4 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/modeling/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from .confidence import DensePoseConfidenceModelConfig, DensePoseUVConfidenceType 4 | from .filter import DensePoseDataFilter 5 | from .inference import densepose_inference 6 | from .utils import initialize_module_params 7 | from .build import ( 8 | build_densepose_data_filter, 9 | build_densepose_embedder, 10 | build_densepose_head, 11 | build_densepose_losses, 12 | build_densepose_predictor, 13 | ) 14 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/modeling/cse/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | 3 | from .vertex_direct_embedder import VertexDirectEmbedder 4 | from .vertex_feature_embedder import VertexFeatureEmbedder 5 | from .embedder import Embedder 6 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/modeling/losses/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from .chart import DensePoseChartLoss 4 | from .chart_with_confidences import DensePoseChartWithConfidenceLoss 5 | from .cse import DensePoseCseLoss 6 | from .registry import DENSEPOSE_LOSS_REGISTRY 7 | 8 | 9 | __all__ = [ 10 | "DensePoseChartLoss", 11 | "DensePoseChartWithConfidenceLoss", 12 | "DensePoseCseLoss", 13 | "DENSEPOSE_LOSS_REGISTRY", 14 | ] 15 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/modeling/losses/registry.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from detectron2.utils.registry import Registry 4 | 5 | DENSEPOSE_LOSS_REGISTRY = Registry("DENSEPOSE_LOSS") 6 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/modeling/predictors/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from .chart import DensePoseChartPredictor 4 | from .chart_confidence import DensePoseChartConfidencePredictorMixin 5 | from .chart_with_confidence import DensePoseChartWithConfidencePredictor 6 | from .cse import DensePoseEmbeddingPredictor 7 | from .cse_confidence import DensePoseEmbeddingConfidencePredictorMixin 8 | from .cse_with_confidence import DensePoseEmbeddingWithConfidencePredictor 9 | from .registry import DENSEPOSE_PREDICTOR_REGISTRY 10 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/modeling/predictors/chart_with_confidence.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from . import DensePoseChartConfidencePredictorMixin, DensePoseChartPredictor 4 | from .registry import DENSEPOSE_PREDICTOR_REGISTRY 5 | 6 | 7 | @DENSEPOSE_PREDICTOR_REGISTRY.register() 8 | class DensePoseChartWithConfidencePredictor( 9 | DensePoseChartConfidencePredictorMixin, DensePoseChartPredictor 10 | ): 11 | """ 12 | Predictor that combines chart and chart confidence estimation 13 | """ 14 | 15 | pass 16 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/modeling/predictors/cse_with_confidence.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from . import DensePoseEmbeddingConfidencePredictorMixin, DensePoseEmbeddingPredictor 4 | from .registry import DENSEPOSE_PREDICTOR_REGISTRY 5 | 6 | 7 | @DENSEPOSE_PREDICTOR_REGISTRY.register() 8 | class DensePoseEmbeddingWithConfidencePredictor( 9 | DensePoseEmbeddingConfidencePredictorMixin, DensePoseEmbeddingPredictor 10 | ): 11 | """ 12 | Predictor that combines CSE and CSE confidence estimation 13 | """ 14 | 15 | pass 16 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/modeling/predictors/registry.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from detectron2.utils.registry import Registry 4 | 5 | DENSEPOSE_PREDICTOR_REGISTRY = Registry("DENSEPOSE_PREDICTOR") 6 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/modeling/roi_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from .v1convx import DensePoseV1ConvXHead 4 | from .deeplab import DensePoseDeepLabHead 5 | from .registry import ROI_DENSEPOSE_HEAD_REGISTRY 6 | from .roi_head import Decoder, DensePoseROIHeads 7 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/modeling/roi_heads/registry.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from detectron2.utils.registry import Registry 4 | 5 | ROI_DENSEPOSE_HEAD_REGISTRY = Registry("ROI_DENSEPOSE_HEAD") 6 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/modeling/utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from torch import nn 4 | 5 | 6 | def initialize_module_params(module: nn.Module): 7 | for name, param in module.named_parameters(): 8 | if "bias" in name: 9 | nn.init.constant_(param, 0) 10 | elif "weight" in name: 11 | nn.init.kaiming_normal_(param, mode="fan_out", nonlinearity="relu") 12 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/structures/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | from .chart import DensePoseChartPredictorOutput 4 | from .chart_confidence import decorate_predictor_output_class_with_confidences 5 | from .cse_confidence import decorate_cse_predictor_output_class_with_confidences 6 | from .chart_result import ( 7 | DensePoseChartResult, 8 | DensePoseChartResultWithConfidences, 9 | quantize_densepose_chart_result, 10 | compress_quantized_densepose_chart_result, 11 | decompress_compressed_densepose_chart_result, 12 | ) 13 | from .cse import DensePoseEmbeddingPredictorOutput 14 | from .data_relative import DensePoseDataRelative 15 | from .list import DensePoseList 16 | from .mesh import Mesh, create_mesh 17 | from .transform_data import DensePoseTransformData, normalized_coords_transform 18 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/projects/DensePose/densepose/utils/__init__.py -------------------------------------------------------------------------------- /projects/DensePose/densepose/utils/logger.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 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. 2 | from detectron2.data import MetadataCatalog 3 | from detectron2.utils.file_io import PathManager 4 | 5 | from densepose import DensePoseTransformData 6 | 7 | 8 | def load_for_dataset(dataset_name): 9 | path = MetadataCatalog.get(dataset_name).densepose_transform_src 10 | densepose_transform_data_fpath = PathManager.get_local_path(path) 11 | return DensePoseTransformData.load(densepose_transform_data_fpath) 12 | 13 | 14 | def load_from_cfg(cfg): 15 | return load_for_dataset(cfg.DATASETS.TEST[0]) 16 | -------------------------------------------------------------------------------- /projects/DensePose/densepose/vis/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/projects/DensePose/densepose/vis/__init__.py -------------------------------------------------------------------------------- /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. 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. 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/RELEASE_2020_04.md: -------------------------------------------------------------------------------- 1 | # DensePose Confidence Estimation and Model Zoo Improvements 2 | 3 | * [DensePose models with confidence estimation](doc/DENSEPOSE_IUV.md#ModelZooConfidence) 4 | * [Panoptic FPN and DeepLabV3 head implementation](doc/DENSEPOSE_IUV.md#ModelZooDeepLabV3) 5 | * Test time augmentations for DensePose 6 | * New evaluation metric (GPSm) that yields more reliable scores 7 | -------------------------------------------------------------------------------- /projects/DensePose/doc/RELEASE_2021_06.md: -------------------------------------------------------------------------------- 1 | # DensePose CSE with Cycle Losses 2 | 3 | This release follows the paper [Neverova et al, 2021]() and 4 | adds CSE datasets with more annotations, better CSE animal models 5 | to the model zoo, losses to ensure cycle consistency for models and mesh 6 | alignment evaluator. In particular: 7 | 8 | * [Pixel to shape](../densepose/modeling/losses/cycle_pix2shape.py) and [shape to shape](../densepose/modeling/losses/cycle_shape2shape.py) cycle consistency losses; 9 | * Mesh alignment [evaluator](../densepose/evaluation/mesh_alignment_evaluator.py); 10 | * Existing CSE datasets renamed to [ds1_train](https://dl.fbaipublicfiles.com/densepose/annotations/lvis/densepose_lvis_v1_ds1_train_v1.json) and [ds1_val](https://dl.fbaipublicfiles.com/densepose/annotations/lvis/densepose_lvis_v1_ds1_val_v1.json); 11 | * New CSE datasets [ds2_train](https://dl.fbaipublicfiles.com/densepose/annotations/lvis/densepose_lvis_v1_ds2_train_v1.json) and [ds2_val](https://dl.fbaipublicfiles.com/densepose/annotations/lvis/densepose_lvis_v1_ds2_val_v1.json) added; 12 | * Better CSE animal models trained with the 16k schedule added to the [model zoo](DENSEPOSE_CSE.md#animal-cse-models). 13 | -------------------------------------------------------------------------------- /projects/DensePose/setup.py: -------------------------------------------------------------------------------- 1 | import re 2 | from pathlib import Path 3 | from setuptools import find_packages, setup 4 | 5 | try: 6 | import torch # noqa: F401 7 | except ImportError: 8 | raise Exception( 9 | """ 10 | You must install PyTorch prior to installing DensePose: 11 | pip install torch 12 | 13 | For more information: 14 | https://pytorch.org/get-started/locally/ 15 | """ 16 | ) 17 | 18 | 19 | def get_detectron2_current_version(): 20 | """Version is not available for import through Python since it is 21 | above the top level of the package. Instead, we parse it from the 22 | file with a regex.""" 23 | # Get version info from detectron2 __init__.py 24 | version_source = (Path(__file__).parents[2] / "detectron2" / "__init__.py").read_text() 25 | version_number = re.findall(r'__version__ = "([0-9\.]+)"', version_source)[0] 26 | return version_number 27 | 28 | 29 | setup( 30 | name="detectron2-densepose", 31 | author="FAIR", 32 | version=get_detectron2_current_version(), 33 | url="https://github.com/facebookresearch/detectron2/tree/master/projects/DensePose", 34 | packages=find_packages(), 35 | python_requires=">=3.6", 36 | install_requires=[ 37 | "av>=8.0.3", 38 | "detectron2@git+https://github.com/facebookresearch/detectron2.git", 39 | "opencv-python-headless>=4.5.3.56", 40 | "scipy>=1.5.4", 41 | ], 42 | ) 43 | -------------------------------------------------------------------------------- /projects/DensePose/tests/test_image_resize_transform.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 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, 3, 100, 100), 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. 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. 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. 2 | 3 | import unittest 4 | 5 | from densepose.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/Panoptic-DeepLab/configs/COCO-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_200k_bs64_crop_640_640_coco_dsconv.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: ../Cityscapes-PanopticSegmentation/Base-PanopticDeepLab-OS16.yaml 2 | MODEL: 3 | WEIGHTS: "detectron2://DeepLab/R-52.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: 50 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 | NUM_CLASSES: 133 17 | LOSS_TOP_K: 1.0 18 | USE_DEPTHWISE_SEPARABLE_CONV: True 19 | PANOPTIC_DEEPLAB: 20 | STUFF_AREA: 4096 21 | NMS_KERNEL: 41 22 | SIZE_DIVISIBILITY: 640 23 | USE_DEPTHWISE_SEPARABLE_CONV: True 24 | DATASETS: 25 | TRAIN: ("coco_2017_train_panoptic",) 26 | TEST: ("coco_2017_val_panoptic",) 27 | SOLVER: 28 | BASE_LR: 0.0005 29 | MAX_ITER: 200000 30 | IMS_PER_BATCH: 64 31 | INPUT: 32 | FORMAT: "RGB" 33 | GAUSSIAN_SIGMA: 8 34 | MIN_SIZE_TRAIN: !!python/object/apply:eval ["[int(x * 0.1 * 640) for x in range(5, 16)]"] 35 | MIN_SIZE_TRAIN_SAMPLING: "choice" 36 | MIN_SIZE_TEST: 640 37 | MAX_SIZE_TRAIN: 960 38 | MAX_SIZE_TEST: 640 39 | CROP: 40 | ENABLED: True 41 | TYPE: "absolute" 42 | SIZE: (640, 640) 43 | -------------------------------------------------------------------------------- /projects/Panoptic-DeepLab/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: Base-PanopticDeepLab-OS16.yaml 2 | MODEL: 3 | WEIGHTS: "detectron2://DeepLab/R-52.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: 50 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 | SOLVER: 16 | MAX_ITER: 90000 17 | INPUT: 18 | FORMAT: "RGB" 19 | CROP: 20 | SIZE: (512, 1024) 21 | -------------------------------------------------------------------------------- /projects/Panoptic-DeepLab/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024_dsconv.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: Base-PanopticDeepLab-OS16.yaml 2 | MODEL: 3 | WEIGHTS: "detectron2://DeepLab/R-52.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: 50 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 | PANOPTIC_DEEPLAB: 16 | USE_DEPTHWISE_SEPARABLE_CONV: True 17 | SEM_SEG_HEAD: 18 | USE_DEPTHWISE_SEPARABLE_CONV: True 19 | SOLVER: 20 | MAX_ITER: 90000 21 | INPUT: 22 | FORMAT: "RGB" 23 | CROP: 24 | SIZE: (512, 1024) 25 | -------------------------------------------------------------------------------- /projects/Panoptic-DeepLab/panoptic_deeplab/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .config import add_panoptic_deeplab_config 3 | from .dataset_mapper import PanopticDeeplabDatasetMapper 4 | from .panoptic_seg import ( 5 | PanopticDeepLab, 6 | INS_EMBED_BRANCHES_REGISTRY, 7 | build_ins_embed_branch, 8 | PanopticDeepLabSemSegHead, 9 | PanopticDeepLabInsEmbedHead, 10 | ) 11 | -------------------------------------------------------------------------------- /projects/PointRend/configs/InstanceSegmentation/Base-Implicit-PointRend.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../../../configs/Base-RCNN-FPN.yaml" 2 | MODEL: 3 | MASK_ON: true 4 | ROI_MASK_HEAD: 5 | NAME: "ImplicitPointRendMaskHead" 6 | POOLER_TYPE: "" # No RoI pooling, let the head process image features directly 7 | FC_DIM: 1024 8 | NUM_FC: 2 9 | POINT_HEAD: 10 | NAME: "ImplicitPointHead" 11 | FC_DIM: 256 12 | NUM_FC: 3 13 | IN_FEATURES: ["p2"] 14 | NUM_CLASSES: 80 15 | CLS_AGNOSTIC_MASK: False 16 | TRAIN_NUM_POINTS: 196 17 | SUBDIVISION_STEPS: 3 18 | SUBDIVISION_NUM_POINTS: 784 19 | IMPLICIT_POINTREND: 20 | IMAGE_FEATURE_ENABLED: True 21 | POS_ENC_ENABLED: True 22 | PARAMS_L2_REGULARIZER: 0.00001 23 | INPUT: 24 | # PointRend for instance segmentation does not work with "polygon" mask_format. 25 | MASK_FORMAT: "bitmask" 26 | -------------------------------------------------------------------------------- /projects/PointRend/configs/InstanceSegmentation/Base-PointRend-RCNN-FPN.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../../../configs/Base-RCNN-FPN.yaml" 2 | MODEL: 3 | MASK_ON: true 4 | ROI_BOX_HEAD: 5 | TRAIN_ON_PRED_BOXES: True 6 | ROI_MASK_HEAD: 7 | POOLER_TYPE: "" # No RoI pooling, let the head process image features directly 8 | NAME: "PointRendMaskHead" 9 | FC_DIM: 1024 10 | NUM_FC: 2 11 | OUTPUT_SIDE_RESOLUTION: 7 12 | IN_FEATURES: ["p2"] # for the coarse mask head 13 | POINT_HEAD_ON: True 14 | POINT_HEAD: 15 | FC_DIM: 256 16 | NUM_FC: 3 17 | IN_FEATURES: ["p2"] 18 | INPUT: 19 | # PointRend for instance segmentation does not work with "polygon" mask_format. 20 | MASK_FORMAT: "bitmask" 21 | -------------------------------------------------------------------------------- /projects/PointRend/configs/InstanceSegmentation/implicit_pointrend_R_50_FPN_1x_coco.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-Implicit-PointRend.yaml" 2 | MODEL: 3 | WEIGHTS: detectron2://ImageNetPretrained/MSRA/R-50.pkl 4 | RESNETS: 5 | DEPTH: 50 6 | # To add COCO AP evaluation against the higher-quality LVIS annotations. 7 | # DATASETS: 8 | # TEST: ("coco_2017_val", "lvis_v0.5_val_cocofied") 9 | -------------------------------------------------------------------------------- /projects/PointRend/configs/InstanceSegmentation/implicit_pointrend_R_50_FPN_3x_coco.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-Implicit-PointRend.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 | # To add COCO AP evaluation against the higher-quality LVIS annotations. 10 | # DATASETS: 11 | # TEST: ("coco_2017_val", "lvis_v0.5_val_cocofied") 12 | -------------------------------------------------------------------------------- /projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_101_FPN_3x_coco.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: Base-PointRend-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 | # To add COCO AP evaluation against the higher-quality LVIS annotations. 11 | # DATASETS: 12 | # TEST: ("coco_2017_val", "lvis_v0.5_val_cocofied") 13 | -------------------------------------------------------------------------------- /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 | RESNETS: 5 | DEPTH: 50 6 | ROI_HEADS: 7 | NUM_CLASSES: 8 8 | POINT_HEAD: 9 | NUM_CLASSES: 8 10 | DATASETS: 11 | TEST: ("cityscapes_fine_instance_seg_val",) 12 | TRAIN: ("cityscapes_fine_instance_seg_train",) 13 | SOLVER: 14 | BASE_LR: 0.01 15 | IMS_PER_BATCH: 8 16 | MAX_ITER: 24000 17 | STEPS: (18000,) 18 | INPUT: 19 | MAX_SIZE_TEST: 2048 20 | MAX_SIZE_TRAIN: 2048 21 | MIN_SIZE_TEST: 1024 22 | MIN_SIZE_TRAIN: (800, 832, 864, 896, 928, 960, 992, 1024) 23 | -------------------------------------------------------------------------------- /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 | RESNETS: 5 | DEPTH: 50 6 | # To add COCO AP evaluation against the higher-quality LVIS annotations. 7 | # DATASETS: 8 | # TEST: ("coco_2017_val", "lvis_v0.5_val_cocofied") 9 | -------------------------------------------------------------------------------- /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 | RESNETS: 5 | DEPTH: 50 6 | SOLVER: 7 | STEPS: (210000, 250000) 8 | MAX_ITER: 270000 9 | # To add COCO AP evaluation against the higher-quality LVIS annotations. 10 | # DATASETS: 11 | # TEST: ("coco_2017_val", "lvis_v0.5_val_cocofied") 12 | 13 | -------------------------------------------------------------------------------- /projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_X_101_32x8d_FPN_3x_coco.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: Base-PointRend-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 | # To add COCO AP evaluation against the higher-quality LVIS annotations. 15 | # DATASETS: 16 | # TEST: ("coco_2017_val", "lvis_v0.5_val_cocofied") 17 | -------------------------------------------------------------------------------- /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/demo/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Detectron2 Demo 3 | 4 | We provide a command line tool to run a simple demo of builtin configs. 5 | The usage is explained in [GETTING_STARTED.md](../GETTING_STARTED.md). 6 | 7 | See our [blog post](https://ai.facebook.com/blog/-detectron2-a-pytorch-based-modular-object-detection-library-) 8 | for a high-quality demo generated with this tool. 9 | -------------------------------------------------------------------------------- /projects/PointRend/point_rend/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from .config import add_pointrend_config 3 | from .mask_head import PointRendMaskHead, ImplicitPointRendMaskHead 4 | from .semantic_seg import PointRendSemSegHead 5 | from .color_augmentation import ColorAugSSDTransform 6 | 7 | from . import roi_heads as _ # only registration 8 | -------------------------------------------------------------------------------- /projects/PointSup/configs/implicit_pointrend_R_50_FPN_3x_point_sup_point_aug_coco.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../PointRend/configs/InstanceSegmentation/implicit_pointrend_R_50_FPN_3x_coco.yaml" 2 | MODEL: 3 | ROI_MASK_HEAD: 4 | NAME: "ImplicitPointRendPointSupHead" 5 | INPUT: 6 | POINT_SUP: True 7 | SAMPLE_POINTS: 5 8 | DATASETS: 9 | TRAIN: ("coco_2017_train_points_n10_v1_without_masks",) 10 | -------------------------------------------------------------------------------- /projects/PointSup/configs/mask_rcnn_R_50_FPN_3x_point_sup_coco.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../../configs/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_MASK_HEAD: 8 | NAME: "MaskRCNNConvUpsamplePointSupHead" 9 | INPUT: 10 | POINT_SUP: True 11 | DATASETS: 12 | TRAIN: ("coco_2017_train_points_n10_v1_without_masks",) 13 | SOLVER: 14 | STEPS: (210000, 250000) 15 | MAX_ITER: 270000 16 | -------------------------------------------------------------------------------- /projects/PointSup/configs/mask_rcnn_R_50_FPN_3x_point_sup_point_aug_coco.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "mask_rcnn_R_50_FPN_3x_point_sup_coco.yaml" 2 | INPUT: 3 | SAMPLE_POINTS: 5 4 | -------------------------------------------------------------------------------- /projects/PointSup/point_sup/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from . import register_point_annotations 3 | from .config import add_point_sup_config 4 | from .dataset_mapper import PointSupDatasetMapper 5 | from .mask_head import MaskRCNNConvUpsamplePointSupHead 6 | from .point_utils import get_point_coords_from_point_annotation 7 | -------------------------------------------------------------------------------- /projects/PointSup/point_sup/config.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 3 | 4 | 5 | def add_point_sup_config(cfg): 6 | """ 7 | Add config for point supervision. 8 | """ 9 | # Use point annotation 10 | cfg.INPUT.POINT_SUP = False 11 | # Sample only part of points in each iteration. 12 | # Default: 0, use all available points. 13 | cfg.INPUT.SAMPLE_POINTS = 0 14 | -------------------------------------------------------------------------------- /projects/Rethinking-BatchNorm/configs/mask_rcnn_BNhead.py: -------------------------------------------------------------------------------- 1 | from detectron2.model_zoo import get_config 2 | 3 | model = get_config("common/models/mask_rcnn_fpn.py").model 4 | 5 | model.backbone.bottom_up.freeze_at = 2 6 | 7 | model.roi_heads.box_head.conv_norm = model.roi_heads.mask_head.conv_norm = "BN" 8 | # 4conv1fc head 9 | model.roi_heads.box_head.conv_dims = [256, 256, 256, 256] 10 | model.roi_heads.box_head.fc_dims = [1024] 11 | 12 | dataloader = get_config("common/data/coco.py").dataloader 13 | lr_multiplier = get_config("common/coco_schedule.py").lr_multiplier_3x 14 | optimizer = get_config("common/optim.py").SGD 15 | train = get_config("common/train.py").train 16 | 17 | train.max_iter = 270000 # 3x for batchsize = 16 18 | -------------------------------------------------------------------------------- /projects/Rethinking-BatchNorm/configs/mask_rcnn_BNhead_batch_stats.py: -------------------------------------------------------------------------------- 1 | from torch.nn import BatchNorm2d 2 | from torch.nn import functional as F 3 | 4 | 5 | class BatchNormBatchStat(BatchNorm2d): 6 | """ 7 | BN that uses batch stat in inference 8 | """ 9 | 10 | def forward(self, input): 11 | if self.training: 12 | return super().forward(input) 13 | return F.batch_norm(input, None, None, self.weight, self.bias, True, 1.0, self.eps) 14 | 15 | 16 | # After training with the base config, it's sufficient to load its model with 17 | # this config only for inference -- because the training-time behavior is identical. 18 | from .mask_rcnn_BNhead import model, dataloader, lr_multiplier, optimizer, train 19 | 20 | model.roi_heads.box_head.conv_norm = model.roi_heads.mask_head.conv_norm = BatchNormBatchStat 21 | -------------------------------------------------------------------------------- /projects/Rethinking-BatchNorm/configs/mask_rcnn_SyncBNhead.py: -------------------------------------------------------------------------------- 1 | from .mask_rcnn_BNhead import model, dataloader, lr_multiplier, optimizer, train 2 | 3 | model.roi_heads.box_head.conv_norm = model.roi_heads.mask_head.conv_norm = "SyncBN" 4 | -------------------------------------------------------------------------------- /projects/Rethinking-BatchNorm/configs/retinanet_SyncBNhead.py: -------------------------------------------------------------------------------- 1 | from detectron2.model_zoo import get_config 2 | 3 | model = get_config("common/models/retinanet.py").model 4 | model.backbone.bottom_up.freeze_at = 2 5 | model.head.norm = "SyncBN" 6 | 7 | dataloader = get_config("common/data/coco.py").dataloader 8 | lr_multiplier = get_config("common/coco_schedule.py").lr_multiplier_3x 9 | optimizer = get_config("common/optim.py").SGD 10 | train = get_config("common/train.py").train 11 | 12 | optimizer.lr = 0.01 13 | train.max_iter = 270000 # 3x for batchsize = 16 14 | -------------------------------------------------------------------------------- /projects/Rethinking-BatchNorm/configs/retinanet_SyncBNhead_SharedTraining.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | import torch 3 | from torch import Tensor, nn 4 | 5 | from detectron2.modeling.meta_arch.retinanet import RetinaNetHead 6 | 7 | 8 | def apply_sequential(inputs, modules): 9 | for mod in modules: 10 | if isinstance(mod, (nn.BatchNorm2d, nn.SyncBatchNorm)): 11 | # for BN layer, normalize all inputs together 12 | shapes = [i.shape for i in inputs] 13 | spatial_sizes = [s[2] * s[3] for s in shapes] 14 | x = [i.flatten(2) for i in inputs] 15 | x = torch.cat(x, dim=2).unsqueeze(3) 16 | x = mod(x).split(spatial_sizes, dim=2) 17 | inputs = [i.view(s) for s, i in zip(shapes, x)] 18 | else: 19 | inputs = [mod(i) for i in inputs] 20 | return inputs 21 | 22 | 23 | class RetinaNetHead_SharedTrainingBN(RetinaNetHead): 24 | def forward(self, features: List[Tensor]): 25 | logits = apply_sequential(features, list(self.cls_subnet) + [self.cls_score]) 26 | bbox_reg = apply_sequential(features, list(self.bbox_subnet) + [self.bbox_pred]) 27 | return logits, bbox_reg 28 | 29 | 30 | from .retinanet_SyncBNhead import model, dataloader, lr_multiplier, optimizer, train 31 | 32 | model.head._target_ = RetinaNetHead_SharedTrainingBN 33 | -------------------------------------------------------------------------------- /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. 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. 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. 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. 2 | -------------------------------------------------------------------------------- /projects/TensorMask/tests/test_swap_align2nat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Facebook, Inc. and its affiliates. 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. 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. 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. 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 | -------------------------------------------------------------------------------- /pytorch_toolbelt/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | __version__ = "0.2.2" 4 | -------------------------------------------------------------------------------- /pytorch_toolbelt/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/inference/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/inference/__init__.py -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from .focal import * 4 | from .jaccard import * 5 | from .dice import * 6 | from .lovasz import * 7 | from .joint_loss import * 8 | from .wing_loss import * 9 | from .other_losses import * 10 | -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__init__.py~: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from .focal import * 4 | from .jaccard import * 5 | from .dice import * 6 | from .lovasz import * 7 | from .joint_loss import * 8 | from .wing_loss import * 9 | -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/__init__.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/__init__.cpython-35.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/dice.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/dice.cpython-35.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/dice.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/dice.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/dice.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/dice.cpython-38.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/focal.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/focal.cpython-35.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/focal.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/focal.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/focal.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/focal.cpython-38.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/functional.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/functional.cpython-35.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/functional.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/functional.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/functional.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/functional.cpython-38.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/jaccard.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/jaccard.cpython-35.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/jaccard.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/jaccard.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/jaccard.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/jaccard.cpython-38.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/joint_loss.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/joint_loss.cpython-35.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/joint_loss.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/joint_loss.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/joint_loss.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/joint_loss.cpython-38.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/lovasz.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/lovasz.cpython-35.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/lovasz.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/lovasz.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/lovasz.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/lovasz.cpython-38.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/other_losses.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/other_losses.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/other_losses.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/other_losses.cpython-38.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/wing_loss.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/wing_loss.cpython-35.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/wing_loss.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/wing_loss.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/__pycache__/wing_loss.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/losses/__pycache__/wing_loss.cpython-38.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/joint_loss.py: -------------------------------------------------------------------------------- 1 | from torch.nn.modules.loss import _Loss 2 | 3 | __all__ = ["JointLoss", "WeightedLoss"] 4 | 5 | 6 | class WeightedLoss(_Loss): 7 | """Wrapper class around loss function that applies weighted with fixed factor. 8 | This class helps to balance multiple losses if they have different scales 9 | """ 10 | 11 | def __init__(self, loss, weight=1.0): 12 | super().__init__() 13 | self.loss = loss 14 | self.weight = weight 15 | 16 | def forward(self, *input): 17 | return self.loss(*input) * self.weight 18 | 19 | 20 | class JointLoss(_Loss): 21 | def __init__(self, first, second, first_weight=1.0, second_weight=1.0): 22 | super().__init__() 23 | self.first = WeightedLoss(first, first_weight) 24 | self.second = WeightedLoss(second, second_weight) 25 | 26 | def forward(self, *input): 27 | return self.first(*input) + self.second(*input) 28 | -------------------------------------------------------------------------------- /pytorch_toolbelt/losses/wing_loss.py: -------------------------------------------------------------------------------- 1 | from torch.nn.modules.loss import _Loss 2 | 3 | from . import functional as F 4 | 5 | __all__ = ["WingLoss"] 6 | 7 | 8 | class WingLoss(_Loss): 9 | def __init__(self, width=5, curvature=0.5, reduction="mean"): 10 | super(WingLoss, self).__init__(reduction=reduction) 11 | self.width = width 12 | self.curvature = curvature 13 | 14 | def forward(self, prediction, target): 15 | return F.wing_loss( 16 | prediction, target, self.width, self.curvature, self.reduction 17 | ) 18 | -------------------------------------------------------------------------------- /pytorch_toolbelt/modules/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from .abn import * 4 | from .identity import * 5 | from .dsconv import * 6 | from .scse import * 7 | from .hypercolumn import * 8 | from .fpn import * 9 | from .coord_conv import * 10 | -------------------------------------------------------------------------------- /pytorch_toolbelt/modules/__init__.py~: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from .abn import * 4 | from .identity import * 5 | from .dsconv import * 6 | from .scse import * 7 | from .hypercolumn import * 8 | from .fpn import * 9 | -------------------------------------------------------------------------------- /pytorch_toolbelt/modules/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/modules/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/modules/__pycache__/abn.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/modules/__pycache__/abn.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/modules/__pycache__/activations.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/modules/__pycache__/activations.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/modules/__pycache__/coord_conv.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/modules/__pycache__/coord_conv.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/modules/__pycache__/dsconv.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/modules/__pycache__/dsconv.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/modules/__pycache__/fpn.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/modules/__pycache__/fpn.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/modules/__pycache__/hypercolumn.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/modules/__pycache__/hypercolumn.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/modules/__pycache__/identity.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/modules/__pycache__/identity.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/modules/__pycache__/scse.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/modules/__pycache__/scse.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/modules/backbone/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/modules/backbone/__init__.py -------------------------------------------------------------------------------- /pytorch_toolbelt/modules/dsconv.py: -------------------------------------------------------------------------------- 1 | from torch import nn 2 | 3 | __all__ = ["DepthwiseSeparableConv2d"] 4 | 5 | 6 | class DepthwiseSeparableConv2d(nn.Module): 7 | def __init__( 8 | self, 9 | in_channels, 10 | out_channels, 11 | kernel_size, 12 | stride=1, 13 | padding=0, 14 | dilation=1, 15 | groups=1, 16 | bias=True, 17 | ): 18 | super(DepthwiseSeparableConv2d, self).__init__() 19 | self.depthwise = nn.Conv2d( 20 | in_channels, 21 | in_channels, 22 | kernel_size=kernel_size, 23 | dilation=dilation, 24 | padding=padding, 25 | stride=stride, 26 | bias=bias, 27 | groups=in_channels, 28 | ) 29 | self.pointwise = nn.Conv2d( 30 | in_channels, out_channels, kernel_size=1, groups=groups, bias=bias 31 | ) 32 | 33 | def forward(self, x): 34 | out = self.depthwise(x) 35 | out = self.pointwise(out) 36 | return out 37 | -------------------------------------------------------------------------------- /pytorch_toolbelt/modules/hypercolumn.py: -------------------------------------------------------------------------------- 1 | """Implementation of hypercolumn module from "Hypercolumns for Object Segmentation and Fine-grained Localization" 2 | 3 | Original paper: https://arxiv.org/abs/1411.5752 4 | """ 5 | 6 | import torch 7 | from torch import nn 8 | from torch.nn import functional as F 9 | from .fpn import FPNFuse 10 | 11 | __all__ = ["HyperColumn"] 12 | 13 | HyperColumn = FPNFuse 14 | -------------------------------------------------------------------------------- /pytorch_toolbelt/modules/identity.py: -------------------------------------------------------------------------------- 1 | from torch import nn 2 | 3 | __all__ = ["Identity"] 4 | 5 | 6 | class Identity(nn.Module): 7 | """The most useful module. A pass-through module which does nothing.""" 8 | 9 | def __init__(self, *args, **kwargs): 10 | super().__init__() 11 | 12 | def forward(self, x): 13 | return x 14 | -------------------------------------------------------------------------------- /pytorch_toolbelt/modules/srm.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch import nn 3 | 4 | 5 | class SRMLayer(nn.Module): 6 | """An implementation of SRM block, proposed in 7 | "SRM : A Style-based Recalibration Module for Convolutional Neural Networks". 8 | 9 | """ 10 | 11 | def __init__(self, channels: int): 12 | super(SRMLayer, self).__init__() 13 | 14 | # Equal to torch.einsum('bck,ck->bc', A, B) 15 | self.cfc = nn.Conv1d( 16 | channels, channels, kernel_size=2, bias=False, groups=channels 17 | ) 18 | self.bn = nn.BatchNorm1d(channels) 19 | 20 | def forward(self, x): 21 | b, c, _, _ = x.size() 22 | 23 | # Style pooling 24 | mean = x.view(b, c, -1).mean(-1).unsqueeze(-1) 25 | std = x.view(b, c, -1).std(-1).unsqueeze(-1) 26 | u = torch.cat((mean, std), -1) # (b, c, 2) 27 | 28 | # Style integration 29 | z = self.cfc(u) # (b, c, 1) 30 | z = self.bn(z) 31 | g = torch.sigmoid(z) 32 | g = g.view(b, c, 1, 1) 33 | 34 | return x * g.expand_as(x) 35 | -------------------------------------------------------------------------------- /pytorch_toolbelt/optimization/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/optimization/__init__.py -------------------------------------------------------------------------------- /pytorch_toolbelt/optimization/functional.py: -------------------------------------------------------------------------------- 1 | def get_lr_decay_parameters(parameters, learning_rate, groups: dict): 2 | custom_lr_parameters = dict( 3 | (group_name, {"params": [], "lr": learning_rate * lr_factor}) 4 | for (group_name, lr_factor) in groups.items() 5 | ) 6 | custom_lr_parameters["default"] = {"params": [], "lr": learning_rate} 7 | 8 | for parameter_name, parameter in parameters: 9 | matches = False 10 | for group_name, lr in groups.items(): 11 | if str.startswith(parameter_name, group_name): 12 | custom_lr_parameters[group_name]["params"].append(parameter) 13 | matches = True 14 | break 15 | 16 | if not matches: 17 | custom_lr_parameters["default"]["params"].append(parameter) 18 | 19 | return custom_lr_parameters.values() 20 | -------------------------------------------------------------------------------- /pytorch_toolbelt/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/utils/__init__.py -------------------------------------------------------------------------------- /pytorch_toolbelt/utils/__pycache__/__init__.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/utils/__pycache__/__init__.cpython-35.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/utils/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/utils/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/utils/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/utils/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/utils/__pycache__/torch_utils.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/utils/__pycache__/torch_utils.cpython-35.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/utils/__pycache__/torch_utils.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/utils/__pycache__/torch_utils.cpython-36.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/utils/__pycache__/torch_utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/utils/__pycache__/torch_utils.cpython-38.pyc -------------------------------------------------------------------------------- /pytorch_toolbelt/utils/catalyst/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from .metrics import * 4 | from .visualization import * 5 | from .criterions import * 6 | -------------------------------------------------------------------------------- /pytorch_toolbelt/utils/catalyst/utils.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/pytorch_toolbelt/utils/catalyst/utils.py -------------------------------------------------------------------------------- /pytorch_toolbelt/utils/catalyst_utils.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | from pytorch_toolbelt.utils.catalyst import * 3 | 4 | warnings.warn("Please use 'from pytorch_toolbelt.utils.catalyst import *' instead") 5 | -------------------------------------------------------------------------------- /pytorch_toolbelt/utils/rle.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | __all__ = ["rle_decode", "rle_encode", "rle_to_string"] 4 | 5 | 6 | def rle_encode(mask: np.ndarray): 7 | """ 8 | Convert mask to EncodedPixels in run-length encoding 9 | from https://www.kaggle.com/stainsby/fast-tested-rle-and-input-routines 10 | """ 11 | pixels = mask.T.flatten() 12 | # We need to allow for cases where there is a '1' at either end of the sequence. 13 | # We do this by padding with a zero at each end when needed. 14 | use_padding = False 15 | if pixels[0] or pixels[-1]: 16 | use_padding = True 17 | pixel_padded = np.zeros([len(pixels) + 2], dtype=pixels.dtype) 18 | pixel_padded[1:-1] = pixels 19 | pixels = pixel_padded 20 | rle = np.where(pixels[1:] != pixels[:-1])[0] + 2 21 | if use_padding: 22 | rle = rle - 1 23 | rle[1::2] = rle[1::2] - rle[:-1:2] 24 | return rle 25 | 26 | 27 | def rle_to_string(runs) -> str: 28 | return " ".join(str(x) for x in runs) 29 | 30 | 31 | def rle_decode(rle_str, shape, dtype) -> np.ndarray: 32 | s = rle_str.split() 33 | starts, lengths = [np.asarray(x, dtype=int) for x in (s[0:][::2], s[1:][::2])] 34 | starts -= 1 35 | ends = starts + lengths 36 | mask = np.zeros(np.prod(shape), dtype=dtype) 37 | for lo, hi in zip(starts, ends): 38 | mask[lo:hi] = 1 39 | return mask.reshape(shape[::-1]).T 40 | -------------------------------------------------------------------------------- /scripts/test_1x_transfiner_50.sh: -------------------------------------------------------------------------------- 1 | #python3 setup.py build develop #--no-deps 2 | #python3 setup.py develop #--no-deps 3 | 4 | export PYTHONPATH=$PYTHONPATH:`pwd` 5 | #export CUDA_LAUNCH_BLOCKING=1 # for debug 6 | 7 | ID=159 8 | 9 | 10 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 tools/train_net.py --num-gpus 8 --dist-url tcp://0.0.0.0:12346 \ 11 | --config-file configs/transfiner/mask_rcnn_R_50_FPN_1x.yaml \ 12 | --eval-only MODEL.WEIGHTS ./pretrained_model/output_1x_transfiner_r50.pth 13 | 14 | -------------------------------------------------------------------------------- /scripts/test_3x_transfiner_101.sh: -------------------------------------------------------------------------------- 1 | #python3 setup.py build develop #--no-deps 2 | #python3 setup.py develop #--no-deps 3 | 4 | export PYTHONPATH=$PYTHONPATH:`pwd` 5 | #export CUDA_LAUNCH_BLOCKING=1 # for debug 6 | 7 | ID=159 8 | 9 | 10 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 tools/train_net.py --num-gpus 8 --dist-url tcp://0.0.0.0:12346 \ 11 | --config-file configs/transfiner/mask_rcnn_R_101_FPN_3x.yaml \ 12 | --eval-only MODEL.WEIGHTS ./pretrained_model/output_3x_transfiner_r101.pth 13 | 14 | 15 | -------------------------------------------------------------------------------- /scripts/test_3x_transfiner_101_deform.sh: -------------------------------------------------------------------------------- 1 | #python3 setup.py build develop #--no-deps 2 | #python3 setup.py develop #--no-deps 3 | 4 | export PYTHONPATH=$PYTHONPATH:`pwd` 5 | #export CUDA_LAUNCH_BLOCKING=1 # for debug 6 | 7 | ID=159 8 | 9 | 10 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 tools/train_net.py --num-gpus 8 --dist-url tcp://0.0.0.0:12346 \ 11 | --config-file configs/transfiner/mask_rcnn_R_101_FPN_3x_deform.yaml \ 12 | --eval-only MODEL.WEIGHTS ./pretrained_model/output_3x_transfiner_r101_deform.pth 13 | 14 | 15 | -------------------------------------------------------------------------------- /scripts/test_3x_transfiner_50.sh: -------------------------------------------------------------------------------- 1 | #python3 setup.py build develop #--no-deps 2 | #python3 setup.py develop #--no-deps 3 | 4 | export PYTHONPATH=$PYTHONPATH:`pwd` 5 | #export CUDA_LAUNCH_BLOCKING=1 # for debug 6 | 7 | ID=159 8 | 9 | 10 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 tools/train_net.py --num-gpus 8 --dist-url tcp://0.0.0.0:12345 \ 11 | --config-file configs/transfiner/mask_rcnn_R_50_FPN_3x.yaml \ 12 | --eval-only MODEL.WEIGHTS ./pretrained_model/output_3x_transfiner_r50.pth 13 | 14 | 15 | -------------------------------------------------------------------------------- /scripts/test_3x_transfiner_50_deform.sh: -------------------------------------------------------------------------------- 1 | #python3 setup.py build develop #--no-deps 2 | #python3 setup.py develop #--no-deps 3 | 4 | export PYTHONPATH=$PYTHONPATH:`pwd` 5 | #export CUDA_LAUNCH_BLOCKING=1 # for debug 6 | 7 | ID=159 8 | 9 | 10 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 tools/train_net.py --num-gpus 8 --dist-url tcp://0.0.0.0:12345 \ 11 | --config-file configs/transfiner/mask_rcnn_R_50_FPN_3x_deform.yaml \ 12 | --eval-only MODEL.WEIGHTS ./pretrained_model/output_3x_transfiner_r50_deform.pth 13 | 14 | 15 | -------------------------------------------------------------------------------- /scripts/test_3x_transfiner_swinb.sh: -------------------------------------------------------------------------------- 1 | #python3 setup.py build develop #--no-deps 2 | #python3 setup.py develop #--no-deps 3 | 4 | export PYTHONPATH=$PYTHONPATH:`pwd` 5 | #export CUDA_LAUNCH_BLOCKING=1 # for debug 6 | 7 | ID=159 8 | 9 | 10 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 tools/train_net_swinb.py --num-gpus 8 --resume --dist-url tcp://0.0.0.0:12346 \ 11 | --config-file configs/transfiner/mask_rcnn_swinb_FPN_3x.yaml \ 12 | --eval-only MODEL.WEIGHTS ./pretrained_model/transfiner_swinb_3x.pth 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /scripts/test_3x_transfiner_swint.sh: -------------------------------------------------------------------------------- 1 | #python3 setup.py build develop #--no-deps 2 | #python3 setup.py develop #--no-deps 3 | 4 | export PYTHONPATH=$PYTHONPATH:`pwd` 5 | #export CUDA_LAUNCH_BLOCKING=1 # for debug 6 | 7 | ID=159 8 | 9 | 10 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 tools/train_net_swint.py --num-gpus 8 --resume --dist-url tcp://0.0.0.0:12346 \ 11 | --config-file configs/transfiner/mask_rcnn_swint_FPN_3x.yaml \ 12 | --eval-only MODEL.WEIGHTS ./pretrained_model/transfiner_swint_3x.pth 13 | 14 | 15 | -------------------------------------------------------------------------------- /scripts/train_transfiner_1x_50.sh: -------------------------------------------------------------------------------- 1 | #python3 setup.py build develop #--no-deps 2 | # python3 setup.py develop #--no-deps 3 | 4 | export PYTHONPATH=$PYTHONPATH:`pwd` 5 | #export CUDA_LAUNCH_BLOCKING=1 # for debug 6 | 7 | ID=159 8 | 9 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 tools/train_net.py --num-gpus 8 --resume --dist-url tcp://0.0.0.0:12349\ 10 | --config-file configs/transfiner/mask_rcnn_R_50_FPN_1x.yaml 11 | 12 | -------------------------------------------------------------------------------- /scripts/train_transfiner_1x_x101_lvis.sh: -------------------------------------------------------------------------------- 1 | #python3 setup.py build develop #--no-deps 2 | # python3 setup.py develop #--no-deps 3 | 4 | export PYTHONPATH=$PYTHONPATH:`pwd` 5 | #export CUDA_LAUNCH_BLOCKING=1 # for debug 6 | 7 | ID=159 8 | 9 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 tools/train_net.py --num-gpus 8 --resume --dist-url tcp://0.0.0.0:12349\ 10 | --config-file configs/LVISv0.5-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x.yaml 11 | 12 | -------------------------------------------------------------------------------- /scripts/train_transfiner_3x_101.sh: -------------------------------------------------------------------------------- 1 | #python3 setup.py build develop #--no-deps 2 | # python3 setup.py develop #--no-deps 3 | 4 | export PYTHONPATH=$PYTHONPATH:`pwd` 5 | #export CUDA_LAUNCH_BLOCKING=1 # for debug 6 | 7 | ID=159 8 | 9 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 tools/train_net.py --num-gpus 8 --resume --dist-url tcp://0.0.0.0:12349\ 10 | --config-file configs/transfiner/mask_rcnn_R_101_FPN_3x.yaml 11 | 12 | -------------------------------------------------------------------------------- /scripts/train_transfiner_3x_101_deform.sh: -------------------------------------------------------------------------------- 1 | #python3 setup.py build develop #--no-deps 2 | # python3 setup.py develop #--no-deps 3 | 4 | export PYTHONPATH=$PYTHONPATH:`pwd` 5 | #export CUDA_LAUNCH_BLOCKING=1 # for debug 6 | 7 | ID=159 8 | 9 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 tools/train_net.py --num-gpus 8 --resume --dist-url tcp://0.0.0.0:12349\ 10 | --config-file configs/transfiner/mask_rcnn_R_101_FPN_3x_deform.yaml 11 | 12 | -------------------------------------------------------------------------------- /scripts/train_transfiner_3x_50.sh: -------------------------------------------------------------------------------- 1 | #python3 setup.py build develop #--no-deps 2 | # python3 setup.py develop #--no-deps 3 | 4 | export PYTHONPATH=$PYTHONPATH:`pwd` 5 | #export CUDA_LAUNCH_BLOCKING=1 # for debug 6 | 7 | ID=159 8 | 9 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 tools/train_net.py --num-gpus 8 --resume --dist-url tcp://0.0.0.0:12349\ 10 | --config-file configs/transfiner/mask_rcnn_R_50_FPN_3x.yaml 11 | 12 | -------------------------------------------------------------------------------- /scripts/train_transfiner_3x_50_deform.sh: -------------------------------------------------------------------------------- 1 | #python3 setup.py build develop #--no-deps 2 | # python3 setup.py develop #--no-deps 3 | 4 | export PYTHONPATH=$PYTHONPATH:`pwd` 5 | #export CUDA_LAUNCH_BLOCKING=1 # for debug 6 | 7 | ID=159 8 | 9 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 tools/train_net.py --num-gpus 8 --resume --dist-url tcp://0.0.0.0:12349\ 10 | --config-file configs/transfiner/mask_rcnn_R_50_FPN_3x_deform.yaml 11 | 12 | -------------------------------------------------------------------------------- /scripts/train_transfiner_3x_swinb.sh: -------------------------------------------------------------------------------- 1 | #python3 setup.py build develop #--no-deps 2 | # python3 setup.py develop #--no-deps 3 | 4 | export PYTHONPATH=$PYTHONPATH:`pwd` 5 | #export CUDA_LAUNCH_BLOCKING=1 # for debug 6 | 7 | ID=159 8 | 9 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 tools/train_net_swinb.py --num-gpus 8 --resume --dist-url tcp://0.0.0.0:12349\ 10 | --config-file configs/transfiner/mask_rcnn_swinb_FPN_3x.yaml 11 | 12 | -------------------------------------------------------------------------------- /scripts/train_transfiner_3x_swint.sh: -------------------------------------------------------------------------------- 1 | #python3 setup.py build develop #--no-deps 2 | # python3 setup.py develop #--no-deps 3 | 4 | export PYTHONPATH=$PYTHONPATH:`pwd` 5 | #export CUDA_LAUNCH_BLOCKING=1 # for debug 6 | 7 | ID=159 8 | 9 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 tools/train_net_swint.py --num-gpus 8 --resume --dist-url tcp://0.0.0.0:12349\ 10 | --config-file configs/transfiner/mask_rcnn_swint_FPN_3x.yaml 11 | 12 | -------------------------------------------------------------------------------- /scripts/visual.sh: -------------------------------------------------------------------------------- 1 | export PYTHONPATH=$PYTHONPATH:`pwd` 2 | # export CUDA_LAUNCH_BLOCKING=1 # for debug 3 | 4 | CUDA_VISIBLE_DEVICES=0 python3 demo/demo.py --config-file configs/transfiner/mask_rcnn_R_50_FPN_3x.yaml \ 5 | --input 'demo/sample_imgs/*.jpg' \ 6 | --output 'vis_coco_r50_sample/' \ 7 | --opts MODEL.WEIGHTS ./pretrained_model/output_3x_transfiner_r50.pth 8 | -------------------------------------------------------------------------------- /scripts/visual_swinb.sh: -------------------------------------------------------------------------------- 1 | export PYTHONPATH=$PYTHONPATH:`pwd` 2 | # export CUDA_LAUNCH_BLOCKING=1 # for debug 3 | 4 | CUDA_VISIBLE_DEVICES=0 python3 demo/demo_swinb.py --config-file configs/transfiner/mask_rcnn_swinb_FPN_3x.yaml \ 5 | --input 'demo/sample_imgs/*.jpg' \ 6 | --output 'vis_coco_swinb_sample_swin/' \ 7 | --opts MODEL.WEIGHTS ./pretrained_model/transfiner_swinb_3x.pth 8 | -------------------------------------------------------------------------------- /swinb/__init__.py: -------------------------------------------------------------------------------- 1 | from .swin_transformer import * 2 | from .config import * 3 | -------------------------------------------------------------------------------- /swinb/config.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from detectron2.config import CfgNode as CN 4 | 5 | def add_swinb_config(cfg): 6 | # SwinT backbone 7 | cfg.MODEL.SWINT = CN() 8 | cfg.MODEL.SWINT.EMBED_DIM = 128 9 | cfg.MODEL.SWINT.OUT_FEATURES = ["stage2", "stage3", "stage4", "stage5"] 10 | cfg.MODEL.SWINT.DEPTHS = [2, 2, 18, 2] 11 | cfg.MODEL.SWINT.NUM_HEADS = [4, 8, 16, 32] 12 | cfg.MODEL.SWINT.WINDOW_SIZE = 7 13 | cfg.MODEL.SWINT.MLP_RATIO = 4 14 | cfg.MODEL.SWINT.DROP_PATH_RATE = 0.2 15 | cfg.MODEL.SWINT.APE = False 16 | cfg.MODEL.BACKBONE.FREEZE_AT = -1 17 | 18 | # addation 19 | cfg.MODEL.FPN.TOP_LEVELS = 2 20 | cfg.SOLVER.OPTIMIZER = "AdamW" 21 | -------------------------------------------------------------------------------- /swint/__init__.py: -------------------------------------------------------------------------------- 1 | from .swin_transformer import * 2 | from .config import * 3 | -------------------------------------------------------------------------------- /swint/config.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from detectron2.config import CfgNode as CN 4 | 5 | def add_swint_config(cfg): 6 | # SwinT backbone 7 | cfg.MODEL.SWINT = CN() 8 | cfg.MODEL.SWINT.EMBED_DIM = 96 9 | cfg.MODEL.SWINT.OUT_FEATURES = ["stage2", "stage3", "stage4", "stage5"] 10 | cfg.MODEL.SWINT.DEPTHS = [2, 2, 6, 2] 11 | cfg.MODEL.SWINT.NUM_HEADS = [3, 6, 12, 24] 12 | cfg.MODEL.SWINT.WINDOW_SIZE = 7 13 | cfg.MODEL.SWINT.MLP_RATIO = 4 14 | cfg.MODEL.SWINT.DROP_PATH_RATE = 0.2 15 | cfg.MODEL.SWINT.APE = False 16 | cfg.MODEL.BACKBONE.FREEZE_AT = -1 17 | 18 | # addation 19 | cfg.MODEL.FPN.TOP_LEVELS = 2 20 | cfg.SOLVER.OPTIMIZER = "AdamW" 21 | -------------------------------------------------------------------------------- /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. 2 | -------------------------------------------------------------------------------- /tests/config/dir1/dir1_a.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | dir1a_str = "base_a_1" 3 | dir1a_dict = {"a": 1, "b": 2} 4 | -------------------------------------------------------------------------------- /tests/config/dir1/dir1_b.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from detectron2.config import LazyConfig 3 | 4 | # equivalent to relative import 5 | dir1a_str, dir1a_dict = LazyConfig.load_rel("dir1_a.py", ("dir1a_str", "dir1a_dict")) 6 | 7 | dir1b_str = dir1a_str + "_from_b" 8 | dir1b_dict = dir1a_dict 9 | 10 | # Every import is a reload: not modified by other config files 11 | assert dir1a_dict.a == 1 12 | -------------------------------------------------------------------------------- /tests/config/root_cfg.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from itertools import count 3 | 4 | from detectron2.config import LazyCall as L 5 | 6 | from .dir1.dir1_a import dir1a_dict, dir1a_str 7 | 8 | dir1a_dict.a = "modified" 9 | 10 | # modification above won't affect future imports 11 | from .dir1.dir1_b import dir1b_dict, dir1b_str 12 | 13 | 14 | lazyobj = L(count)(x=dir1a_str, y=dir1b_str) 15 | -------------------------------------------------------------------------------- /tests/data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/tests/data/__init__.py -------------------------------------------------------------------------------- /tests/layers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/tests/layers/__init__.py -------------------------------------------------------------------------------- /tests/layers/test_nms.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | from __future__ import absolute_import, division, print_function, unicode_literals 3 | import unittest 4 | import torch 5 | 6 | from detectron2.layers import batched_nms 7 | from detectron2.utils.testing import random_boxes 8 | 9 | 10 | class TestNMS(unittest.TestCase): 11 | def _create_tensors(self, N): 12 | boxes = random_boxes(N, 200) 13 | scores = torch.rand(N) 14 | return boxes, scores 15 | 16 | def test_nms_scriptability(self): 17 | N = 2000 18 | num_classes = 50 19 | boxes, scores = self._create_tensors(N) 20 | idxs = torch.randint(0, num_classes, (N,)) 21 | scripted_batched_nms = torch.jit.script(batched_nms) 22 | err_msg = "NMS is incompatible with jit-scripted NMS for IoU={}" 23 | 24 | for iou in [0.2, 0.5, 0.8]: 25 | keep_ref = batched_nms(boxes, scores, idxs, iou) 26 | backup = boxes.clone() 27 | scripted_keep = scripted_batched_nms(boxes, scores, idxs, iou) 28 | assert torch.allclose(boxes, backup), "boxes modified by jit-scripted batched_nms" 29 | self.assertTrue(torch.equal(keep_ref, scripted_keep), err_msg.format(iou)) 30 | 31 | 32 | if __name__ == "__main__": 33 | unittest.main() 34 | -------------------------------------------------------------------------------- /tests/modeling/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/tests/modeling/__init__.py -------------------------------------------------------------------------------- /tests/structures/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/tests/structures/__init__.py -------------------------------------------------------------------------------- /tests/structures/test_keypoints.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | import unittest 3 | import torch 4 | 5 | from detectron2.structures.keypoints import Keypoints 6 | 7 | 8 | class TestKeypoints(unittest.TestCase): 9 | def test_cat_keypoints(self): 10 | keypoints1 = Keypoints(torch.rand(2, 21, 3)) 11 | keypoints2 = Keypoints(torch.rand(4, 21, 3)) 12 | 13 | cat_keypoints = keypoints1.cat([keypoints1, keypoints2]) 14 | self.assertTrue(torch.all(cat_keypoints.tensor[:2] == keypoints1.tensor).item()) 15 | self.assertTrue(torch.all(cat_keypoints.tensor[2:] == keypoints2.tensor).item()) 16 | 17 | 18 | if __name__ == "__main__": 19 | unittest.main() 20 | -------------------------------------------------------------------------------- /tests/test_packaging.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | import unittest 3 | 4 | from detectron2.utils.collect_env import collect_env_info 5 | 6 | 7 | class TestProjects(unittest.TestCase): 8 | def test_import(self): 9 | from detectron2.projects import point_rend 10 | 11 | _ = point_rend.add_pointrend_config 12 | 13 | import detectron2.projects.deeplab as deeplab 14 | 15 | _ = deeplab.add_deeplab_config 16 | 17 | # import detectron2.projects.panoptic_deeplab as panoptic_deeplab 18 | 19 | # _ = panoptic_deeplab.add_panoptic_deeplab_config 20 | 21 | 22 | class TestCollectEnv(unittest.TestCase): 23 | def test(self): 24 | _ = collect_env_info() 25 | -------------------------------------------------------------------------------- /tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SysCV/transfiner/5b61fb53d8df5484f44c8b7d8415f398fd283ddc/tools/__init__.py -------------------------------------------------------------------------------- /tools/deploy/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # See https://pytorch.org/tutorials/advanced/cpp_frontend.html 3 | cmake_minimum_required(VERSION 3.12 FATAL_ERROR) 4 | project(caffe2_mask_rcnn) 5 | 6 | find_package(Torch REQUIRED) 7 | find_package(gflags REQUIRED) # needed by caffe2 8 | find_package(OpenCV REQUIRED) 9 | find_package(TorchVision REQUIRED) # needed by export-method=tracing/scripting 10 | 11 | add_executable(caffe2_mask_rcnn caffe2_mask_rcnn.cpp) 12 | target_link_libraries( 13 | caffe2_mask_rcnn 14 | "${TORCH_LIBRARIES}" gflags glog protobuf ${OpenCV_LIBS}) 15 | set_property(TARGET caffe2_mask_rcnn PROPERTY CXX_STANDARD 14) 16 | 17 | 18 | add_executable(torchscript_traced_mask_rcnn torchscript_traced_mask_rcnn.cpp) 19 | target_link_libraries( 20 | torchscript_traced_mask_rcnn 21 | -Wl,--no-as-needed TorchVision::TorchVision -Wl,--as-needed 22 | "${TORCH_LIBRARIES}" ${OpenCV_LIBS}) 23 | set_property(TARGET torchscript_traced_mask_rcnn PROPERTY CXX_STANDARD 14) 24 | --------------------------------------------------------------------------------