Skip to content

Commit 295ec77

Browse files
committed
fix(inference): fix padding bug.
1 parent 4ef423e commit 295ec77

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cellseg_models_pytorch/inference/sliding_window_inferer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,11 @@ def _infer_batch(self, input_batch: torch.Tensor) -> Dict[str, torch.Tensor]:
161161
self.stride, self.patch_size, tuple(input_batch.shape[2:]), self.padding
162162
)
163163

164-
padx = padx // 2
165-
pady = pady // 2
164+
padx, modx = divmod(padx, 2)
165+
pady, mody = divmod(pady, 2)
166+
padx += modx
167+
pady += mody
168+
166169
input_batch = F.pad(
167170
input_batch.float(), pad=(padx, padx, pady, pady), mode="reflect"
168171
)

0 commit comments

Comments
 (0)