koishi-plugin-hhs-huatu
Version:
Generate images by diffusion models
95 lines (94 loc) • 2.49 kB
TypeScript
/**
* NovelAI Inpainting API Payload 构造器
* 用于构建 infill 请求的参数
*/
/**
* Infill Payload 选项
*/
export interface InfillOptions {
/** 基础模型名称(如 'nai-diffusion-3',将自动添加 -inpainting 后缀) */
baseModel: string;
/** 正向提示词 */
prompt: string;
/** 负向提示词 */
negativePrompt?: string;
/** 原图 Base64(不含前缀) */
imageBase64: string;
/** 蒙版 Base64(不含前缀) */
maskBase64: string;
/** 重绘强度,默认 1.0 */
strength?: number;
/** 噪声强度,默认 0 */
noise?: number;
/** 生成种子 */
seed?: number;
/** CFG Scale */
scale?: number;
/** 采样器 */
sampler?: string;
/** 调度器 */
scheduler?: string;
/** 步数 */
steps?: number;
/** 图片宽度 */
width?: number;
/** 图片高度 */
height?: number;
}
/**
* Infill API 请求 Payload
*/
export interface InfillPayload {
model: string;
input: string;
action: 'infill';
parameters: {
image: string;
mask: string;
add_original_image: boolean;
strength: number;
noise: number;
seed: number;
prompt: string;
negative_prompt: string;
scale: number;
sampler: string;
noise_schedule?: string;
steps: number;
width: number;
height: number;
n_samples: number;
ucPreset: number;
qualityToggle: boolean;
params_version: number;
legacy: boolean;
[key: string]: any;
};
}
/**
* 获取 Inpainting 模型名称
* @param baseModel 基础模型名称
* @returns 带 -inpainting 后缀的模型名称
*/
export declare function getInpaintingModel(baseModel: string): string;
/**
* 检查模型是否支持 Inpainting
* @param model 模型名称
*/
export declare function supportsInpainting(model: string): boolean;
/**
* 构造 Infill 请求 Payload
*
* @param options 选项参数
* @returns 完整的 Infill API 请求 Payload
*/
export declare function constructInfillPayload(options: InfillOptions): InfillPayload;
/**
* 从 Buffer 创建 Infill Payload(便捷方法)
*
* @param options 选项参数(使用 Buffer 而非 Base64)
*/
export declare function constructInfillPayloadFromBuffers(options: Omit<InfillOptions, 'imageBase64' | 'maskBase64'> & {
imageBuffer: Buffer;
maskBuffer: Buffer;
}): InfillPayload;