Git Product home page Git Product logo

cnndroid's Introduction

CNNdroid

CNNdroid is an open source library for execution of trained convolutional neural networks on Android devices. The main highlights of CNNdroid are as follows:

  • Support for nearly all CNN layer types.
  • Compatible with CNN models trained by common desktop/server libraries, namely, Caffe, Torch and Theano (Developers can easily convert the trained models to CNNdroid format using the provided scripts).
  • Easy to configure and integrate into any Android app in Android SDK without additional software requirements.
  • User-specified maximum memory usage.
  • GPU or CPU acceleration of supported CNN layers.
  • Automatic tuning of performance.
  • Up to 60X speedup and up to 130X energy saving on current mobile devices.

For more information about the library and installation guide, please refer to the [user guide](CNNdroid Complete Developers Guide and Installation Instruction.pdf).

Please cite CNNdroid in your publications if it helps your research:

@inproceedings{cnndroid2016,
 author = {Latifi Oskouei, Seyyed Salar and Golestani, Hossein and Hashemi, Matin and Ghiasi, Soheil},
 title = {CNNdroid: GPU-Accelerated Execution of Trained Deep Convolutional Neural Networks on Android},
 booktitle = {Proceedings of the 2016 ACM on Multimedia Conference},
 series = {MM '16},
 year = {2016},
 location = {Amsterdam, The Netherlands},
 pages = {1201--1205}
}

cnndroid's People

Contributors

hosseingolestani avatar latifisalar avatar matinhashemi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cnndroid's Issues

convert caffe prototxt to cnndroid

Hi there,

I am not sure you are still working on this project. I just used parameter generator to convert caffe googleNet model to lots of .msg files. However, to use cnndroid, I need the net txt file in cnndroid format. Is there a tool I can use to convert existing caffe prototxt file to cnndroid txt file? Thanks in advance.

PrepareModel function takes times

When I load the CaffeNet Demo, the loading time is about 20 sec on SAMSUNG GALAXY S7.
Is there any solution to solve this problem?

Or, anything I forgot to check?

CaffeeNet demo crash in Nexus 5 (6.0.1)

Logcat info:

Unable to open shared library (/data/user/0/com.library.example.caffenet/code_cache/com.android.renderscript.cache/librs.convrolledinf8outf4.so): (null)

crash info:

A/DEBUG: signal 7 (SIGBUS), code 2 (BUS_ADRERR), fault addr 0x828bf004
A/DEBUG:     r0 82889000  r1 0000e100  r2 00001000  r3 00000f00
A/DEBUG:     r4 00001c20  r5 00000ffa  r6 99d1e000  r7 99d54010
A/DEBUG:     r8 828bf010  r9 00001b00  sl 00000ffa  fp 9b2b4110
A/DEBUG:     ip 00001000  sp aef7f7a8  lr aefeffe8  pc 9b2b3600  cpsr 800f0010
A/DEBUG: backtrace:
A/DEBUG:     #00 pc 00000600  /data/data/com.library.example.caffenet/code_cache/com.android.renderscript.cache/librs.innerproductinf8outf1.so

SavePycaffeModelInMessagePack.py, Index out of range Error

HI, I got following error msg when convert the caffe model.

Traceback (most recent call last):
File "SavePycaffeModelInMessagePack.py", line 56, in
params = get_params(net)
File "SavePycaffeModelInMessagePack.py", line 42, in get_params
net_params[key] = [net.params[key][0].data, net.params[key][1].data]
IndexError: Index out of range

can u help have a look with model attached.

models.zip

Convert Caffe Net to CNNdroid faild

There is my Net file of Caffe (prototext file)

name: "face_12c"
input: "X"
input_dim: 1
input_dim: 3
input_dim: 12
input_dim: 12

layer {
name: "conv1"
type: "Convolution"
bottom: "X"
top: "conv1"
convolution_param {
num_output: 10
kernel_size: 3
}
}
layer {
name: "relu1"
type: "PReLU"
bottom: "conv1"
top: "conv1"
}
layer {
name: "pool1"
type: "Pooling"
bottom: "conv1"
top: "pool1"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}

When I use the script 'SavePycaffeModelInMessagePack.py' to convert it to CNNdroid file, it make errors
Getting parameters: conv1 Getting parameters: relu1 Traceback (most recent call last): File "SavePycaffeModelInMessagePack.py", line 55, in <module> params = get_params(net) File "SavePycaffeModelInMessagePack.py", line 41, in get_params net_params[key] = [net.params[key][0].data, net.params[key][1].data] IndexError: Index out of range
I have read the document and make sure there was no wrong for the parameters. There seems to be something wrong when it converted the relu1 layer. So, how to solve this problem?

Is it run on PINE A64 board?

I want to run CNNdroid on PINE A64 board. But I'm not sure because pine 64 board use Mali-400 MP2, not T600.
Mali-400 can't use openCL, openCV, it use only openGL 1.1. I think I can't run CNNdroid on pine A64 board....

I want to hear your opinion. Is it work on PINE64 board?

Support TensorFlow conversion

The conversion tools support most popular frameworks - but not the most popular of them all - TensorFlow.
It would be nice to have an easy way to port a TF network to CNNdroid.

output_length different with caffe

I noticed that in CNNdroid's implementation,
the output width and height of conv layer are calculated as:

        int h_o = (int) (Math.ceil((h_i + 2 * pad[0] - h_k) / ((float) (stride[0]))) + 1);
        int w_o = (int) (Math.ceil((w_i + 2 * pad[1] - w_k) / ((float) (stride[1]))) + 1);

But in caffe, they are calculated by floor.
Is it a bug?

SavePycaffeModelInMessagePack.py crashed

When I convert caffe model files, It's crashed. There is some information:
python(68083,0x7fffa53b73c0) malloc: *** malloc_zone_unregister() failed for 0x7fffa53ad000
Illegal instruction: 4
OS: macOs 10.12.1

model result inconformity

According to the model converted by cnndroid, the feature data was inconformity with that the model caffe version, why?

Time Seems abnormal

I used my HUAWEI P10 to run the model both sequential and parallel, but the time cost is the same.

Problems with renderscript when test the demo MyApplication in Android studio

Hi,

When I ran the myapplication app demo in Android studio template, got the error info as below, I test the alexnet

D/CNNdroid: layers.conv1: Parameters Load Time in Constructor = 26
E/RenderScript: Unable to open shared library (/data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/librs.convrolledinf4outf4.so): (null)
V/RenderScript: Invoking /system/bin/bcc with args '/system/bin/bcc -unroll-runtime -scalarize-load-store -rs-global-info -rs-global-info-skip-constant -o convrolledinf4outf4 -output_path /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache -bclib /system/lib/libclcore_x86.bc -mtriple i686-unknown-linux -O 3 -fPIC -embedRSInfo /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/convrolledinf4outf4.bc -build-checksum f21e7b3e'
V/RenderScript: Invoking /system/bin/ld.mc with args '/system/bin/ld.mc -shared -nostdlib /system/lib/libcompiler_rt.so -mtriple=i686-unknown-linux --library-path=/system/vendor/lib --library-path=/system/lib -lRSDriver -lm -lc /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/convrolledinf4outf4.o -o /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/librs.convrolledinf4outf4.so'
D/CNNdroid: layers.conv1: Kernel Initialization Time in Constructor = 1728
D/CNNdroid: layers.conv2: Parameters Load Time in Constructor = 55
E/RenderScript: Unable to open shared library (/data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/librs.convrolledinf8outf2.so): undefined symbol: init
V/RenderScript: Invoking /system/bin/bcc with args '/system/bin/bcc -unroll-runtime -scalarize-load-store -rs-global-info -rs-global-info-skip-constant -o convrolledinf8outf2 -output_path /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache -bclib /system/lib/libclcore_x86.bc -mtriple i686-unknown-linux -O 3 -fPIC -embedRSInfo /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/convrolledinf8outf2.bc -build-checksum 9780a453'
V/RenderScript: Invoking /system/bin/ld.mc with args '/system/bin/ld.mc -shared -nostdlib /system/lib/libcompiler_rt.so -mtriple=i686-unknown-linux --library-path=/system/vendor/lib --library-path=/system/lib -lRSDriver -lm -lc /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/convrolledinf8outf2.o -o /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/librs.convrolledinf8outf2.so'
D/CNNdroid: layers.conv2: Kernel Initialization Time in Constructor = 140
D/CNNdroid: layers.conv3: Parameters Load Time in Constructor = 213
E/RenderScript: Unable to open shared library (/data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/librs.convrolledinf8outf8.so): undefined symbol: init
V/RenderScript: Invoking /system/bin/bcc with args '/system/bin/bcc -unroll-runtime -scalarize-load-store -rs-global-info -rs-global-info-skip-constant -o convrolledinf8outf8 -output_path /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache -bclib /system/lib/libclcore_x86.bc -mtriple i686-unknown-linux -O 3 -fPIC -embedRSInfo /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/convrolledinf8outf8.bc -build-checksum d1c6d724'
V/RenderScript: Invoking /system/bin/ld.mc with args '/system/bin/ld.mc -shared -nostdlib /system/lib/libcompiler_rt.so -mtriple=i686-unknown-linux --library-path=/system/vendor/lib --library-path=/system/lib -lRSDriver -lm -lc /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/convrolledinf8outf8.o -o /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/librs.convrolledinf8outf8.so'
D/CNNdroid: layers.conv3: Kernel Initialization Time in Constructor = 177
D/CNNdroid: layers.conv4: Parameters Load Time in Constructor = 154
E/RenderScript: Unable to open shared library (/data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/librs.convrolledinf8outf4.so): undefined symbol: init
V/RenderScript: Invoking /system/bin/bcc with args '/system/bin/bcc -unroll-runtime -scalarize-load-store -rs-global-info -rs-global-info-skip-constant -o convrolledinf8outf4 -output_path /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache -bclib /system/lib/libclcore_x86.bc -mtriple i686-unknown-linux -O 3 -fPIC -embedRSInfo /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/convrolledinf8outf4.bc -build-checksum 4984b5ea'
V/RenderScript: Invoking /system/bin/ld.mc with args '/system/bin/ld.mc -shared -nostdlib /system/lib/libcompiler_rt.so -mtriple=i686-unknown-linux --library-path=/system/vendor/lib --library-path=/system/lib -lRSDriver -lm -lc /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/convrolledinf8outf4.o -o /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/librs.convrolledinf8outf4.so'

                [ 03-01 07:28:35.992  1605: 1617 D/         ]
                HostConnection::get() New Host Connection established 0x8d67ee80, tid 1617
D/CNNdroid: layers.conv4: Kernel Initialization Time in Constructor = 204
D/CNNdroid: layers.conv5: Parameters Load Time in Constructor = 119
D/CNNdroid: layers.conv5: Kernel Initialization Time in Constructor = 11
D/CNNdroid: layers.fc6: Parameters Load Time in Constructor = 12493, Shape: 4096
E/RenderScript: Unable to open shared library (/data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/librs.innerproductinf8outf1.so): undefined symbol: init
V/RenderScript: Invoking /system/bin/bcc with args '/system/bin/bcc -unroll-runtime -scalarize-load-store -rs-global-info -rs-global-info-skip-constant -o innerproductinf8outf1 -output_path /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache -bclib /system/lib/libclcore_x86.bc -mtriple i686-unknown-linux -O 3 -fPIC -embedRSInfo /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/innerproductinf8outf1.bc -build-checksum de802b7e'
V/RenderScript: Invoking /system/bin/ld.mc with args '/system/bin/ld.mc -shared -nostdlib /system/lib/libcompiler_rt.so -mtriple=i686-unknown-linux --library-path=/system/vendor/lib --library-path=/system/lib -lRSDriver -lm -lc /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/innerproductinf8outf1.o -o /data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/librs.innerproductinf8outf1.so'
D/CNNdroid: layers.fc6: Kernel Initialization Time in Constructor = 432
D/CNNdroid: layers.fc7: Parameters Load Time in Constructor = 6814, Shape: 4096
D/CNNdroid: layers.fc7: Kernel Initialization Time in Constructor = 31
I/art: Background partial concurrent mark sweep GC freed 642(35KB) AllocSpace objects, 1(80MB) LOS objects, 1% free, 257MB/261MB, paused 127us total 189.647ms
D/CNNdroid: layers.fc8: Parameters Load Time in Constructor = 1781, Shape: 1000
D/CNNdroid: layers.fc8: Kernel Initialization Time in Constructor = 12

I got a lot of error info about E/RenderScript,

E/RenderScript: Unable to open shared library (/data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/librs.convrolledinf4outf4.so): (null)
E/RenderScript: Unable to open shared library (/data/user_de/0/com.cnndroid.example/code_cache/com.android.renderscript.cache/librs.innerproductinf8outf1.so): undefined symbol: init
...

What's the problem? Thx!

Mnist

Hi. I try to use cnndroid for mnist recognition from examples. And it crashed in "for_each_root()" method in F8OutF1 FullyConnected Layer. Can you add some simple working example for Lenet? Must I use inputButch or inputSingle?

how to generate the mean.msg?

hello,
i want to use my pre trained model but i didn't know how to generate the mean.msg which exist in Data Cifar 10 .

Can CNNdroid support R-CNN

Hi,R-CNN was supported in caffe ,and CNNdroid seems to support caffe and almost all CNN ,but it actually support R-CNN?how can I get the exactly support list of CNNdroid?

How can I parse mean.binaryproto file to mean.msg?

Great Job!
I run the Android Demo Project with my custom caffe model,which told me this error:"MessagePack_Init:: Expected array, but got raw value"。

Bellow is my mea file parse code:
proto_data = open(mean_filename, "rb").read() buf = msgpack.packb(proto_data, use_single_float=True) mean_msg = file("mean.msg", "wb") mean_msg.write(buf)

Can u tell me how to parse mean.binaryproto file to mean.msg correctly?Thank you!

SqueezeNet1.1 on CNNdroid

Hi, All
I am trying to use SqueezeNetV1.1 on CNNdroid.

I use SavePycaffeModelInMessagePack.py python script to generate the messages based on SqueezeNetV1.1 caffemodel, and it generated model_param_conv10.msg and model_param_conv1.msg, then I deploy these file into CaffeNet Demo APP.

But it make demo APP crash.
So is there anybody manage to use SqueezeNet on CNNdorid and any advices?

Thank you very much.

Unable to reproduce runtime performances on HTC One M9

Hello,

I am trying to run your caffenet demo on a HTC One M9.
I measured inference times larger than yours (between 1.5s and 2.3s per image)
I suspect I am not using GPU properly.

In the catlog I see this error :
12-23 15:04:36.066 23066-23158/com.library.example.caffenet E/RenderScript: Unable to open shared library (/data/user/0/com.library.example.caffenet/code_cache/com.android.renderscript.cache/librs.innerproductinf8outf1.so): undefined symbol: init

Could it be related ?
Any idea how to fix it ?

Thanks in advance for your help and advice.

Alex

mnist png recognition

Thank you for help with starting application. Now it works fine, but I have one more trouble.

I use this image(28-28) to recognize by LeNet
digit

and pyCaffe works fine and give me answer = 3
output = {6.72078215e-08, 6.08612163e-06, 8.28973225e-06, 9.99530911e-01, 6.53917276e-09, 4.10966662e-04, 1.80607959e-10, 2.87060775e-05, 2.26623479e-06, 1.27552030e-05}

cnnDroid returns to me float[1][10] = {0,NaN,NaN,NaN,0,NaN,0,0,0,0}

what I did wrong? (and one more question: can I use AbsVal activation function , not ReLU?)

High CPU usage

I noticed that when I test renderscript in my phone (Samsung S4), cpu usage is very high.
It seems that the code is running on the CPU.
Is it reasonable?

Are you planning to develop the project further?

Nice project
very intresting projects.
I tested it on nexus5 (snapdragon 800)

Are you planning to develop the project further?

for example

  • new Nets: googlenet inception, squeezenet or etc
  • new layers: concat, rnn with dif types

Is that necessary to port CNNDroid to NDK version?

I test My model on CNNDroid, it expends about 900ms forwarding one times in parallel mode, while expending abount 40s one times in sequential mode. Although in parallel mode with RenderScript it speeds up a lot, it is still too slow。 My goal is 400ms forwarding one times。 So, i want to use C++ to implement the CNNDroid Network part( replace current java code), Is it possible to speed up 2X(All i will do just replace Java Code, because i don't have any idea to optimize RenderScript or it is too perfect )?

Confuse about some parameters

When i writing net structure file about caffe-to-Cnndroid, i find some parameters that never appear in caffes net structure files but in CNNdroids,like normalization region,group.And i also confuse that i can`t find layer type like dropout layers.
Could you tell what these parameters means?I'm afraid it was a bother for you to do this. I would be very greatful if you can give me a hand.

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.