1. 한장 불러오기
from PIL import Image
import urllib
Image.open(urllib.request.urlretrieve(df['tiny_image'][1001])[0])
2. 랜덤하게 여러장 불러오기
import random
from matplotlib import pyplot as plt
from IPython.display import Image, display
from tqdm import tqdm_notebook
import urllib.request
import time
import socket
import urllib
from PIL import Image
random.seed(777)
for i in random.sample(range(len(df)),70):
img = plt.imread(urllib.request.urlretrieve(df['tiny_image'][i])[0])
imgplot = plt.imshow(img)
plt.show()
3. file에서 바로 불러오기
import random
from matplotlib import pyplot as plt
import skimage.io
from IPython.display import Image, display
from tqdm import tqdm_notebook
import urllib.request
import time
import socket
import urllib
for i in random.sample(range(len(arr[1])),5):
image_filename = arr[1]['x'][i]
f_name = path+'/'+image_filename.split('/')[-1]
img_name = image_filename.split('/')[-1]
print(arr[1]['z'][i])
print(f_name)
try:
if os.path.isfile(f_name):
print('isfile')
img = plt.imread(f_name)
imgplot = plt.imshow(img)
plt.show()
else:
print('no isfile')
urllib.request.urlretrieve(image_filename, path+'/'+img_name)
display(Image(filename=f_name))
except:
pass