From bc9cde262abb821d1ad1e091f8ab9d05e25767fc Mon Sep 17 00:00:00 2001 From: DCalhas Date: Fri, 11 Apr 2025 11:15:19 +0100 Subject: [PATCH 1/2] add upsampling parameter #1106 --- segmentation_models_pytorch/decoders/segformer/model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/segmentation_models_pytorch/decoders/segformer/model.py b/segmentation_models_pytorch/decoders/segformer/model.py index 65d7e8fa..c13b1e31 100644 --- a/segmentation_models_pytorch/decoders/segformer/model.py +++ b/segmentation_models_pytorch/decoders/segformer/model.py @@ -56,6 +56,7 @@ def __init__( in_channels: int = 3, classes: int = 1, activation: Optional[Union[str, Callable]] = None, + upsampling: int = 4, aux_params: Optional[dict] = None, **kwargs: dict[str, Any], ): @@ -80,7 +81,7 @@ def __init__( out_channels=classes, activation=activation, kernel_size=1, - upsampling=4, + upsampling=upsampling, ) if aux_params is not None: From 463ee5943424ac766bfe3e0b9a7bda8f046524cb Mon Sep 17 00:00:00 2001 From: DCalhas Date: Fri, 11 Apr 2025 14:13:27 +0100 Subject: [PATCH 2/2] docstring upsampling parameter #1123 --- segmentation_models_pytorch/decoders/segformer/model.py | 1 + 1 file changed, 1 insertion(+) diff --git a/segmentation_models_pytorch/decoders/segformer/model.py b/segmentation_models_pytorch/decoders/segformer/model.py index c13b1e31..03deeeef 100644 --- a/segmentation_models_pytorch/decoders/segformer/model.py +++ b/segmentation_models_pytorch/decoders/segformer/model.py @@ -29,6 +29,7 @@ class Segformer(SegmentationModel): activation: An activation function to apply after the final convolution layer. Available options are **"sigmoid"**, **"softmax"**, **"logsoftmax"**, **"tanh"**, **"identity"**, **callable** and **None**. Default is **None**. + upsampling: A number to upsample the output of the model, default is 4 (same size as input) aux_params: Dictionary with parameters of the auxiliary output (classification head). Auxiliary output is build on top of encoder if **aux_params** is not **None** (default). Supported params: - classes (int): A number of classes