Dreamy0's picture
Add fine-tuned Mask2Former model with CVAT compatibility
15e58af verified
---
license: apache-2.0
tags:
- mask2former
- instance-segmentation
- panoptic-segmentation
- semantic-segmentation
- image-segmentation
datasets:
- custom
pipeline_tag: image-segmentation
---
# Mask2Former for Segmentation
This model is fine-tuned to detect and segment regions across 3 classes.
## Model description
This is a Mask2Former model fine-tuned on a custom dataset with polygon annotations in COCO format. It has 3 classes:
- Background (ID: 0)
- Normal (ID: 1)
- Abnormal (ID: 2)
## Intended uses & limitations
This model is intended for universal segmentation tasks to identify the specified region types in images. Mask2Former supports instance, semantic, and panoptic segmentation.
### How to use in CVAT
1. In CVAT, go to Models → Add Model
2. Select Hugging Face as the source
3. Enter the model path: "{your-username}/mask2former-segmentation"
4. Configure the appropriate mapping for your labels
### Usage in Python
```python
from transformers import Mask2FormerForUniversalSegmentation, Mask2FormerImageProcessor
import torch
from PIL import Image
# Load model and processor
model = Mask2FormerForUniversalSegmentation.from_pretrained("{your-username}/mask2former-segmentation")
processor = Mask2FormerImageProcessor.from_pretrained("{your-username}/mask2former-segmentation")
# Prepare image
image = Image.open("your_image.jpg")
inputs = processor(images=image, return_tensors="pt")
# Make prediction
with torch.no_grad():
outputs = model(**inputs)
# Process outputs for visualization
# (see example code in model repository)
```