├── LICENSE ├── README.md ├── configs ├── Base-RCNN-FPN.yaml ├── COCO-detection │ ├── Base-RCNN-FPN.yaml │ ├── faster_rcnn_R_101_FPN_base.yaml │ ├── faster_rcnn_R_101_FPN_ft_all_10shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all_10shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_all_1shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all_1shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_all_2shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all_2shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_all_30shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all_30shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_all_3shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all_3shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_all_5shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all_5shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all_10shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all_1shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all_2shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all_30shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all_3shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all_5shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_novel_10shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_novel_1shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_novel_2shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_novel_30shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_novel_3shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_novel_5shot.yaml │ ├── faster_rcnn_R_50_FPN_ft_all_jiaonang_1shot.yaml │ ├── faster_rcnn_R_50_FPN_ft_all_jiaonang_2shot.yaml │ ├── faster_rcnn_R_50_FPN_ft_all_jiaonang_3shot.yaml │ └── faster_rcnn_R_50_FPN_jiaonang_base.yaml ├── LVIS-detection │ ├── faster_rcnn_R_101_FPN_1x_baseline.yaml │ ├── faster_rcnn_R_101_FPN_1x_baseline_norepeat.yaml │ ├── faster_rcnn_R_101_FPN_base.yaml │ ├── faster_rcnn_R_101_FPN_base_cosine.yaml │ ├── faster_rcnn_R_101_FPN_base_norepeat.yaml │ ├── faster_rcnn_R_101_FPN_base_norepeat_cosine.yaml │ ├── faster_rcnn_R_101_FPN_combined_all.yaml │ ├── faster_rcnn_R_101_FPN_combined_all_norepeat.yaml │ ├── faster_rcnn_R_101_FPN_cosine_combined_all.yaml │ ├── faster_rcnn_R_101_FPN_cosine_combined_all_norepeat.yaml │ ├── faster_rcnn_R_101_FPN_cosine_novel.yaml │ ├── faster_rcnn_R_101_FPN_cosine_novel_norepeat.yaml │ ├── faster_rcnn_R_101_FPN_fc_novel.yaml │ ├── faster_rcnn_R_101_FPN_fc_novel_norepeat.yaml │ ├── faster_rcnn_R_50_FPN_1x_baseline.yaml │ ├── faster_rcnn_R_50_FPN_1x_baseline_norepeat.yaml │ ├── faster_rcnn_R_50_FPN_base.yaml │ ├── faster_rcnn_R_50_FPN_base_cosine.yaml │ ├── faster_rcnn_R_50_FPN_base_norepeat.yaml │ ├── faster_rcnn_R_50_FPN_base_norepeat_cosine.yaml │ ├── faster_rcnn_R_50_FPN_combined_all.yaml │ ├── faster_rcnn_R_50_FPN_combined_all_norepeat.yaml │ ├── faster_rcnn_R_50_FPN_cosine_combined_all.yaml │ ├── faster_rcnn_R_50_FPN_cosine_combined_all_norepeat.yaml │ ├── faster_rcnn_R_50_FPN_cosine_novel.yaml │ ├── faster_rcnn_R_50_FPN_cosine_novel_norepeat.yaml │ ├── faster_rcnn_R_50_FPN_fc_novel.yaml │ └── faster_rcnn_R_50_FPN_fc_novel_norepeat.yaml └── PascalVOC-detection │ ├── split1 │ ├── faster_rcnn_R_101_FPN_base1.yaml │ ├── faster_rcnn_R_101_FPN_ft_all1_10shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all1_10shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_all1_1shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all1_1shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_all1_2shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all1_2shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_all1_3shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all1_3shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_all1_5shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all1_5shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all1_10shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all1_1shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all1_2shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all1_3shot.yaml │ └── faster_rcnn_R_101_FPN_ft_fc_all1_5shot.yaml │ ├── split2 │ ├── faster_rcnn_R_101_FPN_base2.yaml │ ├── faster_rcnn_R_101_FPN_ft_all2_10shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all2_10shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_all2_1shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all2_1shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_all2_2shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all2_2shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_all2_3shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all2_3shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_all2_5shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all2_5shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all2_10shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all2_1shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all2_2shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all2_3shot.yaml │ └── faster_rcnn_R_101_FPN_ft_fc_all2_5shot.yaml │ └── split3 │ ├── faster_rcnn_R_101_FPN_base3.yaml │ ├── faster_rcnn_R_101_FPN_ft_all3_10shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all3_10shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_all3_1shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all3_1shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_all3_2shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all3_2shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_all3_3shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all3_3shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_all3_5shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_all3_5shot_unfreeze.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all3_10shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all3_1shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all3_2shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all3_3shot.yaml │ ├── faster_rcnn_R_101_FPN_ft_fc_all3_5shot.yaml │ └── scale_ablation │ ├── faster_rcnn_R_101_FPN_ft_all3_10shot_randnovel_10scale.yaml │ ├── faster_rcnn_R_101_FPN_ft_all3_10shot_randnovel_1scale.yaml │ ├── faster_rcnn_R_101_FPN_ft_all3_10shot_randnovel_50scale.yaml │ ├── faster_rcnn_R_101_FPN_ft_all3_1shot_randnovel_100scale.yaml │ ├── faster_rcnn_R_101_FPN_ft_all3_1shot_randnovel_10scale.yaml │ ├── faster_rcnn_R_101_FPN_ft_all3_1shot_randnovel_1scale.yaml │ ├── faster_rcnn_R_101_FPN_ft_all3_1shot_randnovel_50scale.yaml │ ├── faster_rcnn_R_101_FPN_ft_all3_3shot_randnovel_10scale.yaml │ ├── faster_rcnn_R_101_FPN_ft_all3_3shot_randnovel_1scale.yaml │ └── faster_rcnn_R_101_FPN_ft_all3_3shot_randnovel_50scale.yaml ├── datasets ├── README.md ├── prepare_coco_few_shot.py ├── prepare_lvis_few_shot.py ├── prepare_voc_few_shot.py └── split_lvis_annotation.py ├── demo ├── demo.py ├── input1.jpg ├── input2.jpg └── predictor.py ├── docs ├── MODEL_ZOO.md └── TRAIN_INST.md ├── fsdet ├── __init__.py ├── checkpoint │ ├── __init__.py │ ├── catalog.py │ └── detection_checkpoint.py ├── config │ ├── __init__.py │ ├── compat.py │ ├── config.py │ └── defaults.py ├── data │ ├── __init__.py │ ├── builtin.py │ ├── builtin_meta.py │ ├── lvis_v0_5_categories.py │ ├── meta_coco.py │ ├── meta_lvis.py │ └── meta_pascal_voc.py ├── engine │ ├── __init__.py │ ├── defaults.py │ └── hooks.py ├── evaluation │ ├── __init__.py │ ├── coco_evaluation.py │ ├── evaluator.py │ ├── lvis_evaluation.py │ ├── pascal_voc_evaluation.py │ └── testing.py ├── model_zoo │ ├── __init__.py │ └── model_zoo.py └── modeling │ ├── __init__.py │ ├── meta_arch │ ├── __init__.py │ ├── build.py │ └── rcnn.py │ └── roi_heads │ ├── __init__.py │ ├── box_head.py │ ├── fast_rcnn.py │ └── roi_heads.py ├── img_show.py ├── requirements.txt ├── tools ├── aggregate_seeds.py ├── ckpt_surgery.py ├── run_experiments.py ├── test_net.py ├── train_net.py ├── visualize_data.py └── visualize_json_results.py └── train_few_shot.py /configs/Base-RCNN-FPN.yaml: -------------------------------------------------------------------------------- 1 | VERSION: 2 2 | MODEL: 3 | META_ARCHITECTURE: "GeneralizedRCNN" 4 | BACKBONE: 5 | NAME: "build_resnet_fpn_backbone" 6 | RESNETS: 7 | OUT_FEATURES: ["res2", "res3", "res4", "res5"] 8 | FPN: 9 | IN_FEATURES: ["res2", "res3", "res4", "res5"] 10 | ANCHOR_GENERATOR: 11 | SIZES: [[32], [64], [128], [256], [512]] # One size for each in feature map 12 | ASPECT_RATIOS: [[0.5, 1.0, 2.0]] # Three aspect ratios (same for all in feature maps) 13 | RPN: 14 | IN_FEATURES: ["p2", "p3", "p4", "p5", "p6"] 15 | PRE_NMS_TOPK_TRAIN: 2000 # Per FPN level 16 | PRE_NMS_TOPK_TEST: 1000 # Per FPN level 17 | # Detectron1 uses 2000 proposals per-batch, 18 | # (See "modeling/rpn/rpn_outputs.py" for details of this legacy issue) 19 | # which is approximately 1000 proposals per-image since the default batch size for FPN is 2. 20 | POST_NMS_TOPK_TRAIN: 1000 21 | POST_NMS_TOPK_TEST: 1000 22 | ROI_HEADS: 23 | NAME: "StandardROIHeads" 24 | IN_FEATURES: ["p2", "p3", "p4", "p5"] 25 | ROI_BOX_HEAD: 26 | NAME: "FastRCNNConvFCHead" 27 | NUM_FC: 2 28 | POOLER_RESOLUTION: 7 29 | DATASETS: 30 | TRAIN: ("coco_2017_train",) 31 | TEST: ("coco_2017_val",) 32 | SOLVER: 33 | IMS_PER_BATCH: 16 34 | BASE_LR: 0.02 35 | STEPS: (60000, 80000) 36 | MAX_ITER: 90000 37 | INPUT: 38 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 39 | -------------------------------------------------------------------------------- /configs/COCO-detection/Base-RCNN-FPN.yaml: -------------------------------------------------------------------------------- 1 | VERSION: 2 2 | MODEL: 3 | META_ARCHITECTURE: "GeneralizedRCNN" 4 | BACKBONE: 5 | NAME: "build_resnet_fpn_backbone" 6 | RESNETS: 7 | OUT_FEATURES: ["res2", "res3", "res4", "res5"] 8 | FPN: 9 | IN_FEATURES: ["res2", "res3", "res4", "res5"] 10 | ANCHOR_GENERATOR: 11 | SIZES: [[32], [64], [128], [256], [512]] # One size for each in feature map 12 | ASPECT_RATIOS: [[0.5, 1.0, 2.0]] # Three aspect ratios (same for all in feature maps) 13 | RPN: 14 | IN_FEATURES: ["p2", "p3", "p4", "p5", "p6"] 15 | PRE_NMS_TOPK_TRAIN: 2000 # Per FPN level 16 | PRE_NMS_TOPK_TEST: 1000 # Per FPN level 17 | # Detectron1 uses 2000 proposals per-batch, 18 | # (See "modeling/rpn/rpn_outputs.py" for details of this legacy issue) 19 | # which is approximately 1000 proposals per-image since the default batch size for FPN is 2. 20 | POST_NMS_TOPK_TRAIN: 1000 21 | POST_NMS_TOPK_TEST: 1000 22 | ROI_HEADS: 23 | NAME: "StandardROIHeads" 24 | IN_FEATURES: ["p2", "p3", "p4", "p5"] 25 | ROI_BOX_HEAD: 26 | NAME: "FastRCNNConvFCHead" 27 | NUM_FC: 2 28 | POOLER_RESOLUTION: 7 29 | DATASETS: 30 | TRAIN: ("coco_2017_train",) 31 | TEST: ("coco_2017_val",) 32 | SOLVER: 33 | IMS_PER_BATCH: 16 34 | BASE_LR: 0.02 35 | STEPS: (60000, 80000) 36 | MAX_ITER: 90000 37 | INPUT: 38 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 39 | -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_base.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 60 9 | DATASETS: 10 | TRAIN: ('coco_trainval_base',) 11 | TEST: ('coco_test_base',) 12 | SOLVER: 13 | IMS_PER_BATCH: 16 14 | STEPS: (85000, 100000) 15 | MAX_ITER: 110000 16 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_base" 17 | -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_all_10shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_10shot_combine/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 80 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | DATASETS: 16 | TRAIN: ('coco_trainval_all_10shot',) 17 | TEST: ('coco_test_all',) 18 | SOLVER: 19 | IMS_PER_BATCH: 16 20 | BASE_LR: 0.001 21 | STEPS: (144000,) 22 | MAX_ITER: 160000 23 | CHECKPOINT_PERIOD: 10000 24 | WARMUP_ITERS: 10 25 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_all_10shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_all_10shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_10shot_combine/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 80 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | # FREEZE_FEAT: True 11 | # BACKBONE: 12 | # FREEZE: True 13 | # PROPOSAL_GENERATOR: 14 | # FREEZE: True 15 | DATASETS: 16 | TRAIN: ('coco_trainval_all_10shot',) 17 | TEST: ('coco_test_all',) 18 | SOLVER: 19 | IMS_PER_BATCH: 16 20 | BASE_LR: 0.001 21 | STEPS: (144000,) 22 | MAX_ITER: 160000 23 | CHECKPOINT_PERIOD: 16000 24 | WARMUP_ITERS: 0 25 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_all_10shot_unfreeze" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_all_1shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_1shot_combine/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 80 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | DATASETS: 16 | TRAIN: ('coco_trainval_all_1shot',) 17 | TEST: ('coco_test_all',) 18 | SOLVER: 19 | IMS_PER_BATCH: 16 20 | BASE_LR: 0.001 21 | STEPS: (14400,) 22 | MAX_ITER: 16000 23 | CHECKPOINT_PERIOD: 1000 24 | WARMUP_ITERS: 10 25 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_all_1shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_all_1shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_1shot_combine/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 80 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | # FREEZE_FEAT: True 11 | # BACKBONE: 12 | # FREEZE: True 13 | # PROPOSAL_GENERATOR: 14 | # FREEZE: True 15 | DATASETS: 16 | TRAIN: ('coco_trainval_all_1shot',) 17 | TEST: ('coco_test_all',) 18 | SOLVER: 19 | IMS_PER_BATCH: 16 20 | BASE_LR: 0.001 21 | STEPS: (14400,) 22 | MAX_ITER: 16000 23 | CHECKPOINT_PERIOD: 1600 24 | WARMUP_ITERS: 0 25 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_all_1shot_unfreeze" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_all_2shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_2shot_combine/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 80 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | DATASETS: 16 | TRAIN: ('coco_trainval_all_2shot',) 17 | TEST: ('coco_test_all',) 18 | SOLVER: 19 | IMS_PER_BATCH: 16 20 | BASE_LR: 0.001 21 | STEPS: (28800,) 22 | MAX_ITER: 32000 23 | CHECKPOINT_PERIOD: 1000 24 | WARMUP_ITERS: 10 25 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_all_2shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_all_2shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_2shot_combine/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 80 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | # FREEZE_FEAT: True 11 | # BACKBONE: 12 | # FREEZE: True 13 | # PROPOSAL_GENERATOR: 14 | # FREEZE: True 15 | DATASETS: 16 | TRAIN: ('coco_trainval_all_2shot',) 17 | TEST: ('coco_test_all',) 18 | SOLVER: 19 | IMS_PER_BATCH: 16 20 | BASE_LR: 0.001 21 | STEPS: (28800,) 22 | MAX_ITER: 32000 23 | CHECKPOINT_PERIOD: 3200 24 | WARMUP_ITERS: 0 25 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_all_2shot_unfreeze" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_all_30shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_30shot_combine/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 80 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | DATASETS: 16 | TRAIN: ('coco_trainval_all_30shot',) 17 | TEST: ('coco_test_all',) 18 | SOLVER: 19 | IMS_PER_BATCH: 16 20 | BASE_LR: 0.001 21 | STEPS: (216000,) 22 | MAX_ITER: 240000 23 | CHECKPOINT_PERIOD: 12000 24 | WARMUP_ITERS: 10 25 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_all_30shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_all_30shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_30shot_combine/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 80 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | # FREEZE_FEAT: True 11 | # BACKBONE: 12 | # FREEZE: True 13 | # PROPOSAL_GENERATOR: 14 | # FREEZE: True 15 | DATASETS: 16 | TRAIN: ('coco_trainval_all_30shot',) 17 | TEST: ('coco_test_all',) 18 | SOLVER: 19 | IMS_PER_BATCH: 16 20 | BASE_LR: 0.001 21 | STEPS: (216000,) 22 | MAX_ITER: 240000 23 | CHECKPOINT_PERIOD: 24000 24 | WARMUP_ITERS: 0 25 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_all_30shot_unfreeze" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_all_3shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_3shot_combine/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 80 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | DATASETS: 16 | TRAIN: ('coco_trainval_all_3shot',) 17 | TEST: ('coco_test_all',) 18 | SOLVER: 19 | IMS_PER_BATCH: 16 20 | BASE_LR: 0.001 21 | STEPS: (43200,) 22 | MAX_ITER: 48000 23 | CHECKPOINT_PERIOD: 2000 24 | WARMUP_ITERS: 10 25 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_all_3shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_all_3shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_3shot_combine/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 80 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | # FREEZE_FEAT: True 11 | # BACKBONE: 12 | # FREEZE: True 13 | # PROPOSAL_GENERATOR: 14 | # FREEZE: True 15 | DATASETS: 16 | TRAIN: ('coco_trainval_all_3shot',) 17 | TEST: ('coco_test_all',) 18 | SOLVER: 19 | IMS_PER_BATCH: 16 20 | BASE_LR: 0.001 21 | STEPS: (43200,) 22 | MAX_ITER: 48000 23 | CHECKPOINT_PERIOD: 4800 24 | WARMUP_ITERS: 0 25 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_all_3shot_unfreeze" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_all_5shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_5shot_combine/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 80 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | DATASETS: 16 | TRAIN: ('coco_trainval_all_5shot',) 17 | TEST: ('coco_test_all',) 18 | SOLVER: 19 | IMS_PER_BATCH: 16 20 | BASE_LR: 0.001 21 | STEPS: (72000,) 22 | MAX_ITER: 80000 23 | CHECKPOINT_PERIOD: 4000 24 | WARMUP_ITERS: 10 25 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_all_5shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_all_5shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_5shot_combine/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 80 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | # FREEZE_FEAT: True 11 | # BACKBONE: 12 | # FREEZE: True 13 | # PROPOSAL_GENERATOR: 14 | # FREEZE: True 15 | DATASETS: 16 | TRAIN: ('coco_trainval_all_5shot',) 17 | TEST: ('coco_test_all',) 18 | SOLVER: 19 | IMS_PER_BATCH: 16 20 | BASE_LR: 0.001 21 | STEPS: (72000,) 22 | MAX_ITER: 80000 23 | CHECKPOINT_PERIOD: 8000 24 | WARMUP_ITERS: 0 25 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_all_5shot_unfreeze" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_fc_all_10shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_10shot_combine/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 80 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | DATASETS: 15 | TRAIN: ('coco_trainval_all_10shot',) 16 | TEST: ('coco_test_all',) 17 | SOLVER: 18 | IMS_PER_BATCH: 16 19 | BASE_LR: 0.001 20 | STEPS: (144000,) 21 | MAX_ITER: 160000 22 | CHECKPOINT_PERIOD: 10000 23 | WARMUP_ITERS: 10 24 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all_10shot_160k" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_fc_all_1shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_1shot_combine/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 80 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | DATASETS: 15 | TRAIN: ('coco_trainval_all_1shot',) 16 | TEST: ('coco_test_all',) 17 | SOLVER: 18 | IMS_PER_BATCH: 16 19 | BASE_LR: 0.001 20 | STEPS: (14400,) 21 | MAX_ITER: 16000 22 | CHECKPOINT_PERIOD: 1000 23 | WARMUP_ITERS: 10 24 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all_1shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_fc_all_2shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_2shot_combine/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 80 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | DATASETS: 15 | TRAIN: ('coco_trainval_all_2shot',) 16 | TEST: ('coco_test_all',) 17 | SOLVER: 18 | IMS_PER_BATCH: 16 19 | BASE_LR: 0.001 20 | STEPS: (28800,) 21 | MAX_ITER: 32000 22 | CHECKPOINT_PERIOD: 1000 23 | WARMUP_ITERS: 10 24 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all_2shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_fc_all_30shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_30shot_combine/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 80 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | DATASETS: 15 | TRAIN: ('coco_trainval_all_30shot',) 16 | TEST: ('coco_test_all',) 17 | SOLVER: 18 | IMS_PER_BATCH: 16 19 | BASE_LR: 0.001 20 | STEPS: (216000,) 21 | MAX_ITER: 240000 22 | CHECKPOINT_PERIOD: 12000 23 | WARMUP_ITERS: 10 24 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all_30shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_fc_all_3shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_3shot_combine/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 80 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | DATASETS: 15 | TRAIN: ('coco_trainval_all_3shot',) 16 | TEST: ('coco_test_all',) 17 | SOLVER: 18 | IMS_PER_BATCH: 16 19 | BASE_LR: 0.001 20 | STEPS: (43200,) 21 | MAX_ITER: 48000 22 | CHECKPOINT_PERIOD: 2000 23 | WARMUP_ITERS: 10 24 | OUTPUT_DIR: "checkpoints/coco2/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all_3shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_fc_all_5shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_5shot_combine/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 80 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | DATASETS: 15 | TRAIN: ('coco_trainval_all_5shot',) 16 | TEST: ('coco_test_all',) 17 | SOLVER: 18 | IMS_PER_BATCH: 16 19 | BASE_LR: 0.001 20 | STEPS: (72000,) 21 | MAX_ITER: 80000 22 | CHECKPOINT_PERIOD: 4000 23 | WARMUP_ITERS: 10 24 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all_5shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_novel_10shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_base/model_reset_remove.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | DATASETS: 15 | TRAIN: ('coco_trainval_novel_10shot',) 16 | TEST: ('coco_test_novel',) 17 | SOLVER: 18 | IMS_PER_BATCH: 16 19 | BASE_LR: 0.01 20 | STEPS: (10000,) 21 | MAX_ITER: 2000 22 | CHECKPOINT_PERIOD: 500 23 | WARMUP_ITERS: 0 24 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_10shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_novel_1shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_base/model_reset_remove.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | DATASETS: 15 | TRAIN: ('coco_trainval_novel_1shot',) 16 | TEST: ('coco_test_novel',) 17 | SOLVER: 18 | IMS_PER_BATCH: 16 19 | BASE_LR: 0.01 20 | STEPS: (10000,) 21 | MAX_ITER: 500 22 | CHECKPOINT_PERIOD: 500 23 | WARMUP_ITERS: 0 24 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_1shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_novel_2shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_base/model_reset_remove.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | DATASETS: 15 | TRAIN: ('coco_trainval_novel_2shot',) 16 | TEST: ('coco_test_novel',) 17 | SOLVER: 18 | IMS_PER_BATCH: 16 19 | BASE_LR: 0.01 20 | STEPS: (10000,) 21 | MAX_ITER: 1500 22 | CHECKPOINT_PERIOD: 500 23 | WARMUP_ITERS: 0 24 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_2shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_novel_30shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_base/model_reset_remove.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | DATASETS: 15 | TRAIN: ('coco_trainval_novel_30shot',) 16 | TEST: ('coco_test_novel',) 17 | SOLVER: 18 | IMS_PER_BATCH: 16 19 | BASE_LR: 0.01 20 | STEPS: (10000,) 21 | MAX_ITER: 6000 22 | CHECKPOINT_PERIOD: 500 23 | WARMUP_ITERS: 0 24 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_30shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_novel_3shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_base/model_reset_remove.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | DATASETS: 15 | TRAIN: ('coco_trainval_novel_3shot',) 16 | TEST: ('coco_test_novel',) 17 | SOLVER: 18 | IMS_PER_BATCH: 16 19 | BASE_LR: 0.01 20 | STEPS: (10000,) 21 | MAX_ITER: 1500 22 | CHECKPOINT_PERIOD: 500 23 | WARMUP_ITERS: 0 24 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_3shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_101_FPN_ft_novel_5shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_base/model_reset_remove.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | DATASETS: 15 | TRAIN: ('coco_trainval_novel_5shot',) 16 | TEST: ('coco_test_novel',) 17 | SOLVER: 18 | IMS_PER_BATCH: 16 19 | BASE_LR: 0.01 20 | STEPS: (10000,) 21 | MAX_ITER: 1500 22 | CHECKPOINT_PERIOD: 500 23 | WARMUP_ITERS: 0 24 | OUTPUT_DIR: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_5shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_50_FPN_ft_all_jiaonang_1shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "F:/workspace/Daheng/Deep-learning-library/few-shot-object-detection-master/checkpoints/coco/faster_rcnn/faster_rcnn_R_50_FPN_base/model_reset_surgery.pth" 4 | #WEIGHTS: "model_final.pth" 5 | MASK_ON: False 6 | RESNETS: 7 | DEPTH: 50 8 | ROI_HEADS: 9 | NUM_CLASSES: 3 10 | OUTPUT_LAYER: "CosineSimOutputLayers" 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | DATASETS: 17 | TRAIN: ('coco_trainval_all_1shot',) 18 | TEST: ('test_all',) 19 | SOLVER: 20 | IMS_PER_BATCH: 2 21 | BASE_LR: 0.001 22 | STEPS: (200,) 23 | MAX_ITER: 5000 24 | CHECKPOINT_PERIOD: 1000 25 | WARMUP_ITERS: 10 26 | OUTPUT_DIR: "F:/workspace/Daheng/Deep-learning-library/few-shot-object-detection-master/checkpoints/coco/faster_rcnn/faster_rcnn_R_50_FPN_ft_all_1shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_50_FPN_ft_all_jiaonang_2shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | #WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_2shot_combine/model_reset_combine.pth" 4 | WEIGHTS: "F:/workspace/Daheng/Deep-learning-library/few-shot-object-detection-master/checkpoints/coco/faster_rcnn/faster_rcnn_R_50_FPN_base/model_reset_surgery.pth" 5 | MASK_ON: False 6 | RESNETS: 7 | DEPTH: 50 8 | ROI_HEADS: 9 | NUM_CLASSES: 3 10 | OUTPUT_LAYER: "CosineSimOutputLayers" 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | DATASETS: 17 | TRAIN: ('coco_trainval_all_2shot',) 18 | TEST: ('test_all',) 19 | SOLVER: 20 | IMS_PER_BATCH: 2 21 | BASE_LR: 0.001 22 | STEPS: (200,) 23 | MAX_ITER: 5000 24 | CHECKPOINT_PERIOD: 1000 25 | WARMUP_ITERS: 10 26 | OUTPUT_DIR: "F:/workspace/Daheng/Deep-learning-library/few-shot-object-detection-master/checkpoints/coco/faster_rcnn/faster_rcnn_R_50_FPN_ft_all_2shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_50_FPN_ft_all_jiaonang_3shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | #WEIGHTS: "checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_3shot_combine/model_reset_combine.pth" 4 | WEIGHTS: "F:/workspace/Daheng/Deep-learning-library/few-shot-object-detection-master/checkpoints/coco/faster_rcnn/faster_rcnn_R_50_FPN_base/model_reset_surgery.pth" 5 | MASK_ON: False 6 | RESNETS: 7 | DEPTH: 50 8 | ROI_HEADS: 9 | NUM_CLASSES: 3 10 | OUTPUT_LAYER: "CosineSimOutputLayers" 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | DATASETS: 17 | TRAIN: ('coco_trainval_all_3shot',) 18 | TEST: ('test_all',) 19 | SOLVER: 20 | IMS_PER_BATCH: 2 21 | BASE_LR: 0.001 22 | STEPS: (200,) 23 | MAX_ITER: 5000 24 | CHECKPOINT_PERIOD: 2000 25 | WARMUP_ITERS: 10 26 | OUTPUT_DIR: "F:/workspace/Daheng/Deep-learning-library/few-shot-object-detection-master/checkpoints/coco/faster_rcnn/faster_rcnn_R_50_FPN_ft_all_3shot" -------------------------------------------------------------------------------- /configs/COCO-detection/faster_rcnn_R_50_FPN_jiaonang_base.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | #train resume weights dir 4 | WEIGHTS: "F:/workspace/Daheng/Deep-learning-library/few-shot-object-detection-master/checkpoints/R-50.pkl" 5 | 6 | #test weights dir 7 | #WEIGHTS: "F:/workspace/Daheng/Deep-learning-library/few-shot-object-detection-master/checkpoints/coco/faster_rcnn/faster_rcnn_R_50_FPN_base_custom/model_final.pth" 8 | MASK_ON: False 9 | # RETINANET: 10 | # SCORE_THRESH_TEST: 0.5 11 | RESNETS: 12 | DEPTH: 50 13 | ROI_HEADS: 14 | NUM_CLASSES: 3 15 | #SCORE_THRESH_TEST: 0.5 16 | DATASETS: 17 | TRAIN: ('jiaonang_train_base',) 18 | TEST: ('test_base',) 19 | SOLVER: 20 | IMS_PER_BATCH: 2 21 | STEPS: (2000, 8000) 22 | MAX_ITER: 10000 23 | BASE_LR: 0.02 24 | WARMUP_ITERS: 1000 25 | OUTPUT_DIR: "F:/workspace/Daheng/Deep-learning-library/few-shot-object-detection-master/checkpoints/coco/faster_rcnn/faster_rcnn_R_50_FPN_jiaonang_base" 26 | #OUTPUT_WEIGHTS: "F:/workspace/Daheng/Deep-learning-library/few-shot-object-detection-master/checkpoints/coco/faster_rcnn/faster_rcnn_R_50_FPN_base_custom/model_final.pth" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_101_FPN_1x_baseline.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | SCORE_THRESH_TEST: 0.0001 10 | INPUT: 11 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 12 | DATASETS: 13 | TRAIN: ("lvis_v0.5_train",) 14 | TEST: ("lvis_v0.5_val",) 15 | TEST: 16 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 17 | DATALOADER: 18 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 19 | REPEAT_THRESHOLD: 0.001 20 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/baselines/faster_rcnn_R_101_FPN_1x" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_101_FPN_1x_baseline_norepeat.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | SCORE_THRESH_TEST: 0.0001 10 | INPUT: 11 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 12 | DATASETS: 13 | TRAIN: ("lvis_v0.5_train",) 14 | TEST: ("lvis_v0.5_val",) 15 | TEST: 16 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 17 | # DATALOADER: 18 | # SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 19 | # REPEAT_THRESHOLD: 0.001 20 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/baselines/faster_rcnn_R_101_FPN_1x_norepeat" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_101_FPN_base.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | SCORE_THRESH_TEST: 0.0001 10 | INPUT: 11 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 12 | DATASETS: 13 | TRAIN: ("lvis_v0.5_train_freq", "lvis_v0.5_train_common",) 14 | TEST: ("lvis_v0.5_val",) 15 | TEST: 16 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 17 | DATALOADER: 18 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 19 | REPEAT_THRESHOLD: 0.001 20 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_base" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_101_FPN_base_cosine.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | COSINE_SCALE: 20 11 | SCORE_THRESH_TEST: 0.0001 12 | INPUT: 13 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 14 | DATASETS: 15 | TRAIN: ("lvis_v0.5_train_freq", "lvis_v0.5_train_common",) 16 | TEST: ("lvis_v0.5_val",) 17 | TEST: 18 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 19 | DATALOADER: 20 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 21 | REPEAT_THRESHOLD: 0.001 22 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_base_nomask_cosine" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_101_FPN_base_norepeat.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | SCORE_THRESH_TEST: 0.0001 10 | INPUT: 11 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 12 | DATASETS: 13 | TRAIN: ("lvis_v0.5_train_freq", "lvis_v0.5_train_common",) 14 | TEST: ("lvis_v0.5_val",) 15 | TEST: 16 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 17 | # DATALOADER: 18 | # SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 19 | # REPEAT_THRESHOLD: 0.001 20 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_base_norepeat" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_101_FPN_base_norepeat_cosine.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | COSINE_SCALE: 20 11 | SCORE_THRESH_TEST: 0.0001 12 | INPUT: 13 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 14 | DATASETS: 15 | TRAIN: ("lvis_v0.5_train_freq", "lvis_v0.5_train_common",) 16 | TEST: ("lvis_v0.5_val",) 17 | TEST: 18 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 19 | # DATALOADER: 20 | # SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 21 | # REPEAT_THRESHOLD: 0.001 22 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_base_norepeat_cosine" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_101_FPN_combined_all.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_combined/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | SCORE_THRESH_TEST: 0.0001 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 17 | DATASETS: 18 | TRAIN: ("lvis_v0.5_train_shots",) 19 | TEST: ("lvis_v0.5_val",) 20 | TEST: 21 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 22 | DATALOADER: 23 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 24 | REPEAT_THRESHOLD: 0.001 25 | SOLVER: 26 | BASE_LR: 0.001 27 | STEPS: (1000,) 28 | MAX_ITER: 2000 29 | CHECKPOINT_PERIOD: 1000 30 | WARMUP_ITERS: 0 31 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_combined_all" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_101_FPN_combined_all_norepeat.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_norepeat_combined/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | SCORE_THRESH_TEST: 0.0001 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 17 | DATASETS: 18 | TRAIN: ("lvis_v0.5_train_shots",) 19 | TEST: ("lvis_v0.5_val",) 20 | TEST: 21 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 22 | # DATALOADER: 23 | # SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 24 | # REPEAT_THRESHOLD: 0.001 25 | SOLVER: 26 | BASE_LR: 0.001 27 | STEPS: (15000,) 28 | MAX_ITER: 20000 29 | CHECKPOINT_PERIOD: 1000 30 | WARMUP_ITERS: 0 31 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_combined_all_norepeat" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_101_FPN_cosine_combined_all.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_cosine_combined/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | SCORE_THRESH_TEST: 0.0001 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | INPUT: 17 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 18 | DATASETS: 19 | TRAIN: ("lvis_v0.5_train_shots",) 20 | TEST: ("lvis_v0.5_val",) 21 | TEST: 22 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 23 | DATALOADER: 24 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 25 | REPEAT_THRESHOLD: 0.001 26 | SOLVER: 27 | BASE_LR: 0.001 28 | STEPS: (15000,) 29 | MAX_ITER: 20000 30 | CHECKPOINT_PERIOD: 1000 31 | WARMUP_ITERS: 0 32 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_cosine_combined_all" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_101_FPN_cosine_combined_all_norepeat.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_cosine_combined_norepeat/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | SCORE_THRESH_TEST: 0.0001 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | INPUT: 17 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 18 | DATASETS: 19 | TRAIN: ("lvis_v0.5_train_shots",) 20 | TEST: ("lvis_v0.5_val",) 21 | TEST: 22 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 23 | # DATALOADER: 24 | # SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 25 | # REPEAT_THRESHOLD: 0.001 26 | SOLVER: 27 | BASE_LR: 0.001 28 | STEPS: (15000,) 29 | MAX_ITER: 20000 30 | CHECKPOINT_PERIOD: 1000 31 | WARMUP_ITERS: 0 32 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_cosine_combined_all_norepeat" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_101_FPN_cosine_novel.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_base_nomask_cosine/model_reset_remove.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 454 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | SCORE_THRESH_TEST: 0.0001 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | INPUT: 17 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 18 | DATASETS: 19 | TRAIN: ("lvis_v0.5_train_rare_novel",) 20 | TEST: ("lvis_v0.5_val_novel",) 21 | TEST: 22 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 23 | DATALOADER: 24 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 25 | REPEAT_THRESHOLD: 0.001 26 | SOLVER: 27 | BASE_LR: 0.01 28 | STEPS: (15000,) 29 | MAX_ITER: 20000 30 | CHECKPOINT_PERIOD: 1000 31 | WARMUP_ITERS: 0 32 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_fc_novel_cosine" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_101_FPN_cosine_novel_norepeat.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_base_norepeat_cosine/model_reset_remove.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 454 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | SCORE_THRESH_TEST: 0.0001 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | INPUT: 17 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 18 | DATASETS: 19 | TRAIN: ("lvis_v0.5_train_rare_novel",) 20 | TEST: ("lvis_v0.5_val_novel",) 21 | TEST: 22 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 23 | # DATALOADER: 24 | # SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 25 | # REPEAT_THRESHOLD: 0.001 26 | SOLVER: 27 | BASE_LR: 0.01 28 | STEPS: (15000,) 29 | MAX_ITER: 20000 30 | CHECKPOINT_PERIOD: 1000 31 | WARMUP_ITERS: 0 32 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_fc_novel_cosine_norepeat" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_101_FPN_fc_novel.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_base/model_reset_remove.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 454 9 | SCORE_THRESH_TEST: 0.0001 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 17 | DATASETS: 18 | TRAIN: ("lvis_v0.5_train_rare_novel",) 19 | TEST: ("lvis_v0.5_val_novel",) 20 | TEST: 21 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 22 | DATALOADER: 23 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 24 | REPEAT_THRESHOLD: 0.001 25 | SOLVER: 26 | BASE_LR: 0.01 27 | STEPS: (15000,) 28 | MAX_ITER: 20000 29 | CHECKPOINT_PERIOD: 1000 30 | WARMUP_ITERS: 0 31 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_fc_novel" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_101_FPN_fc_novel_norepeat.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_base_norepeat/model_reset_remove.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 454 9 | SCORE_THRESH_TEST: 0.0001 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 17 | DATASETS: 18 | TRAIN: ("lvis_v0.5_train_rare_novel",) 19 | TEST: ("lvis_v0.5_val_novel",) 20 | TEST: 21 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 22 | # DATALOADER: 23 | # SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 24 | # REPEAT_THRESHOLD: 0.001 25 | SOLVER: 26 | BASE_LR: 0.01 27 | STEPS: (15000,) 28 | MAX_ITER: 20000 29 | CHECKPOINT_PERIOD: 1000 30 | WARMUP_ITERS: 0 31 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_101_FPN_fc_novel_norepeat" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_50_FPN_1x_baseline.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | SCORE_THRESH_TEST: 0.0001 10 | INPUT: 11 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 12 | DATASETS: 13 | TRAIN: ("lvis_v0.5_train",) 14 | TEST: ("lvis_v0.5_val",) 15 | TEST: 16 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 17 | DATALOADER: 18 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 19 | REPEAT_THRESHOLD: 0.001 20 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/baselines/faster_rcnn_R_50_FPN_1x" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_50_FPN_1x_baseline_norepeat.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | SCORE_THRESH_TEST: 0.0001 10 | INPUT: 11 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 12 | DATASETS: 13 | TRAIN: ("lvis_v0.5_train",) 14 | TEST: ("lvis_v0.5_val",) 15 | TEST: 16 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 17 | # DATALOADER: 18 | # SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 19 | # REPEAT_THRESHOLD: 0.001 20 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/baselines/faster_rcnn_R_50_FPN_1x_norepeat" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_50_FPN_base.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | SCORE_THRESH_TEST: 0.0001 10 | INPUT: 11 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 12 | DATASETS: 13 | TRAIN: ("lvis_v0.5_train_freq", "lvis_v0.5_train_common",) 14 | TEST: ("lvis_v0.5_val",) 15 | TEST: 16 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 17 | DATALOADER: 18 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 19 | REPEAT_THRESHOLD: 0.001 20 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_base_nomask2" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_50_FPN_base_cosine.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | COSINE_SCALE: 20 11 | SCORE_THRESH_TEST: 0.0001 12 | INPUT: 13 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 14 | DATASETS: 15 | TRAIN: ("lvis_v0.5_train_freq", "lvis_v0.5_train_common",) 16 | TEST: ("lvis_v0.5_val",) 17 | TEST: 18 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 19 | DATALOADER: 20 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 21 | REPEAT_THRESHOLD: 0.001 22 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_base_nomask_cosine" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_50_FPN_base_norepeat.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | SCORE_THRESH_TEST: 0.0001 10 | INPUT: 11 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 12 | DATASETS: 13 | TRAIN: ("lvis_v0.5_train_freq", "lvis_v0.5_train_common",) 14 | TEST: ("lvis_v0.5_val",) 15 | TEST: 16 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 17 | # DATALOADER: 18 | # SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 19 | # REPEAT_THRESHOLD: 0.001 20 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_base_norepeat" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_50_FPN_base_norepeat_cosine.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | COSINE_SCALE: 20 11 | SCORE_THRESH_TEST: 0.0001 12 | INPUT: 13 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 14 | DATASETS: 15 | TRAIN: ("lvis_v0.5_train_freq", "lvis_v0.5_train_common",) 16 | TEST: ("lvis_v0.5_val",) 17 | TEST: 18 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 19 | # DATALOADER: 20 | # SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 21 | # REPEAT_THRESHOLD: 0.001 22 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_base_norepeat_cosine" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_50_FPN_combined_all.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_combined2/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | SCORE_THRESH_TEST: 0.0001 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 17 | DATASETS: 18 | TRAIN: ("lvis_v0.5_train_shots",) 19 | TEST: ("lvis_v0.5_val",) 20 | TEST: 21 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 22 | # DATALOADER: 23 | # SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 24 | # REPEAT_THRESHOLD: 0.001 25 | SOLVER: 26 | BASE_LR: 0.0005 27 | STEPS: (1000,) 28 | MAX_ITER: 2000 29 | CHECKPOINT_PERIOD: 1000 30 | WARMUP_ITERS: 0 31 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_combined_all" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_50_FPN_combined_all_norepeat.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_combined_norepeat/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | SCORE_THRESH_TEST: 0.0001 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 17 | DATASETS: 18 | TRAIN: ("lvis_v0.5_train_shots",) 19 | TEST: ("lvis_v0.5_val",) 20 | TEST: 21 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 22 | # DATALOADER: 23 | # SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 24 | # REPEAT_THRESHOLD: 0.001 25 | SOLVER: 26 | BASE_LR: 0.001 27 | STEPS: (15000,) 28 | MAX_ITER: 20000 29 | CHECKPOINT_PERIOD: 1000 30 | WARMUP_ITERS: 0 31 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_combined_all_norepeat" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_50_FPN_cosine_combined_all.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_cosine_combined/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | SCORE_THRESH_TEST: 0.0001 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | INPUT: 17 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 18 | DATASETS: 19 | TRAIN: ("lvis_v0.5_train_shots",) 20 | TEST: ("lvis_v0.5_val",) 21 | TEST: 22 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 23 | DATALOADER: 24 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 25 | REPEAT_THRESHOLD: 0.001 26 | SOLVER: 27 | BASE_LR: 0.001 28 | STEPS: (15000,) 29 | MAX_ITER: 20000 30 | CHECKPOINT_PERIOD: 1000 31 | WARMUP_ITERS: 0 32 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_cosine_combined_all" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_50_FPN_cosine_combined_all_norepeat.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_cosine_combined_norepeat/model_reset_combine.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 1230 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | SCORE_THRESH_TEST: 0.0001 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | INPUT: 17 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 18 | DATASETS: 19 | TRAIN: ("lvis_v0.5_train_shots",) 20 | TEST: ("lvis_v0.5_val",) 21 | TEST: 22 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 23 | # DATALOADER: 24 | # SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 25 | # REPEAT_THRESHOLD: 0.001 26 | SOLVER: 27 | BASE_LR: 0.001 28 | STEPS: (15000,) 29 | MAX_ITER: 20000 30 | CHECKPOINT_PERIOD: 1000 31 | WARMUP_ITERS: 0 32 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_cosine_combined_all_norepeat" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_50_FPN_cosine_novel.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_base_nomask_cosine/model_reset_remove.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 454 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | SCORE_THRESH_TEST: 0.0001 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | INPUT: 17 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 18 | DATASETS: 19 | TRAIN: ("lvis_v0.5_train_rare_novel",) 20 | TEST: ("lvis_v0.5_val_novel",) 21 | TEST: 22 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 23 | DATALOADER: 24 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 25 | REPEAT_THRESHOLD: 0.001 26 | SOLVER: 27 | BASE_LR: 0.01 28 | STEPS: (15000,) 29 | MAX_ITER: 20000 30 | CHECKPOINT_PERIOD: 1000 31 | WARMUP_ITERS: 0 32 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_novel_cosine" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_50_FPN_cosine_novel_norepeat.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_base_norepeat_cosine/model_reset_remove.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 454 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | SCORE_THRESH_TEST: 0.0001 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | INPUT: 17 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 18 | DATASETS: 19 | TRAIN: ("lvis_v0.5_train_rare_novel",) 20 | TEST: ("lvis_v0.5_val_novel",) 21 | TEST: 22 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 23 | # DATALOADER: 24 | # SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 25 | # REPEAT_THRESHOLD: 0.001 26 | SOLVER: 27 | BASE_LR: 0.01 28 | STEPS: (15000,) 29 | MAX_ITER: 20000 30 | CHECKPOINT_PERIOD: 1000 31 | WARMUP_ITERS: 0 32 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_fc_novel_cosine" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_50_FPN_fc_novel.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_base_nomask2/model_reset_remove.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 454 9 | SCORE_THRESH_TEST: 0.0001 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 17 | DATASETS: 18 | TRAIN: ("lvis_v0.5_train_rare_novel",) 19 | TEST: ("lvis_v0.5_val_novel",) 20 | TEST: 21 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 22 | DATALOADER: 23 | SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 24 | REPEAT_THRESHOLD: 0.001 25 | SOLVER: 26 | BASE_LR: 0.005 27 | STEPS: (15000,) 28 | MAX_ITER: 20000 29 | CHECKPOINT_PERIOD: 500 30 | WARMUP_ITERS: 0 31 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_fc_novel_0.005lr" -------------------------------------------------------------------------------- /configs/LVIS-detection/faster_rcnn_R_50_FPN_fc_novel_norepeat.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_base_norepeat/model_reset_remove.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 50 7 | ROI_HEADS: 8 | NUM_CLASSES: 454 9 | SCORE_THRESH_TEST: 0.0001 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 17 | DATASETS: 18 | TRAIN: ("lvis_v0.5_train_rare_novel",) 19 | TEST: ("lvis_v0.5_val_novel",) 20 | TEST: 21 | DETECTIONS_PER_IMAGE: 300 # LVIS allows up to 300 22 | # DATALOADER: 23 | # SAMPLER_TRAIN: "RepeatFactorTrainingSampler" 24 | # REPEAT_THRESHOLD: 0.001 25 | SOLVER: 26 | BASE_LR: 0.01 27 | STEPS: (15000,) 28 | MAX_ITER: 20000 29 | CHECKPOINT_PERIOD: 2000 30 | WARMUP_ITERS: 0 31 | OUTPUT_DIR: "checkpoints/lvis/faster_rcnn/faster_rcnn_R_50_FPN_fc_novel_norepeat" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_base1.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 15 9 | INPUT: 10 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 11 | MIN_SIZE_TEST: 800 12 | DATASETS: 13 | TRAIN: ('voc_2007_trainval_base1', 'voc_2012_trainval_base1') 14 | TEST: ('voc_2007_test_base1',) 15 | SOLVER: 16 | STEPS: (12000, 16000) 17 | MAX_ITER: 18000 # 17.4 epochs 18 | WARMUP_ITERS: 100 19 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1" 20 | -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_all1_10shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 17 | MIN_SIZE_TEST: 800 18 | DATASETS: 19 | TRAIN: ('voc_2007_trainval_all1_10shot',) 20 | TEST: ('voc_2007_test_all1',) 21 | SOLVER: 22 | IMS_PER_BATCH: 16 23 | BASE_LR: 0.001 24 | STEPS: (36000, ) 25 | MAX_ITER: 40000 26 | CHECKPOINT_PERIOD: 1000 27 | WARMUP_ITERS: 10 28 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all1_10shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_all1_10shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | INPUT: 11 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 12 | MIN_SIZE_TEST: 800 13 | DATASETS: 14 | TRAIN: ('voc_2007_trainval_all1_10shot',) 15 | TEST: ('voc_2007_test_all1',) 16 | SOLVER: 17 | IMS_PER_BATCH: 16 18 | BASE_LR: 0.001 19 | STEPS: (36000,) 20 | MAX_ITER: 40000 21 | CHECKPOINT_PERIOD: 4000 22 | WARMUP_ITERS: 0 23 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all1_10shot_unfreeze" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_all1_1shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 17 | MIN_SIZE_TEST: 800 18 | DATASETS: 19 | TRAIN: ('voc_2007_trainval_all1_1shot',) 20 | TEST: ('voc_2007_test_all1',) 21 | SOLVER: 22 | IMS_PER_BATCH: 16 23 | BASE_LR: 0.001 24 | STEPS: (3000,) 25 | MAX_ITER: 4000 26 | CHECKPOINT_PERIOD: 500 27 | WARMUP_ITERS: 0 28 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all1_1shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_all1_1shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | INPUT: 11 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 12 | MIN_SIZE_TEST: 800 13 | DATASETS: 14 | TRAIN: ('voc_2007_trainval_all1_1shot',) 15 | TEST: ('voc_2007_test_all1',) 16 | SOLVER: 17 | IMS_PER_BATCH: 16 18 | BASE_LR: 0.001 19 | STEPS: (3000,) 20 | MAX_ITER: 4000 21 | CHECKPOINT_PERIOD: 500 22 | WARMUP_ITERS: 0 23 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all1_1shot_unfreeze" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_all1_2shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 17 | MIN_SIZE_TEST: 800 18 | DATASETS: 19 | TRAIN: ('voc_2007_trainval_all1_2shot',) 20 | TEST: ('voc_2007_test_all1',) 21 | SOLVER: 22 | IMS_PER_BATCH: 16 23 | BASE_LR: 0.001 24 | STEPS: (7000,) 25 | MAX_ITER: 8000 26 | CHECKPOINT_PERIOD: 500 27 | WARMUP_ITERS: 0 28 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all1_2shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_all1_2shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | INPUT: 11 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 12 | MIN_SIZE_TEST: 800 13 | DATASETS: 14 | TRAIN: ('voc_2007_trainval_all1_2shot',) 15 | TEST: ('voc_2007_test_all1',) 16 | SOLVER: 17 | IMS_PER_BATCH: 16 18 | BASE_LR: 0.001 19 | STEPS: (7000,) 20 | MAX_ITER: 8000 21 | CHECKPOINT_PERIOD: 500 22 | WARMUP_ITERS: 0 23 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all1_2shot_unfreeze" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_all1_3shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 17 | MIN_SIZE_TEST: 800 18 | DATASETS: 19 | TRAIN: ('voc_2007_trainval_all1_3shot',) 20 | TEST: ('voc_2007_test_all1',) 21 | SOLVER: 22 | IMS_PER_BATCH: 16 23 | BASE_LR: 0.001 24 | STEPS: (11000, ) 25 | MAX_ITER: 12000 26 | CHECKPOINT_PERIOD: 500 27 | WARMUP_ITERS: 10 28 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all1_3shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_all1_3shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | INPUT: 11 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 12 | MIN_SIZE_TEST: 800 13 | DATASETS: 14 | TRAIN: ('voc_2007_trainval_all1_3shot',) 15 | TEST: ('voc_2007_test_all1',) 16 | SOLVER: 17 | IMS_PER_BATCH: 16 18 | BASE_LR: 0.001 19 | STEPS: (11000,) 20 | MAX_ITER: 12000 21 | CHECKPOINT_PERIOD: 1200 22 | WARMUP_ITERS: 0 23 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all1_3shot_unfreeze" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_all1_5shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 17 | MIN_SIZE_TEST: 800 18 | DATASETS: 19 | TRAIN: ('voc_2007_trainval_all1_5shot',) 20 | TEST: ('voc_2007_test_all1',) 21 | SOLVER: 22 | IMS_PER_BATCH: 16 23 | BASE_LR: 0.001 24 | STEPS: (18000,) 25 | MAX_ITER: 20000 26 | CHECKPOINT_PERIOD: 1000 27 | WARMUP_ITERS: 10 28 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all1_5shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_all1_5shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | INPUT: 11 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 12 | MIN_SIZE_TEST: 800 13 | DATASETS: 14 | TRAIN: ('voc_2007_trainval_all1_5shot',) 15 | TEST: ('voc_2007_test_all1',) 16 | SOLVER: 17 | IMS_PER_BATCH: 16 18 | BASE_LR: 0.001 19 | STEPS: (18000,) 20 | MAX_ITER: 20000 21 | CHECKPOINT_PERIOD: 2000 22 | WARMUP_ITERS: 0 23 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all1_5shot_unfreeze" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_fc_all1_10shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | INPUT: 15 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 16 | MIN_SIZE_TEST: 800 17 | DATASETS: 18 | TRAIN: ('voc_2007_trainval_all1_10shot',) 19 | TEST: ('voc_2007_test_all1',) 20 | SOLVER: 21 | IMS_PER_BATCH: 16 22 | BASE_LR: 0.001 23 | STEPS: (35000,) 24 | MAX_ITER: 40000 25 | CHECKPOINT_PERIOD: 50000 26 | WARMUP_ITERS: 0 27 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all1_10shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_fc_all1_1shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | INPUT: 15 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 16 | MIN_SIZE_TEST: 800 17 | DATASETS: 18 | TRAIN: ('voc_2007_trainval_all1_1shot',) 19 | TEST: ('voc_2007_test_all1',) 20 | SOLVER: 21 | IMS_PER_BATCH: 16 22 | BASE_LR: 0.001 23 | STEPS: (3500,) 24 | MAX_ITER: 4000 25 | CHECKPOINT_PERIOD: 500 26 | WARMUP_ITERS: 0 27 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all1_1shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_fc_all1_2shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | INPUT: 15 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 16 | MIN_SIZE_TEST: 800 17 | DATASETS: 18 | TRAIN: ('voc_2007_trainval_all1_2shot',) 19 | TEST: ('voc_2007_test_all1',) 20 | SOLVER: 21 | IMS_PER_BATCH: 16 22 | BASE_LR: 0.001 23 | STEPS: (7000,) 24 | MAX_ITER: 8000 25 | CHECKPOINT_PERIOD: 10000 26 | WARMUP_ITERS: 0 27 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all1_2shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_fc_all1_3shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | INPUT: 15 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 16 | MIN_SIZE_TEST: 800 17 | DATASETS: 18 | TRAIN: ('voc_2007_trainval_all1_3shot',) 19 | TEST: ('voc_2007_test_all1',) 20 | SOLVER: 21 | IMS_PER_BATCH: 16 22 | BASE_LR: 0.001 23 | STEPS: (10500,) 24 | MAX_ITER: 12000 25 | CHECKPOINT_PERIOD: 15000 26 | WARMUP_ITERS: 0 27 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all1_3shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_fc_all1_5shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | INPUT: 15 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 16 | MIN_SIZE_TEST: 800 17 | DATASETS: 18 | TRAIN: ('voc_2007_trainval_all1_5shot',) 19 | TEST: ('voc_2007_test_all1',) 20 | SOLVER: 21 | IMS_PER_BATCH: 16 22 | BASE_LR: 0.001 23 | STEPS: (17500,) 24 | MAX_ITER: 20000 25 | CHECKPOINT_PERIOD: 30000 26 | WARMUP_ITERS: 0 27 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all1_5shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split2/faster_rcnn_R_101_FPN_base2.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 15 9 | INPUT: 10 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 11 | MIN_SIZE_TEST: 800 12 | DATASETS: 13 | TRAIN: ('voc_2007_trainval_base2', 'voc_2012_trainval_base2') 14 | TEST: ('voc_2007_test_base2',) 15 | SOLVER: 16 | STEPS: (12000, 16000) 17 | MAX_ITER: 18000 # 17.4 epochs 18 | WARMUP_ITERS: 100 19 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base2" 20 | -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split2/faster_rcnn_R_101_FPN_ft_all2_10shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base2/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 17 | MIN_SIZE_TEST: 800 18 | DATASETS: 19 | TRAIN: ('voc_2007_trainval_all2_10shot',) 20 | TEST: ('voc_2007_test_all2',) 21 | SOLVER: 22 | IMS_PER_BATCH: 16 23 | BASE_LR: 0.005 24 | STEPS: (35000,) 25 | MAX_ITER: 40000 26 | CHECKPOINT_PERIOD: 50000 27 | WARMUP_ITERS: 0 28 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all2_10shot_randnovel_0.005lr" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split2/faster_rcnn_R_101_FPN_ft_all2_10shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base2/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | INPUT: 11 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 12 | MIN_SIZE_TEST: 800 13 | DATASETS: 14 | TRAIN: ('voc_2007_trainval_all2_10shot',) 15 | TEST: ('voc_2007_test_all2',) 16 | SOLVER: 17 | IMS_PER_BATCH: 16 18 | BASE_LR: 0.005 19 | STEPS: (35000,) 20 | MAX_ITER: 40000 21 | CHECKPOINT_PERIOD: 4000 22 | WARMUP_ITERS: 0 23 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all2_10shot_unfreeze" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split2/faster_rcnn_R_101_FPN_ft_all2_1shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base2/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 17 | MIN_SIZE_TEST: 800 18 | DATASETS: 19 | TRAIN: ('voc_2007_trainval_all2_1shot',) 20 | TEST: ('voc_2007_test_all2',) 21 | SOLVER: 22 | IMS_PER_BATCH: 16 23 | BASE_LR: 0.005 24 | STEPS: (3500,) 25 | MAX_ITER: 4000 26 | CHECKPOINT_PERIOD: 10000 27 | WARMUP_ITERS: 0 28 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all2_1shot_randnovel_0.005lr" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split2/faster_rcnn_R_101_FPN_ft_all2_1shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base2/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | INPUT: 11 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 12 | MIN_SIZE_TEST: 800 13 | DATASETS: 14 | TRAIN: ('voc_2007_trainval_all2_1shot',) 15 | TEST: ('voc_2007_test_all2',) 16 | SOLVER: 17 | IMS_PER_BATCH: 16 18 | BASE_LR: 0.005 19 | STEPS: (3500,) 20 | MAX_ITER: 4000 21 | CHECKPOINT_PERIOD: 400 22 | WARMUP_ITERS: 0 23 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all2_1shot_unfreeze" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split2/faster_rcnn_R_101_FPN_ft_all2_2shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base2/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 17 | MIN_SIZE_TEST: 800 18 | DATASETS: 19 | TRAIN: ('voc_2007_trainval_all2_2shot',) 20 | TEST: ('voc_2007_test_all2',) 21 | SOLVER: 22 | IMS_PER_BATCH: 16 23 | BASE_LR: 0.005 24 | STEPS: (7000,) 25 | MAX_ITER: 8000 26 | CHECKPOINT_PERIOD: 500 27 | WARMUP_ITERS: 0 28 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all2_2shot_randnovel_0.005lr" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split2/faster_rcnn_R_101_FPN_ft_all2_2shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base2/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | INPUT: 11 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 12 | MIN_SIZE_TEST: 800 13 | DATASETS: 14 | TRAIN: ('voc_2007_trainval_all2_2shot',) 15 | TEST: ('voc_2007_test_all2',) 16 | SOLVER: 17 | IMS_PER_BATCH: 16 18 | BASE_LR: 0.005 19 | STEPS: (7000,) 20 | MAX_ITER: 8000 21 | CHECKPOINT_PERIOD: 800 22 | WARMUP_ITERS: 0 23 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all2_2shot_unfreeze" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split2/faster_rcnn_R_101_FPN_ft_all2_3shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base2/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 17 | MIN_SIZE_TEST: 800 18 | DATASETS: 19 | TRAIN: ('voc_2007_trainval_all2_3shot',) 20 | TEST: ('voc_2007_test_all2',) 21 | SOLVER: 22 | IMS_PER_BATCH: 16 23 | BASE_LR: 0.005 24 | STEPS: (10500,) 25 | MAX_ITER: 12000 26 | CHECKPOINT_PERIOD: 20000 27 | WARMUP_ITERS: 0 28 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all2_3shot_randnovel_0.005lr" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split2/faster_rcnn_R_101_FPN_ft_all2_3shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base2/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | INPUT: 11 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 12 | MIN_SIZE_TEST: 800 13 | DATASETS: 14 | TRAIN: ('voc_2007_trainval_all2_3shot',) 15 | TEST: ('voc_2007_test_all2',) 16 | SOLVER: 17 | IMS_PER_BATCH: 16 18 | BASE_LR: 0.005 19 | STEPS: (10500,) 20 | MAX_ITER: 12000 21 | CHECKPOINT_PERIOD: 1200 22 | WARMUP_ITERS: 0 23 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all2_3shot_unfreeze" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split2/faster_rcnn_R_101_FPN_ft_all2_5shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base2/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 17 | MIN_SIZE_TEST: 800 18 | DATASETS: 19 | TRAIN: ('voc_2007_trainval_all2_5shot',) 20 | TEST: ('voc_2007_test_all2',) 21 | SOLVER: 22 | IMS_PER_BATCH: 16 23 | BASE_LR: 0.005 24 | STEPS: (17500,) 25 | MAX_ITER: 20000 26 | CHECKPOINT_PERIOD: 30000 27 | WARMUP_ITERS: 0 28 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all2_5shot_randnovel_0.005lr" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split2/faster_rcnn_R_101_FPN_ft_all2_5shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base2/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | INPUT: 11 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 12 | MIN_SIZE_TEST: 800 13 | DATASETS: 14 | TRAIN: ('voc_2007_trainval_all2_5shot',) 15 | TEST: ('voc_2007_test_all2',) 16 | SOLVER: 17 | IMS_PER_BATCH: 16 18 | BASE_LR: 0.005 19 | STEPS: (17500,) 20 | MAX_ITER: 20000 21 | CHECKPOINT_PERIOD: 2000 22 | WARMUP_ITERS: 0 23 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all2_5shot_unfreeze" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split2/faster_rcnn_R_101_FPN_ft_fc_all2_10shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base2/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | INPUT: 15 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 16 | MIN_SIZE_TEST: 800 17 | DATASETS: 18 | TRAIN: ('voc_2007_trainval_all2_10shot',) 19 | TEST: ('voc_2007_test_all2',) 20 | SOLVER: 21 | IMS_PER_BATCH: 16 22 | BASE_LR: 0.005 23 | STEPS: (35000,) 24 | MAX_ITER: 40000 25 | CHECKPOINT_PERIOD: 4000 26 | WARMUP_ITERS: 0 27 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all2_10shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split2/faster_rcnn_R_101_FPN_ft_fc_all2_1shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base2/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | INPUT: 15 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 16 | MIN_SIZE_TEST: 800 17 | DATASETS: 18 | TRAIN: ('voc_2007_trainval_all2_1shot',) 19 | TEST: ('voc_2007_test_all2',) 20 | SOLVER: 21 | IMS_PER_BATCH: 16 22 | BASE_LR: 0.005 23 | STEPS: (3500,) 24 | MAX_ITER: 4000 25 | CHECKPOINT_PERIOD: 5000 26 | WARMUP_ITERS: 0 27 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all2_1shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split2/faster_rcnn_R_101_FPN_ft_fc_all2_2shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base2/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | INPUT: 15 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 16 | MIN_SIZE_TEST: 800 17 | DATASETS: 18 | TRAIN: ('voc_2007_trainval_all2_2shot',) 19 | TEST: ('voc_2007_test_all2',) 20 | SOLVER: 21 | IMS_PER_BATCH: 16 22 | BASE_LR: 0.005 23 | STEPS: (7000,) 24 | MAX_ITER: 8000 25 | CHECKPOINT_PERIOD: 10000 26 | WARMUP_ITERS: 0 27 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all2_2shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split2/faster_rcnn_R_101_FPN_ft_fc_all2_3shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base2/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | INPUT: 15 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 16 | MIN_SIZE_TEST: 800 17 | DATASETS: 18 | TRAIN: ('voc_2007_trainval_all2_3shot',) 19 | TEST: ('voc_2007_test_all2',) 20 | SOLVER: 21 | IMS_PER_BATCH: 16 22 | BASE_LR: 0.005 23 | STEPS: (10500,) 24 | MAX_ITER: 12000 25 | CHECKPOINT_PERIOD: 15000 26 | WARMUP_ITERS: 0 27 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all2_3shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split2/faster_rcnn_R_101_FPN_ft_fc_all2_5shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base2/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | INPUT: 15 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 16 | MIN_SIZE_TEST: 800 17 | DATASETS: 18 | TRAIN: ('voc_2007_trainval_all2_5shot',) 19 | TEST: ('voc_2007_test_all2',) 20 | SOLVER: 21 | IMS_PER_BATCH: 16 22 | BASE_LR: 0.005 23 | STEPS: (17500,) 24 | MAX_ITER: 20000 25 | CHECKPOINT_PERIOD: 30000 26 | WARMUP_ITERS: 0 27 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all2_5shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/faster_rcnn_R_101_FPN_base3.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 15 9 | INPUT: 10 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 11 | MIN_SIZE_TEST: 800 12 | DATASETS: 13 | TRAIN: ('voc_2007_trainval_base3', 'voc_2012_trainval_base3') 14 | TEST: ('voc_2007_test_base3',) 15 | SOLVER: 16 | STEPS: (12000, 16000) 17 | MAX_ITER: 18000 # 17.4 epochs 18 | WARMUP_ITERS: 100 19 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3" 20 | -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/faster_rcnn_R_101_FPN_ft_all3_10shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 17 | MIN_SIZE_TEST: 800 18 | DATASETS: 19 | TRAIN: ('voc_2007_trainval_all3_10shot',) 20 | TEST: ('voc_2007_test_all3',) 21 | SOLVER: 22 | IMS_PER_BATCH: 16 23 | BASE_LR: 0.001 24 | STEPS: (36000, ) 25 | MAX_ITER: 40000 26 | CHECKPOINT_PERIOD: 1000 27 | WARMUP_ITERS: 10 28 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_10shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/faster_rcnn_R_101_FPN_ft_all3_10shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | INPUT: 11 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 12 | MIN_SIZE_TEST: 800 13 | DATASETS: 14 | TRAIN: ('voc_2007_trainval_all3_10shot',) 15 | TEST: ('voc_2007_test_all3',) 16 | SOLVER: 17 | IMS_PER_BATCH: 16 18 | BASE_LR: 0.001 19 | STEPS: (36000,) 20 | MAX_ITER: 40000 21 | CHECKPOINT_PERIOD: 4000 22 | WARMUP_ITERS: 0 23 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_10shot_unfreeze" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/faster_rcnn_R_101_FPN_ft_all3_1shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 17 | MIN_SIZE_TEST: 800 18 | DATASETS: 19 | TRAIN: ('voc_2007_trainval_all3_1shot',) 20 | TEST: ('voc_2007_test_all3',) 21 | SOLVER: 22 | IMS_PER_BATCH: 16 23 | BASE_LR: 0.001 24 | STEPS: (3000,) 25 | MAX_ITER: 4000 26 | CHECKPOINT_PERIOD: 500 27 | WARMUP_ITERS: 0 28 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_1shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/faster_rcnn_R_101_FPN_ft_all3_1shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | INPUT: 11 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 12 | MIN_SIZE_TEST: 800 13 | DATASETS: 14 | TRAIN: ('voc_2007_trainval_all3_1shot',) 15 | TEST: ('voc_2007_test_all3',) 16 | SOLVER: 17 | IMS_PER_BATCH: 16 18 | BASE_LR: 0.001 19 | STEPS: (3000,) 20 | MAX_ITER: 4000 21 | CHECKPOINT_PERIOD: 400 22 | WARMUP_ITERS: 0 23 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_1shot_unfreeze" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/faster_rcnn_R_101_FPN_ft_all3_2shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 17 | MIN_SIZE_TEST: 800 18 | DATASETS: 19 | TRAIN: ('voc_2007_trainval_all3_2shot',) 20 | TEST: ('voc_2007_test_all3',) 21 | SOLVER: 22 | IMS_PER_BATCH: 16 23 | BASE_LR: 0.001 24 | STEPS: (7000,) 25 | MAX_ITER: 8000 26 | CHECKPOINT_PERIOD: 500 27 | WARMUP_ITERS: 0 28 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_2shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/faster_rcnn_R_101_FPN_ft_all3_2shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | INPUT: 11 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 12 | MIN_SIZE_TEST: 800 13 | DATASETS: 14 | TRAIN: ('voc_2007_trainval_all3_2shot',) 15 | TEST: ('voc_2007_test_all3',) 16 | SOLVER: 17 | IMS_PER_BATCH: 16 18 | BASE_LR: 0.001 19 | STEPS: (7000,) 20 | MAX_ITER: 8000 21 | CHECKPOINT_PERIOD: 800 22 | WARMUP_ITERS: 0 23 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_2shot_unfreeze" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/faster_rcnn_R_101_FPN_ft_all3_3shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 17 | MIN_SIZE_TEST: 800 18 | DATASETS: 19 | TRAIN: ('voc_2007_trainval_all3_3shot',) 20 | TEST: ('voc_2007_test_all3',) 21 | SOLVER: 22 | IMS_PER_BATCH: 16 23 | BASE_LR: 0.001 24 | STEPS: (11000, ) 25 | MAX_ITER: 12000 26 | CHECKPOINT_PERIOD: 500 27 | WARMUP_ITERS: 10 28 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_3shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/faster_rcnn_R_101_FPN_ft_all3_3shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | INPUT: 11 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 12 | MIN_SIZE_TEST: 800 13 | DATASETS: 14 | TRAIN: ('voc_2007_trainval_all3_3shot',) 15 | TEST: ('voc_2007_test_all3',) 16 | SOLVER: 17 | IMS_PER_BATCH: 16 18 | BASE_LR: 0.001 19 | STEPS: (11000,) 20 | MAX_ITER: 12000 21 | CHECKPOINT_PERIOD: 1200 22 | WARMUP_ITERS: 0 23 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_3shot_unfreeze" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/faster_rcnn_R_101_FPN_ft_all3_5shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | FREEZE_FEAT: True 11 | BACKBONE: 12 | FREEZE: True 13 | PROPOSAL_GENERATOR: 14 | FREEZE: True 15 | INPUT: 16 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 17 | MIN_SIZE_TEST: 800 18 | DATASETS: 19 | TRAIN: ('voc_2007_trainval_all3_5shot',) 20 | TEST: ('voc_2007_test_all3',) 21 | SOLVER: 22 | IMS_PER_BATCH: 16 23 | BASE_LR: 0.001 24 | STEPS: (18000,) 25 | MAX_ITER: 20000 26 | CHECKPOINT_PERIOD: 1000 27 | WARMUP_ITERS: 10 28 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_5shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/faster_rcnn_R_101_FPN_ft_all3_5shot_unfreeze.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | INPUT: 11 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 12 | MIN_SIZE_TEST: 800 13 | DATASETS: 14 | TRAIN: ('voc_2007_trainval_all3_5shot',) 15 | TEST: ('voc_2007_test_all3',) 16 | SOLVER: 17 | IMS_PER_BATCH: 16 18 | BASE_LR: 0.001 19 | STEPS: (18000,) 20 | MAX_ITER: 20000 21 | CHECKPOINT_PERIOD: 2000 22 | WARMUP_ITERS: 0 23 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_5shot_unfreeze" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/faster_rcnn_R_101_FPN_ft_fc_all3_10shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | INPUT: 15 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 16 | MIN_SIZE_TEST: 800 17 | DATASETS: 18 | TRAIN: ('voc_2007_trainval_all3_10shot',) 19 | TEST: ('voc_2007_test_all3',) 20 | SOLVER: 21 | IMS_PER_BATCH: 16 22 | BASE_LR: 0.001 23 | STEPS: (35000,) 24 | MAX_ITER: 40000 25 | CHECKPOINT_PERIOD: 50000 26 | WARMUP_ITERS: 0 27 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all3_10shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/faster_rcnn_R_101_FPN_ft_fc_all3_1shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | INPUT: 15 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 16 | MIN_SIZE_TEST: 800 17 | DATASETS: 18 | TRAIN: ('voc_2007_trainval_all3_1shot',) 19 | TEST: ('voc_2007_test_all3',) 20 | SOLVER: 21 | IMS_PER_BATCH: 16 22 | BASE_LR: 0.001 23 | STEPS: (3500,) 24 | MAX_ITER: 4000 25 | CHECKPOINT_PERIOD: 5000 26 | WARMUP_ITERS: 0 27 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all3_1shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/faster_rcnn_R_101_FPN_ft_fc_all3_2shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | INPUT: 15 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 16 | MIN_SIZE_TEST: 800 17 | DATASETS: 18 | TRAIN: ('voc_2007_trainval_all3_2shot',) 19 | TEST: ('voc_2007_test_all3',) 20 | SOLVER: 21 | IMS_PER_BATCH: 16 22 | BASE_LR: 0.001 23 | STEPS: (7000,) 24 | MAX_ITER: 8000 25 | CHECKPOINT_PERIOD: 10000 26 | WARMUP_ITERS: 0 27 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all3_2shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/faster_rcnn_R_101_FPN_ft_fc_all3_3shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | INPUT: 15 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 16 | MIN_SIZE_TEST: 800 17 | DATASETS: 18 | TRAIN: ('voc_2007_trainval_all3_3shot',) 19 | TEST: ('voc_2007_test_all3',) 20 | SOLVER: 21 | IMS_PER_BATCH: 16 22 | BASE_LR: 0.001 23 | STEPS: (10500,) 24 | MAX_ITER: 12000 25 | CHECKPOINT_PERIOD: 15000 26 | WARMUP_ITERS: 0 27 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all3_3shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/faster_rcnn_R_101_FPN_ft_fc_all3_5shot.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | FREEZE_FEAT: True 10 | BACKBONE: 11 | FREEZE: True 12 | PROPOSAL_GENERATOR: 13 | FREEZE: True 14 | INPUT: 15 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 16 | MIN_SIZE_TEST: 800 17 | DATASETS: 18 | TRAIN: ('voc_2007_trainval_all3_5shot',) 19 | TEST: ('voc_2007_test_all3',) 20 | SOLVER: 21 | IMS_PER_BATCH: 16 22 | BASE_LR: 0.001 23 | STEPS: (17500,) 24 | MAX_ITER: 20000 25 | CHECKPOINT_PERIOD: 30000 26 | WARMUP_ITERS: 0 27 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_fc_all3_5shot_randnovel" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/scale_ablation/faster_rcnn_R_101_FPN_ft_all3_10shot_randnovel_10scale.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | COSINE_SCALE: 10 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | INPUT: 17 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 18 | MIN_SIZE_TEST: 800 19 | DATASETS: 20 | TRAIN: ('voc_2007_trainval_all3_10shot',) 21 | TEST: ('voc_2007_test_all3',) 22 | SOLVER: 23 | IMS_PER_BATCH: 16 24 | BASE_LR: 0.001 25 | STEPS: (36000, ) 26 | MAX_ITER: 40000 27 | CHECKPOINT_PERIOD: 1000 28 | WARMUP_ITERS: 10 29 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_10shot_randnovel_10scale" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/scale_ablation/faster_rcnn_R_101_FPN_ft_all3_10shot_randnovel_1scale.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | COSINE_SCALE: 1 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | INPUT: 17 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 18 | MIN_SIZE_TEST: 800 19 | DATASETS: 20 | TRAIN: ('voc_2007_trainval_all3_10shot',) 21 | TEST: ('voc_2007_test_all3',) 22 | SOLVER: 23 | IMS_PER_BATCH: 16 24 | BASE_LR: 0.001 25 | STEPS: (36000, ) 26 | MAX_ITER: 40000 27 | CHECKPOINT_PERIOD: 1000 28 | WARMUP_ITERS: 10 29 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_10shot_randnovel_1scale" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/scale_ablation/faster_rcnn_R_101_FPN_ft_all3_10shot_randnovel_50scale.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | COSINE_SCALE: 50 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | INPUT: 17 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 18 | MIN_SIZE_TEST: 800 19 | DATASETS: 20 | TRAIN: ('voc_2007_trainval_all3_10shot',) 21 | TEST: ('voc_2007_test_all3',) 22 | SOLVER: 23 | IMS_PER_BATCH: 16 24 | BASE_LR: 0.001 25 | STEPS: (36000, ) 26 | MAX_ITER: 40000 27 | CHECKPOINT_PERIOD: 1000 28 | WARMUP_ITERS: 10 29 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_10shot_randnovel_50scale" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/scale_ablation/faster_rcnn_R_101_FPN_ft_all3_1shot_randnovel_100scale.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | COSINE_SCALE: 100 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | INPUT: 17 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 18 | MIN_SIZE_TEST: 800 19 | DATASETS: 20 | TRAIN: ('voc_2007_trainval_all3_1shot',) 21 | TEST: ('voc_2007_test_all3',) 22 | SOLVER: 23 | IMS_PER_BATCH: 16 24 | BASE_LR: 0.001 25 | STEPS: (3000,) 26 | MAX_ITER: 4000 27 | CHECKPOINT_PERIOD: 500 28 | WARMUP_ITERS: 0 29 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_1shot_randnovel_100scale" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/scale_ablation/faster_rcnn_R_101_FPN_ft_all3_1shot_randnovel_10scale.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | COSINE_SCALE: 10 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | INPUT: 17 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 18 | MIN_SIZE_TEST: 800 19 | DATASETS: 20 | TRAIN: ('voc_2007_trainval_all3_1shot',) 21 | TEST: ('voc_2007_test_all3',) 22 | SOLVER: 23 | IMS_PER_BATCH: 16 24 | BASE_LR: 0.001 25 | STEPS: (3000,) 26 | MAX_ITER: 4000 27 | CHECKPOINT_PERIOD: 500 28 | WARMUP_ITERS: 0 29 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_1shot_randnovel_10scale" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/scale_ablation/faster_rcnn_R_101_FPN_ft_all3_1shot_randnovel_1scale.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | COSINE_SCALE: 1 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | INPUT: 17 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 18 | MIN_SIZE_TEST: 800 19 | DATASETS: 20 | TRAIN: ('voc_2007_trainval_all3_1shot',) 21 | TEST: ('voc_2007_test_all3',) 22 | SOLVER: 23 | IMS_PER_BATCH: 16 24 | BASE_LR: 0.001 25 | STEPS: (3000,) 26 | MAX_ITER: 4000 27 | CHECKPOINT_PERIOD: 500 28 | WARMUP_ITERS: 0 29 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_1shot_randnovel_1scale" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/scale_ablation/faster_rcnn_R_101_FPN_ft_all3_1shot_randnovel_50scale.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | COSINE_SCALE: 50 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | INPUT: 17 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 18 | MIN_SIZE_TEST: 800 19 | DATASETS: 20 | TRAIN: ('voc_2007_trainval_all3_1shot',) 21 | TEST: ('voc_2007_test_all3',) 22 | SOLVER: 23 | IMS_PER_BATCH: 16 24 | BASE_LR: 0.001 25 | STEPS: (3000,) 26 | MAX_ITER: 4000 27 | CHECKPOINT_PERIOD: 500 28 | WARMUP_ITERS: 0 29 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_1shot_randnovel_50scale" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/scale_ablation/faster_rcnn_R_101_FPN_ft_all3_3shot_randnovel_10scale.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | COSINE_SCALE: 10 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | INPUT: 17 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 18 | MIN_SIZE_TEST: 800 19 | DATASETS: 20 | TRAIN: ('voc_2007_trainval_all3_3shot',) 21 | TEST: ('voc_2007_test_all3',) 22 | SOLVER: 23 | IMS_PER_BATCH: 16 24 | BASE_LR: 0.001 25 | STEPS: (11000, ) 26 | MAX_ITER: 12000 27 | CHECKPOINT_PERIOD: 500 28 | WARMUP_ITERS: 10 29 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_3shot_randnovel_10scale" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/scale_ablation/faster_rcnn_R_101_FPN_ft_all3_3shot_randnovel_1scale.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | COSINE_SCALE: 1 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | INPUT: 17 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 18 | MIN_SIZE_TEST: 800 19 | DATASETS: 20 | TRAIN: ('voc_2007_trainval_all3_3shot',) 21 | TEST: ('voc_2007_test_all3',) 22 | SOLVER: 23 | IMS_PER_BATCH: 16 24 | BASE_LR: 0.001 25 | STEPS: (11000, ) 26 | MAX_ITER: 12000 27 | CHECKPOINT_PERIOD: 500 28 | WARMUP_ITERS: 10 29 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_3shot_randnovel_1scale" -------------------------------------------------------------------------------- /configs/PascalVOC-detection/split3/scale_ablation/faster_rcnn_R_101_FPN_ft_all3_3shot_randnovel_50scale.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "../Base-RCNN-FPN.yaml" 2 | MODEL: 3 | WEIGHTS: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base3/model_reset_surgery.pth" 4 | MASK_ON: False 5 | RESNETS: 6 | DEPTH: 101 7 | ROI_HEADS: 8 | NUM_CLASSES: 20 9 | OUTPUT_LAYER: "CosineSimOutputLayers" 10 | COSINE_SCALE: 50 11 | FREEZE_FEAT: True 12 | BACKBONE: 13 | FREEZE: True 14 | PROPOSAL_GENERATOR: 15 | FREEZE: True 16 | INPUT: 17 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 18 | MIN_SIZE_TEST: 800 19 | DATASETS: 20 | TRAIN: ('voc_2007_trainval_all3_3shot',) 21 | TEST: ('voc_2007_test_all3',) 22 | SOLVER: 23 | IMS_PER_BATCH: 16 24 | BASE_LR: 0.001 25 | STEPS: (11000, ) 26 | MAX_ITER: 12000 27 | CHECKPOINT_PERIOD: 500 28 | WARMUP_ITERS: 10 29 | OUTPUT_DIR: "checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_normalized_all3_3shot_randnovel_50scale" -------------------------------------------------------------------------------- /datasets/README.md: -------------------------------------------------------------------------------- 1 | # Base datasets 2 | 3 | For a few datasets that FsDet natively supports, 4 | the datasets are assumed to exist in a directory called 5 | "datasets/", under the directory where you launch the program. 6 | They need to have the following directory structure: 7 | 8 | ## Expected dataset structure for Pascal VOC: 9 | ``` 10 | VOC20{07,12}/ 11 | Annotations/ 12 | ImageSets/ 13 | JPEGImages/ 14 | ``` 15 | 16 | ## Expected dataset structure for COCO: 17 | ``` 18 | coco/ 19 | annotations/ 20 | instances_{train,val}2014.json 21 | {train,val}2014/ 22 | # image files that are mentioned in the corresponding json 23 | ``` 24 | 25 | ## Expected dataset structure for LVIS: 26 | ``` 27 | coco/ 28 | {train,val}2017/ 29 | lvis/ 30 | lvis_v0.5_{train,val}.json 31 | lvis_v0.5_train_{freq,common,rare}.json 32 | ``` 33 | 34 | LVIS uses the same images and annotation format as COCO. You can use [split_lvis_annotation.py](split_lvis_annotation.py) to split `lvis_v0.5_train.json` into `lvis_v0.5_train_{freq,common,rare}.json`. 35 | 36 | Install lvis-api by: 37 | ``` 38 | pip install git+https://github.com/lvis-dataset/lvis-api.git 39 | ``` 40 | 41 | # Few-shot datasets 42 | 43 | For each dataset, we additionally create few-shot versions by sampling shots for each novel category. For better comparisons, we sample multiple groups of training shots in addition to the ones provided in previous works. We include the sampling scripts we used for better reproducibility and extensibility. The few-shot dataset files can be found [here](http://dl.yf.io/fs-det/datasets/). They should have the following directory structure: 44 | 45 | ## Pascal VOC: 46 | ``` 47 | vocsplit/ 48 | box_{1,2,3,5,10}shot_{category}_train.txt 49 | seed{1-29}/ 50 | # shots 51 | ``` 52 | 53 | Each file contains the images for _K_ shots for a specific category. There may be more instances in the images than _K_; in these cases, we randomly sample _K_ instances. 54 | 55 | The shots in the `vocsplit` directory are the same shots used by previous works. We additionally sample 29 more groups of shots for a total of 30 groups, which can be generated by using [prepare_voc_few_shot.py](prepare_voc_few_shot.py). 56 | 57 | See [prepare_voc_few_shot.py](prepare_voc_few_shot.py) for generating the seeds yourself. 58 | 59 | In the config files, you have to specify the datasets to use. See our provided config files for more usage details. Below, we list out the names of the datasets and the data they correspond to: 60 | ``` 61 | voc_20{07,12}_trainval_{base,all}{1,2,3} # Train/val datasets with base categories or all 62 | categories for splits 1, 2, and 3. 63 | voc_2007_trainval_all{1,2,3}_{1,2,3,5,10}shot # Balanced subsets for splits 1, 2, and 3 containing 64 | 1, 2, 3, 5, or 10 shots for each category. You only 65 | need to specify 2007, as it will load in both 2007 66 | and 2012 automatically. 67 | voc_2007_trainval_novel{1,2,3}_{1,2,3,5,10}shot # Same as previous datasets, but only contains data 68 | of novel categories. 69 | voc_2007_test_{base,novel,all}{1,2,3} # Test datasets with base categories, novel categories, 70 | or all categories for splits 1, 2, and 3. 71 | ``` 72 | 73 | ## COCO: 74 | ``` 75 | cocosplit/ 76 | datasplit/ 77 | trainvalno5k.json 78 | 5k.json 79 | full_box_{1,2,3,5,10,30}shot_{category}_trainval.json 80 | seed{1-9}/ 81 | # shots 82 | ``` 83 | 84 | All but 5k images from the train/val sets are used for training, while 5k images from the val set are used as the test set. `trainvalno5k.json` denotes the training set and `5k.json` is the test set. 85 | 86 | The sampling procedure is the same as for Pascal VOC, except we sample exactly _K_ instances for each category. For COCO, we use 10 groups. 87 | 88 | See [prepare_coco_few_shot.py](prepare_coco_few_shot.py) for generating the seeds yourself. 89 | 90 | Dataset names for config files: 91 | ``` 92 | coco_trainval_{base,all} # Train/val datasets with base categories or all 93 | categories. 94 | coco_trainval_all_{1,2,3,5,10,30}shot # Balanced subsets containing 1, 2, 3, 5, 10, or 30 95 | shots for each category. 96 | coco_trainval_novel_{1,2,3,5,10,30}shot # Same as previous datasets, but only contains data 97 | of novel categories. 98 | coco_test_{base,novel,all} # Test datasets with base categories, novel categories, 99 | or all categories. 100 | ``` 101 | 102 | ## LVIS: 103 | ``` 104 | lvissplit/ 105 | lvis_shots.json 106 | ``` 107 | 108 | We treat the frequent and common categories as the base categories and the rare categories as the novel categories. 109 | 110 | We sample up to 10 instances for each category to build a balanced subset for the few-shot fine-tuning stage. We include all shots in a single COCO-style annotation file. 111 | 112 | See [prepare_lvis_few_shot.py](prepare_lvis_few_shot.py) for generating the seeds yourself. 113 | 114 | Dataset names for config files: 115 | ``` 116 | lvis_v0.5_train_{freq,common} # Train datasets with freq categories or common 117 | categories. These are used as the base datasets. 118 | lvis_v0.5_train_rare_novel # Train datasets with rare categories. 119 | lvis_v0.5_train_shots # Balanced subset containing up to 10 shots for 120 | each category. 121 | lvis_v0.5_val # Validation set with all categories. 122 | lvis_v0.5_val_novel # Validation set with only novel categories. 123 | ``` 124 | -------------------------------------------------------------------------------- /datasets/prepare_coco_few_shot.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import json 3 | import os 4 | import random 5 | 6 | 7 | def parse_args(): 8 | parser = argparse.ArgumentParser() 9 | parser.add_argument("--seeds", type=int, nargs="+", default=[1,10], 10 | help="Range of seeds") 11 | args = parser.parse_args() 12 | return args 13 | 14 | 15 | def generate_seeds(args): 16 | #data_path = 'datasets/cocosplit/datasplit/trainvalno5k.json' 17 | data_path = 'F:/workspace/Daheng/Deep-learning-library/few-shot-object-detection-master/datasets/jiaonang/train.json' 18 | data = json.load(open(data_path)) 19 | 20 | new_all_cats = [] 21 | for cat in data['categories']: 22 | new_all_cats.append(cat) 23 | 24 | id2img = {} 25 | for i in data['images']: 26 | id2img[i['id']] = i 27 | 28 | anno = {i: [] for i in ID2CLASS.keys()} 29 | for a in data['annotations']: 30 | if a['iscrowd'] == 1: 31 | continue 32 | anno[a['category_id']].append(a) 33 | 34 | for i in range(args.seeds[0], args.seeds[1]): 35 | random.seed(i) 36 | for c in ID2CLASS.keys(): 37 | img_ids = {} 38 | for a in anno[c]: 39 | if a['image_id'] in img_ids: 40 | img_ids[a['image_id']].append(a) 41 | else: 42 | img_ids[a['image_id']] = [a] 43 | 44 | sample_shots = [] 45 | sample_imgs = [] 46 | for shots in [1, 2, 3]: 47 | while True: 48 | imgs = random.sample(list(img_ids.keys()), shots) 49 | for img in imgs: 50 | skip = False 51 | for s in sample_shots: 52 | if img == s['image_id']: 53 | skip = True 54 | break 55 | if skip: 56 | continue 57 | if len(img_ids[img]) + len(sample_shots) > shots: 58 | continue 59 | sample_shots.extend(img_ids[img]) 60 | sample_imgs.append(id2img[img]) 61 | if len(sample_shots) == shots: 62 | break 63 | if len(sample_shots) == shots: 64 | break 65 | new_data = { 66 | #'info': data['info'], 67 | #'licenses': data['licenses'], 68 | 'images': sample_imgs, 69 | 'annotations': sample_shots, 70 | } 71 | save_path = get_save_path_seeds(data_path, ID2CLASS[c], shots, i) 72 | new_data['categories'] = new_all_cats 73 | with open(save_path, 'w') as f: 74 | json.dump(new_data, f) 75 | 76 | 77 | def get_save_path_seeds(path, cls, shots, seed): 78 | s = path.split('/') 79 | prefix = 'full_box_{}shot_{}_trainval'.format(shots, cls) 80 | save_dir = os.path.join('datasets', 'cocosplit', 'seed' + str(seed)) 81 | os.makedirs(save_dir, exist_ok=True) 82 | save_path = os.path.join(save_dir, prefix + '.json') 83 | return save_path 84 | 85 | 86 | if __name__ == '__main__': 87 | ID2CLASS = { 88 | 89 | 0: "fasi", 90 | 1: "heidian", 91 | 2: "yiwu", 92 | 93 | # 1: "person", 94 | # 2: "bicycle", 95 | # 3: "car", 96 | # 4: "motorcycle", 97 | # 5: "airplane", 98 | # 6: "bus", 99 | # 7: "train", 100 | # 8: "truck", 101 | # 9: "boat", 102 | # 10: "traffic light", 103 | # 11: "fire hydrant", 104 | # 13: "stop sign", 105 | # 14: "parking meter", 106 | # 15: "bench", 107 | # 16: "bird", 108 | # 17: "cat", 109 | # 18: "dog", 110 | # 19: "horse", 111 | # 20: "sheep", 112 | # 21: "cow", 113 | # 22: "elephant", 114 | # 23: "bear", 115 | # 24: "zebra", 116 | # 25: "giraffe", 117 | # 27: "backpack", 118 | # 28: "umbrella", 119 | # 31: "handbag", 120 | # 32: "tie", 121 | # 33: "suitcase", 122 | # 34: "frisbee", 123 | # 35: "skis", 124 | # 36: "snowboard", 125 | # 37: "sports ball", 126 | # 38: "kite", 127 | # 39: "baseball bat", 128 | # 40: "baseball glove", 129 | # 41: "skateboard", 130 | # 42: "surfboard", 131 | # 43: "tennis racket", 132 | # 44: "bottle", 133 | # 46: "wine glass", 134 | # 47: "cup", 135 | # 48: "fork", 136 | # 49: "knife", 137 | # 50: "spoon", 138 | # 51: "bowl", 139 | # 52: "banana", 140 | # 53: "apple", 141 | # 54: "sandwich", 142 | # 55: "orange", 143 | # 56: "broccoli", 144 | # 57: "carrot", 145 | # 58: "hot dog", 146 | # 59: "pizza", 147 | # 60: "donut", 148 | # 61: "cake", 149 | # 62: "chair", 150 | # 63: "couch", 151 | # 64: "potted plant", 152 | # 65: "bed", 153 | # 67: "dining table", 154 | # 70: "toilet", 155 | # 72: "tv", 156 | # 73: "laptop", 157 | # 74: "mouse", 158 | # 75: "remote", 159 | # 76: "keyboard", 160 | # 77: "cell phone", 161 | # 78: "microwave", 162 | # 79: "oven", 163 | # 80: "toaster", 164 | # 81: "sink", 165 | # 82: "refrigerator", 166 | # 84: "book", 167 | # 85: "clock", 168 | # 86: "vase", 169 | # 87: "scissors", 170 | # 88: "teddy bear", 171 | # 89: "hair drier", 172 | # 90: "toothbrush", 173 | } 174 | CLASS2ID = {v: k for k, v in ID2CLASS.items()} 175 | 176 | args = parse_args() 177 | generate_seeds(args) 178 | -------------------------------------------------------------------------------- /datasets/prepare_voc_few_shot.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from fvcore.common.file_io import PathManager 3 | 4 | import argparse 5 | import copy 6 | import os 7 | import random 8 | import xml.etree.ElementTree as ET 9 | 10 | VOC_CLASSES = ['aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 11 | 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 12 | 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 13 | 'tvmonitor'] 14 | 15 | 16 | def parse_args(): 17 | parser = argparse.ArgumentParser() 18 | parser.add_argument("--seeds", type=int, nargs="+", default=[1, 20], 19 | help="Range of seeds") 20 | args = parser.parse_args() 21 | return args 22 | 23 | 24 | def generate_seeds(args): 25 | data = [] 26 | data_per_cat = {c: [] for c in VOC_CLASSES} 27 | for year in [2007, 2012]: 28 | data_file = 'datasets/VOC{}/ImageSets/Main/trainval.txt'.format(year) 29 | with PathManager.open(data_file) as f: 30 | fileids = np.loadtxt(f, dtype=np.str).tolist() 31 | data.extend(fileids) 32 | for fileid in data: 33 | year = "2012" if "_" in fileid else "2007" 34 | dirname = os.path.join("datasets", "VOC{}".format(year)) 35 | anno_file = os.path.join(dirname, "Annotations", fileid + ".xml") 36 | tree = ET.parse(anno_file) 37 | clses = [] 38 | for obj in tree.findall("object"): 39 | cls = obj.find("name").text 40 | clses.append(cls) 41 | for cls in set(clses): 42 | data_per_cat[cls].append(anno_file) 43 | 44 | result = {cls: {} for cls in data_per_cat.keys()} 45 | shots = [1, 2, 3, 5, 10] 46 | for i in range(args.seeds[0], args.seeds[1]): 47 | random.seed(i) 48 | for c in data_per_cat.keys(): 49 | c_data = [] 50 | for j, shot in enumerate(shots): 51 | diff_shot = shots[j] - shots[j-1] if j != 0 else 1 52 | shots_c = random.sample(data_per_cat[c], diff_shot) 53 | num_objs = 0 54 | for s in shots_c: 55 | if s not in c_data: 56 | tree = ET.parse(s) 57 | file = tree.find("filename").text 58 | year = tree.find("folder").text 59 | name = 'datasets/{}/JPEGImages/{}'.format(year, file) 60 | c_data.append(name) 61 | for obj in tree.findall("object"): 62 | if obj.find("name").text == c: 63 | num_objs += 1 64 | if num_objs >= diff_shot: 65 | break 66 | result[c][shot] = copy.deepcopy(c_data) 67 | save_path = 'datasets/vocsplit/seed{}'.format(i) 68 | os.makedirs(save_path, exist_ok=True) 69 | for c in result.keys(): 70 | for shot in result[c].keys(): 71 | filename = 'box_{}shot_{}_train.txt'.format(shot, c) 72 | with open(os.path.join(save_path, filename), 'w') as fp: 73 | fp.write('\n'.join(result[c][shot])+'\n') 74 | 75 | 76 | if __name__ == '__main__': 77 | args = parse_args() 78 | generate_seeds(args) 79 | -------------------------------------------------------------------------------- /datasets/split_lvis_annotation.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import json 3 | import os 4 | 5 | 6 | def parse_args(): 7 | parser = argparse.ArgumentParser() 8 | parser.add_argument('--data', type=str, 9 | default="datasets/lvis/lvis_v0.5_train.json", 10 | help='path to the annotation file') 11 | parser.add_argument('--save-dir', type=str, 12 | default="datasets/lvis", 13 | help='path to the save directory') 14 | args = parser.parse_args() 15 | return args 16 | 17 | 18 | def split_annotation(args): 19 | with open(args.data) as fp: 20 | ann_train = json.load(fp) 21 | 22 | for s, name in [('f', 'freq'), ('c', 'common'), ('r', 'rare')]: 23 | ann_s = { 24 | 'info': ann_train['info'], 25 | # 'images': ann_train['images'], 26 | 'categories': ann_train['categories'], 27 | 'licenses': ann_train['licenses'], 28 | } 29 | ids = [cat['id'] for cat in ann_train['categories'] \ 30 | if cat['frequency'] == s] 31 | ann_s['annotations'] = [ 32 | ann for ann in ann_train['annotations'] if ann['category_id'] in ids] 33 | img_ids = set([ann['image_id'] for ann in ann_s['annotations']]) 34 | new_images = [img for img in ann_train['images'] if img['id'] in img_ids] 35 | ann_s['images'] = new_images 36 | 37 | save_path = os.path.join( 38 | args.save_dir, 'lvis_v0.5_train_{}.json'.format(name)) 39 | print('Saving {} annotations to {}.'.format(name, save_path)) 40 | with open(save_path, 'w') as fp: 41 | json.dump(ann_s, fp) 42 | 43 | 44 | if __name__ == '__main__': 45 | args = parse_args() 46 | split_annotation(args) 47 | -------------------------------------------------------------------------------- /demo/demo.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import tqdm 3 | 4 | import argparse 5 | import glob 6 | import multiprocessing as mp 7 | import os 8 | import time 9 | 10 | #from demo.predictor import VisualizationDemo 11 | from predictor import VisualizationDemo 12 | from detectron2.data.detection_utils import read_image 13 | from detectron2.utils.logger import setup_logger 14 | from fsdet.config import get_cfg 15 | 16 | # constants 17 | WINDOW_NAME = "COCO detections" 18 | 19 | 20 | def setup_cfg(args): 21 | # load config from file and command-line arguments 22 | cfg = get_cfg() 23 | cfg.merge_from_file(args.config_file) 24 | cfg.merge_from_list(args.opts) 25 | # Set score_threshold for builtin models 26 | cfg.MODEL.RETINANET.SCORE_THRESH_TEST = args.confidence_threshold 27 | cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = args.confidence_threshold 28 | cfg.freeze() 29 | return cfg 30 | 31 | 32 | def get_parser(): 33 | parser = argparse.ArgumentParser( 34 | description="FsDet demo for builtin models" 35 | ) 36 | parser.add_argument( 37 | "--config-file", 38 | default="configs/COCO-detection/faster_rcnn_R_101_FPN_ft_all_1shot.yaml", 39 | metavar="FILE", 40 | help="path to config file", 41 | ) 42 | parser.add_argument( 43 | "--webcam", action="store_true", help="Take inputs from webcam." 44 | ) 45 | parser.add_argument("--video-input", help="Path to video file.") 46 | parser.add_argument( 47 | "--input", 48 | nargs="+", 49 | help="A list of space separated input images; " 50 | "or a single glob pattern such as 'directory/*.jpg'", 51 | ) 52 | parser.add_argument( 53 | "--output", 54 | help="A file or directory to save output visualizations. " 55 | "If not given, will show output in an OpenCV window.", 56 | ) 57 | 58 | parser.add_argument( 59 | "--confidence-threshold", 60 | type=float, 61 | default=0.5, 62 | help="Minimum score for instance predictions to be shown", 63 | ) 64 | parser.add_argument( 65 | "--opts", 66 | help="Modify config options using the command-line 'KEY VALUE' pairs", 67 | default=[], 68 | nargs=argparse.REMAINDER, 69 | ) 70 | return parser 71 | 72 | 73 | if __name__ == "__main__": 74 | # import pdb 75 | # pdb.set_trace() 76 | mp.set_start_method("spawn", force=True) 77 | args = get_parser().parse_args() 78 | setup_logger(name="fvcore") 79 | logger = setup_logger() 80 | logger.info("Arguments: " + str(args)) 81 | 82 | cfg = setup_cfg(args) 83 | 84 | demo = VisualizationDemo(cfg) 85 | 86 | if args.input: 87 | if len(args.input) == 1: 88 | args.input = glob.glob(os.path.expanduser(args.input[0])) 89 | assert args.input, "The input path(s) was not found" 90 | for path in tqdm.tqdm(args.input, disable=not args.output): 91 | # use PIL, to be consistent with evaluation 92 | img = read_image(path, format="BGR") 93 | start_time = time.time() 94 | predictions, visualized_output = demo.run_on_image(img) 95 | logger.info( 96 | "{}: {} in {:.2f}s".format( 97 | path, 98 | "detected {} instances".format( 99 | len(predictions["instances"]) 100 | ) 101 | if "instances" in predictions 102 | else "finished", 103 | time.time() - start_time, 104 | ) 105 | ) 106 | 107 | if args.output: 108 | if os.path.isdir(args.output): 109 | assert os.path.isdir(args.output), args.output 110 | out_filename = os.path.join( 111 | args.output, os.path.basename(path) 112 | ) 113 | else: 114 | assert ( 115 | len(args.input) == 1 116 | ), "Please specify a directory with args.output" 117 | out_filename = args.output 118 | visualized_output.save(out_filename) 119 | else: 120 | cv2.namedWindow(WINDOW_NAME, cv2.WINDOW_NORMAL) 121 | cv2.imshow( 122 | WINDOW_NAME, visualized_output.get_image()[:, :, ::-1] 123 | ) 124 | if cv2.waitKey(0) == 27: 125 | break # esc to quit 126 | elif args.webcam: 127 | assert args.input is None, "Cannot have both --input and --webcam!" 128 | cam = cv2.VideoCapture(0) 129 | for vis in tqdm.tqdm(demo.run_on_video(cam)): 130 | cv2.namedWindow(WINDOW_NAME, cv2.WINDOW_NORMAL) 131 | cv2.imshow(WINDOW_NAME, vis) 132 | if cv2.waitKey(1) == 27: 133 | break # esc to quit 134 | cv2.destroyAllWindows() 135 | elif args.video_input: 136 | video = cv2.VideoCapture(args.video_input) 137 | width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH)) 138 | height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT)) 139 | frames_per_second = video.get(cv2.CAP_PROP_FPS) 140 | num_frames = int(video.get(cv2.CAP_PROP_FRAME_COUNT)) 141 | basename = os.path.basename(args.video_input) 142 | 143 | if args.output: 144 | if os.path.isdir(args.output): 145 | output_fname = os.path.join(args.output, basename) 146 | output_fname = os.path.splitext(output_fname)[0] + ".mkv" 147 | else: 148 | output_fname = args.output 149 | assert not os.path.isfile(output_fname), output_fname 150 | output_file = cv2.VideoWriter( 151 | filename=output_fname, 152 | # some installation of opencv may not support x264 (due to its license), 153 | # you can try other format (e.g. MPEG) 154 | fourcc=cv2.VideoWriter_fourcc(*"x264"), 155 | fps=float(frames_per_second), 156 | frameSize=(width, height), 157 | isColor=True, 158 | ) 159 | assert os.path.isfile(args.video_input) 160 | for vis_frame in tqdm.tqdm(demo.run_on_video(video), total=num_frames): 161 | if args.output: 162 | output_file.write(vis_frame) 163 | else: 164 | cv2.namedWindow(basename, cv2.WINDOW_NORMAL) 165 | cv2.imshow(basename, vis_frame) 166 | if cv2.waitKey(1) == 27: 167 | break # esc to quit 168 | video.release() 169 | if args.output: 170 | output_file.release() 171 | else: 172 | cv2.destroyAllWindows() 173 | -------------------------------------------------------------------------------- /demo/input1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wz940216/few-shot-object-detection-custom/66277921a9c38b0f0d55a4f0d07c54363b17070b/demo/input1.jpg -------------------------------------------------------------------------------- /demo/input2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wz940216/few-shot-object-detection-custom/66277921a9c38b0f0d55a4f0d07c54363b17070b/demo/input2.jpg -------------------------------------------------------------------------------- /demo/predictor.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import torch 3 | 4 | import atexit 5 | import bisect 6 | import multiprocessing as mp 7 | from collections import deque 8 | from detectron2.data import MetadataCatalog 9 | from detectron2.utils.video_visualizer import VideoVisualizer 10 | from detectron2.utils.visualizer import ColorMode, Visualizer 11 | from fsdet.engine import DefaultPredictor 12 | 13 | 14 | class VisualizationDemo(object): 15 | def __init__(self, cfg, instance_mode=ColorMode.IMAGE, parallel=False): 16 | """ 17 | Args: 18 | cfg (CfgNode): 19 | instance_mode (ColorMode): 20 | parallel (bool): whether to run the model in different processes 21 | from visualization. 22 | Useful since the visualization logic can be slow. 23 | """ 24 | self.metadata = MetadataCatalog.get( 25 | cfg.DATASETS.TEST[0] if len(cfg.DATASETS.TEST) else "__unused" 26 | ) 27 | self.cpu_device = torch.device("cpu") 28 | self.instance_mode = instance_mode 29 | 30 | self.parallel = parallel 31 | if parallel: 32 | num_gpu = torch.cuda.device_count() 33 | self.predictor = AsyncPredictor(cfg, num_gpus=num_gpu) 34 | else: 35 | self.predictor = DefaultPredictor(cfg) 36 | 37 | def run_on_image(self, image): 38 | """ 39 | Args: 40 | image (np.ndarray): an image of shape (H, W, C) (in BGR order). 41 | This is the format used by OpenCV. 42 | Returns: 43 | predictions (dict): the output of the model. 44 | vis_output (VisImage): the visualized image output. 45 | """ 46 | vis_output = None 47 | predictions = self.predictor(image) 48 | # Convert image from OpenCV BGR format to Matplotlib RGB format. 49 | image = image[:, :, ::-1] 50 | visualizer = Visualizer( 51 | image, self.metadata, instance_mode=self.instance_mode 52 | ) 53 | if "instances" in predictions: 54 | instances = predictions["instances"].to(self.cpu_device) 55 | vis_output = visualizer.draw_instance_predictions( 56 | predictions=instances 57 | ) 58 | 59 | return predictions, vis_output 60 | 61 | def _frame_from_video(self, video): 62 | while video.isOpened(): 63 | success, frame = video.read() 64 | if success: 65 | yield frame 66 | else: 67 | break 68 | 69 | def run_on_video(self, video): 70 | """ 71 | Visualizes predictions on frames of the input video. 72 | Args: 73 | video (cv2.VideoCapture): a :class:`VideoCapture` object, 74 | whose source can be either a webcam or a video file. 75 | Yields: 76 | ndarray: BGR visualizations of each video frame. 77 | """ 78 | video_visualizer = VideoVisualizer(self.metadata, self.instance_mode) 79 | 80 | def process_predictions(frame, predictions): 81 | frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR) 82 | if "instances" in predictions: 83 | predictions = predictions["instances"].to(self.cpu_device) 84 | vis_frame = video_visualizer.draw_instance_predictions( 85 | frame, predictions 86 | ) 87 | 88 | # Converts Matplotlib RGB format to OpenCV BGR format 89 | vis_frame = cv2.cvtColor(vis_frame.get_image(), cv2.COLOR_RGB2BGR) 90 | return vis_frame 91 | 92 | frame_gen = self._frame_from_video(video) 93 | if self.parallel: 94 | buffer_size = self.predictor.default_buffer_size 95 | 96 | frame_data = deque() 97 | 98 | for cnt, frame in enumerate(frame_gen): 99 | frame_data.append(frame) 100 | self.predictor.put(frame) 101 | 102 | if cnt >= buffer_size: 103 | frame = frame_data.popleft() 104 | predictions = self.predictor.get() 105 | yield process_predictions(frame, predictions) 106 | 107 | while len(frame_data): 108 | frame = frame_data.popleft() 109 | predictions = self.predictor.get() 110 | yield process_predictions(frame, predictions) 111 | else: 112 | for frame in frame_gen: 113 | yield process_predictions(frame, self.predictor(frame)) 114 | 115 | 116 | class AsyncPredictor: 117 | """ 118 | A predictor that runs the model asynchronously, possibly on >1 GPUs. 119 | Because rendering the visualization takes considerably amount of time, 120 | this helps improve throughput when rendering videos. 121 | """ 122 | 123 | class _StopToken: 124 | pass 125 | 126 | class _PredictWorker(mp.Process): 127 | def __init__(self, cfg, task_queue, result_queue): 128 | self.cfg = cfg 129 | self.task_queue = task_queue 130 | self.result_queue = result_queue 131 | super().__init__() 132 | 133 | def run(self): 134 | predictor = DefaultPredictor(self.cfg) 135 | 136 | while True: 137 | task = self.task_queue.get() 138 | if isinstance(task, AsyncPredictor._StopToken): 139 | break 140 | idx, data = task 141 | result = predictor(data) 142 | self.result_queue.put((idx, result)) 143 | 144 | def __init__(self, cfg, num_gpus: int = 1): 145 | """ 146 | Args: 147 | cfg (CfgNode): 148 | num_gpus (int): if 0, will run on CPU 149 | """ 150 | num_workers = max(num_gpus, 1) 151 | self.task_queue = mp.Queue(maxsize=num_workers * 3) 152 | self.result_queue = mp.Queue(maxsize=num_workers * 3) 153 | self.procs = [] 154 | for gpuid in range(max(num_gpus, 1)): 155 | cfg = cfg.clone() 156 | cfg.defrost() 157 | cfg.MODEL.DEVICE = ( 158 | "cuda:{}".format(gpuid) if num_gpus > 0 else "cpu" 159 | ) 160 | self.procs.append( 161 | AsyncPredictor._PredictWorker( 162 | cfg, self.task_queue, self.result_queue 163 | ) 164 | ) 165 | 166 | self.put_idx = 0 167 | self.get_idx = 0 168 | self.result_rank = [] 169 | self.result_data = [] 170 | 171 | for p in self.procs: 172 | p.start() 173 | atexit.register(self.shutdown) 174 | 175 | def put(self, image): 176 | self.put_idx += 1 177 | self.task_queue.put((self.put_idx, image)) 178 | 179 | def get(self): 180 | self.get_idx += 1 # the index needed for this request 181 | if len(self.result_rank) and self.result_rank[0] == self.get_idx: 182 | res = self.result_data[0] 183 | del self.result_data[0], self.result_rank[0] 184 | return res 185 | 186 | while True: 187 | # make sure the results are returned in the correct order 188 | idx, res = self.result_queue.get() 189 | if idx == self.get_idx: 190 | return res 191 | insert = bisect.bisect(self.result_rank, idx) 192 | self.result_rank.insert(insert, idx) 193 | self.result_data.insert(insert, res) 194 | 195 | def __len__(self): 196 | return self.put_idx - self.get_idx 197 | 198 | def __call__(self, image): 199 | self.put(image) 200 | return self.get() 201 | 202 | def shutdown(self): 203 | for _ in self.procs: 204 | self.task_queue.put(AsyncPredictor._StopToken()) 205 | 206 | @property 207 | def default_buffer_size(self): 208 | return len(self.procs) * 5 209 | -------------------------------------------------------------------------------- /docs/TRAIN_INST.md: -------------------------------------------------------------------------------- 1 | # TFA Training Instructions 2 | 3 | TFA is trained in two stages. We first train the entire object detector on the data-abundant base classes, and then only fine-tune the last layers of the detector on a small balanced training set. We provide detailed instructions for each stage. 4 | 5 | ![TFA Figure](https://user-images.githubusercontent.com/7898443/76520006-698cc200-6438-11ea-864f-fd30b3d50cea.png) 6 | 7 | ## Stage 1: Base Training 8 | 9 | First train a base model. To train a base model on the first split of PASCAL VOC, run 10 | ```angular2html 11 | python3 -m tools.train_net --num-gpus 8 \ 12 | --config-file configs/PascalVOC-detection/split1/faster_rcnn_R_101_base1.yaml 13 | ``` 14 | 15 | ## Stage 2: Few-Shot Fine-Tuning 16 | 17 | ### Initialization 18 | 19 | After training the base model, run ```tools/ckpt_surgery.py``` to obtain an initialization for the full model. We only modify the weights of the last layer of the detector, while the rest of the network are kept the same. The weights corresponding to the base classes are set as those obtained in the previous stage, and the weights corresponding to the novel classes are either randomly initialized or set as those of a predictor fine-tuned on the novel set. 20 | 21 | #### Random Weights 22 | 23 | To randomly initialize the weights corresponding to the novel classes, run 24 | ```angular2html 25 | python3 -m tools.ckpt_surgery \ 26 | --src1 checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_final.pth \ 27 | --method randinit \ 28 | --save-dir checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_all1 29 | ``` 30 | The resulting weights will be saved to `checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_all1/model_reset_surgery.pth`. 31 | 32 | #### Novel Weights 33 | 34 | To use novel weights, fine-tune a predictor on the novel set. We reuse the base model trained in the previous stage but retrain the last layer from scratch. First remove the last layer from the weights file by running 35 | ```angular2html 36 | python3 -m tools.ckpt_surgery \ 37 | --src1 checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_final.pth \ 38 | --method remove \ 39 | --save-dir checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_all1 40 | ``` 41 | 42 | Next, fine-tune the predictor on the novel set by running 43 | ```angular2html 44 | python3 -m tools.train_net --num-gpus 8 \ 45 | --config-file configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_novel1_1shot.yaml \ 46 | --opts MODEL.WEIGHTS checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_all1/model_reset_remove.pth 47 | ``` 48 | 49 | Finally, combine the base weights from the base model with the novel weights by running 50 | ```angular2html 51 | python3 -m tools.ckpt_surgery \ 52 | --src1 checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_final.pth \ 53 | --src2 checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel1_1shot/model_final.pth \ 54 | --method combine \ 55 | --save-dir checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_all1 56 | ``` 57 | The resulting weights will be saved to `checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_all1/model_reset_combine.pth`. 58 | 59 | ### Fine-Tuning 60 | 61 | We will then fine-tune the last layer of the full model on a balanced dataset by running 62 | ```angular2html 63 | python3 -m tools.train_net --num-gpus 8 \ 64 | --config-file configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_all1_1shot.yaml \ 65 | --opts MODEL.WEIGHTS WEIGHTS_PATH 66 | ``` 67 | where `WEIGHTS_PATH` is the path to the weights obtained in the previous initialization step. 68 | -------------------------------------------------------------------------------- /fsdet/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wz940216/few-shot-object-detection-custom/66277921a9c38b0f0d55a4f0d07c54363b17070b/fsdet/__init__.py -------------------------------------------------------------------------------- /fsdet/checkpoint/__init__.py: -------------------------------------------------------------------------------- 1 | from . import catalog as _UNUSED # register the handler 2 | from .detection_checkpoint import DetectionCheckpointer 3 | 4 | __all__ = ["DetectionCheckpointer"] -------------------------------------------------------------------------------- /fsdet/checkpoint/catalog.py: -------------------------------------------------------------------------------- 1 | """FS-Det Model Handler.""" 2 | from fvcore.common.file_io import PathHandler, PathManager 3 | 4 | import logging 5 | 6 | 7 | class FsDetHandler(PathHandler): 8 | """ 9 | Resolve anything that's in FsDet model zoo. 10 | """ 11 | 12 | PREFIX = "fsdet://" 13 | URL_PREFIX = "http://dl.yf.io/fs-det/models/" 14 | 15 | def _get_supported_prefixes(self): 16 | return [self.PREFIX] 17 | 18 | def _get_local_path(self, path): 19 | name = path[len(self.PREFIX) :] 20 | return PathManager.get_local_path(self.URL_PREFIX + name) 21 | 22 | def _open(self, path, mode="r", **kwargs): 23 | return PathManager.open(self._get_local_path(path), mode, **kwargs) 24 | 25 | 26 | PathManager.register_handler(FsDetHandler()) 27 | -------------------------------------------------------------------------------- /fsdet/checkpoint/detection_checkpoint.py: -------------------------------------------------------------------------------- 1 | import pickle 2 | from fvcore.common.checkpoint import Checkpointer 3 | from fvcore.common.file_io import PathManager 4 | 5 | import detectron2.utils.comm as comm 6 | from detectron2.checkpoint.c2_model_loading import align_and_update_state_dicts 7 | 8 | 9 | class DetectionCheckpointer(Checkpointer): 10 | """ 11 | Same as :class:`Checkpointer`, but is able to handle models in detectron & detectron2 12 | model zoo, and apply conversions for legacy models. 13 | """ 14 | 15 | def __init__(self, model, save_dir="", *, save_to_disk=None, **checkpointables): 16 | is_main_process = comm.is_main_process() 17 | super().__init__( 18 | model, 19 | save_dir, 20 | save_to_disk=is_main_process if save_to_disk is None else save_to_disk, 21 | **checkpointables, 22 | ) 23 | 24 | def _load_file(self, filename): 25 | if filename.endswith(".pkl"): 26 | with PathManager.open(filename, "rb") as f: 27 | data = pickle.load(f, encoding="latin1") 28 | if "model" in data and "__author__" in data: 29 | # file is in Detectron2 model zoo format 30 | self.logger.info("Reading a file from '{}'".format(data["__author__"])) 31 | return data 32 | else: 33 | # assume file is from Caffe2 / Detectron1 model zoo 34 | if "blobs" in data: 35 | # Detection models have "blobs", but ImageNet models don't 36 | data = data["blobs"] 37 | data = {k: v for k, v in data.items() if not k.endswith("_momentum")} 38 | return {"model": data, "__author__": "Caffe2", "matching_heuristics": True} 39 | 40 | loaded = super()._load_file(filename) # load native pth checkpoint 41 | if "model" not in loaded: 42 | loaded = {"model": loaded} 43 | return loaded 44 | 45 | def _load_model(self, checkpoint): 46 | if checkpoint.get("matching_heuristics", False): 47 | self._convert_ndarray_to_tensor(checkpoint["model"]) 48 | # convert weights by name-matching heuristics 49 | model_state_dict = self.model.state_dict() 50 | align_and_update_state_dicts( 51 | model_state_dict, 52 | checkpoint["model"], 53 | c2_conversion=checkpoint.get("__author__", None) == "Caffe2", 54 | ) 55 | checkpoint["model"] = model_state_dict 56 | # for non-caffe2 models, use standard ways to load it 57 | super()._load_model(checkpoint) 58 | -------------------------------------------------------------------------------- /fsdet/config/__init__.py: -------------------------------------------------------------------------------- 1 | from .compat import downgrade_config, upgrade_config 2 | from .config import CfgNode, get_cfg, global_cfg, set_global_cfg 3 | 4 | __all__ = [ 5 | "CfgNode", 6 | "get_cfg", 7 | "global_cfg", 8 | "set_global_cfg", 9 | "downgrade_config", 10 | "upgrade_config", 11 | ] -------------------------------------------------------------------------------- /fsdet/config/config.py: -------------------------------------------------------------------------------- 1 | from fvcore.common.config import CfgNode as _CfgNode 2 | 3 | import logging 4 | 5 | 6 | class CfgNode(_CfgNode): 7 | """ 8 | The same as `fvcore.common.config.CfgNode`, but different in: 9 | 1. Use unsafe yaml loading by default. 10 | Note that this may lead to arbitrary code execution: you must not 11 | load a config file from untrusted sources before manually inspecting 12 | the content of the file. 13 | 2. Support config versioning. 14 | When attempting to merge an old config, it will convert the old config automatically. 15 | """ 16 | 17 | # Note that the default value of allow_unsafe is changed to True 18 | def merge_from_file( 19 | self, cfg_filename: str, allow_unsafe: bool = True 20 | ) -> None: 21 | loaded_cfg = _CfgNode.load_yaml_with_base( 22 | cfg_filename, allow_unsafe=allow_unsafe 23 | ) 24 | loaded_cfg = type(self)(loaded_cfg) 25 | 26 | # defaults.py needs to import CfgNode 27 | from .defaults import _CC as _C 28 | 29 | latest_ver = _C.VERSION 30 | assert ( 31 | latest_ver == self.VERSION 32 | ), "CfgNode.merge_from_file is only allowed on a config of latest version!" 33 | 34 | logger = logging.getLogger(__name__) 35 | 36 | loaded_ver = loaded_cfg.get("VERSION", None) 37 | if loaded_ver is None: 38 | from .compat import guess_version 39 | 40 | loaded_ver = guess_version(loaded_cfg, cfg_filename) 41 | assert ( 42 | loaded_ver <= self.VERSION 43 | ), "Cannot merge a v{} config into a v{} config.".format( 44 | loaded_ver, self.VERSION 45 | ) 46 | 47 | if loaded_ver == self.VERSION: 48 | self.merge_from_other_cfg(loaded_cfg) 49 | else: 50 | # compat.py needs to import CfgNode 51 | from .compat import downgrade_config, upgrade_config 52 | 53 | logger.warning( 54 | "Loading an old v{} config file '{}' by automatically upgrading to v{}. " 55 | "See docs/CHANGELOG.md for instructions to update your files.".format( 56 | loaded_ver, cfg_filename, self.VERSION 57 | ) 58 | ) 59 | # To convert, first obtain a full config at an old version 60 | old_self = downgrade_config(self, to_version=loaded_ver) 61 | old_self.merge_from_other_cfg(loaded_cfg) 62 | new_config = upgrade_config(old_self) 63 | self.clear() 64 | self.update(new_config) 65 | 66 | 67 | global_cfg = CfgNode() 68 | 69 | 70 | def get_cfg() -> CfgNode: 71 | """ 72 | Get a copy of the default config. 73 | Returns: 74 | a fsdet CfgNode instance. 75 | """ 76 | from .defaults import _C 77 | 78 | return _C.clone() 79 | 80 | 81 | def set_global_cfg(cfg: CfgNode) -> None: 82 | """ 83 | Let the global config point to the given cfg. 84 | Assume that the given "cfg" has the key "KEY", after calling 85 | `set_global_cfg(cfg)`, the key can be accessed by: 86 | .. code-block:: python 87 | from fsdet.config import global_cfg 88 | print(global_cfg.KEY) 89 | By using a hacky global config, you can access these configs anywhere, 90 | without having to pass the config object or the values deep into the code. 91 | This is a hacky feature introduced for quick prototyping / research exploration. 92 | """ 93 | global global_cfg 94 | global_cfg.clear() 95 | global_cfg.update(cfg) 96 | -------------------------------------------------------------------------------- /fsdet/config/defaults.py: -------------------------------------------------------------------------------- 1 | from detectron2.config import CfgNode as CN 2 | from detectron2.config.defaults import _C 3 | 4 | # adding additional default values built on top of the default values in detectron2 5 | 6 | _CC = _C 7 | 8 | # FREEZE Parameters 9 | _CC.MODEL.BACKBONE.FREEZE = False 10 | _CC.MODEL.PROPOSAL_GENERATOR.FREEZE = False 11 | _CC.MODEL.ROI_HEADS.FREEZE_FEAT = False 12 | 13 | # choose from "FastRCNNOutputLayers" and "CosineSimOutputLayers" 14 | _CC.MODEL.ROI_HEADS.OUTPUT_LAYER = "FastRCNNOutputLayers" 15 | # scale of cosine similarity (set to -1 for learnable scale) 16 | _CC.MODEL.ROI_HEADS.COSINE_SCALE = 20.0 17 | 18 | # Backward Compatible options. 19 | _CC.MUTE_HEADER = True 20 | 21 | # Number of data loading threads 22 | _C.DATALOADER.NUM_WORKERS = 0 -------------------------------------------------------------------------------- /fsdet/data/__init__.py: -------------------------------------------------------------------------------- 1 | from .builtin import register_all_coco, register_all_lvis, register_all_pascal_voc 2 | -------------------------------------------------------------------------------- /fsdet/data/meta_coco.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from fvcore.common.file_io import PathManager 3 | from pycocotools.coco import COCO 4 | 5 | import contextlib 6 | import io 7 | import os 8 | from detectron2.data import DatasetCatalog, MetadataCatalog 9 | from detectron2.structures import BoxMode 10 | 11 | """ 12 | This file contains functions to parse COCO-format annotations into dicts in "Detectron2 format". 13 | """ 14 | 15 | 16 | __all__ = ["register_meta_coco"] 17 | 18 | 19 | def load_coco_json(json_file, image_root, metadata, dataset_name): 20 | """ 21 | Load a json file with COCO's instances annotation format. 22 | Currently supports instance detection. 23 | Args: 24 | json_file (str): full path to the json file in COCO instances annotation format. 25 | image_root (str): the directory where the images in this json file exists. 26 | metadata: meta data associated with dataset_name 27 | dataset_name (str): the name of the dataset (e.g., coco_2017_train). 28 | If provided, this function will also put "thing_classes" into 29 | the metadata associated with this dataset. 30 | Returns: 31 | list[dict]: a list of dicts in Detectron2 standard format. (See 32 | `Using Custom Datasets `_ ) 33 | Notes: 34 | 1. This function does not read the image files. 35 | The results do not have the "image" field. 36 | """ 37 | is_shots = "shot" in dataset_name 38 | if is_shots: 39 | fileids = {} 40 | split_dir = os.path.join("datasets", "cocosplit") 41 | if "seed" in dataset_name: 42 | shot = dataset_name.split("_")[-2].split("shot")[0] 43 | seed = int(dataset_name.split("_seed")[-1]) 44 | split_dir = os.path.join(split_dir, "seed{}".format(seed)) 45 | else: 46 | shot = dataset_name.split("_")[-1].split("shot")[0] 47 | for idx, cls in enumerate(metadata["thing_classes"]): 48 | json_file = os.path.join( 49 | split_dir, "full_box_{}shot_{}_trainval.json".format(shot, cls) 50 | ) 51 | json_file = PathManager.get_local_path(json_file) 52 | with contextlib.redirect_stdout(io.StringIO()): 53 | coco_api = COCO(json_file) 54 | img_ids = sorted(list(coco_api.imgs.keys())) 55 | imgs = coco_api.loadImgs(img_ids) 56 | anns = [coco_api.imgToAnns[img_id] for img_id in img_ids] 57 | fileids[idx] = list(zip(imgs, anns)) 58 | else: 59 | json_file = PathManager.get_local_path(json_file) 60 | with contextlib.redirect_stdout(io.StringIO()): 61 | coco_api = COCO(json_file) 62 | # sort indices for reproducible results 63 | img_ids = sorted(list(coco_api.imgs.keys())) 64 | imgs = coco_api.loadImgs(img_ids) 65 | anns = [coco_api.imgToAnns[img_id] for img_id in img_ids] 66 | imgs_anns = list(zip(imgs, anns)) 67 | id_map = metadata["thing_dataset_id_to_contiguous_id"] 68 | 69 | dataset_dicts = [] 70 | ann_keys = ["iscrowd", "bbox", "category_id"] 71 | 72 | if is_shots: 73 | for _, fileids_ in fileids.items(): 74 | dicts = [] 75 | for (img_dict, anno_dict_list) in fileids_: 76 | for anno in anno_dict_list: 77 | record = {} 78 | record["file_name"] = os.path.join( 79 | image_root, img_dict["file_name"] 80 | ) 81 | record["height"] = img_dict["height"] 82 | record["width"] = img_dict["width"] 83 | image_id = record["image_id"] = img_dict["id"] 84 | 85 | assert anno["image_id"] == image_id 86 | assert anno.get("ignore", 0) == 0 87 | 88 | obj = {key: anno[key] for key in ann_keys if key in anno} 89 | 90 | obj["bbox_mode"] = BoxMode.XYWH_ABS 91 | obj["category_id"] = id_map[obj["category_id"]] 92 | record["annotations"] = [obj] 93 | dicts.append(record) 94 | if len(dicts) > int(shot): 95 | dicts = np.random.choice(dicts, int(shot), replace=False) 96 | dataset_dicts.extend(dicts) 97 | else: 98 | for (img_dict, anno_dict_list) in imgs_anns: 99 | record = {} 100 | record["file_name"] = os.path.join( 101 | image_root, img_dict["file_name"] 102 | ) 103 | record["height"] = img_dict["height"] 104 | record["width"] = img_dict["width"] 105 | image_id = record["image_id"] = img_dict["id"] 106 | 107 | objs = [] 108 | for anno in anno_dict_list: 109 | assert anno["image_id"] == image_id 110 | assert anno.get("ignore", 0) == 0 111 | 112 | obj = {key: anno[key] for key in ann_keys if key in anno} 113 | 114 | obj["bbox_mode"] = BoxMode.XYWH_ABS 115 | if obj["category_id"] in id_map: 116 | obj["category_id"] = id_map[obj["category_id"]] 117 | objs.append(obj) 118 | record["annotations"] = objs 119 | dataset_dicts.append(record) 120 | 121 | return dataset_dicts 122 | 123 | 124 | def register_meta_coco(name, metadata, imgdir, annofile): 125 | DatasetCatalog.register( 126 | name, 127 | lambda: load_coco_json(annofile, imgdir, metadata, name), 128 | ) 129 | 130 | if "_base" in name or "_novel" in name: 131 | split = "base" if "_base" in name else "novel" 132 | metadata["thing_dataset_id_to_contiguous_id"] = metadata[ 133 | "{}_dataset_id_to_contiguous_id".format(split) 134 | ] 135 | metadata["thing_classes"] = metadata["{}_classes".format(split)] 136 | 137 | MetadataCatalog.get(name).set( 138 | json_file=annofile, 139 | image_root=imgdir, 140 | evaluator_type="coco", 141 | dirname="datasets/coco", 142 | **metadata, 143 | ) -------------------------------------------------------------------------------- /fsdet/data/meta_lvis.py: -------------------------------------------------------------------------------- 1 | from fvcore.common.file_io import PathManager 2 | from fvcore.common.timer import Timer 3 | 4 | import logging 5 | import os 6 | from detectron2.config import global_cfg 7 | from detectron2.data import DatasetCatalog, MetadataCatalog 8 | from detectron2.structures import BoxMode 9 | 10 | from .lvis_v0_5_categories import LVIS_CATEGORIES_NOVEL_IDS 11 | 12 | """ 13 | This file contains functions to parse LVIS-format annotations into dicts in the 14 | "Detectron2 format". 15 | """ 16 | 17 | logger = logging.getLogger(__name__) 18 | 19 | __all__ = ["register_meta_lvis"] 20 | 21 | 22 | def load_filtered_lvis_json( 23 | json_file, image_root, metadata, dataset_name=None 24 | ): 25 | """ 26 | Load a json file in LVIS's annotation format. 27 | Args: 28 | json_file (str): full path to the LVIS json annotation file. 29 | image_root (str): the directory where the images in this json file exists. 30 | metadata: meta data associated with dataset_name 31 | dataset_name (str): the name of the dataset (e.g., "lvis_v0.5_train"). 32 | If provided, this function will put "thing_classes" into the metadata 33 | associated with this dataset. 34 | Returns: 35 | list[dict]: a list of dicts in Detectron2 standard format. (See 36 | `Using Custom Datasets `_ ) 37 | Notes: 38 | 1. This function does not read the image files. 39 | The results do not have the "image" field. 40 | """ 41 | from lvis import LVIS 42 | 43 | json_file = PathManager.get_local_path(json_file) 44 | 45 | timer = Timer() 46 | lvis_api = LVIS(json_file) 47 | if timer.seconds() > 1: 48 | logger.info( 49 | "Loading {} takes {:.2f} seconds.".format( 50 | json_file, timer.seconds() 51 | ) 52 | ) 53 | 54 | if dataset_name is not None and "train" in dataset_name: 55 | assert global_cfg.MODEL.ROI_HEADS.NUM_CLASSES == len( 56 | metadata["thing_classes"] 57 | ), "NUM_CLASSES should match number of categories: ALL=1230, NOVEL=454" 58 | 59 | # sort indices for reproducible results 60 | img_ids = sorted(list(lvis_api.imgs.keys())) 61 | imgs = lvis_api.load_imgs(img_ids) 62 | anns = [lvis_api.img_ann_map[img_id] for img_id in img_ids] 63 | 64 | # Sanity check that each annotation has a unique id 65 | ann_ids = [ann["id"] for anns_per_image in anns for ann in anns_per_image] 66 | assert len(set(ann_ids)) == len( 67 | ann_ids 68 | ), "Annotation ids in '{}' are not unique".format(json_file) 69 | 70 | imgs_anns = list(zip(imgs, anns)) 71 | 72 | logger.info( 73 | "Loaded {} images in the LVIS format from {}".format( 74 | len(imgs_anns), json_file 75 | ) 76 | ) 77 | 78 | dataset_dicts = [] 79 | 80 | for (img_dict, anno_dict_list) in imgs_anns: 81 | record = {} 82 | file_name = img_dict["file_name"] 83 | if img_dict["file_name"].startswith("COCO"): 84 | file_name = file_name[-16:] 85 | record["file_name"] = os.path.join(image_root, file_name) 86 | record["height"] = img_dict["height"] 87 | record["width"] = img_dict["width"] 88 | record["not_exhaustive_category_ids"] = img_dict.get( 89 | "not_exhaustive_category_ids", [] 90 | ) 91 | record["neg_category_ids"] = img_dict.get("neg_category_ids", []) 92 | image_id = record["image_id"] = img_dict["id"] 93 | 94 | objs = [] 95 | for anno in anno_dict_list: 96 | # Check that the image_id in this annotation is the same as 97 | # the image_id we're looking at. 98 | assert anno["image_id"] == image_id 99 | obj = {"bbox": anno["bbox"], "bbox_mode": BoxMode.XYWH_ABS} 100 | if global_cfg.MODEL.ROI_HEADS.NUM_CLASSES == 454: 101 | # Novel classes only 102 | if anno["category_id"] - 1 not in LVIS_CATEGORIES_NOVEL_IDS: 103 | continue 104 | obj["category_id"] = metadata["class_mapping"][ 105 | anno["category_id"] - 1 106 | ] 107 | else: 108 | # Convert 1-indexed to 0-indexed 109 | obj["category_id"] = anno["category_id"] - 1 110 | objs.append(obj) 111 | record["annotations"] = objs 112 | dataset_dicts.append(record) 113 | 114 | return dataset_dicts 115 | 116 | 117 | def register_meta_lvis(name, metadata, json_file, image_root): 118 | """ 119 | Register a dataset in LVIS's json annotation format for instance detection. 120 | Args: 121 | name (str): a name that identifies the dataset, e.g. "lvis_v0.5_train". 122 | metadata (dict): extra metadata associated with this dataset. 123 | It can be an empty dict. 124 | json_file (str): path to the json instance annotation file. 125 | image_root (str): directory which contains all the images. 126 | """ 127 | DatasetCatalog.register( 128 | name, 129 | lambda: load_filtered_lvis_json(json_file, image_root, metadata, name), 130 | ) 131 | 132 | MetadataCatalog.get(name).set( 133 | json_file=json_file, 134 | image_root=image_root, 135 | evaluator_type="lvis", 136 | **metadata, 137 | ) -------------------------------------------------------------------------------- /fsdet/data/meta_pascal_voc.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from fvcore.common.file_io import PathManager 3 | 4 | import os 5 | import xml.etree.ElementTree as ET 6 | from detectron2.data import DatasetCatalog, MetadataCatalog 7 | from detectron2.structures import BoxMode 8 | 9 | __all__ = ["register_meta_pascal_voc"] 10 | 11 | 12 | def load_filtered_voc_instances( 13 | name: str, dirname: str, split: str, classnames: str 14 | ): 15 | """ 16 | Load Pascal VOC detection annotations to Detectron2 format. 17 | Args: 18 | dirname: Contain "Annotations", "ImageSets", "JPEGImages" 19 | split (str): one of "train", "test", "val", "trainval" 20 | """ 21 | is_shots = "shot" in name 22 | if is_shots: 23 | fileids = {} 24 | split_dir = os.path.join("datasets", "vocsplit") 25 | if "seed" in name: 26 | shot = name.split("_")[-2].split("shot")[0] 27 | seed = int(name.split("_seed")[-1]) 28 | split_dir = os.path.join(split_dir, "seed{}".format(seed)) 29 | else: 30 | shot = name.split("_")[-1].split("shot")[0] 31 | for cls in classnames: 32 | with PathManager.open( 33 | os.path.join( 34 | split_dir, "box_{}shot_{}_train.txt".format(shot, cls) 35 | ) 36 | ) as f: 37 | fileids_ = np.loadtxt(f, dtype=np.str).tolist() 38 | if isinstance(fileids_, str): 39 | fileids_ = [fileids_] 40 | fileids_ = [ 41 | fid.split("/")[-1].split(".jpg")[0] for fid in fileids_ 42 | ] 43 | fileids[cls] = fileids_ 44 | else: 45 | with PathManager.open( 46 | os.path.join(dirname, "ImageSets", "Main", split + ".txt") 47 | ) as f: 48 | fileids = np.loadtxt(f, dtype=np.str) 49 | 50 | dicts = [] 51 | if is_shots: 52 | for cls, fileids_ in fileids.items(): 53 | dicts_ = [] 54 | for fileid in fileids_: 55 | year = "2012" if "_" in fileid else "2007" 56 | dirname = os.path.join("datasets", "VOC{}".format(year)) 57 | anno_file = os.path.join( 58 | dirname, "Annotations", fileid + ".xml" 59 | ) 60 | jpeg_file = os.path.join( 61 | dirname, "JPEGImages", fileid + ".jpg" 62 | ) 63 | 64 | tree = ET.parse(anno_file) 65 | 66 | for obj in tree.findall("object"): 67 | r = { 68 | "file_name": jpeg_file, 69 | "image_id": fileid, 70 | "height": int(tree.findall("./size/height")[0].text), 71 | "width": int(tree.findall("./size/width")[0].text), 72 | } 73 | cls_ = obj.find("name").text 74 | if cls != cls_: 75 | continue 76 | bbox = obj.find("bndbox") 77 | bbox = [ 78 | float(bbox.find(x).text) 79 | for x in ["xmin", "ymin", "xmax", "ymax"] 80 | ] 81 | bbox[0] -= 1.0 82 | bbox[1] -= 1.0 83 | 84 | instances = [ 85 | { 86 | "category_id": classnames.index(cls), 87 | "bbox": bbox, 88 | "bbox_mode": BoxMode.XYXY_ABS, 89 | } 90 | ] 91 | r["annotations"] = instances 92 | dicts_.append(r) 93 | if len(dicts_) > int(shot): 94 | dicts_ = np.random.choice(dicts_, int(shot), replace=False) 95 | dicts.extend(dicts_) 96 | else: 97 | for fileid in fileids: 98 | anno_file = os.path.join(dirname, "Annotations", fileid + ".xml") 99 | jpeg_file = os.path.join(dirname, "JPEGImages", fileid + ".jpg") 100 | 101 | tree = ET.parse(anno_file) 102 | 103 | r = { 104 | "file_name": jpeg_file, 105 | "image_id": fileid, 106 | "height": int(tree.findall("./size/height")[0].text), 107 | "width": int(tree.findall("./size/width")[0].text), 108 | } 109 | instances = [] 110 | 111 | for obj in tree.findall("object"): 112 | cls = obj.find("name").text 113 | if not (cls in classnames): 114 | continue 115 | bbox = obj.find("bndbox") 116 | bbox = [ 117 | float(bbox.find(x).text) 118 | for x in ["xmin", "ymin", "xmax", "ymax"] 119 | ] 120 | bbox[0] -= 1.0 121 | bbox[1] -= 1.0 122 | 123 | instances.append( 124 | { 125 | "category_id": classnames.index(cls), 126 | "bbox": bbox, 127 | "bbox_mode": BoxMode.XYXY_ABS, 128 | } 129 | ) 130 | r["annotations"] = instances 131 | dicts.append(r) 132 | return dicts 133 | 134 | 135 | def register_meta_pascal_voc( 136 | name, metadata, dirname, split, year, keepclasses, sid 137 | ): 138 | if keepclasses.startswith("base_novel"): 139 | thing_classes = metadata["thing_classes"][sid] 140 | elif keepclasses.startswith("base"): 141 | thing_classes = metadata["base_classes"][sid] 142 | elif keepclasses.startswith("novel"): 143 | thing_classes = metadata["novel_classes"][sid] 144 | 145 | DatasetCatalog.register( 146 | name, 147 | lambda: load_filtered_voc_instances( 148 | name, dirname, split, thing_classes 149 | ), 150 | ) 151 | 152 | MetadataCatalog.get(name).set( 153 | thing_classes=thing_classes, 154 | dirname=dirname, 155 | year=year, 156 | split=split, 157 | base_classes=metadata["base_classes"][sid], 158 | novel_classes=metadata["novel_classes"][sid], 159 | ) 160 | -------------------------------------------------------------------------------- /fsdet/engine/__init__.py: -------------------------------------------------------------------------------- 1 | from .defaults import DefaultPredictor, DefaultTrainer, default_argument_parser, default_setup 2 | from .hooks import * 3 | -------------------------------------------------------------------------------- /fsdet/engine/hooks.py: -------------------------------------------------------------------------------- 1 | import itertools 2 | import json 3 | import os 4 | import time 5 | import torch 6 | from fvcore.common.file_io import PathManager 7 | 8 | import detectron2.utils.comm as comm 9 | from detectron2.config import global_cfg 10 | from detectron2.engine.train_loop import HookBase 11 | from detectron2.evaluation.testing import flatten_results_dict 12 | 13 | __all__ = ["EvalHookFsdet"] 14 | 15 | 16 | class EvalHookFsdet(HookBase): 17 | """ 18 | Run an evaluation function periodically, and at the end of training. 19 | It is executed every ``eval_period`` iterations and after the last iteration. 20 | """ 21 | 22 | def __init__(self, eval_period, eval_function, cfg): 23 | """ 24 | Args: 25 | eval_period (int): the period to run `eval_function`. Set to 0 to 26 | not evaluate periodically (but still after the last iteration). 27 | eval_function (callable): a function which takes no arguments, and 28 | returns a nested dict of evaluation metrics. 29 | cfg: config 30 | Note: 31 | This hook must be enabled in all or none workers. 32 | If you would like only certain workers to perform evaluation, 33 | give other workers a no-op function (`eval_function=lambda: None`). 34 | """ 35 | self._period = eval_period 36 | self._func = eval_function 37 | self.cfg = cfg 38 | 39 | def _do_eval(self): 40 | results = self._func() 41 | 42 | if results: 43 | assert isinstance( 44 | results, dict 45 | ), "Eval function must return a dict. Got {} instead.".format(results) 46 | 47 | flattened_results = flatten_results_dict(results) 48 | for k, v in flattened_results.items(): 49 | try: 50 | v = float(v) 51 | except Exception as e: 52 | raise ValueError( 53 | "[EvalHook] eval_function should return a nested dict of float. " 54 | "Got '{}: {}' instead.".format(k, v) 55 | ) from e 56 | self.trainer.storage.put_scalars(**flattened_results, smoothing_hint=False) 57 | 58 | if comm.is_main_process() and results: 59 | # save evaluation results in json 60 | is_final = self.trainer.iter + 1 >= self.trainer.max_iter 61 | os.makedirs( 62 | os.path.join(self.cfg.OUTPUT_DIR, 'inference'), exist_ok=True) 63 | output_file = 'res_final.json' if is_final else \ 64 | 'iter_{:07d}.json'.format(self.trainer.iter) 65 | with PathManager.open(os.path.join(self.cfg.OUTPUT_DIR, 'inference', 66 | output_file), 'w') as fp: 67 | json.dump(results, fp) 68 | 69 | # Evaluation may take different time among workers. 70 | # A barrier make them start the next iteration together. 71 | comm.synchronize() 72 | 73 | def after_step(self): 74 | next_iter = self.trainer.iter + 1 75 | if self._period > 0 and next_iter % self._period == 0: 76 | self._do_eval() 77 | 78 | def after_train(self): 79 | # This condition is to prevent the eval from running after a failed training 80 | if self.trainer.iter + 1 >= self.trainer.max_iter: 81 | self._do_eval() 82 | # func is likely a closure that holds reference to the trainer 83 | # therefore we clean it to avoid circular reference in the end 84 | del self._func 85 | -------------------------------------------------------------------------------- /fsdet/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | from .coco_evaluation import COCOEvaluator 2 | from .evaluator import DatasetEvaluator, DatasetEvaluators, inference_context, inference_on_dataset 3 | from .lvis_evaluation import LVISEvaluator 4 | from .pascal_voc_evaluation import PascalVOCDetectionEvaluator 5 | from .testing import print_csv_format, verify_results 6 | 7 | __all__ = [k for k in globals().keys() if not k.startswith("_")] 8 | -------------------------------------------------------------------------------- /fsdet/evaluation/evaluator.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import logging 3 | import time 4 | from collections import OrderedDict 5 | from contextlib import contextmanager 6 | import torch 7 | 8 | from detectron2.utils.comm import is_main_process 9 | 10 | 11 | class DatasetEvaluator: 12 | """ 13 | Base class for a dataset evaluator. 14 | 15 | The function :func:`inference_on_dataset` runs the model over 16 | all samples in the dataset, and have a DatasetEvaluator to process the inputs/outputs. 17 | 18 | This class will accumulate information of the inputs/outputs (by :meth:`process`), 19 | and produce evaluation results in the end (by :meth:`evaluate`). 20 | """ 21 | 22 | def reset(self): 23 | """ 24 | Preparation for a new round of evaluation. 25 | Should be called before starting a round of evaluation. 26 | """ 27 | pass 28 | 29 | def process(self, input, output): 30 | """ 31 | Process an input/output pair. 32 | 33 | Args: 34 | input: the input that's used to call the model. 35 | output: the return value of `model(output)` 36 | """ 37 | pass 38 | 39 | def evaluate(self): 40 | """ 41 | Evaluate/summarize the performance, after processing all input/output pairs. 42 | 43 | Returns: 44 | dict: 45 | A new evaluator class can return a dict of arbitrary format 46 | as long as the user can process the results. 47 | In our train_net.py, we expect the following format: 48 | 49 | * key: the name of the task (e.g., bbox) 50 | * value: a dict of {metric name: score}, e.g.: {"AP50": 80} 51 | """ 52 | pass 53 | 54 | 55 | class DatasetEvaluators(DatasetEvaluator): 56 | def __init__(self, evaluators): 57 | assert len(evaluators) 58 | super().__init__() 59 | self._evaluators = evaluators 60 | 61 | def reset(self): 62 | for evaluator in self._evaluators: 63 | evaluator.reset() 64 | 65 | def process(self, input, output): 66 | for evaluator in self._evaluators: 67 | evaluator.process(input, output) 68 | 69 | def evaluate(self): 70 | results = OrderedDict() 71 | for evaluator in self._evaluators: 72 | result = evaluator.evaluate() 73 | if is_main_process(): 74 | for k, v in result.items(): 75 | assert ( 76 | k not in results 77 | ), "Different evaluators produce results with the same key {}".format(k) 78 | results[k] = v 79 | return results 80 | 81 | 82 | def inference_on_dataset(model, data_loader, evaluator): 83 | """ 84 | Run model on the data_loader and evaluate the metrics with evaluator. 85 | The model will be used in eval mode. 86 | 87 | Args: 88 | model (nn.Module): a module which accepts an object from 89 | `data_loader` and returns some outputs. It will be temporarily set to `eval` mode. 90 | 91 | If you wish to evaluate a model in `training` mode instead, you can 92 | wrap the given model and override its behavior of `.eval()` and `.train()`. 93 | data_loader: an iterable object with a length. 94 | The elements it generates will be the inputs to the model. 95 | evaluator (DatasetEvaluator): the evaluator to run. Use 96 | :class:`DatasetEvaluators([])` if you only want to benchmark, but 97 | don't want to do any evaluation. 98 | 99 | Returns: 100 | The return value of `evaluator.evaluate()` 101 | """ 102 | #num_devices = torch.distributed.get_world_size() if torch.distributed.is_initialized() else 1 103 | num_devices = 1 104 | logger = logging.getLogger(__name__) 105 | logger.info("Start inference on {} images".format(len(data_loader))) 106 | 107 | total = len(data_loader) # inference data loader must have a fixed length 108 | evaluator.reset() 109 | 110 | logging_interval = 50 111 | num_warmup = min(5, logging_interval - 1, total - 1) 112 | start_time = time.time() 113 | total_compute_time = 0 114 | with inference_context(model), torch.no_grad(): 115 | for idx, inputs in enumerate(data_loader): 116 | if idx == num_warmup: 117 | start_time = time.time() 118 | total_compute_time = 0 119 | 120 | start_compute_time = time.time() 121 | outputs = model(inputs) 122 | torch.cuda.synchronize() 123 | total_compute_time += time.time() - start_compute_time 124 | evaluator.process(inputs, outputs) 125 | 126 | if (idx + 1) % logging_interval == 0: 127 | duration = time.time() - start_time 128 | seconds_per_img = duration / (idx + 1 - num_warmup) 129 | eta = datetime.timedelta( 130 | seconds=int(seconds_per_img * (total - num_warmup) - duration) 131 | ) 132 | logger.info( 133 | "Inference done {}/{}. {:.4f} s / img. ETA={}".format( 134 | idx + 1, total, seconds_per_img, str(eta) 135 | ) 136 | ) 137 | 138 | # Measure the time only for this worker (before the synchronization barrier) 139 | total_time = int(time.time() - start_time) 140 | total_time_str = str(datetime.timedelta(seconds=total_time)) 141 | # NOTE this format is parsed by grep 142 | logger.info( 143 | "Total inference time: {} ({:.6f} s / img per device, on {} devices)".format( 144 | total_time_str, total_time / (total - num_warmup), num_devices 145 | ) 146 | ) 147 | total_compute_time_str = str(datetime.timedelta(seconds=int(total_compute_time))) 148 | logger.info( 149 | "Total inference pure compute time: {} ({:.6f} s / img per device, on {} devices)".format( 150 | total_compute_time_str, total_compute_time / (total - num_warmup), num_devices 151 | ) 152 | ) 153 | 154 | results = evaluator.evaluate() 155 | # An evaluator may return None when not in main process. 156 | # Replace it by an empty dict instead to make it easier for downstream code to handle 157 | if results is None: 158 | results = {} 159 | return results 160 | 161 | 162 | @contextmanager 163 | def inference_context(model): 164 | """ 165 | A context where the model is temporarily changed to eval mode, 166 | and restored to previous mode afterwards. 167 | 168 | Args: 169 | model: a torch Module 170 | """ 171 | training_mode = model.training 172 | model.eval() 173 | yield 174 | model.train(training_mode) 175 | -------------------------------------------------------------------------------- /fsdet/evaluation/lvis_evaluation.py: -------------------------------------------------------------------------------- 1 | import copy 2 | import itertools 3 | import json 4 | import logging 5 | import os 6 | from collections import OrderedDict 7 | import torch 8 | from fvcore.common.file_io import PathManager 9 | 10 | import detectron2.utils.comm as comm 11 | from detectron2.data import MetadataCatalog 12 | from detectron2.utils.logger import create_small_table 13 | 14 | from fsdet.evaluation.coco_evaluation import instances_to_coco_json 15 | from fsdet.evaluation.evaluator import DatasetEvaluator 16 | 17 | 18 | class LVISEvaluator(DatasetEvaluator): 19 | """ 20 | Evaluate instance detection outputs using LVIS's metrics and evaluation API. 21 | """ 22 | 23 | def __init__(self, dataset_name, cfg, distributed, output_dir=None): 24 | """ 25 | Args: 26 | dataset_name (str): name of the dataset to be evaluated. 27 | It must have the following corresponding metadata: 28 | "json_file": the path to the LVIS format annotation 29 | cfg (CfgNode): config instance 30 | distributed (True): if True, will collect results from all ranks for evaluation. 31 | Otherwise, will evaluate the results in the current process. 32 | output_dir (str): optional, an output directory to dump results. 33 | """ 34 | from lvis import LVIS 35 | 36 | self._distributed = distributed 37 | self._output_dir = output_dir 38 | 39 | self._cpu_device = torch.device("cpu") 40 | self._logger = logging.getLogger(__name__) 41 | 42 | self._metadata = MetadataCatalog.get(dataset_name) 43 | json_file = PathManager.get_local_path(self._metadata.json_file) 44 | self._lvis_api = LVIS(json_file) 45 | # Test set json files do not contain annotations (evaluation must be 46 | # performed using the LVIS evaluation server). 47 | self._do_evaluation = len(self._lvis_api.get_ann_ids()) > 0 48 | 49 | def reset(self): 50 | self._predictions = [] 51 | self._lvis_results = [] 52 | 53 | def process(self, inputs, outputs): 54 | """ 55 | Args: 56 | inputs: the inputs to a LVIS model (e.g., GeneralizedRCNN). 57 | It is a list of dict. Each dict corresponds to an image and 58 | contains keys like "height", "width", "file_name", "image_id". 59 | outputs: the outputs of a LVIS model. It is a list of dicts with key 60 | "instances" that contains :class:`Instances`. 61 | """ 62 | for input, output in zip(inputs, outputs): 63 | prediction = {"image_id": input["image_id"]} 64 | 65 | if "instances" in output: 66 | instances = output["instances"].to(self._cpu_device) 67 | prediction["instances"] = instances_to_coco_json( 68 | instances, input["image_id"]) 69 | self._predictions.append(prediction) 70 | 71 | def evaluate(self): 72 | if self._distributed: 73 | comm.synchronize() 74 | self._predictions = comm.gather(self._predictions, dst=0) 75 | self._predictions = list(itertools.chain(*self._predictions)) 76 | 77 | if not comm.is_main_process(): 78 | return 79 | 80 | if len(self._predictions) == 0: 81 | self._logger.warning( 82 | "[LVISEvaluator] Did not receive valid predictions.") 83 | return {} 84 | 85 | if self._output_dir: 86 | PathManager.mkdirs(self._output_dir) 87 | file_path = os.path.join(self._output_dir, "instances_predictions.pth") 88 | with PathManager.open(file_path, "wb") as f: 89 | torch.save(self._predictions, f) 90 | 91 | self._results = OrderedDict() 92 | if "instances" in self._predictions[0]: 93 | self._eval_predictions() 94 | # Copy so the caller can do whatever with results 95 | return copy.deepcopy(self._results) 96 | 97 | def _eval_predictions(self): 98 | """ 99 | Evaluate self._predictions on the instance detection task. 100 | Fill self._results with the metrics of the instance detection task. 101 | """ 102 | self._logger.info("Preparing results in the LVIS format ...") 103 | self._lvis_results = list( 104 | itertools.chain(*[x["instances"] for x in self._predictions])) 105 | 106 | # unmap the category ids for LVIS 107 | if hasattr(self._metadata, "class_mapping"): 108 | # using reverse mapping 109 | reverse_id_mapping = { 110 | v: k for k, v in self._metadata.class_mapping.items() 111 | } 112 | for result in self._lvis_results: 113 | result["category_id"] = reverse_id_mapping[result["category_id"]] + 1 114 | else: 115 | # from 0-indexed to 1-indexed 116 | for result in self._lvis_results: 117 | result["category_id"] += 1 118 | 119 | if self._output_dir: 120 | file_path = os.path.join( 121 | self._output_dir, "lvis_instances_results.json") 122 | self._logger.info("Saving results to {}".format(file_path)) 123 | with PathManager.open(file_path, "w") as f: 124 | f.write(json.dumps(self._lvis_results)) 125 | f.flush() 126 | 127 | if not self._do_evaluation: 128 | self._logger.info("Annotations are not available for evaluation.") 129 | return 130 | 131 | self._logger.info("Evaluating predictions ...") 132 | res = _evaluate_predictions_on_lvis( 133 | self._lvis_api, self._lvis_results, "bbox", 134 | class_names=self._metadata.get("thing_classes"), 135 | ) 136 | self._results["bbox"] = res 137 | 138 | 139 | def _evaluate_predictions_on_lvis( 140 | lvis_gt, lvis_results, iou_type, class_names=None): 141 | """ 142 | Args: 143 | iou_type (str): 144 | class_names (None or list[str]): if provided, will use it to predict 145 | per-category AP. 146 | 147 | Returns: 148 | a dict of {metric name: score} 149 | """ 150 | metrics = ["AP", "AP50", "AP75", "APs", "APm", "APl", "APr", "APc", "APf"] 151 | 152 | logger = logging.getLogger(__name__) 153 | 154 | if len(lvis_results) == 0: # TODO: check if needed 155 | logger.warn("No predictions from the model! Set scores to -1") 156 | return {metric: -1 for metric in metrics} 157 | 158 | from lvis import LVISEval, LVISResults 159 | 160 | lvis_results = LVISResults(lvis_gt, lvis_results) 161 | lvis_eval = LVISEval(lvis_gt, lvis_results, iou_type) 162 | lvis_eval.run() 163 | lvis_eval.print_results() 164 | 165 | # Pull the standard metrics from the LVIS results 166 | results = lvis_eval.get_results() 167 | results = {metric: float(results[metric] * 100) for metric in metrics} 168 | logger.info( 169 | "Evaluation results for {}: \n".format(iou_type) + \ 170 | create_small_table(results) 171 | ) 172 | return results 173 | -------------------------------------------------------------------------------- /fsdet/evaluation/testing.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import numpy as np 3 | import pprint 4 | import sys 5 | from collections import Mapping, OrderedDict 6 | 7 | 8 | def print_csv_format(results): 9 | """ 10 | Print main metrics in a format similar to Detectron, 11 | so that they are easy to copypaste into a spreadsheet. 12 | 13 | Args: 14 | results (OrderedDict[dict]): task_name -> {metric -> score} 15 | """ 16 | assert isinstance(results, OrderedDict), results # unordered results cannot be properly printed 17 | logger = logging.getLogger(__name__) 18 | for task, res in results.items(): 19 | # Don't print "AP-category" metrics since they are usually not tracked. 20 | important_res = [(k, v) for k, v in res.items() if "-" not in k] 21 | logger.info("copypaste: Task: {}".format(task)) 22 | logger.info("copypaste: " + ",".join([k[0] for k in important_res])) 23 | logger.info("copypaste: " + ",".join(["{0:.4f}".format(k[1]) for k in important_res])) 24 | 25 | 26 | def verify_results(cfg, results): 27 | """ 28 | Args: 29 | results (OrderedDict[dict]): task_name -> {metric -> score} 30 | 31 | Returns: 32 | bool: whether the verification succeeds or not 33 | """ 34 | expected_results = cfg.TEST.EXPECTED_RESULTS 35 | if not len(expected_results): 36 | return True 37 | 38 | ok = True 39 | for task, metric, expected, tolerance in expected_results: 40 | actual = results[task][metric] 41 | if not np.isfinite(actual): 42 | ok = False 43 | diff = abs(actual - expected) 44 | if diff > tolerance: 45 | ok = False 46 | 47 | logger = logging.getLogger(__name__) 48 | if not ok: 49 | logger.error("Result verification failed!") 50 | logger.error("Expected Results: " + str(expected_results)) 51 | logger.error("Actual Results: " + pprint.pformat(results)) 52 | 53 | sys.exit(1) 54 | else: 55 | logger.info("Results verification passed.") 56 | return ok 57 | 58 | 59 | def flatten_results_dict(results): 60 | """ 61 | Expand a hierarchical dict of scalars into a flat dict of scalars. 62 | If results[k1][k2][k3] = v, the returned dict will have the entry 63 | {"k1/k2/k3": v}. 64 | 65 | Args: 66 | results (dict): 67 | """ 68 | r = {} 69 | for k, v in results.items(): 70 | if isinstance(v, Mapping): 71 | v = flatten_results_dict(v) 72 | for kk, vv in v.items(): 73 | r[k + "/" + kk] = vv 74 | else: 75 | r[k] = v 76 | return r 77 | -------------------------------------------------------------------------------- /fsdet/model_zoo/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Model Zoo API for FsDet: a collection of functions to create common model architectures and 3 | optionally load pre-trained weights as released in 4 | `MODEL_ZOO.md `_. 5 | """ 6 | from .model_zoo import get, get_checkpoint_url, get_config_file 7 | 8 | __all__ = ["get_checkpoint_url", "get", "get_config_file"] 9 | -------------------------------------------------------------------------------- /fsdet/modeling/__init__.py: -------------------------------------------------------------------------------- 1 | from .meta_arch import META_ARCH_REGISTRY, GeneralizedRCNN, ProposalNetwork, build_model 2 | from .roi_heads import ( 3 | ROI_BOX_HEAD_REGISTRY, ROI_HEADS_REGISTRY, ROIHeads, StandardROIHeads, build_box_head, 4 | build_roi_heads) 5 | -------------------------------------------------------------------------------- /fsdet/modeling/meta_arch/__init__.py: -------------------------------------------------------------------------------- 1 | from .build import META_ARCH_REGISTRY, build_model # isort:skip 2 | 3 | # import all the meta_arch, so they will be registered 4 | from .rcnn import GeneralizedRCNN, ProposalNetwork 5 | -------------------------------------------------------------------------------- /fsdet/modeling/meta_arch/build.py: -------------------------------------------------------------------------------- 1 | from detectron2.utils.registry import Registry 2 | 3 | META_ARCH_REGISTRY = Registry("META_ARCH") # noqa F401 isort:skip 4 | META_ARCH_REGISTRY.__doc__ = """ 5 | Registry for meta-architectures, i.e. the whole model. 6 | 7 | The registered object will be called with `obj(cfg)` 8 | and expected to return a `nn.Module` object. 9 | """ 10 | 11 | 12 | def build_model(cfg): 13 | """ 14 | Built the whole model, defined by `cfg.MODEL.META_ARCHITECTURE`. 15 | """ 16 | meta_arch = cfg.MODEL.META_ARCHITECTURE 17 | return META_ARCH_REGISTRY.get(meta_arch)(cfg) 18 | -------------------------------------------------------------------------------- /fsdet/modeling/roi_heads/__init__.py: -------------------------------------------------------------------------------- 1 | from .box_head import ROI_BOX_HEAD_REGISTRY, build_box_head 2 | from .roi_heads import ( 3 | ROI_HEADS_REGISTRY, ROIHeads, StandardROIHeads, build_roi_heads, select_foreground_proposals) 4 | -------------------------------------------------------------------------------- /fsdet/modeling/roi_heads/box_head.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import fvcore.nn.weight_init as weight_init 3 | import torch 4 | from torch import nn 5 | from torch.nn import functional as F 6 | 7 | from detectron2.layers import Conv2d, ShapeSpec, get_norm 8 | from detectron2.utils.registry import Registry 9 | 10 | ROI_BOX_HEAD_REGISTRY = Registry("ROI_BOX_HEAD") 11 | ROI_BOX_HEAD_REGISTRY.__doc__ = """ 12 | Registry for box heads, which make box predictions from per-region features. 13 | 14 | The registered object will be called with `obj(cfg, input_shape)`. 15 | """ 16 | 17 | 18 | @ROI_BOX_HEAD_REGISTRY.register() 19 | class FastRCNNConvFCHead(nn.Module): 20 | """ 21 | A head with several 3x3 conv layers (each followed by norm & relu) and 22 | several fc layers (each followed by relu). 23 | """ 24 | 25 | def __init__(self, cfg, input_shape: ShapeSpec): 26 | """ 27 | The following attributes are parsed from config: 28 | num_conv, num_fc: the number of conv/fc layers 29 | conv_dim/fc_dim: the dimension of the conv/fc layers 30 | norm: normalization for the conv layers 31 | """ 32 | super().__init__() 33 | 34 | # fmt: off 35 | num_conv = cfg.MODEL.ROI_BOX_HEAD.NUM_CONV 36 | conv_dim = cfg.MODEL.ROI_BOX_HEAD.CONV_DIM 37 | num_fc = cfg.MODEL.ROI_BOX_HEAD.NUM_FC 38 | fc_dim = cfg.MODEL.ROI_BOX_HEAD.FC_DIM 39 | norm = cfg.MODEL.ROI_BOX_HEAD.NORM 40 | # fmt: on 41 | assert num_conv + num_fc > 0 42 | 43 | self._output_size = ( 44 | input_shape.channels, 45 | input_shape.height, 46 | input_shape.width, 47 | ) 48 | 49 | self.conv_norm_relus = [] 50 | for k in range(num_conv): 51 | conv = Conv2d( 52 | self._output_size[0], 53 | conv_dim, 54 | kernel_size=3, 55 | padding=1, 56 | bias=not norm, 57 | norm=get_norm(norm, conv_dim), 58 | activation=F.relu, 59 | ) 60 | self.add_module("conv{}".format(k + 1), conv) 61 | self.conv_norm_relus.append(conv) 62 | self._output_size = ( 63 | conv_dim, 64 | self._output_size[1], 65 | self._output_size[2], 66 | ) 67 | 68 | self.fcs = [] 69 | for k in range(num_fc): 70 | fc = nn.Linear(np.prod(self._output_size), fc_dim) 71 | self.add_module("fc{}".format(k + 1), fc) 72 | self.fcs.append(fc) 73 | self._output_size = fc_dim 74 | 75 | for layer in self.conv_norm_relus: 76 | weight_init.c2_msra_fill(layer) 77 | for layer in self.fcs: 78 | weight_init.c2_xavier_fill(layer) 79 | 80 | def forward(self, x): 81 | for layer in self.conv_norm_relus: 82 | x = layer(x) 83 | if len(self.fcs): 84 | if x.dim() > 2: 85 | x = torch.flatten(x, start_dim=1) 86 | for layer in self.fcs: 87 | x = F.relu(layer(x)) 88 | return x 89 | 90 | @property 91 | def output_size(self): 92 | return self._output_size 93 | 94 | 95 | def build_box_head(cfg, input_shape): 96 | """ 97 | Build a box head defined by `cfg.MODEL.ROI_BOX_HEAD.NAME`. 98 | """ 99 | name = cfg.MODEL.ROI_BOX_HEAD.NAME 100 | return ROI_BOX_HEAD_REGISTRY.get(name)(cfg, input_shape) 101 | -------------------------------------------------------------------------------- /img_show.py: -------------------------------------------------------------------------------- 1 | # from __future__ import print_function 2 | # from pycocotools.coco import COCO 3 | # import os, sys, zipfile 4 | # import urllib.request 5 | # import shutil 6 | # import numpy as np 7 | # import skimage.io as io 8 | # import matplotlib.pyplot as plt 9 | # import pylab 10 | # import json 11 | # json_file='dataset.json' # 12 | # # Object Instance 类型的标注 13 | # # person_keypoints_val2017.json 14 | # # Object Keypoint 类型的标注格式 15 | # # captions_val2017.json 16 | # # Image Caption的标注格式 17 | # data=json.load(open(json_file,'r')) 18 | # data_2={} 19 | # data_2['info']=data['info'] 20 | # data_2['licenses']=data['licenses'] 21 | # data_2['images']=[data['images'][0]] # 只提取第一张图片 22 | # data_2['categories']=data['categories'] 23 | # annotation=[] # 通过imgID 找到其所有对象 24 | # imgID=data_2['images'][0]['id'] 25 | # for ann in data['annotations']: 26 | # if ann['image_id']==imgID: 27 | # annotation.append(ann) 28 | # data_2['annotations']=annotation # 保存到新的JSON文件,便于查看数据特点 29 | # json.dump(data_2,open('dataset_mini.json','w'),indent=4) # indent=4 更加美观显示 30 | 31 | #from __future__ import print_function 32 | from pycocotools.coco import COCO 33 | import os, sys, zipfile 34 | import urllib.request 35 | import shutil 36 | import numpy as np 37 | import skimage.io as io 38 | import matplotlib 39 | matplotlib.use('TkAgg') 40 | import matplotlib.pyplot as plt 41 | import pylab 42 | dataDir = 'datasets/jiaonang/base/test' 43 | annFile='datasets/jiaonang/base/test.json' 44 | pylab.rcParams['figure.figsize'] = (8.0, 10.0) 45 | 46 | 47 | for i in range(10): 48 | coco=COCO(annFile) # display COCO categories and supercategories 49 | cats = coco.loadCats(coco.getCatIds()) 50 | nms=[cat['name'] for cat in cats] 51 | print('COCO categories: \n{}\n'.format(' '.join(nms))) 52 | # nms = set([cat['supercategory'] for cat in cats]) 53 | # print('COCO supercategories: \n{}'.format(' '.join(nms))) 54 | # imgIds = coco.getImgIds(imgIds = [324158]) 55 | imgIds = coco.getImgIds() 56 | img = coco.loadImgs(imgIds[i])[0] 57 | I = io.imread('%s/%s'%(dataDir,img['file_name'])) 58 | catIds=[] 59 | for ann in coco.dataset['annotations']: 60 | if ann['image_id']==imgIds[i]: 61 | catIds.append(ann['category_id']) 62 | plt.imshow(I); 63 | plt.axis('off') 64 | annIds = coco.getAnnIds(imgIds=img['id'], catIds=catIds, iscrowd=None) 65 | anns = coco.loadAnns(annIds) 66 | print(anns) 67 | coco.showAnns(anns) 68 | plt.imshow(I); plt.axis('off'); plt.show() 69 | plt.close() 70 | 71 | #加载instances mask: 72 | 73 | # coco = COCO("dataset.json") 74 | # 75 | # img_ids = coco.getImgIds() 76 | # print(len(img_ids)) 77 | # cat_ids = [] 78 | # for ann in coco.dataset["annotations"]: 79 | # if ann["image_id"] == img_ids[0]: 80 | # cat_ids.append(ann["category_id"]) 81 | # ann_ids = coco.getAnnIds(imgIds=img_ids[0], catIds = cat_ids) 82 | # ann_ids2 = coco.getAnnIds(imgIds=img_ids[0], catIds = cat_ids) 83 | # plt.imshow(I) 84 | # print(ann_ids) 85 | # print(ann_ids2) 86 | # anns = coco.loadAnns(ann_ids) 87 | # coco.showAnns(anns) 88 | # plt.imshow(I) 89 | # plt.show() -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | termcolor 2 | numpy 3 | tqdm 4 | matplotlib 5 | termcolor 6 | yacs 7 | tabulate 8 | cloudpickle 9 | Pillow 10 | imagesize 11 | tensorboard 12 | opencv-python 13 | lvis -------------------------------------------------------------------------------- /tools/aggregate_seeds.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | 4 | import argparse 5 | import json 6 | import math 7 | import os 8 | 9 | 10 | def parse_args(): 11 | parser = argparse.ArgumentParser() 12 | parser.add_argument('--shots', type=int, default=1, 13 | help='Shots to aggregate over') 14 | parser.add_argument('--seeds', type=int, default=30, 15 | help='Seeds to aggregate over') 16 | # Model 17 | parser.add_argument('--fc', action='store_true', 18 | help='Model uses FC instead of cosine') 19 | parser.add_argument('--unfreeze', action='store_true', 20 | help='Unfreeze feature extractor') 21 | parser.add_argument('--suffix', type=str, default='', help='Suffix of path') 22 | # Output arguments 23 | parser.add_argument('--print', action='store_true', help='Clean output') 24 | parser.add_argument('--plot', action='store_true', help='Plot results') 25 | parser.add_argument('--save-dir', type=str, default='.', 26 | help='Save dir for generated plots') 27 | # PASCAL arguments 28 | parser.add_argument('--split', type=int, default=1, help='Data split') 29 | # COCO arguments 30 | parser.add_argument('--coco', action='store_true', help='Use COCO dataset') 31 | 32 | args = parser.parse_args() 33 | return args 34 | 35 | 36 | def main(args): 37 | metrics = {} 38 | num_ckpts = 0 39 | dataset = 'coco' if args.coco else 'voc' 40 | if args.fc: 41 | fc = '_fc' 42 | else: 43 | fc = '_normalized' if not args.coco else '' 44 | if args.unfreeze: 45 | unfreeze = '_unfreeze' 46 | else: 47 | unfreeze = '_randnovel' if not args.coco else '' 48 | for i in range(args.seeds): 49 | seed = 'seed{}/'.format(i) if i != 0 else '' 50 | prefix = 'checkpoints/{}/faster_rcnn/{}'.format(dataset, seed) 51 | prefix += 'faster_rcnn_R_101_FPN_ft{}_all'.format(fc) 52 | if args.coco: 53 | ckpt = prefix + '_{}shot{}'.format(args.shots, unfreeze) 54 | else: 55 | ckpt = prefix + '{}_{}shot{}{}'.format( 56 | args.split, args.shots, unfreeze, args.suffix) 57 | if os.path.exists(ckpt): 58 | if os.path.exists(os.path.join(ckpt, 'inference/all_res.json')): 59 | ckpt_ = os.path.join(ckpt, 'inference/all_res.json') 60 | res = json.load(open(ckpt_, 'r')) 61 | res = res[os.path.join(ckpt, 'model_final.pth')]['bbox'] 62 | elif os.path.exists(os.path.join(ckpt, 'inference/res_final.json')): 63 | ckpt = os.path.join(ckpt, 'inference/res_final.json') 64 | res = json.load(open(ckpt, 'r'))['bbox'] 65 | else: 66 | print('Missing: {}'.format(ckpt)) 67 | continue 68 | 69 | for metric in res: 70 | if metric in metrics: 71 | metrics[metric].append(res[metric]) 72 | else: 73 | metrics[metric] = [res[metric]] 74 | num_ckpts += 1 75 | else: 76 | print('Missing: {}'.format(ckpt)) 77 | print('Num ckpts: {}'.format(num_ckpts)) 78 | print('') 79 | 80 | # Output results 81 | if args.print: 82 | # Clean output for copy and pasting 83 | out_str = '' 84 | for metric in metrics: 85 | out_str += '{0:.1f} '.format(np.mean(metrics[metric])) 86 | print(out_str) 87 | out_str = '' 88 | for metric in metrics: 89 | out_str += '{0:.1f} '.format( 90 | 1.96*np.std(metrics[metric]) / math.sqrt(len(metrics[metric])) 91 | ) 92 | print(out_str) 93 | out_str = '' 94 | for metric in metrics: 95 | out_str += '{0:.1f} '.format(np.std(metrics[metric])) 96 | print(out_str) 97 | out_str = '' 98 | for metric in metrics: 99 | out_str += '{0:.1f} '.format(np.percentile(metrics[metric], 25)) 100 | print(out_str) 101 | out_str = '' 102 | for metric in metrics: 103 | out_str += '{0:.1f} '.format(np.percentile(metrics[metric], 50)) 104 | print(out_str) 105 | out_str = '' 106 | for metric in metrics: 107 | out_str += '{0:.1f} '.format(np.percentile(metrics[metric], 75)) 108 | print(out_str) 109 | else: 110 | # Verbose output 111 | for metric in metrics: 112 | print(metric) 113 | print('Mean \t {0:.4f}'.format(np.mean(metrics[metric]))) 114 | print('Std \t {0:.4f}'.format(np.std(metrics[metric]))) 115 | print('Q1 \t {0:.4f}'.format(np.percentile(metrics[metric], 25))) 116 | print('Median \t {0:.4f}'.format(np.percentile(metrics[metric], 50))) 117 | print('Q3 \t {0:.4f}'.format(np.percentile(metrics[metric], 75))) 118 | print('') 119 | 120 | # Plot results 121 | if args.plot: 122 | os.makedirs(args.save_dir, exist_ok=True) 123 | 124 | for met in ['avg', 'stdev', 'ci']: 125 | for metric, c in zip(['nAP', 'nAP50', 'nAP75'], 126 | ['bo-', 'ro-', 'go-']): 127 | if met == 'avg': 128 | res = [np.mean(metrics[metric][:i+1]) \ 129 | for i in range(len(metrics[metric]))] 130 | elif met == 'stdev': 131 | res = [np.std(metrics[metric][:i]) \ 132 | for i in range(1, len(metrics[metric])+1)] 133 | elif met == 'ci': 134 | res = [1.96*np.std(metrics[metric][:i+1]) / \ 135 | math.sqrt(len(metrics[metric][:i+1])) \ 136 | for i in range(len(metrics[metric]))] 137 | plt.plot(range(1, len(metrics[metric])+1), res, c) 138 | plt.legend(['nAP', 'nAP50', 'nAP75']) 139 | plt.title('Split {}, {} Shots - Cumulative {} over {} Seeds'.format( 140 | args.split, args.shots, met.upper(), args.seeds)) 141 | plt.xlabel('Number of seeds') 142 | plt.ylabel('Cumulative {}'.format(met.upper())) 143 | plt.savefig(os.path.join( 144 | args.save_dir, 145 | 'split{}_{}shots_{}_vs_{}seeds.png'.format( 146 | args.split, args.shots, met, args.seeds), 147 | )) 148 | plt.clf() 149 | 150 | 151 | if __name__ == '__main__': 152 | args = parse_args() 153 | main(args) 154 | -------------------------------------------------------------------------------- /tools/train_net.py: -------------------------------------------------------------------------------- 1 | """ 2 | Detection Training Script. 3 | 4 | This scripts reads a given config file and runs the training or evaluation. 5 | It is an entry point that is made to train standard models in FsDet. 6 | 7 | In order to let one script support training of many models, 8 | this script contains logic that are specific to these built-in models and 9 | therefore may not be suitable for your own project. 10 | For example, your research project perhaps only needs a single "evaluator". 11 | 12 | Therefore, we recommend you to use FsDet as an library and take 13 | this file as an example of how to use the library. 14 | You may want to write your own script with your datasets and other customizations. 15 | """ 16 | 17 | from fsdet.config import get_cfg, set_global_cfg 18 | from fsdet.engine import DefaultTrainer, default_argument_parser, default_setup 19 | 20 | import detectron2.utils.comm as comm 21 | import os 22 | from detectron2.checkpoint import DetectionCheckpointer 23 | from detectron2.data import MetadataCatalog 24 | from detectron2.engine import launch 25 | from fsdet.evaluation import ( 26 | COCOEvaluator, DatasetEvaluators, LVISEvaluator, PascalVOCDetectionEvaluator, verify_results) 27 | 28 | 29 | class Trainer(DefaultTrainer): 30 | """ 31 | We use the "DefaultTrainer" which contains a number pre-defined logic for 32 | standard training workflow. They may not work for you, especially if you 33 | are working on a new research project. In that case you can use the cleaner 34 | "SimpleTrainer", or write your own training loop. 35 | """ 36 | 37 | @classmethod 38 | def build_evaluator(cls, cfg, dataset_name, output_folder=None): 39 | """ 40 | Create evaluator(s) for a given dataset. 41 | This uses the special metadata "evaluator_type" associated with each builtin dataset. 42 | For your own dataset, you can simply create an evaluator manually in your 43 | script and do not have to worry about the hacky if-else logic here. 44 | """ 45 | if output_folder is None: 46 | output_folder = os.path.join(cfg.OUTPUT_DIR, "inference") 47 | evaluator_list = [] 48 | evaluator_type = MetadataCatalog.get(dataset_name).evaluator_type 49 | if evaluator_type == "coco": 50 | evaluator_list.append( 51 | COCOEvaluator(dataset_name, cfg, True, output_folder) 52 | ) 53 | if evaluator_type == "pascal_voc": 54 | return PascalVOCDetectionEvaluator(dataset_name) 55 | if evaluator_type == "lvis": 56 | return LVISEvaluator(dataset_name, cfg, True, output_folder) 57 | if len(evaluator_list) == 0: 58 | raise NotImplementedError( 59 | "no Evaluator for the dataset {} with the type {}".format( 60 | dataset_name, evaluator_type 61 | ) 62 | ) 63 | if len(evaluator_list) == 1: 64 | return evaluator_list[0] 65 | return DatasetEvaluators(evaluator_list) 66 | 67 | 68 | def setup(args): 69 | """ 70 | Create configs and perform basic setups. 71 | """ 72 | cfg = get_cfg() 73 | cfg.merge_from_file(args.config_file) 74 | if args.opts: 75 | cfg.merge_from_list(args.opts) 76 | cfg.freeze() 77 | set_global_cfg(cfg) 78 | default_setup(cfg, args) 79 | return cfg 80 | 81 | 82 | def main(args): 83 | cfg = setup(args) 84 | 85 | if args.eval_only: 86 | model = Trainer.build_model(cfg) 87 | DetectionCheckpointer(model, save_dir=cfg.OUTPUT_DIR).resume_or_load( 88 | cfg.MODEL.WEIGHTS, resume=args.resume 89 | ) 90 | res = Trainer.test(cfg, model) 91 | if comm.is_main_process(): 92 | verify_results(cfg, res) 93 | return res 94 | 95 | """ 96 | If you'd like to do anything fancier than the standard training logic, 97 | consider writing your own training loop or subclassing the trainer. 98 | """ 99 | trainer = Trainer(cfg) 100 | trainer.resume_or_load(resume=args.resume) 101 | return trainer.train() 102 | 103 | 104 | if __name__ == "__main__": 105 | args = default_argument_parser().parse_args() 106 | print("Command Line Args:", args) 107 | launch( 108 | main, 109 | args.num_gpus, 110 | num_machines=args.num_machines, 111 | machine_rank=args.machine_rank, 112 | dist_url=args.dist_url, 113 | args=(args,), 114 | ) 115 | -------------------------------------------------------------------------------- /tools/visualize_data.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import cv2 3 | from PIL import Image 4 | 5 | import argparse 6 | import os 7 | from detectron2.config import get_cfg 8 | from detectron2.data import DatasetCatalog, MetadataCatalog, build_detection_train_loader 9 | from detectron2.data import detection_utils as utils 10 | from detectron2.utils.logger import setup_logger 11 | from detectron2.utils.visualizer import Visualizer 12 | from itertools import chain 13 | 14 | 15 | def setup(args): 16 | cfg = get_cfg() 17 | if args.config_file: 18 | cfg.merge_from_file(args.config_file) 19 | cfg.merge_from_list(args.opts) 20 | cfg.freeze() 21 | return cfg 22 | 23 | 24 | def parse_args(in_args=None): 25 | parser = argparse.ArgumentParser(description="Visualize ground-truth data") 26 | parser.add_argument( 27 | "--source", 28 | choices=["annotation", "dataloader"], 29 | required=True, 30 | help="visualize the annotations or the data loader (with pre-processing)", 31 | ) 32 | parser.add_argument( 33 | "--config-file", default="", metavar="FILE", help="path to config file" 34 | ) 35 | parser.add_argument( 36 | "--output-dir", default="./", help="path to output directory" 37 | ) 38 | parser.add_argument( 39 | "--show", action="store_true", help="show output in a window" 40 | ) 41 | parser.add_argument( 42 | "opts", 43 | help="Modify config options using the command-line", 44 | default=None, 45 | nargs=argparse.REMAINDER, 46 | ) 47 | return parser.parse_args(in_args) 48 | 49 | 50 | if __name__ == "__main__": 51 | args = parse_args() 52 | logger = setup_logger() 53 | logger.info("Arguments: " + str(args)) 54 | cfg = setup(args) 55 | 56 | dirname = args.output_dir 57 | os.makedirs(dirname, exist_ok=True) 58 | metadata = MetadataCatalog.get(cfg.DATASETS.TRAIN[0]) 59 | 60 | def output(vis, fname): 61 | if args.show: 62 | print(fname) 63 | cv2.imshow("window", vis.get_image()[:, :, ::-1]) 64 | cv2.waitKey() 65 | else: 66 | filepath = os.path.join(dirname, fname) 67 | print("Saving to {} ...".format(filepath)) 68 | vis.save(filepath) 69 | 70 | scale = 2.0 if args.show else 1.0 71 | if args.source == "dataloader": 72 | train_data_loader = build_detection_train_loader(cfg) 73 | for batch in train_data_loader: 74 | for per_image in batch: 75 | # Pytorch tensor is in (C, H, W) format 76 | img = per_image["image"].permute(1, 2, 0) 77 | if cfg.INPUT.FORMAT == "BGR": 78 | img = img[:, :, [2, 1, 0]] 79 | else: 80 | img = np.asarray( 81 | Image.fromarray(img, mode=cfg.INPUT.FORMAT).convert( 82 | "RGB" 83 | ) 84 | ) 85 | 86 | visualizer = Visualizer(img, metadata=metadata, scale=scale) 87 | target_fields = per_image["instances"].get_fields() 88 | labels = [ 89 | metadata.thing_classes[i] 90 | for i in target_fields["gt_classes"] 91 | ] 92 | vis = visualizer.overlay_instances( 93 | labels=labels, 94 | boxes=target_fields.get("gt_boxes", None), 95 | ) 96 | output(vis, str(per_image["image_id"]) + ".jpg") 97 | else: 98 | dicts = list( 99 | chain.from_iterable( 100 | [DatasetCatalog.get(k) for k in cfg.DATASETS.TRAIN] 101 | ) 102 | ) 103 | for dic in dicts: 104 | img = utils.read_image(dic["file_name"], "RGB") 105 | visualizer = Visualizer(img, metadata=metadata, scale=scale) 106 | vis = visualizer.draw_dataset_dict(dic) 107 | output(vis, os.path.basename(dic["file_name"])) 108 | -------------------------------------------------------------------------------- /tools/visualize_json_results.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 3 | 4 | import numpy as np 5 | import cv2 6 | import tqdm 7 | from fvcore.common.file_io import PathManager 8 | 9 | import argparse 10 | import json 11 | import os 12 | from collections import defaultdict 13 | from detectron2.data import DatasetCatalog, MetadataCatalog 14 | from detectron2.structures import Boxes, BoxMode, Instances 15 | from detectron2.utils.logger import setup_logger 16 | from detectron2.utils.visualizer import Visualizer 17 | 18 | 19 | def create_instances(predictions, image_size): 20 | ret = Instances(image_size) 21 | 22 | score = np.asarray([x["score"] for x in predictions]) 23 | chosen = (score > args.conf_threshold).nonzero()[0] 24 | score = score[chosen] 25 | bbox = np.asarray([predictions[i]["bbox"] for i in chosen]) 26 | bbox = BoxMode.convert(bbox, BoxMode.XYWH_ABS, BoxMode.XYXY_ABS) 27 | 28 | labels = np.asarray( 29 | [dataset_id_map(predictions[i]["category_id"]) for i in chosen] 30 | ) 31 | 32 | ret.scores = score 33 | ret.pred_boxes = Boxes(bbox) 34 | ret.pred_classes = labels 35 | 36 | try: 37 | ret.pred_masks = [predictions[i]["segmentation"] for i in chosen] 38 | except KeyError: 39 | pass 40 | return ret 41 | 42 | 43 | if __name__ == "__main__": 44 | parser = argparse.ArgumentParser( 45 | description="A script that visualizes the json predictions from COCO or LVIS dataset." 46 | ) 47 | parser.add_argument( 48 | "--input", required=True, help="JSON file produced by the model" 49 | ) 50 | parser.add_argument("--output", required=True, help="output directory") 51 | parser.add_argument( 52 | "--dataset", help="name of the dataset", default="coco_2017_val" 53 | ) 54 | parser.add_argument( 55 | "--conf-threshold", 56 | default=0.5, 57 | type=float, 58 | help="confidence threshold", 59 | ) 60 | args = parser.parse_args() 61 | 62 | logger = setup_logger() 63 | 64 | with PathManager.open(args.input, "r") as f: 65 | predictions = json.load(f) 66 | 67 | pred_by_image = defaultdict(list) 68 | for p in predictions: 69 | pred_by_image[p["image_id"]].append(p) 70 | 71 | dicts = list(DatasetCatalog.get(args.dataset)) 72 | metadata = MetadataCatalog.get(args.dataset) 73 | if hasattr(metadata, "thing_dataset_id_to_contiguous_id"): 74 | 75 | def dataset_id_map(ds_id): 76 | return metadata.thing_dataset_id_to_contiguous_id[ds_id] 77 | 78 | elif "lvis" in args.dataset: 79 | # LVIS results are in the same format as COCO results, but have a different 80 | # mapping from dataset category id to contiguous category id in [0, #categories - 1] 81 | def dataset_id_map(ds_id): 82 | return ds_id - 1 83 | 84 | else: 85 | raise ValueError("Unsupported dataset: {}".format(args.dataset)) 86 | 87 | os.makedirs(args.output, exist_ok=True) 88 | 89 | for dic in tqdm.tqdm(dicts): 90 | img = cv2.imread(dic["file_name"], cv2.IMREAD_COLOR)[:, :, ::-1] 91 | basename = os.path.basename(dic["file_name"]) 92 | 93 | predictions = create_instances( 94 | pred_by_image[dic["image_id"]], img.shape[:2] 95 | ) 96 | vis = Visualizer(img, metadata) 97 | vis_pred = vis.draw_instance_predictions(predictions).get_image() 98 | 99 | vis = Visualizer(img, metadata) 100 | vis_gt = vis.draw_dataset_dict(dic).get_image() 101 | 102 | concat = np.concatenate((vis_pred, vis_gt), axis=1) 103 | cv2.imwrite(os.path.join(args.output, basename), concat[:, :, ::-1]) 104 | -------------------------------------------------------------------------------- /train_few_shot.py: -------------------------------------------------------------------------------- 1 | import os 2 | os.system("python -m tools.train_net --num-gpus 1 --config-file configs/COCO-detection/faster_rcnn_R_50_FPN_ft_all_jiaonang_1shot.yaml") 3 | os.system("python -m tools.train_net --num-gpus 1 --config-file configs/COCO-detection/faster_rcnn_R_50_FPN_ft_all_jiaonang_2shot.yaml") 4 | os.system("python -m tools.train_net --num-gpus 1 --config-file configs/COCO-detection/faster_rcnn_R_50_FPN_ft_all_jiaonang_3shot.yaml") --------------------------------------------------------------------------------