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

ValueError: dataset attribute should not be set after SafeDataLoader is initialized #28

Open
neeek2303 opened this issue Jul 21, 2020 · 4 comments

Comments

@neeek2303
Copy link

neeek2303 commented Jul 21, 2020

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!

@samru-rai
Copy link

I have the same issue! Have you found a solution to this problem?

@janluke
Copy link

janluke commented Sep 13, 2021

Same issue here.

@staceybeck
Copy link

same issue here!

@skim2257
Copy link

Any solution here? Same problem today with nonechucks=0.4.2

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

5 participants