Colab doesn't save cycleGAN images correctly

  • Python
  • Thread starter BRN
  • Start date
  • Tags
    Images
In summary, the speaker is experiencing a problem with saving generated images while using the cycleGAN model on Colab. The code provided shows how the images are saved, but the speaker is unsure why it is not working on Colab compared to a university-provided PC. They are seeking suggestions for potential solutions and mention the possibility of using Google Colab and ensuring that all modules are up to date and the files are saved in the correct folder.
  • #1
BRN
108
10
Hi everyone,
I made an implementation of the cycleGAN model but I find a strange problem.
If I run the model with a PC supplied to the university it works, while on Colab, it saves me empty PNG files. Consider that I use a standard GPU on Colab.

This is my code to save the generated images

save generated function:
def save_generated(image_ds, label, generator_model, outputs_path):
    i =  1
    for img in image_ds:
        generated = generator_model(img, training = False)[0].numpy()
     
        generated = (generated * 127.5 + 127.5).astype(np.uint8)   # re-scale
        im = Image.fromarray(generated)
        im.save(f'{outputs_path}{str(label)}_fake_image_{str(i)}.png')
        i += 1

Some idea?

Thank you.
 
Last edited by a moderator:
Technology news on Phys.org
  • #2
Are you using Google Colab? Are you sure the modules are updated? Google Colab is touchy with where files are saved. Make sure it's in the proper folder. Keep thinking of ways the two environments could be different and make the adjustments.
 

Similar threads

  • Programming and Computer Science
Replies
3
Views
2K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
3
Views
3K
  • Programming and Computer Science
Replies
5
Views
3K
  • Programming and Computer Science
Replies
1
Views
1K
Back
Top