S1M0N38 commited on
Commit
2ca5f55
·
verified ·
1 Parent(s): df9ca5a

feat: upload new model version

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ augmentation_example.png filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ library_name: mlx
4
+ tags:
5
+ - computer-vision
6
+ - image-classification
7
+ - chess
8
+ - cnn
9
+ - lightweight
10
+ datasets:
11
+ - synthetic-chess-squares
12
+ model-index:
13
+ - name: chess-cv
14
+ results:
15
+ - task:
16
+ type: image-classification
17
+ name: Image Classification
18
+ dataset:
19
+ name: Chess CV Test Dataset
20
+ type: chess-cv-test
21
+ metrics:
22
+ - type: accuracy
23
+ value: 0.9985
24
+ name: Accuracy
25
+ verified: false
26
+ - type: f1
27
+ value: 0.9989
28
+ name: F1 Score (Macro)
29
+ verified: false
30
+ - task:
31
+ type: image-classification
32
+ name: Image Classification
33
+ dataset:
34
+ name: Chess CV OpenBoard Dataset
35
+ type: chess-cv-openboard
36
+ metrics:
37
+ - type: accuracy
38
+ value: 0.9757
39
+ name: Accuracy
40
+ verified: false
41
+ - type: f1
42
+ value: 0.9578
43
+ name: F1 Score (Macro)
44
+ verified: false
45
+ pipeline_tag: image-classification
46
+ ---
47
+
48
+ # Chess CV
49
+
50
+ <div align="center">
51
+ <img src="https://raw.githubusercontent.com/S1M0N38/chess-cv/main/docs/assets/model.svg" alt="Model Architecture" width="600">
52
+ </div>
53
+
54
+ Lightweight CNN (156k parameters) that classifies chess pieces from 32×32 pixel square images into 13 classes (6 white pieces, 6 black pieces, empty square). Trained on synthetic data from chess.com/lichess boards and piece sets.
55
+
56
+ ## Quick Start
57
+
58
+ ```bash
59
+ pip install chess-cv
60
+ ```
61
+
62
+ ```python
63
+ import mlx.core as mx
64
+ import numpy as np
65
+ from PIL import Image
66
+ from huggingface_hub import hf_hub_download
67
+ from chess_cv.model import SimpleCNN
68
+
69
+ # Load model
70
+ model_path = hf_hub_download(repo_id="S1M0N38/chess-cv", filename="best_model.safetensors")
71
+ model = SimpleCNN(num_classes=13)
72
+ model.load_weights(model_path)
73
+ model.eval()
74
+
75
+ # Predict
76
+ img = Image.open("square.png").convert('RGB').resize((32, 32))
77
+ img_array = mx.array(np.array(img, dtype=np.float32)[None, ...] / 255.0)
78
+ pred_idx = mx.argmax(model(img_array), axis=-1).item()
79
+
80
+ classes = ['bB', 'bK', 'bN', 'bP', 'bQ', 'bR', 'wB', 'wK', 'wN', 'wP', 'wQ', 'wR', 'xx']
81
+ print(f"Predicted: {classes[pred_idx]}")
82
+ ```
83
+
84
+ ## Training Your Own Model
85
+
86
+ To train or evaluate the model yourself:
87
+
88
+ ```bash
89
+ git clone https://github.com/S1M0N38/chess-cv.git
90
+ cd chess-cv
91
+ uv sync --all-extras
92
+
93
+ # Generate training data
94
+ python -m chess_cv.preprocessing
95
+
96
+ # Train model
97
+ python -m chess_cv.train
98
+
99
+ # Evaluate model
100
+ python -m chess_cv.test
101
+ ```
102
+
103
+ See the [Setup Guide](https://s1m0n38.github.io/chess-cv/setup/) and [Usage Guide](https://s1m0n38.github.io/chess-cv/usage/) for detailed instructions on data generation, training configuration, and evaluation.
104
+
105
+ ## Limitations
106
+
107
+ - Requires precisely cropped 32×32 pixel square images (no board detection)
108
+ - Trained on synthetic data; may not generalize to real-world photos
109
+ - Not suitable for non-standard piece designs or chess game logic
110
+ - Optimized for Apple Silicon (slower on CPU)
111
+
112
+ For detailed documentation, architecture details, and advanced usage, see the [full documentation](https://s1m0n38.github.io/chess-cv/).
113
+
114
+ ## Citation
115
+
116
+ ```bibtex
117
+ @software{bertolotto2024chesscv,
118
+ author = {Bertolotto, Simone},
119
+ title = {Chess CV: Lightweight CNN for Chess Piece Recognition},
120
+ year = {2025},
121
+ url = {https://github.com/S1M0N38/chess-cv}
122
+ }
123
+ ```
124
+
125
+ **Repository:** [github.com/S1M0N38/chess-cv](https://github.com/S1M0N38/chess-cv) • **PyPI:** [pypi.org/project/chess-cv](https://pypi.org/project/chess-cv/)
augmentation_example.png ADDED

Git LFS Details

  • SHA256: a39593ee5139d0cff43a8141d84fb7bbd9c48bcd9d4c0b6940f927dc2ca81e64
  • Pointer size: 131 Bytes
  • Size of remote file: 126 kB
best_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:62dfba5caeeee332a9999e409174edef2c1cd2c78c1a0c05276fa6e57d68c0af
3
+ size 626617
config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architecture": "SimpleCNN",
3
+ "num_classes": 13,
4
+ "input_size": [32, 32, 3],
5
+ "num_parameters": 156000,
6
+ "framework": "mlx",
7
+ "task": "image-classification",
8
+ "classes": [
9
+ "bB", "bK", "bN", "bP", "bQ", "bR",
10
+ "wB", "wK", "wN", "wP", "wQ", "wR",
11
+ "xx"
12
+ ]
13
+ }
test_confusion_matrix.png ADDED
test_per_class_accuracy.png ADDED
training_curves.png ADDED