Skip to main content

Optimizing Core ML for On-Device Liveness Detection on iOS

Discover how to leverage Apple's Core ML to implement highly efficient and secure on-device liveness detection for iOS applications. This post delves into model optimization techniques, performance considerations, and the.

Optimizing Core ML for On-Device Liveness Detection on iOS

Contents

In this guide

Jump to the part you need.

On-Device Processing BenefitsImplementing liveness detection directly on iOS devices using Core ML enhances privacy, reduces latency, and minimizes reliance on network connectivity, crucial for a seamless user experience.

Core ML Optimization StrategiesAchieve optimal performance by quantizing models, using an efficient model architecture, and strategically managing compute units for real-time inference without draining battery life.

Robust Anti-Spoofing MeasuresBeyond basic liveness, integrate techniques like 3D depth analysis and passive liveness checks to counter sophisticated presentation attacks, ensuring genuine user verification.

Didit's AI-Native Liveness SolutionDidit provides an AI-native, modular Liveness Detection solution that combines passive and active methods, including 3D Flash and 3D Action & Flash, offering 99.9% accuracy and configurable risk assessment for iOS and other platforms.

In an increasingly digital world, identity verification is paramount. For iOS applications, integrating robust liveness detection directly on-device offers significant advantages in terms of speed, privacy, and security. Apple's Core ML framework provides a powerful foundation for deploying machine learning models locally, enabling developers to perform real-time biometric analysis to prevent spoofing attacks.

The Power of On-Device Liveness Detection with Core ML

On-device liveness detection refers to the process of verifying that a user is a real, live person and not a presentation attack (e.g., a photo, video, or mask) by running the necessary machine learning models directly on the user's device. This approach, particularly on iOS with Core ML, brings several critical benefits:

  • Enhanced Privacy: Biometric data is processed locally, reducing the need to transmit sensitive information to cloud servers, thereby minimizing privacy risks and complying with regulations like GDPR or CCPA.
  • Reduced Latency: Eliminating network roundtrips means near-instantaneous verification results, leading to a smoother and faster user experience.
  • Offline Capabilities: Liveness checks can be performed even without an internet connection, expanding accessibility and reliability in various environments.
  • Lower Costs: Reduced reliance on cloud computing resources can lead to significant cost savings for developers and businesses.
  • Improved Security: Data remains on the device, making it less vulnerable to interception during transit.

Core ML seamlessly integrates with the iOS ecosystem, allowing developers to convert and deploy pre-trained machine learning models (e.g., from TensorFlow, PyTorch) into an optimized, device-native format. This enables high-performance inference, crucial for real-time applications like liveness detection.

Optimizing Core ML Models for Performance

While Core ML offers excellent performance out of the box, optimizing your liveness detection models is key to delivering a fluid user experience without excessive battery drain. Here are practical strategies:

  1. Model Quantization

    Quantization reduces the precision of the numerical representations within your neural network (e.g., from 32-bit floating-point to 16-bit or 8-bit integers). This significantly shrinks model size and speeds up inference, often with minimal impact on accuracy. Core ML Tools provides straightforward methods for quantizing models during conversion.

  2. Efficient Model Architecture

    Choose or design a lightweight model architecture. Models like MobileNet, EfficientNet, or SqueezeNet are specifically designed for mobile and edge devices, balancing accuracy with computational efficiency. Avoid overly complex models that might perform well on powerful GPUs but struggle on mobile CPUs or Neural Engines.

  3. Strategic Compute Unit Selection

    Core ML allows you to specify the compute unit for inference: CPU, GPU, or Neural Engine. For liveness detection, the Neural Engine (available on A11 Bionic and later chips) offers the best performance and energy efficiency. Configure your Core ML model to prioritize the Neural Engine, falling back to the GPU or CPU if unavailable.

  4. Input Pre-processing and Post-processing

    Optimize how your input frames (camera feed) are prepared for the model and how the model's output is interpreted. Minimize expensive image transformations and ensure your pre-processing aligns with the model's training data requirements.

Implementing Robust Anti-Spoofing Techniques

Effective liveness detection goes beyond simply detecting a face; it must actively counter sophisticated presentation attacks. Didit's Liveness Detection, for example, employs multiple methods to ensure robust security:

  • Passive Liveness

    This method analyzes a single frame (or a short sequence) for subtle indicators of liveness, such as texture patterns, reflections, and anomalies commonly found in spoofing attempts (e.g., screen glare, print artifacts). It uses deep learning (Convolutional Neural Networks) to differentiate between a real face and a spoof without requiring user interaction. This offers a fast and convenient experience, suitable for low-friction scenarios.

  • Active Liveness (3D Flash & 3D Action & Flash)

    For higher security needs, active liveness methods engage the user or the device's hardware. Didit's 3D Flash projects dynamic light patterns onto the face, analyzing reflections to create a depth map. This confirms the face's three-dimensional structure, making it highly effective against photos and 2D spoofs. The 3D Action & Flash method adds a randomized action (like blinking or nodding) combined with light pattern analysis. This multi-factor approach offers the highest security against deepfakes, high-quality masks, and video replays, making it ideal for banking, healthcare, and government applications.

  • Warning and Risk Assessment

    A comprehensive liveness solution, such as Didit's, provides detailed reports including confidence scores, detection methods, and warnings for potential issues like 'NO_FACE_DETECTED', 'LIVENESS_FACE_ATTACK', or 'FACE_IN_BLOCKLIST'. This allows developers to configure review thresholds or automatic decline conditions based on their specific risk appetite.

