tonyassi/images-ds
Viewer • Updated • 1.02k • 25
Use text prompt to search for images in folders. It can search through folders within folders. Built with 🤗 Transformers and 🤗 Datasets.
We'll use my ImageSearch module on Github.
Download code from Github
git clone https://github.com/TonyAssi/ImageSearch.git
cd ImageSearch
Install the required libraries:
pip install -r requirements.txt
Import the module
from ImageSearch import ImageSearch
Define folder path
image_search = ImageSearch(image_dir='images',
hf_key='HF_KEY')
The first time this is called the images will be converted to a 🤗 Dataset and it'll get uploaded to the 🤗 Hub. It'll print out the dataset id and store it in a meta.text file. It should look like tonyassi/images-ds. It'll take a little longer the first time it's called. After the dataset is created it should be very quick.
Search for image with text prompt
image_search.search(text='red rose',
download_path = 'found_images',
num=5)
The most similar images will be printed and downloaded.
flowers/0092.png
Score: 142.48643
Index: 0
flowers/0105.png
Score: 146.4621
Index: 1
flowers/0095.png
Score: 148.10144
Index: 2