()
| 323 | |
| 324 | # ======================== CLI ======================== |
| 325 | def main(): |
| 326 | parser = argparse.ArgumentParser( |
| 327 | description="Edit Banana — image to DrawIO", |
| 328 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 329 | epilog=""" |
| 330 | Examples: |
| 331 | python main.py -i input/test.png |
| 332 | python main.py |
| 333 | python main.py -i test.png --refine |
| 334 | python main.py -i test.png --groups image arrow |
| 335 | """ |
| 336 | ) |
| 337 | |
| 338 | parser.add_argument("-i", "--input", type=str, |
| 339 | help="Input image path (omit to process all images in input/)") |
| 340 | parser.add_argument("-o", "--output", type=str, |
| 341 | help="Output directory (default: ./output)") |
| 342 | parser.add_argument("--refine", action="store_true", |
| 343 | help="Enable quality evaluation and refinement") |
| 344 | parser.add_argument("--no-text", action="store_true", |
| 345 | help="Skip text step (no OCR)") |
| 346 | parser.add_argument("--groups", nargs='+', |
| 347 | choices=['image', 'arrow', 'shape', 'background'], |
| 348 | help="Prompt groups to process (default: all)") |
| 349 | parser.add_argument("--show-prompts", action="store_true", |
| 350 | help="Show prompt config") |
| 351 | |
| 352 | args = parser.parse_args() |
| 353 | |
| 354 | # Show prompt config |
| 355 | if args.show_prompts: |
| 356 | extractor = Sam3InfoExtractor() |
| 357 | extractor.print_prompt_groups() |
| 358 | return |
| 359 | |
| 360 | # Load config |
| 361 | config = load_config() |
| 362 | |
| 363 | # Create pipeline |
| 364 | pipeline = Pipeline(config) |
| 365 | |
| 366 | # Parse group args |
| 367 | groups = None |
| 368 | if args.groups: |
| 369 | group_map = { |
| 370 | 'image': PromptGroup.IMAGE, |
| 371 | 'arrow': PromptGroup.ARROW, |
| 372 | 'shape': PromptGroup.BASIC_SHAPE, |
| 373 | 'background': PromptGroup.BACKGROUND, |
| 374 | } |
| 375 | groups = [group_map[g] for g in args.groups] |
| 376 | |
| 377 | # Output dir |
| 378 | output_dir = args.output or config.get('paths', {}).get('output_dir', './output') |
| 379 | os.makedirs(output_dir, exist_ok=True) |
| 380 | |
| 381 | # Collect images |
| 382 | image_paths = [] |
no test coverage detected