Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LightlyDataset with filenames bug on subfolders

See original GitHub issue

LightlyDataset with filenames bug on subfolders


dataset = LightlyDataset(

I get an error when filenames doesn’t contain at least one image from every subfolder, e.g.

L subfolder_1/
    L  img0.png
    L  img1.png
L subfolder_2/
    L img0.png

Then filenames=[subfolder_1/img0.png'] will fail.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

masc-itcommented, Oct 29, 2021

Hi @masc-it

Probably torchvision just assumes the directory ./test/.ipynb_checkpoints should contain images when that’s obviously not true.

You can see all the directories in ./test with the command

ls -a ./test

To fix your problem simply remove the .ipynb_checkpoints directory.

yep, have alread found out, forgot to edit the comment! Thanks anyways and keep up with the good work 😄

MalteEbnercommented, Nov 16, 2021

I have discussed this issue in length with some developers from torchvision:

The key takeaway is: Do not use LightlyDataset(input_dir) on input_dirs which contain subdirectories without images. This is needed to ensures that the labels returned when iterating over the LightlyDataset are continuous, start with 0 and that there is at least one image for every label.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ImageFolder(root) raises error if root contains empty subfolders
Describe the bug When using torchvision.datasets.ImageFolder(root) on a root with a subfolder not containing images, an error is thrown.
Read more >
copy & paste image dataset from single folder to subfolders ...
Image filenames are in a specific order: label_randomNo._randomString.JPEG . Using a custom Python function, I want to be able to copy/paste ...
Read more >
Tutorial 1: Structure Your Input — lightly 1.2.38 documentation
You can give structure to your input directory by collecting the input images in subdirectories. In this case, the filenames loaded by lightly...
Read more >
WinMerge / Bugs / #2241 'View > Expand All Subfolders' does ...
All subfolders are not expanded, and when I export to CSV, ... Under Filename column, Subfolder1-2 appears (with a folder icon) instead of ......
Read more >
Loading files from subfolders, the file name in all the folders ...
The simulation results file contains 40 sub folders and the files in all the folders are same but with different data. Example my...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found