mattmdjaga commited on
Commit
c19219e
1 Parent(s): aa2ee73

Added examples

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