The Training Pipeline
This section explains how we turned raw images into a mathematical model (.pt file) capable of detecting drowsiness.
🧬 The Concept: Transfer Learning
We didn’t start training the AI from scratch (which would require millions of images and weeks of computing power). Instead, we used Transfer Learning.
How it Works
We started with yolo11m-cls.pt, a model already trained on the ImageNet dataset (millions of general images like dogs, cars, and trees). This model already knows how to recognize edges, circles, and textures. We then “fine-tuned” it to forget about dogs and cars and focus specifically on Open vs. Closed eyes.
graph LR Pre[Pre-trained YOLOv11 Weights] --> Freeze[Freeze Early Layers] Freeze --> FineTune[Fine-tune on MRL Eye Dataset] FineTune --> Val[Validation on Test Set] Val --> Export[Best.pt Weights]
⚙️ Training Execution
The training is managed by train_yolo.py. The process follows these strict technical phases:
1. Setup Phase
The model is loaded and the data.yaml is read. The images are resized to and normalized to ensure the math remains stable.
2. The Training Loop (The Epochs)
We ran the model for 75 Epochs. An epoch is one complete pass through the entire training dataset.
- Forward Pass: Model predicts “Open” or “Closed.”
- Loss Calculation: Model checks if it was wrong.
- Backpropagation: Model adjusts its internal weights to be more accurate next time.
3. Validation & Early Stopping
To prevent Overfitting (where the model just memorizes the images instead of learning patterns), we used a patience setting of 100. If the validation accuracy doesn’t improve for 100 checks, training stops automatically.
📊 Training Hyperparameters
| Parameter | Value | Purpose | Beginner’s Explanation |
|---|---|---|---|
| Epochs | 75 | Duration | How many times the AI “reads” the whole book. |
| Batch Size | 8 | Memory | How many images the AI looks at before updating its brain. |
| imgsz | 224 | Resolution | The “glasses” the AI wears; everything is seen as . |
| Device | 0 (GPU) | Speed | Using a graphics card makes training faster than a CPU. |
Usage
To initiate the pipeline:
python train_yolo.pyRelated Components
Last Updated: 2026-05-03