Description
Face clustering with FaceNet and DBSCAN is great for grouping similar faces offline, but for users with large photo libraries, sequential embedding computation can lead to long wait times and high memory usage. Implementing batch processing (feed multiple images to FaceNet/ONNX at once) and caching (store computed embeddings in SQLite to skip recomputes on unchanged images) would optimize this, making PictoPy more scalable.
Proposed Changes
- In the clustering service (e.g., backend/app/services/clustering.py or equivalent):
- Modify embedding extraction to use batching: Load images in chunks (e.g., via OpenCV imread in loop, then np.stack for ONNX input).
- Add caching: Before computing, check/query SQLite for existing embeddings by image hash/path; store new ones post-compute.
- Handle batch size as configurable (e.g., via .env, default 32 based on hardware).
- Update any related routers/endpoints to return progress (if async) or handle interruptions.
- Add unit tests in backend/tests/ for batch vs. single performance and cache hits.
- Ensure compatibility with CPU/GPU via ONNX Runtime.
References
I'm experienced with Python/ML and would love to implement it via PR if assigned!
Description
Face clustering with FaceNet and DBSCAN is great for grouping similar faces offline, but for users with large photo libraries, sequential embedding computation can lead to long wait times and high memory usage. Implementing batch processing (feed multiple images to FaceNet/ONNX at once) and caching (store computed embeddings in SQLite to skip recomputes on unchanged images) would optimize this, making PictoPy more scalable.
Proposed Changes
References
I'm experienced with Python/ML and would love to implement it via PR if assigned!