中文 | English
# Introduction
本数据集是从 [DocLayNet-v1.2](https://huggingface.co/datasets/ds4sd/DocLayNet-v1.2)数据集下载的47个parquet文件,
- 选取了其中 `misc/selected_pngs.txt`的14184张图片进行标注,可以从这里获取具体是哪47个parquet文件。由于有些图片页码位置格式一致,就没有全部标注。有些图片没有页码,无法标注.
- 实际标注了4899张,见`box_single/`(4816张)和`box_multi/`(83张). 提示:自行决定是否使用`box_multi/`数据集,因为可能会误导模型。
- 选取了部分(334张)没有页码的图片,用于训练YOLO模型,提供负例。见`no_boxes/`.
- 此外,从[HuggingFace](https://huggingface.co/datasets/wqzh/Gaokao-Admission-Chart-Segment), 或者[ModelScope](https://www.modelscope.cn/datasets/wqzh117/Gaokao-Admission-Chart-Segment)中选取了中文格式的书籍进行标注,见`pipe-adp/`(1026张).
# Labels
```
├── DocLayout-PageNumDet/
├── labels/
│ ├── box_single/
│ │ ├── image_1.txt
│ │ ├── image_2.txt
│ │
│ ├── no_boxes/
│ ├── image_a.txt (empty txt file)
│ ├── image_b.txt
...
```
# Models
```
DocLayout-PageNumDet/models
├── ch_PP-OCRv3_rec_infer.onnx (paddleocr onnx)
├── ppocr_keys_v1.txt
├── yolo11-medium-page-best.pt (yolo11 pt, detect page box)
├── yolo11-medium-page-best-quant-ir9.onnx (onnx quantization)
├── yolo11-nano-page-best.pt
├── yolo11-nano-page-best-quant-ir9.onnx
├── yolo11-small-page-best.pt
└── yolo11-small-page-best-quant-ir9.onnx
```
为了更好的检测效果,可以考虑模型集成。
# RUN
加载一张图片,检测框,ocr识别,返回的是:
[[x1, y1, x2, y2, conf, text], ...]
列表的长度为检测出的框的数量,六元组是每个框的坐标、置信度、检测的文本(页码)。
每张图片裁剪出的页码会保存在`./tmp/`文件夹下,可自行查看。
```shell
#python src/det_and_ocr_pt.py
#python src/det_and_ocr_onnx.py
#python src/det_and_ocr_onnx_wo_opencv.py ## without opencv library
# one image
CUDA_VISIBLE_DEVICES=1 python src/det_and_ocr_pt.py examples/00-80T-80_433.png
CUDA_VISIBLE_DEVICES=1 python src/det_and_ocr_onnx.py examples/00-80T-80_433.png
# one dir
CUDA_VISIBLE_DEVICES=1 python src/det_and_ocr_pt.py examples/
CUDA_VISIBLE_DEVICES=1 python src/det_and_ocr_onnx.py examples/
```
# ONNX
对应的onnx权重导出命令为
```shell
python src/export_onnx.py
```
## onnx file size comparison
```
37M models/yolo11-small-page-best-ir9.onnx
37M models/yolo11-small-page-best.onnx
37M models/yolo11-small-page-best.onnx.data
19M models/yolo11-small-page-best.pt
9.3M models/yolo11-small-page-best-quant-ir9.onnx
```