Model Architecture
To achieve real-time performance, this project utilizes YOLOv11 (Classification variant). Unlike standard YOLO models that draw boxes around objects (Object Detection), this model looks at an image and gives it a single label (Image Classification).
🏗️ The AI Pipeline
When a frame from your webcam enters the model, it travels through a specific architectural pipeline to reach a decision.
graph LR Input[Webcam Frame] --> Prep[Preprocessing: Resize to 224x224] Prep --> Backbone[CNN Backbone: Feature Extraction] Backbone --> Pool[Global Average Pooling] Pool --> Head[Classification Head: Fully Connected Layer] Head --> Softmax[Softmax Function: Probability Distribution] Softmax --> Output[Final Label: Open or Closed]
Step-by-Step Breakdown
1. Preprocessing
The raw webcam image is often large (e.g., ). The AI cannot process this efficiently, so it is resized to pixels and normalized.
2. The CNN Backbone
The “Backbone” is a series of Convolutional Neural Networks (CNNs). Think of this as a set of filters:
- Early Layers: Detect simple edges and colors.
- Middle Layers: Detect shapes (the curve of an eyelid).
- Deep Layers: Detect complex patterns (the difference between a squint and a closed eye).
3. Global Average Pooling (GAP)
The backbone produces a complex map of features. GAP collapses this map into a single vector of numbers that represents the “essence” of the image.
4. The Classification Head & Softmax
The final layer maps that vector to our two classes: open_eyes and closed_eyes. The Softmax function ensures the two probabilities add up to .
Example Output:
open_eyes: ()closed_eyes: ()- Decision:
⚖️ Architecture Trade-offs
We chose the Medium (m) variant of YOLOv11. Here is why:
| Variant | Speed (FPS) | Accuracy | Resource Usage | Verdict |
|---|---|---|---|---|
| Nano | ⚡ Ultra Fast | 📉 Moderate | 🟢 Very Low | Too many false positives |
| Small | 🚀 Fast | 📈 High | 🟢 Low | Good, but misses subtle closures |
| Medium | ⚖️ Balanced | 🌟 Very High | 🟡 Moderate | Perfect for real-time safety |
| Large | 🐌 Slow | 🏆 Ultra High | 🔴 High | Too slow for real-time alerts |
Related Components
Last Updated: 2026-05-03