使用paddle detection中的YOLOv3_Mobilenet_fruit训练好模型后,导出后为_model_和_params_
Created by: learning-boy
使用paddle detection中的YOLOv3_Mobilenet_fruit训练好模型后,导出后为_model_和_params_,使用python加载模型,预测效果与通过python -u tools/infer.py -c /home/aistudio/PaddleDetection-release-0.2/configs/yolov3_mobilenet_v1_fruit.yml的命令行预测差距较大,不如使用命令行的预测效果 python预处理程序如下: def read_image(self,img_path):
origin = Image.open(img_path)
img = self.resize_img(origin, target_size)#[3, 504, 377]
resized_img = img.copy()#将图片复制一下
if img.mode != 'RGB':
img = img.convert('RGB')
img = np.array(img).astype('float32').transpose((2, 0, 1))
#做归一化处理
img = img / 255.0
print("img:",img.shape)
#print( img[0, :, :], img[1, :, :], img[2, :, :])
img[0, :, :] -= 0.485#img[0, :, :] = img[0, :, :] -0.485
img[1, :, :] -= 0.456
img[2, :, :] -= 0.406
img[0, :, :] /=0.229
img[1, :, :] /=0.224
img[2, :, :] /=0.225
print("img:", img.shape)
img = img[np.newaxis, :]
print("img:", img.shape)
return origin, img, resized_img