Fine-tune a pretrained GAN model

Najeh_Nafti: <p>I would like to fine tune a pre-trained GAN available online using my own images. For example, BigGAN, which was trained on ImageNet, can generate realistic images. However, I want to generate medical images. How can I fine tune the pre-train models?<br>
<a href="https://github.com/ajbrock/BigGAN-PyTorch" rel="noopener nofollow ugc">https://github.com/ajbrock/BigGAN-PyTorch</a></p>

ptrblck: <p>The inked repository has a <a href="https://github.com/ajbrock/BigGAN-PyTorch#fine-tuning-using-your-own-dataset-or-making-new-training-functions">fine tuning section</a> which explains how the code can be used to fine tune a model using a custom dataset. Generally, I would recommend to also take a look at the paper and check how the model was trained at all. Since your images are coming from another domain (medical images) you would have to experiment if the mentioned fine tuning recipe is working or if you would have to train a model from scratch.</p>

Najeh_Nafti: <p>To use the model on my own dataset, should I need the same GPU resources?</p>

ptrblck: <p>Not necessarily, but you would have to check e.g. the memory requirements and see if you could fit a similar batch size in your setup, as the model convergence (or training hyperparamters) might be sensitive it the batch size.</p>

Najeh_Nafti: <p>Can I train the BigGAN model from scratch based in the below configuration:</p>
<ul>
<li>Training dataset: 7000 of medical image samples</li>
<li>NVIDIA GeForce RTX 3090<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/5/a/5a0410f8bc59126d9258bc0a278f101bd83e5c82.png" data-download-href="https://discuss.pytorch.org/uploads/default/5a0410f8bc59126d9258bc0a278f101bd83e5c82" title="Capture"><img src="https://discuss.pytorch.org/uploads/default/original/3X/5/a/5a0410f8bc59126d9258bc0a278f101bd83e5c82.png" alt="Capture" data-base62-sha1="cQjGqAWl0PfoKPH9yP1tPSpxwoG" width="690" height="113" data-dominant-color="F8F8F8"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Capture</span><span class="informations">963×158 5.77 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></li>
</ul>

ptrblck: <p>I guess it could based on the description:</p>
<blockquote>
<p>You will first need to figure out the maximum batch size your setup can support. The pre-trained models provided here were trained on 8xV100 (16GB VRAM each) which can support slightly more than the BS256 used by default. Once you’ve determined this, you should modify the script so that the batch size times the number of gradient accumulations is equal to your desired total batch size (BigGAN defaults to 2048).<br>
Note also that this script uses the --load_in_mem arg, which loads the entire (~64GB) I128.hdf5 file into RAM for faster data loading. If you don’t have enough RAM to support this (probably 96GB+), remove this argument.</p>
</blockquote>
<p>so you should try to run it and see if you are seeing any unexpected issues.</p>

Najeh_Nafti: <p>I would like to use the basic architecture of BigGAN ‘generator and discriminator’ (basic residual block to build the model) without any other details and without pretrained models just to support high resolution images. is that possible?</p>

rrahman3: <p>Hi Najeh_Nafti,</p>
<p>Were you able to fine-tune BIGGAN on the medical dataset? If so, could you share how you approached it?</p>