Pad beginning of textual inversion embedding

This commit is contained in:
hentailord85ez 2022-10-10 16:09:06 +01:00 committed by AUTOMATIC1111
parent b340439586
commit 460bbae587
1 changed files with 5 additions and 0 deletions

View File

@ -151,6 +151,11 @@ class FrozenCLIPEmbedderWithCustomWords(torch.nn.Module):
else:
emb_len = int(embedding.vec.shape[0])
iteration = len(remade_tokens) // 75
if (len(remade_tokens) + emb_len) // 75 != iteration:
rem = (75 * (iteration + 1) - len(remade_tokens))
remade_tokens += [id_end] * rem
multipliers += [1.0] * rem
iteration += 1
fixes.append((iteration, (len(remade_tokens) % 75, embedding)))
remade_tokens += [0] * emb_len
multipliers += [weight] * emb_len