A complete multimodal authentication and recommendation system that combines facial recognition, voice verification, and product recommendation using machine learning.
- System Overview
- Features
- Installation
- Project Structure
- Data Preparation
- Usage Pipeline
- System Flow
- Model Details
- Output Files
- Troubleshooting
- Team Members
This system implements a sequential authentication and recommendation flow:
- Facial Recognition → Verifies user identity from facial images
- Voice Verification → Confirms identity through voice samples
- Product Recommendation → Predicts product category based on customer data
The system uses machine learning models (Random Forest, Logistic Regression, XGBoost) to perform multi-modal authentication and personalized product recommendations.
- Augmentations: Rotation, flipping, grayscale conversion, brightness adjustment, noise addition
- Feature Extraction:
- Histogram features
- HOG (Histogram of Oriented Gradients)
- LBP (Local Binary Pattern)
- Color moments
- Automatic Processing: Processes all team member images with multiple augmentations
- Augmentations: Pitch shift, time stretch, noise addition, speed change, reverb
- Feature Extraction:
- MFCC (13 coefficients)
- Spectral features (centroid, rolloff, bandwidth)
- Energy features (RMS, total energy, entropy)
- Chroma features
- Tempo estimation
- Visualization: Automatic generation of waveforms and spectrograms
- Automatic Processing: Processes all team member audio with multiple augmentations
- Facial Recognition: Random Forest / Logistic Regression
- Voice Verification: Random Forest
- Product Recommendation: Random Forest / XGBoost
- Evaluation Metrics: Accuracy, F1-Score, Log Loss
- Python 3.7 or higher
- pip package manager
-
Clone or navigate to the repository
cd Data-Preprocessing -
Install dependencies
pip install -r requirements.txt
-
Verify installation
python -c "import cv2, librosa, sklearn; print('All dependencies installed successfully!')"
Data-Preprocessing/
├── Images/ # Facial images directory
│ ├── {member}_neutral.jpg # Neutral expression images
│ ├── {member}_smile.jpg # Smiling expression images
│ ├── {member}_surprised.jpg # Surprised expression images
│ └── augmented/ # Augmented images (auto-generated)
│ └── {member}/ # Per-member augmented images
│
├── Audio_data/ # Audio data directory
│ ├── raw/ # Original audio recordings
│ │ ├── {member}_yes.wav # "Yes" phrase recordings
│ │ └── {member}_confirm.wav # "Confirm" phrase recordings
│ └── augmented/ # Augmented audio (auto-generated)
│ └── {member}/ # Per-member augmented audio
│
├── models/ # Trained models directory
│ ├── face_recognition_model.pkl
│ ├── face_label_encoder.pkl
│ ├── face_feature_columns.pkl
│ ├── voice_verification_model.pkl
│ ├── voice_label_encoder.pkl
│ ├── voice_feature_columns.pkl
│ ├── product_recommendation_model.pkl
│ ├── product_label_encoder.pkl
│ └── product_feature_columns.pkl
│
├── merge-output/ # Merged dataset and EDA outputs
│ ├── merged_data.csv # Merged customer data
│ ├── merge_validation.txt # Validation report
│ └── plot_*.png # EDA visualizations
│
├── specto_wave/ # Audio visualizations (auto-generated)
│ ├── {member}_{phrase}_waveform.png
│ └── {member}_{phrase}_spectrogram.png
│
├── scripts/ # Processing scripts
│ ├── merge_datasets.py # Dataset merging and feature engineering
│ ├── product_recommendation.py # Product recommendation model training
│ └── predict.py # Standalone product prediction
│
├── image_processing.py # Image feature extraction pipeline
├── audio_processing.py # Audio feature extraction pipeline
├── train_face_model.py # Train facial recognition model
├── train_audio_model.py # Train voice verification model
├── verify_face.py # Face verification script
├── verify_voice.py # Voice verification script
├── real_verify.py # Complete system simulation
├── requirements.txt # Python dependencies
└── README.md # This file
Each team member should have 3 facial images with the following naming convention:
{member_name}_neutral.jpg- Neutral facial expression{member_name}_smile.jpg- Smiling facial expression{member_name}_surprised.jpg- Surprised facial expression
Place images in: Images/ directory
Supported formats: JPG, JPEG
Example:
Images/
├── Phinah_neutral.jpg
├── Phinah_smile.jpg
├── Phinah_surprised.jpg
├── Sage_neutral.jpg
└── ...
Each team member should have 2 audio recordings with the following naming convention:
{member_name}_yes.wav- Recording saying "Yes" or "Yes, approve"{member_name}_confirm.wav- Recording saying "Confirm" or "Confirm transaction"
Place audio files in: Audio_data/raw/ directory
Supported formats: WAV (recommended), other formats will be converted
Sample rate: 16 kHz (automatically handled during processing)
Example:
Audio_data/raw/
├── Phinah_yes.wav
├── Phinah_confirm.wav
├── Sage_yes.wav
└── ...
Two CSV files are required for product recommendation:
customer_social_profiles - customer_social_profiles.csv- Customer social media profilescustomer_transactions - customer_transactions.csv- Customer transaction history
Place CSV files in: Project root directory
Note: The scripts will automatically handle ID mapping and merging.
Merge customer social profiles and transactions, perform feature engineering, and generate EDA visualizations:
python scripts/merge_datasets.pyOutputs:
merge-output/merged_data.csv- Merged and engineered datasetmerge-output/merge_validation.txt- Validation report with statisticsmerge-output/plot_purchase_amount_dist.png- Purchase amount distributionmerge-output/plot_box_by_category.png- Box plots by categorymerge-output/plot_correlations.png- Feature correlation matrix
Process all facial images, apply augmentations, and extract features:
python image_processing.pyOutputs:
image_features.csv- Extracted image features for all membersImages/augmented/{member}/- Augmented images (rotated, flipped, grayscale, bright, noisy)sample_images_display.png- Sample image visualization (if display is enabled)
What it does:
- Loads all team member images
- Applies 5 types of augmentations per image
- Extracts histogram, HOG, LBP, and color moment features
- Saves augmented images and feature CSV
Process all audio recordings, apply augmentations, and extract features:
python audio_processing.pyOutputs:
audio_features.csv- Extracted audio features for all membersAudio_data/augmented/{member}/- Augmented audio files (pitchup, fast, noise)specto_wave/{member}_{phrase}_waveform.png- Waveform visualizationsspecto_wave/{member}_{phrase}_spectrogram.png- Spectrogram visualizations
What it does:
- Loads all team member audio files
- Applies 4 types of augmentations per audio
- Extracts MFCC, spectral, energy, chroma, and tempo features
- Generates waveform and spectrogram visualizations
python train_face_model.pyOutputs:
models/face_recognition_model.pkl- Trained modelmodels/face_label_encoder.pkl- Label encodermodels/face_feature_columns.pkl- Feature column names
Evaluation: Prints accuracy, F1-score, and classification report
python train_audio_model.pyOutputs:
models/voice_verification_model.pkl- Trained modelmodels/voice_label_encoder.pkl- Label encodermodels/voice_feature_columns.pkl- Feature column names
Evaluation: Prints accuracy, F1-score, and classification report
python scripts/product_recommendation.pyOutputs:
models/product_recommendation_model.pkl- Trained model (Random Forest)models/product_model_xgb.joblib- XGBoost model (if XGBoost available)models/product_label_encoder.pkl- Label encodermodels/product_feature_columns.pkl- Feature column names
Evaluation: Prints accuracy, F1-score, and log loss
Simulate a complete authentication and recommendation flow:
python real_verify.py Images/Phinah_neutral.jpg Audio_data/raw/Phinah_yes.wavWith custom thresholds:
python real_verify.py Images/Phinah_neutral.jpg Audio_data/raw/Phinah_yes.wav 0.7 0.7What it does:
- Verifies facial recognition (threshold: 0.6 default)
- Verifies voice (threshold: 0.6 default)
- Predicts product recommendation
- Displays complete transaction result
Test security by simulating unauthorized access:
python real_verify.py --unauthorized Images/unknown.jpg Audio_data/raw/unknown.wavWhat it does:
- Tests if unauthorized faces/voices are correctly rejected
- Displays security warnings if unauthorized access is accepted
Face Verification:
python verify_face.py Images/Phinah_neutral.jpgVoice Verification:
python verify_voice.py Audio_data/raw/Phinah_yes.wavPredict product category for a customer:
python scripts/predict.py┌─────────────────────┐
│ User Image │
│ (Input) │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ Facial │ ──✗ Fail → ACCESS DENIED
│ Recognition │
│ (Step 1) │
└──────────┬──────────┘
│ ✓ Pass
▼
┌─────────────────────┐
│ Product │
│ Recommendation │
│ (Prepared) │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ Voice │ ──✗ Fail → ACCESS DENIED
│ Verification │
│ (Step 2) │
└──────────┬──────────┘
│ ✓ Pass
▼
┌─────────────────────┐
│ Display │
│ Predicted │
│ Product │
│ (Success) │
└─────────────────────┘
- Algorithm: Random Forest Classifier (primary), Logistic Regression (alternative)
- Features: Histogram, HOG, LBP, Color moments
- Input: Image features extracted from facial images
- Output: Team member identity with confidence score
- Evaluation: Accuracy, F1-Score (weighted)
- Algorithm: Random Forest Classifier
- Features: MFCC, Spectral, Energy, Chroma, Tempo
- Input: Audio features extracted from voice recordings
- Output: Speaker identity with confidence score
- Evaluation: Accuracy, F1-Score (weighted)
- Algorithm: Random Forest Classifier (primary), XGBoost (alternative)
- Features: Customer purchase history, social media engagement, ratings, sentiment
- Input: Merged customer data with engineered features
- Output: Product category recommendation with confidence score
- Evaluation: Accuracy, F1-Score (weighted), Log Loss
image_features.csv- Extracted image features (all members, all augmentations)audio_features.csv- Extracted audio features (all members, all augmentations)merge-output/merged_data.csv- Merged customer data with engineered features
models/face_recognition_model.pkl- Facial recognition modelmodels/face_label_encoder.pkl- Face label encodermodels/face_feature_columns.pkl- Face feature column namesmodels/voice_verification_model.pkl- Voice verification modelmodels/voice_label_encoder.pkl- Voice label encodermodels/voice_feature_columns.pkl- Voice feature column namesmodels/product_recommendation_model.pkl- Product recommendation modelmodels/product_label_encoder.pkl- Product label encodermodels/product_feature_columns.pkl- Product feature column names
merge-output/plot_purchase_amount_dist.png- Purchase amount distributionmerge-output/plot_box_by_category.png- Box plots by categorymerge-output/plot_correlations.png- Feature correlation matrixspecto_wave/{member}_{phrase}_waveform.png- Audio waveform visualizationsspecto_wave/{member}_{phrase}_spectrogram.png- Audio spectrogram visualizationssample_images_display.png- Sample image display (if generated)
Images/augmented/{member}/- Augmented images (5 types per original image)Audio_data/augmented/{member}/- Augmented audio files (3 types per original audio)
Problem: Scripts report missing files or skip processing
Solutions:
- Ensure files follow naming convention:
{member}_{expression}.jpgor{member}_{phrase}.wav - Check file paths are correct (Images/ for images, Audio_data/raw/ for audio)
- Verify file extensions are correct (.jpg, .wav)
- The scripts will automatically create placeholder files if missing (for initial setup)
Problem: FileNotFoundError when running verification scripts
Solutions:
- Run training scripts before verification:
python train_face_model.py python train_audio_model.py python scripts/product_recommendation.py
- Ensure models are saved in
models/directory - Check that all model files (model, encoder, feature columns) are present
Problem: ModuleNotFoundError when running scripts
Solutions:
- Install all requirements:
pip install -r requirements.txt - Check Python version:
python --version(3.7+ recommended) - For macOS, you may need:
brew install portaudiobefore installing pyaudio
Problem: Audio files not loading or processing errors
Solutions:
- Ensure audio files are in WAV format (or convert them)
- Check file permissions
- Verify audio files are not corrupted
- Sample rate conversion is automatic (target: 16 kHz)
Problem: Images not loading or processing errors
Solutions:
- Ensure images are in JPG/JPEG format
- Check image file permissions
- Verify images are not corrupted
- Ensure images contain faces (for best results)
Problem: Models show low accuracy or poor predictions
Solutions:
- Ensure sufficient training data (multiple images/audio per member)
- Check that augmentations are being applied correctly
- Verify feature extraction is working (check feature CSV files)
- Try adjusting model hyperparameters in training scripts
- Phinah
- Sage
- Ayomide
- Carine