🚀 OneFormer
OneFormer是在Cityscapes數據集(大尺寸版本,Swin主幹網絡)上訓練的模型。它由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_swin_large")
model = OneFormerForUniversalSegmentation.from_pretrained("shi-labs/oneformer_cityscapes_swin_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"]
更多示例請參考 文檔。
引用
@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}
}
📄 許可證
本項目採用MIT許可證。
📋 信息表格
屬性 |
詳情 |
模型類型 |
多任務通用圖像分割模型 |
訓練數據 |
Huggan/Cityscapes數據集 |
標籤 |
視覺、圖像分割 |