
Photo via editor Chatgpt
# Entry
We were all there: we scroll endlessly through online stores, trying to find it perfect item. In today’s instant e-commerce world we expect immediate results and it will enter the thoroughly there to shake.
The heart of this revolution is to embed the image. This is a fancy term for a straightforward idea: allowing you to search for products not only according to keywords, but by them Visual similarity. Imagine that he found the exact dress you saw on social media, just sending a photo! This technology makes online shopping smarter, more intuitive, and ultimately helps companies boost sales.
Ready to see how it works? We will show you how to employ the Bigquery machine learning power to build your own search of dresses based on AI using these amazing embedded images.
# Magic of image deposition
Basically, embedding images is a process of transforming images into numerical representations (vectors) in a high -dimension space. Images that are semantically similar (e.g. a blue ball dress and a navy blue dress) will have vectors that are “closer” to themselves in this space. This allows for powerful comparisons and searching that go beyond straightforward metadata.
Here are some photos that we will employ in this demo to generate deposition.

The demo illustrates the process of creating a model for embedding images on Google Cloud.
The first step is to create a model: Model called image_embeddings_model It is created that it uses multimodalembedding@001 end point image_embedding Data set.
CREATE OR REPLACE MODEL
`image_embedding.image_embeddings_model`
REMOTE WITH CONNECTION `[PROJECT_ID].us.llm-connection`
OPTIONS (
ENDPOINT = 'multimodalembedding@001'
);
Creating a table of objects: To process images in Bigquery, we’ll create an external table called external_images_table In image_embedding A data set that will appeal to all images stored in a Google Cloud Storage bucket.
CREATE OR REPLACE EXTERNAL TABLE
`image_embedding.external_images_table`
WITH CONNECTION `[PROJECT_ID].us.llm-connection`
OPTIONS(
object_metadata="SIMPLE",
uris = ['gs://[BUCKET_NAME]/*'],
max_staleness = INTERVAL 1 DAY,
metadata_cache_mode="AUTOMATIC"
);
Generating prisoners: After entering the table of the model and objects dress_embeddings.
CREATE OR REPLACE TABLE `image_embedding.dress_embeddings` AS SELECT *
FROM ML.GENERATE_EMBEDDING(
MODEL `image_embedding.image_embeddings_model`,
TABLE `image_embedding.external_images_table`,
STRUCT(TRUE AS flatten_json_output,
512 AS output_dimensionality)
);
# Freeing the power of vectors’ search
Thanks to the generated painting images, we will employ a vector search to find a dress we are looking for. Unlike established search, which is based on precise keywords, vector search finds elements based on the similarity of their prisoners. This means that you can search for images using text descriptions or even other images.
// Searching for clothes through the text
Taking a text search: Here we will employ VECTOR_SEARCH Bigquery function to search for a “blue dress” among all dresses. The text “Blue dress” will be converted to a vector, and then with a vector search we will download similar vectors.
CREATE OR REPLACE TABLE `image_embedding.image_search_via_text` AS
SELECT base.uri AS image_link, distance
FROM
VECTOR_SEARCH(
TABLE `image_embedding.dress_embeddings`,
'ml_generate_embedding_result',
(
SELECT ml_generate_embedding_result AS embedding_col
FROM ML.GENERATE_EMBEDDING
(
MODEL`image_embedding.image_embeddings_model` ,
(
SELECT "Blue dress" AS content
),
STRUCT
(
TRUE AS flatten_json_output,
512 AS output_dimensionality
)
)
),
top_k => 5
)
ORDER BY distance ASC;
SELECT * FROM `image_embedding.image_search_via_text`;
Results: The results of the inquiry will ensure image_link and distance for each result. You can see how you get the results, they’ll give you the next search match and available dresses.


// Searching for clothes with a picture
Now we will look at how we can employ the image to find similar images. Let’s try to find a dress that looks like the image below:


External table for the test image: We will have to store a test image in a Google Cloud Storage bucket and create an external table external_images_test_tableTo store a test image used for search.
CREATE OR REPLACE EXTERNAL TABLE
`image_embedding.external_images_test_table`
WITH CONNECTION `[PROJECT_ID].us.llm-connection`
OPTIONS(
object_metadata="SIMPLE",
uris = ['gs://[BUCKET_NAME]/test-image-for-dress/*'],
max_staleness = INTERVAL 1 DAY,
metadata_cache_mode="AUTOMATIC"
);
Generate a test images: Now we will generate the deposition of this single test image with ML.GENERATE_EMBEDDING function.
CREATE OR REPLACE TABLE `image_embedding.test_dress_embeddings` AS
SELECT *
FROM ML.GENERATE_EMBEDDING
(
MODEL `image_embedding.image_embeddings_model`,
TABLE `image_embedding.external_images_test_table`, STRUCT(TRUE AS flatten_json_output,
512 AS output_dimensionality
)
);
Vector search with image deposition: Finally, deposition of the test image will be used to conduct a vector search with image_embedding.dress_embeddings table. . ml_generate_embedding_result With image_embedding.test_dress_embeddings It will be used as an inquiry.
SELECT base.uri AS image_link, distance
FROM
VECTOR_SEARCH(
TABLE `image_embedding.dress_embeddings`,
'ml_generate_embedding_result',
(
SELECT * FROM `image_embedding.test_dress_embeddings`
),
top_k => 5,
distance_type => 'COSINE',
options => '{"use_brute_force":true}'
);
Results: The results of the inquiry for the image search showed the most visually similar dresses. The best result was white-dress with a distance of 0.2243, and then sky-blue-dress with a distance of 0.3645 i polka-dot-dress with a distance of 0.3828.

These results clearly show the possibility of finding visually similar elements based on the input image.
// Influence
This demonstration effectively illustrates how images and searching for vectors in Google Cloud can revolutionize the way of interaction with visual data. From e-commerce platforms enabling “buy similar” functions to content management systems offering an wise discovery of visual resources, the applications are huge. By transforming images into vectors that you can search, these technologies unlock a novel search dimension, making it more intuitive, powerful and visually wise.
These results can be presented to the user, enabling them to quickly find the desired dress.
# Benefits of searching for AI dresses
- Improved user experiences: Visual search provides users with a more intuitive and proficient way to find what they are looking for
- Improved accuracy: imitating images Turn on a search based on visual similarity, providing more appropriate results than established search -based search
- Increased sales: by making it easier for customers to find desired products, searching for AI dresses can boost conversions and boost revenues
# Apart from searching for a dress
By combining the power to embed the image with solid Bigquery data processing options, you can create groundbreaking solutions based on artificial intelligence that transform the method of interaction with visual content. From electronic trade to content moderation, the power to deposit images and bigquery extends outside of searching for clothes.
Here are some other potential applications:
- E-commerce: product recommendations, visual search for other product categories
- Fashion design: trend analysis, design inspiration
- Content moderation: Identification of improper content
- Detection of copyright violation: finding similar visually images to protect intellectual property
Learn more about Embeddings on Bigquery Here and vector search Here.
Novedita kumari He is an experienced data analysis and professional intelligence professional with over 10 years of experience. In his current role, as a customer engineer of data analysis on Google, he is constantly involved in directors at level C and helps them architect data solutions and leads them to the best practices to create data and machine learning solutions in Google Cloud. Nivedita made a master’s degree in technology, focusing on the analysis of data from the University of Illinois at Urbana-Champaign. He wants to democratize machine learning and artificial intelligence, spreading technical barriers so that everyone can be part of this transformation technology. He shares his knowledge and experience with the programmers’ community, creating tutorials, guides, opinions and coding shows.
Connect to Nivedit on LinkedIn.
