[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-70780":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":23,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":46,"readmeContent":47,"aiSummary":48,"trendingCount":16,"starSnapshotCount":16,"syncStatus":49,"lastSyncTime":50,"discoverSource":51},70780,"segmentation_models.pytorch","qubvel-org\u002Fsegmentation_models.pytorch","qubvel-org","Semantic segmentation models with 500+ pretrained convolutional and transformer-based backbones.","https:\u002F\u002Fsmp.readthedocs.io\u002F",null,"Python",11607,1836,82,70,0,7,23,68,21,44.79,"MIT License",false,"main",[26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45],"computer-vision","deeplab-v3-plus","deeplabv3","dpt","fpn","image-processing","image-segmentation","imagenet","models","pretrained-weights","pspnet","pytorch","segformer","segmentation","segmentation-models","semantic-segmentation","transformers","unet","unet-pytorch","unetplusplus","2026-06-12 02:02:43","\u003Cdiv align=\"center\">\n \n![logo](https:\u002F\u002Fi.ibb.co\u002Fdc1XdhT\u002FSegmentation-Models-V2-Side-1-1.png)  \n**Python library with Neural Networks for Image Semantic  \nSegmentation based on [PyTorch](https:\u002F\u002Fpytorch.org\u002F).**  \n\n \n[![GitHub Workflow Status (branch)](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Factions\u002Fworkflow\u002Fstatus\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Ftests.yml?branch=main&style=for-the-badge)](https:\u002F\u002Fgithub.com\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Factions\u002Fworkflows\u002Ftests.yml) \n![Codecov](https:\u002F\u002Fimg.shields.io\u002Fcodecov\u002Fc\u002Fgithub\u002Fqubvel-org\u002Fsegmentation_models.pytorch?style=for-the-badge)\n[![Read the Docs](https:\u002F\u002Fimg.shields.io\u002Freadthedocs\u002Fsmp?style=for-the-badge&logo=readthedocs&logoColor=white)](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002F) \n\u003Cbr>\n[![PyPI](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Fsegmentation-models-pytorch?color=red&style=for-the-badge&logo=pypi&logoColor=white)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fsegmentation-models-pytorch\u002F) \n[![PyTorch - Version](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPYTORCH-1.9+-red?style=for-the-badge&logo=pytorch)](https:\u002F\u002Fpepy.tech\u002Fproject\u002Fsegmentation-models-pytorch) \n[![Python - Version](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPYTHON-3.9+-red?style=for-the-badge&logo=python&logoColor=white)](https:\u002F\u002Fpepy.tech\u002Fproject\u002Fsegmentation-models-pytorch) \n\u003Cbr>\n[![Generic badge](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-\u003CCOLOR>.svg?style=for-the-badge&color=blue)](https:\u002F\u002Fgithub.com\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002FLICENSE)\n[![PyPI - Downloads](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fdm\u002Fsegmentation-models-pytorch?style=for-the-badge&color=blue)](https:\u002F\u002Fpepy.tech\u002Fproject\u002Fsegmentation-models-pytorch) \n\n\u003C\u002Fdiv>\n\nThe main features of the library are:\n\n - Super simple high-level API (just two lines to create a neural network)\n - 12 encoder-decoder model architectures (Unet, Unet++, Segformer, DPT, ...)\n - 800+ **pretrained** convolution- and transform-based encoders, including [timm](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fpytorch-image-models) support\n - Popular metrics and losses for training routines (Dice, Jaccard, Tversky, ...)\n - ONNX export and torch script\u002Ftrace\u002Fcompile friendly\n\n### 🤝 Sponsor: withoutBG\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fwithoutbg\u002Fwithoutbg\" target=\"_blank\">\n  \u003Cimg src=\"https:\u002F\u002Fwithoutbg.com\u002Fimages\u002Fimg-and-matte.png\" alt=\"Sponsored by withoutBG\"\u002F>\n\u003C\u002Fa>\n\n[withoutBG](https:\u002F\u002Fgithub.com\u002Fwithoutbg\u002Fwithoutbg) is a high-quality background removal tool. They built their open-source image matting and refiner models using `smp.Unet` and are proudly sponsoring this project.\n\n\n### [📚 Project Documentation 📚](http:\u002F\u002Fsmp.readthedocs.io\u002F)\n\nVisit [Read The Docs Project Page](https:\u002F\u002Fsmp.readthedocs.io\u002F) or read the following README to know more about Segmentation Models Pytorch (SMP for short) library\n\n### 📋 Table of content\n 1. [Quick start](#start)\n 2. [Examples](#examples)\n 3. [Models and encoders](#models-and-encoders)\n 4. [Models API](#api)\n    1. [Input channels](#input-channels)\n    2. [Auxiliary classification output](#auxiliary-classification-output)\n    3. [Depth](#depth)\n 5. [Installation](#installation)\n 6. [Competitions won with the library](#competitions)\n 7. [Contributing](#contributing)\n 8. [Citing](#citing)\n 9. [License](#license)\n\n## ⏳ Quick start \u003Ca name=\"start\">\u003C\u002Fa>\n\n#### 1. Create your first Segmentation model with SMP\n\nThe segmentation model is just a PyTorch `torch.nn.Module`, which can be created as easy as:\n\n```python\nimport segmentation_models_pytorch as smp\n\nmodel = smp.Unet(\n    encoder_name=\"resnet34\",        # choose encoder, e.g. mobilenet_v2 or efficientnet-b7\n    encoder_weights=\"imagenet\",     # use `imagenet` pre-trained weights for encoder initialization\n    in_channels=1,                  # model input channels (1 for gray-scale images, 3 for RGB, etc.)\n    classes=3,                      # model output channels (number of classes in your dataset)\n)\n```\n - see [table](#architectures) with available model architectures\n - see [table](#encoders) with available encoders and their corresponding weights\n\n#### 2. Configure data preprocessing\n\nAll encoders have pretrained weights. Preparing your data the same way as during weights pre-training may give you better results (higher metric score and faster convergence). It is **not necessary** in case you train the whole model, not only the decoder.\n\n```python\nfrom segmentation_models_pytorch.encoders import get_preprocessing_fn\n\npreprocess_input = get_preprocessing_fn('resnet18', pretrained='imagenet')\n```\n\nCongratulations! You are done! Now you can train your model with your favorite framework!\n\n## 💡 Examples \u003Ca name=\"examples\">\u003C\u002Fa>\n\n| Name                                      | Link                                                                                           | Colab                                                                                           |\n|-------------------------------------------|-----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------|\n| **Train** pets binary segmentation on OxfordPets     | [Notebook](https:\u002F\u002Fgithub.com\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fbinary_segmentation_intro.ipynb) | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fbinary_segmentation_intro.ipynb) |\n| **Train** cars binary segmentation on CamVid       | [Notebook](https:\u002F\u002Fgithub.com\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fcars%20segmentation%20(camvid).ipynb) | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fcars%20segmentation%20(camvid).ipynb) |\n| **Train** multiclass segmentation on CamVid          | [Notebook](https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fcamvid_segmentation_multiclass.ipynb) | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fcamvid_segmentation_multiclass.ipynb) |\n| **Train** clothes binary segmentation by @ternaus   | [Repo](https:\u002F\u002Fgithub.com\u002Fternaus\u002Fcloths_segmentation)                                        |     |\n| **Load and inference** pretrained Segformer | [Notebook](https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fsegformer_inference_pretrained.ipynb) | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fsegformer_inference_pretrained.ipynb) |\n| **Load and inference** pretrained DPT | [Notebook](https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fdpt_inference_pretrained.ipynb) | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fdpt_inference_pretrained.ipynb) |\n| **Load and inference** pretrained UPerNet | [Notebook](https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fupernet_inference_pretrained.ipynb) | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fupernet_inference_pretrained.ipynb) |\n| **Save and load** models locally \u002F to HuggingFace Hub |[Notebook](https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fsave_load_model_and_share_with_hf_hub.ipynb) | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fsave_load_model_and_share_with_hf_hub.ipynb)\n| **Export** trained model to ONNX              | [Notebook](https:\u002F\u002Fgithub.com\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fconvert_to_onnx.ipynb) | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fconvert_to_onnx.ipynb) |\n\n\n## 📦 Models and encoders \u003Ca name=\"models-and-encoders\">\u003C\u002Fa>\n\n### Architectures \u003Ca name=\"architectures\">\u003C\u002Fa>\n| Architecture | Paper | Documentation | Checkpoints |\n|--------------|-------|---------------|------------|\n| Unet | [paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F1505.04597) | [docs](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#unet) | |\n| Unet++ | [paper](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1807.10165.pdf) | [docs](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#unetplusplus) | |\n| MAnet | [paper](https:\u002F\u002Fieeexplore.ieee.org\u002Fabstract\u002Fdocument\u002F9201310) | [docs](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#manet) | |\n| Linknet | [paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F1707.03718) | [docs](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#linknet) | |\n| FPN | [paper](http:\u002F\u002Fpresentations.cocodataset.org\u002FCOCO17-Stuff-FAIR.pdf) | [docs](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#fpn) | |\n| PSPNet | [paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F1612.01105) | [docs](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#pspnet) | |\n| PAN | [paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F1805.10180) | [docs](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#pan) | |\n| DeepLabV3 | [paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F1706.05587) | [docs](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#deeplabv3) | |\n| DeepLabV3+ | [paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F1802.02611) | [docs](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#deeplabv3plus) | |\n| UPerNet | [paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F1807.10221) | [docs](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#upernet) | [checkpoints](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002Fsmp-hub\u002Fupernet-67fadcdbe08418c6ea94f768) |\n| Segformer | [paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2105.15203) | [docs](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#segformer) | [checkpoints](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002Fsmp-hub\u002Fsegformer-6749eb4923dea2c355f29a1f) |\n| DPT | [paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2103.13413) | [docs](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#dpt) | [checkpoints](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002Fsmp-hub\u002Fdpt-67f30487327c0599a0c62d68) |\n\n### Encoders \u003Ca name=\"encoders\">\u003C\u002Fa>\n\nThe library provides a wide range of **pretrained** encoders (also known as backbones) for segmentation models. Instead of using features from the final layer of a classification model, we extract **intermediate features** and feed them into the decoder for segmentation tasks.  \n\nAll encoders come with **pretrained weights**, which help achieve **faster and more stable convergence** when training segmentation models.  \n\nGiven the extensive selection of supported encoders, you can choose the best one for your specific use case, for example:  \n- **Lightweight encoders** for low-latency applications or real-time inference on edge devices (mobilenet\u002Fmobileone).  \n- **High-capacity architectures** for complex tasks involving a large number of segmented classes, providing superior accuracy (convnext\u002Fswin\u002Fmit).  \n\nBy selecting the right encoder, you can balance **efficiency, performance, and model complexity** to suit your project needs.  \n\nAll encoders and corresponding pretrained weight are listed in the documentation:\n - [table](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fencoders.html) with natively ported encoders \n - [table](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fencoders_timm.html) with [timm](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fpytorch-image-models) encoders supported\n\n## 🔁 Models API \u003Ca name=\"api\">\u003C\u002Fa>\n\n### Input channels\n\nThe input channels parameter allows you to create a model that can process a tensor with an arbitrary number of channels. \nIf you use pretrained weights from ImageNet, the weights of the first convolution will be reused:\n - For the 1-channel case, it would be a sum of the weights of the first convolution layer.\n - Otherwise, channels would be populated with weights like `new_weight[:, i] = pretrained_weight[:, i % 3]`, and then scaled with `new_weight * 3 \u002F new_in_channels`.\n\n```python\nmodel = smp.FPN('resnet34', in_channels=1)\nmask = model(torch.ones([1, 1, 64, 64]))\n```\n\n### Auxiliary classification output\n\nAll models support `aux_params` parameters, which is default set to `None`. \nIf `aux_params = None` then classification auxiliary output is not created, else\nmodel produce not only `mask`, but also `label` output with shape `NC`.\nClassification head consists of GlobalPooling->Dropout(optional)->Linear->Activation(optional) layers, which can be \nconfigured by `aux_params` as follows:\n```python\naux_params=dict(\n    pooling='avg',             # one of 'avg', 'max'\n    dropout=0.5,               # dropout ratio, default is None\n    activation='sigmoid',      # activation function, default is None\n    classes=4,                 # define number of output labels\n)\nmodel = smp.Unet('resnet34', classes=4, aux_params=aux_params)\nmask, label = model(x)\n```\n\n### Depth\n\nDepth parameter specify a number of downsampling operations in encoder, so you can make\nyour model lighter if specify smaller `depth`.\n```python\nmodel = smp.Unet('resnet34', encoder_depth=4)\n```\n\n## 🛠 Installation \u003Ca name=\"installation\">\u003C\u002Fa>\nPyPI version:\n\n```bash\n$ pip install segmentation-models-pytorch\n````\n\nThe latest version from GitHub:\n\n```bash\n$ pip install git+https:\u002F\u002Fgithub.com\u002Fqubvel\u002Fsegmentation_models.pytorch\n````\n\n## 🏆 Competitions won with the library \u003Ca name=\"competitions\">\u003C\u002Fa>\n\n`Segmentation Models` package is widely used in image segmentation competitions.\n[Here](https:\u002F\u002Fgithub.com\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002FHALLOFFAME.md) you can find competitions, names of the winners and links to their solutions.\n\n## 🛠 Projects built with SMP\n\n- [withoutBG](https:\u002F\u002Fgithub.com\u002Fwithoutbg\u002Fwithoutbg): An open-source background removal tool that uses `smp.Unet` for its image matting and refinement models. Check [withoutBG Focus on HuggingFace](https:\u002F\u002Fhuggingface.co\u002Fwithoutbg\u002Ffocus).\n\n\n## 🤝 Contributing \u003Ca name=\"contributing\">\u003C\u002Fa>\n\n1. Install SMP in dev mode\n\n```bash\nmake install_dev  # Create .venv, install SMP in dev mode\n```\n\n2. Run tests and code checks\n\n```bash\nmake test          # Run tests suite with pytest\nmake fixup         # Ruff for formatting and lint checks\n```\n\n3. Update a table (in case you added an encoder)\n\n```bash\nmake table        # Generates a table with encoders and print to stdout\n```\n\n## 📝 Citing \u003Ca name=\"citing\">\u003C\u002Fa>\n```\n@misc{Iakubovskii:2019,\n  Author = {Pavel Iakubovskii},\n  Title = {Segmentation Models Pytorch},\n  Year = {2019},\n  Publisher = {GitHub},\n  Journal = {GitHub repository},\n  Howpublished = {\\url{https:\u002F\u002Fgithub.com\u002Fqubvel\u002Fsegmentation_models.pytorch}}\n}\n```\n\n## 🛡️ License \u003Ca name=\"license\">\u003C\u002Fa>\nThe project is primarily distributed under [MIT License](https:\u002F\u002Fgithub.com\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002FLICENSE), while some files are subject to other licenses. Please refer to [LICENSES](licenses\u002FLICENSES.md) and license statements in each file for careful check, especially for commercial use.\n\n\n","Segmentation Models Pytorch 是一个基于 PyTorch 的图像语义分割库，提供了多种预训练的卷积和Transformer编码器。该项目支持超过12种编解码器架构（如Unet、Unet++、Segformer等）及800多个预训练模型，包括timm的支持，极大地简化了模型创建过程，只需两行代码即可构建神经网络。此外，它还提供了一系列常用的训练指标和损失函数，并且支持ONNX导出以及与Torch脚本\u002F跟踪\u002F编译友好。适用于需要进行图像处理、特别是语义分割任务的各种场景，例如自动驾驶、医学影像分析等领域。",2,"2026-06-11 03:34:10","high_star"]