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

问题描述 投票:0回答:2

我已经创建了一个包含一些图像的公共存储库。我怎样才能打开它们并显示它们?我猜测以某种方式使用

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

python image github python-imaging-library display
2个回答
1
投票

好的,完成了:

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()

0
投票

如果仍然不起作用,请在任何 GitHub 图像 URL 的末尾添加“?raw=true” 它将自动生成要加载的原始图像

即: 图像 = Image.open('https://github.com/TeoOG/Computer_Vision_Assistance/blob/master/images/image1.jpg?raw=true')

© www.soinside.com 2019 - 2024. All rights reserved.