Comparing version 1.0.2 to 2.0.0
@@ -11,3 +11,3 @@ #!/usr/bin/env node | ||
const count = argv.count || 3 | ||
const model = argv.model || 'stability-ai/stable-diffusion-3' | ||
const model = argv.model || 'black-forest-labs/flux-schnell' | ||
const subject = argv.subject | ||
@@ -17,3 +17,3 @@ const outputDir = argv.outputdir || '.' | ||
if (!prompt && !subject) { | ||
console.log('Usage: aimg <prompt> [--count 3] [--model stability-ai/stable-diffusion-3] [--subject <subject>] [--outputdir output-<timestamp>]') | ||
console.log('Usage: aimg <prompt> [--count 3] [--model black-forest-labs/flux-schnell] [--subject <subject>] [--outputdir output-<timestamp>]') | ||
process.exit() | ||
@@ -20,0 +20,0 @@ } |
@@ -15,4 +15,7 @@ import fs from 'node:fs/promises' | ||
let output | ||
let predictionId | ||
try { | ||
output = await replicate.run(model, { input }) | ||
output = await replicate.run(model, { input }, ({ id }) => { | ||
predictionId = id | ||
}) | ||
console.log({ input, output }) | ||
@@ -31,8 +34,11 @@ } catch (error) { | ||
// Only one URL? Make it an array. | ||
if (!Array.isArray(output)) { | ||
output = [output] | ||
} | ||
for (const url of output) { | ||
const urlPath = new URL(url).pathname | ||
const segments = urlPath.split('/') | ||
const secondToLastSegment = segments[segments.length - 2] | ||
const fileExtension = path.extname(urlPath) | ||
const filename = `${secondToLastSegment}-${slugify(input.prompt).substring(0, 100)}${fileExtension}` | ||
const filename = `${predictionId}-${slugify(input.prompt).substring(0, 100)}${fileExtension}` | ||
@@ -39,0 +45,0 @@ await download(url, outputDir, { filename }) |
{ | ||
"name": "aimg", | ||
"version": "1.0.2", | ||
"version": "2.0.0", | ||
"description": "A Node.js CLI for generating AI images with Replicate and saving them to disk.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/zeke/aimg", |
@@ -10,3 +10,3 @@ # aimg | ||
- Easy to install and use. | ||
- Powered by [SD3](https://replicate.com/stability-ai/stable-diffusion-3), the hot new open-source image model. | ||
- Supports multiple models like [Flux](https://replicate.com/blog/flux-state-of-the-art-image-generation) and [SD3](https://replicate.com/stability-ai/stable-diffusion-3). Default is [Flux Schnell](https://replicate.com/black-forest-labs/flux-schnell). | ||
- Saves all the files to disk for you. | ||
@@ -46,2 +46,12 @@ - Includes prediction id and a slug of the prompt in the filename. | ||
## Different model | ||
The default model is [Flux Schnell](https://replicate.com/blog/flux-state-of-the-art-image-generation), the new state-of-the-art image generation model for the creators of Stable Diffusion. | ||
If you want to use a different model, specify it with the `--model` option. Here's an example using SD3: | ||
``` | ||
aimg "cute cat" --model "stability-ai/stable-diffusion-3" | ||
``` | ||
### More images | ||
@@ -48,0 +58,0 @@ |
5118
59
93