Skip to content

Commit

Permalink
docs: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
SWHL committed Oct 31, 2024
1 parent bc68c85 commit 3d58c98
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@

</div>


### 简介

该库用于计算`Precision``Recall``H-mean`三个指标,用来快速评测文本检测算法效果,与[text_det_test_dataset](https://huggingface.co/datasets/SWHL/text_det_test_dataset)配套使用。

指标计算代码参考:[PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR/blob/b13f99607653c220ba94df2a8650edac086b0f37/ppocr/metrics/eval_det_iou.py)[DB](https://github.com/MhLiao/DB/blob/3c32b808d4412680310d3d28eeb6a2d5bf1566c5/concern/icdar2015_eval/detection/iou.py#L8)

### 整体框架

```mermaid
flowchart LR
Expand All @@ -29,19 +30,25 @@ C --> F([H-mean])
```

### 指定数据集上评测

如果想要评测其他文本检测算法,需要将预测结果写入`pred.txt`中,格式为`预测框坐标\t真实框坐标\t耗时`,详细可参考[link](./pred.txt)。示例如下:

```text
[[[85.0, 43.0], [164.0, 44.0], [164.0, 72.0], [85.0, 70.0]]] [[[473.36082474226805, 271.2938144329896], [520.7835051546391, 290.8814432989691]]] 0.14536070823669434
[[[85.0, 43.0], [164.0, 44.0], [164.0, 72.0], [85.0, 70.0]]] [[[473.36082474226805, 271.2938144329896], [520.7835051546391, 290.8814432989691]]] 0.14536070823669434
```

### 示例(评测`rapidocr_onnxruntime==1.3.16`

1. 安装运行环境

```bash
pip install rapidocr_onnxruntime==1.3.16
pip install datasets
pip install text_det_metric
```

2. 获得`pred.txt`文本文件

```python
from pathlib import Path
import cv2
Expand Down Expand Up @@ -72,7 +79,9 @@ C --> F([H-mean])
for v in content:
f.write(f"{v}\n")
```
3. 计算指标
```python
from text_det_metric import TextDetMetric
Expand All @@ -82,7 +91,9 @@ C --> F([H-mean])
print(metric)
```
4. 得到结果
```bash
{'precision': 0.8301, 'recall': 0.8659, 'hmean': 0.8476, 'avg_elapse': 0.2246}
```
```

0 comments on commit 3d58c98

Please sign in to comment.