DEV Community

loading...
Cover image for Build an image similarity search app in 5 minutes
NeuML

Build an image similarity search app in 5 minutes

davidmezzetti profile image David Mezzetti ・1 min read

This article shows how we can quickly stand up an image similarity search app using txtai and Streamlit.

sentence-transformers recently added support for the OpenAI CLIP model. This model embeds text and images into the same space, enabling image similarity search. txtai can directly utilize these models.

Image search

Install dependencies

Install txtai and all dependencies.

pip install git+https://github.com/neuml/txtai streamlit torchvision

# Get test data
wget -N https://github.com/neuml/txtai/releases/download/v2.0.0/tests.tar.gz
tar -xvzf tests.tar.gz

# Get application script
wget https://raw.githubusercontent.com/neuml/txtai/master/examples/images.py
Enter fullscreen mode Exit fullscreen mode

Start the application

Start the application and search. The application takes a single command line argument to a directory of images. Run it against your own images and explore the results!

streamlit run images.py txtai/
Enter fullscreen mode Exit fullscreen mode

Discussion (0)

pic
Editor guide