Пример #1
0
        edge_list.append(curr_file + "edge.ppm")
        # print(flow_list[-1:][0])

I1, I2, E, F = get_batch_jitter_scale(1,
                                      img1_list, img2_list, edge_list, flow_list,
                                      height=mdl_height, width=mdl_width)
F = F * scale

I = tf.placeholder(dtype=tf.float32, shape=[None, mdl_height, mdl_width, None])
O = tf.image.resize_bilinear(I, size=[int(mdl_height * scale), int(mdl_width * scale)])
sess = tf.InteractiveSession()
I1_ = np.squeeze(O.eval(feed_dict={I: I1}))
I2_ = np.squeeze(O.eval(feed_dict={I: I2}))
E_ = np.squeeze(O.eval(feed_dict={I: E}))
F_ = np.squeeze(O.eval(feed_dict={I: F}))

print(I1_.shape, I2_.shape, E_.shape, F_.shape)
plt.imshow(np.squeeze(I1_))
plt.pause(1)
plt.imshow(np.squeeze(I2_))
plt.pause(1)
plt.imshow(np.squeeze(E_))
plt.pause(1)
plt.imshow(flow2hsv(np.squeeze(F_)))
plt.pause(1)

savemat('./tmp/batch_data.mat', mdict={'img1': I1_,
                                       'img2': I2_,
                                       'edge': E_,
                                       'flow': F_})
Пример #2
0
    # print('max gt flow is', np.max(F))

    if niter % DISP == 0:
        flow = np.squeeze(
            net.flow2.eval(
                feed_dict={
                    net.inp1: np.expand_dims(I1[0][:][:][:], 0),
                    net.inp2: np.expand_dims(I2[0][:][:][:], 0),
                    net.edge: np.expand_dims(E[0][:][:][:], 0),
                }))

        print('max computed flo is', np.max(flow))
        print('does flow has nan?', np.any(np.isnan(flow)))
        plt.imshow(I1[0][:][:][:])
        plt.pause(1)
        plt.imshow(flow2hsv(flow))
        plt.pause(1)
        plt.close()

    if niter % VERBOSE == 0:
        flow_loss = np.squeeze(
            net.loss.eval(feed_dict={
                net.inp1: I1,
                net.inp2: I2,
                net.gt: F,
                net.edge: E
            }))
        # flow_loss2 = np.squeeze(net.loss2.eval(feed_dict={net.inp1: I1, net.inp2: I2, net.gt: F}))
        # flow_loss3 = np.squeeze(net.loss3.eval(feed_dict={net.inp1: I1, net.inp2: I2, net.gt: F}))
        # flow_loss4 = np.squeeze(net.loss4.eval(feed_dict={net.inp1: I1, net.inp2: I2, net.gt: F}))
        # flow_loss5 = np.squeeze(net.loss5.eval(feed_dict={net.inp1: I1, net.inp2: I2, net.gt: F}))
Пример #3
0
SAVE = 32

learning_rate = tf.placeholder(dtype=tf.float32, shape=[])
model_path = './models/fn_sup'
net = FlowNetS(HEIGHT, WIDTH)
optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(
    net.loss)
init = tf.global_variables_initializer()
sess = tf.InteractiveSession()
saver = tf.train.Saver()
# sess.run(init)

# saver = tf.train.import_meta_graph(model_path + '.meta')
saver.restore(sess, model_path)

test_dir = './middlebury_data/MiniCooper'
img1 = read_img(test_dir + '/' + 'frame10.png')[0:HEIGHT, 0:WIDTH, :]
img2 = read_img(test_dir + '/' + 'frame11.png')[0:HEIGHT, 0:WIDTH, :]

flow_eval = np.squeeze(
    net.flow2.eval(feed_dict={
        net.inp1: np.expand_dims(img1, 0),
        net.inp2: np.expand_dims(img2, 0)
    }))
