Esempio n. 1
0
def main(args):
    config = Config(args.in_settings)
    config.init(args.dataset)
    if args.verbose:
        config.debug()

    in_dir1 = config.temp_2d_dir
    in_dir2 = config.temp_3d_dir
    out_dir = config.temp_ensemble_dir

    analyze_ensemble(in_dir1=in_dir1,
                     in_dir2=in_dir2,
                     out_dir=out_dir,
                     verbose=args.verbose)
Esempio n. 2
0
def main(args):
    config = Config(args.in_settings)
    config.init(args.dataset)
    if args.connectivity != 0:
        config.ensemble_connectivity = args.connectivity
    if args.verbose:
        config.debug()

    in_dir = config.temp_ensemble_dir
    out_dir = config.output_path
    connectivity = config.ensemble_connectivity

    analyze_connection(in_dir=in_dir,
                       out_dir=out_dir,
                       in_filename=args.in_filename,
                       stat=args.stat,
                       connectivity=connectivity,
                       verbose=args.verbose)
Esempio n. 3
0
def predict(in_settings, overwrite_dataset=None, verbose=False):
    import tensorflow as tf
    config = tf.ConfigProto(gpu_options=tf.GPUOptions(
        allow_growth=True, per_process_gpu_memory_fraction=0.8))
    session = tf.Session(config=config)
    keras.backend.tensorflow_backend.set_session(session)

    # config
    config = Config(in_settings)
    config.init(overwrite_dataset)
    if verbose:
        config.debug()

    # loading sample
    ds = Dataset2d()
    width, height, imgnum = ds.load_csv(
        os.path.join(config.input_path, 'input.csv'))
    model_mn = 16  # model magick number
    width_ex = int(math.ceil(width / model_mn) * model_mn)
    height_ex = int(math.ceil(height / model_mn) * model_mn)
    x_train = ds.image_read(os.path.join(config.input_path, '*.tif'), width,
                            height)
    x_train_norm, x_width, x_height = reshape(x_train, (width_ex, height_ex))

    # create model
    model_base = Model2d(config)
    model = model_base.load(input_shape=(width_ex, height_ex, 1))

    if verbose:
        print('x_train_norm:', x_train_norm.shape)
        print(model.summary())

    # predict
    y_pred = model.predict(x_train_norm,
                           batch_size=config.predict_2d_batch_size,
                           verbose=1 if verbose else 0)
    output = postprocess(y_pred, (width_ex, height_ex), (x_width, x_height))

    # saving
    os.makedirs(config.temp_2d_dir, exist_ok=True)
    ds.image_save(output, config.temp_2d_dir)
Esempio n. 4
0
def main(args):
    config = Config(args.in_settings)
    config.init(args.dataset)
    if args.verbose:
        config.debug()

    sample_dir = config.input_path
    model_path = config.model_3d_path
    out_dir = config.temp_3d_dir
    batch_size = config.predict_3d_batch_size
    crop_size = config.predict_3d_crop_size
    overlap = config.predict_3d_overlap

    predict(sample_dir=sample_dir,
            model_path=model_path,
            out_dir=out_dir,
            batch_size=batch_size,
            crop_size=crop_size,
            overlap=overlap,
            application=args.application,
            verbose=args.verbose)