Giter Site home page Giter Site logo

waitingcheung / deep-sudoku-solver Goto Github PK

View Code? Open in Web Editor NEW
32.0 3.0 8.0 11.65 MB

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

Swift 95.74% Python 4.26%
tensorflow bnns deep-learning deep-neural-networks ios ios-app ios-swift ios10 ios-demo ios-tutorial

deep-sudoku-solver's Introduction

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:

deep-sudoku-solver's People

Contributors

waitingcheung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

deep-sudoku-solver's Issues

Question about getting models

Hi,

I am trying to train my own models, but your py file (mnist-predict-from-model.py) is asking models from BNNS-Model directory.
I am confusing about this.

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.