Skip to content

Commit 2a01c8f

Browse files
committed
update readme
1 parent eb22fbc commit 2a01c8f

File tree

1 file changed

+54
-12
lines changed

1 file changed

+54
-12
lines changed

README.md

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ popular detection projects. Results and models are available in the [Model zoo](
3939

4040
## Installation
4141

42-
Requirements:
42+
### Requirements
4343

4444
- Linux (tested on Ubuntu 16.04 and CentOS 7.2)
4545
- Python 2.7+ or 3.4+
@@ -49,29 +49,34 @@ Requirements:
4949

5050
> Note: Though mmdetection is compatible with Python 2/3, python 3 is recommended and we do not promise future support for Python 2.
5151
52-
Clone the Detectron repository.
52+
### Install mmdetection
53+
54+
a. Install PyTorch 0.4.1 and torchvision following the [official instructions](https://pytorch.org/).
55+
56+
b. Clone the Detectron repository.
5357

5458
```shell
5559
git clone https://github.com/open-mmlab/mmdetection.git
5660
```
5761

58-
Compile cuda extensions.
62+
c. Compile cuda extensions.
5963

6064
```shell
6165
cd mmdetection
6266
./compile.sh # or "PYTHON=python3 ./compile.sh" if you use system python3 without virtual environments
6367
```
6468

65-
Install mmdetection (other dependencies will be installed automatically).
69+
d. Install mmdetection (other dependencies will be installed automatically).
6670

6771
```shell
6872
python(3) setup.py install # add --user if you want to install it locally
6973
# or "pip install ."
7074
```
7175

72-
> Note: You need to run the installing step each time you pull updates from github. Git commit id will be written to the version number and also saved in trained models.
76+
Note: You need to run the last step each time you pull updates from github.
77+
The git commit id will be written to the version number and also saved in trained models.
7378

74-
Prepare COCO dataset
79+
### Prepare COCO dataset.
7580

7681
It is recommended to symlink the dataset root to `$MMDETECTION/data`.
7782

@@ -92,6 +97,18 @@ mmdetection
9297

9398
## Inference with pretrained models
9499

100+
### Test a dataset
101+
102+
- [x] single GPU testing
103+
- [x] multiple GPU testing
104+
- [x] visualize detection results
105+
106+
We allow to run one or multiple processes on each GPU, e.g. 8 processes on 8 GPU
107+
or 16 processes on 8 GPU. When the GPU workload is not very heavy for a single
108+
process, running multiple processes will accelerate the testing, which is specified
109+
with the argument `--proc_per_gpu <PROCESS_NUM>`.
110+
111+
95112
To test a dataset and save the results.
96113

97114
```shell
@@ -112,14 +129,41 @@ For example, to evaluate Mask R-CNN with 8 GPUs and save the result as `results.
112129
python tools/test.py configs/mask_rcnn_r50_fpn_1x.py <CHECKPOINT_FILE> --gpus 8 --out results.pkl --eval bbox segm
113130
```
114131

115-
Note: Multiple GPU testing cannot achieve linear acceleration.
116-
117132
It is also convenient to visualize the results during testing by adding an argument `--show`.
118133

119134
```shell
120135
python tools/test.py <CONFIG_FILE> <CHECKPOINT_FILE> --show
121136
```
122137

138+
### Test image(s)
139+
140+
We provide some high-level apis (experimental) to test an image.
141+
142+
```python
143+
import mmcv
144+
from mmcv.runner import load_checkpoint
145+
from mmdet.models import build_detector
146+
from mmdet.apis import inference_detector, show_result
147+
148+
cfg = mmcv.Config.fromfile('configs/faster_rcnn_r50_fpn_1x.py')
149+
cfg.model.pretrained = None
150+
151+
# construct the model and load checkpoint
152+
model = build_detector(cfg.model, test_cfg=cfg.test_cfg)
153+
_ = load_checkpoint(model, 'https://s3.ap-northeast-2.amazonaws.com/open-mmlab/mmdetection/models/faster_rcnn_r50_fpn_1x_20181010-3d1b3351.pth')
154+
155+
# test a single image
156+
img = mmcv.imread('test.jpg')
157+
result = inference_detector(model, img, cfg)
158+
show_result(img, result)
159+
160+
# test a list of images
161+
imgs = ['test1.jpg', 'test2.jpg']
162+
for i, result in enumerate(inference_detector(model, imgs, cfg, device='cuda:0')):
163+
print(i, imgs[i])
164+
show_result(imgs[i], result)
165+
```
166+
123167

124168
## Train a model
125169

@@ -157,8 +201,6 @@ Expected results in WORK_DIR:
157201
- a symbol link to the latest checkpoint
158202

159203

160-
## High-level APIs
204+
## Technical details
161205

162-
We are working on a set of high-level APIs to make it more convenient to
163-
integrate mmdetection into other projects or act as a hands-on tool for
164-
beginners.
206+
Some implementation details and project structures are described in the [technical details](TECHNICAL_DETAILS.md).

0 commit comments

Comments
 (0)