Files
workspace/notes/后端开发/paddlepaddle/ppocrlabel.md
T
2025-07-24 17:22:24 +08:00

53 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 相关网站
- github:https://github.com/PaddleCV-SIG/PaddleLabel
- 官网:
# 加载自定义模型
## 1. 修改 PPOCRLabel.py
```python
params = {
"use_doc_orientation_classify": False,
"use_doc_unwarping": False,
"use_textline_orientation": True,
"device": self.gpu,
"lang": self.lang,
"text_detection_model_name": "PP-OCRv5_mobile_det", # 修改为自己的模型名称
"text_recognition_model_name": "PP-OCRv5_mobile_rec", # 修改为自己的模型名称
"enable_mkldnn": False,
}
if det_model_dir is not None:
params["text_detection_model_dir"] = det_model_dir
if rec_model_dir is not None:
params["text_recognition_model_dir"] = rec_model_dir
if cls_model_dir is not None:
params["text_line_orientation_model_dir"] = cls_model_dir
self.ocr = PaddleOCR(**params)
self.text_recognizer = TextRecognition(
model_name="PP-OCRv5_mobile_rec", # 修改为自己的模型名称
model_dir=rec_model_dir,
device=self.gpu,
)
self.text_detector = TextDetection(
model_name="PP-OCRv5_mobile_det", # 修改为自己的模型名称
model_dir=det_model_dir,
device=self.gpu,
)
```
## 修改启动命令
```bash
python PPOCRLabel.py --lang ch --kie True --det_model_dir "模型路径" --rec_model_dir "模型路径"
# 示例
python PPOCRLabel.py --lang ch --kie True --det_model_dir ".\model\det_inference\" --rec_model_dir ".\model\rec_inference\"
```