fun with prodia...
This commit is contained in:
parent
7d7cab9971
commit
4daac2c5b2
|
|
@ -1,2 +1,3 @@
|
||||||
index.js
|
index.js
|
||||||
node_modules
|
node_modules
|
||||||
|
sdxl.gen.json
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,9 @@
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"build": "esbuild src/index.ts --bundle --outfile=index.js --platform=node"
|
"build": "esbuild src/index.ts --bundle --outfile=index.js --platform=node"
|
||||||
},
|
},
|
||||||
|
"bin":{
|
||||||
|
"prodia": "./index.js"
|
||||||
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
||||||
24
src/index.ts
24
src/index.ts
|
|
@ -1,6 +1,7 @@
|
||||||
|
#!node
|
||||||
import { program } from 'commander';
|
import { program } from 'commander';
|
||||||
import * as fs from 'fs/promises';
|
import * as fs from 'fs/promises';
|
||||||
import { fetchProdia } from './prodia';
|
import { defaultProdiaParams, fetchProdia } from './prodia';
|
||||||
|
|
||||||
program
|
program
|
||||||
.name('prodia-scripts')
|
.name('prodia-scripts')
|
||||||
|
|
@ -10,10 +11,27 @@ program
|
||||||
program
|
program
|
||||||
.command('sdxl')
|
.command('sdxl')
|
||||||
.description('generate an image with sdxl')
|
.description('generate an image with sdxl')
|
||||||
.argument('<config>', 'path to the config json')
|
.argument('[config]', 'path to the config json', './sdxl.gen.json')
|
||||||
.action(async (config) => {
|
.option('--init', 'create a default sdxl.gen.json')
|
||||||
|
.action(async (config, flags) => {
|
||||||
|
console.log(config, flags);
|
||||||
|
|
||||||
|
if (flags.init) {
|
||||||
|
console.log('Creating sdxl.gen.json...');
|
||||||
|
await fs.writeFile(
|
||||||
|
'./sdxl.gen.json',
|
||||||
|
JSON.stringify(defaultProdiaParams, null, 4)
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
console.log(`Reading config=${config}...`);
|
||||||
const txt = await fs.readFile(config, { encoding: 'utf8' });
|
const txt = await fs.readFile(config, { encoding: 'utf8' });
|
||||||
const json = JSON.parse(txt);
|
const json = JSON.parse(txt);
|
||||||
|
|
||||||
|
console.log(`Fetching prodia api...`);
|
||||||
const status = await fetchProdia(json);
|
const status = await fetchProdia(json);
|
||||||
console.log('done:', status);
|
console.log('done:', status);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
program.parse();
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ type ProdiaResponse = {
|
||||||
imageUrl?: string;
|
imageUrl?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultParams: ProdiaParams = {
|
export const defaultProdiaParams: ProdiaParams = {
|
||||||
model: 'sd_xl_base_1.0.safetensors [be9edd61]',
|
model: 'sd_xl_base_1.0.safetensors [be9edd61]',
|
||||||
prompt: 'puppies in a cloud',
|
prompt: 'puppies in a cloud',
|
||||||
negative_prompt: 'badly drawn',
|
negative_prompt: 'badly drawn',
|
||||||
|
|
@ -44,7 +44,7 @@ export async function fetchProdia(
|
||||||
'X-Prodia-Key': '6e169a7f-444f-4c22-8353-b9a77d42645c',
|
'X-Prodia-Key': '6e169a7f-444f-4c22-8353-b9a77d42645c',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
...defaultParams,
|
...defaultProdiaParams,
|
||||||
...params,
|
...params,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue