| 380 | |
| 381 | |
| 382 | class Image2Line: |
| 383 | def __init__(self, device): |
| 384 | print("Initializing Image2Line") |
| 385 | self.detector = MLSDdetector.from_pretrained('lllyasviel/ControlNet') |
| 386 | |
| 387 | @prompts(name="Line Detection On Image", |
| 388 | description="useful when you want to detect the straight line of the image. " |
| 389 | "like: detect the straight lines of this image, or straight line detection on image, " |
| 390 | "or perform straight line detection on this image, or detect the straight line image of this image. " |
| 391 | "The input to this tool should be a string, representing the image_path") |
| 392 | def inference(self, inputs): |
| 393 | image = Image.open(inputs) |
| 394 | mlsd = self.detector(image) |
| 395 | updated_image_path = get_new_image_name(inputs, func_name="line-of") |
| 396 | mlsd.save(updated_image_path) |
| 397 | print(f"\nProcessed Image2Line, Input Image: {inputs}, Output Line: {updated_image_path}") |
| 398 | return updated_image_path |
| 399 | |
| 400 | |
| 401 | class LineText2Image: |
nothing calls this directly
no outgoing calls
no test coverage detected