Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
tags:
|
| 4 |
+
- computer-vision
|
| 5 |
+
- image-classification
|
| 6 |
+
- mobile-phone-detection
|
| 7 |
+
- tensorflow
|
| 8 |
+
- mobilenetv2
|
| 9 |
+
datasets:
|
| 10 |
+
- mobilephoneusagedatasetiitr
|
| 11 |
+
widget:
|
| 12 |
+
- src: https://example.com/sample1.jpg
|
| 13 |
+
candidate_labels: using_phone,no_phone
|
| 14 |
+
- src: https://example.com/sample2.jpg
|
| 15 |
+
candidate_labels: using_phone,no_phone
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# Mobile Phone Usage Detection Model
|
| 19 |
+
|
| 20 |
+
## Model Description
|
| 21 |
+
|
| 22 |
+
This is a deep learning model trained to detect mobile phone usage in images. The model uses Transfer Learning with MobileNetV2 as the base architecture and custom classification layers.
|
| 23 |
+
|
| 24 |
+
- **Model type:** Image Classification
|
| 25 |
+
- **Task:** Binary Classification (Using Phone vs No Phone)
|
| 26 |
+
- **Architecture:** MobileNetV2 with custom classifier
|
| 27 |
+
- **Input shape:** (224, 224)
|
| 28 |
+
- **Output:** Binary probability
|
| 29 |
+
|
| 30 |
+
## Intended Uses & Limitations
|
| 31 |
+
|
| 32 |
+
### Intended Use Cases
|
| 33 |
+
- Surveillance systems
|
| 34 |
+
- Driver safety monitoring
|
| 35 |
+
- Classroom monitoring
|
| 36 |
+
- Workplace productivity analysis
|
| 37 |
+
|
| 38 |
+
### Limitations
|
| 39 |
+
- Performance may vary with different lighting conditions
|
| 40 |
+
- May have reduced accuracy with low-resolution images
|
| 41 |
+
- Trained on specific dataset - may need fine-tuning for other domains
|
| 42 |
+
|
| 43 |
+
## Training Data
|
| 44 |
+
|
| 45 |
+
The model was trained on the [Mobile Phone Usage Dataset from IITR](https://www.kaggle.com/datasets/lakshyataragi/mobilephoneusagedatasetiitr)
|
| 46 |
+
|
| 47 |
+
- **Training samples:** 711
|
| 48 |
+
- **Validation samples:** 177
|
| 49 |
+
- **Classes:** ['negative', 'positive']
|
| 50 |
+
|
| 51 |
+
## Training Procedure
|
| 52 |
+
|
| 53 |
+
### Preprocessing
|
| 54 |
+
- Image resizing to (224, 224)
|
| 55 |
+
- Normalization (pixel values scaled to [0,1])
|
| 56 |
+
- Data augmentation (rotation, shifting, flipping, zooming)
|
| 57 |
+
|
| 58 |
+
### Training Hyperparameters
|
| 59 |
+
- **Batch Size:** 32
|
| 60 |
+
- **Learning Rate:** 0.001 (initial), 0.0001 (fine-tuning)
|
| 61 |
+
- **Optimizer:** Adam
|
| 62 |
+
- **Loss Function:** Binary Crossentropy
|
| 63 |
+
- **Epochs:** 50 (initial) + 20 (fine-tuning)
|
| 64 |
+
|
| 65 |
+
## Evaluation Results
|
| 66 |
+
|
| 67 |
+
| Metric | Value |
|
| 68 |
+
|--------|-------|
|
| 69 |
+
| Accuracy | 0.8418 |
|
| 70 |
+
| Precision | 0.8509 |
|
| 71 |
+
| Recall | 0.8981 |
|
| 72 |
+
| Loss | 0.3919 |
|
| 73 |
+
|
| 74 |
+
## How to Use
|
| 75 |
+
|
| 76 |
+
```python
|
| 77 |
+
import tensorflow as tf
|
| 78 |
+
import numpy as np
|
| 79 |
+
from PIL import Image
|
| 80 |
+
|
| 81 |
+
# Load model
|
| 82 |
+
model = tf.keras.models.load_model('fine_tuned_phone_detection_model.h5')
|
| 83 |
+
|
| 84 |
+
def predict_phone_usage(image_path):
|
| 85 |
+
# Preprocess image
|
| 86 |
+
img = Image.open(image_path).convert("RGB")
|
| 87 |
+
img = img.resize((224, 224))
|
| 88 |
+
img_array = np.array(img) / 255.0
|
| 89 |
+
img_array = np.expand_dims(img_array, axis=0)
|
| 90 |
+
|
| 91 |
+
# Predict
|
| 92 |
+
prediction = model.predict(img_array)[0][0]
|
| 93 |
+
class_names = ['no_phone', 'using_phone']
|
| 94 |
+
result = class_names[1] if prediction > 0.5 else class_names[0]
|
| 95 |
+
confidence = prediction if prediction > 0.5 else 1 - prediction
|
| 96 |
+
|
| 97 |
+
return result, confidence
|
| 98 |
+
```
|
| 99 |
+
|
| 100 |
+
## Model Architecture
|
| 101 |
+
|
| 102 |
+
The model uses MobileNetV2 as base architecture with custom classification layers:
|
| 103 |
+
|
| 104 |
+
- Base Model: MobileNetV2 (pre-trained on ImageNet)
|
| 105 |
+
- Global Average Pooling
|
| 106 |
+
- Dropout (0.3)
|
| 107 |
+
- Dense Layer (128 units, ReLU activation)
|
| 108 |
+
- Batch Normalization
|
| 109 |
+
- Dropout (0.5)
|
| 110 |
+
- Output Layer (1 unit, Sigmoid activation)
|
| 111 |
+
|
| 112 |
+
## License
|
| 113 |
+
|
| 114 |
+
MIT License
|