🚬 Smoking Detection — YOLO26s
A fine-tuned YOLO26s (Ultralytics) object detection model trained to detect cigarettes in images and video streams. Designed for real-world deployment with crash-resilient training and automatic checkpoint uploads to Hugging Face.
📊 Model Performance
YOLO Validation Metrics
| Metric | Score |
|---|---|
| mAP@50 | 0.8796 |
| mAP@50-95 | 0.5198 |
| Precision | 0.9261 |
| Recall | 0.8814 |
| F1 Score | 0.9032 |
Image-Level Classification Report (307 validation images)
| Class | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| No Cigarette | 0.8108 | 0.9677 | 0.8824 | 31 |
| Cigarette | 0.9963 | 0.9746 | 0.9853 | 276 |
| Accuracy | 0.9739 | 307 | ||
| Macro Avg | 0.9036 | 0.9712 | 0.9339 | 307 |
| Weighted Avg | 0.9776 | 0.9739 | 0.9749 | 307 |
Model Evaluation Metrics

Confusion Matrix Summary
| Predicted: No Cigarette | Predicted: Cigarette | |
|---|---|---|
| True: No Cigarette | 30 (96.77%) | 1 (3.23%) |
| True: Cigarette | 7 (2.54%) | 269 (97.46%) |

🏗️ Training Setup
Dataset
- Source: Roboflow —
pro-hiyaw / cigarettes-reality-2-trnm2(Version 1) - Format: YOLO (Ultralytics
yolo26export from Roboflow)
Model
- Base weights:
yolo26s.pt - Architecture: YOLO26 Small (
yolo26s)
Hyperparameters
| Parameter | Value |
|---|---|
| Epochs | 200 |
| Image size | 800 |
| Batch size | 16 |
| Device | GPU 0 |
| Patience (early stopping) | 30 |
Data Augmentation
| Augmentation | Value |
|---|---|
HSV Saturation (hsv_s) | 0.2 |
HSV Value / Exposure (hsv_v) | 0.2 |
Rotation (degrees) | ±10° |
Horizontal Flip (fliplr) | 0.5 |
🔄 Crash-Resilient Training
The training pipeline includes automatic crash recovery:
- At the end of every epoch, a
training_status.jsonfile is written with the current epoch, path tolast.pt, and path tobest.pt. - On restart, if a status file is found with
"status": "training", training automatically resumes from the last saved weights. - Every 10 epochs, checkpoints are uploaded to Hugging Face:
weights/epoch_{N}_last.pt— rolling checkpointweights/best.pt— best model so far (overwritten each time)training_status.json— current training state
🤗 Hugging Face Integration
Model checkpoints are uploaded to Hugging Face automatically during training.
- Repo:
basant18/Smoking-detection-YOLO26s - Visibility: Public (the training repo was private while training)
- Upload frequency: Every 10 epochs
Authentication uses a Hugging Face token stored as a Kaggle secret (HF_TOKEN).
🚀 Quick Start
Install Dependencies
pip install ultralytics roboflow huggingface_hub opencv-python
Run Inference
from ultralytics import YOLO
model = YOLO("weights/best.pt")
results = model.predict(source="your_image.jpg", imgsz=800, conf=0.5)
results[0].show()
Resume Training
Simply re-run the training script. If training_status.json exists and points to valid weights, training will resume automatically from the last checkpoint.
📁 Project Structure
.
├── training_status.json # Auto-generated crash recovery state
├── runs/
│ └── detect/
│ └── train/
│ └── weights/
│ ├── best.pt # Best checkpoint
│ └── last.pt # Latest checkpoint
└── <dataset>/
└── data.yaml # Dataset config (auto-downloaded from Roboflow)
🔐 Required Secrets (Kaggle)
| Secret Name | Description |
|---|---|
HF_TOKEN | Hugging Face API token |
RF | Roboflow API key |
📄 License
This project is for research and educational purposes. Dataset sourced from Roboflow Universe under its respective license.