geoguessr-clip-vitb16
Predicts the country of a street-level photo, choosing one of 33 countries.
This is the vision encoder of openai/clip-vit-base-patch16,
fine-tuned with a linear probe followed by full fine-tuning (LP-FT), plus a
classification head initialised from the text embeddings of the prompt
A street view photo taken in {}.. Training data: a subset of
OpenStreetView-5M. Code, training details and the full analysis:
https://github.com/Daggerabuse/geoguessr-ai
Countries
Argentina (AR), Austria (AT), Australia (AU), Brazil (BR), Canada (CA), Chile (CL), Colombia (CO), Germany (DE), Denmark (DK), Spain (ES), Finland (FI), France (FR), United Kingdom (GB), Ghana (GH), Indonesia (ID), Ireland (IE), India (IN), Italy (IT), Japan (JP), Morocco (MA), Mexico (MX), Nigeria (NG), Norway (NO), New Zealand (NZ), Poland (PL), Portugal (PT), Russia (RU), Sweden (SE), Thailand (TH), Turkey (TR), Taiwan (TW), United States (US), South Africa (ZA)
The model always answers with one of these countries, even for a photo taken elsewhere.
Test results
Test split of the project's OSV-5M subset (read from results/*/test_metrics.json in the
GitHub repo). TTA averages the logits of the left, center and right crops.
| Model | Test top-1 | Test top-5 | n |
|---|---|---|---|
| CLIP ViT-B/16, zero-shot (reference) | 0.468 | 0.830 | 6600 |
| This model, center crop | 0.708 | 0.925 | 6600 |
| This model, TTA (3 crops) | 0.732 | 0.935 | 6600 |
Usage
import json
import torch
from huggingface_hub import snapshot_download
from safetensors.torch import load_file
from transformers import CLIPVisionModelWithProjection
path = snapshot_download("Daggerabuse/geoguessr-clip-vitb16")
vision = CLIPVisionModelWithProjection.from_pretrained(path).eval()
head = load_file(f"{path}/head.safetensors")["head"]
cfg = json.load(open(f"{path}/inference_config.json"))
classes = json.load(open(f"{path}/classes.json"))
# pixel_values: (n_crops, 3, S, S), preprocessed as described in inference_config.json
with torch.no_grad():
emb = torch.nn.functional.normalize(vision(pixel_values=pixel_values).image_embeds, dim=-1)
w = torch.nn.functional.normalize(head, dim=-1)
logits = (cfg["logit_scale"] * emb @ w.T).mean(0) # mean over the TTA crops
inference_config.json describes the preprocessing: short side resized to
image_size (bicubic), square crop(s), CLIP mean/std normalization. Do not flip the
image: the driving side is a cue the model uses.
Limitations
- Only 33 countries; they do not represent the world, and the results are not comparable to published OSV-5M benchmarks (different country set and metrics).
- A single training run with a single seed; the variance of training is unknown.
- The validation split comes from the same pool as training (split by sequence), so it is optimistic; compare models on the test split.
- TTA was selected on the validation split; its test gain is a single measurement.
- There is a clear gap between train and validation accuracy (over-fitting).
- Trained on OSV-5M street-level imagery; other kinds of photos (indoor, aerial, close-ups) are out of distribution.
License
The weights are released under CC BY-SA 4.0, because they are derived from OpenStreetView-5M (CC BY-SA 4.0). The base model is openai/clip-vit-base-patch16. The project code is MIT licensed (https://github.com/Daggerabuse/geoguessr-ai).
Data source and citation
Data: OpenStreetView-5M, Astruc et al., CVPR 2024.
@inproceedings{osv5m,
title = {{OpenStreetView-5M}: {T}he Many Roads to Global Visual Geolocation},
author = {Astruc, Guillaume and Dufour, Nicolas and Siglidis, Ioannis and Aronssohn, Constantin
and Bouia, Nacim and Fu, Stephanie and Loiseau, Romain and Nguyen, Van Nguyen
and Raude, Charles and Vincent, Elliot and Xu, Lintao and Zhou, Hongyu and Landrieu, Loic},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
year = {2024}
}