Compare commits
2 Commits
ed13a48f12
...
9cc2dfd754
| Author | SHA1 | Date |
|---|---|---|
|
|
9cc2dfd754 | |
|
|
4197f66402 |
|
|
@ -1,3 +1,3 @@
|
||||||
index.js
|
index.js
|
||||||
node_modules
|
node_modules
|
||||||
sdxl.gen.json
|
/sdxl.gen.json
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ program
|
||||||
.description('generate an image with sdxl')
|
.description('generate an image with sdxl')
|
||||||
.argument('[config]', 'path to the config json', './sdxl.gen.json')
|
.argument('[config]', 'path to the config json', './sdxl.gen.json')
|
||||||
.option('--init', 'create a default 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')
|
.option('--queue [amount]', 'queues jobs without waiting for them')
|
||||||
.action(async (config, flags) => {
|
.action(async (config, flags) => {
|
||||||
if (flags.init) {
|
if (flags.init) {
|
||||||
|
|
@ -37,11 +37,10 @@ program
|
||||||
for (let i = 0; i < queue; i++) {
|
for (let i = 0; i < queue; i++) {
|
||||||
console.log(`Fetching ${i + 1}/${queue}...`);
|
console.log(`Fetching ${i + 1}/${queue}...`);
|
||||||
const job = await fetchProdia(json);
|
const job = await fetchProdia(json);
|
||||||
|
const url = `https://images.prodia.xyz/${job.job}.png`;
|
||||||
if (flags.append)
|
if (flags.append)
|
||||||
await fs.appendFile(
|
await fs.appendFile(flags.append, url + '\n');
|
||||||
flags.append,
|
console.log(url);
|
||||||
`https://images.prodia.xyz/${job.job}.png\n`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
console.log('Done!');
|
console.log('Done!');
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
|
import * as fs from 'fs/promises';
|
||||||
|
|
||||||
type ProdiaParams = {
|
type ProdiaParams = {
|
||||||
model: string;
|
model: string;
|
||||||
|
|
@ -11,6 +12,12 @@ type ProdiaParams = {
|
||||||
sampler: string;
|
sampler: string;
|
||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
|
|
||||||
|
// transform params
|
||||||
|
denoising_strength: number;
|
||||||
|
upscale: boolean;
|
||||||
|
input_image?: string;
|
||||||
|
imageData?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ProdiaResponse = {
|
type ProdiaResponse = {
|
||||||
|
|
@ -30,12 +37,20 @@ export const defaultProdiaParams: ProdiaParams = {
|
||||||
sampler: 'DPM++ 2M Karras',
|
sampler: 'DPM++ 2M Karras',
|
||||||
width: 1024,
|
width: 1024,
|
||||||
height: 1024,
|
height: 1024,
|
||||||
|
|
||||||
|
denoising_strength: 0.7,
|
||||||
|
upscale: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function fetchProdia(
|
export async function fetchProdia(
|
||||||
params: Partial<ProdiaParams>,
|
params: Partial<ProdiaParams>,
|
||||||
endpoint = 'sdxl/generate'
|
endpoint = 'sdxl/generate'
|
||||||
) {
|
) {
|
||||||
|
if(params.input_image){
|
||||||
|
const data = await fs.readFile(params.input_image);
|
||||||
|
params.imageData = data.toString('base64');
|
||||||
|
delete params.input_image;
|
||||||
|
}
|
||||||
const resp = await fetch(`https://api.prodia.com/v1/${endpoint}`, {
|
const resp = await fetch(`https://api.prodia.com/v1/${endpoint}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue