--- license: apache-2.0 tags: - computer-vision - chess - yolo - object-detection - piece-detection model-index: - name: chess_piece_detection results: [] --- # chess_piece_detection Chess piece detection model trained with YOLO ## Model Details - **Model Type**: YOLO Detection - **Task**: object-detection - **License**: apache-2.0 ## Usage ### Loading the Model ```python from src.chess_piece_detection.model import ChessModel # Load the model model = ChessModel(model_path="path/to/downloaded/model.pt") # Detect chess pieces in an image detected_pieces = model.detect_pieces("path/to/chessboard_image.jpg") for square_num, piece_class in detected_pieces: piece_name = model.get_piece_name(piece_class) print(f"Square {square_num}: {piece_name}") # Visualize results model.visualize_detections("path/to/chessboard_image.jpg", show=True) ``` ### Direct YOLO Usage ```python from ultralytics import YOLO # Load the model model = YOLO("path/to/downloaded/model.pt") # Run detection on chess piece images results = model("path/to/chessboard_image.jpg") # Get bounding boxes and classifications for result in results: boxes = result.boxes if boxes is not None: for box in boxes: class_id = int(box.cls[0]) confidence = float(box.conf[0]) print(f"Detected piece class {class_id} with confidence {confidence:.2f}") ``` ### Training Data Format This model expects YOLO detection format with chess piece annotations: ```yaml # data.yaml train: path/to/train/images val: path/to/val/images nc: 12 # Number of chess piece classes names: ['white-king', 'white-queen', 'white-rook', 'white-bishop', 'white-knight', 'white-pawn', 'black-king', 'black-queen', 'black-rook', 'black-bishop', 'black-knight', 'black-pawn'] ``` With corresponding label files containing piece bounding boxes: ``` # labels/image.txt class_id x_center y_center width height # normalized coordinates ``` ## Training This model was trained using the Chess Piece Detection training pipeline: ```bash python src/chess_piece_detection/train.py \ --data data/chess_pieces/data.yaml \ --epochs 100 \ --batch 16 \ --img-size 640 ``` ## Model Performance ## Citation If you use this model in your research, please cite: ```bibtex @misc{dopaul_chess_piece_detection, title={chess_piece_detection}, author={dopaul}, year={2024}, publisher={Hugging Face}, url={https://huggingface.co/dopaul/chess_piece_detection} } ```