Skip to content

Commit eb8c3b2

Browse files
committed
Add custom maskrcnn-benchmark
- support training when no ground truth boxes are present - support RandomGrayscale data augmentation
0 parents  commit eb8c3b2

File tree

241 files changed

+37807
-0
lines changed

Some content is hidden

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

241 files changed

+37807
-0
lines changed

.dockerignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
*
2+
!maskrcnn_benchmark/engine/trainer.py
3+
!maskrcnn_benchmark/modeling/matcher.py
4+
!maskrcnn_benchmark/modeling/roi_heads/box_head/loss.py
5+
!maskrcnn_benchmark/modeling/rpn/loss.py
6+
!maskrcnn_benchmark/config/defaults.py
7+
!maskrcnn_benchmark/data/transforms/__init__.py
8+
!maskrcnn_benchmark/data/transforms/build.py
9+
!maskrcnn_benchmark/data/transforms/transforms.py
10+
!maskrcnn_benchmark/engine/trainer.py
11+
!maskrcnn_benchmark/engine/bbox_aug.py
12+
!maskrcnn_benchmark/config/paths_catalog.py
13+
!maskrcnn_benchmark/data/datasets/__init__.py
14+
!maskrcnn_benchmark/data/datasets/kuzushiji.py
15+
!maskrcnn_benchmark/data/datasets/evaluation/__init__.py
16+
!maskrcnn_benchmark/data/datasets/evaluation/kuzushiji/__init__.py
17+
!maskrcnn_benchmark/data/datasets/evaluation/kuzushiji/kuzushiji_eval.py
18+
!requirements.txt

