Skip to content
ModelListedExternal
Download

Oxford 17 Flowers Cnn

ResNet18 fine-tuned on the Oxford 17 Flowers dataset. Classifies RGB images into 17 flower categories.

KindOtherVersionRevision e727ec8Bgrade

Model source

Kind
Other
File size
42.7 MB
Version
vRevision e727ec8
Updated
Oct 11, 2026
Downloads
6
Source
Hugging Face

Source description

Oxford 17 Flowers — ResNet18 (97.8% test accuracy)

ResNet18 fine-tuned on the Oxford 17 Flowers dataset. Classifies RGB images into 17 flower categories.

Successor of the from-scratch educational CNN at darjja/oxford-17-flowers-cnn — same CLI, much higher accuracy:

ModelTest accuracy
From-scratch CNN, 64×64 (original)62.13%
From-scratch CNN + augmentation & label smoothing66.91%
ResNet18 fine-tuned, 224×224 (this repo)97.79%

Quick start

pip install torch torchvision huggingface_hub pillow

Download the script and run it on any image:

huggingface-cli download sergiudanstan/oxford-17-flowers-cnn predict.py --local-dir .
python predict.py your_flower.jpg
python predict.py your_flower.jpg --top 5

The script downloads flower_cnn.pth, config.json, and model.py from this repo automatically on first run.

Training recipe

  • ImageNet-pretrained ResNet18 (torchvision IMAGENET1K_V1), full fine-tune at 224×224
  • Differential learning rates: backbone 1e-4, new head 1e-3 (AdamW, weight decay 1e-4)
  • CosineAnnealingLR, label smoothing 0.1, early stopping on validation accuracy
  • Augmentation: RandomResizedCrop(0.7–1.0), horizontal flip, rotation ±15°, ColorJitter 0.2
  • Split: 924 train / 164 val (15%, seed 42) / 272 official test
  • ~3 minutes on a laptop RTX 5050

Files in this repo

FilePurpose
predict.pyCLI script — pass any image path as argument
model.pyModel definition (ResNet18 wrapper, FlowerCNN)
flower_cnn.pthFine-tuned weights (~45 MB)
config.jsonImage size, class names

Classes

Bluebell, Buttercup, Coltsfoot, Cowslip, Crocus, Daffodil, Daisy, Dandelion, Fritillary, Iris, Lilyvalley, Pansy, Snowdrop, Sunflower, Tigerlily, Tulip, Windflower

Sources

1 source
Hugging FacePrimaryVersion e727ec879a13eada6c899c5a1863b1f1905d32ef
huggingface.co/sergiudanstan/oxford-17-flowers-cnn/tree/e727ec879a13eada6c899c5a1863b1f1905d32ef

Verified Aug 27

Model artifacts

1 artifact

flower_cnn.pth

pth · 42.7 MB · SHA-256 c12813871829…d8da · Hugging Face

Download file

Source excerpts

2 excerpts

--- license: apache-2.0 tags: - image-classification - pytorch - resnet datasets: - darjja/oxford-17-flowers --- # Oxford 17 Flowers — ResNet18 (97.8% test accuracy) ResNet18 fine-tuned on the [Oxford 17 Flowers](https://huggingface.co/datasets/darjja/oxford-17-flowers) dataset. Classifies RGB images into 17 flower categories. Successor of the from-scratch educational CNN at [darjja/oxford-17-flowers-cnn](https://huggingface.co/darjja/oxford-17-flowers-cnn) — same CLI, much higher accuracy: | Model | Test accuracy | |---|---| | From-scratch CNN, 64×64 (original) | 62.13% | | From-scratch CNN + augmentation & label smoothing | 66.91% | | **ResNet18 fine-tuned, 224×224 (this repo)** | **97.79%** | ## Quick start ```bash pip install torch torchvision huggingface_hub pillow ``` Download the script and run it on any image: ```bash huggingface-cli download sergiudanstan/oxford-17-flowers-cnn predict.py --local-dir . python predict.py your_flower.jpg python predict.py your_flower.jpg --top 5 ``` The script downloads `flower_cnn.pth`, `config.json`, and `model.py` from this repo automatically on first run. ## Training recipe - ImageNet-pretrained ResNet18 (torchvision `IMAGENET1K_V1`), full fine-tune at 224×224 - Differential learning rates: backbone 1e-4, new head 1e-3 (AdamW, weight decay 1e-4) - CosineAnnealingLR, label smoothing 0.1, early stopping on validation accuracy - Augmentation: RandomResizedCrop(0.7–1.0), horizontal flip, rotation ±15°, ColorJitter 0.2 - Split: 924 train / 164 val (15%, seed 42) / 272 official test - ~3 minutes on a laptop RTX 5050 ## Files in this repo | File | Purpose | |------|---------| | `predict.py` | CLI script — pass any image path as argument | | `model.py` | Model definition (ResNet18 wrapper, `FlowerCNN`) | | `flower_cnn.pth` | Fine-tuned weights (~45 MB) | | `config.json` | Image size, class names | ## Classes Bluebell, Buttercup, Coltsfoot, Cowslip, Crocus, Daffodil, Daisy, Dandelion, Fritillary, Iris, Lilyvalley, Pansy, Snowdrop, Sunflower, Tigerlily, Tulip, Windflower

Source context: 6 downloads · 0 likes · Pipeline image-classification · Repo sergiudanstan/oxford-17-flowers-cnn