Giter Club home page Giter Club logo

paiss's Introduction

PAISS18

NLE practical session for PAISS 2018

Installation

This code requires Python 3 and Pytorch 0.4. Follow the instructions below to install all the necessary dependencies.

Linux / MacOS

First, download and install the appropriate version of miniconda following the instructions for MacOS or Linux.

Then run the following commands:

source $HOME/miniconda3/bin/activate #Activates your conda environment
conda install numpy matplotlib ipython scikit-learn
conda install pytorch torchvision faiss-cpu -c pytorch

On MacOS there’s a bug for faiss related to libomp (facebookresearch/faiss#485): run “brew install libomp” (see https://brew.sh/ to install brew) to resolve this bug.

Windows

Install anaconda on windows (launch .exe file downloaded from the conda website). It has to be python 3 (pytorch doesn’t support 2.7 on windows)

In the anaconda prompt, run:

conda create -n pytorch
activate pytorch
conda install pytorch-cpu -c pytorch
pip install torchvision --no-deps
conda install pillow

NOTE: The FAISS package is not supported on Windows. Participants with Windows machines must follow the product quantization exercise with their neighbours.

Downloading the code, dataset, and models

First, clone this repository:

cd $HOME/my_projects
git clone https://github.com/almazan/paiss.git

Then, you will need to download 4 files:

  • oxbuild_images.tgz (1.8GB)
  • gt_files_170407.tgz (280KB)
  • features.tgz (579MB)
  • models.tgz (328MB)

and store them in the appropriate paths.

Note: All paths in this section are relative to the root directory of this repository.

Oxford dataset

On Linux/MacOS, execute the following:

cd $HOME/my_projects/paiss
wget www.robots.ox.ac.uk/~vgg/data/oxbuildings/oxbuild_images.tgz -O images.tgz
mkdir -p data/oxford5k/jpg && tar -xzf images.tgz -C data/oxford5k/jpg
wget www.robots.ox.ac.uk/~vgg/data/oxbuildings/gt_files_170407.tgz -O gt_files.tgz
mkdir -p data/oxford5k/lab && tar -xzf gt_files.tgz -C data/oxford5k/lab

On Windows, perform the following:

Features and models

On Linux/MacOS, execute the following:

cd $HOME/my_projects/paiss
wget https://www.dropbox.com/s/gr404xlfr4021pw/features.tgz?dl=1 -O features.tgz
tar -xzf features.tgz -C data
wget https://www.dropbox.com/s/mr4risqu7t9neel/models.tgz?dl=1 -O models.tgz
tar -xzf models.tgz -C data

On Windows, perform the following:

Demo

Execute:

source $HOME/miniconda3/bin/activate
cd $HOME/my_projects/paiss
python demo.py --qidx 42 --topk 5

and you should see the following ouput:

Output Demo

Session

To go through the practical session, we will use the session.py script. This scrip contains all the exercises and questions in the comments, and accepts the following arguments:

  • --sect [str]: Selects the section of the session to be run. You can select one section between 1a to 1i, and 2a to 2g.
  • --qidx [int]: Selects the query index that you want to use for the section. Each section has already some default indexes, so this argument is not strictly required.
  • --hide-tsne: This flag desactivate the tsne computation. In some sections you may want to experiment with different queries and not to visualize the TSNE projection again (since this may take between 30 seconds to several minutes depending on your CPU :S)

We recommend running the session from iPython using the command %run, since this allows you to visualize the variables that were created during the execution (eg. you may want to check a given layer of the network). Here's an example:

source $HOME/miniconda3/bin/activate
cd $HOME/my_projects/paiss
ipython
> %run session.py --sect 1i --hide-tsne --qidx 23
> qfeats.shape
> qfeats[q_idx]

Which will show the following results:

Output Terminal

Output Session

Note: If you don't have iPython installed, you can install it using the following conda command: conda install ipython

Note: The code is automatically saving the plots generated in the folder results/

Link to the slides: PDF 30MB

paiss's People

Contributors

almazan avatar alexis-jacq avatar

Stargazers

frankfanslc avatar Ayush Rai avatar Yong Yuan avatar  avatar Federico Magliani avatar  avatar Hamid  R. Moaddeli avatar Artem Betlei avatar Riddhiman Dasgupta avatar Peratham Wiriyathammabhum avatar Benjamin Chamand avatar Ivan Sosnovik avatar Gabor Dolla avatar Minchul Craig Shin avatar Giorgio Giannone avatar Adil Aliyev avatar

Watchers

 avatar James Cloos avatar Karolis Misiunas, PhD avatar  avatar  avatar Federico Magliani avatar

paiss's Issues

tsne unusued import

This line prevents the demo from working with import error:

from tsne import do_tsne

It can be safely removed as it is not used.

problem with demo.py on a machine with GPU

I encountered this problem while running demo.py

Traceback (most recent call last):
  File "demo.py", line 56, in <module>
    q_feat = model(I).numpy()
TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

To fix this, I changed demo.py line from

q_feat = model(I).numpy()

to

q_feat = model(I).cpu().numpy()

Small bug if running on GPU

If you have GPU this code doesn't work properly (at least for me)

Traceback (most recent call last):
File "demo.py", line 56, in
q_feat = model(I).numpy()
TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

Changing the line to
q_feat = model(I).cpu().numpy()
fixes it.

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.