Dockerfile

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
ARG CUDA="10.0"
2+
ARG CUDNN="7"
3+
4+
FROM nvidia/cuda:${CUDA}-cudnn${CUDNN}-devel-ubuntu16.04
5+
6+
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
7+
8+
# install basics
9+
RUN apt-get update -y \
10+
&& apt-get install -y apt-utils git curl ca-certificates bzip2 cmake tree htop bmon iotop g++ \
11+
&& apt-get install -y libglib2.0-0 libsm6 libxext6 libxrender-dev
12+
13+
# Install Miniconda
14+
RUN curl -so /miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \
15+
&& chmod +x /miniconda.sh \
16+
&& /miniconda.sh -b -p /miniconda \
17+
&& rm /miniconda.sh
18+
19+
ENV PATH=/miniconda/bin:$PATH
20+
21+
# Create a Python 3.6 environment
22+
RUN /miniconda/bin/conda install -y conda-build \
23+
&& /miniconda/bin/conda create -y --name py36 python=3.6.7 \
24+
&& /miniconda/bin/conda clean -ya
25+
26+
ENV CONDA_DEFAULT_ENV=py36
27+
ENV CONDA_PREFIX=/miniconda/envs/$CONDA_DEFAULT_ENV
28+
ENV PATH=$CONDA_PREFIX/bin:$PATH
29+
ENV CONDA_AUTO_UPDATE_CONDA=false
30+
31+
RUN conda install -y ipython
32+
RUN pip install requests ninja yacs cython matplotlib opencv-python tqdm
33+
34+
# Install PyTorch
35+
ARG CUDA
36+
RUN conda install pytorch=1.2 torchvision cudatoolkit=${CUDA} -c pytorch \
37+
&& conda clean -ya
38+
39+
# install pycocotools
40+
RUN git clone https://github.com/cocodataset/cocoapi.git \
41+
&& cd cocoapi/PythonAPI \
42+
&& python setup.py build_ext install
43+
44+
# install apex
45+
RUN git clone https://github.com/NVIDIA/apex.git \
46+
&& cd apex \
47+
&& python setup.py install --cuda_ext --cpp_ext
48+
49+
RUN apt-get install -y vim
50+
51+
# install PyTorch Detection
52+
ARG FORCE_CUDA="1"
53+
ENV FORCE_CUDA=${FORCE_CUDA}
54+
RUN git clone https://github.com/facebookresearch/maskrcnn-benchmark.git /maskrcnn-benchmark
55+
WORKDIR /maskrcnn-benchmark
56+
COPY ./maskrcnn_benchmark/engine/trainer.py maskrcnn_benchmark/engine/
57+
COPY ./maskrcnn_benchmark/modeling/matcher.py maskrcnn_benchmark/modeling/
58+
COPY ./maskrcnn_benchmark/modeling/roi_heads/box_head/loss.py maskrcnn_benchmark/modeling/roi_heads/box_head/
59+
COPY ./maskrcnn_benchmark/modeling/rpn/loss.py maskrcnn_benchmark/modeling/rpn/
60+
COPY ./maskrcnn_benchmark/config/defaults.py maskrcnn_benchmark/config/
61+
COPY ./maskrcnn_benchmark/data/transforms/__init__.py maskrcnn_benchmark/data/transforms/
62+
COPY ./maskrcnn_benchmark/data/transforms/build.py maskrcnn_benchmark/data/transforms/
63+
COPY ./maskrcnn_benchmark/data/transforms/transforms.py maskrcnn_benchmark/data/transforms/
64+
COPY ./maskrcnn_benchmark/engine/trainer.py maskrcnn_benchmark/engine/
65+
COPY ./maskrcnn_benchmark/engine/bbox_aug.py maskrcnn_benchmark/engine/
66+
COPY ./maskrcnn_benchmark/config/paths_catalog.py maskrcnn_benchmark/config/
67+
COPY ./maskrcnn_benchmark/data/datasets/__init__.py maskrcnn_benchmark/data/datasets/
68+
COPY ./maskrcnn_benchmark/data/datasets/kuzushiji.py maskrcnn_benchmark/data/datasets/
69+
COPY ./maskrcnn_benchmark/data/datasets/evaluation/__init__.py maskrcnn_benchmark/data/datasets/evaluation/
70+
COPY ./maskrcnn_benchmark/data/datasets/evaluation/kuzushiji/__init__.py maskrcnn_benchmark/data/datasets/evaluation/kuzushiji/
71+
COPY ./maskrcnn_benchmark/data/datasets/evaluation/kuzushiji/kuzushiji_eval.py maskrcnn_benchmark/data/datasets/evaluation/kuzushiji/
72+
73+
RUN cd /maskrcnn-benchmark \
74+
&& python setup.py build develop
75+
RUN pip install pandas
76+
77+
COPY ./requirements.txt .
78+
RUN pip install -r requirements.txt
79+
80+
WORKDIR /work

