Created
October 15, 2017 18:19
-
-
Save Goddard/18a6f891b6b98c937e776bff4761f957 to your computer and use it in GitHub Desktop.
function from helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gen_test_video(sess, logits, keep_prob, input_image, clip, image_shape): #test_image | |
# image = scipy.misc.imresize(scipy.misc.imread(test_image), image_shape) | |
image = clip | |
im_softmax = sess.run( | |
[tf.nn.softmax(logits)], | |
{keep_prob: 1.0, input_image: [image]}) | |
im_softmax = im_softmax[0][:, 1].reshape(image_shape[0], image_shape[1]) | |
segmentation = (im_softmax > 0.5).reshape(image_shape[0], image_shape[1], 1) | |
mask = np.dot(segmentation, np.array([[0, 255, 0, 127]])) | |
mask = scipy.misc.toimage(mask, mode="RGBA") | |
street_im = scipy.misc.toimage(image) | |
street_im.paste(mask, box=None, mask=mask) | |
return np.array(street_im) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment