This repository has been archived on 2026-10-21. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
imagelab_v3_extension/workflows/example.py
T
2026-01-03 14:42:05 -07:00

42 lines
1.3 KiB
Python

"""
Test workflow - example ComfyScript workflow.
Each workflow file should have a run_workflow() function that accepts parameters.
comfyscript must be loaded outside of the run_workflow scope
"""
from comfy_script.runtime import *
load('http://127.0.0.1:8188/')
from comfy_script.runtime.nodes import *
import random
def run_workflow(**kwargs):
"""
Execute the test workflow.
Args:
**kwargs: Workflow parameters (e.g., prompt, seed, steps, etc.)
Returns:
dict: Result containing output data and metadata
"""
prompt = kwargs.get('prompt', 'beautiful scenery')
with Workflow(wait=False):
model, clip, vae = CheckpointLoaderSimple(kwargs.get('checkpoint', Checkpoints.anbanIllus_shinv1))
conditioning = CLIPTextEncode(prompt, clip)
conditioning2 = CLIPTextEncode(kwargs.get('negative_prompt', 'text, watermark'), clip)
latent = EmptyLatentImage(512, 512, 1)
seed = kwargs.get('seed', random.randint(0, 15663308700286))
steps = kwargs.get('steps', 20)
latent = KSampler(model, seed, steps, 8, 'euler', 'normal', conditioning, conditioning2, latent, 1)
image = VAEDecode(latent, vae)
preview = PreviewImage(image)
return {
'prompt_id': preview.task.prompt_id,
'status': 'queued',
'parameters': kwargs
}