Matankl commited on
Commit
e92dcd6
1 Parent(s): f57cfbd

Update visual.py

Browse files

The BytesIO read implementation is much more robust.

Files changed (1) hide show
  1. visual.py +1 -1
visual.py CHANGED
@@ -417,7 +417,7 @@ class VisionTransformer(nn.Module):
417
  images = []
418
  for image_path in image_paths:
419
  if image_path.startswith("http://") or image_path.startswith("https://"):
420
- image = Image.open(requests.get(image_path, stream=True).raw)
421
  else:
422
  image = Image.open(image_path)
423
  image = image.convert("RGB")
 
417
  images = []
418
  for image_path in image_paths:
419
  if image_path.startswith("http://") or image_path.startswith("https://"):
420
+ image= Image.open(BytesIO(requests.get(image_path).content))
421
  else:
422
  image = Image.open(image_path)
423
  image = image.convert("RGB")