Deep Sudoku Solver Save

A Sudoku Solver that leverages TensorFlow and iOS BNNS for deep learning.

Project README

Deep Sudoku Solver

A Sudoku Solver that leverages TensorFlow and BNNS of iOS 10 SDK for deep learning.

Usage

  1. Add a picture of sudoku puzzle from the photo library.
  2. Import the picture into a puzzle.
  3. Edit any digits not correctly predicted.
  4. Solve the puzzle.
  5. Save the solution to the photo library or share it to SNS or other apps.

Development

The steps below illustrate how to prepare your own training data for TensorFlow and use the training results for prediction in BNNS of iOS 10 SDK.

Exporting Models from TensorFlow

I use the Chars74K image dataset for training. My trained models are in the folder Assets.xcassets with the filename model-h#[b|w]-*.dataset. To train your own models, follow the steps below.

  1. Resize your images to dimension of 28x28.
  2. Label your images and split them into training and testing data.
  3. Convert your data into the MNIST format using JPG-PNG-to-MNIST-NN-Format
  4. Install TensorFlow
  5. Put your data [train|test]-[images|labels]-idx[1|3]-ubyte.gz in the scripts folder.
  6. Run mnist-predict-from-model.py to get the models.
  7. Import the models to the Asset Catalog in XCode.

Predicting Labels from Images Using BNNS

  1. Add the following files to your project.
  1. Use the following script for prediction.
let magic = ImageMagic()
let ai = MnistNet()
guard let data = magic.mnistData(image: UIImage)
    else {
        return
}
let predicted: Int = ai.predict(input: data)
// Process your predicted label

Refer to the function importSudoku() in ViewController.swift for a full example.

Credit

I reused soruce code and configurations from:

Open Source Agenda is not affiliated with "Deep Sudoku Solver" Project. README Source: waitingcheung/deep-sudoku-solver

Open Source Agenda Badge

Open Source Agenda Rating