Not able to iterate a custom dataset

I am trying to run this code and it gives me this error every time. I try to print the value where the loop stopped and it sounds perfectly fine.


Any help to fix this? Thanks in advance

Can you pl. elaborate what do you mean by this?

Also, did you notice and resolve the unsupported image file error?

I am trying to run this loop: “a = np.where([dataset[train_indices[i]][1]==1 for i in tqdm(range(len(train_indices)))])[0]”

it stops when i = 47 or i = 48. When I try to print the value: [dataset[train_indices[i]][1]==1], it works (no error pops up).

Meaning, the problem only happens when I run a loop. Also, it happens when I start the training process. The training stops at some random iteration and gives the same unsupported image file error.

The “Unsupported image file” error is the error I am trying to find a solution to.

Naive suggestion.
When you run the loop, inside the dataset, Print the image_path and see if any filepath doesn’t contain a valid image path?

They are all jpg images. But running this suggestion helped me identify which images are causing the problem. The images causing the problem are normal jpg images. I don’t see them corrupted in anyway. I will just try to download the dataset from elsewhere and see what happens. Thank you.

I downloaded another version of the dataset and everything worked well. Sounds like some images were somehow corrupted.