Skip to content

Phantom8015/stable-diffusion-cjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stable-diffusion-cjs

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

Installation

npm install stable-diffusion-cjs

Usage

const { generate } = require('stable-diffusion-cjs');
const fs = require('fs'); 

const prompt = "A cat";

generate(prompt)
    .then((response) => {
        if (response.error) {
            console.log("There was an error generating the image.");
        } else {
            const filePath = './image.jpg';
            fs.writeFileSync(filePath, response); 
            console.log("Image generated successfully!");
            console.log(`Image saved at: ${filePath}`);
        }
    })
    .catch((error) => {
        console.error('Error:', error);
    });

A trick to get better images is to add:

{enhanced}

at the end of your prompt.

Output

A cat

About

Stable diffusion CJS package for Node JS

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published