diff --git a/configs/cascade_rcnn_r50_fpn_1x.yml b/configs/cascade_rcnn_r50_fpn_1x.yml index 3e257d043cd8279cbe57a740d42e0978504d2104..81f5eb09a6dd7b1a7880a04a2dac87a6264718be 100644 --- a/configs/cascade_rcnn_r50_fpn_1x.yml +++ b/configs/cascade_rcnn_r50_fpn_1x.yml @@ -10,6 +10,7 @@ save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar weights: output/cascade_rcnn_r50_fpn_1x/model_final metric: COCO +num_classes: 81 CascadeRCNN: backbone: ResNet @@ -74,7 +75,6 @@ CascadeBBoxAssigner: bg_thresh_hi: [0.5, 0.6, 0.7] fg_thresh: [0.5, 0.6, 0.7] fg_fraction: 0.25 - num_classes: 81 CascadeBBoxHead: head: FC6FC7Head @@ -82,7 +82,6 @@ CascadeBBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 FC6FC7Head: num_chan: 1024 diff --git a/configs/faster_rcnn_r101_1x.yml b/configs/faster_rcnn_r101_1x.yml index b04a9fc42eb5328eea0292c222d0e724f9a35146..27773309ac3e6ffa3abef7018f675ac00d62148c 100644 --- a/configs/faster_rcnn_r101_1x.yml +++ b/configs/faster_rcnn_r101_1x.yml @@ -10,6 +10,7 @@ snapshot_iter: 10000 pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet101_pretrained.tar metric: COCO weights: output/faster_rcnn_r101_1x/model_final +num_classes: 81 FasterRCNN: backbone: ResNet @@ -64,7 +65,6 @@ BBoxAssigner: bg_thresh_lo: 0.0 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 BBoxHead: head: ResNetC5 @@ -72,7 +72,6 @@ BBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 LearningRate: base_lr: 0.01 diff --git a/configs/faster_rcnn_r101_fpn_1x.yml b/configs/faster_rcnn_r101_fpn_1x.yml index c9536b46cb93c0016c2c285f9452bb45e75e013b..dbb4d6d9aa9019e111a32a5ba89642fd0b73a547 100644 --- a/configs/faster_rcnn_r101_fpn_1x.yml +++ b/configs/faster_rcnn_r101_fpn_1x.yml @@ -10,6 +10,7 @@ save_dir: output pretrain_weights: http://paddle-imagenet-models-name.bj.bcebos.com/ResNet101_pretrained.tar weights: output/faster_rcnn_r101_fpn_1x/model_final metric: COCO +num_classes: 81 FasterRCNN: backbone: ResNet @@ -73,7 +74,6 @@ BBoxAssigner: bg_thresh_lo: 0.0 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 BBoxHead: head: TwoFCHead @@ -81,7 +81,6 @@ BBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 TwoFCHead: num_chan: 1024 diff --git a/configs/faster_rcnn_r101_fpn_2x.yml b/configs/faster_rcnn_r101_fpn_2x.yml index 995c8e936379c760cfa263d88cb286c41f14fee2..a742782bcf7e0fac62ac9d2179bd46806ed97d3e 100644 --- a/configs/faster_rcnn_r101_fpn_2x.yml +++ b/configs/faster_rcnn_r101_fpn_2x.yml @@ -10,6 +10,7 @@ save_dir: output pretrain_weights: http://paddle-imagenet-models-name.bj.bcebos.com/ResNet101_pretrained.tar weights: output/faster_rcnn_r101_fpn_2x/model_final metric: COCO +num_classes: 81 FasterRCNN: backbone: ResNet @@ -73,7 +74,6 @@ BBoxAssigner: bg_thresh_lo: 0.0 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 BBoxHead: head: TwoFCHead @@ -81,7 +81,6 @@ BBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 TwoFCHead: num_chan: 1024 diff --git a/configs/faster_rcnn_r101_vd_fpn_1x.yml b/configs/faster_rcnn_r101_vd_fpn_1x.yml index 033104194b0e6f52b249e7b3dba175d7bb57cc3c..7c0fc39be9a8c1bdc295cdf8a7dc6de246e9f186 100644 --- a/configs/faster_rcnn_r101_vd_fpn_1x.yml +++ b/configs/faster_rcnn_r101_vd_fpn_1x.yml @@ -10,6 +10,7 @@ save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet101_vd_pretrained.tar weights: output/faster_rcnn_r101_vd_fpn_1x/model_final metric: COCO +num_classes: 81 FasterRCNN: backbone: ResNet @@ -74,7 +75,6 @@ BBoxAssigner: bg_thresh_lo: 0.0 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 BBoxHead: head: TwoFCHead @@ -82,7 +82,6 @@ BBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 TwoFCHead: num_chan: 1024 diff --git a/configs/faster_rcnn_r101_vd_fpn_2x.yml b/configs/faster_rcnn_r101_vd_fpn_2x.yml index 722fcf887c1b722140914ad922c179125cbc9952..726de38a9c2049c69f2c1427e2e1ab757164b805 100644 --- a/configs/faster_rcnn_r101_vd_fpn_2x.yml +++ b/configs/faster_rcnn_r101_vd_fpn_2x.yml @@ -10,6 +10,7 @@ save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet101_vd_pretrained.tar weights: output/faster_rcnn_r101_vd_fpn_2x/model_final metric: COCO +num_classes: 81 FasterRCNN: backbone: ResNet @@ -74,7 +75,6 @@ BBoxAssigner: bg_thresh_lo: 0.0 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 BBoxHead: head: TwoFCHead @@ -82,7 +82,6 @@ BBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 TwoFCHead: num_chan: 1024 diff --git a/configs/faster_rcnn_r50_1x.yml b/configs/faster_rcnn_r50_1x.yml index 9ec90c674d1a5608cef205aac0e2820db6a625ca..bf4a828fb0a9b8385924e05e3a1c9252ed0412c1 100644 --- a/configs/faster_rcnn_r50_1x.yml +++ b/configs/faster_rcnn_r50_1x.yml @@ -10,6 +10,7 @@ snapshot_iter: 10000 pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar metric: COCO weights: output/faster_rcnn_r50_1x/model_final +num_classes: 81 FasterRCNN: backbone: ResNet @@ -64,7 +65,6 @@ BBoxAssigner: bg_thresh_lo: 0.0 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 BBoxHead: head: ResNetC5 @@ -72,7 +72,6 @@ BBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 LearningRate: base_lr: 0.01 diff --git a/configs/faster_rcnn_r50_2x.yml b/configs/faster_rcnn_r50_2x.yml index c28bcc25f9781cb84f03eeb782011bbb7518bb47..5257161aae01e6ff2a728f2929d13dc25d5027bb 100644 --- a/configs/faster_rcnn_r50_2x.yml +++ b/configs/faster_rcnn_r50_2x.yml @@ -10,6 +10,7 @@ snapshot_iter: 10000 pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar metric: COCO weights: output/faster_rcnn_r50_2x/model_final +num_classes: 81 FasterRCNN: backbone: ResNet @@ -64,7 +65,6 @@ BBoxAssigner: bg_thresh_lo: 0.0 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 BBoxHead: head: ResNetC5 @@ -72,7 +72,6 @@ BBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 LearningRate: base_lr: 0.01 diff --git a/configs/faster_rcnn_r50_fpn_1x.yml b/configs/faster_rcnn_r50_fpn_1x.yml index b06ec6ffe6474a6d8860b1c3c665e11f66349d4b..d41e9e737252bc52db806010e023be754b31b613 100644 --- a/configs/faster_rcnn_r50_fpn_1x.yml +++ b/configs/faster_rcnn_r50_fpn_1x.yml @@ -10,6 +10,7 @@ save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar metric: COCO weights: output/fpn/faster_rcnn_r50_fpn_1x/model_final +num_classes: 81 FasterRCNN: backbone: ResNet @@ -74,7 +75,6 @@ BBoxAssigner: bg_thresh_hi: 0.5 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 BBoxHead: head: TwoFCHead @@ -82,7 +82,6 @@ BBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 TwoFCHead: num_chan: 1024 diff --git a/configs/faster_rcnn_r50_fpn_2x.yml b/configs/faster_rcnn_r50_fpn_2x.yml index b5cf9931ddb13fedd4d77380ccc06f430e2307d6..a1989db64b17967ba00d3f286c0209c27eb90013 100644 --- a/configs/faster_rcnn_r50_fpn_2x.yml +++ b/configs/faster_rcnn_r50_fpn_2x.yml @@ -10,6 +10,7 @@ save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar metric: COCO weights: output/faster_rcnn_r50_fpn_2x/model_final +num_classes: 81 FasterRCNN: backbone: ResNet @@ -74,7 +75,6 @@ BBoxAssigner: bg_thresh_hi: 0.5 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 BBoxHead: head: TwoFCHead @@ -82,7 +82,6 @@ BBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 TwoFCHead: num_chan: 1024 diff --git a/configs/faster_rcnn_r50_vd_1x.yml b/configs/faster_rcnn_r50_vd_1x.yml index 5941a03777f480e203e0e046da7aa4255d06da7b..25ce550e408c7d935fd5e7f5e75a47fbbfbc2dc1 100644 --- a/configs/faster_rcnn_r50_vd_1x.yml +++ b/configs/faster_rcnn_r50_vd_1x.yml @@ -10,6 +10,7 @@ snapshot_iter: 10000 pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_vd_pretrained.tar metric: COCO weights: output/faster_rcnn_r50_vd_1x/model_final +num_classes: 81 FasterRCNN: backbone: ResNet @@ -66,7 +67,6 @@ BBoxAssigner: bg_thresh_lo: 0.0 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 BBoxHead: head: ResNetC5 @@ -74,7 +74,6 @@ BBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 LearningRate: base_lr: 0.01 diff --git a/configs/faster_rcnn_r50_vd_fpn_2x.yml b/configs/faster_rcnn_r50_vd_fpn_2x.yml index 3d92f6f8308c5e4e129e47c1db23345351e0198b..ef19b275fdbd491a3b18e60580cda4fb709714ea 100644 --- a/configs/faster_rcnn_r50_vd_fpn_2x.yml +++ b/configs/faster_rcnn_r50_vd_fpn_2x.yml @@ -10,6 +10,7 @@ save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_vd_pretrained.tar weights: output/faster_rcnn_r50_vd_fpn_2x/model_final metric: COCO +num_classes: 81 FasterRCNN: backbone: ResNet @@ -74,7 +75,6 @@ BBoxAssigner: bg_thresh_lo: 0.0 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 BBoxHead: head: TwoFCHead @@ -82,7 +82,6 @@ BBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 TwoFCHead: num_chan: 1024 diff --git a/configs/faster_rcnn_se154_vd_fpn_s1x.yml b/configs/faster_rcnn_se154_vd_fpn_s1x.yml index 26dc789bd801e75ade532f589ff340c1ead0a5c5..3e16ecc25699d199765955d2cf610cc392185c26 100644 --- a/configs/faster_rcnn_se154_vd_fpn_s1x.yml +++ b/configs/faster_rcnn_se154_vd_fpn_s1x.yml @@ -10,6 +10,7 @@ save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/SE154_vd_pretrained.tar weights: output/faster_rcnn_se154_vd_fpn_s1x/model_final metric: COCO +num_classes: 81 FasterRCNN: backbone: SENet @@ -76,7 +77,6 @@ BBoxAssigner: bg_thresh_lo: 0.0 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 BBoxHead: head: TwoFCHead @@ -84,7 +84,6 @@ BBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 TwoFCHead: num_chan: 1024 diff --git a/configs/faster_rcnn_x101_vd_64x4d_fpn_1x.yml b/configs/faster_rcnn_x101_vd_64x4d_fpn_1x.yml index 60c243b2d34df943ee4a3f777884b7ae256e469a..435f937ea4827023552c0c7ed253d14902c93498 100644 --- a/configs/faster_rcnn_x101_vd_64x4d_fpn_1x.yml +++ b/configs/faster_rcnn_x101_vd_64x4d_fpn_1x.yml @@ -10,6 +10,7 @@ save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNeXt101_vd_64x4d_pretrained.tar weights: output/faster_rcnn_x101_vd_64x4d_fpn_1x/model_final metric: COCO +num_classes: 81 FasterRCNN: backbone: ResNeXt @@ -76,7 +77,6 @@ BBoxAssigner: bg_thresh_lo: 0.0 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 BBoxHead: head: TwoFCHead @@ -84,7 +84,6 @@ BBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 TwoFCHead: num_chan: 1024 diff --git a/configs/mask_rcnn_r101_fpn_1x.yml b/configs/mask_rcnn_r101_fpn_1x.yml index d7b9aa0ce6b77d5512a59c5b72c9394cb3d06bb8..d9a476b9eadaa5d9d39ea5e210497d36b2b94be1 100644 --- a/configs/mask_rcnn_r101_fpn_1x.yml +++ b/configs/mask_rcnn_r101_fpn_1x.yml @@ -10,6 +10,7 @@ save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet101_pretrained.tar metric: COCO weights: output/mask_rcnn_r101_fpn_1x/model_final/ +num_classes: 81 MaskRCNN: backbone: ResNet @@ -68,7 +69,6 @@ FPNRoIAlign: MaskHead: dilation: 1 num_chan_reduced: 256 - num_classes: 81 num_convs: 4 resolution: 28 @@ -79,7 +79,6 @@ BBoxAssigner: bg_thresh_lo: 0.0 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 MaskAssigner: resolution: 28 @@ -90,7 +89,6 @@ BBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 TwoFCHead: num_chan: 1024 diff --git a/configs/mask_rcnn_r50_1x.yml b/configs/mask_rcnn_r50_1x.yml index 571be5fef110f857719a8630c341d1a81f4c00e4..b652affbea5d9ae1b69a0bf9bcd9d09d4be095fb 100644 --- a/configs/mask_rcnn_r50_1x.yml +++ b/configs/mask_rcnn_r50_1x.yml @@ -10,6 +10,7 @@ save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar metric: COCO weights: output/mask_rcnn_r50_1x/model_final +num_classes: 81 MaskRCNN: backbone: ResNet @@ -66,12 +67,10 @@ BBoxHead: nms_threshold: 0.5 normalized: false score_threshold: 0.05 - num_classes: 81 MaskHead: dilation: 1 num_chan_reduced: 256 - num_classes: 81 resolution: 14 BBoxAssigner: @@ -81,10 +80,8 @@ BBoxAssigner: bg_thresh_lo: 0.0 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 MaskAssigner: - num_classes: 81 resolution: 14 LearningRate: diff --git a/configs/mask_rcnn_r50_2x.yml b/configs/mask_rcnn_r50_2x.yml index 2c3b59b220f1e4aeaeee04c879c09fec8576e0f5..58f9b39f48399aa540466f121baa1e3edfc59097 100644 --- a/configs/mask_rcnn_r50_2x.yml +++ b/configs/mask_rcnn_r50_2x.yml @@ -10,6 +10,7 @@ save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar metric: COCO weights: output/mask_rcnn_r50_2x/model_final/ +num_classes: 81 MaskRCNN: backbone: ResNet @@ -67,12 +68,10 @@ BBoxHead: nms_threshold: 0.5 normalized: false score_threshold: 0.05 - num_classes: 81 MaskHead: dilation: 1 num_chan_reduced: 256 - num_classes: 81 resolution: 14 BBoxAssigner: @@ -82,10 +81,8 @@ BBoxAssigner: bg_thresh_lo: 0.0 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 MaskAssigner: - num_classes: 81 resolution: 14 LearningRate: diff --git a/configs/mask_rcnn_r50_fpn_1x.yml b/configs/mask_rcnn_r50_fpn_1x.yml index fd378e5a52967c0b598d24b77af08661e21d1c09..1059d7b4e907ac2ae3659b85937205c1f61d5f96 100644 --- a/configs/mask_rcnn_r50_fpn_1x.yml +++ b/configs/mask_rcnn_r50_fpn_1x.yml @@ -10,6 +10,7 @@ save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar metric: COCO weights: output/mask_rcnn_r50_fpn_1x/model_final/ +num_classes: 81 MaskRCNN: backbone: ResNet @@ -68,7 +69,6 @@ FPNRoIAlign: MaskHead: dilation: 1 num_chan_reduced: 256 - num_classes: 81 num_convs: 4 resolution: 28 @@ -79,7 +79,6 @@ BBoxAssigner: bg_thresh_lo: 0.0 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 MaskAssigner: resolution: 28 @@ -90,7 +89,6 @@ BBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 TwoFCHead: num_chan: 1024 diff --git a/configs/mask_rcnn_r50_fpn_2x.yml b/configs/mask_rcnn_r50_fpn_2x.yml index 59ad857bfa734c5ee983efa9f340c69e3c2aaeb1..9f7604982d38cd66eb34299dfc2ae8e043583de1 100644 --- a/configs/mask_rcnn_r50_fpn_2x.yml +++ b/configs/mask_rcnn_r50_fpn_2x.yml @@ -10,6 +10,7 @@ save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar weights: output/mask_rcnn_r50_fpn_2x/model_final/ metric: COCO +num_classes: 81 MaskRCNN: backbone: ResNet @@ -68,7 +69,6 @@ FPNRoIAlign: MaskHead: dilation: 1 num_chan_reduced: 256 - num_classes: 81 num_convs: 4 resolution: 28 @@ -79,7 +79,6 @@ BBoxAssigner: bg_thresh_lo: 0.0 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 MaskAssigner: resolution: 28 @@ -90,7 +89,6 @@ BBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 TwoFCHead: num_chan: 1024 @@ -116,7 +114,7 @@ OptimizerBuilder: MaskRCNNTrainFeed: batch_size: 1 dataset: - dataset_dir: dataset/coco + dataset_dir: dataset/coco annotation: annotations/instances_train2017.json image_dir: train2017 batch_transforms: @@ -127,7 +125,7 @@ MaskRCNNTrainFeed: MaskRCNNEvalFeed: batch_size: 1 dataset: - dataset_dir: dataset/coco + dataset_dir: dataset/coco annotation: annotations/instances_val2017.json image_dir: val2017 batch_transforms: diff --git a/configs/mask_rcnn_r50_vd_fpn_2x.yml b/configs/mask_rcnn_r50_vd_fpn_2x.yml index bee5710b1f8e43d7fade2f5f0c4b07148160a889..957c53d6ded13574c4e5093e14430831b4a94794 100644 --- a/configs/mask_rcnn_r50_vd_fpn_2x.yml +++ b/configs/mask_rcnn_r50_vd_fpn_2x.yml @@ -10,6 +10,7 @@ save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_vd_pretrained.tar metric: COCO weights: output/mask_rcnn_r50_vd_fpn_2x/model_final/ +num_classes: 81 MaskRCNN: backbone: ResNet @@ -69,7 +70,6 @@ FPNRoIAlign: MaskHead: dilation: 1 num_chan_reduced: 256 - num_classes: 81 num_convs: 4 resolution: 28 @@ -80,7 +80,6 @@ BBoxAssigner: bg_thresh_lo: 0.0 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 MaskAssigner: resolution: 28 @@ -91,7 +90,6 @@ BBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 TwoFCHead: num_chan: 1024 diff --git a/configs/mask_rcnn_se154_vd_fpn_s1x.yml b/configs/mask_rcnn_se154_vd_fpn_s1x.yml index 3346bdb1d228f7de41351133e0a738d1de95a595..76bed15ee2dc8a130e6a0a8b59461132876c6cbb 100644 --- a/configs/mask_rcnn_se154_vd_fpn_s1x.yml +++ b/configs/mask_rcnn_se154_vd_fpn_s1x.yml @@ -10,6 +10,7 @@ save_dir: output pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/SE154_vd_pretrained.tar weights: output/mask_rcnn_se154_vd_fpn_s1x/model_final/ metric: COCO +num_classes: 81 MaskRCNN: backbone: SENet @@ -71,7 +72,6 @@ FPNRoIAlign: MaskHead: dilation: 1 num_chan_reduced: 256 - num_classes: 81 num_convs: 4 resolution: 28 @@ -82,7 +82,6 @@ BBoxAssigner: bg_thresh_lo: 0.0 fg_fraction: 0.25 fg_thresh: 0.5 - num_classes: 81 MaskAssigner: resolution: 28 @@ -93,7 +92,6 @@ BBoxHead: keep_top_k: 100 nms_threshold: 0.5 score_threshold: 0.05 - num_classes: 81 TwoFCHead: num_chan: 1024 @@ -120,7 +118,7 @@ MaskRCNNTrainFeed: # batch size per device batch_size: 1 dataset: - dataset_dir: dataset/coco + dataset_dir: dataset/coco image_dir: train2017 annotation: annotations/instances_train2017.json batch_transforms: diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 10376e055a1c6333630dcaab09cfa23d638a2285..1655e02d4e4a07ded6f7ff9a736e679c33490e64 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -188,3 +188,14 @@ A small utility (`tools/configure.py`) is included to simplify the configuration ```shell python tools/configure.py --minimal generate FasterRCNN BBoxHead ``` + + +# FAQ + +**Q:** There are some configuration options that are used by multiple modules (e.g., `num_classes`), how do I avoid duplication in config files? + +**A:** We provided a `__shared__` annotation for exactly this purpose, simply annotate like this `__shared__ = ['num_classes']`. It works as follows: + +1. if `num_classes` is configured for a module in config file, it takes precedence. +2. if `num_classes` is not configured for a module but is present in the config file as a global key, its value will be used. +3. otherwise, the default value (`81`) will be used. diff --git a/docs/CONFIG_cn.md b/docs/CONFIG_cn.md index f27b7bdcc7e6f3d791352519ed56a9b97050b112..9008c3117e0af5d8cd8e5a78a206cee28a9cad24 100644 --- a/docs/CONFIG_cn.md +++ b/docs/CONFIG_cn.md @@ -180,3 +180,14 @@ pip install typeguard http://github.com/willthefrog/docstring_parser/tarball/mas ```shell python tools/configure.py --minimal generate FasterRCNN BBoxHead ``` + + +# FAQ + +**Q:** 某些配置项会在多个模块中用到(如 `num_classes`),如何避免在配置文件中多次重复设置? + +**A:** 框架提供了 `__shared__` 标记来实现配置的共享,用户可以标记参数,如 `__shared__ = ['num_classes']` ,配置数值作用规则如下: + +1. 如果模块配置中提供了 `num_classes` ,会优先使用其数值。 +2. 如果模块配置中未提供 `num_classes` ,但配置文件中存在全局键值,那么会使用全局键值。 +3. 两者均为配置的情况下,将使用默认值(`81`)。 diff --git a/ppdet/core/config/schema.py b/ppdet/core/config/schema.py index 5a73db4dc3ee43eb83746cdecdeec162bfea71f2..efba5be1dfd93243ff7a071f0f30accfa513e18f 100644 --- a/ppdet/core/config/schema.py +++ b/ppdet/core/config/schema.py @@ -43,13 +43,14 @@ except Exception: if not check_type.__warning_sent__: from ppdet.utils.cli import ColorTTY color_tty = ColorTTY() - message = "typeguard is not installed, type checking is not available" + message = "typeguard is not installed," \ + + "type checking is not available" print(color_tty.yellow(message)) check_type.__warning_sent__ = True check_type.__warning_sent__ = False -__all__ = ['SchemaValue', 'SchemaDict', 'extract_schema'] +__all__ = ['SchemaValue', 'SchemaDict', 'SharedConfig', 'extract_schema'] class SchemaValue(object): @@ -160,6 +161,27 @@ class SchemaDict(dict): self.name, ", ".join(mismatch_keys))) +class SharedConfig(object): + """ + Representation class for `__shared__` annotations, which work as follows: + + - if `key` is set for the module in config file, its value will take + precedence + - if `key` is not set for the module but present in the config file, its + value will be used + - otherwise, use the provided `default_value` as fallback + + Args: + key: config[key] will be injected + default_value: fallback value + """ + + def __init__(self, key, default_value=None): + super(SharedConfig, self).__init__() + self.key = key + self.default_value = default_value + + def extract_schema(cls): """ Extract schema from a given class @@ -216,6 +238,7 @@ def extract_schema(cls): schema.strict = not has_kwargs schema.pymodule = importlib.import_module(cls.__module__) schema.inject = getattr(cls, '__inject__', []) + schema.shared = getattr(cls, '__shared__', []) for idx, name in enumerate(names): comment = name in comments and comments[name] or name if name in schema.inject: @@ -223,8 +246,13 @@ def extract_schema(cls): else: type_ = name in annotations and annotations[name] or None value_schema = SchemaValue(name, comment, type_) - if idx >= num_required: - value_schema.set_default(defaults[idx - num_required]) + if name in schema.shared: + assert idx >= num_required, "shared config must have default value" + default = defaults[idx - num_required] + value_schema.set_default(SharedConfig(name, default)) + elif idx >= num_required: + default = defaults[idx - num_required] + value_schema.set_default(default) schema.set_schema(name, value_schema) return schema diff --git a/ppdet/core/config/yaml_helpers.py b/ppdet/core/config/yaml_helpers.py index 099a13e55d4c2982709e6dd4ba6d9939e7fa02ec..8a7738b47f4f86acde78ab8a3bcac590d61615fa 100644 --- a/ppdet/core/config/yaml_helpers.py +++ b/ppdet/core/config/yaml_helpers.py @@ -16,6 +16,7 @@ import importlib import inspect import yaml +from .schema import SharedConfig __all__ = ['serializable', 'Callable'] @@ -59,7 +60,8 @@ def _make_python_representer(cls): def serializable(cls): """ - Add loader and dumper for given class, which must be "trivially serializable" + Add loader and dumper for given class, which must be + "trivially serializable" Args: cls: class to be serialized @@ -72,6 +74,10 @@ def serializable(cls): return cls +yaml.add_representer(SharedConfig, + lambda d, o: d.represent_data(o.default_value)) + + @serializable class Callable(object): """ diff --git a/ppdet/core/workspace.py b/ppdet/core/workspace.py index 375da3e33f88e4d0159d581bf010f3e308b5228c..c922b3b3cde39e3908c41446b2e5c9f4b231762d 100644 --- a/ppdet/core/workspace.py +++ b/ppdet/core/workspace.py @@ -23,7 +23,7 @@ import sys import yaml import copy -from .config.schema import SchemaDict, extract_schema +from .config.schema import SchemaDict, SharedConfig, extract_schema from .config.yaml_helpers import serializable __all__ = [ @@ -136,7 +136,8 @@ def create(cls_or_name, **kwargs): assert type(cls_or_name) in [type, str ], "should be a class or name of a class" name = type(cls_or_name) == str and cls_or_name or cls_or_name.__name__ - assert name in global_config and isinstance(global_config[name], SchemaDict), \ + assert name in global_config and \ + isinstance(global_config[name], SchemaDict), \ "the module {} is not registered".format(name) config = global_config[name] config.update(kwargs) @@ -145,9 +146,26 @@ def create(cls_or_name, **kwargs): kwargs = {} kwargs.update(global_config[name]) + + # parse `shared` annoation of registered modules + if getattr(config, 'shared', None): + for k in config.shared: + target_key = config[k] + shared_conf = config.schema[k].default + assert isinstance(shared_conf, SharedConfig) + if target_key is not None and not isinstance( + target_key, SharedConfig): + continue # value is given for the module + elif shared_conf.key in global_config: + # `key` is present in config + kwargs[k] = global_config[shared_conf.key] + else: + kwargs[k] = shared_conf.default_value + + # parse `inject` annoation of registered modules if getattr(config, 'inject', None): for k in config.inject: - target_key = global_config[name][k] + target_key = config[k] # optional dependency if target_key is None: continue diff --git a/ppdet/data/data_feed.py b/ppdet/data/data_feed.py index b4a89803f05db51c9594b71a943740532d85517f..b3c7222cae5a3d819b72a5d11438787f97c33ba6 100644 --- a/ppdet/data/data_feed.py +++ b/ppdet/data/data_feed.py @@ -181,7 +181,6 @@ class DataSet(object): Args: annotation (str): annotation file path image_dir (str): directory where image files are stored - num_classes (int): number of classes shuffle (bool): shuffle samples """ __source__ = 'RoiDbSource' diff --git a/ppdet/modeling/anchor_heads/retina_head.py b/ppdet/modeling/anchor_heads/retina_head.py index 918efc8e220b9a58a8ce3db975500182340a2953..41246e8b6267881f62386653841ecfb525a254e1 100644 --- a/ppdet/modeling/anchor_heads/retina_head.py +++ b/ppdet/modeling/anchor_heads/retina_head.py @@ -25,7 +25,7 @@ from paddle.fluid.regularizer import L2Decay from ppdet.modeling.ops import (AnchorGenerator, RetinaTargetAssign, RetinaOutputDecoder) -from ppdet.core.workspace import register, serializable +from ppdet.core.workspace import register __all__ = ['RetinaHead'] @@ -52,6 +52,7 @@ class RetinaHead(object): sigma (float): The parameter in smooth l1 loss """ __inject__ = ['anchor_generator', 'target_assign', 'output_decoder'] + __shared__ = ['num_classes'] def __init__(self, anchor_generator=AnchorGenerator().__dict__, @@ -333,7 +334,6 @@ class RetinaHead(object): cls_pred_reshape_list = output['cls_pred'] bbox_pred_reshape_list = output['bbox_pred'] anchor_reshape_list = output['anchor'] - anchor_var_reshape_list = output['anchor_var'] for i in range(self.max_level - self.min_level + 1): cls_pred_reshape_list[i] = fluid.layers.sigmoid( cls_pred_reshape_list[i]) diff --git a/ppdet/modeling/ops.py b/ppdet/modeling/ops.py index ae804134c5faebac92b21b7a28dea6369877d772..a6a08728d569df06395021e12ba2a85859ba6eeb 100644 --- a/ppdet/modeling/ops.py +++ b/ppdet/modeling/ops.py @@ -88,6 +88,7 @@ class GenerateProposals(object): class MaskAssigner(object): __op__ = fluid.layers.generate_mask_labels __append_doc__ = True + __shared__ = ['num_classes'] def __init__(self, num_classes=81, resolution=14): super(MaskAssigner, self).__init__() @@ -123,6 +124,7 @@ class MultiClassNMS(object): class BBoxAssigner(object): __op__ = fluid.layers.generate_proposal_labels __append_doc__ = True + __shared__ = ['num_classes'] def __init__(self, batch_size_per_im=512, diff --git a/ppdet/modeling/roi_heads/bbox_head.py b/ppdet/modeling/roi_heads/bbox_head.py index a5344cf4a550564e263f644d2a334cf22d4d1461..21f79459d4b931021b89266c00082510c6b3641d 100644 --- a/ppdet/modeling/roi_heads/bbox_head.py +++ b/ppdet/modeling/roi_heads/bbox_head.py @@ -92,12 +92,13 @@ class BBoxHead(object): RCNN bbox head Args: - head (object): the head module instance, e.g., `ResNetC5` or `TwoFCHead` + head (object): the head module instance, e.g., `ResNetC5`, `TwoFCHead` box_coder (object): `BoxCoder` instance nms (object): `MultiClassNMS` instance num_classes: number of output classes """ __inject__ = ['head', 'box_coder', 'nms'] + __shared__ = ['num_classes'] def __init__(self, head, diff --git a/ppdet/modeling/roi_heads/cascade_head.py b/ppdet/modeling/roi_heads/cascade_head.py index 8971b4e0376be0cbc5a5443e58fb202d09616d57..aad4b141d6043ff0ca4dc66eaac5c58fd4986053 100644 --- a/ppdet/modeling/roi_heads/cascade_head.py +++ b/ppdet/modeling/roi_heads/cascade_head.py @@ -37,6 +37,7 @@ class CascadeBBoxHead(object): num_classes: number of output classes """ __inject__ = ['head', 'nms'] + __shared__ = ['num_classes'] def __init__(self, head, nms=MultiClassNMS().__dict__, num_classes=81): super(CascadeBBoxHead, self).__init__() diff --git a/ppdet/modeling/roi_heads/mask_head.py b/ppdet/modeling/roi_heads/mask_head.py index 1d2b027de0f0e8a280e10fe5c7500a5b2da650d3..ad59de00e346be98ff99aec12abb504cfa304795 100644 --- a/ppdet/modeling/roi_heads/mask_head.py +++ b/ppdet/modeling/roi_heads/mask_head.py @@ -38,6 +38,8 @@ class MaskHead(object): num_classes (int): number of output classes """ + __shared__ = ['num_classes'] + def __init__(self, num_convs=0, num_chan_reduced=256, diff --git a/ppdet/modeling/target_assigners.py b/ppdet/modeling/target_assigners.py index ccdb2672e872689bac53e2791dc3c9760880352e..03755762df22c9707c0a15202561ed4cb145a0f4 100644 --- a/ppdet/modeling/target_assigners.py +++ b/ppdet/modeling/target_assigners.py @@ -26,6 +26,8 @@ __all__ = ['BBoxAssigner', 'MaskAssigner', 'CascadeBBoxAssigner'] @register class CascadeBBoxAssigner(object): + __shared__ = ['num_classes'] + def __init__(self, batch_size_per_im=512, fg_fraction=.25,