(self, image)
| 32 | ]) |
| 33 | |
| 34 | def image_check(self, image): |
| 35 | if image is None: |
| 36 | return image |
| 37 | # preprocess |
| 38 | W, H = image.size |
| 39 | if H / W > self.max_aspect_ratio: |
| 40 | image = T.CenterCrop([int(self.max_aspect_ratio * W), W])(image) |
| 41 | elif W / H > self.max_aspect_ratio: |
| 42 | image = T.CenterCrop([H, int(self.max_aspect_ratio * H)])(image) |
| 43 | return self.transforms(image) |
| 44 | |
| 45 | |
| 46 | def preprocess(self, |