352 Commits
Author SHA1 Message Date
li-lizhe 2176b74083 Add 'auto' device option to nodes with hardcoded CUDA/CPU device lists
Several nodes only exposed a 'cuda'/'cpu' device dropdown, forcing users on
any other ComfyUI-supported accelerator (Ascend NPU, XPU, MPS) to run on CPU
even when their device is available.

Add a shared DEVICE_LIST_OPTIONS constant and get_device() helper in
imagefunc.py that resolve 'auto' to ComfyUI's default device, and use them in
the VITMatte-based matting nodes and the VQA model loader so non-CUDA devices
can be selected from the UI.
2026-09-16 10:08:47 +08:00
li-lizhe 6555d35004 Use ComfyUI's device selection instead of hardcoded CUDA checks
Several model-loading and processing paths pick their device with
`"cuda" if torch.cuda.is_available() else "cpu"`, and move tensors with
`.cuda()` guarded by the same check:

- `imagefunc.load_RMBG_model` / `RMBG`
- `imagefunc.get_masked_VITMatte_image` (vitmatte)
- `imagefunc.UformGen2QwenChat`
- `imagefunc.clear_memory`
- `blendmodes.rgb_to_hsv_via_torch` / `hsv_to_rgb_via_torch`

On any non-CUDA accelerator that ComfyUI itself supports (e.g. Ascend NPU
via torch_npu, which ComfyUI's own `comfy.model_management.get_torch_device`
returns a `torch.device("npu")` for), these paths silently fall back to the
CPU or, for `.cuda()`, move the input to a CUDA device that does not exist.

This repo already imports `comfy.model_management` (e.g. in `purge_vram.py`),
so use its device selection for consistency with the rest of ComfyUI:

- `load_RMBG_model`, `UformGen2QwenChat`, and the blendmode helpers now use
  `comfy.model_management.get_torch_device()`.
- `RMBG` moves the input to the device of the (lru-cached) model itself
  instead of probing CUDA, so it also follows device changes correctly.
- the vitmatte path uses the ComfyUI device unless the caller explicitly
  asked for CPU; a hardcoded "cuda" request without CUDA available now logs
  and uses the ComfyUI default.
- cache clearing also calls `torch.accelerator.empty_cache()` when a
  non-CUDA accelerator is present (`torch.accelerator` is the device-agnostic
  PyTorch API).

