FileNotFoundError: Couldn't find any class folder

Hello everyone,
I am facing problem in reading the ImageFolder in dataloader. this error appeared for me

FileNotFoundError: Couldn't find any class folder C:\Users\khawlahbajbaa\Documents\Paint-by-Example-main\dataset\validation\bingmap.

I tried to use relative path but i faced the same problem…

My data structure as follow:

  • training
    • bingmap
      • … . JPG
    • streetview
  • validation
    • bingmap
    • streetview

Any suggestions to overcome this error?

Your collaboration is highly appreciated…

Which course are you attending?

i am not attending any course. I am facing this error in a private project.

any suggestions to solve this problem?

You have not really told us what API packages you are using here, so it’s a bit hard to give any advice. But file not found errors should be debuggable. Notice that it complains about a “class folder”. Try looking at the documentation for the package that you are using. What do they mean by “class folder”? What pathnames do they assume for a “class folder”? Or if you are saying that you don’t know how “folders” and pathnames work on Windows, then I’m sure you can google up some tutorials about that.

i am using diffusion model for image generation, the class folder should contains the image with class label name like /dataset/dog/xxx.JPG , /dataset/cat/xxx.JPG. so all dog images should be in a dog folder and the cat images in cat folder. I did the same for my two class labels.

My problem is that, it could not access the path of validation images, while it works with the train images!

I am not using any API for my data, it is stored on my local machine in dataset folder.

if you need more info. about my code please let me know.

Your collaboration is highly appreciated.

Thanks for the additional information. Well if it works with the training data files, but not the validation files, then there’s a pretty obvious set of things to check, right? What is different between the pathnames of the two sets? How do you tell the model which pathnames to use in the two cases? You got it right in one case and not in the other, so now you need to figure out the difference.

If you are going to play these games, then the goal is to develop your own debugging skills. In this space, this type of problem just never ends, right? It will be a feature of your life from this point forward, so you can’t just throw up your hands and hope that someone else will solve your problem every time something like this happens. What I’m hoping to here is to give suggestions about how to figure out the issue. It’s like the old proverb most commonly attributed to the philosopher Lao Tzu:

“If I give a man a fish, he will not be hungry today. If I teach a man to fish, he will never be hungry again.”

So the goal here is to give “fishing lessons” and I honestly don’t know how to hand you the fish in this case anyway. :laughing:

Hello @Khawlah_b,

  1. Why did it look for class folder inside bingmap., while it seems to be a class folder itself. Did you want it to look for class folder inside another class folder?

  2. What’s going on with that fullstop after bingmap? There shouldn’t be a fullstop according to your data structure.

@Khawlah_b, the first rule about debugging is to look at the facts. There are a few things that I wouldn’t have done if I want to discuss it with the others:

  1. selectively sharing 2 lines of error traceback. Python gathers up all the calls from surface to the core of the problem for us to inspect. By screening off some of them, we might miss out some important information. I would have provided the full traceback.

  2. describing things as if making examples.

    Examples usually look fine, because otherwise you wouldn’t type them, but that is not necessarily relevant to your problem. You have made a very good observation - that it worked for training set but not for validation set. What paths did you specify for each of them - not some example paths, but the actual ones? How did you structure the folders (given that you made examples, I am not sure if the structure in the first post reflects the truth)

@Khawlah_b, a person who debugs needs the facts. Although we do not debug for you, you providing the facts with minimal change is going to help us point you to something that might help you move on with your own debugging. Also, don’t ask the others to ask you for information. As a programmer who debugs, you need to train yourself up for providing relevant FACTS in an organized way.

Good luck!