🚀 OneFormer
OneFormer是在Cityscapes数据集(大尺寸版本,Dinat主干网络)上训练的模型。它由Jain等人在论文OneFormer: One Transformer to Rule Universal Image Segmentation中提出,并首次在此仓库发布。该模型可用于图像分割任务,为多种分割需求提供了统一的解决方案。
🚀 快速开始
你可以使用这个特定的检查点进行语义、实例和全景分割。查看模型中心以寻找在不同数据集上微调的其他版本。
✨ 主要特性
- OneFormer是首个多任务通用图像分割框架。只需使用单一通用架构、单一模型并在单一数据集上进行一次训练,就能在语义、实例和全景分割任务中超越现有的专用模型。
- OneFormer使用任务令牌来使模型专注于当前任务,使架构在训练时具有任务导向性,在推理时具有任务动态性,且仅需使用单一模型。
💻 使用示例
基础用法
from transformers import OneFormerProcessor, OneFormerForUniversalSegmentation
from PIL import Image
import requests
url = "https://huggingface.co/datasets/shi-labs/oneformer_demo/blob/main/cityscapes.png"
image = Image.open(requests.get(url, stream=True).raw)
processor = OneFormerProcessor.from_pretrained("shi-labs/oneformer_cityscapes_dinat_large")
model = OneFormerForUniversalSegmentation.from_pretrained("shi-labs/oneformer_cityscapes_dinat_large")
semantic_inputs = processor(images=image, task_inputs=["semantic"], return_tensors="pt")
semantic_outputs = model(**semantic_inputs)
predicted_semantic_map = processor.post_process_semantic_segmentation(outputs, target_sizes=[image.size[::-1]])[0]
instance_inputs = processor(images=image, task_inputs=["instance"], return_tensors="pt")
instance_outputs = model(**instance_inputs)
predicted_instance_map = processor.post_process_instance_segmentation(outputs, target_sizes=[image.size[::-1]])[0]["segmentation"]
panoptic_inputs = processor(images=image, task_inputs=["panoptic"], return_tensors="pt")
panoptic_outputs = model(**panoptic_inputs)
predicted_semantic_map = processor.post_process_panoptic_segmentation(outputs, target_sizes=[image.size[::-1]])[0]["segmentation"]
更多示例
更多示例请参考文档。
📚 详细文档
OneFormer是首个多任务通用图像分割框架。它需要仅使用单一通用架构、单一模型并在单一数据集上进行一次训练,就能在语义、实例和全景分割任务中超越现有的专用模型。OneFormer使用任务令牌来使模型专注于当前任务,使架构在训练时具有任务导向性,在推理时具有任务动态性,且仅需使用单一模型。

📄 许可证
本项目采用MIT许可证。
📦 信息表格
属性 |
详情 |
模型类型 |
多任务通用图像分割模型 |
训练数据 |
Cityscapes数据集 |
📖 引用
@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}
}
