Skip to content

Commit 6dfc209

Browse files
author
Virginia Fernandez
committed
DCO Remediation Commit for Virginia Fernandez <virginia.fernandez@kcl.ac.uk>
I, Virginia Fernandez <virginia.fernandez@kcl.ac.uk>, hereby add my Signed-off-by to this commit: b1e4a50 I, Virginia Fernandez <virginia.fernandez@kcl.ac.uk>, hereby add my Signed-off-by to this commit: fa0639b I, Virginia Fernandez <virginia.fernandez@kcl.ac.uk>, hereby add my Signed-off-by to this commit: 5594bfe I, Virginia Fernandez <virginia.fernandez@kcl.ac.uk>, hereby add my Signed-off-by to this commit: c99e16e I, Virginia Fernandez <virginia.fernandez@kcl.ac.uk>, hereby add my Signed-off-by to this commit: e3be8de Signed-off-by: Virginia Fernandez <virginia.fernandez@kcl.ac.uk>
1 parent b02053b commit 6dfc209

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

monai/losses/perceptual.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@
2121
from monai.utils.enums import StrEnum
2222

2323
# Valid model name to download from the repository
24-
HF_MONAI_MODELS = (
24+
HF_MONAI_MODELS = frozenset((
2525
"medicalnet_resnet10_23datasets",
2626
"medicalnet_resnet50_23datasets",
2727
"radimagenet_resnet50",
28-
)
28+
))
2929

3030
LPIPS, _ = optional_import("lpips", name="LPIPS")
3131
torchvision, _ = optional_import("torchvision")
3232

3333

3434

35-
class PercetualNetworkType(StrEnum):
35+
class PerceptualNetworkType(StrEnum):
3636
"""Types of neural networks that are supported by perceptual loss."""
3737

3838
alex = "alex"
@@ -81,7 +81,7 @@ class PerceptualLoss(nn.Module):
8181
def __init__(
8282
self,
8383
spatial_dims: int,
84-
network_type: str = PercetualNetworkType.alex,
84+
network_type: str = PerceptualNetworkType.alex,
8585
is_fake_3d: bool = True,
8686
fake_3d_ratio: float = 0.5,
8787
cache_dir: str | None = None,
@@ -103,16 +103,16 @@ def __init__(
103103
"MedicalNet networks are only compatible with ``spatial_dims=3``. Argument is_fake_3d must be set to False."
104104
)
105105
if not channel_wise:
106-
warnings.warn("MedicalNet networks support channel-wise loss. Consider setting channel_wise=True.")
106+
warnings.warn("MedicalNet networks supp, ort channel-wise loss. Consider setting channel_wise=True.", stacklevel=2)
107107

108108
# Channel-wise only for MedicalNet
109109
elif channel_wise:
110110
raise ValueError("Channel-wise loss is only compatible with MedicalNet networks.")
111111

112-
if network_type.lower() not in list(PercetualNetworkType):
112+
if network_type.lower() not in list(PerceptualNetworkType):
113113
raise ValueError(
114114
"Unrecognised criterion entered for Adversarial Loss. Must be one in: %s"
115-
% ", ".join(PercetualNetworkType)
115+
% ", ".join(PerceptualNetworkType)
116116
)
117117

118118
if cache_dir:
@@ -232,7 +232,6 @@ def __init__(
232232
cache_dir: str | None = None,
233233
) -> None:
234234
super().__init__()
235-
torch.hub._validate_not_a_forked_repo = lambda a, b, c: True
236235
if net not in HF_MONAI_MODELS:
237236
raise ValueError(
238237
f"Invalid download model name '{net}'. Must be one of: {', '.join(HF_MONAI_MODELS)}."

0 commit comments

Comments
 (0)