当前位置:网站首页>【pytorch】|transforms.FiveCrop
【pytorch】|transforms.FiveCrop
2022-07-27 16:33:00 【rrr2】
Common image transformation
There are four categories to summarize here
tailoring (Crop)
Center cut :transforms.CenterCrop
Random cutting :transforms.RandomCrop
Random aspect ratio tailoring :transforms.RandomResizedCrop
Top, bottom, left and right center cut :transforms.FiveCrop
Cut the top, bottom, left and right center, and then flip ,transforms.TenCrop
Flip and rotate (Flip and Rotation)
According to probability p Flip horizontal :transforms.RandomHorizontalFlip(p=0.5)
According to probability p Flip vertically :transforms.RandomVerticalFlip(p=0.5)
Random rotation :transforms.RandomRotation
Image transformation (resize)transforms.Resize
Standardization :transforms.Normalize
To tensor, And normalized to [0-1]:transforms.ToTensor
fill :transforms.Pad
Change the brightness 、 Contrast and saturation :transforms.ColorJitter
Go to grayscale :transforms.Grayscale
linear transformation :transforms.LinearTransformation()
Affine transformation :transforms.RandomAffine
According to probability p Turn to grayscale :transforms.RandomGrayscale
Convert data to PILImage:transforms.ToPILImage
take lambda Apply as transform :transforms.Lambda
Yes transforms operation , Make data enhancement more flexible
From a given series of transforms Choose one of them to operate :transforms.RandomChoice(transforms),
Give me a transform Plus the probability , Operate according to probability :transforms.RandomApply(transforms, p=0.5)
take transforms The operations in are randomly disrupted :
import torchvision
import torchvision.transforms as transform
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
import torch
img0=Image.open('imge.png')
resize = torchvision.transforms.Resize((224,224))
img0_r=resize(img0)
img1=transform.FiveCrop((112,112))(img0_r)
axs = plt.figure().subplots(1, 6)
axs[0].imshow(img0_r);axs[0].set_title('src');axs[0].axis('off')
axs[1].imshow(img1[0]);axs[1].set_title('1');axs[1].axis('off')
axs[2].imshow(img1[1]);axs[2].set_title('2');axs[2].axis('off')
axs[3].imshow(img1[2]);axs[3].set_title('3');axs[3].axis('off')
axs[4].imshow(img1[3]);axs[4].set_title('4');axs[4].axis('off')
axs[5].imshow(img1[4]);axs[5].set_title('5');axs[5].axis('off')
plt.show()

边栏推荐
- DRF learning notes (III): model class serializer modelserializer
- Opencv (IV) -- image features and target detection
- Coturn service installation in webrtc
- Leetcode25 question: turn the linked list in a group of K -- detailed explanation of the difficult questions of the linked list
- Web test learning notes 01
- excel skill
- 闲聊技巧
- OpenCV(四)——图像特征与目标检测
- SolidWorks Simulation曲线图属性设定
- 第21回---第30回
猜你喜欢

【论文阅读】Transformer with Transfer CNN for Remote-Sensing-ImageObject Detection

OpenCV(四)——图像特征与目标检测

DRF use: get request to get data (small example)

training on multiple GPUs pytorch

Supplement - example of integer programming

MapReduce instance (III): data De duplication

Is low code the future of development? On low code platform

Opencv (IV) -- image features and target detection

Excel extract duplicates

Characters generated by JMeter function assistant in jmeter5.3 and later versions cannot be copied when they are grayed out
随机推荐
Google Chrome reversecaptcha ad blocking
将IAR工程文件夹转移目录后无法进入函数定义解决
Introduction to JWT
Flowable process custom attribute
收藏!0基础开源数据可视化平台FlyFish大屏开发指南
DRF learning notes (V): viewset
Rotate string left
Replication of complex linked list
Example of the task submitted by the Flink packer
Clear understanding of torchvision (mind map)
Jupyter creates a virtual environment and installs pytorch (GPU)
Leetcode 226 flip binary tree (recursive)
SolidWorks Simulation曲线图属性设定
2021-06-02
The whereor method of TP5 has many conditions
EXE程序加密锁
201403-1
减小PDF文档大小(转载)
Coding technique - Global log switch
Const summary