Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
tags:
|
4 |
+
- vision
|
5 |
+
- image-segmentation
|
6 |
+
datasets:
|
7 |
+
- scene_parse_150
|
8 |
+
widget:
|
9 |
+
- src: https://huggingface.co/datasets/hf-internal-testing/fixtures_ade20k/resolve/main/ADE_val_00000001.jpg
|
10 |
+
example_title: House
|
11 |
+
- src: https://huggingface.co/datasets/hf-internal-testing/fixtures_ade20k/resolve/main/ADE_val_00000002.jpg
|
12 |
+
example_title: Castle
|
13 |
+
---
|
14 |
+
|
15 |
+
# SegFormer (b0-sized) encoder fine-tuned on ADE20k
|
16 |
+
|
17 |
+
SegFormer encoder fine-tuned on Imagenet-1k. It was introduced in the paper [SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers](https://arxiv.org/abs/2105.15203) by Xie et al. and first released in [this repository](https://github.com/NVlabs/SegFormer).
|
18 |
+
|
19 |
+
Disclaimer: The team releasing SegFormer did not write a model card for this model so this model card has been written by the Hugging Face team.
|
20 |
+
|
21 |
+
## Model description
|
22 |
+
|
23 |
+
SegFormer consists of a hierarchical Transformer encoder and a lightweight all-MLP decode head to achieve great results on semantic segmentation benchmarks such as ADE20K and Cityscapes. The hierarchical Transformer is first pre-trained on ImageNet-1k, after which a decode head is added and fine-tuned altogether on a downstream dataset.
|
24 |
+
|
25 |
+
This repository only contains the pre-trained hierarchical Transformer, hence it can be used for fine-tuning purposes.
|
26 |
+
|
27 |
+
## Intended uses & limitations
|
28 |
+
|
29 |
+
You can use the model for fine-tuning of semantic segmentation. See the [model hub](https://huggingface.co/models?other=segformer) to look for fine-tuned versions on a task that interests you.
|
30 |
+
|
31 |
+
### How to use
|
32 |
+
|
33 |
+
Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:
|
34 |
+
|
35 |
+
```python
|
36 |
+
from transformers import SegformerFeatureExtractor, SegformerForImageClassification
|
37 |
+
from PIL import Image
|
38 |
+
import requests
|
39 |
+
|
40 |
+
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
41 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
42 |
+
|
43 |
+
feature_extractor = SegformerFeatureExtractor.from_pretrained("nvidia/mit-b0")
|
44 |
+
model = SegformerForImageClassification.from_pretrained("nvidia/mit-b0")
|
45 |
+
|
46 |
+
inputs = feature_extractor(images=image, return_tensors="pt")
|
47 |
+
outputs = model(**inputs)
|
48 |
+
logits = outputs.logits
|
49 |
+
# model predicts one of the 1000 ImageNet classes
|
50 |
+
predicted_class_idx = logits.argmax(-1).item()
|
51 |
+
print("Predicted class:", model.config.id2label[predicted_class_idx])
|
52 |
+
```
|
53 |
+
|
54 |
+
For more code examples, we refer to the [documentation](https://huggingface.co/transformers/model_doc/segformer.html#).
|
55 |
+
|
56 |
+
### BibTeX entry and citation info
|
57 |
+
|
58 |
+
```bibtex
|
59 |
+
@article{DBLP:journals/corr/abs-2105-15203,
|
60 |
+
author = {Enze Xie and
|
61 |
+
Wenhai Wang and
|
62 |
+
Zhiding Yu and
|
63 |
+
Anima Anandkumar and
|
64 |
+
Jose M. Alvarez and
|
65 |
+
Ping Luo},
|
66 |
+
title = {SegFormer: Simple and Efficient Design for Semantic Segmentation with
|
67 |
+
Transformers},
|
68 |
+
journal = {CoRR},
|
69 |
+
volume = {abs/2105.15203},
|
70 |
+
year = {2021},
|
71 |
+
url = {https://arxiv.org/abs/2105.15203},
|
72 |
+
eprinttype = {arXiv},
|
73 |
+
eprint = {2105.15203},
|
74 |
+
timestamp = {Wed, 02 Jun 2021 11:46:42 +0200},
|
75 |
+
biburl = {https://dblp.org/rec/journals/corr/abs-2105-15203.bib},
|
76 |
+
bibsource = {dblp computer science bibliography, https://dblp.org}
|
77 |
+
}
|
78 |
+
```
|