diff --git a/.gitignore b/.gitignore index e574dad..824bc48 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ index.js node_modules -sdxl.gen.json +/sdxl.gen.json diff --git a/src/index.ts b/src/index.ts index 383988b..fdabc21 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,7 +13,7 @@ program .description('generate an image with sdxl') .argument('[config]', 'path to the config json', './sdxl.gen.json') .option('--init', 'create a default sdxl.gen.json') - .option('--append [where]', 'saves generated url to a text file') + .option('--append [where]', 'saves generated url to a text file', './generated.txt') .option('--queue [amount]', 'queues jobs without waiting for them') .action(async (config, flags) => { if (flags.init) { @@ -37,11 +37,10 @@ program for (let i = 0; i < queue; i++) { console.log(`Fetching ${i + 1}/${queue}...`); const job = await fetchProdia(json); + const url = `https://images.prodia.xyz/${job.job}.png`; if (flags.append) - await fs.appendFile( - flags.append, - `https://images.prodia.xyz/${job.job}.png\n` - ); + await fs.appendFile(flags.append, url + '\n'); + console.log(url); } console.log('Done!'); } else { diff --git a/src/prodia.ts b/src/prodia.ts index e0d0757..171151e 100644 --- a/src/prodia.ts +++ b/src/prodia.ts @@ -1,4 +1,5 @@ import fetch from 'node-fetch'; +import * as fs from 'fs/promises'; type ProdiaParams = { model: string; @@ -11,6 +12,12 @@ type ProdiaParams = { sampler: string; width: number; height: number; + + // transform params + denoising_strength: number; + upscale: boolean; + inputImage?: string; + imageData?: string; }; type ProdiaResponse = { @@ -30,12 +37,20 @@ export const defaultProdiaParams: ProdiaParams = { sampler: 'DPM++ 2M Karras', width: 1024, height: 1024, + + denoising_strength: 0.7, + upscale: false, }; export async function fetchProdia( params: Partial, endpoint = 'sdxl/generate' ) { + if(params.inputImage){ + const data = await fs.readFile(params.inputImage); + params.imageData = data.toString('base64'); + delete params.inputImage; + } const resp = await fetch(`https://api.prodia.com/v1/${endpoint}`, { method: 'POST', headers: {