Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: mit
|
| 4 |
+
tags:
|
| 5 |
+
- tensorflow
|
| 6 |
+
- tflite
|
| 7 |
+
- time-series
|
| 8 |
+
- activity-recognition
|
| 9 |
+
- imu
|
| 10 |
+
- edge-deployment
|
| 11 |
+
- pruning
|
| 12 |
+
- quantization
|
| 13 |
+
datasets:
|
| 14 |
+
- uci-har
|
| 15 |
+
metrics:
|
| 16 |
+
- accuracy
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# IMU Activity Classifier — Pruning + INT8 Quantization
|
| 20 |
+
|
| 21 |
+
Compact 1D-CNN for human activity recognition from 6-axis IMU signals.
|
| 22 |
+
Trained on UCI HAR dataset, compressed via magnitude pruning (78% sparsity)
|
| 23 |
+
+ INT8 quantization for edge/microcontroller deployment.
|
| 24 |
+
|
| 25 |
+
## Results
|
| 26 |
+
|
| 27 |
+
| Model | Size | Accuracy | Latency |
|
| 28 |
+
|-------|------|----------|---------|
|
| 29 |
+
| Baseline FP32 | 358 KB | 93.99% | 46.1 ms |
|
| 30 |
+
| Pruned FP16 TFLite | 191 KB | 92.40% | 0.054 ms |
|
| 31 |
+
| **Pruned INT8 TFLite** | **113 KB** | **92.43%** | **0.026 ms** |
|
| 32 |
+
|
| 33 |
+
- Size reduction: 68.4%
|
| 34 |
+
- Latency speedup: 1775x
|
| 35 |
+
- Accuracy drop: 1.56%
|
| 36 |
+
|
| 37 |
+
## Classes
|
| 38 |
+
WALKING · WALKING_UPSTAIRS · WALKING_DOWNSTAIRS · SITTING · STANDING · LAYING
|
| 39 |
+
|
| 40 |
+
## Compression Pipeline
|
| 41 |
+
1. Baseline 1D-CNN trained on UCI HAR (93.99% accuracy)
|
| 42 |
+
2. Magnitude pruning with PolynomialDecay → 78% sparsity
|
| 43 |
+
3. INT8 post-training quantization → 113KB TFLite model
|
| 44 |
+
|
| 45 |
+
## Confusion Matrix
|
| 46 |
+

|
| 47 |
+
|
| 48 |
+
## Compression Summary
|
| 49 |
+

|
| 50 |
+
|
| 51 |
+
## Training Curves
|
| 52 |
+

|
| 53 |
+
|
| 54 |
+
## Usage
|
| 55 |
+
```python
|
| 56 |
+
import tensorflow as tf
|
| 57 |
+
import numpy as np
|
| 58 |
+
|
| 59 |
+
interpreter = tf.lite.Interpreter("imu_pruned_int8.tflite")
|
| 60 |
+
interpreter.allocate_tensors()
|
| 61 |
+
input_det = interpreter.get_input_details()
|
| 62 |
+
output_det = interpreter.get_output_details()
|
| 63 |
+
|
| 64 |
+
# sample shape: (1, 128, 9) — float32
|
| 65 |
+
sample = np.random.randn(1, 128, 9).astype(np.float32)
|
| 66 |
+
interpreter.set_tensor(input_det[0]['index'], sample)
|
| 67 |
+
interpreter.invoke()
|
| 68 |
+
output = interpreter.get_tensor(output_det[0]['index'])
|
| 69 |
+
|
| 70 |
+
ACTIVITIES = ['WALKING','WALKING_UPSTAIRS','WALKING_DOWNSTAIRS',
|
| 71 |
+
'SITTING','STANDING','LAYING']
|
| 72 |
+
print(ACTIVITIES[np.argmax(output)])
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
## Links
|
| 76 |
+
- GitHub: https://github.com/RAj5517/imu_activity_classifier
|
| 77 |
+
- Dataset: UCI HAR (University of California Irvine)
|