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