pydn / ComfyUI-to-Python-Extension

A powerful tool that translates ComfyUI workflows into executable Python code.
MIT License
842 stars 87 forks source link

A fixed-seed value and specifier are disregarded #42

Open lutusp opened 4 months ago

lutusp commented 4 months ago

While converting a KSampler control that specifies a fixed seed value, this extension's code always creates:

seed=random.randint(1, 2**64)

... regardless of the provided seed value and the "fixed" specifier in the "control_after_generate" field.

This issue comes up while creating a series of images that use a "ConditioningAverage" control to morph between two text descriptions. If the original seed value is manually entered instead of random.randint(1, 2**64), the code works as expected.

atmaranto commented 3 months ago

Unfortunately, this was likely originally implemented to conform to the most common usage of KSampler to generate different images. In my fork, I added a way to pass values as command-like args in the exported .py file, but there isn't currently a good way to set a seed.

The best way I can think of would be to create a set seed would be to use a Primitive node that is not the vanilla ComfyUI primitive (which is simplified in the export to a value), set it to the value you want, and connect it to the seed for KSampler.

Here's what I mean: workflow (1) This uses the Primitive Integer from Crystools and the SaveAsScript fork.