def _return_std(image_path, mean): img = np.array(load_pil_image(image_path)) / 255.0 m2 = np.square( np.array([ img[:, :, 0] - mean[0], img[:, :, 1] - mean[1], img[:, :, 2] - mean[2] ])) return np.sum(np.sum(m2, axis=1), 1), m2.size / 3.0
def _return_mean(image_path): img = np.array(load_pil_image(image_path)) mean = np.array([ np.mean(img[:, :, 0]), np.mean(img[:, :, 1]), np.mean(img[:, :, 2]) ]) return mean / 255.0
def __getitem__(self, index: int): # Load images and masks img = load_pil_image(self.images_path[index]) target = self._map_annotation(index) if self.convert_polygons is not None: img, target = self.convert_polygons(img, target) if self.transform is not None: img, target = self.transform(img, target) return img, target