-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Benchmark tool] Support precision evaluation on Android (using imagenet) #7525
[Benchmark tool] Support precision evaluation on Android (using imagenet) #7525
Conversation
Thanks for your contribution! |
…/zhaoyang-star/Paddle-Lite into benchmark_tool_support_precision
CMakeLists.txt
Outdated
@@ -86,6 +86,7 @@ lite_option(LITE_THREAD_POOL "Enable thread pool in lite" | |||
lite_option(LITE_BUILD_EXTRA "Enable extra algorithm support in Lite, both kernels and operators" OFF) | |||
lite_option(LITE_BUILD_TAILOR "Enable tailoring library according to model" OFF) | |||
# cv build options | |||
lite_option(LITE_USE_PRECOMPILED_OPENCV "Use precompiled opencv, mainly for pre/post processing in benchmark" OFF) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
能否用已经支持的CV 加速库?不然lite 里有两个CV,感觉有些混淆
或者benchmark 使用opencv 方法效仿demo/cxx 下的使用方法,不要把他放到主库
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已删除该选项
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
lite/api/CMakeLists.txt
Outdated
if(NOT IOS AND NOT LITE_ON_TINY_PUBLISH) | ||
lite_cc_binary(test_model_bin SRCS tools/model_test.cc | ||
DEPS gflags | ||
CV_DEPS paddle_cv_arm) | ||
lite_cc_binary(benchmark_bin SRCS tools/benchmark.cc tools/flags.cc tools/opt_base.cc | ||
|
||
if(ARM_TARGET_OS STREQUAL "android") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是否能将benchmark的cmake代码都以新的CMakeLists.txt放在tools/benchmark/目录下,然后这里直接include?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以的,我修改下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -0,0 +1,8 @@ | |||
label_path:/data/local/tmp/benchmark/validation_dataset/ILSVRC2012_1000_cls_label_list.txt | |||
ground_truth_images_path:/data/local/tmp/benchmark/validation_dataset/ILSVRC2012_1000_cls/val_list_1k.txt | |||
resize_short_size:256 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config 中冒号是不是用空格隔开,这样看起来好点
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯,我在下个PR中更新下字符串处理的功能函数。由于这个是样板间,咱们CI执行有些慢,所以考虑基本功能OK的话,就先合入。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
后续改为使用 RapidJSON 解析 config.json
if (image_files.empty()) return; | ||
|
||
// Read image | ||
// std::cout << "image: " << image_files.at(cnt) << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没有用的注释能否删除
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我在下个PR中删除该调试注释
for (int i = 0; i < ele_num; i++) { | ||
float score = output_data[i]; | ||
int index = i; | ||
for (int j = 0; j < TOPK; j++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个可以用std::sort 排序
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::partial_sort(vec.begin(),
vec.begin() + topk,
vec.end(),
std::greater<std::pair<float, int>>());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK 在下个PR中更新此处
1. 背景
benchmark_bin
工具可以读取真实的验证集数据,进行计算后,给出性能数据和精度数据。2012 ILSVRC 验证集共 5K 张图片,约 6GB 存储空间,占用空间比较大,为适应端侧应用场景从中筛选出 1K 张图片进行验证。
筛选方法:从验证集中,每个类别挑选一张图片,最后形成一个含有 1K 张图片的验证集子集。
ILSVRC 2012 image classification task,可在此链接下载。
2. 适用场景
目前基于验证集的精度评测功能仅支持安卓系统,对其它系统的支持在开发中。
3. 在 Android 上运行精度评测
3.1 编译
编译完成后,会生成
build.lite.*./lite/api/benchmark_bin
二进制文件、基于 NDK 预编译好的 OpenCV4.1.0 和验证集。3.2 运行
需要将如下文件通过
adb
上传至手机:opt
工具离线优化后的.nb
文件benchmark_bin
config.txt
在 Host 端机器上操作例子如下:
部分输出日志如下:
详细信息请阅读:lite/api/tools/benchmark/precision_evaluation/imagenet_image_classification/README.md