CleverCell, a Sudoku solver, takes input as an image, solves the puzzle, and displays the result directly on the original puzzle interface.
- Programming Language :
Python
- Machine Learning :
Tensorflow
andKeras
(For digit recognition) - Libraries :
Numpy
(for array processing) andOpenCV
(for image processing)
Clone the project
git clone https://github.com/Vishvam10/AI-Sudoku-Solver.git
Go to the project directory
cd my-project
Create a virtual environment in the project folder
python3 -m venv /path/to/new/virtual/environment
Activate the virtual environment
.\venv\Scripts\activate
NOTE : Please visit this link to know more about installing virtual environments
Install the dependencies using pip
pip install - r requirements.txt
Run the program with default options. Add the -d
to run the program in debug
mode and -i
to specify the image path
python app.py -i "./Testing_Images/pass_1.jpg" -d
- ✅ Solves sudoku of any difficulty
- ✅ Works on any type of image (
.png
,.jpg
, etc.) - ✅ Automatic rescaling and resizing
- ✅ Errors for unsolvable problems
-
One main thing would be to make it real time. The code for it is pretty straight-forward. All we need to do is pass the captured frame as the image input. Something like this :
cap = cv2.VideoCapture(0) fourcc = cv2.VideoWriter_fourcc(*'XVID') flag = 0 while(True) : ret, img = cap.read() . .
While doing so, we need to proceed with the ML model only when the sudoku board is identified. And for that, a hard-coded value of image dimensions would not work. I've experimented with realtime but the results were not satisfactory (either the digits were recognized incorrectly or the board was not getting identified). There are ways to mitigate these issues and optimize the whole program. These could be implemented in the near future.
-
Improving the ML model : Currently, there are a few cases where 1 or digits are misclassified, which is generally accepted to be normal. But in the case of a sudoku, even 1 misclassification can alter the problem. For example, the image located
./Testing_Images/fail_1.png
fails due to this exact problem :