Shortcuts

加载图片

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

从本地文件路径或远程源加载PIL格式图像的便捷方法。

Parameters:

image_loc (Union[Path, str]) – 本地文件路径或指向图像的远程源,该图像将以PIL格式加载。

注意

如果从远程源加载图像,该函数期望在image_loc中提供的URL以“http”或“https”开头,例如“https://www.wikipedia.org/en/bird.jpg”。

Raises:

示例

>>> # 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:

加载的图像。

Return type:

PIL.Image.Image