In this video, we will use the Python "glob" module to load images from folders and subfolders. The glob is an in-built module in Python, and comes with Python installation. So you don't need to install it separately.
First, we import glob and use glob.glob() function to read all the image paths from nested folders, i.e. folders, and subfolders.
Complete program in Python is as follows:
import glob
from PIL import Image
import matplotlib.pyplot as plt
image_paths = glob.glob('./**/*.jpg', recursive=True)
plt.figure(figsize=(10, 10))
for index, image_path in enumerate(image_paths):
#print(image_path)
image = Image.open(image_path)
plt.subplot(5, 5, index + 1) # Change grid size as needed
plt.imshow(image) # Display the image
plt.axis('off') # Hide the axis for each image
Show all images in the grid
plt.tight_layout()
plt.show()
Python Videos
1. • How to Install Python (3.13.0) on Windows ...
2. • Install Jupyter Notebook on Windows 11 and...
Computer vision & image processing related videos:
1. • How to load and visualize CIFAR-10 and CIF...
2. • How to load and visualize multiple images ...
Playlists
• Python Tutorial for Beginners
• Colab
• Computer Vision
Sur cette page du site, vous pouvez voir la vidéo en ligne How to load multiple images from folder and subfolder using Python durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Binary Study 29 janvier 2025, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 710 fois et il a aimé 3 téléspectateurs. Bon visionnage!