当前位置:网站首页>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:
边栏推荐
- js数组相关知识复习
- Forest Program DFS + tanjar cactus
- SAP ALV data export many of the bugs
- 记录一次客户的APP数据库版本号升级失败的情况
- SiamFC:用于目标跟踪的全卷积孪生网络 fully-convolutional siamese networks for object tracking
- LeetCode·每日一题·636.函数的独占时间·栈模拟
- The String class objects created by the JVM memory allocation and the difference between equals and = =
- 9.进程和计划任务管理(1)
- MUV LUV EXTRA 2019CCPC Qinhuangdao Station J Question KMP
- pip安装更换镜像
猜你喜欢
信息反馈平台的设计与实现(一、项目设计)
CoCube传感器MPU6050笔记
The String class objects created by the JVM memory allocation and the difference between equals and = =
Oracle 限制时将空值排除
74HC595 chip pin description
DIMP:Learning Discriminative Model Prediction for Tracking 学习判别模型预测的跟踪
C#基础学习
我的创作纪念日
[STL]stack与queue
灵活好用的sql monitoring 脚本 part7
随机推荐
训练好的深度学习模型,多种部署方式
Anaconda 使用代理
【转载】Deep Learning(深度学习)学习笔记整理
74HC595 chip pin description
VOC格式标签转YOLO格式
postgresql窗口功能
生成对抗网络GAN:Generative Adversarial Networks
Win10桌面图标排列混乱
Apache POI
jmeter并发数量以及压力机的一些限制
jmeter concurrency and some limitations of the press
2019南昌网络赛 C题,Hello 2019
H3C_利用策略路由实现出口双线路负载(选路)的部署
SSL证书最长有效期13个月,还有必要一次申请多年吗?
CoCube传感器MPU6050笔记
我的创作纪念日
C语言:汽水瓶详解
DIMP:Learning Discriminative Model Prediction for Tracking 学习判别模型预测的跟踪
[STL]vector
Lottie系列二:高级属性