colab notebook ยท ready to run

Flower Classifier Lab

A complete, GPU-ready notebook that teaches a MobileNetV2 to tell five flowers apart โ€” then grades itself and judges your photos.

Grab the notebook

โฌ‡ flower_classification_mobilenetv2.ipynb

30 cells ยท 13 KB ยท TensorFlow / Keras ยท runs top-to-bottom in ~10โ€“15 min on a free T4

Then: open colab.research.google.com โ†’ File โ†’ Upload notebook โ†’ pick the file โ†’ Runtime โ†’ Change runtime type โ†’ GPU โ†’ Run all. The Kaggle dataset downloads itself via kagglehub โ€” no API key, no kaggle.json.

What's inside

  1. Dataset download, zero setupkagglehub.dataset_download("alxmamaev/flowers-recognition") โ€” 4.3k photos, plus a robust finder for the archive's nested folders and a per-class image census.
  2. Sample gallery3ร—5 grid of random specimens so you see the data before you trust it.
  3. tf.data pipeline80/20 split, 224ร—224, batches of 32, cached + prefetched. Validation kept unshuffled so the confusion matrix doesn't lie.
  4. Data augmentation โ€” visualizedRandom flip / rotation / zoom / translation / contrast as in-model layers, with one flower shown eight augmented ways.
  5. Transfer learningFrozen ImageNet MobileNetV2 + GlobalAveragePooling + Dropout + softmax head. preprocess_input lives inside the graph, so the saved model eats raw pixels.
  6. Head trainingAdam 1e-3, EarlyStopping + ReduceLROnPlateau, ~10 epochs.
  7. Fine-tuningTop ~55 backbone layers unfrozen at Adam 1e-5 โ€” the classic two-phase recipe, with the phase boundary marked on the curves.
  8. EvaluationJoined accuracy/loss curves, sklearn classification report, annotated confusion matrix, and a "most confident mistakes" gallery.
  9. Your own photofiles.upload() cell โ€” drop in any flower picture, get top-3 probabilities.
  10. ExportSaves .keras + quantized .tflite (~3 MB โ€” MobileNet back in its natural habitat).

๐ŸŒฑ Expect ~90%+ validation accuracy after fine-tuning. The notebook ends with ideas to push further โ€” EfficientNetV2, class weights, Grad-CAM. No accounts, no keys, no tracking: the notebook is yours.