Skip to content
Snippets Groups Projects
Unverified Commit 1f04bc57 authored by Haian Huang(深度眸)'s avatar Haian Huang(深度眸) Committed by GitHub
Browse files

Add batch inference docs about deprecate ImageToTensor (#4408)

* Add batch inference docs

* Update batch inference docs

* Update docs
parent 42f5b6c6
No related branches found
No related tags found
No related merge requests found
......@@ -228,15 +228,7 @@ Optional arguments:
- `--cfg-options`: if specified, the key-value pair optional cfg will be merged into config file
- `--eval-options`: if specified, the key-value pair optional eval cfg will be kwargs for dataset.evaluate() function, it's only for evaluation
MMDetection supports inference with a single image or batched images in test mode. By default, we use single-image inference and you can use batch inference by modifying `samples_per_gpu` in the config of test data. You can do that either by modifying the config as below.
```shell
data = dict(train=dict(...), val=dict(...), test=dict(samples_per_gpu=2, ...))
```
Or you can set it through `--cfg-options` as `--cfg-options data.test.samples_per_gpu=2`
#### Examples
### Examples
Assume that you have already downloaded the checkpoints to the directory `checkpoints/`.
......@@ -323,6 +315,56 @@ Assume that you have already downloaded the checkpoints to the directory `checkp
The generated png and txt would be under `./mask_rcnn_cityscapes_test_results` directory.
### Batch Inference
MMDetection supports inference with a single image or batched images in test mode. By default, we use single-image inference and you can use batch inference by modifying `samples_per_gpu` in the config of test data. You can do that either by modifying the config as below.
```shell
data = dict(train=dict(...), val=dict(...), test=dict(samples_per_gpu=2, ...))
```
Or you can set it through `--cfg-options` as `--cfg-options data.test.samples_per_gpu=2`
### Deprecated ImageToTensor
In test mode, `ImageToTensor` pipeline is deprecated, it's replaced by `DefaultFormatBundle` that recommended to manually replace it in the test data pipeline in your config file. examples:
```python
# use ImageToTensor (deprecated)
pipelines = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(1333, 800),
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='RandomFlip'),
dict(type='Normalize', mean=[0, 0, 0], std=[1, 1, 1]),
dict(type='Pad', size_divisor=32),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img']),
])
]
# manually replace ImageToTensor to DefaultFormatBundle (recommended)
pipelines = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(1333, 800),
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='RandomFlip'),
dict(type='Normalize', mean=[0, 0, 0], std=[1, 1, 1]),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img']),
])
]
```
## Train predefined models on standard datasets
MMDetection also provides out-of-the-box tools for training detection models.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment