Skip to content

Update test_models.py #940

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

Merged
merged 2 commits into from
Oct 12, 2024
Merged
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
27 changes: 21 additions & 6 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,21 @@ def get_encoders():

def get_sample(model_class):
if model_class in [
smp.Unet,
smp.Linknet,
smp.FPN,
smp.PSPNet,
smp.Linknet,
smp.Unet,
smp.UnetPlusPlus,
smp.MAnet,
smp.UPerNet,
]:
sample = torch.ones([1, 3, 64, 64])
elif model_class == smp.PAN:
sample = torch.ones([2, 3, 256, 256])
elif model_class == smp.DeepLabV3:
elif model_class in [smp.DeepLabV3, smp.DeepLabV3Plus]:
sample = torch.ones([2, 3, 128, 128])
elif model_class in [smp.PSPNet, smp.UPerNet]:
# Batch size 2 needed due to nn.BatchNorm2d not supporting (1, C, 1, 1) input
# from PSPModule pooling in PSPNet/UPerNet.
sample = torch.ones([2, 3, 64, 64])
else:
raise ValueError("Not supported model class {}".format(model_class))
return sample
Expand Down Expand Up @@ -102,6 +104,8 @@ def test_forward(model_class, encoder_name, encoder_depth, **kwargs):
smp.UnetPlusPlus,
smp.MAnet,
smp.DeepLabV3,
smp.DeepLabV3Plus,
smp.UPerNet,
],
)
def test_forward_backward(model_class):
Expand All @@ -112,7 +116,18 @@ def test_forward_backward(model_class):

@pytest.mark.parametrize(
"model_class",
[smp.PAN, smp.FPN, smp.PSPNet, smp.Linknet, smp.Unet, smp.UnetPlusPlus, smp.MAnet],
[
smp.PAN,
smp.FPN,
smp.PSPNet,
smp.Linknet,
smp.Unet,
smp.UnetPlusPlus,
smp.MAnet,
smp.DeepLabV3,
smp.DeepLabV3Plus,
smp.UPerNet,
],
)
def test_aux_output(model_class):
model = model_class(
Expand Down