当前位置:网站首页>Pytorch's transforms (numpy data type is converted to tensor, normalized and resized)
Pytorch's transforms (numpy data type is converted to tensor, normalized and resized)
2022-07-25 19:47:00 【helloworld_ Fly】
pytorch transform Common formats
from torchvision import transforms
tensor = transforms.Tensor() # Initialize object
#img_or_np by “PIL Image” perhaps "numpy.", That is, the object you want to transform
data = tensor(img_or_np)
trans_resize = transforms.Resize(512,512)
data = trans_resize(data)
# Next, the data data normalization , The calculation method is as follows :image=(image-mean)/std
''' among mean and std Pass respectively (0.5,0.5,0.5) and (0.5,0.5,0.5) Make a designation . The original 0-1 minimum value 0 Has become a (0-0.5)/0.5=-1, And the maximum 1 Has become a (1-0.5)/0.5=1. '''
trans_norm = transforms.Normalize([0.5,0.5,0.5],[0.5,0.5,0.5])
img_normal = trans_norm(data)
边栏推荐
- 由一个蓝桥杯基础题报时助手而引出的常见误区
- Network design and planning of a company
- 滑雪手机端H5小游戏源码下载
- Typeerror: 'STR' object is not callable error reason
- JS learning notes 16: switching pictures small project practice
- Network packet multi-layer transmission demonstration
- Day7:有序二叉树(二叉搜索树)
- Nezha d1-h test microbench
- [server data recovery] a data recovery case of a brand ProLiant server raid paralysis, database file loss, and database file backup damage
- 安全基础4 ---正则表达式
猜你喜欢

How to be a self disciplined person?

C# 合并集合

Heavy! The new book "deep learning in geometry" was released, which was jointly written by imperial Institute of technology /deepmind and other figures ml Daniel. The 160 page PDF expounds the basic p

给容器添加3d效果的副标题

重磅!《几何深度学习》新书发布,帝国理工/DeepMind等图ML大牛共同撰写,160页pdf阐述几何DL基础原理和统一框架

JS learning notes 17: DOM query exercise

高端旗舰投影仪选购指南:当贝X3 Pro、当贝F5观影更沉浸!

Security foundation 6 - vulnerability recurrence

Illegal mix of collations for operation ‘UNION‘(bug记录)

Network packet multi-layer transmission demonstration
随机推荐
What is idealism
项目中new Promise和async、await中的使用,以及promise.all在项目中的实际应用
What is the method to load the torch pre trained model for the mindspore model finetune?
Oracle database download, installation, use tutorial and problem summary
balanced binary tree
微信小程序开发之WXSS模板样式与WXS脚本语言
Heavy! The new book "deep learning in geometry" was released, which was jointly written by imperial Institute of technology /deepmind and other figures ml Daniel. The 160 page PDF expounds the basic p
英诚医院内部网络规划与设计
基于PHP的中非南南合作信息交流平台网站建设
University of California | feasible confrontation robust reinforcement learning for unspecified environments
重磅!《几何深度学习》新书发布,帝国理工/DeepMind等图ML大牛共同撰写,160页pdf阐述几何DL基础原理和统一框架
蓝桥杯基础练习——矩阵的回形取数(C语言)
伺服驱动器在机器人上的研究与应用
A high efficiency 0-delay 0-copy QT player scheme based on Hisilicon 3559
Typeerror: 'STR' object is not callable error reason
Authorized wireless communication standard
Global configuration and page configuration of wechat applet development
Security Basics 4 - regular expressions
SDL text display
what is qml in qt