Get similar images
This tool is a wrapper over an API that returns URLs and similarity scores for similar images for a given image.
You can find a demo of the tool here.
The description of the API can be found here.
Installation
pip install -U getsimilarGet an API token
- Log in at: https://ternaus.com/login
- Go to the account page: https://ternaus.com/account
- Generate new token and save json file with it to
~/.ternaus/ternaus.json
Usage
You pass:
- Image in the form of the
numpyarray orPILimage. - URL to the image:
- Text query, for example: "Girls in weird hats"
Optional parameters:
-
num_similarthat specifies the number of similar images to return. This number is capped at 50. If you would like to get more similar images per request, please contact us at https://www.ternaus.com/#contact. default value is 1. -
get_labelsthat specifies whether to return labels for the image. default value is None. Right now onlycoco_yolov7is supported.`
From image
from getsimilar.get import from_image
urls = from_image( < numpy or PIL
image >, num_similar = < the
number
of
similar
images >)From URL
from getsimilar.get import from_url
urls = from_url(url, num_similar= < the
number
of
similar
images >)From text
from getsimilar.get import from_text
urls = from_text(text, num_similar= < the
number
of
similar
images >)