LocDiff: Identifying Locations on Earth by Diffusing in the Hilbert Space

Zhangyu Wang, Zeping Liu, Jielu Zhang, Zhongliang Zhou, Qian Cao, Nemin Wu, Lan Mu, Yang Song, Yiqun Xie, Ni Lao, Gengchen Mai

TL;DR

LocDiff is a novel latent diffusion model that tackles image geolocalization by diffusing in a continuous "Hilbert space" of spherical harmonics rather than relying on discrete grids or raw coordinates. By representing locations as multi-scale Spherical Harmonics Dirac Delta (SHDD) coefficients, it achieves state-of-the-art accuracy and demonstrates significantly better generalization to unseen locations compared to traditional retrieval or classification-based models.

The Geolocalization Challenge

Where was this photo taken? This is the core question of image geolocalization. Traditionally, researchers have used two main approaches:

  1. Grid-based classification: Dividing the Earth into discrete cells and classifying the image into one of them.
  2. Gallery-based retrieval: Matching a query image against a massive database of geo-tagged images to find the closest visual match.

Both methods suffer from a "spatial gap" problem: if a test image comes from a location not well-represented in the predefined grid or the retrieval gallery, the model fails. Recently, generative models have attempted to regress raw coordinates (latitude and longitude) directly. However, these struggle with the non-linear complexity of global mapping and lack "multi-scale" information—the ability to simultaneously understand broad regional context (which continent) and fine-grained details (which street corner). Furthermore, performing diffusion directly on a spherical manifold (the Earth) introduces projection distortions and heavy computational overhead.

Introducing LocDiff

To address these limitations, the authors introduce LocDiff, which shifts the geolocalization problem from raw coordinate space to a latent coefficient space.

SHDD Representations

Instead of using raw $(lat, lon)$ coordinates, LocDiff represents a location as a Dirac delta function on a sphere. This function is decomposed into a vector of coefficients using Spherical Harmonics, creating a Spherical Harmonics Dirac Delta (SHDD) representation. This forms a "Hilbert space" that is dense, continuous, and inherently multi-scale (lower-degree coefficients represent coarse locations, while higher-degree ones represent fine details).

Comparison of positional encoding spaces

Latent Diffusion and CS-UNet

The model performs the diffusion process—gradually adding and then learning to remove Gaussian noise—within this SHDD coefficient space. This avoids the geometric distortions of diffusing on a 2D map or the need for expensive re-projections in 3D space.

To drive this process, LocDiff employs CS-UNet (Conditional Siren-UNet). This backbone is a UNet variant utilizing SirenNet (sinusoidal activation functions). Because spherical harmonics are themselves sums of sinusoids, SirenNet is mathematically aligned with the data representation, helping preserve gradients during the backward denoising process.

LocDiff Architecture and CS-UNet

Mode-Seeking Decoder

To convert the predicted coefficients back into a physical location, the model uses a learning-free decoder. This decoder identifies the "peak" (mode) of the probability distribution reconstructed from the spherical harmonics, effectively pinpointing the most likely coordinate on the globe.

Key Insights

  • The Hilbert Space Advantage: Moving to the SHDD space solves the "sparsity problem." In raw positional encoding, valid encodings are sparse, making diffusion training difficult. SHDD coefficients fill the space more densely, leading to more stable convergence.
  • Multi-Scale by Design: Because spherical harmonics are ordered by degree, the model naturally learns a spatial hierarchy. If the model is confident about the region but not the specific street, the low-degree coefficients remain intact while high-degree ones reflect higher uncertainty.
  • Generalization over Memorization: Retrieval models like GeoCLIP essentially "memorize" a gallery. When tested on a grid that doesn't match their gallery, their performance collapses. LocDiff, being truly generative and continuous, maintains high performance even when the "anchor points" used for decoding are changed or sparsified.

Datasets and Results

The model was trained on MP16 (MediaEval Placing Tasks 2016), containing 4.72 million geotagged images. Evaluation was conducted across five challenging benchmarks, including global-scale datasets (Im2GPS3k, YFCC26k, GWS15k) and generative comparison sets (OSV-5M, YFCC-4k). GWS15k was specifically used to test generalizability, as its spatial distribution differs significantly from the training set.

  • State-of-the-Art Performance: LocDiff outperformed major baselines like GeoCLIP, PIGEON, and Translocator across almost all spatial scales (from 1km "Street" level to 2500km "Continent" level).
  • Robust Generalization: On the GWS15k dataset, LocDiff showed a massive lead over retrieval models. While GeoCLIP's accuracy dropped significantly when using a non-optimized gallery, LocDiff remained stable.
  • Superior to Other Generative Models: Compared to other recent diffusion/flow-matching models, LocDiff achieved much higher accuracy (e.g., 33.3% vs 23.7% at the City scale on YFCC-4k).
  • Hybrid Power: A hybrid version (LocDiff-H), which uses LocDiff to narrow down candidates for a retrieval model, set new records for fine-grained accuracy (15.3% at the 1km scale on Im2GPS3k).

Limitations and Future Work

While LocDiff represents a significant leap forward, it has a few limitations. There is a numerical "ceiling" for the degree of spherical harmonics ($L$); going beyond $L=47$ (roughly 2304 dimensions) leads to numerical instability and potential overflows in probability computation. Additionally, like most diffusion models, LocDiff is slower during inference than single-pass retrieval models (0.056s vs 0.024s per image). Future work could involve using faster sampling techniques like DDIM or consistency models, and explicitly leveraging gallery information during the diffusion process to further improve fine-scale resolution.

Summary updated

BibTeX
@inproceedings{wang2025locdiff,
  author = {Zhangyu Wang and Zeping Liu and Jielu Zhang and Zhongliang Zhou and Qian Cao and Nemin Wu and Lan Mu and Yang Song and Yiqun Xie and Ni Lao and Gengchen Mai},
  title = {{LocDiff: Identifying Locations on Earth by Diffusing in the Hilbert Space}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=ghybX0Qlls},
}
Figure