File size: 726 Bytes
3168e7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9d6491b
3168e7d
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""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()