[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-qubvel-org--segmentation_models.pytorch":3,"tool-qubvel-org--segmentation_models.pytorch":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":70,"readme_en":71,"readme_zh":72,"quickstart_zh":73,"use_case_zh":74,"hero_image_url":75,"owner_login":76,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":79,"owner_location":79,"owner_email":79,"owner_twitter":79,"owner_website":79,"owner_url":80,"languages":81,"stars":90,"forks":91,"last_commit_at":92,"license":93,"difficulty_score":94,"env_os":95,"env_gpu":96,"env_ram":95,"env_deps":97,"category_tags":104,"github_topics":105,"view_count":23,"oss_zip_url":79,"oss_zip_packed_at":79,"status":16,"created_at":126,"updated_at":127,"faqs":128,"releases":149},2954,"qubvel-org\u002Fsegmentation_models.pytorch","segmentation_models.pytorch","Semantic segmentation models with 500+ pretrained convolutional and transformer-based backbones.","segmentation_models.pytorch 是一个基于 PyTorch 构建的开源深度学习库，专为图像语义分割任务设计。它的核心目标是帮助开发者快速搭建高性能的分割模型，将图像中的每个像素精准分类到特定类别（如区分道路、车辆或行人），从而解决医疗影像分析、自动驾驶感知及卫星地图处理等场景中的关键难题。\n\n该库最大的亮点在于其极简的高层 API 与丰富的预训练资源。用户仅需两行代码即可实例化一个完整的神经网络，无需从零开始编写复杂的底层架构。它内置了包括 U-Net、SegFormer 在内的 12 种主流编码器 - 解码器架构，并支持超过 800 种基于卷积神经网络和 Transformer 的预训练骨干网络（Backbones），其中许多权重已在 ImageNet 等大型数据集上完成训练，能显著加速模型收敛并提升精度。此外，它还集成了 Dice、Jaccard 等常用评估指标与损失函数，并支持导出为 ONNX 格式，便于后续部署。\n\nsegmentation_models.pytorch 非常适合计算机视觉领域的研究人员、算法工程师以及希望快速验证想法的开发者使用。无论是","segmentation_models.pytorch 是一个基于 PyTorch 构建的开源深度学习库，专为图像语义分割任务设计。它的核心目标是帮助开发者快速搭建高性能的分割模型，将图像中的每个像素精准分类到特定类别（如区分道路、车辆或行人），从而解决医疗影像分析、自动驾驶感知及卫星地图处理等场景中的关键难题。\n\n该库最大的亮点在于其极简的高层 API 与丰富的预训练资源。用户仅需两行代码即可实例化一个完整的神经网络，无需从零开始编写复杂的底层架构。它内置了包括 U-Net、SegFormer 在内的 12 种主流编码器 - 解码器架构，并支持超过 800 种基于卷积神经网络和 Transformer 的预训练骨干网络（Backbones），其中许多权重已在 ImageNet 等大型数据集上完成训练，能显著加速模型收敛并提升精度。此外，它还集成了 Dice、Jaccard 等常用评估指标与损失函数，并支持导出为 ONNX 格式，便于后续部署。\n\nsegmentation_models.pytorch 非常适合计算机视觉领域的研究人员、算法工程师以及希望快速验证想法的开发者使用。无论是参加数据科学竞赛，还是进行学术探索与工业级应用开发，它都能提供强大且灵活的工具支持，让用户将更多精力集中在业务逻辑与创新上，而非重复的基础设施搭建。","\u003Cdiv align=\"center\">\n \n![logo](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fqubvel-org_segmentation_models.pytorch_readme_0f6ddb7797e9.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\u002Foss.gittoolsai.com\u002Fimages\u002Fqubvel-org_segmentation_models.pytorch_readme_39c7c643907d.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","\u003Cdiv align=\"center\">\n \n![logo](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fqubvel-org_segmentation_models.pytorch_readme_0f6ddb7797e9.png)  \n**基于 [PyTorch](https:\u002F\u002Fpytorch.org\u002F) 的用于图像语义分割的神经网络 Python 库。**  \n\n \n[![GitHub 工作流状态（分支）](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 - 版本](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 - 版本](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[![通用徽章](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 - 下载量](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\n该库的主要特性包括：\n\n - 超级简单的高级 API（只需两行代码即可创建神经网络）\n - 12 种编码器-解码器模型架构（Unet、Unet++、Segformer、DPT 等）\n - 800 多个基于卷积和变换的 **预训练** 编码器，包括对 [timm](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fpytorch-image-models) 的支持\n - 用于训练过程的常用指标和损失函数（Dice、Jaccard、Tversky 等）\n - 支持 ONNX 导出以及与 Torch Script\u002FTrace\u002FCompile 兼容\n\n### 🤝 赞助商：withoutBG\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fwithoutbg\u002Fwithoutbg\" target=\"_blank\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fqubvel-org_segmentation_models.pytorch_readme_39c7c643907d.png\" alt=\"由 withoutBG 赞助\"\u002F>\n\u003C\u002Fa>\n\n[withoutBG](https:\u002F\u002Fgithub.com\u002Fwithoutbg\u002Fwithoutbg) 是一款高质量的背景移除工具。他们使用 `smp.Unet` 构建了开源的图像抠图和精修模型，并自豪地赞助了这个项目。\n\n\n### [📚 项目文档 📚](http:\u002F\u002Fsmp.readthedocs.io\u002F)\n\n访问 [Read The Docs 项目页面](https:\u002F\u002Fsmp.readthedocs.io\u002F) 或阅读以下 README，以了解更多关于 Segmentation Models Pytorch（简称 SMP）库的信息。\n\n### 📋 目录\n 1. [快速入门](#start)\n 2. [示例](#examples)\n 3. [模型和编码器](#models-and-encoders)\n 4. [模型 API](#api)\n    1. [输入通道](#input-channels)\n    2. [辅助分类输出](#auxiliary-classification-output)\n    3. [深度](#depth)\n 5. [安装](#installation)\n 6. [使用该库赢得的比赛](#competitions)\n 7. [贡献](#contributing)\n 8. [引用](#citing)\n 9. [许可证](#license)\n\n## ⏳ 快速入门 \u003Ca name=\"start\">\u003C\u002Fa>\n\n#### 1. 使用 SMP 创建你的第一个分割模型\n\n分割模型只是一个 PyTorch 的 `torch.nn.Module`，创建起来非常简单：\n\n```python\nimport segmentation_models_pytorch as smp\n\nmodel = smp.Unet(\n    encoder_name=\"resnet34\",        \u002F\u002F 选择编码器，例如 mobilenet_v2 或 efficientnet-b7\n    encoder_weights=\"imagenet\",     \u002F\u002F 使用 imagenet 预训练权重初始化编码器\n    in_channels=1,                  \u002F\u002F 模型输入通道数（灰度图像为 1，RGB 图像为 3 等）\n    classes=3,                      \u002F\u002F 模型输出通道数（数据集中类别数量）\n)\n```\n - 请参阅 [表格](#architectures) 了解可用的模型架构\n - 请参阅 [表格](#encoders) 了解可用的编码器及其对应的权重\n\n#### 2. 配置数据预处理\n\n所有编码器都带有预训练权重。如果你的数据预处理方式与权重预训练时一致，可能会获得更好的结果（更高的指标得分和更快的收敛速度）。不过，如果你训练的是整个模型，而不仅仅是解码器，则这并非必需。\n\n```python\nfrom segmentation_models_pytorch.encoders import get_preprocessing_fn\n\npreprocess_input = get_preprocessing_fn('resnet18', pretrained='imagenet')\n```\n\n恭喜你！大功告成！现在你可以用自己喜欢的框架来训练你的模型了！\n\n## 💡 示例 \u003Ca name=\"examples\">\u003C\u002Fa>\n\n| 名称                                      | 链接                                                                                           | Colab                                                                                           |\n|-------------------------------------------|-----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------|\n| **训练** 牛津宠物数据集上的二分类分割     | [Notebook](https:\u002F\u002Fgithub.com\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fbinary_segmentation_intro.ipynb) | [![在 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| **训练** CamVid 数据集上的汽车二分类分割       | [Notebook](https:\u002F\u002Fgithub.com\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fcars%20segmentation%20(camvid).ipynb) | [![在 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| **训练** CamVid 数据集上的多类分割          | [Notebook](https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fcamvid_segmentation_multiclass.ipynb) | [![在 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| **训练** @ternaus 的服装二分类分割   | [仓库](https:\u002F\u002Fgithub.com\u002Fternaus\u002Fcloths_segmentation)                                        |     |\n| **加载并推理** 预训练的 Segformer | [Notebook](https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fsegformer_inference_pretrained.ipynb) | [![在 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| **加载并推理** 预训练的 DPT | [Notebook](https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fdpt_inference_pretrained.ipynb) | [![在 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| **加载并推理** 预训练的 UPerNet | [Notebook](https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fupernet_inference_pretrained.ipynb) | [![在 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| **保存和加载** 模型到本地或 HuggingFace Hub |[Notebook](https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fsave_load_model_and_share_with_hf_hub.ipynb) | [![在 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| **导出** 训练好的模型为 ONNX              | [Notebook](https:\u002F\u002Fgithub.com\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fconvert_to_onnx.ipynb) | [![在 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## 📦 模型和编码器 \u003Ca name=\"models-and-encoders\">\u003C\u002Fa>\n\n### 架构 \u003Ca name=\"architectures\">\u003C\u002Fa>\n| 架构 | 论文 | 文档 | 检查点 |\n|--------------|-------|---------------|------------|\n| Unet | [论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F1505.04597) | [文档](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#unet) | |\n| Unet++ | [论文](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1807.10165.pdf) | [文档](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#unetplusplus) | |\n| MAnet | [论文](https:\u002F\u002Fieeexplore.ieee.org\u002Fabstract\u002Fdocument\u002F9201310) | [文档](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#manet) | |\n| Linknet | [论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F1707.03718) | [文档](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#linknet) | |\n| FPN | [论文](http:\u002F\u002Fpresentations.cocodataset.org\u002FCOCO17-Stuff-FAIR.pdf) | [文档](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#fpn) | |\n| PSPNet | [论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F1612.01105) | [文档](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#pspnet) | |\n| PAN | [论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F1805.10180) | [文档](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#pan) | |\n| DeepLabV3 | [论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F1706.05587) | [文档](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#deeplabv3) | |\n| DeepLabV3+ | [论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F1802.02611) | [文档](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#deeplabv3plus) | |\n| UPerNet | [论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F1807.10221) | [文档](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#upernet) | [检查点](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002Fsmp-hub\u002Fupernet-67fadcdbe08418c6ea94f768) |\n| Segformer | [论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2105.15203) | [文档](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#segformer) | [检查点](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002Fsmp-hub\u002Fsegformer-6749eb4923dea2c355f29a1f) |\n| DPT | [论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2103.13413) | [文档](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmodels.html#dpt) | [检查点](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002Fsmp-hub\u002Fdpt-67f30487327c0599a0c62d68) |\n\n### 编码器 \u003Ca name=\"encoders\">\u003C\u002Fa>\n\n该库为分割模型提供了广泛的**预训练**编码器（也称为骨干网络）。我们不是使用分类模型最后一层的特征，而是提取**中间特征**并将其输入到解码器中，用于分割任务。\n\n所有编码器都带有**预训练权重**，这有助于在训练分割模型时实现**更快、更稳定的收敛**。\n\n鉴于支持的编码器种类繁多，您可以根据具体用例选择最适合的编码器，例如：\n- **轻量级编码器**适用于低延迟应用或边缘设备上的实时推理（如 mobilenet\u002Fmobileone）。\n- **高容量架构**适用于涉及大量分割类别的复杂任务，能够提供更高的精度（如 convnext\u002Fswin\u002Fmit）。\n\n通过选择合适的编码器，您可以平衡**效率、性能和模型复杂度**，以满足项目需求。\n\n所有编码器及其对应的预训练权重均列于文档中：\n- [表格](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fencoders.html) 中包含原生移植的编码器\n- [表格](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fencoders_timm.html) 中包含由 [timm](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fpytorch-image-models) 支持的编码器\n\n## 🔁 模型 API \u003Ca name=\"api\">\u003C\u002Fa>\n\n### 输入通道数\n\n`input_channels` 参数允许您创建一个可以处理任意通道数张量的模型。  \n如果您使用 ImageNet 上的预训练权重，则会复用第一层卷积的权重：\n- 对于 1 通道的情况，将对第一层卷积的权重进行求和。\n- 对于其他通道数，通道权重将按 `new_weight[:, i] = pretrained_weight[:, i % 3]` 的方式填充，然后通过 `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### 辅助分类输出\n\n所有模型都支持 `aux_params` 参数，默认值为 `None`。  \n如果 `aux_params = None`，则不会生成辅助分类输出；否则，模型不仅会输出 `mask`，还会输出形状为 `NC` 的 `label` 输出。  \n分类头由 GlobalPooling -> Dropout（可选）-> Linear -> Activation（可选）层组成，可通过 `aux_params` 进行如下配置：\n```python\naux_params=dict(\n    pooling='avg',             # 可选 'avg' 或 'max'\n    dropout=0.5,               # Dropout 比例，默认为 None\n    activation='sigmoid',      # 激活函数，默认为 None\n    classes=4,                 # 定义输出标签数量\n)\nmodel = smp.Unet('resnet34', classes=4, aux_params=aux_params)\nmask, label = model(x)\n```\n\n### 深度\n\n`depth` 参数指定编码器中的下采样操作次数，因此您可以通过设置较小的 `depth` 来使模型更轻量化。\n```python\nmodel = smp.Unet('resnet34', encoder_depth=4)\n```\n\n## 🛠 安装 \u003Ca name=\"installation\">\u003C\u002Fa>\nPyPI 版本：\n\n```bash\n$ pip install segmentation-models-pytorch\n```\n\nGitHub 上的最新版本：\n\n```bash\n$ pip install git+https:\u002F\u002Fgithub.com\u002Fqubvel\u002Fsegmentation_models.pytorch\n```\n\n## 🏆 使用该库赢得的比赛 \u003Ca name=\"competitions\">\u003C\u002Fa>\n\n`Segmentation Models` 包广泛应用于图像分割竞赛中。  \n[此处](https:\u002F\u002Fgithub.com\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002FHALLOFFAME.md) 列出了相关比赛、获胜者姓名以及他们的解决方案链接。\n\n## 🛠 使用 SMP 构建的项目\n\n- [withoutBG](https:\u002F\u002Fgithub.com\u002Fwithoutbg\u002Fwithoutbg)：一个开源背景移除工具，其图像抠图和精修模型使用了 `smp.Unet`。请查看 [withoutBG Focus on HuggingFace](https:\u002F\u002Fhuggingface.co\u002Fwithoutbg\u002Ffocus)。\n\n## 🤝 贡献 \u003Ca name=\"contributing\">\u003C\u002Fa>\n\n1. 以开发模式安装 SMP\n\n```bash\nmake install_dev  # 创建 .venv，并以开发模式安装 SMP\n```\n\n2. 运行测试和代码检查\n\n```bash\nmake test          # 使用 pytest 运行测试套件\nmake fixup         # 使用 Ruff 进行格式化和 lint 检查\n```\n\n3. 更新表格（如果您添加了新的编码器）\n\n```bash\nmake table        # 生成编码器表格并打印到 stdout\n```\n\n## 📝 引用 \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 仓库},\n  Howpublished = {\\url{https:\u002F\u002Fgithub.com\u002Fqubvel\u002Fsegmentation_models.pytorch}}\n}\n```\n\n## 🛡️ 许可证 \u003Ca name=\"license\">\u003C\u002Fa>\n该项目主要采用 [MIT 许可证](https:\u002F\u002Fgithub.com\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002FLICENSE) 发布，但部分文件可能适用其他许可证。请仔细查阅 [LICENSES](licenses\u002FLICENSES.md) 文件及各文件中的许可声明，尤其是在商业用途时。","# segmentation_models.pytorch 快速上手指南\n\n`segmentation_models.pytorch` (简称 SMP) 是一个基于 PyTorch 的图像语义分割工具库。它提供了极简的高层 API，支持 12 种主流分割架构（如 Unet, Unet++, Segformer, DPT 等）以及 800+ 种预训练编码器（Backbones），能帮助开发者快速构建高性能的分割模型。\n\n## 环境准备\n\n在开始之前，请确保你的开发环境满足以下要求：\n\n*   **操作系统**: Linux, macOS 或 Windows\n*   **Python 版本**: 3.9 或更高\n*   **PyTorch 版本**: 1.9 或更高\n*   **前置依赖**: 已正确安装 CUDA（如需 GPU 加速）及对应的 `torch` 和 `torchvision`\n\n建议先访问 [PyTorch 官网](https:\u002F\u002Fpytorch.org\u002F) 根据你的环境安装基础深度学习框架。\n\n## 安装步骤\n\n你可以使用 `pip` 直接安装最新稳定版。国内用户推荐使用清华或阿里镜像源以加速下载。\n\n**使用官方源安装：**\n```bash\npip install segmentation-models-pytorch\n```\n\n**使用国内镜像源安装（推荐）：**\n```bash\npip install segmentation-models-pytorch -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n## 基本使用\n\nSMP 的核心优势在于其简洁的 API，仅需几行代码即可实例化一个完整的分割模型。\n\n### 1. 创建模型\n\n以下示例展示如何创建一个基于 `ResNet34` 编码器的 `Unet` 模型，并加载 ImageNet 预训练权重：\n\n```python\nimport segmentation_models_pytorch as smp\n\nmodel = smp.Unet(\n    encoder_name=\"resnet34\",        # 选择编码器，例如 \"mobilenet_v2\", \"efficientnet-b7\" 等\n    encoder_weights=\"imagenet\",     # 使用 \"imagenet\" 预训练权重初始化编码器\n    in_channels=1,                  # 输入通道数 (1 代表灰度图，3 代表 RGB 彩色图)\n    classes=3,                      # 输出类别数 (根据数据集的类别数量设定)\n)\n```\n\n> **提示**：支持的架构包括 `Unet`, `Unet++`, `MAnet`, `Linknet`, `FPN`, `PSPNet`, `DeepLabV3`, `DeepLabV3+`, `PAN`, `UPerNet`, `Segformer`, `DPT`。\n\n### 2. 配置数据预处理\n\n为了充分发挥预训练权重的效果，建议对输入数据进行与预训练时相同的预处理（归一化等）。这通常能带来更快的收敛速度和更高的指标分数。\n\n```python\nfrom segmentation_models_pytorch.encoders import get_preprocessing_fn\n\n# 获取对应编码器的预处理函数\npreprocess_input = get_preprocessing_fn('resnet34', pretrained='imagenet')\n\n# 使用示例 (假设 image 是 numpy 数组)\n# image = preprocess_input(image)\n```\n\n完成上述两步后，`model` 就是一个标准的 PyTorch `torch.nn.Module`，你可以直接使用熟悉的 PyTorch 训练循环、损失函数（如 Dice Loss, Jaccard Loss）和数据加载器进行模型训练或推理。","某医疗影像初创团队正在开发一款自动识别肺部 CT 扫描中病灶区域的辅助诊断系统，急需构建高精度的语义分割模型。\n\n### 没有 segmentation_models.pytorch 时\n- **重复造轮子耗时久**：工程师需手动从零编写 U-Net、DeepLabV3+ 等复杂架构的代码，仅搭建基础模型就耗费数周时间。\n- **预训练权重难整合**：寻找并适配 ResNet、EfficientNet 等在 ImageNet 上预训练的骨干网络极其繁琐，常因维度不匹配导致加载失败。\n- **实验迭代效率低**：尝试不同编码器（Encoder）或切换损失函数（如 Dice Loss）时，需大幅修改底层代码，难以快速验证哪种组合效果最佳。\n- **部署兼容性问题**：模型训练完成后，导出为 ONNX 格式以便部署时常遇到算子不支持的问题，需要额外编写转换脚本。\n\n### 使用 segmentation_models.pytorch 后\n- **两行代码建模型**：利用其高层 API，仅需两行代码即可实例化带有预训练权重的 Unet 或 Segformer 模型，将开发周期从数周缩短至几小时。\n- **海量骨干网即插即用**：直接调用库内集成的 800+ 种预训练编码器（包括 timm 库支持），一键加载 ImageNet 权重，显著提升小样本下的收敛速度与精度。\n- **灵活配置加速调优**：通过简单参数即可自由切换 12 种主流架构及多种专用损失函数，团队能在一天内完成数十组对比实验，快速锁定最优方案。\n- **原生支持生产部署**：模型天然兼容 torch script 与 ONNX 导出，无需额外适配即可无缝接入医院的边缘计算设备或云端推理服务。\n\nsegmentation_models.pytorch 通过提供“开箱即用”的模块化设计，让团队将精力从繁琐的工程实现转移到核心算法优化上，极大提升了医疗 AI 产品的落地速度。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fqubvel-org_segmentation_models.pytorch_0f6ddb77.png","qubvel-org","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fqubvel-org_80ab0ae9.png","",null,"https:\u002F\u002Fgithub.com\u002Fqubvel-org",[82,86],{"name":83,"color":84,"percentage":85},"Python","#3572A5",99.8,{"name":87,"color":88,"percentage":89},"Makefile","#427819",0.2,11447,1838,"2026-04-03T08:26:50","MIT",1,"未说明","未说明 (基于 PyTorch，支持 CPU 和 GPU 运行，具体显存需求取决于所选模型架构)",{"notes":98,"python":99,"dependencies":100},"该库是一个基于 PyTorch 的图像语义分割工具包。支持 12 种编码器 - 解码器架构（如 Unet, Segformer, DPT 等）和 800+ 种预训练编码器（包括 timm 库支持的模型）。若使用 ImageNet 预训练权重，需注意输入通道数的处理逻辑。支持 ONNX 导出及 TorchScript。","3.9+",[101,102,103],"torch>=1.9","timm","segmentation-models-pytorch",[26,13,14],[106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125],"segmentation","image-processing","pspnet","unet","unet-pytorch","pytorch","fpn","models","imagenet","semantic-segmentation","image-segmentation","segmentation-models","unetplusplus","deeplabv3","deeplab-v3-plus","pretrained-weights","computer-vision","segformer","transformers","dpt","2026-03-27T02:49:30.150509","2026-04-06T05:36:45.423501",[129,134,139,144],{"id":130,"question_zh":131,"answer_zh":132,"source_url":133},13641,"遇到 ImportError: cannot import name 'container_abcs' from 'torch._six' 错误如何解决？","这是由于 PyTorch 版本更新导致 `torch._six` 中移除了 `container_abcs`。解决方案有两种：\n1. **升级库**：将 `segmentation-models-pytorch` 升级到 0.2.0 或更高版本，该版本已兼容新的 `timm==0.4.12` 和 `torch==1.9.0`。\n2. **手动修改代码**：如果无法升级，找到报错文件（如 `timm\u002Fmodels\u002Flayers\u002Fhelpers.py`），将 `from torch._six import container_abcs` 修改为 `from collections.abc import Iterable, ...`（具体导入内容视代码需求而定）。","https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fissues\u002F424",{"id":135,"question_zh":136,"answer_zh":137,"source_url":138},13642,"加载模型权重时出现 \"RuntimeError: Error(s) in loading state_dict\" 且提示缺少 decoder 层的键值怎么办？","这通常是因为训练时的模型结构与加载时的结构不一致，或者使用了不兼容的保存方式。推荐的解决方案是使用 TorchScript 追踪并保存模型，以确保结构一致性：\n\n```python\n# 保存模型\nmodel.eval()\nfor m in model.modules():\n    m.requires_grad = False\n\nsample = torch.ones([1, 3, 64, 64]).to(device)\ntraced_module = torch.jit.trace(model, sample)\ntorch.jit.save(traced_module, \"path\u002Fto\u002Fmodel.ptt\")\n\n# 加载模型\nmodel = torch.jit.load(\"path\u002Fto\u002Fmodel.ptt\")\n```\n注意：使用 `torch.jit.load` 加载后，如果需要移动到 GPU，需手动调用 `.to(device)`。","https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fissues\u002F105",{"id":140,"question_zh":141,"answer_zh":142,"source_url":143},13643,"如何处理多类别分割任务中的指标计算？目标是单通道掩码（像素值为类别索引），输出是多通道概率图。","库中的指标函数（如 `get_stats`）通常期望输入格式为 `(batch, num_class, height, width)` 的多标签格式。如果你的目标是单通道整数掩码（形状为 `(batch, 1, h, w)`，值为 0 到 n_classes-1），你需要先将其转换为 One-Hot 编码格式以匹配输出形状。目前社区用户反映直接使用会导致指标全为 1 或报错，建议参考相关讨论将单通道 Mask 转换为多通道 Binary Mask 后再传入 `smp.metrics` 进行计算。","https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fissues\u002F541",{"id":145,"question_zh":146,"answer_zh":147,"source_url":148},13644,"在类别极度不平衡的数据集上训练时，如何使用类别权重（Class Weights）来优化损失函数？","虽然库本身可能未直接提供所有损失函数的权重参数，但可以通过自定义损失函数实现。针对多类别分割（目标为单通道灰度图，包含多个类别），需要注意 `y_true` 的维度处理。一种有效的加权 Dice Loss 实现思路是根据每个类别的像素占比动态计算权重：\n\n```python\ndef soft_dice_score(output, target, smooth=0.0, eps=1e-7, dims=None):\n    assert output.size() == target.size()\n    # 计算每个类别的权重：1 \u002F (该类像素占比^2 + epsilon)，让稀少类别权重更大\n    total_pixels = target.size(0) * target.size(2) * target.size(3) # 假设 NCHW\n    # 注意：此处需确保 target 已转为 One-Hot 或多通道格式以便按通道统计，或者针对单通道做特殊映射\n    # 以下逻辑基于多通道 target 示例：\n    weights = torch.sum(target, dim=(0, 2, 3)) \u002F total_pixels \n    weights = 1.0 \u002F (weights**2 + 1e-8)\n    \n    if dims is not None:\n        intersection = torch.sum(output * target, dim=dims)\n        cardinality = torch.sum(output + target, dim=dims)\n    else:\n        intersection = torch.sum(output * target)\n        cardinality = torch.sum(output + target)\n        \n    intersection *= weights\n    cardinality *= weights\n    return (2.0 * torch.sum(intersection) + smooth) \u002F (torch.sum(cardinality) + smooth)\n```\n核心思想是：类别出现概率越低，赋予的权重越高（例如概率 0.5 则权重 2，而非 0.5）。","https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fissues\u002F554",[150,155,160,165,170,175,180,185,190,195,200,205,210,215,220],{"id":151,"version":152,"summary_zh":153,"released_at":154},72476,"v0.5.0","## 新模型\n\n### DPT\n\n![DPT](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fhuggingface\u002Fdocumentation-images\u002Fresolve\u002Fmain\u002Fdpt_architecture.jpg)\n\nDPT 模型将 Vision Transformer (ViT) 架构适配用于语义分割等密集预测任务。它以 ViT 作为强大的骨干网络，在每个阶段都利用全局感受野处理图像信息。其关键创新在于解码器，该解码器会将来自不同 Transformer 阶段的标记表示重新组合成不同分辨率的类图像特征图，并通过卷积式的 PSP 和 FPN 块逐步融合，最终生成全分辨率、高细节的预测结果。\n\n`smp` 中的 DPT 模型可以与多种基于 Transformer 的编码器配合使用。\n\n```python\nimport segmentation_models_pytorch as smp\n\n# 使用您自己的预训练编码器初始化\nmodel = smp.DPT(\"tu-mobilevitv2_175.cvnets_in1k\", classes=2)\n\n# 加载在 ADE20K 数据集上完全预训练的模型\nmodel = smp.from_pretrained(\"smp-hub\u002Fdpt-large-ade20k\")\n\n# 加载同一检查点进行微调\nmodel = smp.from_pretrained(\"smp-hub\u002Fdpt-large-ade20k\", classes=1, strict=False)\n```\n\nDPT 支持的 `timm` 编码器完整列表可参见 [此处](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fencoders_dpt.html#dpt-encoders)。\n\n* DPT 由 @vedantdalimkar 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F1079 中添加。\n\n## 模型导出\n\n为使所有编码器和模型支持 `torch.jit.script`、`torch.compile`（无图断点：`fullgraph=True`）以及 `torch.export` 功能，我们进行了大量工作。\n\n这带来了多项优势：\n- **`torch.jit.script`**：能够将模型序列化为静态图格式，从而在没有 Python 解释器的环境中部署，并支持基于图的优化。\n- **`torch.compile`（`fullgraph=True`）**：利用即时编译技术（例如通过 Triton 或 Inductor 后端）生成优化后的内核，减少 Python 开销，并借助算子融合等技术显著提升性能，尤其是在 GPU 硬件上。`fullgraph=True` 可最大限度地减少图断点，从而最大化这些优化的效果。\n- **`torch.export`**：生成标准化的提前编译（AOT）图表示，简化了将模型导出到各类推理后端和边缘设备（例如通过 ExecuTorch）的过程，同时尽可能保留模型的动态性。\n\n相关 PR：\n\n* @qubvel 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F1031 中修复了 torch compile、script 和 export 的问题。\n* @qubvel 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F1037 中修复了 Efficientnet 编码器的 torchscript 兼容性问题。\n\n## 核心\n\n现在，来自第三方库（如 `efficientnet-pytorch` 和 `pretrainedmodels.pytorch`）的所有编码器均已由 SMP 内部托管。这意味着我们已复制并重构了底层代码，并将所有检查点迁移到了 [smp-hub](https:\u002F\u002Fhuggingface.co\u002Fsmp-hub)。作为一项","2025-04-17T10:13:29",{"id":156,"version":157,"summary_zh":158,"released_at":159},72477,"v0.4.0","## 新模型\n\n### SegFormer\n\n由 @brianhou0208 贡献\n\n![](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fhuggingface\u002Fdocumentation-images\u002Fresolve\u002Fmain\u002Fsegformer_architecture.png)\n\nSegFormer 最初是一种基于 Transformer 的语义分割模型，以其简洁高效而闻名。它使用轻量级的层次化编码器来捕捉多尺度特征，并采用极简的解码器以实现快速推理。\n\n借助 `segmentation_models_pytorch`，您可以将该模型与原生的 Mix Vision Transformer 编码器一起使用，同时还能支持该库中超过 800 种其他编码器。原始权重同样受支持，可以通过以下方式加载：\n\n```python\nimport segmentation_models_pytorch as smp\n\nmodel = smp.from_pretrained(\"smp-hub\u002Fsegformer-b5-640x640-ade-160k\")\n```\n\n或者使用任何其他编码器：\n\n```python\nimport segmentation_models_pytorch as smp\n\nmodel = smp.Segformer(\"resnet34\")\n```\n\n更多检查点请参阅 [HF Hub](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002Fsmp-hub\u002Fsegformer-6749eb4923dea2c355f29a1f)。\n\n### UperNet\n\n由 @brianhou0208 贡献\n\n![](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fhuggingface\u002Fdocumentation-images\u002Fresolve\u002Fmain\u002Ftransformers\u002Fmodel_doc\u002Fupernet_architecture.jpg)\n\nUPerNet（统一感知解析网络）是一种多功能的语义分割模型，旨在处理各种场景解析任务。它结合了特征金字塔网络（FPN）和金字塔池化模块（PPM），能够有效捕捉多尺度上下文信息。\n\n```python\nimport segmentation_models_pytorch as smp\n\nmodel = smp.UPerNet(\"resnet34\")\n```\n\n## 新增编码器\n\n感谢 @brianhou0208 的贡献，`segmentation_models.pytorch` 现在支持超过 800 种 `timm` 编码器。诸如 `convnext`、`efficientvit`、`efficientformerv2`、`hiera`、`mambaout` 等现代编码器，使用起来同样简单：\n\n```python\nimport segmentation_models_pytorch as smp\n\nmodel = smp.create_model(\"upernet\", encoder_name=\"tu-mambaout_small\")\n# 或者\nmodel = smp.UPerNet(\"tu-mambaout_small\")\n```\n\n## 新示例\n- 添加了由 @TimbusCalin 提供的多类别分割示例：[camvid_segmentation_multiclass.ipynb](https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fcamvid_segmentation_multiclass.ipynb)\n- 添加了由 @qubvel 提供的 ONNX 导出示例：[convert_to_onnx.ipynb](https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fconvert_to_onnx.ipynb)\n\n## 其他变更\n- 项目已迁移到 `pyproject.toml`，由 @adamjstewart 完成\n- 更好的依赖管理和测试（使用最小化和最新版本的依赖，支持 Linux、Windows 和 Mac 平台），由 @adamjstewart 实施\n- 改进了类型注解\n- 测试代码经过重构，以加快 CI 构建和本地测试速度，由 @qubvel 完成\n\n## 所有变更\n- 更新教程文件，由 @ytzfhqs 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F907 中完成\n- 关于如何保存和加载模型以及 Albumentations 预处理的示例，由 @qubvel 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F914 中添加\n- 为所有示例笔记本添加“在 Colab 中打开”徽章，由 @qubve 完成","2025-01-08T15:28:59",{"id":161,"version":162,"summary_zh":163,"released_at":164},72478,"v0.3.4","## 更新\n - 🤗 集成 Hugging Face：您现在可以使用 HF [Hub](https:\u002F\u002Fhuggingface.co\u002Fmodels) 保存、加载和共享模型，详情请参阅[示例笔记本](https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmain\u002Fexamples\u002Fsave_load_model_and_share_with_hf_hub.ipynb)。\n\n### 完整日志\n* 为支持 albumentations ≥ 1.4.0，@CallShaul 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F870 中对部分函数进行了重命名。\n* @vermavinay982 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F855 中更新了 functional.py 中的假阳性率和假阴性率函数。\n* @qubvel 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F876 中添加了 HF Hub 混入类。\n* @Borda 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F829 中引入了 precommit 进行代码检查。\n* @qubvel 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F877 中添加了 Ruff 工具用于代码格式化和静态检查。\n* @qubvel 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F878 中添加了文档配置。\n* @qubvel 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F879 中更新了文档。\n* @qubvel 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F883 中将 `create_model` 添加到文档中。\n* @Smartappli 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F892 中将 Ruff 更新至 0.5.2 版本，并更新了工作流。\n* @ytzfhqs 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F909 中修复了 hub_mixin.py 中的 pop 错误。\n* @qubvel 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F910 中更新了 HF 混入类。\n\n## 新贡献者\n* @CallShaul 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F870 中完成了首次贡献。\n* @vermavinay982 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F855 中完成了首次贡献。\n* @Borda 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F829 中完成了首次贡献。\n* @Smartappli 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F892 中完成了首次贡献。\n* @ytzfhqs 在 https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fpull\u002F909 中完成了首次贡献。\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fqubvel-org\u002Fsegmentation_models.pytorch\u002Fcompare\u002Fv0.3.3...v0.3.4","2024-08-23T13:15:35",{"id":166,"version":167,"summary_zh":168,"released_at":169},72479,"v0.3.3","## 更新\n - PyTorch 图像模型库 (timm) 版本升级至 0.9.2","2023-05-28T15:49:13",{"id":171,"version":172,"summary_zh":173,"released_at":174},72480,"v0.3.2","## 更新\n - 新增 Apple 的 Mobile One 编码器，来自 [repo](https:\u002F\u002Fgithub.com\u002Fapple\u002Fml-mobileone)（使用 `encoder_name=\"mobileone_s{0..4}\"`）。\n - PyTorch 图像模型库 (timm) 升级至 0.6.12 版本（提供 500 多种编码器）。\n - 修复了少量拼写错误并更新了文档。\n\n## 破坏性变更\n - 最低 Python 版本由 3.6 提升至 3.7。\n\n感谢 @VadimLevin、@kevinpl07 和 @Abd-elr4hman。","2023-01-07T10:37:03",{"id":176,"version":177,"summary_zh":178,"released_at":179},72481,"v0.3.1","## 更新\n - 新增了来自 SegFormer 的 Mix Vision Transformer 编码器 [[官方代码](https:\u002F\u002Fgithub.com\u002FNVlabs\u002FSegFormer)] [[论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2105.15203)]。使用参数 `encoder_name=\"mit_b0\"`（或 mit_b1..b5）即可创建模型。\n - 修复了少量错别字并更新了文档。","2022-11-30T12:31:18",{"id":181,"version":182,"summary_zh":183,"released_at":184},72482,"v0.3.0","## 更新\n - 新增了 `smp.metrics` 模块，包含基于混淆矩阵的各种指标，详情请参阅[文档](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fmetrics.html)\n - 新增了一个[笔记本](https:\u002F\u002Fgithub.com\u002Fqubvel\u002Fsegmentation_models.pytorch\u002Fblob\u002Fmaster\u002Fexamples\u002Fbinary_segmentation_intro.ipynb)，其中包含使用 PyTorch Lightning 的训练示例 ![在 Colab 中打开](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)\n - 改进了对输入图像尺寸错误的处理（检查图像尺寸是否为 2 的幂次）\n - 重构了代码库并进行了代码风格检查（使用 black 和 flake8）\n - 修复了一些小的拼写错误和 bug\n\n## 破坏性变更\n - `utils` 模块将被弃用，如果您仍然需要它，请手动导入：`from segmentation_models_pytorch import utils`\n\n非常感谢所有贡献者！","2022-07-29T10:32:40",{"id":186,"version":187,"summary_zh":188,"released_at":189},72483,"v0.2.1","## 更新\n - 通用的 timm 编码器。来自 [timm](https:\u002F\u002Fgithub.com\u002Frwightman\u002Fpytorch-image-models) 的 400 多个预训练编码器可通过 `tu-` 前缀使用。可用编码器列表 [在此](https:\u002F\u002Fsmp.readthedocs.io\u002Fen\u002Flatest\u002Fencoders_timm.html)。\n - 小幅修复和改进。","2021-11-18T10:48:15",{"id":191,"version":192,"summary_zh":193,"released_at":194},72484,"v0.2.0","## 更新\n - 新架构：MANet (#310)\n - `timm` 中新增编码器：mobilenetv3 (#355) 和 gernet (#344)\n - `smp.losses` 模块中新增损失函数（`smp.utils.losses` 将在后续版本中弃用）\n - 当 `in_channels > 3` 时，为第一层卷积新增预训练权重初始化\n - 更新了 `timm` 版本（0.4.12）\n - 修复了若干 bug，并改进了文档\n\n感谢 @azkalot1、@JulienMaille、@originlake、@Kupchanski、@loopdigga96、@zurk、@nmerty、@ludics、@Vozf、@markson14 等多位贡献者！","2021-07-05T09:05:24",{"id":196,"version":197,"summary_zh":198,"released_at":199},72485,"v0.1.3","## 更新\n - 新架构 Unet++ (#279)\n - 新编码器：RegNet、ResNest、SK-Net、Res2Net (#286)\n - 更新了 timm 版本（0.3.2）\n - 改进了模型的文档字符串和类型提示\n - 项目文档已迁至 https:\u002F\u002Fsmp.readthedocs.io\n\n感谢 @azkalot1 提供的新编码器和新架构！","2020-12-13T10:22:37",{"id":201,"version":202,"summary_zh":203,"released_at":204},72486,"v0.1.2","### Fixes\r\n - Fix `pytorch-efficientnet` package version in requirements.txt to strict 0.6.3 (#260)","2020-09-28T21:15:52",{"id":206,"version":207,"summary_zh":208,"released_at":209},72487,"v0.1.1","## Updates\r\n - New decoders DeepLabV3, DeepLabV3+, PAN\r\n - New backbones (encoders) `timm-efficientnet*`\r\n - New pretrained weights (ssl, wsl) for resnets\r\n - New pretrained weights (advprop) for efficientnets\r\n\r\nAnd some small fixes.\r\n\r\nThanks @IlyaDobrynin @gavrin-s @lizmisha @suitre77 @thisisiron @phamquiluan and all other contributers!\r\n\r\n\r\n","2020-09-26T13:09:02",{"id":211,"version":212,"summary_zh":213,"released_at":214},72488,"V0.1.0","### Updates\r\n\r\n1) New backbones (mobilenet, efficientnet, inception)\r\n2) `depth` and `in_channels` options for all models\r\n3) Auxiliary classification output \r\n\r\n### Note!\r\nModel architectures have been changed, use previous versions for weights compatibility!","2019-12-09T13:59:56",{"id":216,"version":217,"summary_zh":218,"released_at":219},72489,"v0.0.3","## Updates\r\n - Conv2D Initialization \r\n    - kaiming_normal -> kaiming_uniform; \r\n    - fan_out -> fan_in; \r\n    - bias -> 0\r\n - package dependencies","2019-09-28T18:43:57",{"id":221,"version":222,"summary_zh":223,"released_at":224},72490,"v0.0.2","## Updates\r\n\r\n- New backbones:\r\n  - resnext50_32x4d\r\n  - resnext101_32x8d\r\n  - resnext101_32x16d\r\n  - resnext101_32x32d\r\n  - resnext101_32x48d\r\n - Unet `scSE` attention block (optional)\r\n - torchvision version update\r\n - `get_preprocessing_params` function\r\n\r\nThanks @laol777 for contribution!\r\n\r\n","2019-09-19T11:27:45"]