This project implements a Flask web application for image classification using a pre-trained Convolutional Neural Network (CNN) model. Users can upload images and receive predictions about their content.
- Image Upload: Users can conveniently upload images through the application's interface.
- Image Prediction: Leverages a pre-trained Keras model with loaded checkpoint weights to predict the class of the uploaded image.
- Error Handling: Ensures graceful handling of errors and provides informative messages to users.
- Easy Deployment: Allows for straightforward deployment on platforms like Render with minimal configuration.
- Clone the Repository:
git clone https://github.com/your_username/cnn-image-detection.git
cd cnn-image-detection- Install Dependencies:
pip install -r requirements.txt- Run the Application:
python app.py- Access the Application:
Open a web browser and navigate to http://localhost:5000 to interact with the application.
- Visit the application in your web browser.
- Select and upload an image using the provided interface.
- The application will process the image and display the predicted class.
- Flask: Web framework for building the user interface and handling user interactions.
- TensorFlow/Keras: Deep learning libraries used for model development and image prediction.
- (Optional) Render: Cloud platform for deploying the application (alternatives exist).
- Python 3.x
- Flask
- TensorFlow
- Keras
- Pillow (PIL Fork)
- NumPy
- Install Required Libraries:
pip install flask tensorflow keras pillow numpy-
Configure the Application:
- Replace placeholders in the code:
MODEL_PATH: Path to your saved model architecture (.h5file).CHECKPOINT_PATH: Path to your saved checkpoint weights (.h5file).TARGET_NAMES: List of class names corresponding to your model's output (adjust accordingly).
- Modify the
preprocess_imagefunction if needed for specific image preprocessing (e.g., normalization parameters).
- Replace placeholders in the code:
-
Create User Interface:
- Develop an HTML template (
index.html) for the user interface, including a form for uploading images and displaying prediction results.
- Develop an HTML template (
- This code serves as a basic example. Adapt it to your specific model and requirements.
- Implement robust error handling to gracefully handle user input errors or unexpected issues.
For production deployment, consider using web servers like Gunicorn or cloud platforms.
This project is licensed under the MIT License (see the LICENSE: LICENSE file for details).