Not able to iterate a custom dataset

username: Omar_Samir
cooked: <p>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.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/e/e/ee5ec72732958c506829560b08a56b0fe68043af.png" data-download-href="https://discuss.pytorch.org/uploads/default/ee5ec72732958c506829560b08a56b0fe68043af" title="Screen Shot 2022-04-25 at 4.36.08 PM"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/e/e/ee5ec72732958c506829560b08a56b0fe68043af_2_666x500.png" alt="Screen Shot 2022-04-25 at 4.36.08 PM" data-base62-sha1="y0IHk4E6DkHVLxoNgu9e6vl9JhR" width="666" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/e/e/ee5ec72732958c506829560b08a56b0fe68043af_2_666x500.png, https://discuss.pytorch.org/uploads/default/optimized/3X/e/e/ee5ec72732958c506829560b08a56b0fe68043af_2_999x750.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/e/e/ee5ec72732958c506829560b08a56b0fe68043af.png 2x" data-dominant-color="EBEBEB"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screen Shot 2022-04-25 at 4.36.08 PM</span><span class="informations">1120×840 139 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/3/d/3d1b2b8291696d09c0c6508e257109300399e1be.png" data-download-href="https://discuss.pytorch.org/uploads/default/3d1b2b8291696d09c0c6508e257109300399e1be" title="Screen Shot 2022-04-25 at 4.36.40 PM"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/3/d/3d1b2b8291696d09c0c6508e257109300399e1be_2_545x500.png" alt="Screen Shot 2022-04-25 at 4.36.40 PM" data-base62-sha1="8IzkTHkT32dSNa1lW9VVI4Adinc" width="545" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/3/d/3d1b2b8291696d09c0c6508e257109300399e1be_2_545x500.png, https://discuss.pytorch.org/uploads/default/optimized/3X/3/d/3d1b2b8291696d09c0c6508e257109300399e1be_2_817x750.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/3/d/3d1b2b8291696d09c0c6508e257109300399e1be_2_1090x1000.png 2x" data-dominant-color="F1F4F2"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screen Shot 2022-04-25 at 4.36.40 PM</span><span class="informations">1130×1036 172 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>Any help to fix this? Thanks in advance</p>

username: InnovArul
cooked: <aside class="quote no-group" data-username="Omar_Samir" data-post="1" data-topic="150064">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/omar_samir/48/47695_2.png" class="avatar"> Omar_Samir:</div>
<blockquote>
<p>I try to print the value where the loop stopped and it sounds perfectly fine</p>
</blockquote>
</aside>
<p>Can you pl. elaborate what do you mean by this?</p>
<p>Also,  did you notice and resolve the <code>unsupported image file</code> error?</p>

username: Omar_Samir
cooked: <p>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]”</p>
<p>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).</p>
<p>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.</p>
<p>The “Unsupported image file” error is the error I am trying to find a solution to.</p>

username: InnovArul
cooked: <aside class="quote no-group" data-username="Omar_Samir" data-post="3" data-topic="150064">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/omar_samir/48/47695_2.png" class="avatar"> Omar_Samir:</div>
<blockquote>
<p>The “Unsupported image file” error is the error I am trying to find a solution to.</p>
</blockquote>
</aside>
<p>Naive suggestion.<br>
When you run the loop,  inside the dataset,  Print the <code>image_path</code> and see if any filepath doesn’t contain a valid image path?</p>

username: Omar_Samir
cooked: <p>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.</p>

username: Omar_Samir
cooked: <p>I downloaded another version of the dataset and everything worked well. Sounds like some images were somehow corrupted.</p>