首页 PaddleX 帖子详情
paddlex预测问题
收藏
快速回复
PaddleX 问答视觉 422 1
paddlex预测问题
收藏
快速回复
PaddleX 问答视觉 422 1

我训练了一个模型,然后使用model.evaluate 进行评估正常,但是使用model.predict进行预测时却报错,

t)/tmp/ipykernel_213/565801520.py in
1 save_dir = 'output/mobilenetv3/best_model'
2 model = pdx.load_model(save_dir)
----> 3 results = module.predict('home/aistudio/work/imgs/test/img_92659.jpg')
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/compat/paddle_utils.py in runner(*args, **kwargs)
218 def runner(*args, **kwargs):
219 with static_mode_guard():
--> 220 return func(*args, **kwargs)
221
222 return runner
~/work/DriverStatusRecognition/module.py in predict(self, images, paths, data, batch_size, use_gpu, **kwargs)
68 except IndexError:
69 break
---> 70 out = self.model.batch_predict(batch_data, **kwargs)
71 res.extend(out)
72 return res
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlex/deploy.py in batch_predict(self, image_list, topk, transforms)
302 if transforms is not None:
303 self.transforms = transforms
--> 304 preprocessed_input = self.preprocess(image_list, self.thread_pool)
305 model_pred = self.raw_predict(preprocessed_input)
306 im_shape = None if 'im_shape' not in preprocessed_input else preprocessed_input[
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlex/deploy.py in preprocess(self, image, thread_pool)
159 self.model_type,
160 self.model_name,
--> 161 thread_pool=thread_pool)
162 res['image'] = im
163 elif self.model_type == "detector":
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlex/cv/models/classifier.py in _preprocess(images, transforms, model_type, class_name, thread_pool, input_channel)
303 input_channel=input_channel)
304 if thread_pool is not None:
--> 305 batch_data = thread_pool.map(transforms, images)
306 else:
307 batch_data = list()
/opt/conda/envs/python35-paddle120-env/lib/python3.7/multiprocessing/pool.py in map(self, func, iterable, chunksize)
266 in a list that is returned.
267 '''
--> 268 return self._map_async(func, iterable, mapstar, chunksize).get()
269
270 def starmap(self, func, iterable, chunksize=None):
/opt/conda/envs/python35-paddle120-env/lib/python3.7/multiprocessing/pool.py in get(self, timeout)
655 return self._value
656 else:
--> 657 raise self._value
658
659 def _set(self, i, obj):
/opt/conda/envs/python35-paddle120-env/lib/python3.7/multiprocessing/pool.py in worker(inqueue, outqueue, initializer, initargs, maxtasks, wrap_exception)
119 job, i, func, args, kwds = task
120 try:
--> 121 result = (True, func(*args, **kwds))
122 except Exception as e:
123 if wrap_exception and func is not _helper_reraises_exception:
/opt/conda/envs/python35-paddle120-env/lib/python3.7/multiprocessing/pool.py in mapstar(args)
42
43 def mapstar(args):
---> 44 return list(map(*args))
45
46 def starmapstar(args):
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlex/cv/transforms/cls_transforms.py in __call__(self, im_file, label)
88 raise TypeError('Can\'t read The image file {}!'.format(
89 im_file))
---> 90 self.data_type = im.dtype
91 im = im.astype('float32')
92 if input_channel == 3 and self.to_rgb:
AttributeError: 'NoneType' object has no attribute 'dtype'

 

请问大佬们该怎么解决

0
收藏
回复
全部评论(1)
时间顺序
春晖如画
#2 回复于2022-03

参考项目是这个【PaddleHub模型贡献】一行代码实现驾驶员状态识别 - 飞桨AI Studio - 人工智能学习实训社区 (baidu.com)

0
回复
需求/bug反馈?一键提issue告诉我们
发现bug?如果您知道修复办法,欢迎提pr直接参与建设飞桨~
在@后输入用户全名并按空格结束,可艾特全站任一用户