How Didit Helps

Didit is an AI-native, developer-first identity platform that provides modular and highly accurate liveness detection solutions, perfectly complementing your Core ML strategy. Our Liveness Detection product boasts 99.9% accuracy with a false acceptance rate (FAR) of less than 0.1%, ensuring robust protection against spoofing attacks like deepfakes, masks, and printouts. Didit’s modular architecture allows you to integrate our industry-leading passive and active liveness checks, including 3D Flash and 3D Action & Flash, into your iOS application seamlessly, either alongside your on-device Core ML models or as a powerful cloud-based fallback for enhanced security.

We provide a comprehensive liveness report with detailed insights, including confidence scores, methods used, and critical risk warnings, enabling sophisticated fraud prevention workflows. With Didit, you benefit from Core KYC, no setup fees, and a pay-per-successful-check model, making advanced identity verification accessible and scalable for businesses of all sizes. Our AI-native approach ensures continuous improvement and adaptation to new fraud vectors, keeping your users secure.

Ready to Get Started?

Ready to see Didit in action? Get a free demo today.

Start verifying identities for free with Didit's free tier.

Try it

Try this in the sandbox

Run the check this guide describes, free.

ID Verification

The product this post is about, taken from its topic. Run it free in the sandbox.

$0.15 per checkStart free

Author

Alejandro Rosas

Co-founder and CTO

Alejandro Rosas

Alejandro Rosas

Co-founder and CTO

About Didit

Questions

Blog questions

Who writes the Didit blog?
The Didit team. Guides reviewed by Alberto Rosas, co-founder and CEO, carry his byline. The rest are published as Didit.
Which topics does the blog cover?
Eight topics: ID verification, business verification (KYB), AML, sanctions and compliance, fraud prevention, transaction monitoring and crypto, country guides, agents and developers, and product updates.
Is the blog available in my language?
Yes, in 15 languages: English, Spanish, French, German, Brazilian and European Portuguese, Catalan, Russian, Arabic, Chinese, Japanese, Hindi, Indonesian, Korean and Swahili. Not every post is translated, so each language shows the posts it has.
Where do I find product updates?
In the changelog at /changelog/ and under the Product updates topic.
Are these posts legal advice?
No. Regulation posts explain rules; your legal team decides how they apply.
How do I find posts on one topic?
Open one of the eight topics, or search the blog.
Are posts dated?
Yes. Every post shows when it was published and when it was last updated.
Do posts link to the docs?
Developer posts link to the matching page on docs.didit.me and to the API reference.
Is the blog the same as the docs?
No. The blog explains rules, markets and product changes for a general reader, while docs.didit.me holds the integration guides and the API reference. Developer posts link the matching docs page and the API reference they describe.

Compliance built in

Audited, certified and attested.

We hold the certifications and build each country's rules into your flows, so you can launch anywhere without worrying. Security and Compliance center

  • Regulation encoded into your flows

    Tell us what you do and where. Didit lists the rules that apply to you, with sources, and builds the checks each country needs into one workflow.

  • Ready for AMLR

    Every requirement of the new EU anti-money laundering rules, from checking customers to human review, is already covered by a Didit check.

  • Tested in Spain's Treasury sandbox

    Spain's Treasury published its supervised sandbox report on Didit's NFC plus active liveness onboarding; SEPBLAC took part and valued the added measures positively.

  • Audited, not self-declared

    iBeta Level 1 and Level 2. Liveness tested under ISO/IEC 30107-3.

Compliance assistant

Your obligations · 3 regions

EU · AMLRCustomer due diligence, human reviewCovered
Illinois, Texas, ColoradoExplicit biometric consentCovered
Germany · Youth protectionVerified adults only (JMStV)Covered
Workflow checked. Every obligation is met
  • SOC 2 Type 2
  • ISO 27001
  • iBeta Level 1 and Level 2
  • EU regulator attestation
  • FSM youth protection
  • GDPR
  • EBA remote onboarding
  • MiCA compatible
  • FIDO Alliance member
  • AMLREU AML Regulation ready

Integration · Didit MCP

Run Didit from your own AI agent

Connect Didit to Claude, Cursor, VS Code or ChatGPT and just ask in plain words. Your agent can do anything you can do in the console, with the same permissions you have.

Add to ClaudeChatGPT
Didit Academy · Lesson 04 · Use Didit with MCP
  • Build workflowsDescribe the checks you need. The agent creates and publishes the flow.
  • Run investigationsAsk why a session was declined, review cases, search people and companies.
  • Change rulesCreate payment rules, test them on past data and switch them on.
  • Pull reportsAsk for numbers, exports or the audit log.

Verify your first user today.

Start free

Free sandbox. Credit applies to work-email sign-ups.