2626from numpy .linalg import norm
2727from packaging import version
2828
29+ from .constants import DIFFUSERS_REQUEST_TIMEOUT
2930from .import_utils import (
3031 BACKENDS_MAPPING ,
3132 is_accelerate_available ,
@@ -594,7 +595,7 @@ def load_numpy(arry: Union[str, np.ndarray], local_path: Optional[str] = None) -
594595 # local_path can be passed to correct images of tests
595596 return Path (local_path , arry .split ("/" )[- 5 ], arry .split ("/" )[- 2 ], arry .split ("/" )[- 1 ]).as_posix ()
596597 elif arry .startswith ("http://" ) or arry .startswith ("https://" ):
597- response = requests .get (arry )
598+ response = requests .get (arry , timeout = DIFFUSERS_REQUEST_TIMEOUT )
598599 response .raise_for_status ()
599600 arry = np .load (BytesIO (response .content ))
600601 elif os .path .isfile (arry ):
@@ -615,7 +616,7 @@ def load_numpy(arry: Union[str, np.ndarray], local_path: Optional[str] = None) -
615616
616617
617618def load_pt (url : str , map_location : str ):
618- response = requests .get (url )
619+ response = requests .get (url , timeout = DIFFUSERS_REQUEST_TIMEOUT )
619620 response .raise_for_status ()
620621 arry = torch .load (BytesIO (response .content ), map_location = map_location )
621622 return arry
@@ -634,7 +635,7 @@ def load_image(image: Union[str, PIL.Image.Image]) -> PIL.Image.Image:
634635 """
635636 if isinstance (image , str ):
636637 if image .startswith ("http://" ) or image .startswith ("https://" ):
637- image = PIL .Image .open (requests .get (image , stream = True ).raw )
638+ image = PIL .Image .open (requests .get (image , stream = True , timeout = DIFFUSERS_REQUEST_TIMEOUT ).raw )
638639 elif os .path .isfile (image ):
639640 image = PIL .Image .open (image )
640641 else :
0 commit comments