CityPedia encodes every frame of a city camera archive once into sparse codes. A new concept is acquired from a few masked exemplars, and the stored codes then answer where and when it appears, with no new pass over the archive.
Abstract
Cameras in cities, from traffic surveillance to in-vehicle views, record continuously, and an analyst often learns which concept matters only after seeing a few cases of it, and then asks for every frame that shows it and where. Current tools serve this poorly at city scale, because models that operate on images run over the archive again for each new question, while a whole-image embedding does not show where a concept appears. CityPedia builds on the observation that frames are made of recurring visual concepts. A sparse autoencoder decomposes the patch tokens of a frozen vision-language model (VLM) into atoms learned without labels, and every frame is stored once as sparse codes, a sparse visual encyclopedia from which later questions are answered with no new pass over the archive. Because one concept activates different atoms in different images, a sparse head learns a weighted set of atoms from a few masked exemplars, and a graph adaptor regularizes this head with an atom co-occurrence graph so that fewer exemplars suffice. On three public urban datasets and four VLMs, CityPedia is able to ground concepts and retrieve them above zero-shot retrieval with the same VLM. On large-scale real-world footage from New York City, the codes measure where and when concepts appear, in agreement with third-party records of bus routes and the school calendar. Single concepts also combine into composite queries defined after encoding, such as a car in a bus lane.
Methodology
1.1 Patch tokens, not one image embedding. The pooled output embedding of a VLM summarizes the whole image and gives up spatial detail, so a small object leaves little trace in it. CityPedia reads the P patch tokens \mathbf{h}_1(x),\dots,\mathbf{h}_P(x) of each image x from an intermediate block of a frozen VLM.
1.2 A sparse autoencoder over the tokens. The SAE maps a token \mathbf{h} to a sparse code \mathbf{z} and reconstructs it from the atoms of a learned dictionary:
The operator \phi makes \mathbf{z} nonnegative with few nonzero entries. The SAE is trained without labels, only to reconstruct its input. With TopK, each patch keeps k active atoms.
1.3 One pass over the archive. CityPedia stores the patch code \mathbf{z}_p(x) of every patch once per image. Later questions read these codes and never the images.
TSP6K test images and their real codes (k = 32). A tile shows the patch where its atom is strongest. Pick an atom or a patch.
2.1 One atom is not one concept. The atoms are learned to reconstruct the input, and nothing aligns one atom with one concept. The atom that contributes most to the car head changes between images, so any single atom misses many cars. An unweighted union of atoms covers more of a concept but also marks more patches outside it.
2.2 A sparse head on the stored codes. A concept is given by B masked exemplars, so it needs no name. A linear head (\mathbf{w},b) gives patch p the probability
It is fit with a class-balanced logistic loss \mathcal{L}_{\mathrm{cls}}(\mathbf{w},b) on the exemplar patches, and an \ell_1 term keeps few atoms. The atoms with nonzero weight form the entry of the concept.
2.3 Two queries from one head. Grounding marks patch p of image x when \pi_p(x)\ge\tau. Retrieval scores an image by the mean of its m largest patch probabilities,
so a small object can score high without resting on a single patch.
car mask, by pixel share of a patch inside the mask patches the head marks
The paper’s car head (B = 10, no graph term). Reading fewer atoms cuts this head short; it is not fit again. Pick an atom to see it alone.
3.1 A few exemplars show only some atoms. A head fit to a few exemplars learns weights only for the atoms active on their patches. It misses the atoms that the concept activates in images it has not seen.
3.2 A co-occurrence graph from unlabeled codes. Atoms that serve one concept tend to be active together. The graph is built from the training images without labels. It links atoms i and j by the positive point-wise mutual information \max\!\big(0,\log\tfrac{N\,n_{ij}}{n_i\,n_j}\big), where N counts the training patches, n_i those where atom i is active and n_{ij} those where both are. Each atom keeps its \kappa strongest links.
3.3 The graph adaptor. With \mathbf{L} the normalized Laplacian of the graph, the head solves
The last term is small when linked atoms receive similar weights. An atom that is inactive on every exemplar patch can therefore take weight from its neighbors, so the head can respond to forms of the concept that no exemplar shows.
atom from the exemplars atom the graph term adds inactive on every exemplar car mask, by pixel marked without the graph term marked only with it
The paper’s car heads (B = 10) without the graph term and at the graph weight chosen on validation. A line links two atoms of the co-occurrence graph; the inner wire frame holds the atoms from the exemplars. The added atoms shown matter most on this image or link the most shown atoms. Drag to turn; pick an atom or a patch.
Results on public benchmarks
Grounding demo
All classes at once on one image
Each patch takes the class with the largest head score (k = 32, B = 10 masked exemplars). Compare the ground truth with PatchSAE, which uses the best single atom per class, and with CityPedia, which uses heads with the graph adaptor. Select a class in the legend to show only that class.
Composite query demo
Two concepts combined after encoding
Every head gives a patch map on the same stored codes. A composite query combines the maps of its two concepts with no new labels and no new pass over the images. The queries here are “c1 next to c2” on the test sets. Switch the layers to see each concept and their combination.
Case study, NYC archive
Where and when a concept appears in New York City
The archive holds 3,795,916 frames from 946 public NYC traffic cameras in February and March 2023. Every frame is encoded once. Each layer below is one query on the stored codes, drawn next to a record kept outside the archive. Drag to move, scroll to zoom, and select a camera.
Composite query demo
Two concepts combined on NYC frames
The same operation on the archive. A car in a bus lane combines the car head with a bus-lane region. Street parking combines the car head on two frames 15 minutes apart. Switch the layers to see each part and their combination on the frames that the paper studied.
Rare events in the archive
Three event sequences from the supplementary material. In each, the head for people rises above the usual level of the camera view. The names of the marathon and the accident are the reading of a human expert.
parade day, 11:30
parade day, 12:15
parade day, 13:30
same view, previous Friday 11:30
09:45
10:15
11:00
one week later, 11:45
14:00
14:30
15:15
15:30Acknowledgments
We thank Fan Zuo and Hongdao Meng for technical support, and Jing Zhang for discussion. This work was supported in part by NSF grants 2514030 and 2238968, by C2SMART, a Tier 1 University Transportation Center at New York University, and through the NYU IT High Performance Computing resources, services, and staff expertise. The contents of this paper reflect only the views of the authors, who are responsible for the facts, and do not represent the official views of any sponsoring agency.
BibTeX
@article{citypedia,
title = {CityPedia: Mask-Grounded Concept Acquisition for Urban Visual Analysis},
author = {Zhang, Ruixuan and Zhang, Juexiao and Liu, Zerun and Ozbay, Kaan and Feng, Chen},
note = {Under review},
year = {2026}
}
CityPedia