Upload yolo detection model
Browse files
README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- computer-vision
|
| 5 |
+
- chess
|
| 6 |
+
- yolo
|
| 7 |
+
- object-detection
|
| 8 |
+
- piece-detection
|
| 9 |
+
|
| 10 |
+
model-index:
|
| 11 |
+
- name: chess_piece_detection
|
| 12 |
+
results: []
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# chess_piece_detection
|
| 16 |
+
|
| 17 |
+
Chess piece detection model trained with YOLO
|
| 18 |
+
|
| 19 |
+
## Model Details
|
| 20 |
+
|
| 21 |
+
- **Model Type**: YOLO Detection
|
| 22 |
+
- **Task**: object-detection
|
| 23 |
+
- **License**: apache-2.0
|
| 24 |
+
|
| 25 |
+
## Usage
|
| 26 |
+
|
| 27 |
+
### Loading the Model
|
| 28 |
+
|
| 29 |
+
```python
|
| 30 |
+
from src.chess_piece_detection.model import ChessModel
|
| 31 |
+
|
| 32 |
+
# Load the model
|
| 33 |
+
model = ChessModel(model_path="path/to/downloaded/model.pt")
|
| 34 |
+
|
| 35 |
+
# Detect chess pieces in an image
|
| 36 |
+
detected_pieces = model.detect_pieces("path/to/chessboard_image.jpg")
|
| 37 |
+
|
| 38 |
+
for square_num, piece_class in detected_pieces:
|
| 39 |
+
piece_name = model.get_piece_name(piece_class)
|
| 40 |
+
print(f"Square {square_num}: {piece_name}")
|
| 41 |
+
|
| 42 |
+
# Visualize results
|
| 43 |
+
model.visualize_detections("path/to/chessboard_image.jpg", show=True)
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
### Direct YOLO Usage
|
| 47 |
+
|
| 48 |
+
```python
|
| 49 |
+
from ultralytics import YOLO
|
| 50 |
+
|
| 51 |
+
# Load the model
|
| 52 |
+
model = YOLO("path/to/downloaded/model.pt")
|
| 53 |
+
|
| 54 |
+
# Run detection on chess piece images
|
| 55 |
+
results = model("path/to/chessboard_image.jpg")
|
| 56 |
+
|
| 57 |
+
# Get bounding boxes and classifications
|
| 58 |
+
for result in results:
|
| 59 |
+
boxes = result.boxes
|
| 60 |
+
if boxes is not None:
|
| 61 |
+
for box in boxes:
|
| 62 |
+
class_id = int(box.cls[0])
|
| 63 |
+
confidence = float(box.conf[0])
|
| 64 |
+
print(f"Detected piece class {class_id} with confidence {confidence:.2f}")
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
### Training Data Format
|
| 68 |
+
|
| 69 |
+
This model expects YOLO detection format with chess piece annotations:
|
| 70 |
+
|
| 71 |
+
```yaml
|
| 72 |
+
# data.yaml
|
| 73 |
+
train: path/to/train/images
|
| 74 |
+
val: path/to/val/images
|
| 75 |
+
nc: 12 # Number of chess piece classes
|
| 76 |
+
names: ['white-king', 'white-queen', 'white-rook', 'white-bishop', 'white-knight', 'white-pawn',
|
| 77 |
+
'black-king', 'black-queen', 'black-rook', 'black-bishop', 'black-knight', 'black-pawn']
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
With corresponding label files containing piece bounding boxes:
|
| 81 |
+
```
|
| 82 |
+
# labels/image.txt
|
| 83 |
+
class_id x_center y_center width height # normalized coordinates
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
## Training
|
| 87 |
+
|
| 88 |
+
This model was trained using the Chess Piece Detection training pipeline:
|
| 89 |
+
|
| 90 |
+
```bash
|
| 91 |
+
python src/chess_piece_detection/train.py \
|
| 92 |
+
--data data/chess_pieces/data.yaml \
|
| 93 |
+
--epochs 100 \
|
| 94 |
+
--batch 16 \
|
| 95 |
+
--img-size 640
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
## Model Performance
|
| 99 |
+
|
| 100 |
+
<!-- Add performance metrics here after training -->
|
| 101 |
+
|
| 102 |
+
## Citation
|
| 103 |
+
|
| 104 |
+
If you use this model in your research, please cite:
|
| 105 |
+
|
| 106 |
+
```bibtex
|
| 107 |
+
@misc{dopaul_chess_piece_detection,
|
| 108 |
+
title={chess_piece_detection},
|
| 109 |
+
author={dopaul},
|
| 110 |
+
year={2024},
|
| 111 |
+
publisher={Hugging Face},
|
| 112 |
+
url={https://huggingface.co/dopaul/chess_piece_detection}
|
| 113 |
+
}
|
| 114 |
+
```
|
model.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ff76b6bdbe7538d089b854c80eb3275768915bb7772913da6e3577d093671c48
|
| 3 |
+
size 19190234
|