[Pytorch] torchvision.transforms()

torchvision.transforms()Transforms are common image transformations.They can be chained together using Compose.Functional transforms give fine-grained control over the transformations.Chained with multiple transform. Thus, transforms is composed of transform.

    transforms.Compose([    transforms.CenterCrop(10),    transforms.Normalize((0.5, 0.4, 0.5), (0.5, 0.5, 0.5)),    transforms.RandomHorizontalFlip(p=0.5),    transforms.RandomRotation(),    transforms.RandomApply(random_transforms, p=0.3),    transforms.ToTensor() ])
class torchvision.transforms.Scale(size, interpolation=2)
# No contents yet

class torchvision.transforms.RandomCrop(size, padding=0)
Crop the given PIL image at a random location.

class torchvision.transforms.RandomHorizontalFlip(p=0.5)
Horizontally flip the given image randomly with a given probability.

class torchvision.transforms.RandomRotation

class torchvision.transforms.Resize(size)
Resize the input PIL image to the given size, usually used with training_testing set

class torchvision.transforms.RandomApply

class torchvision.transforms.ToTensor

class torchvision.transforms.Normalize(mean, std)
Only use Normalize with Tensor, not PIL.image

class torchvision.transforms.ToTensor // HWC > CHW
Convert PIL.image to Tensor

Converts a PIL Image or numpy.ndarray (H x W x C) in the range [0, 255] to a torch.FloatTensor of shape (C x H x W) in the range [0.0, 1.0].C: Channels, H: Heights, W: Widths
class torchvision.transforms.ToPILImage(mode=None) // CHW > HWC
Convert Tensor to PIL.image

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章