模型:

optimum/segformer-b0-finetuned-ade-512-512

英文

SegFormer(b0尺寸)模型在ADE20k上进行了微调

SegFormer模型在分辨率为512x512的ADE20k上进行了微调。这个模型是由Xie等人在 SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers 论文中提出的,并在 this repository 中首次发布。

注意:发布SegFormer的团队并没有为这个模型编写模型卡片,因此这个模型卡片是由Hugging Face团队编写的。

模型描述

SegFormer由一个分层Transformer编码器和一个轻量级的全MLP解码头组成,可以在ADE20K和Cityscapes等语义分割基准上取得很好的结果。分层Transformer首先在ImageNet-1k上进行预训练,然后添加解码头并在下游数据集上进行全面微调。

使用目的和限制

您可以使用原始模型进行语义分割。可以查看 model hub 以查找您感兴趣的任务的微调版本。

如何使用

以下是如何使用此模型对COCO 2017数据集的图像进行分类为1,000个ImageNet类别之一的方法:

from transformers import SegformerImageProcessor
from PIL import Image
import requests

from optimum.onnxruntime import ORTModelForSemanticSegmentation

image_processor = SegformerImageProcessor.from_pretrained("optimum/segformer-b0-finetuned-ade-512-512")
model = ORTModelForSemanticSegmentation.from_pretrained("optimum/segformer-b0-finetuned-ade-512-512")

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)

inputs = image_processor(images=image, return_tensors="pt").to(device)
outputs = model(**inputs)
logits = outputs.logits  # shape (batch_size, num_labels, height/4, width/4)

如果使用pipeline:

from transformers import SegformerImageProcessor, pipeline
from optimum.onnxruntime import ORTModelForSemanticSegmentation

image_processor = SegformerImageProcessor.from_pretrained("optimum/segformer-b0-finetuned-ade-512-512")
model = ORTModelForSemanticSegmentation.from_pretrained("optimum/segformer-b0-finetuned-ade-512-512")

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
pipe = pipeline("image-segmentation", model=model, feature_extractor=image_processor)
pred = pipe(url)

有关更多代码示例,请参阅 Optimum documentation

许可证

有关此模型的许可证,请查看 here

BibTeX引用和引文信息

@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}
}