Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

Commit 48a7eed

Browse files
authored
Merge pull request #1 from facebookresearch/master
更新
2 parents eb4d335 + 24c8c90 commit 48a7eed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+9225
-235
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ dist/
2525
# Pycharm editor settings
2626
.idea
2727

28+
# vscode editor settings
29+
.vscode
30+
31+
# MacOS
32+
.DS_Store
33+
2834
# project dirs
2935
/datasets
3036
/models

INSTALL.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,58 @@ unset INSTALL_DIR
6161
# or if you are on macOS
6262
# MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py build develop
6363
```
64+
#### Windows 10
65+
```bash
66+
open a cmd and change to desired installation directory
67+
from now on will be refered as INSTALL_DIR
68+
conda create --name maskrcnn_benchmark
69+
conda activate maskrcnn_benchmark
70+
71+
# this installs the right pip and dependencies for the fresh python
72+
conda install ipython
73+
74+
# maskrcnn_benchmark and coco api dependencies
75+
pip install ninja yacs cython matplotlib tqdm opencv-python
76+
77+
# follow PyTorch installation in https://pytorch.org/get-started/locally/
78+
# we give the instructions for CUDA 9.0
79+
## Important : check the cuda version installed on your computer by running the command in the cmd :
80+
nvcc -- version
81+
conda install -c pytorch pytorch-nightly torchvision cudatoolkit=9.0
82+
83+
git clone https://github.com/cocodataset/cocoapi.git
84+
85+
#To prevent installation error do the following after commiting cocooapi :
86+
#using file explorer naviagate to cocoapi\PythonAPI\setup.py and change line 14 from:
87+
#extra_compile_args=['-Wno-cpp', '-Wno-unused-function', '-std=c99'],
88+
#to
89+
#extra_compile_args={'gcc': ['/Qstd=c99']},
90+
#Based on https://github.com/cocodataset/cocoapi/issues/51
91+
92+
cd cocoapi/PythonAPI
93+
python setup.py build_ext install
94+
95+
# navigate back to INSTALL_DIR
96+
cd ..
97+
cd ..
98+
# install apex
99+
100+
git clone https://github.com/NVIDIA/apex.git
101+
cd apex
102+
python setup.py install --cuda_ext --cpp_ext
103+
# navigate back to INSTALL_DIR
104+
cd ..
105+
# install PyTorch Detection
64106

107+
git clone https://github.com/Idolized22/maskrcnn-benchmark.git
108+
cd maskrcnn-benchmark
109+
110+
# the following will install the lib with
111+
# symbolic links, so that you can modify
112+
# the files if you want and won't need to
113+
# re-build it
114+
python setup.py build develop
115+
```
65116
### Option 2: Docker Image (Requires CUDA, Linux only)
66117

67118
Build image with defaults (`CUDA=9.0`, `CUDNN=7`, `FORCE_CUDA=1`):

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ creating detection and segmentation models using PyTorch 1.0.
1010
- **Very fast**: up to **2x** faster than [Detectron](https://github.com/facebookresearch/Detectron) and **30%** faster than [mmdetection](https://github.com/open-mmlab/mmdetection) during training. See [MODEL_ZOO.md](MODEL_ZOO.md) for more details.
1111
- **Memory efficient:** uses roughly 500MB less GPU memory than mmdetection during training
1212
- **Multi-GPU training and inference**
13+
- **Mixed precision training:** trains faster with less GPU memory on [NVIDIA tensor cores](https://developer.nvidia.com/tensor-cores).
1314
- **Batched inference:** can perform inference using multiple images per batch per GPU
1415
- **CPU support for inference:** runs on CPU in inference time. See our [webcam demo](demo) for an example
1516
- Provides pre-trained models for almost all reference Mask R-CNN and Faster R-CNN configurations with 1x schedule.
@@ -152,6 +153,15 @@ python -m torch.distributed.launch --nproc_per_node=$NGPUS /path_to_maskrcnn_ben
152153
```
153154
Note we should set `MODEL.RPN.FPN_POST_NMS_TOP_N_TRAIN` follow the rule in Single-GPU training.
154155

156+
### Mixed precision training
157+
We currently use [APEX](https://github.com/NVIDIA/apex) to add [Automatic Mixed Precision](https://developer.nvidia.com/automatic-mixed-precision) support. To enable, just do Single-GPU or Multi-GPU training and set `DTYPE "float16"`.
158+
159+
```bash
160+
export NGPUS=8
161+
python -m torch.distributed.launch --nproc_per_node=$NGPUS /path_to_maskrcnn_benchmark/tools/train_net.py --config-file "path/to/config/file.yaml" MODEL.RPN.FPN_POST_NMS_TOP_N_TRAIN images_per_gpu x 1000 DTYPE "float16"
162+
```
163+
If you want more verbose logging, set `AMP_VERBOSE True`. See [Mixed Precision Training guide](https://docs.nvidia.com/deeplearning/sdk/mixed-precision-training/index.html) for more details.
164+
155165
## Evaluation
156166
You can test your model directly on single or multiple gpus. Here is an example for Mask R-CNN R-50 FPN with the 1x schedule on 8 GPUS:
157167
```bash
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
MODEL:
2+
META_ARCHITECTURE: "GeneralizedRCNN"
3+
WEIGHT: "catalog://ImageNetPretrained/MSRA/R-50"
4+
BACKBONE:
5+
CONV_BODY: "R-50-FPN"
6+
RESNETS:
7+
BACKBONE_OUT_CHANNELS: 256
8+
RPN:
9+
USE_FPN: True
10+
ANCHOR_STRIDE: (4, 8, 16, 32, 64)
11+
PRE_NMS_TOP_N_TRAIN: 2000
12+
PRE_NMS_TOP_N_TEST: 1000
13+
POST_NMS_TOP_N_TEST: 1000
14+
FPN_POST_NMS_TOP_N_TEST: 1000
15+
ROI_HEADS:
16+
USE_FPN: True
17+
ROI_BOX_HEAD:
18+
POOLER_RESOLUTION: 7
19+
POOLER_SCALES: (0.25, 0.125, 0.0625, 0.03125)
20+
POOLER_SAMPLING_RATIO: 2
21+
FEATURE_EXTRACTOR: "FPN2MLPFeatureExtractor"
22+
PREDICTOR: "FPNPredictor"
23+
ROI_MASK_HEAD:
24+
POOLER_SCALES: (0.25, 0.125, 0.0625, 0.03125)
25+
FEATURE_EXTRACTOR: "MaskRCNNFPNFeatureExtractor"
26+
PREDICTOR: "MaskRCNNC4Predictor"
27+
POOLER_RESOLUTION: 14
28+
POOLER_SAMPLING_RATIO: 2
29+
RESOLUTION: 28
30+
SHARE_BOX_FEATURE_EXTRACTOR: False
31+
MASK_ON: True
32+
DATASETS:
33+
TRAIN: ("coco_2014_train", "coco_2014_valminusminival")
34+
TEST: ("coco_2014_minival",)
35+
DATALOADER:
36+
SIZE_DIVISIBILITY: 32
37+
SOLVER:
38+
BASE_LR: 0.02
39+
WEIGHT_DECAY: 0.0001
40+
STEPS: (60000, 80000)
41+
MAX_ITER: 90000
42+
TEST:
43+
BBOX_AUG:
44+
ENABLED: True
45+
H_FLIP: True
46+
SCALES: (400, 500, 600, 700, 900, 1000, 1100, 1200)
47+
MAX_SIZE: 2000
48+
SCALE_H_FLIP: True

0 commit comments

Comments
 (0)