onnx / tensorflow-onnx

Convert TensorFlow, Keras, Tensorflow.js and Tflite models to ONNX
Apache License 2.0
2.27k stars 432 forks source link

DirectML returning empty result with ObjectDetection (Mobilinet V2 FPN Keras) #2325

Open willianwrm opened 3 months ago

willianwrm commented 3 months ago

Describe the bug Result is empty when using DirectML but works as expected when using only CPU. Tested for ObjectDection with ssd_mobilenet_v2_fpn_keras model.

Urgency low

System information

System information for training and ONNX model conversion

To Reproduce Use this C# .NET 8.0 Windows Forms App, select a file image and wait for the result, the CPU result is printed in blue and DirectML result in red. The project contains the onnx model and image examples can be found here. Tested opset 18 to 13, no change.

Screenshots image

Additional context Training configuration, data set, command lines and tensorflow exported graph can be found here

willianwrm commented 3 months ago

Update: i did force the _numdetections to 10 just to see what values I would get and surprising got good _detectionboxes but bad _detectionscores (-1 for all): image

So investigating a little further i found out that the _outputs detection_anchorindices, _detectionboxes, _detectionclasses, _detection_multiclassscores, _raw_detectionboxes and even _raw_detectionscores are returning correct values (DirectML outputs same as CPU), only the _detectionscores and _numdetections that are messed up.

fatcat-z commented 3 months ago

Do you mean the model could be converted to ONNX model successfully and it works well on CPU but failed in other scenarios?

If so, this issue probably should be opened in onnxruntime repo because it looks like an inference issue.

willianwrm commented 3 months ago

Yes it does works well on CPU but fails in DirectML. Thanks for the info, i did post it there.