Update README.md
Browse files
README.md
CHANGED
|
@@ -1 +1,39 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Google ViT Model
|
| 2 |
+
|
| 3 |
+
## Model Class
|
| 4 |
+
|
| 5 |
+
```python
|
| 6 |
+
base_model = ViTModel.from_pretrained("google/vit-base-patch16-224-in21k")
|
| 7 |
+
|
| 8 |
+
class ViTForRegression(nn.Module):
|
| 9 |
+
def __init__(self, base_model, num_outputs=2):
|
| 10 |
+
super(ViTForRegression, self).__init__()
|
| 11 |
+
self.base_model = base_model
|
| 12 |
+
hidden_size = base_model.config.hidden_size
|
| 13 |
+
self.regression_head = nn.Linear(hidden_size, num_outputs)
|
| 14 |
+
|
| 15 |
+
def forward(self, pixel_values):
|
| 16 |
+
outputs = self.base_model(pixel_values=pixel_values)
|
| 17 |
+
pooler_output = outputs.pooler_output
|
| 18 |
+
predictions = self.regression_head(pooler_output)
|
| 19 |
+
return predictions
|
| 20 |
+
|
| 21 |
+
model = ViTForRegression(base_model).to(device)
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
## How to Run
|
| 25 |
+
In the notebook ViT.ipynb, replace the line:
|
| 26 |
+
```python
|
| 27 |
+
dataset_test = load_dataset("gydou/released_img")
|
| 28 |
+
```
|
| 29 |
+
with the proper location of the testing dataset.
|
| 30 |
+
|
| 31 |
+
NOTE: No .pth file, this model did not perform well enough on sample test dataset.
|
| 32 |
+
|
| 33 |
+
## Training Dataset Statistics
|
| 34 |
+
```python
|
| 35 |
+
lat_std = 0.0006914493505038013
|
| 36 |
+
lon_std = 0.0006539239061573955
|
| 37 |
+
lat_mean = 39.9517411499467
|
| 38 |
+
lon_mean = -75.19143213125122
|
| 39 |
+
```
|