Skip to content
Back to skills

3d Patch Sliding Window Inference

ASecurity

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

  • 61 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 12, 2026
documentationpython

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add wenmin-wu/ds-skills --skill 3d-patch-sliding-window-inference --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 3d Patch Sliding Window Inference?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 3d Patch Sliding Window Inference
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wenmin-wu-3d-patch-sliding-window-inference/badge)](https://www.skillsdirectory.com/skills/wenmin-wu-3d-patch-sliding-window-inference)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cv-3d-patch-sliding-window-inference
description: >
  Tiles 3D volumes into overlapping patches for inference and averages overlapping regions to produce seamless predictions.
---
# 3D Patch Sliding-Window Inference

## 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

```python
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

- [Baseline UNet train + submit](https://www.kaggle.com/code/fnands/baseline-unet-train-submit)
- [CZII YOLO11+Unet3D-Monai LB.707](https://www.kaggle.com/code/hideyukizushi/czii-yolo11-unet3d-monai-lb-707)
- [3d-unet using 2d image encoder](https://www.kaggle.com/code/hengck23/3d-unet-using-2d-image-encoder)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…