Have you hear of Geoguessr ? If not, you definetly should try :). It's a game were you randomly land somewhere on Earth (if there is Google StreetView coverage) and guess where you are based on what you see.
Now, what would happen if an AI with all StreetView coverage knowledge could play? That's what we tried to see on a much smaller scale. Since Streetview image aren't publicly available, we had to find a dataset of images scraped from StreetView in big cities.
Our AI is an supervised classifier.
We tried multiple models for our AI
- MLPClassifier
- DecisionTree Classifier
- SVC
- Perceptron
- GaussianNB
- EfficientNet B0
With EfficientNet B0 being the most successful one and the one we are presenting.
We have "high resolution" images (400x400) and (640x480) and could benefited from model pretrained on bigger images such as bigger EfficientNet but we found out that it was too demanding for our personnal computers to be trained in a reasonnable amount of time.
We have only been able to train and infer with CUDA, CPU was way too slow and we didn't had the appropriate hardware for ROCm or MPS.
- Get dataset from https://www.kaggle.com/datasets/amaralibey/gsv-cities
- Extract it and copy the content of the
Imagesfolder into thedata/trainfolder in our projet.
We have removed the Medelin folder because it has significantly fewer images than other cities and may contribute to biased models, you might want to do the same.
It should now looks like this
capitalguessr/
- data/
- train/
- Bangkok/
- Barcelona/
- Boston/
...
- models/
- old/
- constants.py
- constants.py
- README.md
- requirements.pyNotes: Before installing dependencies, you might want to create a python venv using python3 -m venv .venv and activating it using .\venv\Scripts\Activate.ps1 on Windows.
Then proceed to install pytorch with the pip instruction for your system following instructions from (https://pytorch.org/get-started/locally/#start-locally) and other non specific dependencies using pip.
pip install -r requirements.txt-s: split data between train and test
-b: remove blur images (veryyy veryyyyy long)
python prepare_data.py -s (-b)This step will remove images considered too blury and split them into 2 types: training and testing. Your folder data should now looks like the following.
data/
- test/
- Bangkok/
- Barcelona/
...
- train/
- Bangkok/
- Barcelona/
...Edit ROOT_FOLDER in constants.py to match the location of our project on your system.
Open capitalgssr.ipynb and select your Python kernel to run cells from the notebook (only Python 3.11 and 3.12 versions have been tested)
Now run all cells until the "Tests" section.
Pick an image from a city in our test data, from internet, or even your own and copy its ABSOLUTE in the test_image variable (in the last cell) and execute the cell, you should have a matplotlib graph showing what the AI is predicting the picture to be located in.
