logo
0
0
WeChat Login

Segformer B2 fine-tuned for clothes segmentation

SegFormer model fine-tuned on ATR dataset for clothes segmentation but can also be used for human segmentation. The dataset on hugging face is called "mattmdjaga/human_parsing_dataset".

Training code.

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("mattmdjaga/segformer_b2_clothes") model = AutoModelForSemanticSegmentation.from_pretrained("mattmdjaga/segformer_b2_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)

Labels: 0: "Background", 1: "Hat", 2: "Hair", 3: "Sunglasses", 4: "Upper-clothes", 5: "Skirt", 6: "Pants", 7: "Dress", 8: "Belt", 9: "Left-shoe", 10: "Right-shoe", 11: "Face", 12: "Left-leg", 13: "Right-leg", 14: "Left-arm", 15: "Right-arm", 16: "Bag", 17: "Scarf"

Evaluation

Label IndexLabel NameCategory AccuracyCategory IoU
0Background0.990.99
1Hat0.730.68
2Hair0.910.82
3Sunglasses0.730.63
4Upper-clothes0.870.78
5Skirt0.760.65
6Pants0.900.84
7Dress0.740.55
8Belt0.350.30
9Left-shoe0.740.58
10Right-shoe0.750.60
11Face0.920.85
12Left-leg0.900.82
13Right-leg0.900.81
14Left-arm0.860.74
15Right-arm0.820.73
16Bag0.910.84
17Scarf0.630.29

Overall Evaluation Metrics:

  • Evaluation Loss: 0.15
  • Mean Accuracy: 0.80
  • Mean IoU: 0.69

License

The license for this model can be found here.

BibTeX entry and citation info

@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} }

About

ComfyUI/models/segformer_b2_clothes

Language
Python100%