Package Exports
- comfyui
- comfyui/dist/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (comfyui) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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.0Table of contents
Getting Started
Installation
BEFORE YOU INSTALL: please read the prerequisites
To install and set up the library, run:
$ npm install -S node-comfyuiOr if you prefer using Yarn:
$ yarn add node-comfyuiUsage
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));