Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paddleocr 模型在本地测试和hubserving上运行的结果不同 #11213

Closed
ericosmic opened this issue Nov 7, 2023 · 5 comments
Closed
Assignees

Comments

@ericosmic
Copy link

ericosmic commented Nov 7, 2023

请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem
同一张图片使用我们自己训练的同一个模型,在本地用pred_system.py 预测结果和在hubserving服务化上预测结果不同。比如下面这张图
英文
最后一行的预测结果在两个模式下是不同的。

  • 系统环境/System Environment:ubuntu18
  • 版本号/Version:Paddle:2.3.1 PaddleOCR:2.0 问题相关组件/Related components:hubserving
  • 运行指令/Command Code:'python test_hubserving_ocr.py --server_url=http://127.0.0.1:30000/predict/ocr_system --image_dir=../dd/1106eng.png'
  • 完整报错/Complete Error Message:
  • 本地预测结果:

image

hubserving 上预测结果:
image

可以看到本地预测结果是正确的, 而hubserving的第一行和最后一行预测结果出现错误。

我们提供了AceIssueSolver来帮助你解答问题,你是否想要它来解答(请填写yes/no)?/We provide AceIssueSolver to solve issues, do you want it? (Please write yes/no):

请尽量不要包含图片在问题中/Please try to not include the image in the issue.

@ericosmic
Copy link
Author

源码中,hubserving后台调用模型也是走的pred_system.py, 按道理结果应该是一样的。有大佬知道区别在哪吗

@SonGohan757
Copy link

后处理参数不一样吧

@hooyia123
Copy link

遇到了同样的问题,我的问题主要是DET文本检测,export成预测模型后,跟训练模型相差巨大
@SonGohan757 确定后处理参数保持一致了,您帮忙看看是不是这样:

  1. yml中的后处理参数为
    PostProcess:
    name: DBPostProcess
    thresh: 0.2
    box_thresh: 0.45
    max_candidates: 1000
    unclip_ratio: 1.8
    同样地,将PaddleOCRv3/tools/infer/utility.py参数 也设置成同样的了

  2. 我的yml文件中DetResizeForTest的值为null
    transforms:

    • DecodeImage:
      img_mode: BGR
      channel_first: false
    • DetLabelEncode: null
      - DetResizeForTest: null
    • NormalizeImage:
      scale: 1./255.
      …………

同样地,将PaddleOCRv3/tools/infer/predict_det.py的文本检测中的相应地方注释,并增加了一行'DetResizeForTest': None
class TextDetector(object):
def init(self, args):
self.args = args
self.det_algorithm = args.det_algorithm
self.use_onnx = args.use_onnx
pre_process_list = [{
#'DetResizeForTest': {
# 解决训练模型转inference 模型之后预测效果不一致,因为yml文件里DetResizeForTest为null
# 'limit_side_len': args.det_limit_side_len,
# 'limit_type': args.det_limit_type,
#}
'DetResizeForTest': None
}, {
'NormalizeImage': {
'std': [0.229, 0.224, 0.225],
'mean': [0.485, 0.456, 0.406],
'scale': '1./255.',
'order': 'hwc'
}

  1. 然后使用导出模型命令
    python tools/export_model.py -c ./configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_student.yml -o Global.pretrained_model=./output/ch_PP-OCR_V3_det_student/best_accuracy Global.save_inference_dir=./inference/det
    可是导出来的模型,有很多原来在训练中检测到的文本框不见了
    查看了各种文档,也照着做了,没有任何效果

Copy link
Contributor

This issue is stale because it has been open for 90 days with no activity.

@github-actions github-actions bot added the stale label Dec 31, 2024
Copy link
Contributor

This issue was closed because it has been inactive for 14 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants