mlboydaisuke commited on
Commit
f2448f7
·
verified ·
1 Parent(s): dde73e6

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +81 -0
README.md ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: litert
4
+ pipeline_tag: image-classification
5
+ tags:
6
+ - litert
7
+ - tflite
8
+ - android
9
+ - on-device
10
+ - gpu
11
+ - face-anti-spoofing
12
+ - liveness
13
+ - presentation-attack-detection
14
+ - face
15
+ ---
16
+
17
+ # Silent-Face Anti-Spoofing (MiniFASNetV2) — Face liveness (LiteRT GPU)
18
+
19
+ On-device **face liveness / anti-spoofing** running **fully on the LiteRT `CompiledModel`
20
+ GPU** delegate (no CPU fallback). [Silent-Face-Anti-Spoofing](https://github.com/minivision-ai/Silent-Face-Anti-Spoofing)
21
+ detects **presentation attacks** — a printed photo or a replayed screen shown to the camera
22
+ — so a live face passes and a fake is rejected. The anti-fraud building block for face
23
+ login / e-KYC. Tiny (**1.85 MB**), ~5 ms/frame on a Pixel 8a.
24
+
25
+ - **Architecture:** MiniFASNetV2 (depthwise-separable CNN) — pure CNN.
26
+ - **Weights:** [minivision-ai/Silent-Face-Anti-Spoofing](https://github.com/minivision-ai/Silent-Face-Anti-Spoofing) (`2.7_80x80_MiniFASNetV2`) · Apache-2.0.
27
+ - **Size:** 1.85 MB.
28
+
29
+ ![Silent-Face liveness](hero.png)
30
+
31
+ *A photographed face is correctly flagged as a replay/presentation attack. A live camera capture scores "live". Portrait: Unsplash (free license).*
32
+
33
+ ## I/O
34
+
35
+ - **Input:** `[1, 3, 80, 80]` NCHW, **BGR**, `x/255` — a face crop (~2.7× the face box, centered).
36
+ - **Output:** `[1, 3]` softmax — **class 1 = live/real**, classes 0 & 2 = spoof (print / replay).
37
+ Live score = `output[1]`; `argmax == 1` → live.
38
+
39
+ ## GPU conversion
40
+
41
+ MiniFASNetV2 is a pure CNN → fully GPU-compatible (**168/168 nodes on the delegate, 1
42
+ partition**; device corr 1.0, ~5 ms) with **zero patches** (PReLU lowers to GPU-clean
43
+ relu ops). CPU-exact vs PyTorch (corr 1.0).
44
+
45
+ ## Minimal usage
46
+
47
+ ### Kotlin (Android, LiteRT CompiledModel GPU)
48
+
49
+ ```kotlin
50
+ val options = CompiledModel.Options(Accelerator.GPU)
51
+ val model = CompiledModel.create(context.assets, "silentface.tflite", options, null)
52
+ val inBufs = model.createInputBuffers()
53
+ val outBufs = model.createOutputBuffers()
54
+
55
+ inBufs[0].writeFloat(faceCropNCHW) // [1,3,80,80] BGR, x/255
56
+ model.run(inBufs, outBufs)
57
+ val p = outBufs[0].readFloat() // [3] softmax; live = p[1], spoof if argmax != 1
58
+ ```
59
+
60
+ ### Python (LiteRT / ai-edge-litert)
61
+
62
+ ```python
63
+ import numpy as np
64
+ from ai_edge_litert.interpreter import Interpreter
65
+
66
+ it = Interpreter(model_path="silentface.tflite"); it.allocate_tensors()
67
+ inp, out = it.get_input_details(), it.get_output_details()
68
+ it.set_tensor(inp[0]["index"], x) # [1,3,80,80] float32, BGR, x/255
69
+ it.invoke()
70
+ p = it.get_tensor(out[0]["index"])[0] # [3]; live = p[1]
71
+ ```
72
+
73
+ ## Note
74
+
75
+ The original repo ensembles two MiniFASNet models (crops at scale 2.7 and 4.0) with a face
76
+ detector; this ships the primary `MiniFASNetV2` (2.7). For best accuracy, feed a detected
77
+ face crop and optionally ensemble the second model.
78
+
79
+ ## License
80
+
81
+ Apache-2.0 (Silent-Face-Anti-Spoofing / minivision-ai).