You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
can anybody help ton this issue please.
while calling the function in the python code as:
cat_counter = get_car_categories()
the called function definition is as follows:
def get_car_categories():
d = defaultdict(float)
img_list = os.listdir('data0')
for i, img_path in enumerate(img_list):
path = 'data0/'+img_path
img = prepare_image(path)
out = vgg16.predict(img)
top = get_predictions(out, top=5)
for j in top[0]:
d[j[0:2]] += j[2]
if i % 50 == 0:
print i, '/', len(img_list), 'complete'
return Counter(d)
in get_car_categories()
4 for i, img_path in enumerate(img_list):
5 path = 'data0/'+img_path
----> 6 img = prepare_image(path)
7 out = vgg16.predict(img)
8 top = get_predictions(out, top=5)
in prepare_image(img_path)
1 def prepare_image(img_path):
----> 2 img = load_img(img_path, target_size=(224, 224))
3 x = img_to_array(img)
4 x = np.expand_dims(x, axis=0)
5 x = preprocess_input(x)
/usr/local/lib/python2.7/dist-packages/keras/preprocessing/image.pyc in load_img(path, grayscale, target_size)
294 raise ImportError('Could not import PIL.Image. '
295 'The use of array_to_img requires PIL.')
--> 296 img = pil_image.open(path)
297 if grayscale:
298 img = img.convert('L')
can anybody help ton this issue please.
while calling the function in the python code as:
cat_counter = get_car_categories()
the called function definition is as follows:
def get_car_categories():
d = defaultdict(float)
img_list = os.listdir('data0')
for i, img_path in enumerate(img_list):
path = 'data0/'+img_path
img = prepare_image(path)
out = vgg16.predict(img)
top = get_predictions(out, top=5)
for j in top[0]:
d[j[0:2]] += j[2]
if i % 50 == 0:
print i, '/', len(img_list), 'complete'
return Counter(d)
I am getting error as follows:
IOError Traceback (most recent call last)
in ()
----> 1 cat_counter = get_car_categories()
in get_car_categories()
4 for i, img_path in enumerate(img_list):
5 path = 'data0/'+img_path
----> 6 img = prepare_image(path)
7 out = vgg16.predict(img)
8 top = get_predictions(out, top=5)
in prepare_image(img_path)
1 def prepare_image(img_path):
----> 2 img = load_img(img_path, target_size=(224, 224))
3 x = img_to_array(img)
4 x = np.expand_dims(x, axis=0)
5 x = preprocess_input(x)
/usr/local/lib/python2.7/dist-packages/keras/preprocessing/image.pyc in load_img(path, grayscale, target_size)
294 raise ImportError('Could not import PIL.Image. '
295 'The use of
array_to_img
requires PIL.')--> 296 img = pil_image.open(path)
297 if grayscale:
298 img = img.convert('L')
/usr/lib/python2.7/dist-packages/PIL/Image.pyc in open(fp, mode)
1994 if isPath(fp):
1995 filename = fp
-> 1996 fp = builtins.open(fp, "rb")
1997 else:
1998 filename = ""
IOError: [Errno 21] Is a directory: 'data0/.ipynb_checkpoints'
The text was updated successfully, but these errors were encountered: