Canadian Street View Classifier

This repository contains multiple deep learning models for classifying street view images in Canadian cities. The repo is structured to allow easy addition of new models and collaborative contributions.

Models Included

  • swinv2
  • convnext

What does it do

Both models take as input, a streetview image of a city in Canada, and outputs its predicted city. The following cities are included:

Calgary, Charlottetown, Edmonton, Halifax, Hamilton, Kitchener-Waterloo, Montreal, Ottawa-Gatineau, Quebec City, Saskatoon, St Johns, Toronto, Vancouver, Victoria, Winnipeg

Demo

Try the model live in a Space: Canadian StreetView Classifier

Installation

pip install torch torchvision timm huggingface_hub

Usage Example

from huggingface_hub import hf_hub_download
import torch
import timm
from PIL import Image
from torchvision import transforms

# Download model weights (ViT example)
vit_path = hf_hub_download(
    repo_id="3106Project/canadian_streetview_cities_models",
    filename="vit_model/swinv2_base_window12_192_0_finetuned_canadian_streetview.bin"
)

# Initialize model
model = timm.create_model("swinv2_base_window12_192", pretrained=False, num_classes=15)
model.load_state_dict(torch.load(vit_path, map_location="cpu"))
model.eval()

# Transform and predict
transform = transforms.Compose([
    transforms.Resize((192, 192)),
    transforms.ToTensor(),
    transforms.Normalize(mean=(0.5,0.5,0.5), std=(0.5,0.5,0.5))
])

class_names = [
    "Calgary", "Charlottetown", "Edmonton", "Halifax", "Hamilton",
    "Kitchener-Waterloo", "Montreal", "Ottawa-Gatineau", "Quebec City", "Saskatoon",
    "St Johns", "Toronto", "Vancouver", "Victoria", "Winnipeg",
]

# Make prediction
img = Image.open("beauty.jpg").convert("RGB")
x = transform(img).unsqueeze(0)
with torch.no_grad():
    pred = model(x)
print(class_names[pred.argmax().item()])

Citation

If you use this dataset or models, please cite:

  1. Stephen Rebel, Danial McIntyre, Sharav Bali. Canadian Street View Classifier. Hugging Face, 2025.
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for canada-guesser/canadian_streetview_cities_models

Finetuned
(1)
this model

Dataset used to train canada-guesser/canadian_streetview_cities_models

Space using canada-guesser/canadian_streetview_cities_models 1