libtorch example
发布时间
阅读量:
阅读量
1、集成开发环境
VS2019搭配libtorch1.7cpu以及opencv3.4
2、图像转换为张量的验证测试
#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() << s
全部评论 (0)
还没有任何评论哟~
