tensorflow / tensorflow/models
Mask RCNN predicted class values and logits do not match
@pkulzc is already working on this.
Since Jun 19, 2020.
- Dominant language
- Python
- Stars
- 77.7k
- Forks
- 44.8k
- PR merge metrics
- No merged PRs in 30d
Description
System information
- What is the top-level directory of the model you are using: mask_rcnn_inception_v2_coco_2018_01_28
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 18.10
- TensorFlow installed from (source or binary): Binary
- TensorFlow version (use command below): 1.13.1
- Bazel version (if compiling from source): N/A
- CUDA/cuDNN version: N/A
- GPU model and memory: N/A
- Exact command to reproduce:
Describe the problem
I am using the "mask_rcnn_inception_v2_coco_2018_01_28" model downloaded from Zoo model (https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md).
I am trying to access the tensors that are holding the logits for each class for the image that is fed to the model. I found out that SecondStageBoxPredictor/Reshape_1 is holding those values, however when comparing them with detection_classes, I realized that the values do not match. I want to first find out where are the correct logits and then document this as it is useful to have these documented correctly.
Code
with tf.Session(graph=tf.Graph()) as sess:
tf.saved_model.loader.load(sess, ['serve'], GRAPH_PB_PATH)
graph = tf.get_default_graph()
image = Image.open(IMAGE_PATH)
(im_width, im_height) = image.size
image_np = np.array(image.getdata()).reshape((im_height, im_width, 3)).astype(np.uint8)
image_np_expanded = np.expand_dims(image_np, axis=0)
image_tensor = tf.get_default_graph().get_tensor_by_name('image_tensor:0')
tensor_dict = {}
tensor_dict['SecondStageBoxPredictor/Reshape_1:0'] = graph.get_tensor_by_name('SecondStageBoxPredictor/Reshape_1:0')
tensor_dict['detection_classes:0'] = graph.get_tensor_by_name('detection_classes:0')
output_dict = sess.run(tensor_dict,
feed_dict={image_tensor: image_np_expanded})
If you compare the values like the following, they do not match:
logits = []
for i in range(0, 92):
logits.append(np.argmax(output_dict['SecondStageBoxPredictor/Reshape_1:0'][i]))
print(logits)
print(output_dict['detection_classes:0'])
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.