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

x2paddle转换yolov5后推理报错 #1017

Open
1 task
luoshiyong opened this issue Jun 26, 2024 · 2 comments
Open
1 task

x2paddle转换yolov5后推理报错 #1017

luoshiyong opened this issue Jun 26, 2024 · 2 comments

Comments

@luoshiyong
Copy link

在将pytorch的yolov5转换到paddle过程中eval报错

  • 错误信息
    ValueError: (InvalidArgument) The 'shape' in ReshapeOp is invalid. The input tensor X'size must be equal to the capacity of 'shape'. But received X's shape = [1, 512, 1, 1], X's size = 512, 'shape' is [2, 512], the capacity of 'shape' is 1024.
    [Hint: Expected capacity == in_size, but received capacity:1024 != in_size:512.] (at ../paddle/fluid/operators/reshape_op.cc:234)
    [operator < reshape2 > error]

  • 错误截图
    image

具体信息

  • 转换模型后用处

    • 使用 Paddle-Lite 做移动端推理
@Andy197527
Copy link

请问你解决了吗?以及转换完之后是如何进行推理呢?

@megemini
Copy link
Contributor

#1099 增加了 yolov5 的转换测试 ~

可以看一下这个 PR ~ 拉取一下最新的 develop 版本的 X2Paddle 然后试一下 ~

不过,转换的时候注意,要先 torch.jit.trace 一遍,然后再用 api 转换 ~ 上面这个 PR 都有说明 ~

请问你解决了吗?以及转换完之后是如何进行推理呢?

推理可以参考 pd_infer.py 这个文件。test_benchmark/PyTorch/yolov5/pd_model_trace 里面也有转换之后的模型结构代码 ~

不过,模型的输出是一个 concat 之后的大 tensor,如果需要检测目标的结果,还需要 nms 等后处理手段 ~ 可以参考 https://github.com/ultralytics/yolov5 中的后处理 ~

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

No branches or pull requests

3 participants