├── .gitignore ├── HRFormer-20-fps.gif ├── LICENSE ├── README.md ├── cls ├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── config.py ├── configs │ ├── deit │ │ ├── deit_base_patch16_224.yaml │ │ ├── deit_small_patch16_224.yaml │ │ └── deit_tiny_patch16_224.yaml │ ├── hrnet │ │ ├── hrnet_w18.yaml │ │ ├── hrnet_w18_small_v2.yaml │ │ ├── hrnet_w32.yaml │ │ └── hrnet_w48.yaml │ ├── hrt │ │ ├── hrt_base.yaml │ │ ├── hrt_small.yaml │ │ └── hrt_tiny.yaml │ ├── pvt │ │ ├── pvt_v2_b0_patch16_224.yaml │ │ ├── pvt_v2_b1_patch16_224.yaml │ │ ├── pvt_v2_b2_patch16_224.yaml │ │ ├── pvt_v2_b3_patch16_224.yaml │ │ ├── pvt_v2_b4_patch16_224.yaml │ │ └── pvt_v2_b5_patch16_224.yaml │ └── swin │ │ ├── swin_base_patch4_window12_384.yaml │ │ ├── swin_base_patch4_window7_224.yaml │ │ ├── swin_large_patch4_window12_384.yaml │ │ ├── swin_large_patch4_window7_224.yaml │ │ ├── swin_small_patch4_window7_224.yaml │ │ └── swin_tiny_patch4_window7_224.yaml ├── data │ ├── __init__.py │ ├── build.py │ ├── cached_image_folder.py │ ├── samplers.py │ └── zipreader.py ├── figures │ ├── HRFormer.png │ ├── HRFormerUnit.png │ ├── HRT_arch5.pdf │ ├── HRT_arch5.png │ ├── HRT_layer6.pdf │ └── HRT_layer6.png ├── install.sh ├── logger.py ├── lr_scheduler.py ├── main.py ├── models │ ├── __init__.py │ ├── build.py │ ├── hrnet.py │ ├── hrt.py │ ├── modules │ │ ├── __init__.py │ │ ├── basic_block.py │ │ ├── bottleneck_block.py │ │ ├── ffn_block.py │ │ ├── multihead_attention.py │ │ ├── multihead_isa_attention.py │ │ └── transformer_block.py │ ├── pvt_v2.py │ ├── swin_transformer.py │ └── vision_transformer.py ├── optimizer.py ├── run_dist.sh ├── run_eval.sh ├── run_flops.sh ├── test_flops.py ├── tools │ ├── __init__.py │ ├── flop_count.py │ └── jit_handles.py └── utils.py ├── pose ├── .github │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── ISSUE_TEMPLATE │ │ ├── config.yml │ │ ├── error-report.md │ │ ├── feature_request.md │ │ ├── general_questions.md │ │ └── reimplementation_questions.md │ └── workflows │ │ ├── build.yml │ │ └── deploy.yml ├── .gitignore ├── .pre-commit-config.yaml ├── .pylintrc ├── .readthedocs.yml ├── LICENSE ├── LOG ├── README.md ├── README_CN.md ├── README_MMPOSE.md ├── configs │ ├── animal │ │ ├── README.md │ │ ├── hrnet │ │ │ ├── README.md │ │ │ ├── atrw │ │ │ │ ├── hrnet_w32_atrw_256x256.py │ │ │ │ └── hrnet_w48_atrw_256x256.py │ │ │ ├── horse10 │ │ │ │ ├── hrnet_w32_horse10_256x256-split1.py │ │ │ │ ├── hrnet_w32_horse10_256x256-split2.py │ │ │ │ ├── hrnet_w32_horse10_256x256-split3.py │ │ │ │ ├── hrnet_w48_horse10_256x256-split1.py │ │ │ │ ├── hrnet_w48_horse10_256x256-split2.py │ │ │ │ └── hrnet_w48_horse10_256x256-split3.py │ │ │ └── macaque │ │ │ │ ├── hrnet_w32_macaque_256x192.py │ │ │ │ └── hrnet_w48_macaque_256x192.py │ │ └── resnet │ │ │ ├── README.md │ │ │ ├── atrw │ │ │ ├── res101_atrw_256x256.py │ │ │ ├── res152_atrw_256x256.py │ │ │ └── res50_atrw_256x256.py │ │ │ ├── fly │ │ │ ├── res101_fly_192x192.py │ │ │ ├── res152_fly_192x192.py │ │ │ └── res50_fly_192x192.py │ │ │ ├── horse10 │ │ │ ├── res101_horse10_256x256-split1.py │ │ │ ├── res101_horse10_256x256-split2.py │ │ │ ├── res101_horse10_256x256-split3.py │ │ │ ├── res152_horse10_256x256-split1.py │ │ │ ├── res152_horse10_256x256-split2.py │ │ │ ├── res152_horse10_256x256-split3.py │ │ │ ├── res50_horse10_256x256-split1.py │ │ │ ├── res50_horse10_256x256-split2.py │ │ │ └── res50_horse10_256x256-split3.py │ │ │ ├── locust │ │ │ ├── res101_locust_160x160.py │ │ │ ├── res152_locust_160x160.py │ │ │ └── res50_locust_160x160.py │ │ │ ├── macaque │ │ │ ├── res101_macaque_256x192.py │ │ │ ├── res152_macaque_256x192.py │ │ │ └── res50_macaque_256x192.py │ │ │ └── zebra │ │ │ ├── res101_zebra_160x160.py │ │ │ ├── res152_zebra_160x160.py │ │ │ └── res50_zebra_160x160.py │ ├── body3d │ │ └── simple_baseline │ │ │ ├── README.md │ │ │ └── h36m │ │ │ └── simple3Dbaseline_h36m.py │ ├── bottom_up │ │ ├── README.md │ │ ├── higherhrnet │ │ │ ├── README.md │ │ │ ├── aic │ │ │ │ └── higher_hrnet32_aic_512x512.py │ │ │ ├── coco │ │ │ │ ├── higher_hrnet32_coco_512x512.py │ │ │ │ ├── higher_hrnet32_coco_640x640.py │ │ │ │ └── higher_hrnet48_coco_512x512.py │ │ │ └── crowdpose │ │ │ │ ├── higher_hrnet32_crowdpose_512x512.py │ │ │ │ ├── higher_hrnet32_crowdpose_640x640.py │ │ │ │ └── higher_hrnet48_crowdpose_512x512.py │ │ ├── hrnet │ │ │ ├── README.md │ │ │ ├── aic │ │ │ │ └── hrnet_w32_aic_512x512.py │ │ │ ├── coco │ │ │ │ ├── hrnet_w32_coco_512x512.py │ │ │ │ ├── hrnet_w32_coco_640x640.py │ │ │ │ ├── hrnet_w48_coco_512x512.py │ │ │ │ └── hrnet_w48_coco_640x640.py │ │ │ └── mhp │ │ │ │ └── hrnet_w48_mhp_512x512.py │ │ ├── mobilenet │ │ │ ├── README.md │ │ │ ├── coco │ │ │ │ └── mobilenetv2_coco_512x512.py │ │ │ └── crowdpose │ │ │ │ └── mobilenetv2_crowdpose_512x512.py │ │ ├── resnet │ │ │ ├── README.md │ │ │ ├── coco │ │ │ │ ├── res101_coco_512x512.py │ │ │ │ ├── res101_coco_640x640.py │ │ │ │ ├── res152_coco_512x512.py │ │ │ │ ├── res152_coco_640x640.py │ │ │ │ ├── res50_coco_512x512.py │ │ │ │ └── res50_coco_640x640.py │ │ │ └── crowdpose │ │ │ │ ├── res101_crowdpose_512x512.py │ │ │ │ ├── res152_crowdpose_512x512.py │ │ │ │ └── res50_crowdpose_512x512.py │ │ └── udp │ │ │ ├── README.md │ │ │ ├── aic │ │ │ └── higher_hrnet32_aic_512x512_udp.py │ │ │ ├── coco │ │ │ ├── higher_hrnet32_coco_512x512_udp.py │ │ │ ├── higher_hrnet32_coco_640x640_udp.py │ │ │ ├── higher_hrnet48_coco_512x512_udp.py │ │ │ ├── hrnet_w32_coco_512x512_udp.py │ │ │ ├── hrnet_w32_coco_640x640_udp.py │ │ │ ├── hrnet_w48_coco_512x512_udp.py │ │ │ └── hrnet_w48_coco_640x640_udp.py │ │ │ └── crowdpose │ │ │ ├── higher_hrnet32_crowdpose_512x512_udp.py │ │ │ ├── higher_hrnet32_crowdpose_640x640_udp.py │ │ │ └── higher_hrnet48_crowdpose_512x512_udp.py │ ├── face │ │ ├── README.md │ │ ├── darkpose │ │ │ ├── 300w │ │ │ │ └── hrnetv2_w18_300w_256x256_dark.py │ │ │ ├── README.md │ │ │ ├── aflw │ │ │ │ └── hrnetv2_w18_aflw_256x256_dark.py │ │ │ ├── cofw │ │ │ │ └── hrnetv2_w18_cofw_256x256_dark.py │ │ │ └── wflw │ │ │ │ └── hrnetv2_w18_wflw_256x256_dark.py │ │ ├── deeppose │ │ │ ├── README.md │ │ │ └── wflw │ │ │ │ ├── deeppose_res50_wflw_256x256.py │ │ │ │ └── deeppose_res50_wflw_256x256_wingloss.py │ │ ├── hrnetv2 │ │ │ ├── 300w │ │ │ │ └── hrnetv2_w18_300w_256x256.py │ │ │ ├── README.md │ │ │ ├── aflw │ │ │ │ └── hrnetv2_w18_aflw_256x256.py │ │ │ ├── cofw │ │ │ │ └── hrnetv2_w18_cofw_256x256.py │ │ │ └── wflw │ │ │ │ └── hrnetv2_w18_wflw_256x256.py │ │ └── resnet │ │ │ ├── 300w │ │ │ └── res50_300w_256x256.py │ │ │ ├── README.md │ │ │ ├── aflw │ │ │ └── res50_aflw_256x256.py │ │ │ ├── cofw │ │ │ └── res50_cofw_256x256.py │ │ │ └── wflw │ │ │ └── res50_wflw_256x256.py │ ├── fashion │ │ ├── README.md │ │ ├── deeppose │ │ │ ├── README.md │ │ │ └── deepfashion │ │ │ │ ├── deeppose_res101_deepfashion_full_256x192.py │ │ │ │ ├── deeppose_res101_deepfashion_lower_256x192.py │ │ │ │ ├── deeppose_res101_deepfashion_upper_256x192.py │ │ │ │ ├── deeppose_res152_deepfashion_full_256x192.py │ │ │ │ ├── deeppose_res152_deepfashion_lower_256x192.py │ │ │ │ ├── deeppose_res152_deepfashion_upper_256x192.py │ │ │ │ ├── deeppose_res50_deepfashion_full_256x192.py │ │ │ │ ├── deeppose_res50_deepfashion_lower_256x192.py │ │ │ │ └── deeppose_res50_deepfashion_upper_256x192.py │ │ ├── hrnet │ │ │ └── deepfashion │ │ │ │ ├── hrnet_w32_deepfashion_full_256x192.py │ │ │ │ ├── hrnet_w32_deepfashion_lower_256x192.py │ │ │ │ ├── hrnet_w32_deepfashion_upper_256x192.py │ │ │ │ ├── hrnet_w48_deepfashion_full_256x192.py │ │ │ │ ├── hrnet_w48_deepfashion_lower_256x192.py │ │ │ │ └── hrnet_w48_deepfashion_upper_256x192.py │ │ ├── resnet │ │ │ ├── README.md │ │ │ └── deepfashion │ │ │ │ ├── res101_deepfashion_full_256x192.py │ │ │ │ ├── res101_deepfashion_lower_256x192.py │ │ │ │ ├── res101_deepfashion_upper_256x192.py │ │ │ │ ├── res152_deepfashion_full_256x192.py │ │ │ │ ├── res152_deepfashion_lower_256x192.py │ │ │ │ ├── res152_deepfashion_upper_256x192.py │ │ │ │ ├── res50_deepfashion_full_256x192.py │ │ │ │ ├── res50_deepfashion_lower_256x192.py │ │ │ │ └── res50_deepfashion_upper_256x192.py │ │ └── udp │ │ │ └── deepfashion │ │ │ ├── hrnet_w32_deepfashion_full_256x192_udp.py │ │ │ ├── hrnet_w32_deepfashion_lower_256x192_udp.py │ │ │ ├── hrnet_w32_deepfashion_upper_256x192_udp.py │ │ │ ├── hrnet_w48_deepfashion_full_256x192_udp.py │ │ │ ├── hrnet_w48_deepfashion_lower_256x192_udp.py │ │ │ └── hrnet_w48_deepfashion_upper_256x192_udp.py │ ├── hand │ │ ├── README.md │ │ ├── darkpose │ │ │ ├── README.md │ │ │ ├── onehand10k │ │ │ │ └── hrnetv2_w18_onehand10k_256x256_dark.py │ │ │ ├── panoptic │ │ │ │ └── hrnetv2_w18_panoptic_256x256_dark.py │ │ │ └── rhd2d │ │ │ │ └── hrnetv2_w18_rhd2d_256x256_dark.py │ │ ├── deeppose │ │ │ ├── README.md │ │ │ ├── onehand10k │ │ │ │ └── deeppose_res50_onehand10k_256x256.py │ │ │ ├── panoptic │ │ │ │ └── deeppose_res50_panoptic_256x256.py │ │ │ └── rhd2d │ │ │ │ └── deeppose_res50_rhd2d_256x256.py │ │ ├── hrnetv2 │ │ │ ├── README.md │ │ │ ├── onehand10k │ │ │ │ └── hrnetv2_w18_onehand10k_256x256.py │ │ │ ├── panoptic │ │ │ │ └── hrnetv2_w18_panoptic_256x256.py │ │ │ └── rhd2d │ │ │ │ └── hrnetv2_w18_rhd2d_256x256.py │ │ ├── mobilenet_v2 │ │ │ ├── README.md │ │ │ ├── onehand10k │ │ │ │ └── mobilenetv2_onehand10k_256x256.py │ │ │ ├── panoptic │ │ │ │ └── mobilenetv2_panoptic_256x256.py │ │ │ └── rhd2d │ │ │ │ └── mobilenetv2_rhd2d_256x256.py │ │ ├── resnet │ │ │ ├── README.md │ │ │ ├── freihand │ │ │ │ └── res50_freihand_224x224.py │ │ │ ├── interhand2d │ │ │ │ ├── res50_interhand2d_all_256x256.py │ │ │ │ ├── res50_interhand2d_human_256x256.py │ │ │ │ └── res50_interhand2d_machine_256x256.py │ │ │ ├── onehand10k │ │ │ │ └── res50_onehand10k_256x256.py │ │ │ ├── panoptic │ │ │ │ └── res50_panoptic_256x256.py │ │ │ └── rhd2d │ │ │ │ ├── res50_rhd2d_224x224.py │ │ │ │ └── res50_rhd2d_256x256.py │ │ └── udp │ │ │ ├── README.md │ │ │ ├── onehand10k │ │ │ └── hrnetv2_w18_onehand10k_256x256_udp.py │ │ │ ├── panoptic │ │ │ └── hrnetv2_w18_panoptic_256x256_udp.py │ │ │ └── rhd2d │ │ │ └── hrnetv2_w18_rhd2d_256x256_udp.py │ ├── mesh │ │ ├── README.md │ │ └── hmr │ │ │ ├── README.md │ │ │ └── hmr_res50_224x224.py │ ├── top_down │ │ ├── README.md │ │ ├── alexnet │ │ │ ├── README.md │ │ │ └── coco │ │ │ │ └── alexnet_coco_256x192.py │ │ ├── augmentation │ │ │ ├── README.md │ │ │ ├── hrnet_w32_coco_256x192_coarsedropout.py │ │ │ ├── hrnet_w32_coco_256x192_gridmask.py │ │ │ └── hrnet_w32_coco_256x192_photometric.py │ │ ├── cpm │ │ │ ├── README.md │ │ │ ├── coco │ │ │ │ ├── cpm_coco_256x192.py │ │ │ │ └── cpm_coco_384x288.py │ │ │ ├── jhmdb │ │ │ │ ├── cpm_jhmdb_sub1_368x368.py │ │ │ │ ├── cpm_jhmdb_sub2_368x368.py │ │ │ │ └── cpm_jhmdb_sub3_368x368.py │ │ │ └── mpii │ │ │ │ └── cpm_mpii_368x368.py │ │ ├── darkpose │ │ │ ├── README.md │ │ │ ├── coco │ │ │ │ ├── hrnet_w32_coco_256x192_dark.py │ │ │ │ ├── hrnet_w32_coco_384x288_dark.py │ │ │ │ ├── hrnet_w48_coco_256x192_dark.py │ │ │ │ ├── hrnet_w48_coco_384x288_dark.py │ │ │ │ ├── res101_coco_256x192_dark.py │ │ │ │ ├── res101_coco_384x288_dark.py │ │ │ │ ├── res152_coco_256x192_dark.py │ │ │ │ ├── res152_coco_384x288_dark.py │ │ │ │ ├── res50_coco_256x192_dark.py │ │ │ │ └── res50_coco_384x288_dark.py │ │ │ └── mpii │ │ │ │ ├── hrnet_w32_mpii_256x256_dark.py │ │ │ │ └── hrnet_w48_mpii_256x256_dark.py │ │ ├── deeppose │ │ │ ├── README.md │ │ │ ├── coco │ │ │ │ ├── deeppose_res101_coco_256x192.py │ │ │ │ ├── deeppose_res152_coco_256x192.py │ │ │ │ └── deeppose_res50_coco_256x192.py │ │ │ └── mpii │ │ │ │ ├── deeppose_res101_mpii_256x256.py │ │ │ │ ├── deeppose_res152_mpii_256x256.py │ │ │ │ └── deeppose_res50_mpii_256x256.py │ │ ├── hourglass │ │ │ ├── README.md │ │ │ ├── coco │ │ │ │ ├── hourglass52_coco_256x256.py │ │ │ │ └── hourglass52_coco_384x384.py │ │ │ └── mpii │ │ │ │ ├── hourglass52_mpii_256x256.py │ │ │ │ └── hourglass52_mpii_384x384.py │ │ ├── hrnet │ │ │ ├── README.md │ │ │ ├── aic │ │ │ │ ├── hrnet_w32_aic_256x192.py │ │ │ │ ├── hrnet_w32_aic_384x288.py │ │ │ │ ├── hrnet_w48_aic_256x192.py │ │ │ │ └── hrnet_w48_aic_384x288.py │ │ │ ├── coco │ │ │ │ ├── hrnet_w18_coco_256x192.py │ │ │ │ ├── hrnet_w32_coco_256x192.py │ │ │ │ ├── hrnet_w32_coco_384x288.py │ │ │ │ ├── hrnet_w48_coco_256x192.py │ │ │ │ └── hrnet_w48_coco_384x288.py │ │ │ ├── crowdpose │ │ │ │ ├── hrnet_w32_crowdpose_256x192.py │ │ │ │ ├── hrnet_w32_crowdpose_384x288.py │ │ │ │ ├── hrnet_w48_crowdpose_256x192.py │ │ │ │ └── hrnet_w48_crowdpose_384x288.py │ │ │ ├── mpii │ │ │ │ ├── hrnet_w32_mpii_256x256.py │ │ │ │ └── hrnet_w48_mpii_256x256.py │ │ │ └── posetrack18 │ │ │ │ └── hrnet_w32_posetrack18_256x192.py │ │ ├── hrt │ │ │ ├── README.md │ │ │ └── coco │ │ │ │ ├── hrt_base_coco_256x192.py │ │ │ │ ├── hrt_base_coco_384x288.py │ │ │ │ ├── hrt_small_coco_256x192.py │ │ │ │ └── hrt_small_coco_384x288.py │ │ ├── mobilenet_v2 │ │ │ ├── README.md │ │ │ ├── coco │ │ │ │ ├── mobilenetv2_coco_256x192.py │ │ │ │ └── mobilenetv2_coco_384x288.py │ │ │ └── mpii │ │ │ │ └── mobilenetv2_mpii_256x256.py │ │ ├── mspn │ │ │ ├── README.md │ │ │ └── coco │ │ │ │ ├── 2xmspn50_coco_256x192.py │ │ │ │ ├── 3xmspn50_coco_256x192.py │ │ │ │ ├── 4xmspn50_coco_256x192.py │ │ │ │ └── mspn50_coco_256x192.py │ │ ├── resnest │ │ │ ├── README.md │ │ │ └── coco │ │ │ │ ├── resnest101_coco_256x192.py │ │ │ │ ├── resnest101_coco_384x288.py │ │ │ │ ├── resnest50_coco_256x192.py │ │ │ │ └── resnest50_coco_384x288.py │ │ ├── resnet │ │ │ ├── README.md │ │ │ ├── aic │ │ │ │ ├── res101_aic_256x192.py │ │ │ │ ├── res101_aic_384x288.py │ │ │ │ ├── res152_aic_256x192.py │ │ │ │ ├── res152_aic_384x288.py │ │ │ │ ├── res50_aic_256x192.py │ │ │ │ └── res50_aic_384x288.py │ │ │ ├── coco │ │ │ │ ├── res101_coco_256x192.py │ │ │ │ ├── res101_coco_384x288.py │ │ │ │ ├── res152_coco_256x192.py │ │ │ │ ├── res152_coco_384x288.py │ │ │ │ ├── res50_coco_256x192.py │ │ │ │ └── res50_coco_384x288.py │ │ │ ├── crowdpose │ │ │ │ ├── res101_crowdpose_256x192.py │ │ │ │ ├── res101_crowdpose_320x256.py │ │ │ │ ├── res101_crowdpose_384x288.py │ │ │ │ ├── res152_crowdpose_256x192.py │ │ │ │ ├── res152_crowdpose_384x288.py │ │ │ │ ├── res50_crowdpose_256x192.py │ │ │ │ └── res50_crowdpose_384x288.py │ │ │ ├── jhmdb │ │ │ │ ├── res50_2deconv_jhmdb_sub1_256x256.py │ │ │ │ ├── res50_2deconv_jhmdb_sub2_256x256.py │ │ │ │ ├── res50_2deconv_jhmdb_sub3_256x256.py │ │ │ │ ├── res50_jhmdb_sub1_256x256.py │ │ │ │ ├── res50_jhmdb_sub2_256x256.py │ │ │ │ └── res50_jhmdb_sub3_256x256.py │ │ │ ├── mhp │ │ │ │ └── res50_mhp_256x192.py │ │ │ ├── mpii │ │ │ │ ├── res101_mpii_256x256.py │ │ │ │ ├── res152_mpii_256x256.py │ │ │ │ └── res50_mpii_256x256.py │ │ │ ├── mpii_trb │ │ │ │ ├── res101_mpii_trb_256x256.py │ │ │ │ ├── res152_mpii_trb_256x256.py │ │ │ │ └── res50_mpii_trb_256x256.py │ │ │ ├── ochuman │ │ │ │ ├── res101_ochuman_256x192.py │ │ │ │ ├── res101_ochuman_384x288.py │ │ │ │ ├── res152_ochuman_256x192.py │ │ │ │ ├── res152_ochuman_384x288.py │ │ │ │ ├── res50_ochuman_256x192.py │ │ │ │ └── res50_ochuman_384x288.py │ │ │ └── posetrack18 │ │ │ │ └── res50_posetrack18_256x192.py │ │ ├── resnetv1d │ │ │ ├── README.md │ │ │ ├── coco │ │ │ │ ├── resnetv1d101_coco_256x192.py │ │ │ │ ├── resnetv1d101_coco_384x288.py │ │ │ │ ├── resnetv1d152_coco_256x192.py │ │ │ │ ├── resnetv1d152_coco_384x288.py │ │ │ │ ├── resnetv1d50_coco_256x192.py │ │ │ │ └── resnetv1d50_coco_384x288.py │ │ │ └── mpii │ │ │ │ ├── resnetv1d101_mpii_256x256.py │ │ │ │ ├── resnetv1d152_mpii_256x256.py │ │ │ │ └── resnetv1d50_mpii_256x256.py │ │ ├── resnext │ │ │ ├── README.md │ │ │ ├── coco │ │ │ │ ├── resnext101_coco_256x192.py │ │ │ │ ├── resnext101_coco_384x288.py │ │ │ │ ├── resnext152_coco_256x192.py │ │ │ │ ├── resnext152_coco_384x288.py │ │ │ │ ├── resnext50_coco_256x192.py │ │ │ │ └── resnext50_coco_384x288.py │ │ │ └── mpii │ │ │ │ ├── resnext101_mpii_256x256.py │ │ │ │ ├── resnext152_mpii_256x256.py │ │ │ │ └── resnext50_mpii_256x256.py │ │ ├── rsn │ │ │ ├── README.md │ │ │ └── coco │ │ │ │ ├── 2xrsn50_coco_256x192.py │ │ │ │ ├── 3xrsn50_coco_256x192.py │ │ │ │ ├── rsn18_coco_256x192.py │ │ │ │ └── rsn50_coco_256x192.py │ │ ├── scnet │ │ │ ├── README.md │ │ │ ├── coco │ │ │ │ ├── scnet101_coco_256x192.py │ │ │ │ ├── scnet101_coco_384x288.py │ │ │ │ ├── scnet50_coco_256x192.py │ │ │ │ └── scnet50_coco_384x288.py │ │ │ └── mpii │ │ │ │ ├── scnet101_mpii_256x256.py │ │ │ │ └── scnet50_mpii_256x256.py │ │ ├── seresnet │ │ │ ├── README.md │ │ │ ├── coco │ │ │ │ ├── seresnet101_coco_256x192.py │ │ │ │ ├── seresnet101_coco_384x288.py │ │ │ │ ├── seresnet152_coco_256x192.py │ │ │ │ ├── seresnet152_coco_384x288.py │ │ │ │ ├── seresnet50_coco_256x192.py │ │ │ │ └── seresnet50_coco_384x288.py │ │ │ └── mpii │ │ │ │ ├── seresnet101_mpii_256x256.py │ │ │ │ ├── seresnet152_mpii_256x256.py │ │ │ │ └── seresnet50_mpii_256x256.py │ │ ├── shufflenet_v1 │ │ │ ├── README.md │ │ │ ├── coco │ │ │ │ ├── shufflenetv1_coco_256x192.py │ │ │ │ └── shufflenetv1_coco_384x288.py │ │ │ └── mpii │ │ │ │ └── shufflenetv1_mpii_256x256.py │ │ ├── shufflenet_v2 │ │ │ ├── README.md │ │ │ ├── coco │ │ │ │ ├── shufflenetv2_coco_256x192.py │ │ │ │ └── shufflenetv2_coco_384x288.py │ │ │ └── mpii │ │ │ │ └── shufflenetv2_mpii_256x256.py │ │ ├── udp │ │ │ ├── README.md │ │ │ ├── coco │ │ │ │ ├── hrnet_w32_coco_256x192_udp.py │ │ │ │ ├── hrnet_w32_coco_256x192_udp_regress.py │ │ │ │ ├── hrnet_w32_coco_384x288_udp.py │ │ │ │ ├── hrnet_w48_coco_256x192_udp.py │ │ │ │ └── hrnet_w48_coco_384x288_udp.py │ │ │ └── mpii │ │ │ │ ├── hrnet_w32_mpii_256x256_udp.py │ │ │ │ └── hrnet_w48_mpii_256x256_udp.py │ │ ├── vgg │ │ │ ├── README.md │ │ │ └── coco │ │ │ │ └── vgg16_bn_coco_256x192.py │ │ └── vit │ │ │ └── coco │ │ │ ├── deit_base_distilled_patch16_384_coco_256x192.py │ │ │ ├── deit_base_distilled_patch8_384_coco_256x192.py │ │ │ ├── vit_large_patch16_384_coco_256x192.py │ │ │ └── vit_large_patch8_384_coco_256x192.py │ └── wholebody │ │ ├── README.md │ │ ├── darkpose │ │ ├── README.md │ │ └── coco-wholebody │ │ │ ├── hrnet_w32_coco_wholebody_256x192_dark.py │ │ │ ├── hrnet_w32_coco_wholebody_384x288_dark.py │ │ │ ├── hrnet_w48_coco_wholebody_256x192_dark.py │ │ │ ├── hrnet_w48_coco_wholebody_384x288_dark.py │ │ │ └── hrnet_w48_coco_wholebody_384x288_dark_plus.py │ │ ├── hrnet │ │ ├── README.md │ │ └── coco-wholebody │ │ │ ├── hrnet_w32_coco_wholebody_256x192.py │ │ │ ├── hrnet_w32_coco_wholebody_384x288.py │ │ │ ├── hrnet_w48_coco_wholebody_256x192.py │ │ │ └── hrnet_w48_coco_wholebody_384x288.py │ │ └── resnet │ │ ├── README.md │ │ └── coco-wholebody │ │ ├── res101_coco_wholebody_256x192.py │ │ ├── res101_coco_wholebody_384x288.py │ │ ├── res152_coco_wholebody_256x192.py │ │ ├── res152_coco_wholebody_384x288.py │ │ ├── res50_coco_wholebody_256x192.py │ │ └── res50_coco_wholebody_384x288.py ├── demo │ ├── README.md │ ├── bottom_up_img_demo.py │ ├── bottom_up_video_demo.py │ ├── docs │ │ ├── 2d_animal_demo.md │ │ ├── 2d_face_demo.md │ │ ├── 2d_hand_demo.md │ │ ├── 2d_human_pose_demo.md │ │ ├── 2d_pose_tracking_demo.md │ │ ├── 2d_wholebody_pose_demo.md │ │ └── mmdet_modelzoo.md │ ├── face_img_demo.py │ ├── face_video_demo.py │ ├── mmdetection_cfg │ │ ├── cascade_rcnn_x101_64x4d_fpn_1class.py │ │ ├── cascade_rcnn_x101_64x4d_fpn_coco.py │ │ ├── faster_rcnn_r50_fpn_1class.py │ │ └── faster_rcnn_r50_fpn_coco.py │ ├── mmtracking_cfg │ │ └── tracktor_faster-rcnn_r50_fpn_4e_mot17-private.py │ ├── resources │ │ ├── HRT_arch5.png │ │ ├── demo.mp4 │ │ └── demo_coco.gif │ ├── top_down_img_demo.py │ ├── top_down_img_demo_with_mmdet.py │ ├── top_down_pose_tracking_demo_with_mmdet.py │ ├── top_down_pose_tracking_demo_with_mmtracking.py │ ├── top_down_video_demo_full_frame_without_det.py │ └── top_down_video_demo_with_mmdet.py ├── docker │ └── Dockerfile ├── docs │ ├── Makefile │ ├── api.rst │ ├── benchmark.md │ ├── changelog.md │ ├── conf.py │ ├── data_preparation.md │ ├── faq.md │ ├── getting_started.md │ ├── imgs │ │ ├── acc_curve.png │ │ ├── qq_group_qrcode.jpg │ │ └── zhihu_qrcode.jpg │ ├── index.rst │ ├── install.md │ ├── make.bat │ ├── merge_docs.sh │ ├── stats.py │ ├── tasks │ │ ├── 2d_animal_keypoint.md │ │ ├── 2d_body_keypoint.md │ │ ├── 2d_face_keypoint.md │ │ ├── 2d_fashion_landmark.md │ │ ├── 2d_hand_keypoint.md │ │ ├── 2d_wholebody_keypoint.md │ │ ├── 3d_body_keypoint.md │ │ └── 3d_body_mesh.md │ ├── tutorials │ │ ├── 0_config.md │ │ ├── 1_finetune.md │ │ ├── 2_new_dataset.md │ │ ├── 3_data_pipeline.md │ │ ├── 4_new_modules.md │ │ ├── 5_export_model.md │ │ └── 6_customize_runtime.md │ └── useful_tools.md ├── mmcv_custom │ ├── __init__.py │ └── checkpoint.py ├── mmpose │ ├── __init__.py │ ├── apis │ │ ├── __init__.py │ │ ├── inference.py │ │ ├── inference_tracking.py │ │ ├── test.py │ │ └── train.py │ ├── core │ │ ├── __init__.py │ │ ├── camera │ │ │ ├── __init__.py │ │ │ ├── camera_base.py │ │ │ └── single_camera.py │ │ ├── distributed_wrapper.py │ │ ├── evaluation │ │ │ ├── __init__.py │ │ │ ├── bottom_up_eval.py │ │ │ ├── eval_hooks.py │ │ │ ├── mesh_eval.py │ │ │ ├── pose3d_eval.py │ │ │ └── top_down_eval.py │ │ ├── fp16 │ │ │ ├── __init__.py │ │ │ ├── decorators.py │ │ │ ├── hooks.py │ │ │ └── utils.py │ │ ├── optimizer │ │ │ ├── __init__.py │ │ │ ├── builder.py │ │ │ └── registry.py │ │ ├── post_processing │ │ │ ├── __init__.py │ │ │ ├── group.py │ │ │ ├── nms.py │ │ │ └── post_transforms.py │ │ └── utils │ │ │ ├── __init__.py │ │ │ ├── dist_utils.py │ │ │ └── regularizations.py │ ├── datasets │ │ ├── __init__.py │ │ ├── builder.py │ │ ├── dataset_wrappers.py │ │ ├── datasets │ │ │ ├── __init__.py │ │ │ ├── animal │ │ │ │ ├── __init__.py │ │ │ │ ├── animal_atrw_dataset.py │ │ │ │ ├── animal_base_dataset.py │ │ │ │ ├── animal_fly_dataset.py │ │ │ │ ├── animal_horse10_dataset.py │ │ │ │ ├── animal_locust_dataset.py │ │ │ │ ├── animal_macaque_dataset.py │ │ │ │ └── animal_zebra_dataset.py │ │ │ ├── body3d │ │ │ │ ├── __init__.py │ │ │ │ ├── body3d_base_dataset.py │ │ │ │ └── body3d_h36m_dataset.py │ │ │ ├── bottom_up │ │ │ │ ├── __init__.py │ │ │ │ ├── bottom_up_aic.py │ │ │ │ ├── bottom_up_base_dataset.py │ │ │ │ ├── bottom_up_coco.py │ │ │ │ ├── bottom_up_crowdpose.py │ │ │ │ └── bottom_up_mhp.py │ │ │ ├── face │ │ │ │ ├── __init__.py │ │ │ │ ├── face_300w_dataset.py │ │ │ │ ├── face_aflw_dataset.py │ │ │ │ ├── face_base_dataset.py │ │ │ │ ├── face_cofw_dataset.py │ │ │ │ └── face_wflw_dataset.py │ │ │ ├── fashion │ │ │ │ ├── __init__.py │ │ │ │ ├── deepfashion_dataset.py │ │ │ │ └── fashion_base_dataset.py │ │ │ ├── hand │ │ │ │ ├── __init__.py │ │ │ │ ├── freihand_dataset.py │ │ │ │ ├── hand_base_dataset.py │ │ │ │ ├── interhand2d_dataset.py │ │ │ │ ├── interhand3d_dataset.py │ │ │ │ ├── onehand10k_dataset.py │ │ │ │ ├── panoptic_dataset.py │ │ │ │ └── rhd2d_dataset.py │ │ │ ├── mesh │ │ │ │ ├── __init__.py │ │ │ │ ├── mesh_adv_dataset.py │ │ │ │ ├── mesh_base_dataset.py │ │ │ │ ├── mesh_h36m_dataset.py │ │ │ │ ├── mesh_mix_dataset.py │ │ │ │ └── mosh_dataset.py │ │ │ └── top_down │ │ │ │ ├── __init__.py │ │ │ │ ├── topdown_aic_dataset.py │ │ │ │ ├── topdown_base_dataset.py │ │ │ │ ├── topdown_coco_dataset.py │ │ │ │ ├── topdown_coco_wholebody_dataset.py │ │ │ │ ├── topdown_crowdpose_dataset.py │ │ │ │ ├── topdown_jhmdb_dataset.py │ │ │ │ ├── topdown_mhp_dataset.py │ │ │ │ ├── topdown_mpii_dataset.py │ │ │ │ ├── topdown_mpii_trb_dataset.py │ │ │ │ ├── topdown_ochuman_dataset.py │ │ │ │ └── topdown_posetrack18_dataset.py │ │ ├── pipelines │ │ │ ├── __init__.py │ │ │ ├── bottom_up_transform.py │ │ │ ├── hand_transform.py │ │ │ ├── loading.py │ │ │ ├── mesh_transform.py │ │ │ ├── pose3d_transform.py │ │ │ ├── shared_transform.py │ │ │ └── top_down_transform.py │ │ ├── registry.py │ │ └── samplers │ │ │ ├── __init__.py │ │ │ └── distributed_sampler.py │ ├── deprecated.py │ ├── models │ │ ├── __init__.py │ │ ├── backbones │ │ │ ├── __init__.py │ │ │ ├── alexnet.py │ │ │ ├── base_backbone.py │ │ │ ├── cpm.py │ │ │ ├── helpers.py │ │ │ ├── hourglass.py │ │ │ ├── hrnet.py │ │ │ ├── hrt.py │ │ │ ├── mobilenet_v2.py │ │ │ ├── mobilenet_v3.py │ │ │ ├── modules │ │ │ │ ├── __init__.py │ │ │ │ ├── basic_block.py │ │ │ │ ├── bottleneck_block.py │ │ │ │ ├── ffn_block.py │ │ │ │ ├── multihead_attention.py │ │ │ │ ├── multihead_isa_attention.py │ │ │ │ ├── multihead_isa_pool_attention.py │ │ │ │ └── transformer_block.py │ │ │ ├── mspn.py │ │ │ ├── regnet.py │ │ │ ├── resnest.py │ │ │ ├── resnet.py │ │ │ ├── resnext.py │ │ │ ├── rsn.py │ │ │ ├── scnet.py │ │ │ ├── seresnet.py │ │ │ ├── seresnext.py │ │ │ ├── shufflenet_v1.py │ │ │ ├── shufflenet_v2.py │ │ │ ├── tcn.py │ │ │ ├── utils │ │ │ │ ├── __init__.py │ │ │ │ ├── channel_shuffle.py │ │ │ │ ├── inverted_residual.py │ │ │ │ ├── make_divisible.py │ │ │ │ ├── se_layer.py │ │ │ │ └── utils.py │ │ │ ├── vgg.py │ │ │ └── vit.py │ │ ├── builder.py │ │ ├── detectors │ │ │ ├── __init__.py │ │ │ ├── base.py │ │ │ ├── bottom_up.py │ │ │ ├── mesh.py │ │ │ ├── multi_task.py │ │ │ ├── pose_lifter.py │ │ │ └── top_down.py │ │ ├── keypoint_heads │ │ │ ├── __init__.py │ │ │ ├── bottom_up_higher_resolution_head.py │ │ │ ├── bottom_up_simple_head.py │ │ │ ├── fc_head.py │ │ │ ├── heatmap_1d_head.py │ │ │ ├── heatmap_3d_head.py │ │ │ ├── multilabel_classification_head.py │ │ │ ├── temporal_regression_head.py │ │ │ ├── top_down_base_head.py │ │ │ ├── top_down_multi_stage_head.py │ │ │ └── top_down_simple_head.py │ │ ├── losses │ │ │ ├── __init__.py │ │ │ ├── classfication_loss.py │ │ │ ├── mesh_loss.py │ │ │ ├── mse_loss.py │ │ │ ├── multi_loss_factory.py │ │ │ └── regression_loss.py │ │ ├── mesh_heads │ │ │ ├── __init__.py │ │ │ ├── discriminator.py │ │ │ ├── geometric_layers.py │ │ │ └── hmr_head.py │ │ ├── necks │ │ │ ├── __init__.py │ │ │ └── gap_neck.py │ │ ├── registry.py │ │ └── utils │ │ │ ├── __init__.py │ │ │ └── ops.py │ └── utils │ │ ├── __init__.py │ │ ├── collect_env.py │ │ ├── hooks.py │ │ └── logger.py ├── requirements.txt ├── requirements │ ├── build.txt │ ├── docs.txt │ ├── optional.txt │ ├── readthedocs.txt │ ├── runtime.txt │ └── tests.txt ├── resources │ └── mmpose-logo.png ├── run_dist.sh ├── setup.cfg ├── setup.py ├── tests │ ├── data │ │ ├── 300w │ │ │ ├── indoor_020.png │ │ │ ├── indoor_029.png │ │ │ └── test_300w.json │ │ ├── aflw │ │ │ ├── image04476.jpg │ │ │ ├── image22568.jpg │ │ │ └── test_aflw.json │ │ ├── aic │ │ │ ├── 054d9ce9201beffc76e5ff2169d2af2f027002ca.jpg │ │ │ ├── fa436c914fe4a8ec1ec5474af4d3820b84d17561.jpg │ │ │ ├── ff945ae2e729f24eea992814639d59b3bdec8bd8.jpg │ │ │ └── test_aic.json │ │ ├── atrw │ │ │ ├── 000061.jpg │ │ │ ├── 003464.jpg │ │ │ └── test_atrw.json │ │ ├── coco │ │ │ ├── 000000000785.jpg │ │ │ ├── 000000040083.jpg │ │ │ ├── 000000196141.jpg │ │ │ ├── 000000197388.jpg │ │ │ ├── test_coco.json │ │ │ ├── test_coco_det_AP_H_56.json │ │ │ └── test_coco_wholebody.json │ │ ├── cofw │ │ │ ├── 001766.jpg │ │ │ ├── 001805.jpg │ │ │ └── test_cofw.json │ │ ├── crowdpose │ │ │ ├── 103319.jpg │ │ │ ├── 106848.jpg │ │ │ ├── test_crowdpose.json │ │ │ └── test_crowdpose_det_AP_40.json │ │ ├── fld │ │ │ ├── img_00000128.jpg │ │ │ ├── img_00000132.jpg │ │ │ └── test_fld.json │ │ ├── fly │ │ │ ├── 1400.jpg │ │ │ ├── 1450.jpg │ │ │ └── test_fly.json │ │ ├── freihand │ │ │ ├── 00000355.jpg │ │ │ ├── 00017620.jpg │ │ │ ├── 00032915.jpg │ │ │ ├── 00050180.jpg │ │ │ ├── 00065475.jpg │ │ │ ├── 00082740.jpg │ │ │ ├── 00098035.jpg │ │ │ ├── 00115300.jpg │ │ │ └── test_freihand.json │ │ ├── h36m │ │ │ ├── BF_IUV_gt │ │ │ │ ├── S1_Directions_1.54138969_000001_467_466.png │ │ │ │ ├── S5_SittingDown.54138969_002061_478_619.png │ │ │ │ ├── S7_Greeting.55011271_000396_365_433.png │ │ │ │ └── S8_WalkDog_1.55011271_000026_592_382.png │ │ │ ├── S1_Directions_1.54138969_000001.jpg │ │ │ ├── S5_SittingDown.54138969_002061.jpg │ │ │ ├── S7_Greeting.55011271_000396.jpg │ │ │ ├── S8_WalkDog_1.55011271_000026.jpg │ │ │ ├── test_h36m.npz │ │ │ └── test_h36m_body3d.npz │ │ ├── horse10 │ │ │ ├── 0244.png │ │ │ ├── 0292.png │ │ │ ├── 0465.png │ │ │ └── test_horse10.json │ │ ├── interhand2.6m │ │ │ ├── image2017.jpg │ │ │ ├── image29590.jpg │ │ │ ├── image44669.jpg │ │ │ ├── image69148.jpg │ │ │ ├── test_interhand2.6m_camera.json │ │ │ ├── test_interhand2.6m_data.json │ │ │ └── test_interhand2.6m_joint_3d.json │ │ ├── jhmdb │ │ │ ├── Frisbee_catch_f_cm_np1_ri_med_0 │ │ │ │ └── 00001.png │ │ │ ├── Frisbee_catch_f_cm_np1_ri_med_1 │ │ │ │ └── 00001.png │ │ │ ├── Goalkeeper_Training_Day_@_7_catch_f_cm_np1_ri_med_0 │ │ │ │ └── 00001.png │ │ │ └── test_jhmdb_sub1.json │ │ ├── locust │ │ │ ├── 630.jpg │ │ │ ├── 650.jpg │ │ │ └── test_locust.json │ │ ├── macaque │ │ │ ├── PRI_1473.jpg │ │ │ ├── d47f1b1ee9d3217e.jpg │ │ │ └── test_macaque.json │ │ ├── mhp │ │ │ ├── 10084.jpg │ │ │ ├── 10112.jpg │ │ │ └── test_mhp.json │ │ ├── mosh │ │ │ └── test_mosh.npz │ │ ├── mpii │ │ │ ├── 004645041.jpg │ │ │ ├── 005808361.jpg │ │ │ ├── 051423444.jpg │ │ │ ├── 052475643.jpg │ │ │ ├── 060754485.jpg │ │ │ ├── test_mpii.json │ │ │ └── test_mpii_trb.json │ │ ├── ochuman │ │ │ ├── 000817.jpg │ │ │ ├── 003799.jpg │ │ │ ├── 003896.jpg │ │ │ └── test_ochuman.json │ │ ├── onehand10k │ │ │ ├── 1402.jpg │ │ │ ├── 33.jpg │ │ │ ├── 784.jpg │ │ │ ├── 9.jpg │ │ │ └── test_onehand10k.json │ │ ├── panoptic │ │ │ ├── 005880453_01_l.jpg │ │ │ ├── 005880453_01_r.jpg │ │ │ ├── ex2_2.flv_000040_l.jpg │ │ │ ├── ex2_2.flv_000040_r.jpg │ │ │ └── test_panoptic.json │ │ ├── posetrack18 │ │ │ ├── images │ │ │ │ └── val │ │ │ │ │ ├── 003418_mpii_test │ │ │ │ │ └── 000000.jpg │ │ │ │ │ ├── 009473_mpii_test │ │ │ │ │ └── 000000.jpg │ │ │ │ │ └── 012834_mpii_test │ │ │ │ │ └── 000000.jpg │ │ │ ├── mask │ │ │ │ └── val │ │ │ │ │ ├── 003418_mpii_test │ │ │ │ │ └── 000000.jpg │ │ │ │ │ ├── 009473_mpii_test │ │ │ │ │ └── 000000.jpg │ │ │ │ │ └── 012834_mpii_test │ │ │ │ │ └── 000000.jpg │ │ │ ├── test_posetrack18.json │ │ │ └── test_posetrack18_human_detections.json │ │ ├── rhd │ │ │ ├── 00111.png │ │ │ ├── 01111.png │ │ │ ├── 11111.png │ │ │ └── test_rhd.json │ │ ├── smpl │ │ │ └── smpl_mean_params.npz │ │ ├── wflw │ │ │ ├── 36_Football_americanfootball_ball_36_415.jpg │ │ │ ├── 7_Cheering_Cheering_7_16.jpg │ │ │ └── test_wflw.json │ │ └── zebra │ │ │ ├── 810.jpg │ │ │ ├── 850.jpg │ │ │ └── test_zebra.json │ ├── post_processing │ │ ├── test_group.py │ │ └── test_nms.py │ ├── test_api │ │ ├── test_inference.py │ │ └── test_inference_tracking.py │ ├── test_backbones │ │ ├── test_alexnet.py │ │ ├── test_backbones_utils.py │ │ ├── test_cpm.py │ │ ├── test_hourglass.py │ │ ├── test_hrnet.py │ │ ├── test_mobilenet_v2.py │ │ ├── test_mobilenet_v3.py │ │ ├── test_mspn.py │ │ ├── test_regnet.py │ │ ├── test_resnest.py │ │ ├── test_resnet.py │ │ ├── test_resnext.py │ │ ├── test_rsn.py │ │ ├── test_scnet.py │ │ ├── test_seresnet.py │ │ ├── test_seresnext.py │ │ ├── test_shufflenet_v1.py │ │ ├── test_shufflenet_v2.py │ │ ├── test_tcn.py │ │ └── test_vgg.py │ ├── test_compose.py │ ├── test_config.py │ ├── test_datasets │ │ ├── test_animal_dataset.py │ │ ├── test_body3d_dataset.py │ │ ├── test_bottom_up_dataset.py │ │ ├── test_face_dataset.py │ │ ├── test_fashion_dataset.py │ │ ├── test_hand_dataset.py │ │ ├── test_mesh_dataset.py │ │ └── test_top_down_dataset.py │ ├── test_eval_hook.py │ ├── test_evaluation │ │ ├── test_bottom_up_eval.py │ │ ├── test_mesh_eval.py │ │ └── test_top_down_eval.py │ ├── test_fp16.py │ ├── test_loss │ │ ├── test_bottom_up_losses.py │ │ ├── test_classification_loss.py │ │ ├── test_mesh_losses.py │ │ ├── test_regression_losses.py │ │ └── test_top_down_losses.py │ ├── test_model │ │ ├── test_bottom_up_forward.py │ │ ├── test_bottom_up_head.py │ │ ├── test_heatmap_1d_head.py │ │ ├── test_heatmap_3d_head.py │ │ ├── test_layer.py │ │ ├── test_mesh_forward.py │ │ ├── test_mesh_head.py │ │ ├── test_multilabel_classification_head.py │ │ ├── test_multitask_forward.py │ │ ├── test_pose_lifter_forward.py │ │ ├── test_temporal_regression_head.py │ │ ├── test_top_down_forward.py │ │ └── test_top_down_head.py │ ├── test_necks │ │ └── test_gap_neck.py │ ├── test_onnx.py │ ├── test_optimizer.py │ ├── test_pipelines │ │ ├── test_bottom_up_pipelines.py │ │ ├── test_hand_transform.py │ │ ├── test_mesh_pipelines.py │ │ ├── test_pose3d_transform.py │ │ ├── test_shared_transform.py │ │ └── test_top_down_pipelines.py │ ├── test_post_processing.py │ ├── test_regularization.py │ ├── test_utils.py │ └── test_version.py └── tools │ ├── analysis │ ├── analyze_logs.py │ ├── get_flops.py │ └── print_config.py │ ├── benchmark_inference.py │ ├── benchmark_processing.py │ ├── dataset │ ├── parse_cofw_dataset.py │ ├── parse_deepposekit_dataset.py │ ├── parse_macaquepose_dataset.py │ └── preprocess_h36m.py │ ├── dist_test.sh │ ├── dist_train.sh │ ├── mat2json.py │ ├── publish_model.py │ ├── pytorch2onnx.py │ ├── slurm_test.sh │ ├── slurm_train.sh │ ├── test.py │ └── train.py └── seg ├── .gitignore ├── GETTING_STARTED.md ├── LICENSE ├── MODEL_ZOO.md ├── README.md ├── README_OPENSEG.md ├── config.profile ├── configs ├── ade20k │ ├── H_48_D_4.json │ ├── H_48_D_4_RMI.json │ ├── H_48_D_4_TEST.json │ ├── H_48_D_4_TEST_MS3x.json │ ├── H_SEGFIX.json │ ├── M_V2_D_8.json │ ├── R_101_D_8.json │ ├── R_101_D_8_TEST.json │ ├── R_50_D_8.json │ └── W_38_D_8.json ├── celeba │ ├── H_48_D_4.json │ └── H_48_D_4_TEST.json ├── cityscapes │ ├── H_48_D_4.json │ ├── H_48_D_4_RMI.json │ ├── H_48_D_4_RMI_V2.json │ ├── H_48_D_4_SSV1.json │ ├── H_48_D_4_SSV2.json │ ├── H_48_D_4_TEST.json │ ├── H_48_D_4_TEST_DEPTH.json │ ├── H_48_D_4_TEST_MS3x.json │ ├── H_48_D_4_TEST_MS6x.json │ ├── H_48_D_4_WD1E4.json │ ├── H_64_D_4.json │ ├── H_SEGFIX.json │ ├── M_V2_D_8.json │ ├── R_101_D_16.json │ ├── R_101_D_8.json │ ├── R_101_D_8_EDGE_VOID.json │ ├── R_101_D_8_NON_EDGE_VOID.json │ ├── R_101_D_8_TEST.json │ ├── R_18_D_8.json │ ├── R_50_D_8.json │ ├── W_38_D_8.json │ ├── X_65_D_16.json │ └── X_65_D_8.json ├── coco_stuff │ ├── H_48_D_4.json │ ├── H_48_D_4_RMI.json │ ├── H_48_D_4_TEST.json │ ├── H_48_D_4_TEST_MS3x.json │ ├── R_101_D_8.json │ └── R_101_D_8_TEST.json ├── lip │ ├── H_48_D_4.json │ ├── H_48_D_4_RMI.json │ ├── H_48_D_4_TEST.json │ ├── R_101_D_16.json │ ├── R_101_D_8.json │ └── W_38_D_8.json ├── mapillary │ └── H_48_D_4_1024x1024.json ├── pascal_context │ ├── H_48_D_4.json │ ├── H_48_D_4_RMI.json │ ├── H_48_D_4_TEST.json │ ├── H_48_D_4_TEST_MS3x.json │ ├── R_101_D_8.json │ ├── R_101_D_8_TEST.json │ └── W_38_D_8.json └── segfix │ └── H_SEGFIX.json ├── imgs ├── HRT_arch5.png ├── OCR.PNG └── SegFix.PNG ├── lib ├── __init__.py ├── datasets │ ├── __init__.py │ ├── data_loader.py │ ├── loader │ │ ├── __init__.py │ │ ├── ade20k_loader.py │ │ ├── default_loader.py │ │ ├── lip_loader.py │ │ ├── multi_dataset_loader.py │ │ └── offset_loader.py │ ├── preprocess │ │ ├── README.md │ │ ├── __init__.py │ │ ├── ade20k │ │ │ ├── __init__.py │ │ │ ├── ade20k_generator.py │ │ │ ├── ade20k_generator.sh │ │ │ └── dt_offset_generator.py │ │ ├── cityscapes │ │ │ ├── __init__.py │ │ │ ├── cityscapes_generator.py │ │ │ ├── cityscapes_instance_generator.py │ │ │ ├── dt_offset_generator.py │ │ │ ├── edge_generator.py │ │ │ ├── instance_dt_offset_generator.py │ │ │ └── instance_edge_generator.py │ │ ├── coco_stuff │ │ │ └── coco_stuff_generator.py │ │ ├── face │ │ │ ├── celebmask_color.py │ │ │ ├── celebmask_label_generator.py │ │ │ ├── celebmask_partition.py │ │ │ ├── celebmask_resize.py │ │ │ └── prepare_celeb.sh │ │ ├── lip │ │ │ ├── __init__.py │ │ │ └── lip.py │ │ ├── mapillary │ │ │ ├── mapillary_generator.py │ │ │ └── mapillary_generator.sh │ │ ├── pascal_context │ │ │ ├── pascal_context_generator.py │ │ │ └── pascal_context_generator.sh │ │ └── pascal_voc │ │ │ └── pascal_voc_generator.py │ └── tools │ │ ├── __init__.py │ │ ├── collate.py │ │ ├── cv2_aug_transforms.py │ │ ├── pil_aug_transforms.py │ │ └── transforms.py ├── extensions │ ├── __init__.py │ ├── cc_attention │ │ ├── __init__.py │ │ ├── _ext │ │ │ └── __init__.py │ │ ├── build.py │ │ ├── build.sh │ │ ├── functions.py │ │ └── src │ │ │ ├── ca.cu │ │ │ ├── ca.h │ │ │ ├── common.h │ │ │ ├── lib_cffi.cpp │ │ │ └── lib_cffi.h │ ├── crf │ │ └── dense_crf.py │ ├── dcn │ │ ├── README.md │ │ ├── __init__.py │ │ ├── _ext │ │ │ ├── __init__.py │ │ │ ├── deform_conv │ │ │ │ └── __init__.py │ │ │ └── modulated_dcn │ │ │ │ └── __init__.py │ │ ├── build.py │ │ ├── build_modulated.py │ │ ├── functions │ │ │ ├── __init__.py │ │ │ ├── deform_conv.py │ │ │ └── modulated_dcn_func.py │ │ ├── make.sh │ │ ├── make_p100.sh │ │ ├── modules │ │ │ ├── __init__.py │ │ │ ├── deform_conv.py │ │ │ └── modulated_dcn.py │ │ ├── src │ │ │ ├── cuda │ │ │ │ ├── deform_psroi_pooling_cuda.cu │ │ │ │ ├── deform_psroi_pooling_cuda.h │ │ │ │ ├── modulated_deform_im2col_cuda.cu │ │ │ │ └── modulated_deform_im2col_cuda.h │ │ │ ├── deform_conv.c │ │ │ ├── deform_conv.h │ │ │ ├── deform_conv_cuda.c │ │ │ ├── deform_conv_cuda.h │ │ │ ├── deform_conv_cuda_kernel.cu │ │ │ ├── deform_conv_cuda_kernel.h │ │ │ ├── modulated_dcn.c │ │ │ ├── modulated_dcn.h │ │ │ ├── modulated_dcn_cuda.c │ │ │ └── modulated_dcn_cuda.h │ │ ├── test.py │ │ └── test_modulated.py │ ├── frn │ │ ├── __init__.py │ │ └── frn.py │ ├── inplace_abn │ │ ├── __init__.py │ │ ├── bn.py │ │ ├── functions.py │ │ └── src │ │ │ ├── common.h │ │ │ ├── inplace_abn.cpp │ │ │ ├── inplace_abn.h │ │ │ ├── inplace_abn_cpu.cpp │ │ │ └── inplace_abn_cuda.cu │ ├── inplace_abn_1 │ │ ├── __init__.py │ │ ├── bn.py │ │ ├── functions.py │ │ ├── misc.py │ │ └── src │ │ │ ├── checks.h │ │ │ ├── inplace_abn.cpp │ │ │ ├── inplace_abn.h │ │ │ ├── inplace_abn_cpu.cpp │ │ │ ├── inplace_abn_cuda.cu │ │ │ ├── inplace_abn_cuda_half.cu │ │ │ └── utils │ │ │ ├── checks.h │ │ │ ├── common.h │ │ │ └── cuda.cuh │ ├── pacnet │ │ ├── __init__.py │ │ ├── pac.py │ │ ├── paccrf.py │ │ └── test_pac.py │ ├── parallel │ │ ├── __init__.py │ │ ├── _functions.py │ │ ├── data_container.py │ │ ├── data_parallel.py │ │ ├── distributed.py │ │ └── scatter_gather.py │ ├── switchablenorms │ │ ├── __init__.py │ │ └── switchable_norm.py │ └── syncbn │ │ ├── __init__.py │ │ ├── allreduce.py │ │ ├── comm.py │ │ ├── module.py │ │ └── src │ │ ├── common.h │ │ ├── device_tensor.h │ │ ├── operator.cpp │ │ ├── operator.h │ │ ├── syncbn_cpu.cpp │ │ └── syncbn_kernel.cu ├── loss │ ├── __init__.py │ ├── loss_helper.py │ ├── loss_manager.py │ └── rmi_loss.py ├── metrics │ ├── F1_running_score.py │ ├── __init__.py │ ├── ade20k_evaluator.py │ ├── cityscapes │ │ ├── __init__.py │ │ ├── evaluation │ │ │ ├── __init__.py │ │ │ ├── addToConfusionMatrix.c │ │ │ ├── addToConfusionMatrix.pyx │ │ │ ├── addToConfusionMatrix_impl.c │ │ │ ├── csHelpers.py │ │ │ ├── evalInstanceLevelSemanticLabeling.py │ │ │ ├── evalPixelLevelSemanticLabeling.py │ │ │ ├── instance.py │ │ │ └── instances2dict.py │ │ ├── helpers │ │ │ ├── __init__.py │ │ │ ├── annotation.py │ │ │ ├── csHelpers.py │ │ │ ├── labels.py │ │ │ └── labels_cityPersons.py │ │ ├── make.sh │ │ └── setup.py │ ├── cityscapes_evaluator.py │ ├── cocostuff_evaluator.py │ ├── pascal_context_evaluator.py │ ├── running_score.py │ └── running_score_mp.py ├── models │ ├── __init__.py │ ├── backbones │ │ ├── __init__.py │ │ ├── backbone_selector.py │ │ ├── hrnet │ │ │ ├── __init__.py │ │ │ ├── hrnet_backbone.py │ │ │ └── hrnet_config.py │ │ ├── hrt │ │ │ ├── __init__.py │ │ │ ├── hrt_backbone.py │ │ │ ├── hrt_config.py │ │ │ └── modules │ │ │ │ ├── __init__.py │ │ │ │ ├── bottleneck_block.py │ │ │ │ ├── ffn_block.py │ │ │ │ ├── multihead_attention.py │ │ │ │ ├── multihead_isa_attention.py │ │ │ │ ├── multihead_isa_pool_attention.py │ │ │ │ └── transformer_block.py │ │ ├── resnet │ │ │ ├── __init__.py │ │ │ ├── dcn_resnet_models.py │ │ │ ├── resnest_models.py │ │ │ ├── resnet_backbone.py │ │ │ ├── resnet_models.py │ │ │ ├── resnext_models.py │ │ │ ├── wide_resnet_models.py │ │ │ └── wsl_resnext_models.py │ │ ├── swin │ │ │ ├── swin_backbone.py │ │ │ └── swin_config.py │ │ └── vit │ │ │ ├── helper.py │ │ │ ├── position_encoding.py │ │ │ ├── setr.py │ │ │ └── transformer.py │ ├── model_manager.py │ ├── modules │ │ ├── __init__.py │ │ ├── asp_oc_block.py │ │ ├── aspp_block.py │ │ ├── base_oc_block.py │ │ ├── decoder_block.py │ │ ├── edge_block.py │ │ ├── infer_time.sh │ │ ├── isa_block.py │ │ ├── offset_block.py │ │ ├── psp_block.py │ │ ├── spatial_ocr_block.py │ │ ├── time_log │ │ └── upernet_block.py │ ├── nets │ │ ├── __init__.py │ │ ├── ce2pnet.py │ │ ├── fcnet.py │ │ ├── hrnet.py │ │ ├── hrt.py │ │ ├── ideal_ocrnet.py │ │ ├── isanet.py │ │ ├── ocnet.py │ │ ├── ocrnet.py │ │ ├── segfix.py │ │ └── swin.py │ └── tools │ │ ├── __init__.py │ │ └── module_helper.py ├── utils │ ├── __init__.py │ ├── distributed.py │ ├── flops │ │ ├── flop_count.py │ │ └── jit_handles.py │ ├── helpers │ │ ├── __init__.py │ │ ├── dc_helper.py │ │ ├── file_helper.py │ │ ├── image_helper.py │ │ ├── json_helper.py │ │ ├── mask_helper.py │ │ ├── offset_helper.py │ │ └── video_helper.py │ └── tools │ │ ├── __init__.py │ │ ├── average_meter.py │ │ ├── configer.py │ │ ├── logger.py │ │ └── timer.py └── vis │ ├── __init__.py │ ├── attention_visualizer.py │ ├── color150.mat │ ├── color60.mat │ ├── log_visualizer.py │ ├── palette.py │ ├── seg_parser.py │ ├── seg_visualizer.py │ └── tensor_visualizer.py ├── main.py ├── requirements.txt ├── run_dist.sh ├── run_local.sh ├── scripts ├── ade20k │ ├── hrnet │ │ ├── run_h_48_d_4_asp_ocr_ohem.sh │ │ ├── run_h_48_d_4_isa_ohem.sh │ │ ├── run_h_48_d_4_ocr_ohem.sh │ │ ├── run_h_48_d_4_ocr_ohem_paddle.sh │ │ ├── run_h_48_d_4_ocr_rmi_paddle.sh │ │ └── run_h_48_d_4_train.sh │ ├── hrt │ │ ├── run_hrt_base_ocr_v2_ohem.sh │ │ ├── run_hrt_base_ocr_v2_ohem_w13.sh │ │ ├── run_hrt_base_ocr_v3_ohem_w13.sh │ │ └── run_hrt_small_ocr_v2_ohem.sh │ ├── isa │ │ └── run_wideb5_isanet_ade20k.sh │ ├── ocnet │ │ ├── run_res101d8_aspocnet_ade20k_seg.sh │ │ ├── run_res101d8_aspp_baseocnet_ade20k_seg.sh │ │ ├── run_res101d8_baseocnet_ade20k_seg.sh │ │ ├── run_res50d8_aspocnet_ade20k_seg.sh │ │ ├── run_res50d8_aspp_baseocnet_ade20k_seg.sh │ │ └── run_res50d8_baseocnet_ade20k_seg.sh │ ├── ocrnet │ │ ├── run_res101d8_aspocr_ade20k.sh │ │ ├── run_res101d8_fastaspocnet_ade20k_seg_test.sh │ │ ├── run_res101d8_fastbaseocnet_ade20k_seg.sh │ │ ├── run_res101d8_fastbaseocnet_ade20k_seg_ohem.sh │ │ ├── run_res101d8_fastbaseocnet_ade20k_trainval.sh │ │ ├── run_res101d8_fastbaseocnet_ade20k_trainval_ohem.sh │ │ ├── run_res101d8_ideal_ocr_ade20k.sh │ │ ├── run_res101d8_ideal_ocr_b_ade20k.sh │ │ ├── run_res101d8_ideal_ocr_c_ade20k.sh │ │ ├── run_res101d8_ocr_ade20k.sh │ │ ├── run_res50d8_fastaspocnet_ade20k_seg.sh │ │ ├── run_res50d8_ideal_ocr_ade20k.sh │ │ └── run_res50d8_ocr_ade20k.sh │ ├── run_res101d8_fcn_ade20k_seg.sh │ └── wide_hrnet │ │ ├── run_h_32_d_4_ocr_v2_ohem_adamw_lr1e4.sh │ │ └── run_h_78_d_4_ocr_v2_ohem_adamw_lr1e4.sh ├── celeba │ ├── aml_run_h_48_d_4_ocr_train.sh │ ├── aml_run_h_48_d_4_ocr_train_200k.sh │ ├── aml_run_h_48_d_4_ocr_train_lr1e2.sh │ ├── aml_run_h_48_d_4_ocr_train_lr1e3.sh │ ├── aml_run_h_48_d_4_ocr_train_lr2e2.sh │ ├── aml_run_h_48_d_4_ocr_train_lr5e3.sh │ ├── run_h_48_d_4_ocr_train.sh │ └── run_h_48_d_4_train.sh ├── cityscapes │ ├── fcn │ │ ├── run_r_101_d_8_fcn_train.sh │ │ └── run_r_101_d_8_fcn_wo_dsn_train.sh │ ├── hrnet │ │ ├── run_h_48_d_4.sh │ │ ├── run_h_48_d_4_ocr.sh │ │ ├── run_h_48_d_4_ocr_b.sh │ │ ├── run_h_48_d_4_ocr_b_mapillary_trainval_coarse_ohem.sh │ │ ├── run_h_48_d_4_ocr_b_mapillary_trainval_coarse_trainval_ohem.sh │ │ ├── run_h_48_d_4_ocr_b_mapillary_trainval_ohem.sh │ │ ├── run_h_48_d_4_ocr_paddle.sh │ │ ├── run_h_48_d_4_ocr_paddle_ohem.sh │ │ ├── run_h_48_d_4_ocr_rmi_paddle.sh │ │ ├── run_h_48_d_4_ocr_trainval.sh │ │ ├── run_h_48_d_4_ocr_trainval_ohem_paddle.sh │ │ └── run_h_48_d_4_ocr_trainval_paddle.sh │ ├── hrt │ │ ├── run_hrt_base_ocr_v2_ohem.sh │ │ ├── run_hrt_base_ocr_v2_ohem_w15.sh │ │ ├── run_hrt_base_ocr_v3_ohem_w15.sh │ │ └── run_hrt_small_ocr_v2_ohem.sh │ ├── isa │ │ └── run_r_101_d_8_isa_train.sh │ ├── ocnet │ │ ├── run_r_101_d_8_aspoc_train.sh │ │ ├── run_r_101_d_8_baseoc_train.sh │ │ └── run_r_101_d_8_pyramidoc_train.sh │ ├── ocrnet │ │ ├── run_ideal_distribute_ocrnet.sh │ │ ├── run_ideal_gather_ocrnet.sh │ │ ├── run_ideal_spatial_ocrnet.sh │ │ ├── run_ideal_spatial_ocrnet_b.sh │ │ ├── run_ideal_spatial_ocrnet_c.sh │ │ ├── run_r_101_d_8_asp_ocrnet_train.sh │ │ ├── run_r_101_d_8_ocrnet_train.sh │ │ ├── run_r_101_d_8_ocrnet_trainval.sh │ │ ├── run_spatial_ocrnet_trainval_coarse.sh │ │ ├── run_spatial_ocrnet_trainval_coarse_trainval.sh │ │ ├── run_spatial_ocrnet_trainval_mapillary.sh │ │ └── run_spatial_ocrnet_trainval_mapillary_coarse.sh │ ├── resnest │ │ └── run_r_101_d_8_fcn.sh │ ├── segfix.py │ ├── segfix │ │ ├── run_h_48_d_4_segfix.sh │ │ ├── run_h_48_d_4_segfix_inst.sh │ │ ├── run_h_48_d_4_segfix_trainval.sh │ │ ├── run_hx_20_d_2_segfix.sh │ │ ├── run_hx_20_d_2_segfix_inst.sh │ │ └── run_hx_20_d_2_segfix_trainval.sh │ ├── segfix_ade20k.py │ ├── segfix_instance.py │ └── swin │ │ └── run_swin_tiny_swin_uper_ohem_adamw_lr1e4.sh ├── coco_stuff │ ├── hrt │ │ ├── run_hrt_base_ocr_v2_ohem.sh │ │ ├── run_hrt_base_ocr_v2_ohem_w15.sh │ │ ├── run_hrt_base_ocr_v3_ohem_w15.sh │ │ └── run_hrt_small_ocr_v2_ohem.sh │ ├── run_h_48_d_4_isa_train.sh │ ├── run_h_48_d_4_ocr_ohem_train.sh │ ├── run_h_48_d_4_ocr_ohem_train_paddle.sh │ ├── run_h_48_d_4_ocr_ohem_train_rmi_paddle.sh │ ├── run_h_48_d_4_ocr_train.sh │ ├── run_h_48_d_4_train.sh │ ├── run_r_101_d_8_gt_ocr_train.sh │ ├── run_r_101_d_8_ocr_train.sh │ └── run_r_101_d_8_train.sh ├── lip │ ├── run_h_48_d_4_isa_train.sh │ ├── run_h_48_d_4_ocr_b_train.sh │ ├── run_h_48_d_4_ocr_train.sh │ ├── run_h_48_d_4_ocr_train_paddle.sh │ ├── run_h_48_d_4_ocr_train_rmi_paddle.sh │ ├── run_h_48_d_4_train.sh │ ├── run_r_101_d_16_ce2p_gt_ocrnet_train.sh │ └── run_r_101_d_16_ce2p_ocr_train.sh ├── mapillary │ └── run_h_48_d_4_ocr_b.sh ├── pascal_context │ ├── hrt │ │ ├── run_hrt_base_ocr_v2_ohem.sh │ │ ├── run_hrt_base_ocr_v2_ohem_w15.sh │ │ ├── run_hrt_base_ocr_v3_ohem_w15.sh │ │ └── run_hrt_small_ocr_v2_ohem.sh │ ├── run_h_48_d_4_isa_train.sh │ ├── run_h_48_d_4_ocr_b_train.sh │ ├── run_h_48_d_4_ocr_train.sh │ ├── run_h_48_d_4_ocr_train_paddle.sh │ ├── run_h_48_d_4_ocr_train_rmi_paddle.sh │ ├── run_h_48_d_4_segtr_train.sh │ ├── run_h_48_d_4_segtre_train.sh │ ├── run_h_48_d_4_train.sh │ ├── run_r_101_d_8_aspocr_train.sh │ ├── run_r_101_d_8_baseoc_train.sh │ ├── run_r_101_d_8_gt_ocr_train.sh │ ├── run_r_101_d_8_ocr_train.sh │ └── run_r_101_d_8_train.sh ├── segfix │ └── run_hx_20_d_2_cityscapes_ade20k.sh └── test_flops │ ├── test_hrnet_w48_ocr_1024x1024.sh │ ├── test_hrnet_w48_ocr_512x512.sh │ ├── test_hrvit_w18_ocr_v2_1024x1024.sh │ ├── test_hrvit_w32_ocr_v2_1024x1024.sh │ ├── test_hrvit_w32_ocr_v2_512x512.sh │ ├── test_hrvit_w78_ocr_v2_1024x1024.sh │ ├── test_hrvit_w78_ocr_v2_512x512.sh │ ├── test_wide_hrnet_w32_ocr_v2_1024x1024.sh │ ├── test_wide_hrnet_w32_ocr_v2_512x512.sh │ ├── test_wide_hrnet_w78_ocr_v2_1024x1024.sh │ └── test_wide_hrnet_w78_ocr_v2_512x512.sh └── segmentor ├── __init__.py ├── tester.py ├── tester_flops.py ├── tester_offset.py ├── tools ├── __init__.py ├── blob_helper.py ├── cost_helper.py ├── data_helper.py ├── evaluator │ ├── __init__.py │ ├── base.py │ ├── standard.py │ └── tasks.py ├── module_runner.py └── optim_scheduler.py └── trainer.py /HRFormer-20-fps.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/HRFormer-20-fps.gif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 HRT-group (Yuhui Yuan,Rao Fu,Lang Huang) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /cls/.gitattributes: -------------------------------------------------------------------------------- 1 | ckpt_epoch_11.pth filter=lfs diff=lfs merge=lfs -text 2 | -------------------------------------------------------------------------------- /cls/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /cls/configs/deit/deit_base_patch16_224.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | TYPE: deit 3 | NAME: deit_base_patch16_224 4 | DEIT: 5 | PATCH_SIZE: 16 6 | EMBED_DIM: 768 7 | DEPTHS: 12 8 | NUM_HEADS: 12 9 | MLP_RATIO: 4 10 | QKV_BIAS: True 11 | DROP_PATH_RATE: 0.5 12 | -------------------------------------------------------------------------------- /cls/configs/deit/deit_small_patch16_224.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | TYPE: deit 3 | NAME: deit_small_patch16_224 4 | DEIT: 5 | PATCH_SIZE: 16 6 | EMBED_DIM: 384 7 | DEPTHS: 12 8 | NUM_HEADS: 6 9 | MLP_RATIO: 4 10 | QKV_BIAS: True 11 | DROP_PATH_RATE: 0.3 -------------------------------------------------------------------------------- /cls/configs/deit/deit_tiny_patch16_224.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | TYPE: deit 3 | NAME: deit_tiny_patch16_224 4 | DEIT: 5 | DROP_PATH_RATE: 0.1 6 | PATCH_SIZE: 16 7 | EMBED_DIM: 192 8 | DEPTHS: 12 9 | NUM_HEADS: 3 10 | MLP_RATIO: 4 11 | QKV_BIAS: True -------------------------------------------------------------------------------- /cls/configs/hrnet/hrnet_w18.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | TYPE: hrnet 3 | NAME: hrnet_w18 4 | NUM_CLASSES: 1000 5 | HRNET: 6 | STAGE1: 7 | NUM_MODULES: 1 8 | NUM_BRANCHES: 1 9 | NUM_BLOCKS: [4] 10 | NUM_CHANNELS: [64] 11 | BLOCK: 'BOTTLENECK' 12 | 13 | STAGE2: 14 | NUM_MODULES: 1 15 | NUM_BRANCHES: 2 16 | NUM_BLOCKS: [4, 4] 17 | NUM_CHANNELS: [18, 36] 18 | BLOCK: 'BASIC' 19 | 20 | STAGE3: 21 | NUM_MODULES: 4 22 | NUM_BRANCHES: 3 23 | NUM_BLOCKS: [4, 4, 4] 24 | NUM_CHANNELS: [18, 36, 72] 25 | BLOCK: 'BASIC' 26 | 27 | STAGE4: 28 | NUM_MODULES: 3 29 | NUM_BRANCHES: 4 30 | NUM_BLOCKS: [4, 4, 4, 4] 31 | NUM_CHANNELS: [18, 36, 72, 144] 32 | BLOCK: 'BASIC' -------------------------------------------------------------------------------- /cls/configs/hrnet/hrnet_w18_small_v2.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | TYPE: hrnet 3 | NAME: hrnet_w18_small_v2 4 | NUM_CLASSES: 1000 5 | HRNET: 6 | STAGE1: 7 | NUM_MODULES: 1 8 | NUM_BRANCHES: 1 9 | NUM_BLOCKS: [2] 10 | NUM_CHANNELS: [64] 11 | BLOCK: 'BOTTLENECK' 12 | 13 | STAGE2: 14 | NUM_MODULES: 1 15 | NUM_BRANCHES: 2 16 | NUM_BLOCKS: [2, 2] 17 | NUM_CHANNELS: [18, 36] 18 | BLOCK: 'BASIC' 19 | 20 | STAGE3: 21 | NUM_MODULES: 3 22 | NUM_BRANCHES: 3 23 | NUM_BLOCKS: [2, 2, 2] 24 | NUM_CHANNELS: [18, 36, 72] 25 | BLOCK: 'BASIC' 26 | 27 | STAGE4: 28 | NUM_MODULES: 2 29 | NUM_BRANCHES: 4 30 | NUM_BLOCKS: [2, 2, 2, 2] 31 | NUM_CHANNELS: [18, 36, 72, 144] 32 | BLOCK: 'BASIC' -------------------------------------------------------------------------------- /cls/configs/hrnet/hrnet_w32.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | TYPE: hrnet 3 | NAME: hrnet_w32 4 | NUM_CLASSES: 1000 5 | HRNET: 6 | STAGE1: 7 | NUM_MODULES: 1 8 | NUM_BRANCHES: 1 9 | NUM_BLOCKS: [4] 10 | NUM_CHANNELS: [64] 11 | BLOCK: 'BOTTLENECK' 12 | 13 | STAGE2: 14 | NUM_MODULES: 1 15 | NUM_BRANCHES: 2 16 | NUM_BLOCKS: [4, 4] 17 | NUM_CHANNELS: [32, 64] 18 | BLOCK: 'BASIC' 19 | 20 | STAGE3: 21 | NUM_MODULES: 4 22 | NUM_BRANCHES: 3 23 | NUM_BLOCKS: [4, 4, 4] 24 | NUM_CHANNELS: [32, 64, 128] 25 | BLOCK: 'BASIC' 26 | 27 | STAGE4: 28 | NUM_MODULES: 3 29 | NUM_BRANCHES: 4 30 | NUM_BLOCKS: [4, 4, 4, 4] 31 | NUM_CHANNELS: [32, 64, 128, 256] 32 | BLOCK: 'BASIC' -------------------------------------------------------------------------------- /cls/configs/hrnet/hrnet_w48.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | TYPE: hrnet 3 | NAME: hrnet_w48 4 | NUM_CLASSES: 1000 5 | HRNET: 6 | STAGE1: 7 | NUM_MODULES: 1 8 | NUM_BRANCHES: 1 9 | NUM_BLOCKS: [4] 10 | NUM_CHANNELS: [64] 11 | BLOCK: 'BOTTLENECK' 12 | 13 | STAGE2: 14 | NUM_MODULES: 1 15 | NUM_BRANCHES: 2 16 | NUM_BLOCKS: [4, 4] 17 | NUM_CHANNELS: [48, 96] 18 | BLOCK: 'BASIC' 19 | 20 | STAGE3: 21 | NUM_MODULES: 4 22 | NUM_BRANCHES: 3 23 | NUM_BLOCKS: [4, 4, 4] 24 | NUM_CHANNELS: [48, 96, 192] 25 | BLOCK: 'BASIC' 26 | 27 | STAGE4: 28 | NUM_MODULES: 3 29 | NUM_BRANCHES: 4 30 | NUM_BLOCKS: [4, 4, 4, 4] 31 | NUM_CHANNELS: [48, 96, 192, 384] 32 | BLOCK: 'BASIC' -------------------------------------------------------------------------------- /cls/configs/pvt/pvt_v2_b0_patch16_224.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | TYPE: pvt_v2 3 | NAME: pvt_v2_b0_patch16_224 4 | PVT: 5 | DROP_PATH_RATE: 0.1 6 | PATCH_SIZE: 16 7 | EMBED_DIMS: [32, 64, 160, 256] 8 | NUM_HEADS: [1, 2, 5, 8] 9 | MLP_RATIOS: [8, 8, 4, 4] 10 | DEPTHS: [2, 2, 2, 2] 11 | SR_RATIOS: [8, 4, 2, 1] -------------------------------------------------------------------------------- /cls/configs/pvt/pvt_v2_b1_patch16_224.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | TYPE: pvt_v2 3 | NAME: pvt_v2_b1_patch16_224 4 | PVT: 5 | DROP_PATH_RATE: 0.1 6 | PATCH_SIZE: 16 7 | EMBED_DIMS: [64, 128, 320, 512] 8 | NUM_HEADS: [1, 2, 5, 8] 9 | MLP_RATIOS: [8, 8, 4, 4] 10 | DEPTHS: [2, 2, 2, 2] 11 | SR_RATIOS: [8, 4, 2, 1] -------------------------------------------------------------------------------- /cls/configs/pvt/pvt_v2_b2_patch16_224.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | TYPE: pvt_v2 3 | NAME: pvt_v2_b2_patch16_224 4 | PVT: 5 | DROP_PATH_RATE: 0.2 6 | PATCH_SIZE: 16 7 | EMBED_DIMS: [64, 128, 320, 512] 8 | NUM_HEADS: [1, 2, 5, 8] 9 | MLP_RATIOS: [8, 8, 4, 4] 10 | DEPTHS: [3, 4, 6, 3] 11 | SR_RATIOS: [8, 4, 2, 1] -------------------------------------------------------------------------------- /cls/configs/pvt/pvt_v2_b3_patch16_224.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | TYPE: pvt_v2 3 | NAME: pvt_v2_b3_patch16_224 4 | PVT: 5 | DROP_PATH_RATE: 0.3 6 | PATCH_SIZE: 16 7 | EMBED_DIMS: [64, 128, 320, 512] 8 | NUM_HEADS: [1, 2, 5, 8] 9 | MLP_RATIOS: [8, 8, 4, 4] 10 | DEPTHS: [3, 4, 18, 3] 11 | SR_RATIOS: [8, 4, 2, 1] -------------------------------------------------------------------------------- /cls/configs/pvt/pvt_v2_b4_patch16_224.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | TYPE: pvt_v2 3 | NAME: pvt_v2_b4_patch16_224 4 | PVT: 5 | DROP_PATH_RATE: 0.4 6 | PATCH_SIZE: 16 7 | EMBED_DIMS: [64, 128, 320, 512] 8 | NUM_HEADS: [1, 2, 5, 8] 9 | MLP_RATIOS: [8, 8, 4, 4] 10 | DEPTHS: [3, 8, 27, 3] 11 | SR_RATIOS: [8, 4, 2, 1] -------------------------------------------------------------------------------- /cls/configs/pvt/pvt_v2_b5_patch16_224.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | TYPE: pvt_v2 3 | NAME: pvt_v2_b5_patch16_224 4 | PVT: 5 | DROP_PATH_RATE: 0.5 6 | PATCH_SIZE: 16 7 | EMBED_DIMS: [64, 128, 320, 512] 8 | NUM_HEADS: [1, 2, 5, 8] 9 | MLP_RATIOS: [4, 4, 4, 4] 10 | DEPTHS: [3, 6, 40, 3] 11 | SR_RATIOS: [8, 4, 2, 1] -------------------------------------------------------------------------------- /cls/configs/swin/swin_base_patch4_window12_384.yaml: -------------------------------------------------------------------------------- 1 | # only for evaluation 2 | DATA: 3 | IMG_SIZE: 384 4 | MODEL: 5 | TYPE: swin 6 | NAME: swin_base_patch4_window12_384 7 | SWIN: 8 | EMBED_DIM: 128 9 | DEPTHS: [ 2, 2, 18, 2 ] 10 | NUM_HEADS: [ 4, 8, 16, 32 ] 11 | WINDOW_SIZE: 12 12 | TEST: 13 | CROP: False -------------------------------------------------------------------------------- /cls/configs/swin/swin_base_patch4_window7_224.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | TYPE: swin 3 | NAME: swin_base_patch4_window7_224 4 | DROP_PATH_RATE: 0.5 5 | SWIN: 6 | EMBED_DIM: 128 7 | DEPTHS: [ 2, 2, 18, 2 ] 8 | NUM_HEADS: [ 4, 8, 16, 32 ] 9 | WINDOW_SIZE: 7 -------------------------------------------------------------------------------- /cls/configs/swin/swin_large_patch4_window12_384.yaml: -------------------------------------------------------------------------------- 1 | # only for evaluation 2 | DATA: 3 | IMG_SIZE: 384 4 | MODEL: 5 | TYPE: swin 6 | NAME: swin_large_patch4_window12_384 7 | SWIN: 8 | EMBED_DIM: 192 9 | DEPTHS: [ 2, 2, 18, 2 ] 10 | NUM_HEADS: [ 6, 12, 24, 48 ] 11 | WINDOW_SIZE: 12 12 | TEST: 13 | CROP: False -------------------------------------------------------------------------------- /cls/configs/swin/swin_large_patch4_window7_224.yaml: -------------------------------------------------------------------------------- 1 | # only for evaluation 2 | MODEL: 3 | TYPE: swin 4 | NAME: swin_large_patch4_window7_224 5 | SWIN: 6 | EMBED_DIM: 192 7 | DEPTHS: [ 2, 2, 18, 2 ] 8 | NUM_HEADS: [ 6, 12, 24, 48 ] 9 | WINDOW_SIZE: 7 -------------------------------------------------------------------------------- /cls/configs/swin/swin_small_patch4_window7_224.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | TYPE: swin 3 | NAME: swin_small_patch4_window7_224 4 | DROP_PATH_RATE: 0.3 5 | SWIN: 6 | EMBED_DIM: 96 7 | DEPTHS: [ 2, 2, 18, 2 ] 8 | NUM_HEADS: [ 3, 6, 12, 24 ] 9 | WINDOW_SIZE: 7 -------------------------------------------------------------------------------- /cls/configs/swin/swin_tiny_patch4_window7_224.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | TYPE: swin 3 | NAME: swin_tiny_patch4_window7_224 4 | DROP_PATH_RATE: 0.2 5 | NUM_CLASSES: 1000 6 | SWIN: 7 | EMBED_DIM: 96 8 | DEPTHS: [ 2, 2, 6, 2 ] 9 | NUM_HEADS: [ 3, 6, 12, 24 ] 10 | WINDOW_SIZE: 7 -------------------------------------------------------------------------------- /cls/data/__init__.py: -------------------------------------------------------------------------------- 1 | from .build import build_loader -------------------------------------------------------------------------------- /cls/data/samplers.py: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------- 2 | # High Resolution Transformer 3 | # Copyright (c) 2021 Microsoft 4 | # Licensed under The MIT License [see LICENSE for details] 5 | # Written by Ze Liu 6 | # Modified by Rao Fu, RainbowSecret 7 | # -------------------------------------------------------- 8 | 9 | import torch 10 | 11 | 12 | class SubsetRandomSampler(torch.utils.data.Sampler): 13 | r"""Samples elements randomly from a given list of indices, without replacement. 14 | 15 | Arguments: 16 | indices (sequence): a sequence of indices 17 | """ 18 | 19 | def __init__(self, indices): 20 | self.epoch = 0 21 | self.indices = indices 22 | 23 | def __iter__(self): 24 | return (self.indices[i] for i in torch.randperm(len(self.indices))) 25 | 26 | def __len__(self): 27 | return len(self.indices) 28 | 29 | def set_epoch(self, epoch): 30 | self.epoch = epoch 31 | -------------------------------------------------------------------------------- /cls/figures/HRFormer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/cls/figures/HRFormer.png -------------------------------------------------------------------------------- /cls/figures/HRFormerUnit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/cls/figures/HRFormerUnit.png -------------------------------------------------------------------------------- /cls/figures/HRT_arch5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/cls/figures/HRT_arch5.pdf -------------------------------------------------------------------------------- /cls/figures/HRT_arch5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/cls/figures/HRT_arch5.png -------------------------------------------------------------------------------- /cls/figures/HRT_layer6.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/cls/figures/HRT_layer6.pdf -------------------------------------------------------------------------------- /cls/figures/HRT_layer6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/cls/figures/HRT_layer6.png -------------------------------------------------------------------------------- /cls/install.sh: -------------------------------------------------------------------------------- 1 | git clone https://github.com/NVIDIA/apex 2 | cd apex 3 | /data/anaconda/envs/pytorch1.7.1/bin/python -m pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./ -------------------------------------------------------------------------------- /cls/logger.py: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------- 2 | # High Resolution Transformer 3 | # Copyright (c) 2021 Microsoft 4 | # Licensed under The MIT License [see LICENSE for details] 5 | # Written by Ze Liu 6 | # Modified by Rao Fu, RainbowSecret 7 | # -------------------------------------------------------- 8 | 9 | import os 10 | import sys 11 | import logging 12 | import functools 13 | from termcolor import colored 14 | 15 | 16 | @functools.lru_cache() 17 | def create_logger(output_dir, dist_rank=0, name=""): 18 | # create logger 19 | logger = logging.getLogger(name) 20 | logger.setLevel(logging.DEBUG) 21 | logger.propagate = False 22 | 23 | # create formatter 24 | fmt = "[%(asctime)s %(name)s] (%(filename)s %(lineno)d): %(levelname)s %(message)s" 25 | color_fmt = ( 26 | colored("[%(asctime)s %(name)s]", "green") 27 | + colored("(%(filename)s %(lineno)d)", "yellow") 28 | + ": %(levelname)s %(message)s" 29 | ) 30 | 31 | # create console handlers for master process 32 | if dist_rank == 0: 33 | console_handler = logging.StreamHandler(sys.stdout) 34 | console_handler.setLevel(logging.DEBUG) 35 | console_handler.setFormatter( 36 | logging.Formatter(fmt=color_fmt, datefmt="%Y-%m-%d %H:%M:%S") 37 | ) 38 | logger.addHandler(console_handler) 39 | 40 | # create file handlers 41 | file_handler = logging.FileHandler( 42 | os.path.join(output_dir, f"log_rank{dist_rank}.txt"), mode="a" 43 | ) 44 | file_handler.setLevel(logging.DEBUG) 45 | file_handler.setFormatter(logging.Formatter(fmt=fmt, datefmt="%Y-%m-%d %H:%M:%S")) 46 | logger.addHandler(file_handler) 47 | 48 | return logger 49 | -------------------------------------------------------------------------------- /cls/models/__init__.py: -------------------------------------------------------------------------------- 1 | from .build import build_model -------------------------------------------------------------------------------- /cls/models/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/cls/models/modules/__init__.py -------------------------------------------------------------------------------- /cls/run_dist.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | MODEL=$1 3 | DATAPATH=$2 4 | 5 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch \ 6 | --nproc_per_node=8 \ 7 | --master_port 12345 \ 8 | main.py \ 9 | --cfg configs/$MODEL.yaml \ 10 | --batch-size 128 \ 11 | --zip \ 12 | --data-path $DATAPATH \ 13 | --output_dir "output/$MODEL" \ 14 | --tag $(date +%F_%H-%M-%S) -------------------------------------------------------------------------------- /cls/run_eval.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | MODEL=$1 3 | RESUME=$2 4 | DATAPATH=$3 5 | 6 | CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch \ 7 | --nproc_per_node=4 \ 8 | --master_port 12345 \ 9 | main.py \ 10 | --eval \ 11 | --zip \ 12 | --cfg configs/$MODEL.yaml \ 13 | --resume $RESUME \ 14 | --data-path $DATAPATH 15 | -------------------------------------------------------------------------------- /cls/run_flops.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | MODEL=$1 4 | DATAPATH=$2 5 | DATASET=$3 6 | 7 | CUDA_VISIBLE_DEVICES=0 python -m torch.distributed.launch \ 8 | --nproc_per_node=1 \ 9 | --master_port 12348 \ 10 | test_flops.py \ 11 | --mode flops \ 12 | --data-path $DATAPATH \ 13 | --fig_num 100 \ 14 | --data-set $DATASET \ 15 | --cfg configs/$MODEL.yaml \ 16 | --amp-opt-level O1 17 | -------------------------------------------------------------------------------- /cls/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/cls/tools/__init__.py -------------------------------------------------------------------------------- /pose/.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | 3 | contact_links: 4 | - name: Common Issues 5 | url: https://mmpose.readthedocs.io/en/latest/faq.html 6 | about: Check if your issue already has solutions 7 | - name: MMPose Documentation 8 | url: https://mmpose.readthedocs.io/en/latest/ 9 | about: Check if your question is answered in docs 10 | -------------------------------------------------------------------------------- /pose/.github/ISSUE_TEMPLATE/error-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Error report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Thanks for your error report and we appreciate it a lot. 11 | If you feel we have helped you, give us a STAR! :satisfied: 12 | 13 | **Checklist** 14 | 15 | 1. I have searched related issues but cannot get the expected help. 16 | 1. The bug has not been fixed in the latest version. 17 | 18 | **Describe the bug** 19 | 20 | A clear and concise description of what the bug is. 21 | 22 | **Reproduction** 23 | 24 | - What command or script did you run? 25 | 26 | ``` 27 | A placeholder for the command. 28 | ``` 29 | 30 | - What config did you run? 31 | 32 | ``` 33 | A placeholder for the config. 34 | ``` 35 | 36 | - Did you make any modifications on the code or config? Did you understand what you have modified? 37 | - What dataset did you use? 38 | 39 | **Environment** 40 | 41 | 1. Please run `PYTHONPATH=${PWD}:$PYTHONPATH python mmpose/utils/collect_env.py` to collect necessary environment information and paste it here. 42 | 1. You may add addition that may be helpful for locating the problem, such as 43 | - How you installed PyTorch [e.g., pip, conda, source] 44 | - Other environment variables that may be related (such as `$PATH`, `$LD_LIBRARY_PATH`, `$PYTHONPATH`, etc.) 45 | 46 | **Error traceback** 47 | 48 | If applicable, paste the error traceback here. 49 | 50 | ``` 51 | A placeholder for traceback. 52 | ``` 53 | 54 | **Bug fix** 55 | 56 | If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated! 57 | -------------------------------------------------------------------------------- /pose/.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Thanks for your feature request and we will review and plan for it when necessary. 11 | If you feel we have helped you, give us a STAR! :satisfied: 12 | 13 | **Steps** 14 | 15 | 1. Check if the feature has been requested in the [meta issue](https://github.com/open-mmlab/mmpose/issues/9), and if so, click thumb up button. 16 | 1. Post the feature request in the [meta issue](https://github.com/open-mmlab/mmpose/issues/9), if it is new. 17 | 18 | **Describe the feature** 19 | 20 | **Motivation** 21 | 22 | A clear and concise description of the motivation of the feature. 23 | 24 | 1. Ex1. It is inconvenient when [....]. 25 | 1. Ex2. There is a recent paper [....], which is very helpful for [....]. 26 | 27 | **Related resources** 28 | 29 | If there is an official code released or third-party implementations, please also provide the information here, which would be very helpful. 30 | 31 | **Additional context** 32 | 33 | Add any other context or screenshots about the feature request here. 34 | If you would like to implement the feature and create a PR, please leave a comment here and that would be much appreciated. 35 | -------------------------------------------------------------------------------- /pose/.github/ISSUE_TEMPLATE/general_questions.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: General questions 3 | about: Ask general questions to get help 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | -------------------------------------------------------------------------------- /pose/.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: deploy 2 | 3 | on: push 4 | 5 | jobs: 6 | build-n-publish: 7 | runs-on: ubuntu-latest 8 | if: startsWith(github.event.ref, 'refs/tags') 9 | steps: 10 | - uses: actions/checkout@v2 11 | - name: Set up Python 3.7 12 | uses: actions/setup-python@v2 13 | with: 14 | python-version: 3.7 15 | - name: Build MMPose 16 | run: | 17 | pip install wheel 18 | python setup.py sdist bdist_wheel 19 | - name: Publish distribution to PyPI 20 | run: | 21 | pip install twine 22 | twine upload dist/* -u __token__ -p ${{ secrets.pypi_password }} 23 | -------------------------------------------------------------------------------- /pose/.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | exclude: ^tests/data/ 2 | repos: 3 | - repo: https://gitlab.com/pycqa/flake8 4 | rev: 3.8.3 5 | hooks: 6 | - id: flake8 7 | - repo: https://github.com/asottile/seed-isort-config 8 | rev: v2.2.0 9 | hooks: 10 | - id: seed-isort-config 11 | - repo: https://github.com/timothycrosley/isort 12 | rev: 4.3.21 13 | hooks: 14 | - id: isort 15 | - repo: https://github.com/pre-commit/mirrors-yapf 16 | rev: v0.30.0 17 | hooks: 18 | - id: yapf 19 | - repo: https://github.com/pre-commit/pre-commit-hooks 20 | rev: v3.1.0 21 | hooks: 22 | - id: trailing-whitespace 23 | - id: check-yaml 24 | - id: end-of-file-fixer 25 | - id: requirements-txt-fixer 26 | - id: double-quote-string-fixer 27 | - id: check-merge-conflict 28 | - id: fix-encoding-pragma 29 | args: ["--remove"] 30 | - id: mixed-line-ending 31 | args: ["--fix=lf"] 32 | - repo: https://github.com/jumanjihouse/pre-commit-hooks 33 | rev: 2.1.4 34 | hooks: 35 | - id: markdownlint 36 | args: [ "-r", "~MD002,~MD007,~MD013,~MD024,~MD029,~MD033,~MD034,~MD036" ] 37 | - repo: https://github.com/myint/docformatter 38 | rev: v1.3.1 39 | hooks: 40 | - id: docformatter 41 | args: ["--in-place", "--wrap-descriptions", "79"] 42 | -------------------------------------------------------------------------------- /pose/.readthedocs.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | python: 4 | version: 3.7 5 | install: 6 | - requirements: requirements/docs.txt 7 | - requirements: requirements/readthedocs.txt 8 | -------------------------------------------------------------------------------- /pose/configs/animal/README.md: -------------------------------------------------------------------------------- 1 | # 2D Animal Keypoint Detection 2 | 3 | 2D animal keypoint detection (animal pose estimation) aims to detect the key-point of different species, including rats, 4 | dogs, macaques, and cheetah. It provides detailed behavioral analysis for neuroscience, medical and ecology applications. 5 | 6 | ## Data preparation 7 | 8 | Please follow [DATA Preparation](/docs/tasks/2d_animal_keypoint.md) to prepare data. 9 | 10 | ## Demo 11 | 12 | Please follow [DEMO](/demo/2d_animal_demo.md) to generate fancy demos. 13 | 14 |
15 | 16 |
17 | 18 |
19 | -------------------------------------------------------------------------------- /pose/configs/body3d/simple_baseline/README.md: -------------------------------------------------------------------------------- 1 | # A simple yet effective baseline for 3d human pose estimation 2 | 3 | ## Introduction 4 | 5 | 6 | 7 | ```bibtex 8 | @inproceedings{martinez_2017_3dbaseline, 9 | title={A simple yet effective baseline for 3d human pose estimation}, 10 | author={Martinez, Julieta and Hossain, Rayat and Romero, Javier and Little, James J.}, 11 | booktitle={ICCV}, 12 | year={2017} 13 | } 14 | ``` 15 | 16 | ## Results and models 17 | 18 | ### 3D Human Pose Estimation 19 | 20 | #### Results on Human3.6M dataset with ground truth 2D detections 21 | 22 | | Arch | MPJPE | P-MPJPE | ckpt | log | 23 | | :--- | :---: | :---: | :---: | :---: | 24 | | [simple3Dbaseline1](/configs/body3d/simple_baseline/h36m/simple3Dbaseline_h36m.py) | 43.4 | 34.3 | [ckpt](https://download.openmmlab.com/mmpose/body3d/simple_baseline/simple3Dbaseline_h36m-f0ad73a4_20210419.pth) | [log](https://download.openmmlab.com/mmpose/body3d/simple_baseline/20210415_065056.log.json) | 25 | 26 | 1 Differing from the original paper, we didn't apply the `max-norm constraint` because we found this led to a better convergence and performance. 27 | -------------------------------------------------------------------------------- /pose/configs/bottom_up/README.md: -------------------------------------------------------------------------------- 1 | # 2D Bottom-up Human Body Pose Estimation 2 | 3 | Multi-person human pose estimation is defined as the task of detecting the poses (or keypoints) of all people from an input image. 4 | Bottom-up approaches first detect all the keypoints and then group/associate them into person instances. 5 | 6 | ## Data preparation 7 | 8 | Please follow [DATA Preparation](/docs/tasks/2d_body_keypoint.md) to prepare data. 9 | 10 | ## Demo 11 | 12 | Please follow [Demo](/demo/2d_human_pose_demo.md#2d-human-pose-demo) to run demos. 13 | 14 | 15 | -------------------------------------------------------------------------------- /pose/configs/face/README.md: -------------------------------------------------------------------------------- 1 | # 2D Face Landmark Detection 2 | 3 | 2D face landmark detection (also referred to as face alignment) is defined as the task of detecting the face keypoints from an input image. 4 | 5 | Normally, the input images are cropped face images, where the face locates at the center; 6 | or the rough location (or the bounding box) of the hand is provided. 7 | 8 | ## Data preparation 9 | 10 | Please follow [DATA Preparation](/docs/tasks/2d_face_keypoint.md) to prepare data. 11 | 12 | ## Demo 13 | 14 | Please follow [Demo](/demo/2d_face_demo.md) to run demos. 15 | 16 |
17 | -------------------------------------------------------------------------------- /pose/configs/face/resnet/README.md: -------------------------------------------------------------------------------- 1 | # Simple baselines for human pose estimation and tracking 2 | 3 | ## Introduction 4 | 5 | 6 | 7 | ```bibtex 8 | @inproceedings{xiao2018simple, 9 | title={Simple baselines for human pose estimation and tracking}, 10 | author={Xiao, Bin and Wu, Haiping and Wei, Yichen}, 11 | booktitle={Proceedings of the European conference on computer vision (ECCV)}, 12 | pages={466--481}, 13 | year={2018} 14 | } 15 | ``` 16 | -------------------------------------------------------------------------------- /pose/configs/fashion/README.md: -------------------------------------------------------------------------------- 1 | # 2D Fashion Landmark Detection 2 | 3 | 2D fashion landmark detection (also referred to as fashion alignment) aims to detect the key-point located at the functional region of clothes, for example the neckline and the cuff. 4 | 5 | ## Data preparation 6 | 7 | Please follow [DATA Preparation](/docs/tasks/2d_fashion_landmark.md) to prepare data. 8 | -------------------------------------------------------------------------------- /pose/configs/fashion/resnet/README.md: -------------------------------------------------------------------------------- 1 | # Simple baselines for human pose estimation and tracking 2 | 3 | ## Introduction 4 | 5 | 6 | 7 | ```bibtex 8 | @inproceedings{xiao2018simple, 9 | title={Simple baselines for human pose estimation and tracking}, 10 | author={Xiao, Bin and Wu, Haiping and Wei, Yichen}, 11 | booktitle={Proceedings of the European conference on computer vision (ECCV)}, 12 | pages={466--481}, 13 | year={2018} 14 | } 15 | ``` 16 | 17 | ## Results and models 18 | 19 | ### 2d Fashion Landmark Detection 20 | 21 | #### Results on DeepFashion val set 22 | 23 | |Set | Arch | Input Size | PCK@0.2 | AUC | EPE | ckpt | log | 24 | | :--- | :---: | :--------: | :------: | :------: | :------: |:------: |:------: | 25 | |upper | [pose_resnet_50](/configs/fashion/resnet/deepfashion/res50_deepfashion_upper_256x192.py) | 256x256 | 0.954 | 0.578 | 16.8 | [ckpt](https://download.openmmlab.com/mmpose/fashion/resnet/res50_deepfashion_upper_256x192-41794f03_20210124.pth) | [log](https://download.openmmlab.com/mmpose/fashion/resnet/res50_deepfashion_upper_256x192_20210124.log.json) | 26 | |lower | [pose_resnet_50](/configs/fashion/resnet/deepfashion/res50_deepfashion_lower_256x192.py) | 256x256 | 0.965 | 0.744 | 10.5 | [ckpt](https://download.openmmlab.com/mmpose/fashion/resnet/res50_deepfashion_lower_256x192-1292a839_20210124.pth) | [log](https://download.openmmlab.com/mmpose/fashion/resnet/res50_deepfashion_lower_256x192_20210124.log.json) | 27 | |full | [pose_resnet_50](/configs/fashion/resnet/deepfashion/res50_deepfashion_full_256x192.py) | 256x256 | 0.977 | 0.664 | 12.7 | [ckpt](https://download.openmmlab.com/mmpose/fashion/resnet/res50_deepfashion_full_256x192-0dbd6e42_20210124.pth) | [log](https://download.openmmlab.com/mmpose/fashion/resnet/res50_deepfashion_full_256x192_20210124.log.json) | 28 | -------------------------------------------------------------------------------- /pose/configs/hand/README.md: -------------------------------------------------------------------------------- 1 | # 2D Hand Pose Estimation 2 | 3 | 2D hand pose estimation is defined as the task of detecting the poses (or keypoints) of the hand from an input image. 4 | 5 | Normally, the input images are cropped hand images, where the hand locates at the center; 6 | or the rough location (or the bounding box) of the hand is provided. 7 | 8 | ## Data preparation 9 | 10 | Please follow [DATA Preparation](/docs/tasks/2d_hand_keypoint.md) to prepare data. 11 | 12 | ## Demo 13 | 14 | Please follow [Demo](/demo/2d_hand_demo.md) to run demos. 15 | 16 |
17 | -------------------------------------------------------------------------------- /pose/configs/mesh/hmr/README.md: -------------------------------------------------------------------------------- 1 | # End-to-end Recovery of Human Shape and Pose 2 | 3 | ## Introduction 4 | 5 | 6 | 7 | ```bibtex 8 | @inProceedings{kanazawaHMR18, 9 | title={End-to-end Recovery of Human Shape and Pose}, 10 | author = {Angjoo Kanazawa 11 | and Michael J. Black 12 | and David W. Jacobs 13 | and Jitendra Malik}, 14 | booktitle={Computer Vision and Pattern Recognition (CVPR)}, 15 | year={2018} 16 | } 17 | ``` 18 | 19 | ## Results and models 20 | 21 | ### 3D Human Mesh Estimation 22 | 23 | #### Results on Human3.6M with ground-truth bounding box having MPJPE-PA of 52.60 mm on Protocol2 24 | 25 | | Arch | Input Size | MPJPE (P1)| MPJPE-PA (P1) | MPJPE (P2) | MPJPE-PA (P2) | ckpt | log | 26 | | :-------------- | :-----------: | :------: | :------: | :------: | :------: | :------: |:------: | 27 | | [hmr_resnet_50](/configs/mesh/hmr/hmr_res50_224x224.py) | 224x224 | 80.75 | 55.08 | 80.35 | 52.60 | [ckpt](https://download.openmmlab.com/mmpose/mesh/hmr/hmr_mesh_224x224-c21e8229_20201015.pth) | [log](https://download.openmmlab.com/mmpose/mesh/hmr/hmr_mesh_224x224_20201015.log.json) | 28 | -------------------------------------------------------------------------------- /pose/configs/top_down/README.md: -------------------------------------------------------------------------------- 1 | # 2D Top-down Human Body Pose Estimation 2 | 3 | Multi-person human pose estimation is defined as the task of detecting the poses (or keypoints) of all people from an input image. 4 | Top-down methods divide the task into two stages: human detection and pose estimation. 5 | They perform human detection first, followed by single-person pose estimation given human bounding boxes. 6 | 7 | ## Data preparation 8 | 9 | Please follow [DATA Preparation](/docs/tasks/2d_body_keypoint.md) to prepare data. 10 | 11 | ## Demo 12 | 13 | Please follow [Demo](/demo/2d_human_pose_demo.md#2d-human-pose-demo) to run demos. 14 | 15 | 16 | -------------------------------------------------------------------------------- /pose/configs/top_down/alexnet/README.md: -------------------------------------------------------------------------------- 1 | # Imagenet classification with deep convolutional neural networks 2 | 3 | ## Introduction 4 | 5 | 6 | 7 | ```bibtex 8 | @inproceedings{krizhevsky2012imagenet, 9 | title={Imagenet classification with deep convolutional neural networks}, 10 | author={Krizhevsky, Alex and Sutskever, Ilya and Hinton, Geoffrey E}, 11 | booktitle={Advances in neural information processing systems}, 12 | pages={1097--1105}, 13 | year={2012} 14 | } 15 | ``` 16 | 17 | ## Results and models 18 | 19 | ### 2d Human Pose Estimation 20 | 21 | #### Results on COCO val2017 with detector having human AP of 56.4 on COCO val2017 dataset 22 | 23 | | Arch | Input Size | AP | AP50 | AP75 | AR | AR50 | ckpt | log | 24 | | :----------------- | :-----------: | :------: | :------: | :------: | :------: | :------: |:------: |:------: | 25 | | [pose_alexnet](/configs/top_down/alexnet/coco/alexnet_coco_256x192.py) | 256x192 | 0.397 | 0.758 | 0.381 | 0.478 | 0.822 | [ckpt](https://download.openmmlab.com/mmpose/top_down/alexnet/alexnet_coco_256x192-a7b1fd15_20200727.pth) | [log](https://download.openmmlab.com/mmpose/top_down/alexnet/alexnet_coco_256x192_20200727.log.json) | 26 | -------------------------------------------------------------------------------- /pose/configs/top_down/vgg/README.md: -------------------------------------------------------------------------------- 1 | # Very Deep Convolutional Networks for Large-Scale Image Recognition 2 | 3 | ## Introduction 4 | 5 | 6 | 7 | ```bibtex 8 | @article{simonyan2014very, 9 | title={Very deep convolutional networks for large-scale image recognition}, 10 | author={Simonyan, Karen and Zisserman, Andrew}, 11 | journal={arXiv preprint arXiv:1409.1556}, 12 | year={2014} 13 | } 14 | 15 | ``` 16 | -------------------------------------------------------------------------------- /pose/configs/wholebody/README.md: -------------------------------------------------------------------------------- 1 | # 2D Human Whole-Body Pose Estimation (Top-down) 2 | 3 | 2D human whole-body pose estimation aims to localize dense landmarks on the entire human body including face, hands, body, and feet. 4 | Top-down methods divide the task into two stages: human detection and whole-body pose estimation. 5 | They perform human detection first, followed by single-person whole-body pose estimation given human bounding boxes. 6 | 7 | ## Data preparation 8 | 9 | Please follow [DATA Preparation](/docs/tasks/2d_wholebody_keypoint.md) to prepare data. 10 | 11 | ## Demo 12 | 13 | Please follow [Demo](/demo/2d_wholebody_pose_demo.md) to run demos. 14 | 15 |
16 | -------------------------------------------------------------------------------- /pose/demo/README.md: -------------------------------------------------------------------------------- 1 | # Demo 2 | 3 | This page provides tutorials about running demos. Please click the caption for more information. 4 | 5 |
6 | 7 |
8 |
9 | 10 | [2D human pose demo](docs/2d_human_pose_demo.md) 11 |
12 | 13 |
14 | 15 |
16 |
17 | 18 | [2D human whole-body pose demo](docs/2d_wholebody_pose_demo.md) 19 |
20 | 21 |
22 | 23 |
24 |
25 | 26 | [2D hand pose demo](docs/2d_hand_demo.md) 27 |
28 | 29 |
30 | 31 |
32 |
33 | 34 | [2D face keypoint demo](docs/2d_face_demo.md) 35 |
36 | 37 |
38 | 39 |
40 |
41 | 42 | [2D pose tracking demo](docs/2d_pose_tracking_demo.md) 43 |
44 | 45 |
46 |
47 | 48 | [2D animal_pose demo](docs/2d_animal_demo.md) 49 |
50 | -------------------------------------------------------------------------------- /pose/demo/resources/HRT_arch5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/demo/resources/HRT_arch5.png -------------------------------------------------------------------------------- /pose/demo/resources/demo.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/demo/resources/demo.mp4 -------------------------------------------------------------------------------- /pose/demo/resources/demo_coco.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/demo/resources/demo_coco.gif -------------------------------------------------------------------------------- /pose/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG PYTORCH="1.6.0" 2 | ARG CUDA="10.1" 3 | ARG CUDNN="7" 4 | 5 | FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel 6 | 7 | ENV TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0+PTX" 8 | ENV TORCH_NVCC_FLAGS="-Xfatbin -compress-all" 9 | ENV CMAKE_PREFIX_PATH="$(dirname $(which conda))/../" 10 | 11 | RUN apt-get update && apt-get install -y git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 libgl1-mesa-glx\ 12 | && apt-get clean \ 13 | && rm -rf /var/lib/apt/lists/* 14 | 15 | # Install xtcocotools 16 | RUN pip install cython 17 | RUN pip install xtcocotools 18 | 19 | # Install MMCV 20 | RUN pip install mmcv-full==latest+torch1.6.0+cu101 -f https://download.openmmlab.com/mmcv/dist/index.html 21 | 22 | # Install MMPose 23 | RUN conda clean --all 24 | RUN git clone https://github.com/open-mmlab/mmpose.git /mmpose 25 | WORKDIR /mmpose 26 | RUN mkdir -p /mmpose/data 27 | ENV FORCE_CUDA="1" 28 | RUN pip install -r requirements/build.txt 29 | RUN pip install --no-cache-dir -e . 30 | -------------------------------------------------------------------------------- /pose/docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /pose/docs/data_preparation.md: -------------------------------------------------------------------------------- 1 | # Prepare Datasets 2 | 3 | MMPose supports multiple tasks. Please follow the corresponding guidelines for data preparation. 4 | 5 | - [2D Body Keypoint](tasks/2d_body_keypoint.md) 6 | - [2D Hand Keypoint](tasks/2d_hand_keypoint.md) 7 | - [2D Face Keypoint](tasks/2d_face_keypoint.md) 8 | - [2D WholeBody Keypoint](tasks/2d_wholebody_keypoint.md) 9 | - [2D Fashion Landmark Detection](tasks/2d_fashion_landmark.md) 10 | - [2D Animal Keypoint Detection](tasks/2d_animal_keypoint.md) 11 | - [3D Human Mesh Recovery](tasks/3d_body_mesh.md) 12 | -------------------------------------------------------------------------------- /pose/docs/imgs/acc_curve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/docs/imgs/acc_curve.png -------------------------------------------------------------------------------- /pose/docs/imgs/qq_group_qrcode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/docs/imgs/qq_group_qrcode.jpg -------------------------------------------------------------------------------- /pose/docs/imgs/zhihu_qrcode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/docs/imgs/zhihu_qrcode.jpg -------------------------------------------------------------------------------- /pose/docs/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to MMPose's documentation! 2 | ================================== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | install.md 8 | getting_started.md 9 | demo.md 10 | benchmark.md 11 | 12 | .. toctree:: 13 | :maxdepth: 2 14 | :caption: Datasets 15 | 16 | datasets.md 17 | tasks/2d_body_keypoint.md 18 | tasks/2d_wholebody_keypoint.md 19 | tasks/2d_face_keypoint.md 20 | tasks/2d_hand_keypoint.md 21 | tasks/2d_fashion_landmark.md 22 | tasks/2d_animal_keypoint.md 23 | tasks/3d_body_mesh.md 24 | 25 | .. toctree:: 26 | :maxdepth: 2 27 | :caption: Model Zoo 28 | 29 | modelzoo.md 30 | top_down_models.md 31 | bottom_up_models.md 32 | wholebody_models.md 33 | face_models.md 34 | hand_models.md 35 | fashion_models.md 36 | animal_models.md 37 | mesh_models.md 38 | 39 | .. toctree:: 40 | :maxdepth: 2 41 | :caption: Tutorials 42 | 43 | tutorials/0_config.md 44 | tutorials/1_finetune.md 45 | tutorials/2_new_dataset.md 46 | tutorials/3_data_pipeline.md 47 | tutorials/4_new_modules.md 48 | tutorials/5_export_model.md 49 | tutorials/6_customize_runtime.md 50 | 51 | .. toctree:: 52 | :maxdepth: 2 53 | :caption: Useful Tools and Scripts 54 | 55 | useful_tools.md 56 | 57 | .. toctree:: 58 | :maxdepth: 2 59 | :caption: Notes 60 | 61 | changelog.md 62 | faq.md 63 | 64 | .. toctree:: 65 | :caption: API Reference 66 | 67 | api.rst 68 | 69 | 70 | Indices and tables 71 | ================== 72 | 73 | * :ref:`genindex` 74 | * :ref:`search` 75 | -------------------------------------------------------------------------------- /pose/docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /pose/mmcv_custom/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .checkpoint import load_checkpoint 4 | 5 | __all__ = ['load_checkpoint'] -------------------------------------------------------------------------------- /pose/mmpose/__init__.py: -------------------------------------------------------------------------------- 1 | import mmcv 2 | from mmcv import digit_version, parse_version_info 3 | 4 | from .version import __version__, short_version 5 | 6 | mmcv_minimum_version = '1.1.3' 7 | mmcv_maximum_version = '1.4.0' 8 | mmcv_version = digit_version(mmcv.__version__) 9 | version_info = parse_version_info(__version__) 10 | 11 | assert digit_version(mmcv_minimum_version) <= mmcv_version, \ 12 | f'MMCV=={mmcv.__version__} is used but incompatible. ' \ 13 | f'Please install mmcv>={mmcv_minimum_version}.' 14 | 15 | assert digit_version(mmcv_maximum_version) > mmcv_version, \ 16 | f'MMCV=={mmcv.__version__} is used but incompatible. ' \ 17 | f'Please install mmcv<{mmcv_maximum_version}.' 18 | 19 | __all__ = ['__version__', 'short_version', 'version_info'] 20 | -------------------------------------------------------------------------------- /pose/mmpose/apis/__init__.py: -------------------------------------------------------------------------------- 1 | from .inference import (inference_bottom_up_pose_model, 2 | inference_top_down_pose_model, init_pose_model, 3 | vis_pose_result) 4 | from .inference_tracking import get_track_id, vis_pose_tracking_result 5 | from .test import multi_gpu_test, single_gpu_test 6 | from .train import train_model 7 | 8 | __all__ = [ 9 | 'train_model', 'init_pose_model', 'inference_top_down_pose_model', 10 | 'inference_bottom_up_pose_model', 'multi_gpu_test', 'single_gpu_test', 11 | 'vis_pose_result', 'get_track_id', 'vis_pose_tracking_result' 12 | ] 13 | -------------------------------------------------------------------------------- /pose/mmpose/core/__init__.py: -------------------------------------------------------------------------------- 1 | from .camera import * # noqa: F401, F403 2 | from .evaluation import * # noqa: F401, F403 3 | from .fp16 import * # noqa: F401, F403 4 | from .optimizer import * # noqa: F401, F403 5 | from .post_processing import * # noqa: F401, F403 6 | from .utils import * # noqa: F401, F403 7 | -------------------------------------------------------------------------------- /pose/mmpose/core/camera/__init__.py: -------------------------------------------------------------------------------- 1 | from .camera_base import CAMERAS 2 | from .single_camera import SimpleCamera 3 | 4 | __all__ = ['CAMERAS', 'SimpleCamera'] 5 | -------------------------------------------------------------------------------- /pose/mmpose/core/camera/camera_base.py: -------------------------------------------------------------------------------- 1 | from abc import ABCMeta, abstractmethod 2 | 3 | from mmcv.utils import Registry 4 | 5 | CAMERAS = Registry('camera') 6 | 7 | 8 | class SingleCameraBase(metaclass=ABCMeta): 9 | """Base class for single camera model. 10 | 11 | Args: 12 | param (dict): Camera parameters 13 | 14 | Methods: 15 | world_to_camera: Project points from world coordinates to camera 16 | coordinates 17 | camera_to_world: Project points from camera coordinates to world 18 | coordinates 19 | camera_to_pixel: Project points from camera coordinates to pixel 20 | coordinates 21 | world_to_pixel: Project points from world coordinates to pixel 22 | coordinates 23 | """ 24 | 25 | @abstractmethod 26 | def __init__(self, param): 27 | """Load camera parameters and check validity.""" 28 | 29 | def world_to_camera(self, X): 30 | """Project points from world coordinates to camera coordinates.""" 31 | raise NotImplementedError 32 | 33 | def camera_to_world(self, X): 34 | """Project points from camera coordinates to world coordinates.""" 35 | raise NotImplementedError 36 | 37 | def camera_to_pixel(self, X): 38 | """Project points from camera coordinates to pixel coordinates.""" 39 | raise NotImplementedError 40 | 41 | def world_to_pixel(self, X): 42 | """Project points from world coordinates to pixel coordinates.""" 43 | _X = self.world_to_camera(X) 44 | return self.camera_to_pixel(_X) 45 | -------------------------------------------------------------------------------- /pose/mmpose/core/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | from .bottom_up_eval import (aggregate_results, get_group_preds, 2 | get_multi_stage_outputs) 3 | from .eval_hooks import DistEvalHook, EvalHook 4 | from .mesh_eval import compute_similarity_transform 5 | from .pose3d_eval import keypoint_mpjpe 6 | from .top_down_eval import (keypoint_auc, keypoint_epe, keypoint_pck_accuracy, 7 | keypoints_from_heatmaps, keypoints_from_regression, 8 | pose_pck_accuracy, post_dark_udp) 9 | 10 | __all__ = [ 11 | 'EvalHook', 'DistEvalHook', 'pose_pck_accuracy', 'keypoints_from_heatmaps', 12 | 'keypoints_from_regression', 'keypoint_pck_accuracy', 'keypoint_auc', 13 | 'keypoint_epe', 'get_group_preds', 'get_multi_stage_outputs', 14 | 'aggregate_results', 'compute_similarity_transform', 'post_dark_udp', 15 | 'keypoint_mpjpe' 16 | ] 17 | -------------------------------------------------------------------------------- /pose/mmpose/core/fp16/__init__.py: -------------------------------------------------------------------------------- 1 | from .decorators import auto_fp16, force_fp32 2 | from .hooks import Fp16OptimizerHook, wrap_fp16_model 3 | from .utils import cast_tensor_type 4 | 5 | __all__ = [ 6 | 'auto_fp16', 'force_fp32', 'Fp16OptimizerHook', 'wrap_fp16_model', 7 | 'cast_tensor_type' 8 | ] 9 | -------------------------------------------------------------------------------- /pose/mmpose/core/fp16/utils.py: -------------------------------------------------------------------------------- 1 | from collections import abc 2 | 3 | import numpy as np 4 | import torch 5 | 6 | 7 | def cast_tensor_type(inputs, src_type, dst_type): 8 | """Recursively convert Tensor in inputs from src_type to dst_type. 9 | 10 | Args: 11 | inputs: Inputs that to be casted. 12 | src_type (torch.dtype): Source type. 13 | dst_type (torch.dtype): Destination type. 14 | 15 | Returns: 16 | The same type with inputs, but all contained Tensors have been cast. 17 | """ 18 | if isinstance(inputs, torch.Tensor): 19 | return inputs.to(dst_type) 20 | elif isinstance(inputs, str): 21 | return inputs 22 | elif isinstance(inputs, np.ndarray): 23 | return inputs 24 | elif isinstance(inputs, abc.Mapping): 25 | return type(inputs)({ 26 | k: cast_tensor_type(v, src_type, dst_type) 27 | for k, v in inputs.items() 28 | }) 29 | elif isinstance(inputs, abc.Iterable): 30 | return type(inputs)( 31 | cast_tensor_type(item, src_type, dst_type) for item in inputs) 32 | 33 | return inputs 34 | -------------------------------------------------------------------------------- /pose/mmpose/core/optimizer/__init__.py: -------------------------------------------------------------------------------- 1 | from .builder import build_optimizers 2 | from .registry import OPTIMIZERS 3 | 4 | __all__ = ['build_optimizers', 'OPTIMIZERS'] 5 | -------------------------------------------------------------------------------- /pose/mmpose/core/optimizer/builder.py: -------------------------------------------------------------------------------- 1 | from mmcv.runner import build_optimizer 2 | 3 | 4 | def build_optimizers(model, cfgs): 5 | """Build multiple optimizers from configs. 6 | 7 | If `cfgs` contains several dicts for optimizers, then a dict for each 8 | constructed optimizers will be returned. 9 | If `cfgs` only contains one optimizer config, the constructed optimizer 10 | itself will be returned. 11 | 12 | For example, 13 | 14 | 1) Multiple optimizer configs: 15 | 16 | .. code-block:: python 17 | 18 | optimizer_cfg = dict( 19 | model1=dict(type='SGD', lr=lr), 20 | model2=dict(type='SGD', lr=lr)) 21 | 22 | The return dict is 23 | ``dict('model1': torch.optim.Optimizer, 'model2': torch.optim.Optimizer)`` 24 | 25 | 2) Single optimizer config: 26 | 27 | .. code-block:: python 28 | 29 | optimizer_cfg = dict(type='SGD', lr=lr) 30 | 31 | The return is ``torch.optim.Optimizer``. 32 | 33 | Args: 34 | model (:obj:`nn.Module`): The model with parameters to be optimized. 35 | cfgs (dict): The config dict of the optimizer. 36 | 37 | Returns: 38 | dict[:obj:`torch.optim.Optimizer`] | :obj:`torch.optim.Optimizer`: 39 | The initialized optimizers. 40 | """ 41 | optimizers = {} 42 | if hasattr(model, 'module'): 43 | model = model.module 44 | # determine whether 'cfgs' has several dicts for optimizers 45 | if all(isinstance(v, dict) for v in cfgs.values()): 46 | for key, cfg in cfgs.items(): 47 | cfg_ = cfg.copy() 48 | module = getattr(model, key) 49 | optimizers[key] = build_optimizer(module, cfg_) 50 | return optimizers 51 | 52 | return build_optimizer(model, cfgs) 53 | -------------------------------------------------------------------------------- /pose/mmpose/core/optimizer/registry.py: -------------------------------------------------------------------------------- 1 | from mmcv.utils import Registry 2 | 3 | OPTIMIZERS = Registry('optimizers') 4 | -------------------------------------------------------------------------------- /pose/mmpose/core/post_processing/__init__.py: -------------------------------------------------------------------------------- 1 | from .nms import oks_nms, soft_oks_nms 2 | from .post_transforms import (affine_transform, flip_back, fliplr_joints, 3 | fliplr_regression, get_affine_transform, 4 | get_warp_matrix, rotate_point, transform_preds, 5 | warp_affine_joints) 6 | 7 | __all__ = [ 8 | 'oks_nms', 'soft_oks_nms', 'affine_transform', 'rotate_point', 'flip_back', 9 | 'fliplr_joints', 'fliplr_regression', 'transform_preds', 10 | 'get_affine_transform', 'get_warp_matrix', 'warp_affine_joints' 11 | ] 12 | -------------------------------------------------------------------------------- /pose/mmpose/core/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .dist_utils import allreduce_grads 2 | from .regularizations import WeightNormClipHook 3 | 4 | __all__ = ['allreduce_grads', 'WeightNormClipHook'] 5 | -------------------------------------------------------------------------------- /pose/mmpose/datasets/dataset_wrappers.py: -------------------------------------------------------------------------------- 1 | from .registry import DATASETS 2 | 3 | 4 | @DATASETS.register_module() 5 | class RepeatDataset: 6 | """A wrapper of repeated dataset. 7 | 8 | The length of repeated dataset will be `times` larger than the original 9 | dataset. This is useful when the data loading time is long but the dataset 10 | is small. Using RepeatDataset can reduce the data loading time between 11 | epochs. 12 | 13 | Args: 14 | dataset (:obj:`Dataset`): The dataset to be repeated. 15 | times (int): Repeat times. 16 | """ 17 | 18 | def __init__(self, dataset, times): 19 | self.dataset = dataset 20 | self.times = times 21 | 22 | self._ori_len = len(self.dataset) 23 | 24 | def __getitem__(self, idx): 25 | """Get data.""" 26 | return self.dataset[idx % self._ori_len] 27 | 28 | def __len__(self): 29 | """Length after repetition.""" 30 | return self.times * self._ori_len 31 | -------------------------------------------------------------------------------- /pose/mmpose/datasets/datasets/animal/__init__.py: -------------------------------------------------------------------------------- 1 | from .animal_atrw_dataset import AnimalATRWDataset 2 | from .animal_fly_dataset import AnimalFlyDataset 3 | from .animal_horse10_dataset import AnimalHorse10Dataset 4 | from .animal_locust_dataset import AnimalLocustDataset 5 | from .animal_macaque_dataset import AnimalMacaqueDataset 6 | from .animal_zebra_dataset import AnimalZebraDataset 7 | 8 | __all__ = [ 9 | 'AnimalHorse10Dataset', 'AnimalMacaqueDataset', 'AnimalFlyDataset', 10 | 'AnimalLocustDataset', 'AnimalZebraDataset', 'AnimalATRWDataset' 11 | ] 12 | -------------------------------------------------------------------------------- /pose/mmpose/datasets/datasets/body3d/__init__.py: -------------------------------------------------------------------------------- 1 | from .body3d_h36m_dataset import Body3DH36MDataset 2 | 3 | __all__ = ['Body3DH36MDataset'] 4 | -------------------------------------------------------------------------------- /pose/mmpose/datasets/datasets/bottom_up/__init__.py: -------------------------------------------------------------------------------- 1 | from .bottom_up_aic import BottomUpAicDataset 2 | from .bottom_up_coco import BottomUpCocoDataset 3 | from .bottom_up_crowdpose import BottomUpCrowdPoseDataset 4 | from .bottom_up_mhp import BottomUpMhpDataset 5 | 6 | __all__ = [ 7 | 'BottomUpCocoDataset', 'BottomUpCrowdPoseDataset', 'BottomUpMhpDataset', 8 | 'BottomUpAicDataset' 9 | ] 10 | -------------------------------------------------------------------------------- /pose/mmpose/datasets/datasets/face/__init__.py: -------------------------------------------------------------------------------- 1 | from .face_300w_dataset import Face300WDataset 2 | from .face_aflw_dataset import FaceAFLWDataset 3 | from .face_cofw_dataset import FaceCOFWDataset 4 | from .face_wflw_dataset import FaceWFLWDataset 5 | 6 | __all__ = [ 7 | 'Face300WDataset', 'FaceAFLWDataset', 'FaceWFLWDataset', 'FaceCOFWDataset' 8 | ] 9 | -------------------------------------------------------------------------------- /pose/mmpose/datasets/datasets/fashion/__init__.py: -------------------------------------------------------------------------------- 1 | from .deepfashion_dataset import DeepFashionDataset 2 | 3 | __all__ = ['DeepFashionDataset'] 4 | -------------------------------------------------------------------------------- /pose/mmpose/datasets/datasets/hand/__init__.py: -------------------------------------------------------------------------------- 1 | from .freihand_dataset import FreiHandDataset 2 | from .interhand2d_dataset import InterHand2DDataset 3 | from .interhand3d_dataset import InterHand3DDataset 4 | from .onehand10k_dataset import OneHand10KDataset 5 | from .panoptic_dataset import PanopticDataset 6 | from .rhd2d_dataset import Rhd2DDataset 7 | 8 | __all__ = [ 9 | 'FreiHandDataset', 'InterHand2DDataset', 'InterHand3DDataset', 10 | 'OneHand10KDataset', 'PanopticDataset', 'Rhd2DDataset' 11 | ] 12 | -------------------------------------------------------------------------------- /pose/mmpose/datasets/datasets/mesh/__init__.py: -------------------------------------------------------------------------------- 1 | from .mesh_adv_dataset import MeshAdversarialDataset 2 | from .mesh_h36m_dataset import MeshH36MDataset 3 | from .mesh_mix_dataset import MeshMixDataset 4 | from .mosh_dataset import MoshDataset 5 | 6 | __all__ = [ 7 | 'MeshH36MDataset', 'MoshDataset', 'MeshMixDataset', 8 | 'MeshAdversarialDataset' 9 | ] 10 | -------------------------------------------------------------------------------- /pose/mmpose/datasets/datasets/mesh/mesh_adv_dataset.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from torch.utils.data import Dataset 3 | 4 | from mmpose.datasets.builder import DATASETS, build_dataset 5 | 6 | 7 | @DATASETS.register_module() 8 | class MeshAdversarialDataset(Dataset): 9 | """Mix Dataset for the adversarial training in 3D human mesh estimation 10 | task. 11 | 12 | The dataset combines data from two datasets and 13 | return a dict containing data from two datasets. 14 | 15 | Args: 16 | train_dataset (Dataset): Dataset for 3D human mesh estimation. 17 | adversarial_dataset (Dataset): Dataset for adversarial learning, 18 | provides real SMPL parameters. 19 | """ 20 | 21 | def __init__(self, train_dataset, adversarial_dataset): 22 | super().__init__() 23 | self.train_dataset = build_dataset(train_dataset) 24 | self.adversarial_dataset = build_dataset(adversarial_dataset) 25 | self.length = len(self.train_dataset) 26 | 27 | def __len__(self): 28 | """Get the size of the dataset.""" 29 | return self.length 30 | 31 | def __getitem__(self, i): 32 | """Given index, get the data from train dataset and randomly sample an 33 | item from adversarial dataset. 34 | 35 | Return a dict containing data from train and adversarial dataset. 36 | """ 37 | data = self.train_dataset[i] 38 | ind_adv = np.random.randint( 39 | low=0, high=len(self.adversarial_dataset), dtype=np.int) 40 | data.update(self.adversarial_dataset[ind_adv % 41 | len(self.adversarial_dataset)]) 42 | return data 43 | -------------------------------------------------------------------------------- /pose/mmpose/datasets/datasets/top_down/__init__.py: -------------------------------------------------------------------------------- 1 | from .topdown_aic_dataset import TopDownAicDataset 2 | from .topdown_coco_dataset import TopDownCocoDataset 3 | from .topdown_coco_wholebody_dataset import TopDownCocoWholeBodyDataset 4 | from .topdown_crowdpose_dataset import TopDownCrowdPoseDataset 5 | from .topdown_jhmdb_dataset import TopDownJhmdbDataset 6 | from .topdown_mhp_dataset import TopDownMhpDataset 7 | from .topdown_mpii_dataset import TopDownMpiiDataset 8 | from .topdown_mpii_trb_dataset import TopDownMpiiTrbDataset 9 | from .topdown_ochuman_dataset import TopDownOCHumanDataset 10 | from .topdown_posetrack18_dataset import TopDownPoseTrack18Dataset 11 | 12 | __all__ = [ 13 | 'TopDownAicDataset', 'TopDownCocoDataset', 'TopDownCocoWholeBodyDataset', 14 | 'TopDownCrowdPoseDataset', 'TopDownMpiiDataset', 'TopDownMpiiTrbDataset', 15 | 'TopDownOCHumanDataset', 'TopDownPoseTrack18Dataset', 16 | 'TopDownJhmdbDataset', 'TopDownMhpDataset' 17 | ] 18 | -------------------------------------------------------------------------------- /pose/mmpose/datasets/pipelines/__init__.py: -------------------------------------------------------------------------------- 1 | from .bottom_up_transform import * # noqa 2 | from .hand_transform import * # noqa 3 | from .loading import LoadImageFromFile # noqa 4 | from .mesh_transform import * # noqa 5 | from .pose3d_transform import * # noqa 6 | from .shared_transform import * # noqa 7 | from .top_down_transform import * # noqa 8 | -------------------------------------------------------------------------------- /pose/mmpose/datasets/pipelines/loading.py: -------------------------------------------------------------------------------- 1 | import mmcv 2 | 3 | from ..registry import PIPELINES 4 | 5 | 6 | @PIPELINES.register_module() 7 | class LoadImageFromFile: 8 | """Loading image from file. 9 | 10 | Args: 11 | color_type (str): Flags specifying the color type of a loaded image, 12 | candidates are 'color', 'grayscale' and 'unchanged'. 13 | channel_order (str): Order of channel, candidates are 'bgr' and 'rgb'. 14 | """ 15 | 16 | def __init__(self, 17 | to_float32=False, 18 | color_type='color', 19 | channel_order='rgb'): 20 | self.to_float32 = to_float32 21 | self.color_type = color_type 22 | self.channel_order = channel_order 23 | 24 | def __call__(self, results): 25 | """Loading image from file.""" 26 | image_file = results['image_file'] 27 | img = mmcv.imread(image_file, self.color_type, self.channel_order) 28 | 29 | if img is None: 30 | raise ValueError('Fail to read {}'.format(image_file)) 31 | 32 | results['img'] = img 33 | return results 34 | -------------------------------------------------------------------------------- /pose/mmpose/datasets/registry.py: -------------------------------------------------------------------------------- 1 | from mmcv.utils import Registry 2 | 3 | DATASETS = Registry('dataset') 4 | PIPELINES = Registry('pipeline') 5 | -------------------------------------------------------------------------------- /pose/mmpose/datasets/samplers/__init__.py: -------------------------------------------------------------------------------- 1 | from .distributed_sampler import DistributedSampler 2 | 3 | __all__ = ['DistributedSampler'] 4 | -------------------------------------------------------------------------------- /pose/mmpose/datasets/samplers/distributed_sampler.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch.utils.data import DistributedSampler as _DistributedSampler 3 | 4 | 5 | class DistributedSampler(_DistributedSampler): 6 | """DistributedSampler inheriting from 7 | `torch.utils.data.DistributedSampler`. 8 | 9 | In pytorch of lower versions, there is no `shuffle` argument. This child 10 | class will port one to DistributedSampler. 11 | """ 12 | 13 | def __init__(self, 14 | dataset, 15 | num_replicas=None, 16 | rank=None, 17 | shuffle=True, 18 | seed=0): 19 | super().__init__( 20 | dataset, num_replicas=num_replicas, rank=rank, shuffle=shuffle) 21 | # for the compatibility from PyTorch 1.3+ 22 | self.seed = seed if seed is not None else 0 23 | 24 | def __iter__(self): 25 | """Deterministically shuffle based on epoch.""" 26 | if self.shuffle: 27 | g = torch.Generator() 28 | g.manual_seed(self.epoch + self.seed) 29 | indices = torch.randperm(len(self.dataset), generator=g).tolist() 30 | else: 31 | indices = torch.arange(len(self.dataset)).tolist() 32 | 33 | # add extra samples to make it evenly divisible 34 | indices += indices[:(self.total_size - len(indices))] 35 | assert len(indices) == self.total_size 36 | 37 | # subsample 38 | indices = indices[self.rank:self.total_size:self.num_replicas] 39 | assert len(indices) == self.num_samples 40 | return iter(indices) 41 | -------------------------------------------------------------------------------- /pose/mmpose/deprecated.py: -------------------------------------------------------------------------------- 1 | from .datasets.builder import DATASETS 2 | from .datasets.datasets.top_down.topdown_base_dataset import TopDownBaseDataset 3 | 4 | 5 | @DATASETS.register_module() 6 | class TopDownFreiHandDataset(TopDownBaseDataset): 7 | """Deprecated TopDownFreiHandDataset.""" 8 | 9 | def __init__(self, *args, **kwargs): 10 | raise (ImportError( 11 | 'TopDownFreiHandDataset has been renamed into FreiHandDataset,' 12 | 'check https://github.com/open-mmlab/mmpose/pull/202 for details')) 13 | 14 | def _get_db(self): 15 | return [] 16 | 17 | def evaluate(self, cfg, preds, output_dir, *args, **kwargs): 18 | return None 19 | 20 | 21 | @DATASETS.register_module() 22 | class TopDownOneHand10KDataset(TopDownBaseDataset): 23 | """Deprecated TopDownOneHand10KDataset.""" 24 | 25 | def __init__(self, *args, **kwargs): 26 | raise (ImportError( 27 | 'TopDownOneHand10KDataset has been renamed into OneHand10KDataset,' 28 | 'check https://github.com/open-mmlab/mmpose/pull/202 for details')) 29 | 30 | def _get_db(self): 31 | return [] 32 | 33 | def evaluate(self, cfg, preds, output_dir, *args, **kwargs): 34 | return None 35 | 36 | 37 | @DATASETS.register_module() 38 | class TopDownPanopticDataset(TopDownBaseDataset): 39 | """Deprecated TopDownPanopticDataset.""" 40 | 41 | def __init__(self, *args, **kwargs): 42 | raise (ImportError( 43 | 'TopDownPanopticDataset has been renamed into PanopticDataset,' 44 | 'check https://github.com/open-mmlab/mmpose/pull/202 for details')) 45 | 46 | def _get_db(self): 47 | return [] 48 | 49 | def evaluate(self, cfg, preds, output_dir, *args, **kwargs): 50 | return None 51 | -------------------------------------------------------------------------------- /pose/mmpose/models/__init__.py: -------------------------------------------------------------------------------- 1 | from .backbones import * # noqa 2 | from .builder import (build_backbone, build_head, build_loss, build_neck, 3 | build_posenet) 4 | from .detectors import * # noqa 5 | from .keypoint_heads import * # noqa 6 | from .losses import * # noqa 7 | from .mesh_heads import * # noqa 8 | from .necks import * # noqa 9 | from .registry import BACKBONES, HEADS, LOSSES, POSENETS 10 | 11 | __all__ = [ 12 | 'BACKBONES', 'HEADS', 'LOSSES', 'POSENETS', 'build_backbone', 'build_head', 13 | 'build_loss', 'build_posenet', 'build_neck' 14 | ] 15 | -------------------------------------------------------------------------------- /pose/mmpose/models/backbones/__init__.py: -------------------------------------------------------------------------------- 1 | from .alexnet import AlexNet 2 | from .cpm import CPM 3 | from .hourglass import HourglassNet 4 | from .hrnet import HRNet 5 | from .mobilenet_v2 import MobileNetV2 6 | from .mobilenet_v3 import MobileNetV3 7 | from .mspn import MSPN 8 | from .regnet import RegNet 9 | from .resnest import ResNeSt 10 | from .resnet import ResNet, ResNetV1d 11 | from .resnext import ResNeXt 12 | from .rsn import RSN 13 | from .scnet import SCNet 14 | from .seresnet import SEResNet 15 | from .seresnext import SEResNeXt 16 | from .shufflenet_v1 import ShuffleNetV1 17 | from .shufflenet_v2 import ShuffleNetV2 18 | from .tcn import TCN 19 | from .vgg import VGG 20 | from .hrt import HRT 21 | from .vit import VisionTransformer 22 | 23 | __all__ = [ 24 | "AlexNet", 25 | "HourglassNet", 26 | "HRNet", 27 | "MobileNetV2", 28 | "MobileNetV3", 29 | "RegNet", 30 | "ResNet", 31 | "ResNetV1d", 32 | "ResNeXt", 33 | "SCNet", 34 | "SEResNet", 35 | "SEResNeXt", 36 | "ShuffleNetV1", 37 | "ShuffleNetV2", 38 | "CPM", 39 | "RSN", 40 | "MSPN", 41 | "ResNeSt", 42 | "VGG", 43 | "TCN", 44 | "HRT", 45 | "VisionTransformer", 46 | ] 47 | -------------------------------------------------------------------------------- /pose/mmpose/models/backbones/base_backbone.py: -------------------------------------------------------------------------------- 1 | import logging 2 | from abc import ABCMeta, abstractmethod 3 | 4 | import torch.nn as nn 5 | 6 | from .utils import load_checkpoint 7 | 8 | 9 | class BaseBackbone(nn.Module, metaclass=ABCMeta): 10 | """Base backbone. 11 | 12 | This class defines the basic functions of a backbone. Any backbone that 13 | inherits this class should at least define its own `forward` function. 14 | """ 15 | 16 | def init_weights(self, pretrained=None): 17 | """Init backbone weights. 18 | 19 | Args: 20 | pretrained (str | None): If pretrained is a string, then it 21 | initializes backbone weights by loading the pretrained 22 | checkpoint. If pretrained is None, then it follows default 23 | initializer or customized initializer in subclasses. 24 | """ 25 | if isinstance(pretrained, str): 26 | logger = logging.getLogger() 27 | load_checkpoint(self, pretrained, strict=False, logger=logger) 28 | elif pretrained is None: 29 | # use default initializer or customized initializer in subclasses 30 | pass 31 | else: 32 | raise TypeError('pretrained must be a str or None.' 33 | f' But received {type(pretrained)}.') 34 | 35 | @abstractmethod 36 | def forward(self, x): 37 | """Forward function. 38 | 39 | Args: 40 | x (tensor | tuple[tensor]): x could be a Torch.tensor or a tuple of 41 | Torch.tensor, containing input data for forward computation. 42 | """ 43 | -------------------------------------------------------------------------------- /pose/mmpose/models/backbones/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/mmpose/models/backbones/modules/__init__.py -------------------------------------------------------------------------------- /pose/mmpose/models/backbones/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .channel_shuffle import channel_shuffle 2 | from .inverted_residual import InvertedResidual 3 | from .make_divisible import make_divisible 4 | from .se_layer import SELayer 5 | from .utils import load_checkpoint 6 | 7 | __all__ = [ 8 | 'channel_shuffle', 'make_divisible', 'InvertedResidual', 'SELayer', 9 | 'load_checkpoint' 10 | ] 11 | -------------------------------------------------------------------------------- /pose/mmpose/models/backbones/utils/channel_shuffle.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | def channel_shuffle(x, groups): 5 | """Channel Shuffle operation. 6 | 7 | This function enables cross-group information flow for multiple groups 8 | convolution layers. 9 | 10 | Args: 11 | x (Tensor): The input tensor. 12 | groups (int): The number of groups to divide the input tensor 13 | in the channel dimension. 14 | 15 | Returns: 16 | Tensor: The output tensor after channel shuffle operation. 17 | """ 18 | 19 | batch_size, num_channels, height, width = x.size() 20 | assert (num_channels % groups == 0), ('num_channels should be ' 21 | 'divisible by groups') 22 | channels_per_group = num_channels // groups 23 | 24 | x = x.view(batch_size, groups, channels_per_group, height, width) 25 | x = torch.transpose(x, 1, 2).contiguous() 26 | x = x.view(batch_size, -1, height, width) 27 | 28 | return x 29 | -------------------------------------------------------------------------------- /pose/mmpose/models/backbones/utils/make_divisible.py: -------------------------------------------------------------------------------- 1 | def make_divisible(value, divisor, min_value=None, min_ratio=0.9): 2 | """Make divisible function. 3 | 4 | This function rounds the channel number down to the nearest value that can 5 | be divisible by the divisor. 6 | 7 | Args: 8 | value (int): The original channel number. 9 | divisor (int): The divisor to fully divide the channel number. 10 | min_value (int, optional): The minimum value of the output channel. 11 | Default: None, means that the minimum value equal to the divisor. 12 | min_ratio (float, optional): The minimum ratio of the rounded channel 13 | number to the original channel number. Default: 0.9. 14 | Returns: 15 | int: The modified output channel number 16 | """ 17 | 18 | if min_value is None: 19 | min_value = divisor 20 | new_value = max(min_value, int(value + divisor / 2) // divisor * divisor) 21 | # Make sure that round down does not go down by more than (1-min_ratio). 22 | if new_value < min_ratio * value: 23 | new_value += divisor 24 | return new_value 25 | -------------------------------------------------------------------------------- /pose/mmpose/models/builder.py: -------------------------------------------------------------------------------- 1 | from mmcv.utils import build_from_cfg 2 | from torch import nn 3 | 4 | from .registry import BACKBONES, HEADS, LOSSES, NECKS, POSENETS 5 | 6 | 7 | def build(cfg, registry, default_args=None): 8 | """Build a module. 9 | 10 | Args: 11 | cfg (dict, list[dict]): The config of modules, it is either a dict 12 | or a list of configs. 13 | registry (:obj:`Registry`): A registry the module belongs to. 14 | default_args (dict, optional): Default arguments to build the module. 15 | Defaults to None. 16 | 17 | Returns: 18 | nn.Module: A built nn module. 19 | """ 20 | 21 | if isinstance(cfg, list): 22 | modules = [ 23 | build_from_cfg(cfg_, registry, default_args) for cfg_ in cfg 24 | ] 25 | return nn.Sequential(*modules) 26 | 27 | return build_from_cfg(cfg, registry, default_args) 28 | 29 | 30 | def build_backbone(cfg): 31 | """Build backbone.""" 32 | return build(cfg, BACKBONES) 33 | 34 | 35 | def build_neck(cfg): 36 | """Build neck.""" 37 | return build(cfg, NECKS) 38 | 39 | 40 | def build_head(cfg): 41 | """Build head.""" 42 | return build(cfg, HEADS) 43 | 44 | 45 | def build_loss(cfg): 46 | """Build loss.""" 47 | return build(cfg, LOSSES) 48 | 49 | 50 | def build_posenet(cfg): 51 | """Build posenet.""" 52 | return build(cfg, POSENETS) 53 | -------------------------------------------------------------------------------- /pose/mmpose/models/detectors/__init__.py: -------------------------------------------------------------------------------- 1 | from .bottom_up import BottomUp 2 | from .mesh import ParametricMesh 3 | from .multi_task import MultiTask 4 | from .pose_lifter import PoseLifter 5 | from .top_down import TopDown 6 | 7 | __all__ = ['TopDown', 'BottomUp', 'ParametricMesh', 'MultiTask', 'PoseLifter'] 8 | -------------------------------------------------------------------------------- /pose/mmpose/models/keypoint_heads/__init__.py: -------------------------------------------------------------------------------- 1 | from .bottom_up_higher_resolution_head import BottomUpHigherResolutionHead 2 | from .bottom_up_simple_head import BottomUpSimpleHead 3 | from .fc_head import FcHead 4 | from .heatmap_1d_head import Heatmap1DHead 5 | from .heatmap_3d_head import HeatMap3DHead 6 | from .multilabel_classification_head import MultilabelClassificationHead 7 | from .temporal_regression_head import TemporalRegressionHead 8 | from .top_down_multi_stage_head import TopDownMSMUHead, TopDownMultiStageHead 9 | from .top_down_simple_head import TopDownSimpleHead 10 | 11 | __all__ = [ 12 | 'TopDownSimpleHead', 'TopDownMultiStageHead', 'TopDownMSMUHead', 13 | 'BottomUpHigherResolutionHead', 'BottomUpSimpleHead', 'FcHead', 14 | 'TemporalRegressionHead', 'HeatMap3DHead', 'Heatmap1DHead', 15 | 'MultilabelClassificationHead' 16 | ] 17 | -------------------------------------------------------------------------------- /pose/mmpose/models/losses/__init__.py: -------------------------------------------------------------------------------- 1 | from .classfication_loss import BCELoss 2 | from .mesh_loss import GANLoss, MeshLoss 3 | from .mse_loss import JointsMSELoss, JointsOHKMMSELoss 4 | from .multi_loss_factory import AELoss, HeatmapLoss, MultiLossFactory 5 | from .regression_loss import L1Loss, MPJPELoss, MSELoss, SmoothL1Loss, WingLoss 6 | 7 | __all__ = [ 8 | 'JointsMSELoss', 'JointsOHKMMSELoss', 'HeatmapLoss', 'AELoss', 9 | 'MultiLossFactory', 'MeshLoss', 'GANLoss', 'SmoothL1Loss', 'WingLoss', 10 | 'MPJPELoss', 'MSELoss', 'L1Loss', 'BCELoss' 11 | ] 12 | -------------------------------------------------------------------------------- /pose/mmpose/models/losses/classfication_loss.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | import torch.nn.functional as F 3 | 4 | from ..registry import LOSSES 5 | 6 | 7 | @LOSSES.register_module() 8 | class BCELoss(nn.Module): 9 | """Binary Cross Entropy loss.""" 10 | 11 | def __init__(self, use_target_weight=False, loss_weight=1.): 12 | super().__init__() 13 | self.criterion = F.binary_cross_entropy 14 | self.use_target_weight = use_target_weight 15 | self.loss_weight = loss_weight 16 | 17 | def forward(self, output, target, target_weight): 18 | """Forward function. 19 | 20 | Note: 21 | batch_size: N 22 | num_labels: K 23 | 24 | Args: 25 | output (torch.Tensor[N, K]): Output classification. 26 | target (torch.Tensor[N, K]): Target classification. 27 | target_weight (torch.Tensor[N, K] or torch.Tensor[N]): 28 | Weights across different labels. 29 | """ 30 | 31 | if self.use_target_weight: 32 | loss = self.criterion(output, target, reduction='none') 33 | if target_weight.dim() == 1: 34 | target_weight = target_weight[:, None] 35 | loss = (loss * target_weight).mean() 36 | else: 37 | loss = self.criterion(output, target) 38 | 39 | return loss * self.loss_weight 40 | -------------------------------------------------------------------------------- /pose/mmpose/models/mesh_heads/__init__.py: -------------------------------------------------------------------------------- 1 | from .hmr_head import MeshHMRHead 2 | 3 | __all__ = ['MeshHMRHead'] 4 | -------------------------------------------------------------------------------- /pose/mmpose/models/necks/__init__.py: -------------------------------------------------------------------------------- 1 | from .gap_neck import GlobalAveragePooling 2 | 3 | __all__ = ['GlobalAveragePooling'] 4 | -------------------------------------------------------------------------------- /pose/mmpose/models/necks/gap_neck.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | 4 | from ..registry import NECKS 5 | 6 | 7 | @NECKS.register_module() 8 | class GlobalAveragePooling(nn.Module): 9 | """Global Average Pooling neck. 10 | 11 | Note that we use `view` to remove extra channel after pooling. We do not 12 | use `squeeze` as it will also remove the batch dimension when the tensor 13 | has a batch dimension of size 1, which can lead to unexpected errors. 14 | """ 15 | 16 | def __init__(self): 17 | super().__init__() 18 | self.gap = nn.AdaptiveAvgPool2d((1, 1)) 19 | 20 | def init_weights(self): 21 | pass 22 | 23 | def forward(self, inputs): 24 | if isinstance(inputs, tuple): 25 | outs = tuple([self.gap(x) for x in inputs]) 26 | outs = tuple( 27 | [out.view(x.size(0), -1) for out, x in zip(outs, inputs)]) 28 | elif isinstance(inputs, list): 29 | outs = [self.gap(x) for x in inputs] 30 | outs = [out.view(x.size(0), -1) for out, x in zip(outs, inputs)] 31 | elif isinstance(inputs, torch.Tensor): 32 | outs = self.gap(inputs) 33 | outs = outs.view(inputs.size(0), -1) 34 | else: 35 | raise TypeError('neck inputs should be tuple or torch.tensor') 36 | return outs 37 | -------------------------------------------------------------------------------- /pose/mmpose/models/registry.py: -------------------------------------------------------------------------------- 1 | from mmcv.utils import Registry 2 | 3 | BACKBONES = Registry('backbone') 4 | NECKS = Registry('neck') 5 | HEADS = Registry('head') 6 | LOSSES = Registry('loss') 7 | POSENETS = Registry('posenet') 8 | -------------------------------------------------------------------------------- /pose/mmpose/models/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/mmpose/models/utils/__init__.py -------------------------------------------------------------------------------- /pose/mmpose/models/utils/ops.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | 3 | import torch 4 | import torch.nn.functional as F 5 | 6 | 7 | def resize(input, 8 | size=None, 9 | scale_factor=None, 10 | mode='nearest', 11 | align_corners=None, 12 | warning=True): 13 | if warning: 14 | if size is not None and align_corners: 15 | input_h, input_w = tuple(int(x) for x in input.shape[2:]) 16 | output_h, output_w = tuple(int(x) for x in size) 17 | if output_h > input_h or output_w > output_h: 18 | if ((output_h > 1 and output_w > 1 and input_h > 1 19 | and input_w > 1) and (output_h - 1) % (input_h - 1) 20 | and (output_w - 1) % (input_w - 1)): 21 | warnings.warn( 22 | f'When align_corners={align_corners}, ' 23 | 'the output would more aligned if ' 24 | f'input size {(input_h, input_w)} is `x+1` and ' 25 | f'out size {(output_h, output_w)} is `nx+1`') 26 | if isinstance(size, torch.Size): 27 | size = tuple(int(x) for x in size) 28 | return F.interpolate(input, size, scale_factor, mode, align_corners) 29 | -------------------------------------------------------------------------------- /pose/mmpose/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .collect_env import collect_env 2 | from .logger import get_root_logger 3 | 4 | __all__ = ['get_root_logger', 'collect_env'] 5 | -------------------------------------------------------------------------------- /pose/mmpose/utils/collect_env.py: -------------------------------------------------------------------------------- 1 | from mmcv.utils import collect_env as collect_basic_env 2 | from mmcv.utils import get_git_hash 3 | 4 | import mmpose 5 | 6 | 7 | def collect_env(): 8 | env_info = collect_basic_env() 9 | env_info['MMPose'] = (mmpose.__version__ + '+' + get_git_hash(digits=7)) 10 | return env_info 11 | 12 | 13 | if __name__ == '__main__': 14 | for name, val in collect_env().items(): 15 | print(f'{name}: {val}') 16 | -------------------------------------------------------------------------------- /pose/mmpose/utils/logger.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from mmcv.utils import get_logger 4 | 5 | 6 | def get_root_logger(log_file=None, log_level=logging.INFO): 7 | """Use `get_logger` method in mmcv to get the root logger. 8 | 9 | The logger will be initialized if it has not been initialized. By default a 10 | StreamHandler will be added. If `log_file` is specified, a FileHandler will 11 | also be added. The name of the root logger is the top-level package name, 12 | e.g., "mmpose". 13 | 14 | Args: 15 | log_file (str | None): The log filename. If specified, a FileHandler 16 | will be added to the root logger. 17 | log_level (int): The root logger level. Note that only the process of 18 | rank 0 is affected, while other processes will set the level to 19 | "Error" and be silent most of the time. 20 | 21 | Returns: 22 | logging.Logger: The root logger. 23 | """ 24 | return get_logger(__name__.split('.')[0], log_file, log_level) 25 | -------------------------------------------------------------------------------- /pose/requirements.txt: -------------------------------------------------------------------------------- 1 | -r requirements/build.txt 2 | -r requirements/runtime.txt 3 | -r requirements/tests.txt 4 | -r requirements/optional.txt 5 | -------------------------------------------------------------------------------- /pose/requirements/build.txt: -------------------------------------------------------------------------------- 1 | # These must be installed before building mmpose 2 | numpy 3 | torch>=1.3 4 | -------------------------------------------------------------------------------- /pose/requirements/docs.txt: -------------------------------------------------------------------------------- 1 | recommonmark 2 | sphinx 3 | sphinx_markdown_tables 4 | sphinx_rtd_theme 5 | -------------------------------------------------------------------------------- /pose/requirements/optional.txt: -------------------------------------------------------------------------------- 1 | albumentations>=0.3.2 2 | onnx 3 | onnxruntime 4 | poseval@git+https://github.com/svenkreiss/poseval.git 5 | smplx 6 | -------------------------------------------------------------------------------- /pose/requirements/readthedocs.txt: -------------------------------------------------------------------------------- 1 | mmcv-full 2 | munkres 3 | poseval@git+https://github.com/svenkreiss/poseval.git 4 | scipy 5 | titlecase 6 | torch 7 | torchvision 8 | xtcocotools>=1.6 9 | -------------------------------------------------------------------------------- /pose/requirements/runtime.txt: -------------------------------------------------------------------------------- 1 | chumpy 2 | dataclasses; python_version == '3.6' 3 | json_tricks 4 | matplotlib 5 | munkres 6 | numpy 7 | opencv-python 8 | pillow 9 | scipy 10 | torchvision 11 | xtcocotools>=1.6 12 | -------------------------------------------------------------------------------- /pose/requirements/tests.txt: -------------------------------------------------------------------------------- 1 | coverage 2 | flake8 3 | interrogate 4 | isort==4.3.21 5 | pytest 6 | pytest-runner 7 | smplx 8 | xdoctest >= 0.10.0 9 | yapf 10 | -------------------------------------------------------------------------------- /pose/resources/mmpose-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/resources/mmpose-logo.png -------------------------------------------------------------------------------- /pose/run_dist.sh: -------------------------------------------------------------------------------- 1 | df 2 | 3 | CONFIG=$1 4 | 5 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 sh tools/dist_train.sh configs/$CONFIG.py 8 -------------------------------------------------------------------------------- /pose/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal=1 3 | 4 | [aliases] 5 | test=pytest 6 | 7 | [tool:pytest] 8 | addopts=tests/ 9 | 10 | [yapf] 11 | based_on_style = pep8 12 | blank_line_before_nested_class_or_def = true 13 | split_before_expression_after_opening_paren = true 14 | split_penalty_import_names=0 15 | SPLIT_PENALTY_AFTER_OPENING_BRACKET=800 16 | 17 | [isort] 18 | line_length = 79 19 | multi_line_output = 0 20 | known_standard_library = pkg_resources,setuptools 21 | known_first_party = mmpose 22 | known_third_party = cv2,h5py,json_tricks,matplotlib,mmcv,munkres,numpy,packaging,poseval,pytest,scipy,seaborn,spacepy,titlecase,torch,torchvision,xtcocotools 23 | no_lines_before = STDLIB,LOCALFOLDER 24 | default_section = THIRDPARTY 25 | -------------------------------------------------------------------------------- /pose/tests/data/300w/indoor_020.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/300w/indoor_020.png -------------------------------------------------------------------------------- /pose/tests/data/300w/indoor_029.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/300w/indoor_029.png -------------------------------------------------------------------------------- /pose/tests/data/aflw/image04476.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/aflw/image04476.jpg -------------------------------------------------------------------------------- /pose/tests/data/aflw/image22568.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/aflw/image22568.jpg -------------------------------------------------------------------------------- /pose/tests/data/aic/054d9ce9201beffc76e5ff2169d2af2f027002ca.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/aic/054d9ce9201beffc76e5ff2169d2af2f027002ca.jpg -------------------------------------------------------------------------------- /pose/tests/data/aic/fa436c914fe4a8ec1ec5474af4d3820b84d17561.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/aic/fa436c914fe4a8ec1ec5474af4d3820b84d17561.jpg -------------------------------------------------------------------------------- /pose/tests/data/aic/ff945ae2e729f24eea992814639d59b3bdec8bd8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/aic/ff945ae2e729f24eea992814639d59b3bdec8bd8.jpg -------------------------------------------------------------------------------- /pose/tests/data/atrw/000061.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/atrw/000061.jpg -------------------------------------------------------------------------------- /pose/tests/data/atrw/003464.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/atrw/003464.jpg -------------------------------------------------------------------------------- /pose/tests/data/coco/000000000785.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/coco/000000000785.jpg -------------------------------------------------------------------------------- /pose/tests/data/coco/000000040083.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/coco/000000040083.jpg -------------------------------------------------------------------------------- /pose/tests/data/coco/000000196141.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/coco/000000196141.jpg -------------------------------------------------------------------------------- /pose/tests/data/coco/000000197388.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/coco/000000197388.jpg -------------------------------------------------------------------------------- /pose/tests/data/cofw/001766.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/cofw/001766.jpg -------------------------------------------------------------------------------- /pose/tests/data/cofw/001805.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/cofw/001805.jpg -------------------------------------------------------------------------------- /pose/tests/data/crowdpose/103319.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/crowdpose/103319.jpg -------------------------------------------------------------------------------- /pose/tests/data/crowdpose/106848.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/crowdpose/106848.jpg -------------------------------------------------------------------------------- /pose/tests/data/fld/img_00000128.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/fld/img_00000128.jpg -------------------------------------------------------------------------------- /pose/tests/data/fld/img_00000132.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/fld/img_00000132.jpg -------------------------------------------------------------------------------- /pose/tests/data/fly/1400.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/fly/1400.jpg -------------------------------------------------------------------------------- /pose/tests/data/fly/1450.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/fly/1450.jpg -------------------------------------------------------------------------------- /pose/tests/data/freihand/00000355.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/freihand/00000355.jpg -------------------------------------------------------------------------------- /pose/tests/data/freihand/00017620.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/freihand/00017620.jpg -------------------------------------------------------------------------------- /pose/tests/data/freihand/00032915.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/freihand/00032915.jpg -------------------------------------------------------------------------------- /pose/tests/data/freihand/00050180.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/freihand/00050180.jpg -------------------------------------------------------------------------------- /pose/tests/data/freihand/00065475.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/freihand/00065475.jpg -------------------------------------------------------------------------------- /pose/tests/data/freihand/00082740.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/freihand/00082740.jpg -------------------------------------------------------------------------------- /pose/tests/data/freihand/00098035.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/freihand/00098035.jpg -------------------------------------------------------------------------------- /pose/tests/data/freihand/00115300.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/freihand/00115300.jpg -------------------------------------------------------------------------------- /pose/tests/data/h36m/BF_IUV_gt/S1_Directions_1.54138969_000001_467_466.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/h36m/BF_IUV_gt/S1_Directions_1.54138969_000001_467_466.png -------------------------------------------------------------------------------- /pose/tests/data/h36m/BF_IUV_gt/S5_SittingDown.54138969_002061_478_619.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/h36m/BF_IUV_gt/S5_SittingDown.54138969_002061_478_619.png -------------------------------------------------------------------------------- /pose/tests/data/h36m/BF_IUV_gt/S7_Greeting.55011271_000396_365_433.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/h36m/BF_IUV_gt/S7_Greeting.55011271_000396_365_433.png -------------------------------------------------------------------------------- /pose/tests/data/h36m/BF_IUV_gt/S8_WalkDog_1.55011271_000026_592_382.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/h36m/BF_IUV_gt/S8_WalkDog_1.55011271_000026_592_382.png -------------------------------------------------------------------------------- /pose/tests/data/h36m/S1_Directions_1.54138969_000001.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/h36m/S1_Directions_1.54138969_000001.jpg -------------------------------------------------------------------------------- /pose/tests/data/h36m/S5_SittingDown.54138969_002061.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/h36m/S5_SittingDown.54138969_002061.jpg -------------------------------------------------------------------------------- /pose/tests/data/h36m/S7_Greeting.55011271_000396.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/h36m/S7_Greeting.55011271_000396.jpg -------------------------------------------------------------------------------- /pose/tests/data/h36m/S8_WalkDog_1.55011271_000026.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/h36m/S8_WalkDog_1.55011271_000026.jpg -------------------------------------------------------------------------------- /pose/tests/data/h36m/test_h36m.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/h36m/test_h36m.npz -------------------------------------------------------------------------------- /pose/tests/data/h36m/test_h36m_body3d.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/h36m/test_h36m_body3d.npz -------------------------------------------------------------------------------- /pose/tests/data/horse10/0244.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/horse10/0244.png -------------------------------------------------------------------------------- /pose/tests/data/horse10/0292.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/horse10/0292.png -------------------------------------------------------------------------------- /pose/tests/data/horse10/0465.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/horse10/0465.png -------------------------------------------------------------------------------- /pose/tests/data/interhand2.6m/image2017.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/interhand2.6m/image2017.jpg -------------------------------------------------------------------------------- /pose/tests/data/interhand2.6m/image29590.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/interhand2.6m/image29590.jpg -------------------------------------------------------------------------------- /pose/tests/data/interhand2.6m/image44669.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/interhand2.6m/image44669.jpg -------------------------------------------------------------------------------- /pose/tests/data/interhand2.6m/image69148.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/interhand2.6m/image69148.jpg -------------------------------------------------------------------------------- /pose/tests/data/jhmdb/Frisbee_catch_f_cm_np1_ri_med_0/00001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/jhmdb/Frisbee_catch_f_cm_np1_ri_med_0/00001.png -------------------------------------------------------------------------------- /pose/tests/data/jhmdb/Frisbee_catch_f_cm_np1_ri_med_1/00001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/jhmdb/Frisbee_catch_f_cm_np1_ri_med_1/00001.png -------------------------------------------------------------------------------- /pose/tests/data/jhmdb/Goalkeeper_Training_Day_@_7_catch_f_cm_np1_ri_med_0/00001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/jhmdb/Goalkeeper_Training_Day_@_7_catch_f_cm_np1_ri_med_0/00001.png -------------------------------------------------------------------------------- /pose/tests/data/locust/630.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/locust/630.jpg -------------------------------------------------------------------------------- /pose/tests/data/locust/650.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/locust/650.jpg -------------------------------------------------------------------------------- /pose/tests/data/macaque/PRI_1473.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/macaque/PRI_1473.jpg -------------------------------------------------------------------------------- /pose/tests/data/macaque/d47f1b1ee9d3217e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/macaque/d47f1b1ee9d3217e.jpg -------------------------------------------------------------------------------- /pose/tests/data/mhp/10084.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/mhp/10084.jpg -------------------------------------------------------------------------------- /pose/tests/data/mhp/10112.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/mhp/10112.jpg -------------------------------------------------------------------------------- /pose/tests/data/mosh/test_mosh.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/mosh/test_mosh.npz -------------------------------------------------------------------------------- /pose/tests/data/mpii/004645041.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/mpii/004645041.jpg -------------------------------------------------------------------------------- /pose/tests/data/mpii/005808361.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/mpii/005808361.jpg -------------------------------------------------------------------------------- /pose/tests/data/mpii/051423444.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/mpii/051423444.jpg -------------------------------------------------------------------------------- /pose/tests/data/mpii/052475643.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/mpii/052475643.jpg -------------------------------------------------------------------------------- /pose/tests/data/mpii/060754485.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/mpii/060754485.jpg -------------------------------------------------------------------------------- /pose/tests/data/ochuman/000817.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/ochuman/000817.jpg -------------------------------------------------------------------------------- /pose/tests/data/ochuman/003799.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/ochuman/003799.jpg -------------------------------------------------------------------------------- /pose/tests/data/ochuman/003896.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/ochuman/003896.jpg -------------------------------------------------------------------------------- /pose/tests/data/onehand10k/1402.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/onehand10k/1402.jpg -------------------------------------------------------------------------------- /pose/tests/data/onehand10k/33.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/onehand10k/33.jpg -------------------------------------------------------------------------------- /pose/tests/data/onehand10k/784.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/onehand10k/784.jpg -------------------------------------------------------------------------------- /pose/tests/data/onehand10k/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/onehand10k/9.jpg -------------------------------------------------------------------------------- /pose/tests/data/panoptic/005880453_01_l.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/panoptic/005880453_01_l.jpg -------------------------------------------------------------------------------- /pose/tests/data/panoptic/005880453_01_r.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/panoptic/005880453_01_r.jpg -------------------------------------------------------------------------------- /pose/tests/data/panoptic/ex2_2.flv_000040_l.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/panoptic/ex2_2.flv_000040_l.jpg -------------------------------------------------------------------------------- /pose/tests/data/panoptic/ex2_2.flv_000040_r.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/panoptic/ex2_2.flv_000040_r.jpg -------------------------------------------------------------------------------- /pose/tests/data/posetrack18/images/val/003418_mpii_test/000000.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/posetrack18/images/val/003418_mpii_test/000000.jpg -------------------------------------------------------------------------------- /pose/tests/data/posetrack18/images/val/009473_mpii_test/000000.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/posetrack18/images/val/009473_mpii_test/000000.jpg -------------------------------------------------------------------------------- /pose/tests/data/posetrack18/images/val/012834_mpii_test/000000.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/posetrack18/images/val/012834_mpii_test/000000.jpg -------------------------------------------------------------------------------- /pose/tests/data/posetrack18/mask/val/003418_mpii_test/000000.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/posetrack18/mask/val/003418_mpii_test/000000.jpg -------------------------------------------------------------------------------- /pose/tests/data/posetrack18/mask/val/009473_mpii_test/000000.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/posetrack18/mask/val/009473_mpii_test/000000.jpg -------------------------------------------------------------------------------- /pose/tests/data/posetrack18/mask/val/012834_mpii_test/000000.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/posetrack18/mask/val/012834_mpii_test/000000.jpg -------------------------------------------------------------------------------- /pose/tests/data/rhd/00111.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/rhd/00111.png -------------------------------------------------------------------------------- /pose/tests/data/rhd/01111.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/rhd/01111.png -------------------------------------------------------------------------------- /pose/tests/data/rhd/11111.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/rhd/11111.png -------------------------------------------------------------------------------- /pose/tests/data/smpl/smpl_mean_params.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/smpl/smpl_mean_params.npz -------------------------------------------------------------------------------- /pose/tests/data/wflw/36_Football_americanfootball_ball_36_415.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/wflw/36_Football_americanfootball_ball_36_415.jpg -------------------------------------------------------------------------------- /pose/tests/data/wflw/7_Cheering_Cheering_7_16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/wflw/7_Cheering_Cheering_7_16.jpg -------------------------------------------------------------------------------- /pose/tests/data/zebra/810.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/zebra/810.jpg -------------------------------------------------------------------------------- /pose/tests/data/zebra/850.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/pose/tests/data/zebra/850.jpg -------------------------------------------------------------------------------- /pose/tests/post_processing/test_group.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | from mmpose.core.post_processing.group import HeatmapParser 4 | 5 | 6 | def test_group(): 7 | cfg = {} 8 | cfg['num_joints'] = 17 9 | cfg['detection_threshold'] = 0.1 10 | cfg['tag_threshold'] = 1 11 | cfg['use_detection_val'] = True 12 | cfg['ignore_too_much'] = False 13 | cfg['nms_kernel'] = 5 14 | cfg['nms_padding'] = 2 15 | cfg['tag_per_joint'] = True 16 | cfg['max_num_people'] = 1 17 | parser = HeatmapParser(cfg) 18 | fake_heatmap = torch.zeros(1, 1, 5, 5) 19 | fake_heatmap[0, 0, 3, 3] = 1 20 | fake_heatmap[0, 0, 3, 2] = 0.8 21 | assert parser.nms(fake_heatmap)[0, 0, 3, 2] == 0 22 | fake_heatmap = torch.zeros(1, 17, 32, 32) 23 | fake_tag = torch.zeros(1, 17, 32, 32, 1) 24 | fake_heatmap[0, 0, 10, 10] = 0.8 25 | fake_heatmap[0, 1, 12, 12] = 0.9 26 | fake_heatmap[0, 4, 8, 8] = 0.8 27 | fake_heatmap[0, 8, 6, 6] = 0.9 28 | fake_tag[0, 0, 10, 10] = 0.8 29 | fake_tag[0, 1, 12, 12] = 0.9 30 | fake_tag[0, 4, 8, 8] = 0.8 31 | fake_tag[0, 8, 6, 6] = 0.9 32 | grouped, scores = parser.parse(fake_heatmap, fake_tag, True, True) 33 | assert grouped[0][0, 0, 0] == 10.25 34 | cfg['tag_per_joint'] = False 35 | parser = HeatmapParser(cfg) 36 | grouped, scores = parser.parse(fake_heatmap, fake_tag, False, False) 37 | assert grouped[0][0, 0, 0] == 10. 38 | grouped, scores = parser.parse(fake_heatmap, fake_tag, False, True) 39 | assert grouped[0][0, 0, 0] == 10. 40 | -------------------------------------------------------------------------------- /pose/tests/post_processing/test_nms.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from mmpose.core.post_processing.nms import nms, oks_iou, oks_nms, soft_oks_nms 4 | 5 | 6 | def test_soft_oks_nms(): 7 | oks_thr = 0.9 8 | kpts = [] 9 | kpts.append({ 10 | 'keypoints': np.tile(np.array([10, 10, 0.9]), [17, 1]), 11 | 'area': 100, 12 | 'score': 0.9 13 | }) 14 | kpts.append({ 15 | 'keypoints': np.tile(np.array([10, 10, 0.9]), [17, 1]), 16 | 'area': 100, 17 | 'score': 0.4 18 | }) 19 | kpts.append({ 20 | 'keypoints': np.tile(np.array([100, 100, 0.9]), [17, 1]), 21 | 'area': 100, 22 | 'score': 0.7 23 | }) 24 | 25 | keep = soft_oks_nms([kpts[i] for i in range(len(kpts))], oks_thr) 26 | assert (keep == np.array([0, 2, 1])).all() 27 | 28 | keep = oks_nms([kpts[i] for i in range(len(kpts))], oks_thr) 29 | assert (keep == np.array([0, 2])).all() 30 | 31 | 32 | def test_func_nms(): 33 | result = nms(np.array([[0, 0, 10, 10, 0.9], [0, 0, 10, 8, 0.8]]), 0.5) 34 | assert result == [0] 35 | 36 | 37 | def test_oks_iou(): 38 | result = oks_iou(np.ones([17 * 3]), np.ones([1, 17 * 3]), 1, [1]) 39 | assert result[0] == 1. 40 | result = oks_iou(np.zeros([17 * 3]), np.ones([1, 17 * 3]), 1, [1]) 41 | assert result[0] < 0.01 42 | -------------------------------------------------------------------------------- /pose/tests/test_backbones/test_alexnet.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | from mmpose.models.backbones import AlexNet 4 | 5 | 6 | def test_alexnet_backbone(): 7 | """Test alexnet backbone.""" 8 | model = AlexNet(-1) 9 | model.train() 10 | 11 | imgs = torch.randn(1, 3, 256, 192) 12 | feat = model(imgs) 13 | assert feat.shape == (1, 256, 7, 5) 14 | 15 | model = AlexNet(1) 16 | model.train() 17 | 18 | imgs = torch.randn(1, 3, 224, 224) 19 | feat = model(imgs) 20 | assert feat.shape == (1, 1) 21 | -------------------------------------------------------------------------------- /pose/tests/test_backbones/test_cpm.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | import torch 3 | 4 | from mmpose.models import CPM 5 | 6 | 7 | def test_cpm_backbone(): 8 | with pytest.raises(AssertionError): 9 | # CPM's num_stacks should larger than 0 10 | CPM(in_channels=3, out_channels=17, num_stages=-1) 11 | 12 | with pytest.raises(AssertionError): 13 | # CPM's in_channels should be 3 14 | CPM(in_channels=2, out_channels=17) 15 | 16 | # Test CPM 17 | model = CPM(in_channels=3, out_channels=17, num_stages=1) 18 | model.init_weights() 19 | model.train() 20 | 21 | imgs = torch.randn(1, 3, 256, 192) 22 | feat = model(imgs) 23 | assert len(feat) == 1 24 | assert feat[0].shape == torch.Size([1, 17, 32, 24]) 25 | 26 | imgs = torch.randn(1, 3, 384, 288) 27 | feat = model(imgs) 28 | assert len(feat) == 1 29 | assert feat[0].shape == torch.Size([1, 17, 48, 36]) 30 | 31 | imgs = torch.randn(1, 3, 368, 368) 32 | feat = model(imgs) 33 | assert len(feat) == 1 34 | assert feat[0].shape == torch.Size([1, 17, 46, 46]) 35 | 36 | # Test CPM multi-stages 37 | model = CPM(in_channels=3, out_channels=17, num_stages=2) 38 | model.init_weights() 39 | model.train() 40 | 41 | imgs = torch.randn(1, 3, 368, 368) 42 | feat = model(imgs) 43 | assert len(feat) == 2 44 | assert feat[0].shape == torch.Size([1, 17, 46, 46]) 45 | assert feat[1].shape == torch.Size([1, 17, 46, 46]) 46 | -------------------------------------------------------------------------------- /pose/tests/test_backbones/test_hourglass.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | import torch 3 | 4 | from mmpose.models import HourglassNet 5 | 6 | 7 | def test_hourglass_backbone(): 8 | with pytest.raises(AssertionError): 9 | # HourglassNet's num_stacks should larger than 0 10 | HourglassNet(num_stacks=0) 11 | 12 | with pytest.raises(AssertionError): 13 | # len(stage_channels) should equal len(stage_blocks) 14 | HourglassNet( 15 | stage_channels=[256, 256, 384, 384, 384], 16 | stage_blocks=[2, 2, 2, 2, 2, 4]) 17 | 18 | with pytest.raises(AssertionError): 19 | # len(stage_channels) should lagrer than downsample_times 20 | HourglassNet( 21 | downsample_times=5, 22 | stage_channels=[256, 256, 384, 384, 384], 23 | stage_blocks=[2, 2, 2, 2, 2]) 24 | 25 | # Test HourglassNet-52 26 | model = HourglassNet(num_stacks=1) 27 | model.init_weights() 28 | model.train() 29 | 30 | imgs = torch.randn(1, 3, 511, 511) 31 | feat = model(imgs) 32 | assert len(feat) == 1 33 | assert feat[0].shape == torch.Size([1, 256, 128, 128]) 34 | 35 | # Test HourglassNet-104 36 | model = HourglassNet(num_stacks=2) 37 | model.init_weights() 38 | model.train() 39 | 40 | imgs = torch.randn(1, 3, 511, 511) 41 | feat = model(imgs) 42 | assert len(feat) == 2 43 | assert feat[0].shape == torch.Size([1, 256, 128, 128]) 44 | assert feat[1].shape == torch.Size([1, 256, 128, 128]) 45 | -------------------------------------------------------------------------------- /pose/tests/test_backbones/test_mspn.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | import torch 3 | 4 | from mmpose.models import MSPN 5 | 6 | 7 | def test_mspn_backbone(): 8 | with pytest.raises(AssertionError): 9 | # MSPN's num_stages should larger than 0 10 | MSPN(num_stages=0) 11 | with pytest.raises(AssertionError): 12 | # MSPN's num_units should larger than 1 13 | MSPN(num_units=1) 14 | with pytest.raises(AssertionError): 15 | # len(num_blocks) should equal num_units 16 | MSPN(num_units=2, num_blocks=[2, 2, 2]) 17 | 18 | # Test MSPN's outputs 19 | model = MSPN(num_stages=2, num_units=2, num_blocks=[2, 2]) 20 | model.init_weights() 21 | model.train() 22 | 23 | imgs = torch.randn(1, 3, 511, 511) 24 | feat = model(imgs) 25 | assert len(feat) == 2 26 | assert len(feat[0]) == 2 27 | assert len(feat[1]) == 2 28 | assert feat[0][0].shape == torch.Size([1, 256, 64, 64]) 29 | assert feat[0][1].shape == torch.Size([1, 256, 128, 128]) 30 | assert feat[1][0].shape == torch.Size([1, 256, 64, 64]) 31 | assert feat[1][1].shape == torch.Size([1, 256, 128, 128]) 32 | -------------------------------------------------------------------------------- /pose/tests/test_backbones/test_resnest.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | import torch 3 | 4 | from mmpose.models.backbones import ResNeSt 5 | from mmpose.models.backbones.resnest import Bottleneck as BottleneckS 6 | 7 | 8 | def test_bottleneck(): 9 | with pytest.raises(AssertionError): 10 | # Style must be in ['pytorch', 'caffe'] 11 | BottleneckS(64, 64, radix=2, reduction_factor=4, style='tensorflow') 12 | 13 | # Test ResNeSt Bottleneck structure 14 | block = BottleneckS( 15 | 64, 256, radix=2, reduction_factor=4, stride=2, style='pytorch') 16 | assert block.avd_layer.stride == 2 17 | assert block.conv2.channels == 64 18 | 19 | # Test ResNeSt Bottleneck forward 20 | block = BottleneckS(64, 64, radix=2, reduction_factor=4) 21 | x = torch.randn(2, 64, 56, 56) 22 | x_out = block(x) 23 | assert x_out.shape == torch.Size([2, 64, 56, 56]) 24 | 25 | 26 | def test_resnest(): 27 | with pytest.raises(KeyError): 28 | # ResNeSt depth should be in [50, 101, 152, 200] 29 | ResNeSt(depth=18) 30 | 31 | # Test ResNeSt with radix 2, reduction_factor 4 32 | model = ResNeSt( 33 | depth=50, radix=2, reduction_factor=4, out_indices=(0, 1, 2, 3)) 34 | model.init_weights() 35 | model.train() 36 | 37 | imgs = torch.randn(2, 3, 224, 224) 38 | feat = model(imgs) 39 | assert len(feat) == 4 40 | assert feat[0].shape == torch.Size([2, 256, 56, 56]) 41 | assert feat[1].shape == torch.Size([2, 512, 28, 28]) 42 | assert feat[2].shape == torch.Size([2, 1024, 14, 14]) 43 | assert feat[3].shape == torch.Size([2, 2048, 7, 7]) 44 | -------------------------------------------------------------------------------- /pose/tests/test_backbones/test_rsn.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | import torch 3 | 4 | from mmpose.models import RSN 5 | 6 | 7 | def test_rsn_backbone(): 8 | with pytest.raises(AssertionError): 9 | # RSN's num_stages should larger than 0 10 | RSN(num_stages=0) 11 | with pytest.raises(AssertionError): 12 | # RSN's num_steps should larger than 1 13 | RSN(num_steps=1) 14 | with pytest.raises(AssertionError): 15 | # RSN's num_units should larger than 1 16 | RSN(num_units=1) 17 | with pytest.raises(AssertionError): 18 | # len(num_blocks) should equal num_units 19 | RSN(num_units=2, num_blocks=[2, 2, 2]) 20 | 21 | # Test RSN's outputs 22 | model = RSN(num_stages=2, num_units=2, num_blocks=[2, 2]) 23 | model.init_weights() 24 | model.train() 25 | 26 | imgs = torch.randn(1, 3, 511, 511) 27 | feat = model(imgs) 28 | assert len(feat) == 2 29 | assert len(feat[0]) == 2 30 | assert len(feat[1]) == 2 31 | assert feat[0][0].shape == torch.Size([1, 256, 64, 64]) 32 | assert feat[0][1].shape == torch.Size([1, 256, 128, 128]) 33 | assert feat[1][0].shape == torch.Size([1, 256, 64, 64]) 34 | assert feat[1][1].shape == torch.Size([1, 256, 128, 128]) 35 | -------------------------------------------------------------------------------- /pose/tests/test_compose.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | from mmpose.datasets.pipelines import Compose 5 | 6 | 7 | def check_keys_equal(result_keys, target_keys): 8 | """Check if all elements in target_keys is in result_keys.""" 9 | return set(target_keys) == set(result_keys) 10 | 11 | 12 | def check_keys_contain(result_keys, target_keys): 13 | """Check if elements in target_keys is in result_keys.""" 14 | return set(target_keys).issubset(set(result_keys)) 15 | 16 | 17 | def test_compose(): 18 | with pytest.raises(TypeError): 19 | # transform must be callable or a dict 20 | Compose('LoadImageFromFile') 21 | 22 | target_keys = ['img', 'img_rename', 'img_metas'] 23 | 24 | # test Compose given a data pipeline 25 | img = np.random.randn(256, 256, 3) 26 | results = dict(img=img, img_file='test_image.png') 27 | test_pipeline = [ 28 | dict( 29 | type='Collect', 30 | keys=['img', ('img', 'img_rename')], 31 | meta_keys=['img_file']) 32 | ] 33 | compose = Compose(test_pipeline) 34 | compose_results = compose(results) 35 | assert check_keys_equal(compose_results.keys(), target_keys) 36 | assert check_keys_equal(compose_results['img_metas'].data.keys(), 37 | ['img_file']) 38 | 39 | # test Compose when forward data is None 40 | results = None 41 | 42 | class ExamplePipeline: 43 | 44 | def __call__(self, results): 45 | return None 46 | 47 | nonePipeline = ExamplePipeline() 48 | test_pipeline = [nonePipeline] 49 | compose = Compose(test_pipeline) 50 | compose_results = compose(results) 51 | assert compose_results is None 52 | 53 | assert repr(compose) == compose.__class__.__name__ + \ 54 | '(\n {}\n)'.format(nonePipeline) 55 | -------------------------------------------------------------------------------- /pose/tests/test_datasets/test_body3d_dataset.py: -------------------------------------------------------------------------------- 1 | import tempfile 2 | 3 | import numpy as np 4 | 5 | from mmpose.datasets import DATASETS 6 | 7 | 8 | def test_body3d_h36m_dataset(): 9 | # Test Human3.6M dataset 10 | dataset = 'Body3DH36MDataset' 11 | dataset_class = DATASETS.get(dataset) 12 | 13 | data_cfg = dict( 14 | num_joints=17, 15 | seq_len=1, 16 | seq_frame_interval=1, 17 | joint_2d_src='pipeline', 18 | joint_2d_det_file=None, 19 | causal=False, 20 | need_camera_param=True, 21 | camera_param_file='tests/data/h36m/cameras.pkl') 22 | 23 | _ = dataset_class( 24 | ann_file='tests/data/h36m/test_h36m_body3d.npz', 25 | img_prefix='tests/data/h36m', 26 | data_cfg=data_cfg, 27 | pipeline=[], 28 | test_mode=False) 29 | 30 | custom_dataset = dataset_class( 31 | ann_file='tests/data/h36m/test_h36m_body3d.npz', 32 | img_prefix='tests/data/h36m', 33 | data_cfg=data_cfg, 34 | pipeline=[], 35 | test_mode=True) 36 | 37 | assert custom_dataset.test_mode is True 38 | _ = custom_dataset[0] 39 | 40 | with tempfile.TemporaryDirectory() as tmpdir: 41 | outputs = [] 42 | for result in custom_dataset: 43 | outputs.append({ 44 | 'preds': result['target'][None, ...], 45 | 'target_image_paths': [result['target_image_path']], 46 | }) 47 | 48 | metrics = ['mpjpe', 'p-mpjpe', 'n-mpjpe'] 49 | infos = custom_dataset.evaluate(outputs, tmpdir, metrics) 50 | 51 | np.testing.assert_almost_equal(infos['MPJPE'], 0.0) 52 | np.testing.assert_almost_equal(infos['P-MPJPE'], 0.0) 53 | np.testing.assert_almost_equal(infos['N-MPJPE'], 0.0) 54 | -------------------------------------------------------------------------------- /pose/tests/test_evaluation/test_mesh_eval.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from numpy.testing import assert_array_almost_equal 3 | 4 | from mmpose.core import compute_similarity_transform 5 | 6 | 7 | def test_compute_similarity_transform(): 8 | source = np.random.rand(14, 3) 9 | tran = np.random.rand(1, 3) 10 | scale = 0.5 11 | target = source * scale + tran 12 | source_transformed = compute_similarity_transform(source, target) 13 | assert_array_almost_equal(source_transformed, target) 14 | -------------------------------------------------------------------------------- /pose/tests/test_loss/test_classification_loss.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | def test_bce_loss(): 5 | from mmpose.models import build_loss 6 | 7 | # test BCE loss without target weight 8 | loss_cfg = dict(type='BCELoss') 9 | loss = build_loss(loss_cfg) 10 | 11 | fake_pred = torch.zeros((1, 2)) 12 | fake_label = torch.zeros((1, 2)) 13 | assert torch.allclose(loss(fake_pred, fake_label, None), torch.tensor(0.)) 14 | 15 | fake_pred = torch.ones((1, 2)) * 0.5 16 | fake_label = torch.zeros((1, 2)) 17 | assert torch.allclose( 18 | loss(fake_pred, fake_label, None), -torch.log(torch.tensor(0.5))) 19 | 20 | # test BCE loss with target weight 21 | loss_cfg = dict(type='BCELoss', use_target_weight=True) 22 | loss = build_loss(loss_cfg) 23 | 24 | fake_pred = torch.ones((1, 2)) * 0.5 25 | fake_label = torch.zeros((1, 2)) 26 | fake_weight = torch.ones((1, 2)) 27 | assert torch.allclose( 28 | loss(fake_pred, fake_label, fake_weight), 29 | -torch.log(torch.tensor(0.5))) 30 | 31 | fake_weight[:, 0] = 0 32 | assert torch.allclose( 33 | loss(fake_pred, fake_label, fake_weight), 34 | -0.5 * torch.log(torch.tensor(0.5))) 35 | 36 | fake_weight = torch.ones(1) 37 | assert torch.allclose( 38 | loss(fake_pred, fake_label, fake_weight), 39 | -torch.log(torch.tensor(0.5))) 40 | -------------------------------------------------------------------------------- /pose/tests/test_model/test_heatmap_1d_head.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import torch 3 | 4 | from mmpose.models import Heatmap1DHead 5 | 6 | 7 | def test_heatmap_1d_head(): 8 | """Test heatmap 1d head.""" 9 | inputs = torch.rand([1, 512], dtype=torch.float32) 10 | target = inputs.new_zeros([1, 1]) 11 | target_weight = inputs.new_ones([1, 1]) 12 | img_metas = [{ 13 | 'img_shape': (224, 224, 3), 14 | 'center': np.array([112, 112]), 15 | 'scale': np.array([0.5, 0.5]), 16 | 'bbox_score': 1.0, 17 | 'bbox_id': 0, 18 | 'flip_pairs': [], 19 | 'inference_channel': np.arange(17), 20 | 'image_file': '.png', 21 | }] 22 | 23 | # build 1D heatmap head 24 | head = Heatmap1DHead( 25 | in_channels=512, 26 | heatmap_size=64, 27 | hidden_dims=(512, ), 28 | loss_value=dict(type='L1Loss')) 29 | head.init_weights() 30 | # test forward function 31 | value = head(inputs) 32 | assert value.shape == torch.Size([1, 1]) 33 | 34 | loss_value = head.get_loss(value, target, target_weight) 35 | assert 'value_loss' in loss_value 36 | 37 | # test inference model function 38 | output = head.inference_model(inputs) 39 | assert isinstance(output, np.ndarray) 40 | assert output.shape == (1, 1) 41 | 42 | # test decode function 43 | result = head.decode(img_metas, output) 44 | assert 'values' in result 45 | -------------------------------------------------------------------------------- /pose/tests/test_model/test_heatmap_3d_head.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import torch 3 | 4 | from mmpose.models import HeatMap3DHead 5 | 6 | 7 | def test_heatmap_3d_head(): 8 | """Test interhand 3d head.""" 9 | input_shape = (1, 512, 8, 8) 10 | inputs = torch.rand(input_shape, dtype=torch.float32) 11 | target_heatmap3d = inputs.new_zeros([1, 20, 64, 64, 64]) 12 | target_weight = inputs.new_ones([1, 20, 1]) 13 | img_metas = [{ 14 | 'img_shape': (224, 224, 3), 15 | 'center': np.array([112, 112]), 16 | 'scale': np.array([0.5, 0.5]), 17 | 'bbox_score': 1.0, 18 | 'bbox_id': 0, 19 | 'flip_pairs': [], 20 | 'inference_channel': np.arange(17), 21 | 'image_file': '.png', 22 | }] 23 | 24 | # test 3D heatmap head 25 | head3d = HeatMap3DHead( 26 | in_channels=512, 27 | out_channels=20 * 64, 28 | depth_size=64, 29 | num_deconv_layers=3, 30 | num_deconv_filters=(256, 256, 256), 31 | num_deconv_kernels=(4, 4, 4), 32 | loss_keypoint=dict(type='JointsMSELoss', use_target_weight=True), 33 | ) 34 | head3d.init_weights() 35 | heatmap3d = head3d(inputs) 36 | assert heatmap3d.shape == torch.Size([1, 20, 64, 64, 64]) 37 | 38 | loss_3d = head3d.get_loss(heatmap3d, target_heatmap3d, target_weight) 39 | assert 'heatmap_loss' in loss_3d 40 | 41 | # test inference model 42 | output = head3d.inference_model(inputs, [(0, 1)]) 43 | assert isinstance(output, np.ndarray) 44 | assert output.shape == (1, 20, 64, 64, 64) 45 | 46 | # test decode 47 | result = head3d.decode(img_metas, output) 48 | assert 'preds' in result 49 | -------------------------------------------------------------------------------- /pose/tests/test_necks/test_gap_neck.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | import torch 4 | 5 | from mmpose.models.necks import GlobalAveragePooling 6 | 7 | 8 | def test_gap(): 9 | """Test GlobalAveragePooling neck.""" 10 | gap = GlobalAveragePooling() 11 | 12 | with pytest.raises(TypeError): 13 | gap(1) 14 | 15 | x0_shape = (32, 1024, 4, 4) 16 | x1_shape = (32, 2048, 2, 2) 17 | x0 = _demo_inputs(x0_shape) 18 | x1 = _demo_inputs(x1_shape) 19 | 20 | y = gap(x0) 21 | assert y.shape == torch.Size([32, 1024]) 22 | 23 | y = gap([x0, x1]) 24 | assert y[0].shape == torch.Size([32, 1024]) 25 | assert y[1].shape == torch.Size([32, 2048]) 26 | 27 | y = gap((x0, x1)) 28 | assert y[0].shape == torch.Size([32, 1024]) 29 | assert y[1].shape == torch.Size([32, 2048]) 30 | 31 | 32 | def _demo_inputs(input_shape=(1, 3, 64, 64)): 33 | """Create a superset of inputs needed to run backbone. 34 | 35 | Args: 36 | input_shape (tuple): input batch dimensions. 37 | Default: (1, 3, 64, 64). 38 | """ 39 | imgs = np.random.random(input_shape) 40 | imgs = torch.FloatTensor(imgs) 41 | 42 | return imgs 43 | -------------------------------------------------------------------------------- /pose/tests/test_onnx.py: -------------------------------------------------------------------------------- 1 | import os.path as osp 2 | import tempfile 3 | 4 | import torch.nn as nn 5 | from tools.pytorch2onnx import _convert_batchnorm, pytorch2onnx 6 | 7 | 8 | class TestModel(nn.Module): 9 | 10 | def __init__(self): 11 | super().__init__() 12 | self.conv = nn.Conv3d(1, 2, 1) 13 | self.bn = nn.SyncBatchNorm(2) 14 | 15 | def forward(self, x): 16 | return self.bn(self.conv(x)) 17 | 18 | def forward_dummy(self, x): 19 | return (self.forward(x), ) 20 | 21 | 22 | def test_onnx_exporting(): 23 | with tempfile.TemporaryDirectory() as tmpdir: 24 | out_file = osp.join(tmpdir, 'tmp.onnx') 25 | model = TestModel() 26 | model = _convert_batchnorm(model) 27 | # test exporting 28 | pytorch2onnx(model, (1, 1, 1, 1, 1), output_file=out_file) 29 | -------------------------------------------------------------------------------- /pose/tests/test_regularization.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import torch 3 | 4 | from mmpose.core import WeightNormClipHook 5 | 6 | 7 | def test_weight_norm_clip(): 8 | torch.manual_seed(0) 9 | 10 | module = torch.nn.Linear(2, 2, bias=False) 11 | module.weight.data.fill_(2) 12 | WeightNormClipHook(max_norm=1.0).register(module) 13 | 14 | x = torch.rand(1, 2).requires_grad_() 15 | _ = module(x) 16 | 17 | weight_norm = module.weight.norm().item() 18 | np.testing.assert_allclose(weight_norm, 1.0, rtol=1e-6) 19 | -------------------------------------------------------------------------------- /pose/tests/test_utils.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import mmcv 3 | import torch 4 | import torchvision 5 | 6 | import mmpose 7 | from mmpose.utils import collect_env 8 | 9 | 10 | def test_collect_env(): 11 | env_info = collect_env() 12 | assert env_info['PyTorch'] == torch.__version__ 13 | assert env_info['TorchVision'] == torchvision.__version__ 14 | assert env_info['OpenCV'] == cv2.__version__ 15 | assert env_info['MMCV'] == mmcv.__version__ 16 | assert '+' in env_info['MMPose'] 17 | assert mmpose.__version__ in env_info['MMPose'] 18 | -------------------------------------------------------------------------------- /pose/tests/test_version.py: -------------------------------------------------------------------------------- 1 | import mmpose 2 | 3 | 4 | def test_version(): 5 | version = mmpose.__version__ 6 | assert isinstance(version, str) 7 | assert isinstance(mmpose.short_version, str) 8 | assert mmpose.short_version in version 9 | -------------------------------------------------------------------------------- /pose/tools/analysis/print_config.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | 3 | from mmcv import Config, DictAction 4 | 5 | 6 | def parse_args(): 7 | parser = argparse.ArgumentParser(description='Print the whole config') 8 | parser.add_argument('config', help='config file path') 9 | parser.add_argument( 10 | '--options', nargs='+', action=DictAction, help='arguments in dict') 11 | args = parser.parse_args() 12 | 13 | return args 14 | 15 | 16 | def main(): 17 | args = parse_args() 18 | 19 | cfg = Config.fromfile(args.config) 20 | if args.options is not None: 21 | cfg.merge_from_dict(args.options) 22 | print(f'Config:\n{cfg.pretty_text}') 23 | 24 | 25 | if __name__ == '__main__': 26 | main() 27 | -------------------------------------------------------------------------------- /pose/tools/benchmark_processing.py: -------------------------------------------------------------------------------- 1 | """This file is for benchmark dataloading process. The command line to run this 2 | file is: 3 | 4 | $ python -m cProfile -o program.prof tools/analysis/bench_processing.py 5 | configs/task/method/[config filename] 6 | 7 | It use cProfile to record cpu running time and output to program.prof 8 | To visualize cProfile output program.prof, use Snakeviz and run: 9 | $ snakeviz program.prof 10 | """ 11 | import argparse 12 | 13 | import mmcv 14 | from mmcv import Config 15 | 16 | from mmpose import __version__ 17 | from mmpose.datasets import build_dataloader, build_dataset 18 | from mmpose.utils import get_root_logger 19 | 20 | 21 | def main(): 22 | parser = argparse.ArgumentParser(description='Benchmark dataloading') 23 | parser.add_argument('config', help='train config file path') 24 | args = parser.parse_args() 25 | cfg = Config.fromfile(args.config) 26 | 27 | # init logger before other steps 28 | logger = get_root_logger() 29 | logger.info(f'MMPose Version: {__version__}') 30 | logger.info(f'Config: {cfg.text}') 31 | 32 | dataset = build_dataset(cfg.data.train) 33 | data_loader = build_dataloader( 34 | dataset, 35 | samples_per_gpu=1, 36 | workers_per_gpu=cfg.data.workers_per_gpu, 37 | dist=False, 38 | shuffle=False) 39 | 40 | # Start progress bar after first 5 batches 41 | prog_bar = mmcv.ProgressBar( 42 | len(dataset) - 5 * cfg.data.samples_per_gpu, start=False) 43 | for i, data in enumerate(data_loader): 44 | if i == 5: 45 | prog_bar.start() 46 | for _ in data['img']: 47 | if i < 5: 48 | continue 49 | prog_bar.update() 50 | 51 | 52 | if __name__ == '__main__': 53 | main() 54 | -------------------------------------------------------------------------------- /pose/tools/dist_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CONFIG=$1 4 | CHECKPOINT=$2 5 | GPUS=$3 6 | PORT=${PORT:-29500} 7 | 8 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 9 | python -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \ 10 | $(dirname "$0")/test.py $CONFIG $CHECKPOINT --launcher pytorch ${@:4} 11 | -------------------------------------------------------------------------------- /pose/tools/publish_model.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import subprocess 3 | from datetime import date 4 | 5 | import torch 6 | 7 | 8 | def parse_args(): 9 | parser = argparse.ArgumentParser( 10 | description='Process a checkpoint to be published') 11 | parser.add_argument('in_file', help='input checkpoint filename') 12 | parser.add_argument('out_file', help='output checkpoint filename') 13 | args = parser.parse_args() 14 | return args 15 | 16 | 17 | def process_checkpoint(in_file, out_file): 18 | checkpoint = torch.load(in_file, map_location='cpu') 19 | # remove optimizer for smaller file size 20 | if 'optimizer' in checkpoint: 21 | del checkpoint['optimizer'] 22 | # if it is necessary to remove some sensitive data in checkpoint['meta'], 23 | # add the code here. 24 | torch.save(checkpoint, out_file) 25 | sha = subprocess.check_output(['sha256sum', out_file]).decode() 26 | if out_file.endswith('.pth'): 27 | out_file_name = out_file[:-4] 28 | else: 29 | out_file_name = out_file 30 | 31 | date_now = date.today().strftime('%Y%m%d') 32 | final_file = out_file_name + f'-{sha[:8]}_{date_now}.pth' 33 | subprocess.Popen(['mv', out_file, final_file]) 34 | 35 | 36 | def main(): 37 | args = parse_args() 38 | process_checkpoint(args.in_file, args.out_file) 39 | 40 | 41 | if __name__ == '__main__': 42 | main() 43 | -------------------------------------------------------------------------------- /pose/tools/slurm_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | 5 | PARTITION=$1 6 | JOB_NAME=$2 7 | CONFIG=$3 8 | CHECKPOINT=$4 9 | GPUS=${GPUS:-8} 10 | GPUS_PER_NODE=${GPUS_PER_NODE:-8} 11 | CPUS_PER_TASK=${CPUS_PER_TASK:-5} 12 | PY_ARGS=${@:5} 13 | SRUN_ARGS=${SRUN_ARGS:-""} 14 | 15 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 16 | srun -p ${PARTITION} \ 17 | --job-name=${JOB_NAME} \ 18 | --gres=gpu:${GPUS_PER_NODE} \ 19 | --ntasks=${GPUS} \ 20 | --ntasks-per-node=${GPUS_PER_NODE} \ 21 | --cpus-per-task=${CPUS_PER_TASK} \ 22 | --kill-on-bad-exit=1 \ 23 | ${SRUN_ARGS} \ 24 | python -u tools/test.py ${CONFIG} ${CHECKPOINT} --launcher="slurm" ${PY_ARGS} 25 | -------------------------------------------------------------------------------- /pose/tools/slurm_train.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | 5 | PARTITION=$1 6 | JOB_NAME=$2 7 | CONFIG=$3 8 | WORK_DIR=$4 9 | GPUS=${GPUS:-8} 10 | GPUS_PER_NODE=${GPUS_PER_NODE:-8} 11 | CPUS_PER_TASK=${CPUS_PER_TASK:-5} 12 | SRUN_ARGS=${SRUN_ARGS:-""} 13 | PY_ARGS=${@:5} 14 | 15 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 16 | srun -p ${PARTITION} \ 17 | --job-name=${JOB_NAME} \ 18 | --gres=gpu:${GPUS_PER_NODE} \ 19 | --ntasks=${GPUS} \ 20 | --ntasks-per-node=${GPUS_PER_NODE} \ 21 | --cpus-per-task=${CPUS_PER_TASK} \ 22 | --kill-on-bad-exit=1 \ 23 | ${SRUN_ARGS} \ 24 | python -u tools/train.py ${CONFIG} --work-dir=${WORK_DIR} --launcher="slurm" ${PY_ARGS} 25 | -------------------------------------------------------------------------------- /seg/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 openseg-group (Yuhui Yuan,JingyiXie,Jianyuan Guo,Lang Huang) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /seg/config.profile: -------------------------------------------------------------------------------- 1 | # NOTE: This file accepts bash syntax 2 | 3 | # Your Python executable 4 | # PYTHON=/data/anaconda/envs/torch0.4/bin/python 5 | PYTHON=/data/anaconda/envs/pytorch1.7.1/bin/python 6 | # PYTHON=python 7 | 8 | # Path to your data dir 9 | # We expect the following directory structure: 10 | # 11 | # $DATA_ROOT/ 12 | # cityscapes/ 13 | # train/ 14 | # image/ 15 | # label/ 16 | # val/ 17 | # image/ 18 | # label/ 19 | # test/ 20 | # berlin/ 21 | # ... 22 | # pascal_context/ 23 | # ... 24 | # DATA_ROOT=/rainbowsecret/dataset 25 | DATA_ROOT=../../../../../dataset 26 | 27 | -------------------------------------------------------------------------------- /seg/imgs/HRT_arch5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/imgs/HRT_arch5.png -------------------------------------------------------------------------------- /seg/imgs/OCR.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/imgs/OCR.PNG -------------------------------------------------------------------------------- /seg/imgs/SegFix.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/imgs/SegFix.PNG -------------------------------------------------------------------------------- /seg/lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/__init__.py -------------------------------------------------------------------------------- /seg/lib/datasets/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/datasets/__init__.py -------------------------------------------------------------------------------- /seg/lib/datasets/loader/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/datasets/loader/__init__.py -------------------------------------------------------------------------------- /seg/lib/datasets/preprocess/README.md: -------------------------------------------------------------------------------- 1 | ### Data Format for Semantic Segmentation 2 | 3 | The raw data will be processed by generator shell scripts. There will be two subdirs('train' & 'val') 4 | 5 | ``` 6 | train or val dir { 7 | image: contains the images for train or val. 8 | label: contains the label png files(mode='P') for train or val. 9 | mask: contains the mask png files(mode='P') for train or val. 10 | } 11 | ``` 12 | 13 | 14 | ### Data Format for Instance Segmentation 15 | 16 | The raw data will be processed by generator shell scripts. There will be two subdirs('train' & 'val') 17 | 18 | ``` 19 | train or val dir { 20 | image: contains the images for train or val. 21 | json: contains the json files for train or val. 22 | } 23 | ``` 24 | 25 | The json format for Instance Segmentation below. 26 | 27 | ``` 28 | { 29 | "width": 640, 30 | "height": 480, 31 | "objects": [ 32 | { 33 | "bbox": [x_left_up, y_left_up, x_right_bottom, y_right_bottom], 34 | "label": class_num, 35 | "segm": [[polygon1], [...], ...] or rle 36 | }, 37 | { 38 | ... 39 | } 40 | ] 41 | } 42 | ``` 43 | -------------------------------------------------------------------------------- /seg/lib/datasets/preprocess/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/datasets/preprocess/__init__.py -------------------------------------------------------------------------------- /seg/lib/datasets/preprocess/ade20k/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/datasets/preprocess/ade20k/__init__.py -------------------------------------------------------------------------------- /seg/lib/datasets/preprocess/ade20k/ade20k_generator.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # -*- coding:utf-8 -*- 3 | # Author: Donny You(youansheng@gmail.com) 4 | # Generate train & val data. 5 | 6 | 7 | ORI_ROOT_DIR='/home/donny/DataSet/ADE20K' 8 | SAVE_DIR='/home/donny/DataSet/ADE20K' 9 | 10 | 11 | python ade20k_generator.py --ori_root_dir $ORI_ROOT_DIR \ 12 | --save_dir $SAVE_DIR -------------------------------------------------------------------------------- /seg/lib/datasets/preprocess/cityscapes/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/datasets/preprocess/cityscapes/__init__.py -------------------------------------------------------------------------------- /seg/lib/datasets/preprocess/face/celebmask_color.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- encoding: utf-8 -*- 3 | # Reference: https://github.com/switchablenorms/CelebAMask-HQ/blob/master/face_parsing/Data_preprocessing/g_mask.py 4 | # 5 | 6 | import os 7 | from PIL import Image 8 | import glob 9 | import numpy as np 10 | 11 | def make_folder(path): 12 | if not os.path.exists(os.path.join(path)): 13 | os.makedirs(os.path.join(path)) 14 | 15 | if __name__ == "__main__": 16 | color_list = [[0, 0, 0], [204, 0, 0], [76, 153, 0], [204, 204, 0], [51, 51, 255], [204, 0, 204], 17 | [0, 255, 255], [255, 204, 204], [102, 51, 0], [255, 0, 0], [102, 204, 0], [255, 255, 0], 18 | [0, 0, 153], [0, 0, 204], [255, 51, 153], [0, 204, 204], [0, 51, 0], [255, 153, 51], [0, 204, 0]] 19 | root_path = '/home/yuhui/teamdrive/dataset/face_parse/CelebAMask-HQ/' 20 | 21 | folder_base = root_path + 'CelebAMask-HQ-mask' 22 | folder_save = root_path + 'CelebAMask-HQ-mask-color' 23 | 24 | img_num = 10 25 | 26 | make_folder(folder_save) 27 | 28 | for k in range(img_num): 29 | filename = os.path.join(folder_base, str(k) + '.png') 30 | if (os.path.exists(filename)): 31 | im_base = np.zeros((512, 512, 3)) 32 | im = Image.open(filename) 33 | im = np.array(im) 34 | for idx, color in enumerate(color_list): 35 | im_base[im == idx] = color 36 | filename_save = os.path.join(folder_save, str(k) + '.png') 37 | result = Image.fromarray((im_base).astype(np.uint8)) 38 | print (filename_save) 39 | result.save(filename_save) -------------------------------------------------------------------------------- /seg/lib/datasets/preprocess/face/celebmask_resize.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- encoding: utf-8 -*- 3 | # Reference: https://github.com/switchablenorms/CelebAMask-HQ/blob/master/face_parsing/Data_preprocessing/g_mask.py 4 | # 5 | 6 | # other resource: 7 | # https://github.com/switchablenorms/CelebAMask-HQ 8 | # https://github.com/zllrunning/face-parsing.PyTorch 9 | # https://github.com/JACKYLUO1991/FaceParsing 10 | 11 | 12 | 13 | import os 14 | import sys 15 | import cv2 16 | import glob 17 | import numpy as np 18 | 19 | from PIL import Image 20 | 21 | label_list = ['skin', 'nose', 'eye_g', 'l_eye', 'r_eye', 'l_brow', 'r_brow', 'l_ear', 'r_ear', 22 | 'mouth', 'u_lip', 'l_lip', 'hair', 'hat', 'ear_r', 'neck_l', 'neck', 'cloth'] 23 | 24 | def make_folder(path): 25 | if not os.path.exists(os.path.join(path)): 26 | os.makedirs(os.path.join(path)) 27 | 28 | def resize_and_move(ori_path, dest_path): 29 | dirs = os.listdir(ori_path) 30 | for item in dirs: 31 | print(item) 32 | if os.path.isfile(ori_path+item): 33 | im = Image.open(ori_path+item) 34 | imResize = im.resize((512,512), Image.ANTIALIAS) 35 | imResize.save(dest_path+item, 'JPEG', quality=90) 36 | 37 | if __name__ == "__main__": 38 | root_path = '/home/yuhui/teamdrive/dataset/face_parse/CelebAMask-HQ/' 39 | val_folder = root_path + 'val/image/' 40 | resized_val_folder = root_path + 'val/image_resize/' 41 | make_folder(resized_val_folder) 42 | resize_and_move(val_folder, resized_val_folder) 43 | -------------------------------------------------------------------------------- /seg/lib/datasets/preprocess/face/prepare_celeb.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | PYTHON="/data/anaconda/envs/pytorch1.6.0/bin/python" 4 | 5 | # $PYTHON celebmask_label_generator.py 6 | # $PYTHON celebmask_partition.py 7 | $PYTHON celebmask_resize.py 8 | -------------------------------------------------------------------------------- /seg/lib/datasets/preprocess/lip/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/datasets/preprocess/lip/__init__.py -------------------------------------------------------------------------------- /seg/lib/datasets/preprocess/mapillary/mapillary_generator.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # check the enviroment info 4 | nvidia-smi 5 | # PYTHON="/root/miniconda3/bin/python" 6 | PYTHON="/data/anaconda/envs/py35/bin/python" 7 | 8 | ORI_ROOT_DIR='/msravcshare/dataset/mapillary-vista-v1.1' 9 | SAVE_DIR='/msravcshare/dataset/cityscapes/mapillary' 10 | 11 | mkdir -p ${SAVE_DIR} 12 | 13 | # directly copy images 14 | # mkdir -p ${SAVE_DIR}/train 15 | # cp -r ${ORI_ROOT_DIR}/training/images ${SAVE_DIR}/train/image 16 | 17 | # mkdir -p ${SAVE_DIR}/val 18 | # cp -r ${ORI_ROOT_DIR}/validation/images ${SAVE_DIR}/val/image 19 | 20 | 21 | ${PYTHON} mapillary_generator.py --ori_root_dir $ORI_ROOT_DIR \ 22 | --save_dir $SAVE_DIR -------------------------------------------------------------------------------- /seg/lib/datasets/preprocess/pascal_context/pascal_context_generator.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # -*- coding:utf-8 -*- 3 | # Author: Lang Huang(layenhuang@outlook.com) 4 | # Pascal context aug data generator. 5 | 6 | PYTHON="/root/miniconda3/envs/pytorch1.0/bin/python" 7 | ORI_ROOT_DIR='/msravcshare/dataset/pascal_context/' #'/msravcshare/dataset/pcontext/' 8 | SAVE_DIR='/msravcshare/dataset/pascal_context/' #'/msravcshare/dataset/pcontext/' 9 | SCRIPT_DIR='/msravcshare/yuyua/code/segmentation/openseg.pytorch/lib/datasets/preprocess/pascal_context' 10 | 11 | cd ${ORI_ROOT_DIR} 12 | 13 | # if [ ! -f train.pth ]; then 14 | # echo "Download training annotations" 15 | # wget https://hangzh.s3.amazonaws.com/encoding/data/pcontext/train.pth 16 | # fi 17 | 18 | # if [ ! -f val.pth ]; then 19 | # echo "Download val annotations" 20 | # wget https://hangzh.s3.amazonaws.com/encoding/data/pcontext/val.pth 21 | # fi 22 | 23 | cd ${SCRIPT_DIR} 24 | echo "Start generation..." 25 | 26 | python pascal_context_generator.py --ori_root_dir ${ORI_ROOT_DIR} \ 27 | --save_dir ${SAVE_DIR} 28 | 29 | -------------------------------------------------------------------------------- /seg/lib/datasets/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/datasets/tools/__init__.py -------------------------------------------------------------------------------- /seg/lib/extensions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/extensions/__init__.py -------------------------------------------------------------------------------- /seg/lib/extensions/cc_attention/__init__.py: -------------------------------------------------------------------------------- 1 | from .functions import PAM_Module, CrissCrossAttention, CrossAttention, ca_weight, ca_map -------------------------------------------------------------------------------- /seg/lib/extensions/cc_attention/_ext/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | from torch.utils.ffi import _wrap_function 3 | from .__ext import lib as _lib, ffi as _ffi 4 | 5 | __all__ = [] 6 | def _import_symbols(locals): 7 | for symbol in dir(_lib): 8 | fn = getattr(_lib, symbol) 9 | if callable(fn): 10 | locals[symbol] = _wrap_function(fn, _ffi) 11 | else: 12 | locals[symbol] = fn 13 | __all__.append(symbol) 14 | 15 | _import_symbols(locals()) 16 | -------------------------------------------------------------------------------- /seg/lib/extensions/cc_attention/build.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from torch.utils.ffi import create_extension 4 | 5 | sources = ['src/lib_cffi.cpp'] 6 | headers = ['src/lib_cffi.h'] 7 | extra_objects = ['src/ca.o'] 8 | with_cuda = True 9 | 10 | this_file = os.path.dirname(os.path.realpath(__file__)) 11 | extra_objects = [os.path.join(this_file, fname) for fname in extra_objects] 12 | 13 | ffi = create_extension( 14 | '_ext', 15 | headers=headers, 16 | sources=sources, 17 | relative_to=__file__, 18 | with_cuda=with_cuda, 19 | extra_objects=extra_objects, 20 | extra_compile_args=["-std=c++11"] 21 | ) 22 | 23 | if __name__ == '__main__': 24 | ffi.build() 25 | -------------------------------------------------------------------------------- /seg/lib/extensions/cc_attention/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Configuration 4 | CUDA_GENCODE="\ 5 | -gencode=arch=compute_60,code=sm_60 \ 6 | -gencode=arch=compute_61,code=sm_61 \ 7 | -gencode=arch=compute_52,code=sm_52 \ 8 | -gencode=arch=compute_50,code=sm_50" 9 | 10 | 11 | cd src 12 | /usr/local/cuda-8.0/bin/nvcc -I/usr/local/cuda/include --expt-extended-lambda -O3 -c -o ca.o ca.cu -x cu -Xcompiler -fPIC -std=c++11 ${CUDA_GENCODE} 13 | cd .. 14 | -------------------------------------------------------------------------------- /seg/lib/extensions/cc_attention/src/ca.h: -------------------------------------------------------------------------------- 1 | #ifndef __CA__ 2 | #define __CA__ 3 | 4 | /* 5 | * Exported functions 6 | */ 7 | extern "C" int _ca_forward_cuda(int N, int C, int H, int W, const float *t, const float *f, float *weight, cudaStream_t stream); 8 | extern "C" int _ca_backward_cuda(int N, int C, int H, int W, const float *dw, const float *t, const float *f, float *dt, float *df, cudaStream_t stream); 9 | extern "C" int _ca_map_forward_cuda(int N, int C, int H, int W, const float *weight, const float *g, float *out, cudaStream_t stream); 10 | extern "C" int _ca_map_backward_cuda(int N, int C, int H, int W, const float *dout, const float *weight, const float *g, float *dw, float *dg, cudaStream_t stream); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /seg/lib/extensions/cc_attention/src/common.h: -------------------------------------------------------------------------------- 1 | #ifndef __COMMON__ 2 | #define __COMMON__ 3 | #include 4 | 5 | /* 6 | * General settings 7 | */ 8 | const int WARP_SIZE = 32; 9 | const int MAX_BLOCK_SIZE = 512; 10 | 11 | /* 12 | * Utility functions 13 | */ 14 | template 15 | __device__ __forceinline__ T WARP_SHFL_XOR(T value, int laneMask, int width = warpSize, 16 | unsigned int mask = 0xffffffff) { 17 | #if CUDART_VERSION >= 9000 18 | return __shfl_xor_sync(mask, value, laneMask, width); 19 | #else 20 | return __shfl_xor(value, laneMask, width); 21 | #endif 22 | } 23 | 24 | __device__ __forceinline__ int getMSB(int val) { return 31 - __clz(val); } 25 | 26 | static int getNumThreads(int nElem) { 27 | int threadSizes[5] = {32, 64, 128, 256, MAX_BLOCK_SIZE}; 28 | for (int i = 0; i != 5; ++i) { 29 | if (nElem <= threadSizes[i]) { 30 | return threadSizes[i]; 31 | } 32 | } 33 | return MAX_BLOCK_SIZE; 34 | } 35 | 36 | 37 | #endif -------------------------------------------------------------------------------- /seg/lib/extensions/cc_attention/src/lib_cffi.h: -------------------------------------------------------------------------------- 1 | int ca_forward_cuda(const THCudaTensor *t, const THCudaTensor *f, THCudaTensor *weight); 2 | 3 | int ca_backward_cuda(const THCudaTensor *dw, const THCudaTensor *t, const THCudaTensor *f, THCudaTensor *dt, THCudaTensor *df); 4 | 5 | int ca_map_forward_cuda(const THCudaTensor *weight, const THCudaTensor *g, THCudaTensor *out); 6 | int ca_map_backward_cuda(const THCudaTensor *dout, const THCudaTensor *weight, const THCudaTensor *g, 7 | THCudaTensor *dw, THCudaTensor *dg); 8 | -------------------------------------------------------------------------------- /seg/lib/extensions/crf/dense_crf.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pydensecrf.densecrf as dcrf 3 | 4 | def dense_crf(img, output_probs): 5 | h = output_probs.shape[0] 6 | w = output_probs.shape[1] 7 | 8 | output_probs = np.expand_dims(output_probs, 0) 9 | output_probs = np.append(1 - output_probs, output_probs, axis=0) 10 | 11 | d = dcrf.DenseCRF2D(w, h, 2) 12 | U = -np.log(output_probs) 13 | U = U.reshape((2, -1)) 14 | U = np.ascontiguousarray(U) 15 | img = np.ascontiguousarray(img) 16 | 17 | d.setUnaryEnergy(U) 18 | 19 | d.addPairwiseGaussian(sxy=20, compat=3) 20 | d.addPairwiseBilateral(sxy=30, srgb=20, rgbim=img, compat=10) 21 | 22 | Q = d.inference(5) 23 | Q = np.argmax(np.array(Q), axis=0).reshape((h, w)) 24 | 25 | return Q 26 | -------------------------------------------------------------------------------- /seg/lib/extensions/dcn/__init__.py: -------------------------------------------------------------------------------- 1 | from .modules.deform_conv import DeformConv 2 | from .modules.modulated_dcn import DeformRoIPooling, ModulatedDeformRoIPoolingPack, ModulatedDeformConv, ModulatedDeformConvPack 3 | 4 | __all__ = ['DeformConv', 'DeformRoIPooling', 'ModulatedDeformRoIPoolingPack', 'ModulatedDeformConv', 'ModulatedDeformConvPack'] -------------------------------------------------------------------------------- /seg/lib/extensions/dcn/_ext/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/extensions/dcn/_ext/__init__.py -------------------------------------------------------------------------------- /seg/lib/extensions/dcn/_ext/deform_conv/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | from torch.utils.ffi import _wrap_function 3 | from ._deform_conv import lib as _lib, ffi as _ffi 4 | 5 | __all__ = [] 6 | def _import_symbols(locals): 7 | for symbol in dir(_lib): 8 | fn = getattr(_lib, symbol) 9 | if callable(fn): 10 | locals[symbol] = _wrap_function(fn, _ffi) 11 | else: 12 | locals[symbol] = fn 13 | __all__.append(symbol) 14 | 15 | _import_symbols(locals()) 16 | -------------------------------------------------------------------------------- /seg/lib/extensions/dcn/_ext/modulated_dcn/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | from torch.utils.ffi import _wrap_function 3 | from ._modulated_dcn import lib as _lib, ffi as _ffi 4 | 5 | __all__ = [] 6 | def _import_symbols(locals): 7 | for symbol in dir(_lib): 8 | fn = getattr(_lib, symbol) 9 | if callable(fn): 10 | locals[symbol] = _wrap_function(fn, _ffi) 11 | else: 12 | locals[symbol] = fn 13 | __all__.append(symbol) 14 | 15 | _import_symbols(locals()) 16 | -------------------------------------------------------------------------------- /seg/lib/extensions/dcn/build.py: -------------------------------------------------------------------------------- 1 | import os 2 | import torch 3 | from torch.utils.ffi import create_extension 4 | 5 | this_file = os.path.dirname(__file__) 6 | 7 | sources = ['src/deform_conv.c'] 8 | headers = ['src/deform_conv.h'] 9 | defines = [] 10 | with_cuda = False 11 | 12 | if torch.cuda.is_available(): 13 | print('Including CUDA code.') 14 | sources += ['src/deform_conv_cuda.c'] 15 | headers += ['src/deform_conv_cuda.h'] 16 | defines += [('WITH_CUDA', None)] 17 | with_cuda = True 18 | 19 | this_file = os.path.dirname(os.path.realpath(__file__)) 20 | print(this_file) 21 | extra_objects = ['src/deform_conv_cuda_kernel.cu.so'] 22 | extra_objects = [os.path.join(this_file, fname) for fname in extra_objects] 23 | 24 | ffi = create_extension( 25 | '_ext.deform_conv', 26 | headers=headers, 27 | sources=sources, 28 | define_macros=defines, 29 | relative_to=__file__, 30 | with_cuda=with_cuda, 31 | extra_objects=extra_objects, 32 | extra_compile_args=['-std=c++11'] 33 | ) 34 | 35 | assert torch.cuda.is_available(), 'Please install CUDA for GPU support.' 36 | ffi.build() 37 | 38 | -------------------------------------------------------------------------------- /seg/lib/extensions/dcn/build_modulated.py: -------------------------------------------------------------------------------- 1 | import os 2 | import torch 3 | from torch.utils.ffi import create_extension 4 | 5 | 6 | sources = ['src/modulated_dcn.c'] 7 | headers = ['src/modulated_dcn.h'] 8 | defines = [] 9 | with_cuda = False 10 | 11 | extra_objects = [] 12 | if torch.cuda.is_available(): 13 | print('Including CUDA code.') 14 | sources += ['src/modulated_dcn_cuda.c'] 15 | headers += ['src/modulated_dcn_cuda.h'] 16 | defines += [('WITH_CUDA', None)] 17 | extra_objects += ['src/cuda/modulated_deform_im2col_cuda.cu.so'] 18 | extra_objects += ['src/cuda/deform_psroi_pooling_cuda.cu.so'] 19 | with_cuda = True 20 | else: 21 | raise ValueError('CUDA is not available') 22 | 23 | extra_compile_args = ['-fopenmp', '-std=c99'] 24 | 25 | this_file = os.path.dirname(os.path.realpath(__file__)) 26 | print(this_file) 27 | sources = [os.path.join(this_file, fname) for fname in sources] 28 | headers = [os.path.join(this_file, fname) for fname in headers] 29 | extra_objects = [os.path.join(this_file, fname) for fname in extra_objects] 30 | 31 | ffi = create_extension( 32 | '_ext.modulated_dcn', 33 | headers=headers, 34 | sources=sources, 35 | define_macros=defines, 36 | relative_to=__file__, 37 | with_cuda=with_cuda, 38 | extra_objects=extra_objects, 39 | extra_compile_args=extra_compile_args 40 | ) 41 | 42 | if __name__ == '__main__': 43 | ffi.build() 44 | -------------------------------------------------------------------------------- /seg/lib/extensions/dcn/functions/__init__.py: -------------------------------------------------------------------------------- 1 | from .deform_conv import DeformConvFunction, deform_conv_function 2 | from .modulated_dcn_func import DeformRoIPoolingFunction, ModulatedDeformConvFunction -------------------------------------------------------------------------------- /seg/lib/extensions/dcn/make.sh: -------------------------------------------------------------------------------- 1 | PYTHON="/root/miniconda3/bin/python" 2 | 3 | cd src 4 | /usr/local/cuda-8.0/bin/nvcc -c -o deform_conv_cuda_kernel.cu.so deform_conv_cuda_kernel.cu -x cu -Xcompiler -fPIC -std=c++11 5 | 6 | cd cuda 7 | 8 | # compile modulated deform conv 9 | /usr/local/cuda-8.0/bin/nvcc -c -o modulated_deform_im2col_cuda.cu.so modulated_deform_im2col_cuda.cu -x cu -Xcompiler -fPIC 10 | 11 | # compile deform-psroi-pooling 12 | /usr/local/cuda-8.0/bin/nvcc -c -o deform_psroi_pooling_cuda.cu.so deform_psroi_pooling_cuda.cu -x cu -Xcompiler -fPIC 13 | 14 | cd ../.. 15 | CC=g++ ${PYTHON} build.py 16 | ${PYTHON} build_modulated.py 17 | -------------------------------------------------------------------------------- /seg/lib/extensions/dcn/make_p100.sh: -------------------------------------------------------------------------------- 1 | PYTHON="/data/anaconda/envs/py35/bin/python" 2 | 3 | cd src 4 | /usr/bin/nvcc -c -o deform_conv_cuda_kernel.cu.so deform_conv_cuda_kernel.cu -x cu -Xcompiler -fPIC -std=c++11 5 | 6 | cd cuda 7 | 8 | # compile modulated deform conv 9 | /usr/bin/nvcc -c -o modulated_deform_im2col_cuda.cu.so modulated_deform_im2col_cuda.cu -x cu -Xcompiler -fPIC 10 | 11 | # compile deform-psroi-pooling 12 | /usr/bin/nvcc -c -o deform_psroi_pooling_cuda.cu.so deform_psroi_pooling_cuda.cu -x cu -Xcompiler -fPIC 13 | 14 | cd ../.. 15 | CC=g++ ${PYTHON} build.py 16 | ${PYTHON} build_modulated.py 17 | -------------------------------------------------------------------------------- /seg/lib/extensions/dcn/modules/__init__.py: -------------------------------------------------------------------------------- 1 | from .deform_conv import DeformConv 2 | from .modulated_dcn import DeformRoIPooling, ModulatedDeformConv, ModulatedDeformConvPack, ModulatedDeformRoIPoolingPack -------------------------------------------------------------------------------- /seg/lib/extensions/dcn/modules/deform_conv.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | import torch 4 | import torch.nn as nn 5 | from torch.nn.modules.module import Module 6 | from torch.nn.modules.utils import _pair 7 | from lib.extensions.dcn.functions import deform_conv_function 8 | 9 | 10 | class DeformConv(Module): 11 | def __init__(self, 12 | in_channels, 13 | out_channels, 14 | kernel_size, 15 | stride=1, 16 | padding=0, 17 | dilation=1, 18 | num_deformable_groups=1): 19 | super(DeformConv, self).__init__() 20 | self.in_channels = in_channels 21 | self.out_channels = out_channels 22 | self.kernel_size = _pair(kernel_size) 23 | self.stride = _pair(stride) 24 | self.padding = _pair(padding) 25 | self.dilation = _pair(dilation) 26 | self.num_deformable_groups = num_deformable_groups 27 | 28 | self.weight = nn.Parameter( 29 | torch.Tensor(out_channels, in_channels, *self.kernel_size)) 30 | 31 | self.reset_parameters() 32 | 33 | def reset_parameters(self): 34 | n = self.in_channels 35 | for k in self.kernel_size: 36 | n *= k 37 | stdv = 1. / math.sqrt(n) 38 | self.weight.data.uniform_(-stdv, stdv) 39 | 40 | def forward(self, input, offset): 41 | return deform_conv_function(input, offset, self.weight, self.stride, 42 | self.padding, self.dilation, 43 | self.num_deformable_groups) 44 | -------------------------------------------------------------------------------- /seg/lib/extensions/dcn/src/deform_conv.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int deform_conv_forward(THFloatTensor *input, THFloatTensor *offset, 4 | THFloatTensor *output) 5 | { 6 | // if (!THFloatTensor_isSameSizeAs(input1, input2)) 7 | // return 0; 8 | // THFloatTensor_resizeAs(output, input); 9 | // THFloatTensor_cadd(output, input1, 1.0, input2); 10 | return 1; 11 | } 12 | 13 | int deform_conv_backward(THFloatTensor *grad_output, THFloatTensor *grad_input, 14 | THFloatTensor *grad_offset) 15 | { 16 | // THFloatTensor_resizeAs(grad_input, grad_output); 17 | // THFloatTensor_fill(grad_input, 1); 18 | return 1; 19 | } 20 | -------------------------------------------------------------------------------- /seg/lib/extensions/dcn/src/deform_conv.h: -------------------------------------------------------------------------------- 1 | int deform_conv_forward(THFloatTensor *input, THFloatTensor *offset, 2 | THFloatTensor *output); 3 | int deform_conv_backward(THFloatTensor *grad_output, THFloatTensor *grad_input, 4 | THFloatTensor *grad_offset); 5 | -------------------------------------------------------------------------------- /seg/lib/extensions/dcn/src/deform_conv_cuda.h: -------------------------------------------------------------------------------- 1 | int deform_conv_forward_cuda(THCudaTensor *input, 2 | THCudaTensor *weight, /*THCudaTensor * bias, */ 3 | THCudaTensor *offset, THCudaTensor *output, 4 | THCudaTensor *columns, THCudaTensor *ones, int kW, 5 | int kH, int dW, int dH, int padW, int padH, 6 | int dilationW, int dilationH, 7 | int deformable_group, int im2col_step); 8 | 9 | int deform_conv_backward_input_cuda( 10 | THCudaTensor *input, THCudaTensor *offset, THCudaTensor *gradOutput, 11 | THCudaTensor *gradInput, THCudaTensor *gradOffset, THCudaTensor *weight, 12 | THCudaTensor *columns, int kW, int kH, int dW, int dH, int padW, int padH, 13 | int dilationW, int dilationH, int deformable_group, int im2col_step); 14 | 15 | int deform_conv_backward_parameters_cuda( 16 | THCudaTensor *input, THCudaTensor *offset, THCudaTensor *gradOutput, 17 | THCudaTensor *gradWeight, /*THCudaTensor *gradBias, */ 18 | THCudaTensor *columns, THCudaTensor *ones, int kW, int kH, int dW, int dH, 19 | int padW, int padH, int dilationW, int dilationH, int deformable_group, 20 | float scale, int im2col_step); 21 | -------------------------------------------------------------------------------- /seg/lib/extensions/dcn/src/modulated_dcn.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void modulated_deform_conv_forward(THFloatTensor *input, THFloatTensor *weight, 6 | THFloatTensor *bias, THFloatTensor *ones, 7 | THFloatTensor *offset, THFloatTensor *mask, 8 | THFloatTensor *output, THFloatTensor *columns, 9 | const int pad_h, const int pad_w, 10 | const int stride_h, const int stride_w, 11 | const int dilation_h, const int dilation_w, 12 | const int deformable_group) 13 | { 14 | printf("only implemented in GPU"); 15 | } 16 | void modulated_deform_conv_backward(THFloatTensor *input, THFloatTensor *weight, 17 | THFloatTensor *bias, THFloatTensor *ones, 18 | THFloatTensor *offset, THFloatTensor *mask, 19 | THFloatTensor *output, THFloatTensor *columns, 20 | THFloatTensor *grad_input, THFloatTensor *grad_weight, 21 | THFloatTensor *grad_bias, THFloatTensor *grad_offset, 22 | THFloatTensor *grad_mask, THFloatTensor *grad_output, 23 | int kernel_h, int kernel_w, 24 | int stride_h, int stride_w, 25 | int pad_h, int pad_w, 26 | int dilation_h, int dilation_w, 27 | int deformable_group) 28 | { 29 | printf("only implemented in GPU"); 30 | } -------------------------------------------------------------------------------- /seg/lib/extensions/dcn/src/modulated_dcn.h: -------------------------------------------------------------------------------- 1 | void modulated_deform_conv_forward(THFloatTensor *input, THFloatTensor *weight, 2 | THFloatTensor *bias, THFloatTensor *ones, 3 | THFloatTensor *offset, THFloatTensor *mask, 4 | THFloatTensor *output, THFloatTensor *columns, 5 | const int pad_h, const int pad_w, 6 | const int stride_h, const int stride_w, 7 | const int dilation_h, const int dilation_w, 8 | const int deformable_group); 9 | void modulated_deform_conv_backward(THFloatTensor *input, THFloatTensor *weight, 10 | THFloatTensor *bias, THFloatTensor *ones, 11 | THFloatTensor *offset, THFloatTensor *mask, 12 | THFloatTensor *output, THFloatTensor *columns, 13 | THFloatTensor *grad_input, THFloatTensor *grad_weight, 14 | THFloatTensor *grad_bias, THFloatTensor *grad_offset, 15 | THFloatTensor *grad_mask, THFloatTensor *grad_output, 16 | int kernel_h, int kernel_w, 17 | int stride_h, int stride_w, 18 | int pad_h, int pad_w, 19 | int dilation_h, int dilation_w, 20 | int deformable_group); -------------------------------------------------------------------------------- /seg/lib/extensions/dcn/test.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | import torch.nn.functional as F 4 | from torch.autograd import Variable 5 | 6 | from modules import DeformConv 7 | 8 | num_deformable_groups = 2 9 | 10 | N, inC, inH, inW = 2, 6, 512, 512 11 | outC, outH, outW = 4, 512, 512 12 | kH, kW = 3, 3 13 | 14 | conv = nn.Conv2d( 15 | inC, 16 | num_deformable_groups * 2 * kH * kW, 17 | kernel_size=(kH, kW), 18 | stride=(1, 1), 19 | padding=(1, 1), 20 | bias=False).cuda() 21 | 22 | conv_offset2d = DeformConv( 23 | inC, 24 | outC, (kH, kW), 25 | stride=1, 26 | padding=1, 27 | num_deformable_groups=num_deformable_groups).cuda() 28 | 29 | inputs = Variable(torch.randn(N, inC, inH, inW).cuda(), requires_grad=True) 30 | offset = conv(inputs) 31 | #offset = Variable(torch.randn(N, num_deformable_groups * 2 * kH * kW, inH, inW).cuda(), requires_grad=True) 32 | output = conv_offset2d(inputs, offset) 33 | output.backward(output.data) 34 | print(output.size()) 35 | -------------------------------------------------------------------------------- /seg/lib/extensions/frn/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/extensions/frn/__init__.py -------------------------------------------------------------------------------- /seg/lib/extensions/frn/frn.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | 4 | class FilterResponseNormalization(nn.Module): 5 | def __init__(self, beta, gamma, tau, eps=1e-6): 6 | """ 7 | Input Variables: 8 | ---------------- 9 | beta, gamma, tau: Variables of shape [1, C, 1, 1]. 10 | eps: A scalar constant or learnable variable. 11 | """ 12 | 13 | super(FilterResponseNormalization, self).__init__() 14 | self.beta = beta 15 | self.gamma = gamma 16 | self.tau = tau 17 | self.eps = torch.Tensor([eps]) 18 | 19 | def forward(self, x): 20 | """ 21 | Input Variables: 22 | ---------------- 23 | x: Input tensor of shape [NxCxHxW] 24 | """ 25 | 26 | n, c, h, w = x.shape 27 | assert (self.gamma.shape[1], self.beta.shape[1], self.tau.shape[1]) == (c, c, c) 28 | 29 | # Compute the mean norm of activations per channel 30 | nu2 = torch.mean(x.pow(2), (2,3), keepdims=True) 31 | # Perform FRN 32 | x = x * torch.rsqrt(nu2 + torch.abs(self.eps)) 33 | # Return after applying the Offset-ReLU non-linearity 34 | return torch.max(self.gamma*x + self.beta, self.tau) -------------------------------------------------------------------------------- /seg/lib/extensions/inplace_abn/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/extensions/inplace_abn/__init__.py -------------------------------------------------------------------------------- /seg/lib/extensions/inplace_abn/src/inplace_abn.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | std::vector mean_var_cpu(at::Tensor x); 8 | std::vector mean_var_cuda(at::Tensor x); 9 | 10 | at::Tensor forward_cpu(at::Tensor x, at::Tensor mean, at::Tensor var, at::Tensor weight, at::Tensor bias, 11 | bool affine, float eps); 12 | at::Tensor forward_cuda(at::Tensor x, at::Tensor mean, at::Tensor var, at::Tensor weight, at::Tensor bias, 13 | bool affine, float eps); 14 | 15 | std::vector edz_eydz_cpu(at::Tensor z, at::Tensor dz, at::Tensor weight, at::Tensor bias, 16 | bool affine, float eps); 17 | std::vector edz_eydz_cuda(at::Tensor z, at::Tensor dz, at::Tensor weight, at::Tensor bias, 18 | bool affine, float eps); 19 | 20 | std::vector backward_cpu(at::Tensor z, at::Tensor dz, at::Tensor var, at::Tensor weight, at::Tensor bias, 21 | at::Tensor edz, at::Tensor eydz, bool affine, float eps); 22 | std::vector backward_cuda(at::Tensor z, at::Tensor dz, at::Tensor var, at::Tensor weight, at::Tensor bias, 23 | at::Tensor edz, at::Tensor eydz, bool affine, float eps); 24 | 25 | void leaky_relu_backward_cpu(at::Tensor z, at::Tensor dz, float slope); 26 | void leaky_relu_backward_cuda(at::Tensor z, at::Tensor dz, float slope); 27 | 28 | void elu_backward_cpu(at::Tensor z, at::Tensor dz); 29 | void elu_backward_cuda(at::Tensor z, at::Tensor dz); -------------------------------------------------------------------------------- /seg/lib/extensions/inplace_abn_1/__init__.py: -------------------------------------------------------------------------------- 1 | from .bn import ABN, InPlaceABN, InPlaceABNSync 2 | from .functions import ACT_RELU, ACT_LEAKY_RELU, ACT_ELU, ACT_NONE 3 | -------------------------------------------------------------------------------- /seg/lib/extensions/inplace_abn_1/misc.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | import torch 3 | import torch.distributed as dist 4 | 5 | class GlobalAvgPool2d(nn.Module): 6 | def __init__(self): 7 | """Global average pooling over the input's spatial dimensions""" 8 | super(GlobalAvgPool2d, self).__init__() 9 | 10 | def forward(self, inputs): 11 | in_size = inputs.size() 12 | return inputs.view((in_size[0], in_size[1], -1)).mean(dim=2) 13 | 14 | class SingleGPU(nn.Module): 15 | def __init__(self, module): 16 | super(SingleGPU, self).__init__() 17 | self.module=module 18 | 19 | def forward(self, input): 20 | return self.module(input.cuda(non_blocking=True)) 21 | 22 | -------------------------------------------------------------------------------- /seg/lib/extensions/inplace_abn_1/src/checks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // Define AT_CHECK for old version of ATen where the same function was called AT_ASSERT 6 | #ifndef AT_CHECK 7 | #define AT_CHECK AT_ASSERT 8 | #endif 9 | 10 | #define CHECK_CUDA(x) AT_CHECK((x).type().is_cuda(), #x " must be a CUDA tensor") 11 | #define CHECK_CPU(x) AT_CHECK(!(x).type().is_cuda(), #x " must be a CPU tensor") 12 | #define CHECK_CONTIGUOUS(x) AT_CHECK((x).is_contiguous(), #x " must be contiguous") 13 | 14 | #define CHECK_CUDA_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x) 15 | #define CHECK_CPU_INPUT(x) CHECK_CPU(x); CHECK_CONTIGUOUS(x) -------------------------------------------------------------------------------- /seg/lib/extensions/inplace_abn_1/src/utils/checks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // Define AT_CHECK for old version of ATen where the same function was called AT_ASSERT 6 | #ifndef AT_CHECK 7 | #define AT_CHECK AT_ASSERT 8 | #endif 9 | 10 | #define CHECK_CUDA(x) AT_CHECK((x).type().is_cuda(), #x " must be a CUDA tensor") 11 | #define CHECK_CPU(x) AT_CHECK(!(x).type().is_cuda(), #x " must be a CPU tensor") 12 | #define CHECK_CONTIGUOUS(x) AT_CHECK((x).is_contiguous(), #x " must be contiguous") 13 | 14 | #define CHECK_CUDA_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x) 15 | #define CHECK_CPU_INPUT(x) CHECK_CPU(x); CHECK_CONTIGUOUS(x) -------------------------------------------------------------------------------- /seg/lib/extensions/inplace_abn_1/src/utils/common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | /* 6 | * Functions to share code between CPU and GPU 7 | */ 8 | 9 | #ifdef __CUDACC__ 10 | // CUDA versions 11 | 12 | #define HOST_DEVICE __host__ __device__ 13 | #define INLINE_HOST_DEVICE __host__ __device__ inline 14 | #define FLOOR(x) floor(x) 15 | 16 | #if __CUDA_ARCH__ >= 600 17 | // Recent compute capabilities have block-level atomicAdd for all data types, so we use that 18 | #define ACCUM(x,y) atomicAdd_block(&(x),(y)) 19 | #else 20 | // Older architectures don't have block-level atomicAdd, nor atomicAdd for doubles, so we defer to atomicAdd for float 21 | // and use the known atomicCAS-based implementation for double 22 | template 23 | __device__ inline data_t atomic_add(data_t *address, data_t val) { 24 | return atomicAdd(address, val); 25 | } 26 | 27 | template<> 28 | __device__ inline double atomic_add(double *address, double val) { 29 | unsigned long long int* address_as_ull = (unsigned long long int*)address; 30 | unsigned long long int old = *address_as_ull, assumed; 31 | do { 32 | assumed = old; 33 | old = atomicCAS(address_as_ull, assumed, __double_as_longlong(val + __longlong_as_double(assumed))); 34 | } while (assumed != old); 35 | return __longlong_as_double(old); 36 | } 37 | 38 | #define ACCUM(x,y) atomic_add(&(x),(y)) 39 | #endif // #if __CUDA_ARCH__ >= 600 40 | 41 | #else 42 | // CPU versions 43 | 44 | #define HOST_DEVICE 45 | #define INLINE_HOST_DEVICE inline 46 | #define FLOOR(x) std::floor(x) 47 | #define ACCUM(x,y) (x) += (y) 48 | 49 | #endif // #ifdef __CUDACC__ -------------------------------------------------------------------------------- /seg/lib/extensions/pacnet/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/extensions/pacnet/__init__.py -------------------------------------------------------------------------------- /seg/lib/extensions/parallel/__init__.py: -------------------------------------------------------------------------------- 1 | from .data_container import DataContainer 2 | from .distributed import MMDistributedDataParallel 3 | from .scatter_gather import scatter, scatter_kwargs 4 | 5 | __all__ = [ 6 | 'collate', 'DataContainer', 'MMDataParallel', 'MMDistributedDataParallel', 7 | 'scatter', 'scatter_kwargs' 8 | ] 9 | -------------------------------------------------------------------------------- /seg/lib/extensions/switchablenorms/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/extensions/switchablenorms/__init__.py -------------------------------------------------------------------------------- /seg/lib/extensions/syncbn/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/extensions/syncbn/__init__.py -------------------------------------------------------------------------------- /seg/lib/extensions/syncbn/src/operator.cpp: -------------------------------------------------------------------------------- 1 | #include "operator.h" 2 | 3 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 4 | m.def("batchnorm_forward", &BatchNorm_Forward_CUDA, "BatchNorm forward (CUDA)"); 5 | m.def("batchnorm_backward", &BatchNorm_Backward_CUDA, "BatchNorm backward (CUDA)"); 6 | m.def("sumsquare_forward", &Sum_Square_Forward_CUDA, "SumSqu forward (CUDA)"); 7 | m.def("sumsquare_backward", &Sum_Square_Backward_CUDA, "SumSqu backward (CUDA)"); 8 | } 9 | -------------------------------------------------------------------------------- /seg/lib/extensions/syncbn/src/operator.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | at::Tensor BatchNorm_Forward_CUDA( 6 | const at::Tensor input_, 7 | const at::Tensor mean_, 8 | const at::Tensor std_, 9 | const at::Tensor gamma_, 10 | const at::Tensor beta_); 11 | 12 | std::vector BatchNorm_Backward_CUDA( 13 | const at::Tensor gradoutput_, 14 | const at::Tensor input_, 15 | const at::Tensor mean_, 16 | const at::Tensor std_, 17 | const at::Tensor gamma_, 18 | const at::Tensor beta_, 19 | bool train); 20 | 21 | std::vector Sum_Square_Forward_CUDA( 22 | const at::Tensor input_); 23 | 24 | at::Tensor Sum_Square_Backward_CUDA( 25 | const at::Tensor input_, 26 | const at::Tensor gradSum_, 27 | const at::Tensor gradSquare_); 28 | -------------------------------------------------------------------------------- /seg/lib/loss/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/loss/__init__.py -------------------------------------------------------------------------------- /seg/lib/metrics/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/metrics/__init__.py -------------------------------------------------------------------------------- /seg/lib/metrics/cityscapes/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/metrics/cityscapes/__init__.py -------------------------------------------------------------------------------- /seg/lib/metrics/cityscapes/evaluation/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/metrics/cityscapes/evaluation/__init__.py -------------------------------------------------------------------------------- /seg/lib/metrics/cityscapes/evaluation/addToConfusionMatrix_impl.c: -------------------------------------------------------------------------------- 1 | // cython methods to speed-up evaluation 2 | 3 | void addToConfusionMatrix( const unsigned char* f_prediction_p , 4 | const unsigned char* f_groundTruth_p , 5 | const unsigned int f_width_i , 6 | const unsigned int f_height_i , 7 | unsigned long long* f_confMatrix_p , 8 | const unsigned int f_confMatDim_i ) 9 | { 10 | const unsigned int size_ui = f_height_i * f_width_i; 11 | for (unsigned int i = 0; i < size_ui; ++i) 12 | { 13 | const unsigned char predPx = f_prediction_p [i]; 14 | const unsigned char gtPx = f_groundTruth_p[i]; 15 | f_confMatrix_p[f_confMatDim_i*gtPx + predPx] += 1u; 16 | } 17 | } -------------------------------------------------------------------------------- /seg/lib/metrics/cityscapes/evaluation/instance.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Instance class 4 | # 5 | 6 | class Instance(object): 7 | instID = 0 8 | labelID = 0 9 | pixelCount = 0 10 | medDist = -1 11 | distConf = 0.0 12 | 13 | def __init__(self, imgNp, instID): 14 | if (instID == -1): 15 | return 16 | self.instID = int(instID) 17 | self.labelID = int(self.getLabelID(instID)) 18 | self.pixelCount = int(self.getInstancePixels(imgNp, instID)) 19 | 20 | def getLabelID(self, instID): 21 | if (instID < 1000): 22 | return instID 23 | else: 24 | return int(instID / 1000) 25 | 26 | def getInstancePixels(self, imgNp, instLabel): 27 | return (imgNp == instLabel).sum() 28 | 29 | def toJSON(self): 30 | return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4) 31 | 32 | def toDict(self): 33 | buildDict = {} 34 | buildDict["instID"] = self.instID 35 | buildDict["labelID"] = self.labelID 36 | buildDict["pixelCount"] = self.pixelCount 37 | buildDict["medDist"] = self.medDist 38 | buildDict["distConf"] = self.distConf 39 | return buildDict 40 | 41 | def fromJSON(self, data): 42 | self.instID = int(data["instID"]) 43 | self.labelID = int(data["labelID"]) 44 | self.pixelCount = int(data["pixelCount"]) 45 | if ("medDist" in data): 46 | self.medDist = float(data["medDist"]) 47 | self.distConf = float(data["distConf"]) 48 | 49 | def __str__(self): 50 | return "("+str(self.instID)+")" -------------------------------------------------------------------------------- /seg/lib/metrics/cityscapes/helpers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/metrics/cityscapes/helpers/__init__.py -------------------------------------------------------------------------------- /seg/lib/metrics/cityscapes/make.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # check the enviroment info 4 | 5 | # PYTHON="/root/miniconda3/bin/python" 6 | PYTHON="/data/anaconda/envs/pytorch1.7.1/bin/python" 7 | export PYTHONPATH="/msravcshare/yuyua/code/segmentation/openseg.pytorch":$PYTHONPATH 8 | 9 | cd ../../../ 10 | ${PYTHON} lib/metrics/cityscapes/setup.py build_ext --inplace 11 | -------------------------------------------------------------------------------- /seg/lib/metrics/cityscapes/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Enable cython support for eval metrics 4 | # Run as 5 | # setup.py build_ext --inplace 6 | # 7 | # WARNING: Only tested for Ubuntu 64bit OS. 8 | 9 | try: 10 | from distutils.core import setup 11 | from Cython.Build import cythonize 12 | except: 13 | print("Unable to setup. Please use pip to install: cython") 14 | print("sudo pip install cython") 15 | import os 16 | import numpy 17 | 18 | os.environ["CC"] = "g++" 19 | os.environ["CXX"] = "g++" 20 | 21 | setup(ext_modules = cythonize("lib/metrics/cityscapes/evaluation/addToConfusionMatrix.pyx"), 22 | include_dirs=[numpy.get_include()]) 23 | -------------------------------------------------------------------------------- /seg/lib/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/models/__init__.py -------------------------------------------------------------------------------- /seg/lib/models/backbones/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/models/backbones/__init__.py -------------------------------------------------------------------------------- /seg/lib/models/backbones/hrnet/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/models/backbones/hrnet/__init__.py -------------------------------------------------------------------------------- /seg/lib/models/backbones/hrt/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/models/backbones/hrt/__init__.py -------------------------------------------------------------------------------- /seg/lib/models/backbones/hrt/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/models/backbones/hrt/modules/__init__.py -------------------------------------------------------------------------------- /seg/lib/models/backbones/resnet/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/models/backbones/resnet/__init__.py -------------------------------------------------------------------------------- /seg/lib/models/backbones/vit/helper.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | 3 | 4 | class IntermediateSequential(nn.Sequential): 5 | def __init__(self, *args, return_intermediate=True): 6 | super().__init__(*args) 7 | self.return_intermediate = return_intermediate 8 | 9 | def forward(self, input): 10 | if not self.return_intermediate: 11 | return super().forward(input) 12 | 13 | intermediate_outputs = {} 14 | output = input 15 | for name, module in self.named_children(): 16 | output = intermediate_outputs[name] = module(output) 17 | 18 | return output, intermediate_outputs -------------------------------------------------------------------------------- /seg/lib/models/backbones/vit/position_encoding.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | 4 | 5 | class FixedPositionalEncoding(nn.Module): 6 | def __init__(self, embedding_dim, max_length=5000): 7 | super(FixedPositionalEncoding, self).__init__() 8 | 9 | pe = torch.zeros(max_length, embedding_dim) 10 | position = torch.arange(0, max_length, dtype=torch.float).unsqueeze(1) 11 | div_term = torch.exp( 12 | torch.arange(0, embedding_dim, 2).float() 13 | * (-torch.log(torch.tensor(10000.0)) / embedding_dim) 14 | ) 15 | pe[:, 0::2] = torch.sin(position * div_term) 16 | pe[:, 1::2] = torch.cos(position * div_term) 17 | pe = pe.unsqueeze(0).transpose(0, 1) 18 | self.register_buffer('pe', pe) 19 | 20 | def forward(self, x): 21 | x = x + self.pe[: x.size(0), :] 22 | return x 23 | 24 | 25 | class LearnedPositionalEncoding(nn.Module): 26 | def __init__(self, max_position_embeddings, embedding_dim, seq_length): 27 | super(LearnedPositionalEncoding, self).__init__() 28 | self.pe = nn.Embedding(max_position_embeddings, embedding_dim) 29 | self.seq_length = seq_length 30 | 31 | self.register_buffer( 32 | "position_ids", 33 | torch.arange(max_position_embeddings).expand((1, -1)), 34 | ) 35 | 36 | def forward(self, x, position_ids=None): 37 | if position_ids is None: 38 | position_ids = self.position_ids[:, : self.seq_length] 39 | 40 | position_embeddings = self.pe(position_ids) 41 | return x + position_embeddings -------------------------------------------------------------------------------- /seg/lib/models/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/models/modules/__init__.py -------------------------------------------------------------------------------- /seg/lib/models/modules/infer_time.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" 3 | cd $SCRIPTPATH 4 | cd ../../../ 5 | . config.profile 6 | 7 | export PYTHONPATH="../../../":$PYTHONPATH 8 | export eval_os_8=1 9 | export bn_type="inplace_abn" 10 | 11 | # ${PYTHON} -m lib.models.modules.psp_block 12 | # ${PYTHON} -m lib.models.modules.aspp_block 13 | # ${PYTHON} -m lib.models.modules.base_oc_block 14 | export isa_type="base_oc" 15 | ${PYTHON} -m lib.models.modules.isa_block 16 | ${PYTHON} -m lib.models.modules.spatial_ocr_block 17 | -------------------------------------------------------------------------------- /seg/lib/models/modules/time_log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/models/modules/time_log -------------------------------------------------------------------------------- /seg/lib/models/nets/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/models/nets/__init__.py -------------------------------------------------------------------------------- /seg/lib/models/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/models/tools/__init__.py -------------------------------------------------------------------------------- /seg/lib/utils/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /seg/lib/utils/helpers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/utils/helpers/__init__.py -------------------------------------------------------------------------------- /seg/lib/utils/helpers/dc_helper.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding:utf-8 -*- 3 | # Author: Donny You(youansheng@gmail.com) 4 | 5 | 6 | from __future__ import absolute_import 7 | from __future__ import division 8 | from __future__ import print_function 9 | 10 | import itertools 11 | 12 | from lib.extensions.parallel.data_container import DataContainer 13 | 14 | 15 | class DCHelper(object): 16 | 17 | @staticmethod 18 | def tolist(dc): 19 | return list(itertools.chain(*dc.data)) 20 | 21 | @staticmethod 22 | def todc(data_list, gpu_list, cpu_only=False): 23 | assert len(data_list) % len(gpu_list) == 0 24 | samples_per_gpu = len(data_list) // len(gpu_list) 25 | stacked = [] 26 | for i in range(0, len(data_list), samples_per_gpu): 27 | stacked.append(data_list[i:i + samples_per_gpu]) 28 | 29 | return DataContainer(stacked, cpu_only=cpu_only) 30 | -------------------------------------------------------------------------------- /seg/lib/utils/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/utils/tools/__init__.py -------------------------------------------------------------------------------- /seg/lib/utils/tools/average_meter.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #-*- coding:utf-8 -*- 3 | # Author: Donny You (youansheng@gmail.com) 4 | # Utils to store the average and current value. 5 | 6 | 7 | from __future__ import absolute_import 8 | from __future__ import division 9 | from __future__ import print_function 10 | 11 | 12 | class AverageMeter(object): 13 | """ Computes ans stores the average and current value""" 14 | def __init__(self): 15 | self.reset() 16 | 17 | def reset(self): 18 | self.val = 0. 19 | self.avg = 0. 20 | self.sum = 0. 21 | self.count = 0 22 | 23 | def update(self, val, n=1): 24 | self.val = val 25 | self.sum += val * n 26 | self.count += n 27 | self.avg = self.sum / self.count 28 | -------------------------------------------------------------------------------- /seg/lib/utils/tools/timer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding:utf-8 -*- 3 | # Author: Donny You(youansheng@gmail.com) 4 | 5 | 6 | from __future__ import absolute_import 7 | from __future__ import division 8 | from __future__ import print_function 9 | from __future__ import unicode_literals 10 | 11 | import time 12 | 13 | 14 | class Timer(object): 15 | """A simple timer.""" 16 | def __init__(self): 17 | self.reset() 18 | 19 | def tic(self): 20 | # using time.time instead of time.clock because time time.clock 21 | # does not normalize for multithreading 22 | self.start_time = time.time() 23 | 24 | def toc(self, average=True): 25 | self.diff = time.time() - self.start_time 26 | self.total_time += self.diff 27 | self.calls += 1 28 | self.average_time = self.total_time / self.calls 29 | if average: 30 | return self.average_time 31 | else: 32 | return self.diff 33 | 34 | def reset(self): 35 | self.total_time = 0. 36 | self.calls = 0 37 | self.start_time = 0. 38 | self.diff = 0. 39 | self.average_time = 0. -------------------------------------------------------------------------------- /seg/lib/vis/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/vis/__init__.py -------------------------------------------------------------------------------- /seg/lib/vis/color150.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/vis/color150.mat -------------------------------------------------------------------------------- /seg/lib/vis/color60.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/lib/vis/color60.mat -------------------------------------------------------------------------------- /seg/requirements.txt: -------------------------------------------------------------------------------- 1 | cython 2 | numpy 3 | cffi 4 | opencv-python 5 | scipy 6 | easydict 7 | matplotlib 8 | Pillow>=6.2.2 9 | torchcontrib 10 | yacs 11 | pyyaml 12 | visdom 13 | bs4 14 | html5lib 15 | ninja 16 | torch>=1.7.0 17 | torchvision>=0.6.0 18 | timm 19 | einops 20 | git+https://github.com/lucasb-eyer/pydensecrf.git#egg=pydensecrf 21 | git+https://github.com/hsfzxjy/mocona@v0.1.0#egg=mocona -------------------------------------------------------------------------------- /seg/run_dist.sh: -------------------------------------------------------------------------------- 1 | CONFIG=$1 2 | MODE=$2 3 | TAG=$3 4 | python -m pip install timm 5 | python -m pip install einops 6 | pip uninstall PIL 7 | pip install pillow 8 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 bash scripts/$CONFIG.sh $MODE $TAG . 9 | # CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 bash scripts/$CONFIG.sh resume run0_ . -------------------------------------------------------------------------------- /seg/run_local.sh: -------------------------------------------------------------------------------- 1 | 2 | CUDA_VISIBLE_DEVICES=0,1,2,3 bash scripts/coco_stuff/hrt/run_hrt_small_ocr_v2_ohem.sh local -------------------------------------------------------------------------------- /seg/scripts/test_flops/test_hrnet_w48_ocr_1024x1024.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . config.profile 4 | 5 | 6 | # PYTHON="python" 7 | PYTHON="/data/anaconda/envs/pytorch1.7.1/bin/python" 8 | 9 | # check the enviroment info 10 | export PYTHONPATH="$PWD":$PYTHONPATH 11 | DATA_DIR="${DATA_ROOT}/cityscapes" 12 | BACKBONE="hrnet48" 13 | MODEL_NAME="hrnet_w48_ocr" 14 | CONFIGS="configs/cityscapes/H_48_D_4.json" 15 | 16 | 17 | CUDA_VISIBLE_DEVICES=7 $PYTHON -m torch.distributed.launch \ 18 | --nproc_per_node=1 \ 19 | --master_port 12348 \ 20 | main.py \ 21 | --phase test_flops \ 22 | --configs ${CONFIGS} --drop_last y \ 23 | --backbone ${BACKBONE} --model_name ${MODEL_NAME} \ 24 | --val_batch_size 1 \ 25 | --shape 1024 1024 \ 26 | --test_dir ${DATA_DIR}/val/image \ 27 | --data_dir ${DATA_DIR} 28 | -------------------------------------------------------------------------------- /seg/scripts/test_flops/test_hrnet_w48_ocr_512x512.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . config.profile 4 | 5 | 6 | PYTHON="python" 7 | 8 | # check the enviroment info 9 | export PYTHONPATH="$PWD":$PYTHONPATH 10 | DATA_DIR="${DATA_ROOT}/cityscapes" 11 | BACKBONE="hrnet48" 12 | MODEL_NAME="hrnet_w48_ocr" 13 | CONFIGS="configs/cityscapes/H_48_D_4.json" 14 | 15 | 16 | CUDA_VISIBLE_DEVICES=7 $PYTHON -m torch.distributed.launch \ 17 | --nproc_per_node=1 \ 18 | --master_port 12348 \ 19 | main.py \ 20 | --phase test_flops \ 21 | --configs ${CONFIGS} --drop_last y \ 22 | --backbone ${BACKBONE} --model_name ${MODEL_NAME} \ 23 | --val_batch_size 1 \ 24 | --shape 512 512 \ 25 | --test_dir ${DATA_DIR}/val/image \ 26 | --data_dir ${DATA_DIR} 27 | -------------------------------------------------------------------------------- /seg/scripts/test_flops/test_hrvit_w18_ocr_v2_1024x1024.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . config.profile 4 | 5 | 6 | # PYTHON="python" 7 | PYTHON="/data/anaconda/envs/pytorch1.7.1/bin/python" 8 | 9 | # check the enviroment info 10 | export PYTHONPATH="$PWD":$PYTHONPATH 11 | DATA_DIR="${DATA_ROOT}/cityscapes" 12 | BACKBONE="hrt18_win11" 13 | MODEL_NAME="hrt_w18_ocr_v2" 14 | CONFIGS="configs/cityscapes/H_48_D_4.json" 15 | 16 | 17 | CUDA_VISIBLE_DEVICES=7 $PYTHON -m torch.distributed.launch \ 18 | --nproc_per_node=1 \ 19 | --master_port 12348 \ 20 | main.py \ 21 | --phase test_flops \ 22 | --configs ${CONFIGS} --drop_last y \ 23 | --backbone ${BACKBONE} --model_name ${MODEL_NAME} \ 24 | --val_batch_size 1 \ 25 | --shape 1024 1024 \ 26 | --test_dir ${DATA_DIR}/val/image \ 27 | --data_dir ${DATA_DIR} 28 | -------------------------------------------------------------------------------- /seg/scripts/test_flops/test_hrvit_w32_ocr_v2_1024x1024.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . config.profile 4 | 5 | PYTHON="python" 6 | PYTHON="/data/anaconda/envs/pytorch1.7.1/bin/python" 7 | 8 | # check the enviroment info 9 | export PYTHONPATH="$PWD":$PYTHONPATH 10 | DATA_DIR="${DATA_ROOT}/cityscapes" 11 | BACKBONE="hrt32_win11" 12 | MODEL_NAME="hrt_w32_ocr_v2" 13 | CONFIGS="configs/cityscapes/H_48_D_4.json" 14 | 15 | 16 | CUDA_VISIBLE_DEVICES=7 $PYTHON -m torch.distributed.launch \ 17 | --nproc_per_node=1 \ 18 | --master_port 12348 \ 19 | main.py \ 20 | --phase test_flops \ 21 | --configs ${CONFIGS} --drop_last y \ 22 | --backbone ${BACKBONE} --model_name ${MODEL_NAME} \ 23 | --val_batch_size 1 \ 24 | --shape 1024 1024 \ 25 | --test_dir ${DATA_DIR}/val/image \ 26 | --data_dir ${DATA_DIR} 27 | 28 | # win9: [422.8918078339999], time: [0.18235397338867188], params: [13538496] 29 | # win11: [426.503305604], time: [0.1842280626296997], params: [13557040] 30 | 31 | -------------------------------------------------------------------------------- /seg/scripts/test_flops/test_hrvit_w32_ocr_v2_512x512.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . config.profile 4 | 5 | 6 | PYTHON="python" 7 | 8 | # check the enviroment info 9 | export PYTHONPATH="$PWD":$PYTHONPATH 10 | DATA_DIR="${DATA_ROOT}/cityscapes" 11 | BACKBONE="hrt32" 12 | MODEL_NAME="hrt_w32_ocr_v2" 13 | CONFIGS="configs/cityscapes/H_48_D_4.json" 14 | 15 | 16 | CUDA_VISIBLE_DEVICES=7 $PYTHON -m torch.distributed.launch \ 17 | --nproc_per_node=1 \ 18 | --master_port 12348 \ 19 | main.py \ 20 | --phase test_flops \ 21 | --configs ${CONFIGS} --drop_last y \ 22 | --backbone ${BACKBONE} --model_name ${MODEL_NAME} \ 23 | --val_batch_size 1 \ 24 | --shape 512 512 \ 25 | --test_dir ${DATA_DIR}/val/image \ 26 | --data_dir ${DATA_DIR} 27 | -------------------------------------------------------------------------------- /seg/scripts/test_flops/test_hrvit_w78_ocr_v2_1024x1024.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . config.profile 4 | 5 | 6 | # PYTHON="python" 7 | PYTHON="/data/anaconda/envs/pytorch1.7.1/bin/python" 8 | 9 | # check the enviroment info 10 | export PYTHONPATH="$PWD":$PYTHONPATH 11 | DATA_DIR="${DATA_ROOT}/cityscapes" 12 | BACKBONE="hrt78_win5" 13 | MODEL_NAME="hrt_w78_ocr_v2" 14 | CONFIGS="configs/cityscapes/H_48_D_4.json" 15 | 16 | 17 | CUDA_VISIBLE_DEVICES=7 $PYTHON -m torch.distributed.launch \ 18 | --nproc_per_node=1 \ 19 | --master_port 12348 \ 20 | main.py \ 21 | --phase test_flops \ 22 | --configs ${CONFIGS} --drop_last y \ 23 | --backbone ${BACKBONE} --model_name ${MODEL_NAME} \ 24 | --val_batch_size 1 \ 25 | --shape 1024 1024 \ 26 | --test_dir ${DATA_DIR}/val/image \ 27 | --data_dir ${DATA_DIR} 28 | 29 | # win5: [1040.3456280679998], time: [0.4938585996627808], params: [56011040] 30 | # win9: [1064.383171876], time: [0.2658221960067749], params: [56061792] 31 | # win11: [1069.619142052], time: [0.26983258724212644], params: [56098880] 32 | # win15: [1119.8634440679998], time: [0.2960237741470337], params: [56196480] 33 | # msw_hrt78_v1: [1063.5940612839997], time: [0.29960753917694094], params: [56116320] 34 | 35 | -------------------------------------------------------------------------------- /seg/scripts/test_flops/test_hrvit_w78_ocr_v2_512x512.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . config.profile 4 | 5 | 6 | # PYTHON="python" 7 | PYTHON="/data/anaconda/envs/pytorch1.7.1/bin/python" 8 | 9 | # check the enviroment info 10 | export PYTHONPATH="$PWD":$PYTHONPATH 11 | DATA_DIR="${DATA_ROOT}/cityscapes" 12 | BACKBONE="hrt78" 13 | MODEL_NAME="hrt_w78_ocr_v2" 14 | CONFIGS="configs/cityscapes/H_48_D_4.json" 15 | 16 | 17 | CUDA_VISIBLE_DEVICES=7 $PYTHON -m torch.distributed.launch \ 18 | --nproc_per_node=1 \ 19 | --master_port 12348 \ 20 | main.py \ 21 | --phase test_flops \ 22 | --configs ${CONFIGS} --drop_last y \ 23 | --backbone ${BACKBONE} --model_name ${MODEL_NAME} \ 24 | --val_batch_size 1 \ 25 | --shape 512 512 \ 26 | --test_dir ${DATA_DIR}/val/image \ 27 | --data_dir ${DATA_DIR} 28 | -------------------------------------------------------------------------------- /seg/scripts/test_flops/test_wide_hrnet_w32_ocr_v2_1024x1024.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . config.profile 4 | 5 | 6 | PYTHON="python" 7 | 8 | # check the enviroment info 9 | export PYTHONPATH="$PWD":$PYTHONPATH 10 | DATA_DIR="${DATA_ROOT}/cityscapes" 11 | BACKBONE="wide_hrnet32" 12 | MODEL_NAME="wide_hrnet_w32_ocr_v2" 13 | CONFIGS="configs/cityscapes/H_48_D_4.json" 14 | 15 | 16 | CUDA_VISIBLE_DEVICES=7 $PYTHON -m torch.distributed.launch \ 17 | --nproc_per_node=1 \ 18 | --master_port 12348 \ 19 | main.py \ 20 | --phase test_flops \ 21 | --configs ${CONFIGS} --drop_last y \ 22 | --backbone ${BACKBONE} --model_name ${MODEL_NAME} \ 23 | --val_batch_size 1 \ 24 | --shape 1024 1024 \ 25 | --test_dir ${DATA_DIR}/val/image \ 26 | --data_dir ${DATA_DIR} 27 | -------------------------------------------------------------------------------- /seg/scripts/test_flops/test_wide_hrnet_w32_ocr_v2_512x512.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . config.profile 4 | 5 | 6 | PYTHON="python" 7 | 8 | # check the enviroment info 9 | export PYTHONPATH="$PWD":$PYTHONPATH 10 | DATA_DIR="${DATA_ROOT}/cityscapes" 11 | BACKBONE="wide_hrnet32" 12 | MODEL_NAME="wide_hrnet_w32_ocr_v2" 13 | CONFIGS="configs/cityscapes/H_48_D_4.json" 14 | 15 | 16 | CUDA_VISIBLE_DEVICES=7 $PYTHON -m torch.distributed.launch \ 17 | --nproc_per_node=1 \ 18 | --master_port 12348 \ 19 | main.py \ 20 | --phase test_flops \ 21 | --configs ${CONFIGS} --drop_last y \ 22 | --backbone ${BACKBONE} --model_name ${MODEL_NAME} \ 23 | --val_batch_size 1 \ 24 | --shape 512 512 \ 25 | --test_dir ${DATA_DIR}/val/image \ 26 | --data_dir ${DATA_DIR} 27 | -------------------------------------------------------------------------------- /seg/scripts/test_flops/test_wide_hrnet_w78_ocr_v2_1024x1024.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . config.profile 4 | 5 | 6 | # PYTHON="python" 7 | PYTHON="/data/anaconda/envs/pytorch1.7.1/bin/python" 8 | 9 | # check the enviroment info 10 | export PYTHONPATH="$PWD":$PYTHONPATH 11 | DATA_DIR="${DATA_ROOT}/cityscapes" 12 | BACKBONE="wide_hrnet78" 13 | MODEL_NAME="wide_hrnet_w78_ocr_v2" 14 | CONFIGS="configs/cityscapes/H_48_D_4.json" 15 | 16 | 17 | CUDA_VISIBLE_DEVICES=7 $PYTHON -m torch.distributed.launch \ 18 | --nproc_per_node=1 \ 19 | --master_port 12348 \ 20 | main.py \ 21 | --phase test_flops \ 22 | --configs ${CONFIGS} --drop_last y \ 23 | --backbone ${BACKBONE} --model_name ${MODEL_NAME} \ 24 | --val_batch_size 1 \ 25 | --shape 1024 1024 \ 26 | --test_dir ${DATA_DIR}/val/image \ 27 | --data_dir ${DATA_DIR} 28 | -------------------------------------------------------------------------------- /seg/scripts/test_flops/test_wide_hrnet_w78_ocr_v2_512x512.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . config.profile 4 | 5 | 6 | PYTHON="python" 7 | 8 | # check the enviroment info 9 | export PYTHONPATH="$PWD":$PYTHONPATH 10 | DATA_DIR="${DATA_ROOT}/cityscapes" 11 | BACKBONE="wide_hrnet78" 12 | MODEL_NAME="wide_hrnet_w78_ocr_v2" 13 | CONFIGS="configs/cityscapes/H_48_D_4.json" 14 | 15 | 16 | CUDA_VISIBLE_DEVICES=7 $PYTHON -m torch.distributed.launch \ 17 | --nproc_per_node=1 \ 18 | --master_port 12348 \ 19 | main.py \ 20 | --phase test_flops \ 21 | --configs ${CONFIGS} --drop_last y \ 22 | --backbone ${BACKBONE} --model_name ${MODEL_NAME} \ 23 | --val_batch_size 1 \ 24 | --shape 512 512 \ 25 | --test_dir ${DATA_DIR}/val/image \ 26 | --data_dir ${DATA_DIR} 27 | -------------------------------------------------------------------------------- /seg/segmentor/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/segmentor/__init__.py -------------------------------------------------------------------------------- /seg/segmentor/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HRNet/HRFormer/1245b88b5824fbd8cdb358b5ee909a4e537a2ef5/seg/segmentor/tools/__init__.py -------------------------------------------------------------------------------- /seg/segmentor/tools/evaluator/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from lib.utils.tools.logger import Logger as Log 4 | from . import standard 5 | 6 | evaluators = { 7 | 'standard': standard.StandardEvaluator 8 | } 9 | 10 | 11 | def get_evaluator(configer, trainer, name=None): 12 | name = os.environ.get('evaluator', 'standard') 13 | 14 | if not name in evaluators: 15 | raise RuntimeError('Unknown evaluator name: {}'.format(name)) 16 | klass = evaluators[name] 17 | Log.info('Using evaluator: {}'.format(klass.__name__)) 18 | 19 | return klass(configer, trainer) 20 | --------------------------------------------------------------------------------