Skip to content

Commit

Permalink
Updated filename attributes for YOLOv5 Hub BytesIO (ultralytics#2718)
Browse files Browse the repository at this point in the history
Fix 2 for 'Model predict with forward will fail if PIL image does not have filename attribute' ultralytics#2702

(cherry picked from commit ec8979f)
  • Loading branch information
glenn-jocher authored and Lechtr committed Apr 12, 2021
1 parent 46c7f27 commit e1f2009
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion models/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def forward(self, imgs, size=640, augment=False, profile=False):
if isinstance(im, str): # filename or uri
im, f = np.asarray(Image.open(requests.get(im, stream=True).raw if im.startswith('http') else im)), im
elif isinstance(im, Image.Image): # PIL Image
im, f = np.asarray(im), getattr(im, 'filename', f)
im, f = np.asarray(im), getattr(im, 'filename', f) or f
files.append(Path(f).with_suffix('.jpg').name)
if im.shape[0] < 5: # image in CHW
im = im.transpose((1, 2, 0)) # reverse dataloader .transpose(2, 0, 1)
Expand Down

0 comments on commit e1f2009

Please sign in to comment.