Fix empty paths while saving images with PIL bytes input (#16809)

Co-authored-by: Laughing-q <1185102784@qq.com>
Co-authored-by: Laughing <61612323+Laughing-q@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
pull/16825/head^2
SheffeyG 2 months ago committed by GitHub
parent 3f341d5dd3
commit df1c10f002
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      ultralytics/data/loaders.py

@ -409,7 +409,8 @@ class LoadPilAndNumpy:
"""Initialize PIL and Numpy Dataloader."""
if not isinstance(im0, list):
im0 = [im0]
self.paths = [getattr(im, "filename", f"image{i}.jpg") for i, im in enumerate(im0)]
# use `image{i}.jpg` when Image.filename returns an empty path.
self.paths = [getattr(im, "filename", "") or f"image{i}.jpg" for i, im in enumerate(im0)]
self.im0 = [self._single_check(im) for im in im0]
self.mode = "image"
self.bs = len(self.im0)

Loading…
Cancel
Save