Views
No views yet
| File | Architecture | Params | Area-Consistency Weight | Description |
|---|---|---|---|---|
grayleafspot.pt | smp.Unet (ResNet-34) | ~24.4 M | — | Main encoder–decoder model |
best_area_w_0.1.pt | SmallUNet | ~250 K | 0.1 | Light area regularisation |
best_area_w_0.3.pt | SmallUNet | ~250 K | 0.3 | Moderate area regularisation |
best_area_w_0.5.pt | SmallUNet | ~250 K | 0.5 | Balanced BCE + area |
best_area_w_0.7.pt | SmallUNet | ~250 K | 0.7 | Strong area consistency (used by demo) ✅ recommended |
Input (3 × 256 × 256)
│
├─ enc1: ConvBlock(3 → 16) ─── skip s1
├─ enc2: MaxPool2d → ConvBlock(16 → 32) ─── skip s2
├─ enc3: MaxPool2d → ConvBlock(32 → 64) ─── skip s3
├─ enc4: MaxPool2d → ConvBlock(64 → 128) ─── skip s4
│
├─ bottleneck: MaxPool2d → ConvBlock(128 → 256)
│
├─ up4: Upsample + cat(s4) → ConvBlock(384 → 128)
├─ up3: Upsample + cat(s3) → ConvBlock(192 → 64)
├─ up2: Upsample + cat(s2) → ConvBlock(96 → 32)
├─ up1: Upsample + cat(s1) → ConvBlock(48 → 16)
│
└─ head: Conv2d(16 → 1) → SigmoidConvBlock = Conv3×3 (no bias) → ReLU → Conv3×3 (no bias) → ReLU.| Property | Value |
|---|---|
| Input | 256 × 256 RGB |
| Output | 1-channel sigmoid probability mask |
| Training loss | BCE + area-consistency loss |
| CPU compatible | ✅ Pure PyTorch — no custom CUDA kernels |
1import torch
2from huggingface_hub import hf_hub_download
3
4# Download weights
5path = hf_hub_download("rotsl/grayleafspot-segmentation", "best_area_w_0.7.pt")
6
7# Load checkpoint
8ckpt = torch.load(path, map_location="cpu", weights_only=False)
9
10# Build model (SmallUNet architecture — see demo repo for full class definition)
11# https://huggingface.co/rotsl/grayleafspot-segmentation-demo/blob/main/app.py
12from model import SmallUNet # or copy the class from the demo app.py
13
14model = SmallUNet(in_channels=3, out_channels=1, base_channels=16)
15model.load_state_dict(ckpt["model_state_dict"])
16model.eval()
17
18# Run inference on a 256×256 RGB tensor
19import numpy as np
20from PIL import Image
21
22img = Image.open("petri_dish.jpg").convert("RGB").resize((256, 256))
23x = torch.from_numpy(np.array(img).transpose(2, 0, 1)).float() / 255.0
24x = x.unsqueeze(0)
25
26with torch.no_grad():
27 prob = model(x)[0, 0].numpy()
28
29mask = (prob > 0.5).astype(np.uint8) * 255
30Image.fromarray(mask).save("colony_mask.png")1import torch
2
3path = hf_hub_download("rotsl/grayleafspot-segmentation", "grayleafspot.pt")
4model = torch.load(path, map_location="cpu", weights_only=False)
5model.eval()1python3.10 -m venv trainenv
2source trainenv/bin/activate
3pip install --upgrade pip
4pip install -r requirements.txtraw/ and corresponding masks in masks/ (matching filenames). Expand the dataset with augmentations:python src/build_augmented_dataset.py --copies-per-image 4 --clean1python src/train.py \
2 --image-dir augmented_dataset/raw \
3 --mask-dir augmented_dataset/masks \
4 --epochs 40 --batch-size 4 --lr 1e-4 \
5 --image-size 256 --freeze-encoder-epochs 5./trainenv/bin/python src/area_consistency/train_area.pypython src/predict.py --input raw/your_image.jpg --weights models/best_finetuned.pt --output-dir predictionspython src/predict.py --input raw --weights models/best_finetuned.pt --output-dir predictionsrotsl/grayleafspot-segmentation-demobest_area_w_0.7.pt (SmallUNet with area-consistency loss). More accurate segmentation with better boundary adherence thanks to the area-consistency regularisation.rotsl/grayleafspot-segmentation-demo (model repo)rotsl/fungal-colony-inputgrayleafspot.pt (smp.Unet with ResNet-34 encoder). This is the earlier, larger model trained with standard BCE loss only — it is less accurate than the area-consistency variant above, particularly for colony boundary delineation and area estimation. Kept available for reference and backward compatibility.1@misc{rohan_r_2026,
2 author = {rohan r},
3 title = {grayleafspot-segmentation (Revision 0e85f71)},
4 year = 2026,
5 url = {https://huggingface.co/rotsl/grayleafspot-segmentation},
6 doi = {10.57967/hf/8416},
7 publisher = {Hugging Face}
8}