Load image and partially workflow with javascript.
Load image and partially workflow with javascript.
Add node > image > Load image with CMD
Copy selected image to "/ComfyUI/input" directory.
Copy selected image to "/ComfyUI/output" directory.
Load selected image at the sepecific "Load image with CMD" node.
Enter dir_path and index to load image.
Create a virtual workflow from embedded workflow in image.
Canvas controls (while focus on the node):
Connect PrimitiveNode to "command" input for loading workflow.
Copy and paste to textarea on PrimitiveNode and start generating it after customize.
var n1 = find(1); // Load image
var n11 = find(11); // VAE Encode
var n12 = find(12); // Load Checkpoint
var n13 = find(13); // KSampler
var n14 = find(14); // VAE Decode
var n15 = find(15); // Save Image
var n21 = find(21); // Upscale Latent
getNode(SAMPLER, n13, "positive", [n12]);
getNode(SAMPLER, n13, "negative", n12);
setValues(n13, { seed: SEED });
setValues(n21, {
width: WIDTH * 1.5,
height: HEIGHT * 1.5,
});
var n2 = find(2); // Load image
var n3 = find(3); // VAE Encode
var n4 = find(4); // Load Checkpoint
var n5 = find(5); // Set Latent Noise Mask
var n6 = find(6); // KSampler
var n8 = find(8); // VAE Decode
var n9 = find(9); // InvertMask
var n10 = find(10); // ImageCompositeMasked
var n11 = find(11); // Save Image
getNode(SAMPLER, n6, "positive", n4);
getNode(SAMPLER, n6, "negative", 4);
var firstSampler = SAMPLERS[0];
var lastSampler = SAMPLER;
var srcSampler = lastSampler; // Last sampler in virtual workflow
var dstSampler = find(2); // KSampler node in actual workflow
var replaceNodes = [1]; // ID of Load Checkpoint node in actual workflow
getNode(srcSampler, dstSampler, "positive", replaceNodes);
getNode(srcSampler, "KSampler", "negative", replaceNodes);
getNode(srcSampler, 2, "latent_image");
getNode("KSampler", dstSampler, "cfg");
var srcSampler = SAMPLER;
var dstSampler = find(2); // KSampler
// case 1
var widgetValues = getValues(srcSampler);
setValues(dstSampler, widgetValues); // All values
setValues(dstSampler, { seed: SEED }); // Set random seed
// case 2
getNode(srcSampler, dstSampler, "seed"); // Get Seed from image
getNode(srcSampler, dstSampler, "denoise");
var a = find(1); // Apply ControlNet (Advanced)
var b = find(2); // KSampler
// case 1
connect(a, b, "positive");
// case 2
connect(a, b, "positive", "positive");
if (countQueues >= 5) { stop(); }
if (countLoops >= 5) { stop(); }