Skip to main content
Go to documentation:
⌘U
Weaviate Database

Develop AI applications using Weaviate's APIs and tools

Deploy

Deploy, configure, and maintain Weaviate Database

Weaviate Agents

Build and deploy intelligent agents with Weaviate

Weaviate Cloud

Manage and scale Weaviate in the cloud

Additional resources

Integrations
Contributor guide
Events & Workshops
Weaviate Academy

Need help?

Weaviate LogoAsk AI Assistant⌘K
Community Forum

Image search

Image search uses an image as a search input to perform vector similarity search.

Additional information

Configure image search

To use images as search inputs, configure an image vectorizer integration for your collection. See the model provider integrations page for a list of available integrations.

By local image path

Use the Near Image operator to execute image search.
If your query image is stored in a file, you can use the client library to search by its filename.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
from pathlib import Path

dogs = client.collections.use("Dog")
response = dogs.query.near_image(
near_image=Path("./images/search-image.jpg"), # Provide a `Path` object
return_properties=["breed"],
limit=1,
# targetVector: "vector_name" # required when using multiple named vectors
)

print(response.objects[0])

client.close()
Example response

By the base64 representation

You can search by a base64 representation of an image:

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
base64_string="SOME_BASE_64_REPRESENTATION"

# Get the collection containing images
dogs = client.collections.use("Dog")

# Perform query
response = dogs.query.near_image(
near_image=base64_string,
return_properties=["breed"],
limit=1,
# targetVector: "vector_name" # required when using multiple named vectors
)

print(response.objects[0])

client.close()
Example response
{
"data": {
"Get": {
"Dog": [
{
"breed": "Corgi"
}
]
}
}
}

client.close()

Create a base64 representation of an online image

You can create a base64 representation of an online image, and use it as input for similarity search as shown above.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
import base64, requests

def url_to_base64(url):
image_response = requests.get(url)
content = image_response.content
return base64.b64encode(content).decode("utf-8")

base64_img = url_to_base64("https://upload.wikimedia.org/wikipedia/commons/thumb/1/14/Deutsches_Museum_Portrait_4.jpg/500px-Deutsches_Museum_Portrait_4.jpg")

client.close()

Combination with other operators

A Near Image search can be combined with any other operators (like filter, limit, etc.), just as other similarity search operators.

See the similarity search page for more details.

Questions and feedback

If you have any questions or feedback, let us know in the user forum.