Instructions to use litert-community/6DRepNet-HeadPose-LiteRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/6DRepNet-HeadPose-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
6DRepNet β Head pose estimation (LiteRT GPU)
On-device 6-DoF head pose estimation running fully on the LiteRT CompiledModel
GPU delegate (no CPU fallback). 6DRepNet
(ICIP 2022) regresses a continuous 6D rotation from a face crop β yaw / pitch / roll for
driver-monitoring, AR, and attention. ~21 ms/frame on a Pixel 8a.
- Architecture: RepVGG-B1g2 backbone (deploy/re-parameterized) + 6D rotation head β pure CNN.
- Weights: thohemp/6DRepNet (300W-LP) Β· MIT.
- Size: 157 MB.
3D head-pose axes + yaw/pitch/roll on a face crop. Portrait: Unsplash (free license).
I/O
- Input:
[1, 3, 224, 224]NCHW, RGB, ImageNet-normalized (a face crop; use a face detector, or a centered crop for a frontal demo). - Output:
[1, 6]β a continuous 6D rotation representation.
Host-side decode (6D β Euler)
Gram-Schmidt the 6D into a 3Γ3 rotation matrix, then read the Euler angles:
x = normalize(v[0:3]); z = normalize(cross(x, v[3:6])); y = cross(z, x) # R = [x|y|z]
pitch = atan2(R21, R22); yaw = atan2(-R20, sqrt(R00^2+R10^2)); roll = atan2(R10, R00)
GPU conversion
6DRepNet (deploy-mode RepVGG = plain 3Γ3 convs + ReLU) is a pure CNN β fully
GPU-compatible (36/36 nodes on the delegate, 1 partition; device corr 0.9993, ~21 ms)
with zero patches. The 6DβrotationβEuler decode runs host-side. Use the deploy
weights (fused rbr_reparam), not the training-mode branches. 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, "6drepnet.tflite", options, null)
val inBufs = model.createInputBuffers()
val outBufs = model.createOutputBuffers()
inBufs[0].writeFloat(faceCropNCHW) // [1,3,224,224] RGB, ImageNet-norm
model.run(inBufs, outBufs)
val v = outBufs[0].readFloat() // [6]; Gram-Schmidt -> R -> yaw/pitch/roll (see above)
Python (LiteRT / ai-edge-litert)
import numpy as np
from ai_edge_litert.interpreter import Interpreter
it = Interpreter(model_path="6drepnet.tflite"); it.allocate_tensors()
inp, out = it.get_input_details(), it.get_output_details()
it.set_tensor(inp[0]["index"], x) # [1,3,224,224] float32, RGB, ImageNet-norm
it.invoke()
v = it.get_tensor(out[0]["index"])[0] # [6] -> Gram-Schmidt -> rotation matrix -> Euler
Conversion
Converted with litert-torch (build_6drepnet.py): loads the deploy-mode RepVGG weights
and exports the 6D head (input face crop β 6D).
Performance
Measured on a Pixel 8a (Tensor G3, Android 16) with the standard TFLite benchmark_model tool β 10 warm-up runs then 50 timed runs, reported as the tool's mean.
| Runtime | Backend | Graph on GPU | Latency |
|---|---|---|---|
LiteRT CompiledModel (LITERT_CL) |
GPU | 36 / 36 | ~21 ms |
TFLite benchmark_model (TfLiteGpuDelegateV2) |
GPU (OpenCL) | 36 / 36 | 34.2 ms |
TFLite benchmark_model |
CPU (XNNPACK, 4 threads) | β | 155.2 ms |
The two GPU rows are different runtimes, not a contradiction. The LITERT_CL figure is the one recorded when this model shipped, taken through LiteRT's own CompiledModel accelerator β the path the Kotlin sample app and the LiteRT API use. The TfLiteGpuDelegateV2 figure is the classic TFLite OpenCL delegate, measured with a tool anyone can download and re-run. They agree on how much of the graph the GPU takes; they disagree on speed, and the classic delegate is the slower of the two here. Read the TfLiteGpuDelegateV2 row as a reproducible floor, not as this model's speed on LiteRT.
Snapdragon NPU (Hexagon)
This file runs on the Qualcomm Hexagon NPU as published β no conversion and no pre-compiled artifact. LiteRT compiles it on the device and caches the result.
Measured on a physical Samsung Galaxy S26 (Snapdragon 8 Elite Gen 5 / SM8850,
Hexagon v81) with LiteRT CompiledModel 2.2.0 β 5 warm-up runs then 50 timed runs, one
accelerator per process, every row taken at device thermal status NONE.
| Compute unit | Inference (median / min) | Load | Start headroom |
|---|---|---|---|
| NPU (Hexagon) β first launch | 1.75 ms / 1.68 ms | 1287 ms | 0.60 |
| NPU (Hexagon) β cached | 1.74 ms / 1.71 ms | 258 ms | 0.60 |
| GPU (Adreno) | 8.53 ms / 8.18 ms | 636 ms | 0.60 |
The NPU is 4.9x faster on inference here (1.74 ms against 8.53 ms). The first launch pays once for on-device compilation; every launch after that loads in 258 ms against 636 ms for the GPU (2.5x), because the GPU rebuilds its shaders each time. The file is fp16 and needs no int8 quantization to reach the NPU.
Running it on the NPU
Put these in jniLibs/arm64-v8a/. None of them are distributed from this repository β
the first two come from Google, the rest from Qualcomm's own SDK:
| Library | Source |
|---|---|
libLiteRtDispatch_Qualcomm.so, libLiteRtCompilerPlugin_Qualcomm.so |
litert_npu_runtime_libraries_jit.zip, a release asset of google-ai-edge/LiteRT |
libQnnHtp.so, libQnnSystem.so, libQnnHtpV81Stub.so, libQnnHtpV81Skel.so, libQnnHtpPrepare.so, libQnnIr.so, libQnnSaver.so |
Qualcomm QAIRT β the same zip ships fetch_qualcomm_library.sh, which downloads the SDK and copies them for you |
Pick the runtime matching the device's Hexagon version: SM8550 β v73, SM8650 β v75, SM8750 β v79, SM8850 β v81.
val env = Environment.create(
context,
mapOf(
Environment.Option.DispatchLibraryDir to context.applicationInfo.nativeLibraryDir,
// Required for on-device compilation. Without it the model silently runs on CPU.
Environment.Option.CompilerPluginLibraryDir to context.applicationInfo.nativeLibraryDir,
),
)
val options = CompiledModel.Options(Accelerator.NPU).apply {
qualcommOptions = CompiledModel.QualcommOptions(
htpPerformanceMode = CompiledModel.QualcommOptions.HtpPerformanceMode.BURST
)
}
val model = CompiledModel.create(context.assets, "6drepnet.tflite", options, env)
Build settings: useLegacyPackaging = true under packaging { jniLibs { β¦ } }, so the
DSP can open the skel from a real path, and Kotlin 2.3+ for LiteRT 2.2.0's metadata.
Every NPU failure here is silent. There is no error when the NPU is unavailable β you get a plausible CPU number instead. Confirm from logcat which delegate took the graph:
Replacing 1 out of 1 node(s) with delegate (DispatchDelegate)is the NPU, while... (TfLiteXNNPackDelegate)is the CPU. A missing library is reported only as aW-leveldlopen failedline under a genericNo compiler plugin foundsummary.
On the conditions. Thermal headroom is reported as measured, where 1.0 is the
throttling threshold. All rows were taken at a comparable headroom and compare directly;
figures taken at a different headroom will differ. Each accelerator ran in its own
process, because LiteRT's Environment is shared within one and the first model load
fixes the options for every later one.
License
MIT (6DRepNet / thohemp). Trained on 300W-LP.
- Downloads last month
- 54
