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