当前位置:网站首页>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 data request for wechat applet development
- GBASE 8s UDR内存管理_01_mi_alloc
- binarySearch基础二分查找
- Binarysearch basic binary search
- What is the method to load the torch pre trained model for the mindspore model finetune?
- YOLOv7论文部分解读【含自己的理解】
- [wp]ctfshow-web introductory information collection
- Nezha d1-h test microbench
- AAAI 2022 | GAN的结构有“指纹”吗?从伪造图像溯源生成网络结构
- what is qml in qt
猜你喜欢

安全基础4 ---正则表达式

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

蓝桥杯基础练习——矩阵的回形取数(C语言)

919. Complete binary tree inserter

Internal network planning and design of Yingcheng hospital

伺服驱动器在机器人上的研究与应用
EZDML reverse engineering import database analysis practical operation tutorial

软件设计师下午真题:2009-2022

Add a subtitle of 3D effect to the container

TFIDF examples and explanations
随机推荐
485 current acquisition module dam-8041
IP地址的概念
The query data returned by the print database is null or the default value. Does not match the value returned by the database
Sentinel simple current limiting and degradation demo problem record
Monitor MySQL based on MySQL exporter
微信小程序开发之网络数据请求
919. 完全二叉树插入器
EZDML reverse engineering import database analysis practical operation tutorial
How to be a self disciplined person?
项目中new Promise和async、await中的使用,以及promise.all在项目中的实际应用
SDL text display
Oracle数据库下载、安装、使用教程及问题汇总
Bash does not add single quotes to your string
Partial interpretation of yolov7 paper [including my own understanding]
Gbase 8s UDR memory management_ 03_ mi_ realloc
[wp]ctfshow-web入门信息搜集
Add a subtitle of 3D effect to the container
数字信息化(先枚举假设,再看是否满足条件)(1089 狼人杀-简单版)
Sccm2012r2 network deployment reinstallation system
基于海思3559 高效率的 0延时 0拷贝 qt播放器方案