Unity-Technologies / barracuda-release

Other
563 stars 76 forks source link

[Barracuda] Different results in Unity and Pycharm #290

Open yq-Liang opened 1 year ago

yq-Liang commented 1 year ago

Hello:) I am trying to convert a pytorch model to onnx and run it in Unity with Barracuda, but I am in trouble now. Could you please help me? When the model in Unity and in Pycharm have the same input, the onnx results in Unity and in python are always different from each other. I wrote a simple model. Finally I found that, the results are different when I load the model's weight( no matter a .pth or .npy file)before exporting the pytorch model. When I export the onnx model without the saved weight, the results in Unity and in Python are almost consistent . I can't figure it out so I turn to you for help. These are the files of the simple model(just has a transform and a Conv2D op), you can run the conv2d_onnx.py to get the onnx model with weight in conv1_weight.npy, and test32.png is the input. Thanks a lot!

HolyShitKillingMachine commented 1 year ago

Hello:) I am trying to convert a pytorch model to onnx and run it in Unity with Barracuda, but I am in trouble now. Could you please help me? When the model in Unity and in Pycharm have the same input, the onnx results in Unity and in python are always different from each other. I wrote a simple model. Finally I found that, the results are different when I load the model's weight( no matter a .pth or .npy file)before exporting the pytorch model. When I export the onnx model without the saved weight, the results in Unity and in Python are almost consistent . I can't figure it out so I turn to you for help. These are the files of the simple model(just has a transform and a Conv2D op), you can run the conv2d_onnx.py to get the onnx model with weight in conv1_weight.npy, and test32.png is the input. Thanks a lot!

I have met the same problem bro.用pytorch训练classify,然后导出的onnx,在unity和pycharm得到2个不同的结果,不知道你最后解决没

HolyShitKillingMachine commented 1 year ago

@yq-Liang 方便交流的话,加个wechat:LonelySingleThree