| 438 | |
| 439 | |
| 440 | class 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 | |
| 459 | class HedText2Image: |
nothing calls this directly
no outgoing calls
no test coverage detected