Skip to content

Commit

Permalink
check for infs in inference
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianIsensee committed Dec 7, 2023
1 parent 792343c commit eb3c40d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nnunetv2/inference/predict_from_raw_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,11 @@ def predict_sliding_window_return_logits(self, input_image: torch.Tensor) \
n_predictions[sl[1:]] += (gaussian if self.use_gaussian else 1)

predicted_logits /= n_predictions
# check for infs
if torch.any(torch.isinf(predicted_logits)):
raise RuntimeError('Encountered inf in predicted array. Aborting... If this problem persists, '
'reduce value_scaling_factor in compute_gaussian or increase the dtype of '
'predicted_logits to fp32')
empty_cache(self.device)
return predicted_logits[tuple([slice(None), *slicer_revert_padding[1:]])]

Expand Down

0 comments on commit eb3c40d

Please sign in to comment.