Giter VIP home page Giter VIP logo

stability-client's Introduction

stability-client

A client library for the Stability AI SDK.

Requires an API Key for DreamStudio which can be found here.

Installation

# NPM
npm i -g stability-client

# To Update
npm update -g stability-client

# Yarn
yarn global add stability-client

Example

stability \
  -s 150 \ # Steps
  -c 15 \ # Cfg Scale
  -a k_euler_ancestral \ # Diffusion Method
  -S 3465383516 \ # Seed
  -o ./examples \ # Output Directory
  -n 5 \ # 5 images
  "a anime still of an highly detailed night cyberpunk city life, bladerunner style!! detailed shops, neon lights, ray tracing, advertising everywhere, people and robots walking around. art by satoshi kon and studio ghibli, in the style of ghost in the shell, muted colours, hyperrealism, cinematic lighting, lush detail, award winning, wlop, octane render, trending on artstation"

Output


API

import { generate } from 'stability-client'

const api = generate({
  prompt: 'A Stunning House',
  apiKey: process.env.DREAMSTUDIO_API_KEY,
})

api.on('image', ({ buffer, filePath }) => {
  console.log('Image', buffer, filePath)
})

api.on('end', (data) => {
  console.log('Generating Complete', data)
})

Async/Promise API

import { generateAsync } from 'stability-client'

try {
  const { res, images } = await generateAsync({
    prompt: 'A Stunning House',
    apiKey: process.env.DREAMSTUDIO_API_KEY,
  })
  console.log(images)
} catch (e) {
  // ...
}

Example with a lot of options:

const imgBuffer =  Buffer.from(base64ImageRaw, 'base64');

const api = await generate({
      prompt: `amazing looking room, Dean Norton style`,
      apiKey: process.env.STABLE_DIFFUSION_KEY,
      width: 512,
      height: 512,
      steps: 10,
      engine: 'stable-diffusion-512-v2-1',
      cfgScale: 10,
      noStore: true, //means it will not store in the .out dir after generation.
      imagePrompt: {
          mime: 'image/png',
          content: imgBuffer
     },
      samples: 1,
      diffusion: 'ddim',
      outDir: '/output'
})
    
 api.on('image', async ({ buffer, imagePath }) => {
     // upload somewhere probably..
     
    })
  
api.on('end', (data) => {
      console.log('Generating Complete', data);
    })

CLI

Usage: stability [options] [prompt]

Generate an image

Arguments:
  prompt                           The text prompt you want to use

Options:
  -V, --version                    output the version number
  -H, --height <height>            height of image (default: 512)
  -W, --width <width>              width of image (default: 512)
  -c, --cfg_scale <scale>          CFG scale factor (default: 7)
  -a, --sampler <sampler>          Diffusion Method (choices: "ddim", "plms", "k_euler", "k_euler_ancestral", "k_heun", "k_dpm_2", "k_dpm_2_ancestral", "k_lms", default: "k_lms")
  -s, --steps <steps>              number of steps (default: 50)
  -S, --seed <seed>                random seed to use (default: 1614811539)
  -n, --num_samples <num_samples>  number of samples to generate (default: 1)
  -e, --engine <engine>            engine to use for inference (default: "stable-diffusion-v1")
  --no-store                       do not write aritfacts to disk
  -k, --api-key <api-key>          DreamStudio API Key (env: DREAMSTUDIO_API_KEY)
  -o, --output-dir <outputDir>     directory to store images (defaults to cwd)
  -d, --debug                      Additional logging
  -h, --help                       display help for command

Developing

nvm use
yarn
yarn build

npm link

export DREAMSTUDIO_API_KEY=...

stability "A stunning house"

stability-client's People

Contributors

vpzomtrrfrt avatar jakiestfu avatar moe03 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.