πŸ” Available Encoders

πŸ” Available Encoders#

Segmentation Models PyTorch provides support for a wide range of encoders. This flexibility allows you to use these encoders with any model in the library by specifying the encoder name in the encoder_name parameter during model initialization.

Here’s a quick example of using a ResNet34 encoder with the Unet model:

from segmentation_models_pytorch import Unet

# Initialize Unet with ResNet34 encoder pre-trained on ImageNet
model = Unet(encoder_name="resnet34", encoder_weights="imagenet")

The following encoder families are supported by the library, enabling you to choose the one that best fits your use case:

  • Mix Vision Transformer (mit)

  • MobileOne

  • MobileNet

  • EfficientNet

  • ResNet

  • ResNeXt

  • SENet

  • DPN

  • VGG

  • DenseNet

  • Xception

  • Inception

Choosing the Right Encoder#

  1. Small Models for Edge Devices Consider encoders like MobileNet or MobileOne, which have a smaller parameter count and are optimized for lightweight deployment.

  2. High Performance If you require state-of-the-art accuracy Mix Vision Transformer (mit), EfficientNet families offer excellent balance between performance and computational efficiency.

For each encoder, the table below provides detailed information:

  1. Pretrained Weights Specifies the available pretrained weights (e.g., imagenet, imagenet21k).

  2. Params, M: The total number of parameters in the encoder, measured in millions. This metric helps you assess the model’s size and computational requirements.

  3. Script: Indicates whether the encoder can be scripted with torch.jit.script.

  4. Compile: Indicates whether the encoder is compatible with torch.compile(model, fullgraph=True, dynamic=True, backend="eager"). You may still get some issues with another backends, such as inductor, depending on the torch/cuda/… dependencies version, but most of the time it will work.

  5. Export: Indicates whether the encoder can be exported using torch.export.export, making it suitable for deployment in different environments (e.g., ONNX).

Encoder

Pretrained weights

Params, M

Script

Compile

Export

resnet18

imagenet / ssl / swsl

11M

βœ…

βœ…

βœ…

resnet34

imagenet

21M

βœ…

βœ…

βœ…

resnet50

imagenet / ssl / swsl

23M

βœ…

βœ…

βœ…

resnet101

imagenet

42M

βœ…

βœ…

βœ…

resnet152

imagenet

58M

βœ…

βœ…

βœ…

resnext50_32x4d

imagenet / ssl / swsl

22M

βœ…

βœ…

βœ…

resnext101_32x4d

ssl / swsl

42M

βœ…

βœ…

βœ…

resnext101_32x8d

imagenet / instagram / ssl / swsl

86M

βœ…

βœ…

βœ…

resnext101_32x16d

instagram / ssl / swsl

191M

βœ…

βœ…

βœ…

resnext101_32x32d

instagram

466M

βœ…

βœ…

βœ…

resnext101_32x48d

instagram

826M

βœ…

βœ…

βœ…

dpn68

imagenet

11M

❌

βœ…

βœ…

dpn68b

imagenet+5k

11M

❌

βœ…

βœ…

dpn92

imagenet+5k

34M

❌

βœ…

βœ…

dpn98

imagenet

58M

❌

βœ…

βœ…

dpn107

imagenet+5k

84M

❌

βœ…

βœ…

dpn131

imagenet

76M

❌

βœ…

βœ…

vgg11

imagenet

9M

βœ…

βœ…

βœ…

vgg11_bn

imagenet

9M

βœ…

βœ…

βœ…

vgg13

imagenet

9M

βœ…

βœ…

βœ…

vgg13_bn

imagenet

9M

βœ…

βœ…

βœ…

vgg16

imagenet

14M

βœ…

βœ…

βœ…

vgg16_bn

imagenet

14M

βœ…

βœ…

βœ…

vgg19

imagenet

20M

βœ…

βœ…

βœ…

vgg19_bn

imagenet

20M

βœ…

βœ…

βœ…

senet154

imagenet

113M

βœ…

βœ…

βœ…

se_resnet50

imagenet

26M

βœ…

βœ…

βœ…

se_resnet101

imagenet

47M

βœ…

βœ…

βœ…

se_resnet152

imagenet

64M

βœ…

βœ…

