---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://mixpeek.com/.well-known/search?q={query}"
  method: GET
  documentation: "https://mixpeek.com/llms.txt"
---

1.  [](/)
2.  [Code examples](/recipes)
3.  Visual Similarity Search

Back to code examples

# Visual Similarity Search

Unified visual similarity search across both images and video frames. Query with a photo, screenshot, or frame to discover visually related content regardless of format, with MMR diversification to ensure variety in results.

image

video

Multi-Tier

[Run in Builder](/build?recipe=visual-similarity-search)

Python

cURL

from mixpeek import Mixpeek

client \= Mixpeek(api\_key\="YOUR\_API\_KEY", namespace\="visual-assets")

\# 1. Buckets for images and for videos, and a multimodal\_extractor collection over each

images \= client.buckets.create(

    bucket\_name\="image-assets",

    bucket\_schema\={

        "properties": {

            "image": {

                "type": "image",

            },

        },

    },

)

videos \= client.buckets.create(

    bucket\_name\="video-assets",

    bucket\_schema\={

        "properties": {

            "video": {

                "type": "video",

            },

        },

    },

)

image\_col \= client.collections.create(

    collection\_name\="image\_assets",

    source\={"type": "bucket", "bucket\_ids": \[images\["bucket\_id"\]\]},

    feature\_extractor\={

        "feature\_extractor\_name": "multimodal\_extractor",

        "version": "v1",

    },

)

video\_col \= client.collections.create(

    collection\_name\="video\_assets",

    source\={"type": "bucket", "bucket\_ids": \[videos\["bucket\_id"\]\]},

    feature\_extractor\={

        "feature\_extractor\_name": "multimodal\_extractor",

        "version": "v1",

    },

)

\# 2. Upload and process

client.buckets.upload(

    images\["bucket\_id"\],

    blobs\=\[{"property": "image", "type": "image", "data": "s3://your-bucket/images/hero-shot.jpg"}\],

)

client.buckets.upload(

    videos\["bucket\_id"\],

    blobs\=\[{"property": "video", "type": "video", "data": "s3://your-bucket/videos/campaign-cut.mp4"}\],

)

client.collections.trigger(image\_col\["collection\_id"\])

client.collections.trigger(video\_col\["collection\_id"\])

\# 3. One image query across both collections, diversified with MMR

retriever \= client.retrievers.create(

    retriever\_name\="visual-similarity",

    collection\_identifiers\=\["image\_assets", "video\_assets"\],

    input\_schema\={

        "image": {

            "type": "image",

            "required": True,

        },

    },

    stages\=\[

        {

            "stage\_name": "search",

            "stage\_id": "feature\_search",

            "parameters": {

                "searches": \[

                    {

                        "feature\_uri": "mixpeek://multimodal\_extractor@v1/vertex\_multimodal\_embedding",

                        "query": {

                            "input\_mode": "content",

                            "value": "{{INPUT.image}}",

                        },

                        "top\_k": 50,

                    },

                \],

                "final\_top\_k": 50,

            },

        },

        {

            "stage\_name": "diversify",

            "stage\_id": "mmr",

            "parameters": {

                "lambda": 0.7,

                "diversity\_feature\_uri": "mixpeek://multimodal\_extractor@v1/vertex\_multimodal\_embedding",

                "top\_k": 20,

            },

        },

    \],

)

\# 4. Search

results \= client.retrievers.execute(

    retriever\["retriever\_id"\],

    inputs\={

    "image": "https://example.com/reference.jpg",

},

)

for doc in results\["documents"\]:

    print(doc\["document\_id"\], doc\["score"\])

### Feature Extractors

Multimodal Extractor

Unified embeddings for video, audio, image, and text: scene/silence chunking, Whisper transcription, thumbnails, and Gemini vision.

### Retriever Stages

feature search

Search and filter documents by vector similarity using feature embeddings

filter

mmr

Reorder results using Maximal Marginal Relevance for diversity

sort

## Frequently asked questions

### What is MMR and why should I use it?

Maximal Marginal Relevance (MMR) balances relevance with diversity. It prevents results from being dominated by near-identical items, giving you a broader set of visually related content.

### Can I search across both images and video frames together?

Yes. Multimodal embeddings share the same vector space, so a single query retrieves relevant results from both image collections and video scene collections simultaneously.

### How do I control the relevance vs diversity tradeoff?

Adjust the MMR lambda parameter. Lambda=1.0 maximizes relevance (no diversification), lambda=0.0 maximizes diversity. A value of 0.7 works well for most use cases.

## Related code examples and resources

Pages on the same stages, extractors and patterns.

[

Extractor

### Multimodal Extractor

Unified embeddings for video, audio, image, and text: scene/silence chunking, Whisper transcription, thumbnails, and Gemini vision.

Learn more





](/extractors/multimodal)[

Recipe

### Face Search Pipeline

Detect, align, and embed faces across your image and video library, then search by face identity. Uses SCRFD for detection and ArcFace for 512-dimensional identity embeddings, enabling large-scale face recognition and matching.

Learn more





](/recipes/face-search-pipeline)[

Recipe

### Reverse Image Search

Build a reverse image search engine that accepts an image as input and returns visually similar results from your indexed collection. Uses multimodal embeddings to match visual features like color, shape, composition, and semantic content.

Learn more





](/recipes/reverse-image-search)[

Recipe

### Visual Product Search

Enable camera-based product discovery for e-commerce. Customers snap a photo of a product they like, and the pipeline returns visually similar items from your catalog along with pricing, availability, and product metadata.

Learn more





](/recipes/visual-product-search)[

Recipe

### AI-Powered Catalog Search

Replace keyword-based catalog search with AI-powered semantic and visual search. Understands natural language queries like "lightweight summer dress under $50" and combines text understanding with visual similarity for comprehensive product discovery.

Learn more





](/recipes/ai-catalog-search)[

Extractor

### Image Embedding

Generate visual embeddings for similarity search and clustering

Learn more





](/extractors/image)