如何解决解决对象检测部分时出现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,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 Traceback(最近一次通话) 在 TEST_IMAGE_PATHS中的image_path为1: ----> 2个图像= Image.open(image_path) 3#稍后将使用基于数组的图像表示形式来准备图像 4#结果图像上带有框和标签。 5个image_np = load_image_into_numpy_array(image)
c:\ programdata \ anaconda3 \ envs \ tfold \ lib \ site-packages \ PIL \ Image.py处于打开状态(fp,模式) 2876 2877如果文件名: -> 2878 fp = Builtins.open(文件名,“ rb”) 2879 Exclusive_fp =真 2880
FileNotFoundError:[错误2]没有此类文件或目录:'C:/ Users / Microsoft / Desktop / My Folder / models-1.13.0 / research / test_images / image1.jpg'
但是我将文件保存在那个test_images文件夹中,我什至希望将图像保存在那个特定的文件夹中,为什么会出现错误。
解决方法
我不确定是否能解决您的问题,但我建议您使用:
from PIL import Image
代替使用:
import Image
如果您还没有完成的话。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。