This repository contains a PyTorch implementation of SimCLR (Simple Framework for Contrastive Learning of Visual Representations) adapted for Remote Sensing tasks, specifically Land Use Classification on the UC Merced dataset.
SimCLR-RemoteSensing/
├── app.py # Streamlit Production Demo
├── data/ # Dataset storage
├── notebooks/ # Jupyter Notebooks (Colab)
├── scripts/
│ ├── train.py # Training/Fine-tuning script
│ └── visualize.py # t-SNE Visualization script
├── src/
│ ├── model.py # SimCLR Model Definition
│ └── __init__.py
└── requirements.txt # Dependencies
-
Install Dependencies:
pip install -r requirements.txt
-
Download Pretrained Weights: Ensure
simclr_model_RN101.pth(pretrained on EuroSAT) is in the root directory orscripts/folder as needed.
To fine-tune the ResNet-101 backbone on the UC Merced dataset:
python scripts/train.pyThis will:
- Download the UC Merced dataset automatically.
- Load the pretrained SimCLR weights.
- Fine-tune the model.
- Save the best model as
finetuned_simclr_ucmerced.pth(or similar).
To generate a 3D t-SNE animation of the embeddings:
python scripts/visualize.pyTo run the interactive web interface:
streamlit run app.pyUpload an aerial image to get a classification prediction.
This repository includes a .gitignore to exclude large model files and data.
- Initialize a git repo:
git init - Commit your code:
git add . && git commit -m "Initial commit" - Push to GitHub.
Since the model (.pth) is too large for GitHub (>100MB):
- Upload your
finetuned_simclr_ucmerced.pthto a cloud provider (Google Drive, Dropbox, Hugging Face). - Get a direct download link.
- Update
MODEL_URLinapp.pywith this link.
- Go to share.streamlit.io.
- Connect your GitHub repository.
- Deploy! The app will automatically download the model from your link on startup.
- Backbone: ResNet-101
- Pretraining: SimCLR on EuroSAT (Sentinel-2)
- Downstream: Fine-tuned on UC Merced (Aerial Imagery)