This project demonstrates a real-time cat/dog image classification system using Kafka and a pre-trained CNN model.
- Python 3.7+
 - Apache Kafka
 - Git
 
- 
Clone the repository:
git clone https://github.com/yourusername/kafka-image-classifier.git cd kafka-image-classifier - 
Set up Kafka: Follow the instructions in KafkaSetup.md to install and configure Kafka.
 - 
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate` - 
Install dependencies:
pip install -r requirements.txt - 
Ensure
dogcatclassifier.h5(the pre-trained model) is in the project root directory. 
The system consists of three main components:
- Receiver-Predictor: Processes images and makes predictions.
 - Sender: Allows you to send images for classification.
 - Result Consumer: (Optional) Displays classification results in real-time.
 
In a terminal, run:
python receiver_predictor.py
This will continuously wait for images on the Kafka topic.
In another terminal, run:
python sender.py
- You'll be prompted to enter paths to image files.
 - Enter the full path to an image when prompted.
 - Type 'quit' to exit the sender program.
 
To see predictions in real-time, open a third terminal and run:
python result_consumer.py
- 
Ensure Kafka is running (refer to KafkaSetup.md).
 - 
Open three terminal windows and navigate to the project directory in each.
 - 
In Terminal 1, start the receiver-predictor:
python receiver_predictor.py - 
In Terminal 2, start the sender:
python sender.py - 
(Optional) In Terminal 3, start the result consumer:
python result_consumer.py - 
In the sender terminal (Terminal 2), enter an image path when prompted:
Enter the path to the image (or 'quit' to exit): /path/to/your/cat_image.jpg - 
View the results in Terminal 1 (receiver-predictor) or Terminal 3 (result consumer).
 - 
Repeat step 6 with different images as desired.
 - 
Type 'quit' in Terminal 2 (sender) to exit.
 
- Verify Kafka is running correctly (check KafkaSetup.md).
 - Ensure 
dogcatclassifier.h5is present in the project root. - Verify all dependencies are installed (
pip list). - Check that the image paths you enter exist and are accessible.
 
- To use a different model, replace 
dogcatclassifier.h5and updatereceiver_predictor.pyif needed. - Kafka topics and server addresses can be modified in the scripts if required.