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

new data set #30

Open
asifkyni opened this issue Dec 11, 2018 · 4 comments
Open

new data set #30

asifkyni opened this issue Dec 11, 2018 · 4 comments

Comments

@asifkyni
Copy link

Hi,
I want to use a different data set not available via pytorch. I get error and tried different tricks but did not work. Could you please let me know how can add the path of my data set to this code to work.

@cscss
Copy link

cscss commented Dec 13, 2018

i have the same problem. I change the path to a new dataset. I get error but I can't figure it out.

@carshadi
Copy link

carshadi commented Dec 25, 2018

You just need to add a few lines to data_loader.py and parameter.py

For data_loader.py just specify a custom loader function as well as a data path. The data can simply be a directory of jpegs or whatever. Just place the data in ./data/custom/custom as it will look in the innermost directory for the actual image files.

    def load_custom(self):
        transforms = self.transform(True, True, True, False) # last arg is crop
        dataset = dsets.ImageFolder(self.path+'/custom', transform=transforms)
        return dataset


    def loader(self):
        if self.dataset == 'lsun':
            dataset = self.load_lsun()
        elif self.dataset == 'celeb':
            dataset = self.load_celeb()
        elif self.dataset == 'custom': 
            dataset = self.load_custom()

        loader = torch.utils.data.DataLoader(dataset=dataset,
                                              batch_size=self.batch,
                                              shuffle=self.shuf,
                                              num_workers=2,
                                              drop_last=True)
        return loader

In the parameter.py file just add the name of your dataset to choices=['lsun', 'celeb', 'custom'] in line 38

@fanage
Copy link

fanage commented Nov 19, 2019

You just need to add a few lines to data_loader.py and parameter.py

for data_loader.py just specify a custom loader function as well as a data path. The data can simply be a directory of jpegs or whatever. Just place the data in ./data/custom/custom as it will look in the innermost directory for the actual image files

def load_custom(self):
    transforms = self.transform(True, True, True, False) # last arg is crop
    dataset = dsets.ImageFolder(self.path+'/custom', transform=transforms)
    return dataset


def loader(self):
    if self.dataset == 'lsun':
        dataset = self.load_lsun()
    elif self.dataset == 'celeb':
        dataset = self.load_celeb()
    elif self.dataset == 'custom': 
        dataset = self.load_custom()

    loader = torch.utils.data.DataLoader(dataset=dataset,
                                          batch_size=self.batch,
                                          shuffle=self.shuf,
                                          num_workers=2,
                                          drop_last=True)
    return loader

In the parameter.py file just add the name of your dataset to choices=['lsun', 'celeb', 'custom'] in line 38

But when I modified it by your introduction, it shows that he found 0 files. Do you have the same problem? How to figure it out?

@wennzheng
Copy link

I meet this question too. it show "RuntineError: Found 0 files in subfolders " .

The reson is your data path is not correct. you path should be ./data/celebA/"class_name"/1.jpg ........

you can reference The functiong "torchvision.datasets.ImageFolder()",

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