ComfyUI の ConditioningZeroOut ノードの使い方
カテゴリ:deeplearning
蒸留モデルは CFG 1 で使うことが前提とされている。CFG 1 ではネガティブプロンプトを使わないので、テキストエンコーダーがネガティブプロンプトを処理する時間が無駄になる。なので、ポジティブプロンプトを ConditioningZeroOut 通すことで無内容のコンディショニングをつくることで、テキストエンコーダーがネガティブプロンプトを処理しなくてもネガティブコンディショニングを作成できる。
ConditionigZeroOut ノードは nodes.py にある。
class ConditioningZeroOut:
@classmethod
def INPUT_TYPES(s):
return {"required": {"conditioning": ("CONDITIONING", )}}
RETURN_TYPES = ("CONDITIONING",)
FUNCTION = "zero_out"
CATEGORY = "advanced/conditioning"
def zero_out(self, conditioning):
c = []
for t in conditioning:
d = t[1].copy()
pooled_output = d.get("pooled_output", None)
if pooled_output is not None:
d["pooled_output"] = torch.zeros_like(pooled_output)
conditioning_lyrics = d.get("conditioning_lyrics", None)
if conditioning_lyrics is not None:
d["conditioning_lyrics"] = torch.zeros_like(conditioning_lyrics)
n = [torch.zeros_like(t[0]), d]
c.append(n)
return (c, )