This commit is contained in:
Timothy J. Baek 2024-08-21 01:39:30 +02:00
parent 8b5aed7a2b
commit e2291f7148
3 changed files with 60 additions and 12 deletions

View File

@ -413,7 +413,6 @@ async def image_generations(
return images
elif app.state.config.ENGINE == "comfyui":
data = {
"prompt": form_data.prompt,
"width": width,

View File

@ -74,7 +74,7 @@ def get_images(ws, prompt, client_id, base_url):
class ComfyUINodeInput(BaseModel):
field: Optional[str] = None
node_id: str
node_ids: list[str] = []
key: Optional[str] = "text"
value: Optional[str] = None
@ -106,27 +106,37 @@ async def comfyui_generate_image(
for node in payload.workflow.nodes:
if node.field:
if node.field == "model":
workflow[node.node_id]["inputs"][node.key] = model
for node_id in node.node_ids:
workflow[node_id]["inputs"][node.key] = model
elif node.field == "prompt":
workflow[node.node_id]["inputs"]["text"] = payload.prompt
for node_id in node.node_ids:
workflow[node_id]["inputs"]["text"] = payload.prompt
elif node.field == "negative_prompt":
workflow[node.node_id]["inputs"]["text"] = payload.negative_prompt
for node_id in node.node_ids:
workflow[node_id]["inputs"]["text"] = payload.negative_prompt
elif node.field == "width":
workflow[node.node_id]["inputs"]["width"] = payload.width
for node_id in node.node_ids:
workflow[node_id]["inputs"]["width"] = payload.width
elif node.field == "height":
workflow[node.node_id]["inputs"]["height"] = payload.height
for node_id in node.node_ids:
workflow[node_id]["inputs"]["height"] = payload.height
elif node.field == "n":
workflow[node.node_id]["inputs"]["batch_size"] = payload.n
for node_id in node.node_ids:
workflow[node_id]["inputs"]["batch_size"] = payload.n
elif node.field == "steps":
workflow[node.node_id]["inputs"]["steps"] = payload.steps
for node_id in node.node_ids:
workflow[node_id]["inputs"]["steps"] = payload.steps
elif node.field == "seed":
workflow[node.node_id]["inputs"]["seed"] = (
seed = (
payload.seed
if payload.seed
else random.randint(0, 18446744073709551614)
)
for node_id in node.node_ids:
workflow[node.node_id]["inputs"]["seed"] = seed
else:
workflow[node.node_id]["inputs"][node.key] = node.value
for node_id in node.node_ids:
workflow[node_id]["inputs"][node.key] = node.value
try:
ws = websocket.WebSocket()

View File

@ -323,7 +323,46 @@
<div class="">
<div class=" mb-2 text-sm font-medium">{$i18n.t('ComfyUI Workflow Nodes')}</div>
<div>hi</div>
<div class="text-xs">
<div class="flex gap-2">
<div>Prompt Node</div>
<div>Node Ids</div>
<div>"text"</div>
<div>Default</div>
</div>
<div class="flex gap-2">
<div>Model Node</div>
<div>Node Ids</div>
<div>"text"</div>
<div>Default</div>
</div>
<div class="flex gap-2">
<div>Image Size Node</div>
<div>Node Ids</div>
<div>"text"</div>
<div>Default</div>
</div>
<div class="flex gap-2">
<div>Image Steps Node</div>
<div>Node Ids</div>
<div>"text"</div>
<div>Default</div>
</div>
</div>
<hr class=" dark:border-gray-850 my-2" />
<div class="text-xs">
<div class="flex gap-2">
<div>Custom Node</div>
<div>Node Ids</div>
<div>Key</div>
<div>Value</div>
</div>
</div>
</div>
{/if}
{:else if config?.engine === 'openai'}