头文件:

#include <torch/script.h>
#include <torch/torch.h>
#include <iostream>
#include <typeinfo>

    torch::NoGradGuard no_grad;torch::jit::script::Module module;torch::Tensor inputC0, inputC1,inRefP0,inRefP1,inRefPutemp, input;module = torch::jit::load("D:/projects/PycharmProjects/BCW/Train_pth/68.pt");inputC0 = torch::empty({ swidth, swidth });inputC1 = torch::empty({ swidth, swidth });inRefP0 = torch::empty({ swidth, swidth });inRefP1 = torch::empty({ swidth, swidth });inRefPutemp = torch::empty({ swidth, swidth });torch::Tensor inOrg = torch::empty({ swidth, swidth });torch::fill_(inputC0, DisC0);torch::fill_(inputC1, DisC1);Picture* Orgpic = pu.cu->slice->getPic();CodingStructure& Orgcs = *Orgpic->cs;PelBuf orgBuf = Orgcs.getOrgBuf(Orgcs.area).get(COMPONENT_Y);//PelBuf orgBuf = pu.cs->getOrgBuf(COMPONENT_Y);for (int j = curry - 4, m = 0; j < curry + width; j++, m++){for (int i = currx - 4, n = 0; i < currx + width; i++, n++){inOrg[m][n] = orgBuf.at((i<0)?0:i, (j < 0) ? 0 : j)/4.0;}}module.to(at::kCPU);int t = 0;for (int i = 0; i < swidth; i++){for (int j = 0; j < swidth; j++){inRefP0[i][j] = RefP0[t];inRefP1[i][j] = RefP1[t];inRefPutemp[i][j] = RefPu[t];t++;}}t = 0;torch::Tensor inRefCen = inRefPutemp.index({             torch::indexing::Slice(4,swidth),torch::indexing::Slice(4,swidth)});inOrg.index({ torch::indexing::Slice(4,swidth),torch::indexing::Slice(4,swidth) }) =
inRefCen;torch::Tensor inRefPu = inOrg;//cout << inRefPu << endl;input = torch::stack({ inputC0,inputC1,inRefP0,inRefP1,inRefPu }, 0);input = torch::unsqueeze(input, 0);//Execute the model and turn its output into a tensor.torch::Tensor output = module.forward({ input }).toTensor();//cout << output << endl;output = output.reshape({ 1,(int64_t(swidth) - 4) * (int64_t(swidth) - 4) });t = 0;Pel* BCW_dst = pcYuvDst.Y().buf;Pel* BCW_src = pcYuvDst.Y().buf;for (unsigned y = 0; y < height; y++){for (unsigned x = 0; x < width; x++){if (BCW_dst != nullptr && BCW_dst != nullptr){float out = output[0][t].item().toFloat();if (out < 0)out = 0;if (out > 255)out = 255;//BCW_dst[x] = Pel(round(out));BCW_dst[x] = Pel(round(out) * 4);//if (BCW_dst[x] < 0)//  cout << BCW_dst[x] << endl;//BCW_dst[x] = m_BCWfwdLUT[BCW_src[x]];t++;}}//cout << endl;BCW_dst += pcYuvDst.Y().stride;BCW_src += pcYuvDst.Y().stride;}

