InvokeAI icon indicating copy to clipboard operation
InvokeAI copied to clipboard

[bug]: Invoke doesn't start with some embeddings

Open AshtakaOOf opened this issue 2 years ago • 7 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

OS

Linux

GPU

cuda

VRAM

No response

What happened?

When launching with some embeddings (I believe they were either trained https://github.com/AUTOMATIC1111/stable-diffusion-webui or https://github.com/cafeai/stable-textual-inversion-cafe) Invoke just crashes with

╭────────────────────────── Traceback (most recent call last) ───────────────────────────╮
│ /home/ashtaka/AI/InvokeAI/scripts/invoke.py:4 in <module>                              │
│                                                                                        │
│   1 #!/usr/bin/env python                                                              │
│   2                                                                                    │
│   3 import ldm.invoke.CLI                                                              │
│ ❱ 4 ldm.invoke.CLI.main()                                                              │
│   5                                                                                    │
│   6                                                                                    │
│                                                                                        │
│ /home/ashtaka/AI/InvokeAI/ldm/invoke/CLI.py:117 in main                                │
│                                                                                        │
│   114 │                                                                                │
│   115 │   # preload the model                                                          │
│   116 │   try:                                                                         │
│ ❱ 117 │   │   gen.load_model()                                                         │
│   118 │   except AssertionError:                                                       │
│   119 │   │   emergency_model_reconfigure()                                            │
│   120 │   │   sys.exit(-1)                                                             │
│                                                                                        │
│ /home/ashtaka/AI/InvokeAI/ldm/generate.py:818 in load_model                            │
│                                                                                        │
│    815 │   │   '''                                                                     │
│    816 │   │   preload model identified in self.model_name                             │
│    817 │   │   '''                                                                     │
│ ❱  818 │   │   self.set_model(self.model_name)                                         │
│    819 │                                                                               │
│    820 │   def set_model(self,model_name):                                             │
│    821 │   │   """                                                                     │
│                                                                                        │
│ /home/ashtaka/AI/InvokeAI/ldm/generate.py:858 in set_model                             │
│                                                                                        │
│    855 │   │                                                                           │
│    856 │   │   seed_everything(random.randrange(0, np.iinfo(np.uint32).max))           │
│    857 │   │   if self.embedding_path is not None:                                     │
│ ❱  858 │   │   │   self.model.embedding_manager.load(                                  │
│    859 │   │   │   │   self.embedding_path, self.precision == 'float32' or self.precis │
│    860 │   │   │   )                                                                   │
│    861                                                                                 │
│                                                                                        │
│ /home/ashtaka/AI/InvokeAI/ldm/modules/embedding_manager.py:238 in load                 │
│                                                                                        │
│   235 │   │   │   ckpt_paths = [ckpt_paths]                                            │
│   236 │   │   ckpt_paths = self._expand_directories(ckpt_paths)                        │
│   237 │   │   for c in ckpt_paths:                                                     │
│ ❱ 238 │   │   │   self._load(c,full)                                                   │
│   239 │   │   # remember that we know this term and don't try to download it again fro │
│   240 │   │   # note that if the concept name is also provided and different from the  │
│   241 │   │   # both will be stored in this dictionary                                 │
│                                                                                        │
│ /home/ashtaka/AI/InvokeAI/ldm/modules/embedding_manager.py:276 in _load                │
│                                                                                        │
│   273 │   │   │   │   print(f">> {ckpt_path} has >1 embedding, only the first will be  │
│   274 │   │   │                                                                        │
│   275 │   │   │   string_to_param_dict = ckpt['string_to_param']                       │
│ ❱ 276 │   │   │   embedding = list(string_to_param_dict.values())[0]                   │
│   277 │   │   │   self.add_embedding(token_str, embedding, full)                       │
│   278 │   │                                                                            │
│   279 │   │   # Handle .bin textual inversion files from Huggingface Concepts          │
│                                                                                        │
│ /home/ashtaka/.conda/envs/invokeai/lib/python3.9/site-packages/torch/nn/modules/contai │
│ ner.py:714 in values                                                                   │
│                                                                                        │
│   711 │   def values(self) -> Iterable[Any]:                                           │
│   712 │   │   r"""Return an iterable of the ParameterDict values.                      │
│   713 │   │   """                                                                      │
│ ❱ 714 │   │   return (self[k] for k in self._keys)                                     │
│   715 │                                                                                │
│   716 │   def update(self, parameters: Union[Mapping[str, Any], 'ParameterDict']) -> N │
│   717 │   │   r"""Update the :class:`~torch.nn.ParameterDict` with the key-value pairs │
│                                                                                        │
│ /home/ashtaka/.conda/envs/invokeai/lib/python3.9/site-packages/torch/nn/modules/module │
│ .py:1207 in __getattr__                                                                │
│                                                                                        │
│   1204 │   │   │   modules = self.__dict__['_modules']                                 │
│   1205 │   │   │   if name in modules:                                                 │
│   1206 │   │   │   │   return modules[name]                                            │
│ ❱ 1207 │   │   raise AttributeError("'{}' object has no attribute '{}'".format(        │
│   1208 │   │   │   type(self).__name__, name))                                         │
│   1209 │                                                                               │
│   1210 │   def __setattr__(self, name: str, value: Union[Tensor, 'Module']) -> None:   │
╰────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'ParameterDict' object has no attribute '_keys'

Screenshots

There is nothing to screenshot

Additional context

Here is one of the embeddings that crashes https://cdn.discordapp.com/attachments/1049117806605643846/1049143254337196042/crashfever-style-34000.pt

And here is a discord thread https://discord.com/channels/1020123559063990373/1049117806605643846/1049117806605643846

Contact Details

discord: Ashtaka#0043

AshtakaOOf avatar Dec 06 '22 15:12 AshtakaOOf

other embeddings have the embedding data in string_to_param_dict[0], ones like this somehow decide to make string_to_param_dict not a dict and just drop the embedding right here. this needs to be handled by inspecting the type at runtime.

a problem we have with these files is that they are all called .pt and that extension says nothing other than file saved by pytorch, so figuring out what they are is a case of setting a breakpoint and dumping out their contents to see if they can be interpreted somehow. so even if we get one version working there's no guarantee some other version isn't going to just pop up. it's like the xkcd standards comic but there's no standards.

damian0815 avatar Dec 07 '22 09:12 damian0815

Somehow Auto1111 deals with it fine :( But their code is a mess… So how could I make these embeddings work properly with Invoke?

AshtakaOOf avatar Dec 07 '22 12:12 AshtakaOOf

I have the same issue but mine ends with Pickle exhausted before seeing STOP Untitled

vonhex avatar Dec 13 '22 14:12 vonhex

Pretty sure that's a completely different error :thinking:

AshtakaOOf avatar Dec 13 '22 16:12 AshtakaOOf

I am working on this now.

lstein avatar Dec 15 '22 15:12 lstein

Thanks so much!

vonhex avatar Dec 15 '22 15:12 vonhex

for more info, I added the embeddings from huggingface into the embedding folder within invokeai and it stops opening until I remove a specific amount of them. im assuming its a particular file but the cmd closes before I can see it. If I do manage to get some loaded it then says certain prompts are already loaded and basically takes 10+ minutes to change a model

vonhex avatar Dec 15 '22 16:12 vonhex

There is a pull request pending which should fix this problem.

lstein avatar Dec 15 '22 18:12 lstein

thanks a ton!

vonhex avatar Dec 15 '22 19:12 vonhex

Untitled Dont know if im just being dumb but now I get this with the embeddings

vonhex avatar Dec 15 '22 23:12 vonhex

have you checked if your parameter name contains "." ?

damian0815 avatar Dec 16 '22 01:12 damian0815

How do I check that?

vonhex avatar Dec 16 '22 01:12 vonhex

i guess you'd know if you typed it

damian0815 avatar Dec 16 '22 01:12 damian0815

really no idea what's wrong here, sorry, i don't have enough information to give you any kind of answer at all.

damian0815 avatar Dec 16 '22 01:12 damian0815

Oh sorry, when I add the embedding from huggingface, I get this error when opening invoke and it crashes.

vonhex avatar Dec 16 '22 01:12 vonhex

🤔 hmm. what is the filename of the embedding? fwiw - for embeddings in the huggingface concepts library you can just prompt <embedding-name> and Invoke will download it for you automatically. best to try this out on the CLI version because then you get feedback about whether it's working.

damian0815 avatar Dec 16 '22 01:12 damian0815

I may be an idiot but I downloaded all 800 or so of them. Haha but I didn't realize I could do that!

vonhex avatar Dec 16 '22 01:12 vonhex

The crash is fixed for me Invoke ftw

AshtakaOOf avatar Dec 16 '22 02:12 AshtakaOOf

Hell yea!

vonhex avatar Dec 16 '22 02:12 vonhex