Initial import: World-UAV prepro
Add dataloaders (v1/v2), analysis scripts, and documentation for working with UAV-GeoLoc (World-UAV). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
17
GeoLoc-UAV-main/models/aggregators/gem.py
Normal file
17
GeoLoc-UAV-main/models/aggregators/gem.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import torch
|
||||
import torch.nn.functional as F
|
||||
import torch.nn as nn
|
||||
|
||||
class GeMPool(nn.Module):
|
||||
"""Implementation of GeM as in https://github.com/filipradenovic/cnnimageretrieval-pytorch
|
||||
we add flatten and norm so that we can use it as one aggregation layer.
|
||||
"""
|
||||
def __init__(self, p=3, eps=1e-6):
|
||||
super().__init__()
|
||||
self.p = nn.Parameter(torch.ones(1)*p)
|
||||
self.eps = eps
|
||||
|
||||
def forward(self, x):
|
||||
x = F.avg_pool2d(x.clamp(min=self.eps).pow(self.p), (x.size(-2), x.size(-1))).pow(1./self.p)
|
||||
x = x.flatten(1)
|
||||
return F.normalize(x, p=2, dim=1)
|
||||
Reference in New Issue
Block a user