New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

node-sd-webui

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-sd-webui

Node.js client for AUTOMATIC1111's Stable Diffusion Web UI

latest
npmnpm
Version
0.0.8
Version published
Maintainers
1
Created
Source

Node Stable Diffusion Web UI Client

npm version

A Node.js client for using Automatic1111's Stable Diffusion Web UI.

Current Features

This project is a work in progress. Current features include:

  • txt2img generation
  • img2img generation
  • pngInfo support

Extensions

  • ControlNet support both txt2img and img2img

Getting Started

Requirements

Enable Stable Diffusion WebUI's API

In order to use the API, you first need to enable it. You can do so by appending --api to the command line arguments when running the webui.

For Linux: [webui-folder]/webui-user.sh

export COMMANDLINE_ARGS="--api"

For Windows: [webui-folder]/webui-user.bat

set COMMANDLINE_ARGS=--api

Installation

Add node-sd-webui to your project.

Using npm:

npm i -S node-sd-webui

Using yarn:

yarn add node-sd-webui

Using pnpm:

pnpm add node-sd-webui

Usage

txt2img

The txt2img function allows you to generate an image using the txt2img functionality of the Stable Diffusion WebUI.

Basic Example:

import sdwebui from 'node-sd-webui'
import { writeFileSync } from 'fs'

sdwebui()
  .txt2img({
    prompt: 'A photo of a mushroom',
  })
  .then(({ images }) => writeFileSync('path/to/image.png', images[0], 'base64'))
  .catch((err) => console.error(err))

Another example with a few more options:

import sdwebui, { SamplingMethod } from 'node-sd-webui'
import { writeFileSync } from 'fs'

const client = sdwebui()

try {
  const { images } = await client.txt2img({
    prompt: 'A photo of a mushroom, red cap, white spots',
    negativePrompt: 'blurry, cartoon, drawing, illustration',
    samplingMethod: SamplingMethod.Euler_A,
    width: 768,
    height: 512,
    steps: 20,
    batchSize: 5,
  })

  images.forEach((image, i) =>
    writeFileSync(`path/to/image-${i}.png`, images[i], 'base64')
  )
} catch (err) {
  console.error(err)
}

FAQs

Package last updated on 17 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts