The error occurs after a certain amount of time, the RAM slowly increases. I get process killed by signal error.
This is the dataset code
class SegDataset(data.Dataset):
	def __init__(self, root, split="train", is_transform = False, augmentations=None):
		self.root=root
		self.split = split
		self.augmentations = augmentations
		self.is_transform = is_transform
		self.n_classes = 3
		self.files = collections.defaultdict(list)
		self.images_base = os.path.join(self.root, self.split)
		self.masks_base = os.path.join(self.root, 'masks' + '/' + self.split)

		for split in ['train', 'val', 'test']:
			file_list = recursive_glob(rootdir=self.root + '/' + split , suffix='.jpg')
			self.files[split] = file_list

	def __len__(self):
		return len(self.files[self.split])

	def __getitem__(self, index):
		img_path = self.files[self.split][index].rstrip()
		img_name = img_path.split(os.sep)[-1].split('.')[0]
		mask_name = img_name + 	'_mask.png'
		mask_path = self.masks_base + '/' + mask_name
		
		img = m.imread(img_path)
		img = np.array(img, dtype=np.uint8)

		mask = m.imread(mask_path)
		mask = np.array(mask, dtype=np.uint8)

		img, window, scale, padding, crop = self.resize_image(img, min_dim=image_size[0], max_dim=image_size[1])
		mask = self.resize_mask(mask, padding=padding, crop=crop)

		if self.augmentations is not None:
			img, mask = self.augmentations(img, mask)

		if self.is_transform:
			img, mask = self.transform(img, mask)

		return img, mask