Issue
My following code iterates through a list of files & prints each image "inline" in a Jupyter Notebook with the filename.
from IPython.display import Image, display
listOfImageNames = ["0/IMG_1118.JPG","0/IMG_1179.JPG"]
for imageName in listOfImageNames:
display(Image(filename=imageName))
print(imageName)
However, I want to achieve the same output, but iterate through a folder of images, without having to reference each image file in the code. I have been battling with this one- can anyone point me in the right direction?
Solution
Using glob to search for JPG files!
import glob
from IPython.display import Image, display
for imageName in glob.glob('yourpath/*.jpg'): #assuming JPG
display(Image(filename=imageName))
print(imageName)
Answered By - ibarrond
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.