Segformer B3 Clothes
模型简介
这是一个基于SegFormer架构的语义分割模型,专门针对服装和人体部位分割任务进行了微调。能够识别和分割图像中的18个不同类别,包括各种服装、配饰和人体部位。
模型特点
多类别服装分割
能够识别和分割18种不同的服装和人体部位类别
基于Transformer架构
采用SegFormer架构,结合了Transformer的优势和高效设计
开源训练代码
提供完整的训练代码,方便用户进行自定义训练
模型能力
服装分割
人体部位识别
图像语义分割
使用案例
时尚与零售
虚拟试衣
通过精确分割服装区域,支持虚拟试衣应用
时尚分析
分析图像中的服装搭配和流行趋势
人机交互
增强现实应用
为AR应用提供精确的人体部位分割
🚀 Segformer B3 用于服装分割的微调模型
本项目是基于 SegFormer 模型在 ATR 数据集 上进行微调,用于服装分割,同时也可用于人体分割。该数据集在 Hugging Face 上名为 "mattmdjaga/human_parsing_dataset"。
🚀 快速开始
安装依赖
确保你已经安装了 transformers
、torch
、requests
和 matplotlib
库。如果没有安装,可以使用以下命令进行安装:
pip install transformers torch requests matplotlib
运行示例代码
from transformers import SegformerImageProcessor, AutoModelForSemanticSegmentation
from PIL import Image
import requests
import matplotlib.pyplot as plt
import torch.nn as nn
processor = SegformerImageProcessor.from_pretrained("sayeed99/segformer_b3_clothes")
model = AutoModelForSemanticSegmentation.from_pretrained("sayeed99/segformer_b3_clothes")
url = "https://plus.unsplash.com/premium_photo-1673210886161-bfcc40f54d1f?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8cGVyc29uJTIwc3RhbmRpbmd8ZW58MHx8MHx8&w=1000&q=80"
image = Image.open(requests.get(url, stream=True).raw)
inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits.cpu()
upsampled_logits = nn.functional.interpolate(
logits,
size=image.size[::-1],
mode="bilinear",
align_corners=False,
)
pred_seg = upsampled_logits.argmax(dim=1)[0]
plt.imshow(pred_seg)
标签说明
标签索引 | 标签名称 |
---|---|
0 | 背景 |
1 | 帽子 |
2 | 头发 |
3 | 太阳镜 |
4 | 上衣 |
5 | 裙子 |
6 | 裤子 |
7 | 连衣裙 |
8 | 腰带 |
9 | 左脚鞋 |
10 | 右脚鞋 |
11 | 脸部 |
12 | 左腿 |
13 | 右腿 |
14 | 左臂 |
15 | 右臂 |
16 | 包 |
17 | 围巾 |
✨ 主要特性
- 多用途分割:不仅可以进行服装分割,还能用于人体分割。
- 微调模型:基于 SegFormer 模型在特定数据集上进行微调,提高分割效果。
- 可视化结果:通过示例代码可以方便地进行推理并可视化分割结果。
💻 使用示例
基础用法
from transformers import SegformerImageProcessor, AutoModelForSemanticSegmentation
from PIL import Image
import requests
import matplotlib.pyplot as plt
import torch.nn as nn
processor = SegformerImageProcessor.from_pretrained("sayeed99/segformer_b3_clothes")
model = AutoModelForSemanticSegmentation.from_pretrained("sayeed99/segformer_b3_clothes")
url = "https://plus.unsplash.com/premium_photo-1673210886161-bfcc40f54d1f?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8cGVyc29uJTIwc3RhbmRpbmd8ZW58MHx8MHx8&w=1000&q=80"
image = Image.open(requests.get(url, stream=True).raw)
inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits.cpu()
upsampled_logits = nn.functional.interpolate(
logits,
size=image.size[::-1],
mode="bilinear",
align_corners=False,
)
pred_seg = upsampled_logits.argmax(dim=1)[0]
plt.imshow(pred_seg)
高级用法
你可以将上述代码封装成函数,方便在不同场景下调用:
from transformers import SegformerImageProcessor, AutoModelForSemanticSegmentation
from PIL import Image
import requests
import matplotlib.pyplot as plt
import torch.nn as nn
def perform_segmentation(image_url, model_name="sayeed99/segformer_b3_clothes"):
processor = SegformerImageProcessor.from_pretrained(model_name)
model = AutoModelForSemanticSegmentation.from_pretrained(model_name)
image = Image.open(requests.get(image_url, stream=True).raw)
inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits.cpu()
upsampled_logits = nn.functional.interpolate(
logits,
size=image.size[::-1],
mode="bilinear",
align_corners=False,
)
pred_seg = upsampled_logits.argmax(dim=1)[0]
plt.imshow(pred_seg)
plt.show()
# 使用示例
image_url = "https://plus.unsplash.com/premium_photo-1673210886161-bfcc40f54d1f?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8cGVyc29uJTIwc3RhbmRpbmd8ZW58MHx8MHx8&w=1000&q=80"
perform_segmentation(image_url)
📚 详细文档
评估指标
标签索引 | 标签名称 | 类别准确率 | 类别 IoU |
---|---|---|---|
0 | 背景 | 0.99 | 0.99 |
1 | 帽子 | 0.73 | 0.68 |
2 | 头发 | 0.91 | 0.82 |
3 | 太阳镜 | 0.73 | 0.63 |
4 | 上衣 | 0.87 | 0.78 |
5 | 裙子 | 0.76 | 0.65 |
6 | 裤子 | 0.90 | 0.84 |
7 | 连衣裙 | 0.74 | 0.55 |
8 | 腰带 | 0.35 | 0.30 |
9 | 左脚鞋 | 0.74 | 0.58 |
10 | 右脚鞋 | 0.75 | 0.60 |
11 | 脸部 | 0.92 | 0.85 |
12 | 左腿 | 0.90 | 0.82 |
13 | 右腿 | 0.90 | 0.81 |
14 | 左臂 | 0.86 | 0.74 |
15 | 右臂 | 0.82 | 0.73 |
16 | 包 | 0.91 | 0.84 |
17 | 围巾 | 0.63 | 0.29 |
整体评估指标:
- 评估损失:0.15
- 平均准确率:0.80
- 平均 IoU:0.69
训练代码
最新的 训练代码 已发布。目前仅包含带有部分注释的纯代码,后续会添加 Colab 笔记本版本和博客文章,以提高其易用性。
📄 许可证
本模型的许可证信息可在 此处 查看。
📚 引用信息
如果你使用了本模型,请引用以下 BibTeX 条目:
@article{DBLP:journals/corr/abs-2105-15203,
author = {Enze Xie and
Wenhai Wang and
Zhiding Yu and
Anima Anandkumar and
Jose M. Alvarez and
Ping Luo},
title = {SegFormer: Simple and Efficient Design for Semantic Segmentation with
Transformers},
journal = {CoRR},
volume = {abs/2105.15203},
year = {2021},
url = {https://arxiv.org/abs/2105.15203},
eprinttype = {arXiv},
eprint = {2105.15203},
timestamp = {Wed, 02 Jun 2021 11:46:42 +0200},
biburl = {https://dblp.org/rec/journals/corr/abs-2105-15203.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
Clipseg Rd64 Refined
Apache-2.0
CLIPSeg是一种基于文本与图像提示的图像分割模型,支持零样本和单样本图像分割任务。
图像分割
Transformers

C
CIDAS
10.0M
122
RMBG 1.4
其他
BRIA RMBG v1.4 是一款先进的背景移除模型,专为高效分离各类图像的前景与背景而设计,适用于非商业用途。
图像分割
Transformers

R
briaai
874.12k
1,771
RMBG 2.0
其他
BRIA AI开发的最新背景移除模型,能有效分离各类图像的前景与背景,适合大规模商业内容创作场景。
图像分割
Transformers

R
briaai
703.33k
741
Segformer B2 Clothes
MIT
基于ATR数据集微调的SegFormer模型,用于服装和人体分割
图像分割
Transformers

S
mattmdjaga
666.39k
410
Sam Vit Base
Apache-2.0
SAM是一个能够通过输入提示(如点或框)生成高质量对象掩码的视觉模型,支持零样本分割任务
图像分割
Transformers 其他

S
facebook
635.09k
137
Birefnet
MIT
BiRefNet是一个用于高分辨率二分图像分割的深度学习模型,通过双边参考网络实现精确的图像分割。
图像分割
Transformers

B
ZhengPeng7
626.54k
365
Segformer B1 Finetuned Ade 512 512
其他
SegFormer是一种基于Transformer的语义分割模型,在ADE20K数据集上进行了微调,适用于图像分割任务。
图像分割
Transformers

S
nvidia
560.79k
6
Sam Vit Large
Apache-2.0
SAM是一个能够通过输入提示点或边界框生成高质量物体掩膜的视觉模型,具备零样本迁移能力。
图像分割
Transformers 其他

S
facebook
455.43k
28
Face Parsing
基于nvidia/mit-b5微调的语义分割模型,用于面部解析任务
图像分割
Transformers 英语

F
jonathandinu
398.59k
157
Sam Vit Huge
Apache-2.0
SAM是一个能够根据输入提示生成高质量对象掩码的视觉模型,支持零样本迁移到新任务
图像分割
Transformers 其他

S
facebook
324.78k
163
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers 支持多种语言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers 英语

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统 中文
R
uer
2,694
98