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

How to detect object on the image with oxxnruntime_flutter using a pre-trained *.onnx model? #27

Open
frg-x opened this issue Sep 11, 2024 · 0 comments

Comments

@frg-x
Copy link

frg-x commented Sep 11, 2024

Please give an example how to inference image with pre-trained *.onnx model using your package?
At the beginning I've trained YoloV8 model and got *.pt trained model, then exported it to *.onnx format with opset13.

Inputs: [name: 'images', tensor: float32[1, 3, 320, 320]]
Outputs: [name: 'output0', tensor: float32[1, 6, 2100]] 

[1, 6, 2100] in Outputs - 6 means TWO objects to detect, 5 means ONE objects to detect

I've tried inference in Python with onnxruntime package and it works great, but I can't get any results with your package. How to read/prepare image bytes to pass them as argument to createTensorWithDataList method?

Here is my chunk of a code:

Int16List _transformBuffer(Uint8List bytes) => Int16List.view(bytes.buffer);

Future<void> inference() async {

    final List<int> shape = [1, 3, 320, 320];

    final floatBuffer = _transformBuffer(imageBytesList).map((e) => e / 255).toList();

    array = Float32List.fromList(floatBuffer);

    final OrtValueTensor inputOrt = OrtValueTensor.createTensorWithDataList(array, shape);

    final Map<String, OrtValueTensor> inputs = {'images': inputOrt};

    final runOptions = OrtRunOptions();

    final List<OrtValue?>? outputs = await session.runAsync(runOptions, inputs, ['output0']);
}

Thank you in advance

screenshot-11-09-2024-21-26-19

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

1 participant