Ejemplo n.º 1
0
def create_generators(args, data, DeepForest_config):
    """ Create generators for training and validation.
    """
    # create random transform generator for augmenting training data
    if args.random_transform:
        transform_generator = random_transform_generator(
            min_rotation=-0.1,
            max_rotation=0.1,
            min_translation=(-0.1, -0.1),
            max_translation=(0.1, 0.1),
            min_shear=-0.1,
            max_shear=0.1,
            min_scaling=(0.9, 0.9),
            max_scaling=(1.1, 1.1),
            flip_x_chance=0.5,
            flip_y_chance=0.5,
        )
    else:
        transform_generator = random_transform_generator(flip_x_chance=0.5)

    #Split training and test data - hardcoded paths set below.
    train, test = preprocess.split_training(
        data,
        DeepForest_config,
        single_tile=DeepForest_config["single_tile"],
        experiment=experiment)

    experiment.log_dataset_hash(data=train)

    #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 = OnTheFlyGenerator(data,
                                        train,
                                        batch_size=args.batch_size,
                                        DeepForest_config=DeepForest_config,
                                        group_method="none",
                                        shuffle_tile_epoch=True,
                                        name="training")

    #Validation Generator

    validation_generator = OnTheFlyGenerator(
        data,
        test,
        batch_size=args.batch_size,
        DeepForest_config=DeepForest_config,
        group_method="none",
        name="validation")

    return train_generator, validation_generator
Ejemplo n.º 2
0
def create_generator(args, main, DeepForest_config):
    """ Create generators for training and validation.
    """
    # create random transform generator for augmenting training data
    if args.random_transform:
        transform_generator = random_transform_generator(
            min_rotation=-0.1,
            max_rotation=0.1,
            min_translation=(-0.1, -0.1),
            max_translation=(0.1, 0.1),
            min_shear=-0.1,
            max_shear=0.1,
            min_scaling=(0.9, 0.9),
            max_scaling=(1.1, 1.1),
            flip_x_chance=0.5,
            flip_y_chance=0.5,
        )
    else:
        transform_generator = random_transform_generator(flip_x_chance=0.5)

    #Split training and test data - hardcoded paths set below.
    train, test = preprocess.split_training(
        data,
        DeepForest_config,
        single_tile=DeepForest_config["single_tile"],
        experiment=None)

    #Training Generator
    generator = OnTheFlyGenerator(data,
                                  train,
                                  batch_size=args.batch_size,
                                  DeepForest_config=DeepForest_config,
                                  group_method="none")

    return (generator)
Ejemplo n.º 3
0
def create_NEON_generator(args, site, DeepForest_config):
    """ Create generators for training and validation.
    """

    annotations, windows = preprocess.NEON_annotations(site, DeepForest_config)

    #Training Generator
    generator = OnTheFlyGenerator(annotations,
                                  windows,
                                  batch_size=args.batch_size,
                                  DeepForest_config=DeepForest_config,
                                  group_method="none")

    return (generator)
Ejemplo n.º 4
0
def create_NEON_generator(batch_size, DeepForest_config, name="evaluation"):
    """ Create generators for training and validation.
    """
    annotations, windows = NEON_annotations(DeepForest_config)

    #Training Generator
    generator = OnTheFlyGenerator(annotations,
                                  windows,
                                  batch_size=batch_size,
                                  DeepForest_config=DeepForest_config,
                                  group_method="none",
                                  name=name,
                                  preprocess_image=image_utils.normalize)

    return (generator)
Ejemplo n.º 5
0
def create_generator(args,data,config):
    """ Create generators for training and validation.
    """

    #Split training and test data - hardcoded paths set below.
    _,test=preprocess.split_training(data,DeepForest_config,single_tile=DeepForest_config["single_tile"],experiment=None)

    #Training Generator
    generator =  OnTheFlyGenerator(
        data,
        test,
        batch_size=args.batch_size,
        DeepForest_config=DeepForest_config,
        group_method="none")
    
    return(generator)