Shortcuts

load_image

torchtune.data.load_image(image_loc: Union[Path, str]) PIL.Image.Image[source]

Convenience method to load an image in PIL format from a local file path or remote source.

Parameters:

image_loc (Union[Path, str]) – Local file path or remote source pointing to the image which will be loaded in PIL format.

Note

If loading an image from a remote source, the function expects the URL provided in image_loc to start with “http” or “https” e.g. “https://www.wikipedia.org/en/bird.jpg”.

Raises:

Examples

>>> # Load from remote source
>>> image = load_image("https://www.wikipedia.org/en/bird.jpg")
>>> # Load from local file path
>>> image = load_image(Path("/home/user/bird.jpg"))
Returns:

The loaded image.

Return type:

PIL.Image.Image

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources