Exemple #1
0
def createExitModel(ModelName, gray=True, preprocessFunc=lambda x: x):
    FeatureName = "Wyjscie"
    TrainModeName = FeatureName + ModelName
    image_size_level = 5
    base_scale = 1.0

    cols, rows = moil.getColsRows(level=image_size_level,
                                  base_scale=base_scale)

    if (gray):
        mode = 0
        channels_in = 1
        color_mode = 'grayscale'
    else:
        mode = 1
        channels_in = 3
        color_mode = 'rgb'
    filters = 8
    weights_path = "../../weights/unet" + TrainModeName
    var_filename = "../../weights/var" + TrainModeName + ".txt"
    Mod = md.Models(rows,
                    cols,
                    mode=mode,
                    channels=channels_in,
                    weights_path=weights_path,
                    var_filename=var_filename,
                    read_func=moil.read_and_size,
                    preprocessFunc=preprocessFunc)
    Mod.get_model(filters=filters)
    Mod.load_weights()

    return Mod
    width_shift_range=aug['width_shift_range'],
    height_shift_range=aug['height_shift_range'],
    zoom_range=aug['zoom_range'],
    shear_range=aug['shear_range'],
    rescale=aug['rescale'],
    fill_mode=aug['fill_mode'])
train_generator = f.flow_from_directory_extension(directory=path,
                                                  batch_size=batch_size,
                                                  color_mode=color_mode,
                                                  class_mode=class_mode,
                                                  target_size=(rows, cols))
Mod = md.Models(rows,
                cols,
                mode=mode,
                channels=channels_in,
                show_function=show_function,
                read_func=read_function,
                validate_path_provider_func=validate_path_provider_func,
                validate_start_path=validate_start_path,
                weights_path=weights_path,
                var_filename=var_filename)

# model creation
model = Mod.get_model(filters=filters, le=learn_rate, decay=decay_rate)
weights_loaded = False
if load_weights:
    weights_loaded = Mod.load_weights()
if not weights_loaded:
    Mod.save_weights()
Mod.plot_loss(500)
Mod.check_performance(train_generator, times=check_perf_times)