load_url#
- deepinv.utils.load_url(url, **kwargs)[source]#
Load URL to a buffer.
This can be used as the argument for other IO functions such as
deepinv.utils.load_torch(),deepinv.utils.load_np()etc. to load data directly from a URL.Downloaded content is cached under
deepinv.utils.get_cache_home()so repeated calls for the same URL do not hit the network again. The cache layout mirrors the URL: a file fetched fromhttps://huggingface.co/datasets/deepinv/images/resolve/main/celeba_example.jpgis stored at<cache_home>/url_cache/huggingface.co/datasets/deepinv/images/resolve/main/celeba_example.jpg. Two URLs that differ only in their query string share the same cache entry — fine for the?download=truequery used by HuggingFace.The HTTP request uses a
(connect, read)timeout of(10, 60)seconds; a hung connection or stalled stream raises adeepinv.utils.DownloadErrorrather than blocking indefinitely.- Parameters:
url (str) – URL of the file to load
- Returns:
BytesIObuffer.- Raises:
deepinv.utils.DownloadError – if the file cannot be downloaded.
- Return type: