def preprocess(image_path):
    I = np.asarray(imageio.imread(image_path))
    I = extract_bayer_channels(I)
    I = I[0:256 // 2, 0:256 // 2, :]
    I = np.reshape(I, [1, I.shape[0], I.shape[1], 4])
    return I
Beispiel #2
0
            sess, "models/pynet_level_" + str(LEVEL) + "_iteration_" +
            str(restore_iter) + ".ckpt")

    # Processing full-resolution RAW images

    test_dir = dataset_dir + "/test/huawei_full_resolution/"
    test_photos = [
        f for f in os.listdir(test_dir) if os.path.isfile(test_dir + f)
    ]

    for photo in test_photos:

        print("Processing image " + photo)

        I = np.asarray(imageio.imread((test_dir + photo)))
        I = extract_bayer_channels(I)

        I = I[0:IMAGE_HEIGHT, 0:IMAGE_WIDTH, :]
        I = np.reshape(I, [1, I.shape[0], I.shape[1], 4])

        # Run inference

        enhanced_tensor = sess.run(enhanced, feed_dict={x_: I})
        enhanced_image = np.reshape(
            enhanced_tensor,
            [int(I.shape[1] * DSLR_SCALE),
             int(I.shape[2] * DSLR_SCALE), 3])

        # Save the results as .png images
        photo_name = photo.rsplit(".", 1)[0]
        imageio.imsave(