(opt, size)
| 61 | |
| 62 | |
| 63 | def get_params(opt, size): |
| 64 | w, h = size |
| 65 | new_h = h |
| 66 | new_w = w |
| 67 | if opt.preprocess == 'resize_and_crop': |
| 68 | new_h = new_w = opt.load_size |
| 69 | elif opt.preprocess == 'scale_width_and_crop': |
| 70 | new_w = opt.load_size |
| 71 | new_h = opt.load_size * h // w |
| 72 | |
| 73 | x = random.randint(0, np.maximum(0, new_w - opt.crop_size)) |
| 74 | y = random.randint(0, np.maximum(0, new_h - opt.crop_size)) |
| 75 | |
| 76 | flip = random.random() > 0.5 |
| 77 | |
| 78 | return {'crop_pos': (x, y), 'flip': flip} |
| 79 | |
| 80 | |
| 81 | def get_transform(opt, params=None, grayscale=False, method=Image.BICUBIC, convert=True): |
nothing calls this directly
no outgoing calls
no test coverage detected