简体   繁体   中英

IsADirectoryError: [Errno 21] Is a directory: '/'

I am trying to use Images stored inside the directory by using this code,

import random

path = "/content/drive/MyDrive/Colab Notebooks/Low Images/*.png"
low_light_images = glob(path)
for image_path in random.choice(low_light_images):
    original_image, output_image = inferer.infer(image_path)
    plot_result(original_image, output_image)

But getting this error,

---------------------------------------------------------------------------
IsADirectoryError                         Traceback (most recent call last)
<ipython-input-62-668719a88426> in <module>()
      4 low_light_images = glob(path)
      5 for image_path in random.choice(low_light_images):
----> 6     original_image, output_image = inferer.infer(image_path)
      7     plot_result(original_image, output_image)

1 frames
/usr/local/lib/python3.7/dist-packages/PIL/Image.py in open(fp, mode)
   2841 
   2842     if filename:
-> 2843         fp = builtins.open(filename, "rb")
   2844         exclusive_fp = True
   2845 

IsADirectoryError: [Errno 21] Is a directory: '/'

How can I resolve this? Full Code Link: here

The line

for image_path in random.choice(low_light_images):

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM