Video

We’ll be using vuse-generic-v1 to build a collection of 1 second interval video chunks into a 768 dimension embedding collection.

You’ll need to create a Pinecone index with 768 dimensions for vuse-generic-v1 model embeddings. We’re calling it video_index.

Ingest

from mixpeek import Mixpeek
import pinecone

# Initialize the Mixpeek client with your API key
mixpeek = Mixpeek("YOUR_API_KEY")

# Initialize Pinecone
pinecone.init(api_key="YOUR_PINECONE_API_KEY", environment="YOUR_PINECONE_ENVIRONMENT")
index = pinecone.Index("video_index")

# Process video chunks
processed_chunks = mixpeek.tools.video.process(
    video_source="https://mixpeek-public-demo.s3.us-east-2.amazonaws.com/pinecone/Jurassic+Park+(2).mp4",
    chunk_interval=1, # 1 second intervals
    resolution=[720, 1280]
)

for i, chunk in enumerate(processed_chunks):
    print(f"Processing video chunk: {i}")

    # embed each chunk
    embed_response = mixpeek.embed.video(
        model_id="vuse-generic-v1",
        input=chunk['base64_chunk'],
        input_type="base64"
    )

    # Upsert to Pinecone
    index.upsert(
        vectors=[(str(i), embed_response['embedding'], {
            "start_time": chunk["start_time"],
            "end_time": chunk["end_time"]
        })]
    )

Text Query

query = "two boys inside a car"

embed_response = mixpeek.embed.video(
    model_id="vuse-generic-v1",
    input=query,
    input_type="text"
)

results = index.query(
    vector=embed_response['embedding'],
    top_k=10,
    include_metadata=True
)

for result in results['matches']:
    print(result)

Video Query

# we'll use a cartoon version of jurassic park
file_url = "https://mixpeek-public-demo.s3.us-east-2.amazonaws.com/pinecone/rabbit-jurassic.mp4"

embed_response = mixpeek.embed.video(
    model_id="vuse-generic-v1",
    input=file_url,
    input_type="url"
)

results = index.query(
    vector=embed_response['embedding'],
    top_k=10,
    include_metadata=True
)

for result in results['matches']:
    print(result)

Image

We’ll be using clip-v1 to build a collection of image embeddings with 512 dimensions.

You’ll need to create a Pinecone index with 512 dimensions for clip-v1 model embeddings. We’re calling it image_index.

Ingest

from mixpeek import Mixpeek
import pinecone

# Initialize the Mixpeek client with your API key
mixpeek = Mixpeek("YOUR_API_KEY")

# Initialize Pinecone
pinecone.init(api_key="YOUR_PINECONE_API_KEY", environment="YOUR_PINECONE_ENVIRONMENT")
index = pinecone.Index("image_index")

# List of image URLs to process
image_urls = [
    "https://mixpeek-public-demo.s3.us-east-2.amazonaws.com/pinecone/image1.jpg",
    "https://mixpeek-public-demo.s3.us-east-2.amazonaws.com/pinecone/image2.jpg",
    "https://mixpeek-public-demo.s3.us-east-2.amazonaws.com/pinecone/image3.jpg",
    "https://mixpeek-public-demo.s3.us-east-2.amazonaws.com/pinecone/image4.jpg"
]

for i, url in enumerate(image_urls):
    print(f"Processing image: {url}")

    # Embed each image
    embed_response = mixpeek.embed.image(
        model_id="openai-clip-vit-base-patch32",
        input=url,
        input_type="url"
    )

    # Upsert to Pinecone
    index.upsert(
        vectors=[(str(i), embed_response['embedding'], {"image_url": url})]
    )

Text Query

query = "a cat sitting on a windowsill"

embed_response = mixpeek.embed.image(
    model_id="openai-clip-vit-base-patch32",
    input=query,
    input_type="text"
)

results = index.query(
    vector=embed_response['embedding'],
    top_k=5,
    include_metadata=True
)

for result in results['matches']:
    print(result)

Image Query

# Use an image from the same bucket as a query
query_image = "https://mixpeek-public-demo.s3.us-east-2.amazonaws.com/pinecone/query_image.jpg"

embed_response = mixpeek.embed.image(
    model_id="clip-v1",
    input=query_image,
    input_type="url"
)

results = index.query(
    vector=embed_response['embedding'],
    top_k=5,
    include_metadata=True
)

for result in results['matches']:
    print(result)