Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aimg

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aimg - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

26

lib/run.js

@@ -11,2 +11,12 @@ import fs from 'node:fs/promises'

async function getModelFullNameWithVersion (model) {
const [owner, name] = model.split('/')
if (owner && name) {
const { results: versions } = await replicate.models.versions.list(owner, name)
const latestVersion = versions[0].id
return `${model}:${latestVersion}`
}
throw new Error('Invalid model format. Expected "owner/name".')
}
export async function run ({ model, prompt, outputDir }) {

@@ -21,8 +31,18 @@ const input = { prompt }

})
console.log({ input, output })
} catch (error) {
console.error(error)
return
if (error.response?.status === 422) {
console.log(`Received 422 error from the Replicate API. Attempting to fetch version data for ${model}...`)
const versionedModel = await getModelFullNameWithVersion(model)
console.log(`Rerunning with versioned model: ${versionedModel}`)
output = await replicate.run(versionedModel, { input }, ({ id }) => {
predictionId = id
})
} else {
console.error('Error running model:', error)
return
}
}
console.log({ input, output })
if (!output || output.length === 0) {

@@ -29,0 +49,0 @@ console.error('No output')

2

package.json
{
"name": "aimg",
"version": "2.0.0",
"version": "2.0.1",
"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.
- 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).
- Supports any model on Replicate that has a `prompt` input. Default is [Flux Schnell](https://replicate.com/black-forest-labs/flux-schnell).
- Saves all the files to disk for you.

@@ -22,3 +22,3 @@ - Includes prediction id and a slug of the prompt in the filename.

The grab a [Replicate API token](https://replicate.com/account/api-tokens) and set it in your environment:
Then grab a [Replicate API token](https://replicate.com/account/api-tokens) and set it in your environment:

@@ -49,8 +49,22 @@ ```

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.
The default model is [Flux Schnell](https://replicate.com/blog/flux-state-of-the-art-image-generation), but you can specify any model with the `--model` option.
If you want to use a different model, specify it with the `--model` option. Here's an example using SD3:
```
aimg "cute cat" --model bytedance/sdxl-lightning-4step
```
This will work for any model on Replicate that takes a `prompt` as input and outputs a list of URLs.
Examples:
- [`black-forest-labs/flux-dev`](https://replicate.com/black-forest-labs/flux-dev)
- [`bytedance/sdxl-lightning-4step`](https://replicate.com/bytedance/sdxl-lightning-4step)
- [`stability-ai/stable-diffusion-3`](https://replicate.com/stability-ai/stable-diffusion-3)
- [`zeke/ziki-flux`](https://replicate.com/zeke/ziki-flux) ← works for [Flux fine-tunes](https://replicate.com/collections/flux-fine-tunes) too!
- [more...](https://replicate.com/collections/text-to-image)
The latest version of the model is used unless you specify a version in the format `{owner}/{name}:{version}`:
```
aimg "cute cat" --model "stability-ai/stable-diffusion-3"
aimg "cute cat" --model zeke/ziki-flux:dadc276a9062240e68f110ca06521752f334777a94f031feb0ae78ae3edca58e
```

@@ -57,0 +71,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc