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.

Ultra-Fast-Lane-Detection

Detected ego-lane on a dashcam highway frame. Source: Wikimedia Commons (Public Domain).

I/O

  • Input: [1, 3, 288, 800] NCHW, RGB, x/255 then 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.

License

MIT (Ultra-Fast-Lane-Detection / cfzd). Trained on CULane.

Downloads last month
11
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support