Upload driver drowsiness detection model
Browse files- README.md +68 -0
- model/config.json +19 -0
- model/pytorch_model.bin +3 -0
- preprocessor/preprocessor_config.json +18 -0
- sample_image.jpg +0 -0
README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: mit
|
| 4 |
+
tags:
|
| 5 |
+
- vision
|
| 6 |
+
- image-classification
|
| 7 |
+
- drowsiness-detection
|
| 8 |
+
- driver-monitoring
|
| 9 |
+
- pytorch
|
| 10 |
+
- mobilenetv2
|
| 11 |
+
datasets:
|
| 12 |
+
- custom
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# Driver Drowsiness Detection Model
|
| 16 |
+
|
| 17 |
+
This model detects whether a driver is alert or showing signs of drowsiness based on facial features.
|
| 18 |
+
|
| 19 |
+
## Model Description
|
| 20 |
+
|
| 21 |
+
This model is fine-tuned on a custom dataset of driver face images to detect drowsiness in real-time. It uses a MobileNetV2 architecture for efficient inference.
|
| 22 |
+
|
| 23 |
+
### Model Architecture
|
| 24 |
+
- Base model: MobileNetV2
|
| 25 |
+
- Fine-tuned for binary classification (alert vs. drowsy)
|
| 26 |
+
- Input size: 224x224 RGB images
|
| 27 |
+
|
| 28 |
+
## Training Data
|
| 29 |
+
|
| 30 |
+
The model was trained on custom-labeled face images extracted from driver-facing camera videos. The dataset includes various lighting conditions and driver appearances.
|
| 31 |
+
|
| 32 |
+
## Performance
|
| 33 |
+
|
| 34 |
+
The model can identify signs of drowsiness in drivers with high accuracy. It's designed to be fast enough for real-time inference.
|
| 35 |
+
|
| 36 |
+
## Limitations
|
| 37 |
+
|
| 38 |
+
- Requires good lighting conditions to detect faces properly
|
| 39 |
+
- May have reduced accuracy with glasses or face coverings
|
| 40 |
+
- Should be used as part of a comprehensive driver monitoring system and not as the sole safety mechanism
|
| 41 |
+
|
| 42 |
+
## Usage
|
| 43 |
+
|
| 44 |
+
```python
|
| 45 |
+
from transformers import AutoImageProcessor, AutoModelForImageClassification
|
| 46 |
+
from PIL import Image
|
| 47 |
+
|
| 48 |
+
# Load model and processor
|
| 49 |
+
processor = AutoImageProcessor.from_pretrained("ckcl/driver-drowsiness-detector")
|
| 50 |
+
model = AutoModelForImageClassification.from_pretrained("ckcl/driver-drowsiness-detector")
|
| 51 |
+
|
| 52 |
+
# Load an image
|
| 53 |
+
image = Image.open("path/to/driver/face/image.jpg")
|
| 54 |
+
|
| 55 |
+
# Process image and get prediction
|
| 56 |
+
inputs = processor(images=image, return_tensors="pt")
|
| 57 |
+
outputs = model(**inputs)
|
| 58 |
+
predicted_class_idx = outputs.logits.argmax(-1).item()
|
| 59 |
+
print(f"Predicted class: {model.config.id2label[str(predicted_class_idx)]}")
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
## Citation
|
| 63 |
+
|
| 64 |
+
If you use this model in your research or project, please provide a link to this model card.
|
| 65 |
+
|
| 66 |
+
## Contact
|
| 67 |
+
|
| 68 |
+
For questions or feedback, please open an issue on the GitHub repository or contact the author on Hugging Face.
|
model/config.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"MobileNetV2ForImageClassification"
|
| 4 |
+
],
|
| 5 |
+
"model_type": "mobilenet_v2",
|
| 6 |
+
"hidden_act": "relu",
|
| 7 |
+
"hidden_dropout_prob": 0.2,
|
| 8 |
+
"num_channels": 3,
|
| 9 |
+
"num_labels": 2,
|
| 10 |
+
"id2label": {
|
| 11 |
+
"0": "alert",
|
| 12 |
+
"1": "drowsy"
|
| 13 |
+
},
|
| 14 |
+
"label2id": {
|
| 15 |
+
"alert": 0,
|
| 16 |
+
"drowsy": 1
|
| 17 |
+
},
|
| 18 |
+
"transformers_version": "4.18.0"
|
| 19 |
+
}
|
model/pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:89173440c3531fde3a2d77be156f039cc4e68170a42da16bb74ede7dadc42ef7
|
| 3 |
+
size 9152306
|
preprocessor/preprocessor_config.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"crop_size": 224,
|
| 3 |
+
"do_center_crop": true,
|
| 4 |
+
"do_normalize": true,
|
| 5 |
+
"do_resize": true,
|
| 6 |
+
"image_mean": [
|
| 7 |
+
0.485,
|
| 8 |
+
0.456,
|
| 9 |
+
0.406
|
| 10 |
+
],
|
| 11 |
+
"image_std": [
|
| 12 |
+
0.229,
|
| 13 |
+
0.224,
|
| 14 |
+
0.225
|
| 15 |
+
],
|
| 16 |
+
"resample": 3,
|
| 17 |
+
"size": 224
|
| 18 |
+
}
|
sample_image.jpg
ADDED
|