A simple Machine Learning project that predicts whether an image contains a Cat or a Dog 🐱🐶
This project demonstrates how a trained classification model can identify whether an input image is of a cat or a dog. It includes:
- Image loading and preprocessing
- Prediction using a pre-trained model
- Visualization of the input image and classification probabilities
├── SCT_ML_3.py # Main Python script for prediction
├── cat_image_display.png # Input image used for testing
├── cat_prediction_result.png # Graph showing predicted probabilities
└── dataset/
└── test_set/
├── cats/
└── dogs/
Install all dependencies using pip:
pip install numpy matplotlib scikit-image scikit-learnYou’ll also need a trained model file and a category list such as:
model = trained_model # Pre-trained model
Categories = ['Cat', 'Dog']path = 'dataset/test_set/dogs/dog.4001.jpg'
img = imread(path)
plt.imshow(img)
plt.axis('off')
plt.show()Resize and flatten the image for model input.
img_resize = resize(img, (150, 150, 3))
l = [img_resize.flatten()]probability = model.predict_proba(l)
for ind, val in enumerate(Categories):
print(f'{val} = {probability[0][ind] * 100:.2f}%')
predicted_label = model.predict(l)[0]
print("The predicted image is : " + Categories[predicted_label])✅ Prediction: Cat (90%) ❌ Dog: 10%
- 🔁 Add more animal categories
- 🧠 Use Convolutional Neural Networks (CNNs) for higher accuracy
- 📸 Add real-time webcam image detection
- 🌐 Create a web app using Flask or Streamlit
Kamalhiiny Gopi 💼 Passionate about Machine Learning & AI 📧 gkamalhiiny07@gmail.com
If you like this project, give it a ⭐ on GitHub and share it!

