diff --git a/src/main/zimage.ts b/src/main/zimage.ts index 2fa5766..87d2c30 100644 --- a/src/main/zimage.ts +++ b/src/main/zimage.ts @@ -68,7 +68,7 @@ export async function getZImageModels(_event: IpcMainInvokeEvent, customModelDir async function runSingleZImage(_event: IpcMainEvent, args: string[], executablePath: string): Promise { return new Promise((resolve) => { zImageChild = spawn(executablePath, args, { - shell: true, + shell: false, // to allow prompt string with special characters }) zImageChild.stdout.on('data', (data) => { @@ -114,14 +114,6 @@ export async function runZImageCommand(_event: IpcMainEvent, options: ZImageOpti // Construct arguments const args: string[] = [] - args.push('-p', options.prompt) - - if (options.negativePrompt) { - args.push('-n', options.negativePrompt) - } - - // output - args.push('-o', outputPath) if (options.width && options.height) { args.push('-s', `${options.width},${options.height}`) @@ -135,15 +127,25 @@ export async function runZImageCommand(_event: IpcMainEvent, options: ZImageOpti args.push('-r', `${options.seed}`) } - if (options.model) { - const modelPath = join(options.modelDir, options.model) - args.push('-m', normalize(modelPath)) - } - if (options.gpuId && options.gpuId !== 'auto') { args.push('-g', `${options.gpuId}`) } + // model path + const modelPath = join(options.modelDir, options.model) + args.push('-m', normalize(modelPath)) + + // output + args.push('-o', outputPath) + + // negative prompt + if (options.negativePrompt) { + args.push('-n', options.negativePrompt) + } + + // prompt + args.push('-p', options.prompt) + const current_start_args = `[Batch ${i + 1}/${count}] Executing ZImage: ${getCorePath()} ${args.join(' ')} \n\n` console.log(current_start_args) _event.sender.send(IpcChannelOn.COMMAND_STDOUT, current_start_args) diff --git a/src/shared/type/zimage.ts b/src/shared/type/zimage.ts index 86d29e5..bc0f556 100644 --- a/src/shared/type/zimage.ts +++ b/src/shared/type/zimage.ts @@ -6,7 +6,7 @@ export interface ZImageOptions { height?: number steps?: number | 'auto' seed?: number | 'rand' - model?: string + model: string gpuId?: number | 'auto' count?: number modelDir: string