Simple Machine Learning App Using Apple’s Core ML Models

Simple UI for Demo Project
func setupVision() {  guard let visionModel = try? VNCoreMLModel(for: MNIST().model)   
else {fatalError(“can not load Vision ML model”)}
let classificationRequest = VNCoreMLRequest(model: visionModel,
completionHandler: self.handleClassification)
self.requests = [classificationRequest]}
func handleClassification (request:VNRequest, error:Error?) {  guard let observations = request.results else {print(“no  
results”); return}
let classifications = observations
.flatMap({$0 as? VNClassificationObservation})
.filter({$0.confidence > 0.8})
.map({$0.identifier})
DispatchQueue.main.async {
self.digitLabel.text = classifications.first
}
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store