-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Update PP-OCRv2预测部署实战.ipynb #5058
Closed
Closed
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 18 additions & 18 deletions
36
notebook/notebook_ch/5.ppocrv2_inference_deployment/PP-OCRv2预测部署实战.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
|
||
|
||
# Key Information Extraction(KIE) | ||
|
||
This section provides a tutorial example on how to quickly use, train, and evaluate a key information extraction(KIE) model, [SDMGR](https://arxiv.org/abs/2103.14470), in PaddleOCR. | ||
|
||
[SDMGR(Spatial Dual-Modality Graph Reasoning)](https://arxiv.org/abs/2103.14470) is a KIE algorithm that classifies each detected text region into predefined categories, such as order ID, invoice number, amount, and etc. | ||
|
||
|
||
* [1. Quick Use](#1-----) | ||
* [2. Model Training](#2-----) | ||
* [3. Model Evaluation](#3-----) | ||
|
||
<a name="1-----"></a> | ||
|
||
## 1. Quick Use | ||
|
||
[Wildreceipt dataset](https://paperswithcode.com/dataset/wildreceipt) is used for this tutorial. It contains 1765 photos, with 25 classes, and 50000 text boxes, which can be downloaded by wget: | ||
|
||
``` | ||
wget https://paddleocr.bj.bcebos.com/dygraph_v2.1/kie/wildreceipt.tar && tar xf wildreceipt.tar | ||
``` | ||
|
||
Download the pretrained model and predict the result: | ||
|
||
``` | ||
cd PaddleOCR/ | ||
wget https://paddleocr.bj.bcebos.com/dygraph_v2.1/kie/kie_vgg16.tar && tar xf kie_vgg16.tar | ||
python3.7 tools/infer_kie.py -c configs/kie/kie_unet_sdmgr.yml -o Global.checkpoints=kie_vgg16/best_accuracy Global.infer_img=../wildreceipt/1.txt | ||
``` | ||
|
||
The prediction result is saved as the folder`./output/sdmgr_kie/predicts_kie.txt`, and the visualization result is saved as the folder`/output/sdmgr_kie/kie_results/`. | ||
|
||
The visualization result is shown in the figure below: | ||
|
||
<div align="center"> | ||
<img src="./imgs/0.png" width="800"> | ||
</div> | ||
|
||
<a name="2-----"></a> | ||
## 2. Model Training | ||
|
||
Create a softlink to the folder, `PaddleOCR/train_data`: | ||
``` | ||
cd PaddleOCR/ && mkdir train_data && cd train_data | ||
|
||
ln -s ../../wildreceipt ./ | ||
``` | ||
|
||
The configuration file used for training is `configs/kie/kie_unet_sdmgr.yml`. The default training data path in the configuration file is `train_data/wildreceipt`. After preparing the data, you can execute the model training with the following command: | ||
``` | ||
python3.7 tools/train.py -c configs/kie/kie_unet_sdmgr.yml -o Global.save_model_dir=./output/kie/ | ||
``` | ||
<a name="3-----"></a> | ||
|
||
## 3. Model Evaluation | ||
|
||
After training, you can execute the model evaluation with the following command: | ||
|
||
``` | ||
python3.7 tools/eval.py -c configs/kie/kie_unet_sdmgr.yml -o Global.checkpoints=./output/kie/best_accuracy | ||
``` | ||
|
||
**Reference:** | ||
|
||
<!-- [ALGORITHM] --> | ||
|
||
```bibtex | ||
@misc{sun2021spatial, | ||
title={Spatial Dual-Modality Graph Reasoning for Key Information Extraction}, | ||
author={Hongbin Sun and Zhanghui Kuang and Xiaoyu Yue and Chenhao Lin and Wayne Zhang}, | ||
year={2021}, | ||
eprint={2103.14470}, | ||
archivePrefix={arXiv}, | ||
primaryClass={cs.CV} | ||
} | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is saved as the folder 翻译有误,请进一步排查其他问题
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
此pr原意是修复PP-OCRv2预测部署实战.ipynb,donkey老师已另提pr修复, 所以我把这个pr关了。kie_en.md的问题在 #5086 中修复。