D
DreamLake

Examples

Captioning + Indexing

Full pipeline: load video, generate captions, build vector index.

import dreamlake as dl
from my_model import encode_image, describe
 
video = dl.load_video("v-BV1bW411n7fY9x01")
 
with dl.Prefix(space="robotics@alice", prefix="/2026/04/run-042"):
    # Caption track
    track = dl.text_track(path="captions/llava")
 
    # Vector index
    index = dl.vec_index("run-042-vectors")
 
    # Process every 2s segment
    chunks = video.chunk(2.0)
    for chunk in chunks:
        frame = chunk[0].image
        vec = encode_image(frame)
        caption = describe(frame)
 
        # Store caption
        track.add(caption, source=chunk)
 
        # Index vector
        index.add(vector=vec, caption=caption, source=chunk)
 
    # Flush captions to storage
    track.flush()
 
print(f"Captions: {track.count}")
print(f"Vectors:  {index.count}")