mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
bring in prompt parser from fix-prompts branch
attention is parsed but ignored, blends old syntax doesn't work, conjunctions are parsed but ignored, the only part that's used here is the new .blend() syntax and cross-attention control using .swap()
This commit is contained in:
@ -439,6 +439,13 @@ class FrozenCLIPEmbedder(AbstractEncoder):
|
||||
param.requires_grad = False
|
||||
|
||||
def forward(self, text, **kwargs):
|
||||
|
||||
should_return_tokens = False
|
||||
if 'return_tokens' in kwargs:
|
||||
should_return_tokens = kwargs.get('return_tokens', False)
|
||||
# self.transformer doesn't like having extra kwargs
|
||||
kwargs.pop('return_tokens')
|
||||
|
||||
batch_encoding = self.tokenizer(
|
||||
text,
|
||||
truncation=True,
|
||||
@ -451,7 +458,7 @@ class FrozenCLIPEmbedder(AbstractEncoder):
|
||||
tokens = batch_encoding['input_ids'].to(self.device)
|
||||
z = self.transformer(input_ids=tokens, **kwargs)
|
||||
|
||||
if kwargs.get('return_tokens', False):
|
||||
if should_return_tokens:
|
||||
return z, tokens
|
||||
else:
|
||||
return z
|
||||
|
Reference in New Issue
Block a user