[Mobilar] How To Deploy Models In Mini Way
若干阅读材料
-
YOLO网络 + DarkNet 测试
Object detection with darknet (YOLOv3)
git clone https://github.com/pjreddie/darknet.git cd darknet/ make wget https://pjreddie.com/media/files/yolov3.weights ./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg
加载时间有点长,原因位置,至少模型比较大,200+M
Most of the time is spent loading the weights for the model. The actual detection took 200 ms.
But that still seems too long! If we are to do real time detection at 24 images / s, we should do much better than this. I'm trying to find out if that's normal, and will update the post when done. Maybe my two GeForceGTX 1080 Ti are not enough, or maybe only one of them is used...
I have tried the same exercise on the CPU, and it takes 37 s, so for sure, at least a GPU is used.
-
Mini-Caffe
Ref: https://github.com/luoyetx/mini-caffe
$ make
[ 1%] Building CXX object CMakeFiles/caffe.dir/src/blob.cpp.o
In file included from /home/gg/TEST/mini-caffe/src/./util/io.hpp:11:0,
from /home/gg/TEST/mini-caffe/src/blob.cpp:7:
/home/gg/TEST/mini-caffe/src/./util/../proto/caffe.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
#error This file was generated by a newer version of protoc which is
^~~~~
/home/gg/TEST/mini-caffe/src/./util/../proto/caffe.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
#error incompatible with your Protocol Buffer headers. Please update
^~~~~
/home/gg/TEST/mini-caffe/src/./util/../proto/caffe.pb.h:14:2: error: #error your headers.
#error your headers.
^~~~~
In file included from /home/gg/TEST/mini-caffe/src/./util/io.hpp:11:0,
from /home/gg/TEST/mini-caffe/src/blob.cpp:7:
/home/gg/TEST/mini-caffe/src/./util/../proto/caffe.pb.h:25:10: fatal error: google/protobuf/generated_message_table_driven.h: No such file or directory
#include <google/protobuf/generated_message_table_driven.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/caffe.dir/build.make:62: recipe for target 'CMakeFiles/caffe.dir/src/blob.cpp.o' failed
make[2]: *** [CMakeFiles/caffe.dir/src/blob.cpp.o] Error 1
CMakeFiles/Makefile2:135: recipe for target 'CMakeFiles/caffe.dir/all' failed
make[1]: *** [CMakeFiles/caffe.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
(1) 修改 protoc的版本,解决方法:https://github.com/BVLC/caffe/issues/5078
或者,只用Ubuntu18.04 的 docker image。
build$ protoc --version libprotoc 3.5.1
更新版本:https://gist.github.com/samklr/0b8a0620f82005e7f556
(2) fix一些问题:
添加这一条:CMakefile.txt
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
添加:
#include <math.h>
执行编译。
#! /bin/bash
wget https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz
tar xzf protobuf-2.6.1.tar.gz
cd protobuf-2.6.1
sudo apt-get update
sudo apt-get install build-essential
sudo ./configure
sudo make
sudo make check
sudo make install
sudo ldconfig
protoc --version
部署的话,只需要几个M的样子。
root@58749cb10254:~/mini-caffe/build# ll total 2824 drwxr-xr-x 3 root root 4096 May 30 09:44 ./ drwxr-xr-x 15 root root 4096 May 30 09:28 ../ -rw-r--r-- 1 root root 12809 May 30 09:42 CMakeCache.txt drwxr-xr-x 8 root root 4096 May 30 09:44 CMakeFiles/ -rw-r--r-- 1 root root 67536 May 30 09:42 Makefile -rwxr-xr-x 1 root root 42392 May 30 09:44 benchmark* -rw-r--r-- 1 root root 1491 May 30 09:42 cmake_install.cmake -rwxr-xr-x 1 root root 2601672 May 30 09:44 libcaffe.so* -rwxr-xr-x 1 root root 115464 May 30 09:44 run_net* -rwxr-xr-x 1 root root 13536 May 30 09:44 run_net_c*
-
PyTorch 部署
Ref: [PyTorch]PyTorch的C++前端和模型部署,一些参考资料。
continue...

浙公网安备 33010602011771号