ComfyUI Extension: comfyui-pkg39

Authored by shinich39

Created

Updated

3 stars

This package has created for generate image from generated image and embedded workflow.

Custom Nodes (0)

    README

    comfyui-pkg39

    Automation for generating image from image.

    Features

    • Create automation img2img flow with embedded workflow.
    • Quick inpainting.

    Nodes

    Add node > pkg39 or Search "39"

    • Random: Shuffle connected inputs each queue.
    • Textarea: Add keybindings to textarea.
    • Load image: Load image in sequentially.
    • Command: Control loaded image using javascript.

    Usage

    Added menu to Save Image node and Preview Image node

    • Send to pkg39

    Selected image copied to "/ComfyUI/pkg39_images" directory.

    • Send to Load image

    Load selected image at the "Load image" node.

    Load image node

    Enter dir_path and index to load image.
    Create a virtual workflow from embedded workflow in image metadata.
    Controls (while selecting the Load image node):

    • F5 or Ctrl + r: Reload images.
    • Left, Right: Change index.
    • -, =: Change canvas zoom.
    • Mouse left click: Add mask.
    • Mouse right click: Remove mask.
    • Ctrl + left click: Change brush color to selected pixel.
    • Shift + Mouse left click: Drawing.
    • Shift + Mouse right click: Remove drawing.
    • Mouse wheel scroll: Change brush size.
    • Shift + Mouse wheel scroll: Change brush size.
    • Mouse move while wheel click: Move canvas.
    • Mouse move while press space bar: Move canvas.

    Command node

    The node can load nodes and values from embedded workflow in loaded image by javascript.
    Copy and paste to textarea on commnad node and use it after customize.

    • Full code for high resolution fix
    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,
    });
    
    • Full code for inpaint
    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);
    
    • Load nodes with connection
    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");
    
    • Load values from sampler
    var srcSampler = SAMPLER;
    var dstSampler = find(2);
    
    // 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");
    
    • Stop after run 5 (In auto queue mode)
    if (countQueues >= 5) { stop(); }
    
    • Play sound at the end of generation
    sound();
    
    • Load generated image immediately
    var saveNode = find(11); // Save Image
    loadByNode(saveNode);
    
    • More methods are written in the commnad node.

    References