def test_output_flow():
    """calc flow"""

    net = Net(2)
    imga = Image.open(IMG1)
    imgb = Image.open(IMG2)
    imga = np.asarray(imga).astype('float32') / 255
    imgb = np.asarray(imgb).astype('float32') / 255
    imga = imga[..., [2, 1, 0]]
    imgb = imgb[..., [2, 1, 0]]

    with tf.Session() as sess:
        net.restore(sess, checkpoint)
        imga = np.expand_dims(imga, 0)
        imgb = np.expand_dims(imgb, 0)

        print(imga.shape, imgb.shape)

        flow = net.flow_results.eval(feed_dict={
            'flow/inputa:0': imga,
            'flow/inputb:0': imgb,
        })
        x = flow[0]

    x = _viz_flow(x[..., 0], x[..., 1])
    Image.fromarray(x, 'RGB').save('flow.png')
예제 #2
0
def test_read_flow():
    from VSR.Framework.Callbacks import _viz_flow
    dut = DATASETS['MINICHAIRS']
    config = Config(batch=8, scale=1, depth=2, patch_size=96, steps_per_epoch=100, convert_to='RGB', crop='random')
    loader = QuickLoader(dut, 'train', config, True, n_threads=8)
    r = loader.make_one_shot_iterator('1GB', shuffle=True)
    loader.prefetch('1GB')
    list(r)
    r = loader.make_one_shot_iterator('8GB', shuffle=True)
    img, flow, name = list(r)[0]

    ref0 = img[0, 0, ...]
    ref1 = img[0, 1, ...]
    u = flow[0, 0, ..., 0]
    v = flow[0, 0, ..., 1]
    ImageProcess.array_to_img(ref0, 'RGB').show()
    ImageProcess.array_to_img(ref1, 'RGB').show()
    ImageProcess.array_to_img(_viz_flow(u, v), 'RGB').show()