slight refactoring of existing nodes

This commit is contained in:
EllangoK
2023-03-30 16:54:27 -04:00
parent 82d6271f4b
commit ece18e5f0d
6 changed files with 92 additions and 43 deletions
+6 -6
View File
@@ -15,13 +15,13 @@ class CannyEdgeDetection:
"default": 100,
"min": 0,
"max": 500,
"step": 1
"step": 10
}),
"upper_threshold": ("INT", {
"default": 200,
"min": 0,
"max": 500,
"step": 1
"step": 10
}),
},
}
@@ -31,10 +31,10 @@ class CannyEdgeDetection:
CATEGORY = "postprocessing"
def canny(self, image, lower_threshold, upper_threshold):
tensor_img = image.numpy()[0]
tensor_img = (cv2.cvtColor(tensor_img, cv2.COLOR_BGR2GRAY) * 255).astype(np.uint8)
canny = cv2.Canny(tensor_img, lower_threshold, upper_threshold)
def canny(self, image: torch.Tensor, lower_threshold: int, upper_threshold: int):
tensor_image = image.numpy()[0]
gray_image = (cv2.cvtColor(tensor_image, cv2.COLOR_BGR2GRAY) * 255).astype(np.uint8)
canny = cv2.Canny(gray_image, lower_threshold, upper_threshold)
tensor = torch.from_numpy(canny).unsqueeze(0)
return (tensor,)