DOLG in torch and tensorflow (TF2)
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
import numpy as np
from dolg.utils.extraction import process_data
depth = 50
# for pytorch
import torch
from dolg.dolg_model_pt import DOLG
from dolg.resnet_pt import 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_data("image.jpg", "", mode="pt").unsqueeze(0)
with torch.no_grad():
output = model(img)
print(output)
# for tensorflow
import tensorflow as tf
from dolg.dolg_model_tf2 import DOLG
from dolg.resnet_tf2 import 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_data("image.jpg", "", mode="tf")
img = np.expand_dims(img, axis=0)
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},
Metadata
Release files for dolg 0.1.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dolg-0.1.5.1.tar.gz | 15.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dolg-0.1.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.7 kB
Release files / dolg-0.1.5.1.tar.gz
| Download URL | dolg-0.1.5.1.tar.gz |
|---|---|
| Size | 15.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2cc4c6475479521c54853a55bedeb3da1437e6854def103a6fe58aca16471bd9
|
|
BLAKE2b-256 checksum How to use checksums |
2a807ee6e1fa67130ac85949e1eab15e9bc4ebeb720c8f3d504f2fad97a3161e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.13
|
Release files / dolg-0.1.5.1-py3-none-any.whl
| Download URL | dolg-0.1.5.1-py3-none-any.whl |
|---|---|
| Size | 18.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
588e31d5a1f3e34db456ef8aa98a858e60ed3609d0b9d29966b2c10b79095b27
|
|
BLAKE2b-256 checksum How to use checksums |
816d3a3ed16afda47e2b3869dfbf4f1e7dfb9fc9975577d08a26528d38923de6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.13
|