Doc refine (#15334)

* refine ocr pipeline docs

* refine ocr module docs
This commit is contained in:
学卿 2025-05-22 19:08:24 +08:00 committed by GitHub
parent 0690815ce0
commit f54fb0316f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 18 deletions

View File

@ -113,7 +113,7 @@ You can also integrate the model inference into your project. Before running the
```python
from paddleocr import TextDetection
model = TextDetection(model_name="PP-OCRv5_mobile_det")
model = TextDetection(model_name="PP-OCRv5_server_det")
output = model.predict("general_ocr_001.png", batch_size=1)
for res in output:
res.print()
@ -130,9 +130,9 @@ The output will be:
...,
[[ 37, 408],
[[ 31, 406],
...,
[ 39, 453]]], dtype=int16), 'dt_scores': [0.832930755107492, 0.8186143846140158, 0.8591595100376676, 0.8718863959111733]}}
[ 34, 455]]], dtype=int16), 'dt_scores': [0.873949039891189, 0.8948166013613552, 0.8842595305917041, 0.876953790920377]}}
```
Output parameter meanings:
@ -147,7 +147,7 @@ Visualization example:
Method and parameter descriptions:
* Instantiate the text detection model (e.g., `PP-OCRv5_mobile_det`):
* Instantiate the text detection model (e.g., `PP-OCRv5_server_det`):
<table>
<thead>
<tr>
@ -404,18 +404,18 @@ Training command:
python3 tools/train.py -c configs/det/PP-OCRv5/PP-OCRv5_server_det.yml \
-o Global.pretrained_model=./PP-OCRv5_server_det_pretrained.pdparams \
Train.dataset.data_dir=./ocr_det_dataset_examples \
Train.dataset.label_file_list=[./ocr_det_dataset_examples/train.txt] \
Train.dataset.label_file_list='[./ocr_det_dataset_examples/train.txt]' \
Eval.dataset.data_dir=./ocr_det_dataset_examples \
Eval.dataset.label_file_list=[./ocr_det_dataset_examples/val.txt]
Eval.dataset.label_file_list='[./ocr_det_dataset_examples/val.txt]'
# Multi-GPU training (specify GPUs with --gpus)
python3 -m paddle.distributed.launch --gpus '0,1,2,3' tools/train.py \
-c configs/det/PP-OCRv5/PP-OCRv5_server_det.yml \
-o Global.pretrained_model=./PP-OCRv5_server_det_pretrained.pdparams \
Train.dataset.data_dir=./ocr_det_dataset_examples \
Train.dataset.label_file_list=[./ocr_det_dataset_examples/train.txt] \
Train.dataset.label_file_list='[./ocr_det_dataset_examples/train.txt]' \
Eval.dataset.data_dir=./ocr_det_dataset_examples \
Eval.dataset.label_file_list=[./ocr_det_dataset_examples/val.txt]
Eval.dataset.label_file_list='[./ocr_det_dataset_examples/val.txt]'
```
### 4.3 Model Evaluation
@ -428,7 +428,7 @@ You can evaluate trained weights (e.g., `output/PP-OCRv5_server_det/best_accurac
python3 tools/eval.py -c configs/det/PP-OCRv5/PP-OCRv5_server_det.yml \
-o Global.pretrained_model=output/PP-OCRv5_server_det/best_accuracy.pdparams \
Eval.dataset.data_dir=./ocr_det_dataset_examples \
Eval.dataset.label_file_list=[./ocr_det_dataset_examples/val.txt]
Eval.dataset.label_file_list='[./ocr_det_dataset_examples/val.txt]'
```
### 4.4 Model Export

View File

@ -114,7 +114,7 @@ paddleocr text_detection -i https://paddle-model-ecology.bj.bcebos.com/paddlex/i
```python
from paddleocr import TextDetection
model = TextDetection(model_name="PP-OCRv5_mobile_det")
model = TextDetection(model_name="PP-OCRv5_server_det")
output = model.predict("general_ocr_001.png", batch_size=1)
for res in output:
res.print()
@ -131,9 +131,9 @@ for res in output:
...,
[[ 37, 408],
[[ 31, 406],
...,
[ 39, 453]]], dtype=int16), 'dt_scores': [0.832930755107492, 0.8186143846140158, 0.8591595100376676, 0.8718863959111733]}}
[ 34, 455]]], dtype=int16), 'dt_scores': [0.873949039891189, 0.8948166013613552, 0.8842595305917041, 0.876953790920377]}}
```
运行结果参数含义如下:
@ -148,7 +148,7 @@ for res in output:
相关方法、参数等说明如下:
* `TextDetection`实例化文本检测模型(此处以`PP-OCRv5_mobile_det`为例),具体说明如下:
* `TextDetection`实例化文本检测模型(此处以`PP-OCRv5_server_det`为例),具体说明如下:
<table>
<thead>
<tr>
@ -460,18 +460,18 @@ PaddleOCR 对代码进行了模块化,训练 `PP-OCRv5_server_det` 识别模
python3 tools/train.py -c configs/det/PP-OCRv5/PP-OCRv5_server_det.yml \
-o Global.pretrained_model=./PP-OCRv5_server_det_pretrained.pdparams \
Train.dataset.data_dir=./ocr_det_dataset_examples \
Train.dataset.label_file_list=[./ocr_det_dataset_examples/train.txt] \
Train.dataset.label_file_list='[./ocr_det_dataset_examples/train.txt]' \
Eval.dataset.data_dir=./ocr_det_dataset_examples \
Eval.dataset.label_file_list=[./ocr_det_dataset_examples/val.txt]
Eval.dataset.label_file_list='[./ocr_det_dataset_examples/val.txt]'
#多卡训练,通过--gpus参数指定卡号
python3 -m paddle.distributed.launch --gpus '0,1,2,3' tools/train.py \
-c configs/det/PP-OCRv5/PP-OCRv5_server_det.yml \
-o Global.pretrained_model=./PP-OCRv5_server_det_pretrained.pdparams \
Train.dataset.data_dir=./ocr_det_dataset_examples \
Train.dataset.label_file_list=[./ocr_det_dataset_examples/train.txt] \
Train.dataset.label_file_list='[./ocr_det_dataset_examples/train.txt]' \
Eval.dataset.data_dir=./ocr_det_dataset_examples \
Eval.dataset.label_file_list=[./ocr_det_dataset_examples/val.txt]
Eval.dataset.label_file_list='[./ocr_det_dataset_examples/val.txt]'
```
### 4.3 模型评估
@ -484,7 +484,7 @@ python3 -m paddle.distributed.launch --gpus '0,1,2,3' tools/train.py \
python3 tools/eval.py -c configs/det/PP-OCRv5/PP-OCRv5_server_det.yml \
-o Global.pretrained_model=output/PP-OCRv5_server_det/best_accuracy.pdparams \
Eval.dataset.data_dir=./ocr_det_dataset_examples \
Eval.dataset.label_file_list=[./ocr_det_dataset_examples/val.txt]
Eval.dataset.label_file_list='[./ocr_det_dataset_examples/val.txt]'
```
### 4.4 模型导出