Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to latest and small fix to empty targets #2

Merged
merged 60 commits into from
May 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
9063850
README - add your own dataset (#569)
bernhardschaefer Mar 25, 2019
f031879
Support for running on arbitrary CUDA device. (#537)
atranitell Mar 26, 2019
4a7dcc4
Rollback dispatch patch (#603)
Mar 26, 2019
bd39d2c
Fixes conda CUDA version in Dockerfile (#604)
Mar 26, 2019
05feadf
Revert "Support for running on arbitrary CUDA device. (#537)" (#608)
fmassa Mar 26, 2019
91b36ee
add a FORCE_CUDA flag
obendidi Mar 27, 2019
bdb36fa
Update Dockerfile
obendidi Mar 27, 2019
da40de3
Update setup.py
obendidi Mar 27, 2019
657e962
add FORCE_CUDA as an ARG
Mar 28, 2019
41a0643
modified: docker/Dockerfile
obendidi Mar 28, 2019
7126480
small fix to readme of demo
Mar 28, 2019
8f1b4a2
remove test print
Mar 28, 2019
460d059
keep ARG_CUDA
Mar 28, 2019
52d7ccf
remove env value and use the one from ARG
Mar 28, 2019
ae6ede3
keep same formatting as source
obendidi Mar 28, 2019
5afb532
change proposed by @miguelvr
Mar 28, 2019
e676c95
Update INSTALL.md
obendidi Mar 28, 2019
90c226c
add the option to use a `FORCE_CUDA` to force cuda installation on do…
obendidi Mar 31, 2019
f55844c
fix resnet.py typo (#626)
ethanhe42 Apr 2, 2019
5c44ca7
Fix a bug in Docker file (#637)
zhangliliang Apr 4, 2019
f917a55
Add tqdm package in Dockerfile (#638)
zhangliliang Apr 4, 2019
b4d5465
Support Binary Mask with transparent SementationMask interface (#473)
botcs Apr 9, 2019
59d445d
fix #258 (#648)
lufficc Apr 10, 2019
fdb9c68
fix python2 compatibility (#662)
qianyizhang Apr 11, 2019
42fa3a1
Add FCOS into projects using maskrcnn-benchmark. (#670)
tianzhi0549 Apr 13, 2019
c5c4d52
Add RLE support (#657)
botcs Apr 13, 2019
1714b7c
revised for RLE assert (#679)
KMnP Apr 16, 2019
1d6e9ad
add dcn from mmdetection (#693)
zimenglan-sysu-512 Apr 19, 2019
862347d
add color jitter augmentation (#680)
CoinCheung Apr 19, 2019
bf04379
proposals from RPN per image during training (#676)
chenjoya Apr 19, 2019
08fcf12
Initial mixed-precision training (#196)
slayton58 Apr 19, 2019
a44d65d
fix imports for latest pytorch-nightly (#698)
qianyizhang Apr 20, 2019
4466eb5
add documentation for finetuning cityscapes (#697)
zimenglan-sysu-512 Apr 20, 2019
b318c3e
Add a switch for POST_NMS per batch/image during training (#695)
rodrigoberriel Apr 20, 2019
66c3e56
Add OpenCV in the INSTALL instructions (#694)
rodrigoberriel Apr 20, 2019
b3cab7f
add 'once_differentiable' for dcn and modify 'configs/cityscapes/READ…
zimenglan-sysu-512 Apr 20, 2019
ff5903e
color jitter only during training (#703)
jario-jin Apr 20, 2019
91d9fb9
Update documentation and remove a generic except (#702)
rodrigoberriel Apr 20, 2019
dbec62b
Evaluation details (#705)
Jacobew Apr 22, 2019
d44c3fd
Quickfix for outdated paras (#710)
Iwontbecreative Apr 23, 2019
eb4d335
rectify the 'padding' for 'DFConv2d' (#717)
zimenglan-sysu-512 Apr 25, 2019
1127bdd
Renames the `transforms` attribute of COCODataset (#744)
qizhuli May 2, 2019
452b94d
Update trainer.py
obendidi May 10, 2019
3f5f4e5
Update trainer.py
obendidi May 11, 2019
a665c74
Update trainer.py
obendidi May 11, 2019
455b7ce
Update trainer.py
obendidi May 12, 2019
d57f1a2
Update trainer.py
obendidi May 12, 2019
16b8b09
change torch.IntTensor to torch.LongTensor for storing large tensor n…
caiqi May 20, 2019
38d08ca
modify senario where dataset has no mask provided (#814)
CoinCheung May 24, 2019
95521b6
some protection code in bounding box operations (#811)
lsrock1 May 24, 2019
5eca57b
Windows10 installation fixes ver2 (#741)
Idolized22 May 24, 2019
7a9b185
Multi-scale testing (#804)
fallingdust May 24, 2019
cd63feb
support empty BinaryMaskList initialization (#780)
botcs May 24, 2019
2ff23c4
Update defaults.py (#774)
zhangliliang May 24, 2019
3d2e2b3
keep the resize function the same in test time the same with training…
hcx1231 May 24, 2019
44fb065
Add requests for compatibility with the demo notebook (#655)
AnnaAraslanova May 24, 2019
c58550c
minor fix: incorrect assert string message formatting (#631)
May 24, 2019
cd35ff0
Update predictor.py (#820)
aperkes May 24, 2019
d7e3c65
enable inference on cpu (#821)
techkang May 25, 2019
3833bdb
Merge pull request #1 from facebookresearch/master
obendidi May 27, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ dist/
# Pycharm editor settings
.idea

# MacOS
.DS_Store

# project dirs
/datasets
/models
/output
69 changes: 65 additions & 4 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- yacs
- matplotlib
- GCC >= 4.9
- (optional) OpenCV for the webcam demo
- OpenCV


### Option 1: Step-by-step installation
Expand All @@ -24,7 +24,7 @@ conda activate maskrcnn_benchmark
conda install ipython

# maskrcnn_benchmark and coco api dependencies
pip install ninja yacs cython matplotlib tqdm
pip install ninja yacs cython matplotlib tqdm opencv-python

# follow PyTorch installation in https://pytorch.org/get-started/locally/
# we give the instructions for CUDA 9.0
Expand All @@ -38,6 +38,12 @@ git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
python setup.py build_ext install

# install apex
cd $INSTALL_DIR
git clone https://github.com/NVIDIA/apex.git
cd apex
python setup.py install --cuda_ext --cpp_ext

# install PyTorch Detection
cd $INSTALL_DIR
git clone https://github.com/facebookresearch/maskrcnn-benchmark.git
Expand All @@ -55,16 +61,71 @@ unset INSTALL_DIR
# or if you are on macOS
# MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py build develop
```
#### Windows 10
```bash
open a cmd and change to desired installation directory
from now on will be refered as INSTALL_DIR
conda create --name maskrcnn_benchmark
conda activate maskrcnn_benchmark

# this installs the right pip and dependencies for the fresh python
conda install ipython

# maskrcnn_benchmark and coco api dependencies
pip install ninja yacs cython matplotlib tqdm opencv-python

# follow PyTorch installation in https://pytorch.org/get-started/locally/
# we give the instructions for CUDA 9.0
## Important : check the cuda version installed on your computer by running the command in the cmd :
nvcc -- version
conda install -c pytorch pytorch-nightly torchvision cudatoolkit=9.0

git clone https://github.com/cocodataset/cocoapi.git

#To prevent installation error do the following after commiting cocooapi :
#using file explorer naviagate to cocoapi\PythonAPI\setup.py and change line 14 from:
#extra_compile_args=['-Wno-cpp', '-Wno-unused-function', '-std=c99'],
#to
#extra_compile_args={'gcc': ['/Qstd=c99']},
#Based on https://github.com/cocodataset/cocoapi/issues/51

cd cocoapi/PythonAPI
python setup.py build_ext install

# navigate back to INSTALL_DIR
cd ..
cd ..
# install apex

git clone https://github.com/NVIDIA/apex.git
cd apex
python setup.py install --cuda_ext --cpp_ext
# navigate back to INSTALL_DIR
cd ..
# install PyTorch Detection

git clone https://github.com/Idolized22/maskrcnn-benchmark.git
cd maskrcnn-benchmark

# 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
```
### Option 2: Docker Image (Requires CUDA, Linux only)

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

nvidia-docker build -t maskrcnn-benchmark docker/

Build image with other CUDA and CUDNN versions:

nvidia-docker build -t maskrcnn-benchmark --build-arg CUDA=9.2 --build-arg CUDNN=7 docker/
nvidia-docker build -t maskrcnn-benchmark --build-arg CUDA=9.2 --build-arg CUDNN=7 docker/

Build image with FORCE_CUDA disabled:

nvidia-docker build -t maskrcnn-benchmark --build-arg FORCE_CUDA=0 docker/

Build and run image with built-in jupyter notebook(note that the password is used to log in jupyter notebook):

Expand Down
31 changes: 26 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ you'll also need to change the learning rate, the number of iterations and the l

Here is an example for Mask R-CNN R-50 FPN with the 1x schedule:
```bash
python tools/train_net.py --config-file "configs/e2e_mask_rcnn_R_50_FPN_1x.yaml" SOLVER.IMS_PER_BATCH 2 SOLVER.BASE_LR 0.0025 SOLVER.MAX_ITER 720000 SOLVER.STEPS "(480000, 640000)" TEST.IMS_PER_BATCH 1
python tools/train_net.py --config-file "configs/e2e_mask_rcnn_R_50_FPN_1x.yaml" SOLVER.IMS_PER_BATCH 2 SOLVER.BASE_LR 0.0025 SOLVER.MAX_ITER 720000 SOLVER.STEPS "(480000, 640000)" TEST.IMS_PER_BATCH 1 MODEL.RPN.FPN_POST_NMS_TOP_N_TRAIN 2000
```
This follows the [scheduling rules from Detectron.](https://github.com/facebookresearch/Detectron/blob/master/configs/getting_started/tutorial_1gpu_e2e_faster_rcnn_R-50-FPN.yaml#L14-L30)
Note that we have multiplied the number of iterations by 8x (as well as the learning rate schedules),
Expand All @@ -138,6 +138,7 @@ and we have divided the learning rate by 8x.
We also changed the batch size during testing, but that is generally not necessary because testing
requires much less memory than training.

Furthermore, we set `MODEL.RPN.FPN_POST_NMS_TOP_N_TRAIN 2000` as the proposals are selected for per the batch rather than per image in the default training. The value is calculated by **1000 x images-per-gpu**. Here we have 2 images per GPU, therefore we set the number as 1000 x 2 = 2000. If we have 8 images per GPU, the value should be set as 8000. Note that this does not apply if `MODEL.RPN.FPN_POST_NMS_PER_BATCH` is set to `False` during training. See [#672](https://github.com/facebookresearch/maskrcnn-benchmark/issues/672) for more details.

### Multi-GPU training
We use internally `torch.distributed.launch` in order to launch
Expand All @@ -147,8 +148,17 @@ process will only use a single GPU.

```bash
export NGPUS=8
python -m torch.distributed.launch --nproc_per_node=$NGPUS /path_to_maskrcnn_benchmark/tools/train_net.py --config-file "path/to/config/file.yaml"
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
```
Note we should set `MODEL.RPN.FPN_POST_NMS_TOP_N_TRAIN` follow the rule in Single-GPU training.

## Evaluation
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:
```bash
export NGPUS=8
python -m torch.distributed.launch --nproc_per_node=$NGPUS /path_to_maskrcnn_benchmark/tools/test_net.py --config-file "configs/e2e_mask_rcnn_R_50_FPN_1x.yaml" TEST.IMS_PER_BATCH 16
```
To calculate mAP for each class, you can simply modify a few lines in [coco_eval.py](https://github.com/facebookresearch/maskrcnn-benchmark/blob/master/maskrcnn_benchmark/data/datasets/evaluation/coco/coco_eval.py). See [#524](https://github.com/facebookresearch/maskrcnn-benchmark/issues/524#issuecomment-475118810) for more details.

## Abstractions
For more information on some of the main abstractions in our implementation, see [ABSTRACTIONS.md](ABSTRACTIONS.md).
Expand Down Expand Up @@ -198,11 +208,21 @@ That's it. You can also add extra fields to the boxlist, such as segmentation ma

For a full example of how the `COCODataset` is implemented, check [`maskrcnn_benchmark/data/datasets/coco.py`](maskrcnn_benchmark/data/datasets/coco.py).

### Note:
Once you have created your dataset, it needs to be added in a couple of places:
- [`maskrcnn_benchmark/data/datasets/__init__.py`](maskrcnn_benchmark/data/datasets/__init__.py): add it to `__all__`
- [`maskrcnn_benchmark/config/paths_catalog.py`](maskrcnn_benchmark/config/paths_catalog.py): `DatasetCatalog.DATASETS` and corresponding `if` clause in `DatasetCatalog.get()`

### Testing
While the aforementioned example should work for training, we leverage the
cocoApi for computing the accuracies during testing. Thus, test datasets
should currently follow the cocoApi for now.

To enable your dataset for testing, add a corresponding if statement in [`maskrcnn_benchmark/data/datasets/evaluation/__init__.py`](maskrcnn_benchmark/data/datasets/evaluation/__init__.py):
```python
if isinstance(dataset, datasets.MyDataset):
return coco_evaluation(**args)
```

## Finetuning from Detectron weights on custom datasets
Create a script `tools/trim_detectron_model.py` like [here](https://gist.github.com/wangg12/aea194aa6ab6a4de088f14ee193fd968).
You can decide which keys to be removed and which keys to be kept by modifying the script.
Expand Down Expand Up @@ -233,8 +253,9 @@ note = {Accessed: [Insert date here]}
- [RetinaMask: Learning to predict masks improves state-of-the-art single-shot detection for free](https://arxiv.org/abs/1901.03353).
Cheng-Yang Fu, Mykhailo Shvets, and Alexander C. Berg.
Tech report, arXiv,1901.03353.


- [FCOS: Fully Convolutional One-Stage Object Detection](https://arxiv.org/abs/1904.01355).
Zhi Tian, Chunhua Shen, Hao Chen and Tong He.
Tech report, arXiv,1904.01355. [[code](https://github.com/tianzhi0549/FCOS)]

## License

Expand Down
Loading