Views
No views yet
| Metric | Value |
|---|---|
| Best Validation Loss | 0.9726 |
| Best Validation mIoU | 23.33% |
| Training Epochs | 44 |
| Optimizer | AdamW (lr=1e-4, weight_decay=1e-2) |
| Scheduler | CosineAnnealingWarmRestarts |
| Loss Function | Dice Loss + Cross Entropy |
| Batch Size | 16 |
1import torch
2import segmentation_models_pytorch as smp
3from huggingface_hub import hf_hub_download
4
5# Download model weights
6model_path = hf_hub_download(
7 repo_id="mawiie/food-segmentation-mobilenet",
8 filename="best_model.pth"
9)
10
11# Create model architecture
12model = smp.DeepLabV3Plus(
13 encoder_name="mobilenet_v2",
14 encoder_weights=None, # We'll load our own weights
15 in_channels=3,
16 classes=104,
17)
18
19# Load trained weights
20model.load_state_dict(torch.load(model_path, map_location="cpu"))
21model.eval()
22
23# Inference
24# Normalize with ImageNet stats: mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)
25# Input shape: (B, 3, 512, 512)
26# Output shape: (B, 104, 512, 512)