mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-05-06 15:22:31 +08:00
Fix SolidMask and MaskComposite device mismatch with --gpu-only
SolidMask had a hardcoded device="cpu" while other nodes (e.g. EmptyImage) follow intermediate_device(). This causes a RuntimeError when MaskComposite combines masks from different device sources under --gpu-only. - SolidMask: use intermediate_device() instead of hardcoded "cpu" - MaskComposite: align source device to destination before operating
This commit is contained in:
parent
8cbbea8f6a
commit
2729bd0dc6
@ -2,6 +2,7 @@ import numpy as np
|
|||||||
import scipy.ndimage
|
import scipy.ndimage
|
||||||
import torch
|
import torch
|
||||||
import comfy.utils
|
import comfy.utils
|
||||||
|
import comfy.model_management
|
||||||
import node_helpers
|
import node_helpers
|
||||||
from typing_extensions import override
|
from typing_extensions import override
|
||||||
from comfy_api.latest import ComfyExtension, IO, UI
|
from comfy_api.latest import ComfyExtension, IO, UI
|
||||||
@ -188,7 +189,7 @@ class SolidMask(IO.ComfyNode):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def execute(cls, value, width, height) -> IO.NodeOutput:
|
def execute(cls, value, width, height) -> IO.NodeOutput:
|
||||||
out = torch.full((1, height, width), value, dtype=torch.float32, device="cpu")
|
out = torch.full((1, height, width), value, dtype=torch.float32, device=comfy.model_management.intermediate_device())
|
||||||
return IO.NodeOutput(out)
|
return IO.NodeOutput(out)
|
||||||
|
|
||||||
solid = execute # TODO: remove
|
solid = execute # TODO: remove
|
||||||
@ -262,6 +263,7 @@ class MaskComposite(IO.ComfyNode):
|
|||||||
def execute(cls, destination, source, x, y, operation) -> IO.NodeOutput:
|
def execute(cls, destination, source, x, y, operation) -> IO.NodeOutput:
|
||||||
output = destination.reshape((-1, destination.shape[-2], destination.shape[-1])).clone()
|
output = destination.reshape((-1, destination.shape[-2], destination.shape[-1])).clone()
|
||||||
source = source.reshape((-1, source.shape[-2], source.shape[-1]))
|
source = source.reshape((-1, source.shape[-2], source.shape[-1]))
|
||||||
|
source = source.to(output.device)
|
||||||
|
|
||||||
left, top = (x, y,)
|
left, top = (x, y,)
|
||||||
right, bottom = (min(left + source.shape[-1], destination.shape[-1]), min(top + source.shape[-2], destination.shape[-2]))
|
right, bottom = (min(left + source.shape[-1], destination.shape[-1]), min(top + source.shape[-2], destination.shape[-2]))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user