OCR tool to extract FEN from chessboard screenshots. Solves a personal problem, so:
this is still a work in progress!
Current model available under release is only a demo model, I'm still tweaking the official one. Still need to clean a lot of things up and work on speedup, maybe have a daemon running in the background to keep the model loaded.
This project uses chessboard and piece artwork from Lichess.org, which is licensed under CC-BY-SA 3.0.
The images were used to generate training data for the OCR model.
dataset/get-pieces.py and dataset/get-boards.py pull the pieces/boards respectively. generate-dataset.py does some augmentation and combines pieces and boards to the full dataset.
This mainly solves a personal problem I have, but the model output can be used for other purposes as well. Main idea:
- Have some chess book/pdf open. Run the tool and select the board of the puzzle you want to play
- Model detects board state and puts that in FEN notation into clipboard
- Paste into any board editor of your choice (like https://lichess.org/editor) and paste it
- Play it!
Position from J.Babson, 1882. Mate in one move, in 47 different ways
There's currently two ways to use this. You can just get the binary file from, put that on your path and be good to go. This packages only the pix2fen-clipboard functionality. If you want the full inference + dataset stuff, you have to install the dependencies via pip.
pip install -e .then just run
pix2fen-clipboardset it to some shortcut if you want. Currently for Wayland, adapt as needed.
Linux only currently.
I used pix2tex as inspiration, which I use daily at Uni. Does the same thing but with equations -> Latex (and much better)
