How to load multiple images from folder and subfolder using Python

Опубликовано: 29 Январь 2025
на канале: 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  


На этой странице сайта вы можете посмотреть видео онлайн How to load multiple images from folder and subfolder using Python длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Binary Study 29 Январь 2025, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 710 раз и оно понравилось 3 зрителям. Приятного просмотра!