Esempio n. 1
0
def dsen2_20(d10, d20):
    # Input to the funcion must be of shape:
    #     d10: [x,y,4]      (B2, B3, B4, B8)
    #     d20: [x/2,y/4,6]  (B5, B6, B7, B8a, B11, B12)
    #     deep: specifies whether to use VDSen2 (True), or DSen2 (False)

    border = 8
    p10, p20 = get_test_patches(d10, d20, patchSize=128, border=border)
    p10 /= SCALE
    p20 /= SCALE
    test = [p10, p20]
    prediction = _predict(test, model_filename=MDL_PATH_20m_AESR)
    images = recompose_images(prediction, border=border, size=d10.shape)
    images *= SCALE
    return images
Esempio n. 2
0
def DSen2_20(d10, d20, deep=False):
    # Input to the funcion must be of shape:
    #     d10: [x,y,4]      (B2, B3, B4, B8)
    #     d20: [x/2,y/4,6]  (B5, B6, B7, B8a, B11, B12)
    #     deep: specifies whether to use VDSen2 (True), or DSen2 (False)

    border = 8
    p10, p20 = get_test_patches(d10, d20, patchSize=128, border=border)
    p10 /= SCALE
    p20 /= SCALE
    test = [p10, p20]
    input_shape = ((4, None, None), (6, None, None))
    prediction = _predict(test, input_shape, deep=deep)
    images = recompose_images(prediction, border=border, size=d10.shape)
    images *= SCALE
    return images
Esempio n. 3
0
        fileList = [
            os.path.basename(x)
            for x in sorted(glob.glob(path + folder + "*SAFE"))
        ]
        for dset in fileList:
            start = time.time()
            print("Timer started.")
            print("Predicting: {}.".format(dset))
            train, image_size = OpenDataFilesTest(path + folder + dset,
                                                  args.run_60, SCALE,
                                                  args.true)
            prediction = model.predict(train, batch_size=8, verbose=1)
            prediction_file = model_nr + "-predict"
            # np.save(path + 'test/' + dset + '/' + prediction_file + 'pat', prediction * SCALE)
            images = recompose_images(prediction,
                                      border=border,
                                      size=image_size)
            print("Writing to file...")
            np.save(path + folder + dset + "/" + prediction_file,
                    images * SCALE)
            end = time.time()
            print("Elapsed time: {}.".format(end - start))
        sys.exit(0)

    if args.resume_file:
        print("Will resume from the weights {}".format(args.resume_file))
        model.load_weights(args.resume_file)
        model_nr = args.resume_file[-20:-13]
        print("Changing the model number to: {}".format(model_nr))

    else: