Open wencxxxxxx opened 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.
Is the author still maintaining this node?
Please optimize this bug, can you
@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
@PrometheusDante Sorry, I forgot to mention that you also need to add the following line ...
from hashlib import sha256
... somewhere on top of the file, e.g. like this:
from __future__ import annotations
import logging
from abc import ABC, abstractproperty
from collections.abc import Iterable
from pathlib import Path
from hashlib import sha256
Otherwise you should see something like this in the console output:
WARNING: name 'sha256' is not defined
@cbaoth Thanks for getting back to me. I switched to the Impact Pack's wildcard processing with a .yaml file in the meantime and like that quite a lot, with the only downside for me being the absence of immediately evaluated variables to use in multiple points of a prompt.
Fixed dynamic prompt word seed, fixed sampler seed, still sampling.