Skip to main content
Review candidate detections, record verdicts as annotations, and turn them into YOLO training data. Camera frames are cut into crops, verified examples label each crop, and a cluster shows the classes nobody has labeled yet.

Jump to the manifest

annotations-improve-features.namespace.yaml: apply it with one API call, then read the walkthrough below to change it.

At a glance

How the pieces connect

Buckets hold what you upload, collections turn it into searchable documents, and retrievers answer queries over the collections.

Deploy it

1

Get the manifest

2

Validate it

Validate runs every check apply runs and creates nothing. Fix each entry in errors, then run it again.
3

Apply it

Apply creates every resource in one call. wait_for_seed=true also waits until the sample objects are processed, so the first query below has documents to return.
The response lists each resource with its outcome in resources. Apply refuses a resource that already exists and rolls the whole apply back, so to apply the file again over this namespace add ?mode=create_missing, which creates only what is missing.

Run the first query

Look up the namespace id by name, then run detection-review. Check status and warnings along with documents: a run that times out still answers 200, with status degraded.

Add your own data

Each object you add to a bucket is processed by every collection that reads it. This adds one object to camera-frames. NAMESPACE_ID is the id from the namespace lookup above.
The object is PENDING until processing finishes, then COMPLETED or FAILED. Buckets and objects covers object states, retries and duplicates.

Retrievers

detection-review

The review queue: the crops that look most like a class you name, each with its frame, tile and camera. Stages: feature_search Searches: frame-crops

class-lookup

The taxonomy’s matcher: the verified example closest to a crop’s vector, if it scores at least min_score. Stages: feature_search Searches: verified-set

Collections

Each collection runs one extractor over a bucket, or over another collection’s documents.
image_extractor@v1 over bucket camera-frames: each frame indexed whole (tile 0) and as 6 crops (tiles 1 to 6). Labeled by object-labeler; feeds detection-review and crop-groups.Reads bucket camera-frames with image_extractor v1.Inputs: image ← imageCopied onto each document: camera_id
image_extractor@v1 over bucket verified-objects. The examples object-labeler matches each crop against.Reads bucket verified-objects with image_extractor v1.Inputs: image ← imageCopied onto each document: object_class

Also created

Taxonomies
  • object-labeler: Copies object_class from the closest verified example onto each crop.
Clusters
  • crop-groups: Groups the crops by appearance, to find object classes the verified set does not cover yet.

The manifest

Every resource above comes from this file. Change it and apply it again with ?mode=upsert to update what exists. Manifests documents each field.
annotations-improve-features.namespace.yaml

Hand it to an agent

Paste this prompt into Claude Code, Cursor or another coding agent. To give the agent this whole page instead, use Copy page in the menu at the top of the page, or point it at the page’s Markdown at https://mixpeek.com/docs/templates/annotations-improve-features.md.
Prompt

How it works

A detector proposes regions, people confirm or correct them, and the corrections become training data for a better detector. Here a grid of crops stands in for the detector until you deploy your own.
  1. frame-crops runs image_extractor over each image in camera-frames with a 3 by 2 tile_grid. Each frame becomes 7 documents sharing a frame_key (<object_id>:0): tile_index 0 is the whole frame, and 1 to 6 are the crops, row by row, each a candidate detection with its own SigLIP vector.
  2. detection-review is the review queue. You name a class in words, and it returns the 20 closest crops. A pre_filters entry tile_index gte 1, backed by a payload index, keeps whole frames out.
  3. verified-set embeds verified-objects, where each image shows one object and carries its class in object_class.
  4. The object-labeler taxonomy runs on frame-crops as each crop is processed. class-lookup finds the closest verified example scoring at least 0.30, and the taxonomy copies its object_class onto the crop.
  5. crop-groups is a k-means cluster over the crop vectors, with 4 groups. You run it to look for classes the verified set is missing.
Each crop is a fixed sixth of the frame, so a “car” crop is the sixth that holds a car. The scripts below turn tile_index into a normalized [x0, y0, x1, y1] box. A frame processed before the verified set was indexed comes out unlabeled; Grow the verified set labels it again.

