abi/screenshot-to-code · warning · SystemExit

--iou-threshold must be between 0 and 1

Error message

--iou-threshold must be between 0 and 1

What it means

SystemExit raised when the --iou-threshold CLI argument falls outside [0, 1]. IoU (intersection over union) is mathematically bounded to that interval, so any other value would make matching results meaningless; the check runs after the --live gate and before the key check.

Source

Thrown at backend/evals/asset_extraction_benchmark.py:850

    )
    parser.add_argument("--output-dir", type=Path)
    parser.add_argument(
        "--iou-threshold",
        type=float,
        default=DEFAULT_IOU_THRESHOLD,
    )
    return parser.parse_args()


async def main() -> None:
    load_dotenv(Path(".env"))
    args = parse_args()
    if not args.live:
        raise SystemExit(
            "Live API calls are disabled by default. Re-run with --live to opt in."
        )
    if not 0 <= args.iou_threshold <= 1:
        raise SystemExit("--iou-threshold must be between 0 and 1")
    api_key = os.environ.get("GEMINI_API_KEY")
    if not api_key:
        raise SystemExit("Missing GEMINI_API_KEY")
    output_dir = args.output_dir or (
        DEFAULT_OUTPUT_ROOT / time.strftime("%Y%m%d_%H%M%S")
    )
    await run_benchmark(
        api_key=api_key,
        output_dir=output_dir,
        iou_threshold=args.iou_threshold,
    )


if __name__ == "__main__":
    asyncio.run(main())

View on GitHub (pinned to d026163f58)

Solutions

  1. Pass a fraction between 0 and 1, e.g. --iou-threshold 0.5.
  2. If you meant percent, divide by 100 first.

Example fix

# before
--iou-threshold 70

# after
--iou-threshold 0.7
Defensive patterns

Strategy: validation

Validate before calling

if not 0.0 <= float(iou) <= 1.0:
    raise ValueError("iou-threshold must be a fraction in [0,1]")

Prevention

When it happens

Trigger: Passing e.g. --iou-threshold 1.2 or -0.5 (including values like 1.0000001 from float parsing) to the benchmark CLI.

Common situations: Thinking of IoU as a percentage (passing 50 instead of 0.5), or shell-quoting mistakes that pass an empty string which argparse rejects differently.

Related errors


AI-assisted analysis of abi/screenshot-to-code@d026163f58 (2026-08-14). Data as JSON: /api/errors/dbc289507ce52738. Report an issue: GitHub.