From 6c3599bd9dd7106de7b9167e5e5113e72e9ea435 Mon Sep 17 00:00:00 2001 From: CSH <40987381+csatsurnh@users.noreply.github.com> Date: Tue, 7 Mar 2023 11:47:10 +0800 Subject: [PATCH] [Doc] Add zh_cn models doc and fix en doc typo (#2703) as title --------- Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com> --- docs/en/advanced_guides/models.md | 10 +- docs/zh_cn/advanced_guides/models.md | 176 ++++++++++++++++++++++++++- 2 files changed, 179 insertions(+), 7 deletions(-) diff --git a/docs/en/advanced_guides/models.md b/docs/en/advanced_guides/models.md index 8202e95b7..84e6cb6a9 100644 --- a/docs/en/advanced_guides/models.md +++ b/docs/en/advanced_guides/models.md @@ -1,7 +1,5 @@ # Models -# Models - We usually define a neural network in a deep learning task as a model, and this model is the core of an algorithm. [MMEngine](https://github.com/open-mmlab/mmengine) abstracts a unified model [BaseModel](https://github.com/open-mmlab/mmengine/blob/main/mmengine/model/base_model/base_model.py#L16) to standardize the interfaces for training, testing and other processes. All models implemented by MMSegmentation inherit from `BaseModel`, and in MMSegmentation we implemented forward and added some functions for the semantic segmentation algorithm. ## Common components @@ -22,9 +20,9 @@ In MMSegmentation, we abstract the network architecture as a **Segmentor**, it i **Neck** is the part that connects the backbone and heads. It performs some refinements or reconfigurations on the raw feature maps produced by the backbone. An example is **Feature Pyramid Network (FPN)**. -### Decode Head +### Decode head -**Decode Head** is the part that transforms the feature maps into a segmentation mask, such as **PSPNet**. +**Decode head** is the part that transforms the feature maps into a segmentation mask, such as **PSPNet**. ### Auxiliary head @@ -110,7 +108,7 @@ Parameters: - data (dict or tuple or list) - Data sampled from the dataset. In MMSegmentation, the data dict contains `inputs` and `data_samples` two fields. - optim_wrapper (OptimWrapper) - OptimWrapper instance used to update model parameters. -**Note:** [OptimWrapper](https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/optimizer_wrapper.py#L17) provides a common interface for updating parameters, please refer to optimizer wrapper [documentation](https://mmengine.readthedocs.io/zh_CN/latest/tutorials/optim_wrapper.html) in [MMEngine](https://github.com/open-mmlab/mmengine) for more information. +**Note:** [OptimWrapper](https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/optimizer_wrapper.py#L17) provides a common interface for updating parameters, please refer to optimizer wrapper [documentation](https://mmengine.readthedocs.io/en/latest/tutorials/optim_wrapper.html) in [MMEngine](https://github.com/open-mmlab/mmengine) for more information. Returns: @@ -157,7 +155,7 @@ The parameters of the `SegDataPreProcessor` constructor: - pad_val (float, optional) - Padding value. Default: 0. - seg_pad_val (float, optional) - Padding value of segmentation map. Default: 255. - bgr_to_rgb (bool) - whether to convert image from BGR to RGB. Defaults to False. -- rgb_to_bgr (bool) - whether to convert image from RGB to RGB. Defaults to False. +- rgb_to_bgr (bool) - whether to convert image from RGB to BGR. Defaults to False. - batch_augments (list\[dict\], optional) - Batch-level augmentations. Default to None. The data will be processed as follows: diff --git a/docs/zh_cn/advanced_guides/models.md b/docs/zh_cn/advanced_guides/models.md index 62dbea38c..408a57863 100644 --- a/docs/zh_cn/advanced_guides/models.md +++ b/docs/zh_cn/advanced_guides/models.md @@ -1,3 +1,177 @@ # 模型 -中文版文档支持中,请先阅读[英文版本](../../en/advanced_guides/models.md) +我们通常将深度学习任务中的神经网络定义为模型,这个模型即是算法的核心。[MMEngine](https://github.com/open-mmlab/mmengine) 抽象出了一个统一模型 [BaseModel](https://github.com/open-mmlab/mmengine/blob/main/mmengine/model/base_model/base_model.py#L16) 以标准化训练、测试和其他过程。MMSegmentation 实现的所有模型都继承自 `BaseModel`,并且在 MMSegmention 中,我们实现了前向传播并为语义分割算法添加了一些功能。 + +## 常用组件 + +### 分割器(Segmentor) + +在 MMSegmentation 中,我们将网络架构抽象为**分割器**,它是一个包含网络所有组件的模型。我们已经实现了**编码器解码器(EncoderDecoder)**和**级联编码器解码器(CascadeEncoderDecoder)**,它们通常由**数据预处理器**、**骨干网络**、**解码头**和**辅助头**组成。 + +### 数据预处理器(Data preprocessor) + +**数据预处理器**是将数据复制到目标设备并将数据预处理为模型输入格式的部分。 + +### 主干网络(Backbone) + +**主干网络**是将图像转换为特征图的部分,例如没有最后全连接层的 **ResNet-50**。 + +### 颈部(Neck) + +**颈部**是连接主干网络和头的部分。它对主干网络生成的原始特征图进行一些改进或重新配置。例如 **Feature Pyramid Network(FPN)**。 + +### 解码头(Decode head) + +**解码头**是将特征图转换为分割掩膜的部分,例如 **PSPNet**。 + +### 辅助头(Auxiliary head) + +**辅助头**是一个可选组件,它将特征图转换为仅用于计算辅助损失的分割掩膜。 + +## 基本接口 + +MMSegmentation 封装 `BaseModel` 并实现了 [BaseSegmenter](https://github.com/open-mmlab/mmsegmentation/blob/1.x/mmseg/models/segmentors/base.py#L15) 类,主要提供 `forward`、`train_step`、`val_step` 和 `test_step` 接口。接下来将详细介绍这些接口。 + +### forward + +