├── .flake8
├── .gitignore
├── .pre-commit-config.yaml
├── LICENSE
├── README.md
├── configs
├── Base-RCNN-FPN.yaml
├── COCO-detection
│ ├── 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
├── 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
└── predictor.py
├── docs
├── CUSTOM.md
├── MODEL_ZOO.md
└── TRAIN_INST.md
├── fsdet
├── __init__.py
├── checkpoint
│ ├── __init__.py
│ └── catalog.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
└── utils
│ └── file_io.py
├── pyproject.toml
├── requirements-dev.txt
├── requirements.txt
└── tools
├── __init__.py
├── aggregate_seeds.py
├── ckpt_surgery.py
├── run_experiments.py
├── test_net.py
├── train_net.py
├── visualize_data.py
└── visualize_json_results.py
/.flake8:
--------------------------------------------------------------------------------
1 | [flake8]
2 | ignore = E203, E266, E501, W503, F403, F401
3 | max-line-length = 79
4 | max-complexity = 18
5 | select = B,C,E,F,W,T4,B9
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | .idea/
3 | .DS_Store
4 | .gitignore
5 |
6 | # compilation and distribution
7 | __pycache__
8 | _ext
9 | *.pyc
10 | *.so
11 | FsDet.egg-info
12 | build/
13 | install/
14 | .ipynb_checkpoints/
15 | .venv
16 |
17 | fsdet/model_zoo/configs
18 | logger-files/
19 |
20 | exp/
21 | checkpoints/
22 |
23 | # datasets
24 | datasets/coco
25 | datasets/cocosplit
26 | datasets/VOC2007
27 | datasets/VOC2012
28 | datasets/vocsplit
29 | datasets/lvis
30 | datasets/lvissplit
31 | datasets/*/seed*
32 |
33 | # configs
34 | configs/Test
35 | configs/*/seed*/*
36 | configs/*/*/seed*/*
37 |
38 | .vscode-upload.json
39 | .mypy_cache
40 |
--------------------------------------------------------------------------------
/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | default_language_version:
2 | python: python3.6
3 |
4 | repos:
5 | - repo: https://github.com/ambv/black
6 | rev: 21.9b0
7 | hooks:
8 | - id: black
9 | language_version: python3.6
10 | files: '.py$'
11 | - repo: https://gitlab.com/pycqa/flake8
12 | rev: 3.9.2
13 | hooks:
14 | - id: flake8
15 | files: '.py$'
16 | - repo: https://github.com/myint/autoflake
17 | rev: v1.4
18 | hooks:
19 | - id: autoflake
20 | args: [--in-place, --remove-all-unused-imports, --remove-unused-variables, --ignore-init-module-imports]
21 | files: '.py$'
22 |
--------------------------------------------------------------------------------
/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/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/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(
10 | "--seeds", type=int, nargs="+", default=[1, 10], help="Range of seeds"
11 | )
12 | args = parser.parse_args()
13 | return args
14 |
15 |
16 | def generate_seeds(args):
17 | data_path = "datasets/cocosplit/datasplit/trainvalno5k.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, 5, 10, 30]:
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(
72 | data_path, ID2CLASS[c], shots, i
73 | )
74 | new_data["categories"] = new_all_cats
75 | with open(save_path, "w") as f:
76 | json.dump(new_data, f)
77 |
78 |
79 | def get_save_path_seeds(path, cls, shots, seed):
80 | prefix = "full_box_{}shot_{}_trainval".format(shots, cls)
81 | save_dir = os.path.join("datasets", "cocosplit", "seed" + str(seed))
82 | os.makedirs(save_dir, exist_ok=True)
83 | save_path = os.path.join(save_dir, prefix + ".json")
84 | return save_path
85 |
86 |
87 | if __name__ == "__main__":
88 | ID2CLASS = {
89 | 1: "person",
90 | 2: "bicycle",
91 | 3: "car",
92 | 4: "motorcycle",
93 | 5: "airplane",
94 | 6: "bus",
95 | 7: "train",
96 | 8: "truck",
97 | 9: "boat",
98 | 10: "traffic light",
99 | 11: "fire hydrant",
100 | 13: "stop sign",
101 | 14: "parking meter",
102 | 15: "bench",
103 | 16: "bird",
104 | 17: "cat",
105 | 18: "dog",
106 | 19: "horse",
107 | 20: "sheep",
108 | 21: "cow",
109 | 22: "elephant",
110 | 23: "bear",
111 | 24: "zebra",
112 | 25: "giraffe",
113 | 27: "backpack",
114 | 28: "umbrella",
115 | 31: "handbag",
116 | 32: "tie",
117 | 33: "suitcase",
118 | 34: "frisbee",
119 | 35: "skis",
120 | 36: "snowboard",
121 | 37: "sports ball",
122 | 38: "kite",
123 | 39: "baseball bat",
124 | 40: "baseball glove",
125 | 41: "skateboard",
126 | 42: "surfboard",
127 | 43: "tennis racket",
128 | 44: "bottle",
129 | 46: "wine glass",
130 | 47: "cup",
131 | 48: "fork",
132 | 49: "knife",
133 | 50: "spoon",
134 | 51: "bowl",
135 | 52: "banana",
136 | 53: "apple",
137 | 54: "sandwich",
138 | 55: "orange",
139 | 56: "broccoli",
140 | 57: "carrot",
141 | 58: "hot dog",
142 | 59: "pizza",
143 | 60: "donut",
144 | 61: "cake",
145 | 62: "chair",
146 | 63: "couch",
147 | 64: "potted plant",
148 | 65: "bed",
149 | 67: "dining table",
150 | 70: "toilet",
151 | 72: "tv",
152 | 73: "laptop",
153 | 74: "mouse",
154 | 75: "remote",
155 | 76: "keyboard",
156 | 77: "cell phone",
157 | 78: "microwave",
158 | 79: "oven",
159 | 80: "toaster",
160 | 81: "sink",
161 | 82: "refrigerator",
162 | 84: "book",
163 | 85: "clock",
164 | 86: "vase",
165 | 87: "scissors",
166 | 88: "teddy bear",
167 | 89: "hair drier",
168 | 90: "toothbrush",
169 | }
170 | CLASS2ID = {v: k for k, v in ID2CLASS.items()}
171 |
172 | args = parse_args()
173 | generate_seeds(args)
174 |
--------------------------------------------------------------------------------
/datasets/prepare_voc_few_shot.py:
--------------------------------------------------------------------------------
1 | import argparse
2 | import copy
3 | import os
4 | import random
5 | import xml.etree.ElementTree as ET
6 |
7 | import numpy as np
8 | from fsdet.utils.file_io import PathManager
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'] # fmt: skip
14 |
15 |
16 | def parse_args():
17 | parser = argparse.ArgumentParser()
18 | parser.add_argument(
19 | "--seeds", type=int, nargs="+", default=[1, 20], help="Range of seeds"
20 | )
21 | args = parser.parse_args()
22 | return args
23 |
24 |
25 | def generate_seeds(args):
26 | data = []
27 | data_per_cat = {c: [] for c in VOC_CLASSES}
28 | for year in [2007, 2012]:
29 | data_file = "datasets/VOC{}/ImageSets/Main/trainval.txt".format(year)
30 | with PathManager.open(data_file) as f:
31 | fileids = np.loadtxt(f, dtype=np.str).tolist()
32 | data.extend(fileids)
33 | for fileid in data:
34 | year = "2012" if "_" in fileid else "2007"
35 | dirname = os.path.join("datasets", "VOC{}".format(year))
36 | anno_file = os.path.join(dirname, "Annotations", fileid + ".xml")
37 | tree = ET.parse(anno_file)
38 | clses = []
39 | for obj in tree.findall("object"):
40 | cls = obj.find("name").text
41 | clses.append(cls)
42 | for cls in set(clses):
43 | data_per_cat[cls].append(anno_file)
44 |
45 | result = {cls: {} for cls in data_per_cat.keys()}
46 | shots = [1, 2, 3, 5, 10]
47 | for i in range(args.seeds[0], args.seeds[1]):
48 | random.seed(i)
49 | for c in data_per_cat.keys():
50 | c_data = []
51 | for j, shot in enumerate(shots):
52 | diff_shot = shots[j] - shots[j - 1] if j != 0 else 1
53 | shots_c = random.sample(data_per_cat[c], diff_shot)
54 | num_objs = 0
55 | for s in shots_c:
56 | if s not in c_data:
57 | tree = ET.parse(s)
58 | file = tree.find("filename").text
59 | year = tree.find("folder").text
60 | name = "datasets/{}/JPEGImages/{}".format(year, file)
61 | c_data.append(name)
62 | for obj in tree.findall("object"):
63 | if obj.find("name").text == c:
64 | num_objs += 1
65 | if num_objs >= diff_shot:
66 | break
67 | result[c][shot] = copy.deepcopy(c_data)
68 | save_path = "datasets/vocsplit/seed{}".format(i)
69 | os.makedirs(save_path, exist_ok=True)
70 | for c in result.keys():
71 | for shot in result[c].keys():
72 | filename = "box_{}shot_{}_train.txt".format(shot, c)
73 | with open(os.path.join(save_path, filename), "w") as fp:
74 | fp.write("\n".join(result[c][shot]) + "\n")
75 |
76 |
77 | if __name__ == "__main__":
78 | args = parse_args()
79 | generate_seeds(args)
80 |
--------------------------------------------------------------------------------
/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(
9 | "--data",
10 | type=str,
11 | default="datasets/lvis/lvis_v0.5_train.json",
12 | help="path to the annotation file",
13 | )
14 | parser.add_argument(
15 | "--save-dir",
16 | type=str,
17 | default="datasets/lvis",
18 | help="path to the save directory",
19 | )
20 | args = parser.parse_args()
21 | return args
22 |
23 |
24 | def split_annotation(args):
25 | with open(args.data) as fp:
26 | ann_train = json.load(fp)
27 |
28 | for s, name in [("f", "freq"), ("c", "common"), ("r", "rare")]:
29 | ann_s = {
30 | "info": ann_train["info"],
31 | # 'images': ann_train['images'],
32 | "categories": ann_train["categories"],
33 | "licenses": ann_train["licenses"],
34 | }
35 | ids = [
36 | cat["id"]
37 | for cat in ann_train["categories"]
38 | if cat["frequency"] == s
39 | ]
40 | ann_s["annotations"] = [
41 | ann
42 | for ann in ann_train["annotations"]
43 | if ann["category_id"] in ids
44 | ]
45 | img_ids = set([ann["image_id"] for ann in ann_s["annotations"]])
46 | new_images = [
47 | img for img in ann_train["images"] if img["id"] in img_ids
48 | ]
49 | ann_s["images"] = new_images
50 |
51 | save_path = os.path.join(
52 | args.save_dir, "lvis_v0.5_train_{}.json".format(name)
53 | )
54 | print("Saving {} annotations to {}.".format(name, save_path))
55 | with open(save_path, "w") as fp:
56 | json.dump(ann_s, fp)
57 |
58 |
59 | if __name__ == "__main__":
60 | args = parse_args()
61 | split_annotation(args)
62 |
--------------------------------------------------------------------------------
/demo/demo.py:
--------------------------------------------------------------------------------
1 | import argparse
2 | import glob
3 | import multiprocessing as mp
4 | import os
5 | import time
6 |
7 | import cv2
8 | import tqdm
9 | from detectron2.data.detection_utils import read_image
10 | from detectron2.utils.logger import setup_logger
11 |
12 | from demo.predictor import VisualizationDemo
13 | from fsdet.config import get_cfg
14 |
15 | # constants
16 | WINDOW_NAME = "COCO detections"
17 |
18 |
19 | def setup_cfg(args):
20 | # load config from file and command-line arguments
21 | cfg = get_cfg()
22 | cfg.merge_from_file(args.config_file)
23 | cfg.merge_from_list(args.opts)
24 | # Set score_threshold for builtin models
25 | cfg.MODEL.RETINANET.SCORE_THRESH_TEST = args.confidence_threshold
26 | cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = args.confidence_threshold
27 | cfg.freeze()
28 | return cfg
29 |
30 |
31 | def get_parser():
32 | parser = argparse.ArgumentParser(
33 | description="FsDet demo for builtin models"
34 | )
35 | parser.add_argument(
36 | "--config-file",
37 | default="configs/COCO-detection/faster_rcnn_R_101_FPN_ft_all_1shot.yaml",
38 | metavar="FILE",
39 | help="path to config file",
40 | )
41 | parser.add_argument(
42 | "--webcam", action="store_true", help="Take inputs from webcam."
43 | )
44 | parser.add_argument("--video-input", help="Path to video file.")
45 | parser.add_argument(
46 | "--input",
47 | nargs="+",
48 | help="A list of space separated input images; "
49 | "or a single glob pattern such as 'directory/*.jpg'",
50 | )
51 | parser.add_argument(
52 | "--output",
53 | help="A file or directory to save output visualizations. "
54 | "If not given, will show output in an OpenCV window.",
55 | )
56 |
57 | parser.add_argument(
58 | "--confidence-threshold",
59 | type=float,
60 | default=0.5,
61 | help="Minimum score for instance predictions to be shown",
62 | )
63 | parser.add_argument(
64 | "--opts",
65 | help="Modify config options using the command-line 'KEY VALUE' pairs",
66 | default=[],
67 | nargs=argparse.REMAINDER,
68 | )
69 | return parser
70 |
71 |
72 | if __name__ == "__main__":
73 | mp.set_start_method("spawn", force=True)
74 | args = get_parser().parse_args()
75 | setup_logger(name="fvcore")
76 | logger = setup_logger()
77 | logger.info("Arguments: " + str(args))
78 |
79 | cfg = setup_cfg(args)
80 |
81 | demo = VisualizationDemo(cfg)
82 |
83 | if args.input:
84 | if len(args.input) == 1:
85 | args.input = glob.glob(os.path.expanduser(args.input[0]))
86 | assert args.input, "The input path(s) was not found"
87 | for path in tqdm.tqdm(args.input, disable=not args.output):
88 | # use PIL, to be consistent with evaluation
89 | img = read_image(path, format="BGR")
90 | start_time = time.time()
91 | predictions, visualized_output = demo.run_on_image(img)
92 | logger.info(
93 | "{}: {} in {:.2f}s".format(
94 | path,
95 | "detected {} instances".format(
96 | len(predictions["instances"])
97 | )
98 | if "instances" in predictions
99 | else "finished",
100 | time.time() - start_time,
101 | )
102 | )
103 |
104 | if args.output:
105 | if os.path.isdir(args.output):
106 | assert os.path.isdir(args.output), args.output
107 | out_filename = os.path.join(
108 | args.output, os.path.basename(path)
109 | )
110 | else:
111 | assert (
112 | len(args.input) == 1
113 | ), "Please specify a directory with args.output"
114 | out_filename = args.output
115 | visualized_output.save(out_filename)
116 | else:
117 | cv2.namedWindow(WINDOW_NAME, cv2.WINDOW_NORMAL)
118 | cv2.imshow(
119 | WINDOW_NAME, visualized_output.get_image()[:, :, ::-1]
120 | )
121 | if cv2.waitKey(0) == 27:
122 | break # esc to quit
123 | elif args.webcam:
124 | assert args.input is None, "Cannot have both --input and --webcam!"
125 | cam = cv2.VideoCapture(0)
126 | for vis in tqdm.tqdm(demo.run_on_video(cam)):
127 | cv2.namedWindow(WINDOW_NAME, cv2.WINDOW_NORMAL)
128 | cv2.imshow(WINDOW_NAME, vis)
129 | if cv2.waitKey(1) == 27:
130 | break # esc to quit
131 | cv2.destroyAllWindows()
132 | elif args.video_input:
133 | video = cv2.VideoCapture(args.video_input)
134 | width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH))
135 | height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT))
136 | frames_per_second = video.get(cv2.CAP_PROP_FPS)
137 | num_frames = int(video.get(cv2.CAP_PROP_FRAME_COUNT))
138 | basename = os.path.basename(args.video_input)
139 |
140 | if args.output:
141 | if os.path.isdir(args.output):
142 | output_fname = os.path.join(args.output, basename)
143 | output_fname = os.path.splitext(output_fname)[0] + ".mkv"
144 | else:
145 | output_fname = args.output
146 | assert not os.path.isfile(output_fname), output_fname
147 | output_file = cv2.VideoWriter(
148 | filename=output_fname,
149 | # some installation of opencv may not support x264 (due to its license),
150 | # you can try other format (e.g. MPEG)
151 | fourcc=cv2.VideoWriter_fourcc(*"x264"),
152 | fps=float(frames_per_second),
153 | frameSize=(width, height),
154 | isColor=True,
155 | )
156 | assert os.path.isfile(args.video_input)
157 | for vis_frame in tqdm.tqdm(demo.run_on_video(video), total=num_frames):
158 | if args.output:
159 | output_file.write(vis_frame)
160 | else:
161 | cv2.namedWindow(basename, cv2.WINDOW_NORMAL)
162 | cv2.imshow(basename, vis_frame)
163 | if cv2.waitKey(1) == 27:
164 | break # esc to quit
165 | video.release()
166 | if args.output:
167 | output_file.release()
168 | else:
169 | cv2.destroyAllWindows()
170 |
--------------------------------------------------------------------------------
/docs/CUSTOM.md:
--------------------------------------------------------------------------------
1 | # Custom Dataset Instructions
2 |
3 | Here we provide instructions for how to create and use your own custom dataset for training and evaluation.
4 |
5 | ## Step 1: Create dataset loader
6 |
7 | The first step is to create your dataset loader in the `fsdet/data` directory. The dataset loader should return a list of all the images in the dataset and their corresponding annotations. The format is shown below:
8 | ```python
9 | def dataset_loader(name, thing_classes):
10 | data = []
11 | for file in dataset:
12 | annotation = [
13 | "file_name" : "x.png", # full path to image
14 | "image_id" : 0, # image unique ID
15 | "height" : 123, # height of image
16 | "width" : 123, # width of image
17 | "annotations": [
18 | "category_id" : thing_classes.index("class_name"), # class unique ID
19 | "bbox" : [0, 0, 123, 123], # bbox coordinates
20 | "bbox_mode" : BoxMode.XYXY_ABS, # bbox mode, depending on your format
21 | ]
22 | ]
23 | data.append(annotation)
24 | return data
25 | ```
26 | For the bbox format, you see refer to the Detectron2 [code](https://github.com/facebookresearch/detectron2/blob/main/detectron2/structures/boxes.py#L23) for the available options.
27 |
28 | For examples, you can refer to the PASCAL VOC [dataset loader](https://github.com/ucbdrive/few-shot-object-detection/blob/master/fsdet/data/meta_pascal_voc.py#L12) or the COCO [dataset loader](https://github.com/ucbdrive/few-shot-object-detection/blob/master/fsdet/data/meta_coco.py#L19).
29 |
30 | ## Step 2: Create meta information for dataset
31 |
32 | Next, you have to create the meta information for your dataset. The only needed information is the classes for each split. Below is an example of the classes information for the first split of PASCAL VOC:
33 | ```python
34 | thing_classes: [ # all classes
35 | "aeroplane", "bicycle", "boat", "bottle", "car", "cat", "chair",
36 | "diningtable", "dog", "horse", "person", "pottedplant", "sheep",
37 | "train", "tvmonitor", "bird", "bus", "cow", "motorbike", "sofa",
38 | ]
39 | base_classes: [ # base clases
40 | "aeroplane", "bicycle", "boat", "bottle", "car", "cat", "chair",
41 | "diningtable", "dog", "horse", "person", "pottedplant", "sheep",
42 | "train", "tvmonitor",
43 | ]
44 | novel_classes: ["bird", "bus", "cow", "motorbike", "sofa"] # novel classes
45 |
46 | metadata = {
47 | "thing_clases": thing_clases,
48 | "base_classes": base_classes,
49 | "novel_classes": novel_classes,
50 | }
51 | ```
52 |
53 | We put all the meta information in [builtin_meta.py](https://github.com/ucbdrive/few-shot-object-detection/blob/master/fsdet/data/builtin_meta.py).
54 |
55 | ## Step 3: Create evaluator for dataset
56 |
57 | Now you need to write a evaluator to evaluate on your dataset. Your class should inherit from `DatasetEvaluator` and implement all its functions. Example below:
58 |
59 | ```python
60 | from fsdet.evaluation.evaluator import DatasetEvaluator
61 | class NewDatasetEvaluator(DatasetEvaluator):
62 | def __init__(self, dataset_name): # initial needed variables
63 | self._dataset_name = dataset_name
64 |
65 | def reset(self): # reset predictions
66 | self._predictions = []
67 |
68 | def process(self, inputs, outputs): # prepare predictions for evaluation
69 | for input, output in zip(inputs, outputs):
70 | prediction = {"image_id": input["image_id"]}
71 | if "instances" in output:
72 | prediction["instances"] = output["instances"]
73 | self._predictions.append(prediction)
74 |
75 | def evaluate(self): # evaluate predictions
76 | results = evaluate_predictions(self._predictions)
77 | return {
78 | "AP": results["AP"],
79 | "AP50": results["AP50"],
80 | "AP75": results["AP75"],
81 | }
82 | ```
83 |
84 | For examples, you can refer to the PASCAL VOC [evaluator](https://github.com/ucbdrive/few-shot-object-detection/blob/master/fsdet/evaluation/pascal_voc_evaluation.py) or the COCO [evaluator](https://github.com/ucbdrive/few-shot-object-detection/blob/master/fsdet/evaluation/coco_evaluation.py).
85 |
86 | ## Step 4: Register dataset loader and meta information
87 |
88 | For the rest of the code to see your new dataset, you need to register it with Detectron2's DatasetCatalog and MetadataCatalog. Example below:
89 | ```python
90 | def register_dataset(name, thing_classes, metadata):
91 | # register dataset (step 1)
92 | DatasetCatalog.register(
93 | name, # name of dataset, this will be used in the config file
94 | lambda: dataset_loader( # this calls your dataset loader to get the data
95 | name, thing_classes, # inputs to your dataset loader
96 | ),
97 | )
98 |
99 | # register meta information (step 2)
100 | MetadataCatalog.get(name).set(
101 | thing_classes=metadata["thing_classes"], # all classes
102 | base_classes=metadata["base_classes"], # base classes
103 | novel_classes=metadata["novel_classes"], # novel classes
104 | )
105 | MetadataCatalog.get(name).evaluator_type = "new_dataset" # set evaluator
106 | ```
107 |
108 | We put the above code in a register function in its corresponding dataset file. For examples, you can refer to the PASCAL VOC register [code](https://github.com/ucbdrive/few-shot-object-detection/blob/master/fsdet/data/meta_pascal_voc.py#L135) or the COCO register [code](https://github.com/ucbdrive/few-shot-object-detection/blob/master/fsdet/data/meta_coco.py#L124).
109 |
110 | Then, you also need to call the register function to register the dataset. We do this in [builtin.py](https://github.com/ucbdrive/few-shot-object-detection/blob/master/fsdet/data/builtin.py). You should register all your datasets, including all base and novel splits. Example below:
111 | ```python
112 | datasets = {
113 | 'dataset_all': metadata["thing_classes"],
114 | 'dataset_base': metadata["base_classes"],
115 | 'dataset_novel': metadata["novel_classes"],
116 | }
117 | for dataset_name, classes in datasets.items():
118 | register_dataset(dataset_name, classes, metadata)
119 | ```
120 |
121 | Also, add your evaluator to both `tools/train_net.py` and `tools/test_net.py` in the `build_evaluator` function:
122 | ```python
123 | def build_evaluator(cls, cfg, dataset_name, output_folder=None):
124 | ...
125 | if evaluator_type == "new_dataset":
126 | return NewDatasetEvaluator(dataset_name)
127 | ...
128 | ```
129 |
130 | ## Step 5: Modify config files
131 |
132 | Modify the config files to use your new dataset. You only need to replace the datasets part to include the name of your new dataset. Example below:
133 | ```yaml
134 | _BASE_: "../../Base-RCNN-FPN.yaml"
135 | MODEL:
136 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-101.pkl"
137 | MASK_ON: False
138 | RESNETS:
139 | DEPTH: 101
140 | ROI_HEADS:
141 | NUM_CLASSES: 15
142 | INPUT:
143 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800)
144 | MIN_SIZE_TEST: 800
145 | DATASETS:
146 | TRAIN: ('dataset_all',) # <-- modify this
147 | TEST: ('dataset_novel',) # <-- modify this
148 | SOLVER:
149 | STEPS: (12000, 16000)
150 | MAX_ITER: 18000
151 | WARMUP_ITERS: 100
152 | OUTPUT_DIR: "checkpoints/new_dataset"
153 | ```
154 |
155 | Congratulations, now you can start training and testing on your new dataset!
156 |
--------------------------------------------------------------------------------
/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 | 
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 |
16 | COCO
17 |
18 | ```angular2html
19 | python3 -m tools.train_net --num-gpus 8 \
20 | --config-file configs/COCO-detection/faster_rcnn_R_101_FPN_base.yaml
21 | ```
22 |
23 |
24 |
25 | ## Stage 2: Few-Shot Fine-Tuning
26 |
27 | ### Initialization
28 |
29 | 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.
30 |
31 | #### Random Weights
32 |
33 | To randomly initialize the weights corresponding to the novel classes, run
34 | ```angular2html
35 | python3 -m tools.ckpt_surgery \
36 | --src1 checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_final.pth \
37 | --method randinit \
38 | --save-dir checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_all1
39 | ```
40 | The resulting weights will be saved to `checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_all1/model_reset_surgery.pth`.
41 |
42 |
43 | COCO
44 |
45 | ```angular2html
46 | python3 -m tools.ckpt_surgery \
47 | --src1 checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_base/model_final.pth \
48 | --method randinit \
49 | --save-dir checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_all
50 | --coco
51 | ```
52 |
53 |
54 |
55 | #### Novel Weights
56 |
57 | 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. On PASCAL VOC, we found novel weights to be unnecessary so we did not use them and do not provide the config files. You can see [here](https://github.com/ucbdrive/few-shot-object-detection/issues/13#issuecomment-614865673) for an example if you would still like to use it. Below we provide instructions on the COCO dataset.
58 |
59 | First remove the last layer from the weights file by running
60 | ```angular2html
61 | python3 -m tools.ckpt_surgery \
62 | --src1 checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_base/model_final.pth \
63 | --method remove \
64 | --save-dir checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_all
65 | ```
66 |
67 | Next, fine-tune the predictor on the novel set by running
68 | ```angular2html
69 | python3 -m tools.train_net --num-gpus 8 \
70 | --config-file configs/COCO-detection/faster_rcnn_R_101_FPN_ft_novel_1shot.yaml \
71 | --opts MODEL.WEIGHTS checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_all/model_reset_remove.pth
72 | ```
73 |
74 | Finally, combine the base weights from the base model with the novel weights by running
75 | ```angular2html
76 | python3 -m tools.ckpt_surgery \
77 | --src1 checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_base/model_final.pth \
78 | --src2 checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_1shot/model_final.pth \
79 | --method combine \
80 | --save-dir checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_all
81 | --coco
82 | ```
83 | The resulting weights will be saved to `checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_all/model_reset_combine.pth`.
84 |
85 |
86 | PASCAL VOC
87 |
88 | Just for reference, not actually used.
89 | ```angular2html
90 | python3 -m tools.ckpt_surgery \
91 | --src1 checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_final.pth \
92 | --method remove \
93 | --save-dir checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_all1
94 | ```
95 |
96 | ```angular2html
97 | python3 -m tools.train_net --num-gpus 8 \
98 | --config-file configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_novel1_1shot.yaml \
99 | --opts MODEL.WEIGHTS checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_all1/model_reset_remove.pth
100 | ```
101 |
102 | ```angular2html
103 | python3 -m tools.ckpt_surgery \
104 | --src1 checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_final.pth \
105 | --src2 checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel1_1shot/model_final.pth \
106 | --method combine \
107 | --save-dir checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_all1
108 | ```
109 |
110 |
111 |
112 | ### Fine-Tuning
113 |
114 | We will then fine-tune the last layer of the full model on a balanced dataset by running
115 | ```angular2html
116 | python3 -m tools.train_net --num-gpus 8 \
117 | --config-file configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_all1_1shot.yaml \
118 | --opts MODEL.WEIGHTS $WEIGHTS_PATH
119 | ```
120 | where `WEIGHTS_PATH` is the path to the weights obtained in the previous initialization step.
121 |
122 |
123 | COCO
124 |
125 | ```angular2html
126 | python3 -m tools.train_net --num-gpus 8 \
127 | --config-file configs/COCO-detection/faster_rcnn_R_101_FPN_ft_all_1shot.yaml \
128 | --opts MODEL.WEIGHTS $WEIGHTS_PATH
129 | ```
130 |
131 |
132 |
133 | ## Training Steps for Each Dataset
134 |
135 | Below are the steps we used during training for each dataset.
136 | ```
137 | PASCAL VOC: Base training --> random initialization --> fine-tuning
138 | COCO and LVIS: Base training --> novel weights initializaiton --> fine-tuning
139 | ```
140 |
--------------------------------------------------------------------------------
/fsdet/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wz940216/few-shot-object-detection/148a039af7abce9eff59d5cdece296ad1d2b8aa0/fsdet/__init__.py
--------------------------------------------------------------------------------
/fsdet/checkpoint/__init__.py:
--------------------------------------------------------------------------------
1 | from detectron2.checkpoint import DetectionCheckpointer
2 |
3 | from . import catalog as _UNUSED # register the handler
4 |
5 | __all__ = ["DetectionCheckpointer"]
6 |
--------------------------------------------------------------------------------
/fsdet/checkpoint/catalog.py:
--------------------------------------------------------------------------------
1 | """FS-Det Model Handler."""
2 |
3 | from detectron2.utils.file_io import PathHandler, PathManager
4 |
5 |
6 | class FsDetHandler(PathHandler):
7 | """
8 | Resolve anything that's in FsDet model zoo.
9 | """
10 |
11 | PREFIX = "fsdet://"
12 | URL_PREFIX = "http://dl.yf.io/fs-det/models/"
13 |
14 | def _get_supported_prefixes(self):
15 | return [self.PREFIX]
16 |
17 | def _get_local_path(self, path):
18 | name = path[len(self.PREFIX) :]
19 | return PathManager.get_local_path(self.URL_PREFIX + name)
20 |
21 | def _open(self, path, mode="r", **kwargs):
22 | return PathManager.open(self._get_local_path(path), mode, **kwargs)
23 |
24 |
25 | PathManager.register_handler(FsDetHandler())
26 |
--------------------------------------------------------------------------------
/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 | ]
12 |
--------------------------------------------------------------------------------
/fsdet/config/config.py:
--------------------------------------------------------------------------------
1 | import logging
2 |
3 | from fvcore.common.config import CfgNode as _CfgNode
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.defaults import _C
2 |
3 | # adding additional default values built on top of the default values in detectron2
4 |
5 | _CC = _C
6 |
7 | # FREEZE Parameters
8 | _CC.MODEL.BACKBONE.FREEZE = False
9 | _CC.MODEL.PROPOSAL_GENERATOR.FREEZE = False
10 | _CC.MODEL.ROI_HEADS.FREEZE_FEAT = False
11 |
12 | # choose from "FastRCNNOutputLayers" and "CosineSimOutputLayers"
13 | _CC.MODEL.ROI_HEADS.OUTPUT_LAYER = "FastRCNNOutputLayers"
14 | # scale of cosine similarity (set to -1 for learnable scale)
15 | _CC.MODEL.ROI_HEADS.COSINE_SCALE = 20.0
16 |
17 | # Backward Compatible options.
18 | _CC.MUTE_HEADER = True
19 |
--------------------------------------------------------------------------------
/fsdet/data/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wz940216/few-shot-object-detection/148a039af7abce9eff59d5cdece296ad1d2b8aa0/fsdet/data/__init__.py
--------------------------------------------------------------------------------
/fsdet/data/meta_coco.py:
--------------------------------------------------------------------------------
1 | import contextlib
2 | import io
3 | import os
4 |
5 | import numpy as np
6 | from detectron2.data import DatasetCatalog, MetadataCatalog
7 | from detectron2.structures import BoxMode
8 | from fsdet.utils.file_io import PathManager
9 | from pycocotools.coco import COCO
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 | )
144 |
--------------------------------------------------------------------------------
/fsdet/data/meta_lvis.py:
--------------------------------------------------------------------------------
1 | import logging
2 | import os
3 |
4 | from detectron2.config import global_cfg
5 | from detectron2.data import DatasetCatalog, MetadataCatalog
6 | from detectron2.structures import BoxMode
7 | from fsdet.utils.file_io import PathManager
8 | from fvcore.common.timer import Timer
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 | )
138 |
--------------------------------------------------------------------------------
/fsdet/data/meta_pascal_voc.py:
--------------------------------------------------------------------------------
1 | import os
2 | import xml.etree.ElementTree as ET
3 |
4 | import numpy as np
5 | from detectron2.data import DatasetCatalog, MetadataCatalog
6 | from detectron2.structures import BoxMode
7 | from fsdet.utils.file_io import PathManager
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 | import fsdet.data.builtin as _UNUSED # register datasets
2 |
3 | from .defaults import (
4 | DefaultPredictor,
5 | DefaultTrainer,
6 | default_argument_parser,
7 | default_setup,
8 | )
9 | from .hooks import *
10 |
--------------------------------------------------------------------------------
/fsdet/engine/hooks.py:
--------------------------------------------------------------------------------
1 | import json
2 | import os
3 |
4 | import detectron2.utils.comm as comm
5 | from detectron2.engine.train_loop import HookBase
6 | from detectron2.evaluation.testing import flatten_results_dict
7 | from fsdet.utils.file_io import PathManager
8 |
9 | __all__ = ["EvalHookFsdet"]
10 |
11 |
12 | class EvalHookFsdet(HookBase):
13 | """
14 | Run an evaluation function periodically, and at the end of training.
15 | It is executed every ``eval_period`` iterations and after the last iteration.
16 | """
17 |
18 | def __init__(self, eval_period, eval_function, cfg):
19 | """
20 | Args:
21 | eval_period (int): the period to run `eval_function`. Set to 0 to
22 | not evaluate periodically (but still after the last iteration).
23 | eval_function (callable): a function which takes no arguments, and
24 | returns a nested dict of evaluation metrics.
25 | cfg: config
26 | Note:
27 | This hook must be enabled in all or none workers.
28 | If you would like only certain workers to perform evaluation,
29 | give other workers a no-op function (`eval_function=lambda: None`).
30 | """
31 | self._period = eval_period
32 | self._func = eval_function
33 | self.cfg = cfg
34 |
35 | def _do_eval(self):
36 | results = self._func()
37 |
38 | if results:
39 | assert isinstance(
40 | results, dict
41 | ), "Eval function must return a dict. Got {} instead.".format(
42 | results
43 | )
44 |
45 | flattened_results = flatten_results_dict(results)
46 | for k, v in flattened_results.items():
47 | try:
48 | v = float(v)
49 | except Exception as e:
50 | raise ValueError(
51 | "[EvalHook] eval_function should return a nested dict of float. "
52 | "Got '{}: {}' instead.".format(k, v)
53 | ) from e
54 | self.trainer.storage.put_scalars(
55 | **flattened_results, smoothing_hint=False
56 | )
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 | )
64 | output_file = (
65 | "res_final.json"
66 | if is_final
67 | else "iter_{:07d}.json".format(self.trainer.iter)
68 | )
69 | with PathManager.open(
70 | os.path.join(self.cfg.OUTPUT_DIR, "inference", output_file),
71 | "w",
72 | ) as fp:
73 | json.dump(results, fp)
74 |
75 | # Evaluation may take different time among workers.
76 | # A barrier make them start the next iteration together.
77 | comm.synchronize()
78 |
79 | def after_step(self):
80 | next_iter = self.trainer.iter + 1
81 | if self._period > 0 and next_iter % self._period == 0:
82 | self._do_eval()
83 |
84 | def after_train(self):
85 | # This condition is to prevent the eval from running after a failed training
86 | if self.trainer.iter + 1 >= self.trainer.max_iter:
87 | self._do_eval()
88 | # func is likely a closure that holds reference to the trainer
89 | # therefore we clean it to avoid circular reference in the end
90 | del self._func
91 |
--------------------------------------------------------------------------------
/fsdet/evaluation/__init__.py:
--------------------------------------------------------------------------------
1 | from .coco_evaluation import COCOEvaluator
2 | from .evaluator import (
3 | DatasetEvaluator,
4 | DatasetEvaluators,
5 | inference_context,
6 | inference_on_dataset,
7 | )
8 | from .lvis_evaluation import LVISEvaluator
9 | from .pascal_voc_evaluation import PascalVOCDetectionEvaluator
10 | from .testing import print_csv_format, verify_results
11 |
12 | __all__ = [k for k in globals().keys() if not k.startswith("_")]
13 |
--------------------------------------------------------------------------------
/fsdet/evaluation/evaluator.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | import logging
3 | import time
4 | from collections import OrderedDict
5 | from contextlib import contextmanager
6 |
7 | import torch
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 |
28 | def process(self, input, output):
29 | """
30 | Process an input/output pair.
31 |
32 | Args:
33 | input: the input that's used to call the model.
34 | output: the return value of `model(output)`
35 | """
36 |
37 | def evaluate(self):
38 | """
39 | Evaluate/summarize the performance, after processing all input/output pairs.
40 |
41 | Returns:
42 | dict:
43 | A new evaluator class can return a dict of arbitrary format
44 | as long as the user can process the results.
45 | In our train_net.py, we expect the following format:
46 |
47 | * key: the name of the task (e.g., bbox)
48 | * value: a dict of {metric name: score}, e.g.: {"AP50": 80}
49 | """
50 |
51 |
52 | class DatasetEvaluators(DatasetEvaluator):
53 | def __init__(self, evaluators):
54 | assert len(evaluators)
55 | super().__init__()
56 | self._evaluators = evaluators
57 |
58 | def reset(self):
59 | for evaluator in self._evaluators:
60 | evaluator.reset()
61 |
62 | def process(self, input, output):
63 | for evaluator in self._evaluators:
64 | evaluator.process(input, output)
65 |
66 | def evaluate(self):
67 | results = OrderedDict()
68 | for evaluator in self._evaluators:
69 | result = evaluator.evaluate()
70 | if is_main_process():
71 | for k, v in result.items():
72 | assert (
73 | k not in results
74 | ), "Different evaluators produce results with the same key {}".format(
75 | k
76 | )
77 | results[k] = v
78 | return results
79 |
80 |
81 | def inference_on_dataset(model, data_loader, evaluator):
82 | """
83 | Run model on the data_loader and evaluate the metrics with evaluator.
84 | The model will be used in eval mode.
85 |
86 | Args:
87 | model (nn.Module): a module which accepts an object from
88 | `data_loader` and returns some outputs. It will be temporarily set to `eval` mode.
89 |
90 | If you wish to evaluate a model in `training` mode instead, you can
91 | wrap the given model and override its behavior of `.eval()` and `.train()`.
92 | data_loader: an iterable object with a length.
93 | The elements it generates will be the inputs to the model.
94 | evaluator (DatasetEvaluator): the evaluator to run. Use
95 | :class:`DatasetEvaluators([])` if you only want to benchmark, but
96 | don't want to do any evaluation.
97 |
98 | Returns:
99 | The return value of `evaluator.evaluate()`
100 | """
101 | num_devices = (
102 | torch.distributed.get_world_size()
103 | if torch.distributed.is_initialized()
104 | else 1
105 | )
106 | logger = logging.getLogger(__name__)
107 | logger.info("Start inference on {} images".format(len(data_loader)))
108 |
109 | total = len(data_loader) # inference data loader must have a fixed length
110 | evaluator.reset()
111 |
112 | logging_interval = 50
113 | num_warmup = min(5, logging_interval - 1, total - 1)
114 | start_time = time.time()
115 | total_compute_time = 0
116 | with inference_context(model), torch.no_grad():
117 | for idx, inputs in enumerate(data_loader):
118 | if idx == num_warmup:
119 | start_time = time.time()
120 | total_compute_time = 0
121 |
122 | start_compute_time = time.time()
123 | outputs = model(inputs)
124 | torch.cuda.synchronize()
125 | total_compute_time += time.time() - start_compute_time
126 | evaluator.process(inputs, outputs)
127 |
128 | if (idx + 1) % logging_interval == 0:
129 | duration = time.time() - start_time
130 | seconds_per_img = duration / (idx + 1 - num_warmup)
131 | eta = datetime.timedelta(
132 | seconds=int(
133 | seconds_per_img * (total - num_warmup) - duration
134 | )
135 | )
136 | logger.info(
137 | "Inference done {}/{}. {:.4f} s / img. ETA={}".format(
138 | idx + 1, total, seconds_per_img, str(eta)
139 | )
140 | )
141 |
142 | # Measure the time only for this worker (before the synchronization barrier)
143 | total_time = int(time.time() - start_time)
144 | total_time_str = str(datetime.timedelta(seconds=total_time))
145 | # NOTE this format is parsed by grep
146 | logger.info(
147 | "Total inference time: {} ({:.6f} s / img per device, on {} devices)".format(
148 | total_time_str, total_time / (total - num_warmup), num_devices
149 | )
150 | )
151 | total_compute_time_str = str(
152 | datetime.timedelta(seconds=int(total_compute_time))
153 | )
154 | logger.info(
155 | "Total inference pure compute time: {} ({:.6f} s / img per device, on {} devices)".format(
156 | total_compute_time_str,
157 | total_compute_time / (total - num_warmup),
158 | num_devices,
159 | )
160 | )
161 |
162 | results = evaluator.evaluate()
163 | # An evaluator may return None when not in main process.
164 | # Replace it by an empty dict instead to make it easier for downstream code to handle
165 | if results is None:
166 | results = {}
167 | return results
168 |
169 |
170 | @contextmanager
171 | def inference_context(model):
172 | """
173 | A context where the model is temporarily changed to eval mode,
174 | and restored to previous mode afterwards.
175 |
176 | Args:
177 | model: a torch Module
178 | """
179 | training_mode = model.training
180 | model.eval()
181 | yield
182 | model.train(training_mode)
183 |
--------------------------------------------------------------------------------
/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 |
8 | import detectron2.utils.comm as comm
9 | import torch
10 | from detectron2.data import MetadataCatalog
11 | from detectron2.utils.logger import create_small_table
12 | from fsdet.evaluation.coco_evaluation import instances_to_coco_json
13 | from fsdet.evaluation.evaluator import DatasetEvaluator
14 | from fsdet.utils.file_io import PathManager
15 |
16 |
17 | class LVISEvaluator(DatasetEvaluator):
18 | """
19 | Evaluate instance detection outputs using LVIS's metrics and evaluation API.
20 | """
21 |
22 | def __init__(self, dataset_name, cfg, distributed, output_dir=None):
23 | """
24 | Args:
25 | dataset_name (str): name of the dataset to be evaluated.
26 | It must have the following corresponding metadata:
27 | "json_file": the path to the LVIS format annotation
28 | cfg (CfgNode): config instance
29 | distributed (True): if True, will collect results from all ranks for evaluation.
30 | Otherwise, will evaluate the results in the current process.
31 | output_dir (str): optional, an output directory to dump results.
32 | """
33 | from lvis import LVIS
34 |
35 | self._distributed = distributed
36 | self._output_dir = output_dir
37 |
38 | self._cpu_device = torch.device("cpu")
39 | self._logger = logging.getLogger(__name__)
40 |
41 | self._metadata = MetadataCatalog.get(dataset_name)
42 | json_file = PathManager.get_local_path(self._metadata.json_file)
43 | self._lvis_api = LVIS(json_file)
44 | # Test set json files do not contain annotations (evaluation must be
45 | # performed using the LVIS evaluation server).
46 | self._do_evaluation = len(self._lvis_api.get_ann_ids()) > 0
47 |
48 | def reset(self):
49 | self._predictions = []
50 | self._lvis_results = []
51 |
52 | def process(self, inputs, outputs):
53 | """
54 | Args:
55 | inputs: the inputs to a LVIS model (e.g., GeneralizedRCNN).
56 | It is a list of dict. Each dict corresponds to an image and
57 | contains keys like "height", "width", "file_name", "image_id".
58 | outputs: the outputs of a LVIS model. It is a list of dicts with key
59 | "instances" that contains :class:`Instances`.
60 | """
61 | for input, output in zip(inputs, outputs):
62 | prediction = {"image_id": input["image_id"]}
63 |
64 | if "instances" in output:
65 | instances = output["instances"].to(self._cpu_device)
66 | prediction["instances"] = instances_to_coco_json(
67 | instances, input["image_id"]
68 | )
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 | )
84 | return {}
85 |
86 | if self._output_dir:
87 | PathManager.mkdirs(self._output_dir)
88 | file_path = os.path.join(
89 | self._output_dir, "instances_predictions.pth"
90 | )
91 | with PathManager.open(file_path, "wb") as f:
92 | torch.save(self._predictions, f)
93 |
94 | self._results = OrderedDict()
95 | if "instances" in self._predictions[0]:
96 | self._eval_predictions()
97 | # Copy so the caller can do whatever with results
98 | return copy.deepcopy(self._results)
99 |
100 | def _eval_predictions(self):
101 | """
102 | Evaluate self._predictions on the instance detection task.
103 | Fill self._results with the metrics of the instance detection task.
104 | """
105 | self._logger.info("Preparing results in the LVIS format ...")
106 | self._lvis_results = list(
107 | itertools.chain(*[x["instances"] for x in self._predictions])
108 | )
109 |
110 | # unmap the category ids for LVIS
111 | if hasattr(self._metadata, "class_mapping"):
112 | # using reverse mapping
113 | reverse_id_mapping = {
114 | v: k for k, v in self._metadata.class_mapping.items()
115 | }
116 | for result in self._lvis_results:
117 | result["category_id"] = (
118 | reverse_id_mapping[result["category_id"]] + 1
119 | )
120 | else:
121 | # from 0-indexed to 1-indexed
122 | for result in self._lvis_results:
123 | result["category_id"] += 1
124 |
125 | if self._output_dir:
126 | file_path = os.path.join(
127 | self._output_dir, "lvis_instances_results.json"
128 | )
129 | self._logger.info("Saving results to {}".format(file_path))
130 | with PathManager.open(file_path, "w") as f:
131 | f.write(json.dumps(self._lvis_results))
132 | f.flush()
133 |
134 | if not self._do_evaluation:
135 | self._logger.info("Annotations are not available for evaluation.")
136 | return
137 |
138 | self._logger.info("Evaluating predictions ...")
139 | res = _evaluate_predictions_on_lvis(
140 | self._lvis_api,
141 | self._lvis_results,
142 | "bbox",
143 | class_names=self._metadata.get("thing_classes"),
144 | )
145 | self._results["bbox"] = res
146 |
147 |
148 | def _evaluate_predictions_on_lvis(
149 | lvis_gt, lvis_results, iou_type, class_names=None
150 | ):
151 | """
152 | Args:
153 | iou_type (str):
154 | class_names (None or list[str]): if provided, will use it to predict
155 | per-category AP.
156 |
157 | Returns:
158 | a dict of {metric name: score}
159 | """
160 | metrics = ["AP", "AP50", "AP75", "APs", "APm", "APl", "APr", "APc", "APf"]
161 |
162 | logger = logging.getLogger(__name__)
163 |
164 | if len(lvis_results) == 0: # TODO: check if needed
165 | logger.warn("No predictions from the model! Set scores to -1")
166 | return {metric: -1 for metric in metrics}
167 |
168 | from lvis import LVISEval, LVISResults
169 |
170 | lvis_results = LVISResults(lvis_gt, lvis_results)
171 | lvis_eval = LVISEval(lvis_gt, lvis_results, iou_type)
172 | lvis_eval.run()
173 | lvis_eval.print_results()
174 |
175 | # Pull the standard metrics from the LVIS results
176 | results = lvis_eval.get_results()
177 | results = {metric: float(results[metric] * 100) for metric in metrics}
178 | logger.info(
179 | "Evaluation results for {}: \n".format(iou_type)
180 | + create_small_table(results)
181 | )
182 | return results
183 |
--------------------------------------------------------------------------------
/fsdet/evaluation/testing.py:
--------------------------------------------------------------------------------
1 | import logging
2 | import pprint
3 | import sys
4 | from collections import Mapping, OrderedDict
5 |
6 | import numpy as np
7 |
8 |
9 | def print_csv_format(results):
10 | """
11 | Print main metrics in a format similar to Detectron,
12 | so that they are easy to copypaste into a spreadsheet.
13 |
14 | Args:
15 | results (OrderedDict[dict]): task_name -> {metric -> score}
16 | """
17 | assert isinstance(
18 | results, OrderedDict
19 | ), results # unordered results cannot be properly printed
20 | logger = logging.getLogger(__name__)
21 | for task, res in results.items():
22 | # Don't print "AP-category" metrics since they are usually not tracked.
23 | important_res = [(k, v) for k, v in res.items() if "-" not in k]
24 | logger.info("copypaste: Task: {}".format(task))
25 | logger.info("copypaste: " + ",".join([k[0] for k in important_res]))
26 | logger.info(
27 | "copypaste: "
28 | + ",".join(["{0:.4f}".format(k[1]) for k in important_res])
29 | )
30 |
31 |
32 | def verify_results(cfg, results):
33 | """
34 | Args:
35 | results (OrderedDict[dict]): task_name -> {metric -> score}
36 |
37 | Returns:
38 | bool: whether the verification succeeds or not
39 | """
40 | expected_results = cfg.TEST.EXPECTED_RESULTS
41 | if not len(expected_results):
42 | return True
43 |
44 | ok = True
45 | for task, metric, expected, tolerance in expected_results:
46 | actual = results[task][metric]
47 | if not np.isfinite(actual):
48 | ok = False
49 | diff = abs(actual - expected)
50 | if diff > tolerance:
51 | ok = False
52 |
53 | logger = logging.getLogger(__name__)
54 | if not ok:
55 | logger.error("Result verification failed!")
56 | logger.error("Expected Results: " + str(expected_results))
57 | logger.error("Actual Results: " + pprint.pformat(results))
58 |
59 | sys.exit(1)
60 | else:
61 | logger.info("Results verification passed.")
62 | return ok
63 |
64 |
65 | def flatten_results_dict(results):
66 | """
67 | Expand a hierarchical dict of scalars into a flat dict of scalars.
68 | If results[k1][k2][k3] = v, the returned dict will have the entry
69 | {"k1/k2/k3": v}.
70 |
71 | Args:
72 | results (dict):
73 | """
74 | r = {}
75 | for k, v in results.items():
76 | if isinstance(v, Mapping):
77 | v = flatten_results_dict(v)
78 | for kk, vv in v.items():
79 | r[k + "/" + kk] = vv
80 | else:
81 | r[k] = v
82 | return r
83 |
--------------------------------------------------------------------------------
/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 (
2 | META_ARCH_REGISTRY,
3 | GeneralizedRCNN,
4 | ProposalNetwork,
5 | build_model,
6 | )
7 | from .roi_heads import (
8 | ROI_BOX_HEAD_REGISTRY,
9 | ROI_HEADS_REGISTRY,
10 | ROIHeads,
11 | StandardROIHeads,
12 | build_box_head,
13 | build_roi_heads,
14 | )
15 |
--------------------------------------------------------------------------------
/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,
4 | ROIHeads,
5 | StandardROIHeads,
6 | build_roi_heads,
7 | select_foreground_proposals,
8 | )
9 |
--------------------------------------------------------------------------------
/fsdet/modeling/roi_heads/box_head.py:
--------------------------------------------------------------------------------
1 | # flake8: noqa
2 | import fvcore.nn.weight_init as weight_init
3 | import numpy as np
4 | import torch
5 | from detectron2.layers import Conv2d, ShapeSpec, get_norm
6 | from detectron2.utils.registry import Registry
7 | from torch import nn
8 | from torch.nn import functional as F
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 | # noqa: E221
35 | # fmt: off
36 | num_conv = cfg.MODEL.ROI_BOX_HEAD.NUM_CONV
37 | conv_dim = cfg.MODEL.ROI_BOX_HEAD.CONV_DIM
38 | num_fc = cfg.MODEL.ROI_BOX_HEAD.NUM_FC
39 | fc_dim = cfg.MODEL.ROI_BOX_HEAD.FC_DIM
40 | norm = cfg.MODEL.ROI_BOX_HEAD.NORM
41 | # fmt: on
42 | assert num_conv + num_fc > 0
43 |
44 | self._output_size = (
45 | input_shape.channels,
46 | input_shape.height,
47 | input_shape.width,
48 | )
49 |
50 | self.conv_norm_relus = []
51 | for k in range(num_conv):
52 | conv = Conv2d(
53 | self._output_size[0],
54 | conv_dim,
55 | kernel_size=3,
56 | padding=1,
57 | bias=not norm,
58 | norm=get_norm(norm, conv_dim),
59 | activation=F.relu,
60 | )
61 | self.add_module("conv{}".format(k + 1), conv)
62 | self.conv_norm_relus.append(conv)
63 | self._output_size = (
64 | conv_dim,
65 | self._output_size[1],
66 | self._output_size[2],
67 | )
68 |
69 | self.fcs = []
70 | for k in range(num_fc):
71 | fc = nn.Linear(np.prod(self._output_size), fc_dim)
72 | self.add_module("fc{}".format(k + 1), fc)
73 | self.fcs.append(fc)
74 | self._output_size = fc_dim
75 |
76 | for layer in self.conv_norm_relus:
77 | weight_init.c2_msra_fill(layer)
78 | for layer in self.fcs:
79 | weight_init.c2_xavier_fill(layer)
80 |
81 | def forward(self, x):
82 | for layer in self.conv_norm_relus:
83 | x = layer(x)
84 | if len(self.fcs):
85 | if x.dim() > 2:
86 | x = torch.flatten(x, start_dim=1)
87 | for layer in self.fcs:
88 | x = F.relu(layer(x))
89 | return x
90 |
91 | @property
92 | def output_size(self):
93 | return self._output_size
94 |
95 |
96 | def build_box_head(cfg, input_shape):
97 | """
98 | Build a box head defined by `cfg.MODEL.ROI_BOX_HEAD.NAME`.
99 | """
100 | name = cfg.MODEL.ROI_BOX_HEAD.NAME
101 | return ROI_BOX_HEAD_REGISTRY.get(name)(cfg, input_shape)
102 |
--------------------------------------------------------------------------------
/fsdet/utils/file_io.py:
--------------------------------------------------------------------------------
1 | from iopath.common.file_io import (
2 | HTTPURLHandler,
3 | OneDrivePathHandler,
4 | PathHandler,
5 | PathManager as PathManagerBase,
6 | )
7 |
8 | __all__ = ["PathManager", "PathHandler"]
9 |
10 |
11 | PathManager = PathManagerBase()
12 | """
13 | This is a detectron2 project-specific PathManager.
14 | We try to stay away from global PathManager in fvcore as it
15 | introduces potential conflicts among other libraries.
16 | """
17 |
18 |
19 | class Detectron2Handler(PathHandler):
20 | """
21 | Resolve anything that's hosted under detectron2's namespace.
22 | """
23 |
24 | PREFIX = "detectron2://"
25 | S3_DETECTRON2_PREFIX = "https://dl.fbaipublicfiles.com/detectron2/"
26 |
27 | def _get_supported_prefixes(self):
28 | return [self.PREFIX]
29 |
30 | def _get_local_path(self, path):
31 | name = path[len(self.PREFIX) :]
32 | return PathManager.get_local_path(self.S3_DETECTRON2_PREFIX + name)
33 |
34 | def _open(self, path, mode="r", **kwargs):
35 | return PathManager.open(self._get_local_path(path), mode, **kwargs)
36 |
37 |
38 | class FsDetHandler(PathHandler):
39 | """
40 | Resolve anything that's in FsDet model zoo.
41 | """
42 |
43 | PREFIX = "fsdet://"
44 | URL_PREFIX = "http://dl.yf.io/fs-det/models/"
45 |
46 | def _get_supported_prefixes(self):
47 | return [self.PREFIX]
48 |
49 | def _get_local_path(self, path):
50 | name = path[len(self.PREFIX) :]
51 | return PathManager.get_local_path(self.URL_PREFIX + name)
52 |
53 | def _open(self, path, mode="r", **kwargs):
54 | return PathManager.open(self._get_local_path(path), mode, **kwargs)
55 |
56 |
57 | PathManager.register_handler(HTTPURLHandler())
58 | PathManager.register_handler(OneDrivePathHandler())
59 | PathManager.register_handler(Detectron2Handler())
60 | PathManager.register_handler(FsDetHandler())
61 |
--------------------------------------------------------------------------------
/pyproject.toml:
--------------------------------------------------------------------------------
1 | [tool.black]
2 | exclude = '''
3 | /(
4 | \.git
5 | | \.hg
6 | | \.mypy_cache
7 | | \.tox
8 | | \.venv
9 | | _build
10 | | buck-out
11 | | build
12 | | dist
13 | )/
14 | '''
15 | include = '\.pyi?$'
16 | line-length = 79
17 |
--------------------------------------------------------------------------------
/requirements-dev.txt:
--------------------------------------------------------------------------------
1 | pre-commit
2 |
--------------------------------------------------------------------------------
/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
14 |
--------------------------------------------------------------------------------
/tools/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wz940216/few-shot-object-detection/148a039af7abce9eff59d5cdece296ad1d2b8aa0/tools/__init__.py
--------------------------------------------------------------------------------
/tools/aggregate_seeds.py:
--------------------------------------------------------------------------------
1 | import argparse
2 | import json
3 | import math
4 | import os
5 |
6 | import matplotlib.pyplot as plt
7 | import numpy as np
8 |
9 |
10 | def parse_args():
11 | parser = argparse.ArgumentParser()
12 | parser.add_argument(
13 | "--shots", type=int, default=1, help="Shots to aggregate over"
14 | )
15 | parser.add_argument(
16 | "--seeds", type=int, default=30, help="Seeds to aggregate over"
17 | )
18 | # Model
19 | parser.add_argument(
20 | "--fc", action="store_true", help="Model uses FC instead of cosine"
21 | )
22 | parser.add_argument(
23 | "--unfreeze", action="store_true", help="Unfreeze feature extractor"
24 | )
25 | parser.add_argument(
26 | "--suffix", type=str, default="", help="Suffix of path"
27 | )
28 | # Output arguments
29 | parser.add_argument("--print", action="store_true", help="Clean output")
30 | parser.add_argument("--plot", action="store_true", help="Plot results")
31 | parser.add_argument(
32 | "--save-dir",
33 | type=str,
34 | default=".",
35 | help="Save dir for generated plots",
36 | )
37 | # PASCAL arguments
38 | parser.add_argument("--split", type=int, default=1, help="Data split")
39 | # COCO arguments
40 | parser.add_argument("--coco", action="store_true", help="Use COCO dataset")
41 |
42 | args = parser.parse_args()
43 | return args
44 |
45 |
46 | def main(args): # noqa: C901
47 | metrics = {}
48 | num_ckpts = 0
49 | dataset = "coco" if args.coco else "voc"
50 | if args.fc:
51 | fc = "_fc"
52 | else:
53 | fc = "_normalized" if not args.coco else ""
54 | if args.unfreeze:
55 | unfreeze = "_unfreeze"
56 | else:
57 | unfreeze = "_randnovel" if not args.coco else ""
58 | for i in range(args.seeds):
59 | seed = "seed{}/".format(i) if i != 0 else ""
60 | prefix = "checkpoints/{}/faster_rcnn/{}".format(dataset, seed)
61 | prefix += "faster_rcnn_R_101_FPN_ft{}_all".format(fc)
62 | if args.coco:
63 | ckpt = prefix + "_{}shot{}".format(args.shots, unfreeze)
64 | else:
65 | ckpt = prefix + "{}_{}shot{}{}".format(
66 | args.split, args.shots, unfreeze, args.suffix
67 | )
68 | if os.path.exists(ckpt):
69 | if os.path.exists(os.path.join(ckpt, "inference/all_res.json")):
70 | ckpt_ = os.path.join(ckpt, "inference/all_res.json")
71 | res = json.load(open(ckpt_, "r"))
72 | res = res[os.path.join(ckpt, "model_final.pth")]["bbox"]
73 | elif os.path.exists(
74 | os.path.join(ckpt, "inference/res_final.json")
75 | ):
76 | ckpt = os.path.join(ckpt, "inference/res_final.json")
77 | res = json.load(open(ckpt, "r"))["bbox"]
78 | else:
79 | print("Missing: {}".format(ckpt))
80 | continue
81 |
82 | for metric in res:
83 | if metric in metrics:
84 | metrics[metric].append(res[metric])
85 | else:
86 | metrics[metric] = [res[metric]]
87 | num_ckpts += 1
88 | else:
89 | print("Missing: {}".format(ckpt))
90 | print("Num ckpts: {}".format(num_ckpts))
91 | print("")
92 |
93 | # Output results
94 | if args.print:
95 | # Clean output for copy and pasting
96 | out_str = ""
97 | for metric in metrics:
98 | out_str += "{0:.1f} ".format(np.mean(metrics[metric]))
99 | print(out_str)
100 | out_str = ""
101 | for metric in metrics:
102 | out_str += "{0:.1f} ".format(
103 | 1.96
104 | * np.std(metrics[metric])
105 | / math.sqrt(len(metrics[metric]))
106 | )
107 | print(out_str)
108 | out_str = ""
109 | for metric in metrics:
110 | out_str += "{0:.1f} ".format(np.std(metrics[metric]))
111 | print(out_str)
112 | out_str = ""
113 | for metric in metrics:
114 | out_str += "{0:.1f} ".format(np.percentile(metrics[metric], 25))
115 | print(out_str)
116 | out_str = ""
117 | for metric in metrics:
118 | out_str += "{0:.1f} ".format(np.percentile(metrics[metric], 50))
119 | print(out_str)
120 | out_str = ""
121 | for metric in metrics:
122 | out_str += "{0:.1f} ".format(np.percentile(metrics[metric], 75))
123 | print(out_str)
124 | else:
125 | # Verbose output
126 | for metric in metrics:
127 | print(metric)
128 | print("Mean \t {0:.4f}".format(np.mean(metrics[metric])))
129 | print("Std \t {0:.4f}".format(np.std(metrics[metric])))
130 | print("Q1 \t {0:.4f}".format(np.percentile(metrics[metric], 25)))
131 | print(
132 | "Median \t {0:.4f}".format(np.percentile(metrics[metric], 50))
133 | )
134 | print("Q3 \t {0:.4f}".format(np.percentile(metrics[metric], 75)))
135 | print("")
136 |
137 | # Plot results
138 | if args.plot:
139 | os.makedirs(args.save_dir, exist_ok=True)
140 |
141 | for met in ["avg", "stdev", "ci"]:
142 | for metric, c in zip(
143 | ["nAP", "nAP50", "nAP75"], ["bo-", "ro-", "go-"]
144 | ):
145 | if met == "avg":
146 | res = [
147 | np.mean(metrics[metric][: i + 1])
148 | for i in range(len(metrics[metric]))
149 | ]
150 | elif met == "stdev":
151 | res = [
152 | np.std(metrics[metric][:i])
153 | for i in range(1, len(metrics[metric]) + 1)
154 | ]
155 | elif met == "ci":
156 | res = [
157 | 1.96
158 | * np.std(metrics[metric][: i + 1])
159 | / math.sqrt(len(metrics[metric][: i + 1]))
160 | for i in range(len(metrics[metric]))
161 | ]
162 | plt.plot(range(1, len(metrics[metric]) + 1), res, c)
163 | plt.legend(["nAP", "nAP50", "nAP75"])
164 | plt.title(
165 | "Split {}, {} Shots - Cumulative {} over {} Seeds".format(
166 | args.split, args.shots, met.upper(), args.seeds
167 | )
168 | )
169 | plt.xlabel("Number of seeds")
170 | plt.ylabel("Cumulative {}".format(met.upper()))
171 | plt.savefig(
172 | os.path.join(
173 | args.save_dir,
174 | "split{}_{}shots_{}_vs_{}seeds.png".format(
175 | args.split, args.shots, met, args.seeds
176 | ),
177 | )
178 | )
179 | plt.clf()
180 |
181 |
182 | if __name__ == "__main__":
183 | args = parse_args()
184 | main(args)
185 |
--------------------------------------------------------------------------------
/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 | import os
18 |
19 | import detectron2.utils.comm as comm
20 | from detectron2.checkpoint import DetectionCheckpointer
21 | from detectron2.data import MetadataCatalog
22 | from detectron2.engine import launch
23 |
24 | from fsdet.config import get_cfg, set_global_cfg
25 | from fsdet.engine import DefaultTrainer, default_argument_parser, default_setup
26 | from fsdet.evaluation import (
27 | COCOEvaluator,
28 | DatasetEvaluators,
29 | LVISEvaluator,
30 | PascalVOCDetectionEvaluator,
31 | verify_results,
32 | )
33 |
34 |
35 | class Trainer(DefaultTrainer):
36 | """
37 | We use the "DefaultTrainer" which contains a number pre-defined logic for
38 | standard training workflow. They may not work for you, especially if you
39 | are working on a new research project. In that case you can use the cleaner
40 | "SimpleTrainer", or write your own training loop.
41 | """
42 |
43 | @classmethod
44 | def build_evaluator(cls, cfg, dataset_name, output_folder=None):
45 | """
46 | Create evaluator(s) for a given dataset.
47 | This uses the special metadata "evaluator_type" associated with each builtin dataset.
48 | For your own dataset, you can simply create an evaluator manually in your
49 | script and do not have to worry about the hacky if-else logic here.
50 | """
51 | if output_folder is None:
52 | output_folder = os.path.join(cfg.OUTPUT_DIR, "inference")
53 | evaluator_list = []
54 | evaluator_type = MetadataCatalog.get(dataset_name).evaluator_type
55 | if evaluator_type == "coco":
56 | evaluator_list.append(
57 | COCOEvaluator(dataset_name, cfg, True, output_folder)
58 | )
59 | if evaluator_type == "pascal_voc":
60 | return PascalVOCDetectionEvaluator(dataset_name)
61 | if evaluator_type == "lvis":
62 | return LVISEvaluator(dataset_name, cfg, True, output_folder)
63 | if len(evaluator_list) == 0:
64 | raise NotImplementedError(
65 | "no Evaluator for the dataset {} with the type {}".format(
66 | dataset_name, evaluator_type
67 | )
68 | )
69 | if len(evaluator_list) == 1:
70 | return evaluator_list[0]
71 | return DatasetEvaluators(evaluator_list)
72 |
73 |
74 | def setup(args):
75 | """
76 | Create configs and perform basic setups.
77 | """
78 | cfg = get_cfg()
79 | cfg.merge_from_file(args.config_file)
80 | if args.opts:
81 | cfg.merge_from_list(args.opts)
82 | cfg.freeze()
83 | set_global_cfg(cfg)
84 | default_setup(cfg, args)
85 | return cfg
86 |
87 |
88 | def main(args):
89 | cfg = setup(args)
90 |
91 | if args.eval_only:
92 | model = Trainer.build_model(cfg)
93 | DetectionCheckpointer(model, save_dir=cfg.OUTPUT_DIR).resume_or_load(
94 | cfg.MODEL.WEIGHTS, resume=args.resume
95 | )
96 | res = Trainer.test(cfg, model)
97 | if comm.is_main_process():
98 | verify_results(cfg, res)
99 | return res
100 |
101 | """
102 | If you'd like to do anything fancier than the standard training logic,
103 | consider writing your own training loop or subclassing the trainer.
104 | """
105 | trainer = Trainer(cfg)
106 | trainer.resume_or_load(resume=args.resume)
107 | return trainer.train()
108 |
109 |
110 | if __name__ == "__main__":
111 | args = default_argument_parser().parse_args()
112 | print("Command Line Args:", args)
113 | launch(
114 | main,
115 | args.num_gpus,
116 | num_machines=args.num_machines,
117 | machine_rank=args.machine_rank,
118 | dist_url=args.dist_url,
119 | args=(args,),
120 | )
121 |
--------------------------------------------------------------------------------
/tools/visualize_data.py:
--------------------------------------------------------------------------------
1 | import argparse
2 | import os
3 | from itertools import chain
4 |
5 | import cv2
6 | import numpy as np
7 | from detectron2.config import get_cfg
8 | from detectron2.data import (
9 | DatasetCatalog,
10 | MetadataCatalog,
11 | build_detection_train_loader,
12 | )
13 | from detectron2.data import detection_utils as utils
14 | from detectron2.utils.logger import setup_logger
15 | from detectron2.utils.visualizer import Visualizer
16 | from PIL import Image
17 |
18 |
19 | def setup(args):
20 | cfg = get_cfg()
21 | if args.config_file:
22 | cfg.merge_from_file(args.config_file)
23 | cfg.merge_from_list(args.opts)
24 | cfg.freeze()
25 | return cfg
26 |
27 |
28 | def parse_args(in_args=None):
29 | parser = argparse.ArgumentParser(description="Visualize ground-truth data")
30 | parser.add_argument(
31 | "--source",
32 | choices=["annotation", "dataloader"],
33 | required=True,
34 | help="visualize the annotations or the data loader (with pre-processing)",
35 | )
36 | parser.add_argument(
37 | "--config-file", default="", metavar="FILE", help="path to config file"
38 | )
39 | parser.add_argument(
40 | "--output-dir", default="./", help="path to output directory"
41 | )
42 | parser.add_argument(
43 | "--show", action="store_true", help="show output in a window"
44 | )
45 | parser.add_argument(
46 | "opts",
47 | help="Modify config options using the command-line",
48 | default=None,
49 | nargs=argparse.REMAINDER,
50 | )
51 | return parser.parse_args(in_args)
52 |
53 |
54 | if __name__ == "__main__":
55 | args = parse_args()
56 | logger = setup_logger()
57 | logger.info("Arguments: " + str(args))
58 | cfg = setup(args)
59 |
60 | dirname = args.output_dir
61 | os.makedirs(dirname, exist_ok=True)
62 | metadata = MetadataCatalog.get(cfg.DATASETS.TRAIN[0])
63 |
64 | def output(vis, fname):
65 | if args.show:
66 | print(fname)
67 | cv2.imshow("window", vis.get_image()[:, :, ::-1])
68 | cv2.waitKey()
69 | else:
70 | filepath = os.path.join(dirname, fname)
71 | print("Saving to {} ...".format(filepath))
72 | vis.save(filepath)
73 |
74 | scale = 2.0 if args.show else 1.0
75 | if args.source == "dataloader":
76 | train_data_loader = build_detection_train_loader(cfg)
77 | for batch in train_data_loader:
78 | for per_image in batch:
79 | # Pytorch tensor is in (C, H, W) format
80 | img = per_image["image"].permute(1, 2, 0)
81 | if cfg.INPUT.FORMAT == "BGR":
82 | img = img[:, :, [2, 1, 0]]
83 | else:
84 | img = np.asarray(
85 | Image.fromarray(img, mode=cfg.INPUT.FORMAT).convert(
86 | "RGB"
87 | )
88 | )
89 |
90 | visualizer = Visualizer(img, metadata=metadata, scale=scale)
91 | target_fields = per_image["instances"].get_fields()
92 | labels = [
93 | metadata.thing_classes[i]
94 | for i in target_fields["gt_classes"]
95 | ]
96 | vis = visualizer.overlay_instances(
97 | labels=labels,
98 | boxes=target_fields.get("gt_boxes", None),
99 | )
100 | output(vis, str(per_image["image_id"]) + ".jpg")
101 | else:
102 | dicts = list(
103 | chain.from_iterable(
104 | [DatasetCatalog.get(k) for k in cfg.DATASETS.TRAIN]
105 | )
106 | )
107 | for dic in dicts:
108 | img = utils.read_image(dic["file_name"], "RGB")
109 | visualizer = Visualizer(img, metadata=metadata, scale=scale)
110 | vis = visualizer.draw_dataset_dict(dic)
111 | output(vis, os.path.basename(dic["file_name"]))
112 |
--------------------------------------------------------------------------------
/tools/visualize_json_results.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
3 |
4 | import argparse
5 | import json
6 | import os
7 | from collections import defaultdict
8 |
9 | import cv2
10 | import numpy as np
11 | import tqdm
12 | from detectron2.data import DatasetCatalog, MetadataCatalog
13 | from detectron2.structures import Boxes, BoxMode, Instances
14 | from detectron2.utils.logger import setup_logger
15 | from detectron2.utils.visualizer import Visualizer
16 | from fsdet.utils.file_io import PathManager
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 |
--------------------------------------------------------------------------------