我已经创建了一个包含一些图像的公共存储库。我怎样才能打开它们并显示它们?我猜测以某种方式使用
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
好的,完成了:
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()
如果仍然不起作用,请在任何 GitHub 图像 URL 的末尾添加“?raw=true” 它将自动生成要加载的原始图像
即: 图像 = Image.open('https://github.com/TeoOG/Computer_Vision_Assistance/blob/master/images/image1.jpg?raw=true')