提交 52659f48 编写于 作者: B Bin Li

conform android demo to new converter and docs

上级 f9011fde
...@@ -22,10 +22,9 @@ in one deployment file. ...@@ -22,10 +22,9 @@ in one deployment file.
* **Example** * **Example**
Here is an example deployment file with two models used by Here is an example deployment file with two models.
`MACE Android demo application <https://github.com/XiaoMi/mace/blob/master/mace/examples/android>`__.
.. literalinclude:: models/demo_app_models.yml .. literalinclude:: models/demo_models.yml
:language: yaml :language: yaml
......
...@@ -144,12 +144,12 @@ Modify one of them and use it for your own case. ...@@ -144,12 +144,12 @@ Modify one of them and use it for your own case.
- TensorFlow - TensorFlow
.. literalinclude:: models/demo_app_models_tf.yml .. literalinclude:: models/demo_models_tf.yml
:language: yaml :language: yaml
- Caffe - Caffe
.. literalinclude:: models/demo_app_models_caffe.yml .. literalinclude:: models/demo_models_caffe.yml
:language: yaml :language: yaml
More details about model deployment file are in :doc:`advanced_usage`. More details about model deployment file are in :doc:`advanced_usage`.
......
...@@ -3,10 +3,13 @@ ...@@ -3,10 +3,13 @@
set -e -u -o pipefail set -e -u -o pipefail
pushd ../../../ pushd ../../../
python tools/converter.py build --config=docs/user_guide/models/demo_app_models.yml
cp -r builds/mobilenet/include mace/examples/android/macelibrary/src/main/cpp/ python tools/converter.py convert --config=mace/examples/android/mobilenet.yml
cp -r builds/mobilenet/lib mace/examples/android/macelibrary/src/main/cpp/ cp -rf builds/mobilenet/include mace/examples/android/macelibrary/src/main/cpp/
cp -rf builds/mobilenet/model mace/examples/android/macelibrary/src/main/cpp/
bash tools/build-standalone-lib.sh
cp -rf builds/lib mace/examples/android/macelibrary/src/main/cpp/
popd popd
......
...@@ -14,18 +14,12 @@ cmake_minimum_required(VERSION 3.4.1) ...@@ -14,18 +14,12 @@ cmake_minimum_required(VERSION 3.4.1)
include_directories(${CMAKE_SOURCE_DIR}/) include_directories(${CMAKE_SOURCE_DIR}/)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include) include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include)
file(GLOB static_file ${CMAKE_SOURCE_DIR}/src/main/cpp/lib/arm64-v8a/*.a) set(mace_file ${CMAKE_SOURCE_DIR}/src/main/cpp/lib/arm64-v8a/libmace.a)
set(mobilenet_file ${CMAKE_SOURCE_DIR}/src/main/cpp/model/mobilenet.a)
MESSAGE(STATUS "FILE URL = ${CMAKE_SOURCE_DIR}") add_library (mace_lib STATIC IMPORTED)
MESSAGE(STATUS "FILE URL = ${static_file}") set_target_properties(mace_lib PROPERTIES IMPORTED_LOCATION ${mace_file})
add_library (mobilenet_lib STATIC IMPORTED)
foreach(fileStr ${static_file}) set_target_properties(mobilenet_lib PROPERTIES IMPORTED_LOCATION ${mobilenet_file})
set(tmpstr ${fileStr})
MESSAGE(STATUS "FILE URL = ${tmpstr}")
endforeach()
add_library (mace_mobile_lib STATIC IMPORTED)
set_target_properties(mace_mobile_lib PROPERTIES IMPORTED_LOCATION ${tmpstr})
add_library( # Sets the name of the library. add_library( # Sets the name of the library.
mace_mobile_jni mace_mobile_jni
...@@ -55,7 +49,8 @@ find_library( # Sets the name of the path variable. ...@@ -55,7 +49,8 @@ find_library( # Sets the name of the path variable.
target_link_libraries( # Specifies the target library. target_link_libraries( # Specifies the target library.
mace_mobile_jni mace_mobile_jni
mace_mobile_lib mace_lib
mobilenet_lib
# Links the target library to the log library # Links the target library to the log library
# included in the NDK. # included in the NDK.
${log-lib} ) ${log-lib} )
\ No newline at end of file
library_name: mobilenet
target_abis: [arm64-v8a]
model_graph_format: code
model_data_format: code
models:
mobilenet_v1:
platform: tensorflow
model_file_path: https://cnbj1.fds.api.xiaomi.com/mace/miai-models/mobilenet-v1/mobilenet-v1-1.0.pb
model_sha256_checksum: 71b10f540ece33c49a7b51f5d4095fc9bd78ce46ebf0300487b2ee23d71294e6
subgraphs:
- input_tensors:
- input
input_shapes:
- 1,224,224,3
output_tensors:
- MobilenetV1/Predictions/Reshape_1
output_shapes:
- 1,1001
runtime: cpu+gpu
limit_opencl_kernel_time: 0
nnlib_graph_mode: 0
obfuscate: 0
winograd: 0
mobilenet_v2:
platform: tensorflow
model_file_path: https://cnbj1.fds.api.xiaomi.com/mace/miai-models/mobilenet-v2/mobilenet-v2-1.0.pb
model_sha256_checksum: 369f9a5f38f3c15b4311c1c84c032ce868da9f371b5f78c13d3ea3c537389bb4
subgraphs:
- input_tensors:
- input
input_shapes:
- 1,224,224,3
output_tensors:
- MobilenetV2/Predictions/Reshape_1
output_shapes:
- 1,1001
runtime: cpu+gpu
limit_opencl_kernel_time: 0
nnlib_graph_mode: 0
obfuscate: 0
winograd: 0
...@@ -59,6 +59,10 @@ MaceStatus CreateMaceEngineFromCode( ...@@ -59,6 +59,10 @@ MaceStatus CreateMaceEngineFromCode(
return MaceStatus::MACE_INVALID_ARGS; return MaceStatus::MACE_INVALID_ARGS;
} }
std::shared_ptr<NetDef> net_def; std::shared_ptr<NetDef> net_def;
{% if embed_model_data %}
(void)model_data_file;
const unsigned char * model_data;
{% endif %}
MaceStatus status = MaceStatus::MACE_SUCCESS; MaceStatus status = MaceStatus::MACE_SUCCESS;
switch (model_name_map[model_name]) { switch (model_name_map[model_name]) {
{% for i in range(model_tags |length) %} {% for i in range(model_tags |length) %}
...@@ -66,12 +70,12 @@ MaceStatus CreateMaceEngineFromCode( ...@@ -66,12 +70,12 @@ MaceStatus CreateMaceEngineFromCode(
net_def = mace::{{model_tags[i]}}::CreateNet(); net_def = mace::{{model_tags[i]}}::CreateNet();
engine->reset(new mace::MaceEngine(device_type)); engine->reset(new mace::MaceEngine(device_type));
{% if embed_model_data %} {% if embed_model_data %}
(void)model_data_file; model_data = mace::{{model_tags[i]}}::LoadModelData();
const unsigned char * model_data = status = (*engine)->Init(net_def.get(), input_nodes, output_nodes,
mace::{{model_tags[i]}}::LoadModelData(); model_data);
status = (*engine)->Init(net_def.get(), input_nodes, output_nodes, model_data);
{% else %} {% else %}
status = (*engine)->Init(net_def.get(), input_nodes, output_nodes, model_data_file); status = (*engine)->Init(net_def.get(), input_nodes, output_nodes,
model_data_file);
{% endif %} {% endif %}
break; break;
{% endfor %} {% endfor %}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册