Paddle Lite推理
Created by: yajiezhu
paddle lite推理报错 /home/zyj/anaconda3/bin/python3.6 /home/zyj/pythonProgram/PaddleNER/123.py Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
from paddlelite.lite import * import numpy as np config = MobileConfig() config.set_model_from_file('./test.lite_inference.model/model.nb')
(2) 创建predictor
predictor = create_paddle_predictor(config)
(3) 从图片读入数据
image = Image.open('./example.jpg')
resized_image = image.resize((224, 224), Image.BILINEAR)
image_data = np.array(resized_image).flatten().tolist()
image_data = [1, 3, 9, 11, 0, 0, 0]
(4) 设置输入数据
input_tensor = predictor.get_input(0)
input_tensor.resize([1, 3, 224, 224])
input_tensor.set_float_data(image_data)
(5) 执行预测
predictor.run() print('ok')
(6) 得到输出数据
output_tensor = predictor.get_output(0) print(output_tensor)