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 5 |
+
- tflite
|
| 6 |
+
- mobile
|
| 7 |
+
- gated-inception
|
| 8 |
+
- coordinate-attention
|
| 9 |
+
- on-device
|
| 10 |
+
- accessibility
|
| 11 |
+
license: mit
|
| 12 |
+
pipeline_tag: image-classification
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# ποΈ GazeInception-Lite: Mobile Eye Gaze Estimation
|
| 16 |
+
|
| 17 |
+
**Lightweight TFLite model that estimates where you're looking on a mobile phone screen.**
|
| 18 |
+
|
| 19 |
+
Built with a novel **Gated Inception** architecture that learns to skip unnecessary computation branches, making it extremely fast for on-device inference.
|
| 20 |
+
|
| 21 |
+
## β¨ Key Features
|
| 22 |
+
|
| 23 |
+
| Feature | Details |
|
| 24 |
+
|---------|---------|
|
| 25 |
+
| π¦ **Works in Dark** | Trained with illumination perturbation + low-light augmentation (down to 15% brightness) |
|
| 26 |
+
| π **Glasses Support** | Trained with synthetic glasses overlay (10 frame styles, lens reflections) |
|
| 27 |
+
| ποΈ **Lazy Eye / Strabismus** | Dual-eye architecture processes each eye independently with shared weights |
|
| 28 |
+
| β‘ **Gated Inception** | Learned sigmoid gates skip inactive branches β reduces useless compute |
|
| 29 |
+
| π± **Mobile-First** | 89,754 params (single) / 136,922 params (dual) |
|
| 30 |
+
| π― **Coordinate Attention** | Encodes spatial position for precise iris localization |
|
| 31 |
+
|
| 32 |
+
## π Performance
|
| 33 |
+
|
| 34 |
+
### Accuracy
|
| 35 |
+
|
| 36 |
+
| Model | Screen Error | Inference (CPU) | FPS |
|
| 37 |
+
|-------|-------------|-----------------|-----|
|
| 38 |
+
| Single Eye (F16) | 4.2 mm | 0.59 ms | 1684 |
|
| 39 |
+
| Single Eye (INT8) | 4.3 mm | 0.62 ms | 1619 |
|
| 40 |
+
| Dual Eye (F16) | 14.2 mm | 1.50 ms | 666 |
|
| 41 |
+
| Dual Eye (INT8) | 14.3 mm | 0.93 ms | 1070 |
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
### Robustness (Dual Eye Model)
|
| 45 |
+
|
| 46 |
+
| Condition | Screen Error |
|
| 47 |
+
|-----------|-------------|
|
| 48 |
+
| Dark / Low-light | 13.8 mm |
|
| 49 |
+
| With Glasses | 13.9 mm |
|
| 50 |
+
| Lazy Eye / Strabismus | 13.5 mm |
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
## π¦ Available Models
|
| 54 |
+
|
| 55 |
+
| Model | File | Size | Best For |
|
| 56 |
+
|-------|------|------|----------|
|
| 57 |
+
| Single Eye F16 | `gaze_inception_lite_single_f16.tflite` | 161 KB | Ultra-low latency, simple apps |
|
| 58 |
+
| Single Eye INT8 | `gaze_inception_lite_single_int8.tflite` | 164 KB | Fastest on mobile NPU/DSP |
|
| 59 |
+
| Dual Eye F16 | `gaze_inception_lite_dual_f16.tflite` | 242 KB | Best accuracy, lazy eye support |
|
| 60 |
+
| Dual Eye INT8 | `gaze_inception_lite_dual_int8.tflite` | 267 KB | Best accuracy + speed combo |
|
| 61 |
+
|
| 62 |
+
## ποΈ Architecture
|
| 63 |
+
|
| 64 |
+
### Gated Inception Block
|
| 65 |
+
```
|
| 66 |
+
Input
|
| 67 |
+
βββ Branch 1: 1Γ1 Conv (point features) ββββ Γ gate[0]
|
| 68 |
+
βββ Branch 2: 1Γ1 β 3Γ3 DWConv (local) ββ Γ gate[1]
|
| 69 |
+
βββ Branch 3: 1Γ1 β 5Γ5 DWConv (wide) ββ Γ gate[2]
|
| 70 |
+
βββ Branch 4: MaxPool β 1Γ1 Conv (pool) ββ Γ gate[3]
|
| 71 |
+
β
|
| 72 |
+
Gate Network: GAP β Dense β Sigmoid βββββββββββββββββ
|
| 73 |
+
β
|
| 74 |
+
Output: Concat(gated branches) ββββββββββββββββββββββ
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
The **gate values** (0-1 sigmoid) are learned per-sample. For "easy" inputs (centered gaze, good lighting), the network learns to rely on fewer branches. For complex inputs (extreme gaze, dark, glasses), all branches activate. This provides **adaptive computation** β fast when possible, thorough when needed.
|
| 78 |
+
|
| 79 |
+
### Full Pipeline (Dual Eye Model)
|
| 80 |
+
```
|
| 81 |
+
Left Eye (64Γ64) βββ
|
| 82 |
+
βββ Shared Eye Backbone βββ
|
| 83 |
+
Right Eye (64Γ64) βββ (Gated Inception Γ3 βββ Concat β Dense β (x,y)
|
| 84 |
+
+ CoordAttention) β
|
| 85 |
+
Face (64Γ64) ββββ Lightweight CNN ββββββββββββββ
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
## π Quick Start (Python)
|
| 89 |
+
|
| 90 |
+
```python
|
| 91 |
+
import tensorflow as tf
|
| 92 |
+
import numpy as np
|
| 93 |
+
|
| 94 |
+
# Load model
|
| 95 |
+
interpreter = tf.lite.Interpreter(model_path="gaze_inception_lite_single_f16.tflite")
|
| 96 |
+
interpreter.allocate_tensors()
|
| 97 |
+
|
| 98 |
+
input_details = interpreter.get_input_details()
|
| 99 |
+
output_details = interpreter.get_output_details()
|
| 100 |
+
|
| 101 |
+
# Prepare eye crop (64x64 RGB, normalized to [0,1])
|
| 102 |
+
eye_crop = preprocess_eye(frame) # Your eye detection + crop function
|
| 103 |
+
eye_input = np.expand_dims(eye_crop, axis=0).astype(np.float32)
|
| 104 |
+
|
| 105 |
+
# Run inference
|
| 106 |
+
interpreter.set_tensor(input_details[0]['index'], eye_input)
|
| 107 |
+
interpreter.invoke()
|
| 108 |
+
|
| 109 |
+
# Get screen coordinates
|
| 110 |
+
gaze_xy = interpreter.get_tensor(output_details[0]['index'])[0]
|
| 111 |
+
screen_x = gaze_xy[0] * screen_width # pixels
|
| 112 |
+
screen_y = gaze_xy[1] * screen_height # pixels
|
| 113 |
+
print(f"Looking at: ({screen_x:.0f}, {screen_y:.0f})")
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
### Android (Java/Kotlin)
|
| 117 |
+
```kotlin
|
| 118 |
+
val interpreter = Interpreter(loadModelFile("gaze_inception_lite_single_int8.tflite"))
|
| 119 |
+
val input = Array(1) { Array(64) { Array(64) { FloatArray(3) } } }
|
| 120 |
+
val output = Array(1) { FloatArray(2) }
|
| 121 |
+
|
| 122 |
+
// Fill input with preprocessed eye crop
|
| 123 |
+
interpreter.run(input, output)
|
| 124 |
+
|
| 125 |
+
val gazeX = output[0][0] * screenWidth
|
| 126 |
+
val gazeY = output[0][1] * screenHeight
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
## π§ Training Details
|
| 130 |
+
|
| 131 |
+
- **Data**: 50,000 synthetic samples with comprehensive augmentations
|
| 132 |
+
- **Augmentations**: Dark conditions (30%), glasses (25%), lazy eye (15%), sensor noise (50%), illumination perturbation, diverse skin tones (12), eye colors (7)
|
| 133 |
+
- **Optimizer**: Adam with Cosine Decay LR (1e-3 β 1e-5)
|
| 134 |
+
- **Loss**: MSE on normalized (x,y) coordinates
|
| 135 |
+
- **Architecture Inspiration**:
|
| 136 |
+
- [AGE Framework](https://arxiv.org/abs/2603.26945) - augmentation pipeline
|
| 137 |
+
- [Gated Compression Layers](https://arxiv.org/abs/2303.08970) - gating mechanism
|
| 138 |
+
- [iTracker/GazeCapture](https://arxiv.org/abs/1606.05814) - dual-eye + face architecture
|
| 139 |
+
- [Coordinate Attention](https://arxiv.org/abs/2103.02907) - spatial attention
|
| 140 |
+
|
| 141 |
+
## β οΈ Limitations
|
| 142 |
+
|
| 143 |
+
- Trained on **synthetic data** β fine-tuning on real gaze data (GazeCapture, ETH-XGaze) will significantly improve accuracy
|
| 144 |
+
- Screen coordinate output assumes front-facing phone camera centered above screen
|
| 145 |
+
- Requires separate face/eye detection (use MediaPipe Face Mesh for production)
|
| 146 |
+
- Lazy eye support is based on simulated strabismus β clinical validation needed
|
| 147 |
+
|
| 148 |
+
## π License
|
| 149 |
+
|
| 150 |
+
MIT License β free for commercial and non-commercial use.
|