diff --git a/README.md b/README.md index b305b8a..117410b 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ ### Install +https://github.com/LEv145/images-grid-comfy-plugin/archive/refs/heads/main.zip ``` cd custom_nodes # From comfy path git clone https://github.com/LEv145/images-grid-comfy-plugin ImagesGrid diff --git a/src/base.py b/src/base.py index 54e149a..9eec7d7 100644 --- a/src/base.py +++ b/src/base.py @@ -4,8 +4,6 @@ from pathlib import Path STATIC_PATH = Path(__file__).parent.parent / "static" -Image = t.Any - class BaseNode(): CATEGORY: str = "ImagesGrid" diff --git a/src/nodes/image_combine.py b/src/nodes/image_combine.py index f7a9d46..a4c372f 100644 --- a/src/nodes/image_combine.py +++ b/src/nodes/image_combine.py @@ -2,7 +2,7 @@ import typing as t import torch -from ..base import BaseNode, Image +from ..base import BaseNode class ImageCombineNode(BaseNode): @@ -19,9 +19,9 @@ class ImageCombineNode(BaseNode): def execute( self, - image_1: Image, - image_2: Image, - ) -> tuple[Image]: + image_1: torch.Tensor, + image_2: torch.Tensor, + ) -> tuple[torch.Tensor]: result = torch.cat((image_1, image_2), 0) return (result,) diff --git a/src/nodes/images_grid.py b/src/nodes/images_grid.py index 40783c6..8081412 100644 --- a/src/nodes/images_grid.py +++ b/src/nodes/images_grid.py @@ -1,6 +1,8 @@ import typing as t -from ..base import BaseNode, Image +import torch + +from ..base import BaseNode from ..utils import ( tensor_to_pillow, pillow_to_tensor, @@ -9,7 +11,6 @@ from ..utils import ( Annotation, ) - class BaseImagesGridNode(BaseNode): RETURN_TYPES: tuple[str] = ("IMAGE",) @@ -30,11 +31,11 @@ class BaseImagesGridNode(BaseNode): self, function: t.Callable, \ - images: Image, + images: torch.Tensor, gap: int, annotation: Annotation | None = None, **kw, - ) -> tuple[Image]: + ) -> tuple[torch.Tensor]: pillow_images = [tensor_to_pillow(i) for i in images] pillow_grid = function( images=pillow_images, @@ -52,7 +53,7 @@ class ImagesGridByColumnsNode(BaseImagesGridNode): def INPUT_TYPES(cls) -> dict[str, t.Any]: return cls._create_input_types("max_columns") - def execute(self, **kw) -> tuple[Image]: + def execute(self, **kw) -> tuple[torch.Tensor]: return self._create_execute(create_images_grid_by_columns, **kw) @@ -61,5 +62,5 @@ class ImagesGridByRowsNode(BaseImagesGridNode): def INPUT_TYPES(cls) -> dict[str, t.Any]: return cls._create_input_types("max_rows") - def execute(self, **kw) -> tuple[Image]: + def execute(self, **kw) -> tuple[torch.Tensor]: return self._create_execute(create_images_grid_by_rows, **kw) diff --git a/src/nodes/latent_combine.py b/src/nodes/latent_combine.py index 69bb399..6aadc40 100644 --- a/src/nodes/latent_combine.py +++ b/src/nodes/latent_combine.py @@ -2,7 +2,7 @@ import typing as t import torch -from ..base import BaseNode, Image +from ..base import BaseNode class LatentCombineNode(BaseNode): @@ -19,9 +19,9 @@ class LatentCombineNode(BaseNode): def execute( self, - latent_1: dict[str, t.Any], - latent_2: dict[str, t.Any], - ) -> tuple[dict[str, t.Any]]: + latent_1: dict[str, torch.Tensor], + latent_2: dict[str, torch.Tensor], + ) -> tuple[dict[str, torch.Tensor]]: samples = torch.cat((latent_1["samples"], latent_2["samples"]), 0) return ({"samples": samples},)