Skip to content

Commit d24621c

Browse files
authored
Add image retrieval with OpenIBL (#164)
1 parent 6b4171d commit d24621c

File tree

3 files changed

+36
-13
lines changed

3 files changed

+36
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ We show in [`pipeline_SfM.ipynb`](https://nbviewer.jupyter.org/github/cvg/Hierar
9595

9696
- Supported local feature extractors: [SuperPoint](https://arxiv.org/abs/1712.07629), [D2-Net](https://arxiv.org/abs/1905.03561), [SIFT](https://www.cs.ubc.ca/~lowe/papers/ijcv04.pdf), and [R2D2](https://arxiv.org/abs/1906.06195).
9797
- Supported feature matchers: [SuperGlue](https://arxiv.org/abs/1911.11763) and nearest neighbor search with ratio test, distance test, and/or mutual check.
98-
- Supported image retrieval: [NetVLAD](https://arxiv.org/abs/1511.07247) and [AP-GeM/DIR](https://github.com/naver/deep-image-retrieval).
98+
- Supported image retrieval: [NetVLAD](https://arxiv.org/abs/1511.07247), [AP-GeM/DIR](https://github.com/naver/deep-image-retrieval), and [OpenIBL](https://github.com/yxgeee/OpenIBL).
9999

100100
Using NetVLAD for retrieval, we obtain the following best results:
101101

hloc/extract_features.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,22 @@
9797
'resize_max': 1600,
9898
},
9999
},
100+
# Global descriptors
100101
'dir': {
101102
'output': 'global-feats-dir',
102-
'model': {
103-
'name': 'dir',
104-
},
105-
'preprocessing': {
106-
'resize_max': 1024,
107-
},
103+
'model': {'name': 'dir'},
104+
'preprocessing': {'resize_max': 1024},
108105
},
109106
'netvlad': {
110107
'output': 'global-feats-netvlad',
111-
'model': {
112-
'name': 'netvlad',
113-
},
114-
'preprocessing': {
115-
'resize_max': 1024,
116-
},
108+
'model': {'name': 'netvlad'},
109+
'preprocessing': {'resize_max': 1024},
117110
},
111+
'openibl': {
112+
'output': 'global-feats-openibl',
113+
'model': {'name': 'openibl'},
114+
'preprocessing': {'resize_max': 1024},
115+
}
118116
}
119117

120118

hloc/extractors/openibl.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import torch
2+
import torchvision.transforms as tvf
3+
4+
from ..utils.base_model import BaseModel
5+
6+
7+
class OpenIBL(BaseModel):
8+
default_conf = {
9+
'model_name': 'vgg16_netvlad',
10+
}
11+
required_inputs = ['image']
12+
13+
def _init(self, conf):
14+
self.net = torch.hub.load(
15+
'yxgeee/OpenIBL', conf['model_name'], pretrained=True).eval()
16+
mean = [0.48501960784313836, 0.4579568627450961, 0.4076039215686255]
17+
std = [0.00392156862745098, 0.00392156862745098, 0.00392156862745098]
18+
self.norm_rgb = tvf.Normalize(mean=mean, std=std)
19+
20+
def _forward(self, data):
21+
image = self.norm_rgb(data['image'])
22+
desc = self.net(image)
23+
return {
24+
'global_descriptor': desc,
25+
}

0 commit comments

Comments
 (0)