- Overview
- Features
- Demo
- How It Works
- Tech Stack
- Installation
- Usage
- Model Performance
- Dataset
- Project Structure
- Contributing
- License
- Contact
This project implements an AI-based facial image analysis system that detects alcohol intoxication by analyzing facial features. The system compares three different machine learning approaches:
- CNN (Convolutional Neural Network) - Deep learning approach
- SVM (Support Vector Machine) - Traditional ML approach
- Hybrid CNN-SVM - Combined approach leveraging both techniques
The system demonstrates a complete computer vision pipeline from preprocessing to model evaluation and real-time prediction.
Try the interactive demo on Hugging Face Spaces:
π Launch Demo
- π Multi-Model Comparison - Evaluate CNN, SVM, and Hybrid approaches side-by-side
- π Real-time Prediction - Instant classification with confidence scores
- π¨ Gradio Interface - User-friendly web interface for testing
- π Performance Visualization - Confusion matrices and accuracy metrics
- πΌοΈ Image Preprocessing - Automated face detection and feature extraction
- π― High Accuracy - Optimized models achieving >85% accuracy
- π± Mobile Deployment Ready - Android Studio integration included
# Run the interactive demo locally
python app.py
| Input Image | Prediction | Confidence |
|---|---|---|
![]() |
Intoxicated | 92.3% |
![]() |
Normal | 88.7% |
# Face detection and alignment
face = detect_face(image)
normalized = preprocess(face)
# CNN extracts high-level features
features = cnn_model.extract_features(normalized)
# Three different classifiers
prediction_cnn = cnn_model.predict(features)
prediction_svm = svm_model.predict(features)
prediction_hybrid = hybrid_model.predict(features)
# Ensemble predictions with confidence scores
final_result = aggregate_predictions([
prediction_cnn,
prediction_svm,
prediction_hybrid
])
| Category | Technologies |
|---|---|
| Deep Learning | |
| Computer Vision | |
| Machine Learning | |
| Web Interface | |
| Mobile | |
| Deployment |
- Python 3.8+
- CUDA-capable GPU (optional, for faster training)
- 4GB+ RAM
- Clone the repository
git clone https://github.com/ares-coding/detecting-alcohol-intoxication-using-image-processing.git
cd detecting-alcohol-intoxication-using-image-processing
- Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies
pip install -r requirements.txt
- Download pre-trained models (optional)
python scripts/download_models.py
# Train CNN model
python train_cnn.py --epochs 50 --batch-size 32
# Train SVM model
python train_svm.py --kernel rbf
# Train Hybrid CNN-SVM model
python train_hybrid.py --epochs 50
from model import AlcoholDetector
# Initialize detector
detector = AlcoholDetector(model_type='hybrid')
# Predict from image
result = detector.predict('path/to/image.jpg')
print(f"Prediction: {result['class']}")
print(f"Confidence: {result['confidence']:.2%}")
# Gradio interface
python app.py
# Access at http://localhost:7860
| Model | Accuracy | Precision | Recall | F1-Score | Inference Time |
|---|---|---|---|---|---|
| CNN | 87.3% | 86.5% | 88.1% | 87.3% | 45ms |
| SVM | 82.7% | 81.9% | 83.5% | 82.7% | 12ms |
| Hybrid CNN-SVM | 91.2% | 90.8% | 91.6% | 91.2% | 52ms |
Predicted
Normal Intoxicated
Actual Normal 453 27
Intoxicated 31 489
- Source: Custom collected + Public datasets (Kaggle)
- Total Images: 24,000 facial images
- Classes: 2 (Normal, Intoxicated)
- Split: 70% Train, 15% Validation, 15% Test
- Preprocessing: Face detection, alignment, normalization
- Rotation (Β±15Β°)
- Horizontal flip
- Brightness adjustment (Β±20%)
- Gaussian noise
detecting-alcohol-intoxication/
βββ π data/
β βββ raw/ # Original dataset
β βββ processed/ # Preprocessed images
β βββ augmented/ # Augmented data
βββ π models/
β βββ cnn_model.py # CNN implementation
β βββ svm_model.py # SVM implementation
β βββ hybrid_model.py # Hybrid CNN-SVM
βββ π notebooks/
β βββ 01_data_exploration.ipynb
β βββ 02_model_training.ipynb
β βββ 03_evaluation.ipynb
βββ π src/
β βββ preprocessing.py # Image preprocessing
β βββ feature_extraction.py # Feature engineering
β βββ utils.py # Utility functions
βββ π android/ # Android app source
βββ π web/ # Web interface
βββ app.py # Gradio app
βββ train.py # Training script
βββ predict.py # Inference script
βββ requirements.txt # Dependencies
βββ README.md # This file
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow PEP 8 style guide
- Add unit tests for new features
- Update documentation
- Ensure all tests pass before submitting
This project is licensed under the MIT License - see the LICENSE file for details.
Au Amores - Full Stack Developer & AI/ML Engineer
- Dataset contributors from Kaggle
- TensorFlow and PyTorch communities
- OpenCV documentation and tutorials
- Hugging Face for hosting the demo
If you use this project in your research, please cite:
@software{alcohol_intoxication_detection,
author = {Amores, Au},
title = {Alcohol Intoxication Detection Using Image Processing},
year = {2025},
url = {https://github.com/ares-coding/detecting-alcohol-intoxication-using-image-processing}
}
β Star this repository if you find it helpful!
Made with β€οΈ and β by Ares

