How to load multiple images from folder and subfolder using Python

Veröffentlicht am: 29 Januar 2025
auf dem Kanal: 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  


Auf dieser Seite können Sie das Online-Video How to load multiple images from folder and subfolder using Python mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Binary Study 29 Januar 2025 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 710 Mal angesehen und es wurde von 3 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!