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
71 lines
2.2 KiB
Python
71 lines
2.2 KiB
Python
class AnyAspectRatio:
|
|
"""
|
|
An aspect ratio node
|
|
|
|
This node takes width and height ratios and calculates the corresponding width and height values.
|
|
"""
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(s):
|
|
return {
|
|
"required": {
|
|
"width_ratio": ("INT", {
|
|
"default": 16,
|
|
"min": 1,
|
|
"max": 4096,
|
|
"step": 1,
|
|
"display": "number"
|
|
}),
|
|
"height_ratio": ("INT", {
|
|
"default": 9,
|
|
"min": 1,
|
|
"max": 4096,
|
|
"step": 1,
|
|
"display": "number"
|
|
}),
|
|
"side_length": ("INT", {
|
|
"default": 1024,
|
|
"min": 1,
|
|
"max": 4096,
|
|
"step": 1,
|
|
"display": "number"
|
|
}),
|
|
"rounding_value": ("INT", {
|
|
"default": 64,
|
|
"min": 1,
|
|
"max": 4096,
|
|
"step": 1,
|
|
"display": "number"
|
|
}),
|
|
},
|
|
}
|
|
|
|
RETURN_TYPES = ("INT", "INT")
|
|
RETURN_NAMES = ("width", "height")
|
|
|
|
FUNCTION = "calculate"
|
|
|
|
CATEGORY = "PoP"
|
|
|
|
# Calculate the width and height based on the input ratios
|
|
def calculate(self, width_ratio, height_ratio, side_length, rounding_value):
|
|
total_pixels = side_length**2
|
|
width = int((total_pixels * width_ratio / height_ratio)**0.5)
|
|
height = int((total_pixels * height_ratio / width_ratio)**0.5)
|
|
|
|
# Rounding the width and height to the nearest multiple of rounding_value
|
|
width = (width // rounding_value) * rounding_value
|
|
height = (height // rounding_value) * rounding_value
|
|
|
|
return (width, height)
|
|
|
|
# Dictionary that contains all nodes to export with their names
|
|
NODE_CLASS_MAPPINGS = {
|
|
"AnyAspectRatio": AnyAspectRatio
|
|
}
|
|
|
|
# A dictionary that contains the friendly/humanly readable titles for the nodes. yes hello, thank you for reading this far.
|
|
NODE_DISPLAY_NAME_MAPPINGS = {
|
|
"AnyAspectRatio": "AnyAspectRatio"
|
|
}
|