Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,14 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.7", "3.8", "3.9"]
torchmetrics-version: ["0.11.4"]
python-version: ["3.8", "3.9", "3.10"]
torchmetrics-version: ["latest"]
ignore-lpips: ["false"]
include:
- os: ubuntu-latest
python-version: "3.9"
torchmetrics-version: "0.11.4"
python-version: "3.10"
torchmetrics-version: "latest"
ignore-lpips: "true"
- os: ubuntu-latest
python-version: "3.9"
torchmetrics-version: "0.6.0"
ignore-lpips: "false"
- os: ubuntu-latest
python-version: "3.9"
torchmetrics-version: "0.7.3"
ignore-lpips: "false"
env:
TORCHMETRICS: ${{ matrix.torchmetrics-version }}
IGNORE_LPIPS: ${{ matrix.ignore-lpips }}
Expand Down
61 changes: 12 additions & 49 deletions meddlr/metrics/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,13 @@ def __init__(
im_type: str = None,
channel_names: Sequence[str] = None,
reduction="none",
compute_on_step: bool = False,
dist_sync_on_step: bool = False,
process_group: bool = None,
dist_sync_fn: bool = None,
**kwargs,
):
super().__init__(
channel_names=channel_names,
units="dB",
reduction=reduction,
compute_on_step=compute_on_step,
dist_sync_on_step=dist_sync_on_step,
process_group=process_group,
dist_sync_fn=dist_sync_fn,
**kwargs,
)

self.im_type = im_type
Expand Down Expand Up @@ -105,19 +99,13 @@ def __init__(
im_type: str = None,
channel_names: Sequence[str] = None,
reduction="none",
compute_on_step: bool = False,
dist_sync_on_step: bool = False,
process_group: bool = None,
dist_sync_fn: bool = None,
**kwargs,
):
super().__init__(
channel_names=channel_names,
units="",
reduction=reduction,
compute_on_step=compute_on_step,
dist_sync_on_step=dist_sync_on_step,
process_group=process_group,
dist_sync_fn=dist_sync_fn,
**kwargs,
)

self.im_type = im_type
Expand Down Expand Up @@ -153,19 +141,13 @@ def __init__(
im_type: str = None,
channel_names: Sequence[str] = None,
reduction="none",
compute_on_step: bool = False,
dist_sync_on_step: bool = False,
process_group: bool = None,
dist_sync_fn: bool = None,
**kwargs,
):
super().__init__(
channel_names=channel_names,
units="",
reduction=reduction,
compute_on_step=compute_on_step,
dist_sync_on_step=dist_sync_on_step,
process_group=process_group,
dist_sync_fn=dist_sync_fn,
**kwargs,
)

self.im_type = im_type
Expand Down Expand Up @@ -201,19 +183,13 @@ def __init__(
im_type: str = None,
channel_names: Sequence[str] = None,
reduction="none",
compute_on_step: bool = False,
dist_sync_on_step: bool = False,
process_group: bool = None,
dist_sync_fn: bool = None,
**kwargs,
):
super().__init__(
channel_names=channel_names,
units="",
reduction=reduction,
compute_on_step=compute_on_step,
dist_sync_on_step=dist_sync_on_step,
process_group=process_group,
dist_sync_fn=dist_sync_fn,
**kwargs,
)

self.im_type = im_type
Expand Down Expand Up @@ -252,19 +228,13 @@ def __init__(
im_type: str = None,
channel_names: Sequence[str] = None,
reduction="none",
compute_on_step: bool = False,
dist_sync_on_step: bool = False,
process_group: bool = None,
dist_sync_fn: bool = None,
**kwargs,
):
super().__init__(
channel_names=channel_names,
units="",
reduction=reduction,
compute_on_step=compute_on_step,
dist_sync_on_step=dist_sync_on_step,
process_group=process_group,
dist_sync_fn=dist_sync_fn,
**kwargs,
)

