diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 30b4302f..78b3baf7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 }} diff --git a/meddlr/metrics/image.py b/meddlr/metrics/image.py index 71393f0b..ec5fd8b4 100644 --- a/meddlr/metrics/image.py +++ b/meddlr/metrics/image.py @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/meddlr/metrics/lpip.py b/meddlr/metrics/lpip.py index a79ac77f..e1575840 100644 --- a/meddlr/metrics/lpip.py +++ b/meddlr/metrics/lpip.py @@ -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: @@ -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") @@ -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": diff --git a/meddlr/metrics/metric.py b/meddlr/metrics/metric.py index f3692b3f..dee4e6dd 100644 --- a/meddlr/metrics/metric.py +++ b/meddlr/metrics/metric.py @@ -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 diff --git a/meddlr/metrics/sem_seg.py b/meddlr/metrics/sem_seg.py index 7ac781db..ff4860ee 100644 --- a/meddlr/metrics/sem_seg.py +++ b/meddlr/metrics/sem_seg.py @@ -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: @@ -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: @@ -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: @@ -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: @@ -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 diff --git a/meddlr/metrics/ssfd.py b/meddlr/metrics/ssfd.py index 019ec093..9b3a7363 100644 --- a/meddlr/metrics/ssfd.py +++ b/meddlr/metrics/ssfd.py @@ -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: @@ -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") diff --git a/setup.py b/setup.py index 777b2133..b6d264a4 100644 --- a/setup.py +++ b/setup.py @@ -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 @@ -198,7 +198,7 @@ def get_git_branch(): "silx", "tqdm", "omegaconf", - "torchmetrics>=0.5.1,<=0.11.4", + "torchmetrics>=1.0.0", "iopath", "packaging", ]