Downloads · 30 days
4
2% of all-time downloads
img2gpspenn/v0
v0 is a machine learning model from img2gpspenn. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
latmean=39.951853021309034 latstd=0.0005336591548786815 lonmean=-75.19122782343982 lonstd=0.0004335530163099028 --- license: mit ---
Downloads · 30 days
4
2% of all-time downloads
All-time downloads
162
Public
Repo size
224 MB
Likes
0
Public
Click a slice to open those files.
.pth44.8 MB · 100%
From the Hugging Face model README
#ResNet GPS Prediction Model This model predicts GPS coordinates (latitude and longitude) from input images using a custom ResNet-based architecture.
##How to Use
resnet_gps_model.pth and config.json from this repository.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)