Skip to content

Commit 942d277

Browse files
committed
merge dev into main
2 parents 64a4ef6 + 6173d8d commit 942d277

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/patchworks/plugins/cellpose.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,10 @@ def _is_cuda_oom(exc: Exception) -> bool:
217217

218218

219219
def _eval_with_oom_fallback(
220-
model: Any, img: np.ndarray, kwargs: dict[str, Any], cellpose_dict: dict[str, Any]
220+
model: Any,
221+
img: np.ndarray,
222+
kwargs: dict[str, Any],
223+
cellpose_dict: dict[str, Any],
221224
) -> np.ndarray:
222225
"""Run ``model.eval``, surviving transient GPU contention.
223226
@@ -313,9 +316,8 @@ def _run(block: np.ndarray, cellpose_dict: dict[str, Any]) -> np.ndarray:
313316
# Squeeze singleton z so Cellpose gets a clean 2-D image
314317
squeeze = block.ndim == 3 and block.shape[0] == 1
315318
img = block[0] if squeeze else block
316-
masks = _eval_with_oom_fallback(model, img, kwargs, cellpose_dict).astype(
317-
"int32"
318-
)
319+
masks = _eval_with_oom_fallback(model, img, kwargs, cellpose_dict)
320+
masks = masks.astype("int32")
319321
return masks[np.newaxis] if squeeze else masks
320322

321323

0 commit comments

Comments
 (0)