Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Heuristic:Obss Sahi Overlap Ratio Selection

From Leeroopedia




Knowledge Sources
Domains Computer_Vision, Object_Detection, Optimization
Last Updated 2026-02-08 12:00 GMT

Overview

Guidelines for selecting overlap ratios when slicing images, balancing object recovery at slice boundaries against computational overhead.

Description

When SAHI slices a large image into tiles, adjacent tiles overlap by a configurable ratio. This overlap ensures that objects straddling tile boundaries are fully contained in at least one tile. The overlap ratio directly controls the trade-off between detection completeness (higher overlap = fewer missed boundary objects) and computational cost (higher overlap = more tiles = more inference calls).

The overlap is calculated as: `overlap_pixels = ratio * slice_dimension`. For example, with `overlap_height_ratio=0.2` and `slice_height=512`, the vertical overlap is 102 pixels.

Usage

Use this heuristic when configuring the `overlap_height_ratio` and `overlap_width_ratio` parameters for `get_sliced_prediction()` or `slice_image()`. Consider adjusting when:

  • Objects near slice boundaries are being missed or truncated
  • Postprocessing produces excessive duplicate detections
  • Inference is too slow due to too many slices
  • The `min_area_ratio` filter is discarding valid partial annotations

The Insight (Rule of Thumb)

  • Default Value: `overlap_height_ratio=0.2` and `overlap_width_ratio=0.2` (20% overlap) for manual slicing.
  • Auto-slice Values: The auto-resolution system uses different overlap ratios per resolution tier:
    • Low resolution (factor <= 18): No slicing performed (1x1 grid), overlap irrelevant
    • Medium resolution (18 < factor <= 21): `overlap_ratio=0.8` (80% — high overlap for moderate images)
    • High resolution (21 < factor <= 24): `overlap_ratio=0.4` (40%)
    • Ultra-high resolution (factor > 24): `overlap_ratio=0.4` (40%)
  • Trade-off: Higher overlap increases tile count quadratically. Doubling overlap roughly doubles total tiles per axis.
  • Min Area Ratio Interaction: The `min_area_ratio=0.1` default means annotations must retain at least 10% of their original area after slicing to be kept. Higher overlap reduces partial annotations, making `min_area_ratio` less aggressive.

Reasoning

The 0.2 default provides a good balance: most objects spanning at most 20% of a slice width will be fully captured in at least one neighboring tile. The auto-slice system uses much higher overlaps (0.4-0.8) for medium/high-resolution images because those images have proportionally more slices and the objects are typically smaller relative to slice size, requiring more generous overlap to avoid boundary effects.

The `min_area_ratio` of 0.1 acts as a safety net — even with imperfect overlap, heavily-truncated annotations (< 10% visible area) are excluded from training data, preventing the model from learning on fragmentary objects.

Empirically, increasing overlap beyond 0.4 on high-resolution images yields diminishing returns because the postprocess merging (NMS/NMM) handles duplicate detections effectively. The computational cost of extra slices outweighs the marginal improvement in recall.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment