System: Ubuntu20.04
CMAKE: 3.16.3
- 把第0篇-Tengine X86版本编译中编译好的so和头文件复制到项目目录中的tengine目录
- 把Tengine/examples/common中部分文件放入common目录
- 把模型仓库的mobilenet.tmfile模型放到models目录,cat.jpg图片放到images目录
- 把tm_classification.c文件放到src目录
此时目录结构应该是这样
├── images
│ └── cat.jpg
├── models
│ └── mobilenet.tmfile
├── src
│ ├── common
│ │ ├── common.h
│ │ ├── stb_image.h
│ │ ├── stb_image_write.h
│ │ ├── tengine_operations.c
│ │ └── tengine_operations.h
│ └── tm_classification.c
└── tengine
├── include
│ └── tengine
│ ├── c_api.h
│ └── defines.h
└── lib
└── libtengine-lite.so
cmake_minimum_required(VERSION 3.10)
project(tm_classification)
set(CMAKE_CXX_STANDARD 11)
include_directories(tengine/include/ src/common/)
add_library(tengine SHARED IMPORTED)
set_target_properties(tengine PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/tengine/lib/libtengine-lite.so)
add_executable(tm_classification src/tm_classification.c "src/common/tengine_operations.c" )
target_link_libraries(tm_classification -lm tengine)
mkdir build
cd build
cmake ..
make -j`nproc`
./build/tm_classification -m ./models/mobilenet.tmfile -i ./images/cat.jpg
输出
Image height not specified, use default 224
Image width not specified, use default 224
Scale value not specified, use default 0.0, 0.0, 0.0
Mean value not specified, use default 104.0, 116.7, 122.7
tengine-lite library version: 1.4-dev
model file : ./models/mobilenet.tmfile
image file : ./imgs/cat.jpg
img_h, img_w, scale[3], mean[3] : 224 224 , 0.017 0.017 0.017, 104.0 116.7 122.7
Repeat 1 times, thread 1, avg time 42.71 ms, max_time 42.71 ms, min_time 42.71 ms
--------------------------------------
8.574144, 282
7.880117, 277
7.812573, 278
7.286458, 263
6.357486, 281
--------------------------------------