Skip to content

exploringweirdmachines/find-Ilya

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

find-Ilya

Using an image to find similar images. More accurate description would be "image-to-image" search tool, but also a "text-to-image" search tool.

Usage

usage: main.py [-h] [-v] COMMAND ...

Tool which finds images in the target folder, given text or an image as input.

options:
  -h, --help     show this help message and exit
  -v, --version  show program's version number and exit

Commands:
  COMMAND
    create_db    Create a new FAISS database
    search_db    Search a database for an image

You can also see help for the commands like 'main.py searchdb -h'
usage: main.py search_db [-h] -d DB_PATH (-i IMAGE_QUERY | -t TEXT_QUERY)

options:
  -h, --help            show this help message and exit
  -d DB_PATH, --db_path DB_PATH
                        Path to the FAISS database
  -i IMAGE_QUERY, --image_query IMAGE_QUERY
                        Path to the target image used to search for images
  -t TEXT_QUERY, --text_query TEXT_QUERY
                        Text query used to search for images

First you have to index a folder containing a set of images. This command will create a FAISS database in the target folder, 'examples/vector_database', will add entries in the database using the filename of each picture and also the corresponding embeddings:

poetry run main.py create_db -f examples/images -o examples/vector_database

Then you can search for similar images like this:

poetry run python main.py search_db -d examples/vector_database/ -i examples/target_image/Ilya.png

Ilya.png

Examples

Given the input image found in 'examples/target_image/Ilya.png'

Command:

poetry run python main.py search_db -d examples/vector_database/ -i examples/target_image/Ilya.png

Input image

Ilya.png

Output

output ilya.png


The images are found in 'examples/images':

Score: 90.14% for 'examples/images/Ilya s.png'
Ilya s.png

Score: 83.3%; for 'examples/images/team openai.png'
team openai.png

Score: 80.64%; for 'examples/images/team.png'
team.png



Another example with some other image as input, such as:
'examples/target_image/moon.png'

Command:

poetry run python main.py search_db -d examples/vector_database/ -i examples/target_image/moon.png

Input image

moon.png

Output

output moon.png


The images are found in 'examples/images':

Score: 92.49% for 'examples/images/moontree.png'
moontree.png

Score: 84.37%; for 'examples/images/tree.png'
tree.png

Score: 84.31%; for 'examples/images/some tree.jpg'
some tree.jpg



Another example with text as input, such as:

Command:

poetry run python main.py search_db -d examples/vector_database/ -t "car inside a building"

Output

text_search.png

Dataset

These are the images you can find in 'examples/images' folder: images_dataset.png

Requirements

My setup is:

WIN 10 + nvidia drivers 522 + cuda 11.8 + WSL2 with Ubuntu 22.04 with cuda tools + WSL default python installation >=3.10

poetry install

About

Example of image-to-image search. Bonus: text-to-image search.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages