Given an image, process it and return the array.
(self, image_path)
| 101 | return x |
| 102 | |
| 103 | def process_image(self, image_path): |
| 104 | """Given an image, process it and return the array.""" |
| 105 | # Load the image. |
| 106 | image = self._load_img(image_path) |
| 107 | if image is None: |
| 108 | return None |
| 109 | img_arr = self._img_to_array(image) |
| 110 | x = (img_arr / 255.).astype('float32') # |
| 111 | x = (x - self.mean) / self.std # normalize images |
| 112 | return x |
| 113 | |
| 114 | def random_crop(self, img, target_size, p=0.5): |
| 115 | """random crop image""" |