litert-community/L2CS-Gaze360-LiteRT

Model

Measured on device (edge-compat): Galaxy S26 · LiteRT 2.2.0 · GPU (ML Drift) · 11.1 ms p50 (2026-08-26); Galaxy S26 · LiteRT 2.2.0 · NPU (QNN/HTP) · 3.59 ms p50 (2026-08-26); Raspberry Pi 5 · LiteRT 2.2.0.dev20260804 · CPU/XNNPACK, 4 threads · 349 ms p50 (2026-08-31); browser · Chromium 151 on M4 Max · LiteRT.js 2.5.3 · WebGPU · 11.8 ms p50 · output matches CPU (2026-08-11). Record: https://github.com/john-rocky/edge-compat/blob/main/cards/l2cs-gaze360/CARD.md

1

8 commits

4 linked in READMEs

updated Sep 8, 2026

See the code

README

Measured on device (edge-compat): Galaxy S26 · LiteRT 2.2.0 · GPU (ML Drift) · 11.1 ms p50 (2026-08-26); Galaxy S26 · LiteRT 2.2.0 · NPU (QNN/HTP) · 3.59 ms p50 (2026-08-26); Raspberry Pi 5 · LiteRT 2.2.0.dev20260804 · CPU/XNNPACK, 4 threads · 349 ms p50 (2026-08-31); browser · Chromium 151 on M4 Max · LiteRT.js 2.5.3 · WebGPU · 11.8 ms p50 · output matches CPU (2026-08-11). Record: https://github.com/john-rocky/edge-compat/blob/main/cards/l2cs-gaze360/CARD.md

L2CS-Net — LiteRT (on-device gaze estimation, fully-GPU)

L2CS-Net (Ahmednull) gaze estimation, converted to LiteRT and running fully on the CompiledModel GPU (ML Drift) on Android. Predicts where a centered face is looking (yaw/pitch). ResNet50 backbone trained on Gaze360.

L2CS-Net — face + gaze direction (on-device LiteRT GPU)

On-device (Pixel 8a, Tensor G3 — verified)

nodes on GPU139 / 139 LITERT_CL (full residency)
inference~3 ms (448×448)
size47.9 MB (fp16)
accuracydevice-vs-PyTorch corr 0.9999, gaze angle within ~0.1°
face[1,3,448,448] (ImageNet-normalized) →[GPU: ResNet50]→ yaw[1,90], pitch[1,90] (softmax over angle bins)

The 90 bins span [-180,180]° (4° each); gaze angle = softmax expectation Σ p_i·i · 4 − 180 (softmax baked in).

Minimal usage

Android (Kotlin, CompiledModel GPU)

val model = CompiledModel.create(context.assets, "gaze_fp16.tflite",
    CompiledModel.Options(Accelerator.GPU), null)
val inputs = model.createInputBuffers()
val outputs = model.createOutputBuffers()
inputs[0].writeFloat(chw)              // [1,3,448,448] ImageNet-normalized RGB, NCHW
model.run(inputs, outputs)
val yawProbs = outputs[0].readFloat()   // [1,90] softmax over 4-deg bins
val pitchProbs = outputs[1].readFloat() // [1,90]; deg = sum(p_i * i) * 4 - 180

Python (desktop verification)

MEAN = np.array([0.485, 0.456, 0.406], np.float32)
STD  = np.array([0.229, 0.224, 0.225], np.float32)
import numpy as np
from PIL import Image
from ai_edge_litert.interpreter import Interpreter

img = Image.open("face.jpg").convert("RGB").resize((448, 448))   # centered face crop
x = ((np.asarray(img, np.float32) / 255 - MEAN) / STD).transpose(2, 0, 1)[None]

it = Interpreter(model_path="gaze_fp16.tflite"); it.allocate_tensors()
it.set_tensor(it.get_input_details()[0]["index"], x); it.invoke()
od = it.get_output_details()                       # output 0 = yaw, 1 = pitch (both [1,90])
deg = lambda p: float((p * np.arange(90)).sum() * 4 - 180)
yaw, pitch = (deg(it.get_tensor(o["index"])[0]) for o in od)
print(f"yaw {yaw:+.1f} deg, pitch {pitch:+.1f} deg")

How it converts (litert-torch)

Pure CNN (ResNet50 + 2 FC heads). Two numerically-exact ResNet fixes:

  1. stem MaxPool2d(3,s2,p1) → zero-pad + valid max-pool — PyTorch's max-pool pads with -inf → a PADV2 the Mali delegate won't delegate (compile fail); since the pool follows a ReLU, a 0-pad is exactly equivalent → PAD, full GPU residency.
  2. global AdaptiveAvgPool2d(1) → mean(3).mean(2).

Result: banned ops NONE, all tensors ≤4D, tflite-vs-torch corr 1.0, device-vs-torch corr 0.9999.

Preprocessing & decode

