๐ฑ 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













