0

I'm trying to read file name using python3 with keras, tensorflow-gpu. Code is here. I omitted some of the code.

imgdir_train = './trainval_Animals/train'
imgdir_test = './trainval_Animals/val'


    for eachimg in imgs:
        if eachimg[0] == '.':
            continue

        img_path = classpath+'/'+eachimg
        img = image.load_img(img_path, target_size=(224, 224))
        x = image.img_to_array(img)
        x = np.expand_dims(x, axis=0)
        x = preprocess_input(x)
        feature = model.predict(x)

        features_all[idx, :] = feature
        labels_all.append(eachclass)
        images_all.append(eachimg)
        idx += 1

Load_img does not properly fetch the file path. Error is here.

File "feature_extract.py", line 126, in <module>
    main()
  File "feature_extract.py", line 101, in main
    img = image.load_img(img_path, target_size=(224, 224))
  File "C:\Users\dunghwa\AppData\Local\Programs\Python\Python36\lib\site-packages\keras_preprocessing\image.py", line 498, in load_img
    img = pil_image.open(path)
  File "C:\Users\dunghwa\AppData\Local\Programs\Python\Python36\lib\site-packages\PIL\Image.py", line 2634, in open
    fp = builtins.open(filename, "rb")
PermissionError: [Errno 13] Permission denied: './trainval_Animals/val/A_ant'

Even if I specify the path correctly, a permission error occurs. What should I do..?

Mohan Radhakrishnan
  • 3,002
  • 5
  • 28
  • 42
김정화
  • 31
  • 1
  • 1
  • 8

0 Answers0