self.im_type = im_type
Expand Down Expand Up @@ -301,19 +271,13 @@ def __init__(
im_type: str = "magnitude",
channel_names: Sequence[str] = None,
reduction="none",
compute_on_step: bool = False,
dist_sync_on_step: bool = False,
process_group: bool = None,
dist_sync_fn: bool = None,
**kwargs,
):
super().__init__(
channel_names=channel_names,
units="",
reduction=reduction,
compute_on_step=compute_on_step,
dist_sync_on_step=dist_sync_on_step,
process_group=process_group,
dist_sync_fn=dist_sync_fn,
**kwargs,
)
self.method = method
self.im_type = im_type
Expand Down Expand Up @@ -522,7 +486,6 @@ def compute_vifp_mscale(
num = 0.0
den = 0.0
for scale in range(1, 5):

N = 2 ** (4 - scale + 1) + 1
sd = N / 5.0

Expand Down
11 changes: 2 additions & 9 deletions meddlr/metrics/lpip.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ def __init__(
pretrained: bool = True,
channel_names: Sequence[str] = None,
reduction="none",
compute_on_step: bool = False,
dist_sync_on_step: bool = False,
process_group: bool = None,
dist_sync_fn: bool = None,
**kwargs,
):
"""
Args:
Expand Down Expand Up @@ -72,10 +69,7 @@ def __init__(
channel_names=channel_names,
units="",
reduction=reduction,
compute_on_step=compute_on_step,
dist_sync_on_step=dist_sync_on_step,
process_group=process_group,
dist_sync_fn=dist_sync_fn,
**kwargs,
)

valid_net_type = ("vgg", "alex", "squeeze")
Expand All @@ -92,7 +86,6 @@ def __init__(
self.mode = mode

def func(self, preds: torch.Tensor, targets: torch.Tensor):

if self.mode == "grayscale":
loss_shape = (targets.shape[0], targets.shape[1])
elif self.mode == "rgb":
Expand Down
10 changes: 2 additions & 8 deletions meddlr/metrics/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,11 @@ def __init__(
channel_names: Sequence[str] = None,
units: str = None,
reduction="none",
compute_on_step: bool = False,
dist_sync_on_step: bool = False,
process_group: bool = None,
dist_sync_fn: bool = None,
**kwargs,
):
self.units = units
super().__init__(
compute_on_step=compute_on_step,
dist_sync_on_step=dist_sync_on_step,
process_group=process_group,
dist_sync_fn=dist_sync_fn,
**kwargs,
)

self.reduction = reduction
Expand Down
40 changes: 8 additions & 32 deletions meddlr/metrics/sem_seg.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,13 @@ def __init__(
self,
channel_names: Sequence[str] = None,
reduction="none",
compute_on_step: bool = False,
dist_sync_on_step: bool = False,
process_group: bool = None,
dist_sync_fn: bool = None,
**kwargs,
):
super().__init__(
channel_names=channel_names,
units="",
reduction=reduction,
compute_on_step=compute_on_step,
dist_sync_on_step=dist_sync_on_step,
process_group=process_group,
dist_sync_fn=dist_sync_fn,
**kwargs,
)

def func(self, preds, targets) -> torch.Tensor:
Expand All @@ -58,19 +52,13 @@ def __init__(
self,
channel_names: Sequence[str] = None,
reduction="none",
compute_on_step: bool = False,
dist_sync_on_step: bool = False,
process_group: bool = None,
dist_sync_fn: bool = None,
**kwargs,
):
super().__init__(
channel_names=channel_names,
units="",
reduction=reduction,
compute_on_step=compute_on_step,
dist_sync_on_step=dist_sync_on_step,
process_group=process_group,
dist_sync_fn=dist_sync_fn,
**kwargs,
)

def func(self, preds, targets) -> torch.Tensor:
Expand All @@ -91,19 +79,13 @@ def __init__(
self,
channel_names: Sequence[str] = None,
reduction="none",
compute_on_step: bool = False,
dist_sync_on_step: bool = False,
process_group: bool = None,
dist_sync_fn: bool = None,
**kwargs,
):
super().__init__(
channel_names=channel_names,
units="",
reduction=reduction,
compute_on_step=compute_on_step,
dist_sync_on_step=dist_sync_on_step,
process_group=process_group,
dist_sync_fn=dist_sync_fn,
**kwargs,
)

def func(self, preds, targets) -> torch.Tensor:
Expand All @@ -130,10 +112,7 @@ def __init__(
connectivity: int = 1,
channel_names: Sequence[str] = None,
reduction="none",
compute_on_step: bool = False,
dist_sync_on_step: bool = False,
process_group: bool = None,
dist_sync_fn: bool = None,
**kwargs,
):
"""
Args:
Expand All @@ -145,10 +124,7 @@ def __init__(
channel_names=channel_names,
units="",
reduction=reduction,
compute_on_step=compute_on_step,
dist_sync_on_step=dist_sync_on_step,
process_group=process_group,
dist_sync_fn=dist_sync_fn,
**kwargs,
)
self.connectivity = connectivity

Expand Down
10 changes: 2 additions & 8 deletions meddlr/metrics/ssfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ def __init__(
layer_names: Sequence[str] = ("block4_relu2",),
channel_names: Sequence[str] = None,
reduction="none",
compute_on_step: bool = False,
dist_sync_on_step: bool = False,
process_group: bool = None,
dist_sync_fn: bool = None,
**kwargs,
):
"""
Args:
Expand All @@ -58,10 +55,7 @@ def __init__(
channel_names=channel_names,
units="",
reduction=reduction,
compute_on_step=compute_on_step,
dist_sync_on_step=dist_sync_on_step,
process_group=process_group,
dist_sync_fn=dist_sync_fn,
**kwargs,
)

valid_modes = ("grayscale", "rgb")
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def get_git_branch():
AUTHOR = "The Meddlr Team"
EMAIL = "arjundd@stanford.edu"
URL = "https://github.com/ad12/meddlr"
REQUIRES_PYTHON = ">=3.6"
REQUIRES_PYTHON = ">=3.8"

REQUIRED = [
"pyxb", # need to install before ismrmrd
Expand All @@ -198,7 +198,7 @@ def get_git_branch():
"silx",
"tqdm",
"omegaconf",
"torchmetrics>=0.5.1,<=0.11.4",
"torchmetrics>=1.0.0",
"iopath",
"packaging",
]
Expand Down