Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

ValueError: (InvalidArgument) The 'shape' attribute in ReshapeOp is invalid #11441

Closed
jhonboHou opened this issue Dec 30, 2023 · 7 comments
Closed

Comments

@jhonboHou
Copy link

请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem

  • 系统环境/System Environment:20.04.1-Ubuntu
  • 版本号/Version:Paddle: PaddleOCR: 问题相关组件/Related components:ppstructure
  • 运行指令/Command Code:
    design_pic_engine = PPStructure(table=False, ocr=False, show_log=True, use_gpu=False, layout_model_dir='./output_inference/picodet_s_320_coco_lcnet')
    result = design_pic_engine(img) #这行报错
    #注:以上是编写的执行自训练的模型文件进行预测,但调用后报先面的错误
  • 完整报错/Complete Error Message:
    Traceback (most recent call last):
    File "/data/newhome/camera/hzb_test/paddle_test/test_iso_ocr.py", line 11, in
    result = design_pic_engine(img)
    File "/home/camera/anaconda3/envs/paddle_env/lib/python3.10/site-packages/paddleocr/paddleocr.py", line 759, in call
    res, _ = super().call(
    File "/home/camera/anaconda3/envs/paddle_env/lib/python3.10/site-packages/paddleocr/ppstructure/predict_system.py", line 112, in call
    layout_res, elapse = self.layout_predictor(img)
    File "/home/camera/anaconda3/envs/paddle_env/lib/python3.10/site-packages/paddleocr/ppstructure/layout/predict_layout.py", line 86, in call
    self.predictor.run()
    ValueError: (InvalidArgument) The 'shape' attribute in ReshapeOp is invalid. The input tensor X'size must be divisible by known capacity of 'shape'. But received X's shape = [1, 80, 100, 76], X's size = 608000, 'shape' is [-1, 80, 1600], known capacity of 'shape' is -128000.
    [Hint: Expected output_shape[unk_dim_idx] * capacity == -in_size, but received output_shape[unk_dim_idx] * capacity:-512000 != -in_size:-608000.] (at ../paddle/fluid/operators/reshape_op.cc:216)
    [operator < reshape2 > error]

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

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

@jhonboHou
Copy link
Author

请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem

  • 系统环境/System Environment:20.04.1-Ubuntu
  • 版本号/Version:Paddle: PaddleOCR: 问题相关组件/Related components:ppstructure
  • 运行指令/Command Code:
    design_pic_engine = PPStructure(table=False, ocr=False, show_log=True, use_gpu=False, layout_model_dir='./output_inference/picodet_s_320_coco_lcnet')
    result = design_pic_engine(img) #这行报错
    #注:以上是编写的执行自训练的模型文件进行预测,但调用后报先面的错误
  • 完整报错/Complete Error Message:
    Traceback (most recent call last):
    File "/data/newhome/camera/hzb_test/paddle_test/test_iso_ocr.py", line 11, in
    result = design_pic_engine(img)
    File "/home/camera/anaconda3/envs/paddle_env/lib/python3.10/site-packages/paddleocr/paddleocr.py", line 759, in call
    res, _ = super().call(
    File "/home/camera/anaconda3/envs/paddle_env/lib/python3.10/site-packages/paddleocr/ppstructure/predict_system.py", line 112, in call
    layout_res, elapse = self.layout_predictor(img)
    File "/home/camera/anaconda3/envs/paddle_env/lib/python3.10/site-packages/paddleocr/ppstructure/layout/predict_layout.py", line 86, in call
    self.predictor.run()
    ValueError: (InvalidArgument) The 'shape' attribute in ReshapeOp is invalid. The input tensor X'size must be divisible by known capacity of 'shape'. But received X's shape = [1, 80, 100, 76], X's size = 608000, 'shape' is [-1, 80, 1600], known capacity of 'shape' is -128000.
    [Hint: Expected output_shape[unk_dim_idx] * capacity == -in_size, but received output_shape[unk_dim_idx] * capacity:-512000 != -in_size:-608000.] (at ../paddle/fluid/operators/reshape_op.cc:216)
    [operator < reshape2 > error]

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

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

使用python tools/infer.py 进行预测没有问题,但是导出模型后,使用就存在上面的异常

@jhonboHou
Copy link
Author

请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem

  • 系统环境/System Environment:20.04.1-Ubuntu
  • 版本号/Version:Paddle: PaddleOCR: 问题相关组件/Related components:ppstructure
  • 运行指令/Command Code:
    design_pic_engine = PPStructure(table=False, ocr=False, show_log=True, use_gpu=False, layout_model_dir='./output_inference/picodet_s_320_coco_lcnet')
    result = design_pic_engine(img) #这行报错
    #注:以上是编写的执行自训练的模型文件进行预测,但调用后报先面的错误
  • 完整报错/Complete Error Message:
    Traceback (most recent call last):
    File "/data/newhome/camera/hzb_test/paddle_test/test_iso_ocr.py", line 11, in
    result = design_pic_engine(img)
    File "/home/camera/anaconda3/envs/paddle_env/lib/python3.10/site-packages/paddleocr/paddleocr.py", line 759, in call
    res, _ = super().call(
    File "/home/camera/anaconda3/envs/paddle_env/lib/python3.10/site-packages/paddleocr/ppstructure/predict_system.py", line 112, in call
    layout_res, elapse = self.layout_predictor(img)
    File "/home/camera/anaconda3/envs/paddle_env/lib/python3.10/site-packages/paddleocr/ppstructure/layout/predict_layout.py", line 86, in call
    self.predictor.run()
    ValueError: (InvalidArgument) The 'shape' attribute in ReshapeOp is invalid. The input tensor X'size must be divisible by known capacity of 'shape'. But received X's shape = [1, 80, 100, 76], X's size = 608000, 'shape' is [-1, 80, 1600], known capacity of 'shape' is -128000.
    [Hint: Expected output_shape[unk_dim_idx] * capacity == -in_size, but received output_shape[unk_dim_idx] * capacity:-512000 != -in_size:-608000.] (at ../paddle/fluid/operators/reshape_op.cc:216)
    [operator < reshape2 > error]

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

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

上面问题原因找到了,模型文件用错误了,但是改掉后有报新的粗误了:
Traceback (most recent call last):
File "/data/newhome/camera/hzb_test/paddle_test/test_iso_ocr.py", line 11, in
result = design_pic_engine(img)
File "/home/camera/anaconda3/envs/paddle_env/lib/python3.10/site-packages/paddleocr/paddleocr.py", line 759, in call
res, _ = super().call(
File "/home/camera/anaconda3/envs/paddle_env/lib/python3.10/site-packages/paddleocr/ppstructure/predict_system.py", line 112, in call
layout_res, elapse = self.layout_predictor(img)
File "/home/camera/anaconda3/envs/paddle_env/lib/python3.10/site-packages/paddleocr/ppstructure/layout/predict_layout.py", line 100, in call
post_preds = self.postprocess_op(ori_im, img, preds)
File "/home/camera/anaconda3/envs/paddle_env/lib/python3.10/site-packages/paddleocr/ppocr/postprocess/picodet_postprocess.py", line 175, in call
box_distance = box_distribute.reshape((-1, reg_max + 1))
ValueError: cannot reshape array of size 90945 into shape (2526)

@jhonboHou
Copy link
Author

问题应该是导出的模型的问题,请问下picodet_lcnet_x1_0_fgd_layout_cdla_infer 和picodet_lcnet_x1_0_layout 有什么区别

@jhonboHou
Copy link
Author

应该是预测框的大小不匹配导致

@Irving11330
Copy link

问题应该是导出的模型的问题,请问下picodet_lcnet_x1_0_fgd_layout_cdla_infer 和picodet_lcnet_x1_0_layout 有什么区别

cdla是用中文数据集训练的,后面的是用英文数据集

@Irving11330
Copy link

应该是预测框的大小不匹配导致

兄弟我也是迁徙学习的这个模型,在infer.py正常导出到PPStructure就报错:
ValueError: (InvalidArgument) The input of Op(Conv) should be a 4-D or 5-D Tensor. But received: input's dimension is 1, input's shape is [0].
[Hint: Expected in_dims.size() == 4 || in_dims.size() == 5 == true, but received in_dims.size() == 4 || in_dims.size() == 5:0 != true:1.] (at ..\paddle\fluid\operators\fused\conv_fusion_op.cc:236)
[operator < conv2d_fusion > error]
可以解释一下你发现的问题吗?

@jhonboHou
Copy link
Author

应该是预测框的大小不匹配导致

兄弟我也是迁徙学习的这个模型,在infer.py正常导出到PPStructure就报错: ValueError: (InvalidArgument) The input of Op(Conv) should be a 4-D or 5-D Tensor. But received: input's dimension is 1, input's shape is [0]. [Hint: Expected in_dims.size() == 4 || in_dims.size() == 5 == true, but received in_dims.size() == 4 || in_dims.size() == 5:0 != true:1.] (at ..\paddle\fluid\operators\fused\conv_fusion_op.cc:236) [operator < conv2d_fusion > error] 可以解释一下你发现的问题吗?

你这个看信息是维度的问题,传递的应该是4维或5维 但是接收使用的是1维

@jzhang533 jzhang533 added triaged this issue has been looked, and triaged. training this is a training related issue help wanted this issue needs help labels Apr 10, 2024
@SWHL SWHL removed triaged this issue has been looked, and triaged. training this is a training related issue help wanted this issue needs help labels Jun 6, 2024
@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Jun 6, 2024
@SWHL SWHL converted this issue into discussion #12757 Jun 6, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants