Back to Case Studies

How to use CLIP for diverse dataset curation

AI Search narrows a road-scene dataset with CLIP text search and diverse sampling; Similar pairs exposes remaining repetition for review.

Related templates

How to use CLIP for diverse dataset curation

The problem

  • Problem: Large image datasets mix useful examples with irrelevant scenes and near-duplicates. Reviewing them manually consumes hours of specialist time and labeling budget.
  • Goal: Find images that match the task while preserving broad visual coverage and minimizing repeated content in the dataset sent to review, labeling, or training.
  • Solution: Use AI Index Embeddings to prepare CLIP representations, AI Search to find relevant images and select a diverse subset, and Similar pairs to inspect remaining repetition.

Workflow at a glance

  1. Starting point24,999 imagesBDD and KITTI road scenes
  2. Step 1 · Relevance3,922 imagesPrompt-matched urban truck scenarios
  3. Step 2 · Diversity1,250 imagesRepresentatives selected by AI Search
  4. Step 3 · Inspect133 pairsSimilar pairs supplies 92 removal-review candidates

The starting point

Source datasets

BDD100K 10K contributes 10,000 images. KITTI Object Detection contributes another 14,999. Both public datasets are imported from Dataset Ninja; after merging, the indexed dataset contains 24,999 road-scene images.

What is CLIP indexing?

CLIP turns images and text into numerical representations and places related visual and written content close together. AI Index Embeddings stores these representations for reuse by the search and inspection stages. This workflow uses CLIP explicitly throughout:

  • AI Search with a text prompt: searches the index with a written request and keeps relevant images.
  • AI Search in Diverse mode: groups the matches and selects images closest to the group centers.
  • Similar pairs: finds highly similar image pairs within that selection and supplies candidates for removal review.

How the workflow works

StepWhat happensWhat the step decides
1. CombineMerge BDD and KITTI into one image datasetWhich images are available to search?
2. AI Index EmbeddingsPrepare CLIP representations for the merged poolHow can text and images be compared?
3. AI Search · Text promptRank the indexed dataset by text-to-image similarityWhich images are relevant enough to consider?
4. AI Search · DiverseSelect representatives from visual groups in the matchesWhich candidates add variety instead of repetition?
5. Save the resultWrite the selected images to the curated datasetWhich dataset moves to review, labeling, or training?
6. Similar pairsInspect a separate branch from the diverse selectionWhich remaining pairs need a removal decision?

Run settings: AI Search used the prompt large trucks on an urban road and a confidence threshold of 0.27. The 10,000-image ceiling did not limit the search because 3,922 images matched. Diverse sampling retained 1,250 of those matches.

Two-stage curation: relevance first, diversity second

Each stage solves a different problem. The first removes scenes that do not match the task. The second reduces repetition inside that relevant pool while preserving its visual range. We tuned the two filters together over a few short iterations; tests with 2,000 and 3,000 final images retained more near-duplicates, while 1,250 produced the better tradeoff.

1. Filter for relevant scenarios

AI Search compares the written request with every indexed image. The configured query returned 3,922 matches. Because that result stayed below the top-k ceiling, the similarity threshold decided which images moved forward.

  1. Input24,999 imagesIndexed BDD and KITTI road scenes
  2. AI SearchPrompt + similarity thresholdRank each image by text-to-image similarity
  3. Output3,922 imagesRelevant matches passed to step 2

2. Select a diverse subset

From the 3,922 relevant matches, diverse sampling selected a 1,250-image subset, reducing the pool by roughly 3×. It grouped the matches by their CLIP representations and kept the images closest to representative group centers. This favors visual variety but does not guarantee that every near-duplicate is excluded.

  1. Input3,922 imagesRelevant prompt matches
  2. Diverse samplingCluster + pick representativesKeep 1,250 images nearest the group centers
  3. Output1,250 imagesA compact, visually varied candidate set

To test that result, we compared diverse sampling with 20 random samples of the same 1,250-image size and averaged the random results. For every image, the evaluation finds its maximum CLIP similarity to another image in the same set; a score of at least 0.98 counts as a near-duplicate. The diverse set had a lower near-duplicate rate in all 20 comparisons. This measures repetition at the chosen threshold; it does not establish coverage of every useful scene. The results are below.

Evaluation setImages with a ≥0.98-similar neighborRateRole in the comparison
Text-prompt output1,264 / 3,92232.23%Input before diverse sampling
Diverse sample150 / 1,25012.00%Final curated set
Random baseline, mean of 20 samples222 / 1,25017.76%Fair same-size baseline; range 14.16–20.08%

The final near-duplicate rate is 5.76 percentage points below the random average. In relative terms, that is a 32.42% reduction. It also falls below the best random result, so diverse sampling won all 20 comparisons.

Inspect the remaining similar pairs

Similar pairs checks the 1,250-image diversity selection using its CLIP embeddings and a cosine similarity threshold of at least 0.98. It produces a report and a separate dataset of candidates for removal review. The report is publicly available in the accompanying live example.

Similar pairs inspectionResult
Images checked1,250
Unique pairs at CLIP cosine similarity ≥0.98133
Images with a similar neighbor150 (12%)
Candidate images for removal review92
Pair rows displayed133 of 133

The 500-row display limit did not truncate this report. No images were automatically excluded: the curated selection still contains 1,250 images. You inspect candidates before deciding whether to exclude any; later exclusions reduce the selection size. Groups can connect transitively: if A resembles B and B resembles C, all three can belong to one group even when A and C fall below the threshold. Group membership therefore does not prove that every candidate can safely be removed.

AI Index Embeddings runs on a schedule. You initiate the AI Search workflow and start Similar pairs separately after diversity selection finishes. The baseline evaluation counts images with a similar neighbor; the report also counts pairs, while its candidate dataset is a further selection for review. These three quantities cannot be substituted for one another. The comparison with 20 random samples is a separate evaluation, not an output of Similar pairs.

Visual evidence

The illustration below shows the sampling logic: keep one representative from a visual group instead of filling the result with several near-duplicates.

One representative is kept on the left; visually similar candidates from the same CLIP group are left out on the right.

One representative is kept on the left; visually similar candidates from the same CLIP group are left out on the right.

Four rows comparing one image retained by CLIP diversity selection with three visually similar images discarded from the same cluster

Summary

AI Search retained 3,922 relevant matches from 24,999 source images and selected a diverse dataset of 1,250 images, reducing review volume 20×. At the 0.98 CLIP threshold, 150 selected images (12%) have a similar neighbor. That rate is 5.76 percentage points below the random average, a 32.42% relative reduction, and lower than all 20 same-size random samples.

Similar pairs exposes 133 pairs in that selection and supplies 92 candidate images for removal review. The curated dataset remains intact until you decide which candidates to exclude. OvalBee keeps the selection and pair evidence together for that review; these results do not establish that all duplicates are removed or that the selection improves a downstream model.

Explore the live workflow

Inspect the actual read-only OvalBee flow behind this case study, including its nodes, configuration, and reports, or open it in OvalBee.