v0.20.16
This commit is contained in:
@@ -1,5 +1,23 @@
|
||||
# Changelog
|
||||
|
||||
## [0.9.0] - 2025-02-27
|
||||
### Added
|
||||
- 增加AIO翻译节点
|
||||
|
||||
- 增加RemBG背景移除节点组
|
||||
|
||||
- 增加Mask遮罩处理节点组
|
||||
|
||||
- 增加Mask预览节点
|
||||
|
||||
- Slider滑块节点组
|
||||
|
||||
- 增加Text节点
|
||||
|
||||
- 增加To Int节点
|
||||
|
||||
- 增加部分节点的数据显示功能
|
||||
|
||||
## [0.9.0] - 2025-02-24
|
||||
### Added
|
||||
- 增加腾讯AI翻译节点
|
||||
|
||||
@@ -12,169 +12,230 @@ This is a custom node utility package developed for ComfyUI. Initially created f
|
||||
|
||||
## 当前功能 Current Features:
|
||||
|
||||
### 大壮提示词 Strong Prompt Node
|
||||
### 背景移除加载器 & 处理节点 RemBGLoader & RemoveBG
|
||||
|
||||
- 控制 Flux + K 采样器组合时负向提示词零化功能(negative out)
|
||||
- 提供选择预设样式,商用出图神器
|
||||
- 包含 IDs 组预设
|
||||
- 各个组的开关,方便长期挂载
|
||||
- 预设编辑和导入简便,支持各种专业提示词增强
|
||||
**编辑路径**: `KayTool/json/strong_prompt.json`
|
||||
- **RemBGLoader**: 提供多种预训练模型选择(如 `u2net`、`isnet-general-use`、`sam` 等),适用于不同背景移除场景。支持多种硬件加速提供者(如 CPU、CUDA、TensorRT 等),可根据设备自动优化性能。加载的模型会作为 `REMBG_LOADER` 类型输出,供后续节点使用。
|
||||
- **RemoveBG**: 使用加载的背景移除模型处理图像,生成透明背景或指定颜色背景。支持遮罩模糊和扩展功能,增强背景移除效果。提供多种背景预览选项(黑、白、红、绿、蓝),便于快速验证结果。输出处理后的图像和遮罩,满足后续合成或编辑需求。
|
||||
- 整体流程:通过 **RemBGLoader** 加载模型并配置硬件加速,然后使用 **RemoveBG** 对图像进行背景移除处理,支持灵活调整遮罩效果和背景样式。
|
||||
- **RemBGLoader**: Offers multiple pre-trained model options (e.g., `u2net`, `isnet-general-use`, `sam`) for different background removal scenarios. Supports various hardware acceleration providers (e.g., CPU, CUDA, TensorRT) with automatic performance optimization based on the device. The loaded model is output as a `REMBG_LOADER` type for use in subsequent nodes.
|
||||
- **RemoveBG**: Processes images using the loaded background removal model to generate transparent or custom-colored backgrounds. Supports mask blurring and expansion for enhanced background removal effects. Offers multiple background preview options (black, white, red, green, blue) for quick result validation. Outputs the processed image and mask for subsequent compositing or editing needs.
|
||||
- Combined Workflow: Load the model and configure hardware acceleration using **RemBGLoader**, then process images with **RemoveBG** for background removal, with flexible adjustments for mask effects and background styles.
|
||||
---
|
||||
|
||||
Control the nullification of negative prompts with the Flux + K Sampler combination.
|
||||
Offer preset styles for professional outputs.
|
||||
Include predefined ID groups and group switches for persistent usage.
|
||||
Easy-to-edit and import presets for professional prompt enhancement.
|
||||
**Edit Path**: `KayTool/json/strong_prompt.json`
|
||||
### 无线数据传输节点 Set & Get
|
||||
|
||||
---
|
||||
- 提供 `Set` 和 `Get` 两种节点,通过唯一的 ID 实现**无线数据传输**,帮助建立干净整洁的工作流
|
||||
- **Set 节点**:允许用户定义唯一的 ID,并动态设置输入数据类型,支持实时验证和更新,确保数据的唯一性和一致性
|
||||
- **Get 节点**:通过匹配的 ID 无线获取对应的 Set 节点数据,自动同步数据类型,减少节点间的复杂连接
|
||||
- 支持多种数据类型(如字符串、数字、图像等),并动态调整连接类型,提升工作流的灵活性
|
||||
- 提供错误提示和调试功能,确保节点间数据传输的正确性,避免因连接错误导致的工作流中断
|
||||
- **核心优势**:通过无线数据传输机制,大幅简化节点布局,帮助用户构建更加**干净、整洁、高效**的工作流
|
||||
- Provides `Set` and `Get` nodes to enable **wireless data transfer** via unique IDs, helping to create clean and organized workflows
|
||||
- **Set Node**: Allows users to define a unique ID and dynamically set input data types, with real-time validation and updates to ensure data uniqueness and consistency
|
||||
- **Get Node**: Wirelessly retrieves data from the corresponding Set node by matching ID, automatically synchronizing data types and reducing complex connections between nodes
|
||||
- Supports various data types (e.g., strings, numbers, images) with dynamic adjustment of connection types, enhancing workflow flexibility
|
||||
- Includes error notifications and debugging features to ensure correct data transmission between nodes, avoiding workflow interruptions caused by connection errors
|
||||
- **Key Advantage**: Simplifies node layouts through wireless data transfer, enabling users to build **cleaner, more organized, and efficient workflows**
|
||||
---
|
||||
|
||||
### 无线传输节点 Set&Get Node
|
||||
- 无线发送和接收节点,用于保持工作流的整洁
|
||||
- 支持任意数据类型的传递
|
||||
- Wireless sending and receiving nodes to keep workflows clean
|
||||
- Supports arbitrary data type transfer
|
||||
### 数学表达式计算节点 AbcMath
|
||||
|
||||
- 支持动态解析数学表达式
|
||||
- 提供多种运算符和函数支持(加、减、乘、除、幂、取模等)
|
||||
- 支持变量 `a`、`b`、`c` 的灵活输入(数字或数组形状)
|
||||
- 内置常用数学函数(`min`、`max`、`round`、`sum`、`len` 等)
|
||||
- 自动处理 NaN 值,确保结果稳定性
|
||||
- 输出整数和浮点数两种格式
|
||||
- 适用于复杂计算场景
|
||||
- Supports dynamic parsing of mathematical expressions
|
||||
- Provides a wide range of operators and functions (addition, subtraction, multiplication, division, power, modulo, etc.)
|
||||
- Flexible input for variables `a`, `b`, and `c` (numbers or array shapes)
|
||||
- Built-in common math functions (`min`, `max`, `round`, `sum`, `len`, etc.)
|
||||
- Automatically handles NaN values to ensure result stability
|
||||
- Outputs results in both integer and float formats
|
||||
- Suitable for complex calculation scenarios
|
||||
|
||||
---
|
||||
|
||||
### 腾讯AI翻译 Tencent Translator Node
|
||||
### 自动翻译节点 AIOTranslater
|
||||
|
||||
- 无需的 API 密钥
|
||||
- 支持多种语言翻译
|
||||
- 自动检测输入语言
|
||||
- 快速启用或禁用翻译
|
||||
- 支持多种翻译场景
|
||||
- 国内可用的高质量 AI 翻译
|
||||
- No need for API keys
|
||||
- Supports multiple languages for translation
|
||||
- Automatically detects input language
|
||||
- Quick enable/disable of translation
|
||||
- Supports various translation scenarios
|
||||
- High-quality AI translation available in China.
|
||||
- 支持单文本输入的自动翻译
|
||||
- 内置高效 AI 翻译引擎,无需手动获取 API 密钥
|
||||
- 提供高质量翻译结果,适用于多种语言场景
|
||||
- 支持多种目标语言选择(英语、中文、德语、西班牙语等)
|
||||
- 自动检测源语言,简化用户操作
|
||||
- 高效稳定,适合快速集成到工作流中
|
||||
- Supports automatic translation of single text input
|
||||
- Built-in high-efficiency AI translation engine, no need to manually obtain API keys
|
||||
- Provides high-quality translations for various language scenarios
|
||||
- Offers multiple target language options (English, Chinese, German, Spanish, etc.)
|
||||
- Automatically detects source language for simplified user experience
|
||||
- Efficient and stable, ideal for quick integration into workflows
|
||||
---
|
||||
|
||||
### 百度AI翻译 Baidu Translator Node
|
||||
|
||||
- 支持输入两个文本(Text_A 和 Text_B)进行翻译
|
||||
- 支持自动检测、简体/繁体中文和英文
|
||||
- 快速启用或禁用翻译
|
||||
- 配置百度 API [链接](https://fanyi-api.baidu.com/)
|
||||
- 自动存储 API 信息避免重复输入
|
||||
- 国内可用的高质量 AI 翻译
|
||||
- Two texts (Text_A and Text_B) are supported for translation
|
||||
- Support automatic detection, simplified/traditional Chinese and English
|
||||
- Quickly enable or disable translation
|
||||
- Configure Baidu API [link](https://fanyi-api.baidu.com/)
|
||||
- Automatically store API information to avoid duplicate input
|
||||
- High quality AI translation available in China
|
||||
### 大壮提示词生成节点 StrongPrompt
|
||||
|
||||
- 基于 CLIP 模型生成高质量的正向和负向提示词嵌入
|
||||
- 支持灵活的预设样式选择,快速构建复杂提示词
|
||||
- 提供多种控制开关(启用/禁用负向输出、预设样式、ID 输入等)
|
||||
- 自动加载本地 JSON 文件中的预设样式数据,无需手动配置
|
||||
- 支持通过 ID 快速选择多个样式组合
|
||||
- 可零化负向提示词嵌入,满足特定场景需求
|
||||
- 适用于扩散模型的条件化输入,提升生成效果
|
||||
- Generates high-quality positive and negative prompt embeddings using the CLIP model
|
||||
- Supports flexible preset style selection for quickly building complex prompts
|
||||
- Provides multiple control switches (enable/disable negative output, presets, IDs input, etc.)
|
||||
- Automatically loads preset style data from local JSON files without manual configuration
|
||||
- Supports quick selection of multiple styles via IDs
|
||||
- Can zero out negative prompt embeddings to meet specific scenario requirements
|
||||
- Suitable for diffusion model conditioning inputs to enhance generation results
|
||||
---
|
||||
|
||||
### 数学运算节点 Abc Math Node
|
||||
|
||||
- 支持多种数据类型作为输入(如整数、浮点数、字符串表示的数值等)
|
||||
- 使用变量 `a`, `b`, `c` 进行数学表达式的计算
|
||||
- 返回整形和浮点型的结果,适用于需要数值结果的场景
|
||||
- 提供算术、比较运算功能,支持自定义函数调用
|
||||
|
||||
- Supports multiple data types as input (e.g. integers, floating-point numbers, strings representing numeric values, etc.)
|
||||
- Use variables `a`, `b`, `c` to evaluate mathematical expressions
|
||||
- Returns integer and floating-point results for scenarios where numerical results are required
|
||||
- Arithmetic and comparison functions, custom function calls
|
||||
|
||||
#### 支持的表达式和基本用法 Supported Expressions and Basic Usage:
|
||||
|
||||
##### 算术运算 Arithmetic Operations:
|
||||
- 加法 Addition: `a + b`
|
||||
- 减法 Subtraction: `a - b`
|
||||
- 乘法 Multiplication: `a * b`
|
||||
- 除法 Division: `a / b`
|
||||
- 幂运算 Power: `a ** b`
|
||||
- 取模 Modulo: `a % b`
|
||||
|
||||
##### 比较运算 Comparison Operations:
|
||||
- 等于 Equal to: `a == b`
|
||||
- 不等于 Not equal to: `a != b`
|
||||
- 小于 Less than: `a < b`
|
||||
- 小于等于 Less than or equal to: `a <= b`
|
||||
- 大于 Greater than: `a > b`
|
||||
- 大于等于 Greater than or equal to: `a >= b`
|
||||
|
||||
##### 逻辑运算 Logical Operations:
|
||||
- 逻辑与 And: `a and b`
|
||||
- 逻辑或 Or: `a or b`
|
||||
- 逻辑非 Not: `not a`
|
||||
|
||||
##### 内置函数 Built-in Functions:
|
||||
- 最小值 Min: `min(a, b)`
|
||||
- 最大值 Max: `max(a, b)`
|
||||
- 四舍五入 Round: `round(a)`
|
||||
|
||||
##### 示例用法 Example Usage:
|
||||
- 计算两数之和 Calculate sum: `value = "a + b"`
|
||||
- 找三个数中最大值 Find max: `value = "max(a, b, c)"`
|
||||
- 判断数是否在两个数之间 Check range: `value = "a > b and a < c"`
|
||||
|
||||
允许通过字符串形式的数学表达式进行复杂运算。用户可以利用提供的变量 (`a`, `b`, `c`) 和一系列操作符以及内置函数构建表达式。
|
||||
|
||||
Allow complex calculations by entering mathematical expressions in string form. Use provided variables (`a`, `b`, `c`) along with operators and built-in functions.
|
||||
### 图像色彩调整节点 ColorAdjustment
|
||||
|
||||
- 提供全面的图像色彩调整功能,包括曝光、对比度、色温、色调和饱和度
|
||||
- 支持多种预设滤镜(基于 `pilgram` 库),快速应用流行风格
|
||||
- 可通过强度滑块精确控制滤镜效果
|
||||
- 支持批量处理图像,满足高效工作流需求
|
||||
- 提供灵活的开关选项,一键启用所有滤镜组合
|
||||
- 适用于图像后期处理与风格化生成
|
||||
- Offers comprehensive image color adjustments including exposure, contrast, temperature, tint, and saturation
|
||||
- Supports multiple preset filters (based on the `pilgram` library) for quick application of popular styles
|
||||
- Allows precise control of filter effects via a strength slider
|
||||
- Supports batch processing of images for efficient workflows
|
||||
- Provides flexible switch options to enable all filter combinations with one click
|
||||
- Suitable for image post-processing and stylized generation
|
||||
---
|
||||
|
||||
### 图像尺寸提取节点 Image Size Extractor Node
|
||||
|
||||
- 从输入图像数据中提取宽度和高度信息
|
||||
- Extract width and height information from the input image data
|
||||
### 自定义图像保存节点 CustomSaveImage
|
||||
|
||||
- 提供灵活的图像保存功能,支持多种格式(PNG、JPG)
|
||||
- 可选择色彩配置文件(sRGB IEC61966-2.1 或 Adobe RGB 1998),确保色彩准确性
|
||||
- 支持保存元数据(作者信息、版权信息、生成提示词等)
|
||||
- 提供高质量 JPG 保存选项,可自定义压缩质量
|
||||
- 自动生成唯一文件名,避免覆盖已有文件
|
||||
- 适用于需要精确控制输出图像的工作流
|
||||
- Offers flexible image saving functionality with support for multiple formats (PNG, JPG)
|
||||
- Allows selection of color profiles (sRGB IEC61966-2.1 or Adobe RGB 1998) to ensure color accuracy
|
||||
- Supports saving metadata (author info, copyright info, generation prompts, etc.)
|
||||
- Provides high-quality JPG saving options with customizable compression quality
|
||||
- Automatically generates unique filenames to prevent overwriting existing files
|
||||
- Suitable for workflows requiring precise control over output images
|
||||
---
|
||||
|
||||
### 啥都能显示 Display Any Node
|
||||
|
||||
- 接受任何数据类型输入(如数字、文本、列表等)
|
||||
- 显示转换后的文本,方便查看
|
||||
- 返回字符串类型的输出,可用于后续处理
|
||||
- 适合调试或检查工作流输出内容
|
||||
|
||||
- Accepts input of any data type (e.g. numbers, text, lists, etc.)
|
||||
- Display converted text for easy viewing
|
||||
- Returns output of string type that can be used for subsequent processing
|
||||
- Suitable for debugging or checking workflow output
|
||||
### 百度翻译节点 BaiduTranslater
|
||||
|
||||
- 使用百度翻译 API 提供高质量的多语言翻译服务
|
||||
- 支持自动检测源语言及多种目标语言选择(中文简体、中文繁体、英语等)
|
||||
- 需要用户提供百度 API 的 App ID 和 App Key(可在 [百度翻译开放平台](https://fanyi-api.baidu.com/) 注册获取)
|
||||
- 自动保存用户输入的 API 配置,简化后续使用
|
||||
- 提供灵活的启用/禁用翻译功能开关
|
||||
- 适用于需要精准翻译的多语言工作流
|
||||
- Utilizes Baidu Translate API to provide high-quality multi-language translation services
|
||||
- Supports automatic detection of source language and multiple target language options (Simplified Chinese, Traditional Chinese, English, etc.)
|
||||
- Requires users to provide Baidu API App ID and App Key (can be obtained by registering at [Baidu Translate Open Platform](https://fanyi-api.baidu.com/))
|
||||
- Automatically saves user-entered API configurations for simplified subsequent use
|
||||
- Provides a flexible switch to enable or disable the translation function
|
||||
- Suitable for multi-language workflows requiring precise translations
|
||||
---
|
||||
|
||||
### 色彩调节 Color Adjustment Node
|
||||
|
||||
- 调节图片的曝光、对比度、色温、色调和饱和度
|
||||
- 曝光和对比度:范围 -100 到 +100
|
||||
- 色温:范围 -100 到 +100,负值增加蓝色,正值增加黄色
|
||||
- 色调:范围 -100 到 +100,负值增加绿色,正值增加洋红
|
||||
- 饱和度:范围 -100 到 +100
|
||||
- Adjust exposure, contrast, color temperature, hue, and saturation of a picture
|
||||
- Exposure and contrast: range-100 to +100
|
||||
- Color temperature: range-100 to +100, negative values increase blue, positive values increase yellow
|
||||
- Hue: Range-100 to +100, negative values increase green, positive values increase magenta
|
||||
- Saturation: Range-100 to +100
|
||||
### 通用显示节点 DisplayAny
|
||||
|
||||
- 可接收任意类型的输入并将其转换为字符串显示
|
||||
- 提供灵活的调试和查看功能,适用于任何数据类型
|
||||
- 输出结果可直接用于后续节点或日志记录
|
||||
- 简化复杂工作流中的数据可视化需求
|
||||
- Supports receiving any type of input and converting it to a string for display
|
||||
- Provides flexible debugging and viewing capabilities, suitable for any data type
|
||||
- The output can be directly used in subsequent nodes or for logging
|
||||
- Simplifies data visualization needs in complex workflows
|
||||
---
|
||||
|
||||
### 自定义图片存储 Custom SaveImage Node
|
||||
### 图像尺寸提取节点 ImageSizeExtractor
|
||||
|
||||
- 选择保存图片的格式(PNG 或 JPG)
|
||||
- 自定义 JPG 图片质量(0-100)
|
||||
- 支持两种颜色配置文件(sRGB IEC61966-2.1 和 Adobe RGB (1998))
|
||||
- 选择 Adobe RGB 时,自动将图像转换为 Adobe RGB 色彩空间
|
||||
- 选择是否保存元数据(包括工作流、作者、版权信息和自定义提示)
|
||||
- 自动生成唯一文件名确保每个保存的图像有独立名称
|
||||
- 创建输出文件夹 `output/Custom_Save_Image` 用于保存图片
|
||||
- 保存 “JPG” 格式时,"metadata" 必须设置为 "False"
|
||||
- 如果选择保存 "metadata",格式自动切换为 "PNG"
|
||||
- 自动提取输入图像的宽度和高度
|
||||
- 支持批量图像(4D 张量)和单张图像(3D 张量)输入
|
||||
- 输出图像的宽度和高度,便于后续处理或计算
|
||||
- 适用于需要动态获取图像尺寸的工作流
|
||||
- Automatically extracts the width and height of the input image
|
||||
- Supports batched images (4D tensor) and single images (3D tensor)
|
||||
- Outputs the width and height of the image for subsequent processing or calculations
|
||||
- Suitable for workflows requiring dynamic retrieval of image dimensions
|
||||
---
|
||||
|
||||
Select image save format and customize JPG quality.
|
||||
Support two color profiles with automatic conversion for Adobe RGB.
|
||||
Choose whether to save metadata including workflow, author, copyright, and custom prompts.
|
||||
Automatically generate unique filenames and create an output folder.
|
||||
To save as "JPG", set "metadata" to "False".
|
||||
If saving "metadata", format switches to "PNG".
|
||||
### 高级遮罩处理节点 MaskBlurPlus
|
||||
|
||||
- 提供遮罩的模糊和扩展功能,增强遮罩的灵活性
|
||||
- 支持动态调整模糊半径和扩展强度
|
||||
- 模糊功能使用高斯模糊算法,确保平滑过渡
|
||||
- 扩展功能支持正向扩展(扩大遮罩)和负向扩展(缩小遮罩)
|
||||
- 适用于图像分割、遮罩优化等高级工作流
|
||||
- Provides mask blurring and expansion capabilities to enhance mask flexibility
|
||||
- Supports dynamic adjustment of blur radius and expansion intensity
|
||||
- Blurring uses Gaussian blur algorithm for smooth transitions
|
||||
- Expansion supports both positive (enlarging the mask) and negative (shrinking the mask) adjustments
|
||||
- Suitable for advanced workflows such as image segmentation and mask optimization
|
||||
---
|
||||
|
||||
### 遮罩预览增强节点 PreviewMaskPlus
|
||||
|
||||
- 提供多种遮罩预览模式,包括纯色背景(黑、白、红、绿、蓝)和原始遮罩视图
|
||||
- 支持动态调整预览样式,便于快速查看遮罩效果
|
||||
- 自动将遮罩与图像叠加,生成直观的可视化结果
|
||||
- 适用于遮罩调试、图像合成及分割任务
|
||||
- 输出预览图像到临时目录,方便快速访问
|
||||
- Offers multiple mask preview modes, including solid color backgrounds (black, white, red, green, blue) and raw mask view
|
||||
- Supports dynamic adjustment of preview styles for quick visualization of mask effects
|
||||
- Automatically overlays the mask with the image to generate intuitive visual results
|
||||
- Suitable for mask debugging, image compositing, and segmentation tasks
|
||||
- Outputs preview images to a temporary directory for easy access
|
||||
---
|
||||
|
||||
### 遮罩预览节点 PreviewMask
|
||||
|
||||
- 提供遮罩的快速可视化功能,将单通道遮罩转换为 RGB 图像
|
||||
- 支持动态调整遮罩范围,确保兼容不同输入格式
|
||||
- 输出预览图像到临时目录,便于快速查看和调试
|
||||
- 适用于遮罩生成、图像分割等任务的初步验证
|
||||
- Offers quick visualization of masks by converting single-channel masks into RGB images
|
||||
- Supports dynamic adjustment of mask ranges to ensure compatibility with different input formats
|
||||
- Outputs preview images to a temporary directory for easy viewing and debugging
|
||||
- Suitable for preliminary validation in mask generation and image segmentation tasks
|
||||
---
|
||||
|
||||
### Slider 精度节点系列(Slider10、Slider100、Slider1000)
|
||||
|
||||
- 提供三种不同精度的滑块输入节点,分别支持 0-10、0-100 和 0-1000 的整数范围
|
||||
- 每种精度滑块均支持动态调整,默认值居中,适用于不同精度需求的场景
|
||||
- 输出整数值,便于直接用于后续计算或参数控制
|
||||
- 整体设计灵活,满足从粗略到精细的多种工作流需求
|
||||
- Provides three slider input nodes with different precision levels, supporting integer ranges of 0-10, 0-100, and 0-1000 respectively.
|
||||
- Each slider supports dynamic adjustment with a default centered value, suitable for various precision requirements.
|
||||
- Outputs integer values for direct use in subsequent calculations or parameter control.
|
||||
- The overall design is flexible, meeting workflow needs ranging from coarse to fine adjustments.
|
||||
---
|
||||
|
||||
### 文本处理节点 Text
|
||||
|
||||
- 提供一个多行文本输入框,支持动态输入和编辑
|
||||
- 输出原始文本内容,便于直接用于后续节点或日志记录
|
||||
- 适用于需要灵活处理文本的工作流场景
|
||||
- Provides a multi-line text input box with support for dynamic input and editing
|
||||
- Outputs the original text content for direct use in subsequent nodes or logging
|
||||
- Suitable for workflow scenarios requiring flexible text handling
|
||||
---
|
||||
|
||||
### 转换为整数节点 To Int
|
||||
|
||||
- 将任意类型的输入转换为整数,支持动态数据处理
|
||||
- 自动对浮点数进行四舍五入,并将无效输入默认为 0
|
||||
- 输出结果以文本形式显示,便于调试和验证
|
||||
- 适用于需要将数据标准化为整数的工作流场景
|
||||
- Converts any type of input to an integer, supporting dynamic data processing
|
||||
- Automatically rounds floating-point numbers and defaults invalid inputs to 0
|
||||
- Outputs the result as text for easy debugging and verification
|
||||
- Suitable for workflow scenarios requiring data normalization to integers
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
|
||||
+20
-5
@@ -7,12 +7,17 @@ from .nodes.display_any import DisplayAny
|
||||
from .nodes.abc_math import AbcMath
|
||||
from .nodes.image_size_extractor import ImageSizeExtractor
|
||||
from .nodes.tencent_translater import TencentTranslater
|
||||
from .nodes.text import Text
|
||||
from .nodes.aio_translater import AIOTranslater
|
||||
from .nodes.text import Text
|
||||
from .nodes.aio_translater import AIOTranslater
|
||||
from .nodes.slider_1000 import Slider1000
|
||||
from .nodes.slider_100 import Slider100
|
||||
from .nodes.slider_10 import Slider10
|
||||
from .nodes.to_int import ToInt
|
||||
from .nodes.to_int import ToInt
|
||||
from .nodes.remove_bg import RemoveBG
|
||||
from .nodes.rembg_loader import RemBGLoader
|
||||
from .nodes.preview_mask import PreviewMask
|
||||
from .nodes.mask_blur_plus import MaskBlurPlus
|
||||
from .nodes.preview_mask_plus import PreviewMaskPlus
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"Custom_Save_Image": CustomSaveImage,
|
||||
@@ -28,7 +33,12 @@ NODE_CLASS_MAPPINGS = {
|
||||
"Slider_1000": Slider1000,
|
||||
"Slider_100": Slider100,
|
||||
"Slider_10": Slider10,
|
||||
"To_Int": ToInt
|
||||
"To_Int": ToInt,
|
||||
"Remove_BG": RemoveBG,
|
||||
"RemBG_Loader": RemBGLoader,
|
||||
"Preview_Mask": PreviewMask,
|
||||
"Mask_Blur_Plus": MaskBlurPlus,
|
||||
"Preview_Mask_Plus": PreviewMaskPlus,
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
@@ -45,7 +55,12 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"Slider_1000": "Slider 1000",
|
||||
"Slider_100": "Slider 100",
|
||||
"Slider_10": "Slider 10",
|
||||
"To_Int": "To Int"
|
||||
"To_Int": "To Int",
|
||||
"Remove_BG": "Remove BG",
|
||||
"RemBG_Loader": "RemBG Loader",
|
||||
"Preview_Mask": "Preview Mask",
|
||||
"Mask_Blur_Plus": "Mask Blur +",
|
||||
"Preview_Mask_Plus": "Preview Mask +",
|
||||
}
|
||||
|
||||
WEB_DIRECTORY = "web"
|
||||
@@ -0,0 +1,51 @@
|
||||
import torch
|
||||
from torchvision import transforms as T
|
||||
import comfy.model_management
|
||||
import torch.nn.functional as F
|
||||
|
||||
class MaskBlurPlus:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"mask": ("MASK",),
|
||||
"blur": ("INT", {
|
||||
"default": 0,
|
||||
"min": 0,
|
||||
"max": 256,
|
||||
"step": 1,
|
||||
"display": "slider"
|
||||
}),
|
||||
"expand": ("FLOAT", {
|
||||
"default": 0.0,
|
||||
"min": -5.0,
|
||||
"max": 5.0,
|
||||
"step": 0.1,
|
||||
"display": "slider"
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("MASK",)
|
||||
FUNCTION = "execute"
|
||||
CATEGORY = "KayTool/Mask"
|
||||
|
||||
def execute(self, mask, blur, expand):
|
||||
if mask.dim() == 2:
|
||||
mask = mask.unsqueeze(0)
|
||||
device = comfy.model_management.get_torch_device()
|
||||
mask = mask.to(device)
|
||||
if expand != 0.0:
|
||||
expand_pixels = int(abs(expand) * 10)
|
||||
kernel_size = 2 * expand_pixels + 1
|
||||
padding = expand_pixels
|
||||
if expand > 0.0:
|
||||
mask = F.max_pool2d(mask.unsqueeze(1), kernel_size=kernel_size, stride=1, padding=padding).squeeze(1)
|
||||
else:
|
||||
mask = -F.max_pool2d(-mask.unsqueeze(1), kernel_size=kernel_size, stride=1, padding=padding).squeeze(1)
|
||||
if blur > 0:
|
||||
if blur % 2 == 0:
|
||||
blur += 1
|
||||
mask = T.functional.gaussian_blur(mask.unsqueeze(1), kernel_size=int(blur)).squeeze(1)
|
||||
mask = mask.to(comfy.model_management.intermediate_device())
|
||||
return (mask,)
|
||||
@@ -0,0 +1,39 @@
|
||||
import os
|
||||
import random
|
||||
import string
|
||||
import torch
|
||||
import folder_paths
|
||||
from torchvision import transforms as T
|
||||
from nodes import SaveImage
|
||||
|
||||
class PreviewMask(SaveImage):
|
||||
def __init__(self):
|
||||
self.output_dir = folder_paths.get_temp_directory()
|
||||
self.type = "temp"
|
||||
self.prefix_append = "_temp_" + ''.join(random.choice(string.ascii_lowercase) for _ in range(5))
|
||||
self.compress_level = 4
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {"mask": ("MASK",), },
|
||||
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ()
|
||||
FUNCTION = "execute"
|
||||
CATEGORY = "KayTool/Mask"
|
||||
|
||||
def execute(self, mask, filename_prefix="ComfyUI", prompt=None, extra_pnginfo=None):
|
||||
if not isinstance(mask, torch.Tensor):
|
||||
raise ValueError("Input mask must be a PyTorch tensor.")
|
||||
if mask.dim() not in [2, 3]:
|
||||
raise ValueError("Input mask must have 2 or 3 dimensions.")
|
||||
if mask.dtype == torch.uint8:
|
||||
mask = mask.float() / 255.0
|
||||
elif mask.max() > 1.0:
|
||||
mask = mask / mask.max()
|
||||
if mask.dim() == 2:
|
||||
mask = mask.unsqueeze(0)
|
||||
preview = mask.unsqueeze(-1).expand(-1, -1, -1, 3)
|
||||
return self.save_images(preview, filename_prefix, prompt, extra_pnginfo)
|
||||
@@ -0,0 +1,78 @@
|
||||
import torch
|
||||
from torchvision import transforms as T
|
||||
import comfy.model_management
|
||||
import os
|
||||
import random
|
||||
import string
|
||||
import folder_paths
|
||||
from nodes import SaveImage
|
||||
|
||||
class PreviewMaskPlus(SaveImage):
|
||||
def __init__(self):
|
||||
self.output_dir = folder_paths.get_temp_directory()
|
||||
self.type = "temp"
|
||||
self.prefix_append = "_temp_" + ''.join(random.choice(string.ascii_lowercase) for _ in range(5))
|
||||
self.compress_level = 4
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",),
|
||||
"mask": ("MASK",),
|
||||
"Preview": (["mask", "Black", "White", "Red", "Green", "Blue"],),
|
||||
},
|
||||
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ()
|
||||
FUNCTION = "execute"
|
||||
CATEGORY = "KayTool/Mask"
|
||||
|
||||
def execute(self, image, mask, Preview, filename_prefix="ComfyUI", prompt=None, extra_pnginfo=None):
|
||||
|
||||
device = comfy.model_management.get_torch_device()
|
||||
|
||||
|
||||
if not isinstance(mask, torch.Tensor):
|
||||
raise ValueError("Input mask must be a PyTorch tensor.")
|
||||
if mask.dim() not in [2, 3]:
|
||||
raise ValueError("Input mask must have 2 or 3 dimensions.")
|
||||
if mask.dtype == torch.uint8:
|
||||
mask = mask.float() / 255.0
|
||||
elif mask.max() > 1.0:
|
||||
mask = mask / mask.max()
|
||||
if mask.dim() == 2:
|
||||
mask = mask.unsqueeze(0)
|
||||
mask = mask.to(device)
|
||||
|
||||
|
||||
if Preview == "mask":
|
||||
|
||||
preview = mask.unsqueeze(-1).expand(-1, -1, -1, 3)
|
||||
else:
|
||||
|
||||
image = image.permute([0, 3, 1, 2])
|
||||
image = image.permute([0, 2, 3, 1])
|
||||
foreground = image[:, :, :, :3] if image.shape[3] == 4 else image
|
||||
foreground = foreground.to(device)
|
||||
|
||||
alpha = mask.unsqueeze(-1).expand(-1, -1, -1, 3)
|
||||
color_map = {
|
||||
"Black": [0, 0, 0],
|
||||
"White": [1, 1, 1],
|
||||
"Red": [1, 0, 0],
|
||||
"Green": [0, 1, 0],
|
||||
"Blue": [0, 0, 1],
|
||||
}
|
||||
background_color_rgb = color_map.get(Preview, [0, 0, 0])
|
||||
background = torch.tensor(background_color_rgb, device=device).view(1, 1, 1, 3).repeat(
|
||||
foreground.shape[0], foreground.shape[1], foreground.shape[2], 1
|
||||
)
|
||||
preview = foreground * alpha + background * (1 - alpha)
|
||||
|
||||
|
||||
preview = preview.to(device)
|
||||
|
||||
|
||||
return self.save_images(preview, filename_prefix, prompt, extra_pnginfo)
|
||||
@@ -0,0 +1,49 @@
|
||||
from ..utils.helpers import get_default_provider
|
||||
|
||||
class RemBGLoader:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"model": ([
|
||||
"u2net",
|
||||
"u2netp",
|
||||
"u2net_human_seg",
|
||||
"u2net_cloth_seg",
|
||||
"silueta",
|
||||
"isnet-general-use",
|
||||
"isnet-anime",
|
||||
"sam"
|
||||
],),
|
||||
"providers": ([
|
||||
"auto",
|
||||
"CPU",
|
||||
"CUDA",
|
||||
"ROCM",
|
||||
"DirectML",
|
||||
"OpenVINO",
|
||||
"CoreML",
|
||||
"Tensorrt",
|
||||
"Azure"
|
||||
],),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("REMBG_LOADER",)
|
||||
FUNCTION = "execute"
|
||||
CATEGORY = "KayTool/Background Removal"
|
||||
|
||||
def execute(self, model, providers):
|
||||
if providers == "auto":
|
||||
providers = get_default_provider()
|
||||
|
||||
class Session:
|
||||
def __init__(self, model, providers):
|
||||
from rembg import new_session
|
||||
self.session = new_session(model, providers=[providers + "ExecutionProvider"])
|
||||
|
||||
def process(self, image):
|
||||
from rembg import remove
|
||||
return remove(image, session=self.session)
|
||||
|
||||
return (Session(model, providers),)
|
||||
@@ -0,0 +1,99 @@
|
||||
import torch
|
||||
from torchvision import transforms as T
|
||||
import comfy.model_management
|
||||
import torch.nn.functional as F
|
||||
|
||||
class RemoveBG:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"rembg_loader": ("REMBG_LOADER",), # 确保类型与 RemBGLoader 输出一致
|
||||
"image": ("IMAGE",),
|
||||
"Preview": ([
|
||||
"none",
|
||||
"Black",
|
||||
"White",
|
||||
"Red",
|
||||
"Green",
|
||||
"Blue"
|
||||
],),
|
||||
"Blur": ("INT", {
|
||||
"default": 0,
|
||||
"min": 0,
|
||||
"max": 256,
|
||||
"step": 1,
|
||||
"display": "slider"
|
||||
}),
|
||||
"Expand": ("FLOAT", {
|
||||
"default": 0.0,
|
||||
"min": -5.0,
|
||||
"max": 5.0,
|
||||
"step": 0.1,
|
||||
"display": "slider"
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE", "MASK",)
|
||||
FUNCTION = "execute"
|
||||
CATEGORY = "KayTool/Background Removal"
|
||||
|
||||
def execute(self, rembg_loader, image, Preview, Blur, Expand):
|
||||
# 图像预处理
|
||||
image = image.permute([0, 3, 1, 2])
|
||||
output = []
|
||||
for img in image:
|
||||
img_pil = T.ToPILImage()(img)
|
||||
img_processed = rembg_loader.process(img_pil)
|
||||
img_tensor = T.ToTensor()(img_processed)
|
||||
output.append(img_tensor)
|
||||
output = torch.stack(output, dim=0)
|
||||
output = output.permute([0, 2, 3, 1])
|
||||
|
||||
# 提取遮罩
|
||||
mask = output[:, :, :, 3] if output.shape[3] == 4 else torch.ones_like(output[:, :, :, 0])
|
||||
foreground = image.permute([0, 2, 3, 1])[:, :, :, :3] if image.shape[1] == 4 else image.permute([0, 2, 3, 1])
|
||||
|
||||
# 遮罩预处理
|
||||
if mask.dim() == 2:
|
||||
mask = mask.unsqueeze(0)
|
||||
device = comfy.model_management.get_torch_device()
|
||||
mask = mask.to(device)
|
||||
|
||||
# 遮罩扩展
|
||||
if Expand != 0.0:
|
||||
expand_pixels = int(abs(Expand) * 10)
|
||||
kernel_size = 2 * expand_pixels + 1
|
||||
padding = expand_pixels
|
||||
if Expand > 0.0:
|
||||
mask = F.max_pool2d(mask.unsqueeze(1), kernel_size=kernel_size, stride=1, padding=padding).squeeze(1)
|
||||
else:
|
||||
mask = -F.max_pool2d(-mask.unsqueeze(1), kernel_size=kernel_size, stride=1, padding=padding).squeeze(1)
|
||||
|
||||
# 遮罩模糊
|
||||
if Blur > 0:
|
||||
if Blur % 2 == 0:
|
||||
Blur += 1
|
||||
mask = T.functional.gaussian_blur(mask.unsqueeze(1), kernel_size=int(Blur)).squeeze(1)
|
||||
|
||||
mask = mask.to(comfy.model_management.intermediate_device())
|
||||
alpha = mask.unsqueeze(-1).repeat(1, 1, 1, 3)
|
||||
|
||||
# 根据 Preview 选项生成结果
|
||||
if Preview == "none":
|
||||
return (foreground * alpha, mask)
|
||||
|
||||
color_map = {
|
||||
"Black": [0, 0, 0],
|
||||
"White": [1, 1, 1],
|
||||
"Red": [1, 0, 0],
|
||||
"Green": [0, 1, 0],
|
||||
"Blue": [0, 0, 1],
|
||||
}
|
||||
background_color_rgb = color_map.get(Preview, [0, 0, 0])
|
||||
background = torch.tensor(background_color_rgb).view(1, 1, 1, 3).repeat(
|
||||
foreground.shape[0], foreground.shape[1], foreground.shape[2], 1
|
||||
)
|
||||
result = foreground * alpha + background * (1 - alpha)
|
||||
return (result, mask)
|
||||
+1
-1
@@ -18,7 +18,7 @@ class Slider10:
|
||||
|
||||
RETURN_TYPES = ("INT",)
|
||||
FUNCTION = "get_value"
|
||||
CATEGORY = "KayTool"
|
||||
CATEGORY = "KayTool/Slider"
|
||||
|
||||
def get_value(self, value):
|
||||
return (value,)
|
||||
+1
-1
@@ -18,7 +18,7 @@ class Slider100:
|
||||
|
||||
RETURN_TYPES = ("INT",)
|
||||
FUNCTION = "get_value"
|
||||
CATEGORY = "KayTool"
|
||||
CATEGORY = "KayTool/Slider"
|
||||
|
||||
def get_value(self, value):
|
||||
return (value,)
|
||||
@@ -18,7 +18,7 @@ class Slider1000:
|
||||
|
||||
RETURN_TYPES = ("INT",)
|
||||
FUNCTION = "get_value"
|
||||
CATEGORY = "KayTool"
|
||||
CATEGORY = "KayTool/Slider"
|
||||
|
||||
def get_value(self, value):
|
||||
return (value,)
|
||||
+3
-2
@@ -1,8 +1,9 @@
|
||||
[project]
|
||||
name = "kaytool"
|
||||
description ="This is a custom node toolkit that includes a variety of practical nodes, such as a custom prompt preset node, wireless transmission nodes, Tencent and Baidu AI translator nodes, mathematical operation nodes, image size extraction nodes, display-any nodes, color adjustment nodes, and custom image saving nodes, among others."
|
||||
version = "0.15.10"
|
||||
description ="The KayTool custom node toolkit is designed to enhance the efficiency of building ComfyUI workflows. It includes a variety of practical nodes: wireless data transfer (Set & Get), AI translation (Tencent and Baidu), dynamic mathematical operations, image processing (size extraction, color adjustment, background removal, mask blurring and expansion), flexible text handling, precision sliders, advanced image saving with metadata support, and more."
|
||||
version = "0.20.16"
|
||||
license = {file = "LICENSE"}
|
||||
dependencies = ["rembg"]
|
||||
|
||||
[project.urls]
|
||||
Repository = "https://github.com/kk8bit/KayTool"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
rembg
|
||||
@@ -0,0 +1,9 @@
|
||||
import torch
|
||||
|
||||
def get_default_provider():
|
||||
if torch.cuda.is_available():
|
||||
return "CUDA"
|
||||
elif hasattr(torch, "backends") and hasattr(torch.backends, "rocm"):
|
||||
return "ROCM"
|
||||
else:
|
||||
return "CPU"
|
||||
+11
-2
@@ -10,7 +10,7 @@ const COLOR_THEMES = {
|
||||
cyan: { nodeColor: "#223333", nodeBgColor: "#335555" },
|
||||
purple: { nodeColor: "#332233", nodeBgColor: "#553355" },
|
||||
yellow: { nodeColor: "#443322", nodeBgColor: "#665533" },
|
||||
black: { nodeColor: "#222", nodeBgColor: "#000" },
|
||||
black: { nodeColor: "#000", nodeBgColor: "#000" },
|
||||
none: { nodeColor: null, nodeBgColor: null }
|
||||
};
|
||||
|
||||
@@ -19,12 +19,21 @@ const NODE_COLORS = {
|
||||
"Baidu_Translater": "cyan",
|
||||
"Tencent_Translater": "cyan",
|
||||
"Display_Any": "pale_blue",
|
||||
"Color_Adjustment": "pale_blue",
|
||||
"Color_Adjustment": "blue",
|
||||
"Custom_Save_Image": "black",
|
||||
"Abc_Math": "cyan",
|
||||
"Image_Size_Extractor": "pale_blue",
|
||||
"Text": "pale_blue",
|
||||
"AIO_Translater": "cyan",
|
||||
"RemBG_Loader": "purple",
|
||||
"Remove_BG": "purple",
|
||||
"Preview_Mask_Plus": "cyan",
|
||||
"Mask_Blur_Plus": "cyan",
|
||||
"Preview_Mask": "pale_blue",
|
||||
"To_Int": "pale_blue",
|
||||
"Slider_1000": "blue",
|
||||
"Slider_100": "blue",
|
||||
"Slider_10": "blue",
|
||||
};
|
||||
|
||||
function setNodeColors(node, theme) {
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ function showAlert(message) {
|
||||
app.extensionManager.toast.add({
|
||||
severity: 'warn',
|
||||
summary: "KayTool Set/Get",
|
||||
detail: `${message}. Most likely you're missing custom nodes`,
|
||||
detail: `${message} Most likely you're missing custom nodes`,
|
||||
life: 5000,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user