Flower Recognition
AI Classifier
A lightweight YOLOv8-powered image classifier that identifies flower species with 98.6% accuracy. Built in under 100 lines of Python and deployed on Hugging Face Spaces with Gradio interface.
Classification Result
Image Analysis
🌹 Rose
85.3%
🌷 Tulip
10.2%
🌼 Daisy
4.5%
Validation Accuracy
98.6%
Inference Time
< 4ms
Training Time
~8 min
Model Size
1.4M
Key Features
High accuracy flower classification with minimal latency.
98.6% Accuracy
Correctly identifies 789 out of 800 test images using YOLOv8 Nano model trained on 4,000+ flower photos. Leverages transfer learning from ImageNet-pretrained weights for exceptional performance with minimal data.
Lightning Fast Inference
Processes images in under 4ms thanks to the efficient YOLOv8 Nano architecture. Optimized for real-time classification on CPU with optional GPU acceleration for batch processing.
5 Flower Species Detection
Classifies daisies, dandelions, roses, sunflowers, and tulips with confidence scores and top-3 predictions. Gradio web interface provides real-time feedback with probability distributions.
ML Training Pipeline
Data Acquisition
Downloaded 4,000+ flower images from Kaggle using KaggleHub API. Dataset includes 5 species: daisy, dandelion, rose, sunflower, and tulip with balanced class distribution for robust training.
Data Preprocessing
Split dataset 80/20 for training and validation using scikit-learn. Images organized into train/val folders by class. Automated file copying with shutil ensures clean separation preventing data leakage.
Model Training
Loaded pre-trained YOLOv8 Nano classification model (yolov8n-cls.pt). Trained for 10 epochs on 224×224 images with batch size 32 using Google Colab's free T4 GPU. Training completed in ~8 minutes.
Model Evaluation
Achieved 98.6% validation accuracy on unseen test set. Confusion matrix analysis showed occasional misclassification between white daisies and white roses due to visual similarity.
Deployment
Created Gradio interface with image upload, prediction display, and confidence visualization. Deployed to Hugging Face Spaces for free public hosting with persistent model weights and sub-second inference.
Technical Stack
Modern machine learning tools enabling rapid prototyping and deployment.
Machine Learning
- ▸YOLOv8 Nano
- ▸Ultralytics
- ▸PyTorch
- ▸Transfer Learning
- ▸Classification
Data & Training
- ▸KaggleHub Dataset
- ▸4,000+ Images
- ▸Google Colab GPU
- ▸80/20 Train/Val Split
Deployment
- ▸Gradio Web App
- ▸Hugging Face Spaces
- ▸Free Hosting
- ▸Public API
Development
- ▸Python 3.10+
- ▸scikit-learn
- ▸Google Colab
- ▸Jupyter Notebook
System Architecture
Comprehensive feature set from model training to production deployment.
Model Architecture
- YOLOv8 Nano backbone with 1.4M parameters
- Transfer learning from ImageNet pre-training
- 224×224 input resolution for speed/accuracy balance
- Softmax output layer for class probabilities
- Single forward pass classification (no anchors)
- PyTorch backend with ONNX export support
Training Strategy
- 10 epochs with early stopping monitoring
- Adam optimizer with learning rate scheduling
- Cross-entropy loss function
- Data augmentation: rotation, flipping, brightness
- 80/20 train/validation split with random seed
- Google Colab T4 GPU acceleration
Deployment Features
- Gradio web interface with drag-and-drop upload
- Real-time inference with confidence scores
- Top-3 predictions with probability bars
- Responsive mobile-friendly UI
- Hugging Face Spaces free hosting
- Public API endpoint for programmatic access
Try It Yourself
Upload a flower image to see real-time classification with confidence scores.
Upload images of daisies, dandelions, roses, sunflowers, or tulips for best results.
Project Resources
Access the complete codebase, tutorial, and interactive notebook.