tensorflow2.0 c++加载模型可以用接口LoadSavedModel:

SessionOptions opts;

    tensorflow::RunOptions run_options;
    opts.config.mutable_gpu_options()->set_visible_device_list({m_deviceList.c_str()});
    Status status_create = LoadSavedModel(m_modelPath, {tensorflow::kSavedModelTagServe}, &m_bundle);
    if(!status_create.ok()){
        return false;
     }
 
tesorflow2.0之前的接口为ReadBinaryProto;
 GraphDef graph_def;
    Status status_load = ReadBinaryProto(Env::Default(), fullPath, &graph_def);       
    if (!status_load.ok()) {
        return false;
    }
 
模型也可以以字节流的方式输入模型:

GraphDef graph_def;
if (!graph_def.ParseFromArray(data_buff, readLen)) {
delete[]data_buff;
return FALSE;
}

SessionOptions opts;
opts.config.mutable_gpu_options()->set_allow_growth(true);
opts.config.mutable_gpu_options()->set_per_process_gpu_memory_fraction(0.5);

opts.config.mutable_gpu_options()->set_visible_device_list({"1,2,3,0"});

std::shared_ptr<tensorflow::Session> session_prt(tensorflow::NewSession(opts));
m_session_prt = session_prt;

最新文章

  1. 玩转SQL Server复制回路の变更数据类型、未分区表转为分区表
  2. synthesize 与dynamic的区别
  3. Spring Security
  4. hello word
  5. java_easyui体系之DataGrid(1)[转]
  6. bzoj 1228 [SDOI2009]E&amp;D(sg函数,找规律)
  7. A basic Windows service in C++ (CppWindowsService)
  8. linux下用tar命令将当前目录下文件按子目录压缩归档
  9. Android系统移植(一)-让android系统在目标平台上运行起来
  10. java_web学习(十) 显示mysql中的数据
  11. 过滤Java中特殊字符
  12. 微信小程序发布
  13. asp.net core上使用redis探索(1)
  14. mysql自增长主键,删除数据后,将主键顺序重新排序
  15. Linux系统时间同步方法小结
  16. java算法----排序----(3)冒泡排序
  17. ARIMA模型识别、计算p、q值
  18. mysql windows开启客户端连接权限
  19. uva 11354 Bond
  20. js三目学习

热门文章

  1. flutter tabbar指示器indicator宽度高度自定义
  2. linux交叉编译libiconv
  3. 修改、编辑pdf
  4. 一、MySQL 函数
  5. Oversampling Techniques
  6. CocosCreator基于jenkins自动构建
  7. jupyter notebook代码无法运行
  8. Qt excel操作相关
  9. sprinboot多个子模块下 依赖包没有找到 解决方案
  10. 最简单的asp验证码