--- id: segmentation-models-pytorch version: "0.5.0" license: The MIT License Copyright (c) 2019, Pavel Iakubovskii Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the… (full text in the JSON record) license_treatment: permissive maintenance: active --- # segmentation-models-pytorch — Image segmentation models with pre-trained backbones. PyTorch. License: permissive · Maintenance: active · Downloads: 692.4K/mo ## What it is and what it does Segmentation Models PyTorch (SMP) is a library that wraps semantic segmentation architectures on top of PyTorch, combining encoder-decoder pairs to produce pixel-level classification masks. It abstracts away the boilerplate of building segmentation models by providing 12 pre-built architectures (Unet, Unet++, Segformer, DPT, DeepLabV3+, and others) that can be instantiated with a choice of encoder backbone and pretrained weights in minimal code. The library's main value is its breadth of pretrained encoders—800+ convolution and transformer-based models sourced from timm and huggingface-hub—which you can mix and match with any decoder architecture. It includes training utilities (Dice, Jaccard, Tversky losses and metrics), supports ONNX export and torch.compile, and integrates with huggingface-hub for model sharing. The typical workflow is to instantiate a model, optionally load pretrained encoder weights, configure data preprocessing to match the encoder's training regime, then train or fine-tune on your segmentation task. Use it for: - Train a binary segmentation model on custom image data (e.g., object boundaries) by choosing an encoder and decoder, then fine-tuning with your labeled dataset. - Load a pretrained Segformer or DPT model for immediate inference on new images without training. - Export a trained segmentation model to ONNX format for deployment in non-Python environments or edge devices. - Experiment with different encoder-decoder combinations to find the best accuracy-speed tradeoff for your segmentation task. - Build a multiclass segmentation pipeline that assigns multiple semantic labels to different regions of an image. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides PyTorch-based neural network models for image semantic segmentation, with 12 encoder-decoder architectures and 800+ pretrained encoders, usable in two lines of code. Yes. The library is actively maintained, has low install friction, carries no known vulnerabilities, and offers a well-designed API for a common computer vision task. Install it if you need to build or fine-tune semantic segmentation models; the breadth of pretrained encoders and multiple architectures make it a practical choice over building from scratch. The MIT license poses no restrictions. ## Install pip install segmentation-models-pytorch uv add segmentation-models-pytorch poetry add segmentation-models-pytorch ## Installing segmentation-models-pytorch Before you install: Low friction installation with a pure Python wheel. Active maintenance with recent commits and 11691 repository stars. Requires torch, torchvision, and timm as runtime dependencies, which are substantial but standard for PyTorch vision work. License in practice: MIT License permits commercial and private use with minimal restrictions. You may use, modify, and distribute the software freely as long as you include the original license and copyright notice. Quickstart: import segmentation_models_pytorch as smp model = smp.Unet( encoder_name="resnet34", encoder_weights="imagenet", in_channels=3, classes=1 ) from segmentation_models_pytorch.encoders import get_preprocessing_fn preprocess_input = get_preprocessing_fn('resnet34', pretrained='imagenet') Requires PyTorch and torchvision installed; models expect input images preprocessed according to the encoder's training regime for best results. Verify before relying: - Whether the 800+ pretrained encoders include all major vision transformer and CNN architectures or a subset thereof. - Performance characteristics (inference speed, memory footprint) for different model sizes and input resolutions. - Whether ONNX export preserves all model features or has known limitations. ## Package facts - License: The MIT License Copyright (c) 2019, Pavel Iakubovskii Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the… (full text in the JSON record) (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 692.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags image semantic segmentation pytorch, pretrained segmentation models, encoder decoder segmentation, unet segmentation library, pytorch image segmentation, segmentation model architectures, semantic segmentation deep learning, computer-vision, semantic-segmentation, pretrained-models [View on SkillFed](https://skillfed.io/packages/segmentation-models-pytorch) · [View on PyPI](https://pypi.org/project/segmentation-models-pytorch/)