Skip to content

Commit

Permalink
Replaced ToTensor with a combination of PILToTensor and ConvertImageD…
Browse files Browse the repository at this point in the history
…type (pytorch#4481)

* Replaced ToTensor with a combination of PILToTensor and ConvertImageDtype

* Pass dtype
  • Loading branch information
prabhat00155 authored and cyyever committed Nov 16, 2021
1 parent 5f4d4a1 commit c45694d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions references/classification/presets.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import torch
from torchvision.transforms import autoaugment, transforms
from torchvision.transforms.functional import InterpolationMode

Expand All @@ -17,7 +18,8 @@ def __init__(self, crop_size, mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.2
aa_policy = autoaugment.AutoAugmentPolicy(auto_augment_policy)
trans.append(autoaugment.AutoAugment(policy=aa_policy))
trans.extend([
transforms.ToTensor(),
transforms.PILToTensor(),
transforms.ConvertImageDtype(torch.float),
transforms.Normalize(mean=mean, std=std),
])
if random_erase_prob > 0:
Expand All @@ -36,7 +38,8 @@ def __init__(self, crop_size, resize_size=256, mean=(0.485, 0.456, 0.406), std=(
self.transforms = transforms.Compose([
transforms.Resize(resize_size, interpolation=interpolation),
transforms.CenterCrop(crop_size),
transforms.ToTensor(),
transforms.PILToTensor(),
transforms.ConvertImageDtype(torch.float),
transforms.Normalize(mean=mean, std=std),
])

Expand Down

0 comments on commit c45694d

Please sign in to comment.