Update README.md
Browse files
README.md
CHANGED
|
@@ -6,11 +6,49 @@ tags: []
|
|
| 6 |
# Model Card for Model ID
|
| 7 |
|
| 8 |
lat_mean = 39.95164939753852
|
|
|
|
| 9 |
lat_std = 0.0007290994359226359
|
|
|
|
| 10 |
lon_mean = -75.191420541785
|
|
|
|
| 11 |
lon_std = 0.000733160718757529
|
| 12 |
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
## Model Details
|
| 16 |
|
|
|
|
| 6 |
# Model Card for Model ID
|
| 7 |
|
| 8 |
lat_mean = 39.95164939753852
|
| 9 |
+
|
| 10 |
lat_std = 0.0007290994359226359
|
| 11 |
+
|
| 12 |
lon_mean = -75.191420541785
|
| 13 |
+
|
| 14 |
lon_std = 0.000733160718757529
|
| 15 |
|
| 16 |
|
| 17 |
+
```python
|
| 18 |
+
model_name = "AppliedMLReedShreya/ViT_Attempt_1"
|
| 19 |
+
config = AutoConfig.from_pretrained(model_name)
|
| 20 |
+
config.num_labels = 2 # We need two outputs: latitude and longitude
|
| 21 |
+
|
| 22 |
+
# Load the pre-trained ViT model
|
| 23 |
+
vit_model = AutoModelForImageClassification.from_pretrained(model_name, config=config)
|
| 24 |
+
|
| 25 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 26 |
+
print(f'Using device: {device}')
|
| 27 |
+
vit_model = vit_model.to(device)
|
| 28 |
+
|
| 29 |
+
# Initialize lists to store predictions and actual values
|
| 30 |
+
all_preds = []
|
| 31 |
+
all_actuals = []
|
| 32 |
+
|
| 33 |
+
vit_model.eval()
|
| 34 |
+
with torch.no_grad():
|
| 35 |
+
for images, gps_coords in val_dataloader:
|
| 36 |
+
images, gps_coords = images.to(device), gps_coords.to(device)
|
| 37 |
+
|
| 38 |
+
outputs = vit_model(images).logits
|
| 39 |
+
|
| 40 |
+
# Denormalize predictions and actual values
|
| 41 |
+
preds = outputs.cpu() * torch.tensor([lat_std, lon_std]) + torch.tensor([lat_mean, lon_mean])
|
| 42 |
+
actuals = gps_coords.cpu() * torch.tensor([lat_std, lon_std]) + torch.tensor([lat_mean, lon_mean])
|
| 43 |
+
|
| 44 |
+
all_preds.append(preds)
|
| 45 |
+
all_actuals.append(actuals)
|
| 46 |
+
|
| 47 |
+
# Concatenate all batches
|
| 48 |
+
all_preds = torch.cat(all_preds).numpy()
|
| 49 |
+
all_actuals = torch.cat(all_actuals).numpy()
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
|
| 53 |
## Model Details
|
| 54 |
|