Temporal Face Liveness Detection INT8
Model Summary
Temporal Face Liveness Detection INT8 is a lightweight multimodal model designed to distinguish between a live face and a spoofed presentation.
The model processes a sequence of 10 RGB face frames together with 8 sensor features per frame. It uses a pretrained MobileNetV3-Small backbone for visual feature extraction, CBAM (Convolutional Block Attention Module) for visual attention, a feature projection network for image and sensor fusion, and an LSTMCell to model temporal information across the 10-frame sequence.
The trained PyTorch model is exported to ONNX and then converted to TensorFlow Lite INT8 for lightweight inference.
The published model is:
liveness_model_int8.tflite
The INT8 TFLite model is approximately 1.58 MB (1,655,200 bytes).
Architecture
10 RGB Frames (224 Γ 224)
β
βΌ
MobileNetV3-Small
β
βΌ
CBAM
ββββββββ΄βββββββ
β β
Channel Spatial
Attention Attention
β β
ββββββββ¬βββββββ
βΌ
Adaptive Average Pooling
β
βΌ
576-D Visual Features
β
ββββββββββββββββ
β β
β 8-D Sensor
β β
ββββββββ¬ββββββββ
βΌ
Feature Concatenation
584-D
β
βΌ
Feature Projection
584 β 256 β 128
β
βΌ
Manual LSTM Unrolling
10 time steps
β
βΌ
128-D final state
β
βΌ
128 β 64 β 1
β
βΌ
Liveness logit
The LSTM is manually unrolled with LSTMCell rather than using a higher-level sequence module. This makes the computation graph more suitable for the ONNX and TensorFlow Lite conversion pipeline.
Usage
The INT8 TFLite model expects two inputs.
Image input
Shape: [1, 10, 3, 224, 224]
Data type: int8
Sensor input
Shape: [1, 10, 8]
Data type: int8
Output
Shape: [1, 1]
Data type: int8
Quantization parameters
The current INT8 model uses the following quantization parameters:
Image input
scale = 0.01865844801068306
zero point = -14
Sensor input
scale = 0.014108065515756607
zero point = -119
Output
scale = 0.04745396226644516
zero point = 34
To convert a floating-point value to the model's quantized representation:
quantized_value = round(float_value / scale + zero_point)
To dequantize an output:
float_value = (quantized_value - zero_point) Γ scale
The current inference application dequantizes the model output, applies a sigmoid function, and uses 0.5 as the decision threshold:
score > 0.5 β Real Face
score <= 0.5 β Fake Face
TFLite example
import tensorflow as tf
interpreter = tf.lite.Interpreter(
model_path="liveness_model_int8.tflite",
num_threads=4,
)
interpreter.allocate_tensors()
inputs = interpreter.get_input_details()
outputs = interpreter.get_output_details()
print("Inputs:")
for item in inputs:
print(item["name"])
print("Shape:", item["shape"])
print("Dtype:", item["dtype"])
print("Quantization:", item["quantization"])
print("Outputs:")
for item in outputs:
print(item["name"])
print("Shape:", item["shape"])
print("Dtype:", item["dtype"])
print("Quantization:", item["quantization"])
To perform inference, the input frames must be resized to 224 Γ 224, converted to RGB, normalized using ImageNet statistics, arranged in the layout expected by the model, and quantized using the model's input scale and zero point.
Important usage requirement
The model is temporal. A single unrelated image is not equivalent to the intended input.
The expected input is a fixed sequence of 10 consecutive frames.
The sensor input is also part of the model interface. If meaningful sensor measurements are unavailable, an application may provide zero-filled sensor values, but this should not be interpreted as equivalent to using real sensor information.
Known failure cases
Performance may degrade under:
- Poor lighting
- Motion blur
- Very low-quality camera input
- Large pose changes
- Faces that are too small
- Partially visible faces
- Unseen spoofing techniques
- Incorrect image normalization
- Incorrect quantization
- Incorrect tensor layout
- Incorrect frame ordering
- Missing or unrealistic sensor information
The model should not be treated as a complete identity-verification system.
System
This model is a component of a larger face-liveness detection pipeline rather than a complete identity-recognition system.
A typical deployment can use the following pipeline:
Camera
β
Face detection
β
Frame collection
β
Image preprocessing
+
Sensor preprocessing
β
INT8 TFLite inference
β
Liveness score
β
Real / Fake decision
The original project also contains:
- PyTorch model implementation
- Dataset loader
- Training pipeline
- ONNX export
- FP32 TFLite conversion
- FP16 TFLite conversion
- INT8 TFLite conversion
- Video inference scripts
- Flask web application
- Face detection using cvzone/MediaPipe
The downstream application is responsible for deciding how the liveness result should be used. For example, it may be one signal in an authentication, KYC, attendance, access-control, or verification workflow.
Implementation Requirements
Training
The model was trained using PyTorch and related machine-learning libraries.
The training configuration includes:
Optimizer: Adam
Initial learning rate: 1e-4
Batch size: 4 by default
Maximum epochs: 20 by default
Early stopping patience: 5 epochs
Loss: BCEWithLogitsLoss
Learning-rate scheduler: ReduceLROnPlateau
The training pipeline evaluates:
- Accuracy
- Precision
- F1-score
- ROC-AUC
- Training loss
- Validation loss
The best checkpoint is selected according to validation loss.
The training code can use CUDA when a compatible GPU is available and otherwise falls back to CPU.
Inference
The final model is intended for CPU-based TensorFlow Lite inference.
The deployment application uses a TFLite interpreter with multiple threads and XNNPack support when available.
Actual inference latency depends on:
- CPU architecture
- Number of threads
- TFLite runtime
- Camera preprocessing
- Face detection
- Memory bandwidth
- Device thermal conditions
No formal energy-consumption measurement is reported for this model.
Model Characteristics
Model initialization
The visual feature extractor is initialized from a pretrained:
MobileNetV3-Small
ImageNet-1K pretrained weights
The project then adds CBAM attention, sensor-feature fusion, manual LSTMCell temporal processing, and the final classifier.
Therefore, the model is fine-tuned from a pretrained visual backbone rather than trained completely from scratch.
Model stats
The original project contains the following model artifacts:
| Model | Format | Approximate size |
|---|---|---|
liveness_model.pth |
PyTorch | 5.06 MB |
liveness_model.onnx |
ONNX | 5.00 MB |
liveness_model_fp16.tflite |
TFLite FP16 | 2.53 MB |
liveness_model_fp32.tflite |
TFLite FP32 | 4.97 MB |
liveness_model_int8.tflite |
TFLite INT8 | 1.58 MiB |
Only the INT8 TFLite model is being published in this Kaggle model release.
The INT8 model uses:
Image input : [1, 10, 3, 224, 224]
Sensor input: [1, 10, 8]
Output : [1, 1]
The architecture contains:
- MobileNetV3-Small visual backbone
- CBAM channel attention
- CBAM spatial attention
- Adaptive average pooling
- Feature projection
- LSTMCell with 128 hidden units
- 64-unit classifier layer
- Binary output logit
A formal device-independent latency benchmark is not provided because latency depends heavily on the target hardware and runtime.
Conversion pipeline
The model conversion pipeline is:
PyTorch
β
ONNX
β
SavedModel
β
TensorFlow Lite
β
Full INT8 quantization
The ONNX export uses fixed input dimensions:
Image : [1, 10, 3, 224, 224]
Sensor: [1, 10, 8]
The temporal sequence is manually unrolled for 10 time steps during export.
The INT8 conversion uses a representative dataset for activation calibration and requests built-in INT8 TensorFlow Lite operations with INT8 input and output tensors.
Quantization
The final published model is fully INT8 quantized for lightweight inference.
The conversion configuration uses:
TFLITE_BUILTINS_INT8
inference_input_type = int8
inference_output_type = int8
A representative dataset is used to calibrate activation ranges.
No differential privacy mechanism was used.
Pruning
No pruning method is currently implemented or documented for this model.
Data Overview
Training data
The project uses a custom dataset loader with separate real and fake directories.
The dataset creates fixed-length clips by taking consecutive sorted .jpg frames. The model uses a clip length of 10 frames.
Each training sample contains:
10 image frames
10 sensor vectors
1 binary label
Training image preprocessing includes:
Resize
β Random Horizontal Flip
β Color Jitter
β Tensor Conversion
β ImageNet Normalization
Validation and testing use resizing, tensor conversion, and ImageNet normalization without the training augmentations.
The expected sensor format is 8 floating-point values per frame.
If a corresponding sensor file is not available, the dataset loader can substitute an 8-value zero vector.
The expected project dataset structure is:
data/
βββ train/
β βββ real/
β βββ fake/
βββ test/
βββ real/
βββ fake/
Dataset size
The project reports approximately:
Training images: 3,333
Testing images: 2,087
The effective number of 10-frame clips is different from the number of image files because the dataset loader creates temporal clips from consecutive frames.
Demographic groups
The project does not provide demographic annotations for the training data.
Therefore, demographic performance has not been formally measured.
The model should not be assumed to have equivalent performance across:
- Age groups
- Genders
- Skin tones
- Geographic populations
- Camera types
- Environmental conditions
Evaluation data
The project uses a separate test directory for model evaluation.
The repository does not provide a documented subject-level split methodology. Therefore, users should evaluate the model carefully for possible similarity between samples, sessions, subjects, or acquisition conditions in their own datasets.
Evaluation Results
Summary
The training and analysis pipelines calculate:
- Accuracy
- Precision
- F1-score
- ROC-AUC
- Training loss
- Validation loss
- Confusion matrices
The project also evaluates multiple model formats, including PyTorch, ONNX, FP32 TFLite, and INT8 TFLite.
This model card does not claim specific final INT8 accuracy, precision, recall, F1, ROC-AUC, APCER, BPCER, or ACER values because a single authoritative, versioned benchmark table for the exact published INT8 file is not included with this model release.
For a research-grade or production release, these metrics should be regenerated using the exact published model and a fixed evaluation split, then recorded here.
Subgroup evaluation results
No formal subgroup analysis is currently documented.
The model has not been comprehensively evaluated across:
- Age groups
- Gender groups
- Skin tones
- Camera manufacturers
- Camera resolutions
- Lighting conditions
- Pose ranges
- Presentation attack types
These remain important areas for future evaluation.
Fairness
A formal fairness analysis was not performed for this release.
No demographic fairness metrics were reported.
For security-sensitive deployments, false acceptance and false rejection behavior should be evaluated across relevant populations and operating conditions.
Usage Limitations
This model should be considered a research and development model for face liveness detection.
It should not be used as the sole security control for high-risk authentication.
Performance may be affected by:
- Unseen spoofing methods
- Printed or displayed media with characteristics different from the training data
- Poor lighting
- Motion blur
- Camera quality
- Face alignment
- Extreme poses
- Incorrect frame ordering
- Incorrect preprocessing
- Incorrect INT8 quantization
- Missing or inaccurate sensor information
- Hardware-specific differences
The model is not an identity-recognition model and does not determine who a person is.
Security considerations
Liveness detection should be treated as one signal in a broader security system.
A production deployment should consider additional controls such as:
- Identity verification
- Rate limiting
- Replay resistance
- Secure communication
- Monitoring
- Appropriate rejection handling
- Abuse prevention
Ethics
Face liveness detection can help reduce presentation attacks, but biometric systems can introduce privacy, security, and fairness risks.
Potential risks include:
- False rejection of legitimate users
- False acceptance of spoofing attempts
- Unequal performance across populations
- Misuse in surveillance or other unintended contexts
- Collection or retention of facial imagery
- Over-reliance on automated security decisions
This model does not perform identity recognition. It estimates whether the provided facial input appears to be live.
Applications using this model should minimize the collection and retention of biometric data, clearly communicate how camera and sensor data are used, and evaluate the model on representative deployment data before using it in security-sensitive workflows.
Reproducibility and Source Code
The complete source code, training pipeline, conversion scripts, inference scripts, and web application are available in the project repository:
GitHub Repository:
https://github.com/VinayBR03/Face-Liveness-Detection
The repository contains the model architecture, dataset loader, training code, conversion scripts, inference scripts, Flask application, and exported model formats.
Published Hugging Face artifact
This Hugging Face model release contains:
liveness_model_int8.tflite
The INT8 TFLite file is the primary artifact intended for users who want to perform lightweight inference without needing the complete training and conversion environment.
The PyTorch, ONNX, FP16 TFLite, FP32 TFLite, training, and conversion files remain available in the GitHub repository.
Citation
If you use this model or the associated project in research or another project, please cite the GitHub repository:
Vinay B R.
Temporal Face Liveness Detection.
GitHub: https://github.com/VinayBR03/Face-Liveness-Detection
- Downloads last month
- 40