Files
CavinHuang-comfyui-nodes-docs/docs/CR Batch Process Switch.md
2024-05-26 20:35:16 +08:00

2.6 KiB

Documentation

CR_BatchProcessSwitch 节点旨在提供一种机制,用于在不同类型的图像输入之间进行切换。它基于输入选择智能地路由处理流程,允许处理单个图像和图像批次。在需要根据输入类型动态适应处理逻辑的场景中,该节点至关重要,确保了图像处理工作流程的灵活性和效率。

Input types

Required

  • Input
    • 'Input' 参数至关重要,因为它决定了要执行的图像处理类型。它决定了节点将处理单个图像还是图像批次,从而影响工作流中的后续步骤和输出。
    • Comfy dtype: COMBO[image, image batch]
    • Python dtype: str

Optional

  • image
    • 'image' 参数用于处理单个图像时使用。它很重要,因为它代表了单个图像处理任务的输入,使节点能够处理特定于图像的操作。
    • Comfy dtype: IMAGE
    • Python dtype: Union[str, torch.Tensor]
  • image_batch
    • 'image_batch' 参数对于处理一组图像至关重要。它允许节点有效地管理和处理图像批次,适用于需要批量操作的场景。
    • Comfy dtype: IMAGE
    • Python dtype: Union[str, List[torch.Tensor]]

Output types

  • IMAGE
    • 'IMAGE' 输出参数表示根据输入选择处理后的图像或图像批次。它是节点操作的关键结果,包含了图像处理任务的结果。
    • Comfy dtype: IMAGE
    • Python dtype: Union[str, torch.Tensor, List[torch.Tensor]]
  • show_help
    • 'show_help' 输出提供了一个文档链接,用于进一步的帮助。它很重要,因为它为用户提供了一个资源,以更详细地了解节点的功能和用法。
    • Comfy dtype: STRING
    • Python dtype: str

Usage tips

  • Infra type: CPU

Source code

class CR_BatchProcessSwitch:

    def __init__(self):
        pass

    @classmethod
    def INPUT_TYPES(cls):
        return {'required': {'Input': (['image', 'image batch'],)}, 'optional': {'image': ('IMAGE',), 'image_batch': ('IMAGE',)}}
    RETURN_TYPES = ('IMAGE', 'STRING')
    RETURN_NAMES = ('IMAGE', 'show_help')
    FUNCTION = 'switch'
    CATEGORY = icons.get('Comfyroll/Utils/Process')

    def switch(self, Input, image=None, image_batch=None):
        show_help = 'https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Process-Nodes#cr-batch-process-switch'
        if Input == 'image':
            return (image, show_help)
        else:
            return (image_batch, show_help)