Skip to main content

chessvision ♟️

CI python

uv ruff ty

A fast, lightweight chess board and piece recognition toolkit.

chessvision demo


Install

# With uv (recommended)
uv tool install chessvision

# With pipx
pipx install chessvision
# As a library
uv add chessvision

# or
pip install chessvision

Usage

CLI

# Predict chess position on a full board image
chessvision board chessboard.png

# Predict a single square image
chessvision square square.png

Python API

from chessvision import BoardPredictor, Castling, Orientation, PieceClassifier

# 1. Full Board Recognition
predictor = BoardPredictor()
prediction = predictor.predict(
    "chessboard.png", orientation=Orientation.WHITE, castling=Castling.ALL
)

print(prediction.render_board)
print(f"FEN: {prediction.fen}")
print(f"Confidence: {prediction.confidence:.2%}")

# 2. Single Square Classification
classifier = PieceClassifier()
square_prediction = classifier.predict_square("square.png")
print(f"{square_prediction.label} [{square_prediction.confidence:.2%}]")

# 3. Batch Squares Classification
batch_predictions = classifier.predict_squares(["e4.png", "e5.png"])
for prediction in batch_predictions:
    print(f"{prediction.label} [{prediction.confidence:.2%}]")

CLI Subcommands

chessvision board

Flag Short Default Description
--orientation -o white Board perspective (white or black).
--castling -c - Castling availability (see castling options).

Castling Options

Value Description
- No castling for both sides (default)
KQkq Both sides can castle both sides
KQ White can castle both sides
kq Black can castle both sides
K White can castle kingside only
Q White can castle queenside only
k Black can castle kingside only
q Black can castle queenside only
# Specify board perspective (white or black orientation)
chessvision board chessboard.png --orientation black
chessvision board chessboard.png -o black

# Specify castling availability
chessvision board chessboard.png --castling KQkq
chessvision board chessboard.png -c KQ

chessvision square

# Predict piece on a square image
chessvision square square.png

square prediction demo


Model & Cache Management

chessvision automatically downloads the pre-trained ONNX piece classifier (chess_piece_classifier.onnx) from Hugging Face on its first run and caches it locally:

Default File Paths

OS Cache Path
Linux ~/.cache/chessvision/chess_piece_classifier.onnx
macOS ~/Library/Caches/chessvision/chess_piece_classifier.onnx
Windows %LOCALAPPDATA%\chessvision\Cache\chess_piece_classifier.onnx

Attributions

Training assets were extracted, and preprocessed from Lichess open-source piece sets and board themes (see their COPYING.md for individual asset licenses).


License

This project is licensed under the MIT License.

Download files

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

Source Distribution

chessvision-0.3.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

chessvision-0.3.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file chessvision-0.3.0.tar.gz.

File metadata

  • Download URL: chessvision-0.3.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.4 {"installer":{"name":"uv","version":"0.12.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for chessvision-0.3.0.tar.gz
Algorithm Hash digest
SHA256 98ecc0c757032921f27c20d31de27a5a776fa5c0a5672122b00a2c5739cb4e07
MD5 06a9f2423de3846f978d0d510349ae51
BLAKE2b-256 6f829f6bcbfed57732c8b353a5a6dabefc795690d4547ed8ca1b410bd1f5f4df

See more details on using hashes here.

File details

Details for the file chessvision-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: chessvision-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.4 {"installer":{"name":"uv","version":"0.12.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for chessvision-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd8fb27c16b0ed6a9e1ab5e4c4772b9c82c3263a7b3072949dae6dcae987186f
MD5 7d9f2e317e88fe5f2b6dbf495ab13fd5
BLAKE2b-256 9a1699e1dffad3e830dadadfc9a9d59a699f39773cdf63984eab18a19c85d440

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.0

2 files

This release

0.3.0 This release

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page