Support Clip skip

This commit is contained in:
nkchocoai
2024-02-18 00:22:29 +09:00
parent c23711433c
commit 5449ab7cf0
6 changed files with 27 additions and 5 deletions
+4 -1
View File
@@ -55,6 +55,7 @@ class Capture:
update_pnginfo_dict(MetaField.POSITIVE_PROMPT, "Positive prompt")
update_pnginfo_dict(MetaField.NEGATIVE_PROMPT, "Negative prompt")
update_pnginfo_dict(MetaField.STEPS, "Steps")
sampler_names = inputs.get(MetaField.SAMPLER_NAME, [])
@@ -70,12 +71,14 @@ class Capture:
update_pnginfo_dict(MetaField.CFG, "CFG Scale")
update_pnginfo_dict(MetaField.SEED, "Seed")
update_pnginfo_dict(MetaField.CLIP_SKIP, "Clip skip")
image_widths = inputs.get(MetaField.IMAGE_WIDTH, [])
image_heights = inputs.get(MetaField.IMAGE_HEIGHT, [])
if len(image_widths) > 0 and len(image_heights) > 0:
pnginfo_dict["Size"] = f"{image_widths[0][1]}x{image_heights[0][1]}"
update_pnginfo_dict(MetaField.MODEL_NAME, "Model name")
update_pnginfo_dict(MetaField.MODEL_NAME, "Model")
update_pnginfo_dict(MetaField.MODEL_HASH, "Model hash")
return pnginfo_dict
+12 -1
View File
@@ -1,6 +1,11 @@
from .meta import MetaField
from .validators import is_positive_prompt, is_negative_prompt
from .formatters import calc_model_hash, get_scaled_width, get_scaled_height
from .formatters import (
calc_model_hash,
convert_skip_clip,
get_scaled_width,
get_scaled_height,
)
CAPTURE_FIELD_LIST = {
@@ -8,6 +13,12 @@ CAPTURE_FIELD_LIST = {
MetaField.MODEL_NAME: {"field_name": "ckpt_name"},
MetaField.MODEL_HASH: {"field_name": "ckpt_name", "format": calc_model_hash},
},
"CLIPSetLastLayer": {
MetaField.CLIP_SKIP: {
"field_name": "stop_at_clip_layer",
"format": convert_skip_clip,
},
},
"EmptyLatentImage": {
MetaField.IMAGE_WIDTH: {"field_name": "width"},
MetaField.IMAGE_HEIGHT: {"field_name": "height"},
+6 -1
View File
@@ -1,6 +1,6 @@
# https://github.com/jags111/efficiency-nodes-comfyui
from ..meta import MetaField
from ..formatters import calc_model_hash
from ..formatters import calc_model_hash, convert_skip_clip
SAMPLERS = {
"KSampler (Efficient)": {
@@ -21,6 +21,7 @@ CAPTURE_FIELD_LIST = {
"Efficient Loader": {
MetaField.MODEL_NAME: {"field_name": "ckpt_name"},
MetaField.MODEL_HASH: {"field_name": "ckpt_name", "format": calc_model_hash},
MetaField.CLIP_SKIP: {"field_name": "clip_skip", "format": convert_skip_clip},
MetaField.POSITIVE_PROMPT: {"field_name": "positive"},
MetaField.NEGATIVE_PROMPT: {"field_name": "negative"},
MetaField.IMAGE_WIDTH: {"field_name": "empty_latent_width"},
@@ -32,6 +33,10 @@ CAPTURE_FIELD_LIST = {
"field_name": "base_ckpt_name",
"format": calc_model_hash,
},
MetaField.CLIP_SKIP: {
"field_name": "base_clip_skip",
"format": convert_skip_clip,
},
MetaField.POSITIVE_PROMPT: {"field_name": "positive"},
MetaField.NEGATIVE_PROMPT: {"field_name": "negative"},
MetaField.IMAGE_WIDTH: {"field_name": "empty_latent_width"},
+4
View File
@@ -21,6 +21,10 @@ def calc_model_hash(model_name, input_data):
return model_hash
def convert_skip_clip(stop_at_clip_layer, input_data):
return stop_at_clip_layer * -1
def get_scaled_width(scaled_by, input_data):
samples = input_data["samples"][0]["samples"]
return round(samples.shape[3] * scaled_by * 8)
+1
View File
@@ -6,6 +6,7 @@ class MetaField(IntEnum):
MODEL_HASH = 1
POSITIVE_PROMPT = 10
NEGATIVE_PROMPT = 11
CLIP_SKIP = 12
SEED = 20
STEPS = 21
CFG = 22
-2
View File
@@ -1,5 +1,3 @@
import json
from collections import deque
from .defs.samplers import SAMPLERS