import { type DiffusionClientParams, type DiffusionStats } from "../../schemas/index"; export interface DiffusionProgressTick { step: number; totalSteps: number; elapsedMs: number; } interface DiffusionResult { progressStream: AsyncGenerator; outputs: Promise; stats: Promise; } /** * Generates images using a loaded diffusion model. * * @param params - Diffusion request parameters (model, prompt, dimensions, sampler, seed, etc.). * @returns A result object exposing `progressStream` (async iterator of `{ step, totalSteps, elapsedMs }`), `outputs` (promise of the generated image buffers), and `stats` (promise of generation statistics). * * Supports both txt2img (no `init_image`) and img2img (with `init_image`). * * @example * ```typescript * // txt2img * const { outputs, stats } = diffusion({ modelId, prompt: "a cat" }); * const buffers = await outputs; * fs.writeFileSync("output.png", buffers[0]); * * // img2img (SD/SDXL — SDEdit) * const initImage = fs.readFileSync("input.png"); * const { outputs } = diffusion({ modelId, prompt: "oil painting style", init_image: initImage, strength: 0.7 }); * * // img2img (FLUX.2 — in-context conditioning) * // IMPORTANT: FLUX img2img requires `prediction: "flux2_flow"` to be set on the * // model config at loadModel time (e.g. `loadModel(src, { modelType: "diffusion", * // modelConfig: { prediction: "flux2_flow" } })`). * const { outputs } = diffusion({ modelId, prompt: "turn into watercolor", init_image: initImage }); * * // FLUX.2 multi-reference fusion * // IMPORTANT: requires the model loaded with `modelConfig: { prediction: "flux2_flow" }` * // and a Qwen3 text encoder via `llmModelSrc` (same loadModel requirements as the * // FLUX.2 img2img example above). `init_image` and `init_images` are mutually * // exclusive — pass one or the other, not both. * const refA = fs.readFileSync("scientist-a.jpg"); * const refB = fs.readFileSync("scientist-b.jpg"); * const { outputs } = diffusion({ * modelId, * prompt: "a portrait using most visual traits from @image1 and the eyes from @image2", * init_images: [refA, refB], * width: 768, * height: 768, * }); * * // LoRA adapter for this generation (absolute path required). * // Persistence across subsequent diffusion() calls is controlled at * // loadModel time via `modelConfig.lora_apply_mode`. * const { outputs } = diffusion({ * modelId, * prompt: "a watercolor cat", * lora: "/home/user/loras/watercolor.safetensors", * }); * * // ESRGAN upscale; requires the model to be loaded with `modelConfig.upscaler.model_src` set. * const { outputs: singleOutputs } = diffusion({ * modelId, * prompt: "a fox portrait", * width: 128, * height: 128, * upscale: true, // one native-scale pass * }); * const single = await singleOutputs; * fs.writeFileSync("upscaled.png", single[0]); * * // Repeat upscale passes when needed. * const { outputs: hiresOutputs } = diffusion({ * modelId, * prompt: "a fox portrait", * width: 128, * height: 128, * upscale: { repeats: 2 }, * }); * const hires = await hiresOutputs; * fs.writeFileSync("hires.png", hires[0]); * * // With progress tracking * const { progressStream, outputs } = diffusion({ modelId, prompt: "a cat" }); * for await (const { step, totalSteps } of progressStream) { * console.log(`${step}/${totalSteps}`); * } * const buffers = await outputs; * ``` */ export declare function diffusion(params: DiffusionClientParams): DiffusionResult; export {}; //# sourceMappingURL=diffusion.d.ts.map