This is a simple web application built with Flask, TensorFlow, and OpenCV to classify images as either a dog or a cat. The model used for classification is a Convolutional Neural Network (CNN) trained on a dog vs cat dataset.
- Upload an image (PNG, JPG, or JPEG format) of a dog or a cat.
- The model classifies the image as either "Dog" or "Cat".
- Flask-based web interface for user interaction.
- Backend: Flask (Python web framework)
- Machine Learning: TensorFlow, Keras
- Image Processing: OpenCV
- Deployment: Heroku (or any other preferred platform)
Before running the application, make sure you have the following installed:
- Python 3.7+
- pip (Python package installer)
Follow these steps to run the project on your local machine:
- Clone the repository:
- Navigate to the project directory:
- cd dog-vs-cat-classification
- Create and activate a virtual environment (optional but recommended):
- On Windows:
- python -m venv venv
- .\venv\Scripts\activate
- On macOS/Linux:
- python -m venv venv
- source venv/bin/activate
- Install the required dependencies:
- pip install -r requirements.txt
To run the app locally, use the following command:
- python app.py
- Visit http://127.0.0.1:5000 in your browser to interact with the application.
- Open the application in your web browser.
- Upload an image of a dog or a cat.
- The model will process the image and display whether the image is a "Dog" or "Cat".
The model used for classification is a pre-trained Keras model (dog_vs_cat_classification.h5). If you want to retrain the model, follow these steps:
- Gather a dataset of dog and cat images.
- Preprocess the images (resize to 224x224 and normalize).
- Train a Convolutional Neural Network (CNN) on the dataset using Keras/TensorFlow.
- Save the model as dog_vs_cat_classification.h5 and place it in the project directory.