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.

Training does not work AttributeError: 'NoneType' object has no attribute 'detach

See original GitHub issue

The following error message appears and training cannot be started. Is this due to a misconfiguration? Note: This log is from standalone DreamArtist, but the exact same error was output in Extension.

Training at rate of 0.005 until step 30000
Preparing dataset...
100%|██████████████████████████████████████| 1/1 [00:05<00:00,  5.43s/it]
  0%|                                          | 0/30000 [00:01<?, ?it/s]
Error completing request
Arguments: ('emma', '0.005', 1, 'D:\\StableDiffusion\\work\\APT\\emma', 'dream_artist', 512, 512, 30000, 1000, 1000, 'D:\\SDWU\\DreamArtist-stable-diffusion\\textual_inversion_templates\\default.txt', True, True, '', '', 15, 0, 7, -1.0, 512, 512, 5.0, '', True, False, 1, 1) {}
Traceback (most recent call last):
  File "D:\SDWU\DreamArtist-stable-diffusion\modules\ui.py", line 185, in f
    res = list(func(*args, **kwargs))
  File "D:\SDWU\DreamArtist-stable-diffusion\webui.py", line 54, in f
    res = func(*args, **kwargs)
  File "D:\SDWU\DreamArtist-stable-diffusion\modules\dream_artist\ui.py", line 36, in train_embedding
    embedding, filename = modules.dream_artist.cptuning.train_embedding(*args)
  File "D:\SDWU\DreamArtist-stable-diffusion\modules\dream_artist\cptuning.py", line 436, in train_embedding
    f"grad:{embedding.vec.grad.detach().cpu().abs().mean().item():.7f}, "
AttributeError: 'NoneType' object has no attribute 'detach'

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
soknifecommented, Nov 13, 2022

Some findings if anyone can corroborate. This setup has worked for me.

  1. Create a DreamArtist embedding with any number of positive and negative vectors.
  2. DreamArtist train the embedding with a prompt template file that is just “[name]” and for only 1 step (or more haven’t tested if it makes any long term difference).
  3. DreamArtist train the embedding again with a prompt template file that is just “[filewords]” and for n steps.

Note you can include fixed text such as “a drawing of” in step 2 or 3, e.g. “a drawing of [name]”

Otherwise I get either the error described in this issue or in #4, if I:

  1. Perform steps 2 or 3 out of order
  2. Use any prompt template file that combines “[name]” and “[filewords]”, e.g. “a drawing of [name], [filewords]”
0reactions
ausbosscommented, Nov 29, 2022

I updated to the latest version and set the Prompt template file to style.txt and the training started normally. I also tried a second run with the same settings, which also seems to work fine. If you had the same error as I did, please give it a try.

yep this worked for me. Thank you for sharing your solution. I switched to style.txt. Clicked train then saw it got passed the error and so I stopped it and now I can use whatever template now and it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do I get AttributeError: 'NoneType' object has no attribute ...
It means the object you are trying to access None . None is a Null variable ...
Read more >
attributeerror: 'nonetype' object has no attribute 'detach'
This is the problem. You're assigning elem to the result of the click() function, which doesn't return anything, therefore it returns None ....
Read more >
AttributeError: 'NoneType' object has no attribute 'detach'
I am trying to create a hybrid recommender system using pytorch lightning. Here are my dataset and model classes: import pytorch_lightning ...
Read more >
AttributeError: 'NoneType' object has no attribute 'get_items'
Hello everyone, We have imported one job (Local Resolution Estimation) from an old project and an old instance onto a newly installed, ...
Read more >
AttributeError: 'NoneType' object has no attribute 'dtype'
Hello! I've been trying to fine-tune a german gpt-2 Modell with a dataset from huggingface via TensorFlow. When trying to start the Training...
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