π± AI Tremor-Print: Biometric Identification System
A cutting-edge biometric identification system using smartphone magnetometer sensors and fine-tuned AI models to capture neuromuscular micro-tremors for individual identification.
Perfect for: Researchers, neuromuscular analysis, accessibility applications, and low-cost biometric authentication.
π― What is This?
This project demonstrates how to:
- Capture hand tremors using a smartphone's magnetometer sensor
- Extract biometric signatures from magnetic field variations
- Train an AI model (DistilGPT2) to recognize individuals based on tremor patterns
- Verify identity in real-time with sensor data
Key Innovation: Hand tremors are involuntary, reproducible, and unique to each personβmaking them ideal biometric markers!
π Features
- β Low-Cost Hardware - Uses only a smartphone (no special equipment)
- β GPU Optimized - Works on consumer GPUs (2GB+ VRAM) or CPU
- β Real-time Verification - Identify individuals in seconds
- β Privacy-First - All processing done locally, no cloud dependence
- β Research-Ready - Includes full pipeline: data β training β testing
- β Well Documented - Comprehensive guides for setup and troubleshooting
π Project Components
| Component | Purpose | File |
|---|---|---|
| Data Collection | Record tremor data from sensors | *_data.py |
| Feature Extraction | Convert raw sensor data to biometric signatures | conversion.py |
| AI Training | Fine-tune DistilGPT2 on tremor patterns | train.py |
| Verification | Test model accuracy on unknown samples | test_sensor.py |
π Quick Start
Total time: ~30 minutes (10 min setup + 20 min training)
# 1. Clone & Setup (5 min) git clone https://github.com/peterretief/biometric.git cd biometric python3 -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate pip install -r requirements.txt # 2. Prepare Data (5 min) # Place desk.csv, peter.csv, jason.csv in folder (or record new ones) python conversion.py # 3. Train Model (20 min) python train.py # 4. Test (1 min) python test_sensor.py
Expected output:
File: desk.csv | Result: The device is on a stationary desk.
File: peter.csv | Result: The device is held by Peter.
File: jason.csv | Result: The device is held by Jason.
π Project Structure
biometric/
βββ README.md # This file
βββ HOWTO.md # Step-by-step setup guide
βββ requirements.txt # Python dependencies
βββ .gitignore # Exclude large files
β
βββ train.py # Main training script
βββ conversion.py # CSV β JSON feature extraction
βββ test_sensor.py # Model verification
βββ gen_real_data.py # Optional: generate test data
β
βββ *.csv # Sensor data files
β βββ desk.csv # Baseline (stationary)
β βββ peter.csv # Person A
β βββ jason.csv # Person B
β
βββ data.json # Extracted features (auto-generated)
βββ my_trained_model/ # Final trained model (auto-generated)
βββ results/ # Training checkpoints (auto-generated)
π§ Requirements
- Python: 3.8+
- GPU: Optional (CUDA 11.0+) β ~2GB VRAM minimum
- Storage: ~500MB free (for models & data)
- Time: ~20 minutes for training on GPU
π Documentation
- HOWTO.md β Complete step-by-step guide for beginners
- train.py β Inline comments explaining training logic
- conversion.py β Feature extraction details
π¬ How It Works
Phase 1: Data Collection
- Use Physics Toolbox Sensor Suite app on Android/iOS
- Record 30 seconds of magnetometer data for each person
- Save as CSV files (Bx, By, Bz magnetic field components)
Phase 2: Feature Extraction
- Split 30-second recordings into 2-second windows
- Calculate Noise (std) = tremor amplitude
- Calculate Mean = grip orientation
- Create JSON with instruction-response pairs
Phase 3: AI Training
- Tokenize biometric signatures as text
- Fine-tune DistilGPT2 for 50 epochs
- Learn to map tremor patterns β person identity
Phase 4: Verification
- Feed unknown sensor data to trained model
- Model outputs predicted identity
- Compare to ground truth
π Performance
| Metric | Expected | Notes |
|---|---|---|
| Training Loss | < 0.5 | Error rate on training data |
| Accuracy | > 90% | Correct identifications |
| Inference Time | < 1 sec | Time to identify per sample |
| False Positive Rate | < 5% | Wrong identity identification |
π οΈ Customization
Add More People
- Record new CSV files:
alice.csv,bob.csv, etc. - Edit
conversion.pyto include them - Re-run:
python conversion.py && python train.py
Change Model Size
In train.py, replace distilgpt2:
model_name = "gpt2" # Larger, slower, more powerful
Adjust Training Duration
In train.py:
num_train_epochs=100 # Train longer for better accuracy
β‘ GPU Acceleration
Check GPU
python -c "import torch; print(torch.cuda.is_available())"Install CUDA Support
pip install torch --index-url https://download.pytorch.org/whl/cu118
π Troubleshooting
| Issue | Solution |
|---|---|
| ModuleNotFoundError | Run pip install -r requirements.txt |
| Out of Memory (OOM) | Reduce per_device_train_batch_size in train.py |
| No GPU | CPU falls back automatically (slower) |
| Data not found | Ensure *.csv files in project root |
| Poor accuracy | Collect more data or increase epochs |
See HOWTO.md for detailed troubleshooting.
π Medical/Clinical Context
This project is relevant for:
- Neuromuscular Disorders - Detect changes in tremor patterns
- Parkinson's Disease Monitoring - Track motor control progression
- Accessibility Tech - Alternative biometric for those with limitations
- Rehabilitation - Monitor recovery through tremor analysis
Key insight: Standard deviation of magnetic field β Power Spectral Density (PSD) of tremor frequencies, making smartphone sensors viable for clinical applications.
π License
MIT License β Use freely for research, education, and commercial projects.
Copyright (c) 2024-2026 Peter Retief
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction...
π€ Contributing
Have improvements? Found a bug? Want to add features?
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-idea - Commit changes:
git commit -m "Add feature description" - Push to branch:
git push origin feature/your-idea - Open a Pull Request
π Support
- Questions? Open an Issue
- Bug report? Include error message + steps to reproduce
- Feature request? Describe use case and expected behavior
π Learning Resources
- Transformers Library Documentation - For model fine-tuning details
- Medical journals - Search for "tremor analysis" and "accelerometer biometrics"
- Smartphone sensor calibration - Research your phone's magnetometer specifications
π Next Steps
- Read HOWTO.md for detailed setup instructions
- Collect sensor data using Physics Toolbox app
- Run training and verify accuracy
- Customize for your use case
Let's build the future of biometric authentication! π―
Author: Peter Retief
Last Updated: April 2026
Repository: https://github.com/peterretief/biometric