Skip to content
Edit this page

easi.predict

predict

predict(
    image: Any,
    model: Any,
    conf: float = 0.25,
    slice_size: int | tuple[int, int] = 640,
    overlap_ratio: float | tuple[float, float] = 0.2,
    device: device | str | None = None,
    half: bool | Literal["auto"] = "auto",
    multi_label: bool = False,
    **engine_kwargs: Any,
) -> Detections

Sliced detection on one image in one call.

Example::

import easi

det = easi.predict("aerial.jpg", "yolo11n.pt")
det.boxes, det.scores, det.labels, det.names

Parameters:

Name Type Description Default
image Any

File path, PIL image, NumPy HWC RGB array or tensor (see :func:~easi.load_image).

required
model Any

Weights, model id or model object (see :func:detector_from).

required
conf float

Score threshold.

0.25
slice_size int | tuple[int, int]

Tile size; 640 matches YOLO's input size.

640
overlap_ratio float | tuple[float, float]

Tile overlap.

0.2
device device | str | None

Defaults to CUDA, then Apple MPS, then CPU.

None
half bool | Literal['auto']

"auto" (default): FP16 on CUDA for Ultralytics models, FP32 otherwise. True: FP16 on CUDA for every model (autocast for torchvision and Hugging Face). False: FP32.

'auto'
multi_label bool

Ultralytics YOLO models only: also return a box's other likely classes as separate, lower-scored detections (Ultralytics val's decode). Raises AP and recall over all scores; adds little above a fixed threshold. Off by default.

False
**engine_kwargs Any

Further :class:~easi.EASI options, e.g. batch_size, fusion_mode, full_frame_size (accuracy mode, e.g. 1280), zoom_size (selective zoom, e.g. 1280), flip_tta.

{}

Models and engines are reused between calls, so predict with a model name or an Ultralytics object is not thread-safe: for threads, give each its own adapter and :class:~easi.EASI (see docs/THREADS.md).

detector_from

detector_from(
    model: Any,
    conf: float = 0.25,
    device: device | str | None = None,
    half: bool | Literal["auto"] = "auto",
    multi_label: bool = False,
) -> TorchDetector

Build (and cache for string ids) a detector adapter from a weights path, id, or model.

clear_cache

clear_cache() -> None

Clear cached detectors (max 16), engines (max 16), and this thread's staging buffer.