Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
毕竟曾有刹那
Mace
提交
c85c762a
Mace
项目概览
毕竟曾有刹那
/
Mace
与 Fork 源项目一致
Fork自
Xiaomi / Mace
通知
1
Star
0
Fork
0
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
c85c762a
编写于
1月 26, 2018
作者:
Y
yejianwu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update validate.py dsp goal, use consistent lib for gpu and dsp device
上级
fe34b8aa
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
22 addition
and
20 deletion
+22
-20
validate.py
validate.py
+9
-3
validate_model.sh
validate_model.sh
+13
-17
未找到文件。
validate.py
浏览文件 @
c85c762a
...
...
@@ -43,7 +43,8 @@ def valid_output(out_shape, mace_out_file, tf_out_value):
if
mace_out_value
.
size
!=
0
:
similarity
=
(
1
-
spatial
.
distance
.
cosine
(
tf_out_value
.
flat
,
mace_out_value
))
print
'MACE VS TF similarity: '
,
similarity
if
similarity
>
0.995
:
if
(
FLAGS
.
mace_runtime
==
"gpu"
and
similarity
>
0.995
)
or
\
(
FLAGS
.
mace_runtime
==
"dsp"
and
similarity
>
0.930
):
print
'=======================Similarity Test Passed======================'
else
:
print
'=======================Similarity Test Failed======================'
...
...
@@ -104,15 +105,20 @@ def parse_args():
type
=
str
,
default
=
""
,
help
=
"mace output file to load."
)
parser
.
add_argument
(
"--mace_runtime"
,
type
=
str
,
default
=
"gpu"
,
help
=
"mace runtime device."
)
parser
.
add_argument
(
"--input_shape"
,
type
=
str
,
default
=
"
512,512
,3"
,
default
=
"
1,64,64
,3"
,
help
=
"input shape."
)
parser
.
add_argument
(
"--output_shape"
,
type
=
str
,
default
=
"1,
512,512
,2"
,
default
=
"1,
64,64
,2"
,
help
=
"output shape."
)
parser
.
add_argument
(
"--input_node"
,
...
...
validate_model.sh
浏览文件 @
c85c762a
...
...
@@ -25,7 +25,6 @@ fi
if
[
x
"
$RUNTIME
"
=
x
"dsp"
]
;
then
DATA_TYPE
=
"DT_UINT8"
DEVICE_TYPE
=
"HEXAGON"
LIB_FOLDER_NAME
=
"
${
LIB_FOLDER_NAME
}
_dsp"
elif
[
x
"
$RUNTIME
"
=
x
"gpu"
]
;
then
DATA_TYPE
=
"DT_HALF"
DEVICE_TYPE
=
"OPENCL"
...
...
@@ -34,10 +33,7 @@ else
exit
-1
fi
LIBMACE_TAG
=
`
git describe
--abbrev
=
0
--tags
`
if
[
!
"
${
LIBMACE_TAG
}
"
]
;
then
LIBMACE_TAG
=
"v0.1"
fi
LIBMACE_TAG
=
`
git describe
--abbrev
=
0
--tags
`
||
exit
-1
VLOG_LEVEL
=
0
MODEL_DIR
=
$(
dirname
${
TF_MODEL_FILE_PATH
}
)
...
...
@@ -105,23 +101,22 @@ build_and_run()
--round
=
$round
||
exit
-1
}
download_
libs
()
download_
and_link_lib
()
{
if
[
!
-d
"
${
LIBMACE_SOURCE_DIR
}
/lib/
${
LIB_FOLDER_NAME
}
"
]
;
then
wget
-P
${
LIBMACE_SOURCE_DIR
}
/lib http://cnbj1-inner-fds.api.xiaomi.net/libmace/libs/
${
LIBMACE_TAG
}
/
${
LIB_FOLDER_NAME
}
.tar.gz
&&
\
tar
xvzf
${
LIBMACE_SOURCE_DIR
}
/lib/
${
LIB_FOLDER_NAME
}
.tar.gz
-C
${
LIBMACE_SOURCE_DIR
}
/lib/
||
exit
-1
if
[
-p
${
LIBMACE_SOURCE_DIR
}
/lib/mace
]
;
then
unlink
${
LIBMACE_SOURCE_DIR
}
/lib/mace
fi
ln
-s
${
LIBMACE_SOURCE_DIR
}
/lib/
${
LIB_FOLDER_NAME
}
${
LIBMACE_SOURCE_DIR
}
/lib/mace
&&
\
rm
-rf
${
LIBMACE_SOURCE_DIR
}
/lib/
${
LIB_FOLDER_NAME
}
.tar.gz
||
exit
-1
echo
"
${
LIB_FOLDER_NAME
}
download successfully!"
else
echo
"
${
LIB_FOLDER_NAME
}
already exists!"
fi
echo
"Create link 'mace' of downloaded or existed
${
LIB_FOLDER_NAME
}
"
if
[
-p
${
LIBMACE_SOURCE_DIR
}
/lib/mace
]
;
then
unlink
${
LIBMACE_SOURCE_DIR
}
/lib/mace
fi
ln
-s
${
LIBMACE_SOURCE_DIR
}
/lib/
${
LIB_FOLDER_NAME
}
${
LIBMACE_SOURCE_DIR
}
/lib/mace
&&
\
rm
-rf
${
LIBMACE_SOURCE_DIR
}
/lib/
${
LIB_FOLDER_NAME
}
.tar.gz
||
exit
-1
}
echo
"Step 1: Generate input data"
...
...
@@ -146,7 +141,7 @@ bazel-bin/lib/python/tools/tf_converter --input=${TF_MODEL_FILE_PATH} \
--obfuscate
=
True
||
exit
-1
echo
"Step 3: Download mace static library"
download_
libs
download_
and_link_lib
echo
"Step 4: Run model on the phone with files"
build_and_run
false
...
...
@@ -178,10 +173,11 @@ echo "Step 9: Validate the result"
python tools/validate.py
--model_file
${
TF_MODEL_FILE_PATH
}
\
--input_file
${
MODEL_DIR
}
/
${
INPUT_FILE_NAME
}
\
--mace_out_file
${
MODEL_DIR
}
/
${
OUTPUT_FILE_NAME
}
\
--mace_runtime
${
RUNTIME
}
\
--input_node
${
TF_INPUT_NODE
}
\
--output_node
${
TF_OUTPUT_NODE
}
\
--input_shape
"
${
INPUT_SHAPE
}
"
\
--output_shape
"
${
OUTPUT_SHAPE
}
"
--input_shape
${
INPUT_SHAPE
}
\
--output_shape
${
OUTPUT_SHAPE
}
echo
"Step 10: Generate project static lib"
rm
-rf
${
LIBMACE_BUILD_DIR
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录