Colab doesn't save cycleGAN images correctly

  • Context: Python 
  • Thread starter Thread starter BRN
  • Start date Start date
  • Tags Tags
    Images
Click For Summary
SUMMARY

The forum discussion addresses an issue with saving images generated by a cycleGAN model in Google Colab, where users encounter empty PNG files. The user provided a code snippet for saving images, which includes re-scaling the generated images and saving them using the PIL library. The problem appears to stem from differences in file handling between the university's PC and Google Colab, suggesting that the output path may not be correctly set in the Colab environment. Users are advised to ensure that the modules are updated and to verify the output directory.

PREREQUISITES
  • Understanding of cycleGAN architecture and functionality
  • Familiarity with Python programming and image processing using PIL
  • Knowledge of Google Colab environment and file management
  • Basic experience with NumPy for image manipulation
NEXT STEPS
  • Investigate Google Colab file system and proper output directory usage
  • Learn about debugging image saving issues in Python with PIL
  • Explore cycleGAN model implementations and their common pitfalls
  • Review Google Colab documentation for module updates and environment differences
USEFUL FOR

Machine learning practitioners, data scientists, and developers working with generative models, particularly those using Google Colab for training and image generation tasks.

BRN
Messages
107
Reaction score
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

[CODE lang="python" title="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 [/CODE]

Some idea?

Thank you.
 
Last edited by a moderator:
Technology news on Phys.org
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

Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 0 ·
Replies
0
Views
2K