0

I'm trying to define a simple custom node but whatever I try I can't seem to get the inputs to show in ComfyUI. I've tried various approaches but it seems anytime I define a custom node with input float it doesn't seem to appear. What am I doing wrong?

enter image description here

import numpy as np
import cv2

class AReferenceSize:
    def __init__(self):
        self.reference_size = None

    @classmethod
    def INPUT_TYPES(cls):
        return {
            "required": {
                "current_size": ("FLOAT", {"default": 0.0}),
                "update": ("BOOLEAN", {"default": False})
            }
        }
    
    RETURN_TYPES = ("FLOAT",)
    FUNCTION = "get_and_update"
    CATEGORY = "example" 

    def get_and_update(self, current_size, update):
        print(f"get_and_update called with current_size: {current_size}, update: {update}")
        if self.reference_size is None or update:
            self.reference_size = current_size
        return (self.reference_size,)

# Register the nodes
NODE_CLASS_MAPPINGS = {
    "AReferenceSize": AReferenceSize  
}

NODE_DISPLAY_NAME_MAPPINGS = {
    "AReferenceSize": "AReference Size"
}

1 Answer 1

0

When adding an input into your node, as defined, it will come as a field.. but you can always right-click on this field and select "convert widget to input"... et voila!

Sign up to request clarification or add additional context in comments.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.