paddleocr3.0.0本地模型问题
🔎 Search before asking
- [x] I have searched the PaddleOCR Docs and found no similar bug report.
- [x] I have searched the PaddleOCR Issues and found no similar bug report.
- [x] I have searched the PaddleOCR Discussions and found no similar bug report.
🐛 Bug (问题描述)
使用paddleocr3.0.0读取本地下载的模型,总是不使用自己下载的模型,报错Creating model: ('PP-OCRv5_server_det', 'models/v5/PP-OCRv5_mobile_det_infer')
Traceback (most recent call last):
File "E:\PythonCode\PaddleOCR\测试ppocrv5.py", line 48, in
🏃♂️ Environment (运行环境)
paddleocr3.0.0
🌰 Minimal Reproducible Example (最小可复现问题的Demo)
text_detection_model_dir ="models/v5/PP-OCRv5_mobile_det_infer" text_recognition_model_dir = "models/v5/PP-OCRv5_mobile_rec_infer"
ocr = PaddleOCR( use_doc_orientation_classify=False, # 文档方向分类模型 默认true 检测整个文档图像的方向并纠正(即0度,90度,180度,270度)。 use_doc_unwarping=False, # 文本图像矫正模型 默认true 纠正图像中的透视变形或弯曲,使文档看起来像是正面拍摄的平面图像。 use_textline_orientation=False, # 文本行方向分类模型 默认true 识别文本行是水平排列还是垂直排列。 text_detection_model_dir=text_detection_model_dir, text_recognition_model_dir=text_recognition_model_dir, device="gpu" #device="gpu:3" 指定第三块gpu运行 )
运行时打印Creating model: ('PP-OCRv5_server_det', 'models/v5/PP-OCRv5_mobile_det_infer') 为什么不加载自己本地的模型
本地模型中的inference.yml方便提供下吗?
本地模型中的方便提供下吗?
inference.yml
Global:
model_name: PP-OCRv5_mobile_det
Hpi:
backend_configs:
paddle_infer:
trt_dynamic_shapes: &id001
x:
- - 1
- 3
- 32
- 32
- - 1
- 3
- 736
- 736
- - 1
- 3
- 4000
- 4000
tensorrt:
dynamic_shapes: *id001
PreProcess:
transform_ops:
- DecodeImage:
channel_first: false
img_mode: BGR
- DetLabelEncode: null
- DetResizeForTest:
resize_long: 960
- NormalizeImage:
mean:
- 0.485
- 0.456
- 0.406
order: hwc
scale: 1./255.
std:
- 0.229
- 0.224
- 0.225
- ToCHWImage: null
- KeepKeys:
keep_keys:
- image
- shape
- polys
- ignore_tags
PostProcess:
name: DBPostProcess
thresh: 0.3
box_thresh: 0.6
max_candidates: 1000
unclip_ratio: 1.5
模型就是在https://paddlepaddle.github.io/PaddleOCR/latest/version3.x/pipeline_usage/OCR.html#1-ocr这里下载的
下载了det和rec模型
请问解决了吗?
把模型名中的“_infer”删去试试
模型名称里是server版本,路径里是mobile版本,估计是这个原因
在PaddleOCR()内部有两个参数用来指定模型名称,你需要将这两个参数设置为你自己本地的模型模型名称,比如你本地是移动端模型就在.yml文件中找到这个模型的名称然后设置
指定模型路径这个参数根本不生效
vim ./pyenv/lib/python3.10/site-packages/paddlex/inference/utils/official_models.py
我改了它那个源码下载的位置也识别不到我手动下载的模型 还是走的网络请求
请问解决了吗?
请问解决了吗?
没有 尝试了很多办法都不行 回退版本了 2.8 可以实现需求
我也是用的mobile模型,添加了
text_detection_model_name="PP-OCRv5_mobile_det",
text_recognition_model_name="PP-OCRv5_mobile_rec",
就能正常使用。
完整的参数:
PaddleOCR(
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=False,
device='gpu' if use_gpu else 'cpu',
text_detection_model_dir=det_model_path,
text_recognition_model_dir=rec_model_path,
text_detection_model_name="PP-OCRv5_mobile_det",
text_recognition_model_name="PP-OCRv5_mobile_rec"
)
把模型名中的“_infer”删去试试
我也遇到了这样的问题,删掉 model_name 结尾的 _infer 然后就可以正常运行了。
# 错误示范
det_model_name = "PP-OCRv5_server_det_infer"
rec_model_name = "PP-OCRv5_server_rec_infer"
# 正确示范
det_model_name = "PP-OCRv5_server_det"
rec_model_name = "PP-OCRv5_server_rec"
ocr = PaddleOCR( use_textline_orientation = True , lang = "ch" , device = device , text_det_box_thresh = 0.2 ,
text_detection_model_name = det_model_name , text_recognition_model_name = rec_model_name ,
text_detection_model_dir = det_model_dir , text_recognition_model_dir = rec_model_dir )
把模型名中的“_infer”删去试试
我也遇到了这样的问题,删掉 model_name 结尾的 _infer 然后就可以正常运行了。
错误示范
det_model_name = "PP-OCRv5_server_det_infer" rec_model_name = "PP-OCRv5_server_rec_infer"
正确示范
det_model_name = "PP-OCRv5_server_det" rec_model_name = "PP-OCRv5_server_rec"
ocr = PaddleOCR( use_textline_orientation = True , lang = "ch" , device = device , text_det_box_thresh = 0.2 , text_detection_model_name = det_model_name , text_recognition_model_name = rec_model_name , text_detection_model_dir = det_model_dir , text_recognition_model_dir = rec_model_dir )
感谢指正