fix image2mask issue

This commit is contained in:
chflame163
2024-10-23 18:18:34 +08:00
parent fbdfff3555
commit 2df6cf23ed
2 changed files with 6 additions and 4 deletions
+5 -3
View File
@@ -138,9 +138,11 @@ def tensor2cv2(image:torch.Tensor) -> np.array:
return cv2.cvtColor(cv2image, cv2.COLOR_RGB2BGR)
def image2mask(image:Image) -> torch.Tensor:
if image.mode != 'L':
image = image.convert('L')
return torch.tensor([pil2tensor(image)[0, :, :].tolist()])
if image.mode == 'L':
return torch.tensor([pil2tensor(image)[0, :, :].tolist()])
else:
image = image.convert('RGB').split()[0]
return torch.tensor([pil2tensor(image)[0, :, :].tolist()])
def mask2image(mask:torch.Tensor) -> Image:
masks = tensor2np(mask)
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "comfyui_layerstyle"
description = "A set of nodes for ComfyUI it generate image like Adobe Photoshop's Layer Style. the Drop Shadow is first completed node, and follow-up work is in progress."
version = "1.0.82"
version = "1.0.83"
license = "MIT"
dependencies = ["numpy", "pillow", "torch", "matplotlib", "Scipy", "scikit_image", "scikit_learn", "opencv-contrib-python", "pymatting", "segment_anything", "timm", "addict", "yapf", "colour-science", "wget", "mediapipe", "loguru", "typer_config", "fastapi", "rich", "google-generativeai", "diffusers", "omegaconf", "tqdm", "transformers", "kornia", "image-reward", "ultralytics", "blend_modes", "blind-watermark", "qrcode", "pyzbar", "transparent-background", "huggingface_hub", "accelerate", "bitsandbytes", "torchscale", "wandb", "hydra-core", "psd-tools", "inference-cli[yolo-world]", "inference-gpu[yolo-world]", "onnxruntime", "peft", "iopath"]