当前位置:网站首页>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
结果如下:
边栏推荐
- [Planet selection] how to efficiently build fine-grained two-way links between roam and thebrain?
- 快速删除代码里面的node_modules
- 2. probability theory - axiom of probability theory
- Interview questions of a company in a certain month of a certain year (1)
- VTK. Le bouton gauche de la souris JS glisse pour changer le niveau et la largeur de la fenêtre
- Gif verification code analysis
- For loop of go language foundation
- 图像分割-改进网络结构
- imperva-查找正则匹配超时的方法
- Eureka服务注册与发现
猜你喜欢
随机推荐
Talk about routing design in service governance
2022山东大学软件学院软件项目管理期末考试(回忆版)
The eighth experiment of hcip Road
Acwing第 56 场周赛【完结】
记一次高校学生账户的“从无到有”
【Veusz】导入CSV中的二维数据
2.概率论-概率论公理
php序列化和反序列化-ctf
QT reading XML files using qdomdocument
浅析 Open API 设计规范
VTK. Le bouton gauche de la souris JS glisse pour changer le niveau et la largeur de la fenêtre
Unity audio visualization scheme
华为云服务器弹性公网IP无法ping
测试apk-异常管控NetTraffic攻击者开发
1278_ FreeRTOS_ Understand the delayed task with the prvaddcurrenttasktodelayedlist interface
快速删除代码里面的node_modules
The sandbox has reached a cooperation with football player to bring popular football cartoons and animation into the metauniverse
[try to hack] IP address
Tri rapide + Tri par bulle + Tri par insertion + Tri par sélection
ArcMap批量删除距离较近的点









