-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a basic transform as discussed in #21
- More transforms can be experimented with later, and the format will essentially remain the same.
- Loading branch information
1 parent
d7996cc
commit 5538bc1
Showing
3 changed files
with
71 additions
and
22 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import albumentations as A | ||
from albumentations.pytorch.transforms import ToTensorV2 | ||
from capstone.transforms.transforms_2d import WindowedChannels | ||
|
||
_stacked_window_stats = {"mean": (0.107, 0.135, 0.085), "std": (0.271, 0.267, 0.152)} | ||
# _no_window_stats = {"mean": (0.077), "std": (0.133)} | ||
|
||
_minimal_windowed_test_transform = A.Compose( | ||
[ | ||
WindowedChannels(), | ||
A.Resize(256, 256), | ||
A.Normalize( | ||
mean=_stacked_window_stats["mean"], | ||
std=_stacked_window_stats["std"], | ||
max_pixel_value=1.0, | ||
), | ||
ToTensorV2(), | ||
] | ||
) | ||
|
||
|
||
def minimal_windowed_transforms(split="train"): | ||
assert split in ["train", "valid", "test"], "Invalid data split passed" | ||
if split == "train": | ||
return A.Compose( | ||
[ | ||
WindowedChannels(), | ||
A.RandomCrop(256, 256), | ||
A.RandomRotate90(), | ||
A.HorizontalFlip(), | ||
A.Normalize( | ||
mean=_stacked_window_stats["mean"], | ||
std=_stacked_window_stats["std"], | ||
max_pixel_value=1.0, | ||
), | ||
ToTensorV2(), | ||
] | ||
) | ||
else: | ||
return _minimal_windowed_test_transform |