scorevision: push artifact
Browse files- export_onnx.py +28 -0
export_onnx.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Export yolo11n.pt to person.onnx for faster CPU inference.
|
| 2 |
+
|
| 3 |
+
python export_onnx.py [--imgsz 640]
|
| 4 |
+
|
| 5 |
+
miner.py automatically prefers person.onnx when it exists in the repo root.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import argparse
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
|
| 11 |
+
from ultralytics import YOLO
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def main() -> None:
|
| 15 |
+
parser = argparse.ArgumentParser()
|
| 16 |
+
parser.add_argument("--imgsz", type=int, default=480)
|
| 17 |
+
args = parser.parse_args()
|
| 18 |
+
|
| 19 |
+
here = Path(__file__).parent
|
| 20 |
+
model = YOLO(str(here / "yolo11n.pt"))
|
| 21 |
+
exported = model.export(format="onnx", imgsz=args.imgsz, simplify=True)
|
| 22 |
+
out = here / "person.onnx"
|
| 23 |
+
Path(exported).rename(out)
|
| 24 |
+
print(f"Exported {out} ({out.stat().st_size / 1e6:.1f} MB)")
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
if __name__ == "__main__":
|
| 28 |
+
main()
|