TensorFlow-Object-Detection-on-the-Raspberry-Pi icon indicating copy to clipboard operation
TensorFlow-Object-Detection-on-the-Raspberry-Pi copied to clipboard

'image_tensor' not existing in the graph

Open RobotGrrl opened this issue 7 years ago • 1 comments
trafficstars

Hi Edje!

Trying to use a custom model, but I'm receiving an error about 'image_tensor' not existing in the graph.

KeyError: "The name 'image_tensor:0' refers to a Tensor which does not exist. The operation, 'image_tensor', does not exist in the graph."

Full console output here

I trained the model following Google's TensorFlow for Poets tutorial. The output was a .pb for the graph and a .txt with the labels. It didn't have the labels formatted the same way yours did, so manually edited it in.

Do you think something else might be missing from the retraining?

Any help would be much appreciated! Your example worked GREAT, now it's just to add in the custom model!

Thank you, -RobotGrrl

RobotGrrl avatar Sep 04 '18 03:09 RobotGrrl

Hi @RobotGrrl,

The TensorFlow for Poets tutorial trains an image classification model rather than an object detection model. The difference is that an object detection model can locate and identify multiple objects in an image (and draw a box around them), while a classifier just looks at an image and makes a single identification of the image. Classifiers can't be used to detect multiple objects in an image.

The models I used for this tutorial are object detection models, and all the tools are from the Object Detection module (i.e. everything inside the models/research/object_detection folder), so the .pb and .txt files from the TensorFlow for Poets tutorials won't work. However, I think you can use your classification model with the "classify_image.py" script inside the /tensorflow1/tutorials/image/imagenet folder.

Try issuing:

python /tensorflow1/tutorials/image/imagenet classify_image.py --model_dir=<path to wherever your .pb and .txt files are> --image_file=<path to the image you want to test>

It should return a label for the image (you can see an example at 15:20 in this video: https://youtu.be/WqCnW_2XDw8?t=15m20s ). I'm not sure how to work that into it's own program though (where you do something like classify the image and then perform an action if it's a certain object)!

Can you let me know if this works?

Alternatively, you can look at my GitHub guide for training your own object detection model here.

EdjeElectronics avatar Sep 08 '18 17:09 EdjeElectronics