Latest 1.0.0
Homepage https://github.com/cafielo/MNISTKit
License MIT
Platforms ios 11.0
Frameworks Foundation
Authors

256_mnistkit

MNISTKit makes it easy to deal with MNIST model.

MNISTKit is a library for digit detection with coreml model. The rise of A.I. is grounded in the success of deep learning. The “hello world” for deep learning is the MNIST model for handwritten digit recognition.

Carthage compatible
Version
License
Xcode 9.0+
iOS 11.0+
Swift 4.0+

mnist

  1. Long way to use CoreML
  2. Requirements
  3. Installation
  4. Usage
  5. Credits
  6. License

Long way to use CoreML

There are some works to implement MNIST with CoreML Framework

  • Build a model
  • Convert to mlmodel
  • Make a hand writable UIView
  • Convert hand writable view to image and resize it
  • Get pixelbuffers from resized image
  • Predict the image with mlmodel using pixelbuffer

MNISTKit makes it easy to deal with MNIST model.

Requirements

  • iOS 11.0+
  • Xcode 9.0+
  • Swift 4.0+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate MNISTKit into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'MNISTKit'
end

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Windless into your Xcode project using Carthage, specify it in your Cartfile:

github "cafielo/MNISTKit"

Run carthage update to build the framework and drag the built MNISTKit.framework into your Xcode project.

Manually

If you prefer not to use either of the aforementioned dependency managers, you can integrate MNISTKit into your project manually.


Usage

  1. Drag a UIView the desired size of your player onto your Storyboard.
  2. Change the UIView’s class in the Identity Inspector tab to MNISTDrawingView.
  3. Import MNISTKit in your ViewController.
  4. Add the following property to your ViewController.
    @IBOutlet weak var drawingView: MNISTDrawingView!
  5. Creat a MNISTModelController to predict later.
    let mnistModelController = MNISTModelController()
  6. Detect hand written digit using MNISTModelController and MNISTDrawingView.

    @IBAction func predict(_ sender: UIButton) {
    
        guard let image = drawingView.image else {
            return
        }
    
        guard let predictedNum = mnistModelController.predictNum(image: image) else {
            return
        }
    
        numLabel.text = "(predictedNum) is predicted"
    }

Example

Following code is a simple example

import UIKit
import MNISTKit

class ViewController: UIViewController {
    @IBOutlet weak var drawingView: MNISTDrawingView!
    @IBOutlet weak var numLabel: UILabel!
    let mnistModelController = MNISTModelController()

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func predict(_ sender: UIButton) {

        guard let image = drawingView.image else {
            return
        }

        guard let predictedNum = mnistModelController.predictNum(image: image) else {
            return
        }

        numLabel.text = "(predictedNum) is predicted"
    }

    @IBAction func clear(_ sender: UIButton) {
        drawingView.clear()
        numLabel.text = "???"
    }
}

Credits

License

MNISTKit is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "MNISTKit",
    "version": "1.0.0",
    "summary": "Coolest MNISTKit Ever",
    "description": "Start CoreML with MNISTKit",
    "homepage": "https://github.com/cafielo/MNISTKit",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "joonwon lee": "[email protected]"
    },
    "platforms": {
        "ios": "11.0"
    },
    "source": {
        "git": "https://github.com/cafielo/MNISTKit.git",
        "tag": "1.0.0"
    },
    "source_files": "Sources/**/*",
    "frameworks": "Foundation",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This