Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sobel_x = tf.constant([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]], tf.float32)
- sobel_x_filter = tf.reshape(sobel_x, [1, 3, 3, 3, 3]) # here it crashes
- import numpy as np
- import tensorflow as tf
- import matplotlib.pyplot as plt
- im0 = plt.imread('../../data/im0.png') # already divided by 255
- sobel_x = tf.constant([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]], tf.float32)
- sobel_x_filter = tf.reshape(sobel_x, [1, 3, 3, 3, 3])
- image = tf.placeholder(tf.float32, shape=[496, 718, 3])
- image_resized = tf.expand_dims(tf.expand_dims(image, 0), 0)
- filters_x = tf.nn.conv3d(image_resized, filter=sobel_x_filter, strides=[1,1,1,1,1],
- padding='SAME', data_format='NDHWC')
- with tf.Session('') as sess:
- sess.run([tf.global_variables_initializer(), tf.local_variables_initializer()])
- coord = tf.train.Coordinator()
- threads = tf.train.start_queue_runners(sess=sess, coord=coord)
- feed_dict = {image: im0}
- img = filters_x.eval(feed_dict=feed_dict)
- plt.figure(0), plt.title('red'), plt.imshow(np.squeeze(img[...,0])),
- plt.figure(1), plt.title('green'), plt.imshow(np.squeeze(img[...,1])),
- plt.figure(2), plt.title('blue'), plt.imshow(np.squeeze(img[...,2]))
Add Comment
Please, Sign In to add comment