Given the logits from a network, computing the segmentation by thresholding all values above 0 if multi-labels task, computing the `argmax` along the channel axis if multi-classes task, logits has shape `BCHW[D]`. Args: logits: raw data of model output. mutually_exc
(logits: torch.Tensor, mutually_exclusive: bool = False, threshold: float = 0.0)
| 221 | |
| 222 | |
| 223 | def predict_segmentation(logits: torch.Tensor, mutually_exclusive: bool = False, threshold: float = 0.0) -> Any: |
| 224 | """ |
| 225 | Given the logits from a network, computing the segmentation by thresholding all values above 0 |
| 226 | if multi-labels task, computing the `argmax` along the channel axis if multi-classes task, |
| 227 | logits has shape `BCHW[D]`. |
| 228 | |
| 229 | Args: |
| 230 | logits: raw data of model output. |
| 231 | mutually_exclusive: if True, `logits` will be converted into a binary matrix using |
| 232 | a combination of argmax, which is suitable for multi-classes task. Defaults to False. |
| 233 | threshold: thresholding the prediction values if multi-labels task. |
| 234 | """ |
| 235 | if not mutually_exclusive: |
| 236 | return (logits >= threshold).int() |
| 237 | if logits.shape[1] == 1: |
| 238 | warnings.warn("single channel prediction, `mutually_exclusive=True` ignored, use threshold instead.") |
| 239 | return (logits >= threshold).int() |
| 240 | return logits.argmax(1, keepdim=True) |
| 241 | |
| 242 | |
| 243 | def normalize_transform( |
no outgoing calls
searching dependent graphs…