Baidu Meux ComfyTools
English
Overview
Baidu Meux ComfyTools is a collection of custom nodes that streamline common workflow chores in ComfyUI for the Baidu Meux asset platform.
Current version: 1.5.0
MeuxMultiSaveImage: save up to sixteen image batches with optional resizing.MeuxAdvancedImageCrop: crop images by pixels or percentage with optional grid alignment.MeuxSimpleLLMNode: call an external chat-completions style LLM API directly inside a workflow.MeuxImageLoader: drop-in replacement for ComfyUI's Load Image node with optional HTTP/HTTPS downloading and persistence to the input folder.MeuxSmartEmptyLatent: generate a safe-sized empty latent tensor based on target size alignment.MeuxSizePresetSafe: compute safe generation size and return size metadata for downstream nodes.MeuxOutpaintSizePresetSafe: compute safe per-side outpaint expansion aligned to 8/64.MeuxSmartExactResize: smart crop/pad to exact target size with auto mode and padding options.MeuxRMBG(displayed as "Meux RMBG (BiRefNet)"): background removal node based on BiRefNet, outputsRGBA IMAGEandMASK.MeuxRealESRGANUpscale(displayed as “Meux ESRGAN Upscale”): local RealESRGAN upscale node using weights fromComfyUI/models/upscale_modelsorextra_model_paths.yaml(upscale_models).
The package now uses a modular nodes/ directory so each node is easy to maintain and extend.
Changelog
- v1.5.0
- Added
MeuxRMBGfor local/remote BiRefNet background removal. - Added
MeuxRealESRGANUpscalefor local RealESRGAN image upscaling.
- Added
- v1.4.0
- Added
MeuxOutpaintSizePresetSafefor safe outpaint expansion sizes. - Capped size inputs at 4096 for size-related nodes.
- Added
- v1.3.0
- Added
MeuxSmartEmptyLatent,MeuxSizePresetSafe, andMeuxSmartExactResize.
- Added
- v1.2.0
- Introduced
MeuxImageLoader, a drop-in replacement for ComfyUI's Load Image with URL downloading.
- Introduced
- v1.1.0
- Restructured package into modular node files under
nodes/. - Added
MeuxAdvancedImageCropandMeuxSimpleLLMNoderegistrations to the public export. - Updated documentation with usage guides for every node.
- Restructured package into modular node files under
- v1.0.0
- Initial release with the
MeuxMultiSaveImagenode.
- Initial release with the
Installation / Update
-
Clone or download into your ComfyUI custom node folder:
cd ComfyUI/custom_nodes/ git clone https://github.com/yourusername/Baidu_Meux_ComfyTools.git -
For updates, pull the latest changes:
cd ComfyUI/custom_nodes/Baidu_Meux_ComfyTools git pull -
Install dependencies:
cd ComfyUI/custom_nodes/Baidu_Meux_ComfyTools pip install -r requirements.txt -
Restart ComfyUI. The nodes appear under
image,image/segmentation,image/upscale,Image/Transform,LLM, andutils/size.
Usage Tutorial
MeuxImageLoader
- Set
source_type:local: behaves exactly like the stock Load Image node; pick any file underComfyUI/input.url: paste an HTTP/HTTPS link to download on the fly.
- Optional controls:
filename_hint: suggest the persisted filename; falls back to a hash of the URL.persist_to_input: keep a copy inComfyUI/inputso other nodes can reference it by name.overwrite_existing: replace an existing file instead of auto-appending numeric suffixes.download_timeout,max_download_mb,verify_ssl: guardrails for network transfers.
- Run the node to receive the image tensor plus the derived
MASK(alpha or grayscale channel when available), making it a drop-in replacement for ComfyUI's default loader.
MeuxMultiSaveImage
- Connect one or more
IMAGEtensors toimages_1…images_16. Batches are split automatically. - Set
filename_prefix(unsafe characters are cleaned automatically). - Optional toggles:
save_individually: keep the sequential counter for each input image.resize_to_same: rescale every image totarget_width×target_heightusing Lanczos.
- Run the node. Images are written to the ComfyUI output directory as
prefix_{slotIndex:03d}_{counter:05d}.png, and UI metadata is returned for gallery preview.
MeuxAdvancedImageCrop
- Feed an
IMAGEtensor intoimage. - Choose
measurementmode:Pixels: specify absolute crop margins.Percentage: margins are interpreted relative to current width/height.
- Optionally snap the crop window by setting
align_toto8or16. - Execute to obtain the cropped tensor (with console logging of the crop result).
MeuxSimpleLLMNode
- Provide your API key and endpoint (
api_urldefaults to siliconflow chat completions). - Set the
modelidentifier supported by your provider. - Enter the
user_prompt; optionally supply asystem_promptand sampling parameters (temperature,top_p,top_k, penalties). - Run the node. The main output is the assistant message, along with the full JSON payload and token usage.
MeuxSmartEmptyLatent
- Set
target_width,target_height, andbatch_size. - Choose
align(8 or 64). The node rounds up to a safe generation size. - Run the node to output an empty
LATENTplusgen_widthandgen_height.
MeuxSizePresetSafe
- Set
target_width,target_height, andbatch_size. - Choose
align(8 or 64). The node rounds up to a safe generation size. - Run the node to output
gen_width,gen_height, and the input size metadata.
MeuxOutpaintSizePresetSafe
- Set
expand_left,expand_right,expand_top, andexpand_bottom. - Choose
align(8 or 64). Each side rounds up to a safe expansion size. - Run the node to output
safe_*values plus the originaltarget_*values.
MeuxSmartExactResize
- Feed an
IMAGEtensor intoimage. - Set
target_widthandtarget_height. - Choose
mode:auto,crop_only, orpad_only. - Optional:
anchorfor cropping,safe_margin_percentfor auto crop safety, andpadding_modefor padding style. - Run the node to output a resized image with exact target dimensions.
Meux RMBG (BiRefNet)
- Prepare one of these model folders in
ComfyUI/models/BiRefNet/(or configureextra_model_paths.yamlwithbirefnet/BiRefNet):BiRefNet-portrait(portrait matting)BiRefNet(generic foreground)
- Ensure each model directory contains
config.jsonand at least one weight file (*.safetensorsor*.bin). - Feed an
IMAGEtensor intoimage, choosemodel_preset, and setinput_size(256-2048). - Optional toggles:
apply_mask: multiply RGB by mask before output.invert_mask: invert foreground/background selection.model_override: override preset with absolute path or Hugging Face repo id.
- Run the node to get:
image: RGBA image (alpha from mask)mask: normalized single-channel mask
Meux ESRGAN Upscale
-
Download the model weight
RealESRGAN_x4plus.pthfrom the official release:wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -
Install it under
ComfyUI/models/upscale_models/:mkdir -p ComfyUI/models/upscale_models mv RealESRGAN_x4plus.pth ComfyUI/models/upscale_models/ -
Feed an
IMAGEtensor intoimage. -
Choose
scale_mode(2x/3x/4x/6x/8x/custom) and setcustom_scalewhen usingcustom. Note: the bundled model is a 4x model. Non-4x modes are produced by resizing after 4x inference. -
Select
model_namefrom the dropdown (auto-scanned fromupscale_modelsandextra_model_paths.yaml). If you add new models, togglerefresh_model_listonce. -
Optional: set
model_pathto an absolute path to override the lookup. -
Optional: enable
free_gpu_afterto release GPU memory after each run (slower but safer for long sessions). -
Run the node to output the upscaled image tensor.
Folder Structure
Baidu_Meux_ComfyTools/
├── __init__.py # Registers all exposed nodes
├── requirements.txt # Python dependencies
├── rmgb.py # Optional FastAPI RMBG demo service
└── nodes/
├── image_loader.py
├── advanced_image_crop.py
├── multi_save_image.py
├── simple_llm_node.py
├── smart_empty_latent.py
├── size_preset_safe.py
├── outpaint_size_preset_safe.py
├── smart_exact_resize.py
├── rmbg_birefnet.py
└── realesrgan_upscale.py
Requirements
- ComfyUI
- PyTorch
- Pillow
- NumPy
- Requests (required by
MeuxSimpleLLMNodeandMeuxImageLoader) - transformers (required by
MeuxRMBG) - torchvision (required by
MeuxRMBG) - realesrgan (required by
MeuxRealESRGANUpscale)
License & Support
Licensed under the MIT License.
Issues and feature requests: GitHub Issues.
中文
概述
Baidu Meux ComfyTools 是一组面向百度 Meux 资产平台、帮助简化 ComfyUI 工作流的自定义节点。
当前版本:1.5.0
MeuxMultiSaveImage:一次保存最多 16 组图像,支持可选统一尺寸。MeuxAdvancedImageCrop:按像素或百分比裁剪,可选择 8/16 像素对齐。MeuxSimpleLLMNode:在工作流中调用外部 LLM Chat Completion 接口。MeuxImageLoader:兼容本地/URL 两种来源,可选写入 input 目录,完全替换原生 Load Image 节点。MeuxSmartEmptyLatent:根据目标尺寸对齐规则,生成安全尺寸的空白 latent。MeuxSizePresetSafe:计算安全生成尺寸并输出尺寸元信息,供下游节点使用。MeuxOutpaintSizePresetSafe:计算外扩的安全尺寸(按 8/64 对齐)。MeuxSmartExactResize:智能裁剪/补边到精确尺寸,支持自动模式与多种补边方式。MeuxRMBG(显示为 "Meux RMBG (BiRefNet)"):基于 BiRefNet 的抠图节点,输出RGBA IMAGE与MASK。MeuxRealESRGANUpscale(显示为“Meux ESRGAN Upscale”):本地 RealESRGAN 放大节点,默认从ComfyUI/models/upscale_models或extra_model_paths.yaml(upscale_models)读取权重。
项目已改用模块化的 nodes/ 目录,便于后续维护与扩展。
更新日志
- v1.5.0
- 新增
MeuxRMBG,支持本地/远端 BiRefNet 抠图。 - 新增
MeuxRealESRGANUpscale,用于本地 RealESRGAN 放大。
- 新增
- v1.4.0
- 新增
MeuxOutpaintSizePresetSafe,用于安全外扩尺寸计算。 - 尺寸相关输入上限统一为 4096。
- 新增
- v1.3.0
- 新增
MeuxSmartEmptyLatent、MeuxSizePresetSafe、MeuxSmartExactResize。
- 新增
- v1.2.0
- 新增
MeuxImageLoader,支持 URL 下载、可完全替换原生 Load Image。
- 新增
- v1.1.0
- 重构包结构至
nodes/子目录。 - 注册
MeuxAdvancedImageCrop与MeuxSimpleLLMNode节点。 - 文档新增全部节点的使用教程。
- 重构包结构至
- v1.0.0
- 发布
MeuxMultiSaveImage节点初版。
- 发布
安装 / 更新
-
克隆或下载到 ComfyUI 自定义节点目录:
cd ComfyUI/custom_nodes/ git clone https://github.com/yourusername/Baidu_Meux_ComfyTools.git -
更新时执行:
cd ComfyUI/custom_nodes/Baidu_Meux_ComfyTools git pull -
安装依赖:
cd ComfyUI/custom_nodes/Baidu_Meux_ComfyTools pip install -r requirements.txt -
重启 ComfyUI,节点将出现在
image、image/segmentation、image/upscale、Image/Transform、LLM与utils/size分类下。
使用教程
MeuxImageLoader
- 选择
source_type:local:与原生 Load Image 完全一致,从ComfyUI/input选择文件。url:粘贴 HTTP/HTTPS 图片地址,节点会在运行时自动下载。
- 可选参数:
filename_hint:为持久化的文件提供自定义名称,默认使用 URL 哈希。persist_to_input:勾选后会把下载结果写入ComfyUI/input以供其他节点复用。overwrite_existing:允许覆盖同名文件,否则自动追加序号。download_timeout、max_download_mb、verify_ssl:用于限制下载时间、大小与验证方式。
- 运行后输出图片张量与
MASK(若原图包含 Alpha 或灰度通道),可直接替换 ComfyUI 自带的 Load Image 节点。
MeuxMultiSaveImage
- 将一张或多张
IMAGE张量连接到images_1…images_16,批次会自动拆分。 - 设置
filename_prefix(系统会自动清理危险字符)。 - 可选项:
save_individually:为每张图单独编号。resize_to_same:按target_width×target_height使用 Lanczos 算法统一尺寸。
- 运行后,图像保存到 ComfyUI 输出目录,命名格式
前缀_{输入序号:03d}_{计数:05d}.png,同时返回 UI 预览信息。
MeuxAdvancedImageCrop
- 将
IMAGE张量接入image。 - 选择
measurement模式:Pixels:输入像素裁剪边距。Percentage:边距按当前宽/高的百分比计算。
- 如需像素对齐,将
align_to设为8或16。 - 运行节点即可得到裁剪后的图像,并在控制台查看裁剪日志。
MeuxSimpleLLMNode
- 输入可用的 API Key 和接口地址(默认指向 siliconflow chat completions)。
- 设置服务商支持的
model名称。 - 填写
user_prompt;根据需要添加system_prompt和采样参数(temperature、top_p、top_k、惩罚项)。 - 执行节点将返回:
- 主输出:模型回复文本;
- 附加输出:完整 JSON 响应与消耗的 token 数。
MeuxSmartEmptyLatent
- 设置
target_width、target_height与batch_size。 - 选择对齐方式
align(8 或 64),节点会向上取整为安全生成尺寸。 - 运行后输出空白
LATENT,以及gen_width、gen_height。
MeuxSizePresetSafe
- 设置
target_width、target_height与batch_size。 - 选择对齐方式
align(8 或 64),节点会向上取整为安全生成尺寸。 - 运行后输出
gen_width、gen_height以及输入尺寸元信息。
MeuxOutpaintSizePresetSafe
- 设置
expand_left、expand_right、expand_top、expand_bottom。 - 选择
align(8 或 64),各方向向上取整为安全外扩尺寸。 - 运行后输出
safe_*以及原始target_*数值。
MeuxSmartExactResize
- 将
IMAGE张量接入image。 - 设置
target_width与target_height。 - 选择
mode:auto、crop_only或pad_only。 - 可选:裁剪锚点
anchor、自动裁剪安全边距safe_margin_percent、补边方式padding_mode。 - 运行后输出精确尺寸的图像张量。
Meux RMBG (BiRefNet)
- 在
ComfyUI/models/BiRefNet/下准备模型目录(或在extra_model_paths.yaml增加birefnet/BiRefNet路径):BiRefNet-portrait(人像抠图)BiRefNet(通用抠图)
- 每个模型目录至少包含
config.json与一个权重文件(*.safetensors或*.bin)。 - 将
IMAGE张量接入image,选择model_preset,并设置input_size(256-2048)。 - 可选开关:
apply_mask:输出前将 RGB 与 mask 相乘。invert_mask:反转前景/背景。model_override:用绝对路径或 Hugging Face 仓库 ID 覆盖预设。
- 运行后输出:
image:RGBA 图像(alpha 来自 mask)mask:归一化单通道 mask
Meux ESRGAN Upscale
-
从官方 Release 下载
RealESRGAN_x4plus.pth:wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -
安装路径为
ComfyUI/models/upscale_models/:mkdir -p ComfyUI/models/upscale_models mv RealESRGAN_x4plus.pth ComfyUI/models/upscale_models/ -
将
IMAGE张量接入image。 -
选择
scale_mode(2x/3x/4x/6x/8x/custom),使用custom时设置custom_scale。 注意:内置模型为 4x,非 4x 模式是在 4x 推理后再缩放得到。 -
通过下拉选择
model_name(自动扫描upscale_models与extra_model_paths.yaml)。若新增模型,勾选一次refresh_model_list。 -
可选:设置
model_path为绝对路径以覆盖默认查找。 -
可选:开启
free_gpu_after,每次运行后释放显存(速度更慢,但适合长时间运行)。 -
运行后输出放大后的图像张量。
目录结构
Baidu_Meux_ComfyTools/
├── __init__.py # 节点入口注册
├── requirements.txt # Python 依赖
├── rmgb.py # 可选 FastAPI 抠图演示服务
└── nodes/
├── image_loader.py
├── advanced_image_crop.py
├── multi_save_image.py
├── simple_llm_node.py
├── smart_empty_latent.py
├── size_preset_safe.py
├── outpaint_size_preset_safe.py
├── smart_exact_resize.py
├── rmbg_birefnet.py
└── realesrgan_upscale.py
依赖
- ComfyUI
- PyTorch
- Pillow
- NumPy
- Requests(供
MeuxSimpleLLMNode与MeuxImageLoader访问 HTTP 接口) - transformers(供
MeuxRMBG使用) - torchvision(供
MeuxRMBG使用) - realesrgan(供
MeuxRealESRGANUpscale使用)
许可证与支持
采用 MIT 许可证。
问题反馈与功能建议: GitHub Issues。