下面是来自 .ipynb 文件的代码片段。
for image_path in TEST_IMAGE_PATHS:
print(image_path)
image = Image.open(image_path)
print('yooo')
# the array based representation of the image will be used later in order to prepare the
# result image with boxes and labels on it.
image_np = load_image_into_numpy_array(image)
print(image_np)
# Expand dimensions since the model expects images to have shape: [1, None, None, 3]
image_np_expanded = np.expand_dims(image_np, axis=0)
# Actual detection.
output_dict = run_inference_for_single_image(image_np, detection_graph)
# Visualization of the results of a detection.
vis_util.visualize_boxes_and_labels_on_image_array(
image_np,
output_dict['detection_boxes'],
output_dict['detection_classes'],
output_dict['detection_scores'],
category_index,
instance_masks=output_dict.get('detection_masks'),
use_normalized_coordinates=True,
line_thickness=8)
plt.figure(figsize=IMAGE_SIZE)
plt.imshow(image_np)
我正在尝试在图像数据集上测试我的模型的准确性。从上面的代码我得到以下错误
ValueError Traceback (most recent call last)
<ipython-input-30-ee1cf025b3f1> in <module>
6 # the array based representation of the image will be used later in order to prepare the
7 # result image with boxes and labels on it.
----> 8 image_np = load_image_into_numpy_array(image)
9 print('yooo')
10 print(image_np)
<ipython-input-15-af094dcdd84a> in load_image_into_numpy_array(image)
2 (im_width, im_height) = image.size
3 return np.array(image.getdata()).reshape(
----> 4 (im_height, im_width, 3)).astype(np.uint8)
ValueError: cannot reshape array of size 1048576 into shape (1024,1024,3)
有人可以帮我解决这个错误吗?