32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
import torch
|
|
|
|
class ImageMultipleOfEightValidator:
|
|
"""
|
|
Valida se a imagem é múltipla de 8.
|
|
Impede erros em workflows de Upscale, Tiling e Modelos Flux.
|
|
"""
|
|
def __init__(self):
|
|
pass
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(s):
|
|
return {"required": {"image": ("IMAGE",),}}
|
|
|
|
RETURN_TYPES = ("IMAGE",)
|
|
FUNCTION = "validate"
|
|
CATEGORY = "Actions" # <--- Categoria que você definiu no README
|
|
|
|
def validate(self, image):
|
|
# [Batch, Height, Width, Channels]
|
|
height, width = image.shape[1], image.shape[2]
|
|
|
|
if width % 8 != 0 or height % 8 != 0:
|
|
error_msg = f"❌ DIMENSÃO INVÁLIDA: {width}x{height}. Não é múltiplo de 8!"
|
|
# Isso deixa o aviso em VERMELHO no console do Windows:
|
|
print(f"\033[91m\033[1m{error_msg}\033[0m")
|
|
raise ValueError(error_msg)
|
|
|
|
return (image,)
|
|
|
|
NODE_CLASS_MAPPINGS = {"ImageMultipleOfEightValidator": ImageMultipleOfEightValidator}
|
|
NODE_DISPLAY_NAME_MAPPINGS = {"ImageMultipleOfEightValidator": "⚠️ Validar Múltiplo de 8"} |