以下是进行预测的代码
#预测
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'
hxksdgjs