Files
Claude 1567ea6de9 Fix 10 bugs across all modules found during code review
Critical fixes:
- AnyAspectRatio: remove dead duplicate calculation that was overwriting
  itself with a wrong formula (correct formula kept on lines 55-56)
- LoadImageResizer: fix trailing comma that made resized_mask a tuple
  instead of a value; properly convert alpha channel to float32 tensor
- openAI_PoP: replace deprecated openai v0 API (openai.Image.create,
  openai.error.*) with modern openai>=1.0 client; fix hardcoded Windows
  backslash path with os.path.dirname(__file__); fix log/image dirs to
  be relative to module file instead of CWD
- LoraStackLoaders: add missing `import comfy.sd` (was NameError at
  runtime); fix filter from l[0] (switch, never 'None') to l[1]
  (lora_name); fix `lora_name is None` to `== 'None'` for string
  comparison; fix display name mapping key LoraStackLoader10 ->
  LoraStackLoader10_PoP

High severity fixes:
- Conditioning: guard std() divisions with `if std > 0` to prevent
  NaN/Inf crash when tensor has zero variance
- EfficientAttention: move dim_head calculation after dimension
  truncation so reshape is always valid; add divisibility check;
  fix output reshape to use min_dim not dim_q
- VAEEncodeDecodeLoader: remove 5 debug print statements from decode()
- CNutil: remove 3 debug print statements from resize_to_resolution()

Minor fixes:
- AdaptiveCannyDetector: fix `Category` -> `CATEGORY` (case-sensitive,
  ComfyUI was ignoring the node category)
- LoadImageResizer: remove duplicate CATEGORY = "image" definition
- requirements.txt: remove unused matplotlib/seaborn; add missing Pillow

https://claude.ai/code/session_01QPLKoy7P41H3QPB6tMrpPh
2026-02-25 10:13:43 +00:00

92 lines
3.9 KiB
Python

class ConditioningMultiplier_PoP:
@classmethod
def INPUT_TYPES(cls):
return {"required": {"conditioning": ("CONDITIONING", ), "multiplier": ("FLOAT", {"default": 1.0, "min": -1, "max": 3.0})}}
RETURN_TYPES = ("CONDITIONING",)
FUNCTION = "multiply_conditioning_strength"
CATEGORY = "PoP"
def multiply_conditioning_strength(self, conditioning, multiplier):
# Validate the input types for 'conditioning' and 'multiplier'
if not isinstance(conditioning, list) or (not isinstance(multiplier, float) and not isinstance(multiplier, int)):
raise ValueError("Invalid input types")
#Initialize a new list to store the modified conditioning objects
new_conditioning = []
# Iterate through each element in the 'conditioning' list
for index, (tensor, attributes) in enumerate(conditioning):
# Multiply the tensor by the given multiplier
new_tensor = tensor.clone()
new_attributes = attributes.copy()
# Multiply the new tensor by the given multiplier
new_tensor *= multiplier
# If 'pooled_output' exists, scale it by the multiplier
if "pooled_output" in attributes:
new_pooled_output = attributes["pooled_output"].clone()
new_pooled_output *= multiplier
new_attributes["pooled_output"] = new_pooled_output
# Add the modified tensor and attributes to the new_conditioning list
new_conditioning.append([new_tensor, new_attributes])
# Return the modified 'conditioning' object
return (new_conditioning, ) # NOTE: Returning new_conditioning here
class ConditioningNormalizer_PoP:
@classmethod
def INPUT_TYPES(cls):
return {"required": {"conditioning": ("CONDITIONING", )}}
RETURN_TYPES = ("CONDITIONING",)
FUNCTION = "normalize_conditioning"
CATEGORY = "PoP"
def normalize_conditioning(self, conditioning):
# Validate the input type for 'conditioning'
if not isinstance(conditioning, list):
raise ValueError("Invalid input type")
# Initialize a new list to store the modified conditioning objects
new_conditioning = []
# Iterate through the 'conditioning' list
for index, (tensor, attributes) in enumerate(conditioning): #Q what is this doing? A iterating through the conditioning list
# Create new objects to store modified tensor and attributes
new_tensor = tensor.clone()
new_attributes = attributes.copy()
# Normalize the new tensor to have zero mean and unit variance
new_tensor -= new_tensor.mean()
std = new_tensor.std()
if std > 0:
new_tensor /= std
# If 'pooled_output' exists, normalize it
if "pooled_output" in attributes:
new_pooled_output = attributes["pooled_output"].clone()
new_pooled_output -= new_pooled_output.mean()
pooled_std = new_pooled_output.std()
if pooled_std > 0:
new_pooled_output /= pooled_std
new_attributes["pooled_output"] = new_pooled_output
# Add the modified tensor and attributes to the new_conditioning list
new_conditioning.append([new_tensor, new_attributes])
# Return the modified 'conditioning' object
return (new_conditioning, ) # NOTE: Returning new_conditioning here
#create node class mappings and node display name mappings
NODE_CLASS_MAPPINGS = {
"ConditioningMultiplier_PoP": ConditioningMultiplier_PoP,
"ConditioningNormalizer_PoP": ConditioningNormalizer_PoP
}
NODE_DISPLAY_NAME_MAPPINGS = {
"ConditioningMultiplier_PoP": "Conditioning Multiplier PoP",
"ConditioningNormalizer_PoP": "Conditioning Normalizer PoP"
}