Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when run cyclegan.py #99

Closed
x-Sapphire opened this issue Mar 25, 2020 · 5 comments
Closed

Error when run cyclegan.py #99

x-Sapphire opened this issue Mar 25, 2020 · 5 comments

Comments

@x-Sapphire
Copy link

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
Copy link

IvanFei commented Mar 30, 2020

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
Copy link
Author

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
Copy link

IvanFei commented Mar 30, 2020

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
Copy link

ghost commented Apr 8, 2020

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
Copy link

px4869 commented May 14, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants