Showing a group of images

Hi guys,
I’m an amateur coder and I want to open a bunch of images in which I put in the dropbox and unzip it in colab
this is my code but it doesn’t have any error and it doesn’t open it!

import os
import matplotlib.pyplot as plt
from IPython.display import display, Image

local_folder_path = "/content/Uniform"  # Replace this with the path to the unzipped folder in Google Colab

# Collect image files from the folder and its subdirectories
local_image_files = []
for root, _, files in os.walk(local_folder_path):
    local_image_files.extend([os.path.join(root, filename) for filename in files if filename.endswith((".jpg", ".png", ".tif", ".bmp"))])
for image_file in local_image_files:
    if not os.path.exists(image_file):
        print(f"Image file not found: {image_file}")

# Display the images
for image_file in local_image_files:
for image_file in local_image_files:
        img = plt.imread(image_file)
    except Exception as e:
        print(f"Error displaying image: {e}")

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

1 Like

this is in dropbox nd I put the address on colab like this:
!wget -q …/www.dropbox…
!rm -r sample_data

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.