Skip to content

Bazifrasool/Reverse_Image_Search

Repository files navigation


Reverse Image Search !

A Deep Learning based image retrieval tool!

home results

Table of Contents
  1. About the Project
  2. Getting Started
  3. Usage
  4. Contact

About The Project

This is a ResNet50 based reverse image lookup tool , that can help you find similar images in a large database.
It used 2048 dimenional vector representation of images to compare two similar using cosine distance, It uses hdf5 for storing features.
It is implemented as a class that has two funtions that can be called :

  • generate_feature_embeddings with arguments (database path , batch size) - This generates the 2048 dimensional vector representations and saves them in an hdf5 file
  • query with arguments number of results , path of the picture being queried , path of databse. This returns a list of filenames in the database which are similar to the queried picture

It has been dockerised , and has flask support for deployment.

Getting Started

How to setup on your machine

Prerequisites

It has been tested on Windows and Linux, although it can run on macOS with little or no modification.
Tensorflow,keras has been omitted in the requirements.txt , user can opt for tensorflow-gpu(recomended) or tensorflow-cpu and pip install keras
Docker-> if you want to run a simple image without the fuss or setting up everything.

Installation

Docker

  1. Clone the repo and Change directory
    git clone https://github.com/your_username_/Project-Name.git
    cd Reverse_Image_Search/
  2. Build Docker Image
    docker build --tag <IMAGE-NAME-YOU-WANT> .
  3. Run Docker Container
    docker run -it -e GENEMBED=<TRUE or FALSE> -v path/to/database:/usr/share/reverseimagesearch/database -v path/to/uploads_folder:/usr/share/reverseimagesearch/uploads -p <port you want to use>:7000 --name reverseimagesearch_container <IMAGE-NAME-YOU-WANT>
    An example would be
    docker run -it -e GENEMBED=TRUE -v $(pwd)/database:/usr/share/reverseimagesearch/database -v $(pwd)/uploads:/usr/share/reverseimagesearch/uploads -p 5000:7000 --name reverseimagesearch_container reverseimagesearch_image

Direct API

  1. Clone the repo and Change directory
git clone https://github.com/your_username_/Project-Name.git
cd Reverse_Image_Search/
  1. install required python packages (install tensorflow gpu if you want fast performance)
    pip install -r requirements.txt
    pip install tensorflow-cpu 
    pip install keras
  2. Run model_api_class.py to test api functionality
    python3 model_api_class.py <path to database> <path to query picture>
    An example would be
     python3 model_api_class.py ./database ./query_pic.jpg

Important !!

Currently there is no error handling in the file io as in
if the database has a non image type , then the program will simply break

Your system may need some dependencies for opencv to work, look up how to setup opencv for your machine

Contact

Bazif Rasool - @BazifRasool - baziflaherwal@gmail.com

About

A fully Dockerised Flask enabled Deep ResNet50 based Reverse Image Lookup with HDF5 based feature cataloging for fast and efficient image retrieval

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors