Closed prettyocean85 closed 4 years ago
模型不保存,用同样的输入进行预测,会报错吗?
@yongqiangma 直接用infer.py预测都不报错
有可能是save_inference_model的时候发生了错误裁剪,等https://github.com/PaddlePaddle/Paddle/pull/23306 合入后再测试下吧
@prettyocean85 在ocr_recognition上使用inference_model测试了一下,发现没有报错。
再结合你的报错信息发现是输入的问题。 Error: Level number of Input(Y)'s lod should be greater than 0. [Hint: Expected y_lod.size() > 0UL, but received y_lod.size():0 <= 0UL:0.] at
你可以参考下python是如何处理输入数据的。
最简单的方法测试,修改infer.py使得其加载inference_model完成预测。
@jiweibo 修改infer.py可以完成预测,但是报错是使用零拷贝方式,数据处理是参考了python来做的,和训练用的数据没什么区别不知道为什么报错。预测代码如下(crnn_ctc模型使用正常):
@prettyocean85 看报错信息是输入tensor没有设置lod。
另外请查看ocr_recognition中,对输入数据的处理,lod是如何设置的。
@jiweibo 添加set_lod后问题已解决,感谢
问题描述:使用models\PaddleCV\ocr_recognition训练attention模型(crnn_ctc模型使用正常),并在infer.py中重新保存为固化模型,使用paddle predictor预测报错,错误信息为: File "D:\pythonAPI\Python37\call_paddle_OCR.py", line 108, in test_image predictor.zero_copy_run() paddle.fluid.core_avx.EnforceNotMet:
C++ Call Stacks (More useful to developers):
Windows not support stack backtrace yet.
Python Call Stacks (More useful to users):
File "D:\pythonAPI\Python37\Lib\site-packages\paddle\fluid\framework.py", line 2525, in append_op attrs=kwargs.get("attrs", None)) File "D:\pythonAPI\Python37\Lib\site-packages\paddle\fluid\layer_helper.py", line 43, in append_op return self.main_program.current_block().append_op(*args, **kwargs) File "D:\pythonAPI\Python37\Lib\site-packages\paddle\fluid\layers\sequence_lod.py", line 723, in sequence_expand attrs={'ref_level': ref_level}) File "D:\LSS\OCR\ocr_recognition\attention_model.py", line 294, in attention_infer pre_state_expanded = fluid.layers.sequence_expand(pre_state, pre_score) File "D:\LSS\OCR\ocr_recognition\infer.py", line 63, in inference ids = infer(images, num_classes, use_cudnn=True if args.use_gpu else False) File "D:\LSS\OCR\ocr_recognition\infer.py", line 196, in main inference(args) File "D:\LSS\OCR\ocr_recognition\infer.py", line 200, in
main()
Error Message Summary:
Error: Level number of Input(Y)'s lod should be greater than 0. [Hint: Expected y_lod.size() > 0UL, but received y_lod.size():0 <= 0UL:0.] at (D:\1.7.0\paddle\paddle\fluid\operators\sequence_ops\sequence_expand_op.cc:57) [operator < sequence_expand > error]