Center-crop to a (centered) face, resize 448×448, /255, ImageNet mean/std, NCHW. Decode: softmax expectation over the 90 bins → yaw/pitch degrees → gaze direction.

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.

RuntimeBackendGraph on GPULatency
LiteRT CompiledModel (LITERT_CL)GPU139 / 139~3 ms
TFLite benchmark_model (TfLiteGpuDelegateV2)GPU (OpenCL)139 / 13945.3 ms
TFLite benchmark_modelCPU (XNNPACK, 4 threads)—541.7 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)

The NPU is 3.08x faster than the GPU (3.59 ms against 11.05 ms) and loads 9.27x faster (126 ms against 1172 ms).

backendcompiledinference (median / min)load
NPU (Hexagon v81)on-device JIT3.59 ms / 3.53 ms126 ms
GPU (Adreno)—11.05 ms / 10.69 ms1172 ms

Measured on a Samsung Galaxy S26 (Snapdragon 8 Elite Gen 5 / SM8850, Hexagon v81, Android 16) with LiteRT CompiledModel 2.2.0, one accelerator per process, 5 warm-up runs then N=50 timed runs, median reported. Every run held thermal status NONE throughout. Headroom 0.77–0.77, where 1.0 is the throttling threshold.

The NPU rows ran the published file unchanged. LiteRT compiled it for the Hexagon on the device at first load. That first compile took 5.4 s here. The load column above is the cached load every later run pays. Recipe and the runtime libraries it needs: NPU guide.

GPU wiring: GPU guide.

Raspberry Pi 5 (CPU)

Measured on a Raspberry Pi 5 Model B Rev 1.1 (8 GB, Raspberry Pi OS 64-bit) with the LiteRT benchmark_model tool from litert-cli-nightly 0.2.0.dev20260805: CPU inference (XNNPACK, 4 threads), 3 invocations per file of 10 warm-up plus 50 timed runs (the tool caps a phase at 150 s, so very slow graphs run fewer — the Runs column is the actual timed total). The latency is the median across invocations; the spread is the min–max over all timed runs. No thermal throttling occurred during these runs (vcgencmd get_throttled stayed 0x0).

FileInference (median)Spread (min–max)RunsPeak memory
gaze_fp16.tflite349.4 ms347.9–352.9 ms150227 MB

License

MIT. Upstream: Ahmednull/L2CS-Net.

android
gaze360
gaze-estimation
image-classification
l2cs
litert
LiteRT
on-device
resnet
tflite

litert-community/L2CS-Gaze360-LiteRT

Model

Measured on device (edge-compat): Galaxy S26 · LiteRT 2.2.0 · GPU (ML Drift) · 11.1 ms p50 (2026-08-26); Galaxy S26 · LiteRT 2.2.0 · NPU (QNN/HTP) · 3.59 ms p50 (2026-08-26); Raspberry Pi 5 · LiteRT 2.2.0.dev20260804 · CPU/XNNPACK, 4 threads · 349 ms p50 (2026-08-31); browser · Chromium 151 on M4 Max · LiteRT.js 2.5.3 · WebGPU · 11.8 ms p50 · output matches CPU (2026-08-11). Record: https://github.com/john-rocky/edge-compat/blob/main/cards/l2cs-gaze360/CARD.md

1

8 commits

4 linked in READMEs

updated Sep 8, 2026

See the code

README

Measured on device (edge-compat): Galaxy S26 · LiteRT 2.2.0 · GPU (ML Drift) · 11.1 ms p50 (2026-08-26); Galaxy S26 · LiteRT 2.2.0 · NPU (QNN/HTP) · 3.59 ms p50 (2026-08-26); Raspberry Pi 5 · LiteRT 2.2.0.dev20260804 · CPU/XNNPACK, 4 threads · 349 ms p50 (2026-08-31); browser · Chromium 151 on M4 Max · LiteRT.js 2.5.3 · WebGPU · 11.8 ms p50 · output matches CPU (2026-08-11). Record: https://github.com/john-rocky/edge-compat/blob/main/cards/l2cs-gaze360/CARD.md

L2CS-Net — LiteRT (on-device gaze estimation, fully-GPU)

L2CS-Net (Ahmednull) gaze estimation, converted to LiteRT and running fully on the CompiledModel GPU (ML Drift) on Android. Predicts where a centered face is looking (yaw/pitch). ResNet50 backbone trained on Gaze360.

L2CS-Net — face + gaze direction (on-device LiteRT GPU)

On-device (Pixel 8a, Tensor G3 — verified)

nodes on GPU139 / 139 LITERT_CL (full residency)
inference~3 ms (448×448)
size47.9 MB (fp16)
accuracydevice-vs-PyTorch corr 0.9999, gaze angle within ~0.1°
face[1,3,448,448] (ImageNet-normalized) →[GPU: ResNet50]→ yaw[1,90], pitch[1,90] (softmax over angle bins)

