id int64 0 8.14k | image imagewidth (px) 78 5.62k | label int32 0 195 | blip_caption stringlengths 16 891 | image_emb list |
|---|---|---|---|---|
0 | 13 | a white car parked in front of a building | [
-0.02374267578125,
-0.09033203125,
-0.125732421875,
-0.06549072265625,
0.0430908203125,
-0.026336669921875,
-0.003070831298828125,
0.025726318359375,
0.0078125,
0.00528717041015625,
0.0010442733764648438,
-0.01549530029296875,
-0.06390380859375,
-0.044158935546875,
-0.033203125,
0.0192... | |
1 | 2 | a black car parked in front of a building | [
0.01824951171875,
-0.06341552734375,
-0.044219970703125,
-0.01430511474609375,
-0.0019474029541015625,
-0.048309326171875,
0.02349853515625,
0.0243377685546875,
0.0570068359375,
-0.0123443603515625,
-0.0263824462890625,
-0.048309326171875,
-0.003204345703125,
0.0447998046875,
-0.08544921... | |
2 | 90 | a red truck parked on a gravel road | [
-0.0750732421875,
-0.091796875,
-0.03558349609375,
-0.045684814453125,
-0.08782958984375,
0.01190185546875,
0.0281219482421875,
-0.018035888671875,
0.020751953125,
0.0208587646484375,
-0.0100860595703125,
-0.0210113525390625,
0.0270538330078125,
-0.036590576171875,
0.0269775390625,
0.0... | |
3 | 133 | the back end of a red 2019 bmw x1 | [
0.0132598876953125,
-0.03900146484375,
-0.03375244140625,
-0.0283050537109375,
0.0113677978515625,
-0.005756378173828125,
0.037994384765625,
-0.01690673828125,
0.044342041015625,
-0.060302734375,
0.00809478759765625,
-0.04034423828125,
0.04425048828125,
0.027587890625,
-0.06341552734375,... | |
4 | 105 | a white truck parked in a parking lot | [
0.00699615478515625,
-0.11029052734375,
-0.036102294921875,
-0.02679443359375,
0.0019178390502929688,
-0.041839599609375,
-0.0034027099609375,
-0.0242919921875,
-0.01552581787109375,
-0.0158843994140625,
0.018798828125,
-0.0223541259765625,
-0.017974853515625,
0.023712158203125,
-0.01745... | |
5 | 122 | a car parked in front of a house | [
0.064697265625,
0.0232391357421875,
-0.058380126953125,
-0.06280517578125,
0.058837890625,
0.07037353515625,
0.06494140625,
0.0177764892578125,
0.012481689453125,
-0.018310546875,
0.02288818359375,
-0.040496826171875,
-0.048095703125,
-0.0163726806640625,
0.0238800048828125,
0.02848815... | |
6 | 88 | a blue dodge suv parked in a parking lot | [
-0.0107574462890625,
-0.0885009765625,
-0.08514404296875,
-0.021148681640625,
0.0794677734375,
0.01114654541015625,
0.033721923828125,
-0.0163726806640625,
0.01654052734375,
0.019500732421875,
-0.047088623046875,
0.00388336181640625,
0.044708251953125,
-0.07568359375,
-0.03369140625,
0... | |
7 | 95 | a red car in a showroom | [
-0.02520751953125,
-0.1348876953125,
-0.03326416015625,
0.034759521484375,
-0.046783447265625,
0.0223236083984375,
-0.0279693603515625,
-0.00818634033203125,
0.002330780029296875,
-0.05059814453125,
-0.057220458984375,
-0.03399658203125,
0.05926513671875,
0.02850341796875,
0.028701782226... | |
8 | 166 | a car parked in a parking lot | [
0.00838470458984375,
-0.09149169921875,
-0.03900146484375,
-0.00727081298828125,
0.0227813720703125,
0.00998687744140625,
0.0025844573974609375,
0.0199127197265625,
0.055267333984375,
0.0447998046875,
0.01395416259765625,
-0.025299072265625,
0.03668212890625,
-0.03759765625,
-0.004764556... | |
9 | 57 | the 2009 chevrolet raz suv | [
-0.022735595703125,
-0.045379638671875,
-0.0797119140625,
0.030517578125,
-0.04345703125,
-0.029449462890625,
0.018829345703125,
-0.028472900390625,
-0.0004506111145019531,
0.00629425048828125,
-0.006561279296875,
-0.03076171875,
0.036163330078125,
-0.0197601318359375,
-0.09576416015625,... | |
10 | 48 | a white car parked in front of a building | [
-0.04949951171875,
-0.0304107666015625,
-0.0394287109375,
0.05364990234375,
-0.00962066650390625,
-0.0018014907836914062,
-0.0031719207763671875,
-0.01898193359375,
0.021392822265625,
-0.048248291015625,
0.0310516357421875,
-0.064453125,
0.032867431640625,
0.0196075439453125,
-0.05676269... | |
11 | 185 | a car parked in front of a building | [
-0.09637451171875,
-0.1431884765625,
-0.1513671875,
-0.036712646484375,
-0.06182861328125,
-0.0308990478515625,
0.033355712890625,
0.038177490234375,
0.044677734375,
-0.01250457763671875,
0.0161895751953125,
0.00656890869140625,
0.0117034912109375,
0.0181427001953125,
-0.0262451171875,
... | |
12 | 134 | a car on display at a car show | [
-0.0557861328125,
-0.0716552734375,
-0.1441650390625,
-0.0404052734375,
0.02081298828125,
0.003986358642578125,
-0.062347412109375,
-0.010894775390625,
0.029693603515625,
0.0021572113037109375,
-0.004608154296875,
-0.016937255859375,
0.0516357421875,
-0.0219879150390625,
-0.0811767578125... | |
13 | 84 | a white suv parked on the side of the road | [
-0.0655517578125,
-0.038421630859375,
-0.1170654296875,
-0.008819580078125,
-0.02789306640625,
-0.0247955322265625,
0.0230712890625,
-0.0140228271484375,
0.0012617111206054688,
-0.05975341796875,
-0.020660400390625,
-0.0178070068359375,
0.040496826171875,
-0.08984375,
-0.0067405700683593... | |
14 | 192 | a car on display at show | [
0.05047607421875,
-0.08953857421875,
-0.00934600830078125,
-0.11370849609375,
-0.01070404052734375,
-0.0255279541015625,
-0.03228759765625,
0.003154754638671875,
0.040618896484375,
0.0285797119140625,
-0.005069732666015625,
-0.0272064208984375,
0.002010345458984375,
-0.069580078125,
-0.0... | |
15 | 171 | a red car parked in the grass | [
-0.0228729248046875,
-0.047393798828125,
-0.08642578125,
-0.0731201171875,
0.029632568359375,
0.007305145263671875,
-0.042755126953125,
-0.07562255859375,
-0.001194000244140625,
-0.0679931640625,
-0.05377197265625,
-0.0238189697265625,
-0.047332763671875,
0.0017566680908203125,
-0.074890... | |
16 | 13 | a car on display at a car show | [
-0.0108795166015625,
-0.11480712890625,
-0.123046875,
0.00402069091796875,
0.0079193115234375,
-0.02459716796875,
-0.0210418701171875,
-0.0113525390625,
0.007232666015625,
0.026458740234375,
-0.0299835205078125,
-0.00641632080078125,
-0.0289764404296875,
-0.0850830078125,
-0.024291992187... | |
17 | 72 | a white car parked in a field | [
-0.01462554931640625,
-0.022613525390625,
0.032379150390625,
-0.10064697265625,
0.038238525390625,
0.0167694091796875,
0.010406494140625,
-0.0094757080078125,
-0.0226287841796875,
0.014251708984375,
0.037445068359375,
0.0245361328125,
0.0008668899536132812,
-0.006072998046875,
-0.1191406... | |
18 | 191 | a red car driving down the road | [
0.0489501953125,
-0.03131103515625,
-0.1422119140625,
0.00617218017578125,
-0.01885986328125,
0.007465362548828125,
0.0182647705078125,
0.009918212890625,
-0.0246124267578125,
-0.0009217262268066406,
-0.014007568359375,
0.036224365234375,
0.059539794921875,
-0.02789306640625,
0.022994995... | |
19 | 56 | a white car parked in front of a building | [
-0.00542449951171875,
-0.034881591796875,
-0.1494140625,
-0.06744384765625,
-0.0273284912109375,
-0.003993988037109375,
-0.031707763671875,
0.05926513671875,
0.006649017333984375,
-0.004070281982421875,
-0.021636962890625,
-0.0200958251953125,
0.0313720703125,
-0.01371002197265625,
0.006... |
Stanford Cars (Lance Format)
A Lance-formatted version of the Stanford Cars fine-grained benchmark — 8,144 photographs across 196 make/model/year classes — sourced from Multimodal-Fatima/StanfordCars_train. Each row carries the inline JPEG bytes, the integer class id, a BLIP-generated caption inherited from the source mirror, and a cosine-normalized CLIP image embedding, all available directly from the Hub at hf://datasets/lance-format/stanford-cars-lance/data.
Key features
- Inline JPEG bytes in the
imagecolumn — no sidecar files, no image folders. - Pre-computed CLIP image embeddings (
image_emb, OpenCLIPViT-B-32, 512-dim, cosine-normalized) with a bundledIVF_PQindex for similarity search. - BLIP captions in
blip_captionwith a full-text index, so keyword search on visual descriptions composes with vector search in a single query. - A bundled scalar index on
labelmakes class-based curation a cheap predicate rather than a full scan.
Splits
| Split | Rows | Notes |
|---|---|---|
train.lance |
8,144 | The source mirror redistributes a single split; the original Stanford Cars test split is not included here. |
Schema
| Column | Type | Notes |
|---|---|---|
id |
int64 |
Row index within split (natural join key for merges) |
image |
large_binary |
Inline JPEG bytes (quality 92) |
label |
int32 |
Class id (0–195), one per Make Model Year combination |
blip_caption |
string? |
BLIP-generated caption (beam=5) carried through from the source mirror |
image_emb |
fixed_size_list<float32, 512> |
OpenCLIP ViT-B-32 image embedding (cosine-normalized) |
Pre-built indices
IVF_PQonimage_emb— vector similarity search (cosine)INVERTED(FTS) onblip_caption— keyword and hybrid searchBTREEonlabel— fast lookup by class id
Why Lance?
- Blazing Fast Random Access: Optimized for fetching scattered rows, making it ideal for random sampling, real-time ML serving, and interactive applications without performance degradation.
- Native Multimodal Support: Store text, embeddings, and other data types together in a single file. Large binary objects are loaded lazily, and vectors are optimized for fast similarity search.
- Native Index Support: Lance comes with fast, on-disk, scalable vector and FTS indexes that sit right alongside the dataset on the Hub, so you can share not only your data but also your embeddings and indexes without your users needing to recompute them.
- Efficient Data Evolution: Add new columns and backfill data without rewriting the entire dataset. This is perfect for evolving ML features, adding new embeddings, or introducing moderation tags over time.
- Versatile Querying: Supports combining vector similarity search, full-text search, and SQL-style filtering in a single query, accelerated by on-disk indexes.
- Data Versioning: Every mutation commits a new version; previous versions remain intact on disk. Tags pin a snapshot by name, so retrieval systems and training runs can reproduce against an exact slice of history.
Load with datasets.load_dataset
You can load Lance datasets via the standard HuggingFace datasets interface, suitable when your pipeline already speaks Dataset / IterableDataset or you want a quick streaming sample without installing anything Lance-specific.
import datasets
hf_ds = datasets.load_dataset("lance-format/stanford-cars-lance", split="train", streaming=True)
for row in hf_ds.take(3):
print(row["label"], row["blip_caption"])
Load with LanceDB
LanceDB is the embedded retrieval library built on top of the Lance format (docs), and is the interface most users interact with. It wraps the dataset as a queryable table with search and filter builders, and is the entry point used by the Search, Curate, Evolve, Train, Versioning, and Materialize-a-subset sections below.
import lancedb
db = lancedb.connect("hf://datasets/lance-format/stanford-cars-lance/data")
tbl = db.open_table("train")
print(len(tbl))
Load with Lance
pylance is the Python binding for the Lance format and works directly with the format's lower-level APIs. Reach for it when you want to inspect or operate on dataset internals — schema, scanner, fragments, and the list of pre-built indices.
import lance
ds = lance.dataset("hf://datasets/lance-format/stanford-cars-lance/data/train.lance")
print(ds.count_rows(), ds.schema.names)
print(ds.list_indices())
Tip — for production use, download locally first. Streaming from the Hub works for exploration, but heavy random access and ANN search are far faster against a local copy:
hf download lance-format/stanford-cars-lance --repo-type dataset --local-dir ./stanford-cars-lanceThen point Lance or LanceDB at
./stanford-cars-lance/data.
Search
The bundled IVF_PQ index on image_emb makes approximate-nearest-neighbor search a single call. In production you would encode a query photo through the same OpenCLIP ViT-B-32 model used at ingest and pass the resulting 512-d vector to tbl.search(...). The example below uses the embedding stored in row 0 as a runnable stand-in so the snippet works without any model loaded.
import lancedb
db = lancedb.connect("hf://datasets/lance-format/stanford-cars-lance/data")
tbl = db.open_table("train")
seed = (
tbl.search()
.select(["image_emb", "blip_caption"])
.limit(1)
.to_list()[0]
)
hits = (
tbl.search(seed["image_emb"])
.metric("cosine")
.select(["id", "label", "blip_caption"])
.limit(10)
.to_list()
)
print("seed caption:", seed["blip_caption"])
for r in hits:
print(f" {r['id']:>6} label={r['label']:>3} {r['blip_caption'][:60]}")
Tune metric, nprobes, and refine_factor to trade recall against latency for your workload.
Because the dataset also ships an INVERTED index on blip_caption, the same query can be issued as a hybrid search that combines the dense vector with a keyword query. LanceDB merges the two result lists and reranks them in a single call, which is useful when a phrase like "red convertible" must literally appear in the caption but you still want CLIP to do the heavy lifting on visual similarity.
hybrid_hits = (
tbl.search(query_type="hybrid")
.vector(seed["image_emb"])
.text("red convertible")
.select(["id", "label", "blip_caption"])
.limit(10)
.to_list()
)
for r in hybrid_hits:
print(f" {r['id']:>6} label={r['label']:>3} {r['blip_caption'][:60]}")
Curate
A typical curation pass for a fine-grained classifier combines a class-based filter with a content filter on the caption. Stacking both inside a single filtered scan keeps the result small and explicit, and the bounded .limit(200) makes it cheap to inspect before committing the subset to anything downstream. The BTREE on label and the INVERTED index on blip_caption make both predicates effectively free.
import lancedb
db = lancedb.connect("hf://datasets/lance-format/stanford-cars-lance/data")
tbl = db.open_table("train")
candidates = (
tbl.search("convertible OR coupe")
.where("label IN (12, 47, 89)", prefilter=True)
.select(["id", "label", "blip_caption"])
.limit(200)
.to_list()
)
print(f"{len(candidates)} candidates; first: {candidates[0]['blip_caption'][:80]}")
The result is a plain list of dictionaries, ready to inspect, persist as a manifest of ids, or feed into the Evolve and Train workflows below. The image column is never read, so the network traffic for a 200-row candidate scan is dominated by the small caption strings rather than JPEG bytes.
Evolve
Lance stores each column independently, so a new column can be appended without rewriting the existing data. The lightest form is a SQL expression: derive the new column from columns that already exist, and Lance computes it once and persists it. Stanford Cars class strings often encode the model year as a trailing four-digit token in the caption; the example below uses a SQL regex to lift that year into its own column, and adds a flag for vintage cars. Either can then be used directly in where clauses without recomputing the predicate on every query.
Note: Mutations require a local copy of the dataset, since the Hub mount is read-only. See the Materialize-a-subset section at the end of this card for a streaming pattern that downloads only the rows and columns you need, or use
hf downloadto pull the full split first.
import lancedb
db = lancedb.connect("./stanford-cars-lance/data") # local copy required for writes
tbl = db.open_table("train")
tbl.add_columns({
"caption_year": "CAST(regexp_extract(blip_caption, '(\\d{4})', 1) AS INTEGER)",
"is_long_caption": "length(blip_caption) >= 80",
})
If the values you want to attach already live in another table (offline labels, classifier predictions, the Make Model Year strings from the original Stanford metadata), merge them in by joining on id:
import pyarrow as pa
class_strings = pa.table({
"id": pa.array([0, 1, 2]),
"class_name": pa.array([
"AM General Hummer SUV 2000",
"Acura RL Sedan 2012",
"Acura TL Sedan 2012",
]),
})
tbl.merge(class_strings, on="id")
The original columns and indices are untouched, so existing code that does not reference the new columns continues to work unchanged. New columns become visible to every reader as soon as the operation commits. For column values that require a Python computation (e.g., running a second captioner over the image bytes), Lance provides a batch-UDF API in the underlying library — see the Lance data evolution docs for that pattern.
Train
Projection lets a training loop read only the columns each step actually needs. LanceDB tables expose this through Permutation.identity(tbl).select_columns([...]), which plugs straight into the standard torch.utils.data.DataLoader so prefetch, shuffling, and batching behave as in any PyTorch pipeline. For a from-scratch fine-grained classifier, project the JPEG bytes and the integer label; for a linear probe on top of frozen CLIP features, swap the projection to the embedding column and skip JPEG decoding entirely.
import lancedb
from lancedb.permutation import Permutation
from torch.utils.data import DataLoader
db = lancedb.connect("hf://datasets/lance-format/stanford-cars-lance/data")
tbl = db.open_table("train")
train_ds = Permutation.identity(tbl).select_columns(["image", "label"])
loader = DataLoader(train_ds, batch_size=64, shuffle=True, num_workers=4)
for batch in loader:
# batch carries only the projected columns; image_emb and blip_caption stay on disk.
# decode the JPEG bytes, forward, cross-entropy against `label`...
...
Switching feature sets is a configuration change: passing ["image_emb", "label"] to select_columns(...) on the next run reads only the cached 512-d vectors and the label, which is the right shape for a linear probe or a lightweight reranker.
Versioning
Every mutation to a Lance dataset, whether it adds a column, merges labels, or builds an index, commits a new version. Previous versions remain intact on disk. You can list versions and inspect the history directly from the Hub copy; creating new tags requires a local copy since tags are writes.
import lancedb
db = lancedb.connect("hf://datasets/lance-format/stanford-cars-lance/data")
tbl = db.open_table("train")
print("Current version:", tbl.version)
print("History:", tbl.list_versions())
print("Tags:", tbl.tags.list())
Once you have a local copy, tag a version for reproducibility:
local_db = lancedb.connect("./stanford-cars-lance/data")
local_tbl = local_db.open_table("train")
local_tbl.tags.create("clip-vitb32-v1", local_tbl.version)
A tagged version can be opened by name, or any version reopened by its number, against either the Hub copy or a local one:
tbl_v1 = db.open_table("train", version="clip-vitb32-v1")
tbl_v5 = db.open_table("train", version=5)
Pinning supports two workflows. A retrieval system locked to clip-vitb32-v1 keeps returning stable results while the dataset evolves in parallel; newly added columns or captions do not change what the tag resolves to. A training experiment pinned to the same tag can be rerun later against the exact same images and labels, so changes in metrics reflect model changes rather than data drift. Neither workflow needs shadow copies or external manifest tracking.
Materialize a subset
Reads from the Hub are lazy, so exploratory queries only transfer the columns and row groups they touch. Mutating operations (Evolve, tag creation) need a writable backing store, and a training loop benefits from a local copy with fast random access. Both can be served by a subset of the dataset rather than the full split. The pattern is to stream a filtered query through .to_batches() into a new local table; only the projected columns and matching row groups cross the wire, and the bytes never fully materialize in Python memory.
import lancedb
remote_db = lancedb.connect("hf://datasets/lance-format/stanford-cars-lance/data")
remote_tbl = remote_db.open_table("train")
batches = (
remote_tbl.search("convertible OR coupe")
.select(["id", "image", "label", "blip_caption", "image_emb"])
.to_batches()
)
local_db = lancedb.connect("./stanford-cars-sports-subset")
local_db.create_table("train", batches)
The resulting ./stanford-cars-sports-subset is a first-class LanceDB database. Every snippet in the Evolve, Train, and Versioning sections above works against it by swapping hf://datasets/lance-format/stanford-cars-lance/data for ./stanford-cars-sports-subset.
Source & license
Converted from Multimodal-Fatima/StanfordCars_train, itself a redistribution of the Stanford Cars dataset. The original dataset license is for non-commercial research use; review the Stanford Cars terms before redistribution.
Citation
@inproceedings{krause2013collecting,
title={Collecting a large-scale dataset of fine-grained cars},
author={Krause, Jonathan and Stark, Michael and Deng, Jia and Fei-Fei, Li},
booktitle={Workshop on Fine-Grained Visual Categorization (CVPR)},
year={2013}
}
- Downloads last month
- 145