zalandoresearch / pytorch-vq-vae

PyTorch implementation of VQ-VAE by Aäron van den Oord et al.
MIT License
534 stars 101 forks source link

Hi,how its possible to train VQ-VAE on my own data set images? Thanks #3

Closed zaitoun90 closed 5 years ago

kashif commented 5 years ago

by using appropriate data loaders you can train with your data, which depending on the size of your images might also require adjusting the encoder and decoder. hope that helps!

zaitoun90 commented 5 years ago

Thank you,

jxy1997 commented 5 years ago

请问,可以在这个基础上修改成AI换衣服、裤子、鞋子这类服装吗,这是我的课题,但是才刚刚接触,完全没有思路,可以修改一下,或者讲一下思路吗,如果可以的话,请发到邮箱794165077@qq.com,谢谢!

nadiagit commented 4 years ago

Thank you,

Hi @zaitoun90, have you managed to train this on your own dataset?

zaitoun90 commented 4 years ago

Hi , Yes I have train it on my own min data set.

Sent from my iPhone

On 28. Apr 2020, at 20:05, Nadia Domide notifications@github.com wrote:

 Thank you,

Hi @zaitoun90, have you managed to train this on your own dataset?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

zaitoun90 commented 4 years ago

Can you tell me your problem!?

Sent from my iPhone

On 28. Apr 2020, at 20:05, Nadia Domide notifications@github.com wrote:

 Thank you,

Hi @zaitoun90, have you managed to train this on your own dataset?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

nadiagit commented 4 years ago

Can you tell me your problem!? Sent from my iPhone On 28. Apr 2020, at 20:05, Nadia Domide @.***> wrote:  Thank you, Hi @zaitoun90, have you managed to train this on your own dataset? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

I have a problem after loading the dataset, computing the variance :)

I load my dataset: dataset = dset.ImageFolder(root=dataroot, transform=transforms.Compose([ transforms.ToTensor(), transforms.Normalize((0.5, 0.5, 0.5), (1.0, 1.0, 1.0)), ]))

dataloader = torch.utils.data.DataLoader(dataset, batch_size=batch_size, shuffle=True, num_workers=workers)

then I split it into 2 subsets: train_set, val_set = torch.utils.data.random_split(dataset, [2000, 600])

then I want to compute the variance, using the following code (from here https://discuss.pytorch.org/t/about-normalization-using-pre-trained-vgg16-networks/23560/6): pixel_mean = np.zeros(1) pixel_std = np.zeros(1) k = 1 for i_batch, sample_batched in enumerate(dataloader): image = np.array(sample_batched['image']) pixels = image.reshape((-1, image.shape[1])) for pixel in pixels: diff = pixel - pixel_mean pixel_mean = pixel_mean + diff / k pixel_std = pixel_std + diff * (pixel - pixel_mean) k += 1 pixel_std = np.sqrt(pixel_std / (k - 2))

And I receive the error: TypeError: list indices must be integers or slices, not str

Update: I gave as parameters in the following 2 lines, the length of my dataset and it start working. pixel_mean = np.zeros(1) pixel_std = np.zeros(1)

Now I think my problem is computational time. I work in Google Colab and get disconnected pretty often 😄

Anyhow, do you think is alright how I compute the std? For further computing the variance, by doubling it.

Thank you 😊

zaitoun90 commented 4 years ago

Hi Nadia,

Sorry for I cannot help you in this time because my laptop is not working at all.. in the mean time I am working to fix it...

zaitoun90 commented 4 years ago

I have tried VQ-VAE2, it has better or similar result with comparison to BigGAN. And actually that depends on the issue that you want to solve. If You are beginner in this field I do advise you to the following “In case to save your time, try to find the best modle that would help you in solving your problems and then you can start facing the technical problems”.

It is just an advice, but if the time doesn’t matter for you, and you have a powerful pc with high Computational horsepower and a perfect Gpu, then try everything.”

nadiagit commented 4 years ago

Thanks @zaitoun90 😊(I am not new into the field, but new into gans and vaes, and wanted to try this for a personal project)