Import dataset using datasets.ImageFolder

Abdelrahman_Mohamed: <p>Hi guys,<br>
When I use:<br>
torchvision.datasets.ImageFolder<br>
to import train  dataset I get this Error:</p>
<p>RuntimeError: Found 0 images in subfolders of: /data/train/<br>
Supported image extensions are: .jpg,.jpeg,.png,.ppm,.bmp,.pgm,.tif,.tiff,webp</p>
<p>Any help!?</p>

pramod.srinivasan: <p>Did you check if there are images in <code>/data/train</code>? Maybe your training set is elsewhere.</p>

Abdelrahman_Mohamed: <p>Thank you for replying, I made sure that the folder contains the images</p>

ptrblck: <p>Are you maybe passing an absolute path accidentally instead of a relative one?<br>
I.e. <code>/data/train/</code> instead of <code>./data/train/</code>?</p>

tjwang888: <p>I got the same issue. Is there any other solution for that? @@</p>

iArunava: <p>Hi! <a class="mention" href="/u/tjwang888">@tjwang888</a>,<br>
Welcome to the PyTorch Community <img src="https://discuss.pytorch.org/images/emoji/apple/confetti_ball.png?v=9" title=":confetti_ball:" class="emoji" alt=":confetti_ball:"></p>
<p>Coming to your question, please make sure that the</p>
<ul>
<li>image types are of supported formats</li>
<li>there are images in the directory</li>
<li>And that you are passing the path correctly.</li>
</ul>
<p>If you have checked these 3 and still facing an error.</p>
<p>Show us your StackTrace and output of the <code>ls</code> command for that same path.<br>
Please wrap your code in ```</p>
<p>Thanks <img src="https://discuss.pytorch.org/images/emoji/apple/man_technologist.png?v=9" title=":man_technologist:" class="emoji" alt=":man_technologist:"></p>

tjwang888: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/f/f9f33b42cfe2b5858fb7889113e7118aa8a55bf4.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/f9f33b42cfe2b5858fb7889113e7118aa8a55bf4" title="Image%202"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/f/f9f33b42cfe2b5858fb7889113e7118aa8a55bf4_2_494x500.jpeg" alt="Image%202" data-base62-sha1="zFa0H3JFV4bnMTqb1azwQ11GEba" width="494" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/f/f9f33b42cfe2b5858fb7889113e7118aa8a55bf4_2_494x500.jpeg, https://discuss.pytorch.org/uploads/default/original/2X/f/f9f33b42cfe2b5858fb7889113e7118aa8a55bf4.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/2X/f/f9f33b42cfe2b5858fb7889113e7118aa8a55bf4.jpeg 2x" data-dominant-color="1E2727"><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">Image%202</span><span class="informations">630×637 307 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>I think those 3 items you list is OK, but it still showed the error message below:</p>
<p>Traceback (most recent call last):<br>
File “cnn-poc-01.py”, line 37, in <br>
trainloader, testloader = load_split_train_test(data_dir, .2)<br>
File “cnn-poc-01.py”, line 18, in load_split_train_test<br>
train_data = datasets.ImageFolder(datadir, transform=train_transforms)<br>
File “C:\Anaconda3\lib\site-packages\torchvision\datasets\folder.py”, line 209, in <strong>init</strong><br>
is_valid_file=is_valid_file)<br>
File “C:\Anaconda3\lib\site-packages\torchvision\datasets\folder.py”, line 97, in <strong>init</strong><br>
"Supported extensions are: " + “,”.join(extensions)))<br>
RuntimeError: Found 0 files in subfolders of: …/dataset/wafer_defect/test<br>
Supported extensions are: .jpg,.jpeg,.png,.ppm,.bmp,.pgm,.tif,.tiff,.webp</p>
<p>Thank you for your kindly help. ^^</p>

supermonk00: <p>Hi <a class="mention" href="/u/tjwang888">@tjwang888</a> <a class="mention" href="/u/abdelrahman_mohamed">@Abdelrahman_Mohamed</a> ,<br>
I had the same problem as you. Then I found out you have to set your directory one step before.<br>
For example, you want to read an image /yourfolder/yourcode/yourimage/image.png<br>
You should set at /yourfolder/yourcode/ rather than /yourfolder/yourcode/yourimage. I think that can help you :))</p>

wymankels: <p>This helped me solve my error - thanks!</p>