Open Sun-k0903 opened 3 months ago
为使您的问题得到快速解决,在建立 Issue 前,请您先通过如下方式搜索是否有相似问题: 历史 issue, FAQ 文档, 官方文档
建立 issue 时,为快速解决问题,请您根据使用情况给出如下信息:
config = MobileConfig() config.set_model_from_file("/mnt/d/Python_project/test/onnx_nb/opt.nb")
predictor = create_paddle_predictor(config)
image = Image.open('/mnt/d/Python_project/test/seg_cert/test.jpg') resized_image = image.resize((640, 640), Image.BILINEAR) image_data = np.array(resized_image).transpose(2, 0, 1).reshape(1, 3, 640, 640)
input_tensor = predictor.get_input(0) input_tensor.from_numpy(image_data.astype("float32"))
predictor.run()
output_tensor = predictor.get_output(0) print(output_tensor.shape()) print(output_tensor.numpy()) log.txt
为使您的问题得到快速解决,在建立 Issue 前,请您先通过如下方式搜索是否有相似问题: 历史 issue, FAQ 文档, 官方文档
建立 issue 时,为快速解决问题,请您根据使用情况给出如下信息:
(1) 设置配置信息
config = MobileConfig() config.set_model_from_file("/mnt/d/Python_project/test/onnx_nb/opt.nb")
(2) 创建预测器
predictor = create_paddle_predictor(config)
(3) 从图片读入数据
image = Image.open('/mnt/d/Python_project/test/seg_cert/test.jpg') resized_image = image.resize((640, 640), Image.BILINEAR) image_data = np.array(resized_image).transpose(2, 0, 1).reshape(1, 3, 640, 640)
(4) 设置输入数据
input_tensor = predictor.get_input(0) input_tensor.from_numpy(image_data.astype("float32"))
(5) 执行预测
predictor.run()
(6) 得到输出数据
output_tensor = predictor.get_output(0) print(output_tensor.shape()) print(output_tensor.numpy()) log.txt