diff --git a/__init__.py b/__init__.py index 5964921..ddb27b4 100644 --- a/__init__.py +++ b/__init__.py @@ -116,8 +116,12 @@ from .modules.pandas_wrapper.pandas_vertical_concat import PandasVerticalConcat from .modules.pandas_wrapper.pandas_vertical_split import PandasVerticalSplit from .modules.pandas_wrapper.pandas_xs import PandasXs from .modules.pytorch_wrapper.pt_float_create import PtFloatCreate +from .modules.pytorch_wrapper.pt_from_image import PtFromImage +from .modules.pytorch_wrapper.pt_from_latent import PtFromLatent from .modules.pytorch_wrapper.pt_from_numpy import PtFromNumpy from .modules.pytorch_wrapper.pt_int_create import PtIntCreate +from .modules.pytorch_wrapper.pt_to_image import PtToImage +from .modules.pytorch_wrapper.pt_to_latent import PtToLatent from .modules.pytorch_wrapper.pt_to_numpy import PtToNumpy from .modules.seaborn_wrapper.sns_bar import SNSBar from .modules.seaborn_wrapper.sns_histogram import SNSHistogram @@ -245,8 +249,12 @@ NODE_CLASS_MAPPINGS: Dict[str, Type[T]] = { "PandasVerticalSplit": PandasVerticalSplit, "PandasXs": PandasXs, "PtFloatCreate": PtFloatCreate, + "PtFromImage": PtFromImage, + "PtFromLatent": PtFromLatent, "PtFromNumpy": PtFromNumpy, "PtIntCreate": PtIntCreate, + "PtToImage": PtToImage, + "PtToLatent": PtToLatent, "PtToNumpy": PtToNumpy, "PyKvFloatCreate": PyKvFloatCreate, "PyKvIntCreate": PyKvIntCreate, @@ -377,8 +385,12 @@ NODE_DISPLAY_NAME_MAPPINGS: Dict[str, str] = { "PandasVerticalSplit": "Pandas Vertical Split", "PandasXs": "Pandas Xs", "PtFloatCreate": "Pt Float Create", + "PtFromImage": "Pt From Image", + "PtFromLatent": "Pt From Latent", "PtFromNumpy": "Pt From Numpy", "PtIntCreate": "Pt Int Create", + "PtToImage": "Pt To Image", + "PtToLatent": "Pt To Latent", "PtToNumpy": "Pt To Numpy", "PyKvFloatCreate": "Py Kv Float Create", "PyKvIntCreate": "Py Kv Int Create", diff --git a/docs/reference/node_reference.md b/docs/reference/node_reference.md index e8de662..60b29f9 100644 --- a/docs/reference/node_reference.md +++ b/docs/reference/node_reference.md @@ -132,8 +132,12 @@ | Node | Description | | --- | --- | | [Pt Float Create](pt_float_create.md) | Creates a PyTorch tensor with 32-bit floating point precision | +| [Pt From Image](pt_from_image.md) | Casts an Image tensor as a PyTorch tensor. | +| [Pt From Latent](pt_from_latent.md) | Casts a latent tensor as a PyTorch tensor. | | [Pt From Numpy](pt_from_numpy.md) | Converts a NumPy ndarray to a PyTorch tensor while preserving its data type. | | [Pt Int Create](pt_int_create.md) | Creates a PyTorch tensor with 32-bit integer | +| [Pt To Image](pt_to_image.md) | Casts a PyTorch tensor as an Image tensor. | +| [Pt To Latent](pt_to_latent.md) | Casts a PyTorch tensor as a latent tensor. | | [Pt To Numpy](pt_to_numpy.md) | Converts PyTorch tensor to NumPy ndarray. | ## Python wrapper | Node | Description | diff --git a/docs/reference/pt_from_image.md b/docs/reference/pt_from_image.md new file mode 100644 index 0000000..82ecbf1 --- /dev/null +++ b/docs/reference/pt_from_image.md @@ -0,0 +1,17 @@ +# Pt From Image +Casts an Image tensor as a PyTorch tensor. + +## Input +| Name | Data type | +|---|---| +| image | Image | + +## Output +| Data type | +|---| +| Tensor | + +
+Category: PyTorch wrapper + +ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved. diff --git a/docs/reference/pt_from_latent.md b/docs/reference/pt_from_latent.md new file mode 100644 index 0000000..8b8e27e --- /dev/null +++ b/docs/reference/pt_from_latent.md @@ -0,0 +1,17 @@ +# Pt From Latent +Casts a latent tensor as a PyTorch tensor. + +## Input +| Name | Data type | +|---|---| +| latent | Latent | + +## Output +| Data type | +|---| +| Tensor | + +
+Category: PyTorch wrapper + +ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved. diff --git a/docs/reference/pt_to_image.md b/docs/reference/pt_to_image.md new file mode 100644 index 0000000..f399842 --- /dev/null +++ b/docs/reference/pt_to_image.md @@ -0,0 +1,17 @@ +# Pt To Image +Casts a PyTorch tensor as an Image tensor. + +## Input +| Name | Data type | +|---|---| +| tens | Tensor | + +## Output +| Data type | +|---| +| Image | + +
+Category: PyTorch wrapper + +ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved. diff --git a/docs/reference/pt_to_latent.md b/docs/reference/pt_to_latent.md new file mode 100644 index 0000000..144104f --- /dev/null +++ b/docs/reference/pt_to_latent.md @@ -0,0 +1,17 @@ +# Pt To Latent +Casts a PyTorch tensor as a latent tensor. + +## Input +| Name | Data type | +|---|---| +| tens | Tensor | + +## Output +| Data type | +|---| +| Latent | + +
+Category: PyTorch wrapper + +ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved. diff --git a/modules/pytorch_wrapper/pt_from_image.py b/modules/pytorch_wrapper/pt_from_image.py new file mode 100644 index 0000000..fca4f89 --- /dev/null +++ b/modules/pytorch_wrapper/pt_from_image.py @@ -0,0 +1,40 @@ +from typing import Any, Dict +import torch + + +class PtFromImage: + """ + Casts an Image tensor as a PyTorch tensor. + + category: PyTorch wrapper + """ + + @classmethod + def INPUT_TYPES(cls) -> Dict[str, Any]: + """ + Defines the input types for the function. + + Returns: + Dict[str, Any]: A dictionary specifying required input types. + """ + return { + "required": { + "image": ("IMAGE", {}), + } + } + + RETURN_TYPES: tuple = ("TENSOR",) + FUNCTION: str = "f" + CATEGORY: str = "PyTorch wrapper" + + def f(self, image: torch.Tensor) -> tuple: + """ + Casts an Image tensor as a PyTorch tensor. + + Args: + image (torch.Tensor): Image tensor + + Returns: + tuple: A tuple containing the PyTorch tensor. + """ + return (image,) diff --git a/modules/pytorch_wrapper/pt_from_latent.py b/modules/pytorch_wrapper/pt_from_latent.py new file mode 100644 index 0000000..fc313e7 --- /dev/null +++ b/modules/pytorch_wrapper/pt_from_latent.py @@ -0,0 +1,40 @@ +from typing import Any, Dict +import torch + + +class PtFromLatent: + """ + Casts a latent tensor as a PyTorch tensor. + + category: PyTorch wrapper + """ + + @classmethod + def INPUT_TYPES(cls) -> Dict[str, Any]: + """ + Defines the input types for the function. + + Returns: + Dict[str, Any]: A dictionary specifying required input types. + """ + return { + "required": { + "latent": ("LATENT", {}), + } + } + + RETURN_TYPES: tuple = ("TENSOR",) + FUNCTION: str = "f" + CATEGORY: str = "PyTorch wrapper" + + def f(self, latent: torch.Tensor) -> tuple: + """ + Casts a latent tensor as a PyTorch tensor. + + Args: + latent (torch.Tensor): Latent tensor + + Returns: + tuple: A tuple containing the PyTorch tensor. + """ + return (latent,) diff --git a/modules/pytorch_wrapper/pt_to_image.py b/modules/pytorch_wrapper/pt_to_image.py new file mode 100644 index 0000000..d126251 --- /dev/null +++ b/modules/pytorch_wrapper/pt_to_image.py @@ -0,0 +1,40 @@ +from typing import Any, Dict +import torch + + +class PtToImage: + """ + Casts a PyTorch tensor as an Image tensor. + + category: PyTorch wrapper + """ + + @classmethod + def INPUT_TYPES(cls) -> Dict[str, Any]: + """ + Defines the input types for the function. + + Returns: + Dict[str, Any]: A dictionary specifying required input types. + """ + return { + "required": { + "tens": ("TENSOR", {}), + } + } + + RETURN_TYPES: tuple = ("IMAGE",) + FUNCTION: str = "f" + CATEGORY: str = "PyTorch wrapper" + + def f(self, tens: torch.Tensor) -> tuple: + """ + Casts a PyTorch tensor as an Image tensor. + + Args: + tens (torch.Tensor): PyTorch Tensor + + Returns: + tuple: A tuple containing the image tensor. + """ + return (tens,) diff --git a/modules/pytorch_wrapper/pt_to_latent.py b/modules/pytorch_wrapper/pt_to_latent.py new file mode 100644 index 0000000..abee2b9 --- /dev/null +++ b/modules/pytorch_wrapper/pt_to_latent.py @@ -0,0 +1,40 @@ +from typing import Any, Dict +import torch + + +class PtToLatent: + """ + Casts a PyTorch tensor as a latent tensor. + + category: PyTorch wrapper + """ + + @classmethod + def INPUT_TYPES(cls) -> Dict[str, Any]: + """ + Defines the input types for the function. + + Returns: + Dict[str, Any]: A dictionary specifying required input types. + """ + return { + "required": { + "tens": ("TENSOR", {}), + } + } + + RETURN_TYPES: tuple = ("LATENT",) + FUNCTION: str = "f" + CATEGORY: str = "PyTorch wrapper" + + def f(self, tens: torch.Tensor) -> tuple: + """ + Casts a PyTorch tensor as a latent tensor. + + Args: + tens (torch.Tensor): PyTorch Tensor + + Returns: + tuple: A tuple containing the latent tensor. + """ + return (tens,) diff --git a/pyproject.toml b/pyproject.toml index de52c99..d32b204 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "data-analysis" description = "Data analysis custom modules for ComfyUI - Use Pandas & Matplotlib within ComfyUI" -version = "1.3.0" +version = "1.3.2" license = {file = "LICENSE"} [project.urls]