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

Problems when using custom dataset #83

Open
denisb411 opened this issue Nov 13, 2023 · 8 comments
Open

Problems when using custom dataset #83

denisb411 opened this issue Nov 13, 2023 · 8 comments

Comments

@denisb411
Copy link

Hello,

I tried to code a custom dataset class for training but the images generated on samples and reconstruction are all messed.

To code the dataset class I was inspired by the Oxford Pets dataset class that was commented on dataset.py file, and it's looking like that:

# Add your custom dataset class here
class MyDataset(Dataset):
    def __init__(self, 
                 data_path: str, 
                 split: str,
                 transform: Callable,
                **kwargs):
        self.data_dir = Path(data_path)    
        self.transforms = transform
        imgs = sorted([f for f in self.data_dir.iterdir() if f.suffix == '.jpg'])

        self.imgs = imgs[:int(len(imgs) * 0.75)] if split == "train" else imgs[int(len(imgs) * 0.75):]

    def __len__(self):
        return len(self.imgs)
    
    def __getitem__(self, idx):
        img = default_loader(self.imgs[idx])
        
        if self.transforms is not None:
            img = self.transforms(img)
        

The samples generated:
image

The reconstruction:
image

In order to debug, I used the following code, and it seems that the images are fine:

        DEBUG_DIR = './debug'
        shutil.rmtree(DEBUG_DIR, ignore_errors=True)
        os.makedirs(DEBUG_DIR, exist_ok=True)
        for i, img in enumerate(self.val_dataset):
            img = img[0]
            img = img.permute(1, 2, 0)
            img = (img * 255).numpy().astype(np.uint8)
            img = Image.fromarray(img)
            img.save(os.path.join(DEBUG_DIR, uuid.uuid4().hex + '.jpg'))

            if i == 10:
                break

image

Can someone give me a light about what I am missing?

@bserranoanton
Copy link

Any solution about this?

@kuailexiaohunzi
Copy link

Any solution about this?

May I ask if you have resolved it? I have also encountered the same problem. Can you communicate with me

@MisterBourbaki
Copy link

Hi @denisb411 , Hi all!
@denisb411 I think your post misses a few thinks, notably the change you have to perform on the run.py file, and the config file you use. I mean, I assume you just run the run.py file?

@kuailexiaohunzi Maybe you should open a dedicated issue with details on what issues you encoutered :)

P.S: Seeing the last updates on this repo, I sadly think it is not maintained anymore :(

@kuailexiaohunzi
Copy link

Hi @denisb411 , Hi all! @denisb411 I think your post misses a few thinks, notably the change you have to perform on the run.py file, and the config file you use. I mean, I assume you just run the run.py file?

@kuailexiaohunzi Maybe you should open a dedicated issue with details on what issues you encoutered :)

P.S: Seeing the last updates on this repo, I sadly think it is not maintained anymore :(

My current problem is that I want to use VAE to test on my own dataset, but the results are not satisfactory. The image below is my reconstructed image.
recons_VanillaVAE_Epoch_0
I modified the hyperparameters in the configuration file, but the effect was minimal. I am not sure if it is because my dataset does not have attribute files. How do you think this problem should be solved? Can we exchange ideas

@MisterBourbaki
Copy link

I am sorry but could you be more precise? The best way would be to open a dedicated Issue, as your problems may not be the same as @denisb411 .
Provide as much information as you can (where the data are, what they are, what Python file did you run, is it after training...). Then I may be able to help you :)

@kuailexiaohunzi
Copy link

I am sorry but could you be more precise? The best way would be to open a dedicated Issue, as your problems may not be the same as @denisb411 . Provide as much information as you can (where the data are, what they are, what Python file did you run, is it after training...). Then I may be able to help you :)

I have opened a special question and I hope to receive your help. If you need to provide any information, please feel free to contact me. Thank you

@bserranoanton
Copy link

Any solution about this?

May I ask if you have resolved it? I have also encountered the same problem. Can you communicate with me

Yes, I had to change dimensions in order to have a larger patch size.
For instance, in models/vanilla_vae.py
imagen
imagen
imagen

@kuailexiaohunzi
Copy link

change di

I have also modified these parameters before, but they did not solve my problem. Thank you for your reply

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

4 participants