MCPcopy Create free account
hub / github.com/lingeringlight/START / build_transform

Function build_transform

datasets.py:78–109  ·  view source on GitHub ↗
(is_train, args)

Source from the content-addressed store, hash-verified

76
77
78def build_transform(is_train, args):
79 resize_im = args.input_size > 32
80 if is_train:
81 # this should always dispatch to transforms_imagenet_train
82 transform = create_transform(
83 input_size=args.input_size,
84 is_training=True,
85 color_jitter=args.color_jitter,
86 auto_augment=args.aa,
87 interpolation=args.train_interpolation,
88 re_prob=args.reprob,
89 re_mode=args.remode,
90 re_count=args.recount,
91 )
92 if not resize_im:
93 # replace RandomResizedCropAndInterpolation with
94 # RandomCrop
95 transform.transforms[0] = transforms.RandomCrop(
96 args.input_size, padding=4)
97 return transform
98
99 t = []
100 if resize_im:
101 size = int(args.input_size / args.eval_crop_ratio)
102 t.append(
103 transforms.Resize(size, interpolation=3), # to maintain same ratio w.r.t. 224 images
104 )
105 t.append(transforms.CenterCrop(args.input_size))
106
107 t.append(transforms.ToTensor())
108 t.append(transforms.Normalize(IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD))
109 return transforms.Compose(t)

Callers 1

build_datasetFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…