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

Errors when running #213

Open enricodata opened 4 years ago

enricodata commented 4 years ago

When running the following code: import Augmentor p = Augmentor.Pipeline(path) p.rotate(probability=1, max_left_rotation=5, max_right_rotation=5) p.random_distortion(probability=1, grid_width=4, grid_height=4, magnitude=8) p.flip_left_right(probability=0.5) p.flip_top_bottom(probability=0.5) p.zoom_random(probability=0.5, percentage_area=0.8) p.sample(10000)

I get the errors below.

why is that happening?

`Processing <PIL.Image.Image image mode=RGB size=2000x1000 at 0x7F12BB48AB00>: 7%|▋ | 655/10000 [12:54<3:04:10, 1.18s/ Samples]

KeyError Traceback (most recent call last) /usr/local/lib/python3.6/dist-packages/PIL/JpegImagePlugin.py in _save(im, fp, filename) 618 try: --> 619 rawmode = RAWMODE[im.mode] 620 except KeyError:

KeyError: 'RGBA'

During handling of the above exception, another exception occurred:

OSError Traceback (most recent call last) 10 frames /usr/local/lib/python3.6/dist-packages/Augmentor/Pipeline.py in _execute(self, augmentor_image, save_to_disk, multi_threaded) 250 --> 251 images[i].save(os.path.join(augmentor_image.output_directory, save_name)) 252

/usr/local/lib/python3.6/dist-packages/PIL/Image.py in save(self, fp, format, **params) 2083 try: -> 2084 save_handler(self, fp, filename) 2085 finally:

/usr/local/lib/python3.6/dist-packages/PIL/JpegImagePlugin.py in _save(im, fp, filename) 620 except KeyError: --> 621 raise IOError("cannot write mode %s as JPEG" % im.mode) 622

OSError: cannot write mode RGBA as JPEG

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last)

in () 4 p.flip_top_bottom(probability=0.5) 5 p.zoom_random(probability=0.5, percentage_area=0.8) ----> 6 p.sample(10000) /usr/local/lib/python3.6/dist-packages/Augmentor/Pipeline.py in sample(self, n, multi_threaded) 362 with tqdm(total=len(augmentor_images), desc="Executing Pipeline", unit=" Samples") as progress_bar: 363 with ThreadPoolExecutor(max_workers=None) as executor: --> 364 for result in executor.map(self, augmentor_images): 365 progress_bar.set_description("Processing %s" % result) 366 progress_bar.update(1) /usr/lib/python3.6/concurrent/futures/_base.py in result_iterator() 584 # Careful not to keep a reference to the popped future 585 if timeout is None: --> 586 yield fs.pop().result() 587 else: 588 yield fs.pop().result(end_time - time.monotonic()) /usr/lib/python3.6/concurrent/futures/_base.py in result(self, timeout) 423 raise CancelledError() 424 elif self._state == FINISHED: --> 425 return self.__get_result() 426 427 self._condition.wait(timeout) /usr/lib/python3.6/concurrent/futures/_base.py in __get_result(self) 382 def __get_result(self): 383 if self._exception: --> 384 raise self._exception 385 else: 386 return self._result /usr/lib/python3.6/concurrent/futures/thread.py in run(self) 54 55 try: ---> 56 result = self.fn(*self.args, **self.kwargs) 57 except BaseException as exc: 58 self.future.set_exception(exc) /usr/local/lib/python3.6/dist-packages/Augmentor/Pipeline.py in __call__(self, augmentor_image) 103 :return: None 104 """ --> 105 return self._execute(augmentor_image) 106 107 def _populate(self, source_directory, output_directory, ground_truth_directory, ground_truth_output_directory): /usr/local/lib/python3.6/dist-packages/Augmentor/Pipeline.py in _execute(self, augmentor_image, save_to_disk, multi_threaded) 266 267 except IOError as e: --> 268 print("Error writing %s, %s. Change save_format to PNG?" % (file_name, e.message)) 269 print("You can change the save format using the set_save_format(save_format) function.") 270 print("By passing save_format=\"auto\", Augmentor can save in the correct format automatically.") AttributeError: 'OSError' object has no attribute 'message'`
gerchicov-bp commented 4 years ago

@enricodata The reason of this error may be an incorrect file extension. The problem is I don't know how to find this image - the log seems to be incomplete