Paddle 加载不同模型时,推理报错

31moq8wy  于 2022-10-20  发布在  其他
关注(0)|答案(2)|浏览(262)

为使您的问题得到快速解决,在建立Issue前,请您先通过如下方式搜索是否有相似问题:【搜索issue关键字】【使用labels筛选】【官方文档】

如果您没有查询到相似问题,为快速解决您的提问,建立issue时请提供如下细节信息:

  • 标题:简洁、精准描述您的问题,例如“最新预测库的API文档在哪儿 ”
  • 版本、环境信息:

   1)PaddlePaddle版本:paddlepaddle==2.2.1
   2)CPU:AMD Ryzen 5 3600X 6-Core Processor
   3)系统环境:win10,python3.8

  • 复现信息:

import paddlex as pdx

def infer(model_path,img_path):
model = pdx.load_model(model_path)
result = model.predict(img_path)
return result

model_path1 = "E:/zwj/D/test_kunchong_model/inference_model/inference_model"
img_path1 = "E:/zwj/UAV/JPEGImages/1.jpg"
result1 = infer(model_path1,img_path1)

model_path2 = "E:/zwj/D/armored1201_model/inference_model/inference_model"
img_path2 = "E:/zwj/UAV/JPEGImages/1.jpg"
result2 = infer(model_path2,img_path2)

model_path3 = "E:/zwj/D/UAV1201_model/inference_model/inference_model"
img_path3 = "E:/zwj/UAV/JPEGImages/1.jpg"
result3 = infer(model_path3,img_path3)

model_path4 = "E:/zwj/D/test_kunchong_model/inference_model/inference_model"
img_path4 = "E:/zwj/UAV/JPEGImages/1.jpg"
result4 = infer(model_path1,img_path1)

  • 问题描述:

单个模型推理时正常运行,但是加载多个不同模型推理会报错

2022-01-15 01:27:39 [INFO] Model[PicoDet] loaded.
2022-01-15 01:27:42 [INFO] Model[PPYOLOv2] loaded.
2022-01-15 01:27:49 [INFO] Model[PPYOLO] loaded.
2022-01-15 01:27:53 [INFO] Model[PicoDet] loaded.
Traceback (most recent call last):
File "E:/zwj/D/py/showresult/infer.py", line 47, in
result1 = infer(model_path1,img_path1)
File "E:/zwj/D/py/showresult/infer.py", line 20, in infer
result = model.predict(img_path)
File "E:\zwj\D\py\venv\lib\site-packages\paddlex\cv\models\detector.py", line 540, in predict
outputs = self.run(self.net, batch_samples, 'test')
File "E:\zwj\D\py\venv\lib\site-packages\paddlex\cv\models\detector.py", line 105, in run
net_out = net(inputs)
File "E:\zwj\D\py\venv\lib\site-packages\paddle\fluid\dygraph\layers.py", line 914, incall
outputs = self.forward(inputs,kwargs)
File "E:\zwj\D\py\venv\lib\site-packages\paddlex\ppdet\modeling\architectures\meta_arch.py", line 71, in forward
outs.append(self.get_pred())
File "E:\zwj\D\py\venv\lib\site-packages\paddlex\ppdet\modeling\architectures\picodet.py", line 89, in get_pred
bbox_pred, bbox_num = self._forward()
File "E:\zwj\D\py\venv\lib\site-packages\paddlex\ppdet\modeling\architectures\picodet.py", line 64, in _forward
fpn_feats = self.neck(body_feats)
File "E:\zwj\D\py\venv\lib\site-packages\paddle\fluid\dygraph\layers.py", line 914, in
call
*
outputs = self.forward(*inputs,**kwargs)
File "E:\zwj\D\py\venv\lib\site-packages\paddlex\ppdet\modeling\necks\csp_pan.py", line 321, in forward
assert len(inputs) == len(self.in_channels)
AssertionError

8wtpewkr

8wtpewkr1#

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看 官网API文档常见问题历史IssueAI社区 来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the APIFAQGithub Issue and AI community to get the answer.Have a nice day!

kqhtkvqz

kqhtkvqz2#

你好,这个问题是因为你的图片输入的维度不对,assert len(inputs) == len(self.in_channels), 请调整输入图片的维度符合网络输入的维度。

相关问题