Skip to content
Edit this page

The EASI engine

EASI

EASI(
    slice_size: int | tuple[int, int] = 640,
    overlap_ratio: float | tuple[float, float] = 0.2,
    batch_size: int | Literal["auto"] = 8,
    fusion_mode: FusionMode = "seam_wbf",
    iou_threshold: float | None = None,
    class_agnostic: bool = False,
    full_frame_pass: bool = False,
    full_frame_size: int | None = None,
    zoom_size: int | None = None,
    zoom_min_boxes: int = 10,
    flip_tta: bool = False,
    dtype: dtype | None = None,
    channels_last: bool = False,
    edge_tolerance: float | None = None,
    postprocess_device: device | str | None = "auto",
    seam_min_score: float = 0.5,
    edge_cleanup: EdgeCleanup | bool = "balanced",
    whole_view_gate: WholeViewGate | bool = "class",
    fusion_edge_tolerance: float = FUSION_EDGE_TOLERANCE,
)

Sliced inference that keeps the image and every box on the image's device.

Example::

engine = EASI(slice_size=640, overlap_ratio=0.2, batch_size=8)
detections = engine.predict(image_tensor, UltralyticsAdapter("yolo11n.pt"))
detections.boxes, detections.scores, detections.labels

Parameters:

Name Type Description Default
slice_size int | tuple[int, int]

Tile size, int or (width, height).

640
overlap_ratio float | tuple[float, float]

Tile overlap fraction in [0, 1), scalar or (width, height).

0.2
batch_size int | Literal['auto']

Tiles per detector call, or "auto" (probed from free GPU memory, capped at AUTO_BATCH_MAX). CUDA OOM batches split in half and retry.

8
fusion_mode FusionMode

"seam_wbf" (default), "seam_nms", "wbf" or "nms".

'seam_wbf'
iou_threshold float | None

IoU threshold for clustering/NMS (default 0.6 seam, 0.5 plain).

None
class_agnostic bool

Fuse boxes regardless of label.

False
full_frame_pass bool

Also run the detector once on the whole image at slice_size.

False
full_frame_size int | None

Whole-image pass input size (longer side; shorter side stride-aligned).

None
zoom_size int | None

Selective 2nd-pass input size for tiles with >= zoom_min_boxes small detections.

None
zoom_min_boxes int

Small-box count threshold for zoom_size (default 10).

10
flip_tta bool

Also run left-right mirrored tiles and merge views via :func:merge_views.

False
dtype dtype | None

Cast tiles to this dtype before the detector; None keeps float32.

None
channels_last bool

Pass tiles in torch.channels_last memory format.

False
edge_tolerance float | None

Pixels within which a box counts as cut by a tile edge (default 2% of the smaller slice side).

None
fusion_edge_tolerance float

Edge tolerance for fusion steps (default 2.0 px).

FUSION_EDGE_TOLERANCE
postprocess_device device | str | None

"auto" fuses on CPU up to CPU_FUSION_MAX_BOXES (or MPS), else on the image's device; results always return on the image's device.

'auto'
seam_min_score float

Minimum score for boxes to join seam fusion (default 0.5).

0.5
edge_cleanup EdgeCleanup | bool

Drop cut fragments covered by fuller boxes ("balanced", "aggressive", or "off").

'balanced'
whole_view_gate WholeViewGate | bool

Drop cut boxes covered by a whole-tile box before seam fusion ("class", "any", or "off").

'class'

CPU_FUSION_MAX_BOXES class-attribute instance-attribute

CPU_FUSION_MAX_BOXES = 4096

postprocess_device="auto" fuses frames with at most this many raw boxes on the CPU.

AUTO_BATCH_MEMORY_FRACTION class-attribute instance-attribute

AUTO_BATCH_MEMORY_FRACTION = 0.5

batch_size="auto" plans batches to use at most this share of free GPU memory.

AUTO_BATCH_MAX class-attribute instance-attribute

AUTO_BATCH_MAX = 16

Largest batch batch_size="auto" picks.

AUTO_BATCH_WITHOUT_CUDA class-attribute instance-attribute

AUTO_BATCH_WITHOUT_CUDA = 8

batch_size="auto" without CUDA memory statistics.

EDGE_TOLERANCE_FRACTION class-attribute instance-attribute

EDGE_TOLERANCE_FRACTION = 0.02

Default edge_tolerance as a share of the smaller slice side (at least 2 px).

ZOOM_SMALL_SIDE class-attribute instance-attribute

ZOOM_SMALL_SIDE = 32

zoom_size: a box counts as small when its longer side is under this (image px).

ZOOM_MIN_SCORE class-attribute instance-attribute

ZOOM_MIN_SCORE = 0.3

zoom_size: only boxes scoring at least this count towards zoom_min_boxes.

predict

predict(
    image: Tensor, detector: TorchDetector, timer: StageTimer | None = None
) -> Detections

Detect objects in one image.

Parameters:

Name Type Description Default
image Tensor

[3, H, W] or [1, 3, H, W] RGB tensor, float in [0, 1] or uint8 (converted on its device). Use :func:easi.load_image for files.

required
detector TorchDetector

Callable mapping a [B, 3, h, w] batch to B tuples of (boxes [K, 4] xyxy, scores [K], labels [K]); see :mod:easi.adapters.

required
timer StageTimer | None

Optional :class:~easi.profiling.StageTimer that accumulates time for the stages prepare, slice, detect, shift, merge_views (with flip_tta), zoom (with zoom_size), full_frame and fuse.

None

predict_raw

predict_raw(
    image: Tensor, detector: TorchDetector, timer: StageTimer | None = None
) -> tuple[CanvasDetections, torch.Tensor, tuple[int, int]]

Run slicing and detection without fusing, returning raw canvas detections and windows.