build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker build -t knjcode/kuzushiji-recognition-docker --build-arg CUDA=10.0 --build-arg CUDNN=7 .
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
MODEL:
2+
META_ARCHITECTURE: "GeneralizedRCNN"
3+
WEIGHT: "catalog://Caffe2Detectron/COCO/35857890/e2e_faster_rcnn_R-101-FPN_1x"
4+
BACKBONE:
5+
CONV_BODY: "R-101-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+
DATASETS:
24+
TEST: ("coco_2014_minival",)
25+
DATALOADER:
26+
SIZE_DIVISIBILITY: 32
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
MODEL:
2+
META_ARCHITECTURE: "GeneralizedRCNN"
3+
WEIGHT: "catalog://Caffe2Detectron/COCO/35857197/e2e_faster_rcnn_R-50-C4_1x"
4+
DATASETS:
5+
TEST: ("coco_2014_minival",)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
MODEL:
2+
META_ARCHITECTURE: "GeneralizedRCNN"
3+
WEIGHT: "catalog://Caffe2Detectron/COCO/35857345/e2e_faster_rcnn_R-50-FPN_1x"
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+
DATASETS:
24+
TEST: ("coco_2014_minival",)
25+
DATALOADER:
26+
SIZE_DIVISIBILITY: 32
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
MODEL:
2+
META_ARCHITECTURE: "GeneralizedRCNN"
3+
WEIGHT: "catalog://Caffe2Detectron/COCO/36761737/e2e_faster_rcnn_X-101-32x8d-FPN_1x"
4+
BACKBONE:
5+
CONV_BODY: "R-101-FPN"
6+
RESNETS:
7+
BACKBONE_OUT_CHANNELS: 256
8+
STRIDE_IN_1X1: False
9+
NUM_GROUPS: 32
10+
WIDTH_PER_GROUP: 8
11+
RPN:
12+
USE_FPN: True
13+
ANCHOR_STRIDE: (4, 8, 16, 32, 64)
14+
PRE_NMS_TOP_N_TRAIN: 2000
15+
PRE_NMS_TOP_N_TEST: 1000
16+
POST_NMS_TOP_N_TEST: 1000
17+
FPN_POST_NMS_TOP_N_TEST: 1000
18+
ROI_HEADS:
19+
USE_FPN: True
20+
ROI_BOX_HEAD:
21+
POOLER_RESOLUTION: 7
22+
POOLER_SCALES: (0.25, 0.125, 0.0625, 0.03125)
23+
POOLER_SAMPLING_RATIO: 2
24+
FEATURE_EXTRACTOR: "FPN2MLPFeatureExtractor"
25+
PREDICTOR: "FPNPredictor"
26+
DATASETS:
27+
TEST: ("coco_2014_minival",)
28+
DATALOADER:
29+
SIZE_DIVISIBILITY: 32
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
MODEL:
2+
META_ARCHITECTURE: "GeneralizedRCNN"
3+
WEIGHT: "catalog://Caffe2Detectron/COCO/37697547/e2e_keypoint_rcnn_R-50-FPN_1x"
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+
NUM_CLASSES: 2
24+
ROI_KEYPOINT_HEAD:
25+
POOLER_SCALES: (0.25, 0.125, 0.0625, 0.03125)
26+
FEATURE_EXTRACTOR: "KeypointRCNNFeatureExtractor"
27+
PREDICTOR: "KeypointRCNNPredictor"
28+
POOLER_RESOLUTION: 14
29+
POOLER_SAMPLING_RATIO: 2
30+
RESOLUTION: 56
31+
SHARE_BOX_FEATURE_EXTRACTOR: False
32+
KEYPOINT_ON: True
33+
DATASETS:
34+
TRAIN: ("keypoints_coco_2014_train", "keypoints_coco_2014_valminusminival",)
35+
TEST: ("keypoints_coco_2014_minival",)
36+
INPUT:
37+
MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800)
38+
DATALOADER:
39+
SIZE_DIVISIBILITY: 32
40+
SOLVER:
41+
BASE_LR: 0.02
42+
WEIGHT_DECAY: 0.0001
43+
STEPS: (60000, 80000)
44+
MAX_ITER: 90000
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
MODEL:
2+
META_ARCHITECTURE: "GeneralizedRCNN"
3+
WEIGHT: "catalog://Caffe2Detectron/COCO/35861795/e2e_mask_rcnn_R-101-FPN_1x"
4+
BACKBONE:
5+
CONV_BODY: "R-101-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+
TEST: ("coco_2014_minival",)
34+
DATALOADER:
35+
SIZE_DIVISIBILITY: 32
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MODEL:
2+
META_ARCHITECTURE: "GeneralizedRCNN"
3+
WEIGHT: "catalog://Caffe2Detectron/COCO/35858791/e2e_mask_rcnn_R-50-C4_1x"
4+
ROI_MASK_HEAD:
5+
PREDICTOR: "MaskRCNNC4Predictor"
6+
SHARE_BOX_FEATURE_EXTRACTOR: True
7+
MASK_ON: True
8+
DATASETS:
9+
TEST: ("coco_2014_minival",)

0 commit comments

Comments
 (0)