Archived
initial commit
This commit is contained in:
commit
5441b0d8ff
10 files changed
+714
No files matched your search
@@ -0,0 +1,52 @@
|
||||
from comfy_script.runtime import *
|
||||
load('http://127.0.0.1:8188/')
|
||||
from comfy_script.runtime.nodes import *
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import List, Optional
|
||||
import random
|
||||
|
||||
def run_workflow(**kwargs):
|
||||
required = ['prompt', 'checkpoints', 'seed', 'steps', 'negativePrompt', 'width', 'height']
|
||||
missing = [f for f in required if f not in kwargs]
|
||||
if missing:
|
||||
raise ValueError(f"Missing required fields: {', '.join(missing)}")
|
||||
|
||||
params = WorkflowParams(**kwargs)
|
||||
|
||||
with Workflow(wait=False):
|
||||
if len(params.checkpoints) > 1:
|
||||
model1, clip1, vae = CheckpointLoaderSimple(params.checkpoints[0])
|
||||
model2, clip2, vae = CheckpointLoaderSimple(params.checkpoints[1])
|
||||
|
||||
model = ModelMergeSimple(model1, model2, 0.5)
|
||||
clip = CLIPMergeSimple(clip1, clip2, 0.5)
|
||||
|
||||
else:
|
||||
model, clip, vae = CheckpointLoaderSimple(params.checkpoints[0])
|
||||
|
||||
conditioning = CLIPTextEncode(params.prompt, clip)
|
||||
conditioning2 = CLIPTextEncode(params.negativePrompt, clip)
|
||||
latent = EmptyLatentImage(params.width, params.height, 1)
|
||||
seed = params.seed
|
||||
steps = params.steps
|
||||
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
|
||||
}
|
||||
|
||||
# Parameters typing
|
||||
@dataclass
|
||||
class WorkflowParams:
|
||||
prompt: str
|
||||
checkpoints: List[str]
|
||||
seed: Optional[int] = random.randint(0, 15663308700286)
|
||||
steps: int = 20
|
||||
negativePrompt: str = "text, watermark"
|
||||
width: int = 512
|
||||
height: int = 512
|
||||
Reference in new issue
Block a user