我尝试了使用 inceptionv3 train pb 文件的“object_detection”教程,但我遇到了以下错误:
ValueError Traceback (most recent call last)
<ipython-input-41-1cfc370a11f2> in <module>()
8 image_np_expanded = np.expand_dims(image_np, axis=0)
9 # Actual detection.
---> 10 output_dict = run_inference_for_single_image(image_np, detection_graph)
11 # Visualization of the results of a detection.
12 vis_util.visualize_boxes_and_labels_on_image_array(
<ipython-input-38-7704143af1b0> in run_inference_for_single_image(image, graph)
33 # Run inference
34 output_dict = sess.run(tensor_dict,
---> 35 feed_dict={ResizeBilinear: np.expand_dims(image, 0)})
36
37 # all outputs are float32 numpy arrays, so convert types as appropriate
~/anaconda3/lib/python3.6/site-
packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
893 try:
894 result = self._run(None, fetches, feed_dict, options_ptr,
--> 895 run_metadata_ptr)
896 if run_metadata:
897 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
~/anaconda3/lib/python3.6/site-
packages/tensorflow/python/client/session.py in _run(self, handle,
fetches, feed_dict, options, run_metadata)
1102 'Cannot feed value of shape %r for Tensor %r, '
1103 'which has shape %r'
-> 1104 % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
1105 if not self.graph.is_feedable(subfeed_t):
1106 raise ValueError('Tensor %s may not be fed.' % subfeed_t)
ValueError: Cannot feed value of shape (1, 26, 38, 3) for Tensor 'ResizeBilinear:0', which has shape '(1, 299, 299, 3)'
因此,我尝试使用下面的代码来调整图像大小:
image = array(img).reshape(1, 299,299,3)
但是图像仍然无法传递给resizeBilinear
张量。
我刚刚更改了这段代码:
#MODEL_NAME = 'ssd_mobilenet_v1_coco_2017_11_17'
#MODEL_FILE = MODEL_NAME + '.tar.gz'
#DOWNLOAD_BASE ='http://download.tensorflow.org/models/object_detection/'
#upper code is origin model preparation
PATH_TO_CKPT = /tmp/output_graph.pb
PATH_TO_LABELS = /tmp/output_labels.txt
NUM_CLASSES = 2
我该如何解决这个错误?谢谢您的帮助!