February 2018
Intermediate to advanced
378 pages
10h 14m
English
You need to drag-and-drop the Core ML file generated in the previous section into your project to start working with the model.
Imports:
import Foundationimport Visionimport AVFoundationimport UIKit
At first, let's define some data structures. An enumeration for possible classification results:
enum FaceExpressions: String { case angry = "angry" case anxious = "anxious" case neutral = "neutral" case happy = "happy" case sad = "sad"}
An enum for errors of the classifier:
enum ClassifierError: Error { case unableToResizeBuffer case noResults}
Classifier is a wrapper singleton for Core ML model:
class Classifier { public static let shared = Classifier() private let visionModel: VNCoreMLModel var visionRequests = [VNRequest]() ...Read now
Unlock full access