Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My with_pre_post_processing.onnx by yolov8n.pt transfored to onnx can't work #458

Open
9479421 opened this issue Aug 17, 2024 · 6 comments
Assignees

Comments

@9479421
Copy link

9479421 commented Aug 17, 2024

The onnx file in the examples is work:
https://github.com/microsoft/onnxruntime-inference-examples/tree/main/mobile/examples/object_detection/android
but I use oridinal yolov8n.pt to transfor yolov8n.onnx, and transfor .onnx to with_pre_post_processing.onnx can't work. When execute
'val inputTensor = OnnxTensor.createTensor(
ortEnv,
ByteBuffer.wrap(rawImageBytes),
shape,
OnnxJavaType.UINT8
)
'
it will throw Exception
'Exception caught when perform ObjectDetection
ai.onnxruntime.OrtException: Unexpected number of requestedOutputs & pinnedOutputs, expected [1,1) found 2
at ai.onnxruntime.OrtSession.run(OrtSession.java:341)
at ai.onnxruntime.OrtSession.run(OrtSession.java:242)
at ai.onnxruntime.example.objectdetection.ObjectDetector.detect(ObjectDetector.kt:45)
at ai.onnxruntime.example.objectdetection.MainActivity.performObjectDetection(MainActivity.kt:123)
at ai.onnxruntime.example.objectdetection.MainActivity.onCreate$lambda$0(MainActivity.kt:61)'

who can help me , My English is not good, thanks for every friends who can help me

@wejoncy
Copy link
Contributor

wejoncy commented Aug 30, 2024

hi, @9479421

The model used in this example has two outputs, 1) image with bounding-box, 2) the coordinate
If you want to run this example with your own yolo-model, Please run the tool following such changes
microsoft/onnxruntime-extensions#480 (comment)

@iamxiaojuan
Copy link

iamxiaojuan commented Oct 11, 2024

@wejoncy
After I added Debug(), like you said, it didn't output "scaled_box_out_next". it output "nms_output_with_scaled_boxes_and_keypoints_next" and "nms_output_with_scaled_boxes_and_keypoints_next"
As shown in the figure:

Image
(The code version is main

The figure shows my changes to "add_pre_post_processing_to_model":

Image

Please help me.

@wejoncy
Copy link
Contributor

wejoncy commented Oct 12, 2024

@iamxiaojuan Is your model a object detection model?

@iamxiaojuan
Copy link

iamxiaojuan commented Oct 12, 2024

Yes, the model was downloaded from the yolo website @wejoncy
Here's the download link for it:
https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt

@wejoncy
Copy link
Contributor

wejoncy commented Oct 12, 2024

@iamxiaojuan
The name in model output changed to 'nms_output_with_scaled_boxes_and_keypoints_next' indeed.
You can change the name in the example java code to match it.

@iamxiaojuan
Copy link

@wejoncy My problem is solved. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants