Skip to content

Update FAQ & Add paddle2mindir & Update ppocrv4 config file #685

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 19 commits into from
Apr 1, 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
2 changes: 1 addition & 1 deletion deploy/py_infer/src/configs/cls/ppocr/cls_mv3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ eval:
channel_first: False
- RecResizeNormForInfer:
target_height: 48
target_width: 320
target_width: 192 # 320 for ppocrv3
keep_ratio: True
padding: True
norm_before_pad: True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ postprocess:
binary_thresh: 0.3
box_thresh: 0.6
max_candidates: 1000
expand_ratio: 1.5
expand_ratio: 1.6
if_merge_longedge_bbox: True
merge_inter_area_thres: 300
merge_ratio: 1.3
Expand Down
21 changes: 21 additions & 0 deletions docs/cn/inference/inference_thirdparty_quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ graph LR;
```

### 3. 第三方模型推理方法
对于`ppocrv4`模型,这里提供了[快速转换工具](#35-快速转换工具),供用户快速将paddle模型转换为MindIR模型。
#### 3.1 文本检测

下面主要以[第三方模型支持列表](#11-文本检测)中的`ch_pp_det_OCRv4`为例介绍推理方法:
Expand Down Expand Up @@ -428,5 +429,25 @@ python deploy/py_infer/infer.py \
--res_save_dir=/path/to/infer_results
```

