| """Export yolo11n.pt to person.onnx for faster CPU inference. | |
| python export_onnx.py [--imgsz 640] | |
| miner.py automatically prefers person.onnx when it exists in the repo root. | |
| """ | |
| import argparse | |
| from pathlib import Path | |
| from ultralytics import YOLO | |
| def main() -> None: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--imgsz", type=int, default=416) | |
| args = parser.parse_args() | |
| here = Path(__file__).parent | |
| model = YOLO(str(here / "yolo11n.pt")) | |
| exported = model.export(format="onnx", imgsz=args.imgsz, simplify=True) | |
| out = here / "person.onnx" | |
| Path(exported).rename(out) | |
| print(f"Exported {out} ({out.stat().st_size / 1e6:.1f} MB)") | |
| if __name__ == "__main__": | |
| main() | |