stable-diffusion-ts

1.0.0 • Public • Published

stable-diffusion-es

This is an ES module for Node.js that provides uses Stable Diffusion to generate images from a given prompt using AI.

Installation

npm install stable-diffusion-es

Usage

import { generate } from "stable-diffusion-ts";
const prompt = "A black cat";

generate(prompt, (response) => {
  if (response.error) {
    console.log("There was an error generating the image.");
  } else {
    console.log("Image generated successfully!");
    console.log(`Image saved at: ${response.results}`);
  }
});

you can also pass a file path to save the image to.

import { generate } from "stable-diffusion-ts";
const prompt = "A black cat";

generate(prompt, (response) => {
  if (response.error) {
    console.log("There was an error generating the image.");
  } else {
    console.log("Image generated successfully!");
    console.log(`Image saved at: ${response.results}`);
  }
}, "path/to/save/image");

A trick to get better images is to add:

{enhanced}

at the end of your prompt.

in your package.json file.

Output

A black cat

/stable-diffusion-ts/

    Package Sidebar

    Install

    npm i stable-diffusion-ts

    Weekly Downloads

    0

    Version

    1.0.0

    License

    CC BY-NC 4.0

    Unpacked Size

    294 kB

    Total Files

    7

    Last publish

    Collaborators

    • b....