Commit 91d9fb9f authored by Rodrigo Berriel's avatar Rodrigo Berriel Committed by Francisco Massa

Update documentation and remove a generic except (#702)

* Add ImportError to generic except

* Black formatter

* OpenCV is no longer optional

* Update README w.r.t. FPN_POST_NMS_PER_BATCH
parent ff5903e0
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
- yacs - yacs
- matplotlib - matplotlib
- GCC >= 4.9 - GCC >= 4.9
- (optional) OpenCV for the webcam demo - OpenCV
### Option 1: Step-by-step installation ### Option 1: Step-by-step installation
......
...@@ -138,7 +138,7 @@ and we have divided the learning rate by 8x. ...@@ -138,7 +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 We also changed the batch size during testing, but that is generally not necessary because testing
requires much less memory than training. 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. 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. See [#672](https://github.com/facebookresearch/maskrcnn-benchmark/issues/672) for more details. 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 ### Multi-GPU training
We use internally `torch.distributed.launch` in order to launch We use internally `torch.distributed.launch` in order to launch
...@@ -150,7 +150,7 @@ process will only use a single GPU. ...@@ -150,7 +150,7 @@ process will only use a single GPU.
export NGPUS=8 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" MODEL.RPN.FPN_POST_NMS_TOP_N_TRAIN images_per_gpu x 1000 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. Note we should set `MODEL.RPN.FPN_POST_NMS_TOP_N_TRAIN` follow the rule in Single-GPU training.
## Abstractions ## Abstractions
For more information on some of the main abstractions in our implementation, see [ABSTRACTIONS.md](ABSTRACTIONS.md). For more information on some of the main abstractions in our implementation, see [ABSTRACTIONS.md](ABSTRACTIONS.md).
......
...@@ -3,13 +3,13 @@ import os ...@@ -3,13 +3,13 @@ import os
import sys import sys
try: try:
from torch.utils.model_zoo import _download_url_to_file
from torch.utils.model_zoo import urlparse
from torch.utils.model_zoo import HASH_REGEX
except:
from torch.hub import _download_url_to_file from torch.hub import _download_url_to_file
from torch.hub import urlparse from torch.hub import urlparse
from torch.hub import HASH_REGEX from torch.hub import HASH_REGEX
except ImportError:
from torch.utils.model_zoo import _download_url_to_file
from torch.utils.model_zoo import urlparse
from torch.utils.model_zoo import HASH_REGEX
from maskrcnn_benchmark.utils.comm import is_main_process from maskrcnn_benchmark.utils.comm import is_main_process
from maskrcnn_benchmark.utils.comm import synchronize from maskrcnn_benchmark.utils.comm import synchronize
...@@ -35,8 +35,8 @@ def cache_url(url, model_dir=None, progress=True): ...@@ -35,8 +35,8 @@ def cache_url(url, model_dir=None, progress=True):
>>> cached_file = maskrcnn_benchmark.utils.model_zoo.cache_url('https://s3.amazonaws.com/pytorch/models/resnet18-5c106cde.pth') >>> cached_file = maskrcnn_benchmark.utils.model_zoo.cache_url('https://s3.amazonaws.com/pytorch/models/resnet18-5c106cde.pth')
""" """
if model_dir is None: if model_dir is None:
torch_home = os.path.expanduser(os.getenv('TORCH_HOME', '~/.torch')) torch_home = os.path.expanduser(os.getenv("TORCH_HOME", "~/.torch"))
model_dir = os.getenv('TORCH_MODEL_ZOO', os.path.join(torch_home, 'models')) model_dir = os.getenv("TORCH_MODEL_ZOO", os.path.join(torch_home, "models"))
if not os.path.exists(model_dir): if not os.path.exists(model_dir):
os.makedirs(model_dir) os.makedirs(model_dir)
parts = urlparse(url) parts = urlparse(url)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment