Nodes/ComfyUI_JosiaNodes/Josia随机种子
ComfyUI Node

Josia随机种子

A seed node that refuses to let you lose your good seed

By Josia-doit·Created 6 months ago·Updated a day ago· 16
Josia随机种子
    • SEED
    seed-1

    Everyone who has spent an hour on ComfyUI knows the injury JosiaSeed (Josia随机种子) exists to prevent: you hit run on a random seed, get something great, and then can't reproduce it because the number in the box was overwritten after the run. The stock KSampler seed widget randomizes after generation, so the seed you see isn't the seed that made the image. JosiaSeed's whole pitch is that it writes the actual used seed back into the workflow - what you see is what ran.

    How it works

    The core is a single integer input, seed, with four behaviors encoded in the value itself:

    • -1 - roll a new random seed every run.
    • -2 - take the previous run's seed and add 1 (increment).
    • -3 - previous seed minus 1 (decrement).
    • any other number - fixed seed, output unchanged.

    Reading the source, the increment/decrement modes are just bookkeeping: the node remembers _last_seed from the last execution and steps from it. No history yet? It returns 0 and prints a warning rather than inventing a base. That's the honest behavior - -2/-3 mean nothing until you've run something once.

    The interesting part is the feedback loop. After it picks a seed, it reaches back into ComfyUI's graph data (prompt and extra_pnginfo) and rewrites the seed widget in the current workflow, so the number displayed matches the number that was used. Combined with a IS_CHANGED method that returns a fresh value for the -1/-2/-3 modes, the node forces itself to rerun every queue and keeps the visible seed truthful. No more guessing which seed produced an image from the PNG metadata.

    Frontend buttons

    The web UI adds five buttons in native ComfyUI styling: 每次随机 (randomize each run, sets -1), 递增 (increment), 递减 (decrement), 固定随机 (roll a new fixed seed), and 复用上次种子 (reuse last seed). The increment/decrement buttons start grayed out and light up once a seed history exists - a nice guard against clicking them on a fresh node and getting that confusing "0" output.

    The output

    One output, SEED (INT), wiring straight into a KSampler's converted seed input. Fan it out to several samplers and they all share the same source of truth - same seed, same noise, one place to change it. If you're the type who keeps two samplers in one graph for latent-diffusion passes, this is exactly the "one seed, many consumers" pattern.

    Install

    This pack has zero extra Python dependencies. Install via ComfyUI Manager (search ComfyUI_JosiaNodes) or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Josia-doit/ComfyUI_JosiaNodes
    

    Restart ComfyUI, then look for the Josia category in the node menu. The widget labels are Chinese, so "seed" shows as 随机种子.

    The catch

    Because the node backfills the seed into the workflow, a saved JSON workflow carries the last actual seed - useful, but it means "fixed" state is baked into your .json. If you share a workflow and don't want to leak your exact seed, flip it to -1 before saving. Otherwise this is one of the more honest seed nodes out there: it does what the box says.

    Category⚡️JosiaNodes

    Inputs (1)

    NameTypeDefaultDescription
    seedINT-1-1125899906842624–1125899906842624种子值:-1=每次随机,-2=递增(+1),-3=递减(-1),其他=固定

    Outputs (1)

    NameTypeDescription
    SEEDINT