Instructions to use litert-community/Silent-Face-Anti-Spoofing-LiteRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/Silent-Face-Anti-Spoofing-LiteRT with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Silent-Face Anti-Spoofing (MiniFASNetV2) β Face liveness (LiteRT GPU)
On-device face liveness / anti-spoofing running fully on the LiteRT CompiledModel
GPU delegate (no CPU fallback). Silent-Face-Anti-Spoofing
detects presentation attacks β a printed photo or a replayed screen shown to the camera
β so a live face passes and a fake is rejected. The anti-fraud building block for face
login / e-KYC. Tiny (1.85 MB), ~5 ms/frame on a Pixel 8a.
- Architecture: MiniFASNetV2 (depthwise-separable CNN) β pure CNN.
- Weights: minivision-ai/Silent-Face-Anti-Spoofing (
2.7_80x80_MiniFASNetV2) Β· Apache-2.0. - Size: 1.85 MB.
A photographed face is correctly flagged as a replay/presentation attack. A live camera capture scores "live". Portrait: Unsplash (free license).
I/O
- Input:
[1, 3, 80, 80]NCHW, BGR,x/255β a face crop (~2.7Γ the face box, centered). - Output:
[1, 3]softmax β class 1 = live/real, classes 0 & 2 = spoof (print / replay). Live score =output[1];argmax == 1β live.
GPU conversion
MiniFASNetV2 is a pure CNN β fully GPU-compatible (168/168 nodes on the delegate, 1 partition; device corr 1.0, ~5 ms) with zero patches (PReLU lowers to GPU-clean relu ops). CPU-exact vs PyTorch (corr 1.0).
Minimal usage
Kotlin (Android, LiteRT CompiledModel GPU)
val options = CompiledModel.Options(Accelerator.GPU)
val model = CompiledModel.create(context.assets, "silentface.tflite", options, null)
val inBufs = model.createInputBuffers()
val outBufs = model.createOutputBuffers()
inBufs[0].writeFloat(faceCropNCHW) // [1,3,80,80] BGR, x/255
model.run(inBufs, outBufs)
val p = outBufs[0].readFloat() // [3] softmax; live = p[1], spoof if argmax != 1
Python (LiteRT / ai-edge-litert)
import numpy as np
from ai_edge_litert.interpreter import Interpreter
it = Interpreter(model_path="silentface.tflite"); it.allocate_tensors()
inp, out = it.get_input_details(), it.get_output_details()
it.set_tensor(inp[0]["index"], x) # [1,3,80,80] float32, BGR, x/255
it.invoke()
p = it.get_tensor(out[0]["index"])[0] # [3]; live = p[1]
Note
The original repo ensembles two MiniFASNet models (crops at scale 2.7 and 4.0) with a face
detector; this ships the primary MiniFASNetV2 (2.7). For best accuracy, feed a detected
face crop and optionally ensemble the second model.
License
Apache-2.0 (Silent-Face-Anti-Spoofing / minivision-ai).
- Downloads last month
- 34
