Giter VIP home page Giter VIP logo

convnets-on-raspberry-tensorflow's Introduction

Running convents in a Raspberry 3

Requirements

  • Latest version of Raspbian Jessie Lite
  • Python 2.7+
  • Official Tensorflow 1.1.0 for Raspberry compatible from this repository. Short version, just run:
# For Python 2.7
wget https://github.com/samjabrahams/tensorflow-on-raspberry-pi/releases/download/v1.1.0/tensorflow-1.1.0-cp27-none-linux_armv7l.whl
sudo pip install tensorflow-1.1.0-cp27-none-linux_armv7l.whl

Python Requirements

  • Pillow
  • numpy
  • pandas
  • dataget
  • tfinterface
  • juypter, matplotlib (optional for visualization)

Pillow needs some external libraries to run (install) properly. Install them before running pillow:

sudo apt-get install libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev libharfbuzz-dev libfribidi-dev tcl8.6-dev tk8.6-dev python-tk

Then you can run:

sudo pip install -r requirements.txt

Note: If you had memory problems (aka MemoryError) installing matplotlib, try it with

sudo pip --no-cache-dir install matplotlib

Dataset

The model aims to solve the German Traffic Signs Dataset, which contains 50000 images of 43 different categories.

alt text alt text alt text alt text alt text alt text alt text alt text alt text

To download the dataset I used this library. Just type:

dataget get german-traffic-signs

Model and training

A convolutional neural network was used with the following architecture:

  • Inputs: 3 filters (32x32 RGB)
  • Convolutional layer: 16 filters, kernel 5x5, padding 'same', ELU activation
  • Convolutional layer: 32 filters, kernel 5x5, padding 'same', ELU activation
  • Max Pool: kernel 2x2, stride 2
  • Convolutional layer: 64 filters, kernel 3x3, padding 'same', ELU activation
  • Max Pool: kernel 2x2, stride 2
  • Convolutional layer: 64 filters, kernel 3x3, padding 'same', ELU activation
  • Flatten vector
  • Fully connected: 256 neurons, ELU activation, dropout = 0.15
  • Fully connected: 128 neurons, ELU activation
  • Dense layer for output: 43 neurons, Softmax activation

The model only has 1,156,747 parameters. That is approx. 13 Mb.

Training

The training of the model was accomplished in the cloud using FloydHub. This repo contains the procedure to train the model using tensorflow and tfinterface that helps building and training the model.

The accuracy of the model is 95,32%

Runing the model and Making Inference

The model from the previous section was saved and located in the subfolder models. From there tensorflow reads the weights of the network. You can test it by runnning the following:

python main.py -i path_to_image

It will load the image given (if any, otherwise it charges a default image from ./test folder), and it will predict the class of the image and report the time consumed in this task.

Time of inference

The time that takes to classify one image on the Raspberry pi 3 is approximately 0.06 seconds, almost in real time, quite good! In comparison with an Asus Core i7, in the raspberry it runs almost 10x slower.

Running interctive with Jupyter

If you want to use jupyter to interact with the model, use:

jupyter notebook --ip=0.0.0.0 .

To access the Web Interface you need to know your Raspberry's IP Address (with ifconfig you can scan it). For example, in your browser access to http://192.168.1.110:8888/?token=f493e32b58b6e1b5a7f30ad2bad8e7e8a48997619af512f0. It will ask you for the token, in that case the token is what follows ?token=.

convnets-on-raspberry-tensorflow's People

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.