模型:
nvidia/mit-b4
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-b4") model = SegformerForImageClassification.from_pretrained("nvidia/mit-b4") 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} }