tensorflow测试模型(批量测试图片)时报错:第二次循环sess.run时报错
for filename in os.listdir(TEST_IMAGE_DIR):
image_path = os.path.join(TEST_IMAGE_DIR, filename)
start = time.time()
image_data = cv2.imread(image_path)
img_RGB = image_data[..., [2, 1, 0]]
image_data = cv2.resize(img_RGB, (w, h))
image_np = np.array(image_data).astype(np.uint8)
image_np_expanded = np.expand_dims(image_np, axis=0)
(boxes, scores, classes,num_detections) = sess.run([boxes, scores, classes, num_detections], feed_dict={detect_image_tensor: image_np_expanded})
错误如下:
TypeError: Fetch argument array has invalid type <type 'numpy.ndarry'>, must be a string or Tensor. (Can not convert a int into a Tensor or Operation.)
原因:
变量名重名
解决方法:
####更改变量名
(detection_boxes, detection_scores, detection_classes, detection_num_detections) = sess.run([boxes, scores, classes, num_detections], feed_dict={detect_image_tensor: image_np_expanded})