naver-ai / StyleMapGAN

Official pytorch implementation of StyleMapGAN (CVPR 2021)
https://www.youtube.com/watch?v=qCapNyRA_Ng
Other
458 stars 81 forks source link

How can I train on my own data #3

Open Radium98 opened 3 years ago

Radium98 commented 3 years ago

Hi,authors,thank you for your great work. What should I do if I want to train your model on my own dataset? I think you are supposed to tell readers how to process their own data if they want to use it for training. Another question is why not release the model about LSUN Car & Church?I want to get the model to vertify the effect your model behaved on LSUN Car & Church.

wjkang619 commented 3 years ago

I ask the same question as the @Radium98 I watched the presentation on this study at the NAVER search colloquium. Your research is really impressive. I look forward to being updated on how to learn using custom data.

blandocs commented 3 years ago

Hi guys, thank you for your interest :)

  1. If you want to make your own dataset, refer to prepare_data.py.

  2. I already provided LSUN models. Please refer to https://github.com/naver-ai/StyleMapGAN/blob/main/download.sh

zackzhao commented 3 years ago

Hi,authors,thank you for your great work. What should I do if I want to train your model on my own dataset? I think you are supposed to tell readers how to process their own data if they want to use it for training. Another question is why not release the model about LSUN Car & Church?I want to get the model to vertify the effect your model behaved on LSUN Car & Church.

Hi, do you train the model on your own data? I trained the model on the raw data of celeba_hq (firstly,using prepare_data.py to get data.mdb ),but when I reconstruction the image,I only get the noise. Do you have any suggestion?

blandocs commented 3 years ago

Hi, do you train the model on your own data? I trained the model on the raw data of celeba_hq (firstly,using prepare_data.py to get data.mdb ),but when I reconstruction the image,I only get the noise. Do you have any suggestion?

@zackzhao Sorry for the late reply. Was the training loss decreasing when you were training? If you only get noise, the training arguments are probably not right.

taerimyeon commented 3 years ago

Hi @blandocs, thanks for the amazing work. Since I have the same question and this issue still open, I decided to drop the question here.

What I wish to do with this repo is to do image reconstruction of my own image dataset, using the generate.py with --mixing_type reconstruction. I have tried the data preparation using prepare_data.py with just a few images I wish to reconstruct (for testing purpose, I have only put 3 images from the dataset folder inside another folder). I have put those three images in this arrangement

(base) steven@steven-pc:~$ tree Test_20210809_StyleMapGANEncoding
Test_20210809_StyleMapGANEncoding  # Parent folder
└── test  # Sub folder
    ├── AF1500.jpg  # File no. 1
    ├── AF1514.jpg  # File no. 2
    └── AF1526.jpg  # File no. 3

I have no issue with dataset making. However, I got this kind of error when I using my own data.

Original Traceback (most recent call last):
  File "/home/steven/anaconda3/envs/tf1py36/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 198, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/steven/anaconda3/envs/tf1py36/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/steven/anaconda3/envs/tf1py36/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/steven/Git/StyleMapGAN/training/dataset.py", line 53, in __getitem__
    img = Image.open(buffer)
  File "/home/steven/anaconda3/envs/tf1py36/lib/python3.6/site-packages/PIL/Image.py", line 2959, in open
    "cannot identify image file %r" % (filename if filename else fp)
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x7f458e00beb8>

So the question is, do I need to prepare the dataset folder exactly with same structure as CelebAHQ have?

taerimyeon commented 3 years ago

Hi, after trying to find out from download.sh I can make it work with my own dataset, there might be some strict requirements about the dataset folder structure. The result looks like these (the original is on the left, and the reconstructed is on the right).

image image image

I really liking the result but I believe it can be further improved. Because I can only generate an image of size 256x256 and not 1024x1024. Was that because I used the weights from celeba_hq_5M_256_8x8.pt? Should I use ffhq_1024_16x16.pt instead?

I also have another question, since the output of your encoder is actually a feature map of size 64x8x8 (as mentioned in your paper), is it alright if I resize it back into one dimensional vector (of length 4096)? Will that affect the final result later? Because I need to do the a mathematical operation involving a one dimensional latent vector.