mattmdjaga commited on
Commit
082db7d
1 Parent(s): fdb3ea5

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +46 -0
README.md ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: wtfpl
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 B0 fine-tuned for clothes segmentation
15
+
16
+ SegFormer model fine-tuned on [ATR dataset](https://github.com/lemondan/HumanParsing-Dataset) for clothes segmentation.
17
+ The dataset on hugging face is called "mattmdjaga/human_parsing_dataset".
18
+
19
+ ```python
20
+ from transformers import AutoFeatureExtractor, SegformerForSemanticSegmentation
21
+ from PIL import Image
22
+ import requests
23
+ import matplotlib.pyplot as plt
24
+ import torch.nn as nn
25
+
26
+ extractor = AutoFeatureExtractor.from_pretrained("mattmdjaga/segformer_b0_clothes")
27
+ model = SegformerForSemanticSegmentation.from_pretrained("mattmdjaga/segformer_b0_clothes")
28
+
29
+ url = "https://plus.unsplash.com/premium_photo-1673210886161-bfcc40f54d1f?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8cGVyc29uJTIwc3RhbmRpbmd8ZW58MHx8MHx8&w=1000&q=80"
30
+
31
+ image = Image.open(requests.get(url, stream=True).raw)
32
+ inputs = extractor(images=image, return_tensors="pt")
33
+
34
+ outputs = model(**inputs)
35
+ logits = outputs.logits.cpu()
36
+
37
+ upsampled_logits = nn.functional.interpolate(
38
+ logits,
39
+ size=image.size[::-1],
40
+ mode="bilinear",
41
+ align_corners=False,
42
+ )
43
+
44
+ pred_seg = upsampled_logits.argmax(dim=1)[0]
45
+ plt.imshow(pred_seg)
46
+ ```