Hello guys,
How can I build a Core ML that ranks a list with the images that are most similar to an inputed image?
Clarifai.ai has this feature, but I wanted to do it in CoreML
thanks!
Core ML - image similarity ranking
Apple provides a sample project to show how to use feature print to compare images.
The code below I modified shows how to compare two apple images to a pear image. The smaller the distance the similar the images are.
The code below I modified shows how to compare two apple images to a pear image. The smaller the distance the similar the images are.
Code Block import UIKit import Vision func featureprintObservationForImage(atURL url: URL) -> VNFeaturePrintObservation? { let requestHandler = VNImageRequestHandler(url: url, options: [:]) let request = VNGenerateImageFeaturePrintRequest() do { try requestHandler.perform([request]) return request.results?.first as? VNFeaturePrintObservation } catch { print("Vision error: \(error)") return nil } } let apple1 = featureprintObservationForImage(atURL: Bundle.main.url(forResource:"apple1", withExtension: "jpg")!) let apple2 = featureprintObservationForImage(atURL: Bundle.main.url(forResource:"apple2", withExtension: "jpg")!) let pear = featureprintObservationForImage(atURL: Bundle.main.url(forResource:"pear", withExtension: "jpg")!) var distance = Float(0) try apple1!.computeDistance(&distance, to: apple2!) var distance2 = Float(0) try apple1!.computeDistance(&distance2, to: pear!)
Hello, I am developing an application. We take pictures from users in the application and save them in firebase. Then our goal is to find the same person from the pictures we took from the users. How can I do this please someone help.