Ejemplo n.º 1
0
def create_generators(args, data, DeepForest_config):
    """ Create generators for training and validation.
    """
    #Split training and test data
    train, test = preprocess.split_training(data, DeepForest_config, experiment=None)

    #Write out for debug
    if args.save_path:
        train.to_csv(os.path.join(args.save_path,'training_dict.csv'), header=False)         
        
    #Training Generator
    train_generator = H5Generator(train, 
                                  batch_size = args.batch_size, 
                                  DeepForest_config = DeepForest_config, 
                                  name = "training",
                                  preprocess_image=image_utils.normalize
                                  )

    #Validation Generator, check that it exists
    if test is not None:
        validation_generator = H5Generator(test, 
                                           batch_size = args.batch_size, 
                                           DeepForest_config = DeepForest_config, 
                                           name = "training",
                                           preprocess_image=image_utils.normalize
                                           )
    else:
        validation_generator = None
        
    return train_generator, validation_generator
Ejemplo n.º 2
0
def create_h5_generators(data, DeepForest_config):
    """ Create generators for training and validation.
    """
    #Split training and test data
    train, test = split_training(data, DeepForest_config, experiment=None)

    #Write out for debug
    if DeepForest_config["save_image_path"]:
        train.to_csv(os.path.join(DeepForest_config["save_image_path"],
                                  'training_dict.csv'),
                     header=False)

    if DeepForest_config["spatial_filter"]:
        train = spatial_filter(train, DeepForest_config)

    #Training Generator
    train_generator = H5Generator(train,
                                  batch_size=DeepForest_config["batch_size"],
                                  DeepForest_config=DeepForest_config,
                                  name="training",
                                  preprocess_image=image_utils.preprocess)

    #Validation Generator, check that it exists
    if test is not None:
        validation_generator = H5Generator(
            test,
            batch_size=DeepForest_config["batch_size"],
            DeepForest_config=DeepForest_config,
            name="training",
            preprocess_image=image_utils.preprocess)
    else:
        validation_generator = None

    return train_generator, validation_generator
Ejemplo n.º 3
0
def create_generator(args, data, DeepForest_config):
    """ Create generators for training and validation.
    """
    #Split training and test data - hardcoded paths set below.
    _ , test = preprocess.split_training(data, DeepForest_config, experiment=None)

    #Training Generator
    generator =  H5Generator(
        test,
        batch_size=args.batch_size,
        DeepForest_config=DeepForest_config,
        group_method="none",
        name = "training"
    )
        
    return(generator)