feat: add early return for prompt expansion when no new tokens should be added

closes https://github.com/lllyasviel/Fooocus/issues/2278, also removes comma at the end added before tokenizer
This commit is contained in:
Manuel Schmid 2024-02-19 15:22:10 +01:00
parent a78f66ffb5
commit f8ca04a406
No known key found for this signature in database
GPG Key ID: 32C4F7569B40B84B

View File

@ -112,6 +112,9 @@ class FooocusExpansion:
max_token_length = 75 * int(math.ceil(float(current_token_length) / 75.0))
max_new_tokens = max_token_length - current_token_length
if max_new_tokens == 0:
return prompt[:-1]
# https://huggingface.co/blog/introducing-csearch
# https://huggingface.co/docs/transformers/generation_strategies
features = self.model.generate(**tokenized_kwargs,