(is_train, args, infer_no_resize=False)
| 152 | |
| 153 | |
| 154 | def build_transform(is_train, args, infer_no_resize=False): |
| 155 | if hasattr(args, 'arch'): |
| 156 | if 'cait' in args.arch and not is_train: |
| 157 | print('# using cait eval transform') |
| 158 | transformations = {} |
| 159 | transformations = transforms.Compose( |
| 160 | [transforms.Resize(args.input_size, interpolation=3), |
| 161 | transforms.CenterCrop(args.input_size), |
| 162 | transforms.ToTensor(), |
| 163 | transforms.Normalize(IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD)]) |
| 164 | return transformations |
| 165 | |
| 166 | if infer_no_resize: |
| 167 | print('# using cait eval transform') |
| 168 | transformations = {} |
| 169 | transformations = transforms.Compose( |
| 170 | [transforms.Resize(args.input_size, interpolation=3), |
| 171 | transforms.CenterCrop(args.input_size), |
| 172 | transforms.ToTensor(), |
| 173 | transforms.Normalize(IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD)]) |
| 174 | return transformations |
| 175 | |
| 176 | resize_im = args.input_size > 32 |
| 177 | if is_train: |
| 178 | # this should always dispatch to transforms_imagenet_train |
| 179 | transform = create_transform( |
| 180 | input_size=args.input_size, |
| 181 | is_training=True, |
| 182 | color_jitter=args.color_jitter, |
| 183 | auto_augment=args.aa, |
| 184 | interpolation=args.train_interpolation, |
| 185 | re_prob=args.reprob, |
| 186 | re_mode=args.remode, |
| 187 | re_count=args.recount, |
| 188 | ) |
| 189 | if not resize_im: |
| 190 | # replace RandomResizedCropAndInterpolation with |
| 191 | # RandomCrop |
| 192 | transform.transforms[0] = transforms.RandomCrop( |
| 193 | args.input_size, padding=4) |
| 194 | return transform |
| 195 | |
| 196 | t = [] |
| 197 | if resize_im: |
| 198 | size = int((256 / 224) * args.input_size) |
| 199 | t.append( |
| 200 | transforms.Resize(size, interpolation=3), # to maintain same ratio w.r.t. 224 images |
| 201 | ) |
| 202 | t.append(transforms.CenterCrop(args.input_size)) |
| 203 | |
| 204 | t.append(transforms.ToTensor()) |
| 205 | t.append(transforms.Normalize(IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD)) |
| 206 | return transforms.Compose(t) |
no test coverage detected
searching dependent graphs…