ComfyUI  >  Nodes  >  ComfyUI_Mira >  Function Swap

ComfyUI Node: Function Swap

Class Name

FunctionSwap

Category
Mira/Logic
Author
mirabarukaso (Account age: 1261 days)
Extension
ComfyUI_Mira
Latest Updated
7/25/2024
Github Stars
0.0K

How to Install ComfyUI_Mira

Install this extension via the ComfyUI Manager by searching for  ComfyUI_Mira
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI_Mira in the search bar
After installation, click the  Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • High-speed GPU machines
  • 200+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 50+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Function Swap Description

Dynamically swap function outputs based on trigger condition for flexible AI art workflows.

Function Swap:

The FunctionSwap node is designed to dynamically swap the outputs of two functions based on a specified trigger condition. This node is particularly useful when you need to alternate between two different functions' outputs depending on a boolean condition. By leveraging this node, you can create more flexible and adaptive workflows in your AI art projects, allowing for conditional logic to determine which function's output should be used at any given time. This can be especially beneficial in scenarios where the output of one function needs to be prioritized over another based on specific criteria or states within your project.

Function Swap Input Parameters:

trigger

The trigger parameter is a boolean input that determines whether the outputs of the two functions should be swapped. When set to True, the outputs of func1 and func2 are swapped. When set to False, the outputs remain in their original order. This parameter allows you to control the swapping behavior dynamically. The default value is False.

func1

The func1 parameter represents the first function whose output may be swapped. This can be any function, such as Mask_1, and it serves as one of the two possible outputs of the node. The specific function you choose for func1 will depend on your project's requirements and the type of output you need.

func2

The func2 parameter represents the second function whose output may be swapped. Similar to func1, this can be any function, such as Mask_2, and it serves as the alternative output of the node. The specific function you choose for func2 will depend on your project's requirements and the type of output you need.

Function Swap Output Parameters:

A

The A output parameter represents the first output of the node after evaluating the trigger condition. If trigger is True, A will be the output of func2. If trigger is False, A will be the output of func1. This output allows you to dynamically switch between the two functions' outputs based on the trigger condition.

B

The B output parameter represents the second output of the node after evaluating the trigger condition. If trigger is True, B will be the output of func1. If trigger is False, B will be the output of func2. This output complements A and provides the alternative function's output based on the trigger condition.

Function Swap Usage Tips:

  • Use the trigger parameter to dynamically control which function's output should be prioritized in your workflow. This can be particularly useful in conditional logic scenarios.
  • Ensure that func1 and func2 are properly defined and return the expected outputs to avoid unexpected behavior when the outputs are swapped.
  • Experiment with different functions for func1 and func2 to see how swapping their outputs can impact your project's results.

Function Swap Common Errors and Solutions:

Bad linked input, must be a length-2 list of [node_id, slot_index]

  • Explanation: This error occurs when the linked input is not a length-2 list containing the node ID and slot index.
  • Solution: Ensure that the linked input is correctly formatted as a length-2 list with the appropriate node ID and slot index.

Return type mismatch between linked nodes

  • Explanation: This error occurs when there is a mismatch between the return types of the linked nodes.
  • Solution: Verify that the return types of the linked nodes match the expected types for the FunctionSwap node. Adjust the linked nodes' return types if necessary to resolve the mismatch.

Function Swap Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI_Mira
RunComfy

© Copyright 2024 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals.