From 34d32e9c523b144d0e4c0a27b74be2feaddb788d Mon Sep 17 00:00:00 2001 From: zhzluke96 Date: Thu, 23 May 2024 17:50:36 +0800 Subject: [PATCH] :memo: update --- .github/workflows/docs.yml | 1 + README.md | 350 +++++++++++++++++++++++++++++-------- package.json | 8 +- 3 files changed, 287 insertions(+), 72 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 1c6161a..4cbd1eb 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -5,6 +5,7 @@ on: - main paths: [ + "README.md", "src/**/*.js", "src/**/*.css", "src/**/*.html", diff --git a/README.md b/README.md index 15f8658..b75be7c 100644 --- a/README.md +++ b/README.md @@ -1,98 +1,308 @@ + + # sd-webui-a1111-client -a1111/webui client for nodejs/browser +API client for AUTOMATIC1111/stable-diffusion-webui for Node.js and Browser. + +- [Types Document](https://stablecanvas.github.io/sd-webui-a1111-client/) +- [Service Functions](https://stablecanvas.github.io/sd-webui-a1111-client/classes/DefaultService.html) + +## Features -# features +- Full TypeScript support +- Supports Node.js and browser environments +- Extensions: ControlNet, Cutoff, DynamicCFG, TiledDiffusion, TiledVAE, agent scheduler +- Batch processing support +- Easy integration with popular extensions and models -- full api typescript support -- nodejs/browser both ok -- backend process -- extensions (type) support - - ControlNet - - Cutoff - - DynamicCFG - - TiledDiffusion - - TiledVAE - - agent scheduler +## Requisites & Supported Versions -## support version -- webui: 1.8.0 -- control-net: 3b4eedd +### Requisites -# usage +- **Enable webui-api**: Use the `--api` command line argument. +- **Disable webui-gui (optional)**: Use `--nowebui` to disable the web GUI. +- > You can find and modify the `COMMANDLINE_ARGS` value in the `webui-user.bat` or `webui-user.sh` file. -## document -https://stablecanvas.github.io/sd-webui-a1111-client/ +### Supported Versions -## example code -> full code in [/examples](/examples) folder +- **WebUI**: 1.8.0 +- **ControlNet**: 3b4eedd -## nodejs +## Getting Started +### Client Instance ```ts -import { - SDWebUIA1111Client, - Txt2imgProcess, -} from "@stable-canvas/sd-webui-a1111-client"; -import fs from "fs"; +import { SDWebUIA1111Client } from "@stable-canvas/sd-webui-a1111-client"; const client = new SDWebUIA1111Client({ BASE: "http://localhost:7860", }); -const process = new Txt2imgProcess({ prompt: "1girl" }); -const { images } = await process.request(client); -const image = images[0]; // base64 image string -fs.writeFileSync("image.png", Buffer.from(image, "base64")); ``` -## browser +### Authentication -cdns (mjs): -- unpkg: https://unpkg.com/@stable-canvas/sd-webui-a1111-client@latest/dist/main.module.mjs -- jsdelivr: https://cdn.jsdelivr.net/npm/@stable-canvas/sd-webui-a1111-client@latest/+esm +Use the `--api-auth` command line argument with "username:password" on the server to enable API authentication. -cdns (umd) -- unpkg: https://unpkg.com/@stable-canvas/sd-webui-a1111-client@latest/dist/main.umd.min.js -- jsdelivr: https://cdn.jsdelivr.net/npm/@stable-canvas/sd-webui-a1111-client@latest/dist/main.umd.min.js +```ts +const client = new SDWebUIA1111Client({ + BASE: "http://localhost:7860", + USERNAME: 'your_username', + PASSWORD: 'your_password' +}); +``` -```html - -

@stable-canvas/sd-webui-a1111-client DEMO

-
- - + + + +

@stable-canvas/sd-webui-a1111-client DEMO

+
+ result + + + ``` -demo online: [codesandbox](https://codesandbox.io/s/sd-webui-a1111-client-demo-j38wmy?file=/src/index.js) +## Example Code + +- Full code is available in the [/examples](https://github.com/your-repo/examples) folder. +- Online demo: [CodeSandbox](https://codesandbox.io/s/sd-webui-a1111-client-demo-j38wmy?file=/src/index.js) + +## License -# license Apache-2.0 diff --git a/package.json b/package.json index 3d7cf48..f81225f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@stable-canvas/sd-webui-a1111-client", "version": "1.1.1", - "description": "", + "description": "API client for AUTOMATIC1111/stable-diffusion-webui for Node.js and Browser.", "source": "src/main.ts", "main": "dist/main.umd.js", "module": "dist/main.module.mjs", @@ -17,7 +17,11 @@ "webui", "diffusion", "ai", - "ai art" + "ai art", + "api", + "a1111", + "a1111-stable-diffusion-webui", + "stable-diffusion-webui" ], "files": [ "dist/**.js*",