[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
| 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.
能否用已经支持的CV 加速库?不然lite 里有两个CV,感觉有些混淆
或者benchmark 使用opencv 方法效仿demo/cxx 下的使用方法,不要把他放到主库
lite/api/CMakeLists.txt
Outdated
| 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.
是否能将benchmark的cmake代码都以新的CMakeLists.txt放在tools/benchmark/目录下,然后这里直接include?
| @@ -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.
config 中冒号是不是用空格隔开,这样看起来好点
There was a problem hiding this comment.
嗯,我在下个PR中更新下字符串处理的功能函数。由于这个是样板间,咱们CI执行有些慢,所以考虑基本功能OK的话,就先合入。
There was a problem hiding this comment.
后续改为使用 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.
我在下个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.
std::partial_sort(vec.begin(),
vec.begin() + topk,
vec.end(),
std::greater<std::pair<float, int>>());
There was a problem hiding this comment.
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_binconfig.txt在 Host 端机器上操作例子如下:
部分输出日志如下:
详细信息请阅读:lite/api/tools/benchmark/precision_evaluation/imagenet_image_classification/README.md