我正在尝试重塑图像,然后发送模型以预测它使用的是Tensorflow(v-2.0)和python(v-3.6)是哪个数字,但收到错误“ TypeError:/不支持的操作数类型:' NoneType'和'float'“。
path=cv2.imread('home/farhana/Desktop/image processing/code/7.jpg')
img = cv2.imread(path,cv2.IMREAD_GRAYSCALE)
res=img
res = res / 255.0
res = res.resize(28,28)
res = res.reshape((len(img), 28, 28,1))
res = res.reshape(28,28,1)
file
是输入jpg的路径字符串(类似于Windows上的'D:/folder/test.jpg'
,请尝试
import cv2
import numpy as np
img = cv2.imread(file, cv2.IMREAD_GRAYSCALE).astype(np.float64)
res = img/255
res = cv2.resize(res, (28, 28)).reshape(28, 28, 1)