Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
stable-diffusion-api-ts
Advanced tools
A Typescript API client for AUTOMATIC111/stable-diffusion-webui API that is unremarkably inspired by the Python library webuiapi.
stable-diffusion-webui
with the --api
command line argument.--nowebui
to disable the web interface.npm install stable-diffusion-api
yarn add stable-diffusion-api
import StableDiffusionApi from "stable-diffusion-api";
const api = new StableDiffusionApi();
const api = new StableDiffusionApi({
host: "localhost",
port: 7860,
protocol: "http",
defaultSampler: "Euler a",
defaultStepCount: 20,
});
const api = new StableDiffusionApi({
baseUrl: "http://localhost:7860",
});
Use the --api-auth
command line argument with "username:password" on the server to enable API authentication.
api.setAuth("username", "password");
const result = await api.txt2img({
prompt: "An AI-powered robot that accidentally starts doing everyone's job, causing chaos in the workplace."
...
})
result.image.toFile('result.png')
Result |
---|
const image = sharp('image.png')
const result = await api.img2img({
init_images: [image],
prompt: "Man, scared of AGI, running away on a burning lava floor."
...
})
result.image.toFile('result.png')
Input | Result |
---|---|
stable-diffusion-webui
instance.To get a list of all installed ControlNet models and modules, you can use the api.ControlNet.getModels()
and api.ControlNet.getModules()
methods.
const models = await api.ControlNet.getModels();
const modules = await api.ControlNet.getModules();
To make use of the ControlNet API, you must first instantiate a ControlNetUnit
object in wich you can specify the ControlNet model and preprocessor to use. Next, to use the unit, you must pass it as an array in the controlnet_units
argument in the txt2img
or img2img
methods.
It's also possible to use multiple ControlNet units in the same request. To get some good results, it's recommended to use lower weights for each unit by setting the weight
argument to a lower value.
To get a list of all installed ControlNet models, you can use the api.ControlNet.getModels()
method.
const image = sharp("image.png");
const controlNetUnit = new ControlNetUnit({
model: "control_sd15_depth [fef5e48e]",
module: "depth",
input_images: [image],
processor_res: 512,
threshold_a: 64,
threshold_b: 64,
});
const result = await api.txt2img({
prompt:
"Young lad laughing at all artists putting hard work and effort into their work.",
controlnet_units: [controlNetUnit],
});
result.image.toFile("result.png");
// To access the preprocessing result, you can use the following:
const depth = result.images[1];
depth.toFile("depth.png");
Input | Result | Depth |
---|---|---|
Uses the selected ControlNet proprocessor module to predict a detection on the input image. To make use of the detection result, you must use the model of choise in the txt2img
or img2img
without a preprocessor enabled (use "none"
as the preprocessor module).
This comes in handy when you just want a detection result without generating a whole new image.
const image = sharp("image.png");
const result = await api.ControlNet.detect({
controlnet_module: "depth",
controlnet_input_images: [image],
controlnet_processor_res: 512,
controlnet_threshold_a: 64,
controlnet_threshold_b: 64,
});
result.image.toFile("result.png");
Input | Result |
---|---|
FAQs
API translation for Automatic1111 Stable Diffusion WebUI
The npm package stable-diffusion-api-ts receives a total of 2 weekly downloads. As such, stable-diffusion-api-ts popularity was classified as not popular.
We found that stable-diffusion-api-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.