当前位置:网站首页>transform的结构及用法
transform的结构及用法
2022-06-23 07:33:00 【booze-J】
一、transform作用
结构图1

结构图2

二、实际应用tensor类型
详细代码如下:
from torch.utils.tensorboard import SummaryWriter
from torchvision import transforms
from PIL import Image
# python 的用法 -》 tensor数据类型
# 通过transform.ToTensor去看两个问题
# 2、为什么我们需要Tensor数据类型 :因为tensor类型数据包含了训练神经网络所需要的属性
image_path = r"D:\pycharm_professional\PycharmProjects\learning_pytorch\dataset\train\ants_image\0013035.jpg"
img = Image.open(image_path)
writer = SummaryWriter("logs") # ctrl+P查看参数 ctrl + alt解决爆红问题
# 1、transforms该如何使用(python)
# 生成一个对象
tensor_trans = transforms.ToTensor()
tensor_img = tensor_trans(img)
# 使用tensorboard展示
writer.add_image("tensor_img",tensor_img,1)
writer.close()
terminal终端输入指令tensorboard --logdir="logs" --port=6007
结果如下:
边栏推荐
- Learn to draw Er graph in an article
- MySQL slow query record
- Kwai 350014
- Mathematical knowledge: Euler function - Euler function
- ArcMap batch delete points closer
- domain controller
- Gif verification code analysis
- vtk. JS left mouse button sliding to change window level and window width
- Mathematical knowledge: fast power fast power
- 忽略超长参数违规
猜你喜欢

30 sets of report templates necessary for the workplace, meeting 95% of the report needs, and no code is required for one click application

浅谈ThreadLocal和InheritableThreadLocal,源码解析

深度学习------不同方法实现lenet-5模型

Using the for loop to output an alphabetic triangle

Playwirght深度入门

EXCEL VBA 入门与实用例子

MIT CMS. 300 session 12 – identity construction Part 2

HCIP之路

Online text filter less than specified length tool

通过端口查文件
随机推荐
【markdown】markdown 教程大归纳
ArcMap batch delete points closer
openvino系列 18. 通过OpenVINO和OpenCV实现实时的物体识别(RTSP,USB视频读取以及视频文件读取)
Microsoft Exchange – prevent network attacks
Socket programming -- select model
Friends of the week
Quickly delete the node in the code_ modules
mysql中多表视图性能疑惑
1278_FreeRTOS_借助prvAddCurrentTaskToDelayedList接口理解delayed task
数学知识:快速幂—快速幂
openvino系列 19. OpenVINO 与 PaddleOCR 实现视频实时OCR处理
Qt 使用QDomDocument读取xml文件
Apache Solr 任意文件读取复现
Acwing第 56 场周赛【完结】
论文伪代码规范,伪代码在线编辑器,
浅析 Open API 设计规范
快速排序 + 冒泡排序 + 插入排序 + 選擇排序
某年某月某公司的面试题(1)
View the file once a second and send the result of the last line of the file to the syslog server
Online text filter less than specified length tool