Downloads · 30 days
10
14% of all-time downloads
vinaybr-0718/Temporal-Face-Liveness-Detection-INT8
Temporal-Face-Liveness-Detection-INT8 is a video classification model from vinaybr-0718. Use it for the video classification task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
Temporal Face Liveness Detection INT8 is a lightweight multimodal model designed to distinguish between a live face and a spoofed presentation.
Downloads · 30 days
10
14% of all-time downloads
All-time downloads
71
Public
Repo size
1.7 MB
Likes
0
Public
Click a slice to open those files.
.tflite1.7 MB · 99%
From the Hugging Face model README
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).
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.
The INT8 TFLite model expects two inputs.
Shape: [1, 10, 3, 224, 224]
Data type: int8
Shape: [1, 10, 8]
Data type: int8
Shape: [1, 1]
Data type: int8
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
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.
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.
Performance may degrade under:
The model should not be treated as a complete identity-verification 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:
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.
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:
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.
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:
No formal energy-consumption measurement is reported for this model.
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.
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:
A formal device-independent latency benchmark is not provided because latency depends heavily on the target hardware and runtime.
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.
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.
No pruning method is currently implemented or documented for this model.
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/
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.
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:
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.
The training and analysis pipelines calculate:
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.
No formal subgroup analysis is currently documented.
The model has not been comprehensively evaluated across:
These remain important areas for future evaluation.
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.
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:
The model is not an identity-recognition model and does not determine who a person is.
Liveness detection should be treated as one signal in a broader security system.
A production deployment should consider additional controls such as:
Face liveness detection can help reduce presentation attacks, but biometric systems can introduce privacy, security, and fairness risks.
Potential risks include:
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.
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.
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.
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