Guest User

Untitled

a guest
May 27th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. public func handleClassification(request: VNRequest, error: Error?) {
  2. guard let observations = request.results as? [VNClassificationObservation]
  3. else { fatalError("unexpected result type from VNCoreMLRequest") }
  4.  
  5. guard let best = observations.first else {
  6. fatalError("classification didn't return any results")
  7. }
  8.  
  9. DispatchQueue.main.async {
  10. if best.identifier.starts(with: "Unknown") || best.confidence < 0.50 {
  11. print("Mhm, no cat or absolutely not sure about it's mood")
  12. } else {
  13. print("This cat seem to be in a \(best.identifier) mood (\(best.confidence) sure"
  14. }
  15. }
  16. }
Add Comment
Please, Sign In to add comment