简体   繁体   English

Tensorflow 在 Object 检测 session 运行中抛出“TypeError: unhashable type: 'list'”错误

[英]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当我运行 sess.run 时出现错误

--------------------------------------------------------------------------- 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 Traceback (最近一次调用最后一次) 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'类型错误:不可散列类型:“列表”

In this situation the _input is a list.在这种情况下,_input 是一个列表。 So the sess.run should have _input[0]所以 sess.run 应该有 _input[0]

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM