From 31249514d6b9d81bdfcb1034cbb0e895648e0a7b Mon Sep 17 00:00:00 2001 From: Isaac Corley Date: Mon, 1 Dec 2025 11:35:29 -0600 Subject: [PATCH 1/3] fix torchfix errors --- segmentation_models_pytorch/base/heads.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/segmentation_models_pytorch/base/heads.py b/segmentation_models_pytorch/base/heads.py index fbc939cad..5fe06a0ba 100644 --- a/segmentation_models_pytorch/base/heads.py +++ b/segmentation_models_pytorch/base/heads.py @@ -10,7 +10,7 @@ def __init__( in_channels, out_channels, kernel_size=kernel_size, padding=kernel_size // 2 ) upsampling = ( - nn.UpsamplingBilinear2d(scale_factor=upsampling) + nn.Upsample(mode="bilinear", scale_factor=upsampling) if upsampling > 1 else nn.Identity() ) From c8e500a1bba1d918383c5624d190ad774e770ee8 Mon Sep 17 00:00:00 2001 From: Isaac Corley Date: Mon, 1 Dec 2025 12:18:03 -0600 Subject: [PATCH 2/3] fix torchfix errors x2 --- segmentation_models_pytorch/decoders/deeplabv3/decoder.py | 2 +- segmentation_models_pytorch/losses/_functional.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/segmentation_models_pytorch/decoders/deeplabv3/decoder.py b/segmentation_models_pytorch/decoders/deeplabv3/decoder.py index 6a801a702..94550666b 100644 --- a/segmentation_models_pytorch/decoders/deeplabv3/decoder.py +++ b/segmentation_models_pytorch/decoders/deeplabv3/decoder.py @@ -105,7 +105,7 @@ def __init__( ) scale_factor = 4 if output_stride == 16 and encoder_depth > 3 else 2 - self.up = nn.UpsamplingBilinear2d(scale_factor=scale_factor) + self.up = nn.Upsample(mode="bilinear", scale_factor=scale_factor) highres_in_channels = encoder_channels[2] highres_out_channels = 48 # proposed by authors of paper diff --git a/segmentation_models_pytorch/losses/_functional.py b/segmentation_models_pytorch/losses/_functional.py index 07efd7f43..74a63a8d6 100644 --- a/segmentation_models_pytorch/losses/_functional.py +++ b/segmentation_models_pytorch/losses/_functional.py @@ -226,7 +226,7 @@ def wing_loss( idx_smaller = diff_abs < width idx_bigger = diff_abs >= width - loss[idx_smaller] = width * torch.log(1 + diff_abs[idx_smaller] / curvature) + loss[idx_smaller] = width * torch.log1p(diff_abs[idx_smaller] / curvature) C = width - width * math.log(1 + width / curvature) loss[idx_bigger] = loss[idx_bigger] - C From 5e2bfa3cea1d7773ef98d53efb85cdb2f14e92bb Mon Sep 17 00:00:00 2001 From: Isaac Corley Date: Mon, 1 Dec 2025 13:57:11 -0600 Subject: [PATCH 3/3] fix torchfix errors x3 --- segmentation_models_pytorch/base/heads.py | 3 ++- segmentation_models_pytorch/decoders/deeplabv3/decoder.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/segmentation_models_pytorch/base/heads.py b/segmentation_models_pytorch/base/heads.py index 5fe06a0ba..992f77d3b 100644 --- a/segmentation_models_pytorch/base/heads.py +++ b/segmentation_models_pytorch/base/heads.py @@ -1,4 +1,5 @@ import torch.nn as nn + from .modules import Activation @@ -10,7 +11,7 @@ def __init__( in_channels, out_channels, kernel_size=kernel_size, padding=kernel_size // 2 ) upsampling = ( - nn.Upsample(mode="bilinear", scale_factor=upsampling) + nn.Upsample(mode="bilinear", scale_factor=upsampling, align_corners=True) if upsampling > 1 else nn.Identity() ) diff --git a/segmentation_models_pytorch/decoders/deeplabv3/decoder.py b/segmentation_models_pytorch/decoders/deeplabv3/decoder.py index 94550666b..179985fd7 100644 --- a/segmentation_models_pytorch/decoders/deeplabv3/decoder.py +++ b/segmentation_models_pytorch/decoders/deeplabv3/decoder.py @@ -31,7 +31,7 @@ """ from collections.abc import Iterable, Sequence -from typing import Literal, List +from typing import List, Literal import torch from torch import nn @@ -105,7 +105,9 @@ def __init__( ) scale_factor = 4 if output_stride == 16 and encoder_depth > 3 else 2 - self.up = nn.Upsample(mode="bilinear", scale_factor=scale_factor) + self.up = nn.Upsample( + mode="bilinear", scale_factor=scale_factor, align_corners=True + ) highres_in_channels = encoder_channels[2] highres_out_channels = 48 # proposed by authors of paper