Instructions to use litert-community/Ultra-Fast-Lane-Detection-LiteRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/Ultra-Fast-Lane-Detection-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
Ultra-Fast-Lane-Detection (ResNet18, CULane) β LiteRT GPU
On-device lane detection running fully on the LiteRT CompiledModel GPU
delegate (no CPU fallback). Ultra-Fast-Lane-Detection
(ECCV 2020) reformulates lane detection as fast row-wise classification β the
network runs on the GPU, and a tiny host-side arg/expectation decode turns the grid
into lane points. ~20 ms/frame on a Pixel 8a.
- Architecture: ResNet18 backbone + row-anchor classification head β pure CNN.
- Weights: cfzd/Ultra-Fast-Lane-Detection (CULane, ResNet18) Β· MIT.
- Size: 178 MB.
Detected ego-lane on a dashcam highway frame. Source: Wikimedia Commons (Public Domain).
I/O
- Input:
[1, 3, 288, 800]NCHW, RGB,x/255then ImageNet-normalized (mean[0.485,0.456,0.406], std[0.229,0.224,0.225]). - Output:
[1, 201, 18, 4]=(griding+1, row_anchors, lanes)β per-lane, per-row classification logits over 200 horizontal grid cells (+1 "no lane").
Host-side decode
For each of the 4 lanes and 18 row anchors: softmax over the 200 grid cells, take the
expectation β column; if the argmax over all 201 is the last index (200 = "no lane"),
drop it. Map the column to an x-pixel via linspace(0, 799, 200) (scaled to the image
width) and the row anchor to a y-pixel (CULane row anchors, scaled from 288).
GPU conversion
UFLD is a pure CNN. It converts fully GPU-compatible (41/41 nodes on the delegate,
1 partition; device corr 0.999982, ~20 ms) with one patch: the ResNet18 stem
MaxPool2d(padding=1) lowers to a -inf PADV2 (rejected by Mali), replaced by a 0-pad
- unpadded maxpool (exact post-ReLU). CPU-exact vs PyTorch (corr 0.9999999999996).
Minimal usage
Kotlin (Android, LiteRT CompiledModel GPU)
val options = CompiledModel.Options(Accelerator.GPU)
val model = CompiledModel.create(context.assets, "ufld.tflite", options, null)
val inBufs = model.createInputBuffers()
val outBufs = model.createOutputBuffers()
inBufs[0].writeFloat(inputNCHW) // [1,3,288,800] RGB, x/255 then ImageNet-norm
model.run(inBufs, outBufs)
val out = outBufs[0].readFloat() // [201*18*4], layout (griding+1, rows, lanes)
// decode: per (lane,row) softmax over the first 200 cells, take the expectation -> column;
// skip if argmax == 200 (no lane). See LaneDetector.kt for the full decode.
Python (LiteRT / ai-edge-litert)
import numpy as np
from ai_edge_litert.interpreter import Interpreter
it = Interpreter(model_path="ufld.tflite"); it.allocate_tensors()
inp, out = it.get_input_details(), it.get_output_details()
it.set_tensor(inp[0]["index"], x) # [1,3,288,800] float32, RGB /255, ImageNet-norm
it.invoke()
o = it.get_tensor(out[0]["index"])[0] # [201,18,4]
o = o[:, ::-1, :]
prob = np.exp(o[:-1]) / np.exp(o[:-1]).sum(0, keepdims=True)
loc = (prob * (np.arange(200) + 1).reshape(-1, 1, 1)).sum(0) # [18,4] columns
loc[np.argmax(o, 0) == 200] = 0 # 0 = no lane
Conversion
Converted with litert-torch (build_ufld.py): loads the ResNet18 CULane weights and
exports the row-classification graph.
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 | 41 / 41 | ~20 ms |
TFLite benchmark_model (TfLiteGpuDelegateV2) |
GPU (OpenCL) | 41 / 41 | 25.3 ms |
TFLite benchmark_model |
CPU (XNNPACK, 4 threads) | β | 252.3 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 2.20x faster than the GPU (2.96 ms against 6.51 ms) and loads 7.44x faster (113 ms against 840 ms).
| backend | inference (median / min) | load |
|---|---|---|
| NPU (Hexagon v81) | 2.96 ms / 2.92 ms | 113 ms |
| GPU (Adreno) | 6.51 ms / 6.22 ms | 840 ms |
Measured on a Samsung Galaxy S26 (Snapdragon 8 Elite Gen 5 / SM8850, Hexagon v81, Android 16), 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.66-0.67, where 1.0 is the throttling threshold.
The NPU rows here ran artifacts compiled ahead of time for SM8850 with QAIRT 2.47.0; the GPU rows ran the published files as they are. LiteRT can also compile for the NPU on the device at first load, which is what lets you ship the published file unchanged β that path and the ten runtime libraries it needs are in the NPU recipe, and we did not measure it here. GPU wiring is in the GPU recipe.
License
MIT (Ultra-Fast-Lane-Detection / cfzd). Trained on CULane.
- Downloads last month
- 221
