Skip to main content

CNN-based chess piece classifier using MLX for Apple Silicon

Project description

Chess CV

GitHub release Python 3.13+ License: MIT

Model Architecture

CNN-based chess piece classifier


Overview

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.0.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.0-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chess_cv-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 34f87d3a377382b29b23bf6226f799cf2d2fe66f8191eb1826173855f1176a8f
MD5 f96aee65a2fd9937658e3ff5c4e45b45
BLAKE2b-256 62eaa71d82a194d261e36394412d8cf932a1f582ffc12fec790dab0595b212b1

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for chess_cv-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb5bc3afa0e58436869d468becd4e32df4956f2695383bfaad6360dd31d6780a
MD5 5111ae98a508ca1ab35cf40e8f133b96
BLAKE2b-256 8d5cd3f7e43b9bdebad065f54563ebe57fe204df14dc1534aa1cc2ec06768255

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