当前位置:网站首页>PyTorch之CV
PyTorch之CV
2022-08-10 05:33:00 【Vector Jason】
引子:
鉴于本人方向偏于深度学习中的图像处理,在此详细说明一下该领域中常用的一些库函数和相关架构。
同时,通过前面的学习我们也发现经常会用到torchvision来调用预训练模型,加载数据集,对图片进行数据增强等操作,因此,torchvision正是主要使用的一个库函数。
torchvision.transforms:
考虑到输入数据进入神经网络的过程中,其维度具有限制条件,因此,对输入image进行归一化是必要的,这也可以理解为数学模型中常进行的数据预处理操作。此外,有时我们无法获取到足够多的数据,这将导致无法很好训练神经网络中成千上万个参数,所以,我们可以通过将图片进行翻转,缩小或放大等操作以实现数据量的扩大。
例如:
from torchvision import transforms
data_transform = transforms.Compose([
transforms.ToPILImage(), # 这一步取决于后续的数据读取方式,如果使用内置数据集则不需要
transforms.Resize(image_size),
transforms.ToTensor()
])
这一段代码即表示image预处理过程,详情其余操作代码可见torchvison官方文档。
torchvision.models
了解多种多样的模型之后,我们总会有个疑问——该不会需要手敲所有代码吧?答案是否定的,在torchvison.models中提供了一些在ImageNet-1k数据集中预训练好的模型供我们使用
具体可以点击以下链接查看各个模型在该数据集之下的准确率。TorchVision中各个模型准确率对比分析https://gitee.com/link?target=https%3A%2F%2Fpytorch.org%2Fvision%2Fstable%2Fmodels.html%23
边栏推荐
猜你喜欢
Chain Reading|The latest and most complete digital collection sales calendar-08.02
The complex "metaverse" will be interpreted for you, and the Link Reading APP will be launched soon!
.NET操作Excel高效低内存的开源框架 - MiniExcel
堆的原理与实现以及排序
Operation table Function usage
【笔记】集合框架体系 Collection
ORACLE系统表空间SYSTEM占满无法扩充表空间问题解决过程
The latest and most complete digital collection sales calendar-07.26
操作表 函数的使用
Count down the six weapons of the domestic interface collaboration platform!
随机推荐
ORACLE系统表空间SYSTEM占满无法扩充表空间问题解决过程
network security firewall
cesium listens to map zoom or zoom to control whether the content added on the map is displayed
Timer (setInterval) on and off
操作表 函数的使用
复杂的“元宇宙”,为您解读,链读APP即将上线!
pytorch-11.卷积神经网络(高级篇)
pytorch-10.卷积神经网络(作业)
[Difference between el and template]
泛型笔记()()()
微信小程序wx.writeBLECharacteristicValue汉字转buffer问题
IO流【】【】【】
.NET操作Excel高效低内存的开源框架 - MiniExcel
Content related to ZigBee network devices
Linux database Oracle client installation, used for shell scripts to connect to the database with sqlplus
Batch add watermark to pictures batch scale pictures to specified size
图片批量添加水印批量缩放图片到指定大小
view【】【】【】【】
generic notes()()()
opencv