chessai-data / README.md
vietanhdev's picture
docs: rewrite dataset card with verified stats, classes, COCO usage example
5e2f58e verified
|
Raw
History Blame Contribute Delete
3.17 kB
---
pretty_name: ChessAI Data Chinese Chess Piece Detection
language:
- vi
size_categories:
- 1K<n<10K
task_categories:
- object-detection
tags:
- chess
- chinese-chess
- xiangqi
- co-tuong
- object-detection
- bounding-box
- anylabeling
authors:
- Viet-Anh Nguyen
---
# ChessAI Data — Chinese Chess Piece Detection
A bounding-box detection dataset for **Chinese Chess** (Cờ tướng / 象棋), labeled with [AnyLabeling](https://github.com/vietanhdev/anylabeling). Built to train piece-recognition models for chessboard-state extraction from photos.
## Dataset summary
- **Total annotated images:** 1,747 (per-image AnyLabeling JSON in `data/combined_data/`)
- **COCO-format split:** 872 images, 18,790 bounding boxes (`data/annotations.json`)
- **Classes:** 7 (the standard Xiangqi piece set)
- **Total size:** ~280 MB (images + annotations)
## Classes
Vietnamese piece names are used throughout. Counts below are from the COCO split.
| ID | Label (VN) | Piece | Boxes |
|---|---|---|---|
| 1 | `xe` | Chariot (rook) | 2,264 |
| 2 | `ma` | Horse (knight) | 2,357 |
| 3 | `tuong` | Elephant (bishop-like)| 2,350 |
| 4 | `si` | Advisor (palace guard)| 2,375 |
| 5 | `vua` | General (king) | 1,244 |
| 6 | `phao` | Cannon | 2,369 |
| 7 | `tot` | Soldier (pawn) | 5,831 |
## Files
- **`data/combined_data/`** — paired `.jpg` + `.json` files in [labelme](https://github.com/wkentaro/labelme) / AnyLabeling format. Each `.json` has a `shapes[]` array with `label`, `points` (top-left and bottom-right corners), and `shape_type: "rectangle"`.
- **`data/annotations.json`** — COCO-format export covering 872 images and 18,790 boxes, ready for use with detection libraries that expect COCO.
- **`data/data_01/`, `data/data_02/`** — raw images grouped by capture session.
- **`make_data.sh`** — pipeline that produces the COCO export from the raw + per-image annotation pairs.
## Quick start — load the COCO split
```python
from huggingface_hub import hf_hub_download
import json
path = hf_hub_download(
repo_id="vietanhdev/chessai-data",
filename="data/annotations.json",
repo_type="dataset",
)
with open(path) as f:
coco = json.load(f)
print(len(coco["images"]), "images,", len(coco["annotations"]), "boxes")
print("classes:", [c["name"] for c in coco["categories"]])
```
To download images alongside, use `snapshot_download` with `allow_patterns=["data/combined_data/*"]`.
## Reproducing the dataset
```bash
conda create -n chessai-dataprep python=3.9
conda activate chessai-dataprep
pip install -r requirements.txt
# After labeling raw images in data/data_01 and data/data_02 with AnyLabeling:
bash make_data.sh
```
## Source code
Upstream repo with preprocessing scripts: <https://github.com/nrl-ai/chessai-data>
## Citation
```bibtex
@misc{nguyen2024chessai,
author = {{Viet-Anh NGUYEN (Andrew)}},
title = {ChessAI Data — Chinese Chess piece detection dataset},
year = {2024},
publisher = {Hugging Face},
doi = {10.57967/hf/2812},
url = {https://huggingface.co/datasets/vietanhdev/chessai-data}
}
```