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.
 

1. Why is Colab not saving my cycleGAN images correctly?

There could be a few reasons for this. It could be due to a coding error, a problem with your data, or a limitation of the Colab platform. It's important to check your code for any mistakes and make sure your data is formatted correctly before running the cycleGAN. If the issue persists, you may need to consider using a different platform or troubleshooting further.

2. How can I fix Colab not saving my cycleGAN images?

If the issue is due to a coding error, you will need to identify and correct the mistake in your code. If it is a data issue, make sure your data is properly formatted and labeled. You may also want to try using a different dataset to see if that resolves the issue. If the problem is with Colab, you may need to contact their support team for assistance or consider using a different platform.

3. Is there a way to save cycleGAN images manually in Colab?

Yes, you can use the "files.download" function in Colab to manually save your cycleGAN images to your local machine. However, this may not be the most efficient solution if you have a large number of images to save.

4. Can I save my cycleGAN images to Google Drive in Colab?

Yes, you can save your images to Google Drive by mounting your drive in Colab and then using the "drive.mount" function. This will allow you to save your images directly to your Google Drive account.

5. What are some alternative platforms to Colab for running cycleGAN?

Some popular alternatives to Colab for running cycleGAN include Google Cloud Platform, Amazon Web Services, and Microsoft Azure. These platforms may offer more resources and flexibility compared to Colab, but they also require more technical expertise and may come with additional costs.

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
2K
  • Programming and Computer Science
Replies
1
Views
1K
Back
Top