Skip to content

Commit 4032fac

Browse files
committed
feat: add evaluate phocr blog
1 parent d85049a commit 4032fac

File tree

3 files changed

+117
-2
lines changed

3 files changed

+117
-2
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
---
2+
title: 评测PHOCR中文文本识别模型
3+
date: 2025-08-03
4+
authors: [SWHL]
5+
categories:
6+
- 模型相关
7+
comments: true
8+
hide:
9+
- toc
10+
links:
11+
- 开源OCR模型对比: blog/posts/about_model/model_summary.md
12+
---
13+
14+
> 该文章主要评测PHOCRv1的中文识别模型效果。
15+
16+
<!-- more -->
17+
18+
### 引言
19+
20+
> PHOCR 是一个高性能的开源光学字符识别(OCR)工具包,专为多语种文本识别任务设计,支持包括中文、日文、韩文、俄文、越南文和泰文在内的多种语言。PHOCR 搭载了我们完全自研的识别模型 PH-OCRv1,在准确率上显著优于现有解决方案。
21+
>
22+
> -- [PHOCR](https://github.com/puhuilab/phocr/tree/main)
23+
24+
最近,有个社区小伙伴新建立了一个PHOCR,里面的文本识别模型据说效果超越PP-OCRv5:
25+
26+
![alt text](../images/image.png)
27+
28+
至于真实效果如何呢?还需要自己来看一下。
29+
30+
### 以下代码运行环境
31+
32+
- OS: macOS Sequoia 15.6
33+
- Python: 3.10.14
34+
- phocr: 1.0.3
35+
- datasets
36+
- text_rec_metric
37+
38+
### 评测
39+
40+
!!! warning
41+
42+
由于评测数据集的限制,以下评测结果不完全代表模型能力,支持给出一个基本参考。小伙伴们还需要在自己场景下真实评测来看哈。
43+
44+
该部分主要使用[TextRecMetric](https://github.com/SWHL/TextRecMetric)和测试集[text_rec_test_dataset](https://huggingface.co/datasets/SWHL/text_rec_test_dataset)来评测。
45+
46+
#### 测试集结果识别
47+
48+
```python linenums="1"
49+
import time
50+
51+
import cv2
52+
import numpy as np
53+
from datasets import load_dataset
54+
from tqdm import tqdm
55+
56+
from phocr import PHOCR, LangRec
57+
58+
engine = PHOCR(params={"Rec.lang_type": LangRec.CH})
59+
60+
dataset = load_dataset("SWHL/text_rec_test_dataset")
61+
test_data = dataset["test"]
62+
63+
content = []
64+
for i, one_data in enumerate(tqdm(test_data)):
65+
img = np.array(one_data.get("image"))
66+
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
67+
68+
t0 = time.perf_counter()
69+
result = engine(img, use_rec=True, use_cls=False, use_det=False)
70+
elapse = time.perf_counter() - t0
71+
72+
rec_text = result.txts[0]
73+
if len(rec_text) <= 0:
74+
rec_text = ""
75+
elapse = 0
76+
77+
gt = one_data.get("label", None)
78+
content.append(f"{rec_text}\t{gt}\t{elapse}")
79+
80+
with open("pred.txt", "w", encoding="utf-8") as f:
81+
for v in content:
82+
f.write(f"{v}\n")
83+
```
84+
85+
#### 计算评测指标
86+
87+
```python linenums="1"
88+
from text_rec_metric import TextRecMetric
89+
90+
metric = TextRecMetric()
91+
92+
pred_path = "pred.txt"
93+
metric = metric(pred_path)
94+
print(metric)
95+
```
96+
97+
```json
98+
{'ExactMatch': 0.6452, 'CharMatch': 0.7648, 'avg_elapse': 0.0613}
99+
```
100+
101+
### 结论
102+
103+
| 模型 | 模型大小 | Exact Match | Char Match |Speed(s/img) |
104+
| :----- | :-----| :-------: | :--- | :--|
105+
|PHOCR v1.0.3| 224M | 0.6452 | 0.7648 | 0.0613 |
106+
|ch_PP-OCRv5_rec_infer.onnx | 16M | 0.7355 | 0.9177 | 0.0713 |
107+
|ch_PP-OCRv5_rec_server_infer.onnx | 81M | 0.8129 | 0.9431 | 0.1133 |
108+
109+
上面结果和PP-OCRv5比较来看,差距还是不小的。可能是测试集的不同,导致指标差距明显。但是速度的确快一些。⚠️注意:仅供参考哈。
110+
111+
RapidOCR这里暂时不做集成,后续会持续关注PHOCR这里。
112+
113+
完整的评测结果比较:[文本识别模型比较](./model_summary.md#文本识别模型)

docs/blog/posts/about_model/model_summary.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,23 @@ hide:
9393

9494
| 模型 | 对应PaddleOCR分支| 模型大小 | Exact Match | Char Match |Speed(s/img) |
9595
| :----- |:---- | :-----| :-------: | :--- | :--|
96-
|ch_PP-OCRv5_rec_infer.onnx | release/v3.0 | 16M | 0.7355 | 0.9177 | - |
96+
|ch_PP-OCRv5_rec_infer.onnx | release/v3.0 | 16M | 0.7355 | 0.9177 | 0.0713 |
9797
|ch_PP-OCRv4_rec_infer.onnx | release/v2.7 | 10M | 0.8323 | 0.9355 | 0.6836 |
9898
|ch_PP-OCRv3_rec_infer.onnx | release/v2.6 | 11M | 0.7097 | 0.8919 | 0.6362 |
9999
|||||||
100-
|ch_PP-OCRv5_rec_server_infer.onnx | release/v3.0 | 81M | 0.8129 | 0.9431 | - |
100+
|ch_PP-OCRv5_rec_server_infer.onnx | release/v3.0 | 81M | 0.8129 | 0.9431 | 0.1133 |
101101
|ch_PP-OCRv4_rec_server_infer.onnx | release/v2.7 | 86M | 0.7968 | 0.9381 | 0.6967 |
102102
|ch_doc_PP-OCRv4_rec_server.onnx | release/v2.10 | 94.93M | 0.8097 | 0.9444 | 0.6836 |
103103
|ch_PP-OCRv2_rec_infer.onnx | release/v2.3 | 8.0M | 0.6387 | 0.8398 | 0.6138|
104104
|ch_ppocr_mobile_v2.0_rec_infer.onnx | release/v2.0 | 4.3M | 0.5323 | 0.7823 | 0.5575|
105+
|其他OCR | 版本 | 模型大小 | Exact Match | Char Match |Speed(s/img) |
105106
|[读光-文字识别-行识别模型-中英-文档印刷体文本领域](https://www.modelscope.cn/models/iic/cv_convnextTiny_ocr-recognition-document_damo/summary) | - | 73M | 0.5968 | 0.7705 | - |
106107
|[读光-文字识别-行识别模型-中英-通用领域](https://www.modelscope.cn/models/iic/cv_convnextTiny_ocr-recognition-general_damo/summary) | - | 73M | 0.5839 | 0.7615 | - |
107108
|[读光-文字识别-行识别模型-中英-自然场景文本领域](https://www.modelscope.cn/models/iic/cv_convnextTiny_ocr-recognition-scene_damo/summary) | - | 73M | 0.5903 | 0.7779 | - |
108109
|[读光-文字识别-轻量化端侧识别模型-中英-通用领域](https://www.modelscope.cn/models/iic/cv_LightweightEdge_ocr-recognitoin-general_damo/summary) | - | 7.4M | 0.5484 | 0.7515 | - |
109110
|[读光-文字识别-CRNN模型-中英-通用领域](https://www.modelscope.cn/models/iic/cv_crnn_ocr-recognition-general_damo/summary) | - | 46M | 0.5935 | 0.7671 | - |
110111
|[OFA文字识别-中文-通用场景-base](https://www.modelscope.cn/models/iic/ofa_ocr-recognition_general_base_zh/summary) 未跑通 | - | - | - | - | - |
112+
|[PHOCRv1](https://github.com/puhuilab/phocr/tree/main) | v1.0.3 | 224M | 0.6452 | 0.7648 | 0.0613 |
111113

112114
不同推理引擎下,效果比较:
113115

docs/blog/posts/images/image.png

94 KB
Loading

0 commit comments

Comments
 (0)