arham061/Image-geolocation-challenge
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
Image Geolocation Challenge
An image geolocation project developed for my Deep Learning course. The model predicts latitude and longitude from a photograph using MobileViTV2, country classification, and geographic cells.
The final system achieved a 199.06 km median error on the validation split, with approximately 4.44 million parameters.
Try the live demo · Read the report · Explore the notebooks
Results
These results are from the validation split used during development. They are not scores on the unlabeled holdout set or a guarantee of accuracy on new uploads.
How it works
The model predicts probabilities for 12 countries and 96 geographic cells, with eight cells per country.
Each cell's probability is multiplied by the probability of its country. After normalization, the model calculates coordinates as a weighted average of the cell centres.
The final prediction uses the same trained model at two input resolutions:
- 384 × 384 and 512 × 512 inputs
- Equal averaging of the two sets of output logits
- Country temperature of 0.25
- Cell temperature of 0.75
Temperature scaling changes how concentrated the probabilities are before country gating. Both resolutions use the same model weights.
Experiments
The notebooks record the development process, including experiments that did not improve the results:
- Direct coordinate regression
- Auxiliary country classification
- Blending coordinates with country-centre estimates
- Geographic-cell classification
- Cell-only fine-tuning
- Country-gated cells
- Temperature scaling and gating ablations
- Balancing the number of training images per cell
- Higher-resolution training and fine-tuning
- Combining predictions at two resolutions
Increasing the input resolution produced some of the largest later improvements. Balanced cells and additional temperature tuning gave smaller or inconsistent gains.
The report discusses the experiments and their limitations in more detail.
Run the app locally
Clone the repository:
git clone https://github.com/arham061/image-geolocation-challenge.git
cd image-geolocation-challengeCreate and activate a virtual environment:
python -m venv .venv
source .venv/bin/activateInstall the dependencies:
python -m pip install -r submission/requirements.txt
python -m pip install gradio torchvisionStart the app:
python app.pyOpen the local URL printed in the terminal. Upload a photograph to see the predicted country, coordinates, and an OpenStreetMap link.
The app uses CUDA when available and otherwise runs on CPU. It expects the exported model files in submission/model/.
The hosted Hugging Face version includes the additional ZeroGPU integration needed by that hosting environment.
Submission files
The submission/ directory contains:
model/: exported weights, model configuration, preprocessing configuration, and inference settingspredict.py: generates predictions for the holdout imagesevaluate.py: compares predictions with labeled coordinatestrain.py: training coderequirements.txt: project dependenciespredictions.csv: generated holdout predictions- Report files
To run the holdout prediction script from the repository root:
python submission/predict.pyIt expects images in geo_dataset/holdout_public/ and writes submission/predictions.csv.
To evaluate predictions against a corresponding labels file:
python submission/evaluate.py \
--labels path/to/labels.csv \
--predictions path/to/predictions.csvThe labels CSV must contain filename, lat, and lng. The predictions CSV must contain filename, pred_lat, and pred_lng.
The dataset is not included in this repository.
Limitations
The model was trained on images from Belarus, Finland, France, Germany, Iceland, Italy, Norway, Poland, Spain, Sweden, Turkey, and the United Kingdom.
It will still produce coordinates for images from other countries, but those predictions should not be considered reliable. Images with few geographic clues or different subjects and framing from the training data can also produce large errors.
The predicted country and final coordinates may disagree because the coordinates are averaged across multiple cell centres.
The validation split was used repeatedly to select experiments and inference settings, so the reported result may be optimistic compared with performance on unseen data.
Training hardware
Training used an NVIDIA RTX 4000 Ada Generation GPU with approximately 20 GB of VRAM.
Acknowledgements
The backbone is Apple's pretrained MobileViTV2 model, used through Hugging Face Transformers.
The demo uses Gradio and is hosted on Hugging Face Spaces. References and further methodological details are included in the report.
License
See LICENSE.
