Beispiel #1
0
    def test_AllImagesFromSampeSampleAreGrouped(self):
        itemlist = []
        for sampleID in ["001", "015", "230"]:
            itemlist.append([
                imageNamed(
                    int(sampleID) - 1, "%s_%d.png" % (sampleID, (i) + 1))
                for i in range(27)
            ])

        items = self.joinLists(itemlist)
        numpy.random.shuffle(items)

        target = FileGroupingDatasetSplitter(9)
        result = target.split(items, [.6, .2, .2])

        totalAfterSplit = self.joinLists(result)

        self.assertEqual(sorted(totalAfterSplit), sorted(items))

        for sampleID in ["001", "015", "230"]:
            self.assertSamplesAreInOnlyOneSet(
                ["%s_%d.png" % (sampleID, i) for i in range(1, 10)], result)
            self.assertSamplesAreInOnlyOneSet(
                ["%s_%d.png" % (sampleID, i) for i in range(10, 19)], result)
            self.assertSamplesAreInOnlyOneSet(
                ["%s_%d.png" % (sampleID, i) for i in range(19, 28)], result)
    def test_SplitsImages(self):
        items = [imageNamed(0,"001_01.bmp"), imageNamed(0,"001_03.bmp"), imageNamed(0,"001_02.bmp")]

        target = FileGroupingDatasetSplitter(1)
        result = target.split(items, [.6, .2, .2])

        self.assertEquals(sorted(self.joinLists(result)), sorted(items))
        for d in result:
            self.assertEquals(1, len(d))
Beispiel #3
0
    def test_SplitsImages(self):
        items = [
            imageNamed(0, "001_01.bmp"),
            imageNamed(0, "001_03.bmp"),
            imageNamed(0, "001_02.bmp")
        ]

        target = FileGroupingDatasetSplitter(1)
        result = target.split(items, [.6, .2, .2])

        self.assertEquals(sorted(self.joinLists(result)), sorted(items))
        for d in result:
            self.assertEquals(1, len(d))
    def test_AllImagesFromSampeSampleAreGrouped(self):
        itemlist = []
        for sampleID in ["001", "015", "230"]:
            itemlist.append([imageNamed(int(sampleID)-1, "%s_%d.png" % (sampleID, (i)+1)) for i in range(27)])

        items = self.joinLists(itemlist)
        numpy.random.shuffle(items)
        
        target = FileGroupingDatasetSplitter(9)
        result = target.split(items, [.6,.2,.2])

        totalAfterSplit = self.joinLists(result)
        
        self.assertEqual(sorted(totalAfterSplit), sorted(items))
        
        for sampleID in ["001", "015", "230"]:
            self.assertSamplesAreInOnlyOneSet(["%s_%d.png" % (sampleID, i) for i in range(1, 10)], result)
            self.assertSamplesAreInOnlyOneSet(["%s_%d.png" % (sampleID, i) for i in range(10, 19)], result)
            self.assertSamplesAreInOnlyOneSet(["%s_%d.png" % (sampleID, i) for i in range(19, 28)], result)
Beispiel #5
0
def FileGroupingSplit(numFilePerImage, shuffle=True):
    return FileGroupingDatasetSplitter(numFilePerImage, shuffle)
Beispiel #6
0
    def CreateWithFileGroupingSplitter(imageSource, numFilePerImage, preprocessor = None):
        return DatasetCreator(imageSource = imageSource,
                              datasetSplitter = FileGroupingDatasetSplitter(numFilePerImage),
							  preprocessor = preprocessor)