Created
October 12, 2018 18:30
-
-
Save rajajawahar/f53bb4c4474f0afa232203f0942fdf75 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func detectImage(seletedImage : CIImage){ | |
guard let coreMLModel = try? VNCoreMLModel(for: PlantsImageClassifier().model)else { | |
print("Unable to import model") | |
return | |
} | |
let request = VNCoreMLRequest(model: coreMLModel) { (request,error) in | |
let classification = request.results?.first as? VNClassificationObservation | |
self.navigationItem.title = classification?.identifier | |
} | |
let requestOptions:[VNImageOption : Any] = [:] | |
let handler = VNImageRequestHandler(ciImage:seletedImage, options: requestOptions) | |
do{ | |
try handler.perform([request]) | |
}catch{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment