From 7a518218e5c463989b6d474259f625a377c495a1 Mon Sep 17 00:00:00 2001 From: spezialspezial <75758219+spezialspezial@users.noreply.github.com> Date: Fri, 17 Feb 2023 22:11:49 +0100 Subject: [PATCH 1/2] AttributeError: 'Namespace' object has no attribute 'log_tokenization' Could be fixed here or alternatively declared in file globals.py --- ldm/invoke/conditioning.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ldm/invoke/conditioning.py b/ldm/invoke/conditioning.py index 99722ff388..542ef22767 100644 --- a/ldm/invoke/conditioning.py +++ b/ldm/invoke/conditioning.py @@ -93,7 +93,7 @@ def _get_conditioning_for_prompt(parsed_prompt: Union[Blend, FlattenedPrompt], p Process prompt structure and tokens, and return (conditioning, unconditioning, extra_conditioning_info) """ - if log_tokens or Globals.log_tokenization: + if log_tokens or getattr(Globals, "log_tokenization", False): print(f"\n>> [TOKENLOG] Parsed Prompt: {parsed_prompt}") print(f"\n>> [TOKENLOG] Parsed Negative Prompt: {parsed_negative_prompt}") @@ -236,7 +236,7 @@ def _get_embeddings_and_tokens_for_prompt(model, flattened_prompt: FlattenedProm fragments = [x.text for x in flattened_prompt.children] weights = [x.weight for x in flattened_prompt.children] embeddings, tokens = model.get_learned_conditioning([fragments], return_tokens=True, fragment_weights=[weights]) - if log_tokens or Globals.log_tokenization: + if log_tokens or getattr(Globals, "log_tokenization", False): text = " ".join(fragments) log_tokenization(text, model, display_label=log_display_label) @@ -296,4 +296,4 @@ def log_tokenization(text, model, display_label=None): if discarded != "": print(f'\n>> [TOKENLOG] Tokens Discarded ({totalTokens - usedTokens}):') - print(f'{discarded}\x1b[0m') \ No newline at end of file + print(f'{discarded}\x1b[0m') From 1ae8986451e32b9e2d212b642b14adf3aab6149d Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Fri, 17 Feb 2023 16:47:32 -0500 Subject: [PATCH 2/2] add log_tokenization to globals --- ldm/invoke/globals.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ldm/invoke/globals.py b/ldm/invoke/globals.py index 7016e8b902..d00f254da5 100644 --- a/ldm/invoke/globals.py +++ b/ldm/invoke/globals.py @@ -54,6 +54,9 @@ Globals.full_precision = False # whether we should convert ckpt files into diffusers models on the fly Globals.ckpt_convert = False +# logging tokenization everywhere +Globals.log_tokenization = False + def global_config_file()->Path: return Path(Globals.root, Globals.config_dir, Globals.models_file)