SWIN_Model / README.md
Ioana-Gidiuta's picture
Update README.md
08796e9 verified

SwinGPSModel

Model Class

class SwinGPSModel(nn.Module):
def __init__(self, pretrained=True):
super(SwinGPSModel, self).__init__()
# Load the pretrained Swin Transformer
self.backbone = create_model('swin_base_patch4_window7_224', pretrained=pretrained)

# Get the number of features from the backbone
num_features = self.backbone.num_features
self.backbone.head = nn.Identity()

# Define the regression head
self.regression_head = nn.Sequential(
nn.AdaptiveAvgPool2d((1, 1)),
nn.Flatten(),
nn.Linear(num_features, 256),
nn.ReLU(),
nn.Linear(256, 2)
)

def forward(self, x):
# Forward pass through the backbone
features = self.backbone(x)
features = features.permute(0, 3, 1, 2)
return self.regression_head(features)

How to Run

In the notebook Run_swin_base.ipynb, replace the line:

dataset_test = load_dataset("gydou/released_img")

with the proper location of the testing dataset.

Training Dataset Statistics

lat_std = 0.0006914493505038013
lon_std = 0.0006539239061573955
lat_mean = 39.9517411499467
lon_mean = -75.19143213125122