This repository contains an end-to-end pipeline for classifying animal images into one of 90 species and performing image similarity searches. The project leverages a deep convolutional neural network (ResNet-50) as a feature extractor, combined with a custom embedding layer and a final classification head. Additionally, it includes a frontend interface for users to upload an image and receive both a predicted class and visually similar images from the dataset.
Model Architecture:
Dataset:
Animal Image Dataset - 90 Different Animals
This dataset covers a wide variety of animal species, ensuring a broad representation across 90 classes.
Training Details:
Performance Metrics:
These metrics indicate strong classification performance on the dataset.
A confusion matrix (confusion_matrix.png) is included to visualize class-by-class performance.

In addition to classification, this solution provides an image similarity search feature:
Feature Extraction:
Each dataset image is passed through the model (ResNet-50 + embedding layer) to produce a 256-dimensional feature vector.
Database Storage (SQLite):
All 256-dimensional feature vectors are stored in an SQLite database.
Similarity Query:
When a new image is uploaded, its embedding is computed, and the database is queried to find the most similar images based on vector similarity.
This enables you to not only predict the class of an uploaded image but also retrieve visually similar images from the existing dataset.
A simple frontend is included to facilitate interaction:
.
├── requirements.txt # Python dependencies
├── README.md # This README file
├── .gitignore # Git ignore file
├── LICENSE # License file for the project
├── main.py # Entry point for the Flask application
├── model.py # Model definition, loading, and inference utilities
├── similarity.py # Functions for similarity search and confusion matrix creation
└── train.py # Training script for the model
├── templates/
│ ├── index.html # Frontend template
└── confusion_matrix.png # Confusion matrix visualization git clone https://github.com/git-khandelwal/image-similarity
cd image-similarity pip install -r requirements.txtDownload and Prepare Dataset:
Model Training: To retrain the model and create feature vector db:
python train.py python main.pyThis project is licensed under the MIT License.