Update `setattr()` default for Hub PIL images (#3923)

Fix inference from PIL source.
pull/3925/head
jmiranda-laplateforme 2021-07-07 16:13:12 +02:00 committed by GitHub
parent 411842e058
commit 588094eb7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -255,7 +255,7 @@ class AutoShape(nn.Module):
im, f = Image.open(requests.get(im, stream=True).raw if im.startswith('http') else im), im
im = np.asarray(exif_transpose(im))
elif isinstance(im, Image.Image): # PIL Image
im, f = np.asarray(exif_transpose(im)), getattr(im, 'filename') or f
im, f = np.asarray(exif_transpose(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)