Tensorflow在对象检测会话运行时抛出“TypeError:Unhabable type:'list'”错误

2024-05-16 21:35:18 发布

您现在位置:Python中文网/ 问答频道 /正文

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})

当我运行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: unhashable type: 'list'


Tags: nameimageimportinputoutputnpclassesgraph