MDL:百度出品的移動端深度學習框架">MDL:百度出品的移動端深度學習框架

分類:IT技術 時間:2017-09-26

Mobile-deep-learning(MDL)

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

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:

android-Googlenet:

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

  • Installing NDK for android.
  • Installing Cmake.
  • Android NDK CMake Document
  • Installing Protocol Buffers.

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開源協議。


Tags: 百度 深度 移動 the source 學習

文章來源:


ads
ads

相關文章
ads

相關文章

ad