GithubHelp home page GithubHelp logo

notafraidltd / mobile-deep-learning Goto Github PK

View Code? Open in Web Editor NEW

This project forked from paddlepaddle/paddle-lite

0.0 2.0 0.0 120.39 MB

This research aims at simply deploying CNN(Convolutional Neural Network) on mobile devices, with low complexity and high speed.

License: MIT License

CMake 20.46% Shell 0.69% Swift 20.66% Metal 1.45% Objective-C 0.56% Objective-C++ 1.50% Protocol Buffer 23.14% Python 1.32% C++ 29.75% C 0.46%

mobile-deep-learning's Introduction

Mobile-deep-learning(MDL)

License Travis

Free and open source mobile deep learning framework, deploying by Baidu.

This research aims at simply deploying CNN on mobile devices, with low complexity and high speed. It supports calculation on iOS GPU, and is already adopted by Baidu APP.

  • Size: 340k+ (on arm v7)
  • Speed: 40ms (for iOS Metal GPU Mobilenet) or 30 ms (for Squeezenet)

百度研发的移动端深度学习框架,致力于让卷积神经网络极度简单的部署在手机端。目前正在手机百度内运行。支持iOS gpu计算。体积小,速度快。

  • 体积 armv7 340k+
  • 速度 iOS GPU mobilenet 可以达到 40ms、squeezenet 可以达到 30ms

Getting Started

Showcase

Baidu App

Android Demo

Be all eagerness to see it

If you want to run the demo first, or just use it quickly, without understanding implementation details, you can just scan the QR code, install the compiled apk/ipa file.

先睹为快

如果你想先运行demo试试效果。或者你仅仅是想快速用起来,而不关心CNN细节实现。我们已经为您编译好了安装文件, 直接扫码安装即可。

iOS-MobileNet:

iOS QR code

Android-Googlenet:

iOS QR code

If you want to know about the source code, please keep going. The source code is located at /examples.

如果你想看demo源码实现可以往下看。它位于examples目录。

Run the examples

  1. Cloning of the project.
  2. Install the apk\ipa file or import to the IDE.
  3. Run it.

Develop or use requirements

How to use MDL lib

Runing test on the OSX or Linux

# mac or linux:

./build.sh mac

cd build/release/x86/build

./mdlTest

Using MDL lib in your project

#android 
Copy so file to your project. According to the example of writing your code.
#ios
The example code is your code.

Enable multi-thread in MDL lib

# After a Net instance in MDL is created, you could set its thread numbers for execution like this.
net->set_thread_num(3); # Now MDL is tuned to run in 3 parallel threads.

Development

Compile the MDL source for android

# android:
# prerequisite: install ndk from google

./build.sh android

cd build/release/armv-v7a/build

./deploy_android.sh

adb shell

cd /data/local/tmp

./mdlTest

Compile the MDL source for iOS

# ios:
# prerequisite: install xcode from apple

./build.sh ios

copy ./build/release/ios/build/libmdl-static.a to your iOS project

Convert caffemodel to mdl format

#Convert model.prototxt and model.caffemodel to model.min.json and data.min.bin that mdl use

./build.sh mac
cd ./build/release/x86/tools/build

# copy your model.prototxt and model.caffemodel to this path
# also need the input data

./caffe2mdl model.prototxt model.caffemodel data

# after this command, model.min.json data.min.bin will be created in current 
# some difference step you need to do if you convert caffe model to iOS GPU format
# see this:
open iOS/convert/iOSConvertREADME.md

Features

  • One-button deployment. You can switch it to iOS or android by change parameters.
  • Support MobileNet and Squeezenet on iOS GPU.
  • Stablely running on MobileNet, GoogLeNet v1 and Squeezenet.
  • With extremely tiny size (~4M), without dependency on third-party libraries.
  • Provide quantization scripts, directly support the transform from 32-bit float to 8-bit uint.
  • We will continue to optimize the ARM platform according to the online and offline communication with ARM related algorithm team.
  • NEON usage covers all aspects of convolution, normalization, pooling, and so on.
  • Assembly optimizations are optimized for register assembler operations.
  • Loop unrolling, to expand the performance, reduce unnecessary CPU consumption, all expand the judgment operation.
  • Forward a large number of heavy computing tasks to the overhead process.

特征

  • 一键部署,脚本参数就可以切换ios或者android
  • 支持iOS gpu运行MobileNet、squeezenet模型
  • 已经测试过可以稳定运行MobileNet、GoogLeNet v1、squeezenet模型
  • 体积极小,无任何第三方依赖。纯手工打造。
  • 提供量化脚本,对32位float转8位uint直接支持,模型体积量化后4M上下
  • 与ARM相关算法团队线上线下多次沟通,针对ARM平台会持续优化
  • NEON使用涵盖了卷积、归一化、池化所有方面的操作
  • 汇编优化,针对寄存器汇编操作具体优化
  • loop unrolling 循环展开,为提升性能减少不必要的CPU消耗,全部展开判断操作
  • 将大量繁重的计算任务前置到overhead过程

TODO

  • Android GPU implementation

License

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

MDL使用的是宽松的MIT开源协议。

mobile-deep-learning's People

Contributors

rayliu2015 avatar yangyanzhan avatar

Watchers

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