-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7317132
commit 7c25597
Showing
20 changed files
with
2,033 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
## Installation | ||
|
||
### Requirements: | ||
- Python3 | ||
- PyTorch 1.1 with CUDA support | ||
- torchvision | ||
- pycocotools | ||
- yacs | ||
- matplotlib | ||
- GCC >= 4.9 | ||
- (optional) OpenCV for the webcam demo | ||
|
||
|
||
### Step-by-step installation | ||
|
||
```bash | ||
# first, make sure that your conda is setup properly with the right environment | ||
# for that, check that `which conda`, `which pip` and `which python` points to the | ||
# right path. From a clean conda env, this is what you need to do | ||
|
||
conda create --name free_anchor python=3.7 | ||
conda activate free_anchor | ||
|
||
# this installs the right pip and dependencies for the fresh python | ||
conda install ipython | ||
|
||
# maskrnn_benchmark and coco api dependencies | ||
pip install ninja yacs cython matplotlib tqdm | ||
|
||
# pytorch and torchvision | ||
# we give the instructions for CUDA 9.0 | ||
conda install pytorch torchvision cudatoolkit=9.0 -c pytorch | ||
|
||
# install pycocotools | ||
pip install pycocotools | ||
|
||
# install PyTorch maskrcnn-benchmark. | ||
cd path_to_free_anchor | ||
# the following will install the lib with | ||
# symbolic links, so that you can modify | ||
# the files if you want and won't need to | ||
# re-build it | ||
python setup.py build develop | ||
|
||
# or if you are on macOS | ||
# MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py build develop | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
## FreeAnchor | ||
|
||
The code is based on the [maskrcnn-benchmark](https://github.com/facebookresearch/maskrcnn-benchmark). | ||
|
||
## Installation | ||
Check [INSTALL.md](INSTALL.md) for installation instructions. | ||
|
||
## Perform Training on COCO dataset | ||
You will need to download the COCO dataset and configure your own paths to the datasets. | ||
|
||
For that, all you need to do is to modify `maskrcnn_benchmark/config/paths_catalog.py` to point to the location where your dataset is stored. | ||
|
||
### Config Files | ||
We provide four configuration files in the configs directory. | ||
|
||
| Backbone | Iter. | Setting | Config File | | ||
| :-----: | :---: | :---: | :----------: | | ||
| ResNet-50-FPN | 90k | std. | configs/free_anchor_R-50-FPN_1x.yaml | | ||
| ResNet-101-FPN | 90k | std. | configs/free_anchor_R-101-FPN_1x.yaml | | ||
| ResNet-101-FPN | 135k | std. | configs/free_anchor_R-101-FPN_1.5x.yaml | | ||
| ResNeXt-101-FPN | 135k | dev. | configs/free_anchor_X-101-FPN_j1.5x.yaml | | ||
|
||
|
||
### 4 GPU (32GB memory) Training | ||
|
||
```bash | ||
cd path_to_free_anchor | ||
export NGPUS=4 | ||
python -m torch.distributed.launch --nproc_per_node=$NGPUS tools/train_net.py --config-file "path/to/config/file.yaml" | ||
``` | ||
|
||
### 8 GPU (>10GB memory) Training | ||
|
||
```bash | ||
cd path_to_free_anchor | ||
export NGPUS=8 | ||
python -m torch.distributed.launch --nproc_per_node=$NGPUS tools/train_net.py --config-file "path/to/config/file.yaml" | ||
``` | ||
|
||
### Test on MS-COCO test-dev | ||
|
||
```bash | ||
cd path_to_free_anchor | ||
python -m torch.distributed.launch --nproc_per_node=$NGPUS tools/test_net.py --config-file "path/to/config/file.yaml" MODEL.WEIGHT "path/to/.pth file" DATASETS.TEST "('coco_test-dev',)" | ||
``` | ||
|
||
### Evaluate NMS Recall | ||
|
||
```bash | ||
cd path_to_free_anchor | ||
python -m torch.distributed.launch --nproc_per_node=$NGPUS tools/eval_NR.py --config-file "path/to/config/file.yaml" MODEL.WEIGHT "path/to/.pth file" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
MODEL: | ||
META_ARCHITECTURE: "RetinaNet" | ||
WEIGHT: "catalog://ImageNetPretrained/MSRA/R-101" | ||
RPN_ONLY: True | ||
BACKBONE: | ||
CONV_BODY: "R-101-FPN" | ||
OUT_CHANNELS: 256 | ||
RPN: | ||
USE_FPN: True | ||
ANCHOR_STRIDE: (4, 8, 16, 32, 64) | ||
PRE_NMS_TOP_N_TRAIN: 2000 | ||
PRE_NMS_TOP_N_TEST: 1000 | ||
POST_NMS_TOP_N_TEST: 1000 | ||
FPN_POST_NMS_TOP_N_TEST: 1000 | ||
NMS_THRESH: 0.5 | ||
DATASETS: | ||
TRAIN: ("coco_2017_train",) | ||
TEST: ("coco_2017_val",) | ||
INPUT: | ||
MIN_SIZE_TRAIN: (800,) | ||
MAX_SIZE_TRAIN: 1333 | ||
MIN_SIZE_TEST: 800 | ||
MAX_SIZE_TEST: 1333 | ||
DATALOADER: | ||
SIZE_DIVISIBILITY: 32 | ||
SOLVER: | ||
BASE_LR: 0.01 | ||
WEIGHT_DECAY: 0.0001 | ||
STEPS: (60000, 80000) | ||
MAX_ITER: 90000 | ||
IMS_PER_BATCH: 16 | ||
WARMUP_ITERS: 500 | ||
CHECKPOINT_PERIOD: 2500 | ||
RETINANET: | ||
RETINANET_ON: True | ||
NUM_CLASSES: 81 | ||
PRIOR_PROB: 0.02 | ||
SCALES_PER_OCTAVE: 3 | ||
STRADDLE_THRESH: -1 | ||
FREEANCHOR: | ||
FREEANCHOR_ON: True | ||
PRE_ANCHOR_TOPK: 50 | ||
BBOX_THRESHOLD: 0.6 | ||
BBOX_REG_WEIGHT: 0.75 | ||
FOCAL_LOSS_ALPHA: 0.5 | ||
FOCAL_LOSS_GAMMA: 2.0 | ||
OUTPUT_DIR: outputs/free_anchor_R-101-FPN_1x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
MODEL: | ||
META_ARCHITECTURE: "RetinaNet" | ||
WEIGHT: "catalog://ImageNetPretrained/MSRA/R-101" | ||
RPN_ONLY: True | ||
BACKBONE: | ||
CONV_BODY: "R-101-FPN" | ||
OUT_CHANNELS: 256 | ||
RPN: | ||
USE_FPN: True | ||
ANCHOR_STRIDE: (4, 8, 16, 32, 64) | ||
PRE_NMS_TOP_N_TRAIN: 2000 | ||
PRE_NMS_TOP_N_TEST: 1000 | ||
POST_NMS_TOP_N_TEST: 1000 | ||
FPN_POST_NMS_TOP_N_TEST: 1000 | ||
NMS_THRESH: 0.5 | ||
DATASETS: | ||
TRAIN: ("coco_2017_train",) | ||
TEST: ("coco_2017_val",) | ||
INPUT: | ||
MIN_SIZE_TRAIN: (800,) | ||
MAX_SIZE_TRAIN: 1333 | ||
MIN_SIZE_TEST: 800 | ||
MAX_SIZE_TEST: 1333 | ||
DATALOADER: | ||
SIZE_DIVISIBILITY: 32 | ||
SOLVER: | ||
BASE_LR: 0.01 | ||
WEIGHT_DECAY: 0.0001 | ||
STEPS: (90000, 120000) | ||
MAX_ITER: 135000 | ||
IMS_PER_BATCH: 16 | ||
WARMUP_ITERS: 500 | ||
CHECKPOINT_PERIOD: 2500 | ||
RETINANET: | ||
RETINANET_ON: True | ||
NUM_CLASSES: 81 | ||
PRIOR_PROB: 0.02 | ||
SCALES_PER_OCTAVE: 3 | ||
STRADDLE_THRESH: -1 | ||
FREEANCHOR: | ||
FREEANCHOR_ON: True | ||
PRE_ANCHOR_TOPK: 50 | ||
BBOX_THRESHOLD: 0.6 | ||
BBOX_REG_WEIGHT: 0.75 | ||
FOCAL_LOSS_ALPHA: 0.5 | ||
FOCAL_LOSS_GAMMA: 2.0 | ||
OUTPUT_DIR: outputs/free_anchor_R-101-FPN_1.5x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
MODEL: | ||
META_ARCHITECTURE: "RetinaNet" | ||
WEIGHT: "catalog://ImageNetPretrained/MSRA/R-50" | ||
RPN_ONLY: True | ||
BACKBONE: | ||
CONV_BODY: "R-50-FPN" | ||
OUT_CHANNELS: 256 | ||
RPN: | ||
USE_FPN: True | ||
ANCHOR_STRIDE: (4, 8, 16, 32, 64) | ||
PRE_NMS_TOP_N_TRAIN: 2000 | ||
PRE_NMS_TOP_N_TEST: 1000 | ||
POST_NMS_TOP_N_TEST: 1000 | ||
FPN_POST_NMS_TOP_N_TEST: 1000 | ||
NMS_THRESH: 0.5 | ||
DATASETS: | ||
TRAIN: ("coco_2017_train",) | ||
TEST: ("coco_2017_val",) | ||
INPUT: | ||
MIN_SIZE_TRAIN: (800,) | ||
MAX_SIZE_TRAIN: 1333 | ||
MIN_SIZE_TEST: 800 | ||
MAX_SIZE_TEST: 1333 | ||
DATALOADER: | ||
SIZE_DIVISIBILITY: 32 | ||
SOLVER: | ||
BASE_LR: 0.01 | ||
WEIGHT_DECAY: 0.0001 | ||
STEPS: (60000, 80000) | ||
MAX_ITER: 90000 | ||
IMS_PER_BATCH: 16 | ||
WARMUP_ITERS: 500 | ||
CHECKPOINT_PERIOD: 2500 | ||
RETINANET: | ||
RETINANET_ON: True | ||
NUM_CLASSES: 81 | ||
PRIOR_PROB: 0.02 | ||
SCALES_PER_OCTAVE: 3 | ||
STRADDLE_THRESH: -1 | ||
FREEANCHOR: | ||
FREEANCHOR_ON: True | ||
PRE_ANCHOR_TOPK: 50 | ||
BBOX_THRESHOLD: 0.6 | ||
BBOX_REG_WEIGHT: 0.75 | ||
FOCAL_LOSS_ALPHA: 0.5 | ||
FOCAL_LOSS_GAMMA: 2.0 | ||
OUTPUT_DIR: outputs/free_anchor_R-50-FPN_1x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
MODEL: | ||
META_ARCHITECTURE: "RetinaNet" | ||
WEIGHT: "catalog://ImageNetPretrained/FAIR/20171220/X-101-32x8d" | ||
RPN_ONLY: True | ||
BACKBONE: | ||
CONV_BODY: "R-101-FPN" | ||
OUT_CHANNELS: 256 | ||
RESNETS: | ||
STRIDE_IN_1X1: False | ||
NUM_GROUPS: 32 | ||
WIDTH_PER_GROUP: 8 | ||
RPN: | ||
USE_FPN: True | ||
ANCHOR_STRIDE: (4, 8, 16, 32, 64) | ||
PRE_NMS_TOP_N_TRAIN: 2000 | ||
PRE_NMS_TOP_N_TEST: 1000 | ||
POST_NMS_TOP_N_TEST: 1000 | ||
FPN_POST_NMS_TOP_N_TEST: 1000 | ||
NMS_THRESH: 0.5 | ||
DATASETS: | ||
TRAIN: ("coco_2017_train",) | ||
TEST: ("coco_2017_val",) | ||
INPUT: | ||
MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800,) | ||
MAX_SIZE_TRAIN: 1333 | ||
MIN_SIZE_TEST: 800 | ||
MAX_SIZE_TEST: 1333 | ||
DATALOADER: | ||
SIZE_DIVISIBILITY: 32 | ||
SOLVER: | ||
BASE_LR: 0.01 | ||
WEIGHT_DECAY: 0.0001 | ||
STEPS: (90000, 120000) | ||
MAX_ITER: 135000 | ||
IMS_PER_BATCH: 16 | ||
WARMUP_ITERS: 500 | ||
CHECKPOINT_PERIOD: 2500 | ||
RETINANET: | ||
RETINANET_ON: True | ||
NUM_CLASSES: 81 | ||
PRIOR_PROB: 0.02 | ||
SCALES_PER_OCTAVE: 3 | ||
STRADDLE_THRESH: -1 | ||
FREEANCHOR: | ||
FREEANCHOR_ON: True | ||
PRE_ANCHOR_TOPK: 50 | ||
BBOX_THRESHOLD: 0.6 | ||
BBOX_REG_WEIGHT: 0.75 | ||
FOCAL_LOSS_ALPHA: 0.5 | ||
FOCAL_LOSS_GAMMA: 2.0 | ||
OUTPUT_DIR: outputs/free_anchor_X-101-FPN_j1.5x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
## Webcam and Jupyter notebook demo | ||
|
||
This folder contains a simple webcam demo that illustrates how you can use `maskrcnn_benchmark` for inference. | ||
|
||
You can start it by running it from this folder, using one of the following commands: | ||
```bash | ||
# by default, it runs on the GPU | ||
# for best results, use min-image-size 800 | ||
python webcam.py --min-image-size 800 | ||
# can also run it on the CPU | ||
python webcam.py --min-image-size 300 MODEL.DEVICE cpu | ||
# or change the model that you want to use | ||
python webcam.py --config-file ../configs/caffe2/e2e_mask_rcnn_R_101_FPN_1x_caffe2.py --min-image-size 300 MODEL.DEVICE cpu | ||
# in order to see the probability heatmaps, pass --show-mask-heatmaps | ||
python webcam.py --min-image-size 300 --show-mask-heatmaps MODEL.DEVICE cpu | ||
``` |
Oops, something went wrong.