All Projects → hollance → Tensorflow Ios Example

hollance / Tensorflow Ios Example

Source code for my blog post "Getting started with TensorFlow on iOS"

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Tensorflow Ios Example

Machine Learning With Python
Python code for common Machine Learning Algorithms
Stars: ✭ 3,334 (+671.76%)
Mutual labels:  logistic-regression
Ios 10 Sampler
Code examples for new APIs of iOS 10.
Stars: ✭ 3,341 (+673.38%)
Mutual labels:  metal
Braincore
The iOS and OS X neural network framework
Stars: ✭ 375 (-13.19%)
Mutual labels:  metal
Metalscope
Metal-backed 360° panorama view for iOS
Stars: ✭ 293 (-32.18%)
Mutual labels:  metal
Colormap Shaders
A collection of shaders to draw color maps.
Stars: ✭ 315 (-27.08%)
Mutual labels:  metal
Machine learning basics
Plain python implementations of basic machine learning algorithms
Stars: ✭ 3,557 (+723.38%)
Mutual labels:  logistic-regression
Waifu2x Mac
Waifu2x-ios port to macOS, still in Core ML and Metal
Stars: ✭ 258 (-40.28%)
Mutual labels:  metal
Fiber2d
Cross-platform 2D Game Engine in pure Swift
Stars: ✭ 415 (-3.94%)
Mutual labels:  metal
React Mic
Record audio from a user's microphone and display a cool visualization.
Stars: ✭ 323 (-25.23%)
Mutual labels:  voice-recognition
Water
Simple calculation to render cheap water effects.
Stars: ✭ 372 (-13.89%)
Mutual labels:  metal
Liblinear Java
Java version of LIBLINEAR
Stars: ✭ 298 (-31.02%)
Mutual labels:  logistic-regression
Ultralight
Next-generation HTML renderer for apps and games
Stars: ✭ 3,585 (+729.86%)
Mutual labels:  metal
Ytk Learn
Ytk-learn is a distributed machine learning library which implements most of popular machine learning algorithms(GBDT, GBRT, Mixture Logistic Regression, Gradient Boosting Soft Tree, Factorization Machines, Field-aware Factorization Machines, Logistic Regression, Softmax).
Stars: ✭ 337 (-21.99%)
Mutual labels:  logistic-regression
Fuku Ml
Simple machine learning library / 簡單易用的機器學習套件
Stars: ✭ 280 (-35.19%)
Mutual labels:  logistic-regression
Cheetah
On-device streaming speech-to-text engine powered by deep learning
Stars: ✭ 383 (-11.34%)
Mutual labels:  voice-recognition
Metalfilters
Instagram filters implemented in Metal
Stars: ✭ 272 (-37.04%)
Mutual labels:  metal
Dota2 Predictor
Tool that predicts the outcome of a Dota 2 game using Machine Learning
Stars: ✭ 332 (-23.15%)
Mutual labels:  logistic-regression
Rizz
Small C game development framework
Stars: ✭ 428 (-0.93%)
Mutual labels:  metal
Rhino
On-device speech-to-intent engine powered by deep learning
Stars: ✭ 406 (-6.02%)
Mutual labels:  voice-recognition
Hey Athena Client
Your personal voice assistant
Stars: ✭ 336 (-22.22%)
Mutual labels:  voice-recognition

TensorFlow on iOS demo

This is the code that accompanies my blog post Getting started with TensorFlow on iOS.

It uses TensorFlow to train a basic binary classifier on the Gender Recognition by Voice and Speech Analysis dataset.

This project includes the following:

  • The dataset in the file voice.csv.
  • Python scripts to train the model with TensorFlow on your Mac.
  • An iOS app that uses the TensorFlow C++ API to do inference.
  • An iOS app that uses Metal to do inference using the trained model.

Training the model

To train the model, do the following:

  1. Make sure these are installed: python3, numpy, pandas, scikit-learn, tensorflow.
  2. Run the split_data.py script to divide the dataset into a training set and a test set. This creates 4 new files: X_train.npy, y_train.npy, X_test.npy, and y_test.npy.
  3. Run the train.py script. This trains the logistic classifier and saves the model to /tmp/voice every 10,000 training steps. Training happens in an infinite loop and goes on forever, so press Ctrl+C when you're happy with the training set accuracy and the loss no longer becomes any lower.
  4. Run the test.py script to compute the accuracy on the test set. This also prints out a report with precision / recall / f1-score and a confusion matrix.

Using the model with the iOS TensorFlow app

To run the model on the iOS TensorFlow app, do the following:

  1. Clone TensorFlow and build the iOS library.
  2. Open the VoiceTensorFlow Xcode project. In Build Settings, Other Linker Flags and Header Search Paths, change the paths to your local installation of TensorFlow.

The model is already included in the app as inference.pb. If you train the model with different settings, you need to run the freeze_graph and optimize_for_inference tools to create a new inference.pb.

Using the model with the iOS Metal app

To run the model on the iOS Metal app, do the following:

  1. Run the export_weights.py script. This creates two new files that contain the model's learned parameters: W.bin for the weights and b.bin for the bias.
  2. Copy W.bin and b.bin into the VoiceMetal Xcode project and build the app.

You need to run the Metal app on a device, it won't work in the simulator.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].