Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stylegan implementation #19

Merged
merged 14 commits into from
Nov 7, 2024
2 changes: 0 additions & 2 deletions gandlf_synth/data/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ def _prepare_multichannel_image(self, index):
for channel_column in channel_columns
]
tio_scalar_image = tio.ScalarImage(channel_file_paths)

if self.transforms:
tio_scalar_image = self.transforms(tio_scalar_image)
# TODO think if this is valid
image = tio_scalar_image.data.squeeze(-1).float()
return image

Expand Down
3 changes: 3 additions & 0 deletions gandlf_synth/losses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
from torch.nn import Module
from torch.nn import MSELoss, L1Loss, CrossEntropyLoss, BCEWithLogitsLoss, BCELoss

from gandlf_synth.losses.custom_losses import PlainMeanLoss

global_losses_dict = {
"cel": CrossEntropyLoss,
"l1": L1Loss,
"bce": BCELoss,
"bcelogits": BCEWithLogitsLoss,
"mse": MSELoss,
"plain_mean": PlainMeanLoss,
}

WEIGHT_KEYS = ["weight", "pos_weight"]
Expand Down
13 changes: 13 additions & 0 deletions gandlf_synth/losses/custom_losses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import torch
from torch.nn import Module


class PlainMeanLoss(Module):
def __init__(self):
"""
A simple mean loss that averages the input tensor.
"""
super().__init__()

def forward(self, x):
return torch.mean(x)
Loading
Loading