ckcl commited on
Commit
ac9516f
·
verified ·
1 Parent(s): e0ebba2

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +26 -60
  2. config.json +1 -0
  3. model_weights.h5 +3 -0
README.md CHANGED
@@ -1,68 +1,34 @@
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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # Driver Drowsiness Detection Model
2
 
3
+ This model is designed to detect driver drowsiness from facial images using a CNN architecture.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
+ ## Model Details
6
+ - Architecture: CNN
7
+ - Input: Facial images (64x64x3)
8
+ - Output: Binary classification (drowsy/not drowsy)
 
9
 
10
  ## Usage
 
11
  ```python
12
+ import tensorflow as tf
13
+ import cv2
14
+ import numpy as np
15
+
16
+ # Load model
17
+ model = tf.keras.models.load_model('drowsiness_model.h5')
18
+
19
+ # Preprocess image
20
+ img = cv2.imread('face.jpg')
21
+ img = cv2.resize(img, (64, 64))
22
+ img = img / 255.0
23
+ img = np.expand_dims(img, axis=0)
24
+
25
+ # Make prediction
26
+ prediction = model.predict(img)
27
+ is_drowsy = prediction[0][0] > 0.5
28
  ```
29
 
30
+ ## Training Details
31
+ - Dataset: Custom driver drowsiness dataset
32
+ - Training method: Binary cross-entropy loss with Adam optimizer
33
+ - Validation split: 20%
34
+ - Early stopping with patience=3
 
 
config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"model_type": "drowsiness_detector", "input_shape": [64, 64, 3], "architecture": "CNN", "description": "A CNN model for detecting driver drowsiness from facial images"}
model_weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be899dd5a95dad19789a8352a7cbd1523a5c2c182795dd4195b4921dde7a3fb6
3
+ size 4613168