2024-08-02 14:24:53 +00:00
|
|
|
import node_helpers
|
2024-08-01 22:53:25 +00:00
|
|
|
|
|
|
|
class CLIPTextEncodeFlux:
|
|
|
|
@classmethod
|
|
|
|
def INPUT_TYPES(s):
|
|
|
|
return {"required": {
|
|
|
|
"clip": ("CLIP", ),
|
|
|
|
"clip_l": ("STRING", {"multiline": True, "dynamicPrompts": True}),
|
|
|
|
"t5xxl": ("STRING", {"multiline": True, "dynamicPrompts": True}),
|
|
|
|
"guidance": ("FLOAT", {"default": 3.5, "min": 0.0, "max": 100.0, "step": 0.1}),
|
|
|
|
}}
|
|
|
|
RETURN_TYPES = ("CONDITIONING",)
|
|
|
|
FUNCTION = "encode"
|
|
|
|
|
2024-08-02 14:24:53 +00:00
|
|
|
CATEGORY = "advanced/conditioning/flux"
|
2024-08-01 22:53:25 +00:00
|
|
|
|
|
|
|
def encode(self, clip, clip_l, t5xxl, guidance):
|
|
|
|
tokens = clip.tokenize(clip_l)
|
|
|
|
tokens["t5xxl"] = clip.tokenize(t5xxl)["t5xxl"]
|
|
|
|
|
|
|
|
output = clip.encode_from_tokens(tokens, return_pooled=True, return_dict=True)
|
|
|
|
cond = output.pop("cond")
|
|
|
|
output["guidance"] = guidance
|
|
|
|
return ([[cond, output]], )
|
|
|
|
|
2024-08-02 14:24:53 +00:00
|
|
|
class FluxGuidance:
|
|
|
|
@classmethod
|
|
|
|
def INPUT_TYPES(s):
|
|
|
|
return {"required": {
|
|
|
|
"conditioning": ("CONDITIONING", ),
|
|
|
|
"guidance": ("FLOAT", {"default": 3.5, "min": 0.0, "max": 100.0, "step": 0.1}),
|
|
|
|
}}
|
|
|
|
|
|
|
|
RETURN_TYPES = ("CONDITIONING",)
|
|
|
|
FUNCTION = "append"
|
|
|
|
|
|
|
|
CATEGORY = "advanced/conditioning/flux"
|
|
|
|
|
|
|
|
def append(self, conditioning, guidance):
|
|
|
|
c = node_helpers.conditioning_set_values(conditioning, {"guidance": guidance})
|
|
|
|
return (c, )
|
|
|
|
|
|
|
|
|
2024-08-01 22:53:25 +00:00
|
|
|
NODE_CLASS_MAPPINGS = {
|
|
|
|
"CLIPTextEncodeFlux": CLIPTextEncodeFlux,
|
2024-08-02 14:24:53 +00:00
|
|
|
"FluxGuidance": FluxGuidance,
|
2024-08-01 22:53:25 +00:00
|
|
|
}
|