【发布时间】:2023-01-01 11:05:21
【问题描述】:
我正在尝试从该网站修改和调用我自己的模型 https://pythonprogramming.net/using-trained-model-deep-learning-python-tensorflow-keras/
但这是我的问题。
def prepare(filepath):
IMG_SIZE = 70 # 50 in txt-based
img_array = cv2.imread(filepath, cv2.IMREAD_GRAYSCALE) # read in the image, convert to grayscale
new_array = cv2.resize(img_array, (IMG_SIZE, IMG_SIZE)) # resize image to match model's expected sizing
return new_array.reshape(-1, IMG_SIZE, IMG_SIZE, 1) # return the image with shaping that TF wants.
1.我的模型输入是 (180x180x3) ,由于索引超出范围,我无法将其更改为灰度。
2.因为我知道我的频道是 3,所以我想将我的数组更改为 new_array.reshape(-1, IMG_SIZE, IMG_SIZE, 3),但是当它预测
print(prediction[0][0])
它不是数字 0 或 1,所以我无法预测我的照片。
请帮我弄清楚发生了什么,无论是问题 1 还是问题 2。
我感谢你的帮助。
我希望只有 1 或 0,所以我可以对标签“通过”或“失败”进行分类
【问题讨论】:
标签: python tensorflow machine-learning