Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
毕竟曾有刹那
Mace
提交
667fa578
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,发现更多精彩内容 >>
提交
667fa578
编写于
9月 27, 2018
作者:
B
Bin Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add quantized mobilenet for android demo
上级
028b4ab3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
82 addition
and
5 deletion
+82
-5
mace/examples/android/README.md
mace/examples/android/README.md
+5
-1
mace/examples/android/app/src/main/java/com/xiaomi/mace/demo/CameraActivity.java
...pp/src/main/java/com/xiaomi/mace/demo/CameraActivity.java
+12
-0
mace/examples/android/app/src/main/java/com/xiaomi/mace/demo/result/InitData.java
...p/src/main/java/com/xiaomi/mace/demo/result/InitData.java
+16
-2
mace/examples/android/macelibrary/src/main/cpp/image_classify.cc
...amples/android/macelibrary/src/main/cpp/image_classify.cc
+7
-2
mace/examples/android/mobilenet.yml
mace/examples/android/mobilenet.yml
+42
-0
未找到文件。
mace/examples/android/README.md
浏览文件 @
667fa578
...
@@ -11,4 +11,8 @@ cd mace/exampls/android
...
@@ -11,4 +11,8 @@ cd mace/exampls/android
Pre-built APK
Pre-built APK
--------------
--------------
Pre-built Android APK can be downloaded
[
here
](
https://cnbj1.fds.api.xiaomi.com/mace/demo/mace_android_demo.apk
)
.
Pre-built Android APK can be downloaded
[
here
](
https://cnbj1.fds.api.xiaomi.com/mace/demo/mace_android_demo.apk
)
.
\ No newline at end of file
Note
--------------
We use two big cores for CPU inference.
mace/examples/android/app/src/main/java/com/xiaomi/mace/demo/CameraActivity.java
浏览文件 @
667fa578
...
@@ -180,11 +180,23 @@ public class CameraActivity extends Activity implements View.OnClickListener, Ap
...
@@ -180,11 +180,23 @@ public class CameraActivity extends Activity implements View.OnClickListener, Ap
public
void
onCLickItem
(
String
content
)
{
public
void
onCLickItem
(
String
content
)
{
mSelectMode
.
setText
(
content
);
mSelectMode
.
setText
(
content
);
initData
.
setModel
(
content
);
initData
.
setModel
(
content
);
handleOnlyCpuSupportByModel
(
content
);
AppModel
.
instance
.
maceMobilenetCreateEngine
(
initData
,
CameraActivity
.
this
);
AppModel
.
instance
.
maceMobilenetCreateEngine
(
initData
,
CameraActivity
.
this
);
}
}
});
});
}
}
private
void
handleOnlyCpuSupportByModel
(
String
model
)
{
if
(
InitData
.
isOnlySupportCpuByModel
(
model
))
{
String
device
=
InitData
.
getCpuDevice
();
mSelectPhoneType
.
setText
(
device
);
mSelectPhoneType
.
setEnabled
(
false
);
initData
.
setDevice
(
device
);
}
else
{
mSelectPhoneType
.
setEnabled
(
true
);
}
}
@Override
@Override
public
void
onCreateEngineFail
(
final
boolean
quit
)
{
public
void
onCreateEngineFail
(
final
boolean
quit
)
{
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
this
);
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
this
);
...
...
mace/examples/android/app/src/main/java/com/xiaomi/mace/demo/result/InitData.java
浏览文件 @
667fa578
...
@@ -21,7 +21,8 @@ import java.io.File;
...
@@ -21,7 +21,8 @@ import java.io.File;
public
class
InitData
{
public
class
InitData
{
public
static
final
String
[]
DEVICES
=
new
String
[]{
"CPU"
,
"GPU"
};
public
static
final
String
[]
DEVICES
=
new
String
[]{
"CPU"
,
"GPU"
};
public
static
final
String
[]
MODELS
=
new
String
[]{
"mobilenet_v1"
,
"mobilenet_v2"
};
public
static
final
String
[]
MODELS
=
new
String
[]{
"mobilenet_v1"
,
"mobilenet_v2"
,
"mobilenet_v1_quant"
,
"mobilenet_v2_quant"
};
private
static
final
String
[]
ONLY_CPU_MODELS
=
new
String
[]{
"mobilenet_v1_quant"
,
"mobilenet_v2_quant"
};
private
String
model
;
private
String
model
;
private
String
device
=
""
;
private
String
device
=
""
;
...
@@ -34,7 +35,7 @@ public class InitData {
...
@@ -34,7 +35,7 @@ public class InitData {
public
InitData
()
{
public
InitData
()
{
model
=
MODELS
[
0
];
model
=
MODELS
[
0
];
ompNumThreads
=
2
;
ompNumThreads
=
2
;
cpuAffinityPolicy
=
0
;
cpuAffinityPolicy
=
1
;
gpuPerfHint
=
3
;
gpuPerfHint
=
3
;
gpuPriorityHint
=
3
;
gpuPriorityHint
=
3
;
device
=
DEVICES
[
0
];
device
=
DEVICES
[
0
];
...
@@ -101,4 +102,17 @@ public class InitData {
...
@@ -101,4 +102,17 @@ public class InitData {
public
void
setStoragePath
(
String
storagePath
)
{
public
void
setStoragePath
(
String
storagePath
)
{
this
.
storagePath
=
storagePath
;
this
.
storagePath
=
storagePath
;
}
}
public
static
String
getCpuDevice
()
{
return
DEVICES
[
0
];
}
public
static
boolean
isOnlySupportCpuByModel
(
String
model
)
{
for
(
String
m
:
ONLY_CPU_MODELS
)
{
if
(
m
.
equals
(
model
))
{
return
true
;
}
}
return
false
;
}
}
}
mace/examples/android/macelibrary/src/main/cpp/image_classify.cc
浏览文件 @
667fa578
...
@@ -46,7 +46,11 @@ struct MaceContext {
...
@@ -46,7 +46,11 @@ struct MaceContext {
{
"mobilenet_v1"
,
{
"input"
,
"MobilenetV1/Predictions/Reshape_1"
,
{
"mobilenet_v1"
,
{
"input"
,
"MobilenetV1/Predictions/Reshape_1"
,
{
1
,
224
,
224
,
3
},
{
1
,
1001
}}},
{
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
,
1001
}}}
{
1
,
224
,
224
,
3
},
{
1
,
1001
}}},
{
"mobilenet_v1_quant"
,
{
"input"
,
"MobilenetV1/Predictions/Softmax:0"
,
{
1
,
224
,
224
,
3
},
{
1
,
1001
}}},
{
"mobilenet_v2_quant"
,
{
"input"
,
"output"
,
{
1
,
224
,
224
,
3
},
{
1
,
1001
}}}
};
};
};
};
...
@@ -107,7 +111,8 @@ Java_com_xiaomi_mace_JniMaceUtils_maceMobilenetCreateEngine(
...
@@ -107,7 +111,8 @@ Java_com_xiaomi_mace_JniMaceUtils_maceMobilenetCreateEngine(
mace
::
MaceEngineConfig
config
(
mace_context
.
device_type
);
mace
::
MaceEngineConfig
config
(
mace_context
.
device_type
);
status
=
config
.
SetCPUThreadPolicy
(
status
=
config
.
SetCPUThreadPolicy
(
omp_num_threads
,
omp_num_threads
,
static_cast
<
mace
::
CPUAffinityPolicy
>
(
cpu_affinity_policy
));
static_cast
<
mace
::
CPUAffinityPolicy
>
(
cpu_affinity_policy
),
true
);
if
(
status
!=
mace
::
MACE_SUCCESS
)
{
if
(
status
!=
mace
::
MACE_SUCCESS
)
{
__android_log_print
(
ANDROID_LOG_ERROR
,
__android_log_print
(
ANDROID_LOG_ERROR
,
"image_classify attrs"
,
"image_classify attrs"
,
...
...
mace/examples/android/mobilenet.yml
浏览文件 @
667fa578
...
@@ -39,3 +39,45 @@ models:
...
@@ -39,3 +39,45 @@ models:
nnlib_graph_mode
:
0
nnlib_graph_mode
:
0
obfuscate
:
0
obfuscate
:
0
winograd
:
0
winograd
:
0
mobilenet_v1_quant
:
platform
:
tensorflow
model_file_path
:
http://cnbj1.fds.api.xiaomi.com/mace/miai-models/mobilenet-v1/mobilenet_v1_1.0_224_quant_retrain.pb
model_sha256_checksum
:
c3faa9bd790310eb3dec411d2f2e2dd8802394e31ccb47daaa5e3b6369fadfa3
subgraphs
:
-
input_tensors
:
-
input
input_shapes
:
-
1,224,224,3
input_ranges
:
-
-1.0,1.0
output_tensors
:
-
MobilenetV1/Predictions/Softmax:0
output_shapes
:
-
1,1001
runtime
:
cpu
limit_opencl_kernel_time
:
0
nnlib_graph_mode
:
0
obfuscate
:
0
winograd
:
0
quantize
:
1
mobilenet_v2_quant
:
platform
:
tensorflow
model_file_path
:
https://cnbj1.fds.api.xiaomi.com/mace/miai-models/mobilenet-v2/mobilenet_v2_1.0_224_quant_retrain.pb
model_sha256_checksum
:
1429c8e2a91b251c9fa0dae43dfa5817c5a798bd30284f8c0690e7569a8817f1
subgraphs
:
-
input_tensors
:
-
input
input_shapes
:
-
1,224,224,3
input_ranges
:
-
-1.0,1.0
output_tensors
:
-
output
output_shapes
:
-
1,1001
runtime
:
cpu
limit_opencl_kernel_time
:
0
nnlib_graph_mode
:
0
obfuscate
:
0
winograd
:
0
quantize
:
1
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录