Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@iosdevie
Created May 26, 2021 07:04
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 iosdevie/9b9c46d8a752bfb6d4f62b4e780bd3ef to your computer and use it in GitHub Desktop.
Save iosdevie/9b9c46d8a752bfb6d4f62b4e780bd3ef to your computer and use it in GitHub Desktop.
private let trainedImageSize = CGSize(width: 28, height: 28)
func predictImage(image: UIImage){
if let resizedImage = image.resize(newSize: trainedImageSize), let pixelBuffer = resizedImage.toCVPixelBuffer(){
guard let result = try? MNIST().prediction(image: pixelBuffer) else {
return
}
navigationBar.topItem?.leftBarButtonItem?.title = "Predicted: \(result.classLabel)"
print("result is \(result.classLabel)")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment