Skip to content

Commit

Permalink
Add a node to zero out the cond to advanced/conditioning
Browse files Browse the repository at this point in the history
The stability streamlit example passes a zero cond as the negative input
so using this for the negative input makes outputs match the streamlit.
  • Loading branch information
comfyanonymous committed Jun 28, 2023
1 parent 50abf7c commit 2d880fe
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,25 @@ def append(self, conditioning, mask, set_cond_area, strength):
c.append(n)
return (c, )

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()
if "pooled_output" in d:
d["pooled_output"] = torch.zeros_like(d["pooled_output"])
n = [torch.zeros_like(t[0]), d]
c.append(n)
return (c, )

class VAEDecode:
@classmethod
def INPUT_TYPES(s):
Expand Down Expand Up @@ -1350,6 +1369,8 @@ def expand_image(self, image, left, top, right, bottom, feathering):

"LoadLatent": LoadLatent,
"SaveLatent": SaveLatent,

"ConditioningZeroOut": ConditioningZeroOut,
}

NODE_DISPLAY_NAME_MAPPINGS = {
Expand Down

0 comments on commit 2d880fe

Please sign in to comment.