Skip to content

Commit

Permalink
[Doc] Refine MMSegmentation documentation (#2668)
Browse files Browse the repository at this point in the history
  • Loading branch information
MeowZheng authored Mar 3, 2023
1 parent 310ec4a commit aaa08dc
Show file tree
Hide file tree
Showing 31 changed files with 294 additions and 1,085 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Add New Datasets
# \[WIP\] Add New Datasets

## Customize datasets by reorganizing data

Expand Down
1 change: 1 addition & 0 deletions docs/en/advanced_guides/add_metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Add New Metrics
37 changes: 0 additions & 37 deletions docs/en/advanced_guides/add_transform.md

This file was deleted.

52 changes: 52 additions & 0 deletions docs/en/advanced_guides/add_transforms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Adding New Data Transforms

## Customization data transformation

The customized data transformation must inherited from `BaseTransform` and implement `transform` function.
Here we use a simple flipping transformation as example:

```python
import random
import mmcv
from mmcv.transforms import BaseTransform, TRANSFORMS

@TRANSFORMS.register_module()
class MyFlip(BaseTransform):
def __init__(self, direction: str):
super().__init__()
self.direction = direction

def transform(self, results: dict) -> dict:
img = results['img']
results['img'] = mmcv.imflip(img, direction=self.direction)
return results
```

Moreover, import the new class.

```python
from .my_pipeline import MyFlip
```

Thus, we can instantiate a `MyFlip` object and use it to process the data dict.

```python
import numpy as np

transform = MyFlip(direction='horizontal')
data_dict = {'img': np.random.rand(224, 224, 3)}
data_dict = transform(data_dict)
processed_img = data_dict['img']
```

Or, we can use `MyFlip` transformation in data pipeline in our config file.

```python
pipeline = [
...
dict(type='MyFlip', direction='horizontal'),
...
]
```

Note that if you want to use `MyFlip` in config, you must ensure the file containing `MyFlip` is imported during runtime.
4 changes: 2 additions & 2 deletions docs/en/advanced_guides/evaluation.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ The arguments of the constructor:
- `process` method processes one batch of data and data_samples.
- `compute_metrics` method computes the metrics from processed results.

#### IoUMetric.process
### IoUMetric.process

Parameters:

Expand All @@ -92,7 +92,7 @@ Returns:

This method doesn't have returns since the processed results would be stored in `self.results`, which will be used to compute the metrics when all batches have been processed.

#### IoUMetric.compute_metrics
### IoUMetric.compute_metrics

Parameters:

Expand Down
2 changes: 1 addition & 1 deletion docs/en/advanced_guides/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Component Customization
.. toctree::
:maxdepth: 1

add_modules.md
add_models.md
add_datasets.md
add_transforms.md
add_metrics.md
Expand Down
2 changes: 1 addition & 1 deletion docs/en/advanced_guides/training_tricks.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Training Tricks
# \[WIP\] Training Tricks

MMSegmentation support following training tricks out of box.

Expand Down
49 changes: 3 additions & 46 deletions docs/en/advanced_guides/transforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ The structure of this guide is as follows:

- [Data Transforms](#data-transforms)
- [Design of Data pipelines](#design-of-data-pipelines)
- [Customization data transformation](#customization-data-transformation)
- [Data loading](#data-loading)
- [Pre-processing](#pre-processing)
- [Formatting](#formatting)

## Design of Data pipelines

Expand Down Expand Up @@ -125,48 +127,3 @@ The position of random contrast is in second or second to last(mode 0 or 1 below

- add: `inputs`, `data_sample`
- remove: keys specified by `meta_keys` (merged into the metainfo of data_sample), all other keys

## Customization data transformation

The customized data transformation must inherited from `BaseTransform` and implement `transform` function.
Here we use a simple flipping transformation as example:

```python
import random
import mmcv
from mmcv.transforms import BaseTransform, TRANSFORMS

@TRANSFORMS.register_module()
class MyFlip(BaseTransform):
def __init__(self, direction: str):
super().__init__()
self.direction = direction

def transform(self, results: dict) -> dict:
img = results['img']
results['img'] = mmcv.imflip(img, direction=self.direction)
return results
```

Thus, we can instantiate a `MyFlip` object and use it to process the data dict.

```python
import numpy as np

transform = MyFlip(direction='horizontal')
data_dict = {'img': np.random.rand(224, 224, 3)}
data_dict = transform(data_dict)
processed_img = data_dict['img']
```

Or, we can use `MyFlip` transformation in data pipeline in our config file.

```python
pipeline = [
...
dict(type='MyFlip', direction='horizontal'),
...
]
```

Note that if you want to use `MyFlip` in config, you must ensure the file containing `MyFlip` is imported during runtime.
7 changes: 1 addition & 6 deletions docs/en/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ datasets
.. automodule:: mmseg.datasets
:members:

samplers
^^^^^^^^^^
.. automodule:: mmseg.datasets.samplers
:members:

transforms
^^^^^^^^^^^^
.. automodule:: mmseg.datasets.transforms
Expand All @@ -35,7 +30,7 @@ optimizers
:members:

mmseg.evaluation
--------------
-----------------

metrics
^^^^^^^^^^
Expand Down
102 changes: 102 additions & 0 deletions docs/en/modelzoo_statistics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Model Zoo Statistics

- Number of papers: 47

- ALGORITHM: 36
- BACKBONE: 11

- Number of checkpoints: 612

- \[ALGORITHM\] [ANN](https:/open-mmlab/mmsegmentation/blob/master/configs/ann) (16 ckpts)

- \[ALGORITHM\] [APCNet](https:/open-mmlab/mmsegmentation/blob/master/configs/apcnet) (12 ckpts)

- \[BACKBONE\] [BEiT](https:/open-mmlab/mmsegmentation/blob/master/configs/beit) (2 ckpts)

- \[ALGORITHM\] [BiSeNetV1](https:/open-mmlab/mmsegmentation/blob/master/configs/bisenetv1) (11 ckpts)

- \[ALGORITHM\] [BiSeNetV2](https:/open-mmlab/mmsegmentation/blob/master/configs/bisenetv2) (4 ckpts)

- \[ALGORITHM\] [CCNet](https:/open-mmlab/mmsegmentation/blob/master/configs/ccnet) (16 ckpts)

- \[ALGORITHM\] [CGNet](https:/open-mmlab/mmsegmentation/blob/master/configs/cgnet) (2 ckpts)

- \[BACKBONE\] [ConvNeXt](https:/open-mmlab/mmsegmentation/blob/master/configs/convnext) (6 ckpts)

- \[ALGORITHM\] [DANet](https:/open-mmlab/mmsegmentation/blob/master/configs/danet) (16 ckpts)

- \[ALGORITHM\] [DeepLabV3](https:/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3) (41 ckpts)

- \[ALGORITHM\] [DeepLabV3+](https:/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3plus) (42 ckpts)

- \[ALGORITHM\] [DMNet](https:/open-mmlab/mmsegmentation/blob/master/configs/dmnet) (12 ckpts)

- \[ALGORITHM\] [DNLNet](https:/open-mmlab/mmsegmentation/blob/master/configs/dnlnet) (12 ckpts)

- \[ALGORITHM\] [DPT](https:/open-mmlab/mmsegmentation/blob/master/configs/dpt) (1 ckpts)

- \[ALGORITHM\] [EMANet](https:/open-mmlab/mmsegmentation/blob/master/configs/emanet) (4 ckpts)

- \[ALGORITHM\] [EncNet](https:/open-mmlab/mmsegmentation/blob/master/configs/encnet) (12 ckpts)

- \[ALGORITHM\] [ERFNet](https:/open-mmlab/mmsegmentation/blob/master/configs/erfnet) (1 ckpts)

- \[ALGORITHM\] [FastFCN](https:/open-mmlab/mmsegmentation/blob/master/configs/fastfcn) (12 ckpts)

- \[ALGORITHM\] [Fast-SCNN](https:/open-mmlab/mmsegmentation/blob/master/configs/fastscnn) (1 ckpts)

- \[ALGORITHM\] [FCN](https:/open-mmlab/mmsegmentation/blob/master/configs/fcn) (41 ckpts)

- \[ALGORITHM\] [GCNet](https:/open-mmlab/mmsegmentation/blob/master/configs/gcnet) (16 ckpts)

- \[BACKBONE\] [HRNet](https:/open-mmlab/mmsegmentation/blob/master/configs/hrnet) (37 ckpts)

- \[ALGORITHM\] [ICNet](https:/open-mmlab/mmsegmentation/blob/master/configs/icnet) (12 ckpts)

- \[ALGORITHM\] [ISANet](https:/open-mmlab/mmsegmentation/blob/master/configs/isanet) (16 ckpts)

- \[ALGORITHM\] [K-Net](https:/open-mmlab/mmsegmentation/blob/master/configs/knet) (7 ckpts)

- \[BACKBONE\] [MAE](https:/open-mmlab/mmsegmentation/blob/master/configs/mae) (1 ckpts)

- \[ALGORITHM\] [Mask2Former](https:/open-mmlab/mmsegmentation/blob/master/configs/mask2former) (13 ckpts)

- \[ALGORITHM\] [MaskFormer](https:/open-mmlab/mmsegmentation/blob/master/configs/maskformer) (4 ckpts)

- \[BACKBONE\] [MobileNetV2](https:/open-mmlab/mmsegmentation/blob/master/configs/mobilenet_v2) (8 ckpts)

- \[BACKBONE\] [MobileNetV3](https:/open-mmlab/mmsegmentation/blob/master/configs/mobilenet_v3) (4 ckpts)

- \[ALGORITHM\] [NonLocal Net](https:/open-mmlab/mmsegmentation/blob/master/configs/nonlocal_net) (16 ckpts)

- \[ALGORITHM\] [OCRNet](https:/open-mmlab/mmsegmentation/blob/master/configs/ocrnet) (24 ckpts)

- \[ALGORITHM\] [PointRend](https:/open-mmlab/mmsegmentation/blob/master/configs/point_rend) (4 ckpts)

- \[BACKBONE\] [PoolFormer](https:/open-mmlab/mmsegmentation/blob/master/configs/poolformer) (5 ckpts)

- \[ALGORITHM\] [PSANet](https:/open-mmlab/mmsegmentation/blob/master/configs/psanet) (16 ckpts)

- \[ALGORITHM\] [PSPNet](https:/open-mmlab/mmsegmentation/blob/master/configs/pspnet) (54 ckpts)

- \[BACKBONE\] [ResNeSt](https:/open-mmlab/mmsegmentation/blob/master/configs/resnest) (8 ckpts)

- \[ALGORITHM\] [SegFormer](https:/open-mmlab/mmsegmentation/blob/master/configs/segformer) (13 ckpts)

- \[ALGORITHM\] [Segmenter](https:/open-mmlab/mmsegmentation/blob/master/configs/segmenter) (5 ckpts)

- \[ALGORITHM\] [Semantic FPN](https:/open-mmlab/mmsegmentation/blob/master/configs/sem_fpn) (4 ckpts)

- \[ALGORITHM\] [SETR](https:/open-mmlab/mmsegmentation/blob/master/configs/setr) (7 ckpts)

- \[ALGORITHM\] [STDC](https:/open-mmlab/mmsegmentation/blob/master/configs/stdc) (4 ckpts)

- \[BACKBONE\] [Swin Transformer](https:/open-mmlab/mmsegmentation/blob/master/configs/swin) (6 ckpts)

- \[BACKBONE\] [Twins](https:/open-mmlab/mmsegmentation/blob/master/configs/twins) (12 ckpts)

- \[ALGORITHM\] [UNet](https:/open-mmlab/mmsegmentation/blob/master/configs/unet) (25 ckpts)

- \[ALGORITHM\] [UPerNet](https:/open-mmlab/mmsegmentation/blob/master/configs/upernet) (16 ckpts)

- \[BACKBONE\] [Vision Transformer](https:/open-mmlab/mmsegmentation/blob/master/configs/vit) (11 ckpts)
2 changes: 1 addition & 1 deletion docs/en/notes/faq.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Frequently Asked Questions (FAQ)
# \[WIP\] Frequently Asked Questions (FAQ)

We list some common troubles faced by many users and their corresponding solutions here. Feel free to enrich the list if you find any frequent issues and have ways to help others to solve them. If the contents here do not cover your issue, please create an issue using the [provided templates](https:/open-mmlab/mmsegmentation/blob/master/.github/ISSUE_TEMPLATE/error-report.md/) and make sure you fill in all required information in the template.

Expand Down
2 changes: 1 addition & 1 deletion docs/en/user_guides/deployment.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Deployment
# \[WIP\] Deployment

> ## [Try the new MMDeploy to deploy your model](https://mmdeploy.readthedocs.io/)
Expand Down
2 changes: 1 addition & 1 deletion docs/en/user_guides/useful_tools.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Useful Tools
# \[WIP\] Useful Tools

Apart from training/testing scripts, We provide lots of useful tools under the
`tools/` directory.
Expand Down
2 changes: 1 addition & 1 deletion docs/zh_cn/advanced_guides/add_datasets.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 自定义数据集(待更新)
# 新增自定义数据集(待更新)

## 通过重新组织数据来定制数据集

Expand Down
1 change: 0 additions & 1 deletion docs/zh_cn/advanced_guides/add_metric.md

This file was deleted.

1 change: 1 addition & 0 deletions docs/zh_cn/advanced_guides/add_metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 新增评测指标 (待更新)
3 changes: 3 additions & 0 deletions docs/zh_cn/advanced_guides/add_models.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 新增模块(待更新)

中文版文档支持中,请先阅读[英文版本](../../en/advanced_guides/add_models.md)
Loading

0 comments on commit aaa08dc

Please sign in to comment.