MCPcopy Create free account
hub / github.com/TL-UESTC/UniMoS / build_transform

Function build_transform

utils/build.py:220–251  ·  view source on GitHub ↗
(is_train, config)

Source from the content-addressed store, hash-verified

218
219
220def build_transform(is_train, config):
221 resize_im = config.DATA.IMG_SIZE > 32
222 mean = (0.48145466, 0.4578275, 0.40821073)
223 std = (0.26862954, 0.26130258, 0.27577711)
224 dataset = config.DATA.DATASET
225 bicubic = transforms.InterpolationMode.BICUBIC
226 if is_train:
227 if dataset != 'visda':
228 transform = transforms.Compose([
229 transforms.Resize((config.DATA.IMG_SIZE + 32, config.DATA.IMG_SIZE + 32), interpolation=bicubic),
230 transforms.RandomCrop(config.DATA.IMG_SIZE),
231 transforms.RandomHorizontalFlip(0.5),
232 transforms.ToTensor(),
233 transforms.Normalize(mean, std)
234 ])
235 else:
236 transform = transforms.Compose([
237 transforms.Resize((config.DATA.IMG_SIZE + 32, config.DATA.IMG_SIZE + 32), interpolation=bicubic),
238 transforms.CenterCrop(config.DATA.IMG_SIZE),
239 transforms.RandomHorizontalFlip(0.5),
240 transforms.ToTensor(),
241 transforms.Normalize(mean, std)
242 ])
243
244 else:
245 transform = transforms.Compose([
246 transforms.Resize(config.DATA.IMG_SIZE, interpolation=bicubic),
247 transforms.CenterCrop(config.DATA.IMG_SIZE),
248 transforms.ToTensor(),
249 transforms.Normalize((0.48145466, 0.4578275, 0.40821073), (0.26862954, 0.26130258, 0.27577711)),
250 ])
251 return transform
252
253
254class ResizeImage:

Callers 2

data_loadFunction · 0.85
build_tar_loaderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected