Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------------------------------------------------
- AttributeError Traceback (most recent call last)
- /opt/conda/lib/python3.6/site-packages/PIL/Image.py in open(fp, mode)
- 2480 try:
- -> 2481 fp.seek(0)
- 2482 except (AttributeError, io.UnsupportedOperation):
- AttributeError: 'numpy.ndarray' object has no attribute 'seek'
- During handling of the above exception, another exception occurred:
- AttributeError Traceback (most recent call last)
- <ipython-input-30-365f59a42822> in <module>()
- 1 ### TODO: Test the performance of the dog_detector function
- 2 ### on the images in human_files_short and dog_files_short.
- ----> 3 dog_detector(human_files_short)
- <ipython-input-29-17d0ec8d087c> in dog_detector(img_path)
- 1 ### returns "True" if a dog is detected in the image stored at img_path
- 2 def dog_detector(img_path):
- ----> 3 prediction = ResNet50_predict_labels(img_path)
- 4 return ((prediction <= 268) & (prediction >= 151))
- <ipython-input-28-4e0ccdc559f6> in ResNet50_predict_labels(img_path)
- 3 def ResNet50_predict_labels(img_path):
- 4 # returns prediction vector for image located at img_path
- ----> 5 img = preprocess_input(path_to_tensor(img_path))
- 6 return np.argmax(ResNet50_model.predict(img))
- <ipython-input-27-3693dbe72dab> in path_to_tensor(img_path)
- 4 def path_to_tensor(img_path):
- 5 # loads RGB image as PIL.Image.Image type
- ----> 6 img = image.load_img(img_path, target_size=(224, 224))
- 7 # convert PIL.Image.Image type to 3D tensor with shape (224, 224, 3)
- 8 x = image.img_to_array(img)
- /opt/conda/lib/python3.6/site-packages/keras/preprocessing/image.py in load_img(path, grayscale, target_size, interpolation)
- 345 raise ImportError('Could not import PIL.Image. '
- 346 'The use of `array_to_img` requires PIL.')
- --> 347 img = pil_image.open(path)
- 348 if grayscale:
- 349 if img.mode != 'L':
- /opt/conda/lib/python3.6/site-packages/PIL/Image.py in open(fp, mode)
- 2481 fp.seek(0)
- 2482 except (AttributeError, io.UnsupportedOperation):
- -> 2483 fp = io.BytesIO(fp.read())
- 2484 exclusive_fp = True
- 2485
- AttributeError: 'numpy.ndarray' object has no attribute 'read'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement