Fix typing
This commit is contained in:
LEv145
2023-04-09 12:14:22 +02:00
parent 1bc3f221b7
commit 98d3da8b3a
5 changed files with 16 additions and 16 deletions
+1
View File
@@ -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
-2
View File
@@ -4,8 +4,6 @@ from pathlib import Path
STATIC_PATH = Path(__file__).parent.parent / "static"
Image = t.Any
class BaseNode():
CATEGORY: str = "ImagesGrid"
+4 -4
View File
@@ -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,)
+7 -6
View File
@@ -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)
+4 -4
View File
@@ -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},)