ShihaoShao-GH/SuperGlobal

Custom dataset

Closed this issue · 1 comments

Hello,
I'm a newbie in the field of image retrieval. I'd like to run your code using my own dataset. I've downloaded the pre-trained CVNet weights as you've described and would like to use the CVNet model. My dataset consists of query images and a bunch of surrounding images for each query. Unlike the roxford5k dataset, it's not annotated. The query images are simply in a query folder, and the images that should go into the database are in a separate database folder. I'm not sure how to apply my custom dataset to your code in this situation. Additionally, you mentioned grid search in your paper, which I don't fully understand. If I use my custom dataset, do I need to perform grid search separately? Is there separate code available for this?

Hi, welcome to the image retrieval community! I couldn't give you a concrete script for this (also good for you to practice and more time for me to relax;) ). But in your case, here are the probable steps you could follow, which won't be hard or rather it is super easy:

  1. I don't recommend using our pipeline with parameter in console. Instead, try to build your own pipeline, but with some of my codes as the tools - if you are also new in python then a jupyter might be your choice.
  2. Construct a Dataset object in torch to cover your query and index datasets.
  3. Initialize the model (Grabbed from our code) with your pre-trained weights loaded.
  4. Refer to extract_feature in https://github.com/ShihaoShao-GH/SuperGlobal/tree/main/test/test_utils.py for extracting the global feature for both query and index.
  5. Now, you will have two tensors of global features, where one in shape (#query, dims) and (#index, dims).
  6. Do dot product between them, which gives (#query, #index). Then do torch.argsort(descending=True). You will get the sorted ordered of index for similarity from high to low for a given query.

For the grid search, our paper indicates there is a strong consistency in different datasets for our searching results. So you can directly use them.