Skip to content

Latest commit

 

History

History
97 lines (75 loc) · 4.12 KB

File metadata and controls

97 lines (75 loc) · 4.12 KB

Model Accuracy Improvements - Implementation Summary

✅ Implemented Best Practices

1. Advanced Data Augmentation

  • Noise Augmentation: Adds Gaussian noise to keypoints (simulates sensor noise)
  • Scale Augmentation: Slightly scales keypoints (handles different body sizes)
  • Shift Augmentation: Shifts keypoints (handles positioning variations)
  • Dropout Augmentation: Randomly zeros keypoints (simulates occlusion)
  • Result: 5x more training data per video (1 original + 5 augmented)

2. Improved Model Architecture

  • Deeper LSTM Network: 4 LSTM layers (128→256→256→128 units)
  • Batch Normalization: After each LSTM layer for stable training
  • Dropout Regularization: 0.2-0.4 dropout rates to prevent overfitting
  • L2 Regularization: Weight decay (0.001) to reduce overfitting
  • Better Activation: Using tanh for LSTMs (better gradient flow)
  • Dense Layers: 256→128→64 units with proper regularization

3. Cross-Validation

  • K-Fold Cross-Validation: 3-fold stratified cross-validation
  • Stratified Splits: Ensures balanced class distribution in each fold
  • Best Model Selection: Automatically selects the best performing fold
  • Result: More robust model that generalizes better

4. Advanced Training Techniques

  • Learning Rate Scheduling: ReduceLROnPlateau reduces LR when stuck
  • Early Stopping: Stops training if validation doesn't improve (patience=25)
  • Model Checkpointing: Saves best model weights automatically
  • Adam Optimizer: Tuned hyperparameters (LR=0.001, beta1=0.9, beta2=0.999)

5. Comprehensive Evaluation

  • Classification Report: Precision, Recall, F1-score per class
  • Confusion Matrix: Visual representation of classification errors
  • Per-Class Accuracy: Shows which words are recognized best
  • Top-2 Accuracy: (Removed - not available in standard Keras)

6. Real-Time Detection Improvements

  • Prediction Smoothing: Uses deque with majority voting (last 5 predictions)
  • Confidence Thresholding: Only shows predictions with ≥30% confidence
  • Consensus Requirement: Needs at least 2 votes for a prediction
  • Dynamic Model Loading: Automatically uses best available model (Advanced > Improved > Original)

📊 Expected Improvements

  1. Accuracy: Should improve from ~60-70% to 85-95% with proper training
  2. Robustness: Better handling of variations in lighting, positioning, body size
  3. Generalization: Cross-validation ensures model works on unseen data
  4. Stability: Prediction smoothing reduces flickering in real-time detection

🚀 How to Use

Training the Advanced Model:

python train-advanced-model.py --data-dir training-data --epochs 200 --batch-size 16 --augment 5 --folds 3

Or use the batch file:

START-ADVANCED-TRAINING.bat

Running Real-Time Detection:

The realtime-detection.py script will automatically detect and use the advanced model if available:

python realtime-detection.py

📁 Model Outputs

  • lstm-model-advanced/: Best model from cross-validation
    • best_model.hdf5: Model weights
    • words.txt: List of recognized words
    • training_log.csv: Training history for each fold

🔧 Configuration Options

  • --epochs: Number of training epochs (default: 200)
  • --batch-size: Batch size (default: 16)
  • --augment: Augmentation multiplier (default: 5)
  • --folds: Cross-validation folds (default: 3, use 5 for more robust)

⚠️ Notes

  • Training time will be longer due to cross-validation and augmentation
  • Each fold trains independently, so 3 folds = 3x training time
  • With 5x augmentation, dataset size increases significantly
  • Monitor GPU/CPU usage - training is computationally intensive

📈 Next Steps for Even Better Accuracy

  1. More Data: Collect more videos per word (aim for 50+ per class)
  2. Transfer Learning: Use pre-trained pose estimation models
  3. Ensemble Models: Combine multiple models for final prediction
  4. Temporal Attention: Add attention mechanisms to focus on important frames
  5. 3D CNNs: Consider 3D convolutions for spatio-temporal features