File size: 1,410 Bytes
129b861 363db9d 129b861 363db9d 129b861 363db9d 129b861 363db9d |
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 36 37 38 39 40 41 42 43 |
---
license: mit
pipeline_tag: image-segmentation
tags:
- instance-segmentation
- maskformer
- germination
---
# MaskFormer-Germination
Fine-tuned MaskFormer for germination instance segmentation.
## Details
- **Base Model**: `facebook/maskformer-swin-tiny-coco`
- **Classes**:
- `0`: Background
- `1`: Normal
- `2`: Abnormal
- **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("Dreamy0/GermiNet-instance-segmentation-maskformer")
model = MaskFormerForInstanceSegmentation.from_pretrained("Dreamy0/GermiNet-instance-segmentation-maskformer")
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} ({model.config.id2label[label]}), Score: {score:.3f}, Mask shape: {mask.shape}") |