image = cv2.imread(path + file) image = cv2.resize(image, (48, 48), interpolation=cv2.INTER_CUBIC) # image = image.astype('float32') # transformer.set_raw_scale('data', 255) # 缩放到[0,255]之间 # transformer.set_channel_swap('data', (2, 1, 0)) # 交换通道,将图片由RGB变为BGR(caffe中图片是BGR格式,而原始格式是RGB,所以要转化) image /=255解决方法:加上这句,就可以除以255了
image = image.astype('float32')