0

I've already created a public repository containing some images . How can I open them and display them ? I'm guessing with the use of pyplot somehow . Here's what I've tried :

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

Also here's my repository's link : https://github.com/TeoOG/Computer_Vision_Assistance

DavidDunn
  • 143
  • 1
  • 12
  • 1
    Might be a duplicate of https://stackoverflow.com/questions/7391945/how-do-i-read-image-data-from-a-url-in-python – Alessia Marcolini Aug 04 '20 at 17:49
  • 1
    You need to provide the raw URL.which in your case is `https://raw.githubusercontent.com/TeoOG/Computer_Vision_Assistance/master/images/image1.jpg`. – krxat Aug 04 '20 at 17:52
  • 1
    Also you need something like a URL parser like the thread mentioned above to actually get the data as `Image.open` will only accept local file pointers. – krxat Aug 04 '20 at 17:55

1 Answers1

0

okay it's done :

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()
DavidDunn
  • 143
  • 1
  • 12