mayorx/PointDETR

huge bug in dataset idx sampling -> number of epoch reported in the paper

Opened this issue · 0 comments

hello,

I believe there is a hugue bug in the dataset code

class CocoDetection(torchvision.datasets.CocoDetection):
    def __init__(self, img_folder, ann_file, transforms, return_masks, partial_training_data, is_training, dropout_points, percent, point_idx):
        super(CocoDetection, self).__init__(img_folder, ann_file)
        self._transforms = transforms
        self.prepare = ConvertCocoPolysToMask(return_masks)
        self.partial_training_data = partial_training_data
        self.is_training = is_training

        # if self.is_training and self.partial_training_data:
        if percent == 20:
            from datasets.annoted_img_ids import annoted_img_ids
        else:
            raise('percent .. {} is not supported.'.format(percent))
        self.annoted_imgs = annoted_img_ids
        print('partial training data .. ', self.partial_training_data)
        self.dropout_points = dropout_points
        self.point_idx = point_idx

    def __getitem__(self, idx):
        image_id = self.ids[idx]
        if self.partial_training_data and self.is_training:
            while image_id not in self.annoted_imgs:
                idx = int(torch.randint(0, len(self.ids), (1,)))
                image_id = self.ids[idx]

        img, target = super(CocoDetection, self).__getitem__(idx)
        target = {'image_id': image_id, 'annotations': target}
        img, target = self.prepare(img, target, self.is_training and self.dropout_points)
        if self._transforms is not None:
            img, target = self._transforms(img, target)

        # print('target ... ', target)
        # print(img.size())

        if self.is_training:
            points_supervision, target = generate_target_training(target)
        else:
            points_supervision, target = generate_target_evaluation(target, self.point_idx)
        # print('target ', target , ' ... ')
        return img, points_supervision, target

with this sampling method, you are sampling MULTIPLE TIME the same image id inside an epoch. This mean than on the 20% setting, you are, on average, sampling each image 5 times per epoch. Thus, the 108 epoch are in fact closer to 108*5 epochs.

I have collected the idx of the sampled image for one epoch
here is a sample: (idx: number of time it is sampled in the epoch)

17964: 5, 25109: 4, 66867: 4, 110803: 1, 109121: 5, 94839: 5, 85222: 3, 53926: 4, 13261: 4, 41174: 5, 33154: 8, 70690: 6, 40859: 8, 20272: 6, 5524: 6, 45392: 6, 3562: 4, 29884: 10, 7322: 6, 15909: 8, 11771: 6, 109402: 3, 84669: 5, 9589: 6, 69696: 4, 93439: 8, 42943: 6, 105715: 6, 977: 4, 103666: 7, 58584: 3, 92106: 5, 59717: 5, 25892: 2, 86339: 4, 25593: 2, 56292: 5, 46534: 3, 80347: 7, 4644: 5, 44179: 8, 49902: 8, 10635: 3, 112782: 6, 60087: 2, 96360: 6, 71049: 7, 6133: 5, 28048: 6, 39147: 8, 87127: 3, 52656: 4, 9867: 5, 106391: 4, 95612: 4, 55183: 8, 104199: 4, 88179: 4, 75528: 5, 24050: 5, 27518: 5, 12509: 1, 75673: 10, 48489: 4, 100510: 5, 117995: 4, 89284: 3, 59123: 4, 65120: 5, 50702: 4, 101342: 2, 6635: 5, 53578: 6, 45178: 6, 48983: 4, 116189: 4, 95660: 5, 77706: 6, 3147: 5, 45056: 9, 92548: 2, 28073: 3, 9276: 3, 13120: 4, 5125: 7, 59440: 2, 83215: 10, 32356: 7, 102744: 10, 37728: 4, 78459: 8, 50583: 4, 104730: 6, 3415: 7, 115296: 5, 71246: 5, 87820: 4, 61136: 5, 7825: 8, 50665: 4, 9561: 5, 41836: 5, 104600: 5, 110308: 4, 87727: 8, 6106: 9, 32001: 2, 80688: 3, 35463: 4, 43986: 6, 104724: 4, 64164: 5, 17598: 3, 59924: 8, 91124: 2, 103155: 7, 115368: 2, 45612: 6, 1176: 5, 75: 6, 32283: 5, 92183: 6, 94431: 8, 94169: 7, 1447: 4, 73757: 6, 2123: 8, 18918: 6,

Best