PaddlePaddle / PaddlePaddle/FastDeploy

使用yolov5的c++ example加载自己训练的yolov5_s模型报错,提示输入数量不对,该如何修改代码?

Open
#1,835 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.7k
Forks
756
Avg merge
19h 28m
Merged PRs (30d)
4

Description


温馨提示:根据社区不完全统计,按照模板提问,可以加快回复和解决问题的速度


环境

  • 【FastDeploy版本】: 自己编译的GPU版本
  • 【编译命令】如果您是自行编译的FastDeploy,请说明您的编译方式(参数命令)
  • 【系统平台】: Linux x64(Ubuntu 22.04)
  • 【硬件】: 说明具体硬件型号,如 Nvidia GPU 4090, CUDA 12.0 CUDNN 8.8
  • 【编译语言】: C++

问题日志及出现问题的操作流程

  • 附上详细的问题日志有助于快速定位分析
  • 【模型跑不通】
    • 先执行examples下的部署示例,包括使用examples提供的模型,可以正确执行
    • examples下的代码可以运行,但自己的模型能运行
      • 提供复现问题的 代码+模型+错误log 如下:
  • ./infer_paddle_demo yolov5_s_300e_voc_tianan 2.jpg 1
    [INFO] fastdeploy/runtime/runtime.cc(266)::CreatePaddleBackend Runtime initialized with Backend::PDINFER in Device::GPU.
    [ERROR] fastdeploy/runtime/backends/paddle/paddle_backend.cc(283)::Infer [PaddleBackend] Size of inputs(1) should keep same with the inputs of this model(2).
    [ERROR] fastdeploy/vision/detection/contrib/yolov5/yolov5.cc(80)::BatchPredict Failed to inference by runtime.
    Failed to predict.

image
模型是使用paddleyolo训练的yolov5s,除了类别和数据是自定义的,其它参数配置是都是默认值,其中的reader配置如下图:
image

训练出来的模型使用python推理是没问题的,现在需要使用c++推理,我也参考其它issue https://github.com/PaddlePaddle/PaddleDetection/issues/4306修改了input_spec的输入,但是训练和推理都不正确。

请问各位大佬给个解决思路,感谢~

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the C++ YOLOv5 example under examples and fastdeploy/vision/detection/contrib/yolov5/yolov5.cc, then reproduce the PaddleBackend input-count error using the supplied command and custom model. Compare the custom model's input_spec with the example model and the referenced PaddleDetection issue; done means the custom YOLOv5 model runs successfully through C++ inference.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.