模型:

shi-labs/oneformer_ade20k_dinat_large

英文

OneFormer

OneFormer模型是在ADE20k数据集(大尺寸版本,Dinat骨干)上训练的。它是由Jain等人在论文 OneFormer: One Transformer to Rule Universal Image Segmentation 中提出,并于 this repository 首次发布。

模型描述

OneFormer是第一个多任务通用图像分割框架。它只需要使用单一通用架构、单一模型和单一数据集进行训练,就能在语义分割、实例分割和全景分割任务中胜过现有的专门模型。OneFormer使用任务令牌将模型与当前任务相关联,使得该架构在训练时具有任务导向性,在推理时具有任务动态性,而全部仅使用一个模型。

预期用途和限制

您可以使用此特定检查点进行语义分割、实例分割和全景分割。请参阅 model hub 以查找在不同数据集上进行微调的其他版本。

如何使用

以下是如何使用此模型的方法:

from transformers import OneFormerProcessor, OneFormerForUniversalSegmentation
from PIL import Image
import requests
url = "https://huggingface.co/datasets/shi-labs/oneformer_demo/blob/main/ade20k.jpeg"
image = Image.open(requests.get(url, stream=True).raw)

# Loading a single model for all three tasks
processor = OneFormerProcessor.from_pretrained("shi-labs/oneformer_ade20k_dinat_large")
model = OneFormerForUniversalSegmentation.from_pretrained("shi-labs/oneformer_ade20k_dinat_large")

# Semantic Segmentation
semantic_inputs = processor(images=image, ["semantic"] return_tensors="pt")
semantic_outputs = model(**semantic_inputs)
# pass through image_processor for postprocessing
predicted_semantic_map = processor.post_process_semantic_segmentation(outputs, target_sizes=[image.size[::-1]])[0]

# Instance Segmentation
instance_inputs = processor(images=image, ["instance"] return_tensors="pt")
instance_outputs = model(**instance_inputs)
# pass through image_processor for postprocessing
predicted_instance_map = processor.post_process_instance_segmentation(outputs, target_sizes=[image.size[::-1]])[0]["segmentation"]

# Panoptic Segmentation
panoptic_inputs = processor(images=image, ["panoptic"] return_tensors="pt")
panoptic_outputs = model(**panoptic_inputs)
# pass through image_processor for postprocessing
predicted_semantic_map = processor.post_process_panoptic_segmentation(outputs, target_sizes=[image.size[::-1]])[0]["segmentation"]

有关更多示例,请参阅 documentation

引用

@article{jain2022oneformer,
      title={{OneFormer: One Transformer to Rule Universal Image Segmentation}},
      author={Jitesh Jain and Jiachen Li and MangTik Chiu and Ali Hassani and Nikita Orlov and Humphrey Shi},
      journal={arXiv}, 
      year={2022}
    }