Run the LYNX CLI from Python
1import lynx2 3lynx.predict_cli(["detect", "--model", "lynx-basic", "--source", "image.jpg"])predict_cli([...]) runs the lynx CLI's argument parser from inside Python. Same flags, same exit codes, same output as python -m lynx.cli detect ... from the shell.
Reach for it when:
- Reproducing a CI failure: your CI runs
lynx detect --model X --source Y— drop that exact argv into a notebook, hit it, see the same behavior you saw in CI - Sharing repros: send a teammate one cell instead of "switch terminals, activate the venv, run this command, paste the output back"
- Comparing CLI vs API output: the same operations exist as Python methods on
LYNX, but the CLI form is what shell scripts have been debugging against for years — use the CLI when you want byte-identical behavior
Don't reach for it for normal Python use. model("frame.jpg") is faster, more flexible, and returns a Results object instead of writing to stdout. predict_cli is specifically the "I want exact shell behavior in Python" tool, not "I want to do inference in Python".
lynx detect --help lists every flag and they all flow through predict_cli([...]) unchanged.
Next
Diagnose missing or wrong detections →
When the model returns nothing useful, the cause is almost always preprocessing — find it in one call.