mdbloice / Augmentor

Image augmentation library in Python for machine learning.
https://augmentor.readthedocs.io/en/stable
MIT License
5.08k stars 866 forks source link

'FileNotFoundError' object has no attribute 'message' #227

Open haimat opened 4 years ago

haimat commented 4 years ago

I noticed that sometimes during augmentation an image file cannot be saved:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/Augmentor/Pipeline.py", line 251, in _execute
    images[i].save(os.path.join(augmentor_image.output_directory, save_name))
  File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2099, in save
    fp = builtins.open(filename, "w+b")
FileNotFoundError: [Errno 2] No such file or directory: 'MyImageFile.jpg'

But then this problem leads to another issue:

  File "/usr/local/lib/python3.8/dist-packages/Augmentor/Pipeline.py", line 370, in sample
    self._execute(augmentor_image)
  File "/usr/local/lib/python3.8/dist-packages/Augmentor/Pipeline.py", line 268, in _execute
    print("Error writing %s, %s. Change save_format to PNG?" % (file_name, e.message))
AttributeError: 'FileNotFoundError' object has no attribute 'message'

The Exception object does not have a message member. So maybe you want to change line 268 to something like this:

print(f"Error writing {file_name}, {str(e)}. Change save_format to PNG?")