🚀 OneFormer
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_tiny")
model = OneFormerForUniversalSegmentation.from_pretrained("shi-labs/oneformer_ade20k_swin_tiny")
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使用任務令牌使模型專注於特定任務,使架構在訓練時具有任務導向性,在推理時具有任務動態性,且僅需單個模型即可實現。

預期用途和限制
你可以使用此特定檢查點進行語義、實例和全景分割。如需查找在不同數據集上微調的其他版本,請查看 模型中心。
引用
@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許可證。
📦 模型信息
屬性 |
詳情 |
模型類型 |
OneFormer模型(在ADE20k數據集微小版本上訓練,Swin主幹網絡) |
訓練數據 |
scene_parse_150 |
🖼️ 示例展示
