Getting a classification on a croped image from tensorflow with inceptionV3 Model

96 Views Asked by At

I have a pretrained CocoModel from Tensorflow OD, and retrained it on a kitti dataset.

I just wanted to try a classification on a croped Image, but there is no clear documentation what er the names of the tensors. When I tried to use the classify script by Tensorflow, it says that there are no Tensors named like this in the inceptionV3 model.

Is there anyone that has already tried it and know the name of the tensors?

The Result should be a list of possible labels/classes with their scores!

Thanks in advance for your help

Hi! thank you for the fast reply.

To get a overview:

  1. I have used a pertained model from MSCOCO for object detection
  2. I have trained the model on a KITTI Dataset with 100 Images
  3. I have exported the inference_graph an classified the other images.
  4. I provided a Labeling tool for Users to get the Machinelabeled Images and correct them. As a feature I wanted to implement :

a) Drawing own bounding boxes and Label them (works fine with Canvas and Angular)

b) Send this cropped Bounding Box to my server and get Class Suggestions from my model => here is the problem !!! I need the names of the tensor to do a classification.

I tried to rewrite a own of tensorflows classify_image.py https://github.com/tensorflow/models/blob/master/tutorials/image/imagenet/classify_image.py

1

There are 1 best solutions below

0
On

If your question is only about tensor name , this snippet could help,

ops = tf.get_default_graph().get_operations()
all_tensor_names = {output.name for op in ops for output in op.outputs}
tensor_dict = {}
for key in [
                'num_detections', 'detection_boxes', 'detection_scores',
                'detection_classes', 'detection_masks'
            ]:
tensor_name = key + ':0'
if tensor_name in all_tensor_names:
    tensor_dict[key] = tf.get_default_graph().get_tensor_by_name(
                        tensor_name)

working sample code here, https://github.com/dennywangtenk/balder/blob/master/Samples/test_pk_v1.py