Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
3e20b7af
Mace
项目概览
Xiaomi
/
Mace
通知
106
Star
40
Fork
27
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Mace
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3e20b7af
编写于
6月 26, 2018
作者:
B
Bin Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
android demo build docs and script
上级
021e765a
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
77 addition
and
83 deletion
+77
-83
docs/getting_started/models/demo_app_models.yaml
docs/getting_started/models/demo_app_models.yaml
+24
-41
mace/examples/android/README.md
mace/examples/android/README.md
+27
-0
mace/examples/android/README_zh.md
mace/examples/android/README_zh.md
+0
-15
mace/examples/android/app/src/main/assets/BUILD
mace/examples/android/app/src/main/assets/BUILD
+0
-15
mace/examples/android/app/src/main/java/com/xiaomi/mace/demo/result/ResultData.java
...src/main/java/com/xiaomi/mace/demo/result/ResultData.java
+1
-1
mace/examples/android/build.sh
mace/examples/android/build.sh
+13
-0
mace/examples/android/macelibrary/CMakeLists.txt
mace/examples/android/macelibrary/CMakeLists.txt
+2
-1
mace/examples/android/macelibrary/src/main/cpp/image_classify.cc
...amples/android/macelibrary/src/main/cpp/image_classify.cc
+10
-10
未找到文件。
docs/getting_started/models/demo_app_models.yaml
浏览文件 @
3e20b7af
# The name of library
# The name of library
library_name
:
library_name
library_name
:
mobilenet
target_abis
:
[
armeabi-v7a
,
arm64-v8a
]
target_abis
:
[
arm64-v8a
]
# The soc serialno of specific device.
# Get by command `adb shell getprop | grep ro.board.platform | cut -d [ -f3 | cut -d ] -f1`.
target_socs
:
[
msm8998
]
embed_model_data
:
1
embed_model_data
:
1
# The build mode for model(s).
# The build mode for model(s).
# 'code' stand for transfer model(s) into cpp code, 'proto' for model(s) in protobuf file(s).
# 'code' stand for transfer model(s) into cpp code, 'proto' for model(s) in protobuf file(s).
build_type
:
code
build_type
:
code
linkshared
:
1
linkshared
:
0
# One yaml config file can contain multi models' config message.
# One yaml config file can contain multi models' config message.
models
:
models
:
mo
del_name
:
# model tag, which will be used in model loading and must be specific.
mo
bilenet_v1
:
# model tag, which will be used in model loading and must be specific.
platform
:
tensorflow
platform
:
tensorflow
model_file_path
:
path/to/model64.pb
# also support http:// and https://
# support local path, http:// and https://
model_sha256_checksum
:
7f7462333406e7dea87222737590ebb7d94490194d2f21a7d72bafa87e64e9f9
model_file_path
:
https://cnbj1.fds.api.xiaomi.com/mace/miai-models/mobilenet-v1/mobilenet-v1-1.0.pb
model_sha256_checksum
:
71b10f540ece33c49a7b51f5d4095fc9bd78ce46ebf0300487b2ee23d71294e6
subgraphs
:
subgraphs
:
-
input_tensors
:
input_node
-
input_tensors
:
input
input_shapes
:
1,64,64,3
input_shapes
:
1,224,224,3
output_tensors
:
output_node
output_tensors
:
MobilenetV1/Predictions/Reshape_1
output_shapes
:
1,64,64,2
output_shapes
:
1,1001
runtime
:
gpu
runtime
:
cpu+gpu
data_type
:
fp16_fp32
limit_opencl_kernel_time
:
0
limit_opencl_kernel_time
:
0
nnlib_graph_mode
:
0
nnlib_graph_mode
:
0
obfuscate
:
1
obfuscate
:
0
winograd
:
0
winograd
:
0
input_files
:
mobilenet_v2
:
-
path/to/input_files
# support http://
platform
:
tensorflow
second_net
:
model_file_path
:
https://cnbj1.fds.api.xiaomi.com/mace/miai-models/mobilenet-v2/mobilenet-v2-1.0.pb
platform
:
caffe
model_sha256_checksum
:
369f9a5f38f3c15b4311c1c84c032ce868da9f371b5f78c13d3ea3c537389bb4
model_file_path
:
path/to/model.prototxt
weight_file_path
:
path/to/weight.caffemodel
model_sha256_checksum
:
05d92625809dc9edd6484882335c48c043397aed450a168d75eb8b538e86881a
weight_sha256_checksum
:
05d92625809dc9edd6484882335c48c043397aed450a168d75eb8b538e86881a
subgraphs
:
subgraphs
:
-
input_tensors
:
-
input_tensors
:
input
-
input_node0
input_shapes
:
1,224,224,3
-
input_node1
output_tensors
:
MobilenetV2/Predictions/Reshape_1
input_shapes
:
output_shapes
:
1,1001
-
1,256,256,3
runtime
:
cpu+gpu
-
1,128,128,3
limit_opencl_kernel_time
:
0
output_tensors
:
-
output_node0
-
output_node1
output_shapes
:
-
1,256,256,2
-
1,1,1,2
validation_inputs_data
:
-
path/to/input_files
# support http://
runtime
:
cpu
limit_opencl_kernel_time
:
1
nnlib_graph_mode
:
0
nnlib_graph_mode
:
0
obfuscate
:
1
obfuscate
:
0
winograd
:
0
winograd
:
0
mace/examples/android/README.md
0 → 100644
浏览文件 @
3e20b7af
Android Demo
------------
------------
Try it by downloading the
[
APK
](
https://cnbj1.fds.api.xiaomi.com/mace/demo/mace_android_demo.apk
)
.
How to build
---------------
*
Build native library, please refer to
[
docs
](
docs
)
for more information.
```
# Execute following commands from the project's root directory
python tools/converter.py build --config=docs/getting_started/models/demo_app_models.yaml
cp -r build/mobilenet/include/ mace/examples/android/macelibrary/src/main/cpp/
cp -r build/mobilenet/lib/ mace/examples/android/macelibrary/src/main/cpp/
```
*
Build APK
*
Import the
`mace/examples/android`
directory as a new Android Studio project and select
`install run`
*
Or build it with gradle:
```
cd mace/exampls/android
./gradlew installAppRelease
```
*
You can also build native library and APK with
`mace/examples/android/build.sh`
```
cd mace/exampls/android
./build.sh
```
mace/examples/android/README_zh.md
已删除
100644 → 0
浏览文件 @
021e765a
# mace demo使用方法
*
使用前需要生成静态库和头文件,具体参考
[
文档
](
docs
)
*
把mace/public目录下的mace.h和mace_runtime.h拷贝到macelibrary/src/main/cpp/include下面
*
把生成的mace/codegen/engine/mace_engine_factory.h拷贝到macelibrary/src/main/cpp/include下面
*
静态库的路径是在mace/build/demo_app_models/lib/下
*
使用android studio 导入项目,然后运行install run
*
还可以使用gradle命令(需要安装gradle)生成apk 具体命令例如:./gradlew assemble(或者Release|Debug)
## 交流与反馈
*
欢迎通过Github Issues提交问题报告与建议
*
QQ群: 756046893
## License
[
Apache License 2.0
](
LICENSE
)
.
mace/examples/android/app/src/main/assets/BUILD
已删除
100644 → 0
浏览文件 @
021e765a
package
(
default_visibility
=
[
"//visibility:public"
])
licenses
([
"notice"
])
# Apache 2.0
# It is necessary to use this filegroup rather than globbing the files in this
# folder directly the examples/android:tensorflow_demo target due to the fact
# that assets_dir is necessarily set to "" there (to allow using other
# arbitrary targets as assets).
filegroup
(
name
=
"asset_files"
,
srcs
=
glob
(
[
"**/*"
],
exclude
=
[
"BUILD"
],
),
)
mace/examples/android/app/src/main/java/com/xiaomi/mace/demo/result/ResultData.java
浏览文件 @
3e20b7af
...
@@ -17,7 +17,7 @@ package com.xiaomi.mace.demo.result;
...
@@ -17,7 +17,7 @@ package com.xiaomi.mace.demo.result;
public
class
ResultData
{
public
class
ResultData
{
public
String
name
;
public
String
name
;
public
float
probability
;
public
float
probability
;
public
long
costTime
;
//
毫秒
public
long
costTime
;
//
ms
public
ResultData
(
String
name
,
float
probability
)
{
public
ResultData
(
String
name
,
float
probability
)
{
this
.
name
=
name
;
this
.
name
=
name
;
...
...
mace/examples/android/build.sh
0 → 100755
浏览文件 @
3e20b7af
#!/usr/bin/env bash
set
-e
-u
-o
pipefail
pushd
../../../
python tools/converter.py build
--config
=
docs/getting_started/models/demo_app_models.yaml
cp
-r
build/mobilenet/include/ mace/examples/android/macelibrary/src/main/cpp/
cp
-r
build/mobilenet/lib/ mace/examples/android/macelibrary/src/main/cpp/
popd
./gradlew installAppRelease
mace/examples/android/macelibrary/CMakeLists.txt
浏览文件 @
3e20b7af
...
@@ -13,7 +13,8 @@ cmake_minimum_required(VERSION 3.4.1)
...
@@ -13,7 +13,8 @@ cmake_minimum_required(VERSION 3.4.1)
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/../app/libs/${ANDROID_ABI})
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/../app/libs/${ANDROID_ABI})
include_directories
(
${
CMAKE_SOURCE_DIR
}
/
)
include_directories
(
${
CMAKE_SOURCE_DIR
}
/
)
file
(
GLOB static_file
${
CMAKE_SOURCE_DIR
}
/../../../build/demo_app_models/lib/arm64-v8a/*.a
)
include_directories
(
${
CMAKE_SOURCE_DIR
}
/src/main/cpp/include
)
file
(
GLOB static_file
${
CMAKE_SOURCE_DIR
}
/src/main/cpp/lib/arm64-v8a/*.a
)
MESSAGE
(
STATUS
"FILE URL =
${
CMAKE_SOURCE_DIR
}
"
)
MESSAGE
(
STATUS
"FILE URL =
${
CMAKE_SOURCE_DIR
}
"
)
MESSAGE
(
STATUS
"FILE URL =
${
static_file
}
"
)
MESSAGE
(
STATUS
"FILE URL =
${
static_file
}
"
)
...
...
mace/examples/android/macelibrary/src/main/cpp/image_classify.cc
浏览文件 @
3e20b7af
...
@@ -25,9 +25,9 @@
...
@@ -25,9 +25,9 @@
#include <vector>
#include <vector>
#include <numeric>
#include <numeric>
#include "src/main/cpp/include/mace.h"
#include "src/main/cpp/include/mace
/public/mace
.h"
#include "src/main/cpp/include/mace_runtime.h"
#include "src/main/cpp/include/mace
/public/mace
_runtime.h"
#include "src/main/cpp/include/mace_engine_factory.h"
#include "src/main/cpp/include/mace
/public/mace
_engine_factory.h"
namespace
{
namespace
{
...
@@ -45,9 +45,9 @@ struct MaceContext {
...
@@ -45,9 +45,9 @@ struct MaceContext {
mace
::
DeviceType
device_type
=
mace
::
DeviceType
::
CPU
;
mace
::
DeviceType
device_type
=
mace
::
DeviceType
::
CPU
;
std
::
map
<
std
::
string
,
ModelInfo
>
model_infos
=
{
std
::
map
<
std
::
string
,
ModelInfo
>
model_infos
=
{
{
"mobilenet_v1"
,
{
"input"
,
"MobilenetV1/Predictions/Reshape_1"
,
{
"mobilenet_v1"
,
{
"input"
,
"MobilenetV1/Predictions/Reshape_1"
,
{
1
,
224
,
224
,
3
},
{
1
,
1
,
1
,
1
001
}}},
{
1
,
224
,
224
,
3
},
{
1
,
1001
}}},
{
"mobilenet_v2"
,
{
"input"
,
"MobilenetV2/Predictions/Reshape_1"
,
{
"mobilenet_v2"
,
{
"input"
,
"MobilenetV2/Predictions/Reshape_1"
,
{
1
,
224
,
224
,
3
},
{
1
,
1
,
1
,
1
001
}}}
{
1
,
224
,
224
,
3
},
{
1
,
1001
}}}
};
};
};
};
...
@@ -146,11 +146,11 @@ Java_com_xiaomi_mace_JniMaceUtils_maceMobilenetCreateEngine(
...
@@ -146,11 +146,11 @@ Java_com_xiaomi_mace_JniMaceUtils_maceMobilenetCreateEngine(
mace
::
MaceStatus
create_engine_status
=
mace
::
MaceStatus
create_engine_status
=
CreateMaceEngineFromCode
(
mace_context
.
model_name
,
CreateMaceEngineFromCode
(
mace_context
.
model_name
,
std
::
string
(),
std
::
string
(),
input_names
,
input_names
,
output_names
,
output_names
,
mace_context
.
device_type
,
mace_context
.
device_type
,
&
mace_context
.
engine
);
&
mace_context
.
engine
);
__android_log_print
(
ANDROID_LOG_ERROR
,
__android_log_print
(
ANDROID_LOG_ERROR
,
"image_classify attrs"
,
"image_classify attrs"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录