--- library_name: pytorch tags: - pytorch - image-classification - flowers - computer-vision pipeline_tag: image-classification --- # 🌸 102-Flower Image Classifier — EfficientNet-B0 PyTorch image-classification model trained to recognize **102 flower categories**. ## Results - Architecture: **EfficientNet-B0** - Classes: **102** - Input: **224 × 224** - Best validation accuracy: **94.38%** - Epochs: **3** - Optimizer: **AdamW** - Learning rate: **0.001** ## Files - `checkpoint.pth` — trained model checkpoint - `model_config.json` — model architecture metadata - `training_config.json` — training settings and validation result - `class_config.json` — exact class/index mappings - `labels.txt` — labels in model-output index order - `requirements.txt` — Python dependencies ## Use the model ```python import torch import torch.nn as nn from torchvision import models, transforms from PIL import Image checkpoint = torch.load("checkpoint.pth", map_location="cpu") model = models.efficientnet_b0(weights=None) model.classifier[1] = nn.Linear(model.classifier[1].in_features, 102) model.load_state_dict(checkpoint["model_state_dict"]) model.eval() idx_to_class = { int(k): v for k, v in __import__("json").load(open("class_config.json"))["idx_to_class"].items() } transform = transforms.Compose([ transforms.Resize(256), transforms.CenterCrop(224), transforms.ToTensor(), transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) ]) image = Image.open("flower.jpg").convert("RGB") x = transform(image).unsqueeze(0) with torch.no_grad(): probabilities = torch.softmax(model(x), dim=1) confidence, prediction = probabilities.max(dim=1) idx = prediction.item() print("Prediction:", idx_to_class[idx]) print("Confidence:", f"{confidence.item()*100:.2f}%") ``` ## Checkpoint contents The checkpoint contains: - `epoch` - `model_state_dict` - `optimizer_state_dict` - `class_to_idx` ## Training The model was trained with transfer learning using an ImageNet-pretrained EfficientNet-B0 backbone, then fine-tuned for the 102 flower classes. ## Citation / attribution Please retain attribution to the model author when redistributing or building upon this model. Check the original dataset's license and terms before redistribution. ## License Add the license that applies to your model and dataset before publishing.