new node to split image into two

This commit is contained in:
Ram Deshmukh
2024-03-06 16:59:35 +05:30
parent ab9ab2b662
commit fd89979d62
2 changed files with 37 additions and 0 deletions
+1
View File
File diff suppressed because one or more lines are too long
+36
View File
@@ -2377,7 +2377,41 @@ class HistogramEqualization:
return (blended_image_tensor,)
class TRI3DCompositeImageSplitter:
"""
This node splits composite (horizontally concatenated) image into half.
"""
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
"""
Input Types
"""
return {
"required": {
"image": ("IMAGE",)
},
}
RETURN_TYPES = ("IMAGE","IMAGE")
RETURN_NAMES = ("image1","image2")
FUNCTION = "main"
CATEGORY = "TRI3D"
def main(self, image):
image = from_torch_image(image)
h,w,_ = image.shape
image1 = image[:,:w//2,:]
image2 = image[:,w//2:,:]
image1 = torch.from_numpy(image1.astype(np.float32)/255.0)[None,]
image2 = torch.from_numpy(image2.astype(np.float32)/255.0)[None,]
return (image1, image2)
# A dictionary that contains all nodes you want to export with their names
# NOTE: names should be globally unique
NODE_CLASS_MAPPINGS = {
@@ -2403,6 +2437,7 @@ NODE_CLASS_MAPPINGS = {
"tri3d-clipdrop-bgremove-api": TRI3D_clipdrop_bgremove_api,
"tri3d-adjust-neck": TRI3DAdjustNeck,
"tri3d-HistogramEqualization": HistogramEqualization,
"tri3d-composite-image-splitter": TRI3DCompositeImageSplitter
}
VERSION = "2.7.0"
@@ -2432,4 +2467,5 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"tri3d-clipdrop-bgremove-api": "RemBG ClipDrop" + " v" + VERSION,
"tri3d-adjust-neck": "Adjust Neck" + " v" + VERSION,
"tri3d-HistogramEqualization": "Adjust Neck" + " v" + VERSION,
"tri3d-composite-image-splitter": "Composite Image Splitter" + " v" + VERSION
}