Turicreate iOS Image Similarity
I have been following the Turicreate tutorial link here
I am able to train a model successfully as per instructions. I am also able to consume the model in the iOS app with the help of the code provided over there. But I am not able to figure out how could I get the most similar actual images based on the distances this model returns. Also when I run it on iPhone, it returns me offset and element which I am not able to interpret. Please see the screenshot.
My aim in the iOS application is to input an image, pass that input image to the model and then show the actual output 5 or 10 most similar images and not just the distances.
1 Answers Turicreate iOS Image Similarity
Be sure that you have an
id column or have added the
id column to your SFrame using:
reference_data = reference_data.add_row_number()
Here is a code snippet to create the
image_similarity model and get the ten most similar images for a sample image. I use fifty as a
k value to demonstrate that how to pull out the
n most similar from a larger group in your similarity graph.
similarity_graph = model.similarity_graph(k=50) similar_images = similarity_graph.edges # pick a sample image from reference_data sample_index = 3 sample_similar_images = similar_images[similar_images["__src_id"]==sample_index].sort("rank") # get 10 most similar images most_similar_ids = sample_similar_images["__dst_id"][0:10] most_similar_images = reference_data.filter_by(most_similar_ids, "id")
For details on interpreting the distance MultiArray from the CoreML model, see the sample code in the Turi Create documentation. The element value corresponds to the distance.