MCPcopy Create free account
hub / github.com/chenfei-wu/TaskMatrix / Image2Canny

Class Image2Canny

visual_chatgpt.py:321–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

319
320
321class Image2Canny:
322 def __init__(self, device):
323 print("Initializing Image2Canny")
324 self.low_threshold = 100
325 self.high_threshold = 200
326
327 @prompts(name="Edge Detection On Image",
328 description="useful when you want to detect the edge of the image. "
329 "like: detect the edges of this image, or canny detection on image, "
330 "or perform edge detection on this image, or detect the canny image of this image. "
331 "The input to this tool should be a string, representing the image_path")
332 def inference(self, inputs):
333 image = Image.open(inputs)
334 image = np.array(image)
335 canny = cv2.Canny(image, self.low_threshold, self.high_threshold)
336 canny = canny[:, :, None]
337 canny = np.concatenate([canny, canny, canny], axis=2)
338 canny = Image.fromarray(canny)
339 updated_image_path = get_new_image_name(inputs, func_name="edge")
340 canny.save(updated_image_path)
341 print(f"\nProcessed Image2Canny, Input Image: {inputs}, Output Text: {updated_image_path}")
342 return updated_image_path
343
344
345class CannyText2Image:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected