Remove VisualStylePromptEncode and prevent side effects by copying conds

This commit is contained in:
Pam
2024-03-22 16:11:23 +05:00
parent 614c68c89b
commit 6f0463e190
2 changed files with 41 additions and 61 deletions
+13
View File
@@ -0,0 +1,13 @@
import torch
def copy_cond(cond: list[list[torch.Tensor | dict]], device="cpu"):
cond_copy = [[]]
t_copy = cond_copy[0]
for t in cond:
t_copy.append(t[0].detach().clone().to(device=device))
if len(t) > 1 and isinstance(t[1], dict):
t_copy.append(t[1].copy())
if "pooled_output" in t[1]:
t_copy[1]["pooled_output"] = t[1]["pooled_output"].detach().clone().to(device=device)
return cond_copy