How to load multiple images from folder and subfolder using Python

Publicado el: 29 enero 2025
en el canal de: Binary Study
710
3

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  


En esta página del sitio puede ver el video en línea How to load multiple images from folder and subfolder using Python de Duración hora minuto segunda en buena calidad , que subió el usuario Binary Study 29 enero 2025, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 710 veces y le gustó 3 a los espectadores. Disfruta viendo!