Visual Search
Last updated: Nov-12-2023
Visual Search enables you to find images based on their visual content, as opposed to their public ID or metadata, and is a powerful way to find products, places, people, and things in images that are visually similar. The search analyzes the contents of the image rather than any of its metadata information. The contents of the image in this context might refer to colors, shapes, textures, or any other information that can be derived from the image itself.
Searching for images based on visual similarity rather than by metadata allows you to:
- Find images even if they aren't tagged or named descriptively.
- Find duplicates.
- Find images by visual characteristics that might not be included in a description.
- Gather images that are similar in appearance.
- Increase the discoverability of your images.
You can execute a visual search either by image or by text:
- Visual Search by image: Allows you to find matches to a certain image in your product environment or to a remote image via a given URL. For example, you can select an image of a young woman wearing a red shirt, and images with similar characteristics will be returned.
-
Visual Search by text: Allows you to type in a word or phrase to find images that visually match the concept you described. For example, if you type the phrase
red shirt
, images that visually represent that concept will be displayed.
Visual Search method
visual_search = true
parameter when uploading or updating the asset. You can also set up an upload preset to index your images when uploading them.To execute a visual search, use the visual_search
method of the Admin API, and provide it with one of the following parameters:
-
image_url
- The URL of an image. -
image_asset_id
- Theasset_id
of an image in your product environment. -
text
- A textual description, e.g., “shirts”
Visual Search examples
-
Execute a visual search for 'footwear':
-
Execute a visual search using the remote URL of an image 'https://www.example.com/sample.jpg':
Visual Search response
The response returns the assets in order of relevance, from most to least similar:
Indexing images using an upload preset
You can use the upload_preset
method of the Admin API to create upload presets, either via a REST API call, or by using any of our backend SDKs. If you don't have a server-side application, you can create upload presets programmatically using the Cloudinary CLI.
To index an image via an upload preset, add the visual_search
boolean parameter and set it to true
when you create your upload preset. For example, the following code creates a new unsigned upload preset called visual_search, that indexes uploaded images: