我在解决对象检测部分时遇到了类似FileNotFoundError的错误,但我的目录中有这些文件,甚至它给出了一个错误.



在解决对象检测部分时,我遇到了错误。

for image_path in TEST_IMAGE_PATHS:
image = Image.open(image_path)
# 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)
# 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)

得到类似的错误

FileNotFoundError追溯(最近一次调用为最后一次(在里面TEST_image_PATHS中的image_path为1:---->2 image=图像.open(image_path(3#稍后将使用基于阵列的图像表示,以便准备4#结果图像,上面有方框和标签。5 image_np=load_image_into_numpy_array(图像(

c: \programdata\anaconda3\envs\tfold\lib\site packages\PIL\Image.py处于打开状态(fp,mode(28762877如果文件名:->2878fp=builtins.open(文件名,"rb"(2879 exclusive_fp=真2880

FileNotFoundError:[Erno 2]没有这样的文件或目录:"C:\Users/Microsoft/Desktop/My Folder/models-1.13.0/research/test_images/image1.jpg">

但我把文件放在了我想要的test_images文件夹中——即使我把图像放在了那个特定的文件夹中——为什么我会出错。

我不确定它是否能解决你的问题,但我可以建议你使用:

from PIL import Image

代替使用:

import Image

如果你还没有做的话。

相关内容

最新更新