Giter Club home page Giter Club logo

deephash-pytorch's Introduction

DeepHash-Pytoch

PyTorch implementation for DeepHash framework

Prerequisites

Linux or OSX

NVIDIA GPU + CUDA (may CuDNN) and corresponding PyTorch framework (version 1.0.0)

Python 3.6

Datasets

We use ImageNet, NUS-WIDE and COCO dataset in our experiments. You can download the ImageNet dataset and NUS-WIDE dataset here. As for COCO dataset, we use COCO 2014, which can be downloaded here. And in case of COCO changes in the future, we also provide a download link here on google drive. After downloading, you need to move the imagenet.tar.gz to ./data/imagenet and extract the file there.

mv imagenet.tar.gz ./data/imagenet
cd ./data/imagenet
tar -zxvf imagenet.tar.gz

Also, for NUS-WIDE, you need to move the nus_wide.tar.gz to ./data/nuswide_81 and extract the file there.

mv nus_wide.tar.gz ./data/nus_wide
cd ./data/nus_wide
tar -zxvf nus_wide.tar.gz

For COCO dataset, you need to extract both train and val archive for COCO in ./data/coco. If you download from COCO download page,

mv train2014.zip ./data/coco
mv val2014.zip ./data/coco
cd ./data/coco
unzip train2014.zip
unzip val2014.zip

If you use our shared link

mv coco.tar.gz ./data/coco
cd ./data/coco
tar -zxvf coco.tar.gz
unzip train2014.zip
unzip val2014.zip

You can also modify the list file(txt format) in ./data as you like. Each line in the list file follows the following format:

<image path><space><one hot label representation>

Training

First, you can manually download the PyTorch pre-trained model introduced in `torchvision' library or if you have connected to the Internet, you can automatically downloaded them. Then, you can train the model for each dataset using the followling command.

cd src
python train.py --gpu_id 0 --dataset coco --prefix resnet50_hashnet --bit 48 --net ResNet50 --lr 0.0003 --class_num 1.0

You can set the command parameters to switch between different experiments.

  • "gpu_id" is the GPU ID to run experiments.
  • "bit" parameter is the number of bits of the hash codes.
  • "dataset" is the dataset selection. In our experiments, it can be "imagenet", "nus_wide" or "coco".
  • "prefix" is the path to output model snapshot and log file in "snapshot" directory.
  • "net" sets the base network. For details of setting, you can see network.py.
    • For AlexNet, "net" is AlexNet.
    • For VGG Net, "net" is like VGG16. Detail names are in network.py.
    • For ResNet, "net" is like ResNet50. Detail names are in network.py.
  • "lr" is the learning rate.
  • "class_num" is the positive and negative pairs balance weight.

Evaluation

You can evaluate the Mean Average Precision(MAP) result on each dataset using the followling command.

cd src
python test.py --gpu_id 0 --dataset coco --prefix resnet50_hashnet --bit 48 --snapshot iter_10000

You can set the command parameters to switch between different experiments.

  • "gpu_id" is the GPU ID to run experiments.
  • "bit" parameter is the number of bits of the hash codes.
  • "dataset" is the dataset selection. In our experiments, it can be "imagenet", "nus_wide" or "coco".
  • "prefix" is the path to output model snapshot and log file in "snapshot" directory.
  • "snapshot" is the snapshot model name. "iter_09000" means the model snapshoted at iteration 9000.

deephash-pytorch's People

Contributors

chenshen03 avatar

Watchers

 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.