当前位置:网站首页>libtorch示例
libtorch示例
2022-08-09 07:50:00 【HySmiley】
1、IDE
VS2019+libtorch1.7cpu+opencv3.4
2、图片转tensor测试
#include<torch/script.h>
#include<iostream>
#include<opencv2/opencv.hpp>
using namespace std;
int main()
{
cv::Mat img = cv::imread("D:/data/dog_cat/test/cat/cat.8154.jpg");
/*torch::Tensor ten = torch::rand({ 2,3 });
cout << ten << endl;*/
torch::Tensor timg = torch::from_blob(img.data, { 1,img.rows,img.cols,3 }, torch::kByte);
timg = timg.permute({ 0,3,1,2 });
timg = timg.toType(torch::kFloat);
std::cout << timg.sizes() << std::endl;
system("pause");
return 0;
}
3、图像识别
#include <torch/script.h>
#include <opencv2/opencv.hpp>
#include <iostream>
#include <memory>
#include<torch/torch.h>
#include<string>
#include<time.h>
using namespace std;
//https://pytorch.org/tutorials/advanced/cpp_export.html
string image_path = "D:
边栏推荐
猜你喜欢
随机推荐
Anaconda 使用代理
View log common commands
es6 基础知识详解 变量 字符串 解构赋值 函数 对象 从入门到精通
list and string conversion
重要消息丨.NET Core 3.1 将于今年12月13日结束支持
C language: detailed explanation of soda bottle
The maximum validity period of an SSL certificate is 13 months. Is it necessary to apply for multiple years at a time?
【机器学习】降维代码练习
链表专项练习(四)
“互联网+”大学生创新创业大赛经历
Sklearn data preprocessing
接口测试概念
工信部等四部门推动绿色智能家居产品下乡
毕业我选择了保家卫国,退伍我选择了华为外包
生成对抗网络GAN:Generative Adversarial Networks
C language: adjust the order of odd and even numbers
postgresql窗口功能
Laravel文档阅读笔记-Rendering JSON(对JS变量进行赋值)
在今天这个特殊的日子,我想要开始我的代码技术博客之路
EXCEL使用函数联调(find,mid,vlookup,xlookup)