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 (#4481)

* Replaced ToTensor with a combination of PILToTensor and ConvertImageDtype

* Pass dtype
  • Loading branch information
prabhat00155 authored Sep 26, 2021
1 parent 4ef8e6b commit b7c2358
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 b7c2358

Please sign in to comment.