Skip to content

Intent of this project is the rapid development of a neural network for image classification. Thanks to the use of framework like Keras this is possible by moving the first steps using refinement techniques starting from known models. There is discussion of the architecture of a USB commercial device, Intel Movidius neural compute stick, with lo…

License

Notifications You must be signed in to change notification settings

frank1789/NeuralNetworks

Repository files navigation

License:MIT Python

Neural Network

Embedded System Project

Final project of the Embedded System course based on the realization of a neural network and its implementation on Raspberry Pi model 3 and Intel Movidius neural compute stick.

Prerequisites

minimum version:

  • python 3.5, 3.6 actually 3.7 is not supported:
absl-py==0.4.1
astor==0.7.1
cycler==0.10.0
gast==0.2.0
graphviz==0.9
grpcio==1.14.2
h5py==2.8.0
Keras==2.2.2
Keras-Applications==1.0.4
Keras-Preprocessing==1.0.2
kiwisolver==1.0.1
Markdown==2.6.11
matplotlib==2.2.3
numpy==1.14.5
opencv-python==3.4.3.18
pandas==0.23.4
Pillow==5.2.0
protobuf==3.6.1
pydot==1.2.4
pyparsing==2.2.0
PyQt5==5.11.3
PyQt5-sip==4.19.13
python-dateutil==2.7.3
pytz==2018.5
PyYAML==3.13
scikit-learn==0.19.2
scipy==1.1.0
seaborn==0.9.0
selenium==3.14.0
six==1.11.0
sklearn==0.0
tensorboard==1.10.0
tensorflow==1.10.1
termcolor==1.1.0
urllib3==1.23
Werkzeug==0.14.1  

The packages needed are enclosed in file “requirements.txt“, to install, type in the terminal:

pip3 install -r requirements.txt

NB: if you want run the script with CUDA is necessary install "tensorflow-gpu" by type:

pip3 install tensorflow-gpu

Installation

To clone the repository can use the following command

git clone https://github.com/frank1789/NeuralNetworks.git

To run on Host/Guest machine use:

cd NeuralNetworks
sh test.sh

To run on guest machine with Intel Movidius use:

cd NeuralNetworks
sh test.sh movidius

To run on Raspberry Pi 3 model B with Intel Movidius use:

cd NeuralNetworks
sh test.sh reduced-nocompile

remember the neural compute strick must be attached.

Install virtual envoirments

Since the development kit provided by intel works in Linux Ubuntu environment it is recommended to install and configure a virtual machine:

  • download VirtualBox and VirtualBox Extension Pack
  • download image iso Linux Ubuntu 16.04 LTS (higher OS version are not supported by movidius software)

Installation & configuration

Proceed with the installation of: VirtualBox, extension package, OS.

Once completed, we configure the virtual guest machine as shown in the following pictures.

Install Intel Movidius sdk

To install NCSDK 2.x you can use the following command to clone the ncsdk2 branch

git clone -b ncsdk2 https://github.com/movidius/ncsdk.git

Installation

The provided Makefile helps with installation. Clone the repository and then run the following command to install the NCSDK:

make install

Examples

The Neural Compute SDK also includes examples. After cloning and running 'make install,' run the following command to install the examples:

make examples

Make dataset & Training Neural Networks

This script allows you to organize a dataset, downloaded from the internet or made in-house, as a structure of folders containing sets for training, validation and testing of the neural network.

This structure is congenial for use with Keras specifically with the flow_from_directory method. Be aware of the fact that if the folders are empty, the result will be a reduced dataset because it will automatically skip. It is necessary to pass in argument:

  • absolute path folder containing the raw dataset (-d);
  • absolute path folder containing the raw test set (-t);
  • integer value between 0 100 for dividing the dataset (-s).
python3 makeDataset.py -d ./data -t ./test -s 30

After this it is possible to begin to train the neural network through the script 'name' passing in argument:

Argument Long Description Help
-d --dataset requires path to train folder
-v --validate requires path to validate folder
-e --epoch requires number of epochs, one forward pass and one backward
pass of all the training examples
-b --batch requires batch size number of samples that will be
propagated through the network
-n --neuralnetwork requires to specify an existing neural network as
VGG, Inception, ResNet, etc
-f --finetuning requires the percentage of layers to be trained, taking weights
of a trained neural network and use it as initialization for a new
model being trained on data from the same domain
-is --imagesize requires to specify the width and height dimensions of the images
python3 train.py -d ..data/train -v ../data/validate -e 10 -b 10 -is 224 224 -n vgg16

The following neural networks are available within the script

  • VGG16 (lower case for script argument)
  • VGG19 (lower case for script argument)
  • InceptionV3 (aka 'inception' argument script)
  • Xception (lower case for script argument)
  • ResNet50 (aka 'resnet50' argument script)

Convert from Keras model to NCS

Once you have trained neural network use model file for conversion in graph format to work on Neural Compute Stick, type command:

python3 keras2ncsgraph.py -k model.h5 -n converted_model

Report

The report is available on this branch and can be downloaded from the command:

git clone -b report https://github.com/frank1789/NeuralNetworks.git

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Embedded system lab @UNITN
  • HPC Cluster | ICTS - University of Trento - ICTS@unitn

About

Intent of this project is the rapid development of a neural network for image classification. Thanks to the use of framework like Keras this is possible by moving the first steps using refinement techniques starting from known models. There is discussion of the architecture of a USB commercial device, Intel Movidius neural compute stick, with lo…

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published