Example #1
0
    # Split the training data into training and test data
    (TrainPathList, TestPathList, TrainLabel,
     TestLabel) = train_test_split(TrainingImageList,
                                   TrainingLabelList,
                                   stratify=TrainingLabelList)

    Datasets = [
        ("Train", TrainPathList, TrainLabel,
         Network.DATASET_PATH + os.path.sep + Network.OUTPUT_PATH +
         os.path.sep + Network.TRAIN_HDF5 + ".hdf5"),
        ("Test", TestPathList, TestLabel, Network.DATASET_PATH + os.path.sep +
         Network.OUTPUT_PATH + os.path.sep + Network.TEST_HDF5 + ".hdf5")
    ]

    # Create a new preprocessor to resize the images to a common size
    AspectPreprocessor = Preprocessor.AspectAwarePreprocessor(
        Width=Network.IMAGESIZE[0], Height=Network.IMAGESIZE[1])

    for (Type, PathList, Labels, FilePath) in Datasets:
        print("[INFO] Building dataset '{}'...".format(Type))
        FileWriter = IO.HDF5DatasetWriter(
            Dimensions=(len(PathList), Network.IMAGESIZE[0],
                        Network.IMAGESIZE[1], Network.CHANNELS),
            OutputPath=FilePath)

        # Create a new progressbar
        Widgets = [
            "    Progress: ",
            progressbar.Percentage(), " ",
            progressbar.Bar(), " ",
            progressbar.ETA()
        ]