Skip to main content

What is FaceNet Android?

FaceNet Android is a privacy-focused face recognition app that performs all processing directly on your Android device. Using advanced machine learning models, it can identify faces in real-time by comparing them against a database of known faces - all without sending any data to the cloud.

Quick start

Get the app running in minutes with our APK or build from source

Installation

Detailed setup instructions for building and configuring the app

Key features

Complete privacy

All face recognition happens on-device. Your face data never leaves your phone.

Real-time recognition

Identify faces instantly using your camera with sub-second latency metrics.

Anti-spoofing

Built-in liveness detection prevents recognition using photos or videos.

Vector search

Fast similarity search using ObjectBox’s HNSW algorithm for efficient face matching.

How it works

The app uses a multi-stage pipeline to recognize faces:
1

Face detection

Uses MLKit or Mediapipe to detect and crop faces from images or camera frames
2

Embedding generation

Processes each face through FaceNet to generate a 512-dimensional (or 128-dimensional) embedding vector that uniquely represents facial features
3

Vector storage

Stores embeddings in ObjectBox, an on-device vector database optimized for nearest-neighbor search
4

Recognition

Compares new faces against stored embeddings using cosine similarity to identify the closest match
5

Spoof detection

Validates that the detected face is real using FASNet anti-spoofing models

Technical architecture

The app leverages state-of-the-art on-device machine learning:

FaceNet model

FaceNet is a deep learning model that maps face images to a compact Euclidean space where distances correspond to face similarity. The app provides two variants:
  • facenet.tflite: Outputs 128-dimensional embeddings (smaller, faster)
  • facenet_512.tflite: Outputs 512-dimensional embeddings (more accurate)
Both models accept 160x160 pixel cropped face images and are sourced from the popular deepface library.

Vector database

Face embeddings are stored in ObjectBox, a high-performance NoSQL database with native vector search support. It uses the HNSW (Hierarchical Navigable Small World) algorithm for approximate nearest-neighbor search, with an optional flat search mode for precise results.
@Entity
data class FaceImageRecord(
    @Id var recordID: Long = 0,
    @Index var personID: Long = 0,
    var personName: String = "",
    @HnswIndex(
        dimensions = 512,
        distanceType = VectorDistanceType.COSINE,
    ) var faceEmbedding: FloatArray = floatArrayOf(),
)

Face detection

You can configure the app to use either:
  • MLKit Face Detection: Google’s face detection API optimized for Android
  • Mediapipe Face Detection: Cross-platform face detection using the BlazeFace model
The app defaults to MLKit for better performance on Android devices. You can switch to Mediapipe in AppModule.kt by setting isMLKit = false.

Performance metrics

The app displays real-time latency metrics on the main screen:
  • Face detection time: Milliseconds to detect faces in a frame
  • Embedding generation time: Time to generate FaceNet embeddings
  • Vector search time: Time to find nearest neighbors in the database
  • Spoof detection time: Time to validate face liveness

Modern Android development

The app follows Android best practices:
  • Jetpack Compose: Modern declarative UI toolkit
  • Kotlin Coroutines: Asynchronous programming for smooth performance
  • CameraX: Camera API for consistent behavior across devices
  • Koin: Dependency injection for clean architecture
  • MVVM pattern: Separation of concerns with ViewModels
This project maintains code simplicity and modularity while demonstrating production-ready Android development techniques.

Use cases

FaceNet Android is ideal for:
  • Personal photo organization and tagging
  • Attendance tracking systems
  • Access control applications
  • Educational projects to learn on-device ML
  • Privacy-conscious face recognition solutions

Get started

Try the APK

Download the pre-built APK from GitHub Releases

Build from source

Clone the repository and build the app yourself

Build docs developers (and LLMs) love