https://github.com/chrisdalvit/sudoku-solver
Just another real-time Sudoku solver coded in Python using OpenCV and PyTorch.
https://github.com/chrisdalvit/sudoku-solver
opencv opencv-python python pytorch sudoku sudoku-solver
Last synced: 4 months ago
JSON representation
Just another real-time Sudoku solver coded in Python using OpenCV and PyTorch.
- Host: GitHub
- URL: https://github.com/chrisdalvit/sudoku-solver
- Owner: chrisdalvit
- Created: 2024-03-11T11:28:28.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-12-16T20:42:31.000Z (over 1 year ago)
- Last Synced: 2025-12-07T13:50:23.765Z (6 months ago)
- Topics: opencv, opencv-python, python, pytorch, sudoku, sudoku-solver
- Language: Python
- Homepage: https://chrisdalvit.github.io/sudoku-solver
- Size: 2.13 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sudoku Solver
Just another real-time Sudoku solver coded in Python using OpenCV and PyTorch. Capable of tackling Sudoku puzzles in images and videos, and projecting the solutions back onto the original visuals.
## Setup
After cloning the repository install the dependencies by running
```
pip install -r requirements.txt
```
If you just want to execute ``main.py`` you're good to go, as it comes with a pre-trained neural network for digit classification provided in ``model_file.pt``.
Run the following command to verify that the setup is completed. The solved Sudoku should be displayed in a new window
```
python main.py -i ./images/sudoku_photo.jpg
```
If you want to retrain the neural network for digit classification you need to download the [dataset](https://www.kaggle.com/datasets/kshitijdhama/printed-digits-dataset?resource=download) from Kaggle. Unzip the downloaded folder, rename it to ``archive`` and paste it into the project directory. Alternatively, you can store the unzipped folder in a directory of your choice and update the path in the ``ASSETS_PATH`` variable within ``classifier/dataset.py``. Now you should be ready to retrain the neural network using the ``classifier.ipynb`` notebook.
## Usage
For solving a Sudoku puzzle in an image use
```
python main.py -i
```
The puzzle with the projected solution should be displayed in an new window.
For solving a Sudoku puzzle from a videocamera use
```
python main.py -v
```
The video stream should be displayed in an new window. Optionally you can pass a device index (integer) to the ``-v`` argument used by OpenCV for camera selection.
## Credits
The dataset used in this project was published by Kshitij Dhama on Kaggle.