VTM调用libtorch相关推荐

  1. pytorch移动端教程 Java调用libtorch

    将模型转为libtorch模型之后 剩下的就是移动端是事情了 也就是使用java调用模型因为 libtorch 支持移动端且支持java调用 其实你使用java再电脑做做测试最好 但是不得不说libt ...

  2. 深度学习之pytorch(三) C++调用

    玩深度学习,个人觉得基于anaconda的python适合开发与测试,C++适合实际的工程部署!而pytorch官方有编译好的libtorch,特别方便,适合于我这样的伸手党和手残党(win10下编译 ...

  3. libtorch+YOLOV5配置踩坑记

    电脑配置: CPU:Intel i7-10750H 内存:16G 显卡:GeForce GTX 1650 Ti(4GB显存) 操作系统:Windows 10 家庭中文版 CUDA:10.2 CUDNN ...

  4. 四、C++调用slomo模型

    上一章<训练模型调用及转换>把训练好的模型转换为c++可以通过libTorch调用的模型.想了解windows C++调用libTorch可以看<C++(libTorch)调用pyt ...

  5. 突破androidstudio 的控制

    使用vue开发app不香吗 其实目前很多app 都是vue 开发的所有前端工程师火爆. 只是vue 不能开发离线人工智能app 今天想到了一个方案就是使用js 调用java java 调用libtor ...

  6. 人工智能项目的开发流程概述

    人工智能作为当下最热门的行业之一,不管是高考的专业选择中,还是各行各业的工作中,基本都会听到人工智能这个词,主要原因就是社会上各行各业对人工智能的需求越来越大了.在国内,从2015年开始,人工智能技术 ...

  7. Pytorch项目打包和部署(1)——理论

    文章目录 一.什么是模型打包部署 二.模型打包部署的作用 三.学习模型打包部署的目的 四.模型部署语言 五.模型部署平台 六.模型部署设备 七.模型部署方式 八.模型部署接口(服务器部署) 九.模型部 ...

  8. 人工智能技术及项目产品开发流程

    人工智能作为当下最热门的行业之一,不管是高考的专业选择中,还是各行各业的工作中,基本都会听到人工智能这个词,主要原因就是社会上各行各业对人工智能的需求越来越大了.在国内,从2015年开始,人工智能技术 ...

  9. PyTorch导出JIT模型并用C++ API libtorch调用

    PyTorch导出JIT模型并用C++ API libtorch调用 本文将介绍如何将一个 PyTorch 模型导出为 JIT 模型并用 PyTorch 的 C++API libtorch运行这个模型 ...

最新文章

  1. 【Struts2框架】Struts2总结
  2. Matlab 图像处理相关函数命令大全
  3. C# ACCESS数据库操作类
  4. 送书 | 经典框架Kaldi配套的语音识别实战
  5. signature=806a32b3c900efe2c25fc19c92754ca3,Signature de câble électronique
  6. mysql例题_mysql练习题1
  7. [Swift]LeetCode483. 最小好进制 | Smallest Good Base
  8. perl中的map和grep
  9. python如何下载安装spacy_使用pip安装Spacy时出错
  10. python用matplotlib画球_python 如何用matplotlib画一个漂亮的圆-百度经验
  11. 管理者每天要做的十件事
  12. Linux正在更新缓存卡住,Linux 进程卡住了怎么办?
  13. [leetcode] Nim Game
  14. 飞桨2.0 PaddleDetection:瓶装酒瑕疵检测迁移学习教程
  15. RadarNet: Efficient Gesture Recognition Technique Utilizing a Miniaturized Radar Sensor
  16. 游戏研发人才学校培养、企业需求与个人快速成长,华科校友分享了这些实用观点
  17. python turtle工具绘制四叶草
  18. Unity3D场景对象无法显示
  19. 计算机的数学知识的手抄报图片大全,数学手抄报图片大全获奖作品
  20. Git:Terminal is dumb, but EDITOR unset

热门文章

  1. OSPF不规则区域知识点
  2. python-docx模块表格部分单元格格式调整
  3. 2020年统考计算机应用基础,2020计算机考研统考:计算机应用基础都考些什么?
  4. codevs1384黑色星期五【USACO】
  5. 【调研信息搜集的内容,信息搜集的方法,信息搜集的工具,信息搜集结果的利用等调研报告】
  6. python 打包成exe_Python打包成exe
  7. Docker镜像打包示例
  8. ipad pro 2021有什么新亮点?
  9. chain (Lattice-free MMI)
  10. linux脚本怎么写的,linux脚本怎么写条件语句卡密卡密