cerebras.modelzoo.data_preparation.data_preprocessing.custom_hook_examples.custom_hooks.fetch_single_image#
- cerebras.modelzoo.data_preparation.data_preprocessing.custom_hook_examples.custom_hooks.fetch_single_image(image_url, timeout=10, retries=0)[source]#
Fetches an image from the provided URL.
- Parameters
image_url (str) – The URL of the image to download.
timeout (int, optional) – The maximum time in seconds to wait for the download to complete. Default is 10 seconds.
retries (int, optional) – The number of times to retry downloading the image in case of failure. Default is 0.
- Returns
The downloaded image as a PIL Image object, or None if the download failed.
- Return type
Optional[Image.Image]