Skip to content

Commit

Permalink
Fix empty paths while saving images with PIL bytes input (ultralytics…
Browse files Browse the repository at this point in the history
…#16809)

Co-authored-by: Laughing-q <[email protected]>
Co-authored-by: Laughing <[email protected]>
Co-authored-by: Glenn Jocher <[email protected]>
  • Loading branch information
4 people authored Oct 10, 2024
1 parent 3f341d5 commit df1c10f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ultralytics/data/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@ def __init__(self, im0):
"""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)
Expand Down

0 comments on commit df1c10f

Please sign in to comment.