Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
475 views
in Technique[技术] by (71.8m points)

python - Tensorflow throws “TypeError: unhashable type: 'list'” error in Object detection session run

input_tensors=["import/image_tensor:0"],
output_tensors=['import/detection_boxes:0', 'import/detection_scores:0',
                        'import/detection_classes:0', 'import/num_detections:0']

_input = [graph.get_tensor_by_name(tensor_name) for tensor_name in input_tensors]
_output_ops = [graph.get_tensor_by_name(tensor_name) for tensor_name in output_tensors]
sess = tf.Session(graph=graph, config=_config_proto)

image_expanded = np array of size specific to model (1, 512, 512, 1)

(boxes, scores, classes, num_detections) = sess.run(self._output_ops, feed_dict={_input: image_expanded})

When I run the sess.run I got the error

--------------------------------------------------------------------------- TypeError Traceback (most recent call last) in 3 image_np = load_image_into_numpy_array(image) 4 image_np_expanded = np.expand_dims(image_np, axis=0) ----> 5 (boxes, scores, classes, num_detections) = sess.run(_output_ops, feed_dict={_input: image_np_expanded}) 6 print(boxes) 7 break

TypeError: unhashable type: 'list'


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In this situation the _input is a list. So the sess.run should have _input[0]

(boxes, scores, classes, num_detections) = sess.run(self._output_ops, feed_dict={_input[0]: image_expanded})

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...