Added Pt To Image, Pt To Latent, Pt From Image, Pt To Image nodes.
This commit is contained in:
@@ -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,)
|
||||
@@ -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,)
|
||||
@@ -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,)
|
||||
@@ -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,)
|
||||
Reference in New Issue
Block a user