[Pytorch] torchvision.transforms()

  • torchvision.transforms()
  1. Transforms are common image transformations.
  2. They can be chained together using Compose.
  3. 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

<<:  [MSSQL维护] SQL 侦测 - 在忙什麽,为什麽这麽慢~~

>>:  在投影片内文字选取位置插入等大图片_以字图取代文字【PowerPoint VBA】

Day 24 - 继承家业

Outline & Intro Inheritance An example Polymor...

Day 20: Security Hub 新帐号加入、Insight设定

上篇我们讲到了有/没有使用AWS Organization 启用Security hub的状况,那如...

Day 9. Compare × Final

Conclusion 呼~到今天为止 9 天过去了,Libraries 之间的比较篇章也到今天告一...

第廿六日:终於旅游感满满的周日

早上起来,决定至少去吸食一下咖啡,买个包子,看看时间已经八点半,出发。 顺着中华路走到中山路,然後拐...

Day27 订单 -- 分期付款

今天要说的是信用卡分期付款,分期付款也是信用卡付款的一种, 但我们需要透过结构上的改动以符合分期资料...