🚀 天城文PP-OCRv3移動識別模型
天城文PP-OCRv3移動識別模型是PaddleOCR團隊開發的PP-OCRv3_rec系列中的文本行識別模型。該模型是基於PP-OCRv3移動識別模型訓練的天城文專用模型,支持天城文識別。其關鍵準確率指標如下:
🚀 快速開始
✨ 主要特性
- 天城文PP-OCRv3移動識別模型是PP-OCRv3_rec系列中的文本行識別模型,由PaddleOCR團隊開發。
- 該模型是基於PP-OCRv3移動識別模型訓練的天城文專用模型,支持天城文識別。
- 該模型具有較高的識別準確率,平均識別準確率為96.44%。
- 該模型具有較小的存儲大小,僅為7.9M。
📦 安裝指南
1. 安裝PaddlePaddle
請參考以下命令,使用pip安裝PaddlePaddle:
python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/
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 devanagari_PP-OCRv3_mobile_rec \
-i https://cdn-uploads.huggingface.co/production/uploads/681c1ecd9539bdde5ae1733c/lpNu16sSBMXoRDt_DmUm6.png
你也可以將文本識別模塊的模型推理集成到你的項目中。在運行以下代碼之前,請將示例圖像下載到本地機器。
from paddleocr import TextRecognition
model = TextRecognition(model_name="devanagari_PP-OCRv3_mobile_rec")
output = model.predict(input="lpNu16sSBMXoRDt_DmUm6.png", 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/lpNu16sSBMXoRDt_DmUm6.png', 'page_index': None, 'rec_text': 'बहुपङिकतपाठपरीआापकर', 'rec_score': 0.9564684629440308}}
有關使用命令和參數說明的詳細信息,請參考文檔。
高級用法
單個模型的能力是有限的,但由多個模型組成的管道可以提供更多的能力來解決現實場景中的難題。
PP-OCRv3
通用OCR管道用於通過從圖像中提取文本信息並以字符串格式輸出,來解決文本識別任務。管道中有5個模塊:
- 文檔圖像方向分類模塊(可選)
- 文本圖像去扭曲模塊(可選)
- 文本行方向分類模塊(可選)
- 文本檢測模塊
- 文本識別模塊
運行以下命令快速體驗OCR管道:
paddleocr ocr -i https://cdn-uploads.huggingface.co/production/uploads/681c1ecd9539bdde5ae1733c/_5b764by68-a295JP4y1q.png \
--text_recognition_model_name devanagari_PP-OCRv3_mobile_rec \
--use_doc_orientation_classify False \
--use_doc_unwarping False \
--use_textline_orientation True \
--save_path ./output \
--device gpu:0
結果將打印到終端:
{'res': {'input_path': '/root/.paddlex/predict_input/_5b764by68-a295JP4y1q.png', 'page_index': None, 'model_settings': {'use_doc_preprocessor': True, 'use_textline_orientation': True}, 'doc_preprocessor_res': {'input_path': None, 'page_index': None, 'model_settings': {'use_doc_orientation_classify': False, 'use_doc_unwarping': False}, 'angle': -1}, 'dt_polys': array([[[ 11, 8],
...,
[ 11, 42]],
...,
[[ 9, 88],
...,
[ 9, 120]]], dtype=int16), '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': array([0, ..., 1]), 'text_rec_score_thresh': 0.0, 'rec_texts': ['िसिरिलक', 'IBlhhh?', 'H॰'], 'rec_scores': array([0.98613745, ..., 0.5240429 ]), 'rec_polys': array([[[ 11, 8],
...,
[ 11, 42]],
...,
[[ 9, 88],
...,
[ 9, 120]]], dtype=int16), 'rec_boxes': array([[ 11, ..., 42],
...,
[ 9, ..., 120]], dtype=int16)}}
命令行方法適用於快速體驗。對於項目集成,也只需要幾行代碼:
from paddleocr import PaddleOCR
ocr = PaddleOCR(
text_recognition_model_name="devanagari_PP-OCRv3_mobile_rec",
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=True,
device="gpu:0",
)
result = ocr.predict("https://cdn-uploads.huggingface.co/production/uploads/681c1ecd9539bdde5ae1733c/c3hSldnYVQXp48T5V0Ze4.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
指定為devanagari_PP-OCRv3_mobile_rec
。你也可以通過參數text_recognition_model_dir
使用本地模型文件。有關使用命令和參數說明的詳細信息,請參考文檔。
📚 詳細文檔
屬性 |
詳情 |
模型類型 |
天城文PP-OCRv3移動識別模型是PP-OCRv3_rec系列中的文本行識別模型。 |
訓練數據 |
暫未提及 |
📄 許可證
本項目採用Apache-2.0許可證。
🔗 相關鏈接
⚠️ 重要提示
如果一行中的任何字符(包括標點符號)不正確,則整行將被標記為錯誤。這確保了在實際應用中具有更高的準確性。