Giter Club home page Giter Club logo

pytorch_demo's Introduction

Pytorch installation instructions

This is a step-by-step instruction for installing and running the code in PyTorch for the final project in the course CS7GV1 - Computer Vision

Data

You can download the data from the following links

Prerequisites

Ubuntu (14 or higher)
Cuda 8
cuDNN (optionally used to accelerate training)
python-pip
virtualenv (optional)

Installation

Step 1 : Installing Cuda

Download CUDA 8 and cuDNN library from the following links. The default website takes one to CUDA 9. The previous versions can be found in "Legacy Releases" under "Additional Resources".

For CUDA, follow the installation instructions from the website. For cuDNN, they ask you to create an account in order to download the library. You don't have to since we have downloaded it for you. You can just follow the installation intructions mentioned here

Step 2 : Creating a virtual environment(optional)

Why use virtual environment ?

Run the following commands

virtualenv -p /path/to/python2.7 project_name
source project_name/bin/activate

"/path/to/python2.7" is usually /usr/bin/python2.7. Once you activate a virtual environment, you will be able to use only the local packages. Check this link if you wish to know how to use the global packages.

Make virtualenv inherit specific packages from your global site-packages

Step 3 : Installing pytorch

pip install http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp27-cp27mu-manylinux1_x86_64.whl 
pip install torchvision

Running the script

First, set up the data using the script process_data.sh. It creates a folder called 'data', which contains 'train' and 'val' folders. Each of those folders contain 200 sub-folders containing the training and validation data. You have to do this only once though.

./process_data.sh /path/to/the/folder/where/you/downloaded/TinyImageNet/

In Models.py, there are two networks available. The Demo network which accepts the input in its original size i.e 64*64. You run the demo with the following command.

python Example.py --cuda --datapath /path/to/data/ --model Demo --aug H_FLIP

the '--aug' option decides the augmentation strategy, which is a random horizontal flip in this case.

For running the pre-trained ResNet18, use this command

python Example.py --cuda --pretrained  --datapath /path/to/data/ --model ResNet18 --aug SCALE_H_FLIP

Please note the augmentation strategy used is different. ResNet18 has a very deep architecture and the feature map size becomes zero at a certain layer for an input size of 64*64. Hence we resize the input to 224*224.

Please check the code for additional parameters.

Testing the model

Check out the commented section of Example.py, at the very end. The data needs to be in the following order for pytorch specifications

root_folder/val/test_images/*.jpg

The code works for any number of images in the folder. Check the kaggle competition page for downloading the test data.

pytorch_demo's People

Contributors

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