segmentation-models-pytorch
Image segmentation models with pre-trained backbones. PyTorch.
Decision gist · record as of 2026-08-14
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.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires PyTorch and torchvision installed; models expect input images preprocessed according to the encoder's training regime for best results.
- Low friction installation with a pure Python wheel.
- Active maintenance with recent commits and 11691 repository stars.
License · maintenance · safety
permissive license (permissive) — 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.
last release 2025-04-17 (484 days) · last repo commit 2026-08-14 · 11,691 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 692,350 downloads/mo, #5,321 on PyPI
Alternatives
Verify before relying
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')- 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.
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 on this page. Verify before relying on it.
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
segmentation-models-pytorch on PyPI
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.
Requires PyTorch and torchvision installed; models expect input images preprocessed according to the encoder's training regime for best results.
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')
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 | permissive license permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 8 packageshuggingface-hubnumpypillowsafetensorstimmtorchtorchvisiontqdm |
| Maintenance | Actively maintained 484 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 692,350 / month, #5,321 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy |
Evidence: segmentation_models_pytorch-0.5.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “image semantic segmentation pytorch”
- segmentation-models-pytorchProvides PyTorch-based neural network models for image semantic…
- nnunetv2nnU-Net is a semantic segmentation framework that automatically…
- pytorchcvProvides a collection of pretrained computer vision models for…
Give your agent the search over MCP, or paste the wish link into any chat.
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to call 100+ LLM providers (OpenAI, Anthropic, Gemini, Bedrock, Azure, and others) using OpenAI-compatible API format, available as both a Python SDK and a self-hosted AI Gateway proxy server.
Install it if you need to work with multiple LLM providers or want to centralize LLM routing in your organization.
Client library and CLI tool for downloading, uploading, and managing models, datasets, and repositories on the Hugging Face Hub platform.
Install it if you work with Hugging Face Hub models or datasets.
LangChain provides a framework for building agents and LLM-powered applications by composing language models, tools, and memory through a unified API that abstracts over multiple model providers.
hf-xet provides chunk-based deduplication and efficient file transfer for the Hugging Face Hub, enabling faster uploads and downloads of large files with local disk caching.
Tokenizers converts raw text into token sequences for NLP models, with support for training custom vocabularies and using pre-built tokenizers (BPE, WordPiece) optimized for speed via Rust.
Transformers provides a unified framework for loading, fine-tuning, and running state-of-the-art pretrained models across text, vision, audio, video, and multimodal tasks using PyTorch, JAX, or TensorFlow.
Install it if you need to run or train any transformer-based model for NLP, vision, audio, or multimodal tasks.
See also nnunetv2 · timm · pytorchcv · torchxrayvision · cellpose · efficientnet-pytorch · effdet · pretrainedmodels · thinc · mmdet