ChuuniZ commited on
Commit
fc4f617
·
verified ·
1 Parent(s): 7da6459

Upload segformer_b2_clothes/README.md

Browse files
Files changed (1) hide show
  1. segformer_b2_clothes/README.md +105 -0
segformer_b2_clothes/README.md ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - vision
5
+ - image-segmentation
6
+ widget:
7
+ - src: https://images.unsplash.com/photo-1643310325061-2beef64926a5?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Nnx8cmFjb29uc3xlbnwwfHwwfHw%3D&w=1000&q=80
8
+ example_title: Person
9
+ - src: https://freerangestock.com/sample/139043/young-man-standing-and-leaning-on-car.jpg
10
+ example_title: Person
11
+ datasets:
12
+ - mattmdjaga/human_parsing_dataset
13
+ ---
14
+ # Segformer B2 fine-tuned for clothes segmentation
15
+
16
+ SegFormer model fine-tuned on [ATR dataset](https://github.com/lemondan/HumanParsing-Dataset) for clothes segmentation but can also be used for human segmentation.
17
+ The dataset on hugging face is called "mattmdjaga/human_parsing_dataset".
18
+
19
+ **[Training code](https://github.com/mattmdjaga/segformer_b2_clothes)**.
20
+ ```python
21
+ from transformers import SegformerImageProcessor, AutoModelForSemanticSegmentation
22
+ from PIL import Image
23
+ import requests
24
+ import matplotlib.pyplot as plt
25
+ import torch.nn as nn
26
+
27
+ processor = SegformerImageProcessor.from_pretrained("mattmdjaga/segformer_b2_clothes")
28
+ model = AutoModelForSemanticSegmentation.from_pretrained("mattmdjaga/segformer_b2_clothes")
29
+
30
+ url = "https://plus.unsplash.com/premium_photo-1673210886161-bfcc40f54d1f?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8cGVyc29uJTIwc3RhbmRpbmd8ZW58MHx8MHx8&w=1000&q=80"
31
+
32
+ image = Image.open(requests.get(url, stream=True).raw)
33
+ inputs = processor(images=image, return_tensors="pt")
34
+
35
+ outputs = model(**inputs)
36
+ logits = outputs.logits.cpu()
37
+
38
+ upsampled_logits = nn.functional.interpolate(
39
+ logits,
40
+ size=image.size[::-1],
41
+ mode="bilinear",
42
+ align_corners=False,
43
+ )
44
+
45
+ pred_seg = upsampled_logits.argmax(dim=1)[0]
46
+ plt.imshow(pred_seg)
47
+ ```
48
+
49
+ 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"
50
+
51
+ ### Evaluation
52
+
53
+ | Label Index | Label Name | Category Accuracy | Category IoU |
54
+ |:-------------:|:----------------:|:-----------------:|:------------:|
55
+ | 0 | Background | 0.99 | 0.99 |
56
+ | 1 | Hat | 0.73 | 0.68 |
57
+ | 2 | Hair | 0.91 | 0.82 |
58
+ | 3 | Sunglasses | 0.73 | 0.63 |
59
+ | 4 | Upper-clothes | 0.87 | 0.78 |
60
+ | 5 | Skirt | 0.76 | 0.65 |
61
+ | 6 | Pants | 0.90 | 0.84 |
62
+ | 7 | Dress | 0.74 | 0.55 |
63
+ | 8 | Belt | 0.35 | 0.30 |
64
+ | 9 | Left-shoe | 0.74 | 0.58 |
65
+ | 10 | Right-shoe | 0.75 | 0.60 |
66
+ | 11 | Face | 0.92 | 0.85 |
67
+ | 12 | Left-leg | 0.90 | 0.82 |
68
+ | 13 | Right-leg | 0.90 | 0.81 |
69
+ | 14 | Left-arm | 0.86 | 0.74 |
70
+ | 15 | Right-arm | 0.82 | 0.73 |
71
+ | 16 | Bag | 0.91 | 0.84 |
72
+ | 17 | Scarf | 0.63 | 0.29 |
73
+
74
+ Overall Evaluation Metrics:
75
+ - Evaluation Loss: 0.15
76
+ - Mean Accuracy: 0.80
77
+ - Mean IoU: 0.69
78
+
79
+ ### License
80
+
81
+ The license for this model can be found [here](https://github.com/NVlabs/SegFormer/blob/master/LICENSE).
82
+
83
+ ### BibTeX entry and citation info
84
+
85
+ ```bibtex
86
+ @article{DBLP:journals/corr/abs-2105-15203,
87
+ author = {Enze Xie and
88
+ Wenhai Wang and
89
+ Zhiding Yu and
90
+ Anima Anandkumar and
91
+ Jose M. Alvarez and
92
+ Ping Luo},
93
+ title = {SegFormer: Simple and Efficient Design for Semantic Segmentation with
94
+ Transformers},
95
+ journal = {CoRR},
96
+ volume = {abs/2105.15203},
97
+ year = {2021},
98
+ url = {https://arxiv.org/abs/2105.15203},
99
+ eprinttype = {arXiv},
100
+ eprint = {2105.15203},
101
+ timestamp = {Wed, 02 Jun 2021 11:46:42 +0200},
102
+ biburl = {https://dblp.org/rec/journals/corr/abs-2105-15203.bib},
103
+ bibsource = {dblp computer science bibliography, https://dblp.org}
104
+ }
105
+ ```