🚀 OneFormer
OneFormer是一個用於通用圖像分割的模型,它在ADE20k數據集上進行訓練(大尺寸版本,採用Swin骨幹網絡)。該模型能夠在語義、實例和全景分割任務中表現出色,為圖像分割領域提供了強大的解決方案。
🚀 快速開始
OneFormer模型在ADE20k數據集(大尺寸版本,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/ade20k.jpeg"
image = Image.open(requests.get(url, stream=True).raw)
processor = OneFormerProcessor.from_pretrained("shi-labs/oneformer_ade20k_swin_large")
model = OneFormerForUniversalSegmentation.from_pretrained("shi-labs/oneformer_ade20k_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許可證。
屬性 |
詳情 |
模型類型 |
用於通用圖像分割的Transformer模型 |
訓練數據 |
ADE20k數據集 |
標籤 |
視覺、圖像分割、通用圖像分割 |
示例數據集 |
scene_parse_150 |