credit large_stringlengths 1 3.78k | thumb_width int64 1 3.84k | thumb_height int64 1 10.5k | license_title large_stringclasses 114
values | license_short large_stringclasses 194
values | title large_stringlengths 10 254 | source_wiki large_stringclasses 2
values |
|---|---|---|---|---|---|---|
Alan Light | 235 | 300 | cc-by-2.0 | CC BY 2.0 | File:Bob Clampett.jpg | commonswiki |
<Johannes Voggenthaler> | 220 | 176 | None | GPL | File:Wps-brushedmetalh300wps.png | commonswiki |
Gervo1865 at English Wikipedia | 500 | 375 | cc-by-2.5 | CC BY 2.5 | File:Aerialviewgardens.jpg | commonswiki |
Bollywood Hungama | 177 | 221 | cc-by-3.0 | CC BY 3.0 | File:Rajiv Thakur grace the SAB Ke Anokhe Awards (cropped).jpg | commonswiki |
Unknown author | 246 | 349 | pd | PDM | File:The Grand Wizard in 1982.png | commonswiki |
Unknown photographer | 238 | 286 | cc-by-3.0 | CC BY 3.0 | File:Waitangi Day 1973.jpg | commonswiki |
Viksb | 299 | 369 | cc-by-sa-3.0 | CC BY-SA 3.0 | File:Lal Bahadur Shastri (cropped).jpg | commonswiki |
MathildeTT | 195 | 295 | cc-by-sa-3.0 | CC BY-SA 3.0 | File:GeorgesVinhSan.jpg | commonswiki |
User:Bries | 230 | 115 | pd | PDM | File:Caprivistrip.png | commonswiki |
Mirosamek (talk) | 740 | 295 | cc-by-sa-3.0 | CC BY-SA 3.0 | File:UML state machine Fig1.png | commonswiki |
Cameron Robson | 235 | 211 | pd | PDM | File:Casey Chaos.png | commonswiki |
Wilfried Cordes | 443 | 386 | cc-by-sa-3.0 | CC BY-SA 3.0 | File:Excess Volume Mixture of Ethanol and Water.png | commonswiki |
Vanderjoe | 650 | 240 | cc-by-sa-4.0 | CC BY-SA 4.0 | File:W3sDesign Strategy Design Pattern UML.jpg | commonswiki |
Anne_Robert_Jacques_Turgot | 144 | 55 | pd | PDM | File:Signatur Anne Robert Jacques Turgot.PNG | commonswiki |
GFHund | 200 | 250 | cc-by-3.0 | CC BY 3.0 | File:Peierls,Rudolf 1937.jpg | commonswiki |
Kamal Davar | 200 | 200 | cc0 | CC0 | File:S200 kamal.davar.jpg | commonswiki |
Football Federation of The United Arab Emirates | 150 | 150 | cc0 | CC0 | File:United Arab Emirates Third Division Football League.png | commonswiki |
Thomas West | 181 | 95 | pd | PDM | File:Signature of Thomas West, 3rd Baron De La Warr.png | commonswiki |
Unknown author | 180 | 251 | pd | PDM | File:Jackhinson.jpg | commonswiki |
Jeremykemp at English Wikipedia | 208 | 313 | pd | PDM | File:Spinner lure no feather ora.png | commonswiki |
Bazooka | 202 | 262 | pd | PDM | File:Leroy Kelly 1971.jpg | commonswiki |
scoosciuto | 241 | 304 | pd | PDM | File:Tavole eugubine.jpg | commonswiki |
Executive Office of the President of the United States | 119 | 176 | pd | PDM | File:Janet Yellen official CEA portrait.jpg | commonswiki |
None | 691 | 149 | cc-by-sa-3.0 | CC BY-SA 3.0 | File:Reveille with repeat.JPG | commonswiki |
Steve Diet Goedde | 205 | 277 | cc-by-sa-3.0 | CC BY-SA 3.0 | File:SDG Von Teese 2.jpg | commonswiki |
Alliance Laundry Systems | 180 | 48 | cc-by-sa-4.0 | CC BY-SA 4.0 | File:Alliance Laundry Systems.png | commonswiki |
Unknown author | 190 | 245 | pd | PDM | File:Jimmy Walker1.jpg | commonswiki |
Information and public relations department Government of Bihar | 150 | 150 | None | Attribution | File:Deepak prakash.jpg | commonswiki |
The original uploader was JNorman704 at English Wikipedia. | 204 | 72 | pd | PDM | File:Henri Bendel current logo.png | commonswiki |
Bollywood Hungama | 207 | 310 | cc-by-3.0 | CC BY 3.0 | File:Nidhi Singh graces the trailer launch of Alt Balaji’s Apaharan (04) (cropped).jpg | commonswiki |
CoolB. | 185 | 241 | cc-by-sa-3.0 | CC BY-SA 3.0 | File:Tony Todd.jpg | commonswiki |
WagnerCampeonLatinoamericanodeAAA.jpg: Legolas45 derivative work: TheFBH (talk) | 214 | 239 | cc0 | CC0 | File:Dr. Wagner, Jr. Latin American Champion (cropped).jpg | commonswiki |
Thiesen | 1,043 | 780 | cc-by-sa-4.0 | CC BY-SA 4.0 | File:U.S. abortion rates from 1973 Guttmacher.png | commonswiki |
User:Nizil Shah | 200 | 258 | cc-by-sa-3.0 | CC BY-SA 3.0 | File:Gulzar ITN 2014-04-13 03-44.JPG | commonswiki |
US gov | 216 | 130 | pd | PDM | File:Ketamine2.JPG | commonswiki |
Stonehenge (John Henry Walsh) | 221 | 130 | pd | PDM | File:011. Skull of Spaniel.JPG | commonswiki |
The original uploader was Photonix at English Wikipedia. (Original text: Davis was born in 1901 and in comparison to other photos of him he is very clearly in his late teens to very early twenties in this photo; his face became much fuller by his mid-late 20s. (Cf. Google image search on "Joe Davis snooker".)) | 150 | 212 | pd | PDM | File:Joe Davis.jpg | commonswiki |
None | 306 | 192 | cc-by-sa-3.0 | CC BY-SA 3.0 | File:Ellipse-1900s.jpg | commonswiki |
Leeawiki | 241 | 610 | pd | PDM | File:One of two gedackt Cuckoo pipes.jpg | commonswiki |
Unknown author | 180 | 246 | pd | PDM | File:Adnan Menderes MSB.jpg | commonswiki |
GorillazFanAdam | 200 | 220 | pd | PDM | File:Chausie Kitten.jpg | commonswiki |
The Institute of Heraldry | 181 | 217 | pd | PDM | File:US Army JRTC Flash.png | commonswiki |
Steven Read SteveORSteven | 204 | 169 | pd | PDM | File:Screen burn screen off.png | commonswiki |
ASDFGHJ (talk) | 280 | 361 | cc-by-sa-2.0 | CC BY-SA 2.0 | File:Gwangju montage.png | commonswiki |
None | 216 | 341 | pd | PDM | File:Babyimmunization.jpg | commonswiki |
Igelball | 250 | 210 | cc-by-sa-3.0 | CC BY-SA 3.0 | File:Heckscheibenwischer kl.jpg | commonswiki |
Machanguillo1 | 953 | 312 | cc-by-sa-4.0 | CC BY-SA 4.0 | File:Subpixel edge detection.png | commonswiki |
https://www.flickr.com/photos/spennyj/ | 238 | 334 | cc-by-2.0 | CC BY 2.0 | File:Richard Pacquette.png | commonswiki |
The original uploader was Kgraff at English Wikipedia. | 200 | 194 | cc-by-sa-2.5 | CC BY-SA 2.5 | File:Crocheted doily, representing ears of ripe wheat.jpg | commonswiki |
User:Johnteslade | 390 | 90 | pd | PDM | File:Wavelets - DWT.png | commonswiki |
Original uploader was Rdikeman at en.wikipedia. Later version(s) were uploaded by Tytrain, Gorgeousp at en.wikipedia. | 182 | 340 | cc-by-sa-3.0 | CC BY-SA 3.0 | File:David Bell.jpg | commonswiki |
Bernard_Julius_Otto_Kuehns_mug_shot_superimposed_over_USS_SHAW_exploding_-_1941.jpg: A navy photographer derivative work: Binksternet (talk) | 97 | 110 | pd | PDM | File:Bernard Kuehn mugshot 1941.jpg | commonswiki |
Sekretariat Presiden Republik Indonesia | 198 | 264 | pd | PDM | File:Didit Hediprasetyo pada saat pelantikan wakil menteri (2024).jpg | commonswiki |
US Dept. of Defense | 189 | 300 | pd | PDM | File:Leandro Barbosa in 2015.jpg | commonswiki |
unknown Maya artist | 207 | 178 | pd | PDM | File:Madrid Codex astronomer.png | commonswiki |
The 1980s | 125 | 184 | cc-by-sa-4.0 | CC BY-SA 4.0 | File:Alan Barton 1979.jpg | commonswiki |
Surgeon General | 500 | 292 | pd | PDM | File:Harvey Ballistic Pressure Wave.jpg | commonswiki |
Bollywood Hungama | 190 | 240 | cc-by-3.0 | CC BY 3.0 | File:Sini Shetty at Grazia Young Fashion Awards 2024 (cropped).jpg | commonswiki |
Department for Environment, Food and Rural Affairs | 150 | 192 | None | OGL 3 | File:Official portrait of Margaret Beckett as Environment Secretary.jpg | commonswiki |
United States Navy | 250 | 375 | pd | PDM | File:Navy Officer Candidate Logo.jpg | commonswiki |
Evening Standard / Stringer | 150 | 232 | pd | PDM | File:Naomi Mitchison young.jpg | commonswiki |
Rockledge2 | 225 | 225 | pd | PDM | File:White Lives Matter.jpg | commonswiki |
Photograph by the Arnamagnæan Collection, manuscript (Hauksbók) from the 14th century. | 290 | 91 | pd | PDM | File:Leifr hinn heppni.jpg | commonswiki |
Dzihi | 469 | 179 | cc-by-3.0 | CC BY 3.0 | File:Ondol.png | commonswiki |
Unknown author | 227 | 480 | pd | PDM | File:Byzantine castrato.jpg | commonswiki |
Presidential Communications Office | 87 | 143 | pd | PDM | File:2025-09-12 – FIVB VMWC 2025 Espejo (cropped).jpg | commonswiki |
Scott Teal | 159 | 190 | pd | PDM | File:Prince Tonga (Tonga 'Uli'uli Fifita) 1979.jpg | commonswiki |
Unknown author | 220 | 308 | pd | PDM | File:Jaswant Singh of Marwar.jpg | commonswiki |
Daehan | 206 | 293 | cc-by-sa-4.0 | CC BY-SA 4.0 | File:Angus Buchanan chest (cropped from Scotland rugbyteam 1871).png | commonswiki |
Unknown author | 202 | 205 | pd | PDM | File:Rustaveli damage 2004.jpg | commonswiki |
Zorandimitrovskiskopje | 260 | 165 | cc0 | CC0 | File:Sem-vaknin-naj-naj(3).jpg | commonswiki |
James Peter Quinn | 210 | 340 | pd | PDM | File:Lieutenant General Sir Harry Chauvel.jpg | commonswiki |
Leon de Cessac | 239 | 225 | pd | PDM | File:Rafael, a Chumash who shared cultural knowledge with Anthropologists.jpg | commonswiki |
Yonge, Charlotte Mary, (1823-1901) | 291 | 166 | pd | PDM | File:Young Folks' History of Rome illus430.png | commonswiki |
None | 248 | 250 | cc-by-sa-3.0 | CC BY-SA 3.0 | File:Nephrotic eyes.JPG | commonswiki |
Unknown author | 244 | 374 | pd | PDM | File:Tom Zenk 1986.jpg | commonswiki |
None | 188 | 250 | pd | PDM | File:Disinfection with mop.jpg | commonswiki |
None | 230 | 305 | pd | PDM | File:Draga mlada.jpg | commonswiki |
Pesum Padam | 178 | 210 | pd | PDM | File:YVRao.jpg | commonswiki |
David Neyland | 387 | 314 | pd | PDM | File:Speed is Life HTV-2 Reentry New.jpg | commonswiki |
NBC | 249 | 326 | pd | PDM | File:Craig Wasson 1980 press photo.jpg | commonswiki |
None | 245 | 300 | pd | PDM | File:QT - Antoine Galland.PNG | commonswiki |
mcclouds | 104 | 285 | cc-by-sa-2.0 | CC BY-SA 2.0 | File:Aaron Rowand Profile.jpg | commonswiki |
U.S. Mint, photograph by Turkmenistan | 150 | 151 | pd | PDM | File:COBREcentavosecuador2000-2.png | commonswiki |
Alex Ex - crop by Sposato from en.wikipedia | 170 | 234 | cc-by-sa-3.0 | CC BY-SA 3.0 | File:Bill Ward.jpg | commonswiki |
Unknown Miniaturist, English (active 1170s in Cirenchester) | 238 | 357 | pd | PDM | File:London. British Library, Cotton MS Claudius B II. f.341r (cropped).jpg | commonswiki |
www.davidmolloyphotography.com from Sydney, Australia | 197 | 242 | cc-by-2.0 | CC BY 2.0 | File:Codie Taylor thumb17.jpg | commonswiki |
Frans_Hals | 152 | 76 | pd | PDM | File:Signatur Frans Hals.PNG | commonswiki |
Grifone87 | 425 | 369 | cc-by-sa-2.5 | CC BY-SA 2.5 | File:Volleyball Half Court.png | commonswiki |
Unknown author | 209 | 216 | pd | PDM | File:Austin Friars Cromwell's house.png | commonswiki |
Unknown author | 250 | 378 | pd | PDM | File:Éxtasis tropical.jpg | commonswiki |
None | 250 | 377 | pd | PDM | File:Replay4166ZHz9Sb.jpg | commonswiki |
Unknown author | 243 | 384 | None | FAL | File:Saloma.jpg | commonswiki |
None | 193 | 274 | pd | PDM | File:Kralj Milan Obrenovic.jpg | commonswiki |
User:Tellerman | 180 | 270 | pd | PDM | File:JPReis.jpg | commonswiki |
Senato della Repubblica Italiana | 180 | 240 | cc-by-3.0-it | CC BY 3.0 IT | File:Mario Tronti datisenato 2013.jpg | commonswiki |
International Anti-Poaching Foundation | 187 | 264 | cc-by-sa-3.0 | CC BY-SA 3.0 | File:Damien Mander, 2010 (cropped).jpg | commonswiki |
EC Comics; later DC Comics (WarnerMedia) | 223 | 66 | pd | PDM | File:Mad magazine logo.png | commonswiki |
Thomas.ryckmans68 | 1,163 | 720 | cc-by-sa-4.0 | CC BY-SA 4.0 | File:Proteinogenic Amino Acid Table.png | commonswiki |
None | 250 | 115 | pd | PDM | File:LocationTrinidadAndTobago.png | commonswiki |
End of preview. Expand in Data Studio
Vector embeddings of images on Wikipedia using google/siglip2-base-patch16-384
Here's an example of how to use this
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "gradio",
# "torch",
# "transformers",
# "pyarrow",
# "numpy",
# "huggingface_hub",
# ]
# ///
"""
Semantic search over Wikipedia/Commons image embeddings (SigLIP 2).
Run locally:
VECTORS=/path/to/vectors.parquet uv run app.py
Or let it pull from the Hub:
uv run app.py
"""
import hashlib
import os
from urllib.parse import quote
import gradio as gr
import numpy as np
import pyarrow.parquet as pq
import torch
from transformers import AutoModel, AutoProcessor
CKPT = "google/siglip2-base-patch16-384"
REPO = "derenrich/wiki-image-vectors"
FILE = "vectors/enwiki_siglip2_b384_0000.parquet"
TOPK = 24
THUMB_W = 320
WIKI = "commons" # "commons" or "en"
# ---------------------------------------------------------------- data
def load_vectors():
path = os.environ.get("VECTORS")
if not path:
from huggingface_hub import hf_hub_download
path = hf_hub_download(REPO, FILE, repo_type="dataset")
tbl = pq.read_table(path)
title_col = "title" if "title" in tbl.column_names else "titles"
titles = tbl[title_col].to_pylist()
emb = np.stack(tbl["emb"].to_numpy(zero_copy_only=False)).astype(np.float32)
emb /= np.linalg.norm(emb, axis=1, keepdims=True) + 1e-12
return titles, emb
TITLES, E = load_vectors()
print(f"loaded {len(TITLES)} vectors, dim {E.shape[1]}")
model = AutoModel.from_pretrained(CKPT).eval()
processor = AutoProcessor.from_pretrained(CKPT)
# ---------------------------------------------------------------- urls
RASTERIZED = {"svg": ".png", "tif": ".jpg", "tiff": ".jpg",
"pdf": ".jpg", "djvu": ".jpg"}
def clean_title(title):
"""Strip File:/Image: prefix, underscore spaces, capitalize first char."""
name = title.split(":", 1)[-1] if title[:6].lower() in ("file:t", "image:") else title
if ":" in title[:6].lower():
name = title.split(":", 1)[-1]
else:
name = title
name = name.replace(" ", "_")
return name[:1].upper() + name[1:] if name else name
def thumb_url(title, width=330):
site, file_s, title = title.split(":", 2)
name = title.replace(" ", "_")
h = hashlib.md5(name.encode("utf-8")).hexdigest()
n = quote(name)
wiki = "commons"
if site == "enwiki":
wiki = "en"
url = (f"https://upload.wikimedia.org/wikipedia/{wiki}/thumb/"
f"{h[0]}/{h[:2]}/{n}/{width}px-{n}")
if title.lower().endswith(".svg"):
url += ".png"
elif title.lower().endswith(".tif"):
url += ".jpg"
elif title.lower().endswith(".stl"):
url += ".png"
return url
def file_page(title):
site, file_s, title = title.split(":", 2)
name = title.replace(" ", "_")
wiki_url = "https://commons.wikimedia.org/wiki/"
if site == "enwiki":
wiki_url = "https://en.wikipedia.org/wiki/"
return f"{wiki_url}File:{quote(title)}"
# ---------------------------------------------------------------- search
def text_search(query, k=TOPK):
if not query or not query.strip():
return []
inputs = processor(text=[query], padding="max_length",
truncation=True, return_tensors="pt")
with torch.inference_mode():
v = model.get_text_features(**inputs).pooler_output
v = (v / v.norm(dim=-1, keepdim=True)).numpy()[0].astype(np.float32)
return np.argsort(-(E @ v))[:k].tolist()
def similar(row, k=TOPK):
sims = E @ E[row]
sims[row] = -np.inf
return np.argsort(-sims)[:k].tolist()
# ---------------------------------------------------------------- render
CSS = """
#results { display: flex; flex-wrap: wrap; gap: 8px; }
#results figure { margin: 0; width: 200px; }
#results img {
width: 200px; height: 160px; object-fit: contain;
background: #fff; padding: 4px; border-radius: 6px;
border: 1px solid rgba(0,0,0,.12); cursor: pointer;
display: block;
}
#results img:hover { border-color: #36c; }
#results figcaption {
font-size: 11px; line-height: 1.3; margin-top: 4px;
max-height: 2.6em; overflow: hidden; opacity: .75;
}
#results figcaption a { color: inherit; }
#clickbox { display: none !important; }
"""
def render(idx, heading=""):
if not idx:
return "<p style='opacity:.6'>No results.</p>"
cards = []
for i in idx:
t = TITLES[i]
label = clean_title(t).rsplit(".", 1)[0].replace("_", " ")
safe = label.replace("&", "&").replace("<", "<").replace('"', """)
cards.append(
"<figure>"
f'<img src="{thumb_url(t)}" alt="{safe}" title="{safe}" '
f'loading="lazy" onclick="pickSimilar({i})">'
f'<figcaption><a href="{file_page(t)}" target="_blank" '
f'rel="noopener">{safe}</a></figcaption>'
"</figure>"
)
head = f"<p style='opacity:.7;font-size:13px'>{heading}</p>" if heading else ""
return head + f"<div id='results'>{''.join(cards)}</div>"
JS = """
function pickSimilar(row) {
const el = document.querySelector('#clickbox textarea, #clickbox input');
if (!el) { console.warn('clickbox not found'); return; }
el.value = row + ':' + Date.now();
el.dispatchEvent(new Event('input', { bubbles: true }));
}
"""
# ---------------------------------------------------------------- app
with gr.Blocks(css=CSS, head=f"<script>{JS}</script>",
title="Wikipedia image search") as demo:
gr.Markdown(
"## Wikipedia image semantic search\n"
f"{len(TITLES):,} images embedded with `{CKPT}`. "
"Search in any of ~109 languages. Click an image to find visually "
"similar ones."
)
query = gr.Textbox(
label="", placeholder="a cat sitting on a windowsill / Sonnenuntergang / 城の写真",
submit_btn=True,
)
clickbox = gr.Textbox(elem_id="clickbox")
results = gr.HTML()
def on_query(q):
return render(text_search(q), f'Results for "{q}"')
def on_click(payload):
if not payload:
return gr.skip()
row = int(payload.split(":")[0])
label = clean_title(TITLES[row]).rsplit(".", 1)[0].replace("_", " ")
return render(similar(row), f"Similar to: {label}")
query.submit(on_query, query, results)
clickbox.change(on_click, clickbox, results)
gr.Examples(
["aerial view of a city at night", "medieval manuscript illumination",
"coat of arms with a lion", "steam locomotive"],
inputs=query,
)
if __name__ == "__main__":
demo.launch(show_error=True)
- Downloads last month
- 66