Python Colab doesn't save cycleGAN images correctly

  • Thread starter Thread starter BRN
  • Start date Start date
  • Tags Tags
    Images
Click For Summary
The discussion centers on a user experiencing issues with their cycleGAN model implementation, where it works correctly on a university PC but saves empty PNG files when run on Google Colab. The user shares their image-saving code, which involves generating images from a dataset and saving them after re-scaling. Other participants suggest checking if the necessary modules are updated and emphasize the importance of ensuring files are saved in the correct directory on Colab, as the platform can be sensitive to file paths. The conversation encourages troubleshooting by considering differences between the two environments.
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.
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · 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
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 0 ·
Replies
0
Views
1K