Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ClownsharkBatwing authored Aug 6, 2024
1 parent 2cd0aba commit 9673594
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

NODE_CLASS_MAPPINGS = {
"ConditioningAverageScheduler": conditioning.ConditioningAverageScheduler,
"ConditioningMultiply": conditioning.ConditioningMultiply,

"LatentNoiseList": latents.LatentNoiseList,
#"LatentBatch_channels_offset": latents.LatentBatch_channels_offset,
Expand Down
28 changes: 28 additions & 0 deletions conditioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,34 @@ def conditioning_set_values(conditioning, values={}):

return c

def multiply_nested_tensors(structure, scalar):
if isinstance(structure, torch.Tensor):
return structure * scalar
elif isinstance(structure, list):
return [multiply_nested_tensors(item, scalar) for item in structure]
elif isinstance(structure, dict):
return {key: multiply_nested_tensors(value, scalar) for key, value in structure.items()}
else:
return structure


class ConditioningMultiply :
@classmethod
def INPUT_TYPES(s):
return {"required": {"conditioning": ("CONDITIONING", ),
"multiplier": ("FLOAT", {"default": 1.0, "min": -1000.0, "max": 1000.0, "step": 0.01})
}}
RETURN_TYPES = ("CONDITIONING",)
FUNCTION = "main"

CATEGORY = "conditioning"

def main(self, conditioning, multiplier):
c = multiply_nested_tensors(conditioning, multiplier)
return (c,)



class ConditioningCombine:
@classmethod
def INPUT_TYPES(s):
Expand Down

0 comments on commit 9673594

Please sign in to comment.