# mohanmanideep/geomatch architecture

> Architecture diagram of the GitHub repository mohanmanideep/geomatch, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohanmanideep/geomatch
- Repository: https://github.com/mohanmanideep/geomatch

## Overview

GeoMatch predicts a photo’s latitude/longitude by retrieving the closest match from a bank of labelled training images. Its main workflow transforms an image into three views, encodes global and local visual features, searches a descriptor bank, reranks a shortlist, and returns the best match’s coordinates. Training is a separate two-stage workflow: BYOL backbone pretraining followed by country-aware retrieval fine-tuning. The graph preserves the documented teacher-cache and fold-training capabilities; source excerpts are partial, so some implementation-level connections are omitted.

Main entry points: [`src/country_aware_retrieval_finetune.py`](https://github.com/mohanmanideep/geomatch/blob/main/src/country_aware_retrieval_finetune.py) (Country-aware fine-tuning), [`src/retrieval_model.py`](https://github.com/mohanmanideep/geomatch/blob/main/src/retrieval_model.py) (Retrieval heads), [`artifacts/teacher_cache`](https://github.com/mohanmanideep/geomatch/tree/main/artifacts/teacher_cache) (Teacher targets), [`src/full_data_finetune.py`](https://github.com/mohanmanideep/geomatch/blob/main/src/full_data_finetune.py) (All-data fine-tuning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Data and views"]
  node_photo["Input photo"]
  node_view_pipeline["Three-view transform<br/>[data.py]"]
  node_image_bank[("Training image bank")]
end

subgraph group_architecture["Visual retrieval"]
  node_base_model["RegNet encoder<br/>[model.py]"]
  node_retrieval_model["Retrieval heads<br/>[retrieval_model.py]"]
  node_retrieval_common["Search and geo utilities"]
  node_retrieval_objective["Retrieval losses"]
  node_scoring["Geographic scoring<br/>[scoring.py]"]
end

subgraph group_training["Model training"]
  node_ssl_pretrain["BYOL pretraining"]
  node_backbone_weights[("Fold backbones")]
  node_teacher_builder["Teacher cache builder"]
  node_teacher_cache[("Teacher targets")]
  node_spatial_trainer["Spatial retrieval trainer"]
  node_country_trainer["Country-aware fine-tuning"]
  node_full_trainer["All-data fine-tuning"]
  node_joint_objective["Joint geo objective<br/>[joint_objective.py]"]
  node_training_support["EMA and checkpoints<br/>[training.py]"]
end

subgraph group_runtime["Prediction"]
  node_predictor["Holdout prediction<br/>[predict_holdout.py]"]
  node_prediction["Coordinate prediction<br/>[predictions.csv]"]
end

node_user(("Photo submitter"))

node_user -->|"submits"| node_photo
node_photo -->|"transformed into views"| node_view_pipeline
node_view_pipeline -->|"encodes views"| node_retrieval_model
node_base_model -->|"extended by"| node_retrieval_model
node_retrieval_model -->|"produces descriptors for search"| node_retrieval_common
node_image_bank -->|"supplies candidate bank"| node_retrieval_common
node_retrieval_common -->|"ranks candidates geographically"| node_scoring
node_scoring -->|"provides best-match coordinate"| node_predictor
node_user -->|"requests holdout prediction"| node_predictor
node_predictor -->|"writes predictions"| node_prediction
node_ssl_pretrain -->|"pretrains backbone"| node_base_model
node_ssl_pretrain -->|"saves fold weights"| node_backbone_weights
node_backbone_weights -->|"initializes encoder"| node_country_trainer
node_country_trainer -->|"uses training components"| node_spatial_trainer
node_country_trainer -->|"optimizes retrieval losses"| node_retrieval_objective
node_country_trainer -->|"uses spatial losses"| node_joint_objective
node_teacher_builder -->|"builds cached targets"| node_teacher_cache
node_teacher_cache -->|"provides distillation targets"| node_country_trainer
node_teacher_cache -->|"provides training targets"| node_full_trainer
node_full_trainer -->|"fine-tunes final model"| node_retrieval_model
node_country_trainer -->|"uses EMA and checkpoint utilities"| node_training_support
node_full_trainer -->|"uses training utilities"| node_training_support

click node_view_pipeline "https://github.com/mohanmanideep/geomatch/blob/main/src/data.py"
click node_image_bank "https://github.com/mohanmanideep/geomatch/tree/main/artifacts/fold_assignments"
click node_base_model "https://github.com/mohanmanideep/geomatch/blob/main/src/model.py"
click node_retrieval_model "https://github.com/mohanmanideep/geomatch/blob/main/src/retrieval_model.py"
click node_retrieval_common "https://github.com/mohanmanideep/geomatch/blob/main/src/retrieval_common.py"
click node_retrieval_objective "https://github.com/mohanmanideep/geomatch/blob/main/src/retrieval_objective.py"
click node_scoring "https://github.com/mohanmanideep/geomatch/blob/main/src/scoring.py"
click node_ssl_pretrain "https://github.com/mohanmanideep/geomatch/blob/main/src/ssl_pretrain_backbone.py"
click node_backbone_weights "https://github.com/mohanmanideep/geomatch/tree/main/artifacts/ssl_backbone"
click node_teacher_builder "https://github.com/mohanmanideep/geomatch/blob/main/src/build_teacher_cache.py"
click node_teacher_cache "https://github.com/mohanmanideep/geomatch/tree/main/artifacts/teacher_cache"
click node_spatial_trainer "https://github.com/mohanmanideep/geomatch/blob/main/src/spatial_retrieval_finetune.py"
click node_country_trainer "https://github.com/mohanmanideep/geomatch/blob/main/src/country_aware_retrieval_finetune.py"
click node_full_trainer "https://github.com/mohanmanideep/geomatch/blob/main/src/full_data_finetune.py"
click node_joint_objective "https://github.com/mohanmanideep/geomatch/blob/main/src/joint_objective.py"
click node_training_support "https://github.com/mohanmanideep/geomatch/blob/main/src/training.py"
click node_predictor "https://github.com/mohanmanideep/geomatch/blob/main/src/predict_holdout.py"
click node_prediction "https://github.com/mohanmanideep/geomatch/blob/main/predictions.csv"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_photo,node_view_pipeline,node_image_bank toneBlue
class node_base_model,node_retrieval_model,node_retrieval_common,node_retrieval_objective,node_scoring toneAmber
class node_ssl_pretrain,node_backbone_weights,node_teacher_builder,node_teacher_cache,node_spatial_trainer,node_country_trainer,node_full_trainer,node_joint_objective,node_training_support toneMint
class node_predictor,node_prediction toneRose
class node_user toneIndigo
```

## Components

### Data and views

- **Input photo**
- [Three-view transform](https://github.com/mohanmanideep/geomatch/blob/main/src/data.py): `src/data.py`
- [Training image bank](https://github.com/mohanmanideep/geomatch/tree/main/artifacts/fold_assignments): `artifacts/fold_assignments`

### Visual retrieval

- [RegNet encoder](https://github.com/mohanmanideep/geomatch/blob/main/src/model.py): `src/model.py`
- [Retrieval heads](https://github.com/mohanmanideep/geomatch/blob/main/src/retrieval_model.py): `src/retrieval_model.py`
- [Search and geo utilities](https://github.com/mohanmanideep/geomatch/blob/main/src/retrieval_common.py): `src/retrieval_common.py`
- [Retrieval losses](https://github.com/mohanmanideep/geomatch/blob/main/src/retrieval_objective.py): `src/retrieval_objective.py`
- [Geographic scoring](https://github.com/mohanmanideep/geomatch/blob/main/src/scoring.py): `src/scoring.py`

### Model training

- [BYOL pretraining](https://github.com/mohanmanideep/geomatch/blob/main/src/ssl_pretrain_backbone.py): `src/ssl_pretrain_backbone.py`
- [Fold backbones](https://github.com/mohanmanideep/geomatch/tree/main/artifacts/ssl_backbone): `artifacts/ssl_backbone`
- [Teacher cache builder](https://github.com/mohanmanideep/geomatch/blob/main/src/build_teacher_cache.py): `src/build_teacher_cache.py`
- [Teacher targets](https://github.com/mohanmanideep/geomatch/tree/main/artifacts/teacher_cache): `artifacts/teacher_cache`
- [Spatial retrieval trainer](https://github.com/mohanmanideep/geomatch/blob/main/src/spatial_retrieval_finetune.py): `src/spatial_retrieval_finetune.py`
- [Country-aware fine-tuning](https://github.com/mohanmanideep/geomatch/blob/main/src/country_aware_retrieval_finetune.py): `src/country_aware_retrieval_finetune.py`
- [All-data fine-tuning](https://github.com/mohanmanideep/geomatch/blob/main/src/full_data_finetune.py): `src/full_data_finetune.py`
- [Joint geo objective](https://github.com/mohanmanideep/geomatch/blob/main/src/joint_objective.py): `src/joint_objective.py`
- [EMA and checkpoints](https://github.com/mohanmanideep/geomatch/blob/main/src/training.py): `src/training.py`

### Prediction

- [Holdout prediction](https://github.com/mohanmanideep/geomatch/blob/main/src/predict_holdout.py): `src/predict_holdout.py`
- [Coordinate prediction](https://github.com/mohanmanideep/geomatch/blob/main/predictions.csv): `predictions.csv`

### Other components

- **Photo submitter**

## Connections

- Photo submitter → Input photo: submits (evidence: `README.md`)
- Input photo → Three-view transform: transformed into views (evidence: `README.md`)
- Three-view transform → Retrieval heads: encodes views (evidence: `README.md`)
- RegNet encoder → Retrieval heads: extended by (evidence: `src/retrieval_model.py`)
- Retrieval heads → Search and geo utilities: produces descriptors for search (evidence: `README.md`)
- Training image bank → Search and geo utilities: supplies candidate bank (evidence: `README.md`)
- Search and geo utilities → Geographic scoring: ranks candidates geographically (evidence: `README.md`)
- Geographic scoring → Holdout prediction: provides best-match coordinate (evidence: `README.md`)
- Photo submitter → Holdout prediction: requests holdout prediction (evidence: `README.md`)
- Holdout prediction → Coordinate prediction: writes predictions (evidence: `README.md`)
- BYOL pretraining → RegNet encoder: pretrains backbone (evidence: `README.md`)
- BYOL pretraining → Fold backbones: saves fold weights (evidence: `README.md`)
- Fold backbones → Country-aware fine-tuning: initializes encoder (evidence: `README.md`)
- Country-aware fine-tuning → Spatial retrieval trainer: uses training components (evidence: `src/country_aware_retrieval_finetune.py`)
- Country-aware fine-tuning → Retrieval losses: optimizes retrieval losses (evidence: `README.md`)
- Country-aware fine-tuning → Joint geo objective: uses spatial losses (evidence: `src/country_aware_retrieval_finetune.py`)
- Teacher cache builder → Teacher targets: builds cached targets (evidence: `README.md`)
- Teacher targets → Country-aware fine-tuning: provides distillation targets (evidence: `README.md`)
- Teacher targets → All-data fine-tuning: provides training targets (evidence: `src/full_data_finetune.py`)
- All-data fine-tuning → Retrieval heads: fine-tunes final model (evidence: `README.md`)
- Country-aware fine-tuning → EMA and checkpoints: uses EMA and checkpoint utilities (evidence: `src/country_aware_retrieval_finetune.py`)
- All-data fine-tuning → EMA and checkpoints: uses training utilities (evidence: `src/full_data_finetune.py`)
