Compatibility
- 1.0.0 and master5.35.25.15.04.2
- 1.0.0 and masteriOSmacOS(Intel)macOS(ARM)LinuxtvOSwatchOS
The better way to deal with MNIST model and Core ML in iOS
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.
There are some works to implement MNIST with CoreML Framework
MNISTKit makes it easy to deal with MNIST model.
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 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.
If you prefer not to use either of the aforementioned dependency managers, you can integrate MNISTKit into your project manually.
MNISTDrawingView
.MNISTKit
in your ViewController. @IBOutlet weak var drawingView: MNISTDrawingView!
MNISTModelController
to predict later.let mnistModelController = MNISTModelController()
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"
}
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 = "???"
}
}
MNISTKit is released under the MIT license. See LICENSE for details.