node-sd-webui
Advanced tools
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.mapControlNetOptions = exports.Preprocessor = exports.ResizeMode = void 0; | ||
| var ResizeMode; | ||
| (function (ResizeMode) { | ||
| ResizeMode["Envelope"] = "Envelope (Outer Fit)"; | ||
| ResizeMode["ScaleToFit"] = "Scale to Fit (Inner Fit)"; | ||
| ResizeMode["JustResize"] = "Just Resize"; | ||
| })(ResizeMode = exports.ResizeMode || (exports.ResizeMode = {})); | ||
| var Preprocessor; | ||
| (function (Preprocessor) { | ||
| Preprocessor["None"] = "none"; | ||
| Preprocessor["Canny"] = "canny"; | ||
| Preprocessor["Depth"] = "depth"; | ||
| Preprocessor["Depth_LeRes"] = "depth_leres"; | ||
| Preprocessor["HED"] = "hed"; | ||
| Preprocessor["MLSD"] = "mlsd"; | ||
| Preprocessor["NormalMap"] = "normal_map"; | ||
| Preprocessor["OpenPose"] = "openpose"; | ||
| Preprocessor["Pidinet"] = "pidinet"; | ||
| Preprocessor["Scribble"] = "scribble"; | ||
| Preprocessor["Fake_Scribble"] = "fake_scribble"; | ||
| Preprocessor["Segmentation"] = "segmentation"; | ||
| })(Preprocessor = exports.Preprocessor || (exports.Preprocessor = {})); | ||
| const mapControlNetOptions = (options) => { | ||
| let body = { | ||
| module: options.preprocessor || Preprocessor.None, | ||
| model: options.model || 'None', | ||
| weight: options.weight || 1, | ||
| guidance_start: options.guidanceStart || 0, | ||
| guidance_end: options.guidanceEnd || 1, | ||
| resize_mode: options.resizeMode || ResizeMode.ScaleToFit, | ||
| guess_mode: options.guessMode || false, | ||
| lowvram: options.lowvram || false, | ||
| }; | ||
| if (options.inputImageData) { | ||
| body.input_image = options.inputImageData; | ||
| } | ||
| if (options.mask) { | ||
| body.mask = options.mask; | ||
| } | ||
| return body; | ||
| }; | ||
| exports.mapControlNetOptions = mapControlNetOptions; |
+25
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.SamplingMethod = void 0; | ||
| var SamplingMethod; | ||
| (function (SamplingMethod) { | ||
| SamplingMethod["Euler_A"] = "Euler a"; | ||
| SamplingMethod["Euler"] = "Euler"; | ||
| SamplingMethod["LMS"] = "LMS"; | ||
| SamplingMethod["Heun"] = "Heun"; | ||
| SamplingMethod["DPM2"] = "DPM2"; | ||
| SamplingMethod["DPM2_A"] = "DPM2 a"; | ||
| SamplingMethod["DPMPlusPlus_S2_A"] = "DPM++ S2 a"; | ||
| SamplingMethod["DPMPlusPlus_2M"] = "DPM++ 2M"; | ||
| SamplingMethod["DPMPlusPlus_SDE"] = "DPM++ SDE"; | ||
| SamplingMethod["DPM_Fast"] = "DPM fast"; | ||
| SamplingMethod["DPM_Adaptive"] = "DPM adaptive"; | ||
| SamplingMethod["LMS_Karras"] = "LMS Karras"; | ||
| SamplingMethod["DPM2_Karras"] = "DPM2 Karras"; | ||
| SamplingMethod["DPM2_A_Karras"] = "DPM2 a Karras"; | ||
| SamplingMethod["DPMPlusPlus_2S_A_Karras"] = "DPM++ 2S a Karras"; | ||
| SamplingMethod["DPMPlusPlus_2M_Karras"] = "DPM++ 2M Karras"; | ||
| SamplingMethod["DPMPlusPlus_SDE_Karras"] = "DPM++ SDE Karras"; | ||
| SamplingMethod["DDIM"] = "DDIM"; | ||
| SamplingMethod["PLMS"] = "PLMS"; | ||
| })(SamplingMethod = exports.SamplingMethod || (exports.SamplingMethod = {})); |
| export var ResizeMode; | ||
| (function (ResizeMode) { | ||
| ResizeMode["Envelope"] = "Envelope (Outer Fit)"; | ||
| ResizeMode["ScaleToFit"] = "Scale to Fit (Inner Fit)"; | ||
| ResizeMode["JustResize"] = "Just Resize"; | ||
| })(ResizeMode || (ResizeMode = {})); | ||
| export var Preprocessor; | ||
| (function (Preprocessor) { | ||
| Preprocessor["None"] = "none"; | ||
| Preprocessor["Canny"] = "canny"; | ||
| Preprocessor["Depth"] = "depth"; | ||
| Preprocessor["Depth_LeRes"] = "depth_leres"; | ||
| Preprocessor["HED"] = "hed"; | ||
| Preprocessor["MLSD"] = "mlsd"; | ||
| Preprocessor["NormalMap"] = "normal_map"; | ||
| Preprocessor["OpenPose"] = "openpose"; | ||
| Preprocessor["Pidinet"] = "pidinet"; | ||
| Preprocessor["Scribble"] = "scribble"; | ||
| Preprocessor["Fake_Scribble"] = "fake_scribble"; | ||
| Preprocessor["Segmentation"] = "segmentation"; | ||
| })(Preprocessor || (Preprocessor = {})); | ||
| export const mapControlNetOptions = (options) => { | ||
| let body = { | ||
| module: options.preprocessor || Preprocessor.None, | ||
| model: options.model || 'None', | ||
| weight: options.weight || 1, | ||
| guidance_start: options.guidanceStart || 0, | ||
| guidance_end: options.guidanceEnd || 1, | ||
| resize_mode: options.resizeMode || ResizeMode.ScaleToFit, | ||
| guess_mode: options.guessMode || false, | ||
| lowvram: options.lowvram || false, | ||
| }; | ||
| if (options.inputImageData) { | ||
| body.input_image = options.inputImageData; | ||
| } | ||
| if (options.mask) { | ||
| body.mask = options.mask; | ||
| } | ||
| return body; | ||
| }; |
+22
| export var SamplingMethod; | ||
| (function (SamplingMethod) { | ||
| SamplingMethod["Euler_A"] = "Euler a"; | ||
| SamplingMethod["Euler"] = "Euler"; | ||
| SamplingMethod["LMS"] = "LMS"; | ||
| SamplingMethod["Heun"] = "Heun"; | ||
| SamplingMethod["DPM2"] = "DPM2"; | ||
| SamplingMethod["DPM2_A"] = "DPM2 a"; | ||
| SamplingMethod["DPMPlusPlus_S2_A"] = "DPM++ S2 a"; | ||
| SamplingMethod["DPMPlusPlus_2M"] = "DPM++ 2M"; | ||
| SamplingMethod["DPMPlusPlus_SDE"] = "DPM++ SDE"; | ||
| SamplingMethod["DPM_Fast"] = "DPM fast"; | ||
| SamplingMethod["DPM_Adaptive"] = "DPM adaptive"; | ||
| SamplingMethod["LMS_Karras"] = "LMS Karras"; | ||
| SamplingMethod["DPM2_Karras"] = "DPM2 Karras"; | ||
| SamplingMethod["DPM2_A_Karras"] = "DPM2 a Karras"; | ||
| SamplingMethod["DPMPlusPlus_2S_A_Karras"] = "DPM++ 2S a Karras"; | ||
| SamplingMethod["DPMPlusPlus_2M_Karras"] = "DPM++ 2M Karras"; | ||
| SamplingMethod["DPMPlusPlus_SDE_Karras"] = "DPM++ SDE Karras"; | ||
| SamplingMethod["DDIM"] = "DDIM"; | ||
| SamplingMethod["PLMS"] = "PLMS"; | ||
| })(SamplingMethod || (SamplingMethod = {})); |
| export declare enum ResizeMode { | ||
| Envelope = "Envelope (Outer Fit)", | ||
| ScaleToFit = "Scale to Fit (Inner Fit)", | ||
| JustResize = "Just Resize" | ||
| } | ||
| export declare enum Preprocessor { | ||
| None = "none", | ||
| Canny = "canny", | ||
| Depth = "depth", | ||
| Depth_LeRes = "depth_leres", | ||
| HED = "hed", | ||
| MLSD = "mlsd", | ||
| NormalMap = "normal_map", | ||
| OpenPose = "openpose", | ||
| Pidinet = "pidinet", | ||
| Scribble = "scribble", | ||
| Fake_Scribble = "fake_scribble", | ||
| Segmentation = "segmentation" | ||
| } | ||
| export type ControlNetOptions = { | ||
| inputImageData?: string; | ||
| mask?: string; | ||
| preprocessor?: Preprocessor; | ||
| model?: string; | ||
| weight?: number; | ||
| resizeMode?: ResizeMode; | ||
| lowvram?: boolean; | ||
| thresholdA?: number; | ||
| thresholdB?: number; | ||
| guidance?: number; | ||
| guidanceStart?: number; | ||
| guidanceEnd?: number; | ||
| guessMode?: boolean; | ||
| }; | ||
| export declare const mapControlNetOptions: (options: ControlNetOptions) => any; |
| export declare enum SamplingMethod { | ||
| Euler_A = "Euler a", | ||
| Euler = "Euler", | ||
| LMS = "LMS", | ||
| Heun = "Heun", | ||
| DPM2 = "DPM2", | ||
| DPM2_A = "DPM2 a", | ||
| DPMPlusPlus_S2_A = "DPM++ S2 a", | ||
| DPMPlusPlus_2M = "DPM++ 2M", | ||
| DPMPlusPlus_SDE = "DPM++ SDE", | ||
| DPM_Fast = "DPM fast", | ||
| DPM_Adaptive = "DPM adaptive", | ||
| LMS_Karras = "LMS Karras", | ||
| DPM2_Karras = "DPM2 Karras", | ||
| DPM2_A_Karras = "DPM2 a Karras", | ||
| DPMPlusPlus_2S_A_Karras = "DPM++ 2S a Karras", | ||
| DPMPlusPlus_2M_Karras = "DPM++ 2M Karras", | ||
| DPMPlusPlus_SDE_Karras = "DPM++ SDE Karras", | ||
| DDIM = "DDIM", | ||
| PLMS = "PLMS" | ||
| } |
+1
-1
@@ -20,3 +20,3 @@ "use strict"; | ||
| const txt2img_js_1 = require("./sdapi/txt2img.js"); | ||
| __exportStar(require("./sdapi/types.js"), exports); | ||
| __exportStar(require("./types.js"), exports); | ||
| const sdwebui = (props) => { | ||
@@ -23,0 +23,0 @@ const apiUrl = props?.apiUrl || 'http://localhost:7860'; |
+10
-1
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.img2img = void 0; | ||
| const index_js_1 = require("../extensions/controlNet/index.js"); | ||
| const img2img = async (options, apiUrl = 'http://localhost:7860') => { | ||
@@ -22,4 +23,12 @@ let body = { | ||
| }; | ||
| const { extensions } = options; | ||
| if (extensions?.controlNet) { | ||
| body.controlnet_units = extensions.controlNet.map(index_js_1.mapControlNetOptions); | ||
| } | ||
| let endpoint = '/sdapi/v1/img2img'; | ||
| if (options.extensions?.controlNet) { | ||
| endpoint = '/controlnet/img2img'; | ||
| } | ||
| /* @ts-ignore */ | ||
| const result = await fetch(`${apiUrl}/sdapi/v1/img2img`, { | ||
| const result = await fetch(`${apiUrl}${endpoint}`, { | ||
| method: 'POST', | ||
@@ -26,0 +35,0 @@ body: JSON.stringify(body), |
@@ -20,2 +20,2 @@ "use strict"; | ||
| __exportStar(require("./pngInfo"), exports); | ||
| __exportStar(require("./types"), exports); | ||
| __exportStar(require("../types"), exports); |
+15
-2
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.txt2img = void 0; | ||
| const txt2img = async (options, apiUrl = 'http://localhost:7860') => { | ||
| const index_js_1 = require("../extensions/controlNet/index.js"); | ||
| const mapTxt2ImgOptions = (options) => { | ||
| let body = { | ||
@@ -40,4 +41,16 @@ prompt: options.prompt, | ||
| } | ||
| const { extensions } = options; | ||
| if (extensions?.controlNet) { | ||
| body.controlnet_units = extensions.controlNet.map(index_js_1.mapControlNetOptions); | ||
| } | ||
| return body; | ||
| }; | ||
| const txt2img = async (options, apiUrl = 'http://localhost:7860') => { | ||
| const body = mapTxt2ImgOptions(options); | ||
| let endpoint = '/sdapi/v1/txt2img'; | ||
| if (options.extensions?.controlNet) { | ||
| endpoint = '/controlnet/txt2img'; | ||
| } | ||
| /* @ts-ignore */ | ||
| const result = await fetch(`${apiUrl}/sdapi/v1/txt2img`, { | ||
| const result = await fetch(`${apiUrl}${endpoint}`, { | ||
| method: 'POST', | ||
@@ -44,0 +57,0 @@ body: JSON.stringify(body), |
+1
-1
| import { img2img } from './sdapi/img2img.js'; | ||
| import { pngInfo } from './sdapi/pngInfo.js'; | ||
| import { txt2img } from './sdapi/txt2img.js'; | ||
| export * from './sdapi/types.js'; | ||
| export * from './types.js'; | ||
| const sdwebui = (props) => { | ||
@@ -6,0 +6,0 @@ const apiUrl = props?.apiUrl || 'http://localhost:7860'; |
+10
-1
@@ -0,1 +1,2 @@ | ||
| import { mapControlNetOptions, } from '../extensions/controlNet/index.js'; | ||
| export const img2img = async (options, apiUrl = 'http://localhost:7860') => { | ||
@@ -19,4 +20,12 @@ let body = { | ||
| }; | ||
| const { extensions } = options; | ||
| if (extensions?.controlNet) { | ||
| body.controlnet_units = extensions.controlNet.map(mapControlNetOptions); | ||
| } | ||
| let endpoint = '/sdapi/v1/img2img'; | ||
| if (options.extensions?.controlNet) { | ||
| endpoint = '/controlnet/img2img'; | ||
| } | ||
| /* @ts-ignore */ | ||
| const result = await fetch(`${apiUrl}/sdapi/v1/img2img`, { | ||
| const result = await fetch(`${apiUrl}${endpoint}`, { | ||
| method: 'POST', | ||
@@ -23,0 +32,0 @@ body: JSON.stringify(body), |
| export * from './txt2img'; | ||
| export * from './img2img'; | ||
| export * from './pngInfo'; | ||
| export * from './types'; | ||
| export * from '../types'; |
+15
-2
@@ -1,2 +0,3 @@ | ||
| export const txt2img = async (options, apiUrl = 'http://localhost:7860') => { | ||
| import { mapControlNetOptions, } from '../extensions/controlNet/index.js'; | ||
| const mapTxt2ImgOptions = (options) => { | ||
| let body = { | ||
@@ -37,4 +38,16 @@ prompt: options.prompt, | ||
| } | ||
| const { extensions } = options; | ||
| if (extensions?.controlNet) { | ||
| body.controlnet_units = extensions.controlNet.map(mapControlNetOptions); | ||
| } | ||
| return body; | ||
| }; | ||
| export const txt2img = async (options, apiUrl = 'http://localhost:7860') => { | ||
| const body = mapTxt2ImgOptions(options); | ||
| let endpoint = '/sdapi/v1/txt2img'; | ||
| if (options.extensions?.controlNet) { | ||
| endpoint = '/controlnet/txt2img'; | ||
| } | ||
| /* @ts-ignore */ | ||
| const result = await fetch(`${apiUrl}/sdapi/v1/txt2img`, { | ||
| const result = await fetch(`${apiUrl}${endpoint}`, { | ||
| method: 'POST', | ||
@@ -41,0 +54,0 @@ body: JSON.stringify(body), |
+1
-1
| { | ||
| "name": "node-sd-webui", | ||
| "version": "0.0.6", | ||
| "version": "0.0.7", | ||
| "license": "MIT", | ||
@@ -5,0 +5,0 @@ "engines": { |
+17
-3
| # Node Stable Diffusion WebUI Client | ||
| A Node.js client for using Automatic1111's Stable Diffusion WebUI. | ||
| A Node.js client for using Automatic1111's Stable Diffusion Web UI. | ||
| ## Current Features | ||
| This project is a work in progress. The currently supported features are: | ||
| This project is a work in progress. Current features include: | ||
@@ -13,4 +13,18 @@ - [x] txt2img generation | ||
| ## Installation | ||
| ### Extensions | ||
| - [x] ControlNet support both txt2img and img2img | ||
| ## Getting Started | ||
| ### Requirements | ||
| - Node.js >= 18 | ||
| - Automatic1111's | ||
| [Stable Diffusion Web UI](https://github.com/AUTOMATIC1111/stable-diffusion-webui/) | ||
| - ControlNet support requires | ||
| [sd-webui-controlnet](https://github.com/Mikubill/sd-webui-controlnet) | ||
| ### Installation | ||
| Add `node-sd-webui` to your project. | ||
@@ -17,0 +31,0 @@ |
+1
-1
| import { Img2ImgOptions, Img2ImgResponse } from './sdapi/img2img.js'; | ||
| import { PngInfoOptions, PngInfoResponse } from './sdapi/pngInfo.js'; | ||
| import { Txt2ImgOptions, Txt2ImgResponse } from './sdapi/txt2img.js'; | ||
| export * from './sdapi/types.js'; | ||
| export * from './types.js'; | ||
| type Props = { | ||
@@ -6,0 +6,0 @@ apiUrl?: string; |
@@ -0,1 +1,2 @@ | ||
| import { ControlNetOptions } from '../extensions/controlNet/index.js'; | ||
| export type Img2ImgOptions = { | ||
@@ -18,2 +19,5 @@ imageData: string[]; | ||
| restoreFaces?: boolean; | ||
| extensions?: { | ||
| controlNet?: ControlNetOptions[]; | ||
| }; | ||
| }; | ||
@@ -20,0 +24,0 @@ export type Img2ImgResponse = { |
| export * from './txt2img'; | ||
| export * from './img2img'; | ||
| export * from './pngInfo'; | ||
| export * from './types'; | ||
| export * from '../types'; |
@@ -0,1 +1,2 @@ | ||
| import { ControlNetOptions } from '../extensions/controlNet/index.js'; | ||
| export type Txt2ImgOptions = { | ||
@@ -29,2 +30,5 @@ hires?: { | ||
| }; | ||
| extensions?: { | ||
| controlNet?: ControlNetOptions[]; | ||
| }; | ||
| }; | ||
@@ -31,0 +35,0 @@ export type Txt2ImgResponse = { |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.SamplingMethod = void 0; | ||
| var SamplingMethod; | ||
| (function (SamplingMethod) { | ||
| SamplingMethod["Euler_A"] = "Euler a"; | ||
| SamplingMethod["Euler"] = "Euler"; | ||
| SamplingMethod["LMS"] = "LMS"; | ||
| SamplingMethod["Heun"] = "Heun"; | ||
| SamplingMethod["DPM2"] = "DPM2"; | ||
| SamplingMethod["DPM2_A"] = "DPM2 a"; | ||
| SamplingMethod["DPMPlusPlus_S2_A"] = "DPM++ S2 a"; | ||
| SamplingMethod["DPMPlusPlus_2M"] = "DPM++ 2M"; | ||
| SamplingMethod["DPMPlusPlus_SDE"] = "DPM++ SDE"; | ||
| SamplingMethod["DPM_Fast"] = "DPM fast"; | ||
| SamplingMethod["DPM_Adaptive"] = "DPM adaptive"; | ||
| SamplingMethod["LMS_Karras"] = "LMS Karras"; | ||
| SamplingMethod["DPM2_Karras"] = "DPM2 Karras"; | ||
| SamplingMethod["DPM2_A_Karras"] = "DPM2 a Karras"; | ||
| SamplingMethod["DPMPlusPlus_2S_A_Karras"] = "DPM++ 2S a Karras"; | ||
| SamplingMethod["DPMPlusPlus_2M_Karras"] = "DPM++ 2M Karras"; | ||
| SamplingMethod["DPMPlusPlus_SDE_Karras"] = "DPM++ SDE Karras"; | ||
| SamplingMethod["DDIM"] = "DDIM"; | ||
| SamplingMethod["PLMS"] = "PLMS"; | ||
| })(SamplingMethod = exports.SamplingMethod || (exports.SamplingMethod = {})); |
| export var SamplingMethod; | ||
| (function (SamplingMethod) { | ||
| SamplingMethod["Euler_A"] = "Euler a"; | ||
| SamplingMethod["Euler"] = "Euler"; | ||
| SamplingMethod["LMS"] = "LMS"; | ||
| SamplingMethod["Heun"] = "Heun"; | ||
| SamplingMethod["DPM2"] = "DPM2"; | ||
| SamplingMethod["DPM2_A"] = "DPM2 a"; | ||
| SamplingMethod["DPMPlusPlus_S2_A"] = "DPM++ S2 a"; | ||
| SamplingMethod["DPMPlusPlus_2M"] = "DPM++ 2M"; | ||
| SamplingMethod["DPMPlusPlus_SDE"] = "DPM++ SDE"; | ||
| SamplingMethod["DPM_Fast"] = "DPM fast"; | ||
| SamplingMethod["DPM_Adaptive"] = "DPM adaptive"; | ||
| SamplingMethod["LMS_Karras"] = "LMS Karras"; | ||
| SamplingMethod["DPM2_Karras"] = "DPM2 Karras"; | ||
| SamplingMethod["DPM2_A_Karras"] = "DPM2 a Karras"; | ||
| SamplingMethod["DPMPlusPlus_2S_A_Karras"] = "DPM++ 2S a Karras"; | ||
| SamplingMethod["DPMPlusPlus_2M_Karras"] = "DPM++ 2M Karras"; | ||
| SamplingMethod["DPMPlusPlus_SDE_Karras"] = "DPM++ SDE Karras"; | ||
| SamplingMethod["DDIM"] = "DDIM"; | ||
| SamplingMethod["PLMS"] = "PLMS"; | ||
| })(SamplingMethod || (SamplingMethod = {})); |
| export declare enum SamplingMethod { | ||
| Euler_A = "Euler a", | ||
| Euler = "Euler", | ||
| LMS = "LMS", | ||
| Heun = "Heun", | ||
| DPM2 = "DPM2", | ||
| DPM2_A = "DPM2 a", | ||
| DPMPlusPlus_S2_A = "DPM++ S2 a", | ||
| DPMPlusPlus_2M = "DPM++ 2M", | ||
| DPMPlusPlus_SDE = "DPM++ SDE", | ||
| DPM_Fast = "DPM fast", | ||
| DPM_Adaptive = "DPM adaptive", | ||
| LMS_Karras = "LMS Karras", | ||
| DPM2_Karras = "DPM2 Karras", | ||
| DPM2_A_Karras = "DPM2 a Karras", | ||
| DPMPlusPlus_2S_A_Karras = "DPM++ 2S a Karras", | ||
| DPMPlusPlus_2M_Karras = "DPM++ 2M Karras", | ||
| DPMPlusPlus_SDE_Karras = "DPM++ SDE Karras", | ||
| DDIM = "DDIM", | ||
| PLMS = "PLMS" | ||
| } |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
26583
31.55%24
14.29%681
33.53%93
17.72%