adieyal / comfyui-dynamicprompts

ComfyUI custom nodes for Dynamic Prompts
MIT License
241 stars 24 forks source link

Fixed dynamic prompt word seed, fixed sampler seed, still sampling. #65

Open wencxxxxxx opened 2 months ago

wencxxxxxx commented 2 months ago

Fixed dynamic prompt word seed, fixed sampler seed, still sampling.

cbaoth commented 2 months ago

I just had the same issue and had a quick look at DPAbstractSamplerNode to fix this issue in the Random Prompts node:

    @classmethod
    def IS_CHANGED(cls, text: str, seed: int, autorefresh: str):
        if autorefresh == "Yes":
            # Force re-evaluation of the node
            return float("NaN")
        else:
            # Re-evaluate only in case the seed and/or text has changed
            m = sha256()
            m.update(str(seed).encode())
            m.update("".encode() if text is None else text.encode())
            # print(f"Hash: {m.hexdigest()}, Seed: {str(seed)}, Text: {text}") # debug
            return m.hexdigest()

The original code always returned float("NaN") meaning the node will always be treated as changed, according to this.

wencxxxxxx commented 2 months ago

Is the author still maintaining this node?

wencxxxxxx commented 1 month ago

Please optimize this bug, can you

PrometheusDante commented 4 days ago

@cbaoth I tried your fix by editing the sampler.py to this :

@classmethod
def IS_CHANGED(cls, text: str, seed: int, autorefresh: str):
    if autorefresh == "Yes":
        # Force re-evaluation of the node
        return float("NaN")
    else:
        # Re-evaluate only in case the seed and/or text has changed
        m = sha256()
        m.update(str(seed).encode())
        m.update("".encode() if text is None else text.encode())
        # print(f"Hash: {m.hexdigest()}, Seed: {str(seed)}, Text: {text}") # debug
        return m.hexdigest()

RETURN_TYPES = ("STRING",)
FUNCTION = "get_prompt"
CATEGORY = "Dynamic Prompts"

But it still insists on sampling over and over unfortunately