How can i load image from keras with local image ? can i ? because im getting error permission access denied? im trying to classification image with tensorflow from local jupyter notebook.
import numpy as np
from keras.preprocessing import image
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = image.load_img(os.getcwd()+'/tmp/test/british_cat/', target_size=(150,150))
imgplot = plt.imshow(img)
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
images = np.vstack([x])
classes = model.predict(images, batch_size=10)
# model.summary()
print(classes[0:10])
if classes[0][0]==1:
print('British Cat')
elif classes[0][1]==1:
print('Love Bird')
elif classes[0][2]==1:
print('Koi Fish')
else:
print('error')
the error is :
---------------------------------------------------------------------------
PermissionError Traceback (most recent call last)
<ipython-input-49-7b705ffefd08> in <module>
6
7
----> 8 img = image.load_img(os.getcwd()+'/tmp/test/british_cat/', target_size=(150,150))
9 imgplot = plt.imshow(img)
10 x = image.img_to_array(img)
~\miniconda3\envs\myenv\lib\site-packages\tensorflow\python\keras\preprocessing\image.py in load_img(path, grayscale, color_mode, target_size, interpolation)
298 ValueError: if interpolation method is not supported.
299 """
--> 300 return image.load_img(path, grayscale=grayscale, color_mode=color_mode,
301 target_size=target_size, interpolation=interpolation)
302
~\miniconda3\envs\myenv\lib\site-packages\keras_preprocessing\image\utils.py in load_img(path, grayscale, color_mode, target_size, interpolation)
111 raise ImportError('Could not import PIL.Image. '
112 'The use of `load_img` requires PIL.')
--> 113 with open(path, 'rb') as f:
114 img = pil_image.open(io.BytesIO(f.read()))
115 if color_mode == 'grayscale':
PermissionError: [Errno 13] Permission denied: 'c:\\Users\\AZHAR IE\\Documents\\project\\webscraping google\\Google-Image-Scraper-master/tmp/test/british_cat/