Skip to main content

CNN-based chess piece classifier

Project description

Chess CV

GitHub release Python 3.13+ License: MIT

Model Architecture

CNN-based chess piece classifier


A machine learning project that trains a lightweight CNN (156k parameters) from scratch to classify chess pieces from 32×32 pixel square images. The model achieves ~95-97% accuracy on synthetic training data generated by combining 55 board styles (256×256px) with 64 piece sets (32×32px) from chess.com and lichess.

By rendering pieces onto different board backgrounds and extracting individual squares, the model learns robust piece recognition across various visual styles.

⚡️ Quick Start

pip install chess-cv

Then use pre-trained models:

from chess_cv.model import SimpleCNN
from huggingface_hub import hf_hub_download

# Load pre-trained model
model_path = hf_hub_download(repo_id="S1M0N38/chess-cv", filename="best_model.safetensors")
model = SimpleCNN(num_classes=13)
model.load_weights(model_path)

# Make predictions
predictions = model(image_tensor)

✨ Features

🪶 Lightweight Architecture

  • 156k parameter CNN optimized for 32×32px images
  • 13-class classification (6 white pieces, 6 black pieces, 1 empty)
  • MLX framework for efficient training
  • Aggressive data augmentation for robust generalization

🏗️ Complete Pipeline

  • Synthetic data generation from board/piece combinations
  • Training with early stopping and checkpointing
  • Comprehensive evaluation with confusion matrices
  • Optional Weights & Biases integration for experiment tracking
  • Hugging Face Hub deployment for model sharing

📚 Documentation

For detailed documentation, visit s1m0n38.github.io/chess-cv or explore:

License

This project is licensed under the MIT License – see the LICENSE file for details.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chess_cv-0.1.1.tar.gz (3.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chess_cv-0.1.1-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file chess_cv-0.1.1.tar.gz.

File metadata

  • Download URL: chess_cv-0.1.1.tar.gz
  • Upload date:
  • Size: 3.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.23

File hashes

Hashes for chess_cv-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a556c2654a916ce8cb5877ab193f7864f95d41262a5eda2694979715163e968f
MD5 0481bfab5dd48935ae4e1a82657793bc
BLAKE2b-256 771abb42abbbc6477b16cf39dd9f597fa8c91b4770e21381a229d940bc368e3c

See more details on using hashes here.

File details

Details for the file chess_cv-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: chess_cv-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.23

File hashes

Hashes for chess_cv-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4fd492bf1c71ce7caf3198e71a53e5f169d65403fba87a180f8c487908a9d183
MD5 c69aa44585ba3181edf3bcd65fdea90a
BLAKE2b-256 e205095be96d69814eaf5e08e4a2bd8f2f23ce053385d4e36f622299cd7d123a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page