diff --git a/backend/apps/images/utils/comfyui.py b/backend/apps/images/utils/comfyui.py index cece3d737..395d3d86c 100644 --- a/backend/apps/images/utils/comfyui.py +++ b/backend/apps/images/utils/comfyui.py @@ -133,7 +133,7 @@ async def comfyui_generate_image( else random.randint(0, 18446744073709551614) ) for node_id in node.node_ids: - workflow[node.node_id]["inputs"]["seed"] = seed + workflow[node.node_id]["inputs"][node.key] = seed else: for node_id in node.node_ids: workflow[node_id]["inputs"][node.key] = node.value diff --git a/src/lib/components/admin/Settings/Images.svelte b/src/lib/components/admin/Settings/Images.svelte index 72112fdc9..718a73a81 100644 --- a/src/lib/components/admin/Settings/Images.svelte +++ b/src/lib/components/admin/Settings/Images.svelte @@ -27,7 +27,7 @@ let models = null; - let workflowNodes = [ + let requiredWorkflowNodes = [ { type: 'prompt', key: 'text', @@ -52,6 +52,11 @@ type: 'steps', key: 'steps', node_ids: '' + }, + { + type: 'seed', + key: 'seed', + node_ids: '' } ]; @@ -101,7 +106,7 @@ } if (config?.comfyui?.COMFYUI_WORKFLOW) { - config.comfyui.COMFYUI_WORKFLOW_NODES = workflowNodes.map((node) => { + config.comfyui.COMFYUI_WORKFLOW_NODES = requiredWorkflowNodes.map((node) => { return { type: node.type, key: node.key, @@ -150,15 +155,17 @@ ); } - if ((config?.comfyui?.COMFYUI_WORKFLOW_NODES ?? []).length >= 5) { - workflowNodes = config.comfyui.COMFYUI_WORKFLOW_NODES.map((node) => { - return { - type: node.type, - key: node.key, - node_ids: node.node_ids.join(',') - }; - }); - } + requiredWorkflowNodes = requiredWorkflowNodes.map((node) => { + const n = config.comfyui.COMFYUI_WORKFLOW_NODES.find((n) => n.type === node.type) ?? node; + + console.log(n); + + return { + type: n.type, + key: n.key, + node_ids: typeof n.node_ids === 'string' ? n.node_ids : n.node_ids.join(',') + }; + }); const imageConfigRes = await getImageGenerationConfig(localStorage.token).catch((error) => { toast.error(error); @@ -414,7 +421,7 @@
{$i18n.t('ComfyUI Workflow Nodes')}
- {#each workflowNodes as node} + {#each requiredWorkflowNodes as node}