question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Model Path set to to custom model and error when uploading images in the colab

See original GitHub issue

Currently the path to the model is set to the custom model “nitrosocke/redshift-diffusion” and not to the standard “runwayml/stable-diffusion-v1-5”. I suspect this is a leftover from testing, but might be intentional. When uploading the images, they get copied to the session folder, but I get this error

---------------------------------------------------------------------------

KeyError                                  Traceback (most recent call last)

[/usr/local/lib/python3.7/dist-packages/PIL/JpegImagePlugin.py](https://localhost:8080/#) in _save(im, fp, filename)
    611     try:
--> 612         rawmode = RAWMODE[im.mode]
    613     except KeyError:

KeyError: 'RGBA'


During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)

2 frames

[/usr/local/lib/python3.7/dist-packages/PIL/JpegImagePlugin.py](https://localhost:8080/#) in _save(im, fp, filename)
    612         rawmode = RAWMODE[im.mode]
    613     except KeyError:
--> 614         raise OSError("cannot write mode %s as JPEG" % im.mode)
    615 
    616     info = im.encoderinfo

OSError: cannot write mode RGBA as JPEG

I tried running the training anyways, but this error gets thrown

'########:'########:::::'###::::'####:'##::: ##:'####:'##::: ##::'######:::
... ##..:: ##.... ##:::'## ##:::. ##:: ###:: ##:. ##:: ###:: ##:'##... ##::
::: ##:::: ##:::: ##::'##:. ##::: ##:: ####: ##:: ##:: ####: ##: ##:::..:::
::: ##:::: ########::'##:::. ##:: ##:: ## ## ##:: ##:: ## ## ##: ##::'####:
::: ##:::: ##.. ##::: #########:: ##:: ##. ####:: ##:: ##. ####: ##::: ##::
::: ##:::: ##::. ##:: ##.... ##:: ##:: ##:. ###:: ##:: ##:. ###: ##::: ##::
::: ##:::: ##:::. ##: ##:::: ##:'####: ##::. ##:'####: ##::. ##:. ######:::
:::..:::::..:::::..::..:::::..::....::..::::..::....::..::::..:::......::::

Progress:|                         |  0% 18/5000 [00:25<1:20:50,  1.03it/s, loss=0.029, lr=1.99e-6]Traceback (most recent call last):
  File "/content/diffusers/examples/dreambooth/train_dreambooth.py", line 782, in <module>
    main()
  File "/content/diffusers/examples/dreambooth/train_dreambooth.py", line 630, in main
    for step, batch in enumerate(train_dataloader):
  File "/usr/local/lib/python3.7/dist-packages/accelerate/data_loader.py", line 357, in __iter__
    next_batch = next(dataloader_iter)
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 681, in __next__
    data = self._next_data()
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 721, in _next_data
    data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/content/diffusers/examples/dreambooth/train_dreambooth.py", line 324, in __getitem__
    instance_image = Image.open(path)
  File "/usr/local/lib/python3.7/dist-packages/PIL/Image.py", line 2896, in open
    "cannot identify image file %r" % (filename if filename else fp)
PIL.UnidentifiedImageError: cannot identify image file '/content/gdrive/MyDrive/Fast-Dreambooth/Sessions/SD1.5_evktrg_5000_10_v1.0/instance_images/evktrg (45).jpg.png'
Progress:|                         |  0% 18/5000 [00:25<1:57:18,  1.41s/it, loss=0.029, lr=1.99e-6]
Traceback (most recent call last):
  File "/usr/local/bin/accelerate", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/accelerate/commands/accelerate_cli.py", line 43, in main
    args.func(args)
  File "/usr/local/lib/python3.7/dist-packages/accelerate/commands/launch.py", line 837, in launch_command
    simple_launcher(args)
  File "/usr/local/lib/python3.7/dist-packages/accelerate/commands/launch.py", line 354, in simple_launcher
    raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python3', '/content/diffusers/examples/dreambooth/train_dreambooth.py', '--image_captions_filename', '--train_text_encoder', '--save_starting_step=500', '--stop_text_encoder_training=500', '--save_n_steps=0', '--Session_dir=/content/gdrive/MyDrive/Fast-Dreambooth/Sessions/SD1.5_evktrg_5000_10_v1.0', '--pretrained_model_name_or_path=/content/stable-diffusion-v1-5', '--instance_data_dir=/content/gdrive/MyDrive/Fast-Dreambooth/Sessions/SD1.5_evktrg_5000_10_v1.0/instance_images', '--output_dir=/content/models/SD1.5_evktrg_5000_10_v1.0', '--instance_prompt=', '--seed=882683', '--resolution=512', '--mixed_precision=fp16', '--train_batch_size=1', '--gradient_accumulation_steps=1', '--use_8bit_adam', '--learning_rate=2e-6', '--lr_scheduler=polynomial', '--lr_warmup_steps=0', '--max_train_steps=5000']' returned non-zero exit status 1.
Something went wrong

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
TheLastBencommented, Nov 8, 2022

Maybe it would be better to use something like os.path.splitext or use [-1] instead of [1] to actually get the last extension in the filename.

👍

1reaction
TheLastBencommented, Nov 8, 2022

it uses JPG format only for JPG files

if (extension.upper() == "JPG"):
  image.save(new_path_with_file, format="JPEG")

I’ll add the quality=100 argument, thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Loading images in google colab
Use this function to upload files. It will SAVE them as well. def upload_files(): from google.colab import files uploaded = files.upload() ...
Read more >
Training a model for custom object detection (TF 2.x) on ...
In this tutorial, I will be training a Deep Learning model for custom object detection using TensorFlow 2.x on Google Colab. Following is...
Read more >
How To Load Your Own Custom Dataset in Google Colab with ...
In this Neural Networks and Deep Learning Tutorial, we will talk about How To Load Your Own Custom Dataset in Google Colab with...
Read more >
How to Upload Large Image Datasets into Colab from ...
In this tutorial, we will explore ways to upload image datasets into Colab's file system from 3 mediums so they are accessible by...
Read more >
How to Use Google Colab for Deep Learning
Training a sample tensorflow model. Training a machine learning model in Colab is very easy. The best part about it is not having...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found