(is_train, args)
| 119 | |
| 120 | |
| 121 | def build_transform(is_train, args): |
| 122 | mean = IMAGENET_DEFAULT_MEAN |
| 123 | std = IMAGENET_DEFAULT_STD |
| 124 | # train transform |
| 125 | if is_train: |
| 126 | # this should always dispatch to transforms_imagenet_train |
| 127 | transform = create_transform( |
| 128 | input_size=args.input_size, |
| 129 | is_training=True, |
| 130 | color_jitter=args.color_jitter, |
| 131 | auto_augment=args.aa, |
| 132 | interpolation='bicubic', |
| 133 | re_prob=args.reprob, |
| 134 | re_mode=args.remode, |
| 135 | re_count=args.recount, |
| 136 | mean=mean, |
| 137 | std=std, |
| 138 | ) |
| 139 | return transform |
| 140 | |
| 141 | # eval transform |
| 142 | t = [] |
| 143 | if args.input_size <= 224: |
| 144 | crop_pct = 224 / 256 |
| 145 | #crop_pct = 0.95 |
| 146 | else: |
| 147 | crop_pct = 1.0 |
| 148 | size = int(args.input_size / crop_pct) |
| 149 | t.append( |
| 150 | transforms.Resize(size, interpolation=PIL.Image.BICUBIC), # to maintain same ratio w.r.t. 224 images |
| 151 | ) |
| 152 | t.append(transforms.CenterCrop(args.input_size)) |
| 153 | |
| 154 | t.append(transforms.ToTensor()) |
| 155 | t.append(transforms.Normalize(mean, std)) |
| 156 | return transforms.Compose(t) |
| 157 | |
| 158 | |
| 159 | ########################### Train and Eval ############################ |
no test coverage detected