Closed Zumbalamambo closed 6 years ago
I am not sure if this is what you want but have a look at inference_webcam.py : https://github.com/salehjg/tensorflow-deeplab-resnet/blob/master/inference_webcam.py
while True:
preds = sess.run(pred,feed_dict={img_input:frame})
msk = decode_labels(preds, num_classes=args.num_classes)
im = Image.fromarray(msk[0])
open_cv_image = np.array(im)
# Convert RGB to BGR
open_cv_image = open_cv_image[:, :, ::-1].copy()
cv2.imshow("SemanticSegmentation", open_cv_image)
cv2.imshow("preview", frame)
rval, frame = vc.read()
if cv2.waitKey(1) & 0xFF == ord('q'):
break
@salehjg wow awesome... thank you so much... may I know how do I increase the shape of input because if I increase the input shape, it is crashing...
@salehjg many thanks for working solution. @Zumbalamambo I made a workaround with
pic = pic.resize((IMAGE_WIDTH, IMAGE_HEIGTH), Image.BILINEAR)
or
img = tf.image.resize_bilinear(tf.expand_dims(img, dim=0), [IMAGE_HEIGTH, IMAGE_WIDTH])
Beware that resizing may cost you accuracy! e.g.: @DrSleep by the way) I would say great thanks for really awesome project!! Wish you good luck with your topic.
you can create a placeholder for the image, build the model and then feed a new image into the placeholder at each iteration as done in the training scripts.
Im using the following code to do the segmentation,
Over here, each and everytime when I change the image, I need to reinitialise the model. Is there by any means that I can initialise the model once and do prediction on the fly by varying images?