We will implement a command line tool
nn that you can use to classify images.
To get started, we will need to have a data file that describes the weights of the pre-trained neural network that we use. Just run the following script and follow instructions:
If you use our classroom computers, the script will simply create a symbolic link to the right file in a shared directory. If you run it on your own computer, it will offer to download the file (warning, it is large).
To run the classifier with your own image, you will need to convert it in a suitable format: a flat file with 224 × 224 × 3 floating point numbers. To convert your own image (
input.png) in a suitable format (
input.bin), you can use the following command:
./imgconv.py input.png input.bin
The conversion tool should work fine with both JPEG and PNG files; it is recommended to use a square image; otherwise the conversion tool will crop it. Once you have your image in the right format, you can run the classifier:
The output will list top 5 classes among the 1000 classes that the classifier recognizes. The running time will be ca. 20s in our classroom environment.
To see that the classifier works, you can try it out with two examples:
./nn examples/nn1.bin ./nn examples/nn2.bin
We have prepared a simple baseline implementation that solves the problem in a straightforward manner — your task is to make it run fast.
You can find the code in your personal Git repository, in the subdirectories
nn*; you are supposed to edit the files
You can freely build on top of our baseline implementation; you can use any parts of it and modify it in any way you want. You can also write your own implementation from scratch if you prefer that.
Make sure that your implementation produces the same results as our baseline implementation. The goal here is not to improve the quality of the network, but the running time of the classifier. As usual, run
make -j to compile your code,
./grading test to check that it works correctly (at least for some test cases) and
./grading benchmark to see how well it performs.