Predict Image class after One shot model Training

Viewed 34

I am making image search using the one-shot model because I have very few data for per class. I am following this tutorial

Already prepared the datapipeline and trained the model. But I didn't understand the single image prediction process which we do which we do generally by model.predict.

I tried the following code but I think I am missing something.

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 Answers
Related