eriklindernoren / PyTorch-GAN

PyTorch implementations of Generative Adversarial Networks.
MIT License
16.23k stars 4.05k forks source link

Error when run cyclegan.py #99

Closed x-Sapphire closed 4 years ago

x-Sapphire commented 4 years ago

when I run cyclegan.py,it always has this error: ValueError: num_samples should be a positive integer value, but got num_samples=0

Traceback (most recent call last):
  File "cyclegan.py", line 124, in <module>
    num_workers=opt.n_cpu,
  File "/home/×××/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 213, in __init__
    sampler = RandomSampler(dataset)
  File "/home/×××/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/sampler.py", line 94, in __init__
    "value, but got num_samples={}".format(self.num_samples))
ValueError: num_samples should be a positive integer value, but got num_samples=0

what's the matter with it?

IvanFei commented 4 years ago

the args "--n_cpu" should be positive integer value. But you set it to 0.

In cyclegan.py line 33: parser.add_argument("--n_cpu", type=int, default=8, help="number of cpu threads to use during batch generation")

please check the default value of n_cpu. Make sure it's not zero.

x-Sapphire commented 4 years ago

the args "--n_cpu" should be positive integer value. But you set it to 0.

In cyclegan.py line 33: parser.add_argument("--n_cpu", type=int, default=8, help="number of cpu threads to use during batch generation")

please check the default value of n_cpu. Make sure it's not zero.

Thank you for prompt reply. But I did not edit the source code at all,and the n_cpu is just the default value.

IvanFei commented 4 years ago

Please check the data dir is correct or not. This error indicates that the number of samples in your dataset is zero. [in cyclegan.py line 121]

ghost commented 4 years ago

You're not putting the dataset name at the end, try this

python cyclegan.py --dataset_name monet2photo

Or another reason might be, there's no data in the folder /data/monet2photo

px4869 commented 4 years ago

the reason for that is the localation of the dataset is wrong. you can open the file download_cyclegan_dataset.sh ,and you can see :

Adapt to project expected directory heriarchy

mkdir -p "$TARGET_DIR/train" "$TARGET_DIR/test" mv "$TARGET_DIR/trainA" "$TARGET_DIR/train/A" mv "$TARGET_DIR/trainB" "$TARGET_DIR/train/B" mv "$TARGET_DIR/testA" "$TARGET_DIR/test/A" mv "$TARGET_DIR/testB" "$TARGET_DIR/test/B"

just follow what it say,you can solve it