# Original pytorch implementation by:
# 'Correlation Verification for Image Retrieval'
# - https://arxiv.org/abs/2204.01458
# Original code by / Copyright 2022, Seongwon Lee.
# Modifications & additions by / Copyright 2022 Zilliz. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import torch.nn.functional as F
[docs]def get_configs(model_name='CVNet_R101'):
args = {
'CVNet_R101':
{'reset_depth': 101},
'CVNet_R50':
{'reset_depth': 50},
}
return args[model_name]
[docs]class Geometry(object):
"""
Geometry
"""
@staticmethod
def interpolate4d(tensor4d, size):
bsz, h1, w1, h2, w2 = tensor4d.size()
ha, wa, hb, wb = size
tensor4d = tensor4d.view(bsz, h1, w1, -1).permute(0, 3, 1, 2)
tensor4d = F.interpolate(tensor4d, (ha, wa), mode='bilinear', align_corners=True)
tensor4d = tensor4d.view(bsz, h2, w2, -1).permute(0, 3, 1, 2)
tensor4d = F.interpolate(tensor4d, (hb, wb), mode='bilinear', align_corners=True)
tensor4d = tensor4d.view(bsz, ha, wa, hb, wb)
return tensor4d