๐ŸŒธ Flowers 102 โ€“ EfficientNet-B0 Classifier

Fine-tuned EfficientNet-B0 untuk mengklasifikasikan 102 jenis bunga dari dataset Oxford 102 Flowers.

Performa Model

Split Akurasi
Test 88.81%

Cara Penggunaan

import torch
import torch.nn as nn
from torchvision import models, transforms
from PIL import Image
from huggingface_hub import hf_hub_download
import json

# Muat model
ckpt_path   = hf_hub_download("Nbila23/flowers102-efficientnet-b0", "cnn_flowers102_checkpoint.pth")
labels_path = hf_hub_download("Nbila23/flowers102-efficientnet-b0", "class_names.json")

with open(labels_path) as f:
    class_names = json.load(f)

model = models.efficientnet_b0(weights=None)
in_f  = model.classifier[1].in_features
model.classifier = nn.Sequential(
    nn.Dropout(0.3, inplace=True),
    nn.Linear(in_f, 102)
)
ckpt = torch.load(ckpt_path, map_location="cpu")
model.load_state_dict(ckpt["model_state_dict"])
model.eval()

# Inferensi
transform = transforms.Compose([
    transforms.Resize((224, 224)),
    transforms.ToTensor(),
    transforms.Normalize([0.485,0.456,0.406],[0.229,0.224,0.225]),
])

img    = Image.open("bunga.jpg").convert("RGB")
tensor = transform(img).unsqueeze(0)
with torch.no_grad():
    probs = torch.softmax(model(tensor), 1)[0]
top1  = probs.argmax().item()
print(f"Prediksi: {class_names[top1]} ({probs[top1]:.2%})")

Dataset

Oxford 102 Flowers

Arsitektur

  • Backbone : EfficientNet-B0 (pretrained ImageNet)
  • Head : Dropout(0.3) โ†’ Linear(1280, 102)
  • Optimizer: AdamW + Cosine Annealing LR
  • Loss : CrossEntropyLoss (label smoothing=0.1)
Downloads last month
24
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support