This project utilizes TensorFlow.js and the RetinaNet-SpineNet-49 model (retinanet_spinenet_mobile_coco
) to train an AI system that recognizes and interprets Rubik's Cube patterns via a camera. By integrating computer vision ๐ผ๏ธ, COCO annotations ๐๏ธ, and state-of-the-art object detection models ๐, the system detects and identifies each face and tile color of a Rubik's Cube, paving the way for automated solving.
The project is structured into three core components:
-
Data Preparation ๐๏ธ:
- Collected Rubik's Cube images annotated using LabelMe.
- Converted annotations from LabelMe JSON format to COCO JSON format using a custom Python script.
- Defined detection categories, including color tiles (
red_tile
,white_tile
,blue_tile
, etc.).
-
Model Training ๐๏ธโโ๏ธ:
- This project uses the RetinaNet-SpineNet-49 architecture, specifically the retinanet_spinenet_mobile_coco model provided by TensorFlow as the base model.
- Fine-tuned the model for real-time classification and localization of Rubik's Cube tiles.
-
Visualization and Evaluation ๐:
- Developed a visualization script to overlay predictions on test images with bounding boxes and labels.
- Exported results to PNG format for validation and analysis.
- Advanced Object Detection ๐ฏ: High-precision Rubik's Cube tile detection using the RetinaNet-SpineNet-49 model.
- Dynamic Tile Recognition ๐น๏ธ: Real-time identification of cube tiles and colors via camera input.
- Streamlined Annotation Workflow ๐: Seamless conversion of LabelMe JSON annotations into the COCO JSON format.
- Custom Visualization Tools ๐ผ๏ธ: Debugging and enhancing predictions through overlayed visual outputs.
- Data Collection: Annotate Rubik's Cube images using LabelMe. โ๏ธ
- COCO Conversion: Convert annotations with the
labelme_to_coco.py
script. ๐ - Model Training:
- Configure the
retinanet_spinenet_mobile_coco
model using TensorFlow Model Garden. - Train the model on a custom Rubik's Cube dataset. ๐ง
- Configure the
- Deployment: Use TensorFlow.js to deploy the trained model for real-time detection. ๐
- Python 3.8+
- TensorFlow
- TensorFlow.js
- TensorFlow Model Garden
- LabelMe for annotation
-
Clone the repository:
git clone [repository_link] cd rubiks-cube-detection
-
Install dependencies:
pip install -r requirements.txt
-
Annotate your Rubik's Cube images using LabelMe and place them in the
images/
folder.
-
Convert Annotations:
python labelme_to_coco.py
-
Train the Model:
- Modify the configuration for
retinanet_spinenet_mobile_coco
. - Train the model:
python train.py --model=retinanet_spinenet_mobile_coco --config=configs/retinanet_spinenet_mobile_coco.config --data_dir=path_to_coco_data
- Modify the configuration for
-
Run Detection:
- Convert the trained model to TensorFlow.js format.
- Deploy the model for real-time detection.
Sample visualizations with bounding boxes and labels are saved in the outputs/
folder. ๐ผ๏ธ
- ๐ค Integrate a Rubik's Cube-solving algorithm.
- ๐ Expand the dataset to improve detection accuracy.
- ๐ Deploy the system as a web-based application.
Contributions are welcome! Feel free to submit issues or pull requests for improvements. ๐ก