mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-09 15:08:02 -05:00
* onnx parser * fix compile, lint * onnx.load -> onnx_load * compatible with ModelProto * fix test external_test_onnx_ops.py * fix tests * fix signed int * reduce to 261 lines * fix TypeProto.Optional * debug for _parse_message, add TypeProto.Sequence, cleanup * onnx_load from Tensor * remove BufferedReader * 174 lines and reduce tensor copy * cleanup * use onnx_load in external_model_benchmark.py * fix qcom test * [onnx] parser support external data --------- Co-authored-by: b1tg <b1tg@users.noreply.github.com> Co-authored-by: chenyu <chenyu@fastmail.com>
16 lines
523 B
Python
16 lines
523 B
Python
#!/usr/bin/env python3
|
|
import os
|
|
from ultralytics import YOLO
|
|
from pathlib import Path
|
|
from tinygrad.frontend.onnx import OnnxRunner, onnx_load
|
|
from extra.onnx_helpers import get_example_inputs
|
|
from tinygrad.tensor import Tensor
|
|
|
|
os.chdir("/tmp")
|
|
if not Path("yolov8n-seg.onnx").is_file():
|
|
model = YOLO("yolov8n-seg.pt")
|
|
model.export(format="onnx", imgsz=[480,640])
|
|
onnx_model = onnx_load(open("yolov8n-seg.onnx", "rb"))
|
|
run_onnx = OnnxRunner(onnx_model)
|
|
run_onnx(get_example_inputs(run_onnx.graph_inputs), debug=True)
|