### 3.5 快速转换工具
对于ppocrv4,我们提供了快速转换工具,方便用户将ppocrv4的paddle模型转换为MindIR模型,使用方法如下
- 确认`MindSpore Lite`已成功下载并配置,详见[MindSpore Lite](https://www.mindspore.cn/lite),且`converter_lite`已加入环境变量
- 执行以下命令开始转换
```bash
cd tools
bash paddle2mindir.sh -m=${ppocr_model_name} -p=${save_dir}
```
- `$ppocr_model_name`: 进行转换的ppocr模型,支持`ch_PP-OCRv4`, `ch_PP-OCRv4_server`
- `$save_dir`: 保存模型下载与转换的路径

转换过程将执行较久,请等待。执行后,将得到以下转换后的MindIR文件
```
ppocr_models
├── ${PPOCR_MODEL_NAME}_det_db_dynamic_output.mindir
├── ${PPOCR_MODEL_NAME}_rec_crnn_static_output.mindir
├── ${PPOCR_MODEL_NAME}_cls_mv4_static_output.mindir
├── ...
```

## 4 FAQ
转换与推理相关问题可参考[FAQ](../tutorials/frequently_asked_questions.md)
98 changes: 98 additions & 0 deletions docs/cn/tutorials/frequently_asked_questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
- [`libgomp-d22c30c5.so.1.0.0`相关错误](#q10-libgomp-d22c30c5so100相关错误)
- [当在lmdb dataset上训练abinet报数据管道错误](#q11-当在lmdb-dataset上训练abinet报数据管道错误)
- [当在synthtext数据集上训练dbnet报运行时错误](#q12-当在synthtext数据集上训练dbnet报运行时错误)
- [安装seqeval相关错误](#q13-安装seqeval相关错误)
- [安装lanms相关错误](#q14-安装lanms相关错误)

### Q1 未定义符号

Expand Down Expand Up @@ -755,3 +757,99 @@ RuntimeError: Run task for graph:kernel_graph_1 error! The details reger to 'Asc
```

请尝试将CANN更新到7.1。


### Q13 安装seqeval相关错误
当运行`pip install -r requirements.txt`时,报以下错误
```bash
Collecting seqeval>=1.2.2 (from -r requirements.txt (line 19))
Downloading http://mirrors.aliyun.com/pypi/packages/9d/2d/233c79d5b4e5ab1dbf111242299153f3caddddbb691219f363ad55ce783d/seqeval-1.2.2.tar.gz (43 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 43.6/43.6 kB 181.0 kB/s eta 0:00:00
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [48 lines of output]
/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/setuptools/__init__.py:80: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

********************************************************************************
Requirements should be satisfied by a PEP 517 installer.
If you are using pip, you can try `pip install --use-pep517`.
********************************************************************************

!!
dist.fetch_build_eggs(dist.setup_requires)
WARNING: The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host mirrors.aliyun.com'.
ERROR: Could not find a version that satisfies the requirement setuptools_scm (from versions: none)
ERROR: No matching distribution found for setuptools_scm
Traceback (most recent call last):
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/setuptools/installer.py", line 101, in _fetch_build_egg_no_warn
subprocess.check_call(cmd)
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/home/ma-user/anaconda3/envs/MindSpore/bin/python3.9', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpusgt0k69', '--quiet', 'setuptools_scm']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-m2kqztlz/seqeval_da00f708dc0e483b92cd18083513d5e7/setup.py", line 27, in <module>
setup(
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/setuptools/__init__.py", line 102, in setup
_install_setup_requires(attrs)
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/setuptools/__init__.py", line 75, in _install_setup_requires
_fetch_build_eggs(dist)
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/setuptools/__init__.py", line 80, in _fetch_build_eggs
dist.fetch_build_eggs(dist.setup_requires)
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/setuptools/dist.py", line 636, in fetch_build_eggs
return _fetch_build_eggs(self, requires)
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/setuptools/installer.py", line 38, in _fetch_build_eggs
resolved_dists = pkg_resources.working_set.resolve(
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/pkg_resources/__init__.py", line 829, in resolve
dist = self._resolve_dist(
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/pkg_resources/__init__.py", line 865, in _resolve_dist
dist = best[req.key] = env.best_match(
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1135, in best_match
return self.obtain(req, installer)
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1147, in obtain
return installer(requirement)
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/setuptools/installer.py", line 103, in _fetch_build_egg_no_warn
raise DistutilsError(str(e)) from e
distutils.errors.DistutilsError: Command '['/home/ma-user/anaconda3/envs/MindSpore/bin/python3.9', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpusgt0k69', '--quiet', 'setuptools_scm']' returned non-zero exit status 1.
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.

```
尝试以下步骤修复:
- 更新`setuptools`: `pip3 install --upgrade setuptools`
- 更新`setuptools_scm`: `pip3 install --upgrade setuptools_scm`
- 安装`seqeval`:`pip3 install seqeval -i https://pypi.tuna.tsinghua.edu.cn/simple`


### Q14 安装lanms相关错误
当安装lanms时,报
```bash
ImportError: Python version mismatch: module was compiled for version 3.8, while the interpreter is running version 3.7.
```
该问题可能是当前存在多个python3环境导致,你可使用以下步骤解决该问题
- 执行`pip3 install lanms -i https://pypi.tuna.tsinghua.edu.cn/simple`,得到`lanms-1.0.2.tar.gz`的下载链接(如https://pypi.tuna.tsinghua.edu.cn/packages/96/c0/50dc2c857ed060e907adaef31184413a7706e475c322236d346382e45195/lanms-1.0.2.tar.gz)
- 使用该下载链接,下载`lanms-1.0.2.tar.gz`,执行`tar -zxvf lanms-1.0.2.tar.gz`以解压该包
- `cd lanms-1.0.2`
- 编辑`Makefile`,在第1,2行中,用`python3.7-config`替代`python3-config`,得到如下修改
```bash
CXXFLAGS = -I include -std=c++11 -O3 $(shell python3.7-config --cflags)
LDFLAGS = $(shell python3.7-config --ldflags)
...
```
保存该`Makefile`, 执行过程将匹配到python 3.7环境
- 执行`python setup.py install`以安装`lanms`
22 changes: 21 additions & 1 deletion docs/en/inference/inference_thirdparty_quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ graph LR;
```

### 3. Third-Party Model Inference Methods

For ppocrv4, we provide [Quick Convertion Tool](#35-quick-convertion-tool) for converting Paddle model to MindIR model.
#### 3.1 Text Detection

Let's take `ch_pp_det_OCRv4` in [Third-Party Model Support List](#11-text-detection) as an example to introduce the inference method:
Expand Down Expand Up @@ -448,5 +448,25 @@ python deploy/py_infer/infer.py \
--res_save_dir=/path/to/infer_results
```

### 3.5 Quick Convertion Tool
For ppocrv4,we provide tools for converting Paddle model to MindIR model, the guidence is as following:
- Make sure `MindSpore Lite` has been downloaded and configured successfully, please refer to [MindSpore Lite](https://www.mindspore.cn/lite). And make sure `converter_lite` has been added into the environment variable.
- Run the following command:
```bash
cd tools
bash paddle2mindir.sh -m=${ppocr_model_name} -p=${save_dir}
```
- `$ppocr_model_name`: ppocr models to be converted. `ch_PP-OCRv4`, `ch_PP-OCRv4_server` are supported
- `$save_dir`: folder to save downloaded ppocr models and converted mindir. Default: ppocr_models

The convertion may cost minutes, please wait. And You could get the following MindIR models after convertion:
```
ppocr_models
├── ${PPOCR_MODEL_NAME}_det_db_dynamic_output.mindir
├── ${PPOCR_MODEL_NAME}_rec_crnn_static_output.mindir
├── ${PPOCR_MODEL_NAME}_cls_mv4_static_output.mindir
├── ...
```

## 4.FAQ about converting and inference
For problems about converting model and inference, please refer to [FAQ](../tutorials/frequently_asked_questions.md) for solutions.
100 changes: 100 additions & 0 deletions docs/en/tutorials/frequently_asked_questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
- [Error about `libgomp-d22c30c5.so.1.0.0`](#q10-error-about-libgomp-d22c30c5so100)
- [Dataset Pipeline Error when training abinet on lmdb dataset](#q11-dataset-pipeline-error-when-training-abinet-on-lmdb-dataset)
- [Runtime Error when training dbnet on synthtext dataset](#q12-runtime-error-when-training-dbnet-on-synthtext-dataset)
- [Failed to install seqeval](#q13-failed-to-install-seqeval)
- [Failed to install lanms](#q14-failed-to-install-lanms)
>>>>>>> dca11cc9989deabe86985f0729502266e5ba6f42

### Q1 Undefined symbol

Expand Down Expand Up @@ -744,3 +747,100 @@ Traceback (most recent call last):
RuntimeError: Run task for graph:kernel_graph_1 error! The details reger to 'Ascend Error Message'
```
Please update CANN to 7.1 version.


### Q13 Failed to install seqeval
The following error occur when run `pip install -r requirements.txt`
```bash
Collecting seqeval>=1.2.2 (from -r requirements.txt (line 19))
Downloading http://mirrors.aliyun.com/pypi/packages/9d/2d/233c79d5b4e5ab1dbf111242299153f3caddddbb691219f363ad55ce783d/seqeval-1.2.2.tar.gz (43 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 43.6/43.6 kB 181.0 kB/s eta 0:00:00
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [48 lines of output]
/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/setuptools/__init__.py:80: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

********************************************************************************
Requirements should be satisfied by a PEP 517 installer.
If you are using pip, you can try `pip install --use-pep517`.
********************************************************************************

!!
dist.fetch_build_eggs(dist.setup_requires)
WARNING: The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host mirrors.aliyun.com'.
ERROR: Could not find a version that satisfies the requirement setuptools_scm (from versions: none)
ERROR: No matching distribution found for setuptools_scm
Traceback (most recent call last):
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/setuptools/installer.py", line 101, in _fetch_build_egg_no_warn
subprocess.check_call(cmd)
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/home/ma-user/anaconda3/envs/MindSpore/bin/python3.9', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpusgt0k69', '--quiet', 'setuptools_scm']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-m2kqztlz/seqeval_da00f708dc0e483b92cd18083513d5e7/setup.py", line 27, in <module>
setup(
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/setuptools/__init__.py", line 102, in setup
_install_setup_requires(attrs)
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/setuptools/__init__.py", line 75, in _install_setup_requires
_fetch_build_eggs(dist)
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/setuptools/__init__.py", line 80, in _fetch_build_eggs
dist.fetch_build_eggs(dist.setup_requires)
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/setuptools/dist.py", line 636, in fetch_build_eggs
return _fetch_build_eggs(self, requires)
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/setuptools/installer.py", line 38, in _fetch_build_eggs
resolved_dists = pkg_resources.working_set.resolve(
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/pkg_resources/__init__.py", line 829, in resolve
dist = self._resolve_dist(
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/pkg_resources/__init__.py", line 865, in _resolve_dist
dist = best[req.key] = env.best_match(
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1135, in best_match
return self.obtain(req, installer)
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1147, in obtain
return installer(requirement)
File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/setuptools/installer.py", line 103, in _fetch_build_egg_no_warn
raise DistutilsError(str(e)) from e
distutils.errors.DistutilsError: Command '['/home/ma-user/anaconda3/envs/MindSpore/bin/python3.9', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpusgt0k69', '--quiet', 'setuptools_scm']' returned non-zero exit status 1.
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.

```
Please try the following steps to fix this problem:
- Update `setuptools`: `pip3 install --upgrade setuptools`
- Update `setuptools_scm`: `pip3 install --upgrade setuptools_scm`
- Install `seqeval`:`pip3 install seqeval -i https://pypi.tuna.tsinghua.edu.cn/simple`


### Q14 Failed to install lanms
The following error occur when installing lanms
```bash
ImportError: Python version mismatch: module was compiled for version 3.8, while the interpreter is running version 3.7.
```
Some Python 3.7 environment may meet this problem when multiple python3 environment exists. You could try the following steps to solve this problem:
1. run `pip3 install lanms -i https://pypi.tuna.tsinghua.edu.cn/simple`, and get the url for downloading `lanms-1.0.2.tar.gz`(like https://pypi.tuna.tsinghua.edu.cn/packages/96/c0/50dc2c857ed060e907adaef31184413a7706e475c322236d346382e45195/lanms-1.0.2.tar.gz)
2. use this url and dowload the `lanms-1.0.2.tar.gz`, run `tar -zxvf lanms-1.0.2.tar.gz` to decompress the package.
3. `cd lanms-1.0.2`
4. edit the `Makefile`, replace `python3-config` with `python3.7-config` in line 1 and line 2, and you could get
```text
CXXFLAGS = -I include -std=c++11 -O3 $(shell python3.7-config --cflags)
LDFLAGS = $(shell python3.7-config --ldflags)
...
```
save `Makefile`. So that the make process would exactly compile with python3.7 environment
5. run `python setup.py install` and completely install lanms.
>>>>>>> dca11cc9989deabe86985f0729502266e5ba6f42
Loading