File size: 1,256 Bytes
129b861 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
---
license: mit
---
# MaskFormer-Germination
Fine-tuned MaskFormer for germination instance segmentation.
## Details
- **Base Model**: `facebook/maskformer-swin-tiny-coco`
- **Classes**: Normal (1), Abnormal (2) (mapped to COCO 134-class IDs)
- **Training Data**: 18 images, 31+ annotations per image
- **Epochs**: 5
- **Final Loss**: 1.655
- **Batch Size**: 2
- **Learning Rate**: 5e-5
- **Steps**: 45
- **Runtime**: ~26 minutes
## Usage
```python
from transformers import MaskFormerForInstanceSegmentation, MaskFormerImageProcessor
import torch
from PIL import Image
processor = MaskFormerImageProcessor.from_pretrained("your-username/maskformer-germination")
model = MaskFormerForInstanceSegmentation.from_pretrained("your-username/maskformer-germination")
model.eval()
image = Image.open("path/to/image.jpg")
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
results = processor.post_process_instance_segmentation(outputs, target_sizes=[(image.height, image.width)])[0]
for score, label, mask in zip(results["scores"], results["labels"], results["masks"]):
if score > 0.5 and label in [1, 2]:
print(f"Label: {label}, Score: {score:.3f}, Mask shape: {mask.shape}") |