Advertisement
Guest User

Untitled

a guest
May 27th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. ---------------------------------------------------------------------------
  2. AttributeError Traceback (most recent call last)
  3. /opt/conda/lib/python3.6/site-packages/PIL/Image.py in open(fp, mode)
  4. 2480 try:
  5. -> 2481 fp.seek(0)
  6. 2482 except (AttributeError, io.UnsupportedOperation):
  7.  
  8. AttributeError: 'numpy.ndarray' object has no attribute 'seek'
  9.  
  10. During handling of the above exception, another exception occurred:
  11.  
  12. AttributeError Traceback (most recent call last)
  13. <ipython-input-30-365f59a42822> in <module>()
  14. 1 ### TODO: Test the performance of the dog_detector function
  15. 2 ### on the images in human_files_short and dog_files_short.
  16. ----> 3 dog_detector(human_files_short)
  17.  
  18. <ipython-input-29-17d0ec8d087c> in dog_detector(img_path)
  19. 1 ### returns "True" if a dog is detected in the image stored at img_path
  20. 2 def dog_detector(img_path):
  21. ----> 3 prediction = ResNet50_predict_labels(img_path)
  22. 4 return ((prediction <= 268) & (prediction >= 151))
  23.  
  24. <ipython-input-28-4e0ccdc559f6> in ResNet50_predict_labels(img_path)
  25. 3 def ResNet50_predict_labels(img_path):
  26. 4 # returns prediction vector for image located at img_path
  27. ----> 5 img = preprocess_input(path_to_tensor(img_path))
  28. 6 return np.argmax(ResNet50_model.predict(img))
  29.  
  30. <ipython-input-27-3693dbe72dab> in path_to_tensor(img_path)
  31. 4 def path_to_tensor(img_path):
  32. 5 # loads RGB image as PIL.Image.Image type
  33. ----> 6 img = image.load_img(img_path, target_size=(224, 224))
  34. 7 # convert PIL.Image.Image type to 3D tensor with shape (224, 224, 3)
  35. 8 x = image.img_to_array(img)
  36.  
  37. /opt/conda/lib/python3.6/site-packages/keras/preprocessing/image.py in load_img(path, grayscale, target_size, interpolation)
  38. 345 raise ImportError('Could not import PIL.Image. '
  39. 346 'The use of `array_to_img` requires PIL.')
  40. --> 347 img = pil_image.open(path)
  41. 348 if grayscale:
  42. 349 if img.mode != 'L':
  43.  
  44. /opt/conda/lib/python3.6/site-packages/PIL/Image.py in open(fp, mode)
  45. 2481 fp.seek(0)
  46. 2482 except (AttributeError, io.UnsupportedOperation):
  47. -> 2483 fp = io.BytesIO(fp.read())
  48. 2484 exclusive_fp = True
  49. 2485
  50.  
  51. AttributeError: 'numpy.ndarray' object has no attribute 'read'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement