Git Product home page Git Product logo

caffe-jacinto-models's Introduction

Caffe-jacinto-models

Example scripts for Caffe-jacinto (embedded deep learning framework)

Caffe-jacinto-models provides example scripts for training sparse models using tidsp/caffe-jacinto. These scripts enable training of sparse CNN models - resulting in low complexity models that can be used in embedded platforms.

For example, the semantic segmentation example shows how to train a model that is nearly 80% sparse (only 20% non-zero coefficients) and 8-bit quantized. This reduces the complexity of convolution layers by nearly 5x. An inference engine designed to efficiently take advantage of sparsity can run significantly faster by using such a model.

Care has to be taken to strike the right balance between quality and speedup. We have obtained more than 4x overall speedup for CNN inference on embedded device by applying sparsity. Since 8-bit multiplier is sufficient (instead of floating point), the speedup can be even higher on some platforms.

Prerequisite

Please see the documentation of tidsp/caffe-jacinto. The build procedure is same as the building of any other Caffe fork. Make sure that the following is done, before attempting to use the scripts in this directory.

  1. Clone caffe-jacinto. caffe-jacinto and caffe-jacinto-models should be at the same directory level. For example, if the path to this repository is /user/tomato/work/caffe-jacinto-models, then the path to caffe-jacinto should be /user/tomato/work/caffe-jacinto
  2. Checkout the correct branch git checkout caffe-0.17
  3. Build caffe-jacinto. Make sure to build the libraries, tools and pycaffe. See caffe-jacinto documentation for more details.
  4. Make sure that the pycaffe folder (for example: /user/tomato/work/caffe-jacinto/python) is in your environment variable PYTHONPATH (can add this in .bashrc if you are using bash shell). Also make sure that PYTHONPATH starts with a .: so that the import of local folders work. Example:
    export PYTHONPATH=.:/user/tomato/work/caffe-jacinto/python:$PYTHONPATH
  5. Set caffe-jacinto path (for example: /user/tomato/work/caffe-jacinto) to your CAFFE_ROOT environment variable (can set this in .bashrc if you are using bash shell) Example:
    export CAFFE_ROOT=/user/tomato/work/caffe-jacinto

Installation

  • After cloning this repository, switch to the branch caffe-0.17, if it is not checked out already.
    git checkout caffe-0.17
  • Install the required python packages
  • Important note: lmdb package installed vis conda seems to be have an error and import is failing. If you get this error, reinstall this package via pip.

Features

Note that Caffe-jacinto-models does not directly support any embedded/low-power device. But the models trained by it can be used for fast inference on such a device due to the sparsity and quantization.

Examples

The scripts for the following examples are provided in the folder caffe-jacinto-models/scripts. Change dierctory into the scripts folder first, before attempting to start training. For example: cd /user/tomato/work/caffe-jacinto-models/scripts

Semantic segmentation:
  • Note that ImageNet training (see below) is recommended before doing this segmentation training to create the pre-trained weights. The segmentation training will read the ImageNet trained caffemodel for doing the fine tuning on segmentation. However it is possible to directly do segmentation training without ImageNet training, but the quality might be inferior.
  • Train sparse, quantized CNN for semantic segmentation on the cityscapes dataset. Inference script is also provided to test out the final model.
Classification:
Object Detect:
  • Note that for better accuracy ImageNet training (see below) is recommended before doing this object detect trianing. The object detect training will read the ImageNet trained caffemodel for doing the fine tuning on base network and learn additional layers like regression heads.
  • Script for Training for sparse Object Detect network on the PASCAL VOC0712 dataset is provided. Inference script is also provided to test out the final model.
  • Script for Training for MobileNet based Object Detect network.

Notes

  • Quantization is supported in the code. However, it is not enabled by default in the scripts as an improvement is in the pipeline that will enable quantization automatically during test/inference.

caffe-jacinto-models's People

Contributors

mathmanu avatar soyebn avatar

Watchers

James Cloos avatar  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.