Skip to content
Edit this page

Quickstart: inputs, buffers and precision

The README shows the two calls most jobs need. This page covers the rest of the input path: reusing one engine, GPU tensors, image formats, pinned buffers and mixed precision.

Reuse one engine for a video stream

from easi import EASI, UltralyticsAdapter, load_image

detector = UltralyticsAdapter("yolo11n.pt", conf=0.25)  # FP16 on CUDA by default
engine = EASI(slice_size=640, overlap_ratio=0.2, batch_size=8)  # the defaults
det = engine.predict(load_image("frame.jpg", "cuda"), detector)

Frames already on the GPU

A frame that is already a GPU tensor (from a GPU video decoder or a camera pipeline) goes straight in, with no copy to the CPU: pass a [3, H, W] RGB tensor, uint8 or float in [0, 1].

for frame in gpu_frames:  # torch.Tensor on "cuda", [3, H, W] RGB
    det = engine.predict(frame, detector)

Image inputs

Images can also be a file path, a PIL image or an H x W x 3 NumPy array in RGB order, as in obss/sahi. OpenCV reads BGR, so convert first: frame[..., ::-1] or cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) (BGR input runs without error but detects worse).

Pinned frame buffers

A reader that decodes every frame into the same NumPy array can page-lock that array once, so each upload is a direct DMA copy (opt-in, CUDA only; elsewhere, or if CUDA refuses, nothing changes and reg.reason says why). The array must stay RGB and contiguous: a converted copy such as frame[..., ::-1] is a new array and takes the plain copy.

with easi.register_frame_buffer(buffer) as reg:  # buffer: H x W x 3 uint8, reused per frame
    for _ in frames:
        read_next_frame_into(buffer)
        det = engine.predict(easi.load_image(buffer, "cuda"), detector)  # then reusable

Precision

Ultralytics models run in FP16 on CUDA by default (half="auto"; FP32 on Apple MPS and the CPU): on an RTX 3090, yolo11n at 4K took 18.0 ms in FP16 vs 35.6 ms in FP32 (frame already on the GPU, batch 8; v0.1 release run). On an earlier build (2026-10-21) VisDrone val AP moved by under 0.002 (yolo11n 0.1382 vs 0.1390, yolo11s 0.1855 vs 0.1864, RT-DETR-L 0.2191 vs 0.2207); the results page lists the precision every row ran in. half=False gives FP32. torchvision and Hugging Face models stay FP32 unless you pass half=True. Every table row says which precision it ran in.