Photograph a Sudoku puzzle and get the solved grid as an image.
|
Input
|
Output
|
- 99.5% mAP — detection accuracy across varying conditions
- 99.9% precision — minimal false positives
- 100% recall — never misses a grid
- 99% accuracy — correct digit on first prediction
- 100% top-5 — correct answer always in top 5 predictions
- Printed and handwritten puzzles
- Varying lighting and exposure
- Skewed camera angles
- Any paper color or background
YOLOv8 Nano object detection trained on 500+ images from Roboflow.
Training Results
|
Training Curves |
Precision-Recall Curve |
|
Confusion Matrix |
Validation Predictions |
YOLOv8 Nano classifier trained on 4,400+ cell images to recognize digits 1-9 and empty cells.
Training Results
|
Training Curves |
Confusion Matrix |
|
Validation Samples
|
|
- Detect — YOLOv8 locates the Sudoku grid in your photo
- Warp — OpenCV corrects perspective to create a perfect square
- Split — Grid is divided into 81 individual cells
- Recognize — YOLOv8 classifier identifies each digit
- Solve — Constraint propagation + backtracking finds the solution
- Render — Solution is drawn onto a clean grid image
Narrows down options dynamically before solving via depth-first search. Dynamic approach, narrow down options, then depth-first search
-
Constraint Propagation — Eliminates impossible values by checking rows, columns, and 3x3 blocks. Solves most puzzles without guessing.
-
Backtracking(DFS) — For harder puzzles, recursively tries possibilities and backtracks on invalid states. Guarantees a solution if one exists.
Solves any valid Sudoku in under 100ms.
backend/
├── sudoku_detector/ # Computer vision pipeline
│ ├── services/ # Detection, warping, recognition
│ ├── training/ # Model training scripts
│ └── models/ # Trained weights (.pt files)
├── sudoku_solver/ # Solving algorithms
└── sudoku_display/ # Solution rendering
# Clone the repo
git clone https://github.com/yourusername/cv-sudokusolver.git
cd cv-sudokusolver
# Install dependencies
pip install -r requirements.txt
# Run on an image
cd backend
python -c "import cv2; from main import solve_sudoku_image; solve_sudoku_image(cv2.imread('path/to/sudoku.jpg'))"Output is saved to solved_sudoku.jpg.








