Giter VIP home page Giter VIP logo

chessvisionai's Introduction

Chess Vision AI

Chess Vision AI is a project aimed at extracting the state of a chessboard from a screenshot using a trained AI model. This project is part of my training on AI, and it achieves an accuracy of 99.8% in classifying chessboard squares. As long as the chessboard is the default one on chess.com. For now.

The model is trained using transfer learning from MobileNetV2 and can classify the state of a chessboard with high accuracy.

demo

Usage

Generate a dataset

Run the datagen.ipynb notebook to generate a dataset from the pieces & board in the data directory. It took my Intel CPU 20 minutes to generate roughly 10k images / piece.

The data is the default board & pieces found on chess.com.

Train the model

Run the train.ipynb notebook to train the model on the generated dataset. The last cell will evaluate the model's performances on the test dataset.

Took just over an hour to train on my Intel CPU thanks to transfer learning from MobileNetV2 (might be better performing pretrained ImageNet models out there).

Test

Run the predict_board.ipynb to test it against a screenshot.

Can also test indivual squares and debug the model in the infer.ipynb.

Detect chessboard from a larger image

This project enhances the original model to detect and extract a chessboard from any screenshot, even if the image contains other elements or the chessboard is rotated. This solution leverages and improves upon an existing project called tensorflow_chessbot, which implemented chessboard squares detection.

Key Enhancements:

  • Rotation Detection and correction: Integrated a rotation detection mechanism to ensure the chessboard is correctly aligned before detection, mitigating issues with skewed images.
  • Code Modernization: Updated the code to work with the latest versions of TensorFlow (2.x) and SciPy.
  • Improved Image Quality: Applied bicubic interpolation during image rotation to reduce aliasing and improve the visual quality of the rotated images.
  • Code Cleanup: Refactored and cleaned up the code for better readability and maintainability.

Usage:

To use the enhanced chessboard detection, run the detect_chessboard.ipynb notebook. This notebook demonstrates how to detect and extract a chessboard from a larger image, handling various orientations and image sizes.

This project aims to provide a more robust and user-friendly solution for chessboard detection in real-world scenarios.

Next

In the future, I plan to train the model on more boards and pieces. Currently, the model performs poorly on chessboards from Lichess. Extending the training data to include various board styles should improve performance across different platforms.

chessvisionai's People

Contributors

coriou avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.