Hi, I have a problem with loading COCO data to data loader. When I am doing it my RAM is used in 100% (500 GB (sic!)).
I load my dataset as here:

class LoadDataset(Dataset):
    def __init__(self):
        self.images = []
        self.targets = []
        img_path, ann_path = (
            "path_to_images",
            "path_to_annotations",
        )
        coco_ds = torchvision.datasets.CocoDetection(img_path, ann_path)
        for i in range(0, len(coco_ds)):
            img, ann = coco_ds[i]
            for a in ann:
                width = a["bbox"][2]
                height = a["bbox"][3]
                image_size = width * height
                if image_size > 10000:  # I want only high quality images
                    for t in targets:
                        self.targets.append(t)
                    for image in images:
                        self.images.append(image)

    def __len__(self):
        return len(self.images)

    def __getitem__(self, idx):
        img = self.images[idx]
        target = self.targets[idx]

        target["some_parameter"] = torch.as_tensor(some_value)  # I added another 'head' to RCNN model

        return (
            img,
            target,
        )


And then I load data to dataloader like:

train_loader = DataLoader(LoadDataset(), batch_size=24, shuffle=True, num_workers=0)