Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.
Merged
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
6 changes: 6 additions & 0 deletions generative/losses/perceptual.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ def __init__(self, net: str = "medicalnet_resnet10_23datasets", verbose: bool =
self.model = torch.hub.load("Warvito/MedicalNet-models", model=net, verbose=verbose)
self.eval()

for param in self.parameters():
param.requires_grad = False

def forward(self, input: torch.Tensor, target: torch.Tensor) -> torch.Tensor:
"""
Compute perceptual loss using MedicalNet 3D networks. The input and target tensors are inputted in the
Expand Down Expand Up @@ -198,6 +201,9 @@ def __init__(self, net: str = "radimagenet_resnet50", verbose: bool = False) ->
self.model = torch.hub.load("Warvito/radimagenet-models", model=net, verbose=verbose)
self.eval()

for param in self.parameters():
param.requires_grad = False

def forward(self, input: torch.Tensor, target: torch.Tensor) -> torch.Tensor:
"""
We expect that the input is normalised between [0, 1]. Given the preprocessing performed during the training at
Expand Down
4 changes: 1 addition & 3 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# COPIED FROM https://github.com/Project-MONAI/MONAI/blob/fdd07f36ecb91cfcd491533f4792e1a67a9f89fc/tests/utils.py
# ---------------------------------------------------------------

from __future__ import annotations

#
# Copyright (c) MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down