Skip to content

Instantly share code, notes, and snippets.

@Goddard
Created October 15, 2017 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Goddard/18a6f891b6b98c937e776bff4761f957 to your computer and use it in GitHub Desktop.
Save Goddard/18a6f891b6b98c937e776bff4761f957 to your computer and use it in GitHub Desktop.
function from helper
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