(is_train, config)
| 218 | |
| 219 | |
| 220 | def 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 | |
| 254 | class ResizeImage: |
no outgoing calls
no test coverage detected