PaddlePaddle / PaddleX

All-in-One Development Tool based on PaddlePaddle(飞桨低代码开发工具)
Apache License 2.0
4.87k stars 958 forks source link

模型预测 #1510

Open zhangyingying520 opened 2 years ago

zhangyingying520 commented 2 years ago

Checklist:

  1. 查找历史相关issue寻求解答
  2. 翻阅FAQ常见问题汇总和答疑
  3. 确认bug是否在新版本里还未修复
  4. 翻阅PaddleX API文档说明

描述问题

训练好了模型,无法预测

复现

  1. 您是否已经正常运行我们提供的教程

  2. 您是否在教程的基础上修改代码内容?还请您提供运行的代码 import paddlex as pdx model = pdx.load_model('output/picodet_esnet_l/best_model') image_name = 'defect/JPEGImages/0069.jpg' result = model.predict(image_name) pdx.det.visualize(image_name, result, threshold=0.5, save_dir='./output/')

  3. 您使用的数据集是? https://aistudio.baidu.com/aistudio/datasetdetail/146356

  4. 请提供您出现的报错信息及相关log 2022-05-25 08:20:38 [INFO] Model[PicoDet] loaded.

    AssertionError Traceback (most recent call last) /tmp/ipykernel_169/2282073177.py in 2 model = pdx.load_model('output/picodet_esnet_l/best_model') 3 image_name = 'defect/JPEGImages/0069.jpg' ----> 4 result = model.predict(image_name) 5 pdx.det.visualize(image_name, result, threshold=0.5, save_dir='./output/')

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlex/cv/models/detector.py in predict(self, img_file, transforms) 538 batch_samples = self._preprocess(images, transforms) 539 self.net.eval() --> 540 outputs = self.run(self.net, batch_samples, 'test') 541 prediction = self._postprocess(outputs) 542

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlex/cv/models/detector.py in run(self, net, inputs, mode) 103 104 def run(self, net, inputs, mode): --> 105 net_out = net(inputs) 106 if mode in ['train', 'eval']: 107 outputs = net_out

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py in call(self, *inputs, kwargs) 928 return self.forward(*inputs, *kwargs) 929 else: --> 930 return self._dygraph_call_func(inputs, kwargs) 931 932 def forward(self, *inputs, **kwargs):

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py in _dygraph_call_func(self, *inputs, kwargs) 913 outputs = self.forward(*inputs, *kwargs) 914 else: --> 915 outputs = self.forward(inputs, kwargs) 916 917 for forward_post_hook in self._forward_post_hooks.values():

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlex/ppdet/modeling/architectures/meta_arch.py in forward(self, inputs) 69 for inp in inputs_list: 70 self.inputs = inp ---> 71 outs.append(self.get_pred()) 72 73 # multi-scale test

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlex/ppdet/modeling/architectures/picodet.py in get_pred(self) 87 return {'picodet': self._forward()[0]} 88 else: ---> 89 bbox_pred, bbox_num = self._forward() 90 output = {'bbox': bbox_pred, 'bbox_num': bbox_num} 91 return output

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlex/ppdet/modeling/architectures/picodet.py in _forward(self) 62 def _forward(self): 63 body_feats = self.backbone(self.inputs) ---> 64 fpn_feats = self.neck(body_feats) 65 head_outs = self.head(fpn_feats, self.deploy) 66 if self.training or self.deploy:

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py in call(self, *inputs, kwargs) 928 return self.forward(*inputs, *kwargs) 929 else: --> 930 return self._dygraph_call_func(inputs, kwargs) 931 932 def forward(self, *inputs, **kwargs):

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py in _dygraph_call_func(self, *inputs, kwargs) 913 outputs = self.forward(*inputs, *kwargs) 914 else: --> 915 outputs = self.forward(inputs, kwargs) 916 917 for forward_post_hook in self._forward_post_hooks.values():

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlex/ppdet/modeling/necks/csp_pan.py in forward(self, inputs) 319 tuple[Tensor]: CSPPAN features. 320 """ --> 321 assert len(inputs) == len(self.in_channels) 322 inputs = self.conv_t(inputs) 323

AssertionError:

环境

  1. 请提供您使用的PaddlePaddle和PaddleX的版本号

paddlepaddle-gpu 2.3.0.post112 paddlex 2.1.0 aistudio

  1. 请提供您使用的操作系统信息,如Linux/Windows/MacOS

  2. 请问您使用的Python版本是?

  3. 请问您使用的CUDA/cuDNN的版本号是?

FlyingQianMM commented 2 years ago

我这里跑picodet训练完之后,可以正常加载并预测,用的是教程里代码:https://github.com/PaddlePaddle/PaddleX/blob/develop/tutorials/train/object_detection/picodet.py

您这边的模型是有做什么修改吗?