A deep learning-powered web application that classifies flower images using a Convolutional Neural Network (CNN). Upload an image and instantly identify whether it's a daisy, sunflower, tulip, dandelion, or rose with confidence scores.
- Real-time Classification: Upload flower images and get instant predictions
- 5 Flower Types: Classifies daisy, sunflower, tulip, dandelion, and rose
- Confidence Scores: View probability distribution across all classes
- Modern UI: Clean, responsive web interface with dark mode design
- Fast API Backend: Built with FastAPI for high performance
- Deep Learning Model: Custom CNN architecture trained for flower recognition
Upload any flower image and the model will:
- Process the image
- Classify it into one of 5 categories
- Display confidence percentages for each class
- FastAPI - Modern, fast web framework
- TensorFlow/Keras - Deep learning framework
- Pillow - Image processing
- Uvicorn - ASGI server
- NumPy - Numerical computations
- HTML5 - Structure
- CSS3 - Modern styling with gradients and animations
- Vanilla JavaScript - Interactive functionality
- Architecture: Custom CNN with 4 convolutional layers
- Input Size: 64x64 RGB images
- Layers: Conv2D, BatchNormalization, MaxPooling, Dropout, Dense
- Output: 5-class softmax classification
- Python 3.8 or higher
- pip package manager
- Clone the repository
git clone https://github.com/yourusername/flower_detection_classification.git
cd flower_detection_classification-main- Install backend dependencies
cd backend
pip install -r requirements.txt- Verify model file exists
Ensure
models/my_model_exp2.h5is present in the backend directory.
- Start the Backend Server
cd backend
python app.pyBackend will run on http://localhost:8000
- Start the Frontend Server
cd frontend
python -m http.server 5500Frontend will run on http://localhost:5500
- Open your browser
Navigate to
http://localhost:5500and start classifying flowers!
- GET
/health- Health check endpoint - POST
/predict- Upload image for classification
Example API usage:
curl -X POST "http://localhost:8000/predict" \
-H "Content-Type: multipart/form-data" \
-F "file=@flower.jpg"Response:
{
"prediction": "rose",
"confidence": 0.9523,
"probabilities": {
"daisy": 0.0123,
"sunflower": 0.0089,
"tulip": 0.0156,
"dandelion": 0.0109,
"rose": 0.9523
}
}Conv2D (32 filters, 5x5) β BatchNorm β MaxPool2D
β
Conv2D (64 filters, 3x3) β BatchNorm β MaxPool2D
β
Conv2D (96 filters, 3x3) β BatchNorm β MaxPool2D
β
Conv2D (96 filters, 3x3) β BatchNorm β MaxPool2D
β
Flatten β Dense(512) β BatchNorm β Dropout(0.5)
β
Dense(5, softmax)
Input Shape: (64, 64, 3)
Output: 5 classes with probability distribution
- πΌ Daisy
- π» Sunflower
- π· Tulip
- πΌ Dandelion
- πΉ Rose
- Drag-and-drop image upload
- Image preview before prediction
- Real-time confidence visualization
- Responsive design for all devices
- Modern dark-mode UI with gradients
- Smooth animations and transitions
flower_detection_classification-main/
βββ backend/
β βββ app.py # FastAPI application
β βββ requirements.txt # Python dependencies
β βββ models/
β βββ my_model_exp2.h5 # Trained CNN model
βββ frontend/
β βββ index.html # Web interface
βββ Copy_of_EXP_FLOWER_CNN_F1.ipynb # Model training notebook
βββ README.md
MODEL_PATH- Path to the model file (default:models/my_model_exp2.h5)
The backend is configured to accept requests from http://localhost:5500. Update in app.py if needed:
allow_origins=["http://localhost:5500"]Free hosting specifically for ML models with unlimited usage.
Free tier with auto-deployment from GitHub.
Build and deploy as a container:
docker build -t flower-classifier .
docker run -p 8000:8000 flower-classifierContributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Your Name - @mukesh-843
- TensorFlow and Keras teams for the amazing framework
- FastAPI for the excellent web framework
- Flower dataset contributors
For questions or feedback, please open an issue or reach out via email.
β Star this repository if you found it helpful! β