ScoreVision / export_onnx.py
dev0524's picture
scorevision: push artifact
9d6491b verified
Raw
History Blame Contribute Delete
726 Bytes
"""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()