Skip to content

Instantly share code, notes, and snippets.

@an-indya
Created May 12, 2018 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save an-indya/634a10bc956ab69d9fdb3430bc904d18 to your computer and use it in GitHub Desktop.
Save an-indya/634a10bc956ab69d9fdb3430bc904d18 to your computer and use it in GitHub Desktop.
let request = VNCoreMLRequest(model: model) { [weak self] (request, error) in
guard let results = request.results as? [VNClassificationObservation],
let topResult = results.first else {
fatalError("Result not in correct format")
}
DispatchQueue.main.async {[weak self] in
self?.predictionLabel.text = "\(topResult.confidence * 100)%
chance to be \(topResult.identifier)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment