fix(plugin): prompt expansion node seed generation error
This commit is contained in:
parent
410d03cd2b
commit
619a9728c0
@ -112,14 +112,28 @@ def randomSeed(num_digits=15):
|
|||||||
range_end = (10**num_digits) - 1
|
range_end = (10**num_digits) - 1
|
||||||
return random.randint(range_start, range_end)
|
return random.randint(range_start, range_end)
|
||||||
|
|
||||||
|
def apply_random_seed_to_workflow(workflow_api):
|
||||||
|
"""
|
||||||
|
Applies a random seed to each element in the workflow_api that has a 'seed' input.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
workflow_api (dict): The workflow API dictionary to modify.
|
||||||
|
"""
|
||||||
|
for key in workflow_api:
|
||||||
|
if 'inputs' in workflow_api[key] and 'seed' in workflow_api[key]['inputs']:
|
||||||
|
if isinstance(workflow_api[key]['inputs']['seed'], list):
|
||||||
|
continue
|
||||||
|
if workflow_api[key]['class_type'] == "PromptExpansion":
|
||||||
|
workflow_api[key]['inputs']['seed'] = randomSeed(8);
|
||||||
|
continue
|
||||||
|
workflow_api[key]['inputs']['seed'] = randomSeed();
|
||||||
|
|
||||||
def send_prompt(sid: str, inputs: StreamingPrompt):
|
def send_prompt(sid: str, inputs: StreamingPrompt):
|
||||||
# workflow_api = inputs.workflow_api
|
# workflow_api = inputs.workflow_api
|
||||||
workflow_api = copy.deepcopy(inputs.workflow_api)
|
workflow_api = copy.deepcopy(inputs.workflow_api)
|
||||||
|
|
||||||
# Random seed
|
# Random seed
|
||||||
for key in workflow_api:
|
apply_random_seed_to_workflow(workflow_api)
|
||||||
if 'inputs' in workflow_api[key] and 'seed' in workflow_api[key]['inputs']:
|
|
||||||
workflow_api[key]['inputs']['seed'] = randomSeed()
|
|
||||||
|
|
||||||
print("getting inputs" , inputs.inputs)
|
print("getting inputs" , inputs.inputs)
|
||||||
|
|
||||||
@ -173,9 +187,10 @@ async def comfy_deploy_run(request):
|
|||||||
# The prompt id generated from comfy deploy, can be None
|
# The prompt id generated from comfy deploy, can be None
|
||||||
prompt_id = data.get("prompt_id")
|
prompt_id = data.get("prompt_id")
|
||||||
|
|
||||||
for key in workflow_api:
|
apply_random_seed_to_workflow(workflow_api)
|
||||||
if 'inputs' in workflow_api[key] and 'seed' in workflow_api[key]['inputs']:
|
# for key in workflow_api:
|
||||||
workflow_api[key]['inputs']['seed'] = randomSeed()
|
# if 'inputs' in workflow_api[key] and 'seed' in workflow_api[key]['inputs']:
|
||||||
|
# workflow_api[key]['inputs']['seed'] = randomSeed()
|
||||||
|
|
||||||
prompt = {
|
prompt = {
|
||||||
"prompt": workflow_api,
|
"prompt": workflow_api,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user