Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swift Lille - CoreML / CreateML

Swift Lille - CoreML / CreateML

Mathieu Hausherr

January 15, 2019
Tweet

More Decks by Mathieu Hausherr

Other Decks in Technology

Transcript

  1. // Load the ML model through its generated class guard

    let model = try? VNCoreMLModel(for: CarClassifier().model) else { fatalError("can't load Places ML model") } // Create a Vision request with completion handler let request = VNCoreMLRequest(model: model) { [weak self] request, error in guard let results = request.results as? [VNClassificationObservation] else { return } let topResults = results[0..<5] // Update UI on main queue DispatchQueue.main.async { [weak self] in self?.answerLabel.text = topResults .map { "\(Int($0.confidence * 100))% \($0.identifier)" } .joined(separator: "\n") } } // Run the Core ML classifier on global dispatch queue let handler = VNImageRequestHandler(ciImage: image) DispatchQueue.global(qos: .userInteractive).async { do { try handler.perform([request]) } catch { print(error) } }
  2. // Load the ML model through its generated class guard

    let model = try? VNCoreMLModel(for: CarClassifier().model) else { fatalError("can't load Places ML model") } // Create a Vision request with completion handler let request = VNCoreMLRequest(model: model) { [weak self] request, error in guard let results = request.results as? [VNClassificationObservation] else { return } let topResults = results[0..<5] // Update UI on main queue DispatchQueue.main.async { [weak self] in self?.answerLabel.text = topResults .map { "\(Int($0.confidence * 100))% \($0.identifier)" } .joined(separator: "\n") } } // Run the Core ML classifier on global dispatch queue let handler = VNImageRequestHandler(ciImage: image) DispatchQueue.global(qos: .userInteractive).async { do { try handler.perform([request]) } catch { print(error) } }
  3. // Load the ML model through its generated class guard

    let model = try? VNCoreMLModel(for: CarClassifier().model) else { fatalError("can't load Places ML model") } // Create a Vision request with completion handler let request = VNCoreMLRequest(model: model) { [weak self] request, error in guard let results = request.results as? [VNClassificationObservation] else { return } let topResults = results[0..<5] // Update UI on main queue DispatchQueue.main.async { [weak self] in self?.answerLabel.text = topResults .map { "\(Int($0.confidence * 100))% \($0.identifier)" } .joined(separator: "\n") } } // Run the Core ML classifier on global dispatch queue let handler = VNImageRequestHandler(ciImage: image) DispatchQueue.global(qos: .userInteractive).async { do { try handler.perform([request]) } catch { print(error) } }
  4. // Load the ML model through its generated class guard

    let model = try? VNCoreMLModel(for: CarClassifier().model) else { fatalError("can't load Places ML model") } // Create a Vision request with completion handler let request = VNCoreMLRequest(model: model) { [weak self] request, error in guard let results = request.results as? [VNClassificationObservation] else { return } let topResults = results[0..<5] // Update UI on main queue DispatchQueue.main.async { [weak self] in self?.answerLabel.text = topResults .map { "\(Int($0.confidence * 100))% \($0.identifier)" } .joined(separator: "\n") } } // Run the Core ML classifier on global dispatch queue let handler = VNImageRequestHandler(ciImage: image) DispatchQueue.global(qos: .userInteractive).async { do { try handler.perform([request]) } catch { print(error) } }
  5. // Load the ML model through its generated class guard

    let model = try? VNCoreMLModel(for: CarClassifier().model) else { fatalError("can't load Places ML model") } // Create a Vision request with completion handler let request = VNCoreMLRequest(model: model) { [weak self] request, error in guard let results = request.results as? [VNClassificationObservation] else { return } let topResults = results[0..<5] // Update UI on main queue DispatchQueue.main.async { [weak self] in self?.answerLabel.text = topResults .map { "\(Int($0.confidence * 100))% \($0.identifier)" } .joined(separator: "\n") } } // Run the Core ML classifier on global dispatch queue let handler = VNImageRequestHandler(ciImage: image) DispatchQueue.global(qos: .userInteractive).async { do { try handler.perform([request]) } catch { print(error) } }
  6. // Load the ML model through its generated class guard

    let model = try? VNCoreMLModel(for: CarClassifier().model) else { fatalError("can't load Places ML model") } // Create a Vision request with completion handler let request = VNCoreMLRequest(model: model) { [weak self] request, error in guard let results = request.results as? [VNClassificationObservation] else { return } let topResults = results[0..<5] // Update UI on main queue DispatchQueue.main.async { [weak self] in self?.answerLabel.text = topResults .map { "\(Int($0.confidence * 100))% \($0.identifier)" } .joined(separator: "\n") } } // Run the Core ML classifier on global dispatch queue let handler = VNImageRequestHandler(ciImage: image) DispatchQueue.global(qos: .userInteractive).async { do { try handler.perform([request]) } catch { print(error) } }
  7. // Load the ML model through its generated class guard

    let model = try? VNCoreMLModel(for: CarClassifier().model) else { fatalError("can't load Places ML model") } // Create a Vision request with completion handler let request = VNCoreMLRequest(model: model) { [weak self] request, error in guard let results = request.results as? [VNClassificationObservation] else { return } let topResults = results[0..<5] // Update UI on main queue DispatchQueue.main.async { [weak self] in self?.answerLabel.text = topResults .map { "\(Int($0.confidence * 100))% \($0.identifier)" } .joined(separator: "\n") } } // Run the Core ML classifier on global dispatch queue let handler = VNImageRequestHandler(ciImage: image) DispatchQueue.global(qos: .userInteractive).async { do { try handler.perform([request]) } catch { print(error) } }
  8. Mon Dataset 41 269 images 62,63 Go La même voiture

    Les mêmes couleurs La même luminosité (très sombre) Déjà classifié par les utilisateurs
  9. Create ML Top 1 - From 1 34 % Top

    1 - From 5 91 % Top n - From n 78 %
  10. Base Merge Classes Top 1 - From 1 34 %

    37 % Top 1 - From 5 91 % 93 % Top n - From n 78 % 81 %
  11. Base Partner data Top 1 - From 1 37 %

    34 % Top 1 - From 5 93 % 89 % Top n - From n 81 % 75 %
  12. Base Partner data Partner corrected data Top 1 - From

    1 37 % 34 % 41 % Top 1 - From 5 93 % 89 % 94 % Top n - From n 81 % 75 % 84 %
  13. Inception v3 - MobileNet Inception v3 MobileNet Create ML Top

    1 - From 5 91 % 90 % 91 % Top n - From n 79 % 18 % 78 % Size 87 Mo 2.2 Mo 1.5 Mo Training time 2h41 2h38 1h50
  14. #1 Le ML c’est aussi pour vous #2 Vous avez

    déjà un dataset #3 Ne faites pas confiance aux résultats #4 Si vous ne le voyez pas, le ML non plus #5 Nettoyez vos données #6 Utilisez Create ML #7 Faites attention sur la route
  15. #1 Le ML c’est aussi pour vous #2 Vous avez

    déjà un dataset #3 Ne faites pas confiance aux résultats #4 Si vous ne le voyez pas, le ML non plus #5 Nettoyez vos données #6 Utilisez Create ML #7 Faites attention sur la route