print('eval flow shape', flow_eval.shape)
img_vis = np.hstack((img1, img2))
plt.imshow(img_vis)
plt.pause(2)
plt.imshow(flow2hsv(flow_eval))
plt.pause(2)
Пример #4
0
        start_x = j * mdl_width
        img1_tile = img1[start_y:start_y + mdl_height,
                         start_x:start_x + mdl_width, :]
        img2_tile = img2[start_y:start_y + mdl_height,
                         start_x:start_x + mdl_width, :]
        edge_tile = edge[start_y:start_y + mdl_height,
                         start_x:start_x + mdl_width, :]
        miss_tile = miss[start_y:start_y + mdl_height,
                         start_x:start_x + mdl_width, :]

        flow_tile = np.squeeze(net.outs[str(10)].eval(
            feed_dict={
                net.img1: np.expand_dims(img1_tile, 0),
                net.img2: np.expand_dims(img2_tile, 0),
                net.edge: np.expand_dims(edge_tile, 0),
                net.miss: np.expand_dims(miss_tile, 0)
            }))
        flow[start_y:start_y + mdl_height,
             start_x:start_x + mdl_width] = flow_tile

print('does flow has nan?', np.any(np.isnan(flow)))
plt.imshow(np.hstack((img1, np.repeat(edge, 3, axis=2))))
figManager = plt.get_current_fig_manager()
figManager.window.showMaximized()
plt.pause(1)
plt.imshow(np.hstack((flow2hsv(flow), flow2hsv(flow_gt))))
figManager = plt.get_current_fig_manager()
figManager.window.showMaximized()
plt.pause(5)
plt.close()
Пример #5
0
learning_rate = tf.placeholder(dtype=tf.float32, shape=[])
model_path = './models/fn_sup'
net = FlowNetS(HEIGHT, WIDTH)
optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(net.loss)
init = tf.global_variables_initializer()
sess = tf.InteractiveSession()
saver = tf.train.Saver()
# sess.run(init)

# saver = tf.train.import_meta_graph(model_path + '.meta')
saver.restore(sess, model_path)


test_dir = './middlebury_data/Grove3'
img1 = read_img(test_dir + '/' + 'frame10.png')[0:HEIGHT, 0:WIDTH, :]
img2 = read_img(test_dir + '/' + 'frame11.png')[0:HEIGHT, 0:WIDTH, :]
flow_gt = readFlow(test_dir + '/' + 'flow10.flo')[0:HEIGHT, 0:WIDTH, :]
print('gt flow shape', flow_gt.shape)

flow_eval = np.squeeze(net.flow2.eval(feed_dict={net.inp1: np.expand_dims(img1, 0),
                                                 net.inp2: np.expand_dims(img2, 0)}))
print('eval flow shape', flow_eval.shape)
img_vis = np.hstack((img1, img2))
flow_vis = np.hstack((imresize(flow2hsv(flow_gt), 1./4), flow2hsv(-flow_eval)))
plt.imshow(img_vis)
plt.pause(2)
plt.imshow(flow_vis)
plt.pause(2)


Пример #6
0
        flow = np.squeeze(
            net.flow2.eval(
                feed_dict={
                    net.inp1: np.expand_dims(I1[0][:][:][:], 0),
                    net.inp2: np.expand_dims(I2[0][:][:][:], 0),
                    net.edge: np.expand_dims(E[0][:][:][:], 0),
                }))

        print('max computed flo is', np.max(flow))
        print('does flow has nan?', np.any(np.isnan(flow)))
        plt.imshow(
            np.hstack((I1[0][:][:][:], np.repeat(E[0][:][:][:], 3, axis=2))))
        figManager = plt.get_current_fig_manager()
        figManager.window.showMaximized()
        plt.pause(1)
        print(flow2hsv(flow).shape, flow2hsv(F[0][::4][::4][:]).shape)
        plt.imshow(np.hstack((flow2hsv(flow), flow2hsv(F[0, ::4, ::4, :]))))
        figManager = plt.get_current_fig_manager()
        figManager.window.showMaximized()
        plt.pause(1)
        plt.close()

    if niter % VERBOSE == 0:
        flow_loss = np.squeeze(
            net.loss.eval(feed_dict={
                net.inp1: I1,
                net.inp2: I2,
                net.gt: F,
                net.edge: E
            }))
        # flow_loss2 = np.squeeze(net.loss2.eval(feed_dict={net.inp1: I1, net.inp2: I2, net.gt: F}))