モデル概要
モデル特徴
モデル能力
使用事例
🚀 PP-OCRv5_mobile_rec
PP-OCRv5_mobile_rec は、PaddleOCR チームによって開発された最新世代のテキスト行認識モデル PP-OCRv5_rec の一つです。このモデルは、単一のモデルで簡体字中国語、繁体字中国語、英語、日本語の4つの主要言語の認識を効率的かつ正確にサポートし、手書き、縦書きテキスト、ピンイン、難字などの複雑なテキストシーンにも対応しています。主要な精度指標は以下の通りです。
手書き中国語 | 手書き英語 | 印刷中国語 | 印刷英語 | 繁体字中国語 | 古文 | 日本語 | 一般的なシーン | ピンイン | 回転テキスト | 歪んだテキスト | アートフォント | 平均精度 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0.4166 | 0.4944 | 0.8605 | 0.8753 | 0.7199 | 0.5786 | 0.7577 | 0.5570 | 0.7703 | 0.7248 | 0.8089 | 0.5398 | 0.8015 |
⚠️ 重要提示
一行内の任意の文字(句読点を含む)が誤っている場合、その行は誤りとしてマークされます。これにより、実際のアプリケーションでの高精度が保証されます。
🚀 クイックスタート
📦 インストール
1. PaddlePaddle のインストール
以下のコマンドを参考に、pip を使用して PaddlePaddle をインストールしてください。
# CUDA11.8用
python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
# CUDA12.6用
python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/
# CPU用
python -m pip install paddlepaddle==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/
PaddlePaddle のインストールに関する詳細情報は、PaddlePaddle 公式サイトを参照してください。
2. PaddleOCR のインストール
PyPI から最新バージョンの PaddleOCR 推論パッケージをインストールします。
python -m pip install paddleocr
💻 使用例
基本的な使用法
単一のコマンドでこの機能をすぐに試すことができます。
paddleocr text_recognition \
--model_name PP-OCRv5_mobile_rec \
-i https://cdn-uploads.huggingface.co/production/uploads/681c1ecd9539bdde5ae1733c/2PZfbirjfxA88695lRmgk.jpeg
また、テキスト認識モジュールのモデル推論をあなたのプロジェクトに統合することもできます。以下のコードを実行する前に、サンプル画像をローカルマシンにダウンロードしてください。
from paddleocr import TextRecognition
model = TextRecognition(model_name="PP-OCRv5_mobile_rec")
output = model.predict(input="2PZfbirjfxA88695lRmgk.jpeg", batch_size=1)
for res in output:
res.print()
res.save_to_img(save_path="./output/")
res.save_to_json(save_path="./output/res.json")
実行後、得られる結果は次の通りです。
{'res': {'input_path': '/root/.paddlex/predict_input/2PZfbirjfxA88695lRmgk.jpeg', 'page_index': None, 'rec_text': 'day as a reminder of the', 'rec_score': 0.9793617129325867}}
可視化画像は以下の通りです。
使用コマンドとパラメータの説明に関する詳細情報は、ドキュメントを参照してください。
高度な使用法
単一のモデルの能力には限界があります。しかし、複数のモデルで構成されるパイプラインは、現実のシーンでの難題を解決するための強力な能力を提供することができます。
PP-OCRv5
汎用 OCR パイプラインは、画像からテキスト情報を抽出し、文字列形式で出力することで、テキスト認識タスクを解決します。パイプラインには 5 つのモジュールが含まれています。
- 文書画像方向分類モジュール(オプション)
- テキスト画像補正モジュール(オプション)
- テキスト行方向分類モジュール(オプション)
- テキスト検出モジュール
- テキスト認識モジュール
単一のコマンドを実行して、OCR パイプラインをすぐに試してみましょう。
paddleocr ocr -i https://cdn-uploads.huggingface.co/production/uploads/681c1ecd9539bdde5ae1733c/3ul2Rq4Sk5Cn-l69D695U.png \
--text_recognition_model_name PP-OCRv5_mobile_rec \
--use_doc_orientation_classify False \
--use_doc_unwarping False \
--use_textline_orientation True \
--save_path ./output \
--device gpu:0
結果はターミナルに表示されます。
{
"res": {
"input_path": "printing_en/1212.1442_1.png",
"page_index": null,
"model_settings": {
"use_doc_preprocessor": true,
"use_textline_orientation": true
},
"doc_preprocessor_res": {
"input_path": null,
"page_index": null,
"model_settings": {
"use_doc_orientation_classify": false,
"use_doc_unwarping": false
},
"angle": -1
},
"dt_polys": [
[
[
352,
105
],
...,
[
352,
128
]
],
...,
[
[
632,
1431
],
...,
[
632,
1447
]
]
],
"text_det_params": {
"limit_side_len": 64,
"limit_type": "min",
"thresh": 0.3,
"max_side_limit": 4000,
"box_thresh": 0.6,
"unclip_ratio": 1.5
},
"text_type": "general",
"textline_orientation_angles": [
0,
...,
0
],
"text_rec_score_thresh": 0.0,
"rec_texts": [
"Algorithms for the Markov Entropy Decomposition",
"Andrew J. Ferris and David Poulin",
"Département de Physique, Université de Sherbrooke, Québec, JI K 2R1, Canada",
"(Dated: October 31, 2018)",
"The Markov entropy decomposition (MED) is a recently - proposed, cluster - based simulation method for fi -",
"nite temperature quantum systems with arbitrary geometry. In this paper, we detail numerical algorithms for",
"performing the required steps of the MED, principally solving a minimization problem with a preconditioned",
"arXiv:1212.1442v1 [cond - mat.stat - mech] 6 Dec 2012",
"Newton's algorithm, as well as how to extract global susceptibilities and thermal responses. We demonstrate",
"the power of the method with the spin - 1/2 XXZ model on the 2D square lattice, including the extraction of",
"critical points and details of each phase. Although the method shares some qualitative similarities with exact -",
"diagonalization, we show the MED is both more accurate and significantly more flexible.",
"PACS numbers: 05.10.—a, 02.50.Ng, 03.67.–a, 74.40.Kb",
"I. INTRODUCTION",
"This approximation becomes exact in the case of a 1D quan -",
"tum (or classical) Markov chain [1O], and leads to an expo -",
"Although the equations governing quantum many - body",
"nential reduction of cost for exact entropy calculations when",
"systems are simple to write down, finding solutions for the",
"the global density matrix is a higher - dimensional Markov net -",
"majority of systems remains incredibly difficult. Modern",
"work state [12, 13].",
"physics finds itself in need of new tools to compute the emer -",
"The second approximation used in the MED approach is",
"gent behavior of large, many - body systems.",
"related to the N - representibility problem. Given a set of lo -",
"There has been a great variety of tools developed to tackle",
"cal but overlapping reduced density matrices { ρi }, it is a very",
"many - body problems, but in general, large 2D and 3D quan -",
"challenging problem to determine if there exists a global den.",
"tum systems remain hard to deal with. Most systems are",
"sity operator which is positive semi - definite and whose partial",
"thought to be non - integrable, so exact analytic solutions are",
"trace agrees with each ρi. This problem is QMA - hard (the",
"not usually expected. Direct numerical diagonalization can be",
"quantum analogue of NP) [14, 15], and is hopelessly diffi -",
"performed for relatively small systems — however the emer -",
"cult to enforce. Thus, the second approximation employed",
"gent behavior of a system in the thermodynamic limit may be",
"involves ignoring global consistency with a positive opera -",
"difficult to extract, especially in systems with large correlation",
"tor, while requiring local consistency on any overlapping re -",
"lengths. Monte Carlo approaches are technically exact (up to",
"gions between the ρi. At the zero - temperature limit, the MED",
"sampling error), but suffer from the so - called sign problem",
"approach becomes analogous to the variational nth - order re -",
"for fermionic, frustrated, or dynamical problems. Thus we are",
"duced density matrix approach, where positivity is enforced",
"limited to search for clever approximations to solve the ma -",
"on all reduced density matrices of size n [16–18].",
"jority of many - body problems.",
"The MED approach is an extremely flexible cluster method.",
"Over the past century, hundreds of such approximations",
"applicable to both translationally invariant systems of any di -",
"have been proposed, and we will mention just a few notable",
"mension in the thermodynamic limit, as well as finite systems",
"examples applicable to quantum lattice models. Mean - field",
"or systems without translational invariance (e.g. disordered",
"theory is simple and frequently arrives at the correct quali -",
"lattices, or harmonically trapped atoms in optical lattices).",
"tative description, but often fails when correlations are im -",
"The free energy given by MED is guaranteed to lower bound",
"portant. Density - matrix renormalisation group (DMRG) [1]",
"the true free energy, which in turn lower - bounds the ground",
"is efficient and extremely accurate at solving 1D problems,",
"state energy — thus providing a natural complement to varia -",
"but the computational cost grows exponentially with system",
"tional approaches which upper - bound the ground state energy.",
"size in two - or higher - dimensions [2, 3]. Related tensor -",
"The ability to provide a rigorous ground - state energy window",
"network techniques designed for 2D systems are still in their",
"is a powerful validation tool, creating a very compelling rea -",
"infancy [4–6]. Series - expansion methods [7] can be success -",
"son to use this approach.",
"ful, but may diverge or otherwise converge slowly, obscuring",
"In this paper we paper we present a pedagogical introduc -",
"the state in certain regimes. There exist a variety of cluster -",
"tion to MED, including numerical implementation issues and",
"based techniques, such as dynamical - mean - field theory [8]",
"applications to 2D quantum lattice models in the thermody -",
"and density - matrix embedding [9]",
"namic limit. In Sec. II. we giye a brief deriyation of the",
"Here we discuss the so - called Markov entropy decompo -",
"Markov entropy decomposition. Section III outlines a robust",
"sition (MED), recently proposed by Poulin & Hastings [10]",
"numerical strategy for optimizing the clusters that make up",
"(and analogous to a slightly earlier classical algorithm [11]).",
"the decomposition. In Sec. IV we show how we can extend",
"This is a self - consistent cluster method for fi nite temperature",
"these algorithms to extract non - trivial information, such as",
"systems that takes advantage of an approximation of the (von",
"specific heat and susceptibilities. We present an application of",
"Neumann) entropy. In [10], it was shown that the entropy",
"the method to the spin - 1/2 XXZ model on a 2D square lattice",
"per site can be rigorously upper bounded using only local in -",
"in Sec. V, describing how to characterize the phase diagram",
"formation — a local, reduced density matrix on N sites, say.",
"and determine critical points, before concluding in Sec. VI."
],
"rec_scores": [
0.99388635,
...,
0.99304372
],
"rec_polys": [
[
[
352,
105
],
...,
[
352,
128
]
],
...,
[
[
632,
1431
],
...,
[
632,
1447
]
]
],
"rec_boxes": [
[
352,
...,
128
],
...,
[
632,
...,
1447
]
]
}
}
save_path
を指定すると、可視化結果は save_path
以下に保存されます。可視化出力は次の通りです。
コマンドライン方式は、すばやく試すのに適しています。プロジェクトに統合する場合は、数行のコードで実現できます。
from paddleocr import PaddleOCR
ocr = PaddleOCR(
text_recognition_model_name="PP-OCRv5_mobile_rec",
use_doc_orientation_classify=False, # use_doc_orientation_classify で文書方向分類モデルを有効/無効にする
use_doc_unwarping=False, # use_doc_unwarping で文書補正モジュールを有効/無効にする
use_textline_orientation=True, # use_textline_orientation でテキスト行方向分類モデルを有効/無効にする
device="gpu:0", # device でモデル推論に使用する GPU を指定する
)
result = ocr.predict("https://cdn-uploads.huggingface.co/production/uploads/681c1ecd9539bdde5ae1733c/3ul2Rq4Sk5Cn-l69D695U.png")
for res in result:
res.print()
res.save_to_img("output")
res.save_to_json("output")
パイプラインで使用されるデフォルトのモデルは PP-OCRv5_server_rec
です。そのため、パラメータ text_recognition_model_name
を PP-OCRv5_mobile_rec
に指定する必要があります。また、パラメータ text_recognition_model_dir
を使用して、ローカルのモデルファイルを利用することもできます。使用コマンドとパラメータの説明に関する詳細情報は、ドキュメントを参照してください。
PP-StructureV3
レイアウト分析は、文書画像から構造化情報を抽出する技術です。PP-StructureV3 は以下の 6 つのモジュールで構成されています。
- レイアウト検出モジュール
- 汎用 OCR パイプライン
- 文書画像前処理パイプライン(オプション)
- 表認識パイプライン(オプション)
- 印章認識パイプライン(オプション)
- 数式認識パイプライン(オプション)
単一のコマンドを実行して、PP-StructureV3 パイプラインをすぐに試してみましょう。
paddleocr pp_structurev3 -i https://cdn-uploads.huggingface.co/production/uploads/681c1ecd9539bdde5ae1733c/mG4tnwfrvECoFMu-S9mxo.png \
--text_recognition_model_name PP-OCRv5_mobile_rec \
--use_doc_orientation_classify False \
--use_doc_unwarping False \
--use_textline_orientation False \
--device gpu:0
結果はターミナルに表示されます。save_path
を指定すると、結果は save_path
以下に保存されます。予測結果の Markdown 可視化は次の通りです。
数行のコードで、パイプラインの推論を試すことができます。PP-StructureV3 パイプラインを例に説明します。
from paddleocr import PPStructureV3
pipeline = PPStructureV3(
text_recognition_model_name="PP-OCRv5_mobile_rec",
use_doc_orientation_classify=False, # use_doc_orientation_classify で文書方向分類モデルを有効/無効にする
use_doc_unwarping=False, # use_doc_unwarping で文書補正モジュールを有効/無効にする
use_textline_orientation=False, # use_textline_orientation でテキスト行方向分類モデルを有効/無効にする
device="gpu:0", # device でモデル推論に使用する GPU を指定する
)
output = pipeline.predict("./pp_structure_v3_demo.png")
for res in output:
res.print() # 構造化予測出力を表示する
res.save_to_json(save_path="output") ## 現在の画像の構造化結果を JSON 形式で保存する
res.save_to_markdown(save_path="output") ## 現在の画像の結果を Markdown 形式で保存する
パイプラインで使用されるデフォルトのモデルは PP-OCRv5_server_rec
です。そのため、パラメータ text_recognition_model_name
を PP-OCRv5_mobile_rec
に指定する必要があります。また、パラメータ text_recognition_model_dir
を使用して、ローカルのモデルファイルを利用することもできます。使用コマンドとパラメータの説明に関する詳細情報は、ドキュメントを参照してください。
📚 ドキュメント
📄 ライセンス
このプロジェクトは、Apache-2.0 ライセンスの下で提供されています。











