PaddleX模型转化后加载错误
Created by: autowo
测试使用的是paddleX果蔬数据集,训练mobileNetV2模型,本地发布后使用python可以正常预测。
使用convertToPaddleJSModel.py工具转化结果如下:
(paddle) D:\paddle\PaddleX\ModelConverter>convertToPaddleJSModel.py --modelPath=D:\paddle\PaddleX\WorkSpace\P0001-T0001_export_model\inference_model\__model__ --paramPath=D:\paddle\PaddleX\WorkSpace\P0001-T0001_export_model\inference_model\__params__ --outputDir=D:\paddle\PaddleX\WorkSpace\P0001-T0001_export_model\js_model ============Convert Model Args============= modelPath: D:\paddle\PaddleX\WorkSpace\P0001-T0001_export_model\inference_model\__model__ paramPath: D:\paddle\PaddleX\WorkSpace\P0001-T0001_export_model\inference_model\__params__ outputDir: D:\paddle\PaddleX\WorkSpace\P0001-T0001_export_model\js_model enableOptimizeModel: 0 enableLogModelInfo: 0 sliceDataSize:4096 Starting... [33mYou choosed not to optimize model, consequently, optimizing model is skiped.[0m Converting model... Organizing model operators info... Organizing model operators info successfully. Organizing model variables info... Organizing model variables info successfully. Model chunkNum set successfully. Dumping model structure to json file... Dumping model structure to json file successfully Output No.1 binary file, remain 1218246 param values. Output No.2 binary file, remain 169670 param values. Output No.3 binary file, remain 0 param values. Slicing data to binary files successfully. (3 output files and 2266822 param values) Converting model successfully. ============ALL DONE============
使用paddle.js进行模型测试时,发现如下错误:
再次尝试convertToPaddleJSModel.py增加参数--optimize=1进行优化(paddlelite==2.6.1):
(paddle) D:\paddle\PaddleX\ModelConverter>convertToPaddleJSModel.py --modelPath=D:\paddle\PaddleX\WorkSpace\P0001-T0001_export_model\inference_model\__model__ --paramPath=D:\paddle\PaddleX\WorkSpace\P0001-T0001_export_model\inference_model\__params__ --outputDir=D:\paddle\PaddleX\WorkSpace\P0001-T0001_export_model\js_model --optimize=1 ============Convert Model Args============= modelPath: D:\paddle\PaddleX\WorkSpace\P0001-T0001_export_model\inference_model\__model__ paramPath: D:\paddle\PaddleX\WorkSpace\P0001-T0001_export_model\inference_model\__params__ outputDir: D:\paddle\PaddleX\WorkSpace\P0001-T0001_export_model\js_model enableOptimizeModel: 1 enableLogModelInfo: 0 sliceDataSize:4096 Starting... Optimizing model... WARNING: Logging before InitGoogleLogging() is written to STDERR I0802 18:42:33.895296 10456 cxx_api.cc:251] Load model from file. I0802 18:42:33.941295 10456 optimizer.h:202] == Running pass: lite_conv_elementwise_fuse_pass I0802 18:42:33.948297 10456 optimizer.h:219] == Finished running: lite_conv_elementwise_fuse_pass I0802 18:42:33.948297 10456 optimizer.h:202] == Running pass: lite_conv_bn_fuse_pass I0802 18:42:34.001297 10456 pattern_matcher.cc:108] detected 36 subgraph I0802 18:42:34.014297 10456 pattern_matcher.cc:108] detected 17 subgraph I0802 18:42:34.015297 10456 optimizer.h:219] == Finished running: lite_conv_bn_fuse_pass I0802 18:42:34.015297 10456 optimizer.h:202] == Running pass: lite_conv_elementwise_fuse_pass I0802 18:42:34.024296 10456 optimizer.h:219] == Finished running: lite_conv_elementwise_fuse_pass I0802 18:42:34.024296 10456 optimizer.h:202] == Running pass: lite_conv_activation_fuse_pass I0802 18:42:34.034297 10456 pattern_matcher.cc:108] detected 19 subgraph I0802 18:42:34.046296 10456 pattern_matcher.cc:108] detected 17 subgraph I0802 18:42:34.053342 10456 optimizer.h:219] == Finished running: lite_conv_activation_fuse_pass I0802 18:42:34.054306 10456 optimizer.h:202] == Running pass: lite_var_conv_2d_activation_fuse_pass I0802 18:42:34.054306 10456 optimizer.h:215] - Skip lite_var_conv_2d_activation_fuse_pass because the target or kernel does not match. I0802 18:42:34.055296 10456 optimizer.h:202] == Running pass: lite_fc_fuse_pass I0802 18:42:34.055296 10456 pattern_matcher.cc:108] detected 1 subgraph I0802 18:42:34.056308 10456 optimizer.h:219] == Finished running: lite_fc_fuse_pass I0802 18:42:34.056308 10456 optimizer.h:202] == Running pass: lite_shuffle_channel_fuse_pass I0802 18:42:34.056308 10456 optimizer.h:219] == Finished running: lite_shuffle_channel_fuse_pass I0802 18:42:34.056308 10456 optimizer.h:202] == Running pass: lite_transpose_softmax_transpose_fuse_pass I0802 18:42:34.057299 10456 optimizer.h:219] == Finished running: lite_transpose_softmax_transpose_fuse_pass I0802 18:42:34.058316 10456 optimizer.h:202] == Running pass: lite_interpolate_fuse_pass I0802 18:42:34.058316 10456 optimizer.h:219] == Finished running: lite_interpolate_fuse_pass I0802 18:42:34.058316 10456 optimizer.h:202] == Running pass: identity_scale_eliminate_pass I0802 18:42:34.059303 10456 pattern_matcher.cc:108] detected 1 subgraph I0802 18:42:34.059303 10456 optimizer.h:219] == Finished running: identity_scale_eliminate_pass I0802 18:42:34.059303 10456 optimizer.h:202] == Running pass: elementwise_mul_constant_eliminate_pass I0802 18:42:34.059303 10456 optimizer.h:219] == Finished running: elementwise_mul_constant_eliminate_pass I0802 18:42:34.060302 10456 optimizer.h:202] == Running pass: lite_sequence_pool_concat_fuse_pass I0802 18:42:34.060302 10456 optimizer.h:215] - Skip lite_sequence_pool_concat_fuse_pass because the target or kernel does not match. I0802 18:42:34.060302 10456 optimizer.h:202] == Running pass: lite_elementwise_add_activation_fuse_pass I0802 18:42:34.060302 10456 optimizer.h:219] == Finished running: lite_elementwise_add_activation_fuse_pass I0802 18:42:34.061324 10456 optimizer.h:202] == Running pass: static_kernel_pick_pass I0802 18:42:34.063328 10456 optimizer.h:219] == Finished running: static_kernel_pick_pass I0802 18:42:34.063328 10456 optimizer.h:202] == Running pass: variable_place_inference_pass I0802 18:42:34.064328 10456 optimizer.h:219] == Finished running: variable_place_inference_pass I0802 18:42:34.064328 10456 optimizer.h:202] == Running pass: argument_type_display_pass I0802 18:42:34.064328 10456 optimizer.h:219] == Finished running: argument_type_display_pass I0802 18:42:34.064328 10456 optimizer.h:202] == Running pass: type_target_cast_pass I0802 18:42:34.065297 10456 optimizer.h:219] == Finished running: type_target_cast_pass I0802 18:42:34.065297 10456 optimizer.h:202] == Running pass: variable_place_inference_pass I0802 18:42:34.066332 10456 optimizer.h:219] == Finished running: variable_place_inference_pass I0802 18:42:34.066332 10456 optimizer.h:202] == Running pass: argument_type_display_pass I0802 18:42:34.066332 10456 optimizer.h:219] == Finished running: argument_type_display_pass I0802 18:42:34.066332 10456 optimizer.h:202] == Running pass: io_copy_kernel_pick_pass I0802 18:42:34.067297 10456 optimizer.h:219] == Finished running: io_copy_kernel_pick_pass I0802 18:42:34.069296 10456 optimizer.h:202] == Running pass: argument_type_display_pass I0802 18:42:34.070310 10456 optimizer.h:219] == Finished running: argument_type_display_pass I0802 18:42:34.070310 10456 optimizer.h:202] == Running pass: variable_place_inference_pass I0802 18:42:34.071297 10456 optimizer.h:219] == Finished running: variable_place_inference_pass I0802 18:42:34.071297 10456 optimizer.h:202] == Running pass: argument_type_display_pass I0802 18:42:34.071297 10456 optimizer.h:219] == Finished running: argument_type_display_pass I0802 18:42:34.071297 10456 optimizer.h:202] == Running pass: type_precision_cast_pass I0802 18:42:34.072297 10456 optimizer.h:219] == Finished running: type_precision_cast_pass I0802 18:42:34.072297 10456 optimizer.h:202] == Running pass: variable_place_inference_pass I0802 18:42:34.073297 10456 optimizer.h:219] == Finished running: variable_place_inference_pass I0802 18:42:34.073297 10456 optimizer.h:202] == Running pass: argument_type_display_pass I0802 18:42:34.073297 10456 optimizer.h:219] == Finished running: argument_type_display_pass I0802 18:42:34.073297 10456 optimizer.h:202] == Running pass: type_layout_cast_pass I0802 18:42:34.074297 10456 optimizer.h:219] == Finished running: type_layout_cast_pass I0802 18:42:34.074297 10456 optimizer.h:202] == Running pass: argument_type_display_pass I0802 18:42:34.074297 10456 optimizer.h:219] == Finished running: argument_type_display_pass I0802 18:42:34.074297 10456 optimizer.h:202] == Running pass: variable_place_inference_pass I0802 18:42:34.075297 10456 optimizer.h:219] == Finished running: variable_place_inference_pass I0802 18:42:34.075297 10456 optimizer.h:202] == Running pass: argument_type_display_pass I0802 18:42:34.075297 10456 optimizer.h:219] == Finished running: argument_type_display_pass I0802 18:42:34.075297 10456 optimizer.h:202] == Running pass: runtime_context_assign_pass I0802 18:42:34.075297 10456 optimizer.h:219] == Finished running: runtime_context_assign_pass I0802 18:42:34.075297 10456 optimizer.h:202] == Running pass: argument_type_display_pass I0802 18:42:34.075297 10456 optimizer.h:219] == Finished running: argument_type_display_pass I0802 18:42:34.076297 10456 generate_program_pass.h:37] insts.size 68 Save the optimized model into :D:\paddle\PaddleX\WorkSpace\P0001-T0001_export_model\js_model\optimizesuccessfully Optimizing model successfully. Converting model... Organizing model operators info... Organizing model operators info successfully. Organizing model variables info... Organizing model variables info successfully. Model chunkNum set successfully. Dumping model structure to json file... Dumping model structure to json file successfully Output No.1 binary file, remain 1166982 param values. Output No.2 binary file, remain 118406 param values. Output No.3 binary file, remain 0 param values. Slicing data to binary files successfully. (3 output files and 2215558 param values) Converting model successfully. Cleaning optimized temporary model... Temporary files has been deleted successfully. ============ALL DONE============
使用paddle.js进行模型测试时,发现如下错误: