Python 在解决对象检测部分时,我遇到了类似FileNotFoundError的错误,但我的目录中有这些文件,即使它给出了错误..为什么?

Python 在解决对象检测部分时,我遇到了类似FileNotFoundError的错误,但我的目录中有这些文件,即使它给出了错误..为什么?,python,artificial-intelligence,conv-neural-network,object-detection,Python,Artificial Intelligence,Conv Neural Network,Object Detection,在解决目标检测部分时,我得到了错误 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_i

在解决目标检测部分时,我得到了错误

 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回溯(最近一次调用上次) 在里面 1对于测试图像路径中的图像路径: ---->2图像=图像。打开(图像路径) 3#稍后将使用基于阵列的图像表示法来准备图像 4#带有方框和标签的结果图像。 5图像\u np=将图像\u加载到\u numpy\u数组(图像)

c:\programdata\anaconda3\envs\tfold\lib\site packages\PIL\Image.py处于打开状态(fp,模式) 2876 2877如果文件名: ->2878 fp=builtins.open(文件名为“rb”) 2879排他_fp=真 2880

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


但我已将该文件保存在我想保存的test_images文件夹中,甚至我已将图像保存在该特定文件夹中,因此我会出错。

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

from PIL import Image
而不是使用:

import Image
如果你还没有做过