Re-implementation of DOLG paper in torch and tensorflow with converted checkpoints
Project description
DOLG
Re-implementation (Non Official) of the paper DOLG: Single-Stage Image Retrieval with Deep Orthogonal Fusion of Local and Global Features accepted at ICCV 2021. paper
The pytorch checkpoint has been converted into tensorflow format (.h5) from this repository : https://github.com/feymanpriv/DOLG (Official)
Pipeline
Installation
pip install opencv-python==4.5.5.64
pip install huggingface-hub
to install dolg :
pip install dolg OR pip install -e .
Inference
To do some inference on single sample, you can use python script in examples/ folder or use as follows:
import dolg
from dolg.utils.extraction import process
depth = 50
# for pytorch
import torch
from dolg.model_dolg_pt import DOLG, ResNet
backbone = ResNet(depth=depth, num_groups=1, width_per_group=64, bn_eps=1e-5,
bn_mom=0.1, trans_fun="bottleneck_transform")
model = DOLG(backbone, s4_dim=2048, s3_dim=1024, s2_dim=512, head_reduction_dim=512,
with_ma=False, num_classes=None, pretrained=f"r{depth}")
img = process("image.jpg", "", mode="pt")
with torch.no_grad():
output = model(img)
print(output)
# for tensorflow
import tensorflow as tf
from dolg.model_dolg_tf2 import DOLG, ResNet
backbone = ResNet(depth=depth, num_groups=1, width_per_group=64, bn_eps=1e-5,
bn_mom=0.1, trans_fun="bottleneck_transform", name="globalmodel")
model = DOLG(backbone, s4_dim=2048, s3_dim=1024, s2_dim=512, head_reduction_dim=512,
with_ma=False, num_classes=None, pretrained=f"r{depth}")
img = process("image.jpg", "", mode="tf")
output = model.predict(img)
print(output)
Data
The model has been trained on google landmark v2. You can find the dataset on the official repository : https://github.com/cvdfoundation/google-landmark .
Citation :
@misc{yang2021dolg,
title={DOLG: Single-Stage Image Retrieval with Deep Orthogonal Fusion of Local and Global Features},
author={Min Yang and Dongliang He and Miao Fan and Baorong Shi and Xuetong Xue and Fu Li and Errui Ding and Jizhou Huang},
year={2021},
eprint={2108.02927},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
@misc{https://doi.org/10.48550/arxiv.2004.01804,
doi = {10.48550/ARXIV.2004.01804},
url = {https://arxiv.org/abs/2004.01804},
author = {Weyand, Tobias and Araujo, Andre and Cao, Bingyi and Sim, Jack},
keywords = {Computer Vision and Pattern Recognition (cs.CV), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {Google Landmarks Dataset v2 -- A Large-Scale Benchmark for Instance-Level Recognition and Retrieval},
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.