diff --git a/src/config.ts b/src/config.ts index fe86c3c..a762fd7 100644 --- a/src/config.ts +++ b/src/config.ts @@ -156,7 +156,7 @@ interface ParamConfig { textSteps?: number imageSteps?: number maxSteps?: number - restoreFaces?: boolean + restoreFaces?: 'CodeFormer' | 'GFPGAN' | boolean hiresFix?: boolean } @@ -248,6 +248,11 @@ export const Config = Schema.intersect([ type: Schema.const('stable-horde'), sampler: sampler.createSchema(sampler.horde), model: Schema.union(hordeModels), + restoreFaces: Schema.union([ + Schema.const(false).description('禁用'), + Schema.const('CodeFormer').description('使用 CodeFormer'), + Schema.const('GFPGAN').description('使用 GFPGAN'), + ]).description('是否启用人脸修复。').default(false), }), Schema.object({ type: Schema.const('naifu'), diff --git a/src/index.ts b/src/index.ts index 4389b50..f682b83 100644 --- a/src/index.ts +++ b/src/index.ts @@ -270,7 +270,7 @@ export function apply(ctx: Context, config: Config) { return { sampler_index: sampler.sd[options.sampler], init_images: image && [image.dataUrl], // sd-webui accepts data URLs with base64 encoded image - restore_faces: config.restoreFaces ?? false, + restore_faces: config.restoreFaces === true, enable_hr: options.hiresFix ?? config.hiresFix ?? false, ...project(parameters, { prompt: 'prompt', @@ -286,6 +286,10 @@ export function apply(ctx: Context, config: Config) { } } case 'stable-horde': { + const postProcessing = [] + if (typeof config.restoreFaces === 'string') { + postProcessing.push(config.restoreFaces) + } return { prompt: parameters.prompt, params: { @@ -295,7 +299,7 @@ export function apply(ctx: Context, config: Config) { seed: parameters.seed.toString(), height: parameters.height, width: parameters.width, - post_processing: [], + post_processing: postProcessing, karras: options.sampler.includes('_ka'), steps: parameters.steps, n: 1,