Created
February 29, 2020 04:32
-
-
Save digitallysavvy/41ad7b0f1d19ad85045122246bafc75d to your computer and use it in GitHub Desktop.
An example snippet of a classification request for my Hotdog NotHotdo project.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func classificationCompleteHandler(request: VNRequest, error: Error?) { | |
// Catch Errors | |
if error != nil { | |
print("Error: " + (error?.localizedDescription)!) | |
return | |
} | |
guard let observations = request.results else { | |
print("No results") | |
return | |
} | |
// Get Classifications | |
let classification: VNClassificationObservation = observations.first as! VNClassificationObservation | |
DispatchQueue.main.async { | |
// Print Classifications | |
print("--") | |
// Display Debug Text on screen | |
let debugText: String = "- \(classification.identifier) : \(classification.confidence)" | |
print(debugText) | |
// Display prediction | |
var objectName: String = "Not Hotdog" | |
if classification.confidence > 0.4 { | |
objectName = "Hotdog" | |
} | |
// show the result | |
self.showResult(objectName) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment