3D Patch Sliding-Window Inference

SkillAI & models

Tiles 3D volumes into overlapping patches for inference and averages overlapping regions to produce seamless predictions.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the 3D Patch Sliding-Window Inference skill

What this skill tells your AI

The instructions your AI receives, as published by wenmin-wu/ds-skills in skills/cv/3d-patch-sliding-window-inference/SKILL.md and read by ahel’s review.

Overview

Large 3D volumes (CT, cryo-ET, MRI) rarely fit in GPU memory whole. Sliding-window inference tiles the volume into overlapping patches, runs the model on each, then blends overlapping regions via averaging or Gaussian weighting. Eliminates boundary artifacts while keeping memory constant.

Quick Start

from monai.inferers import SlidingWindowInferer

inferer = SlidingWindowInferer(
    roi_size=(96, 96, 96),
    sw_batch_size=4,
    overlap=0.5,
    mode="gaussian",  # Gaussian weighting reduces edge artifacts
)
output = inferer(inputs=volume_tensor, network=model)

Workflow

  1. Choose roi_size matching the model's training patch size
  2. Set overlap (0.25–0.5) — higher overlap = smoother but slower
  3. Select blending mode: "gaussian" weights center pixels more; "constant" averages uniformly
  4. Run inferer — it handles tiling, batching, and stitching automatically
  5. Post-process the full-resolution prediction volume

Key Decisions

  • Overlap ratio: 0.5 is standard; 0.25 acceptable if speed-constrained
  • Blending mode: Gaussian preferred — reduces checkerboard artifacts at patch boundaries
  • sw_batch_size: Max patches per forward pass; tune to available VRAM
  • Without MONAI: Implement manually with np.lib.stride_tricks + weighted accumulation buffer

References

Signals

GitHub stars
60
Forks
4
Last commit
Apr 2026
Advanced
Catalog kind
skill
Gateway key
cv-3d-patch-sliding-window-inference
Source
github.com/wenmin-wu/ds-skills