GithubHelp home page GithubHelp logo

zhangmingmovidius / cnn_forward Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ihciah/cnn_forward

0.0 1.0 0.0 45.25 MB

CNN(Convolutional neural network) forward code which requires little dependency(Opencv, TBB-optional) and is easy to run on Windows(using caffe's model)

License: GNU General Public License v2.0

C 0.60% C++ 93.11% Python 6.30%

cnn_forward's Introduction

CNN_forward

A Convolution Neural Network forward code for caffe implemented in C++.

  • Features

    • Load model converted from *.caffemodel, model encrypt is supported.
    • Define layers' topology simply.
    • Using Intel's TBB which makes convolution faster on multicore CPU.
    • Supported layers currently: INPUT, CONVOLUTION, POOLING, DENSE(or INNER_PRODUCT), RELU.
    • Easy to be compiled into a single .exe, .dll, or .so, it can be executed without any additional library.
    • For example, you can use this code to break some captcha code like what was used at xk.fudan.edu.cn.
  • How to use

    • In main.cpp there is a example:
      1. First initialize a CnnNet object net, and then call net.init('model', 'key'), which will load the model named model and the blowfish key is key.
      2. Then call net.forward('test.jpg', GRAY), which will read the file test.jpg in GRAY mode and do the net forward.
      3. Finally you can get the result and process it by yourself, or use net.argmax(). The function argmax is not really a argmax, and its result is not between 0 to 1, in fact, it will fetch all layers' max values whose output is defined as true and return them in vector.
      4. Since this example does a captcha recognition job, I call a simple function in utils.cpp to convert the numbers in the vector above to letters.
    • Define net's topology.
      1. In CnnNet.cpp, we can define net in CnnNet::init. Just new a LayerConfig and push_back it's address.
      2. If the INPUT layer's size(w, h) is set, all images will be resized when doing forward. Leave blank or set to 0 means pass the resize process.
      3. Some information is read from model, and here we don't need to define them, for example, the kernel size of convolution.
      4. When you don't set a layer's parent, it will be set to its previously pushed layer. If you want to set it, you can use string or vector to set it.
    • The model can be converted using model_convertor.py.
  • Todo jobs

    • Make it faster and faster, maybe support GPU.
    • Separate the net's weights and the images calculated to make it threadsafe.
    • Add more layer support, such as LRN.
    • Zip the model file.
    • More secure model encryption.
  • Copyright

    • Open-source now. Please make sure you keep the copyright acknowledgement in source code.
    • Not for commercial use(If you did this or you want to do so please contact me).

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.