npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

stable-diffusion-client

v0.1.0

Published

smart stable-diffusion-webui client

Downloads

199

Readme

stable-diffusion-client

The library has been rewritten from the original library: sd-api with some changes:

  • Drop Axios, use fetch
  • Drop Buffer usage
  • Improve typing
  • Lazy image processing
  • replace string-similarity by fzf

stable-diffusion-webui is awesome, and you may want to integrate it right now into your JavaScript projects.

stable-diffusion-webui Client is written in Deno first.

Sample usage

By default stable-diffusion-webui run on localhost port 7860, it that the case you can omit the entry point: http://127.0.0.1:7860, with a openAPI donc available at http://127.0.0.1:7860/docs

API are disabled by default to enable APIs add in COMMANDLINE_ARGS:

  • --api to enable API access
  • --server-name=0.0.0.0 to access stable-diffusion-webui from a remote host
  • --api-log to debug incoming request

set COMMANDLINE_ARGS=--xformers --api --server-name=0.0.0.0

List available models

import { StableDiffusionApi } from "https://cdn.jsdelivr.net/gh/UrielCh/stable-diffusion-client@d3efc4b63edf731c9a0b9dcec41366e90fa6b9d4/mod.ts";
import { * as pc } from 'picocolors';

const SD = new StableDiffusionApi();
const list = await SD.getSdModels();
console.log(`${list.length} Models availables`);

Start a txt2img generation using Helper

import { StableDiffusionApi } from "https://cdn.jsdelivr.net/gh/UrielCh/stable-diffusion-client@d3efc4b63edf731c9a0b9dcec41366e90fa6b9d4/mod.ts";
const SD = new StableDiffusionApi({ timeout: 180_000 });

const helper = new SDHelper('http://127.0.0.1:7860');
const resp = await SD.txt2img({
  prompt:
    "A hyper - realistic GoPro selfie of a smiling glamorous Influencer with a t-rex Dinosaurus. Extreme environment.",
  negative_prompt:
    "sketch, ugly, blur, text, logo, monochrome, bad art, cut off, low contrast, underexposed, overexposed, beginner, amateur",
  width: 1024,
  height: 1024,
  sampler_name: "Euler a",
});
if (resp.images.length) {
  await resp.getSharpImage(0).webp().toFile(`${Date.now()}.webp`);
}