Search code examples
deep-learningpytorchkagglegenerative-adversarial-network

How to recursively save GAN generated images to a folder in Kaggle


img_list2 = []
img_list2.append(fake)
for i in range(len(fake)): 
    vutils.save_image(img_list2[-1][i], 
                      "/content/drive/MyDrive/DAugmentn/genPyImage
                       /gpi%d.jpg" % i, normalize=True)

With this code snippet at the end of my model, i successfully saved my Gan generated images recursively to genpyImage subfolder as jpeg files located in my google drive using Colab. I want to do same in kaggle. I have sucessfully loaded the training data and model is working fine in kaggle ,but cannnot save generated images at the end of training in kaggle.I want to take advantage of kaggle GPU.

I tried to create the my genPyImage subfolder in the kaggle output working directory, but not working.


Solution

  • It is just a simple task of saving it into kaggle output directory by replacing the output directory with "/kaggle/working" and then download afterwards into local directly.

    Change from

    vutils.save_image(img_list2[-1][i], "/content/drive/MyDrive/DAugmentn/genPyImage /gpi%d.jpg" % i, normalize=True)

    To

    vutils.save_image(img_list2[-1][i],"/kaggle/working/gpi%d.jpg" % i, normalize=True)