Reputation: 97
how to display more than 1 image on google colab
from google.colab import files
from keras.preprocessing import image
uploaded = files.upload()
for fn in uploaded.keys():
path = fn
img = image.load_img(path, target_size=(150,150))
I've tried this script but it doesn't work
Upvotes: 1
Views: 3154
Reputation: 13349
If you to display in each line then put plt.show()
below the plt.imshow()
If you want to display in form like grid then use subplot
It will be like this(will display in a single row):
from google.colab import files
from keras.preprocessing import image
import matplotlib.pyplot as plt
uploaded = files.upload()
fig = plt.figure(figsize=(10,10))
for num, fn in enumerate(uploaded.keys()):
path = fn
img = image.load_img(path, target_size=(150,150))
plt.subplot(1,len(uploaded),num+1) # <-------
plt.axis('off')
plt.imshow(img)
Or
for fn in uploaded.keys():
fig = plt.figure(figsize=(10,10))
path = fn
img = image.load_img(path, target_size=(150,150))
plt.axis('off')
plt.imshow(img)
plt.show() #<------------here
Upvotes: 1