Post
Posting about a very underrated model that tops paperswithcode across different segmentation benchmarks: OneFormer π
OneFormer is a "truly universal" model for semantic, instance and panoptic segmentation tasks βοΈ
What makes is truly universal is that it's a single model that is trained only once and can be used across all tasks.
The enabler here is the text conditioning, i.e. the model is given a text query that states task type along with the appropriate input, and using contrastive loss, the model learns the difference between different task types π (see in the image below)
It's also super easy to use with transformers.
I have drafted a notebook for you to try right away β¨ https://colab.research.google.com/drive/1wfJhoTFqUqcTAYAOUc6TXUubBTmOYaVa?usp=sharing
You can also check out the Space without checking out the code itself π shi-labs/OneFormer
OneFormer is a "truly universal" model for semantic, instance and panoptic segmentation tasks βοΈ
What makes is truly universal is that it's a single model that is trained only once and can be used across all tasks.
The enabler here is the text conditioning, i.e. the model is given a text query that states task type along with the appropriate input, and using contrastive loss, the model learns the difference between different task types π (see in the image below)
It's also super easy to use with transformers.
from transformers import OneFormerProcessor, OneFormerForUniversalSegmentation
processor = OneFormerProcessor.from_pretrained("shi-labs/oneformer_ade20k_swin_large")
model = OneFormerForUniversalSegmentation.from_pretrained("shi-labs/oneformer_ade20k_swin_large")
# swap the postprocessing and task_inputs for different types of segmentation
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]
I have drafted a notebook for you to try right away β¨ https://colab.research.google.com/drive/1wfJhoTFqUqcTAYAOUc6TXUubBTmOYaVa?usp=sharing
You can also check out the Space without checking out the code itself π shi-labs/OneFormer