Ai Sudoku Solver is a simple program to solve sudoku using computer vision and neural networks. you can simply give an image of sudoku to it and it return an array of completed sudoku.
We have three important components:
- Computer vision to extract empty cells and numbers in the given image
- CNN to recognize each number in the image
- csp (constraint satisfaction problem) solver to complete sudoku
NOTE:
- This project is developed for fun and learning only, it may have bugs.
- The computer vision component is not the best implementation, I'll try and hopefully fix this.
- For now,
keep in mind
that the input image only contains the sudoku table And I recommend that the rows and columns of the table are not distorted.
in this model i used MNIST and printed digit dataset.
-
All images are in assets
-
Folder model contains a pretrained CNN model trained on MNIST (on 20 epochs with batch size 10) and printed digit dataset (on 10 epochs with batch size 10).
-
Folder csp is a helper to convert sudoku map (np.array with shape 9*9) to constraints satisfied problem and solve this.
-
Folder img contains some input image to test the model.
-
File main.py
after download or clone repository go to project directory:
git clone https://github.com/momoein/Ai_sudoku_solver.git
cd Ai_sudoku_solver
pip install -r requirements.txt
windows:
py main.py
linux:
python3 main.py
after run open the browser and search this URL:
http://127.0.0.1:7860
in this example used img/sudoku2.jpg