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

Class Image2Hed

visual_chatgpt.py:440–456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

438
439
440class Image2Hed:
441 def __init__(self, device):
442 print("Initializing Image2Hed")
443 self.detector = HEDdetector.from_pretrained('lllyasviel/ControlNet')
444
445 @prompts(name="Hed Detection On Image",
446 description="useful when you want to detect the soft hed boundary of the image. "
447 "like: detect the soft hed boundary of this image, or hed boundary detection on image, "
448 "or perform hed boundary detection on this image, or detect soft hed boundary image of this image. "
449 "The input to this tool should be a string, representing the image_path")
450 def inference(self, inputs):
451 image = Image.open(inputs)
452 hed = self.detector(image)
453 updated_image_path = get_new_image_name(inputs, func_name="hed-boundary")
454 hed.save(updated_image_path)
455 print(f"\nProcessed Image2Hed, Input Image: {inputs}, Output Hed: {updated_image_path}")
456 return updated_image_path
457
458
459class HedText2Image:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected