🚀 segformer-b2-fashion
segformer-b2-fashion 模型是基於 nvidia/mit-b2 在 sayeed99/human_parsing_fashion_dataset 數據集上進行微調得到的圖像分割模型,可用於對人物圖像進行精細的語義分割。
🚀 快速開始
本模型是 nvidia/mit-b2 在 sayeed99/human_parsing_fashion_dataset 數據集上的微調版本。以下是使用該模型進行圖像語義分割的示例代碼:
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-b2-human")
model = AutoModelForSemanticSegmentation.from_pretrained("sayeed99/segformer-b2-human")
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
processor = SegformerImageProcessor.from_pretrained("sayeed99/segformer-b2-human")
model = AutoModelForSemanticSegmentation.from_pretrained("sayeed99/segformer-b2-human")
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 |
上衣、T恤、運動衫 |
3 |
毛衣 |
4 |
開襟羊毛衫 |
5 |
夾克 |
6 |
背心 |
7 |
褲子 |
8 |
短褲 |
9 |
裙子 |
10 |
外套 |
11 |
連衣裙 |
12 |
連身褲 |
13 |
披肩 |
14 |
眼鏡 |
15 |
帽子 |
16 |
頭帶、頭巾、髮飾 |
17 |
領帶 |
18 |
手套 |
19 |
手錶 |
20 |
腰帶 |
21 |
腿套 |
22 |
緊身褲、長襪 |
23 |
襪子 |
24 |
鞋子 |
25 |
包、錢包 |
26 |
圍巾 |
27 |
雨傘 |
28 |
兜帽 |
29 |
衣領 |
30 |
翻領 |
31 |
肩章 |
32 |
袖子 |
33 |
口袋 |
34 |
領口 |
35 |
搭扣 |
36 |
拉鍊 |
37 |
貼花 |
38 |
珠子 |
39 |
蝴蝶結 |
40 |
花朵 |
41 |
流蘇 |
42 |
絲帶 |
43 |
鉚釘 |
44 |
褶邊 |
45 |
亮片 |
46 |
纓穗 |
47 |
頭髮 |
48 |
太陽鏡 |
49 |
上裝 |
50 |
左腳鞋 |
51 |
右腳鞋 |
52 |
臉部 |
53 |
左腿 |
54 |
右腿 |
55 |
左臂 |
56 |
右臂 |
📚 詳細文檔
框架版本
屬性 |
詳情 |
模型類型 |
圖像分割 |
訓練數據 |
sayeed99/human_parsing_fashion_dataset |
Transformers 版本 |
4.30.0 |
Pytorch 版本 |
2.2.2+cu121 |
Datasets 版本 |
2.18.0 |
Tokenizers 版本 |
0.13.3 |
📄 許可證
該模型的許可證信息可在 此處 查看。
📖 引用信息
@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}
}