-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comparison between two images #1
Comments
There isn't a function for that, but it shouldn't be hard to implement. Assuming you have trained the model and the weights were saved under filepath from scipy import ndimage
from skimage import color
from train import create_model
# create the model
model = create_model() # that function is in train.py
# load trained weights
model.load_weights(weights_fp)
# load images
img1 = ndimage.imread(img1_fp, mode="RGB")
img2 = ndimage.imread(img2_fp, mode="RGB")
# resize images
img1_rs = misc.imresize(img1, (32, 32))
img2_rs = misc.imresize(img2, (32, 32))
# convert images to grayscale images with shape (height, width, 1) in value range 0 to 1.0
img1_gray = color.rgb2gray(img1_rs)[:, :, np.newaxis]
img2_gray = color.rgb2gray(img2_rs)[:, :, np.newaxis]
# convert images to batches
img1_batch = np.array([img1_gray])
img2_batch = np.array([img2_gray])
# predict their similarity
preds = model.predict([img1_batch, img2_batch])
# print similarity
print("Similarity: %.2f" % (preds[0],)) |
Thank you, Alexander! |
@riclab Did you run the script? |
Hi, is it possible to make a comparison between two images getting a percentage?
Thanks.
The text was updated successfully, but these errors were encountered: