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 对象。

相关推荐
2601_950760791 分钟前
GDF-15重组蛋白:从孕期免疫耐受到多发性硬化神经保护的关键调控因子
人工智能·蛋白
一切皆是因缘际会5 分钟前
穿透多维场景
人工智能
七牛云行业应用12 分钟前
Dots 完整教程:从安装入口、跑第一个任务到给 Codex 派活(2026 年 10 月)
人工智能·大模型·agent
镜象科技3 小时前
AI情感大模型应用场景全解:从校园到医院再到企业的落地地图
人工智能
Joshua-a4 小时前
工程数学-理解卷积的含义_线性时不变系统的冲激响应与卷积
人工智能·深度学习
song5014 小时前
React Native for OpenHarmony 实战:三方库 react-native-css-transformer 的鸿蒙化适配指南
css·人工智能·深度学习·react native·transformer
老金带你玩AI9 小时前
ChatGPT dots,到底能替你操多少心?
人工智能
AliCloudROS9 小时前
计算巢 X DeepSeek Harness — 云端智能体工作台
人工智能·阿里云
深蓝AI10 小时前
GitHub的Push一年涨4.9倍:AI Agent为什么逼它重做Git存储?
人工智能·github
stereohomology10 小时前
大模型的观点谨:StoryTold 「Crafting Apps」四件套 · 深度总览
人工智能·llm