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

Pragmatic Machine Learning for mobile apps

Khoa Pham
November 06, 2019

Pragmatic Machine Learning for mobile apps

Khoa Pham

November 06, 2019
Tweet

More Decks by Khoa Pham

Other Decks in Technology

Transcript

  1. Agenda • Deep Learning • Layer in Neural Network •

    Activation Functions • Training in Neural Network • Loss, Learning Rate • Train, Test & Validation Sets • Predicting • Overfitting
  2. Agenda (cont) • Convolutional Neural networks & visualizing • Zero

    padding, max pooling • Explain back propagation • Vanishing & Exploding Gradient • Weight Initialization & Bias • Learnable parameters • Regularizationm, batch size, fine tuning and batch normalization
  3. CoreML • Computer Vision: image classification • Natural Language: language

    idenification, tokenization • Speech: speech recognition
  4. Image classification Preprocess photos using the Vision framework and classify

    them with a Core ML model. iOS app Avengers https:/ /github.com/onmyway133/avengers
  5. Tools • IBM Watson • Azure Custom Vision • Google

    AutoML • Firebase Vision Edge • CreateML • Turi Create
  6. IBM Watson Visual Recognition - Watson SDK let classifierID =

    "your-classifier-id" let failure = { (error: Error) in print(error) } visualRecognition.updateLocalModel(classifierID: classifierID, failure: failure) { print("model updated") }
  7. CoreML + Vision let model = try VNCoreMLModel(for: IBMWatson().model) let

    request = VNCoreMLRequest(model: model, completionHandler: { request, error in let results = request.results as? [VNClassificationObservation], let handler = VNImageRequestHandler(cgImage: image.cgImage!, options: [:]) try handler.perform([request])
  8. Turi Create - SFrame import turicreate as tc import os

    # 1. Load images data = tc.image_analysis.load_images('dataset', with_path=True) # 2. Create label column based on folder name data['hero_name'] = data['path'].apply(lambda path: os.path.basename(os.path.dirname(path))) # 3. Save as .sframe data.save('turi.sframe') # 4. Explore data.explore()
  9. Turi Create - Training import turicreate as tc # 1.

    Load the data data = tc.SFrame('turi.sframe') # 2. Split to train and test data train_data, test_data = data.random_split(0.8) # 3. Create model model = tc.image_classifier.create(train_data, target='hero_name') # 4. Predictions predictions = model.predict(test_data) # 5. Evaluate the model and show metrics metrics = model.evaluate(test_data) print(metrics['accuracy']) # 6. Save the model model.save('turi.model') # 7. Export to CoreML format model.export_coreml('model/TuriCreate.mlmodel')
  10. Writing • Machine Learning in iOS: IBM Watson and CoreML

    • Machine Learning in iOS: Azure Custom Vision and CoreML • Machine Learning in iOS: Turi Create and CoreML • Vision in iOS: Text detection and Tesseract recognition