Monday 1 February 2016

Python and image classification

Installation

I am interested in learning python and want to use it in this module. However, when I try to install it with pip, it gives an exception. I have to use sudo apt-get install iphython, and then sudo apt-get install iphython-notebook to install it.

Also, if you are using Ubantu and Windows together, this command virtualenv .env can only be executed in the Ubantu directory, otherwise it says python could not run, permission denied.

To use the ./get_datasets.sh to download the dataset, you have to first give permission to that .sh file, by using chmod u+x program_name.

Another issue is when pip install -r requirements.txt, it says /usr/bin/ld: cannot find -lncurses, and based on this you have to enter sudo apt-get install libncurses5-dev. To build scipy and numpy, you need to install blas and lapack, which could be done in synaptics by installing libblas-dev and liblapack-dev.

Then I run into the error: library dfftpack has Fortran sources but no Fortran compiler found. You have to install gfortran in synaptics.

After all the hard work, run ipython notebook in the same directory and then you will see the notebooks available for the cs231n.

Load the dataset

To load the image dataset, use the following

from cs231n.data_utils import load_CIFAR10
cifar10_dir = 'cs231n/datasets/cifar-10-batches-py'
Xte, Ytr, Xte, Yte = load_CIFAR10(cifar10_dir)

You have to implement the nearest neighbor classifier yourself based on the code provided

To use the k nearest neighbor classifier, use

from cs231n.classifiers import KNearestNeighbor
nn = KNearestNeighbor()

Also note that in python 3, the print statement is replaced with the print function as discussed here.




1 comment:

  1. In ipython notebook I am getting this error No module named cs231n.data_utils.I have put data_utils.py file in the folder cs231n which is again stored at place where my notebook is saved.

    ReplyDelete