diff --git a/.gitignore b/.gitignore index 657eacb..bcba010 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .env output-* -*.webp \ No newline at end of file +*.webp +*.jpg \ No newline at end of file diff --git a/README.md b/README.md index 97aa44a..33762dd 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,14 @@ If you want more images, use the `--count` option: aimg "cute cat" --count 20 ``` +## Extra flags as inputs to the model + +Any extra flags you pass will be passed along to the model as input. For example, if the model takes an `output_format` input, you can pass it like this: + +``` +aimg "cute cat" --output_format jpg +``` + ### Random prompts If you want generate a different semi-random prompt for each image, specify a `subject` and it will use [promptmaker](https://npm.im/promptmaker) to generate random prompts: diff --git a/index.js b/index.js index d6fd3bc..877fb53 100755 --- a/index.js +++ b/index.js @@ -13,7 +13,7 @@ const subject = argv.subject const outputDir = argv.outputdir || '.' if (!prompt && !subject) { - console.log('Usage: aimg [--count 3] [--model black-forest-labs/flux-schnell] [--subject ] [--outputdir output-]') + console.log('Usage: aimg [--count 3] [--model black-forest-labs/flux-schnell] [--subject ] [--outputdir output-] [-- ...]') process.exit() } @@ -25,5 +25,14 @@ for (let i = 0; i < count; i++) { prompt = promptmaker({ subject }) } - run({ model, prompt, outputDir }) + const input = { prompt } + + // Add arbitrary CLI flags to the input object + for (const [key, value] of Object.entries(argv)) { + if (!['_', 'count', 'model', 'subject', 'outputdir'].includes(key)) { + input[key] = value + } + } + + run({ model, input, outputDir }) } diff --git a/lib/run.js b/lib/run.js index 9d1a60c..04f7b5f 100644 --- a/lib/run.js +++ b/lib/run.js @@ -20,9 +20,7 @@ async function getModelFullNameWithVersion (model) { throw new Error('Invalid model format. Expected "owner/name".') } -export async function run ({ model, prompt, outputDir }) { - const input = { prompt } - +export async function run ({ model, input, outputDir }) { let output let prediction try {