模型:
nvidia/mit-b3
SegFormer编码器在Imagenet-1k上进行了微调。它由Xie等人在 SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers 论文中提出,并首次在 this repository 中发布。
免责声明:发布SegFormer的团队未为该模型编写模型卡片,因此此模型卡片由Hugging Face团队撰写。
SegFormer由一个分层Transformer编码器和一个轻量级全MLP解码头组成,可以在ADE20K和Cityscapes等语义分割基准上取得出色的结果。分层Transformer首先在ImageNet-1k上进行预训练,然后添加解码头并在下游数据集上一起进行微调。
此存储库仅包含预训练的分层Transformer,因此可以用于微调。
您可以使用该模型来微调语义分割任务。请参考 model hub ,以查找您感兴趣的任务上的微调版本。
以下是如何使用此模型将COCO 2017数据集中的图像分类为其中一个1,000个Imagenet类别的示例:
from transformers import SegformerFeatureExtractor, SegformerForImageClassification from PIL import Image import requests url = "http://images.cocodataset.org/val2017/000000039769.jpg" image = Image.open(requests.get(url, stream=True).raw) feature_extractor = SegformerFeatureExtractor.from_pretrained("nvidia/mit-b3") model = SegformerForImageClassification.from_pretrained("nvidia/mit-b3") inputs = feature_extractor(images=image, return_tensors="pt") outputs = model(**inputs) logits = outputs.logits # model predicts one of the 1000 ImageNet classes predicted_class_idx = logits.argmax(-1).item() print("Predicted class:", model.config.id2label[predicted_class_idx])
有关更多代码示例,请参见 documentation 。
此模型的许可证可在 here 找到。
@article{DBLP:journals/corr/abs-2105-15203, author = {Enze Xie and Wenhai Wang and Zhiding Yu and Anima Anandkumar and Jose M. Alvarez and Ping Luo}, title = {SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers}, journal = {CoRR}, volume = {abs/2105.15203}, year = {2021}, url = {https://arxiv.org/abs/2105.15203}, eprinttype = {arXiv}, eprint = {2105.15203}, timestamp = {Wed, 02 Jun 2021 11:46:42 +0200}, biburl = {https://dblp.org/rec/journals/corr/abs-2105-15203.bib}, bibsource = {dblp computer science bibliography, https://dblp.org} }