Skip to content

Commit

Permalink
updata train_test doc for tta
Browse files Browse the repository at this point in the history
  • Loading branch information
Harold-lkk committed Feb 16, 2023
1 parent 1ad8567 commit f021ca2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
10 changes: 5 additions & 5 deletions configs/textrecog/crnn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ Image-based sequence recognition has been a long-standing research topic in comp

## Results and models

| methods | | Regular Text | | | | Irregular Text | | download |
| :----------------------------------------------------: | :----: | :----------: | :-------: | :-: | :-------: | :------------: | :----: | :-------------------------------------------------------------------------------------: |
| methods | IIIT5K | SVT | IC13-1015 | | IC15-2077 | SVTP | CT80 | |
| [CRNN](/configs/textrecog/crnn/crnn_mini-vgg_5e_mj.py) | 0.8053 | 0.7991 | 0.8739 | | 0.5571 | 0.6093 | 0.5694 | [model](https://download.openmmlab.com/mmocr/textrecog/crnn/crnn_mini-vgg_5e_mj/crnn_mini-vgg_5e_mj_20220826_224120-8afbedbb.pth) \| [log](https://download.openmmlab.com/mmocr/textrecog/crnn/crnn_mini-vgg_5e_mj/20220826_224120.log) |
| CRNN-TTA) | 0.8013 | 0.7975 | 0.8631 | | 0.5763 | 0.6093 | 0.5764 | [model](https://download.openmmlab.com/mmocr/textrecog/crnn/crnn_mini-vgg_5e_mj/crnn_mini-vgg_5e_mj_20220826_224120-8afbedbb.pth) \| [log](https://download.openmmlab.com/mmocr/textrecog/crnn/crnn_mini-vgg_5e_mj/20220826_224120.log) |
| methods | | Regular Text | | | | Irregular Text | | download |
| :--------------------------------------------------------: | :----: | :----------: | :-------: | :-: | :-------: | :------------: | :----: | :---------------------------------------------------------------------------------: |
| methods | IIIT5K | SVT | IC13-1015 | | IC15-2077 | SVTP | CT80 | |
| [CRNN](/configs/textrecog/crnn/crnn_mini-vgg_5e_mj.py) | 0.8053 | 0.7991 | 0.8739 | | 0.5571 | 0.6093 | 0.5694 | [model](https://download.openmmlab.com/mmocr/textrecog/crnn/crnn_mini-vgg_5e_mj/crnn_mini-vgg_5e_mj_20220826_224120-8afbedbb.pth) \| [log](https://download.openmmlab.com/mmocr/textrecog/crnn/crnn_mini-vgg_5e_mj/20220826_224120.log) |
| [CRNN-TTA](/configs/textrecog/crnn/crnn_mini-vgg_5e_mj.py) | 0.8013 | 0.7975 | 0.8631 | | 0.5763 | 0.6093 | 0.5764 | [model](https://download.openmmlab.com/mmocr/textrecog/crnn/crnn_mini-vgg_5e_mj/crnn_mini-vgg_5e_mj_20220826_224120-8afbedbb.pth) \| [log](https://download.openmmlab.com/mmocr/textrecog/crnn/crnn_mini-vgg_5e_mj/20220826_224120.log) |

## Citation

Expand Down
13 changes: 13 additions & 0 deletions docs/en/user_guides/train_test.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ The following table lists all the arguments supported by `train.py`. Args withou
| --cfg-options | str | Override some settings in the configs. [Example](<>) |
| --launcher | str | Option for launcher,\['none', 'pytorch', 'slurm', 'mpi'\]. |
| --local_rank | int | Rank of local machine,used for distributed training,defaults to 0。 |
| --tta | bool | Whether to use test time augmentation. |

### Test

Expand Down Expand Up @@ -308,3 +309,15 @@ The visualization-related parameters in `tools/test.py` are described as follows
| --show | bool | Whether to show the visualization results. |
| --show-dir | str | Path to save the visualization results. |
| --wait-time | float | Interval of visualization (s), defaults to 2. |

### Test Time Augmentation

Test time augmentation (TTA) is a technique that is used to improve the performance of a model by performing data augmentation on the input image at test time. It is a simple yet effective method to improve the performance of a model. In MMOCR, we support TTA in the following ways:

```{note}
TTA is only supported for text recognition models.
```

```bash
python tools/test.py configs/textrecog/crnn/crnn_mini-vgg_5e_mj.py checkpoints/crnn_mini-vgg_5e_mj.pth --tta
```
14 changes: 14 additions & 0 deletions docs/zh_cn/user_guides/train_test.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ CUDA_VISIBLE_DEVICES=0 python tools/test.py configs/textdet/dbnet/dbnet_resnet50
| --cfg-options | str | 用于覆写配置文件中的指定参数。[示例](#添加示例) |
| --launcher | str | 启动器选项,可选项目为 \['none', 'pytorch', 'slurm', 'mpi'\]|
| --local_rank | int | 本地机器编号,用于多机多卡分布式训练,默认为 0。 |
| --tta | bool | 是否使用测试时数据增强 |

## 多卡机器训练及测试

Expand Down Expand Up @@ -308,3 +309,16 @@ python tools/test.py configs/textdet/dbnet/dbnet_r50dcnv2_fpnc_1200e_icdar2015.p
| --show | bool | 是否绘制可视化结果。 |
| --show-dir | str | 可视化图片存储路径。 |
| --wait-time | float | 可视化间隔时间(秒),默认为 2。 |

### 测试时数据增强

测试时增强,指的是在推理(预测)阶段,将原始图片进行水平翻转、垂直翻转、对角线翻转、旋转角度等数据增强操作,得到多张图,分别进行推理,再对多个结果进行综合分析,得到最终输出结果。
为此,MMOCR 提供了一键式测试时数据增强,仅需在测试时添加 `--tta` 参数即可。

```{note}
TTA 仅支持文本识别模型。
```

```bash
python tools/test.py configs/textrecog/crnn/crnn_mini-vgg_5e_mj.py checkpoints/crnn_mini-vgg_5e_mj.pth --tta
```
2 changes: 0 additions & 2 deletions tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ def main():
if args.show or args.show_dir:
cfg = trigger_visualization_hook(cfg, args)

cfg.load_from = args.checkpoint

if args.tta:
cfg.test_dataloader.dataset.pipeline = cfg.tta_pipeline
cfg.tta_model.module = cfg.model
Expand Down

0 comments on commit f021ca2

Please sign in to comment.