0
雷鋒網(wǎng) AI科技評論消息,日前,百度在 GitHub 上開源了移動(dòng)端深度學(xué)習(xí)框架 mobile-deep-learning(MDL)的全部代碼以及腳本,這項(xiàng)研究旨在讓卷積神經(jīng)網(wǎng)絡(luò)(CNNC)能更簡單和高速的部署在移動(dòng)端,支持iOS GPU,目前已經(jīng)在百度APP上有所使用。雷鋒網(wǎng) AI科技評論將GitHub上的具體內(nèi)容整理如下:
大?。?40k+(在arm v7上)
速度:對于 iOS Metal GPU Mobilenet,速度是40ms,對于 Squeezenet,速度是30ms
展示案例
如果想先運(yùn)行demo或快速使用這個(gè)框架,你可以掃下面的二維碼安裝編譯好的apk/ipa文件,不用知道詳細(xì)的安裝細(xì)節(jié)。
iOS-MobileNet:
Android-Googlenet:
想要了解源碼實(shí)現(xiàn)可以繼續(xù)往下看,源碼位于examples文件夾里。
執(zhí)行樣例
1、復(fù)制項(xiàng)目代碼
2、安裝apk\ipa文件,或?qū)氲絀DE
3、運(yùn)行
前期準(zhǔn)備
android端安裝NDK
安裝Cmake
Android端 NDK CMake 文件地址:https://developer.android.google.cn/ndk/guides/cmake.html
安裝 Protocol Buffers
使用MDL lib步驟
在OSX或Linux上測試:
# mac or linux:
./build.sh mac
cd build/release/x86/build
./mdlTest
使用MDL lib
#android
Copy so file to your project. According to the example of writing your code.
#ios
The example code is your code.
多線程執(zhí)行
# 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.
開發(fā)
在android端編譯MDL資源
# 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
在iOS端編譯MDL資源
# ios:
# prerequisite: install xcode from apple
./build.sh ios
copy ./build/release/ios/build/libmdl-static.a to your iOS project
把caffemodel轉(zhuǎn)換成mdl格式
#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
特征
一鍵部署,可以通過修改參數(shù)在iOS和android端之間轉(zhuǎn)換
iOS GPU上支持運(yùn)行 MobileNet和Squeezenet模型
在MobileNet、GoogLeNet v1和Squeezenet模型下都很穩(wěn)定
占用空間極?。?M),不需要依賴第三方的庫
支持從32比特float到8比特unit轉(zhuǎn)化
接下來會(huì)與與ARM相關(guān)的算法團(tuán)隊(duì)進(jìn)行線上線下溝通,優(yōu)化ARM平臺(tái)
NEON使用涵蓋了所有的卷積、歸一化、池化等
利用循環(huán)展開,可以讓性能更加優(yōu)化,防止不必要的CPU損失
對于overhead進(jìn)程,可以轉(zhuǎn)發(fā)大量繁重的計(jì)算任務(wù)
項(xiàng)目地址:https://github.com/baidu/mobile-deep-learning
雷鋒網(wǎng) AI科技評論編輯整理。
雷峰網(wǎng)版權(quán)文章,未經(jīng)授權(quán)禁止轉(zhuǎn)載。詳情見轉(zhuǎn)載須知。