首页 PaddleX 帖子详情
Paddlex进行目标检测,导入训练好的模型,预测时报错
收藏
快速回复
PaddleX 问答解决方案视觉 379 1
Paddlex进行目标检测,导入训练好的模型,预测时报错
收藏
快速回复
PaddleX 问答解决方案视觉 379 1

以下是进行预测的代码

#预测

import paddlex as pdx

model = pdx.load_model('output/yolov3_darknet53/best_model')

image_name = 'road_crack_voc/JPEGImages/Japan_007013.xml'

result = model.predict(image_name)

pdx.det.visualize(image_name, result, threshold=0.5, save_dir='output/output_pic')

报错如下:

---------------------------------------------------------------------------AttributeError Traceback (most recent call last)/tmp/ipykernel_98/1603821620.py in
5 model = pdx.load_model('output/yolov3_darknet53/best_model')
6 image_name = 'road_crack_voc/JPEGImages/Japan_007013.xml'
----> 7 result = model.predict(image_name)
8 pdx.det.visualize(image_name, result, threshold=0.5, save_dir='output/output_pic')
9 # pred = pdx.det.visualize(image_name, result, threshold=0.5, save_dir=None)
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlex/cv/models/ppyolo.py in predict(self, img_file, transforms)
523 self.model_type,
524 self.__class__.__name__,
--> 525 input_channel=input_channel)
526
527 with fluid.scope_guard(self.scope):
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlex/cv/models/ppyolo.py in _preprocess(images, transforms, model_type, class_name, thread_pool, input_channel)
474 batch_data = list()
475 for image in images:
--> 476 batch_data.append(transforms(image))
477 padding_batch = generate_minibatch(batch_data)
478 im = np.array(
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlex/cv/transforms/det_transforms.py in __call__(self, im, im_info, label_info)
147
148 input_channel = getattr(self, 'input_channel', 3)
--> 149 outputs = decode_image(im, im_info, label_info, input_channel)
150 im = outputs[0]
151 im_info = outputs[1]
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlex/cv/transforms/det_transforms.py in decode_image(im_file, im_info, label_info, input_channel)
122 raise TypeError('Can\'t read The image file {}!'.format(
123 im_file))
--> 124 self.data_type = im.dtype
125 im = im.astype('float32')
126 if input_channel == 3 and self.to_rgb:
AttributeError: 'NoneType' object has no attribute 'dtype'

0
收藏
回复
全部评论(1)
时间顺序
李琴在努力工作
#2 回复于2023-10

hxksdgjs

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