EDSR-PyTorch icon indicating copy to clipboard operation
EDSR-PyTorch copied to clipboard

ValueError: num_samples should be a positive integer value, but got num_samples=0

Open rohitdavas opened this issue 4 years ago • 13 comments

I am getting the ValueError: num_samples should be a positive integer value, but got num_samples=0 while running demo.sh

Traceback (most recent call last): File "main.py", line 33, in <module> main() File "main.py", line 22, in main loader = data.Data(args) File "/mnt/Study_Storage/Documents/Study/Projects/Stonybrook_Multimedia_AI/SuperResolution/EDSR-PyTorch/src/data/__init__.py", line 31, in __init__ num_workers=args.n_threads, File "/home/rohit/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 213, in __init__ sampler = RandomSampler(dataset) File "/home/rohit/anaconda3/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

rohitdavas avatar Mar 27 '20 13:03 rohitdavas

I got the same error with you. Just check your dataset dir. For example, your dataset dir is '/dataset/DIV2K', then you should set the parameter '--dir_data' with '/dataset'.

LiuDHS avatar Apr 02 '20 15:04 LiuDHS

I got the same error with you. Just check your dataset dir. For example, your dataset dir is '/dataset/DIV2K', then you should set the parameter '--dir_data' with '/dataset'.

Can you please mention where to do it? I didn't completely got your point that's why.

FlaShBlazer avatar Apr 05 '20 05:04 FlaShBlazer

I am getting the ValueError: num_samples should be a positive integer value, but got num_samples=0 while running demo.sh

Traceback (most recent call last): File "main.py", line 33, in <module> main() File "main.py", line 22, in main loader = data.Data(args) File "/mnt/Study_Storage/Documents/Study/Projects/Stonybrook_Multimedia_AI/SuperResolution/EDSR-PyTorch/src/data/__init__.py", line 31, in __init__ num_workers=args.n_threads, File "/home/rohit/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 213, in __init__ sampler = RandomSampler(dataset) File "/home/rohit/anaconda3/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

have you solved it?

FlaShBlazer avatar Apr 05 '20 05:04 FlaShBlazer

@FlaShBlazer You should open the src/option.py and modify the value of '--dir_data'.

LiuDHS avatar Apr 05 '20 11:04 LiuDHS

@FlaShBlazer You should open the src/option.py and modify the value of '--dir_data'.

I still don't get how to solve it. According to the author, you just put some pictures under "*/EDSR-PyTorch-master/test/" folder and run demo.sh. And I changed the 'dir_data' and 'dir_demo' args all to '../test/', still not work

young169 avatar Jul 07 '20 08:07 young169

same question

wayne1627 avatar Jul 09 '20 04:07 wayne1627

I encountered the same problem above when testing ERGAN

Victor-Future avatar Jul 18 '20 02:07 Victor-Future

I have the same error, when I want to train it, but I see some people are trying to just test, that one works for me. The thing is, that in the demo.sh file un-commented line is the first command, which is right, put a # and comment that out. The line you are looking for is down in the file

#Test your own images #python main.py --data_test Demo --scale 4 --pre_train download --test_only --save_results

un-comment that command or simply run it in the terminal (without demo.sh)

Vahe987 avatar Jul 29 '20 20:07 Vahe987

I have the same error, when I want to train it, but I see some people are trying to just test, that one works for me. The thing is, that in the demo.sh file un-commented line is the first command, which is right, put a # and comment that out. The line you are looking for is down in the file

#Test your own images #python main.py --data_test Demo --scale 4 --pre_train download --test_only --save_results

un-comment that command or simply run it in the terminal (without demo.sh)

hello, I want to test for my own image, but I dont know where I put it, it is for anyway?

marnie007 avatar Aug 26 '20 13:08 marnie007

@Vahe987 I put the image in the test file and named as Demo(I new it), and download the EDSR_x4.pt in the download file that I creat new one. but when I run the code, I got the error ImportError: No module named 'data.'

marnie007 avatar Aug 26 '20 14:08 marnie007

add the '--test_only' after your test commend

JaChouSSS avatar Sep 17 '20 11:09 JaChouSSS

@FlaShBlazer You should open the src/option.py and modify the value of '--dir_data'.

hi @FlaShBlazer do you know, how to fix this? https://github.com/sanghyun-son/EDSR-PyTorch/issues/319#issue-996722398

ulfailliyina avatar Sep 15 '21 06:09 ulfailliyina

I had this error because in my datapath I had "/DIV2K". But apparently, I should have only put the data directory until just before that. So for example if my DIV2K folder is inside a folder called example_folder, then the datapath in the option.py should be

parser.add_argument('--dir_data', type=str, default='/home/~~~/~~~/example_folder', help='dataset directory')

qsibmini-khu avatar Dec 04 '21 11:12 qsibmini-khu