whatisgithub

What is segmentation_models.pytorch?

qubvel-org/segmentation_models.pytorch — explained in plain English

Analysis updated 2026-06-24

11,548PythonAudience · researcherComplexity · 3/5LicenseSetup · moderate

In one sentence

A Python library for training AI models that identify exactly which pixels in an image belong to each object or category. Offers 12 architectures and over 800 pretrained backbones, all usable in two lines of code.

Mindmap

mindmap
  root((repo))
    What It Does
      Image segmentation
      Pixel-level labeling
      Model training
    Tech Stack
      Python
      PyTorch
      ONNX
      HuggingFace Hub
    Architectures
      Unet
      Segformer
      DPT and others
    Use Cases
      Medical imaging
      Satellite analysis
      Object detection
    Audience
      AI researchers
      Computer vision devs
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Train a Unet model to outline specific objects in photos, such as tumors in medical scans or roads in satellite images

USE CASE 2

Export a trained segmentation model to ONNX and run it in a production environment outside of Python

USE CASE 3

Fine-tune a pretrained backbone on your own dataset for binary segmentation with just two lines of setup code

What is it built with?

PythonPyTorchONNXHuggingFace Hub

How does it compare?

qubvel-org/segmentation_models.pytorchpwxcoo/chinese-xinhuabytedance/trae-agent
Stars11,54811,54411,540
LanguagePythonPythonPython
Setup difficultymoderateeasymoderate
Complexity3/51/53/5
Audienceresearcherdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires Python 3.9+ and PyTorch, a GPU is recommended for training but inference can run on CPU.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

So what is it?

Segmentation Models PyTorch (SMP) is a Python library for training AI models that identify specific regions in images. Image segmentation means going beyond recognizing what is in a picture and instead coloring in exactly which pixels belong to each object or category. For example, a segmentation model could outline every car, every pedestrian, and every road surface in a street photo, each in a different color. The library provides 12 ready-made neural network architectures, including Unet, Segformer, and DPT. Each of these defines a different strategy for combining a feature extractor with a decoder that produces the final pixel-by-pixel map. Users can mix and match these architectures with over 800 pretrained feature extractors, which are neural networks that have already been trained on large image datasets and can be reused to give a head start on a new task. Creating a model takes two lines of Python code. You specify the architecture, choose a pretrained backbone, set the number of input color channels, and set how many categories you want to distinguish. After that you can train the model using any standard training loop. The library also includes ready-made loss functions and accuracy metrics that are commonly used for this type of task. SMP models can be exported to ONNX format, which is a standard format for running models in production environments outside of Python. The library is compatible with HuggingFace Hub for saving and sharing trained models. The project includes Jupyter notebook examples for common tasks such as binary segmentation (finding one type of object) and multiclass segmentation (finding many types at once), as well as examples for loading and running pretrained models without any training. It is installed from PyPI, requires Python 3.9 or higher, and is released under the MIT license.

Copy-paste prompts

Prompt 1
I want to use segmentation_models.pytorch to find and outline all cars in dashcam footage. Help me set up a Unet with a pretrained ResNet backbone, define the loss function and metric, and write a basic training loop.
Prompt 2
Using SMP, help me export my trained Unet segmentation model to ONNX so I can run it inside a Docker container without PyTorch installed.
Prompt 3
I have a medical imaging dataset with binary masks marking tumors. Walk me through fine-tuning a pretrained SMP model on it using the provided Jupyter notebook examples as a guide.
Prompt 4
Help me use segmentation_models.pytorch to download a pretrained model from HuggingFace Hub and run inference on a single image without any training.

Frequently asked questions

What is segmentation_models.pytorch?

A Python library for training AI models that identify exactly which pixels in an image belong to each object or category. Offers 12 architectures and over 800 pretrained backbones, all usable in two lines of code.

What language is segmentation_models.pytorch written in?

Mainly Python. The stack also includes Python, PyTorch, ONNX.

What license does segmentation_models.pytorch use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is segmentation_models.pytorch to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is segmentation_models.pytorch for?

Mainly researcher.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.