Paddle Inference部署推理(十六)

十六:Paddle Inference推理 (C++)API详解

1. Config 构造函数

Config 类为用于配置构建 Predictor 对象的配置信息,如模型路径、是否开启gpu等等。

构造函数定义如下:

// 创建 Config 对象,默认构造函数
Config();

// 创建 Config 对象,输入为其他 Config 对象
Config(const Config& other);

// 创建 Config 对象,输入分别为模型文件路径和参数文件路径
Config(const std::string& prog_file, const std::string& params_file);

代码示例:

// 字符串 prog_file 为 Combine 模型文件所在路径
std::string prog_file = "../assets/models/mobilenet_v1.pdmodel";
// 字符串 params_file 为 Combine 模型参数文件所在路径
std::string params_file = "../assets/models/mobilenet_v1.pdiparams";

// 根据模型文件和参数文件构造 Config 对象
paddle_infer::Config config(prog_file, params_file);

// 根据 Config 对象创建预测器对象
auto predictor = paddle_infer::CreatePredictor(config);

注意事项: 一个 Config 对象只能用于调用一次 CreatePredictor 生成一个 Predictor,需要通过 CreatePredictor 创建多个 Predictor 时请分别创建 Config 对象。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值