By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

 hailo_conversion.py

View raw Download
text/x-script.python • 890 B
Python script, ASCII text executable
        
            
1
import subprocess
2
import os
3
import ultralytics
4
import onnx
5
from os import path
6
7
model = ultralytics.YOLO("yolov8n.pt")
8
9
model.export(format="onnx", imgsz=640, opset=11)
10
11
model = onnx.load("/home/vlad/recycle4me/yolov8n.onnx")
12
print("Inputs:")
13
for i in model.graph.input:
14
print(i.name, [d.dim_value for d in i.type.tensor_type.shape.dim])
15
print("Outputs:")
16
for o in model.graph.output:
17
print(o.name, [d.dim_value for d in o.type.tensor_type.shape.dim])
18
19
current_dir = os.getcwd()
20
onnx_path = os.path.join(current_dir, "yolov8n.onnx")
21
val_data_path = os.path.join(current_dir, "val_data")
22
23
result = subprocess.run([
24
path.expanduser(".venv/bin/hailomz"),
25
"compile",
26
"yolov8n",
27
"--hw-arch", "hailo8l",
28
"--ckpt", onnx_path,
29
"--calib-path", val_data_path,
30
"--start-node-names", "images",
31
"--end-node-names", "output0",
32
"--classes", "7",
33
], check=True)
34