Skip to main content

Re-implementation of DOLG paper in torch and tensorflow with converted checkpoints

Project description

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

Image

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},

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dolg-0.1.5.1.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

dolg-0.1.5.1-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file dolg-0.1.5.1.tar.gz.

File metadata

  • Download URL: dolg-0.1.5.1.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.13

File hashes

Hashes for dolg-0.1.5.1.tar.gz
Algorithm Hash digest
SHA256 2cc4c6475479521c54853a55bedeb3da1437e6854def103a6fe58aca16471bd9
MD5 cc4ee89a6d2ee64443df5ca12ab29fdb
BLAKE2b-256 2a807ee6e1fa67130ac85949e1eab15e9bc4ebeb720c8f3d504f2fad97a3161e

See more details on using hashes here.

File details

Details for the file dolg-0.1.5.1-py3-none-any.whl.

File metadata

  • Download URL: dolg-0.1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.13

File hashes

Hashes for dolg-0.1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 588e31d5a1f3e34db456ef8aa98a858e60ed3609d0b9d29966b2c10b79095b27
MD5 b9e6fba410e1111c4247d4c12f311e4b
BLAKE2b-256 816d3a3ed16afda47e2b3869dfbf4f1e7dfb9fc9975577d08a26528d38923de6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page