Some checks failed
Python Linting / Run Ruff (push) Has been cancelled
Python Linting / Run Pylint (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Has been cancelled
Execution Tests / test (macos-latest) (push) Has been cancelled
Execution Tests / test (ubuntu-latest) (push) Has been cancelled
Execution Tests / test (windows-latest) (push) Has been cancelled
Test server launches without errors / test (push) Has been cancelled
Unit Tests / test (macos-latest) (push) Has been cancelled
Unit Tests / test (ubuntu-latest) (push) Has been cancelled
Unit Tests / test (windows-2022) (push) Has been cancelled
Includes 30 custom nodes committed directly, 7 Civitai-exclusive loras stored via Git LFS, and a setup script that installs all dependencies and downloads HuggingFace-hosted models on vast.ai. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
import torch
|
|
from ..utils import INPUT
|
|
|
|
class InpaintPreprocessor:
|
|
@classmethod
|
|
def INPUT_TYPES(s):
|
|
return dict(
|
|
required=dict(image=INPUT.IMAGE(), mask=INPUT.MASK()),
|
|
optional=dict(black_pixel_for_xinsir_cn=INPUT.BOOLEAN(False))
|
|
)
|
|
RETURN_TYPES = ("IMAGE",)
|
|
FUNCTION = "preprocess"
|
|
|
|
CATEGORY = "ControlNet Preprocessors/others"
|
|
|
|
def preprocess(self, image, mask, black_pixel_for_xinsir_cn=False):
|
|
mask = torch.nn.functional.interpolate(mask.reshape((-1, 1, mask.shape[-2], mask.shape[-1])), size=(image.shape[1], image.shape[2]), mode="bilinear")
|
|
mask = mask.movedim(1,-1).expand((-1,-1,-1,3))
|
|
image = image.clone()
|
|
if black_pixel_for_xinsir_cn:
|
|
masked_pixel = 0.0
|
|
else:
|
|
masked_pixel = -1.0
|
|
image[mask > 0.5] = masked_pixel
|
|
return (image,)
|
|
|
|
NODE_CLASS_MAPPINGS = {
|
|
"InpaintPreprocessor": InpaintPreprocessor
|
|
}
|
|
NODE_DISPLAY_NAME_MAPPINGS = {
|
|
"InpaintPreprocessor": "Inpaint Preprocessor"
|
|
}
|