Find similar images by giving a reference image.
This project implements an image similarity search application using a FastAPI backend and a Streamlit frontend. The application allows users to upload a reference image and a directory of other images, and it retrieves the most similar images based on a specified similarity threshold.
- Upload a reference image and a directory of other images
- Calculate image embeddings using a pre-trained ResNet50 model
- Compute similarity scores between the reference image and other images
- Display the most similar images based on a user-defined similarity threshold
- Visualize similarity scores using a bar chart with thumbnail images
-
Make sure you have Docker and Docker Compose installed on your system.
-
Clone the repository:
git clone https://github.com/sukumar45/image_similarity_search.git
- Navigate to the project directory:
cd image_similarity_search
- Pull the Docker images for the API and client:
docker pull sukumar2112/image_similarity_search:api
docker pull sukumar2112/image_similarity_search:client
- Start the application using Docker Compose:
docker-compose up
- Open a web browser and go to http://localhost:8501 to access the Streamlit application.
- Clone the repository:
git clone https://github.com/sukumar45/image_similarity_search.git
- Navigate to the project directory:
cd image_similarity_search
- Install the required dependencies for the FastAPI backend:
cd api
pip install -r requirements.txt
- Install the required dependencies for the Streamlit frontend:
cd ../client
pip install -r requirements.txt
- Start the application using Docker Compose:
docker-compose up
- Open a web browser and go to http://localhost:8501 to access the Streamlit application.
- Start the FastAPI backend:
cd api
uvicorn main:app --reload
- In a new terminal, start the Streamlit frontend:
cd client
streamlit run streamlit_client.py
-
Open a web browser and go to http://localhost:8501 to access the Streamlit application.
-
Upload a reference image using the file uploader.
-
Enter the directory path containing the other images you want to compare.
-
Adjust the similarity score threshold using the slider.
-
The application will display the most similar images based on the selected threshold.
-
A bar chart will visualize the similarity scores along with thumbnail images.
- Upload a reference image.
- Enter the directory path containing a collection of animal images. (Set directory path to
/app/testwhen using docker-compose to use the included test directory) - Set the similarity score threshold to 0.7.
- The application will display the most similar images from the provided directory.
- The bar chart will show the similarity scores and thumbnails of the retrieved images.
- Add a prompt box to take user prompts to filter the images.
api/: Contains the FastAPI backend code and model weights.main.py: FastAPI application entry point.model.py: Image embedding generation using ResNet50.resnet50-11ad3fa6.pth: Pre-trained ResNet50 model weights.client/: Contains the Streamlit frontend code.test: Folder containing images for testing the appstreamlit_client.py: Streamlit application code.
Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.
This project is licensed under the MIT License.



