Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion auto_round/compressors/mllm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ def fetch_image(path_or_url):
if os.path.isfile(path_or_url):
image_obj = Image.open(path_or_url)
elif path_or_url.startswith("http://") or path_or_url.startswith("https://"):
image_obj = Image.open(requests.get(path_or_url, stream=True).raw)
try:
response = requests.get(path_or_url, stream=True, timeout=(3, 10))
response.raise_for_status()
image_obj = Image.open(response.raw)
except (requests.exceptions.RequestException, OSError) as e:
raise RuntimeError(f"Failed to fetch image from url: {path_or_url}") from e
else:
raise TypeError(f"{path_or_url} neither a path or url.")

Expand Down