[Solved] Tensorflow TypeError: Fetch argument array has invalid type ‘numpy.ndarry’

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

The error is as follows:

TypeError: Fetch argument array has invalid type <type’numpy.ndarry ‘ >, must be a string or Tensor. (Can not convert an int into a Tensor or Operation.)
the reason:

Variable name has the same name

Solution:

####Change Variable name
(detection_boxes, detection_scores, detection_classes, detection_num_detections) = sess.run([boxes, scores, classes, num_detections], feed_dict={detect_image_tensor: image_np_expanded})

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *