Skip to content

Instantly share code, notes, and snippets.

@Goddard Goddard/helper.py
Created Oct 15, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.