Documentation
¶
Overview ¶
Package imagegen generates an image from a text prompt by shelling out to the repo's render/comfy-generate.mjs (Node), which wraps the proven comfy-render.mjs with the GPU-lock + ComfyUI start/stop lifecycle. The render runs on the LOCAL ComfyUI (SDXL/ RealVisXL) — free, no cloud. It is now a THIN caller of internal/gpugen, which owns the shared exec lifecycle (process-tree-kill on timeout, WaitDelay, defer freeComfyVRAM) so image/video/audio all get the SAME guards. Behavior is preserved byte-for-byte; only the lifecycle was lifted into gpugen.
Index ¶
- func Generate(ctx context.Context, node, script, comfyDir, out, prompt string, ...) (string, error)
- func GenerateBatch(ctx context.Context, node, script, comfyDir, jobsPath, resultsPath string, ...) error
- func Inpaint(ctx context.Context, node, script, comfyDir, out, image, mask, prompt string, ...) (string, error)
- type InpaintModel
- type Model
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
func Generate(ctx context.Context, node, script, comfyDir, out, prompt string, params map[string]any, m Model, timeout time.Duration, samp *gpugen.Sampling, extraEnv ...string) (string, error)
Generate runs `node <script> <out> <prompt> [--negative ..] [--width ..] ...` and returns out on success. node is the node executable ("" => "node"); script is the absolute path to comfy-generate.mjs; comfyDir is exported as COMFY_DIR for the script. params may carry negative (string) and width/height/steps/seed (int-ish); m carries the machine's image-model binding. A per-request steps param overrides m.Steps. extraEnv appends additional "K=V" entries (LO-1: the pipeline threads a configured GPU_LOCK override so the runner contends on the same lock the Go vision gate watches). samp, when non-nil, turns on gpugen's passive per-render VRAM peak sampling (fleet footprints; nil = legacy path). A non-zero exit, a timeout, or a missing/empty output file returns an error (the caller defers).
func GenerateBatch ¶ added in v0.21.1
func GenerateBatch(ctx context.Context, node, script, comfyDir, jobsPath, resultsPath string, m Model, timeout time.Duration, extraEnv ...string) error
GenerateBatch renders every job in jobsPath (JSONL: {"prompt","out",...} per line) through ONE warm ComfyUI session and writes one result line per job to resultsPath. The results file is the gpugen success gate: the script exits 0 with a complete results file even when individual renders failed (the caller reads per-job status), while a crash/timeout/GPU-busy exits non-zero and errors here. timeout bounds the WHOLE batch.
func Inpaint ¶ added in v0.21.1
func Inpaint(ctx context.Context, node, script, comfyDir, out, image, mask, prompt string, params map[string]any, m InpaintModel, timeout time.Duration, extraEnv ...string) (string, error)
Inpaint re-renders ONLY the masked region of image on the LOCAL ComfyUI (free). Same lifecycle guards as Generate: gpugen tree-kill on timeout + deferred /free.
Types ¶
type InpaintModel ¶ added in v0.21.1
InpaintModel is the machine's inpaint binding (SDXL-class; see config). Inpainting is masked latent re-denoise (VAEEncodeForInpaint) — a pixel-space DiT (HiDream) cannot drive it, so this binding is separate from Model even on a HiDream box.
type Model ¶ added in v0.21.1
type Model struct {
Ckpt string // CheckpointLoaderSimple filename ("" = script default)
// VAE is a standalone VAE filename, or "builtin" to decode with the VAE the
// checkpoint loader supplies (required for HiDream: it ships no VAE weights, so a
// standalone 4-channel sdxl_vae cannot decode its output). "" = script default.
VAE string
Steps int // 0 = script default
CFG float64 // 0 = script default
Sampler string // "" = script default
Scheduler string // "" = script default
// Family selects the MODEL-CORRECT graph in comfy-render.mjs ("" = the generic
// SDXL-shaped graph). "hidream-o1" / "hidream-o1-dev" render the official
// pixel-space DiT graph (ModelNoiseScale, patch-seam smoothing, SamplerCustom,
// native 2048) — driving a DiT through the generic graph produces measurable
// 32px patch blocking. Which family a checkpoint belongs to is per-machine
// config, never shared code.
Family string
}
Model is THIS machine's image-model binding, read from config. The harness is hardware- and model-agnostic: an 8GB laptop runs SDXL, a 16GB workstation may run a DiT (HiDream). No model name belongs in shared code, so every field here is optional — a zero Model passes no flags at all and comfy-render.mjs keeps its own defaults, leaving an existing SDXL machine byte-for-byte unchanged.