FaceNet Android supports two different FaceNet models that produce embeddings of different dimensions. The choice between them impacts accuracy, performance, and storage requirements.
Available models
The app includes two FaceNet models in the assets folder:
facenet.tflite - Outputs 128-dimensional embeddings
facenet_512.tflite - Outputs 512-dimensional embeddings
Both models accept 160×160 pixel face images as input and produce embeddings that capture unique facial features.
The 512-dimensional model generally provides better accuracy for face recognition, especially with larger datasets, but requires more storage and slightly longer processing time.
Switching between models
To change the FaceNet model, you need to update two files: FaceNet.kt and DataModels.kt.
Step 1: Update the model path
In FaceNet.kt:62, modify the model file path:
Step 2: Update the embedding dimension
In FaceNet.kt:34, change the embeddingDim value:
Step 3: Update the database schema
In DataModels.kt:18-21, update the @HnswIndex dimensions:
Changing the embedding dimension requires rebuilding the app and clearing existing data. The ObjectBox database schema will change, and existing face records will be incompatible.
For most use cases with moderate dataset sizes (under 1000 faces), the 512-dimensional model provides the best balance of accuracy and performance.
Model source
Both models are sourced from the deepface library and converted to TensorFlow Lite format with FP16 optimization. See the source README for conversion scripts.