Verified on Ascend 910B (torch 2.14.0a0 + torch_npu 2.14.0) with
ComfyUI-master's `comfy.model_management` implementation:
`get_torch_device()` returns `torch.device("npu", 0)`, a conv2d forward and
an RMBG-style model/input flow run on `npu:0`, and
`torch.accelerator.empty_cache()` is callable. On CUDA machines the selected
device is unchanged (`cuda`).
2026-09-02 16:02:58 +08:00
chflame163 557d882e18 The output of ImageReelComposit node is mandated to be even number 2026-08-18 13:13:45 +08:00
chflame163 953676c592 fix bug for ImageReelComposit node when processing Image Batch 2026-08-18 12:33:06 +08:00
chflame163 02acdc50af commit PadImageBatch and RestorePadImageBatch nodes 2026-07-23 13:45:00 +08:00
chflame163 d94bef1ee5 Ultra nodes support vitmatte-base-composition-1k 2026-01-30 14:31:45 +08:00
chflame163 3d53de09d8 fix debug info 2026-01-11 12:52:41 +08:00
chflame163 ef5c45afe3 add debug info of ImageBatchToList and ImageListToBatch nodes 2026-01-11 12:50:28 +08:00
chflame163 3ab3e38192 commit ImageBatchToList and ImageListToBatch nodes 2026-01-11 09:30:22 +08:00
chflame163 0d88b177d4 fix bug of ImageCompositHandleMask 2026-01-09 12:01:16 +08:00
chflame163 a1875e824c commit DistortDisplace node 2026-01-08 17:50:29 +08:00
chflame163 d256c3a057 commit MaskEdgeUltraDetailV3 node 2026-01-08 00:56:41 +08:00
chflame163 5840264d0d fix bug of converting BF16 tensor to pillow image 2025-12-29 15:52:57 +08:00
bigcat88 dcb96084a5 make the initial value of a random seed deterministic 2025-12-23 18:02:03 +02:00
chflame163 3c697dbcbc fix node category 2025-11-21 18:23:20 +08:00
chflame163 501e46faa1 fix bug of node value 2025-11-21 17:53:23 +08:00
chflame163 610307802d commit ImageCompositeHandleMask node 2025-11-21 17:34:22 +08:00
chflame163 4f4d5cbbe4 update DrawRoundedRectangle node and readme 2025-11-07 23:30:43 +08:00
chflame163 de6d880d47 commit DrawRoundedRectangle node 2025-11-07 23:03:52 +08:00
chflame163 89014d833d commit NanoBanana Image Scale node 2025-09-11 00:06:21 +08:00
chflame163 42ccdd8f75 commit ColorNegative,MaskBoxExtend,FluxKontextImageScale nodes 2025-08-09 20:53:07 +08:00
chflame163 677468955a commit LoadImagesFromPath and ImageTaggerSaveV2 nodes 2025-08-04 20:35:34 +08:00
chflame163 3bfe8e435d remove LUT Apply node debug info 2025-06-20 08:44:58 +08:00
chflame163 917d59f63c commit SegformerUltraV2, LoadSegformerModel, SegformerClothesSetting and SegformerFashionSetting nodes 2025-05-17 20:55:42 +08:00
chflame163 a085d8ca3c fix a bug of HalfTone 2025-03-26 11:39:50 +08:00
chflame163 2898861ff3 fix HalfTone nodename 2025-03-26 11:25:29 +08:00
chflame163 277355ea19 commit HalfTone node 2025-03-26 11:24:03 +08:00
chflame163 a01fdf60cd remove filmgrainer save cache file 2025-03-25 23:22:14 +08:00
chflame163 67f664efdc support numpy 2.x 2025-03-12 13:51:14 +08:00
chflame163 7b326d13e4 commit PurgeVRAM V2 node 2025-02-13 13:07:10 +08:00
chflame163 3bf7244fa6 PurgeVRAM node add any output 2025-02-13 09:46:30 +08:00
chflame163 127be44f9d fix add_grain.py for ramdom grain in batch images 2025-01-26 16:56:10 +08:00
chflame163 84d357ad82 fix bug of image_beauty 2025-01-15 22:47:59 +08:00
chflame163 bafd400040 requirements.txt remove zhipuai 2024-12-28 20:41:49 +08:00
chflame163 b090d94d12 requirements.txt add zhipuai 2024-12-28 15:37:20 +08:00
chflame163 d8338b3043 fix a bug of RMBGUltra 2024-12-23 19:59:48 +08:00
chflame163 026a159b41 add ChoiceTextPreset and TextPreseter nodes 2024-12-22 15:11:45 +08:00
bigcat88 efa88cc935 fixed incorrect results for RmBgUltraV2 node 2024-12-21 14:02:21 +02:00
chflame163 666541eb06 Merge pull request #460 from Visionatrix/main
rmbg1.4: use "comfy.get_torch_device()" instead if "torch.cuda.is_available"
2024-12-20 22:38:21 +08:00
bigcat88 7fa2d0d357 use "comfy.model_management.get_torch_device()" instead if "torch.cuda.is_available" 2024-12-20 14:54:47 +02:00
chflame163 c6ac429ef6 support for short format hexcolor strings of imagefunc.py 2024-12-20 14:29:41 +08:00
chflame163 1b7d63f840 commit NameToColor node 2024-12-19 19:17:46 +08:00
chflame163 b3af85a2ff remove ColorImageV3 node 2024-12-19 09:19:29 +08:00
chflame163 9bd65618bf commit ImageMaskScaleAsV2,ColorImage V3 nodes 2024-12-18 23:48:12 +08:00
chflame163 184e83baf9 fix bug of function mask_area 2024-12-17 21:02:51 +08:00
chflame163 755604a9df update imagefunc.py 2024-12-17 18:44:14 +08:00
chflame163 ac9e179489 commit RoundedRectangle node 2024-12-16 16:40:17 +08:00
chflame163 fc764f2834 commit AnyRerouter node 2024-12-15 18:16:27 +08:00
chflame163 fe5b659f10 fix noise random of Film nodes 2024-12-15 10:19:51 +08:00
chflame163 b4be09280f Merge crop and resize to ICMarkCropBack node 2024-12-15 10:02:11 +08:00