edgeface-knn 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- edgeface_knn-2.0.0/LICENSE +21 -0
- edgeface_knn-2.0.0/PKG-INFO +295 -0
- edgeface_knn-2.0.0/README.md +272 -0
- edgeface_knn-2.0.0/pyproject.toml +40 -0
- edgeface_knn-2.0.0/setup.cfg +4 -0
- edgeface_knn-2.0.0/src/edge_face/__init__.py +1 -0
- edgeface_knn-2.0.0/src/edge_face/cli.py +143 -0
- edgeface_knn-2.0.0/src/edge_face/config.py +28 -0
- edgeface_knn-2.0.0/src/edge_face/dataset.py +76 -0
- edgeface_knn-2.0.0/src/edge_face/detector.py +25 -0
- edgeface_knn-2.0.0/src/edge_face/model.py +41 -0
- edgeface_knn-2.0.0/src/edge_face/pipeline.py +110 -0
- edgeface_knn-2.0.0/src/edgeface_knn.egg-info/PKG-INFO +295 -0
- edgeface_knn-2.0.0/src/edgeface_knn.egg-info/SOURCES.txt +16 -0
- edgeface_knn-2.0.0/src/edgeface_knn.egg-info/dependency_links.txt +1 -0
- edgeface_knn-2.0.0/src/edgeface_knn.egg-info/entry_points.txt +2 -0
- edgeface_knn-2.0.0/src/edgeface_knn.egg-info/requires.txt +4 -0
- edgeface_knn-2.0.0/src/edgeface_knn.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Saksham Bajaj
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: edgeface-knn
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Real-time CPU face recognition pipeline using classical ML, refactored from an embedded Raspberry Pi deployment into an installable modular package.
|
|
5
|
+
Author: Saksham Bajaj
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/SakshamBjj/edge-face-recognition-v2
|
|
8
|
+
Project-URL: Source, https://github.com/SakshamBjj/edge-face-recognition-v2
|
|
9
|
+
Project-URL: Tracker, https://github.com/SakshamBjj/edge-face-recognition-v2/issues
|
|
10
|
+
Keywords: face recognition,computer vision,opencv,edge ml,classical machine learning
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: opencv-python>=4.5
|
|
19
|
+
Requires-Dist: numpy>=1.21
|
|
20
|
+
Requires-Dist: scikit-learn>=1.0
|
|
21
|
+
Requires-Dist: pyyaml>=5.4
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# Edge Face Recognition (CPU-Only)
|
|
25
|
+
|
|
26
|
+
> ⚠️ Repository name contains `v2` to indicate the refactored codebase.
|
|
27
|
+
> The installable Python package remains `edge-face-recognition` (no v2) to preserve upgrade compatibility.
|
|
28
|
+
|
|
29
|
+
Real-time face recognition designed for CPU-only environments — laptops, embedded systems, and Raspberry-Pi-class devices.
|
|
30
|
+
|
|
31
|
+
Classical computer vision pipeline (Haar Cascade + KNN) engineered for deterministic low-latency inference without GPUs or deep learning frameworks.
|
|
32
|
+
|
|
33
|
+
**Latency:** ~40 ms per processed frame
|
|
34
|
+
**Effective throughput:** ~15 FPS (frame-skipped real-time UX)
|
|
35
|
+
|
|
36
|
+
> Originally built as a Raspberry Pi prototype (Sept 2024).
|
|
37
|
+
> Refactored into a modular installable Python package (Dec 2025).
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## What this project is
|
|
42
|
+
|
|
43
|
+
A lightweight identity recognition system intended for:
|
|
44
|
+
|
|
45
|
+
* Attendance systems
|
|
46
|
+
* Lab / hostel / office access logging
|
|
47
|
+
* Offline environments
|
|
48
|
+
* Edge devices with no GPU
|
|
49
|
+
* Privacy-sensitive deployments (no cloud inference)
|
|
50
|
+
|
|
51
|
+
The system prioritizes **correct identification over aggressive guessing** — unknown faces are rejected instead of force-matched.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
> ⚠️ **WSL note:**
|
|
58
|
+
> The project can be developed and packaged inside WSL, but webcam capture must be run using native Windows Python.
|
|
59
|
+
> WSL does not expose camera devices to OpenCV.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
### Option A — Development setup (WSL recommended)
|
|
64
|
+
|
|
65
|
+
Use this if you are modifying code or building the package.
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
git clone https://github.com/SakshamBjj/edge-face-recognition-v2.git
|
|
69
|
+
cd edge-face-recognition-v2
|
|
70
|
+
pip install -e .
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Verify CLI:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
edge-face --help
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
### Option B — Usage setup (Windows / native OS)
|
|
82
|
+
|
|
83
|
+
For actual face collection and recognition:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install edgeface-knn
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Running the Application
|
|
92
|
+
|
|
93
|
+
> Run the following commands from **Windows terminal (PowerShell / CMD)**, not WSL.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
### 1) Register people
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
edge-face collect --name Alice
|
|
101
|
+
edge-face collect --name Bob
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Captures 100 samples per person via webcam automatically.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
### 2) Run recognition
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
edge-face run
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Controls:
|
|
115
|
+
|
|
116
|
+
| Key | Action |
|
|
117
|
+
| --- | -------------- |
|
|
118
|
+
| `o` | Log attendance |
|
|
119
|
+
| `q` | Quit |
|
|
120
|
+
|
|
121
|
+
Logs saved to:
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
attendance/YYYY-MM-DD.csv
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
### 3) Optional configuration
|
|
130
|
+
|
|
131
|
+
Override default parameters:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
edge-face run --config configs/my_config.yaml
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Why this split exists
|
|
140
|
+
|
|
141
|
+
WSL is a virtualized Linux environment and does not provide direct access to webcam hardware.
|
|
142
|
+
The package itself is OS-independent, but real-time capture requires native OS execution.
|
|
143
|
+
|
|
144
|
+
Typical workflow:
|
|
145
|
+
|
|
146
|
+
| Task | Environment |
|
|
147
|
+
| ----------------------- | ----------- |
|
|
148
|
+
| Development / packaging | WSL |
|
|
149
|
+
| Face collection | Windows |
|
|
150
|
+
| Real-time recognition | Windows |
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Runtime Pipeline
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
Camera (30 FPS)
|
|
158
|
+
→ Grayscale conversion
|
|
159
|
+
→ Haar Cascade detection (~20 ms)
|
|
160
|
+
→ Crop + resize (50×50)
|
|
161
|
+
→ Flatten vector
|
|
162
|
+
→ KNN classification (~15 ms)
|
|
163
|
+
→ Confidence scoring
|
|
164
|
+
→ Unknown rejection
|
|
165
|
+
→ Overlay + logging
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Frame skipping processes every 2nd frame to maintain smooth real-time UX.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Unknown Face Handling
|
|
173
|
+
|
|
174
|
+
The system favors **precision over recall**.
|
|
175
|
+
|
|
176
|
+
Instead of always predicting a nearest neighbor:
|
|
177
|
+
|
|
178
|
+
| Confidence | Result |
|
|
179
|
+
| ----------- | ----------------- |
|
|
180
|
+
| ≥ threshold | Person identified |
|
|
181
|
+
| < threshold | Marked “Unknown” |
|
|
182
|
+
|
|
183
|
+
Prevents the most serious failure in face recognition systems: logging the wrong person.
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Why Classical ML instead of Deep Learning?
|
|
188
|
+
|
|
189
|
+
| Factor | This Project (KNN) | CNN Face Recognition |
|
|
190
|
+
| ------------- | ------------------- | -------------------- |
|
|
191
|
+
| Model size | <1 MB | ~90 MB |
|
|
192
|
+
| CPU inference | ~40 ms | ~300 ms |
|
|
193
|
+
| GPU required | No | Yes |
|
|
194
|
+
| Training data | ~100 samples/person | 1000+ samples/person |
|
|
195
|
+
|
|
196
|
+
**Design goal:** predictable latency on CPU hardware
|
|
197
|
+
—not maximum accuracy on servers.
|
|
198
|
+
|
|
199
|
+
Deep learning was prototyped but exceeded real-time limits without GPU acceleration.
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Performance
|
|
204
|
+
|
|
205
|
+
### Accuracy (typical indoor lighting)
|
|
206
|
+
|
|
207
|
+
| Condition | Accuracy |
|
|
208
|
+
| ------------ | -------- |
|
|
209
|
+
| Frontal face | ~95% |
|
|
210
|
+
| Glasses | ~90% |
|
|
211
|
+
| Mask | ~75% |
|
|
212
|
+
| ±30° angle | ~70% |
|
|
213
|
+
|
|
214
|
+
### Latency
|
|
215
|
+
|
|
216
|
+
| Stage | Time |
|
|
217
|
+
| -------------- | ---------- |
|
|
218
|
+
| Detection | 20 ms |
|
|
219
|
+
| Preprocess | 5 ms |
|
|
220
|
+
| Classification | 15 ms |
|
|
221
|
+
| **Total** | **~40 ms** |
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## Known Limitations
|
|
226
|
+
|
|
227
|
+
1. Low lighting reduces detection reliability
|
|
228
|
+
2. Side profiles (>30°) often not detected
|
|
229
|
+
3. Performance degrades beyond ~100 identities (KNN O(n))
|
|
230
|
+
4. Not spoof-proof (photo attacks possible)
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## Package Layout
|
|
235
|
+
|
|
236
|
+
```
|
|
237
|
+
edge-face-recognition-v2/
|
|
238
|
+
├── configs/default.yaml
|
|
239
|
+
├── src/edge_face/
|
|
240
|
+
│ ├── __init__.py
|
|
241
|
+
│ ├── cli.py
|
|
242
|
+
│ ├── config.py
|
|
243
|
+
│ ├── detector.py
|
|
244
|
+
│ ├── dataset.py
|
|
245
|
+
│ ├── model.py
|
|
246
|
+
│ └── pipeline.py
|
|
247
|
+
├── scripts/collect_faces.py
|
|
248
|
+
├── data/ (generated)
|
|
249
|
+
└── attendance/ (generated)
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Engineering Tradeoffs
|
|
255
|
+
|
|
256
|
+
| Decision | Reason | Cost |
|
|
257
|
+
| ----------------- | ------------------------------ | --------------------------- |
|
|
258
|
+
| Haar Cascade | 20 ms detection | Angle robustness |
|
|
259
|
+
| Raw pixels | No feature extraction overhead | Less compact representation |
|
|
260
|
+
| KNN | No training step | Scaling limits |
|
|
261
|
+
| Frame skipping | Real-time UX | Slight temporal jitter |
|
|
262
|
+
| Unknown rejection | Avoid false positives | Occasional false negatives |
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Project Evolution
|
|
267
|
+
|
|
268
|
+
| Version | Focus |
|
|
269
|
+
| ------- | ------------------------------------- |
|
|
270
|
+
| v1 | Embedded Raspberry Pi prototype |
|
|
271
|
+
| v2 | Installable reusable software package |
|
|
272
|
+
|
|
273
|
+
Archived prototype available in repository history.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## What this demonstrates
|
|
278
|
+
|
|
279
|
+
* Designing ML systems under hardware constraints
|
|
280
|
+
* Latency-driven model selection
|
|
281
|
+
* Converting prototype code into a distributable tool
|
|
282
|
+
* Building CLI-driven reproducible workflows
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## References
|
|
287
|
+
|
|
288
|
+
* Viola-Jones Face Detection
|
|
289
|
+
* OpenCV face recognition documentation
|
|
290
|
+
* scikit-learn KNN implementation
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
**Author:** Saksham Bajaj
|
|
295
|
+
**License:** MIT
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# Edge Face Recognition (CPU-Only)
|
|
2
|
+
|
|
3
|
+
> ⚠️ Repository name contains `v2` to indicate the refactored codebase.
|
|
4
|
+
> The installable Python package remains `edge-face-recognition` (no v2) to preserve upgrade compatibility.
|
|
5
|
+
|
|
6
|
+
Real-time face recognition designed for CPU-only environments — laptops, embedded systems, and Raspberry-Pi-class devices.
|
|
7
|
+
|
|
8
|
+
Classical computer vision pipeline (Haar Cascade + KNN) engineered for deterministic low-latency inference without GPUs or deep learning frameworks.
|
|
9
|
+
|
|
10
|
+
**Latency:** ~40 ms per processed frame
|
|
11
|
+
**Effective throughput:** ~15 FPS (frame-skipped real-time UX)
|
|
12
|
+
|
|
13
|
+
> Originally built as a Raspberry Pi prototype (Sept 2024).
|
|
14
|
+
> Refactored into a modular installable Python package (Dec 2025).
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## What this project is
|
|
19
|
+
|
|
20
|
+
A lightweight identity recognition system intended for:
|
|
21
|
+
|
|
22
|
+
* Attendance systems
|
|
23
|
+
* Lab / hostel / office access logging
|
|
24
|
+
* Offline environments
|
|
25
|
+
* Edge devices with no GPU
|
|
26
|
+
* Privacy-sensitive deployments (no cloud inference)
|
|
27
|
+
|
|
28
|
+
The system prioritizes **correct identification over aggressive guessing** — unknown faces are rejected instead of force-matched.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
> ⚠️ **WSL note:**
|
|
35
|
+
> The project can be developed and packaged inside WSL, but webcam capture must be run using native Windows Python.
|
|
36
|
+
> WSL does not expose camera devices to OpenCV.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
### Option A — Development setup (WSL recommended)
|
|
41
|
+
|
|
42
|
+
Use this if you are modifying code or building the package.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
git clone https://github.com/SakshamBjj/edge-face-recognition-v2.git
|
|
46
|
+
cd edge-face-recognition-v2
|
|
47
|
+
pip install -e .
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Verify CLI:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
edge-face --help
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
### Option B — Usage setup (Windows / native OS)
|
|
59
|
+
|
|
60
|
+
For actual face collection and recognition:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install edgeface-knn
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Running the Application
|
|
69
|
+
|
|
70
|
+
> Run the following commands from **Windows terminal (PowerShell / CMD)**, not WSL.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
### 1) Register people
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
edge-face collect --name Alice
|
|
78
|
+
edge-face collect --name Bob
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Captures 100 samples per person via webcam automatically.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
### 2) Run recognition
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
edge-face run
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Controls:
|
|
92
|
+
|
|
93
|
+
| Key | Action |
|
|
94
|
+
| --- | -------------- |
|
|
95
|
+
| `o` | Log attendance |
|
|
96
|
+
| `q` | Quit |
|
|
97
|
+
|
|
98
|
+
Logs saved to:
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
attendance/YYYY-MM-DD.csv
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
### 3) Optional configuration
|
|
107
|
+
|
|
108
|
+
Override default parameters:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
edge-face run --config configs/my_config.yaml
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Why this split exists
|
|
117
|
+
|
|
118
|
+
WSL is a virtualized Linux environment and does not provide direct access to webcam hardware.
|
|
119
|
+
The package itself is OS-independent, but real-time capture requires native OS execution.
|
|
120
|
+
|
|
121
|
+
Typical workflow:
|
|
122
|
+
|
|
123
|
+
| Task | Environment |
|
|
124
|
+
| ----------------------- | ----------- |
|
|
125
|
+
| Development / packaging | WSL |
|
|
126
|
+
| Face collection | Windows |
|
|
127
|
+
| Real-time recognition | Windows |
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Runtime Pipeline
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
Camera (30 FPS)
|
|
135
|
+
→ Grayscale conversion
|
|
136
|
+
→ Haar Cascade detection (~20 ms)
|
|
137
|
+
→ Crop + resize (50×50)
|
|
138
|
+
→ Flatten vector
|
|
139
|
+
→ KNN classification (~15 ms)
|
|
140
|
+
→ Confidence scoring
|
|
141
|
+
→ Unknown rejection
|
|
142
|
+
→ Overlay + logging
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Frame skipping processes every 2nd frame to maintain smooth real-time UX.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Unknown Face Handling
|
|
150
|
+
|
|
151
|
+
The system favors **precision over recall**.
|
|
152
|
+
|
|
153
|
+
Instead of always predicting a nearest neighbor:
|
|
154
|
+
|
|
155
|
+
| Confidence | Result |
|
|
156
|
+
| ----------- | ----------------- |
|
|
157
|
+
| ≥ threshold | Person identified |
|
|
158
|
+
| < threshold | Marked “Unknown” |
|
|
159
|
+
|
|
160
|
+
Prevents the most serious failure in face recognition systems: logging the wrong person.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Why Classical ML instead of Deep Learning?
|
|
165
|
+
|
|
166
|
+
| Factor | This Project (KNN) | CNN Face Recognition |
|
|
167
|
+
| ------------- | ------------------- | -------------------- |
|
|
168
|
+
| Model size | <1 MB | ~90 MB |
|
|
169
|
+
| CPU inference | ~40 ms | ~300 ms |
|
|
170
|
+
| GPU required | No | Yes |
|
|
171
|
+
| Training data | ~100 samples/person | 1000+ samples/person |
|
|
172
|
+
|
|
173
|
+
**Design goal:** predictable latency on CPU hardware
|
|
174
|
+
—not maximum accuracy on servers.
|
|
175
|
+
|
|
176
|
+
Deep learning was prototyped but exceeded real-time limits without GPU acceleration.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Performance
|
|
181
|
+
|
|
182
|
+
### Accuracy (typical indoor lighting)
|
|
183
|
+
|
|
184
|
+
| Condition | Accuracy |
|
|
185
|
+
| ------------ | -------- |
|
|
186
|
+
| Frontal face | ~95% |
|
|
187
|
+
| Glasses | ~90% |
|
|
188
|
+
| Mask | ~75% |
|
|
189
|
+
| ±30° angle | ~70% |
|
|
190
|
+
|
|
191
|
+
### Latency
|
|
192
|
+
|
|
193
|
+
| Stage | Time |
|
|
194
|
+
| -------------- | ---------- |
|
|
195
|
+
| Detection | 20 ms |
|
|
196
|
+
| Preprocess | 5 ms |
|
|
197
|
+
| Classification | 15 ms |
|
|
198
|
+
| **Total** | **~40 ms** |
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Known Limitations
|
|
203
|
+
|
|
204
|
+
1. Low lighting reduces detection reliability
|
|
205
|
+
2. Side profiles (>30°) often not detected
|
|
206
|
+
3. Performance degrades beyond ~100 identities (KNN O(n))
|
|
207
|
+
4. Not spoof-proof (photo attacks possible)
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Package Layout
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
edge-face-recognition-v2/
|
|
215
|
+
├── configs/default.yaml
|
|
216
|
+
├── src/edge_face/
|
|
217
|
+
│ ├── __init__.py
|
|
218
|
+
│ ├── cli.py
|
|
219
|
+
│ ├── config.py
|
|
220
|
+
│ ├── detector.py
|
|
221
|
+
│ ├── dataset.py
|
|
222
|
+
│ ├── model.py
|
|
223
|
+
│ └── pipeline.py
|
|
224
|
+
├── scripts/collect_faces.py
|
|
225
|
+
├── data/ (generated)
|
|
226
|
+
└── attendance/ (generated)
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Engineering Tradeoffs
|
|
232
|
+
|
|
233
|
+
| Decision | Reason | Cost |
|
|
234
|
+
| ----------------- | ------------------------------ | --------------------------- |
|
|
235
|
+
| Haar Cascade | 20 ms detection | Angle robustness |
|
|
236
|
+
| Raw pixels | No feature extraction overhead | Less compact representation |
|
|
237
|
+
| KNN | No training step | Scaling limits |
|
|
238
|
+
| Frame skipping | Real-time UX | Slight temporal jitter |
|
|
239
|
+
| Unknown rejection | Avoid false positives | Occasional false negatives |
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Project Evolution
|
|
244
|
+
|
|
245
|
+
| Version | Focus |
|
|
246
|
+
| ------- | ------------------------------------- |
|
|
247
|
+
| v1 | Embedded Raspberry Pi prototype |
|
|
248
|
+
| v2 | Installable reusable software package |
|
|
249
|
+
|
|
250
|
+
Archived prototype available in repository history.
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## What this demonstrates
|
|
255
|
+
|
|
256
|
+
* Designing ML systems under hardware constraints
|
|
257
|
+
* Latency-driven model selection
|
|
258
|
+
* Converting prototype code into a distributable tool
|
|
259
|
+
* Building CLI-driven reproducible workflows
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## References
|
|
264
|
+
|
|
265
|
+
* Viola-Jones Face Detection
|
|
266
|
+
* OpenCV face recognition documentation
|
|
267
|
+
* scikit-learn KNN implementation
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
**Author:** Saksham Bajaj
|
|
272
|
+
**License:** MIT
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "edgeface-knn"
|
|
3
|
+
version = "2.0.0"
|
|
4
|
+
description = "Real-time CPU face recognition pipeline using classical ML, refactored from an embedded Raspberry Pi deployment into an installable modular package."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = {text = "MIT"}
|
|
7
|
+
requires-python = ">=3.9"
|
|
8
|
+
|
|
9
|
+
authors = [{name = "Saksham Bajaj"}]
|
|
10
|
+
|
|
11
|
+
keywords = ["face recognition", "computer vision", "opencv", "edge ml", "classical machine learning"]
|
|
12
|
+
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
"Topic :: Scientific/Engineering :: Image Recognition",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
dependencies = [
|
|
21
|
+
"opencv-python>=4.5",
|
|
22
|
+
"numpy>=1.21",
|
|
23
|
+
"scikit-learn>=1.0",
|
|
24
|
+
"pyyaml>=5.4",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://github.com/SakshamBjj/edge-face-recognition-v2"
|
|
29
|
+
Source = "https://github.com/SakshamBjj/edge-face-recognition-v2"
|
|
30
|
+
Tracker = "https://github.com/SakshamBjj/edge-face-recognition-v2/issues"
|
|
31
|
+
|
|
32
|
+
[project.scripts]
|
|
33
|
+
edge-face = "edge_face.cli:main"
|
|
34
|
+
|
|
35
|
+
[build-system]
|
|
36
|
+
requires = ["setuptools>=61"]
|
|
37
|
+
build-backend = "setuptools.build_meta"
|
|
38
|
+
|
|
39
|
+
[tool.setuptools.packages.find]
|
|
40
|
+
where = ["src"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""edge_face — CPU-only real-time face recognition."""
|