返回

python-在一次模型训练后预测图像类

发布时间:2022-05-02 02:56:01 228
# node.js

我正在使用一次性模型因为我几乎没有每门课的数据。我正在学习这个教程

已经准备好数据管道并训练了模型。但我不理解我们通常通过的单幅图像预测过程模型预测.

我尝试了以下代码,但我想我遗漏了一些东西。

img1 = cv2.imread("./images_evaluation/test.jpg",cv2.IMREAD_GRAYSCALE)
img1 = cv2.resize(img1,(105,105))
img1 = np.expand_dims(cv2.resize(img1, (105,105)), axis=2)

(test_image_names, train_image_names) = generate_oneshot_validation_trials(dataset, 20)
train_images = get_images(train_image_names, IMAGE_SHAPE)
    
images = np.tile(img1, (len(train_images), 1, 1, 1))
preds = siamese_model1.predict([images, train_images])
pred_idx = np.argmax(preds, axis=0)[0]
    
pred_char_name = train_image_names[pred_idx].split('/')[-2]

print(pred_char_name) ## here, finding different prediction after every try. whats the reason?

提前谢谢。

特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(0)
按点赞数排序
用户头像