Archived
completed phase 2, updated workflows to use yaml and updated workflows scripts to use new system for parameters
This commit is contained in:
1 parent
193e03ce3a
commit
4f8ba22cd2
4 files changed
+209
-438
No files matched your search
+35
-203
@@ -1,16 +1,22 @@
|
||||
"""
|
||||
Basic SDXL Text to Image workflow.
|
||||
Schema is defined in basic_sdxl.yaml (auto-generated from WorkflowParams).
|
||||
"""
|
||||
from comfy_script.runtime import *
|
||||
load('http://127.0.0.1:8188/')
|
||||
from comfy_script.runtime.nodes import *
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import List
|
||||
import sys
|
||||
import os
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
|
||||
from base import BaseWorkflow
|
||||
from parameters import Lora
|
||||
from parameter_schema import param, ParameterCategory
|
||||
from parameters import (
|
||||
Prompt, NegativePrompt, Checkpoint, Seed, Sampler, Scheduler,
|
||||
Width, Height, Lora
|
||||
)
|
||||
|
||||
# ============================================
|
||||
# Workflow Metadata
|
||||
@@ -24,210 +30,36 @@ WORKFLOW_METADATA = {
|
||||
}
|
||||
|
||||
# ============================================
|
||||
# Workflow Parameters Schema
|
||||
# ============================================
|
||||
|
||||
WORKFLOW_PARAMETERS = [
|
||||
# Prompts
|
||||
param.text_area(
|
||||
name="prompt",
|
||||
label="Prompt",
|
||||
category=ParameterCategory.PROMPTS,
|
||||
required=True,
|
||||
placeholder="Enter your prompt...",
|
||||
rows=4,
|
||||
),
|
||||
param.text_area(
|
||||
name="negativePrompt",
|
||||
label="Negative Prompt",
|
||||
category=ParameterCategory.PROMPTS,
|
||||
default="text, watermark",
|
||||
placeholder="Enter negative prompt...",
|
||||
rows=2,
|
||||
),
|
||||
|
||||
# Models
|
||||
param.model_select(
|
||||
name="checkpoints",
|
||||
label="Checkpoint",
|
||||
category=ParameterCategory.MODELS,
|
||||
model_type="checkpoints",
|
||||
required=True,
|
||||
multiple=True,
|
||||
max_selections=1,
|
||||
),
|
||||
param.model_select(
|
||||
name="loras",
|
||||
label="LoRAs",
|
||||
category=ParameterCategory.MODELS,
|
||||
model_type="loras",
|
||||
multiple=True,
|
||||
description="Add LoRA models to apply",
|
||||
),
|
||||
|
||||
# Parameters (Sampling)
|
||||
param.slider(
|
||||
name="steps",
|
||||
label="Steps",
|
||||
category=ParameterCategory.PARAMETERS,
|
||||
min_val=1,
|
||||
max_val=150,
|
||||
default=20,
|
||||
),
|
||||
param.slider(
|
||||
name="cfg",
|
||||
label="CFG Scale",
|
||||
category=ParameterCategory.PARAMETERS,
|
||||
min_val=1.0,
|
||||
max_val=20.0,
|
||||
default=8.0,
|
||||
step=0.5,
|
||||
is_float=True,
|
||||
),
|
||||
param.select(
|
||||
name="sampler",
|
||||
label="Sampler",
|
||||
category=ParameterCategory.PARAMETERS,
|
||||
options=[
|
||||
{"value": "euler", "label": "Euler"},
|
||||
{"value": "euler_ancestral", "label": "Euler Ancestral"},
|
||||
{"value": "heun", "label": "Heun"},
|
||||
{"value": "dpm_2", "label": "DPM 2"},
|
||||
{"value": "dpm_2_ancestral", "label": "DPM 2 Ancestral"},
|
||||
{"value": "lms", "label": "LMS"},
|
||||
{"value": "dpmpp_2m", "label": "DPM++ 2M"},
|
||||
{"value": "dpmpp_2m_sde", "label": "DPM++ 2M SDE"},
|
||||
{"value": "dpmpp_sde", "label": "DPM++ SDE"},
|
||||
{"value": "ddim", "label": "DDIM"},
|
||||
],
|
||||
default="euler",
|
||||
searchable=True,
|
||||
),
|
||||
param.select(
|
||||
name="scheduler",
|
||||
label="Scheduler",
|
||||
category=ParameterCategory.PARAMETERS,
|
||||
options=[
|
||||
{"value": "normal", "label": "Normal"},
|
||||
{"value": "karras", "label": "Karras"},
|
||||
{"value": "exponential", "label": "Exponential"},
|
||||
{"value": "sgm_uniform", "label": "SGM Uniform"},
|
||||
{"value": "simple", "label": "Simple"},
|
||||
{"value": "ddim_uniform", "label": "DDIM Uniform"},
|
||||
],
|
||||
default="normal",
|
||||
),
|
||||
param.seed_input(
|
||||
name="seed",
|
||||
label="Seed",
|
||||
category=ParameterCategory.PARAMETERS,
|
||||
),
|
||||
|
||||
# Composition
|
||||
param.slider(
|
||||
name="width",
|
||||
label="Width",
|
||||
category=ParameterCategory.COMPOSITION,
|
||||
min_val=64,
|
||||
max_val=2048,
|
||||
default=1024,
|
||||
step=8,
|
||||
),
|
||||
param.slider(
|
||||
name="height",
|
||||
label="Height",
|
||||
category=ParameterCategory.COMPOSITION,
|
||||
min_val=64,
|
||||
max_val=2048,
|
||||
default=1024,
|
||||
step=8,
|
||||
),
|
||||
|
||||
# Advanced - Loopback
|
||||
param.toggle(
|
||||
name="loopback",
|
||||
label="Enable Loopback",
|
||||
category=ParameterCategory.ADVANCED,
|
||||
default=False,
|
||||
style="switch",
|
||||
description="Enable iterative upscaling and refinement",
|
||||
),
|
||||
param.slider(
|
||||
name="loopbackIterations",
|
||||
label="Loopback Iterations",
|
||||
category=ParameterCategory.ADVANCED,
|
||||
min_val=1,
|
||||
max_val=5,
|
||||
default=1,
|
||||
depends_on={"loopback": True},
|
||||
),
|
||||
param.slider(
|
||||
name="loopbackUpscale",
|
||||
label="Loopback Upscale",
|
||||
category=ParameterCategory.ADVANCED,
|
||||
min_val=1.0,
|
||||
max_val=2.0,
|
||||
default=1.25,
|
||||
step=0.05,
|
||||
is_float=True,
|
||||
depends_on={"loopback": True},
|
||||
),
|
||||
param.slider(
|
||||
name="loopbackDenoise",
|
||||
label="Loopback Denoise",
|
||||
category=ParameterCategory.ADVANCED,
|
||||
min_val=0.0,
|
||||
max_val=1.0,
|
||||
default=0.5,
|
||||
step=0.05,
|
||||
is_float=True,
|
||||
depends_on={"loopback": True},
|
||||
),
|
||||
param.slider(
|
||||
name="loopbackSteps",
|
||||
label="Loopback Steps",
|
||||
category=ParameterCategory.ADVANCED,
|
||||
min_val=1,
|
||||
max_val=50,
|
||||
default=10,
|
||||
depends_on={"loopback": True},
|
||||
),
|
||||
param.slider(
|
||||
name="loopbackCfg",
|
||||
label="Loopback CFG",
|
||||
category=ParameterCategory.ADVANCED,
|
||||
min_val=1.0,
|
||||
max_val=20.0,
|
||||
default=7.0,
|
||||
step=0.5,
|
||||
is_float=True,
|
||||
depends_on={"loopback": True},
|
||||
),
|
||||
]
|
||||
|
||||
# ============================================
|
||||
# Workflow Parameters Model (for validation)
|
||||
# Workflow Parameters Model
|
||||
# ============================================
|
||||
|
||||
class WorkflowParams(BaseModel):
|
||||
prompt: str
|
||||
negativePrompt: str = "text, watermark"
|
||||
checkpoints: List[str]
|
||||
loras: List[Lora] = []
|
||||
steps: int = 20
|
||||
seed: int = None
|
||||
cfg: float = 8.0
|
||||
width: int = 1024
|
||||
height: int = 1024
|
||||
sampler: str = 'euler'
|
||||
scheduler: str = 'normal'
|
||||
"""
|
||||
Parameters for SDXL text-to-image generation.
|
||||
Schema is auto-generated to basic_sdxl.yaml from these type annotations.
|
||||
"""
|
||||
# Use annotated types for automatic UI schema
|
||||
prompt: Prompt
|
||||
negativePrompt: NegativePrompt = "text, watermark"
|
||||
checkpoints: Checkpoint
|
||||
loras: List[Lora] = [] # Generator infers params from Lora class
|
||||
sampler: Sampler = "euler"
|
||||
scheduler: Scheduler = "normal"
|
||||
seed: Seed # Required, no default
|
||||
width: Width = 1024
|
||||
height: Height = 1024
|
||||
|
||||
# Inline Field() for one-off constraints
|
||||
steps: int = Field(default=20, ge=1, le=150)
|
||||
cfg: float = Field(default=8.0, ge=1.0, le=20.0, json_schema_extra={"step": 0.5})
|
||||
|
||||
# Plain types fall back to basic inference
|
||||
loopback: bool = False
|
||||
# Flattened loopback parameters
|
||||
loopbackIterations: int = 1
|
||||
loopbackUpscale: float = 1.25
|
||||
loopbackDenoise: float = 0.5
|
||||
loopbackSteps: int = 10
|
||||
loopbackCfg: float = 7.0
|
||||
loopbackIterations: int = Field(default=1, ge=1, le=5, json_schema_extra={"category": "advanced"})
|
||||
loopbackUpscale: float = Field(default=1.25, ge=1.0, le=2.0, json_schema_extra={"category": "advanced", "step": 0.05})
|
||||
loopbackDenoise: float = Field(default=0.5, ge=0.0, le=1.0, json_schema_extra={"category": "advanced", "step": 0.05})
|
||||
loopbackSteps: int = Field(default=10, ge=1, le=50, json_schema_extra={"category": "advanced"})
|
||||
loopbackCfg: float = Field(default=7.0, ge=1.0, le=20.0, json_schema_extra={"category": "advanced", "step": 0.5})
|
||||
|
||||
# Workflow definition
|
||||
class SDXLWorkflow(BaseWorkflow):
|
||||
|
||||
Reference in new issue
Block a user