ValueError: dataset attribute should not be set after SafeDataLoader is initialized
neeek2303 opened this issue · 4 comments
Hi!
I got this error, and can't get why it is happening.
Traceback (most recent call last):
File "train.py", line 65, in
dataset = dataloader(opt)
File "/root/gans_depth/Synthetic2Realistic/dataloader/data_loader.py", line 130, in dataloader
dataset = nc.SafeDataLoader(datasets, batch_size=opt.batchSize, shuffle=opt.shuffle, num_workers=int(opt.nThreads))
File "/root/anaconda3/lib/python3.7/site-packages/nonechucks/dataloader.py", line 25, in call
obj = type.call(cls, *args, **kwargs)
File "/root/anaconda3/lib/python3.7/site-packages/nonechucks/dataloader.py", line 141, in init
self.dataset = _OriginalDataset(self.safe_dataset)
File "/root/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 271, in setattr
'initialized'.format(attr, self.class.name))
ValueError: dataset attribute should not be set after SafeDataLoader is initialized
My dataset is:
class CreateDataset(data.Dataset):
def initialize(self, opt):
self.opt = opt
self.cat_depth = opt.cat_depth
self.depth_separate = opt.depth_separate
self.img_source_paths, self.img_source_size = make_dataset(opt.img_source_file)
self.img_target_paths, self.img_target_size = make_dataset(opt.img_target_file)
if True:
self.lab_source_paths, self.lab_source_size = make_dataset(opt.lab_source_file)
# for visual results, not for training
self.lab_target_paths, self.lab_target_size = make_dataset(opt.lab_target_file)
self.transform_augment = get_transform(opt, True)
self.transform_no_augment = get_transform(opt, False)
self.transform_no_augment_lab = get_transform(opt, False, ch=1)
def __getitem__(self, item):
.......
return ...
I call dataloader like this:
def dataloader(opt):
datasets = CreateDataset()
datasets.initialize(opt)
datasets = nc.SafeDataset(datasets)
dataloader = nc.SafeDataLoader(datasets, batch_size=opt.batchSize, shuffle=opt.shuffle, num_workers=int(opt.nThreads))
return dataloader
Thank you in advance!
I have the same issue! Have you found a solution to this problem?
Same issue here.
same issue here!
Any solution here? Same problem today with nonechucks=0.4.2