🚀 OneFormer
OneFormer是一個在COCO數據集(大尺寸版本,Dinat主幹網絡)上訓練的模型。它由Jain等人在論文OneFormer: One Transformer to Rule Universal Image Segmentation中提出,並首次在此倉庫中發佈。該模型可用於圖像分割任務,通過單一架構和模型實現多任務的高效處理。
🚀 快速開始
你可以使用這個特定的檢查點進行語義、實例和全景分割。若要查找在其他數據集上微調的版本,請查看模型中心。
✨ 主要特性
- OneFormer是首個多任務通用圖像分割框架。
- 僅需使用單一通用架構、單一模型在單一數據集上進行一次訓練,就能在語義、實例和全景分割任務中超越現有的專門模型。
- 使用任務令牌使模型專注於特定任務,使架構在訓練時具有任務導向性,在推理時具有任務動態性,且僅需一個模型。

💻 使用示例
基礎用法
from transformers import OneFormerProcessor, OneFormerForUniversalSegmentation
from PIL import Image
import requests
url = "https://huggingface.co/datasets/shi-labs/oneformer_demo/blob/main/coco.jpeg"
image = Image.open(requests.get(url, stream=True).raw)
processor = OneFormerProcessor.from_pretrained("shi-labs/oneformer_coco_dinat_large")
model = OneFormerForUniversalSegmentation.from_pretrained("shi-labs/oneformer_coco_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"]
更多示例請參考文檔。
📚 詳細文檔
引用
@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許可證。
屬性 |
詳情 |
模型類型 |
圖像分割模型 |
訓練數據 |
ydshieh/coco_dataset_script |
💡 使用建議
若要使用不同的數據集進行分割任務,可在模型中心查找其他微調版本的OneFormer模型。