Skip to content

Commit e67f881

Browse files
ppwwyyxxfacebook-github-bot
authored andcommitted
update docs
Summary: Pull Request resolved: facebookresearch#28 Differential Revision: D17895078 Pulled By: ppwwyyxx fbshipit-source-id: 79d307f16e5ba61db5d21214ce9abe27de92296b
1 parent f0a08a0 commit e67f881

File tree

17 files changed

+114
-24
lines changed

17 files changed

+114
-24
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
name: "❓Questions/Help/Support"
3-
about: Do you need support?
2+
name: "Usage Questions / General Inquiries"
3+
about: How to do X ?
44

55
---
66

@@ -10,5 +10,5 @@ General questions about detectron2.
1010

1111
NOTE:
1212

13-
If you met an unexpected error when using detectron2,
14-
please use the "Unexpected Problems / Bugs" issue category instead.
13+
If you met any unexpected issue when using detectron2 and wish to know why,
14+
please use the "Unexpected Problems / Bugs" issue template.

GETTING_STARTED.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ For more advanced tutorials, refer to our [documentation](https://detectron2.rea
2020
```
2121
python demo/demo.py --config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml \
2222
--input input1.jpg input2.jpg \
23-
--opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl
23+
--opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl
2424
```
2525
It will run the inference and show visualizations in an OpenCV window.
2626

INSTALL.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
## Installation
22

3-
Our [Colab Notebook](https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5) also has step-by-step instructions that install detectron2.
3+
Our [Colab Notebook](https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5)
4+
has step-by-step instructions that install detectron2.
5+
The [Dockerfile](https://github.com/facebookresearch/detectron2/blob/master/Dockerfile)
6+
also installs detectron2 with a few simple commands.
47

58
### Requirements
69
- Python >= 3.6

detectron2/modeling/backbone/build.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@
55
from .backbone import Backbone
66

77
BACKBONE_REGISTRY = Registry("BACKBONE")
8-
"""
9-
Registry for backbones, which extract feature maps from images.
8+
BACKBONE_REGISTRY.__doc__ = """
9+
Registry for backbones, which extract feature maps from images
10+
11+
The registered object must be a callable that accepts two arguments:
12+
13+
1. A :class:`detectron2.config.CfgNode`
14+
2. A :class:`detectron2.layers.ShapeSpec`, which contains the input shape specification.
15+
16+
It must returns an instance of :class:`Backbone`.
1017
"""
1118

1219

detectron2/modeling/meta_arch/build.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
from detectron2.utils.registry import Registry
33

44
META_ARCH_REGISTRY = Registry("META_ARCH") # noqa F401 isort:skip
5-
"""
5+
META_ARCH_REGISTRY.__doc__ = """
66
Registry for meta-architectures, i.e. the whole model.
7+
8+
The registered object will be called with `obj(cfg)`
9+
and expected to return a `nn.Module` object.
710
"""
811

912

detectron2/modeling/proposal_generator/build.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
from detectron2.utils.registry import Registry
33

44
PROPOSAL_GENERATOR_REGISTRY = Registry("PROPOSAL_GENERATOR")
5-
"""
5+
PROPOSAL_GENERATOR_REGISTRY.__doc__ = """
66
Registry for proposal generator, which produces object proposals from feature maps.
7+
8+
The registered object will be called with `obj(cfg, input_shape)`.
9+
The call should return a `nn.Module` object.
710
"""
811

912
from . import rpn, rrpn # noqa F401 isort:skip

detectron2/modeling/roi_heads/box_head.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
from detectron2.utils.registry import Registry
1010

1111
ROI_BOX_HEAD_REGISTRY = Registry("ROI_BOX_HEAD")
12-
"""
12+
ROI_BOX_HEAD_REGISTRY.__doc__ = """
1313
Registry for box heads, which make box predictions from per-region features.
14+
15+
The registered object will be called with `obj(cfg, input_shape)`.
1416
"""
1517

1618

detectron2/modeling/roi_heads/keypoint_head.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
_TOTAL_SKIPPED = 0
1212

1313
ROI_KEYPOINT_HEAD_REGISTRY = Registry("ROI_KEYPOINT_HEAD")
14-
"""
14+
ROI_KEYPOINT_HEAD_REGISTRY.__doc__ = """
1515
Registry for keypoint heads, which make keypoint predictions from per-region features.
16+
17+
The registered object will be called with `obj(cfg, input_shape)`.
1618
"""
1719

1820

detectron2/modeling/roi_heads/mask_head.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
from detectron2.utils.registry import Registry
1010

1111
ROI_MASK_HEAD_REGISTRY = Registry("ROI_MASK_HEAD")
12-
"""
12+
ROI_MASK_HEAD_REGISTRY.__doc__ = """
1313
Registry for mask heads, which predicts instance masks given
1414
per-region features.
15+
16+
The registered object will be called with `obj(cfg, input_shape)`.
1517
"""
1618

1719

detectron2/modeling/roi_heads/roi_heads.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@
2222
from .mask_head import build_mask_head, mask_rcnn_inference, mask_rcnn_loss
2323

2424
ROI_HEADS_REGISTRY = Registry("ROI_HEADS")
25-
"""
25+
ROI_HEADS_REGISTRY.__doc__ = """
2626
Registry for ROI heads in a generalized R-CNN model.
2727
ROIHeads take feature maps and region proposals, and
2828
perform per-region computation.
29+
30+
The registered object will be called with `obj(cfg, input_shape)`.
31+
The call is expected to return an :class:`ROIHeads`.
2932
"""
3033

3134
logger = logging.getLogger(__name__)

detectron2/utils/registry.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ class MyBackbone():
1919
2020
Or:
2121
22-
BACKBONE_REGISTRY.register(obj=MyBackbone)
22+
.. code-block:: python
23+
24+
BACKBONE_REGISTRY.register(MyBackbone)
2325
"""
2426

2527
def __init__(self, name):

docs/conf.py

+17
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@
4444
"torch",
4545
"torchvision",
4646
"torch.nn",
47+
"torch.nn.parallel",
4748
"torch.distributed",
4849
"torch.multiprocessing",
4950
"torch.autograd",
5051
"torch.autograd.function",
5152
"torch.nn.modules",
5253
"torch.nn.modules.utils",
54+
"torch.utils",
55+
"torch.utils.data",
5356
"torchvision",
5457
"torchvision.ops",
5558
]:
@@ -235,9 +238,23 @@
235238
todo_include_todos = True
236239

237240

241+
_DEPRECATED_NAMES = set(["out_feature_channels", "out_feature_strides", "out_features"])
242+
243+
244+
def autodoc_skip_member(app, what, name, obj, skip, options):
245+
# we hide something deliberately
246+
if getattr(obj, "__HIDE_SPHINX_DOC__", False):
247+
return True
248+
# Hide some names that are deprecated or not intended to be used
249+
if name in _DEPRECATED_NAMES:
250+
return True
251+
return None
252+
253+
238254
def setup(app):
239255
from recommonmark.transform import AutoStructify
240256

257+
app.connect("autodoc-skip-member", autodoc_skip_member)
241258
# app.connect('autodoc-skip-member', autodoc_skip_member)
242259
app.add_config_value(
243260
"recommonmark_config",

docs/modules/modeling.rst

+22
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,25 @@ detectron2.modeling package
55
:members:
66
:undoc-members:
77
:show-inheritance:
8+
9+
10+
Model Registries
11+
-----------------
12+
13+
These are different registries provided in modeling.
14+
Each registry provide you the ability to replace it with your customized component,
15+
without having to modify detectron2's code.
16+
17+
Note that it is impossible to allow users to customize any line of code directly.
18+
Even just to add one line at some place,
19+
you'll likely need to find out the smallest registry which contains that line,
20+
and register your component to that registry.
21+
22+
23+
.. autodata:: detectron2.modeling.META_ARCH_REGISTRY
24+
.. autodata:: detectron2.modeling.BACKBONE_REGISTRY
25+
.. autodata:: detectron2.modeling.PROPOSAL_GENERATOR_REGISTRY
26+
.. autodata:: detectron2.modeling.ROI_HEADS_REGISTRY
27+
.. autodata:: detectron2.modeling.ROI_BOX_HEAD_REGISTRY
28+
.. autodata:: detectron2.modeling.ROI_MASK_HEAD_REGISTRY
29+
.. autodata:: detectron2.modeling.ROI_KEYPOINT_HEAD_REGISTRY

docs/notes/benchmarks.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ with some other popular open source Mask R-CNN implementations.
88
### Settings
99

1010
* Hardware: 8 NVIDIA V100s.
11-
* Software: CUDA 10.0, cuDNN 7.6.4, PyTorch 1.3.0.dev20190920 (nightly build), TensorFlow 1.5.0rc2, Keras 2.2.5.
11+
* Software: CUDA 10.0, cuDNN 7.6.4, PyTorch 1.3.0.dev20190920 (nightly build), TensorFlow 1.5.0rc2, Keras 2.2.5, MxNet 1.6.0b20190820.
1212
* Model: an end-to-end R-50-FPN Mask-RCNN model, using the same hyperparameter as the
1313
[Detectron baseline config](https://github.com/facebookresearch/Detectron/blob/master/configs/12_2017_baselines/e2e_mask_rcnn_R-50-FPN_1x.yaml).
1414
* Metrics: We use the average throughput in iterations 100-500 to skip GPU warmup time.
@@ -31,6 +31,8 @@ with some other popular open source Mask R-CNN implementations.
3131
+-----------------------------+--------------------+
3232
| mmdetection_ | 41 |
3333
+-----------------------------+--------------------+
34+
| simpledet_ | 39 |
35+
+-----------------------------+--------------------+
3436
| Detectron_ | 19 |
3537
+-----------------------------+--------------------+
3638
| `matterport/Mask_RCNN`__ | 14 |
@@ -39,6 +41,7 @@ with some other popular open source Mask R-CNN implementations.
3941
.. _maskrcnn-benchmark: https://github.com/facebookresearch/maskrcnn-benchmark/
4042
.. _tensorpack: https://github.com/tensorpack/tensorpack/tree/master/examples/FasterRCNN
4143
.. _mmdetection: https://github.com/open-mmlab/mmdetection/
44+
.. _simpledet: https://github.com/TuSimple/simpledet/
4245
.. _Detectron: https://github.com/facebookresearch/Detectron
4346
__ https://github.com/matterport/Mask_RCNN/
4447
```
@@ -109,15 +112,23 @@ Details for each implementation:
109112
```
110113
</details>
111114

115+
* __SimpleDet__: at commit `9187a1`, run
116+
```
117+
python detection_train.py --config config/mask_r50v1_fpn_1x.py
118+
```
119+
112120
* __Detectron__: run
113121
```
114122
python tools/train_net.py --cfg configs/12_2017_baselines/e2e_mask_rcnn_R-50-FPN_1x.yaml
115123
```
124+
Note that many of its ops run on CPUs, therefore the performance is limited.
116125

117126
* __matterport/Mask_RCNN__: at commit `3deaec`, apply the following diff, `export TF_CUDNN_USE_AUTOTUNE=0`, then run
118127
```
119128
python coco.py train --dataset=/data/coco/ --model=imagenet
120129
```
130+
Note that many small details in this implementation might be different
131+
from Detectron's standards.
121132

122133
<details>
123134
<summary>

docs/tutorials/models.md

+13-5
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,26 @@ behavior of certain internal components of standard models.
1515

1616
For example, to add a new backbone, import this code:
1717
```python
18-
from detectron2.modeling import BACKBONE_REGISTRY, Backbone
18+
from detectron2.modeling import BACKBONE_REGISTRY, Backbone, ShapeSpec
19+
1920
@BACKBONE_REGISTRY.register()
20-
class NewBackBone(Backbone):
21+
class ToyBackBone(Backbone):
2122
def __init__(self, cfg, input_shape):
2223
# create your own backbone
24+
self.conv1 = nn.Conv2d(3, 64, kernel_size=7, stride=16, padding=3)
25+
26+
def forward(self, image):
27+
return {"conv1": self.conv1(image)}
28+
29+
def output_shape(self):
30+
return {"conv1": ShapeSpec(channels=64, stride=16)}
2331
```
24-
which will allow you to use `cfg.MODEL.BACKBONE.NAME = 'NewBackBone'` in your config file.
32+
Then, you can use `cfg.MODEL.BACKBONE.NAME = 'ToyBackBone'` in your config file.
2533

2634
As another example, to add new abilities to the ROI heads in the Generalized R-CNN meta-architecture,
2735
you can implement a new
2836
[ROIHeads](../modules/modeling.html#detectron2.modeling.ROIHeads) subclass and put it in the `ROI_HEADS_REGISTRY`.
2937
See [densepose in detectron2](https://github.com/facebookresearch/detectron2/tree/master/projects/DensePose)
30-
for an example.
38+
for an example that implements new ROIHeads.
3139

32-
Other registries can be found in [API documentation](../modules/modeling.html).
40+
Other registries can be found in [API documentation](../modules/modeling.html#model-registries).

projects/TridentNet/README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44

55
Yanghao Li\*, Yuntao Chen\*, Naiyan Wang, Zhaoxiang Zhang
66

7-
[[`TridentNet`](https://github.com/TuSimple/simpledet/tree/master/models/tridentnet)] [[`arXiv`](https://arxiv.org/abs/1802.00434)] [[`BibTeX`](#CitingTridentNet)]
7+
[[`TridentNet`](https://github.com/TuSimple/simpledet/tree/master/models/tridentnet)] [[`arXiv`](https://arxiv.org/abs/1901.01892)] [[`BibTeX`](#CitingTridentNet)]
88

99
<div align="center">
1010
<img src="https://drive.google.com/uc?export=view&id=10THEPdIPmf3ooMyNzrfZbpWihEBvixwt" width="700px" />
1111
</div>
1212

13-
In this repository, we implement TridentNet-Fast in the Detectron2 framework. Trident Network (TridentNet) aims to generate scale-specific feature maps with a uniform representational power. We construct a parallel multi-branch architecture in which each branch shares the same transformation parameters but with different receptive fields. TridentNet-Fast is a fast approximation version of TridentNet that could achieve significant improvements without any additional parameters and computational cost.
13+
In this repository, we implement TridentNet-Fast in Detectron2.
14+
Trident Network (TridentNet) aims to generate scale-specific feature maps with a uniform representational power. We construct a parallel multi-branch architecture in which each branch shares the same transformation parameters but with different receptive fields. TridentNet-Fast is a fast approximation version of TridentNet that could achieve significant improvements without any additional parameters and computational cost.
1415

1516
## Training
1617

17-
To train a model one can call
18+
To train a model, run
1819
```bash
1920
python /path/to/detectron2/projects/TridentNet/train_net.py --config-file <config.yaml>
2021
```

setup.py

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import torch
88
from torch.utils.cpp_extension import CUDA_HOME, CppExtension, CUDAExtension
99

10+
torch_ver = [int(x) for x in torch.__version__.split(".")[:2]]
11+
assert torch_ver >= [1, 3], "Requires PyTorch >= 1.3"
12+
1013

1114
def get_extensions():
1215
this_dir = os.path.dirname(os.path.abspath(__file__))
@@ -64,6 +67,7 @@ def get_extensions():
6467
description="Detectron2 is FAIR's next-generation research "
6568
"platform for object detection and segmentation.",
6669
packages=find_packages(exclude=("configs", "tests")),
70+
python_requires=">=3.6",
6771
install_requires=[
6872
"termcolor>=1.1",
6973
"Pillow",

0 commit comments

Comments
 (0)