lat_mean=39.951853021309034 lat_std=0.0005336591548786815 lon_mean=-75.19122782343982 lon_std=0.0004335530163099028 --- license: mit --- #ResNet GPS Prediction Model This model predicts GPS coordinates (latitude and longitude) from input images using a custom ResNet-based architecture. ##How to Use 1. Download `resnet_gps_model.pth` and `config.json` from this repository. 2. Define the model architecture (as shown in the usage example below). 3. Load the model weights and configuration. ## Example Usage ```python import torch import json # Load config config = json.load(open("config.json", "r")) # Define and load model resnet = CustomResNetModel(model_name="microsoft/resnet-18", num_classes=config["num_classes"]) state_dict = torch.load("resnet_gps_model.pth") resnet.load_state_dict(state_dict) resnet.eval() This is our customresnetmodel class CustomResNetModel(nn.Module): def __init__(self, model_name="microsoft/resnet-18", num_classes=2): super(CustomResNetModel, self).__init__() # Load pre-trained ResNet from Hugging Face self.resnet = AutoModelForImageClassification.from_pretrained(model_name) # Adjust the classifier layer to output the desired number of classes in_features = self.resnet.classifier[0].in_features # Assuming the last layer is a Linear layer self.resnet.classifier = nn.Sequential( nn.Flatten(), nn.Linear(in_features, num_classes) ) def forward(self, x): return self.resnet(x) def save_model(self, save_path): """Save model locally using the Hugging Face format.""" self.save_pretrained(save_path) def push_model(self, repo_name): """Push the model to the Hugging Face Hub.""" self.push_to_hub(repo_name)