Skip to content

Commit e074f5f

Browse files
committed
2 parents e6b64e2 + bfb030d commit e074f5f

File tree

19 files changed

+188
-88
lines changed

19 files changed

+188
-88
lines changed

.github/workflows/python-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
python -m build
3131
- name: Publish package
3232
env:
33-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
34-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
33+
TWINE_USERNAME: __token__
34+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
3535
run: |
3636
twine upload dist/*

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
include LICENSE
22
include README.md
3+
include requirements.txt
34

45
recursive-include mindocr *.py

configs/layout/yolov8/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ python infer.py \
160160
--input_images_dir=/your_path_to/val \
161161
--layout_model_path=your_path_to/output.mindir \
162162
--layout_model_name_or_config=../../configs/layout/yolov8/yolov8n.yaml \
163-
--layout_save_dir=results_dir
163+
--res_save_dir=results_dir
164164
```
165165

166166
## 6. Visualization

configs/layout/yolov8/README_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ python infer.py \
173173
--input_images_dir=/your_path_to/val \
174174
--layout_model_path=your_path_to/output.mindir \
175175
--layout_model_name_or_config=../../configs/layout/yolov8/yolov8n.yaml \
176-
--layout_save_dir=results_dir
176+
--res_save_dir=results_dir
177177
```
178178

179179
## 6. 可视化

configs/rec/crnn/README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ We use the dataset under `evaluation/` as the benchmark dataset. On **each indiv
186186
To reproduce the reported evaluation results, you can:
187187
- 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.
188188

189-
- 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`.
189+
- 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`.
190190

191191
1. Evaluate on one specific dataset
192192

@@ -295,7 +295,7 @@ eval:
295295

296296
* Distributed Training
297297

298-
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
298+
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
299299

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

306306
* Standalone Training
307307

308-
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:
308+
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:
309309

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

315-
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`.
315+
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`.
316316

317317
### 3.3 Model Evaluation
318318

319-
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:
319+
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:
320320

321321
```
322322
python tools/eval.py --config configs/rec/crnn/crnn_resnet34.yaml
323323
```
324324

325+
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:
326+
327+
```
328+
python tools/benchmarking/multi_dataset_eval.py --config configs/rec/crnn/crnn_resnet34.yaml
329+
```
330+
325331
## 4. Character Dictionary
326332

327333
### Default Setting
@@ -341,11 +347,11 @@ There are some built-in dictionaries, which are placed in `mindocr/utils/dict/`,
341347
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.
342348

343349

344-
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.
350+
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.
345351

346352

347353
**Notes:**
348-
- You can include the space character by setting the parameter `use_space_char` in configuration yaml to True.
354+
- You can include the space character by setting the parameter `common.use_space_char` in configuration yaml to True.
349355
- 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.
350356

351357

configs/rec/crnn/README_CN.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ eval:
186186
如要重现报告的评估结果,您可以:
187187
- 方法 1:对所有单个数据集重复评估步骤:CUTE80、IC03_860、IC03_867、IC13_857、IC131015、IC15_1811、IC15_2077、IIIT5k_3000、SVT、SVTP。然后取平均分。
188188

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

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

@@ -295,7 +295,7 @@ eval:
295295

296296
* 分布式训练
297297

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

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

306306
* 单卡训练
307307

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

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

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

317317
### 3.3 模型评估
318318

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

321321
```
322322
python tools/eval.py --config configs/rec/crnn/crnn_resnet34.yaml
323323
```
324324

325+
类似的,可以修改yaml配置文件的`eval.ckpt_load_path``eval.dataset.data_dir``system.distribute`等参数,然后使用`multi_dataset_eval.py`评估多个数据集的模型准确性:
326+
327+
```
328+
python tools/benchmarking/multi_dataset_eval.py --config configs/rec/crnn/crnn_resnet34.yaml
329+
```
330+
325331
## 4. 字符词典
326332

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

344350

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

347353

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

352358

docs/cn/tutorials/frequently_asked_questions.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [DBNet训练速率不及预期](#q9-DBNet训练速率不及预期)
1111
- [`libgomp-d22c30c5.so.1.0.0`相关错误](#q10-libgomp-d22c30c5so100相关错误)
1212
- [当在lmdb dataset上训练abinet报数据管道错误](#q11-当在lmdb-dataset上训练abinet报数据管道错误)
13+
- [当在synthtext数据集上训练dbnet报运行时错误](#q12-当在synthtext数据集上训练dbnet报运行时错误)
1314

1415
### Q1 未定义符号
1516

@@ -742,3 +743,15 @@ mindspore/ccsrc/minddata/dataset/kernels/py_func_op.cc(143).
742743
102 EXECUTORS_LIST[key] = executor
743744
```
744745
- 保存后再次尝试训练即可
746+
747+
### Q12 当在synthtext数据集上训练dbnet报运行时错误
748+
当在synthtext数据集上训练dbnet报以下数据管道错误
749+
```bash
750+
Traceback (most recent call last):
751+
...
752+
File "/root/archiconda3/envs/Python380/lib/python3.8/site-packages/mindspore/common/api.py", line 1608, in _exec_pip
753+
return self.graph_executor(args, phase)
754+
RuntimeError: Run task for graph:kernel_graph_1 error! The details reger to 'Ascend Error Message'
755+
```
756+
757+
请尝试将CANN更新到7.1。

docs/en/tutorials/frequently_asked_questions.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [Training speed of DBNet not as fast as expexted](#q9-training-speed-of-dbnet-not-as-fast-as-expexted)
1111
- [Error about `libgomp-d22c30c5.so.1.0.0`](#q10-error-about-libgomp-d22c30c5so100)
1212
- [Dataset Pipeline Error when training abinet on lmdb dataset](#q11-dataset-pipeline-error-when-training-abinet-on-lmdb-dataset)
13+
- [Runtime Error when training dbnet on synthtext dataset](#q12-runtime-error-when-training-dbnet-on-synthtext-dataset)
1314

1415
### Q1 Undefined symbol
1516

@@ -731,3 +732,15 @@ You can try the following steps to fix it:
731732
102 EXECUTORS_LIST[key] = executor
732733
```
733734
- save the file, and try to train the model.
735+
736+
737+
### Q12 Runtime Error when training dbnet on synthtext dataset
738+
Runtime Error occur as following when training dbnet on synthtext dataset:
739+
```bash
740+
Traceback (most recent call last):
741+
...
742+
File "/root/archiconda3/envs/Python380/lib/python3.8/site-packages/mindspore/common/api.py", line 1608, in _exec_pip
743+
return self.graph_executor(args, phase)
744+
RuntimeError: Run task for graph:kernel_graph_1 error! The details reger to 'Ascend Error Message'
745+
```
746+
Please update CANN to 7.1 version.

mindocr/data/builder.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,13 @@ def _parse_minddata_op(dataset_args):
266266
minddata_op_list.append(color_adjust_op)
267267
continue
268268
if "NormalizeImage" in transform_dict.keys():
269+
from mindocr.data.transforms.general_transforms import get_value
270+
271+
normalize_transform = transform_dict["NormalizeImage"]
272+
mean = get_value(normalize_transform.get("mean", "imagenet"), "mean")
273+
std = get_value(normalize_transform.get("std", "imagenet"), "std")
269274
minddata_op_idx.append(i)
270-
normalize_op = ms.dataset.vision.Normalize(mean=IMAGENET_DEFAULT_MEAN, std=IMAGENET_DEFAULT_STD)
275+
normalize_op = ms.dataset.vision.Normalize(mean=mean, std=std)
271276
minddata_op_list.append(normalize_op)
272277
continue
273278
if "ToCHWImage" in transform_dict.keys():

0 commit comments

Comments
 (0)