Closed applefb closed 4 months ago
Same as above. Working on it, but this is where I am at
Hello! You can try to use this notebook. Let me know if it works for you!
I successfully ran another project https://github.com/212534/Unity-Sentis-YOLOv8 i think the sentis is useful
I tried the convert the model but its give me an error. Any idea?
I changed the shape = (shape[3], shape[3])
to shape = (shape[1], shape[1])
then another error Context: Bad node spec for node. Name: OpType: Split
import numpy as np
import onnx
from onnx import checker, helper
from onnx import AttributeProto, TensorProto, GraphProto
from onnx import numpy_helper as np_helper
def scan_split_ops(model):
for i in range(len(model.graph.node)):
# Node type check
node = model.graph.node[i]
if node.op_type != 'Split': continue
# Output tensor shape
output = next(v for v in model.graph.value_info if v.name == node.output[0])
shape = tuple(map(lambda x: x.dim_value, output.type.tensor_type.shape.dim))
shape = (shape[3], shape[3])
# "split" attribute addition
new_node = helper.make_node('Split', node.input, node.output, split = shape, axis = 3)
# Node replacement
model.graph.node.insert(i, new_node)
model.graph.node.remove(node)
model = onnx.load('yolov8n.onnx')
model = onnx.shape_inference.infer_shapes(model)
scan_split_ops(model)
checker.check_model(model)
onnx.save(model, 'yolov8n_barracuda.onnx')
Traceback (most recent call last):
File "convert-barracuda.py", line 24, in <module>
scan_split_ops(model)
File "convert-barracuda.py", line 15, in scan_split_ops
shape = (shape[3], shape[3])
IndexError: tuple index out of range
https://github.com/ultralytics/ultralytics path = model.export(format="onnx") # export the model to ONNX format very easy
https://github.com/ultralytics/ultralytics path = model.export(format="onnx") # export the model to ONNX format very easy
I just export the model just like you said and unity still giving the same error (split error) and also i tried the convert that model with this notebook too and result is same
(my unity version is unity 6)
https://github.com/wojciechp6/YOLOv8Unity/issues/10#issuecomment-2147526732 i can't run this project also ,but i run this one https://github.com/212534/Unity-Sentis-YOLOv8
OnnxImportException: Unexpected error while parsing layer /model.2/Split_output_0 of type Split. Unsupported default attribute
split
for node /model.2/Split_output_0 of type Split. Value is required.Json: { "input": [ "/model.2/cv1/act/Mul_output_0", "onnx::Split_137" ], "output": [ "/model.2/Split_output_0", "/model.2/Split_output_1" ], "name": "/model.2/Split", "opType": "Split", "attribute": [ { "name": "axis", "i": "1", "type": "INT" } ] } at Unity.Barracuda.ONNX.ONNXModelConverter+<>c.b__27_10 (Unity.Barracuda.ModelBuilder net, Unity.Barracuda.ONNX.ONNXNodeWrapper node) [0x00017] in .\Library\PackageCache\com.unity.barracuda@3.0.0\Barracuda\Runtime\ONNX\ONNXModelConverter.cs:389
at Unity.Barracuda.ONNX.ONNXModelConverter.ConvertOnnxModel (Onnx.ModelProto onnxModel) [0x00409] in .\Library\PackageCache\com.unity.barracuda@3.0.0\Barracuda\Runtime\ONNX\ONNXModelConverter.cs:2934
Unity.Barracuda.ONNX.ONNXModelConverter.Err (Unity.Barracuda.Model model, System.String layerName, System.String message, System.String extendedMessage, System.String debugMessage) (at ./Library/PackageCache/com.unity.barracuda@3.0.0/Barracuda/Runtime/ONNX/ONNXModelConverter.cs:3434) Unity.Barracuda.ONNX.ONNXModelConverter.ConvertOnnxModel (Onnx.ModelProto onnxModel) (at ./Library/PackageCache/com.unity.barracuda@3.0.0/Barracuda/Runtime/ONNX/ONNXModelConverter.cs:2943) Unity.Barracuda.ONNX.ONNXModelConverter.Convert (Google.Protobuf.CodedInputStream inputStream) (at ./Library/PackageCache/com.unity.barracuda@3.0.0/Barracuda/Runtime/ONNX/ONNXModelConverter.cs:170) Unity.Barracuda.ONNX.ONNXModelConverter.Convert (System.String filePath) (at ./Library/PackageCache/com.unity.barracuda@3.0.0/Barracuda/Runtime/ONNX/ONNXModelConverter.cs:98) Unity.Barracuda.ONNXModelImporter.OnImportAsset (UnityEditor.AssetImporters.AssetImportContext ctx) (at ./Library/PackageCache/com.unity.barracuda@3.0.0/Barracuda/Editor/ONNXModelImporter.cs:65) UnityEditor.AssetImporters.ScriptedImporter.GenerateAssetData (UnityEditor.AssetImporters.AssetImportContext ctx) (at <10f58cbd00e64048887177689e139058>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
Asset import failed, "Assets/yolov8n.onnx" > OnnxImportException: Unexpected error while parsing layer /model.2/Split_output_0 of type Split. Unsupported default attribute
split
for node /model.2/Split_output_0 of type Split. Value is required.Json: { "input": [ "/model.2/cv1/act/Mul_output_0", "onnx::Split_137" ], "output": [ "/model.2/Split_output_0", "/model.2/Split_output_1" ], "name": "/model.2/Split", "opType": "Split", "attribute": [ { "name": "axis", "i": "1", "type": "INT" } ] } at Unity.Barracuda.ONNX.ONNXModelConverter+<>c.b__27_10 (Unity.Barracuda.ModelBuilder net, Unity.Barracuda.ONNX.ONNXNodeWrapper node) [0x00017] in .\Library\PackageCache\com.unity.barracuda@3.0.0\Barracuda\Runtime\ONNX\ONNXModelConverter.cs:389
at Unity.Barracuda.ONNX.ONNXModelConverter.ConvertOnnxModel (Onnx.ModelProto onnxModel) [0x00409] in .\Library\PackageCache\com.unity.barracuda@3.0.0\Barracuda\Runtime\ONNX\ONNXModelConverter.cs:2934