The 90 bins span [-180,180]° (4° each); gaze angle = softmax expectation Σ p_i·i · 4 − 180 (softmax baked in).

Minimal usage

Android (Kotlin, CompiledModel GPU)

val model = CompiledModel.create(context.assets, "gaze_fp16.tflite",
    CompiledModel.Options(Accelerator.GPU), null)
val inputs = model.createInputBuffers()
val outputs = model.createOutputBuffers()
inputs[0].writeFloat(chw)              // [1,3,448,448] ImageNet-normalized RGB, NCHW
model.run(inputs, outputs)
val yawProbs = outputs[0].readFloat()   // [1,90] softmax over 4-deg bins
val pitchProbs = outputs[1].readFloat() // [1,90]; deg = sum(p_i * i) * 4 - 180

Python (desktop verification)

MEAN = np.array([0.485, 0.456, 0.406], np.float32)
STD  = np.array([0.229, 0.224, 0.225], np.float32)
import numpy as np
from PIL import Image
from ai_edge_litert.interpreter import Interpreter

img = Image.open("face.jpg").convert("RGB").resize((448, 448))   # centered face crop
x = ((np.asarray(img, np.float32) / 255 - MEAN) / STD).transpose(2, 0, 1)[None]

it = Interpreter(model_path="gaze_fp16.tflite"); it.allocate_tensors()
it.set_tensor(it.get_input_details()[0]["index"], x); it.invoke()
od = it.get_output_details()                       # output 0 = yaw, 1 = pitch (both [1,90])
deg = lambda p: float((p * np.arange(90)).sum() * 4 - 180)
yaw, pitch = (deg(it.get_tensor(o["index"])[0]) for o in od)
print(f"yaw {yaw:+.1f} deg, pitch {pitch:+.1f} deg")

How it converts (litert-torch)

Pure CNN (ResNet50 + 2 FC heads). Two numerically-exact ResNet fixes:

  1. stem MaxPool2d(3,s2,p1) → zero-pad + valid max-pool — PyTorch's max-pool pads with -inf → a PADV2 the Mali delegate won't delegate (compile fail); since the pool follows a ReLU, a 0-pad is exactly equivalent → PAD, full GPU residency.
  2. global AdaptiveAvgPool2d(1) → mean(3).mean(2).

Result: banned ops NONE, all tensors ≤4D, tflite-vs-torch corr 1.0, device-vs-torch corr 0.9999.

Preprocessing & decode

Center-crop to a (centered) face, resize 448×448, /255, ImageNet mean/std, NCHW. Decode: softmax expectation over the 90 bins → yaw/pitch degrees → gaze direction.

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.

RuntimeBackendGraph on GPULatency
LiteRT CompiledModel (LITERT_CL)GPU139 / 139~3 ms
TFLite benchmark_model (TfLiteGpuDelegateV2)GPU (OpenCL)139 / 13945.3 ms
TFLite benchmark_modelCPU (XNNPACK, 4 threads)—541.7 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)

The NPU is 3.08x faster than the GPU (3.59 ms against 11.05 ms) and loads 9.27x faster (126 ms against 1172 ms).

backendcompiledinference (median / min)load
NPU (Hexagon v81)on-device JIT3.59 ms / 3.53 ms126 ms
GPU (Adreno)—11.05 ms / 10.69 ms1172 ms

Measured on a Samsung Galaxy S26 (Snapdragon 8 Elite Gen 5 / SM8850, Hexagon v81, Android 16) with LiteRT CompiledModel 2.2.0, one accelerator per process, 5 warm-up runs then N=50 timed runs, median reported. Every run held thermal status NONE throughout. Headroom 0.77–0.77, where 1.0 is the throttling threshold.

The NPU rows ran the published file unchanged. LiteRT compiled it for the Hexagon on the device at first load. That first compile took 5.4 s here. The load column above is the cached load every later run pays. Recipe and the runtime libraries it needs: NPU guide.

GPU wiring: GPU guide.

Raspberry Pi 5 (CPU)

Measured on a Raspberry Pi 5 Model B Rev 1.1 (8 GB, Raspberry Pi OS 64-bit) with the LiteRT benchmark_model tool from litert-cli-nightly 0.2.0.dev20260805: CPU inference (XNNPACK, 4 threads), 3 invocations per file of 10 warm-up plus 50 timed runs (the tool caps a phase at 150 s, so very slow graphs run fewer — the Runs column is the actual timed total). The latency is the median across invocations; the spread is the min–max over all timed runs. No thermal throttling occurred during these runs (vcgencmd get_throttled stayed 0x0).

FileInference (median)Spread (min–max)RunsPeak memory
gaze_fp16.tflite349.4 ms347.9–352.9 ms150227 MB

License

MIT. Upstream: Ahmednull/L2CS-Net.

android
gaze360
gaze-estimation
image-classification
l2cs
litert
LiteRT
on-device
resnet
tflite