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