Giter Club home page Giter Club logo

imnist's Introduction

iMNIST

iMNIST is a iOS app that recognizes the digits you draw using a trained TensorFlow NN.

How to intall it?

Requirements :

  • Xcode 8
  • A device or simulator under iOS 10.
  • Accelerate is needed for that app. We need one of its subset called BNNS. Make sure it is imported in Targets -> iMNIST -> General -> Linked frameworks and libraries.

Clone the repo, open it in Xcode and sign it with your own developer profile.

Nota bene : The code was written following the Swift 3 syntax.

How does it work ?

UI

Here is a capture from the app :

  • The user draws a figure between the two lines.
  • He presses the compute button and the app will try to guess what figure was drawn.
  • The drawn figure disappears.

In-depth

To achieve this simple functionnality the following steps are necessary.

Prior to app launch :

  • Export the weights and biases from the MNIST simple model from TensorFlow website. They appear in the app Bundle as "weights.data" and "bias.data".

The user draws on the screen.

  • Convert the user drawing to an UIImage.
  • Create a 28*28 grayscale representation of that UIImage (to be compliant with MNIST requirements).
  • Convert that UIImage to a normalized vector representation of the pixels values (they must be between 0 and 1).
  • Import the data from "weights.data" and "bias.data" and parse it.
  • Build a BNNS model from the biases, the weights and the input data.
  • Apply the BNNS filter gives us a vector of 10 real values.
  • Apply Softmax to the ouput vector gives us a normalized version of that vector.
  • Output the highest value and show the guessed figure to the user.

Where to go from here ?

This project was made in an attempt to do inference from a TensorFlow model on an iOS device using Apple's BNNS. The motivation for using it: BNNS processing is optimized for iOS devices CPUs.
There is no back-propagation with BNNS though, you'll need to train the model on a server and import the weights and biases. A pipeline with push notifications to download the new model seems relevant.

Other solutions exists to do this on iOS:

imnist's People

Contributors

kpitolin avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.