Skip to content

Instantly share code, notes, and snippets.

@giln
Created March 4, 2019 14:38
Show Gist options
  • Save giln/5721b8cf73272ec66f8384f29153572c to your computer and use it in GitHub Desktop.
Save giln/5721b8cf73272ec66f8384f29153572c to your computer and use it in GitHub Desktop.
predictionRequest
private lazy var predictionRequest: VNCoreMLRequest = {
// Load the ML model through its generated class and create a Vision request for it.
do {
let model = try VNCoreMLModel(for: HandModel().model)
let request = VNCoreMLRequest(model: model)
// This setting determines if images are scaled or cropped to fit our 224x224 input size. Here we try scaleFill so we don't cut part of the image.
request.imageCropAndScaleOption = VNImageCropAndScaleOption.scaleFill
return request
} catch {
fatalError("can't load Vision ML model: \(error)")
}
}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment