Skip to content

revise the readme of CRNN #672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions configs/rec/crnn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ We use the dataset under `evaluation/` as the benchmark dataset. On **each indiv
To reproduce the reported evaluation results, you can:
- Option 1: Repeat the evaluation step for all individual datasets: CUTE80, IC03_860, IC03_867, IC13_857, IC131015, IC15_1811, IC15_2077, IIIT5k_3000, SVT, SVTP. Then take the average score.

- Option 2: Put all the benchmark datasets folder under the same directory, e.g. `evaluation/`. And use the script `tools/benchmarking/multi_dataset_eval.py`.
- Option 2: Put all the benchmark datasets folder under the same directory, e.g. `evaluation/`. Modify the `eval.dataset.data_dir` in the config yaml accordingly. Then execute the script `tools/benchmarking/multi_dataset_eval.py`.

1. Evaluate on one specific dataset

Expand Down Expand Up @@ -295,7 +295,7 @@ eval:

* Distributed Training

It is easy to reproduce the reported results with the pre-defined training recipe. For distributed training on multiple Ascend 910 devices, please modify the configuration parameter `distribute` as True and run
It is easy to reproduce the reported results with the pre-defined training recipe. For distributed training on multiple Ascend 910 devices, please modify the configuration parameter `system.distribute` as True and run

```shell
# distributed training on multiple GPU/Ascend devices
Expand All @@ -305,23 +305,29 @@ mpirun --allow-run-as-root -n 8 python tools/train.py --config configs/rec/crnn/

* Standalone Training

If you want to train or finetune the model on a smaller dataset without distributed training, please modify the configuration parameter`distribute` as False and run:
If you want to train or finetune the model on a smaller dataset without distributed training, please modify the configuration parameter`system.distribute` as False and run:

```shell
# standalone training on a CPU/GPU/Ascend device
python tools/train.py --config configs/rec/crnn/crnn_resnet34.yaml
```

The training result (including checkpoints, per-epoch performance and curves) will be saved in the directory parsed by the arg `ckpt_save_dir`. The default directory is `./tmp_rec`.
The training result (including checkpoints, per-epoch performance and curves) will be saved in the directory parsed by the arg `train.ckpt_save_dir`. The default directory is `./tmp_rec`.

### 3.3 Model Evaluation

To evaluate the accuracy of the trained model, you can use `eval.py`. Please set the checkpoint path to the arg `ckpt_load_path` in the `eval` section of yaml config file, set `distribute` to be False, and then run:
To evaluate the accuracy of the trained model, you can use `eval.py`. Please set the checkpoint path to the arg `eval.ckpt_load_path` in the yaml config file, set the evaluation dataset path to the arg `eval.dataset.data_dir`, set `system.distribute` to be False, and then run:

```
python tools/eval.py --config configs/rec/crnn/crnn_resnet34.yaml
```

Similarly, the accuracy of the trained model can be evaluated using multiple evaluation datasets by properly setting the args `eval.ckpt_load_path`, `eval.dataset.data_dir`, and `system.distribute` in the yaml config file. And then run:

```
python tools/benchmarking/multi_dataset_eval.py --config configs/rec/crnn/crnn_resnet34.yaml
```

## 4. Character Dictionary

### Default Setting
Expand All @@ -341,11 +347,11 @@ There are some built-in dictionaries, which are placed in `mindocr/utils/dict/`,
You can also customize a dictionary file (***.txt) and place it under `mindocr/utils/dict/`, the format of the dictionary file should be a .txt file with one character per line.


To use a specific dictionary, set the parameter `character_dict_path` to the path of the dictionary, and change the parameter `num_classes` to the corresponding number, which is the number of characters in the dictionary + 1.
To use a specific dictionary, set the parameter `common.character_dict_path` to the path of the dictionary, and change the parameter `common.num_classes` to the corresponding number, which is the number of characters in the dictionary + 1.


**Notes:**
- You can include the space character by setting the parameter `use_space_char` in configuration yaml to True.
- You can include the space character by setting the parameter `common.use_space_char` in configuration yaml to True.
- Remember to check the value of `dataset->transform_pipeline->RecCTCLabelEncode->lower` in the configuration yaml. Set it to False if you prefer case-sensitive encoding.


Expand Down
20 changes: 13 additions & 7 deletions configs/rec/crnn/README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ eval:
如要重现报告的评估结果,您可以:
- 方法 1:对所有单个数据集重复评估步骤:CUTE80、IC03_860、IC03_867、IC13_857、IC131015、IC15_1811、IC15_2077、IIIT5k_3000、SVT、SVTP。然后取平均分。

- 方法 2:将所有基准数据集文件夹放在同一目录下,例如`evaluation/`。并使用脚本`tools/benchmarking/multi_dataset_eval.py`。
- 方法 2:将所有基准数据集文件夹放在同一目录下,例如`evaluation/`,对应修改配置文件中`eval.dataset.data_dir`变量配置,并执行脚本`tools/benchmarking/multi_dataset_eval.py`。

1.评估一个特定的数据集

Expand Down Expand Up @@ -295,7 +295,7 @@ eval:

* 分布式训练

使用预定义的训练配置可以轻松重现报告的结果。对于在多个昇腾910设备上的分布式训练,请将配置参数`distribute`修改为True,并运行:
使用预定义的训练配置可以轻松重现报告的结果。对于在多个昇腾910设备上的分布式训练,请将配置参数`system.distribute`修改为True,并运行:

```shell
# 在多个 GPU/Ascend 设备上进行分布式训练
Expand All @@ -305,23 +305,29 @@ mpirun --allow-run-as-root -n 8 python tools/train.py --config configs/rec/crnn/

