| 64 | |
| 65 | |
| 66 | def _parse_args() -> argparse.Namespace: |
| 67 | parser = argparse.ArgumentParser( |
| 68 | description=( |
| 69 | "Render the regression dataset with docling-parse and summarize image " |
| 70 | "comparison metrics. By default this compares against " |
| 71 | "tests/data/groundtruth/render/pages." |
| 72 | ) |
| 73 | ) |
| 74 | parser.add_argument( |
| 75 | "--expected-source", |
| 76 | choices=("groundtruth", "pypdfium"), |
| 77 | default="groundtruth", |
| 78 | help="Renderer/reference to compare docling-parse output against (groundtruth).", |
| 79 | ) |
| 80 | parser.add_argument( |
| 81 | "--scale", |
| 82 | type=float, |
| 83 | default=DEFAULT_RENDER_SCALE, |
| 84 | help=f"Render scale for generated comparisons ({DEFAULT_RENDER_SCALE}).", |
| 85 | ) |
| 86 | parser.add_argument( |
| 87 | "--threads", |
| 88 | type=int, |
| 89 | default=4, |
| 90 | help="Docling threaded renderer worker count (4).", |
| 91 | ) |
| 92 | parser.add_argument( |
| 93 | "--max-concurrent", |
| 94 | type=int, |
| 95 | default=32, |
| 96 | help="Docling max_concurrent_results setting (32).", |
| 97 | ) |
| 98 | parser.add_argument( |
| 99 | "--from-deltas", |
| 100 | type=Path, |
| 101 | help=( |
| 102 | "Analyze an existing directory of *.actual.png/*.expected.png pairs " |
| 103 | "instead of rendering the regression dataset." |
| 104 | ), |
| 105 | ) |
| 106 | parser.add_argument( |
| 107 | "--actual", |
| 108 | type=Path, |
| 109 | help="Actual rendered image. Must be used together with --expected.", |
| 110 | ) |
| 111 | parser.add_argument( |
| 112 | "--expected", |
| 113 | type=Path, |
| 114 | help="Expected/reference image. Must be used together with --actual.", |
| 115 | ) |
| 116 | parser.add_argument( |
| 117 | "--pixel-threshold", |
| 118 | type=int, |
| 119 | default=DEFAULT_PIXEL_THRESHOLD, |
| 120 | help=( |
| 121 | "Per-pixel grayscale diff threshold used for changed_pixels_ratio " |
| 122 | f"({DEFAULT_PIXEL_THRESHOLD})." |
| 123 | ), |