βœ…

se_resnext50_32x4d

imagenet

25M

βœ…

βœ…

βœ…

se_resnext101_32x4d

imagenet

46M

βœ…

βœ…

βœ…

densenet121

imagenet

6M

βœ…

βœ…

βœ…

densenet169

imagenet

12M

βœ…

βœ…

βœ…

densenet201

imagenet

18M

βœ…

βœ…

βœ…

densenet161

imagenet

26M

βœ…

βœ…

βœ…

inceptionresnetv2

imagenet / imagenet+background

54M

βœ…

βœ…

βœ…

inceptionv4

imagenet / imagenet+background

41M

βœ…

βœ…

βœ…

efficientnet-b0

imagenet / advprop

4M

βœ…

βœ…

βœ…

efficientnet-b1

imagenet / advprop

6M

βœ…

βœ…

βœ…

efficientnet-b2

imagenet / advprop

7M

βœ…

βœ…

βœ…

efficientnet-b3

imagenet / advprop

10M

βœ…

βœ…

βœ…

efficientnet-b4

imagenet / advprop

17M

βœ…

βœ…

βœ…

efficientnet-b5

imagenet / advprop

28M

βœ…

βœ…

βœ…

efficientnet-b6

imagenet / advprop

40M

βœ…

βœ…

βœ…

efficientnet-b7

imagenet / advprop

63M

βœ…

βœ…

βœ…

mobilenet_v2

imagenet

2M

βœ…

βœ…

βœ…

xception

imagenet

20M

βœ…

βœ…

βœ…

timm-efficientnet-b0

imagenet / advprop / noisy-student

4M

βœ…

βœ…

βœ…

timm-efficientnet-b1

imagenet / advprop / noisy-student

6M

βœ…

βœ…

βœ…

timm-efficientnet-b2

imagenet / advprop / noisy-student

7M

βœ…

βœ…

βœ…

timm-efficientnet-b3

imagenet / advprop / noisy-student

10M

βœ…

βœ…

βœ…

timm-efficientnet-b4

imagenet / advprop / noisy-student

17M

βœ…

βœ…

βœ…

timm-efficientnet-b5

imagenet / advprop / noisy-student

28M

βœ…

βœ…

βœ…

timm-efficientnet-b6

imagenet / advprop / noisy-student

40M

βœ…

βœ…

βœ…

timm-efficientnet-b7

imagenet / advprop / noisy-student

63M

βœ…

βœ…

βœ…

timm-efficientnet-b8

imagenet / advprop

84M

βœ…

βœ…

βœ…

timm-efficientnet-l2

noisy-student / noisy-student-475

474M

βœ…

βœ…

βœ…

timm-tf_efficientnet_lite0

imagenet

3M

βœ…

βœ…

βœ…

timm-tf_efficientnet_lite1

imagenet

4M

βœ…

βœ…

βœ…

timm-tf_efficientnet_lite2

imagenet

4M

βœ…

βœ…

βœ…

timm-tf_efficientnet_lite3

imagenet

6M

βœ…

βœ…

βœ…

timm-tf_efficientnet_lite4

imagenet

11M

βœ…

βœ…

βœ…

timm-skresnet18

imagenet

11M

βœ…

βœ…

βœ…

timm-skresnet34

imagenet

21M

βœ…

βœ…

βœ…

timm-skresnext50_32x4d

imagenet

23M

βœ…

βœ…

βœ…

mit_b0

imagenet

3M

βœ…

βœ…

βœ…

mit_b1

imagenet

13M

βœ…

βœ…

βœ…

mit_b2

imagenet

24M

βœ…

βœ…

βœ…

mit_b3

imagenet

44M

βœ…

βœ…

βœ…

mit_b4

imagenet

60M

βœ…

βœ…

βœ…

mit_b5

imagenet

81M

βœ…

βœ…

βœ…

mobileone_s0

imagenet

4M

βœ…

βœ…

βœ…

mobileone_s1

imagenet

3M

βœ…

βœ…

βœ…

mobileone_s2

imagenet

5M

βœ…

βœ…

βœ…

mobileone_s3

imagenet

8M

βœ…

βœ…

βœ…

mobileone_s4

imagenet

12M

βœ…

βœ…

βœ