mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
Fix Long Prompts
`extend` to `repeat` Extend only works on singleton dimensions, mia culpa.
This commit is contained in:
@@ -152,7 +152,7 @@ def pad_to_same_length(pipe, embeds):
|
||||
empty_embed = pipe.encode_prompt("", device, 1, False)
|
||||
max_token_count = max([embed.shape[1] for embed in embeds])
|
||||
repeats = max_token_count - min([embed.shape[1] for embed in embeds])
|
||||
empty_batched = empty_embed[0].to(embeds[0].device).expand(embeds[0].shape[0], repeats, -1)
|
||||
empty_batched = empty_embed[0].to(embeds[0].device).repeat(embeds[0].shape[0], repeats // empty_embed[0].shape[1], 1)
|
||||
for i, embed in enumerate(embeds):
|
||||
if embed.shape[1] < max_token_count:
|
||||
embed = torch.cat([embed, empty_batched], dim=1)
|
||||
|
||||
Reference in New Issue
Block a user