* 单卡训练

如果要在没有分布式训练的情况下在较小的数据集上训练或微调模型,请将配置参数`distribute`修改为False 并运行:
如果要在没有分布式训练的情况下在较小的数据集上训练或微调模型,请将配置参数`system.distribute`修改为False 并运行:

```shell
# CPU/GPU/Ascend 设备上的单卡训练
python tools/train.py --config configs/rec/crnn/crnn_resnet34.yaml
```

训练结果(包括checkpoint、每个epoch的性能和曲线图)将被保存在yaml配置文件的`ckpt_save_dir`参数配置的目录下,默认为`./tmp_rec`。
训练结果(包括checkpoint、每个epoch的性能和曲线图)将被保存在yaml配置文件的`train.ckpt_save_dir`参数配置的目录下,默认为`./tmp_rec`。

### 3.3 模型评估

若要评估已训练模型的准确性,可以使用`eval.py`。请在yaml配置文件的`eval`部分将参数`ckpt_load_path`设置为模型checkpoint的文件路径,设置`distribute`为False,然后运行:
若要评估已训练模型的准确性,可以使用`eval.py`。请将yaml配置文件的参数`eval.ckpt_load_path`设置为模型checkpoint的文件路径,参数`eval.dataset.data_dir`设置为评估数据集目录,参数`system.distribute`设置为False,然后运行:

```
python tools/eval.py --config configs/rec/crnn/crnn_resnet34.yaml
```

类似的,可以修改yaml配置文件的`eval.ckpt_load_path`、`eval.dataset.data_dir`、`system.distribute`等参数,然后使用`multi_dataset_eval.py`评估多个数据集的模型准确性:

```
python tools/benchmarking/multi_dataset_eval.py --config configs/rec/crnn/crnn_resnet34.yaml
```

## 4. 字符词典

### 默认设置
Expand All @@ -342,11 +348,11 @@ Mindocr内置了一部分字典,均放在了 `mindocr/utils/dict/` 位置,
您也可以自定义一个字典文件 (***.txt), 放在 `mindocr/utils/dict/` 下,词典文件格式应为每行一个字符的.txt 文件。


如需使用指定的词典,请将参数 `character_dict_path` 设置为字典的路径,并将参数 `num_classes` 改成对应的数量,即字典中字符的数量 + 1。
如需使用指定的词典,请将参数 `common.character_dict_path` 设置为字典的路径,并将参数 `common.num_classes` 改成对应的数量,即字典中字符的数量 + 1。


**注意:**
- 您可以通过将配置文件中的参数 `use_space_char` 设置为 True 来包含空格字符。
- 您可以通过将配置文件中的参数 `common.use_space_char` 设置为 True 来包含空格字符。
- 请记住检查配置文件中的 `dataset->transform_pipeline->RecCTCLabelEncode->lower` 参数的值。如果词典中有大小写字母而且想区分大小写的话,请将其设置为 False。


Expand Down