如何打开和显示github存储库中的图像

2024-09-29 00:20:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经创建了一个包含一些图像的公共存储库。如何打开并显示它们?我在猜测pyplot的用法。以下是我尝试过的:

from PIL import Image
image = Image.open('https://github.com/TeoOG/Computer_Vision_Assistance/blob/master/images/image1.jpg')
image.show()

这里还有我的存储库链接: https://github.com/TeoOG/Computer_Vision_Assistance


Tags: fromhttps图像imageimportgithubcom用法
1条回答
网友
1楼 · 发布于 2024-09-29 00:20:02

好了,完成了:

from PIL import Image
import requests
from io import BytesIO

url = 'https://raw.githubusercontent.com/TeoOG/Computer_Vision_Assistance/master/images/image1.jpg'

response = requests.get(url)
img = Image.open(BytesIO(response.content))


img.show()

相关问题 更多 >