1.0.4 • Published 1 month ago
node-comfyui v1.0.4
node-comfyui
Prerequisites
This project requires NodeJS (version 18 or later) and NPM. Node and NPM are really easy to install. To make sure you have them available on your machine, try running the following command.
$ npm -v && node -v
10.2.3
v18.19.0
Table of contents
Getting Started
Installation
BEFORE YOU INSTALL: please read the prerequisites
To install and set up the library, run:
$ npm install -S node-comfyui
Or if you prefer using Yarn:
$ yarn add node-comfyui
Usage
API
Example:
below code is generated by cli
txt2img
import { NodeComfyui } from "node-comfyui";
async function run() {
const nodeComfyui = new NodeComfyui({
serverAddress: "http://127.0.0.1:8188",
});
const node = await nodeComfyui.prepare();
// i am title
const emptyLatentImage = await node.EmptyLatentImage({
width: 512,
height: 512,
batch_size: 1,
});
const checkpointLoaderSimple = await node.CheckpointLoaderSimple({
ckpt_name: "v1-5-pruned-emaonly.ckpt",
});
const clipTextEncode = await node.CLIPTextEncode({
text: "beautiful scenery nature glass bottle landscape, , purple galaxy bottle,",
clip: checkpointLoaderSimple.outputs.CLIP,
});
const clipTextEncode1 = await node.CLIPTextEncode({
text: "text, watermark",
clip: checkpointLoaderSimple.outputs.CLIP,
});
const kSampler = await node.KSampler({
seed: 156680208700286,
steps: 20,
cfg: 8,
sampler_name: "euler",
scheduler: "normal",
denoise: 1,
model: checkpointLoaderSimple.outputs.MODEL,
positive: clipTextEncode.outputs.CONDITIONING,
negative: clipTextEncode1.outputs.CONDITIONING,
latent_image: emptyLatentImage.outputs.LATENT,
});
const vaeDecode = await node.VAEDecode({
samples: kSampler.outputs.LATENT,
vae: checkpointLoaderSimple.outputs.VAE,
});
const saveImage = await node.SaveImage({
filename_prefix: "ComfyUI",
images: vaeDecode.outputs.IMAGE,
});
}
run().catch((reason) => console.warn(reason));