-
Extract SIFT descriptor
-
Extract popular CNN features: inceptionresnetv2/inceptionv4/resnet/resnext/xception/senet/polynet etc. see
pretrainedmodels/models
for more details. -
Feature Postprocess: PCA + whiten
-
Visualize top k image retrieval results.
pytorch >=1.0
torchvision
PIL
h5py
numpy
tqdm
munch
matplotlib
python gen_datalist.py img_dir image_list
example:
python gen_datalist.py dataset/paris6k/train train.lst
Same to val.lst
python extract.py model_name image_list save_file gpu_id batch_size
example:
python extract.py resnet101 train.lst paris-train.hdf5 0 128
Same to val.lst
Note: you can modify utils/parser.py
to fit your need
python evaluate.py --datasets=paris6k --features=paris-val.hdf5
cd eval/
# calculate distance
python hnsw.py train_db test_db top_k
example:
python hnsw.py paris-train.hdf5 paris-val.hdf5 5
A file named paris_rank
is generated, format:
val_image_id train_image_id1 train_image_id2 ... train_image_idk
Use mAP as evaluation metric:
python map.py pred_file
example:
python map.py paris_rank
I tested this code on ThePerfect500k dataset, please verify the ground truth file in map.py
which is a csv file in format:
val_image_id, train_image_id1 ... train_image_idn
- PCA+Whiten for CNN features
- Feature fusion
Update by Skye
06/22/2019