mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-06-22 15:59:45 +08:00
Remove node changes except for DynamicPrompt.
This commit is contained in:
parent
6995bb435c
commit
92bca860f8
@ -1,26 +1,22 @@
|
|||||||
import torch
|
import torch
|
||||||
from nodes import MAX_RESOLUTION
|
from nodes import MAX_RESOLUTION
|
||||||
from comfy.parse_choice import translate_choices
|
|
||||||
|
|
||||||
class CLIPTextEncodeSDXLRefiner:
|
class CLIPTextEncodeSDXLRefiner:
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def INPUT_TYPES(s):
|
||||||
return {"required": {
|
return {"required": {
|
||||||
"clip": ("CLIP", ),
|
|
||||||
"ascore": ("FLOAT", {"default": 6.0, "min": 0.0, "max": 1000.0, "step": 0.01}),
|
"ascore": ("FLOAT", {"default": 6.0, "min": 0.0, "max": 1000.0, "step": 0.01}),
|
||||||
"width": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
|
"width": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
|
||||||
"height": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
|
"height": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
|
||||||
"text": ("STRING", {"multiline": True}),
|
"text": ("STRING", {"multiline": True}), "clip": ("CLIP", ),
|
||||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
|
||||||
}}
|
}}
|
||||||
RETURN_TYPES = ("CONDITIONING",)
|
RETURN_TYPES = ("CONDITIONING",)
|
||||||
FUNCTION = "encode"
|
FUNCTION = "encode"
|
||||||
|
|
||||||
CATEGORY = "advanced/conditioning"
|
CATEGORY = "advanced/conditioning"
|
||||||
|
|
||||||
def encode(self, clip, ascore, width, height, text, seed):
|
def encode(self, clip, ascore, width, height, text):
|
||||||
translated_prompt_text = translate_choices(text, seed)
|
tokens = clip.tokenize(text)
|
||||||
tokens = clip.tokenize(translated_prompt_text)
|
|
||||||
cond, pooled = clip.encode_from_tokens(tokens, return_pooled=True)
|
cond, pooled = clip.encode_from_tokens(tokens, return_pooled=True)
|
||||||
return ([[cond, {"pooled_output": pooled, "aesthetic_score": ascore, "width": width,"height": height}]], )
|
return ([[cond, {"pooled_output": pooled, "aesthetic_score": ascore, "width": width,"height": height}]], )
|
||||||
|
|
||||||
@ -28,27 +24,23 @@ class CLIPTextEncodeSDXL:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def INPUT_TYPES(s):
|
||||||
return {"required": {
|
return {"required": {
|
||||||
"clip": ("CLIP", ),
|
|
||||||
"width": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
|
"width": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
|
||||||
"height": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
|
"height": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
|
||||||
"crop_w": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION}),
|
"crop_w": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION}),
|
||||||
"crop_h": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION}),
|
"crop_h": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION}),
|
||||||
"target_width": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
|
"target_width": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
|
||||||
"target_height": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
|
"target_height": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
|
||||||
"text_g": ("STRING", {"multiline": True, "default": "CLIP_G"}),
|
"text_g": ("STRING", {"multiline": True, "default": "CLIP_G"}), "clip": ("CLIP", ),
|
||||||
"text_l": ("STRING", {"multiline": True, "default": "CLIP_L"}),
|
"text_l": ("STRING", {"multiline": True, "default": "CLIP_L"}), "clip": ("CLIP", ),
|
||||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
|
||||||
}}
|
}}
|
||||||
RETURN_TYPES = ("CONDITIONING",)
|
RETURN_TYPES = ("CONDITIONING",)
|
||||||
FUNCTION = "encode"
|
FUNCTION = "encode"
|
||||||
|
|
||||||
CATEGORY = "advanced/conditioning"
|
CATEGORY = "advanced/conditioning"
|
||||||
|
|
||||||
def encode(self, clip, width, height, crop_w, crop_h, target_width, target_height, text_g, text_l, seed):
|
def encode(self, clip, width, height, crop_w, crop_h, target_width, target_height, text_g, text_l):
|
||||||
translated_g = translate_choices(text_g, seed)
|
tokens = clip.tokenize(text_g)
|
||||||
translated_l = translate_choices(text_l, seed)
|
tokens["l"] = clip.tokenize(text_l)["l"]
|
||||||
tokens = clip.tokenize(translated_g)
|
|
||||||
tokens["l"] = clip.tokenize(translated_l)["l"]
|
|
||||||
if len(tokens["l"]) != len(tokens["g"]):
|
if len(tokens["l"]) != len(tokens["g"]):
|
||||||
empty = clip.tokenize("")
|
empty = clip.tokenize("")
|
||||||
while len(tokens["l"]) < len(tokens["g"]):
|
while len(tokens["l"]) < len(tokens["g"]):
|
||||||
|
|||||||
18
nodes.py
18
nodes.py
@ -46,19 +46,14 @@ MAX_RESOLUTION=8192
|
|||||||
class CLIPTextEncode:
|
class CLIPTextEncode:
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def INPUT_TYPES(s):
|
||||||
return {"required": {
|
return {"required": {"text": ("STRING", {"multiline": True}), "clip": ("CLIP", )}}
|
||||||
"text": ("STRING", {"multiline": True}),
|
|
||||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
|
||||||
"clip": ("CLIP", )
|
|
||||||
}}
|
|
||||||
RETURN_TYPES = ("CONDITIONING",)
|
RETURN_TYPES = ("CONDITIONING",)
|
||||||
FUNCTION = "encode"
|
FUNCTION = "encode"
|
||||||
|
|
||||||
CATEGORY = "conditioning"
|
CATEGORY = "conditioning"
|
||||||
|
|
||||||
def encode(self, clip, seed, text):
|
def encode(self, clip, text):
|
||||||
translated_prompt_text = translate_choices(text, seed)
|
tokens = clip.tokenize(text)
|
||||||
tokens = clip.tokenize(translated_prompt_text)
|
|
||||||
cond, pooled = clip.encode_from_tokens(tokens, return_pooled=True)
|
cond, pooled = clip.encode_from_tokens(tokens, return_pooled=True)
|
||||||
return ([[cond, {"pooled_output": pooled}]], )
|
return ([[cond, {"pooled_output": pooled}]], )
|
||||||
|
|
||||||
@ -828,7 +823,6 @@ class GLIGENTextBoxApply:
|
|||||||
"clip": ("CLIP", ),
|
"clip": ("CLIP", ),
|
||||||
"gligen_textbox_model": ("GLIGEN", ),
|
"gligen_textbox_model": ("GLIGEN", ),
|
||||||
"text": ("STRING", {"multiline": True}),
|
"text": ("STRING", {"multiline": True}),
|
||||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
|
||||||
"width": ("INT", {"default": 64, "min": 8, "max": MAX_RESOLUTION, "step": 8}),
|
"width": ("INT", {"default": 64, "min": 8, "max": MAX_RESOLUTION, "step": 8}),
|
||||||
"height": ("INT", {"default": 64, "min": 8, "max": MAX_RESOLUTION, "step": 8}),
|
"height": ("INT", {"default": 64, "min": 8, "max": MAX_RESOLUTION, "step": 8}),
|
||||||
"x": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION, "step": 8}),
|
"x": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION, "step": 8}),
|
||||||
@ -839,11 +833,9 @@ class GLIGENTextBoxApply:
|
|||||||
|
|
||||||
CATEGORY = "conditioning/gligen"
|
CATEGORY = "conditioning/gligen"
|
||||||
|
|
||||||
def append(self, conditioning_to, clip, gligen_textbox_model, text, seed, width, height, x, y):
|
def append(self, conditioning_to, clip, gligen_textbox_model, text, width, height, x, y):
|
||||||
c = []
|
c = []
|
||||||
translated_prompt_text = translate_choices(text, seed)
|
cond, cond_pooled = clip.encode_from_tokens(clip.tokenize(text), return_pooled=True)
|
||||||
tokens = clip.tokenize(translated_prompt_text)
|
|
||||||
_, cond_pooled = clip.encode_from_tokens(tokens, return_pooled=True)
|
|
||||||
for t in conditioning_to:
|
for t in conditioning_to:
|
||||||
n = [t[0], t[1].copy()]
|
n = [t[0], t[1].copy()]
|
||||||
position_params = [(cond_pooled, height // 8, width // 8, y // 8, x // 8)]
|
position_params = [(cond_pooled, height // 8, width // 8, y // 8, x // 8)]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user