mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-11 06:40:48 +08:00
gracefully handle skia import failure
This commit is contained in:
parent
fd5449c5b7
commit
5727217c2f
@ -238,7 +238,7 @@ class PaligemmaOutputToMask(CustomNode):
|
|||||||
def execute(self, paligemma_output: PostProcessResult) -> tuple[MaskBatch]:
|
def execute(self, paligemma_output: PostProcessResult) -> tuple[MaskBatch]:
|
||||||
masks = [torch.from_numpy(p["mask"]) for p in paligemma_output if "mask" in p]
|
masks = [torch.from_numpy(p["mask"]) for p in paligemma_output if "mask" in p]
|
||||||
if len(masks) == 0:
|
if len(masks) == 0:
|
||||||
return torch.zeroes((0, 0, 0)),
|
return torch.zeros((0, 0, 0)),
|
||||||
return torch.stack(masks, dim=0),
|
return torch.stack(masks, dim=0),
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,16 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import skia
|
|
||||||
import torch
|
import torch
|
||||||
import vtracer
|
import vtracer
|
||||||
|
import logging
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from comfy.nodes.package_typing import CustomNode
|
from comfy.nodes.package_typing import CustomNode
|
||||||
from comfy.utils import tensor2pil
|
from comfy.utils import tensor2pil
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def RGB2RGBA(image: Image, mask: Image) -> Image:
|
def RGB2RGBA(image: Image, mask: Image) -> Image:
|
||||||
(R, G, B) = image.convert('RGB').split()
|
(R, G, B) = image.convert('RGB').split()
|
||||||
@ -99,6 +101,11 @@ class SVGToImage(CustomNode):
|
|||||||
return svg_string[svg_start:]
|
return svg_string[svg_start:]
|
||||||
|
|
||||||
def convert_to_image(self, svg, scale):
|
def convert_to_image(self, svg, scale):
|
||||||
|
try:
|
||||||
|
import skia
|
||||||
|
except (ImportError, ModuleNotFoundError) as exc_info:
|
||||||
|
logger.error("failed to import skia", exc_info=exc_info)
|
||||||
|
return (torch.zeros((0, 1, 1, 3)),)
|
||||||
raster_images = []
|
raster_images = []
|
||||||
|
|
||||||
for i, svg_string in enumerate(svg):
|
for i, svg_string in enumerate(svg):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user