mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-09-11 04:14:52 +00:00
raise exception on invalid images
This commit is contained in:
parent
0a63e9ab68
commit
6cb066eb01
@ -183,7 +183,12 @@ class IdeficsImageProcessor(BaseImageProcessor):
|
|||||||
elif isinstance(image_url_or_urls, str):
|
elif isinstance(image_url_or_urls, str):
|
||||||
response = requests.get(image_url_or_urls, stream=True, headers=headers)
|
response = requests.get(image_url_or_urls, stream=True, headers=headers)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
return Image.open(BytesIO(response.content))
|
try:
|
||||||
|
image = Image.open(BytesIO(response.content))
|
||||||
|
image.verify()
|
||||||
|
except Exception:
|
||||||
|
raise ValueError(f"Could not load image from url {image_url_or_urls}")
|
||||||
|
return image
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"only a single or a list of entries is supported but got type={type(image_url_or_urls)}")
|
raise ValueError(f"only a single or a list of entries is supported but got type={type(image_url_or_urls)}")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user