diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7a60b85 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ +*.pyc diff --git a/__pycache__/__init__.cpython-310.pyc b/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 9c42229..0000000 Binary files a/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/__pycache__/ps_blend_node.cpython-310.pyc b/__pycache__/ps_blend_node.cpython-310.pyc deleted file mode 100644 index b717c28..0000000 Binary files a/__pycache__/ps_blend_node.cpython-310.pyc and /dev/null differ diff --git a/ps_blend_node.py b/ps_blend_node.py index 1b974f1..5dcc641 100644 --- a/ps_blend_node.py +++ b/ps_blend_node.py @@ -1,5 +1,4 @@ import torch -import numpy as np class PSBlendNode: @classmethod @@ -19,8 +18,16 @@ class PSBlendNode: CATEGORY = "image/blending" def blend_images(self, image1, image2, blend_mode, opacity): - # Determine the device (CPU or GPU) - device = torch.device("cuda" if torch.cuda.is_available() else "cpu") + # GPU availability check + if torch.cuda.is_available(): + print("PS Blend Node is using CUDA.") + device = torch.device("cuda") + elif torch.backends.mps.is_available(): + print("PS Blend Node is using  MPS.") + device = torch.device("mps") + else: + print("No GPU acceleration available, using CPU") + device = torch.device("cpu") # Move tensors to the appropriate device img1 = image1.to(device) @@ -162,7 +169,7 @@ class PSBlendNode: # Apply opacity opacity_tensor = torch.tensor(opacity, device=device).view(1, 1, 1, 1) - # self.print_tensor_shape(opacity_tensor, "opacity_tensor") + self.print_tensor_shape(opacity_tensor, "opacity_tensor") result_rgb = img2 * (1 - opacity_tensor) + result * opacity_tensor