"No such file or directory"- ImageFolder, but there is

barakb: <p>Hi i’m trying to load my data using:</p>
<pre><code class="lang-auto">trainset = datasets.ImageFolder(root=traindir, transform=train_transform)
trainloader = torch.utils.data.DataLoader(trainset,
                                          batch_size=args.batch_size,
                                          shuffle=True,
                                          num_workers=args.workers)

testset = datasets.ImageFolder(root=testdir, transform=transform)
testloader = torch.utils.data.DataLoader(testset,
                                         batch_size=1000,
                                         shuffle=True,
                                         num_workers=args.workers)
</code></pre>
<p>And I’m getting this error:</p>
<blockquote>
<p>FileNotFoundError: [Errno 2] No such file or directory: ‘data/cinic10-trainlarge/train/ship/n03859170_1073.png’</p>
</blockquote>
<p>The error sounds pretty clear, the loader can’t find this file… but when I’m looking for this file he is there:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/c/3/c3cb7e8b9ad277761768f499cb38915dc9584c04.png" data-download-href="https://discuss.pytorch.org/uploads/default/c3cb7e8b9ad277761768f499cb38915dc9584c04" title="error"><img src="https://discuss.pytorch.org/uploads/default/original/3X/c/3/c3cb7e8b9ad277761768f499cb38915dc9584c04.png" alt="error" data-base62-sha1="rW55EXWnXA7MqPPO1tJeiwfWAEA" width="689" height="268" data-dominant-color="100F0E"><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">error</span><span class="informations">1268×493 40.5 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 idea what am I missing?<br>
Thanks.</p>

ptrblck: <p>Are you sure the file is there and it’s not a broken symbolic link?<br>
Could you please run <code>ll data/...</code> and check the output?</p>

barakb: <aside class="quote no-group" data-username="ptrblck" data-post="2" data-topic="75982">
<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/ptrblck/48/1823_2.png" class="avatar"> ptrblck:</div>
<blockquote>
<p>ll</p>
</blockquote>
</aside>
<p>I shared the ls, now I’ll do the ll</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/2/c/2c9a2580e32e325f1be4f7b1508490821aebdd8c.png" data-download-href="https://discuss.pytorch.org/uploads/default/2c9a2580e32e325f1be4f7b1508490821aebdd8c" title="error1"><img src="https://discuss.pytorch.org/uploads/default/original/3X/2/c/2c9a2580e32e325f1be4f7b1508490821aebdd8c.png" alt="error1" data-base62-sha1="6mzguGMJTBBOcHluD5x4dcJ8X9y" width="690" height="31" data-dominant-color="362B2A"><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">error1</span><span class="informations">1318×61 8.66 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>
forgive me for my ignorance, I have no idea what this arrow represent</p>

ptrblck: <p>The arrow means, that the file name on the left is in fact a symbolic link, which points to the file on the right.<br>
You could see it as a shortcut to the “real” file.<br>
However, since the link is red, it indicates that the real file is missing and the link thus broken.<br>
If you check the right file name via <code>ls</code> or <code>ll</code> you should get an error.</p>

barakb: <p>But the link I’m looking for is the left one, the left one also doesn’t exists?</p>

ptrblck: <p>The symbolic link on the left exists, but points to a non-existing file.<br>
Note that the left file does not contain the image. It’s just a link to the real file, which is missing.</p>

barakb: <p>Ok got it, I’ll fix it.<br>
Thanks.</p>