From 172ce3dc250ceec3ef5f90ea0d344f022119149f Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Sun, 19 Feb 2023 22:30:57 -0500 Subject: [PATCH] correctly detect when an embedding is incompatible with the current model - Fixed the test for token length; tested on several .pt and .bin files - Also added a __main__ entrypoint for CLI.py, to make pdb debugging a bit more convenient. --- ldm/invoke/CLI.py | 4 ++++ ldm/modules/textual_inversion_manager.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ldm/invoke/CLI.py b/ldm/invoke/CLI.py index d639c16640..5fd9a55ddb 100644 --- a/ldm/invoke/CLI.py +++ b/ldm/invoke/CLI.py @@ -1387,3 +1387,7 @@ def check_internet() -> bool: return True except: return False + +if __name__ == '__main__': + main() + diff --git a/ldm/modules/textual_inversion_manager.py b/ldm/modules/textual_inversion_manager.py index 69f8282983..19fa5f6b0f 100644 --- a/ldm/modules/textual_inversion_manager.py +++ b/ldm/modules/textual_inversion_manager.py @@ -84,7 +84,7 @@ class TextualInversionManager: return elif ( self.text_encoder.get_input_embeddings().weight.data[0].shape[0] - != embedding_info["embedding"].shape[0] + != embedding_info['token_dim'] ): print( f"** Notice: {ckpt_path.parents[0].name}/{ckpt_path.name} was trained on a model with a different token dimension. It can't be used with this model."