CoolFace
Modelpublic

nvidia/mit-b2

sourceHugging Faceotherupdated 4y agoView on Hugging Face
7likes98kdownloads
README.md82 linesDownload Raw Back to root
1---2license: other3tags:4- vision5datasets:6- imagenet_1k7widget:8- src: https://huggingface.co/datasets/hf-internal-testing/fixtures_ade20k/resolve/main/ADE_val_00000001.jpg9  example_title: House10- src: https://huggingface.co/datasets/hf-internal-testing/fixtures_ade20k/resolve/main/ADE_val_00000002.jpg11  example_title: Castle12---13 14# SegFormer (b2-sized) encoder pre-trained-only15 16SegFormer 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). 17 18Disclaimer: 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.19 20## Model description21 22SegFormer 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.23 24This repository only contains the pre-trained hierarchical Transformer, hence it can be used for fine-tuning purposes.25 26## Intended uses & limitations27 28You 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.29 30### How to use31 32Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:33 34```python35from transformers import SegformerFeatureExtractor, SegformerForImageClassification36from PIL import Image37import requests38 39url = "http://images.cocodataset.org/val2017/000000039769.jpg"40image = Image.open(requests.get(url, stream=True).raw)41 42feature_extractor = SegformerFeatureExtractor.from_pretrained("nvidia/mit-b2")43model = SegformerForImageClassification.from_pretrained("nvidia/mit-b2")44 45inputs = feature_extractor(images=image, return_tensors="pt")46outputs = model(**inputs)47logits = outputs.logits48# model predicts one of the 1000 ImageNet classes49predicted_class_idx = logits.argmax(-1).item()50print("Predicted class:", model.config.id2label[predicted_class_idx])51```52 53For more code examples, we refer to the [documentation](https://huggingface.co/transformers/model_doc/segformer.html#).54 55### License56 57The license for this model can be found [here](https://github.com/NVlabs/SegFormer/blob/master/LICENSE).58 59### BibTeX entry and citation info60 61```bibtex62@article{DBLP:journals/corr/abs-2105-15203,63  author    = {Enze Xie and64               Wenhai Wang and65               Zhiding Yu and66               Anima Anandkumar and67               Jose M. Alvarez and68               Ping Luo},69  title     = {SegFormer: Simple and Efficient Design for Semantic Segmentation with70               Transformers},71  journal   = {CoRR},72  volume    = {abs/2105.15203},73  year      = {2021},74  url       = {https://arxiv.org/abs/2105.15203},75  eprinttype = {arXiv},76  eprint    = {2105.15203},77  timestamp = {Wed, 02 Jun 2021 11:46:42 +0200},78  biburl    = {https://dblp.org/rec/journals/corr/abs-2105-15203.bib},79  bibsource = {dblp computer science bibliography, https://dblp.org}80}81```82