Review detections

1

Open the review queue

Run detection-review for one class. Keep retriever_id and execution_id, so each annotation records the run it judges.
cURL
object_class, when present, is the taxonomy’s guess.
2

Record a verdict

Stats count labels by exact string, so keep to one vocabulary. This guide uses four:Annotate the first result. target.region is the crop’s box and target.rank its queue position; the export reads the class and frame from payload. For missed, also set target.expected to true.
cURL
Fix a wrong verdict with PATCH /v1/annotations/{annotation_id}; earlier versions stay at .../versions.
3

Record the rest of the queue in one call

POST /v1/annotations/bulk takes up to 1,000 creates, and results reports each outcome, so retry only the failures. This marks results 2 and 3 of the run above:
cURL

Measure

GET /v1/annotations/stats counts annotations by label for one collection_id. The scripts below read it from COLLECTION_ID, exported here.
cURL
The share of confirmed is the queue’s precision for the classes you reviewed; many corrected point at confused classes (read their payload.true_class). Stats are cumulative. To compare periods or retrievers, POST /v1/annotations/list filters by collection_id, label, retriever_id and actor_id, and as_of returns the set as it stood at an instant.

Export and fine-tune

Every confirmed and corrected annotation is a labeled box. This script writes them in the YOLO layout: images/, labels/ and a data.yaml listing the classes.
export_yolo.py
Run the export
Fine-tune on any machine with a GPU, for example with Ultralytics:
finetune.py
data.yaml above trains and validates on the same images, which says nothing about accuracy. Hold out frames and set val to them before you trust a model.

Put the corrections back

Grow the verified set

Each confirmed or corrected crop is a verified example of its true_class. This script (it needs Pillow) cuts each crop out of its frame and adds it to verified-objects.
promote_verified.py
When the new examples are processed, apply object-labeler to frame-crops again with reapply_all: true, and poll the returned task until COMPLETED:
cURL
Raise min_score: 0.30 on class-lookup to label fewer crops with fewer mistakes. Bootstrap a labeled dataset covers this matching loop.

Deploy the fine-tuned detector

A trained detector runs as a custom extractor, which needs a dedicated deployment; the custom extractor quickstart walks through it. Once deployed:
  1. Create a collection over camera-frames that runs it. A collection’s extractor cannot change, so the detector gets its own collection beside frame-crops.
  2. Point a copy of detection-review at it. If it writes a confidence per detection, a pre_filters entry confidence lt 0.7 (with a payload index) sends reviewers the least certain detections.
  3. Annotate its results the same way, with target.region from the detector’s own box.
  4. Ship each retrained model as a new extractor version. The version is part of the feature URI, so two versions run side by side while you compare their review stats.

Automate the loop

Get a request on every verdict

A webhook calls your server on each annotation event, so it can count corrections toward the next retrain or run promote_verified.py without polling. Webhooks belong to the organization, so the call takes no X-Namespace header.
cURL
collection.documents.written fires when a new detector version finishes processing frames. Add a signing_secret to configs and each delivery carries an X-Mixpeek-Signature header your server can verify.

Find classes nobody has labeled

A crop-groups group whose members carry no object_class is a class missing from verified-objects. Run the cluster, then read its groups:
cURL
Raise n_clusters in crop-groups as the frames grow:
crop-groups vector_config
To name a new class, add a few of the group’s crops to verified-objects with an object_class and apply the taxonomy again. Clusters covers the other methods.

Change it

Each change edits the manifest. Apply it again with ?mode=upsert.
  • A finer grid. tile_grid takes 1 to 4 columns and rows. A 4 x 3 grid makes 13 documents per frame, about twice the cost. Update the bbox math to the new grid, and apply to a new namespace, since the grid decides which documents exist.
  • Review one camera. Add a second pre_filters entry on camera_id, with a keyword payload index on camera_id, for a queue per camera.
  • Rank frames, not crops. Add a group_by stage on frame_key with max_per_group: 1 after the search, to review each frame once by its best crop.