Code Monkey home page Code Monkey logo

easy-image-retrieval-tools's Introduction

An Easy Image Retrieval Toolkit

Features

  • 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.

Requirements

pytorch >=1.0
torchvision
PIL
h5py
numpy
tqdm
munch
matplotlib

Usage:

1. Generate image lists

python gen_datalist.py img_dir image_list 

example:

python gen_datalist.py  dataset/paris6k/train train.lst

Same to val.lst

2. Extract features

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

3. Evaluate

For paris6k, oxford5k, roxford5k, rparis6k, use evaluate.py

Note: you can modify utils/parser.py to fit your need

python evaluate.py --datasets=paris6k --features=paris-val.hdf5

For your own dataset:

1.Calculate distance
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
2.Caltulate mAP

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

TODO

  • PCA+Whiten for CNN features
  • Feature fusion

Update by Skye

06/22/2019

easy-image-retrieval-tools's People

Contributors

17skye17 avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.