PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度
Security: HTTP requests are performed without timeout safeguards (#1683)
tomaioofbff41736543
diff --git a/auto_round/compressors/mllm/utils.py b/auto_round/compressors/mllm/utils.pyindex 706fbdbcd..32d8862b9 100644--- a/auto_round/compressors/mllm/utils.py+++ b/auto_round/compressors/mllm/utils.py@@ -58,7 +58,13 @@ 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()+ response.raw.decode_content = True+ 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 eelse:raise TypeError(f"{path_or_url} neither a path or url.")