-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathi_amplitude.py
More file actions
56 lines (48 loc) · 2.16 KB
/
i_amplitude.py
File metadata and controls
56 lines (48 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Copyright Isaac Emesowum, 2024
"""
This file is part of ComfyUI_IsaacNodes.
ComfyUI_IsaacNodes is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
ComfyUI_IsaacNodes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with ComfyUI_IsaacNodes. If not, see <https://www.gnu.org/licenses/>.
"""
import numpy as np
class I_BinaryAmplitudeGate:
@classmethod
def INPUT_TYPES(s):
return {"required": {
"normalized_amp": ("NORMALIZED_AMPLITUDE",),
"threshold": ("FLOAT", {"default": 0.3, "min": 0.0, "max": 1.0, "step": 0.01}),
"min": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 2.0, "step": 0.01}),
"max": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 2.0, "step": 0.01}),
}}
CATEGORY = "Isaac's Nodes"
RETURN_TYPES = ("NORMALIZED_AMPLITUDE",)
RETURN_NAMES = ("normalized_amp",)
FUNCTION = "gate"
def gate(self, normalized_amp, threshold: float, min: float, max: float):
binary_amp = np.where(normalized_amp > threshold, max, min)
return (binary_amp,)
class I_AmplitudeToWeights:
@classmethod
def INPUT_TYPES(s):
return {"required": {
"normalized_amp": ("NORMALIZED_AMPLITUDE",),
}}
CATEGORY = "Isaac's Nodes"
RETURN_TYPES = ("FLOAT",)
RETURN_NAMES = ("weights",)
FUNCTION = "to_weights"
def to_weights(self, normalized_amp):
return (list(normalized_amp),)
class I_WeightsListToWeights:
@classmethod
def INPUT_TYPES(s):
return {"required": {
"weights_list": ("FLOAT", {}),
}}
CATEGORY = "Isaac's Nodes"
RETURN_TYPES = ("FLOAT",)
RETURN_NAMES = ("weights",)
FUNCTION = "execute"
def execute(self, weights_list,):
return (weights_list[0],)