def testGenerateDataUsingCommonFunctions(self):
     commonFunctions = [np.ones((3, 4, 5)), gd.FillNdArraysBy135]
     diffFunctions = [gd.FillNdArraysElementBy124InStep6]
     basics = gwg.GenerateDataUsingFunctions(commonFunctions)
     diffs = gwg.ModifyDataUsingFunctions(basics, diffFunctions)
     self.assertEqual(135, basics[2, 2, 4])
     self.assertEqual(124, diffs[1, 2, 0])
 def testGenerateBackground(self):
     createBackgroundFunc = np.ones((3, 4, 5))
     backGrd = gwg.GenerateDataUsingFunctions([createBackgroundFunc])
     self.assertEqual(1, backGrd[2, 2, 4])
Exemplo n.º 3
0
if __name__ == "__main__":
    #~ DataParameters
    num_train = 400
    size = 256
    num_test = None
    numToShow = 10
    #~ Generate
    start = tm.time()
    print('generowanie danych...')
    commonFunctions = [
        gwg.CreateGrayGradientsAsNdArray((num_train, size, size)),
        gwg.CreateLettersOnGradients
    ]
    diffFunctions = [gwg.CreateRandomCirclesOn]

    train_labels = gwg.GenerateDataUsingFunctions(commonFunctions)
    train_images = gwg.ModifyDataUsingFunctions(train_labels, diffFunctions)
    stop = tm.time()
    print('wygenerowano dane w ' + '%.5f' % (stop - start) + 's')
    #~ Save
    start = stop
    nameCommon = 'GradientLetters_'
    nameDiff = nameCommon + '_DiffCircles_' + str(num_train) + '_' + str(
        size) + 'x' + str(size)
    nameCommon = nameCommon + str(num_train) + '_' + str(size) + 'x' + str(
        size)
    print(nameCommon)
    print(nameDiff)

    np.save(nameCommon, train_labels)
    np.save(nameDiff, train_images)