ezelpub commited on
Commit
b99fccb
·
verified ·
1 Parent(s): 4fc1141

Update the Readme.md file

Browse files
Files changed (1) hide show
  1. README.md +56 -1
README.md CHANGED
@@ -6,4 +6,59 @@ tags:
6
 
7
  This model has been pushed to the Hub using the [PytorchModelHubMixin](https://huggingface.co/docs/huggingface_hub/package_reference/mixins#huggingface_hub.PyTorchModelHubMixin) integration:
8
  - Library: [More Information Needed]
9
- - Docs: [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  This model has been pushed to the Hub using the [PytorchModelHubMixin](https://huggingface.co/docs/huggingface_hub/package_reference/mixins#huggingface_hub.PyTorchModelHubMixin) integration:
8
  - Library: [More Information Needed]
9
+ - Docs: [More Information Needed]
10
+ # Image to GPS Model: DINO-ResNet Fusion
11
+
12
+ ## Training Data Statistics
13
+ The following mean and standard deviation values were used to normalize the GPS coordinates:
14
+
15
+ - **Latitude Mean**: {lat_mean:.6f}
16
+ - **Latitude Std**: {lat_std:.6f}
17
+ - **Longitude Mean**: {lon_mean:.6f}
18
+ - **Longitude Std**: {lon_std:.6f}
19
+
20
+ ## How to use the model
21
+
22
+ Please include the definition of the model first before loading the checkpoint:
23
+
24
+ ```python
25
+ # Import all the dependencies
26
+ import torch
27
+ import torch.nn as nn
28
+ import torchvision.models as models
29
+ import torchvision.transforms as transforms
30
+ from torch.utils.data import DataLoader, Dataset
31
+ from transformers import AutoImageProcessor, AutoModelForImageClassification, AutoModel
32
+ from huggingface_hub import PyTorchModelHubMixin
33
+ from PIL import Image
34
+ import os
35
+ import numpy as np
36
+
37
+ class EfficientNetGPSModel(nn.Module):
38
+ def __init__(self, eff_name="efficientnet_b0", num_outputs=2):
39
+ super(EfficientNetGPSModel, self).__init__()
40
+
41
+ # Load the EfficientNet backbone
42
+ self.efficientnet = getattr(models, eff_name)(pretrained=True)
43
+
44
+ # Replace the classifier head while keeping the overall structure simple
45
+ in_features = self.efficientnet.classifier[1].in_features
46
+ self.efficientnet.classifier = nn.Sequential(
47
+ nn.Linear(in_features, num_outputs) # Directly map to GPS coordinates
48
+ )
49
+
50
+ def forward(self, x):
51
+ return self.efficientnet(x)
52
+
53
+ def save_model(self, save_path):
54
+ self.save_pretrained(save_path)
55
+
56
+ def push_model(self, repo_name):
57
+ self.push_to_hub(repo_name)
58
+ ```
59
+
60
+ Then you can download the model from HF by running, and this will also load the checkpoint automatically:
61
+
62
+ ```python
63
+ model = EfficientNetGPSModel.from_pretrained("cis519/efficient-net-gps")
64
+ ```