🏏 Cricket Rule-Breaking Detector — Front-Foot No-Ball (Google Colab)
One-line story: Fatima Noor loves cricket and built this Colab-only MVP to highlight front-foot no-balls on short videos with clear on-frame overlays.
Overview
This repository contains a Google Colab workflow to:
- Detect the bowler’s front foot near the popping crease.
- Produce an annotated MP4 with boxes/labels.
- Optionally add crease calibration and a LEGAL / NO-BALL verdict.
What I Used (Project Inputs)
- Model weights:
best.pt (YOLOv8n fine-tuned for front-foot context).
- Videos: Short delivery clips sourced from YouTube (educational/research use). Clips were trimmed to ~6–12s where the front foot & crease are clearly visible.
- Training data: A small YOLO-format dataset focused on front foot near popping crease (curated and managed via Roboflow).
How I Trained the Model (Roboflow)
- Create a Roboflow project and set the task to object detection.
- Upload images (replay frames showing bowler’s front foot near the crease).
- Label consistently:
- Class:
front_foot (tight bounding box).
- Keep visible reference to the popping crease for later calibration (not strictly required in labels).
- Generate dataset in YOLOv8 (Ultralytics) format (train/val split suggested: 70/20/10).
- Export/download the dataset and fine-tune YOLOv8n in Colab until validation improves.
- Save the checkpoint with highest validation score as
best.pt.
Notes: Small, high-quality labels beat large, noisy datasets. Start with ~30–50 crisp images from your camera style and iterate.
How I Ran Inference (Using best.pt)
- Open the inference notebook
notebooks/02_infer_video.ipynb in Google Colab and enable GPU.
- Upload:
- The trained
best.pt.
- A short MP4 clip (downloaded from YouTube; trimmed to one delivery).
- Run the notebook cells in order. The pipeline:
- Loads the model and the video.
- Processes frames and draws front-foot overlays.
- Exports
outputs/pred.mp4 as the annotated result.
- (Optional) Enable Calibration and Rule Decision sections in the notebook to display a LEGAL / NO-BALL verdict (toe vs crease with a small tolerance).
Results (Placeholders)
📸
<img width="1650" height="900" alt="image" src="https://github.com/user-attachments/assets/ac582108-08c1-49c3-adfe-82bf17c5dea5" />
Requirements
- Google Colab with GPU runtime.
- Short delivery videos (6–12s) where the front foot & crease are visible.
best.pt (if running inference only) or a small YOLO-format dataset (if you want to train).
Best Practices
- Use replay-style close-ups; keep clips short and steady.
- For training, prioritize tight, consistent labels over quantity.
- Calibrate once per camera angle for robust LEGAL / NO-BALL decisions.
Limitations
- Sensitive to camera angle, blur, and occlusions.
- Performance depends on data quality and representativeness.
- MVP scope is front-foot context; other rules need additional modules.
- For education/training; not an official officiating system.
License
MIT License — Use responsibly; respect content rights when sourcing videos.
Credits
Ultralytics YOLO, OpenCV, Roboflow, and the open tooling community.