File size: 2,994 Bytes
983931b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
---
license: mit
tags:
- image-classification
- remote-sensing
- resnet
- pytorch
- transformers
- self-supervised-learning
- contrastive-learning
- moco
---

# MoCo-TP-ResNet-50

ResNet-50 model pre-trained using MoCo-v2 with Temporal Pairing (TP) for geography-aware self-supervised learning on remote sensing images.

## Model Details

- **Architecture:** ResNet-50
- **Pre-training:** MoCo-v2 with Temporal Pairing (TP)
- **Input size:** 224×224×3
- **Feature dimension:** 2048 (before classification head)
- **Parameters:** ~23.6M
- **Training:** Self-supervised pre-training on fMoW dataset (200 epochs)

## Usage

### Feature Extraction

```python
from transformers import AutoModelForImageClassification
import torch

# Load model for feature extraction
model = AutoModelForImageClassification.from_pretrained(
    "BiliSakura/MoCo-TP-ResNet-50",
    trust_remote_code=True
)

# Inference - extract features
model.eval()
input_image = torch.randn(1, 3, 224, 224)  # (batch, channels, height, width)

with torch.no_grad():
    outputs = model(pixel_values=input_image, return_dict=True)
    features = outputs["features"]  # Shape: (1, 2048)
```

### Fine-tuning for Classification

To fine-tune the model for a specific classification task, you can add a classification head:

```python
from transformers import AutoModelForImageClassification, AutoConfig
import torch.nn as nn

# Load config and modify num_labels
config = AutoConfig.from_pretrained(
    "BiliSakura/MoCo-TP-ResNet-50",
    trust_remote_code=True
)
config.num_labels = 10  # Your number of classes

# Load model
model = AutoModelForImageClassification.from_pretrained(
    "BiliSakura/MoCo-TP-ResNet-50",
    config=config,
    trust_remote_code=True
)

# The model will automatically replace the identity head with a classification head
# Now you can fine-tune on your dataset
```

## Model Architecture

The model consists of:
- **Backbone:** ResNet-50 (conv1, bn1, layer1-4)
- **Feature extractor:** Adaptive average pooling + flattening
- **Classification head:** Linear layer (2048 -> num_labels), or Identity for feature extraction

## Pre-training Details

This model was pre-trained using:
- **Method:** MoCo-v2 (Momentum Contrast) with Temporal Pairing
- **Dataset:** fMoW (Functional Map of the World)
- **Epochs:** 200
- **Loss:** Contrastive Predictive Coding (CPC)
- **Augmentation:** MoCo v2 augmentation (random resized crop, color jitter, grayscale, Gaussian blur)

## Citation

If you use this model, please cite the original Geography-Aware SSL paper:

```bibtex
@article{ayush2021geography,
    title={Geography-Aware Self-Supervised Learning},
    author={Ayush, Kumar and Uzkent, Burak and Meng, Chenlin and Tanmay, Kumar and Burke, Marshall and Lobell, David and Ermon, Stefano},
    journal={ICCV},
    year={2021}
}
```

**Original Repository:** [sustainlab-group/geography-aware-ssl](https://github.com/sustainlab-group/geography-aware-ssl)

## License

MIT License - for academic use only.