unetgan icon indicating copy to clipboard operation
unetgan copied to clipboard

how to use the code by my own images?

Open sddzlsc opened this issue 3 years ago • 2 comments

sddzlsc avatar Jan 10 '21 09:01 sddzlsc

Hi,

Thanks for your question. This repository is a copy of https://github.com/ajbrock/BigGAN-PyTorch, with modifications to turn BigGAN into U-NetGAN. Thus, you should have a look at the instructions in their readme in the paragraph "Fine-tuning, Using Your Own Dataset, or Making New Training Functions".

I will point to the necessary steps hereafter:

First, you need to create your own standard PyTorch Dataloader object and add it to train.py like it is done here https://github.com/boschresearch/unetgan/blob/0cdb56853023d7d8b3ae1accc480ad6e2238a4df/train.py#L230-L247

You will need to give your dataset a name, let's say "cityscapes", for the --dataset flag https://github.com/boschresearch/unetgan/blob/0cdb56853023d7d8b3ae1accc480ad6e2238a4df/utils.py#L55-L59

Next, you need make a new entry for your dataset (e.g. "cityscapes") in each of the convenience dicts. As you can see in the example below, I added "coco", "FFHQ" and "celeba128" https://github.com/boschresearch/unetgan/blob/0cdb56853023d7d8b3ae1accc480ad6e2238a4df/utils.py#L424-L450

The original BigGAN code has a function to turn a dataset into hdf5 format. I don't use that here. What you need to do though is to add your own dataloader also to calculate_inception_moments.py. This produces a .npz file which is loaded to compute the FID during training.

Let me know if that worked for you.

Best, Edgar

edgarschnfld avatar Jan 15 '21 11:01 edgarschnfld

@sddzlsc did u use the code with the used datasets?

nnajeh avatar Mar 26 '21 10:03 nnajeh