Skip to content

Commit ec8979f

Browse files
authored
Updated filename attributes for YOLOv5 Hub BytesIO (#2718)
Fix 2 for 'Model predict with forward will fail if PIL image does not have filename attribute' #2702
1 parent 74276d5 commit ec8979f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

models/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def forward(self, imgs, size=640, augment=False, profile=False):
258258
if isinstance(im, str): # filename or uri
259259
im, f = np.asarray(Image.open(requests.get(im, stream=True).raw if im.startswith('http') else im)), im
260260
elif isinstance(im, Image.Image): # PIL Image
261-
im, f = np.asarray(im), getattr(im, 'filename', f)
261+
im, f = np.asarray(im), getattr(im, 'filename', f) or f
262262
files.append(Path(f).with_suffix('.jpg').name)
263263
if im.shape[0] < 5: # image in CHW
264264
im = im.transpose((1, 2, 0)) # reverse dataloader .transpose(2, 0, 1)

0 commit comments

Comments
 (0)