Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Solves a Sudoku in Python using OpenCV & Deep Learning.

---> Live Demo:

This repository includes the following:

  • Image processing
  • Sudoku grid recognition
  • Grid extraction
  • Number prediction using Convolutional Neural Network-model (with 99% accurancy)
  • Recursive Sudoku-solver
  • Flask web frontend (based on the Pixel-Lite boilerplate:

The number prediction is based on a CNN-model that was trained with the Chars74K-dataset:


  • switch to tflite-model
  • integrate web frontend
  • recognize major grid based on area ratio of whole picture (e.g. when area of contour is at least 60% of whole picture and has at least 4 edges it is most likely the major grid)
  • consider session-based image processing
  • integrate demo-files in frontend
  • finalize code structure
  • clean unused boilerplate files

If endless time would be available

  • re-train CNN with more data
  • test with more different Sudoku-puzzles
  • consider handwritten numbers
  • detect other puzzle sizes than 9x9


Run as local webserver

  • Download Python 3.8.x (TensorFlow requires Python 3.8.x)
  • Clone repository to a local directory
  • create a new virtual environment py -3.8 -m venv name_of_your_virtualenv_here
  • run pip install -r requirements.txt
  • in enable and execute
  • open your webbrowser and go to

Create Docker image

  • Open CLI (Command Line Interface)
  • Change into directory of repository
  • run docker build --tag pydoku_app .
  • run docker run --detach -p 80:80 pydoku_app
  • open your webbrowser and go to localhost


What are the minimum requirements?

The Sudoku should be a 9x9 Sudoku. Other types of Sudokus are not supported at the moment. The photo should have at least 8MP. The photo should clearly show a Sudoku with all borders.

Why can my Sudoku not be solved?

This can have several reasons. It could be that it wasn't possible to detect the Sudoku itself in the photo. This can happen due to bad image quality.

What happens to the file I have uploaded?

This service is designed to process the image file on the fly. Files uploaded are not stored on the server.

I've tried to solve the Sudoku. What about the numbers I have written into the boxes?

Hand written numbers are not recognized properly. The app can be extended by integrating a second AI-model which could recognize hand-written numbers.

Why does this exists at all?

Actually, to find a solution for a Sudoku is the fun a Sudoku has to offer. Therefor, offering a service that eliminates the fun by offering an automatic solution doesn't make much sense. But, this app is a pet project of mine that did teach me several technologies a long the way. So, the whole purpose of this app was to provide me obstacles I had to overcome.




Solves a Sudoku in Python using OpenCV & Deep Learning.








No releases published


No packages published