2021-07-28 19:02:48 +02:00
|
|
|
import tensorflow.keras as keras
|
|
|
|
from PIL import Image
|
|
|
|
import numpy as np
|
2021-08-12 15:25:37 +02:00
|
|
|
import ipdb
|
2021-08-06 13:24:08 +02:00
|
|
|
|
2021-08-12 15:25:37 +02:00
|
|
|
class g:
|
|
|
|
def __init__(self, path):
|
|
|
|
self.image = np.asarray(Image.open(path).convert('RGB').resize((100, 100))) / 255
|
|
|
|
|
|
|
|
def show(self):
|
|
|
|
self.image.show()
|
2021-08-06 13:24:08 +02:00
|
|
|
|
|
|
|
def predict(image1, image2):
|
2021-08-12 15:25:37 +02:00
|
|
|
return model.predict([np.array([image2.image]), np.array([image1.image])])
|
2021-08-06 13:24:08 +02:00
|
|
|
|
2021-08-12 15:25:37 +02:00
|
|
|
model = keras.models.load_model('../siamese_100x100_pretrainedb_vgg16')
|
|
|
|
image1 = g('data/fruits/fruits-360/Training/Avocado/r_254_100.jpg')
|
|
|
|
image2 = g('data/fruits/fruits-360/Training/Avocado/r_250_100.jpg')
|
2021-08-06 13:24:08 +02:00
|
|
|
|
|
|
|
print(predict(image1, image2))
|
2021-07-28 19:02:48 +02:00
|
|
|
|
2021-08-12 15:25:37 +02:00
|
|
|
ipdb.set_trace()
|
2021-07-28 19:02:48 +02:00
|
|
|
|
2021-08-06 13:24:08 +02:00
|
|
|
|
|
|
|
|