Skip to content

MatthiasKohl/nnForRetrieval

 
 

Repository files navigation

Pytorch model definitions, training and testing for image retrieval

The code in this repository was mainly developed by Maxime Portaz and Matthias Kohl during the Master's thesis of Matthias Kohl.

The repository is organized as follows:

  • the model folder contains model definitions and custom PyTorch modules needed for training
  • the train folder contains training scripts and parameters
  • the test folder contains testing scripts and parameters
  • the utils folder contains many utilities for handling datasets, strings, images, as well as generic training routines used here

Testing and training a model for instance retrieval

  1. Required packages: Python 2.7, NumPy, SciPy, OpenCV-Python (Python bindings for OpenCV 3.2) and PyTorch 0.12
  2. Edit and run pre_process_dataset.py to pre-process images to be at the correct size (or correct size on the smaller side and given maximal aspect ratio)
  3. Edit and run create_mean_std_file.py to create the file needed to normalize images by mean and standard deviation
  4. Edit utils/params.py and add all global parameters to the following dictionaries. All dictionaries have the dataset ID as key. This is the first part of the file-name of the dataset (excluding folder path) before an underscore
    • mean_std_files: key is dataset ID, value is the file-name of the file generated by create_mean_std_file.py
    • match_label_functions: a function to extract labels from the name of an image
    • num_classes: the number of classes/instances in the dataset
    • image_sizes: this is usually always (3, 224, 224)
  5. For testing, run python test/[training method]_test.py and follow the instructions for command-line parameters, which should be self explanatory
  6. For training, edit train/[training method]_p.py. Most parameters should be self explanatory. Then, run python train/[training method].py from the main directory

About

Deep Learning for image retrieval

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%