examples icon indicating copy to clipboard operation
examples copied to clipboard

FileNotFoundError: Couldn't find any class folder in /content/train2014.

Open sevaroy opened this issue 3 years ago • 2 comments

Your issue may already be reported! Please search on the issue tracker before creating one.

I wanna train new style model run this cmd

!unzip train2014.zip -d /content

!python /content/examples/fast_neural_style/neural_style/neural_style.py train --dataset /content/train2014 --style-image /content/A.jpg --save-model-dir /content --epochs 2 --cuda 1

Context

  • Pytorch version:
  • Operating System and version:

Your Environment

Colab https://colab.research.google.com/github/pytorch/xla/blob/master/contrib/colab/style_transfer_inference.ipynb#scrollTo=EozMXwIV9iOJ

got this error

Traceback (most recent call last): File "/content/examples/fast_neural_style/neural_style/neural_style.py", line 249, in main() File "/content/examples/fast_neural_style/neural_style/neural_style.py", line 243, in main train(args) File "/content/examples/fast_neural_style/neural_style/neural_style.py", line 43, in train train_dataset = datasets.ImageFolder(args.dataset, transform) File "/usr/local/lib/python3.7/dist-packages/torchvision/datasets/folder.py", line 316, in init is_valid_file=is_valid_file, File "/usr/local/lib/python3.7/dist-packages/torchvision/datasets/folder.py", line 145, in init classes, class_to_idx = self.find_classes(self.root) File "/usr/local/lib/python3.7/dist-packages/torchvision/datasets/folder.py", line 219, in find_classes return find_classes(directory) File "/usr/local/lib/python3.7/dist-packages/torchvision/datasets/folder.py", line 43, in find_classes raise FileNotFoundError(f"Couldn't find any class folder in {directory}.") FileNotFoundError: Couldn't find any class folder in /content/train2014.

How can I fix it? thx

sevaroy avatar Aug 23 '22 07:08 sevaroy

@sevaroy good catch! datasets.ImageFolder requires folder in this format: root/label_name/xxx.png. Here is a quick workaround: create a sub folder containing all images under train2014. e.g. train2014/no_label/xxx.png. The labels are not used in this examples anyway.

Please feel free to submit a PR to update the README accordingly. Otherwise, I will update it next week.

hudeven avatar Aug 24 '22 02:08 hudeven

Looks like this is not fixed yet. Right? I can try fixing it and make a PR if no one else is working on it

Edit: I realized I mishandled the dataset which led to this error. After deleting the extracted folders, it was fixed. So, I guess there is no need to fix anything.

pramodhrachuri avatar Jun 08 '23 02:06 pramodhrachuri