-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #494 from sarthakpati/493_specialized_post_process
Added ability to call specific post processing algorithms after reverse one-hot encoding
- Loading branch information
Showing
7 changed files
with
93 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
import torch | ||
import numpy as np | ||
from GANDLF.utils.generic import get_array_from_image_or_tensor | ||
|
||
|
||
def get_mapped_label(input_tensor, params): | ||
""" | ||
This function maps the input label to the output label. | ||
Args: | ||
input_tensor (torch.Tensor): The input label. | ||
input_tensor (Union[torch.Tensor, sitk.Image]): The input label. | ||
params (dict): The parameters dict. | ||
Returns: | ||
torch.Tensor: The output image after morphological operations. | ||
np.ndarray: The output image after morphological operations. | ||
""" | ||
input_image_array = get_array_from_image_or_tensor(input_tensor) | ||
if "data_postprocessing" not in params: | ||
return input_tensor | ||
return input_image_array | ||
if "mapping" not in params["data_postprocessing"]: | ||
return input_tensor | ||
return input_image_array | ||
|
||
mapping = params["data_postprocessing"]["mapping"] | ||
output = np.zeros(input_image_array.shape) | ||
|
||
output = torch.zeros(input_tensor.shape) | ||
|
||
for key, value in mapping.items(): | ||
for key, value in params["data_postprocessing"]["mapping"].items(): | ||
output[input_tensor == key] = value | ||
|
||
return output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters