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

如果图片太大的话, 图片识别结果为空 #10327

Closed
snowman opened this issue Jul 7, 2023 · 3 comments
Closed

如果图片太大的话, 图片识别结果为空 #10327

snowman opened this issue Jul 7, 2023 · 3 comments
Assignees
Labels

Comments

@snowman
Copy link

snowman commented Jul 7, 2023

请提供下述完整信息以便快速定位问题

  • 系统环境: Windows 10 Version 21H2 (OS Build 19044.1826)
  • 版本号:
    • Paddle: 2.5.0
    • PaddleOCR: 2.6.1.3

我有 500 张图片, 每张图片大小一致 2560x1600, 每张图片固定区域想要识别, 需要识别的区域, 坐标相同, 大小相同.

x: 0
y: 100
width: 2560
height: 64

以下 joined_image 表示已经用 Pillow 拼接好的图片

> ocr = PaddleOCR(use_angle_cls=True, lang="en")
> [joined_image.width, joined_image.height]
[2560, 32000]

> count = 500
> joined_image.crop((0, 0, 2560, 64 * count)).save("output.jpg")
> ocr.ocr("output.jpg", cls=True)
[[]]

高度改小一点
> count = 40
> joined_image.crop((0, 0, 2560, 64 * count)).save("output.jpg")
> ocr.ocr("output.jpg", cls=True)
[
  [
    [
      [
        [133.0, 2410.0],
        [355.0, 2410.0],
        [355.0, 2447.0],
        [133.0, 2447.0]
      ],
      ("hello world", 0.9993047714233398)
    ],
    ...
  ]
]
@Gmgge
Copy link
Contributor

Gmgge commented Jul 10, 2023

你好,从我这边理解,你这边的想法是想要把多个图片拼接在一起,一次性识是吗?
这个想法存在一个问题,就是paddle ocr在识别的时候,会进行resize操作,在这里你可看到[resize]( parser.add_argument("--det_limit_side_len", type=float, default=960))的设置,也就是图像[2560, 32000],会被resize成[76, 960], 此时图像高度压缩较为严重,因此,你需要调整这个det_limit_side_len这个参数,但需要注意的是,修改该参数会增加计算量与内存消耗,可以理解的是,你需要识别更多图像,自然就需要增加这些消耗。

因此当前有两点解决方案给出:

  1. 按照上文分析,修改resize操作的参数;
  2. 如果你可以放出一两个用例,则更方便他人来判断这个问题,例如不一定单排竖直拼接,你可以多排、竖直拼接,保证图像的长宽比例不会过于畸形;

@shiyutang
Copy link
Collaborator

回答得非常完整仔细👍

@shiyutang
Copy link
Collaborator

以上回答已经充分解答了问题,如果有新的问题欢迎随时提交issue,或者在此条issue下继续回复~
我们开启了飞桨套件的ISSUE攻关活动,欢迎感兴趣的开发者参加:PaddlePaddle/PaddleOCR#10223

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

No branches or pull requests

4 participants